Browse Source

增加交易明细与电子回单接口

wangjun 1 day ago
parent
commit
cc16afa2bb

+ 291 - 0
code/jyyy/nckd-jimin-jyyy-fi/src/main/java/nckd/jimin/jyyy/fi/webapi/BeiElecreceiptConstantInfo.java

@@ -0,0 +1,291 @@
+package nckd.yanye.scm.webapi;
+/**
+ * 电子回单查询常量类
+ *
+ * @author 饶德辉
+ * @version 1.0
+ * @date 2025-04-25 11:41:03
+ */
+public class BeiElecreceiptConstantInfo {
+
+    /**
+     * 实体标识
+     **/
+    public static final String ENTITYID = "bei_elecreceipt";
+    /**
+     * 缺省id字段
+     **/
+    public static final String ID = "ID";
+    /**
+     * 单据编号
+     **/
+    public static final String BILLNO = "BILLNO";
+    /**
+     * 单据状态
+     **/
+    public static final String BILLSTATUS = "BILLSTATUS";
+    /**
+     * 创建人
+     **/
+    public static final String CREATOR = "CREATOR";
+    /**
+     * 修改人
+     **/
+    public static final String MODIFIER = "MODIFIER";
+    /**
+     * 审核人
+     **/
+    public static final String AUDITOR = "AUDITOR";
+    /**
+     * 审核日期
+     **/
+    public static final String AUDITDATE = "AUDITDATE";
+    /**
+     * 修改时间
+     **/
+    public static final String MODIFYTIME = "MODIFYTIME";
+    /**
+     * 创建时间
+     **/
+    public static final String CREATETIME = "CREATETIME";
+    /**
+     * 组织(不用)
+     **/
+    public static final String ORG = "ORG";
+    /**
+     * 交易日期
+     **/
+    public static final String BIZDATE = "BIZDATE";
+    /**
+     * 源单id
+     **/
+    public static final String SOURCEBILLID = "SOURCEBILLID";
+    /**
+     * 币种
+     **/
+    public static final String CURRENCY = "CURRENCY";
+    /**
+     * 金额
+     **/
+    public static final String AMOUNT = "AMOUNT";
+    /**
+     * 金额折本位币
+     **/
+    public static final String LOCAMT = "LOCAMT";
+    /**
+     * 汇率
+     **/
+    public static final String EXCHANGERATE = "EXCHANGERATE";
+    /**
+     * 摘要
+     **/
+    public static final String DESCRIPTION = "DESCRIPTION";
+    /**
+     * 资金组织
+     **/
+    public static final String COMPANY = "COMPANY";
+    /**
+     * 银行账户
+     **/
+    public static final String ACCOUNTBANK = "ACCOUNTBANK";
+    /**
+     * 开户银行
+     **/
+    public static final String BANK = "BANK";
+    /**
+     * 付款金额
+     **/
+    public static final String DEBITAMOUNT = "DEBITAMOUNT";
+    /**
+     * 收款金额
+     **/
+    public static final String CREDITAMOUNT = "CREDITAMOUNT";
+    /**
+     * 对方单位
+     **/
+    public static final String OPPUNIT = "OPPUNIT";
+    /**
+     * 用途
+     **/
+    public static final String USE = "USE";
+    /**
+     * 匹配交易明细
+     **/
+    public static final String ISMATCH = "ISMATCH";
+    /**
+     * 明细流水号
+     **/
+    public static final String DETAILID = "DETAILID";
+    /**
+     * 对方银行账号
+     **/
+    public static final String OPPBANKNUMBER = "OPPBANKNUMBER";
+    /**
+     * 对方开户银行
+     **/
+    public static final String OPPBANK = "OPPBANK";
+    /**
+     * 验证码
+     **/
+    public static final String VALIDCODE = "VALIDCODE";
+    /**
+     * 业务参考号
+     **/
+    public static final String BIZREFNO = "BIZREFNO";
+    /**
+     * 对账标识码
+     **/
+    public static final String BANKCHECKFLAG = "BANKCHECKFLAG";
+    /**
+     * 借贷标记
+     **/
+    public static final String CREDITDEBITFLAG = "CREDITDEBITFLAG";
+    /**
+     * 电子回单号
+     **/
+    public static final String RECEIPTNO = "RECEIPTNO";
+    /**
+     * 是否文件
+     **/
+    public static final String FILEFLAG = "FILEFLAG";
+    /**
+     * 是否完成标识
+     **/
+    public static final String COMPLETEFLAG = "COMPLETEFLAG";
+    /**
+     * 记账网点
+     **/
+    public static final String TRANSNETCODE = "TRANSNETCODE";
+    /**
+     * 记账柜员
+     **/
+    public static final String TRANSTELLNO = "TRANSTELLNO";
+    /**
+     * 文件服务url
+     **/
+    public static final String FILESERVERURL = "FILESERVERURL";
+    /**
+     * tcpurl
+     **/
+    public static final String TCPURL = "TCPURL";
+    /**
+     * 回单路径文件名
+     **/
+    public static final String FILEPATH = "FILEPATH";
+    /**
+     * 上传文件名称
+     **/
+    public static final String UPLOADFILENAME = "UPLOADFILENAME";
+    /**
+     * 服务器主机地址
+     **/
+    public static final String HOST = "HOST";
+    /**
+     * 服务器认证用户名
+     **/
+    public static final String USERNAME = "USERNAME";
+    /**
+     * 服务器认证密码
+     **/
+    public static final String PASSWORD = "PASSWORD";
+    /**
+     * 服务器协议
+     **/
+    public static final String PROXY = "PROXY";
+    /**
+     * 服务器开放端口
+     **/
+    public static final String PORT = "PORT";
+    /**
+     * 业务类型
+     **/
+    public static final String BIZTYPE = "BIZTYPE";
+    /**
+     * 排序号
+     **/
+    public static final String SORTNO = "SORTNO";
+    /**
+     * 备注
+     **/
+    public static final String REMARKS = "REMARKS";
+    /**
+     * 数据来源
+     **/
+    public static final String DATASOURCE = "DATASOURCE";
+    /**
+     * 明细交易时间
+     **/
+    public static final String DETAILDATETIME = "DETAILDATETIME";
+    /**
+     * 对方银行账号名称
+     **/
+    public static final String OPPBANKNAME = "OPPBANKNAME";
+    /**
+     * 打印次数
+     **/
+    public static final String PRINTCOUNT = "PRINTCOUNT";
+    /**
+     * 付方账号
+     **/
+    public static final String ACCNO = "ACCNO";
+    /**
+     * 付款人名称
+     **/
+    public static final String ACCNAME = "ACCNAME";
+    /**
+     * 付方开户银行名称
+     **/
+    public static final String BANKNAME = "BANKNAME";
+    /**
+     * 是否归档
+     **/
+    public static final String ISARCHIVE = "ISARCHIVE";
+    /**
+     * 收方账号
+     **/
+    public static final String RECNO = "RECNO";
+    /**
+     * 收款人名称
+     **/
+    public static final String RECNAME = "RECNAME";
+    /**
+     * 收方开户银行名称
+     **/
+    public static final String RECBANKNAME = "RECBANKNAME";
+    /**
+     * 匹配交易明细信息
+     **/
+    public static final String MATCHDETAILENTRY = "MATCHDETAILENTRY";
+    /**
+     * 分录行号
+     **/
+    public static final String SEQ = "SEQ";
+    /**
+     * 对账标识码
+     **/
+    public static final String E_BANKCHECKFLAG = "E_BANKCHECKFLAG";
+    /**
+     * 交易明细id
+     **/
+    public static final String E_TRANSDETAILID = "E_TRANSDETAILID";
+    /**
+     * 银行交易明细id
+     **/
+    public static final String TRANSDETAILID = "TRANSDETAILID";
+    /**
+     * 匹配方式
+     **/
+    public static final String MATCHTYPE = "MATCHTYPE";
+    /**
+     * 匹配人员
+     **/
+    public static final String MATCHER = "MATCHER";
+    /**
+     * 匹配时间
+     **/
+    public static final String MATCHTIME = "MATCHTIME";
+    /**
+     * 金融机构类别
+     **/
+    public static final String FINANCIALTYPE = "FINANCIALTYPE";
+}

+ 362 - 0
code/jyyy/nckd-jimin-jyyy-fi/src/main/java/nckd/jimin/jyyy/fi/webapi/BeiTransdetailConstantInfo.java

@@ -0,0 +1,362 @@
+package nckd.yanye.scm.webapi;
+/**
+ * 交易明细查询常量类
+ *
+ * @author 饶德辉
+ * @version 1.0
+ * @date 2025-04-24 16:58:51
+ */
+public class BeiTransdetailConstantInfo {
+    /**
+     * 实体标识
+     **/
+    public static final String ENTITYID = "bei_transdetail";
+    /**
+     * 缺省id字段
+     **/
+    public static final String ID = "ID";
+    /**
+     * 交易明细编号
+     **/
+    public static final String BILLNO = "BILLNO";
+    /**
+     * 单据状态
+     **/
+    public static final String BILLSTATUS = "BILLSTATUS";
+    /**
+     * 创建人
+     **/
+    public static final String CREATOR = "CREATOR";
+    /**
+     * 修改人
+     **/
+    public static final String MODIFIER = "MODIFIER";
+    /**
+     * 审核人
+     **/
+    public static final String AUDITOR = "AUDITOR";
+    /**
+     * 审核日期
+     **/
+    public static final String AUDITDATE = "AUDITDATE";
+    /**
+     * 最后更新时间
+     **/
+    public static final String MODIFYTIME = "MODIFYTIME";
+    /**
+     * 创建时间
+     **/
+    public static final String CREATETIME = "CREATETIME";
+    /**
+     * 组织(不用)
+     **/
+    public static final String ORG = "ORG";
+    /**
+     * 交易日期
+     **/
+    public static final String BIZDATE = "BIZDATE";
+    /**
+     * 源单id
+     **/
+    public static final String SOURCEBILLID = "SOURCEBILLID";
+    /**
+     * 币种
+     **/
+    public static final String CURRENCY = "CURRENCY";
+    /**
+     * 金额
+     **/
+    public static final String AMOUNT = "AMOUNT";
+    /**
+     * 金额折本位币
+     **/
+    public static final String LOCAMT = "LOCAMT";
+    /**
+     * 汇率
+     **/
+    public static final String EXCHANGERATE = "EXCHANGERATE";
+    /**
+     * 资金组织
+     **/
+    public static final String COMPANY = "COMPANY";
+    /**
+     * 描述
+     **/
+    public static final String DESCRIPTION = "DESCRIPTION";
+    /**
+     * 银行账号
+     **/
+    public static final String ACCOUNTBANK = "ACCOUNTBANK";
+    /**
+     * 开户银行
+     **/
+    public static final String BANK = "BANK";
+    /**
+     * 业务参考号
+     **/
+    public static final String BIZREFNO = "BIZREFNO";
+    /**
+     * 付款金额
+     **/
+    public static final String DEBITAMOUNT = "DEBITAMOUNT";
+    /**
+     * 收款金额
+     **/
+    public static final String CREDITAMOUNT = "CREDITAMOUNT";
+    /**
+     * 余额
+     **/
+    public static final String TRANSBALANCE = "TRANSBALANCE";
+    /**
+     * 对方户名
+     **/
+    public static final String OPPUNIT = "OPPUNIT";
+    /**
+     * 对方开户行
+     **/
+    public static final String OPPBANK = "OPPBANK";
+    /**
+     * 跟电子回单匹配
+     **/
+    public static final String ISMATCHERECEIPT = "ISMATCHERECEIPT";
+    /**
+     * 是否导入
+     **/
+    public static final String ISDATAIMPORT = "ISDATAIMPORT";
+    /**
+     * 明细流水号
+     **/
+    public static final String DETAILID = "DETAILID";
+    /**
+     * 已经或无需下载银行对账单
+     **/
+    public static final String ISDOWNTOBANKSTATE = "ISDOWNTOBANKSTATE";
+    /**
+     * 确认无回单
+     **/
+    public static final String ISNORECEIPT = "ISNORECEIPT";
+    /**
+     * 电子回单关联标记
+     **/
+    public static final String RECEIPTNO = "RECEIPTNO";
+    /**
+     * 对账标识码(银行返回)
+     **/
+    public static final String ORIGINALBANKCHECKFLAG = "ORIGINALBANKCHECKFLAG";
+    /**
+     * 数据来源
+     **/
+    public static final String DATASOURCE = "DATASOURCE";
+    /**
+     * 业务类型
+     **/
+    public static final String BIZTYPE = "BIZTYPE";
+    /**
+     * 是否退票
+     **/
+    public static final String ISREFUND = "ISREFUND";
+    /**
+     * 银行接口
+     **/
+    public static final String BANKINTERFACE = "BANKINTERFACE";
+    /**
+     * 是否接收
+     **/
+    public static final String ISRECED = "ISRECED";
+    /**
+     * 交易明细时间
+     **/
+    public static final String BIZTIME = "BIZTIME";
+    /**
+     * 是否银企付款
+     **/
+    public static final String ISKDRETFLAG = "ISKDRETFLAG";
+    /**
+     * 银行上划
+     **/
+    public static final String ISTRANSUP = "ISTRANSUP";
+    /**
+     * 银行下拨
+     **/
+    public static final String ISTRANSDOWN = "ISTRANSDOWN";
+    /**
+     * 银行代扣
+     **/
+    public static final String ISBANKWITHHOLDING = "ISBANKWITHHOLDING";
+    /**
+     * 接收单据类型
+     **/
+    public static final String RECEDBILLTYPE = "RECEDBILLTYPE";
+    /**
+     * 入账状态
+     **/
+    public static final String RECEREDTYPE = "RECEREDTYPE";
+    /**
+     * 排序号
+     **/
+    public static final String SORTNO = "SORTNO";
+    /**
+     * 适配入账规则
+     **/
+    public static final String RULENAME = "RULENAME";
+    /**
+     * 票据号
+     **/
+    public static final String BUSINESSBILLNUM = "BUSINESSBILLNUM";
+    /**
+     * 自动收付款
+     **/
+    public static final String AUTORECORPAY = "AUTORECORPAY";
+    /**
+     * 智能匹配
+     **/
+    public static final String SMARTMATCH = "SMARTMATCH";
+    /**
+     * 对方账号
+     **/
+    public static final String OPPBANKNUMBER = "OPPBANKNUMBER";
+    /**
+     * 对账标识码
+     **/
+    public static final String BANKCHECKFLAG = "BANKCHECKFLAG";
+    /**
+     * 接收单据编号
+     **/
+    public static final String RECEDBILLNUMBER = "RECEDBILLNUMBER";
+    /**
+     * 收款认领通知
+     **/
+    public static final String CLAIMNOTICEBILLNO = "CLAIMNOTICEBILLNO";
+    /**
+     * 源单类型
+     **/
+    public static final String SOURCEBILLTYPE = "SOURCEBILLTYPE";
+    /**
+     * 手续费
+     **/
+    public static final String TRANSFERCHARGE = "TRANSFERCHARGE";
+    /**
+     * 流程序列号
+     **/
+    public static final String FLOWSERIALNO = "FLOWSERIALNO";
+    /**
+     * 排序ID
+     **/
+    public static final String SORTID = "SORTID";
+    /**
+     * 银企请求流水号
+     **/
+    public static final String REQUESTSERIALNO = "REQUESTSERIALNO";
+    /**
+     * 银行响应流水号
+     **/
+    public static final String RESPONSESERAILNO = "RESPONSESERAILNO";
+    /**
+     * KD标识
+     **/
+    public static final String KDRETFLAG = "KDRETFLAG";
+    /**
+     * 被代理帐号
+     **/
+    public static final String AGENTACCNO = "AGENTACCNO";
+    /**
+     * 被代理户名
+     **/
+    public static final String AGENTACCNAME = "AGENTACCNAME";
+    /**
+     * 被代理帐号开户行
+     **/
+    public static final String AGENTACCBANKNAME = "AGENTACCBANKNAME";
+    /**
+     * busType
+     **/
+    public static final String BUSTYPE = "BUSTYPE";
+    /**
+     * 银企付款提交的批次号
+     **/
+    public static final String BATCHNO = "BATCHNO";
+    /**
+     * 凭证号
+     **/
+    public static final String VOUHNO = "VOUHNO";
+    /**
+     * 记账日期
+     **/
+    public static final String TRANSDATE = "TRANSDATE";
+    /**
+     * extData
+     **/
+    public static final String EXTDATA = "EXTDATA";
+    /**
+     * 最后修改时间
+     **/
+    public static final String LASTMODIFYTIME = "LASTMODIFYTIME";
+    /**
+     * 银行流水号
+     **/
+    public static final String BANKDETAILNO = "BANKDETAILNO";
+    /**
+     * 银行主键
+     **/
+    public static final String UNIQUESEQ = "UNIQUESEQ";
+    /**
+     * 已下载银行日记账
+     **/
+    public static final String ISDOWNBANKJOURNAL = "ISDOWNBANKJOURNAL";
+    /**
+     * 异常
+     **/
+    public static final String ERRORTYPE = "ERRORTYPE";
+    /**
+     * 异常原因
+     **/
+    public static final String ERRORMSG = "ERRORMSG";
+    /**
+     * 代理查询报文账号
+     **/
+    public static final String EXTRAACCNO = "EXTRAACCNO";
+    /**
+     * 票号
+     **/
+    public static final String BILLNOBILLNO = "BILLNOBILLNO";
+    /**
+     * 企业识别码
+     **/
+    public static final String FRMCOD = "FRMCOD";
+    /**
+     * 金融机构类别
+     **/
+    public static final String FINANCIALTYPE = "FINANCIALTYPE";
+    /**
+     * 电子回单关联信息
+     **/
+    public static final String MATCHRECEIPTENTRY = "MATCHRECEIPTENTRY";
+    /**
+     * 分录行号
+     **/
+    public static final String SEQ = "SEQ";
+    /**
+     * 电子回单id
+     **/
+    public static final String E_RECEIPTID = "E_RECEIPTID";
+    /**
+     * 电子回单关联标记
+     **/
+    public static final String E_RECEIPTNO = "E_RECEIPTNO";
+    /**
+     * 同名转账
+     **/
+    public static final String SYNONYM = "SYNONYM";
+    /**
+     * 已确认金额
+     **/
+    public static final String CONFIRMAMOUNT = "CONFIRMAMOUNT";
+    /**
+     * 未确认金额
+     **/
+    public static final String UNCONFIRMAMOUNT = "UNCONFIRMAMOUNT";
+    /**
+     * 对方账号关联银行账号
+     **/
+    public static final String OPPRELACCT = "OPPRELACCT";
+}

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

@@ -0,0 +1,386 @@
+package nckd.jimin.jyyy.fi.webapi;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import kd.bos.dataentity.entity.DynamicObject;
+import kd.bos.dataentity.entity.DynamicObjectCollection;
+import kd.bos.db.DB;
+import kd.bos.ext.fi.plugin.ArApConvert.util.EmptyUtils;
+import kd.bos.logging.Log;
+import kd.bos.logging.LogFactory;
+import kd.bos.login.utils.DateUtils;
+import kd.bos.openapi.common.custom.annotation.ApiController;
+import kd.bos.openapi.common.custom.annotation.ApiMapping;
+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.orm.query.QCP;
+import kd.bos.orm.query.QFilter;
+import kd.bos.servicehelper.BusinessDataServiceHelper;
+import kd.bos.servicehelper.operation.DeleteServiceHelper;
+import kd.bos.servicehelper.operation.SaveServiceHelper;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+
+/**
+ * 交易明细API插件类
+ * 用于处理交易明细相关的操作,如保存交易明细信息。
+ */
+@ApiController(value = "nstc", desc = "对接九恒星交易明细")
+@ApiMapping("/nstc")
+public class TransDetailApiPlugin implements Serializable {
+
+    private static final Log log = LogFactory.getLog(TransDetailApiPlugin.class);
+
+    /**
+     * 保存交易明细
+     *
+     * @param operation 操作类型
+     * @param jsondata  交易明细数据
+     * @return 处理结果
+     */
+    @ApiPostMapping(value = "/transdetail", desc = "操作九恒星交易明细")
+    public CustomApiResult<Object> oprationTransDetail(
+            @ApiParam(value = "操作类型", required = true) String operation,
+            @ApiParam(value = "交易明细数据", required = true) String jsondata
+    ) {
+        log.info("收到保存交易明细请求:\r\n操作类型:{}\r\n交易明细数据:{}",
+                operation,
+                jsondata
+        );
+
+        //JSONArray jsonArray =JSONArray.parseArray(jsondata);
+        if(jsondata.startsWith("[")){
+            log.error("保存交易明细失败。操作类型:{},交易明细数据:{},错误信息:{}", operation, jsondata, "只允许接收1条数据,请重新传输!");
+            return CustomApiResult.fail("803","操作交易明细失败: 只允许接收1条数据,请重新传输!");
+        }
+
+        try {
+            // 根据操作类型处理不同的逻辑
+            switch (operation) {
+                case "save":
+                    // 添加交易明细逻辑
+                    String errMsg = saveTransDetail(jsondata);
+                    if (!EmptyUtils.isEmpty(errMsg)) {
+                        log.error("交易明细添加失败。操作类型:{},交易明细数据:{},错误信息:{}", operation, jsondata, "交易明细添加失败" + errMsg);
+                        return CustomApiResult.fail("802","交易明细添加失败" + errMsg);
+                    } else {
+                        log.info("交易明细添加成功。操作类型:{},交易明细数据:{}", operation, jsondata);
+                        return CustomApiResult.success("交易明细添加成功");
+                    }
+                case "delete":
+                    // 更新交易明细逻辑
+                    String errMsg1 = deleteTransDetail(jsondata);
+                    if (!EmptyUtils.isEmpty(errMsg1)) {
+                        log.error("交易明细更新失败。操作类型:{},交易明细数据:{},错误信息:{}", operation, jsondata, errMsg1);
+                        return CustomApiResult.fail("801","交易明细更新失败" + errMsg1);
+                    } else {
+                        log.info("交易明细更新成功。操作类型:{},交易明细数据:{}", operation, jsondata);
+                        return CustomApiResult.success("交易明细更新成功");
+                    }
+                default:
+                    log.error("不支持的操作类型。操作类型:{},交易明细数据:{}", operation, jsondata);
+                    return CustomApiResult.fail("700","不支持的操作类型");
+            }
+        } catch (Exception e) {
+            log.error("保存交易明细失败。操作类型:{},交易明细数据:{},错误信息:{}", operation, jsondata, e.getMessage());
+            return CustomApiResult.fail("801","操作交易明细失败: " + e.getMessage());
+        }
+    }
+
+    private String deleteTransDetail(String jsonData) {
+        // 解析JSON数据
+        JSONObject jsonObject = JSON.parseObject(jsonData);
+
+        StringBuilder errMsg = new StringBuilder();
+        // 交易流水号ID  关键字
+        String number = jsonObject.getString("number");
+        // 电子回单号ID  关键字
+        //String receiptNo = jsonObject.getString("receiptNo");
+
+        // 是否有重复信息接收单
+        DynamicObject billByn = BusinessDataServiceHelper.loadSingle(
+                BeiTransdetailConstantInfo.ENTITYID,
+                new QFilter[]{new QFilter(BeiTransdetailConstantInfo.BILLNO, QCP.equals, number)}
+        );
+        if(!EmptyUtils.isEmpty(billByn)) {
+            DeleteServiceHelper.delete(BeiTransdetailConstantInfo.ENTITYID,new QFilter[]{new QFilter("id", QCP.equals, billByn.getPkValue())});
+        }else {
+            errMsg = new StringBuilder("交易流水号: " + number + "不存在;");
+        }
+
+        // 是否有重复信息接收单
+        DynamicObject billeleByn = BusinessDataServiceHelper.loadSingle(
+                BeiElecreceiptConstantInfo.ENTITYID,
+                new QFilter[]{new QFilter(BeiElecreceiptConstantInfo.BILLNO, QCP.equals, number)}
+        );
+        if(!EmptyUtils.isEmpty(billeleByn)) {
+            DeleteServiceHelper.delete(BeiElecreceiptConstantInfo.ENTITYID,new QFilter[]{new QFilter("id", QCP.equals, billeleByn.getPkValue())});
+        }else {
+            errMsg = new StringBuilder("电子回单号: " + number + "不存在;");
+        }
+
+        return errMsg.toString();
+
+    }
+
+    /**
+     * 保存交易明细信息
+     *
+     * @param jsonData  JSON数据
+     */
+    public String saveTransDetail( String jsonData) {
+        // 解析JSON数据
+        JSONObject jsonObject = JSON.parseObject(jsonData);
+
+        StringBuilder errMsg =  new StringBuilder();
+        // 交易流水号ID  关键字
+        String number = jsonObject.getString("number");
+
+
+        // 是否有重复信息接收单
+        DynamicObject billByn = BusinessDataServiceHelper.loadSingle(
+                BeiTransdetailConstantInfo.ENTITYID,
+                new QFilter[]{new QFilter(BeiTransdetailConstantInfo.BILLNO, QCP.equals, number)}
+        );
+        boolean isNew = EmptyUtils.isEmpty(billByn);
+        DynamicObject transDetail = null;
+        if(!isNew){
+            transDetail = billByn;
+        }else {
+            // 创建动态对象,用于存储交易明细数据
+            transDetail = BusinessDataServiceHelper.newDynamicObject(BeiTransdetailConstantInfo.ENTITYID);
+            //生成随机单据id
+            long Id = DB.genLongId("t_bei_transdetail");
+            transDetail.set("id", Id);
+            transDetail.set(BeiTransdetailConstantInfo.BILLNO, number); // 编号
+        }
+
+        // 设置字段值,将JSON中的数据映射到动态对象中
+        /**
+         * 资金组织判断
+         */
+        String company  = jsonObject.getString("company");
+        DynamicObject companyByn = BusinessDataServiceHelper.loadSingle("bos_org",new QFilter[]{new QFilter("number", QCP.equals, company)});
+        if(EmptyUtils.isEmpty(companyByn)) {
+            errMsg.append("资金组织不存在;");
+        }else {
+            transDetail.set(BeiTransdetailConstantInfo.COMPANY, companyByn); // 资金组织Number
+        }
+        /**
+         * 银行账号Number
+         */
+        String bankAccount = jsonObject.getString("bankAccount");
+        DynamicObject bankAccountByn = BusinessDataServiceHelper.loadSingle("bd_accountbanks",new QFilter[]{new QFilter("number", QCP.equals, bankAccount)});
+        if (EmptyUtils.isEmpty(bankAccountByn)){
+            errMsg.append("银行账号不存在;");
+        }else {
+            transDetail.set(BeiTransdetailConstantInfo.ACCOUNTBANK, bankAccountByn); // 银行账号Number
+            transDetail.set(BeiTransdetailConstantInfo.BANK, bankAccountByn.getDynamicObject("bank"));  // 开户银行
+        }
+        /**
+         * 币种ID
+         */
+        String currency = jsonObject.getString("currency");
+        DynamicObject currencyByn = BusinessDataServiceHelper.loadSingle("bd_currency",new QFilter[]{new QFilter("number", QCP.equals, currency)});
+        if (EmptyUtils.isEmpty(currencyByn)){
+            errMsg.append("币种不存在;");
+        }else {
+            transDetail.set(BeiTransdetailConstantInfo.CURRENCY, currencyByn); // 币种Number
+        }
+        String bizTimeStr =  jsonObject.getString("bizTime");
+        Date bizTime = DateUtils.parseDateTime(bizTimeStr, "yyyy-MM-dd HH:mm:ss");
+        transDetail.set(BeiTransdetailConstantInfo.BIZTIME, bizTime); // 原始交易时间
+
+        String bizdateString =  jsonObject.getString("bizDate");
+        Date bizdate = DateUtils.parseDateTime(bizdateString, "yyyy-MM-dd");
+        transDetail.set(BeiTransdetailConstantInfo.BIZDATE, bizdate); // 业务日期
+
+        transDetail.set(BeiTransdetailConstantInfo.DESCRIPTION, jsonObject.getString("description")); // 描述
+        transDetail.set(BeiTransdetailConstantInfo.BUSINESSBILLNUM, jsonObject.getString("name"));    //票据号
+
+        transDetail.set(BeiTransdetailConstantInfo.CREDITAMOUNT, jsonObject.getBigDecimal("creditAmount")); // 收款金额
+        transDetail.set(BeiTransdetailConstantInfo.DEBITAMOUNT, jsonObject.getBigDecimal("debitAmount")); // 付款金额
+        transDetail.set(BeiTransdetailConstantInfo.TRANSBALANCE, jsonObject.getBigDecimal("transBalance")); // 余额
+
+        transDetail.set(BeiTransdetailConstantInfo.OPPUNIT, jsonObject.getString("oppUnit")); // 对方户名
+        transDetail.set(BeiTransdetailConstantInfo.OPPBANK, jsonObject.getString("oppBank")); // 对方开户银行
+        transDetail.set(BeiTransdetailConstantInfo.OPPBANKNUMBER, jsonObject.getString("oppBankNumber")); // 对方银行账号
+
+        /**
+         * 交易流水号ID
+         */
+        transDetail.set(BeiTransdetailConstantInfo.DETAILID, jsonObject.getString("tranPackageID")); // 交易流水号ID
+        transDetail.set(BeiTransdetailConstantInfo.BANKDETAILNO, jsonObject.getString("tranPackageID")); // 银行流水号
+
+        transDetail.set(BeiTransdetailConstantInfo.BILLSTATUS, "C");
+        String receiptNo = jsonObject.getString("receiptNo");
+        transDetail.set(BeiTransdetailConstantInfo.RECEIPTNO, receiptNo); // 电子回单编号
+
+        /**
+         * 入账状态
+         * 待入账=0,已入账=1,无需入账=2
+         */
+        String isReced = jsonObject.getString("isReced");
+        switch (isReced) {
+            case "0":
+                transDetail.set(BeiTransdetailConstantInfo.RECEREDTYPE, "0");
+                break;
+            case "1":
+                transDetail.set(BeiTransdetailConstantInfo.RECEREDTYPE, "3");
+                break;
+            default:
+                errMsg.append("入账状态不存在;");
+                break;
+        }
+
+        /**
+         * 业务类型
+         * 普通	1
+         * 上划	2
+         * 下拨	3
+         * 内部代付	4
+         * 内部转账	5
+         * 内部扣款	6
+         * 贷款收回	7
+         * 贷款结息	8
+         * 活转定	9
+         * 定转活	10
+         * 供应链融资还款	11
+         * 联动支付	12
+         * 内部收款	13
+         * 贷款发放	14
+         * 存款结息	15
+         * 定期收益	16
+         */
+        String bizType = jsonObject.getString("bizType");
+        switch (bizType) {
+            case "1":
+                transDetail.set(BeiTransdetailConstantInfo.BIZTYPE, "1");
+                break;
+            case "2":
+                transDetail.set(BeiTransdetailConstantInfo.BIZTYPE, "2");
+                transDetail.set(BeiTransdetailConstantInfo.ISTRANSUP, true); // 是否上划
+                break;
+            case "3":
+                transDetail.set(BeiTransdetailConstantInfo.BIZTYPE, "3");
+                transDetail.set(BeiTransdetailConstantInfo.ISTRANSDOWN, true); // 是否下拨
+                break;
+            default:
+                errMsg.append("业务类型不存在;");
+                break;
+        }
+
+        String electricAddress = jsonObject.getString("electricAddress");
+        // 判断是否有电子回单,如果有则处理电子回单单据对象,并保存
+        if (EmptyUtils.isNotEmpty(electricAddress)) {
+            DynamicObject elecreceipt = BusinessDataServiceHelper.loadSingle(BeiElecreceiptConstantInfo.ENTITYID, new QFilter[]{new QFilter("billno", QCP.equals, receiptNo)});
+            /**
+             * 保存电子回单
+             */
+            String errStr = saveElecreceipt(transDetail, elecreceipt,electricAddress);
+            if (EmptyUtils.isNotEmpty(errStr)) {
+                errMsg.append(errStr);
+            }else{
+                transDetail.set(BeiTransdetailConstantInfo.ISMATCHERECEIPT, true); // 是否匹配电子回单
+
+            }
+        }
+
+        //  银行主键 不能重复 不能为空
+        transDetail.set(BeiTransdetailConstantInfo.UNIQUESEQ, receiptNo);
+
+        SaveServiceHelper.save(new DynamicObject[]{transDetail});
+
+        return errMsg.toString();
+    }
+
+    private String saveElecreceipt( DynamicObject transDetail,DynamicObject elecreceipt,String electricAddress) {
+        StringBuilder errMsg = new StringBuilder();
+
+        DynamicObject elecreceiptDyn = null;
+        if(!EmptyUtils.isEmpty(elecreceipt)){
+            elecreceiptDyn = elecreceipt;
+        }else {
+            // 创建动态对象,用于存储交易明细数据
+            elecreceiptDyn = BusinessDataServiceHelper.newDynamicObject(BeiElecreceiptConstantInfo.ENTITYID);
+            long Id = DB.genLongId("t_bei_elecreceipt");
+            elecreceiptDyn.set("id", Id);
+
+            elecreceiptDyn.set(BeiElecreceiptConstantInfo.DETAILID, transDetail.get(BeiTransdetailConstantInfo.DETAILID));
+            elecreceiptDyn.set(BeiElecreceiptConstantInfo.BILLNO, transDetail.get(BeiTransdetailConstantInfo.BILLNO));
+            elecreceiptDyn.set(BeiElecreceiptConstantInfo.COMPANY, transDetail.get(BeiTransdetailConstantInfo.COMPANY));
+            elecreceiptDyn.set(BeiElecreceiptConstantInfo.ACCOUNTBANK, transDetail.get(BeiTransdetailConstantInfo.ACCOUNTBANK));
+            elecreceiptDyn.set(BeiElecreceiptConstantInfo.CURRENCY, transDetail.get(BeiTransdetailConstantInfo.CURRENCY));
+            elecreceiptDyn.set(BeiElecreceiptConstantInfo.BIZDATE, transDetail.get(BeiTransdetailConstantInfo.BIZDATE));
+            elecreceiptDyn.set(BeiElecreceiptConstantInfo.BIZTYPE, transDetail.get(BeiTransdetailConstantInfo.BIZTYPE));
+            elecreceiptDyn.set(BeiElecreceiptConstantInfo.DETAILDATETIME, transDetail.get(BeiTransdetailConstantInfo.BIZTIME));
+            elecreceiptDyn.set(BeiElecreceiptConstantInfo.DESCRIPTION, transDetail.get(BeiTransdetailConstantInfo.DESCRIPTION));
+            elecreceiptDyn.set(BeiElecreceiptConstantInfo.DEBITAMOUNT, transDetail.get(BeiTransdetailConstantInfo.DEBITAMOUNT));
+            elecreceiptDyn.set(BeiElecreceiptConstantInfo.CREDITAMOUNT, transDetail.get(BeiTransdetailConstantInfo.CREDITAMOUNT));
+            elecreceiptDyn.set(BeiElecreceiptConstantInfo.RECEIPTNO, transDetail.get(BeiTransdetailConstantInfo.RECEIPTNO));
+            if(transDetail.getBigDecimal(BeiTransdetailConstantInfo.DEBITAMOUNT).compareTo(BigDecimal.ZERO)>0){
+                elecreceiptDyn.set(BeiElecreceiptConstantInfo.AMOUNT, transDetail.get(BeiTransdetailConstantInfo.DEBITAMOUNT));
+                elecreceiptDyn.set(BeiElecreceiptConstantInfo.CREDITDEBITFLAG, "1");
+            }else{
+                elecreceiptDyn.set(BeiElecreceiptConstantInfo.AMOUNT, transDetail.get(BeiTransdetailConstantInfo.CREDITAMOUNT));
+                elecreceiptDyn.set(BeiElecreceiptConstantInfo.CREDITDEBITFLAG, "2"); // 借贷标记
+            }
+            elecreceiptDyn.set(BeiElecreceiptConstantInfo.OPPUNIT, transDetail.get(BeiTransdetailConstantInfo.OPPUNIT));
+            elecreceiptDyn.set(BeiElecreceiptConstantInfo.OPPBANK, transDetail.get(BeiTransdetailConstantInfo.OPPBANK));
+            elecreceiptDyn.set(BeiElecreceiptConstantInfo.OPPBANKNUMBER, transDetail.get(BeiTransdetailConstantInfo.OPPBANKNUMBER));
+            elecreceiptDyn.set(BeiElecreceiptConstantInfo.BILLSTATUS, transDetail.get(BeiTransdetailConstantInfo.BILLSTATUS));
+
+            DynamicObjectCollection entrys = elecreceiptDyn.getDynamicObjectCollection(BeiElecreceiptConstantInfo.MATCHDETAILENTRY);
+            DynamicObject entry = entrys.addNew();
+            entry.set("e_transdetailid",transDetail.getPkValue());
+
+            ///处理交易明细的分录
+            DynamicObjectCollection entrys1 = transDetail.getDynamicObjectCollection(BeiTransdetailConstantInfo.MATCHRECEIPTENTRY);
+            if(entrys1.size()<=0) {
+                DynamicObject entry1 = entrys1.addNew();
+                entry1.set("e_receiptid", Id);
+                entry1.set("e_receiptno", transDetail.get(BeiTransdetailConstantInfo.RECEIPTNO));
+            }
+
+        }
+
+        /**
+         * 地址格式:address="ftp:\\\\172.16.3.232\\Files\\12Qwee.pdf";
+         * 格式 :ftp://172.16.68.44:21/Files/CMB//791904936510302_20250422-20250422_365B261684797_C04474R0007ZOYZ.jpg
+         */
+        String address = electricAddress;
+        String filename = extractFilename(address);
+        elecreceiptDyn.set(BeiElecreceiptConstantInfo.UPLOADFILENAME,filename);//文件名称
+
+        address=address.split("Files")[1];
+        address=address.replace("\\", "/");
+        address="/Files"+address;
+        address=address.replace("//", "/");
+        elecreceiptDyn.set(BeiElecreceiptConstantInfo.FILEPATH,address);//电子回单路径
+
+        /**
+         * 处理文件上传
+         */
+
+        elecreceiptDyn.set(BeiElecreceiptConstantInfo.FILEFLAG, "1"); // 是否已上传
+
+        SaveServiceHelper.save(new DynamicObject[]{elecreceiptDyn});
+
+        return errMsg.toString();
+    }
+
+    public static String extractFilename(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);
+    }
+
+}