Преглед на файлове

同步凭证增加付款单关联关系

wangjun преди 4 седмици
родител
ревизия
620863ca12
променени са 1 файла, в които са добавени 36 реда и са изтрити 0 реда
  1. 36 0
      code/jyyy/nckd-jimin-jyyy-fi/src/main/java/nckd/jimin/jyyy/fi/webapi/TransDetailApiPlugin.java

+ 36 - 0
code/jyyy/nckd-jimin-jyyy-fi/src/main/java/nckd/jimin/jyyy/fi/webapi/TransDetailApiPlugin.java

@@ -21,6 +21,7 @@ import kd.bos.servicehelper.BusinessDataServiceHelper;
 import kd.bos.servicehelper.operation.DeleteServiceHelper;
 import kd.bos.servicehelper.operation.SaveServiceHelper;
 import kd.data.rsa.helper.CodeRuleHelper;
+import kd.fi.cas.helper.CasBotpHelper;
 
 import java.io.Serializable;
 import java.math.BigDecimal;
@@ -300,7 +301,31 @@ public class TransDetailApiPlugin implements Serializable {
         //  银行主键 不能重复 不能为空
         transDetail.set(BeiTransdetailConstantInfo.UNIQUESEQ, receiptNo);
 
+        //需要与付款单建立关联关系
+        String casBillID = jsonObject.getString("sourceBillId");
+        DynamicObject paybillDyn = null;
+        if(StringUtils.isEmpty(casBillID)){
+            errMsg.append("付款单ID为空;");
+        }else {
+            String billid  = extractBillID(casBillID);
+            //获取 付款单号
+            QFilter qFilter = new QFilter("id", QCP.equals, billid);
+            paybillDyn = BusinessDataServiceHelper.loadSingle("cas_paybill", new QFilter[]{qFilter});
+            if (paybillDyn != null) {
+
+                transDetail.set(BeiTransdetailConstantInfo.SOURCEBILLID, paybillDyn.getPkValue());
+                transDetail.set(BeiTransdetailConstantInfo.SOURCEBILLTYPE, "cas_paybill");
+            }
+        }
+
         SaveServiceHelper.save(new DynamicObject[]{transDetail});
+        if (EmptyUtils.isNotEmpty(paybillDyn)) {
+            //保存与付款单的关联关系
+            CasBotpHelper.saveRelation(paybillDyn, transDetail);
+            //在付款单保存交易流水号
+            paybillDyn.set("detailseqid", number);
+            SaveServiceHelper.save(new DynamicObject[]{paybillDyn});
+        }
 
         return errMsg.toString();
     }
@@ -416,5 +441,16 @@ public class TransDetailApiPlugin implements Serializable {
         // Extract the substring after the last slash
         return address.substring(lastSlashIndex + 1);
     }
+    public static String extractBillID(String address) {
+        // Find the last slash in the URL
+        int lastSlashIndex = address.lastIndexOf('-');
+        if (lastSlashIndex == -1) {
+            return null; // No slash found, invalid URL
+        }
+        // Extract the substring after the last slash
+        return address.substring(lastSlashIndex + 1);
+    }
+
+
 
 }