<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<repositoryVO id="__tQBzeluEJNEyb9GPn9i">
  <name>payChack</name>
  <parentId>__LgZds5MVHW3o08T7UcX</parentId>
  <applicationid>__LgZds5MVHW3o08T7UcX</applicationid>
  <content><![CDATA[function payChack(trainId,learnId,sumPrice,trainComid,learnComid){
  println("我进钱包接口了");
var SAAS_URL = "http://attends.test.baibaodun.cn/";
  var Security = new Packages.cn.myapps.common.util.Security();
  var accessToken = Security.getToken(getWebUser().getId());
var URLConnector = Packages.cn.hutool.http.HttpRequest;
//校验是否开通钱包
var trainIsOpenUrl = SAAS_URL + "wallet/get-com-wallet-service-open-info?comId="+trainComid+"&TlkDomainId="+trainId;
var trainIsOpenInfo = URLConnector.get(trainIsOpenUrl).header("userV5Token","1").header("access_token",accessToken).execute().body();
  println("trainIsOpenUrl-->"+trainIsOpenUrl);
var trainIsOpenData = eval('('+trainIsOpenInfo+')');
println("trainIsOpenData==>" + trainIsOpenInfo);
if("0".equals(trainIsOpenData.data.isCompleteOpen)){
  return "您的公司未开通企业钱包，无法收款，请联系该机构开通！";
}

var learnIsOpenUrl = SAAS_URL + "wallet/get-com-wallet-service-open-info?comId="+learnComid+"&TlkDomainId="+learnId;
var learnIsOpenInfo = URLConnector.get(learnIsOpenUrl).header("userV5Token","1").header("access_token",accessToken).execute().body();
var learnIsOpenData = eval('('+learnIsOpenInfo+')');
if("0".equals(learnIsOpenData.data.isCompleteOpen)){
  return "保安公司未开通企业钱包，请先开通！";
}
//
//校验余额
var learnAmountUrl = SAAS_URL + "wallet/get-com-wallet-account-amount?comId="+trainComid+"&TlkDomainId="+trainId;
println("learnAmountUrl==>" + learnAmountUrl);
var learnAmountInfo = URLConnector.get(learnAmountUrl).header("userV5Token","1").header("access_token",accessToken).execute().body();
var learnAmountData = eval('('+learnAmountInfo+')');
println("learnAmountData==>" + learnAmountInfo);
if("-1".equals(learnAmountData.retType)){
  return "获取公司账户余额失败，请联系客服！";
}else{
  var availableAmount = parseFloat(learnAmountData.data.availableAmount);
  println("availableAmount==>" +availableAmount);
  println("sumPrice==>" +sumPrice);
  if(availableAmount<sumPrice){
    return "您公司钱包余额不足，请先充值！";
  }else{
    return "success";
  }
}

}]]></content>
  <version>2</version>
</repositoryVO>