<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<activity id="__mTch7mDWQgpTYdAyfjl">
  <name>提交</name>
  <parentId>__37LPBQTjzitRtOe7Bda</parentId>
  <applicationid>__LgZds5MVHW3o08T7UcX</applicationid>
  <type>13</type>
  <onActionFlow></onActionFlow>
  <onActionPrint></onActionPrint>
  <colorType>default</colorType>
  <beforeActionScript><![CDATA[#include "sysfunction";
#include "payChack";
#include "payFunction";
(function(){
  var domainid = getDomainid();
// var doc=getCurrentDocument();
  var userName= getWebUser().getName();
var isTrue =getItemValueAsString("refundState"); 
var comment = getItemValueAsString("comment"); 
  var amount = getItemValueAsString("amount");
   var now = getToday();
        var bizOrderNo = domainid+format(now, "yyyyMMddHHmmss");
  println("价格"+amount);
if("0".equals(isTrue)) {
  return "是否审核通过必须填写！";
}else if("2".equals(isTrue)){
  if("".equals(comment)) {
    return "拒绝原因必须填写！";
  }
}else{
  var applyId = getItemValueAsString("applyId"); 
  var applyInfoDoc = findDocument(applyId);
  var orderId = applyInfoDoc.findItem("orderId").getValue();

  var orderInfoDoc = findDocument(orderId);


  var trainId = applyInfoDoc.findItem("trainId").getValue(); 
  var learnId = applyInfoDoc.findItem("learnId").getValue(); 
  var bcx = applyInfoDoc.findItem("bcx").getValue(); 
  var sqlPayId = "select comId from com_base_info where tlkComId='" + trainId + "'";
        var sqlOrderId = "select comId from com_base_info where tlkComId='" + learnId + "'";
        var datasPayId = queryByDSName("pay", sqlPayId);
        var datasOrderId = queryByDSName("pay", sqlOrderId);
        if (datasPayId.size() > 0) {
            for (var iterator = datasPayId.iterator(); iterator.hasNext();) {
                var map1 = iterator.next();//取值
                var comidPay = map1.get("comid");//获取本企业的id
            }
        } else {
            return createAlert("请联系管理员，完善本企业信息！");
        }
        if (datasOrderId.size() > 0) {
            for (var iterator = datasOrderId.iterator(); iterator.hasNext();) {
                var map2 = iterator.next();//取值
                var comidOrder = map2.get("comid");//获取培训机构企业的id
            }
        }else {
            return createAlert("请联系管理员或选择的保安公司，完善保安公司企业信息！");
        }
        var ss=payChack(learnId,domainid,amount,comidOrder,comidPay);
     if("success".equals(ss)){
     var aa= payFunction(comidOrder,comidPay,amount,bizOrderNo,userName,bcx);
      if("success".equals(aa)){
      }else{
      return createAlert(aa);
      }
     }else{
return createAlert(ss);
}
}


})()]]></beforeActionScript>
  <afterActionScript><![CDATA[]]></afterActionScript>
  <retractBeforeActionScript><![CDATA[]]></retractBeforeActionScript>
  <retractAfterActionScript><![CDATA[]]></retractAfterActionScript>
  <hiddenScript><![CDATA[]]></hiddenScript>
  <readonlyScript><![CDATA[(function(){
var refundState= getItemValueAsString("refundState"); 
if("0".equals(refundState)) {
    return false;
}else{
	return true
}
})()]]></readonlyScript>
  <startFlowScript><![CDATA[]]></startFlowScript>
  <editMode>0</editMode>
  <fileNameScript><![CDATA[]]></fileNameScript>
  <iconurl></iconurl>
  <orderno>0</orderno>
  <stateToShow></stateToShow>
  <parentForm>__37LPBQTjzitRtOe7Bda</parentForm>
  <jumpType>0</jumpType>
  <expSub>false</expSub>
  <icon></icon>
  <disableFlowNode>false</disableFlowNode>
  <changeFlowOperator>false</changeFlowOperator>
  <changeFlowCc>false</changeFlowCc>
  <multiLanguageLabel></multiLanguageLabel>
  <dispatcherMode>0</dispatcherMode>
  <dispatcherUrl><![CDATA[]]></dispatcherUrl>
  <dispatcherParams><![CDATA[[{"paramKey":"","paramValue":""}]]]></dispatcherParams>
  <jumpMode>0</jumpMode>
  <jumpActOpenType>0</jumpActOpenType>
  <withOld>false</withOld>
  <actionType>2</actionType>
  <actionDispatcherUrlScript><![CDATA[]]></actionDispatcherUrlScript>
  <actionSelection>0</actionSelection>
  <relatedFormId></relatedFormId>
  <actionScript><![CDATA[#include "sysfunction";
#include "payFunction";
(function(){

var applyId = getItemValueAsString("applyId"); 
var securityId = getItemValueAsString("securityId"); 
var process = getDocumentProcess(); 
var applyInfoDoc = findDocument(applyId);

var idCardNo = applyInfoDoc.findItem("idCardNo").getValue();
var orderId = applyInfoDoc.findItem("orderId").getValue();

var orderInfoDoc = findDocument(orderId);
var lessonId = orderInfoDoc.findItem("lessonId").getValue();

var doc = findDocument(getId());
var isTrue = getItemValueAsString("refundState"); 
  var comment = getItemValueAsString("comment"); 
  println("脚本的"+isTrue);
if("否".equals(isTrue)){
  applyInfoDoc.findItem("applyStatus").setValue("0");
  doc.findItem("refundState").setValue("2");
   doc.findItem("comment").setValue(comment);
  orderInfoDoc.findItem("orderState").setValue("1");
}else{
  /* 退款操作*/
  var trainId = applyInfoDoc.findItem("trainId").getValue(); 
  var learnId = applyInfoDoc.findItem("learnId").getValue(); 
  var price = orderInfoDoc.findItem("price").getValue();
 // payFunction(trainId,learnId,price,orderId);

  
  /* 修改资格证报名信息*/
  doc.findItem("refundDate").setValue(format(getToday(),"yyyy-MM-dd HH:mm:ss"));
  doc.findItem("refundState").setValue("1");
    applyInfoDoc.findItem("payState").setValue("0");
    applyInfoDoc.findItem("payDate").setValue("");
    applyInfoDoc.findItem("trainId").setValue("");
    applyInfoDoc.findItem("trainName").setValue("");
    applyInfoDoc.findItem("orderId").setValue("");
     applyInfoDoc.findItem("materialApproveStatus").setValue("0");
       applyInfoDoc.findItem("materialApproveFailReason").setValue("");
    applyInfoDoc.findItem("materialApproveDate").setValue("");
    applyInfoDoc.findItem("materialApprovePerName").setValue("");
     applyInfoDoc.findItem("materialApprovePerIdCardNo").setValue("");
  orderInfoDoc.findItem("orderState").setValue("3");
  
 var deleteSql = "update tlk_learn_order_person set item_isDelete='1',item_orderState='3' where ITEM_SECURITYID = '"+securityId+"'";
  var updateSql = "delete from tlk_lesson_auth_base_info where ITEM_AUTHUSERID = '"+idCardNo+"' and ITEM_AUTHLESSONID = '"+lessonId+"'";
  // var updateSqlBM = "update tlk_system_qualify_person_apply set ITEM_PAYSTATE='2' where ITEM_IDCARDNO = '"+idCardNo+"'and ITEM_ORDERID='"+orderId+"'" ;
      var deleteSqlJD = "delete from tlk_lesson_progress where ITEM_AUTHUSERID = '"+idCardNo+"' and ITEM_AUTHLESSONID = '"+lessonId+"'";
updateByDSName("tms",deleteSql);
    deleteByDSName("organizationAuth",deleteSqlJD);
   // updateByDSName(sysfunction.DS_TMS,updateSqlBM);
  deleteByDSName("tms",updateSql);
}
  process.doUpdate(applyInfoDoc);
  process.doUpdate(doc);
  process.doUpdate(orderInfoDoc);
})()]]></actionScript>
  <workFlowType>0</workFlowType>
  <contextMenu>false</contextMenu>
  <showInToolbar>true</showInToolbar>
  <transpond></transpond>
  <targetList>|</targetList>
  <label><![CDATA[]]></label>
</activity>