|
@@ -2,9 +2,11 @@ package nckd.jimin.jyyy.fi.webapi;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.kingdee.util.StringUtils;
|
|
|
import kd.bos.dataentity.OperateOption;
|
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
|
+import kd.bos.dataentity.entity.LocaleString;
|
|
|
import kd.bos.dataentity.metadata.dynamicobject.DynamicObjectType;
|
|
|
import kd.bos.entity.operate.result.OperationResult;
|
|
|
import kd.bos.logging.Log;
|
|
@@ -13,21 +15,24 @@ import kd.bos.openapi.common.custom.annotation.ApiController;
|
|
|
import kd.bos.openapi.common.custom.annotation.ApiParam;
|
|
|
import kd.bos.openapi.common.custom.annotation.ApiPostMapping;
|
|
|
import kd.bos.openapi.common.result.CustomApiResult;
|
|
|
-import kd.bos.openapi.common.result.OpenApiResult;
|
|
|
-import kd.bos.openapi.common.util.OpenApiSdkUtil;
|
|
|
import kd.bos.orm.query.QCP;
|
|
|
import kd.bos.orm.query.QFilter;
|
|
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
|
-import kd.bos.servicehelper.operation.OperationServiceHelper;
|
|
|
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
|
|
-
|
|
|
+import nckd.base.helper.CommonHelperUtils;
|
|
|
import javax.validation.Valid;
|
|
|
import java.io.Serializable;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.text.ParseException;
|
|
|
import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
|
|
|
+
|
|
|
+ * SRM系统调用,付款同步接口
|
|
|
+ * 描述:接口实现逻辑包含对公报销单同步、预付单同步,通过参数判断传的是对公报销还是预付
|
|
|
+ * bizAccountOutBills:对公报销单;dailyLoanBills:预付单,两个参数只有其中一个有值。
|
|
|
+ * @author wanghaiwu_kd
|
|
|
+ * @date 2025/05010
|
|
|
+ */
|
|
|
@ApiController(
|
|
|
desc = "对接SRM预付款、付款",
|
|
|
value = "SRM"
|
|
@@ -50,7 +55,6 @@ public class SRMSynPayApiPlugin implements Serializable {
|
|
|
int bizAcctOutBillSize = 0;
|
|
|
int dailyLoanBillSize = 0;
|
|
|
|
|
|
-
|
|
|
if(bizAccountOutBills != null && bizAccountOutBills.size() > 0){
|
|
|
bizAcctOutBillSize = bizAccountOutBills.size();
|
|
|
}
|
|
@@ -69,7 +73,6 @@ public class SRMSynPayApiPlugin implements Serializable {
|
|
|
}
|
|
|
|
|
|
return returnResult("0", "成功", responseData);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|
|
@@ -97,8 +100,8 @@ public class SRMSynPayApiPlugin implements Serializable {
|
|
|
*/
|
|
|
private JSONObject saveBizAcctOutBillInfo (JSONObject inputData){
|
|
|
JSONObject returnMap = new JSONObject();
|
|
|
-
|
|
|
- DynamicObject bizAcctOutBill = BusinessDataServiceHelper.newDynamicObject(ENTITY_PUBLICPAY);
|
|
|
+ String code = "1";
|
|
|
+ String returnMessage = "";
|
|
|
|
|
|
String billType = inputData.getString("billType");
|
|
|
String srmBillNo = inputData.getString("SRMBillNo");
|
|
@@ -113,15 +116,102 @@ public class SRMSynPayApiPlugin implements Serializable {
|
|
|
String biller = inputData.getString("biller");
|
|
|
String applier = inputData.getString("applier");
|
|
|
|
|
|
- applier = "ID-000014";
|
|
|
+ if(StringUtils.isEmpty(srmBillNo) || StringUtils.isEmpty(srmUrl) || StringUtils.isEmpty(cause)
|
|
|
+ || StringUtils.isEmpty(orgUnit) || StringUtils.isEmpty(position) || StringUtils.isEmpty(biller) || StringUtils.isEmpty(applier)){
|
|
|
+ returnMessage = "请检查以下参数 SRM单号、srmUrl、事由、申请部门、申请人职位、制单人、经办人 是否为空!";
|
|
|
+ return buildReturnData(code, srmBillNo, returnMessage, null, null, null);
|
|
|
+ } else if("XM".equals(billType)){
|
|
|
+ if(StringUtils.isEmpty(project) || StringUtils.isEmpty(contract)){
|
|
|
+ returnMessage = "项目类付款,请检查以下参数 项目编码、合同编码 是否为空!";
|
|
|
+ return buildReturnData(code, srmBillNo, returnMessage, null, null, null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ DynamicObject creatorInfo = CommonHelperUtils.queryBaseDynamicObject("bos_user", "number", biller);
|
|
|
+ if(creatorInfo == null){
|
|
|
+ returnMessage = "制单人(" + biller + ")在星瀚系统中未匹配到数据!";
|
|
|
+ return buildReturnData(code, srmBillNo, returnMessage, null, null, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ DynamicObject applierInfo = CommonHelperUtils.queryBaseDynamicObject("bos_user", "number", applier);
|
|
|
+ if(applierInfo == null){
|
|
|
+ returnMessage = "经办人(" + applier + ")在星瀚系统中未匹配到数据!";
|
|
|
+ return buildReturnData(code, srmBillNo, returnMessage, null, null, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ DynamicObject dept = CommonHelperUtils.queryBaseDynamicObject("bos_org", "number", orgUnit);
|
|
|
+ if(dept == null){
|
|
|
+ returnMessage = "行政组织(" + orgUnit + ")在星瀚系统中未匹配到数据!";
|
|
|
+ return buildReturnData(code, srmBillNo, returnMessage, null, null, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ DynamicObject positionInfo = CommonHelperUtils.queryBaseDynamicObject("hbpm_positionhr", "number", position);
|
|
|
+ if(positionInfo == null){
|
|
|
+ returnMessage = "岗位(" + position + ")在星瀚系统中未匹配到数据!";
|
|
|
+ return buildReturnData(code, srmBillNo, returnMessage, null, null, null);
|
|
|
+ }
|
|
|
+ LocaleString positionName = new LocaleString(positionInfo.getString("name"));
|
|
|
+
|
|
|
+
|
|
|
+ DynamicObject adminCompany = CommonHelperUtils.getAdminCompany(dept);
|
|
|
+
|
|
|
+ QFilter qFilter = new QFilter("toorg", QCP.equals, dept.getPkValue());
|
|
|
+ DynamicObject relation = BusinessDataServiceHelper.loadSingle("bos_org_orgrelation_dept", qFilter.toArray());
|
|
|
+ if(relation == null){
|
|
|
+ returnMessage = "行政组织(" + dept.getString("number") + ", " + dept.getString("name") + ")在星瀚系统未维护委托业务单元!";
|
|
|
+ return buildReturnData(code, srmBillNo, returnMessage, null, null, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ DynamicObject costCompany = relation.getDynamicObject("fromorg");
|
|
|
+
|
|
|
+ Long exchangeTableId = CommonHelperUtils.getExchageTableId(costCompany.getLong("id"));
|
|
|
+
|
|
|
+ if(exchangeTableId == null){
|
|
|
+ returnMessage = "核算组织(" + costCompany.getString("name") + ")在星瀚系统匹配到汇率表!";
|
|
|
+ return buildReturnData(code, srmBillNo, returnMessage, null, null, null);
|
|
|
+ }
|
|
|
|
|
|
- bizAcctOutBill.set("bizdate", new Date());
|
|
|
+ DynamicObject bizAcctOutBill = BusinessDataServiceHelper.newDynamicObject(ENTITY_PUBLICPAY);
|
|
|
+ Date bizDate = new Date();
|
|
|
+ try {
|
|
|
+ bizDate = CommonHelperUtils.getCurDateForm(new Date(), true);
|
|
|
+ } catch (ParseException e) {
|
|
|
+
|
|
|
+ returnMessage = e.getMessage();
|
|
|
+ return buildReturnData(code, srmBillNo, returnMessage, null, null, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ bizAcctOutBill.set("bizdate", bizDate);
|
|
|
+ bizAcctOutBill.set("billstatus", "A");
|
|
|
+ bizAcctOutBill.set("reimbursetype", "expense");
|
|
|
+ bizAcctOutBill.set("nckd_srmbillno", srmBillNo);
|
|
|
+ bizAcctOutBill.set("nckd_srmurl", srmUrl);
|
|
|
+ bizAcctOutBill.set("contractsconn", contract);
|
|
|
bizAcctOutBill.set("description", cause);
|
|
|
- bizAcctOutBill.set("applier", getF7FieldValue("bos_user", "number", applier));
|
|
|
- bizAcctOutBill.set("org", getF7FieldValue("bos_org", "number", "20240612-0009"));
|
|
|
- bizAcctOutBill.set("company", getF7FieldValue("bos_org", "number", "20240612-0009"));
|
|
|
- bizAcctOutBill.set("costdept", getF7FieldValue("bos_org", "number", "20240612-0009"));
|
|
|
- bizAcctOutBill.set("costcompany", getF7FieldValue("bos_org", "number", "3140"));
|
|
|
+ bizAcctOutBill.set("applier", applierInfo);
|
|
|
+ bizAcctOutBill.set("applierpositionstr", positionName);
|
|
|
+ bizAcctOutBill.set("org", dept);
|
|
|
+ bizAcctOutBill.set("company", adminCompany);
|
|
|
+ bizAcctOutBill.set("costdept", dept);
|
|
|
+ bizAcctOutBill.set("costcompany", costCompany);
|
|
|
+ bizAcctOutBill.set("paycompany", costCompany);
|
|
|
+ bizAcctOutBill.set("creator", creatorInfo);
|
|
|
+ bizAcctOutBill.set("tel", applierInfo.get("phone"));
|
|
|
+ bizAcctOutBill.set("formid", "er_publicreimbursebill");
|
|
|
+ bizAcctOutBill.set("iscrepayablebill", "0");
|
|
|
+ bizAcctOutBill.set("billpayertype", "bd_supplier");
|
|
|
+ bizAcctOutBill.set("detailtype", "biztype_other");
|
|
|
+ bizAcctOutBill.set("assettype", "newasset");
|
|
|
+ bizAcctOutBill.set("abovequota", "0");
|
|
|
+ bizAcctOutBill.set("ispush", "false");
|
|
|
+
|
|
|
+ BigDecimal totalReimburseAmount = BigDecimal.ZERO;
|
|
|
|
|
|
|
|
|
DynamicObjectCollection expenseEntry = bizAcctOutBill.getDynamicObjectCollection("expenseentryentity");
|
|
@@ -131,113 +221,199 @@ public class SRMSynPayApiPlugin implements Serializable {
|
|
|
for(int i = 0; i < bizAccountOutBillEntry.size(); i++){
|
|
|
JSONObject jsonData = bizAccountOutBillEntry.getJSONObject(i);
|
|
|
|
|
|
- String xsproject = "FYXM01.26";
|
|
|
- String tax = jsonData.getString("tax");
|
|
|
- String amountOriWithoutTax = jsonData.getString("amountOriWithoutTax");
|
|
|
- String taxRate = jsonData.getString("taxRate");
|
|
|
+ String xsproject = jsonData.getString("xsproject");
|
|
|
String currencyType = jsonData.getString("currencyType");
|
|
|
- String amountOri = jsonData.getString("amountOri");
|
|
|
+ BigDecimal taxAmount = CommonHelperUtils.getBigDecimal(jsonData.getString("tax"));
|
|
|
+ BigDecimal amountOriWithoutTax = CommonHelperUtils.getBigDecimal(jsonData.getString("amountOriWithoutTax"));
|
|
|
+ BigDecimal taxRate = CommonHelperUtils.getBigDecimal(jsonData.getString("taxRate"));
|
|
|
+ BigDecimal amountOri = CommonHelperUtils.getBigDecimal(jsonData.getString("amountOri"));
|
|
|
+
|
|
|
+ DynamicObject currency = CommonHelperUtils.queryBaseDynamicObject("bd_currency", "number", currencyType);
|
|
|
+ if(currency == null){
|
|
|
+ returnMessage = "币别(" + orgUnit + ")在星瀚系统中未匹配到数据!";
|
|
|
+ return buildReturnData(code, srmBillNo, returnMessage, null, null, null);
|
|
|
+ }
|
|
|
|
|
|
DynamicObject entry = new DynamicObject(type);
|
|
|
|
|
|
- entry.set("expenseitem", getF7FieldValue("er_expenseitemedit", "number", "FYXM01.26"));
|
|
|
- entry.set("entrycurrency", getF7FieldValue("bd_currency", "number", "CNY"));
|
|
|
- entry.set("expenseamount", "100");
|
|
|
+ entry.set("seq", (i+1));
|
|
|
+ entry.set("happendate", bizDate);
|
|
|
+
|
|
|
+ if("XM".equals(billType)){
|
|
|
+ if(StringUtils.isEmpty(xsproject) ){
|
|
|
+ returnMessage = "项目类付款,请检查以下费用明细参数 项目编码 是否为空!";
|
|
|
+ return buildReturnData(code, srmBillNo, returnMessage, null, null, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ DynamicObject projectInfo = CommonHelperUtils.queryBaseDynamicObject("bd_project", "number", project);
|
|
|
+ if(projectInfo == null){
|
|
|
+ returnMessage = "项目(" + project + ")在星瀚系统中未匹配到数据!";
|
|
|
+ return buildReturnData(code, srmBillNo, returnMessage, null, null, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ entry.set("std_project", projectInfo);
|
|
|
+ bizAcctOutBill.set("nckd_project", projectInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ entry.set("entrycostdept", dept);
|
|
|
+ entry.set("entrycostcompany", costCompany);
|
|
|
+ entry.set("entrycurrency", currency);
|
|
|
+ entry.set("taxRate", taxRate);
|
|
|
+ entry.set("expenseamount", amountOri);
|
|
|
+ entry.set("expeapproveamount", amountOri);
|
|
|
+ entry.set("taxamount", taxAmount);
|
|
|
+ entry.set("approvetax", taxAmount);
|
|
|
+ entry.set("orientryamount", amountOriWithoutTax);
|
|
|
+ entry.set("price", amountOriWithoutTax);
|
|
|
+
|
|
|
+ BigDecimal exchangeRate = BigDecimal.ONE;
|
|
|
+ if(currency.getLong("id") != 1L){
|
|
|
+ exchangeRate = CommonHelperUtils.getExchangeRate(exchangeTableId, currency.getLong("id"), 1L, bizDate);
|
|
|
+ }
|
|
|
+
|
|
|
+ entry.set("expquotetype", "0");
|
|
|
+ entry.set("currexpenseamount", amountOri.multiply(exchangeRate).setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
|
+ entry.set("expeapprovecurramount", amountOri.multiply(exchangeRate).setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
|
+ entry.set("curprice", amountOriWithoutTax.multiply(exchangeRate).setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
|
+ entry.set("itemfrom", "0");
|
|
|
+ entry.set("invoicetypeitem", "0");
|
|
|
+ entry.set("iscrepayableentry", "1");
|
|
|
+
|
|
|
+ entry.set("settlestatus", "unsettle");
|
|
|
+ entry.set("pubreimburser", applierInfo);
|
|
|
|
|
|
expenseEntry.add(entry);
|
|
|
+
|
|
|
+ totalReimburseAmount = totalReimburseAmount.add(amountOri);
|
|
|
}
|
|
|
bizAcctOutBill.set("expenseentryentity", expenseEntry);
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+ DynamicObjectCollection accountEntry = bizAcctOutBill.getDynamicObjectCollection("accountentry");
|
|
|
+ type = accountEntry.getDynamicObjectType();
|
|
|
+ JSONArray bizAccountOutBillAccountEntry = inputData.getJSONArray("bizAccountOutBillAccountEntry");
|
|
|
|
|
|
-
|
|
|
- JSONArray test = new JSONArray();
|
|
|
+ for(int i = 0; i < bizAccountOutBillAccountEntry.size(); i++){
|
|
|
+ JSONObject jsonData = bizAccountOutBillAccountEntry.getJSONObject(i);
|
|
|
|
|
|
- JSONObject testobj = new JSONObject();
|
|
|
-
|
|
|
- testobj.put("bizdate", "2022-08-29");
|
|
|
- testobj.put("description", "test");
|
|
|
- testobj.put("applier_number", "ID-000014");
|
|
|
- testobj.put("org_number", "20240612-0009");
|
|
|
- testobj.put("company_number", "20240612-0009");
|
|
|
- testobj.put("costdept_number", "20240612-0009");
|
|
|
- testobj.put("costcompany_number", "3140");
|
|
|
+ String payerType = jsonData.getString("payerType");
|
|
|
+ String payerName = jsonData.getString("payerName");
|
|
|
+ String currencyType = jsonData.getString("currencyType");
|
|
|
+ BigDecimal amountOri = CommonHelperUtils.getBigDecimal(jsonData.getString("amountOri"));
|
|
|
|
|
|
- JSONArray entryArray = new JSONArray();
|
|
|
+ if(StringUtils.isEmpty(payerType)){
|
|
|
+ returnMessage = "检查以下收款信息参数 收款人类型 是否为空!";
|
|
|
+ return buildReturnData(code, srmBillNo, returnMessage, null, null, null);
|
|
|
+ }
|
|
|
+ if(!"20".equals(payerType)){
|
|
|
+ returnMessage = "收款人类型只支持供应商!";
|
|
|
+ return buildReturnData(code, srmBillNo, returnMessage, null, null, null);
|
|
|
+ }
|
|
|
|
|
|
- JSONObject entryObj = new JSONObject();
|
|
|
- entryObj.put("entrycurrency_number", "CNY");
|
|
|
- entryObj.put("expenseitem_number", "FYXM01.26");
|
|
|
- entryObj.put("expenseamount", "989.92");
|
|
|
+ DynamicObject supplier = CommonHelperUtils.queryBaseDynamicObject("bd_supplier", "societycreditcode", payerName);
|
|
|
+ if(supplier == null){
|
|
|
+ returnMessage = "供应商(" + payerName + ")在星瀚系统中未匹配到数据!";
|
|
|
+ return buildReturnData(code, srmBillNo, returnMessage, null, null, null);
|
|
|
+ }
|
|
|
|
|
|
- entryArray.add(entryObj);
|
|
|
+ DynamicObject currency = CommonHelperUtils.queryBaseDynamicObject("bd_currency", "number", currencyType);
|
|
|
+ if(currency == null){
|
|
|
+ returnMessage = "币别(" + orgUnit + ")在星瀚系统中未匹配到数据!";
|
|
|
+ return buildReturnData(code, srmBillNo, returnMessage, null, null, null);
|
|
|
+ }
|
|
|
|
|
|
- testobj.put("expenseentryentity", entryArray);
|
|
|
+ DynamicObject entry = new DynamicObject(type);
|
|
|
+ entry.set("payerType", "bd_supplier");
|
|
|
+ entry.set("supplier", supplier);
|
|
|
+ entry.set("accountcurrency", currency);
|
|
|
+ entry.set("orireceiveamount", amountOri);
|
|
|
+
|
|
|
+ BigDecimal exchangeRate = BigDecimal.ONE;
|
|
|
+ if(currency.getLong("id") != 1L){
|
|
|
+ exchangeRate = CommonHelperUtils.getExchangeRate(exchangeTableId, currency.getLong("id"), 1L, bizDate);
|
|
|
+ }
|
|
|
|
|
|
- test.add(testobj);
|
|
|
+ entry.set("receiveamount", amountOri.multiply(exchangeRate).setScale(4, BigDecimal.ROUND_HALF_UP));
|
|
|
|
|
|
- JSONObject requestDataJson = new JSONObject();
|
|
|
- requestDataJson.put("data", test);
|
|
|
+ accountEntry.add(entry);
|
|
|
|
|
|
- logger.info("srm测试:" + bizAcctOutBill.toString());
|
|
|
+ bizAcctOutBill.set("billpayerid", supplier);
|
|
|
+ }
|
|
|
+ bizAcctOutBill.set("accountentry", accountEntry);
|
|
|
|
|
|
-
|
|
|
+ BigDecimal totalLoanCheckAmount = BigDecimal.ZERO;
|
|
|
+
|
|
|
+ DynamicObjectCollection writeoffmoney = bizAcctOutBill.getDynamicObjectCollection("writeoffmoney");
|
|
|
+ type = writeoffmoney.getDynamicObjectType();
|
|
|
+ JSONArray bizAccountOutBillLoanCheckEntry = inputData.getJSONArray("bizAccountOutBillLoanCheckEntry");
|
|
|
+
|
|
|
+ for(int i = 0; i < bizAccountOutBillLoanCheckEntry.size(); i++){
|
|
|
+ JSONObject jsonData = bizAccountOutBillLoanCheckEntry.getJSONObject(i);
|
|
|
+
|
|
|
+ String sourceBillNumber = jsonData.getString("sourceBillNumber");
|
|
|
+ String currencyType = jsonData.getString("currencyType");
|
|
|
+ String srmseq = jsonData.getString("srmseq");
|
|
|
+
|
|
|
+ BigDecimal checkAmountOri = CommonHelperUtils.getBigDecimal(jsonData.getString("checkAmountOri"));
|
|
|
+
|
|
|
+ if(StringUtils.isEmpty(sourceBillNumber) || StringUtils.isEmpty(currencyType)){
|
|
|
+ returnMessage = "请检查冲预付参数 预付单号、币别 是否为空!";
|
|
|
+ return buildReturnData(code, srmBillNo, returnMessage, null, null, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ DynamicObject currency = CommonHelperUtils.queryBaseDynamicObject("bd_currency", "number", currencyType);
|
|
|
+ if(currency == null){
|
|
|
+ returnMessage = "币别(" + orgUnit + ")在星瀚系统中未匹配到数据!";
|
|
|
+ return buildReturnData(code, srmBillNo, returnMessage, null, null, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ DynamicObject prepayBillInfo = CommonHelperUtils.queryBillDynamicObject("er_prepaybill", "nckd_srmbillno", sourceBillNumber);
|
|
|
+ if(currency == null){
|
|
|
+ returnMessage = "预付单(" + sourceBillNumber + ")在星瀚系统中未匹配到数据!";
|
|
|
+ return buildReturnData(code, srmBillNo, returnMessage, null, null, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ DynamicObject entry = new DynamicObject(type);
|
|
|
+
|
|
|
+ entry.set("loancurrency", currency);
|
|
|
+ entry.set("accloanamount", checkAmountOri);
|
|
|
+ entry.set("sourcebillid", prepayBillInfo.getPkValue().toString());
|
|
|
+ entry.set("seq", srmseq);
|
|
|
+
|
|
|
+ writeoffmoney.add(entry);
|
|
|
+
|
|
|
+ totalLoanCheckAmount = totalLoanCheckAmount.add(checkAmountOri);
|
|
|
+ }
|
|
|
+ bizAcctOutBill.set("writeoffmoney", writeoffmoney);
|
|
|
+
|
|
|
+ bizAcctOutBill.set("reimburseamount", totalReimburseAmount);
|
|
|
+ bizAcctOutBill.set("approveamount", totalReimburseAmount);
|
|
|
+ bizAcctOutBill.set("payamount", totalReimburseAmount.subtract(totalLoanCheckAmount));
|
|
|
+ bizAcctOutBill.set("notpayamount", totalReimburseAmount);
|
|
|
+
|
|
|
+
|
|
|
+ DynamicObjectCollection invoiceEntry = bizAcctOutBill.getDynamicObjectCollection("invoiceentry");
|
|
|
+ type = invoiceEntry.getDynamicObjectType();
|
|
|
+ JSONArray fpentry = inputData.getJSONArray("fpentry");
|
|
|
+
|
|
|
+ for(int i = 0; i < fpentry.size(); i++){
|
|
|
+ JSONObject jsonData = fpentry.getJSONObject(i);
|
|
|
+
|
|
|
+ String fpNumber = jsonData.getString("fpNumber");
|
|
|
+ String fpCode = jsonData.getString("fpCode");
|
|
|
+ String taxAmount = jsonData.getString("taxAmount");
|
|
|
+
|
|
|
+ DynamicObject entry = new DynamicObject(type);
|
|
|
+ entry.set("invoiceno", fpNumber);
|
|
|
+ entry.set("invoicecode", fpCode);
|
|
|
+ entry.set("taxamount_invoice", taxAmount);
|
|
|
+
|
|
|
+ invoiceEntry.add(entry);
|
|
|
+ }
|
|
|
+ bizAcctOutBill.set("invoiceentry", invoiceEntry);
|
|
|
+
|
|
|
+ try {
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
OperationResult resultSave = SaveServiceHelper.saveOperate(ENTITY_PUBLICPAY, new DynamicObject[]{bizAcctOutBill}, OperateOption.create());
|
|
@@ -249,37 +425,18 @@ public class SRMSynPayApiPlugin implements Serializable {
|
|
|
err.append("/").append(message);
|
|
|
}
|
|
|
|
|
|
- returnMap.put("code", "500");
|
|
|
- returnMap.put("msg", err.toString());
|
|
|
-
|
|
|
- return returnMap;
|
|
|
+ returnMessage = "失败" + err.toString();
|
|
|
+ return buildReturnData(code, srmBillNo, returnMessage, null, null, null);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ return buildReturnData("0", srmBillNo, "成功", resultSave.getSuccessPkIds().get(0).toString(), null, ENTITY_PREPAY);
|
|
|
|
|
|
- return returnMap;
|
|
|
- }
|
|
|
-
|
|
|
- private DynamicObject getF7FieldValue(String entityName, String type, String value){
|
|
|
- QFilter qFilter = new QFilter("status", QCP.equals, "C");
|
|
|
- qFilter.and(new QFilter("number", QCP.equals, value));
|
|
|
-
|
|
|
- DynamicObject objectInfo = BusinessDataServiceHelper.loadSingle(entityName, qFilter.toArray());
|
|
|
-
|
|
|
- return objectInfo;
|
|
|
+ } catch(Exception e){
|
|
|
+ returnMessage = "失败" + e.getMessage();
|
|
|
+ return buildReturnData(code, srmBillNo, returnMessage, null, null, null);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
|
|
|
* 同步付款
|
|
|
* @param dailyLoanBills
|
|
@@ -290,6 +447,33 @@ public class SRMSynPayApiPlugin implements Serializable {
|
|
|
return responseData;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 构造返回data参数
|
|
|
+ * @param status
|
|
|
+ * @param message
|
|
|
+ * @param fid
|
|
|
+ * @param number
|
|
|
+ * @param entityName
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public JSONObject buildReturnData(String status, String srmBillNO, String message, String fid, String number, String entityName){
|
|
|
+ JSONObject data = new JSONObject();
|
|
|
+
|
|
|
+ data.put("status", status);
|
|
|
+ data.put("SRMBillNo", srmBillNO);
|
|
|
+ data.put("message", message);
|
|
|
+ if("0".equals(status)) {
|
|
|
+ data.put("fid", fid);
|
|
|
+ data.put("number", number);
|
|
|
+
|
|
|
+ String url = "";
|
|
|
+
|
|
|
+ data.put("url", url);
|
|
|
+ }
|
|
|
+
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
* 自定义返回data对象
|
|
|
* @param code 编码
|