Jelajahi Sumber

Merge remote-tracking branch 'origin/dev' into dev

zk 2 tahun lalu
induk
melakukan
14bf2024fc
27 mengubah file dengan 752 tambahan dan 366 penghapusan
  1. 1 1
      pom.xml
  2. 65 44
      sckw-common/sckw-common-stream/src/main/java/com/sckw/stream/enums/MessageEnum.java
  3. 15 0
      sckw-modules-api/sckw-payment-api/src/main/java/com/sckw/payment/api/dubbo/PaymentDubboService.java
  4. 20 0
      sckw-modules-api/sckw-payment-api/src/main/java/com/sckw/payment/api/model/constant/ChannelEnum.java
  5. 2 0
      sckw-modules/sckw-message/src/main/java/com/sckw/message/model/dto/UserMsgCenterLatestMsgDTO.java
  6. 2 1
      sckw-modules/sckw-message/src/main/java/com/sckw/message/service/KwmMessageUserService.java
  7. 21 8
      sckw-modules/sckw-message/src/main/java/com/sckw/message/service/MessageService.java
  8. 1 1
      sckw-modules/sckw-message/src/main/resources/mapper/KwmMessageUserMapper.xml
  9. 5 5
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpSettlementWalletController.java
  10. 12 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/WalletController.java
  11. 7 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpLedgerTradeMapper.java
  12. 2 2
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/job/AsyncPool.java
  13. 5 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpSettlementWallet.java
  14. 3 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/constant/PayCenterEnum.java
  15. 5 2
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/wallet/PatchPay.java
  16. 64 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/wallet/Recharge.java
  17. 18 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/wallet/RechargePage.java
  18. 17 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/CashDetailReq.java
  19. 5 3
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/WalletDetailBase.java
  20. 228 231
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementWalletService.java
  21. 47 33
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/MessageSender.java
  22. 33 3
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/PayCenterService.java
  23. 75 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/WalletBusinessService.java
  24. 60 25
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/WalletService.java
  25. 35 4
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/dubbo/PaymentDubboServiceImpl.java
  26. 2 2
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerTradeMapper.xml
  27. 2 0
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementWalletMapper.xml

+ 1 - 1
pom.xml

@@ -354,7 +354,7 @@
                 <nacos.namespace>sckw-service-platform</nacos.namespace>
             </properties>
         </profile>
-        <!--测试环境-->
+        <!--生产环境-->
         <profile>
             <id>prod</id>
             <properties>

+ 65 - 44
sckw-common/sckw-common-stream/src/main/java/com/sckw/stream/enums/MessageEnum.java

@@ -1,8 +1,14 @@
 package com.sckw.stream.enums;
 
+import com.sckw.core.utils.CollectionUtils;
 import lombok.AllArgsConstructor;
 import lombok.Getter;
 
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
 /**
  * @author zk
  * @description 短信模板
@@ -108,38 +114,38 @@ public enum MessageEnum {
     /**
      * 合作申请待审核
      */
-    COOPERATE_WAIT_APPROVAL("BUSINESS", "COOPERATE_WAIT_APPROVAL", "合作申请待审核", "【${entName}】对贵司发起了企业合作申请,请前往确认","terminal,ios,android",""),
+    COOPERATE_WAIT_APPROVAL("BUSINESS", "COOPERATE_WAIT_APPROVAL", "合作申请待审核", "【${entName}】对贵司发起了企业合作申请,请前往确认", "terminal,ios,android", ""),
 
     /**
      * 合作申请审核通过
      */
-    COOPERATE_PASS("BUSINESS", "COOPERATE_PASS", "合作申请审核通过", "贵司发起的与【${entName}有限公司】的合作申请,已通过", "terminal,ios,android",""),
+    COOPERATE_PASS("BUSINESS", "COOPERATE_PASS", "合作申请审核通过", "贵司发起的与【${entName}有限公司】的合作申请,已通过", "terminal,ios,android", ""),
 
 
     /**
      * 合作申请审核驳回
      */
-    COOPERATE_REFUSED("BUSINESS", "COOPERATE_REFUSED", "合作申请审核驳回", "贵司发起的与【${entName}有限公司】的合作申请,已驳回,请及时确认", "terminal,ios,android",""),
+    COOPERATE_REFUSED("BUSINESS", "COOPERATE_REFUSED", "合作申请审核驳回", "贵司发起的与【${entName}有限公司】的合作申请,已驳回,请及时确认", "terminal,ios,android", ""),
 
     /**
      * 解除合作关系
      */
-    COOPERATE_DISSOLVE("BUSINESS", "COOPERATE_DISSOLVE", "解除合作关系", "贵司解除了与【${entName}】的合作关系,请及时通知合作单位;操作人:${createByName}", "terminal,ios,android",""),
+    COOPERATE_DISSOLVE("BUSINESS", "COOPERATE_DISSOLVE", "解除合作关系", "贵司解除了与【${entName}】的合作关系,请及时通知合作单位;操作人:${createByName}", "terminal,ios,android", ""),
 
     /**
      * 合作关系被解除
      */
-    COOPERATE_DISSOLVED("BUSINESS", "COOPERATE_DISSOLVED", "合作关系被解除", "【${entName}】解除了与贵司的合作关系,请及时联系合作范围并确认", "terminal,ios,android",""),
+    COOPERATE_DISSOLVED("BUSINESS", "COOPERATE_DISSOLVED", "合作关系被解除", "【${entName}】解除了与贵司的合作关系,请及时联系合作范围并确认", "terminal,ios,android", ""),
 
     /**
      * 恢复合作关系
      */
-    COOPERATE_RESTORE("BUSINESS", "COOPERATE_RESTORE", "恢复合作关系", "贵司恢复了与【${entName}有限公司】的合作关系,请及时通知合作单位;操作人:${createByName}", "terminal,ios,android",""),
+    COOPERATE_RESTORE("BUSINESS", "COOPERATE_RESTORE", "恢复合作关系", "贵司恢复了与【${entName}有限公司】的合作关系,请及时通知合作单位;操作人:${createByName}", "terminal,ios,android", ""),
 
     /**
      * 合作关系被恢复
      */
-    COOPERATE_RESTORED("BUSINESS", "COOPERATE_RESTORED", "合作关系被恢复", "【${entName}有限公司】恢复了与贵司的合作关系,请及时联系合作范围并确认", "terminal,ios,android",""),
+    COOPERATE_RESTORED("BUSINESS", "COOPERATE_RESTORED", "合作关系被恢复", "【${entName}有限公司】恢复了与贵司的合作关系,请及时联系合作范围并确认", "terminal,ios,android", ""),
 
     /**
      * 托运订单-发起物流托运
@@ -208,92 +214,92 @@ public enum MessageEnum {
      * 销售、采购对账
      */
     LEDGER_SELL("BUSINESS", "BUSINESS_LEDGER_SELL", "发起销售对账",
-            "贵司发起了对【${company}】的贸易对账,请留意后续消息;对账单号:${number},对账单名称:${name}", "terminal,ios,android",""),
+            "贵司发起了对【${company}】的贸易对账,请留意后续消息;对账单号:${number},对账单名称:${name}", "terminal,ios,android", ""),
     LEDGER_PURCHASE("BUSINESS", "BUSINESS_LEDGER_PURCHASE", "发起销售对账",
-            "【${company}】对贵司发起了贸易对账确认操作,请及时查看;对账单号:${number},对账单名称:${name}", "terminal,ios,android",""),
+            "【${company}】对贵司发起了贸易对账确认操作,请及时查看;对账单号:${number},对账单名称:${name}", "terminal,ios,android", ""),
     LEDGER_REVOCATION_SELL("BUSINESS", "BUSINESS_LEDGER_REVOCATION_SELL", "撤回对账",
-            "贵司撤回了与【${company}】的贸易对账,请及时确认并联系往来单位;对账单号:${number},对账单名称:${name}", "terminal,ios,android",""),
+            "贵司撤回了与【${company}】的贸易对账,请及时确认并联系往来单位;对账单号:${number},对账单名称:${name}", "terminal,ios,android", ""),
     LEDGER_REVOCATION_PURCHASE("BUSINESS", "BUSINESS_LEDGER_REVOCATION_PURCHASE", "撤回对账",
-            "贵司撤回了与【${company}】的贸易对账,请及时确认并联系往来单位;对账单号:${number},对账单名称:${name}", "terminal,ios,android",""),
+            "贵司撤回了与【${company}】的贸易对账,请及时确认并联系往来单位;对账单号:${number},对账单名称:${name}", "terminal,ios,android", ""),
 
     LEDGER_CONFIRM_SELL("BUSINESS", "BUSINESS_LEDGER_CONFIRM_SELL", "对账申请审核通过",
-            "贵司对【${company}】发起的贸易对账申请已审核通过,请及时确认;对账单号:${number},对账单名称:${name}", "terminal,ios,android",""),
+            "贵司对【${company}】发起的贸易对账申请已审核通过,请及时确认;对账单号:${number},对账单名称:${name}", "terminal,ios,android", ""),
     LEDGER_CONFIRM_PURCHASE("BUSINESS", "BUSINESS_LEDGER_CONFIRM_PURCHASE", "对账申请审核通过",
-            "【${company}】发起的对账申请,贵司已审核通过,请确认;对账单号:${number},对账单名称:${name}", "terminal,ios,android",""),
+            "【${company}】发起的对账申请,贵司已审核通过,请确认;对账单号:${number},对账单名称:${name}", "terminal,ios,android", ""),
 
     LEDGER_SUCCESS_SELL("BUSINESS", "BUSINESS_LEDGER_SUCCESS_SELL", "销售对账完成",
-            "贵司完成了与【${company}】的对账,系统生成了结算单,请及时确认;对账单号:${number},对账单名称:${name}", "terminal,ios,android",""),
+            "贵司完成了与【${company}】的对账,系统生成了结算单,请及时确认;对账单号:${number},对账单名称:${name}", "terminal,ios,android", ""),
     LEDGER_SUCCESS_PURCHASE("BUSINESS", "BUSINESS_LEDGER_SUCCESS_PURCHASE", "销售对账完成",
-            "【${company}】已完成对账流程,系统生成了结算单,请及时确认;对账单号:${number},对账单名称:${name}", "terminal,ios,android",""),
+            "【${company}】已完成对账流程,系统生成了结算单,请及时确认;对账单号:${number},对账单名称:${name}", "terminal,ios,android", ""),
 
     LEDGER_BACK_SELL("BUSINESS", "BUSINESS_LEDGER_BACK_SELL", "付款方驳回对账申请",
-            "贵司的贸易对账申请被【${company}】驳回,请及时查看;对账单号:${number},对账单名称:${name}", "terminal,ios,android",""),
+            "贵司的贸易对账申请被【${company}】驳回,请及时查看;对账单号:${number},对账单名称:${name}", "terminal,ios,android", ""),
     LEDGER_BACK_PURCHASE("BUSINESS", "BUSINESS_LEDGER_BACK_PURCHASE", "付款方驳回对账申请",
-            "贵司驳回了与【${company}】的贸易对账,请及时确认;对账单号:${number},对账单名称:${name}", "terminal,ios,android",""),
+            "贵司驳回了与【${company}】的贸易对账,请及时确认;对账单号:${number},对账单名称:${name}", "terminal,ios,android", ""),
     /**
      * 承运、托运对账
      */
     LEDGER_CARRIER("BUSINESS", "BUSINESS_LEDGER_CARRIER", "发起销售对账",
-            "贵司发起了对【${company}】的物流对账,请留意后续消息;对账单号:${number},对账单名称:${name}", "terminal,ios,android",""),
+            "贵司发起了对【${company}】的物流对账,请留意后续消息;对账单号:${number},对账单名称:${name}", "terminal,ios,android", ""),
     LEDGER_SHIPPER("BUSINESS", "BUSINESS_LEDGER_SHIPPER", "发起销售对账",
-            "【${company}】对贵司发起了物流对账确认操作,请及时查看;对账单号:${number},对账单名称:${name}", "terminal,ios,android",""),
+            "【${company}】对贵司发起了物流对账确认操作,请及时查看;对账单号:${number},对账单名称:${name}", "terminal,ios,android", ""),
     LEDGER_REVOCATION_CARRIER("BUSINESS", "BUSINESS_LEDGER_REVOCATION_CARRIER", "撤回对账",
-            "贵司撤回了与【${company}】的物流对账,请及时确认并联系往来单位;对账单号:${number},对账单名称:${name}", "terminal,ios,android",""),
+            "贵司撤回了与【${company}】的物流对账,请及时确认并联系往来单位;对账单号:${number},对账单名称:${name}", "terminal,ios,android", ""),
     LEDGER_REVOCATION_SHIPPER("BUSINESS", "BUSINESS_LEDGER_REVOCATION_SHIPPER", "撤回对账",
-            "【${company}】撤回了对贵司发起的物流对账申请,请及时确认;对账单号:${number},对账单名称:${name}", "terminal,ios,android",""),
+            "【${company}】撤回了对贵司发起的物流对账申请,请及时确认;对账单号:${number},对账单名称:${name}", "terminal,ios,android", ""),
 
     LEDGER_CONFIRM_CARRIER("BUSINESS", "BUSINESS_LEDGER_CONFIRM_CARRIER", "对账申请审核通过",
-            "贵司对【${company}】发起的物流对账申请已审核通过,请及时确认;对账单号:${number},对账单名称:${name}", "terminal,ios,android",""),
+            "贵司对【${company}】发起的物流对账申请已审核通过,请及时确认;对账单号:${number},对账单名称:${name}", "terminal,ios,android", ""),
     LEDGER_CONFIRM_SHIPPER("BUSINESS", "BUSINESS_LEDGER_CONFIRM_SHIPPER", "对账申请审核通过",
-            "【${company}】发起的对账申请,贵司已审核通过,请确认;对账单号:${number},对账单名称:${name}", "terminal,ios,android",""),
+            "【${company}】发起的对账申请,贵司已审核通过,请确认;对账单号:${number},对账单名称:${name}", "terminal,ios,android", ""),
 
     LEDGER_SUCCESS_CARRIER("BUSINESS", "BUSINESS_LEDGER_SUCCESS_CARRIER", "销售对账完成",
-            "贵司完成了与【${company}】的对账,系统生成了结算单,请及时确认;对账单号:${number},对账单名称:${name}", "terminal,ios,android",""),
+            "贵司完成了与【${company}】的对账,系统生成了结算单,请及时确认;对账单号:${number},对账单名称:${name}", "terminal,ios,android", ""),
     LEDGER_SUCCESS_SHIPPER("BUSINESS", "BUSINESS_LEDGER_SUCCESS_SHIPPER", "销售对账完成",
-            "【${company}】已完成对账流程,系统生成了结算单,请及时确认;对账单号:${number},对账单名称:${name}", "terminal,ios,android",""),
+            "【${company}】已完成对账流程,系统生成了结算单,请及时确认;对账单号:${number},对账单名称:${name}", "terminal,ios,android", ""),
 
     LEDGER_BACK_CARRIER("BUSINESS", "BUSINESS_LEDGER_BACK_CARRIER", "付款方驳回对账申请",
-            "贵司的物流对账申请被【${company}】驳回,请及时查看;对账单号:${number},对账单名称:${name}", "terminal,ios,android",""),
+            "贵司的物流对账申请被【${company}】驳回,请及时查看;对账单号:${number},对账单名称:${name}", "terminal,ios,android", ""),
     LEDGER_BACK_SHIPPER("BUSINESS", "BUSINESS_LEDGER_BACK_SHIPPER", "付款方驳回对账申请",
-            "贵司驳回了与【${company}】的物流对账,请及时确认;对账单号:${number},对账单名称:${name}", "terminal,ios,android",""),
+            "贵司驳回了与【${company}】的物流对账,请及时确认;对账单号:${number},对账单名称:${name}", "terminal,ios,android", ""),
 
     /**
      * 销售、采购结算
      */
     //确认对账
     SETTLEMENT_SELL("BUSINESS", "SETTLEMENT_SELL", "新增销售结算任务",
-            "贵司有一条新增的结算业务,请及时查看;【${company}】;结算单号:${number}", "terminal,ios,android",""),
+            "贵司有一条新增的结算业务,请及时查看;【${company}】;结算单号:${number}", "terminal,ios,android", ""),
     SETTLEMENT_PURCHASE("BUSINESS", "SETTLEMENT_PURCHASE", "新增采购结算任务",
-            "贵司有一条新增的结算业务,请及时查看;【${company}】;结算单号:${number}", "terminal,ios,android",""),
+            "贵司有一条新增的结算业务,请及时查看;【${company}】;结算单号:${number}", "terminal,ios,android", ""),
     //确认收款
     SETTLEMENT_CONFIRM_SELL("BUSINESS", "SETTLEMENT_CONFIRM_SELL", "销售结算确认收款",
-            "贵司对一条结算单进行了确认收款操作,请及时确认;结算单号:${number}", "terminal,ios,android",""),
+            "贵司对一条结算单进行了确认收款操作,请及时确认;结算单号:${number}", "terminal,ios,android", ""),
     SETTLEMENT_CONFIRM_PURCHASE("BUSINESS", "SETTLEMENT_CONFIRM_PURCHASE", "采购结算确认收款",
-            "【${company}】与贵司的一条结算业务已确认收款,请及时确认;结算单号:${number}", "terminal,ios,android",""),
+            "【${company}】与贵司的一条结算业务已确认收款,请及时确认;结算单号:${number}", "terminal,ios,android", ""),
     //发起付款
     SETTLEMENT_START_SELL("BUSINESS", "SETTLEMENT_START_SELL", "销售付款被发起",
-            "【${company}】发起了对贵司的付款操作,请及时联系付款方进行确认;结算单号:${number}", "terminal,ios,android",""),
+            "【${company}】发起了对贵司的付款操作,请及时联系付款方进行确认;结算单号:${number}", "terminal,ios,android", ""),
     SETTLEMENT_START_PURCHASE("BUSINESS", "SETTLEMENT_START_PURCHASE", "发起采购付款",
-            "贵司已发起了对【${company}】的付款操作,请及时确认并联系收款单位;结算单号:${number}", "terminal,ios,android",""),
+            "贵司已发起了对【${company}】的付款操作,请及时确认并联系收款单位;结算单号:${number}", "terminal,ios,android", ""),
 
     /**
      * 承运、托运结算
      */
     //确认对账
     SETTLEMENT_CARRIER("BUSINESS", "SETTLEMENT_CARRIER", "新增承运结算任务",
-            "贵司有一条新增的结算业务,请及时查看;【${company}】;结算单号:${number}", "terminal,ios,android",""),
+            "贵司有一条新增的结算业务,请及时查看;【${company}】;结算单号:${number}", "terminal,ios,android", ""),
     SETTLEMENT_SHIPPER("BUSINESS", "SETTLEMENT_SHIPPER", "新增托运结算任务",
-            "贵司有一条新增的结算业务,请及时查看;【${company}】;结算单号:${number}", "terminal,ios,android",""),
+            "贵司有一条新增的结算业务,请及时查看;【${company}】;结算单号:${number}", "terminal,ios,android", ""),
     //确认收款
     SETTLEMENT_CONFIRM_CARRIER("BUSINESS", "SETTLEMENT_CONFIRM_CARRIER", "承运结算确认收款",
-            "贵司对一条结算单进行了确认收款操作,请及时确认;结算单号:${number}", "terminal,ios,android",""),
+            "贵司对一条结算单进行了确认收款操作,请及时确认;结算单号:${number}", "terminal,ios,android", ""),
     SETTLEMENT_CONFIRM_SHIPPER("BUSINESS", "SETTLEMENT_CONFIRM_SHIPPER", "托运结算确认收款",
-            "【${company}】与贵司的一条结算业务已确认收款,请及时确认;结算单号:${number}", "terminal,ios,android",""),
+            "【${company}】与贵司的一条结算业务已确认收款,请及时确认;结算单号:${number}", "terminal,ios,android", ""),
     //发起付款
     SETTLEMENT_START_CARRIER("BUSINESS", "SETTLEMENT_START_CARRIER", "承运付款被发起",
-            "【${company}】发起了对贵司的付款操作,请及时联系付款方进行确认;结算单号:${number}", "terminal,ios,android",""),
+            "【${company}】发起了对贵司的付款操作,请及时联系付款方进行确认;结算单号:${number}", "terminal,ios,android", ""),
     SETTLEMENT_START_SHIPPER("BUSINESS", "SETTLEMENT_START_SHIPPER", "发起托运付款",
-            "贵司已发起了对【${company}】的付款操作,请及时确认并联系收款单位;结算单号:${number}", "terminal,ios,android",""),
+            "贵司已发起了对【${company}】的付款操作,请及时确认并联系收款单位;结算单号:${number}", "terminal,ios,android", ""),
 
     /**
      * 合同-销售合同、托运合同  补充合同
@@ -304,12 +310,12 @@ public enum MessageEnum {
     /**
      * 完结合同
      */
-    SAELCONTRACT_COMPLETE_CONTRACT("BUSINESS", "SAELCONTRACT_COMPLETE_CONTRACT", "完结合同","贵司已完结了与【${entName}】间的签约合同,请及时通知合作单位;合同编号:${contract_no},合同名称:${name}", "terminal,ios,android", ""),
+    SAELCONTRACT_COMPLETE_CONTRACT("BUSINESS", "SAELCONTRACT_COMPLETE_CONTRACT", "完结合同", "贵司已完结了与【${entName}】间的签约合同,请及时通知合作单位;合同编号:${contract_no},合同名称:${name}", "terminal,ios,android", ""),
 
     /**
      * 发起
      */
-    SAELCONTRACT_SEND_CONTRACT("BUSINESS", "SAELCONTRACT_SEND_CONTRACT", "发起合同签约","贵司新建了合同并发起与【${entName}】的合同签约流程,请留意电话短信;合同编号:${contract_no},合同名称:${name}", "terminal,ios,android", ""),
+    SAELCONTRACT_SEND_CONTRACT("BUSINESS", "SAELCONTRACT_SEND_CONTRACT", "发起合同签约", "贵司新建了合同并发起与【${entName}】的合同签约流程,请留意电话短信;合同编号:${contract_no},合同名称:${name}", "terminal,ios,android", ""),
 
     /**
      * 合同签约成功
@@ -340,9 +346,6 @@ public enum MessageEnum {
     ;
 
 
-
-
-
     /**
      * 消息分类:BUSINESS业务消息,SYSTEM系统消息
      */
@@ -409,4 +412,22 @@ public enum MessageEnum {
         }
         return null;
     }
+
+    public static List<MessageEnum> getEnums(Boolean isMain, Integer length, Set<MessageEnum> excludeEnums) {
+        List<MessageEnum> list = Arrays.stream(MessageEnum.values())
+                .filter(e -> CollectionUtils.isEmpty(excludeEnums) || !excludeEnums.contains(e))
+                .filter(e -> Boolean.TRUE.equals(isMain) || "BUSINESS".equals(e.getCategory()))
+                .limit(length)
+                .collect(Collectors.toList());
+        return CollectionUtils.emptyIfNull(list);
+    }
+
+    public static MessageEnum getEnumByCategoryAndType(String category, String type) {
+        for (MessageEnum e : MessageEnum.values()) {
+            if (e.getCategory().equals(category) && e.getType().equals(type)) {
+                return e;
+            }
+        }
+        return null;
+    }
 }

+ 15 - 0
sckw-modules-api/sckw-payment-api/src/main/java/com/sckw/payment/api/dubbo/PaymentDubboService.java

@@ -1,13 +1,28 @@
 package com.sckw.payment.api.dubbo;
 
+import com.sckw.core.web.response.HttpResult;
+import com.sckw.payment.api.model.constant.ChannelEnum;
 import com.sckw.payment.api.model.constant.OrderEnum;
 import com.sckw.payment.api.model.dto.LedgerCount;
 import com.sckw.payment.api.model.dto.SettlementMoney;
 
+import java.math.BigDecimal;
 import java.util.List;
 import java.util.Map;
 
 public interface PaymentDubboService {
+    /**
+     * 销售订单下单时,冻结资金
+     *
+     * @param payEntId     支付方企业
+     * @param channel      渠道
+     * @param receiveEntId 收款企业id
+     * @param money        订单金额
+     * @param tOrderId     贸易订单id
+     * @return
+     */
+    HttpResult freezeMoney(Long payEntId, ChannelEnum channel, Long receiveEntId, BigDecimal money, Long tOrderId);
+
     /**
      * 确认企业关联的对账单是否存在关联业务
      *

+ 20 - 0
sckw-modules-api/sckw-payment-api/src/main/java/com/sckw/payment/api/model/constant/ChannelEnum.java

@@ -2,6 +2,7 @@ package com.sckw.payment.api.model.constant;
 
 import lombok.AllArgsConstructor;
 import lombok.Getter;
+import org.apache.commons.lang3.StringUtils;
 
 @Getter
 @AllArgsConstructor
@@ -22,6 +23,24 @@ public enum ChannelEnum {
     private final String channel;
     private final String desc;
 
+    /**
+     * 通过交易方式获取支付渠道
+     * @param trading 交易方式字典
+     * @return
+     */
+    public static ChannelEnum getByTrading(String trading) {
+        //长度为1 表示线下付款
+        if (StringUtils.isBlank(trading) || trading.length() <= 1) {
+            return null;
+        }
+        String channel = trading.substring(1, 2);
+        for (ChannelEnum channelEnum : ChannelEnum.values()) {
+            if (channelEnum.getValue().equals(channel)) {
+                return channelEnum;
+            }
+        }
+        return null;
+    }
     public static ChannelEnum getByCode(String code) {
         for (ChannelEnum channelEnum : ChannelEnum.values()) {
             if (channelEnum.getCode().equals(code)) {
@@ -63,6 +82,7 @@ public enum ChannelEnum {
 
     /**
      * 通过渠道获取字典值
+     *
      * @param channel
      * @return
      */

+ 2 - 0
sckw-modules/sckw-message/src/main/java/com/sckw/message/model/dto/UserMsgCenterLatestMsgDTO.java

@@ -29,6 +29,8 @@ public class UserMsgCenterLatestMsgDTO implements Serializable {
      */
     private Integer status;
 
+    private String category;
+
     /**
      * 消息分类
      */

+ 2 - 1
sckw-modules/sckw-message/src/main/java/com/sckw/message/service/KwmMessageUserService.java

@@ -163,7 +163,8 @@ public class KwmMessageUserService {
      * @return: java.util.List<com.sckw.message.model.vo.res.UserMsgCenterResVO>
      */
     public List<UserMsgCenterResVO> userMsgCenter(UserMsgCenterReqDTO dto) {
-        return kwmMessageUserMapper.userMsgCenter(dto);
+        List<UserMsgCenterResVO> list = kwmMessageUserMapper.userMsgCenter(dto);
+        return CollectionUtils.emptyIfNull(list);
     }
 
     /**

+ 21 - 8
sckw-modules/sckw-message/src/main/java/com/sckw/message/service/MessageService.java

@@ -25,6 +25,7 @@ import com.sckw.message.model.vo.req.StatisticsMessagesReqVO;
 import com.sckw.message.model.vo.res.KwmMessageListResVO;
 import com.sckw.message.model.vo.res.MessagesStatisticsResVO;
 import com.sckw.message.model.vo.res.UserMsgCenterResVO;
+import com.sckw.stream.enums.MessageEnum;
 import com.sckw.system.api.RemoteSystemService;
 import com.sckw.system.api.model.dto.res.EntCacheResDto;
 import com.sckw.system.api.model.dto.res.UserCacheResDto;
@@ -279,15 +280,13 @@ public class MessageService {
      */
     public List<UserMsgCenterResVO> userMsgCenter() {
         UserMsgCenterReqDTO dto = new UserMsgCenterReqDTO();
-        if (Objects.equals(LoginUserHolder.getIsMain(), 1)) {
-            dto.setEntId(LoginUserHolder.getEntId());
-        } else {
-            dto.setUserId(LoginUserHolder.getUserId());
-        }
+        boolean isMain = Objects.equals(LoginUserHolder.getIsMain(), 1);
+        dto.setEntId(isMain ? LoginUserHolder.getEntId() : null);
+        dto.setUserId(isMain ? null : LoginUserHolder.getUserId());
         List<UserMsgCenterResVO> result = kwmMessageUserService.userMsgCenter(dto);
-        if (CollectionUtils.isEmpty(result)) {
-            return Collections.emptyList();
-        }
+        int size = result.size();
+        boolean flag = size < 5;
+        Set<MessageEnum> excludeEnums = new HashSet<>();
         String clientType = LoginUserHolder.getClientType();
         result.forEach(e -> {
             dto.setStatus(e.getStatus()).setType(e.getType());
@@ -299,7 +298,21 @@ public class MessageService {
             e.setId(msg.getId()).setTitle(msg.getTitle())
                     .setContent(msg.getContent())
                     .setCreateTime(msg.getCreateTime());
+            if (flag) {
+                MessageEnum messageEnum = MessageEnum.getEnumByCategoryAndType(msg.getCategory(), msg.getType());
+                if (Objects.nonNull(messageEnum)) {
+                    excludeEnums.add(messageEnum);
+                }
+            }
         });
+        if (flag) {
+            List<MessageEnum> enums = MessageEnum.getEnums(isMain, 5 - size, excludeEnums);
+            enums.forEach(e -> {
+                UserMsgCenterResVO vo = new UserMsgCenterResVO();
+                vo.setTitle(e.getTitle()).setContent("暂无" + e.getTitle());
+                result.add(vo);
+            });
+        }
         return result;
     }
 }

+ 1 - 1
sckw-modules/sckw-message/src/main/resources/mapper/KwmMessageUserMapper.xml

@@ -58,7 +58,7 @@
     <select id="getLatestMsg" resultType="com.sckw.message.model.dto.UserMsgCenterLatestMsgDTO">
         SELECT
         mu.id, mu.status, mu.create_time as createTime,
-        m.type, m.title, m.content, m.url
+        m.category, m.type, m.title, m.content, m.url
         FROM
         kwm_message_user mu
         LEFT JOIN kwm_message m ON mu.msg_id = m.id

+ 5 - 5
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpSettlementWalletController.java

@@ -36,11 +36,11 @@ public class KwpSettlementWalletController {
         return HttpResult.ok(kwpSettlementWalletService.pageListLogisticsPayment(settlementWalletReq));
     }
 
-    @GetMapping(name = "物流-电子钱包付款(货到付款)结算记录-详情", path = "detailLogisticsPayment")
-    public HttpResult detailLogisticsPayment(@RequestParam("id") Long id) {
-//        return HttpResult.ok(kwpSettlementWalletService.detailLogisticsPayment(id));
-        return HttpResult.ok(null);
-    }
+//    @GetMapping(name = "物流-电子钱包付款(货到付款)结算记录-详情", path = "detailLogisticsPayment")
+//    public HttpResult detailLogisticsPayment(@RequestParam("id") Long id) {
+////        return HttpResult.ok(kwpSettlementWalletService.detailLogisticsPayment(id));
+//        return HttpResult.ok(null);
+//    }
 
     /**
      * @author Aick Spt

+ 12 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/WalletController.java

@@ -348,6 +348,18 @@ public class WalletController {
         return HttpResult.ok(walletService.cashOrder(moneyPage));
     }
 
+    /*提现-详细记录*/
+
+    /**
+     * 提现
+     *
+     * @param cashDetailReq
+     * @return
+     */
+    @PostMapping("cashDetail")
+    public HttpResult cashDetail(@RequestBody @Valid CashDetailReq cashDetailReq) {
+        return HttpResult.ok(walletService.cashDetail(cashDetailReq));
+    }
     /*预付-详细记录*/
 
     /**

+ 7 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpLedgerTradeMapper.java

@@ -65,6 +65,13 @@ public interface KwpLedgerTradeMapper extends BaseMapper<KwpLedgerTrade> {
 
     List<LedgerPurchaseDto> selectPurchaseIds(@Param("ids") List<Long> ids);
 
+    /**
+     * app端对账统计
+     *
+     * @param tradeReq
+     * @param status
+     * @return
+     */
     LedgerCountSumVo countSum(@Param("tradeReq") TradeReq tradeReq, @Param("status") List<Integer> status);
 
     void updatePrice(@Param("id") Long id, @Param("totalPrice") BigDecimal totalPrice);

+ 2 - 2
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/job/AsyncPool.java

@@ -23,8 +23,8 @@ public class AsyncPool {
     }
 
     private static class ThreadPool {
-        public static final ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(2,
-                2,
+        public static final ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(Runtime.getRuntime().availableProcessors() / 2,
+                Runtime.getRuntime().availableProcessors() / 2 + 1,
                 1,
                 TimeUnit.MINUTES,
                 new LinkedBlockingQueue<>(12));

+ 5 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpSettlementWallet.java

@@ -36,6 +36,11 @@ public class KwpSettlementWallet {
      */
     @TableField(value = "ent_id")
     private Long entId;
+    /**
+     * 中台流水号
+     */
+    @TableField(value = "order_no")
+    private String orderNo;
 
     /**
      * 结算id(交易订单结算/物流订单结算)

+ 3 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/constant/PayCenterEnum.java

@@ -14,7 +14,8 @@ public enum PayCenterEnum {
     MEMBER_WALLET("/v1/member/wallet", "钱包清单"),
     MEMBER_WALLET_V2("/v2/member/wallet", "钱包清单v2"),
     MEMBER_GENERAL("/v2/wallet/general", "总览信息"),
-    WITHDRAW_DETAIL("/v1/wallet/withdraw/detail", "提现详情"),
+    WITHDRAW_DETAIL("/v2/wallet/withdraw/detail", "提现详情"),
+    //    WITHDRAW_DETAIL("/v1/wallet/withdraw/detail", "提现详情"), 原接口
     //    WITHDRAW_INDEX("/v1/wallet/withdraw/index", "提现清单"), 原接口
     WITHDRAW_INDEX("/v2/wallet/withdraw/index", "提现清单"),
     WITHDRAW_CATEGORY("/v2/wallet/withdraw/categories", "提现清单分类"),
@@ -40,6 +41,7 @@ public enum PayCenterEnum {
     MEMBER_PAY_INDEX("/v1/member/pay/index", "订单记录"),
     MEMBER_INDEX("/v1/member/index", "创建/更新账户"),
     PAY_INDEX("/v1/pay/index", "在线充值"),
+    RECHARGE_ORDER("/v2/wallet/recharge/orders", "充值记录清单"),
     WALLET_FREEZE("/v1/wallet/freeze", "冻结资金"),
     WALLET_UNFREEZE("/v1/wallet/unfreeze", "解冻金额"),
     PAY_AGENT_PAY("/v1/pay/agent_pay", "清分"),

+ 5 - 2
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/wallet/PatchPay.java

@@ -1,7 +1,7 @@
 package com.sckw.payment.model.dto.wallet;
 
 import com.alibaba.fastjson.annotation.JSONField;
-import lombok.Data;
+import lombok.*;
 
 import java.io.Serial;
 import java.io.Serializable;
@@ -10,7 +10,10 @@ import java.io.Serializable;
  * @author xucaiqin
  * @date 2023-07-25 17:09:42
  */
-@Data
+@Getter
+@Setter
+@AllArgsConstructor
+@NoArgsConstructor
 public class PatchPay implements Serializable {
     @Serial
     private static final long serialVersionUID = -719246443006291337L;

+ 64 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/wallet/Recharge.java

@@ -0,0 +1,64 @@
+package com.sckw.payment.model.dto.wallet;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+@Getter
+@Setter
+public class Recharge implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 5266898999492496164L;
+    @JSONField(name = "uid")
+    private String uid;
+
+    @JSONField(name = "order_no")
+    private String orderNo;
+
+    @JSONField(name = "status")
+    private int status;
+
+    @JSONField(name = "status_label")
+    private String statusLabel;
+
+
+    @JSONField(name = "channel")
+    private String channel;
+
+    @JSONField(name = "channel_label")
+    private String channelLabel;
+    /**
+     * 往来单位uid
+     */
+    @JSONField(name = "filter")
+    private String filter;
+
+    /**
+     * 充值金额
+     */
+    @JSONField(name = "money")
+    private BigDecimal money;
+    /**
+     * 充值到账后余额
+     */
+    @JSONField(name = "after_money")
+    private BigDecimal afterMoney;
+
+    @JSONField(name = "remarks")
+    private String remarks;
+    /**
+     * 订单提交时间
+     */
+    @JSONField(name = "create_time")
+    private String createTime;
+    /**
+     * 支付完成时间
+     */
+    @JSONField(name = "pay_time")
+    private String payTime;
+}

+ 18 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/wallet/RechargePage.java

@@ -0,0 +1,18 @@
+package com.sckw.payment.model.dto.wallet;
+
+import com.sckw.payment.model.dto.common.Page;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serial;
+
+/**
+ * @author xucaiqin
+ * @date 2023-07-25 16:30:37
+ */
+@Getter
+@Setter
+public class RechargePage extends Page<Recharge> {
+    @Serial
+    private static final long serialVersionUID = 8527382562920050885L;
+}

+ 17 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/CashDetailReq.java

@@ -0,0 +1,17 @@
+package com.sckw.payment.model.vo.req;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 详细记录提现
+ *
+ * @author xucaiqin
+ * @date 2023-09-20 10:16:12
+ */
+@Getter
+@Setter
+public class CashDetailReq {
+    private String uid;
+    private String orderNo;
+}

+ 5 - 3
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/WalletDetailBase.java

@@ -15,7 +15,7 @@ import java.time.LocalDateTime;
  */
 @Getter
 @Setter
-public class WalletDetailBase {
+public class WalletDetailBase implements MoneyChange {
     /**
      * 业务流水号
      */
@@ -49,6 +49,8 @@ public class WalletDetailBase {
     /**
      * 创建时间
      */
-    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
-    private LocalDateTime createTime;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private String createTime;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private String payTime;
 }

+ 228 - 231
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementWalletService.java

@@ -7,10 +7,14 @@ import com.sckw.core.common.enums.NumberConstant;
 import com.sckw.core.common.enums.enums.DictEnum;
 import com.sckw.core.exception.BusinessException;
 import com.sckw.core.model.constant.Global;
+import com.sckw.core.model.enums.LogisticsOrderEnum;
 import com.sckw.core.model.page.PageRes;
 import com.sckw.core.utils.IdWorker;
+import com.sckw.core.utils.OrderUtils;
 import com.sckw.core.utils.StringUtils;
+import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.context.LoginUserHolder;
+import com.sckw.core.web.response.HttpResult;
 import com.sckw.order.api.dubbo.TradeOrderInfoService;
 import com.sckw.order.api.model.UpdateOrderStatusParam;
 import com.sckw.payment.api.model.constant.ChannelEnum;
@@ -37,6 +41,7 @@ import com.sckw.stream.enums.MessageEnum;
 import com.sckw.system.api.RemoteSystemService;
 import com.sckw.system.api.model.dto.res.UserCacheResDto;
 import com.sckw.transport.api.dubbo.TransportDubboService;
+import com.sckw.transport.api.model.param.LogisticsOrderParam;
 import io.seata.spring.annotation.GlobalTransactional;
 import jakarta.annotation.Resource;
 import lombok.RequiredArgsConstructor;
@@ -44,16 +49,12 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 import java.math.BigDecimal;
 import java.text.DecimalFormat;
 import java.time.LocalDateTime;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -68,7 +69,9 @@ public class KwpSettlementWalletService {
     private final KwpSettlementWalletMapper settlementWalletMapper;
     private final KwpSettlementLogisticsMapper kwpSettlementLogisticsMapper;
     private final KwpLedgerTradeOrderService tradeOrderService;
+    private final KwpLedgerLogisticsOrderService kwpLedgerLogisticsOrderService;
     private final KwpSettlementLogisticsService kwpSettlementLogisticsService;
+    private final WalletBusinessService walletBusinessService;
     @Resource
     private KwpSettlementTradeService kwpSettlementTradeService;
     private final PayCenterService payCenterService;
@@ -165,7 +168,7 @@ public class KwpSettlementWalletService {
      * <p>
      * Transactional// isolation:事务的隔离级别,此处使用后端数据库的默认隔离级别, propagation: 如果当前没有事务,就新建一个事务,如果已经存在一个事务中,加入到这个事务中(常见)。(rollbackFor = Exception.class, isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
      */
-    @Transactional
+    @GlobalTransactional(rollbackFor = Exception.class, name = "default_tx_group")
     public Integer confirmLogisticsPayment(OfflinePaymentReq offlinePaymentReq) {
         Long id = offlinePaymentReq.getIdLong();
         BigDecimal price = offlinePaymentReq.getPrice();
@@ -175,7 +178,6 @@ public class KwpSettlementWalletService {
         if (price == null || price.compareTo(BigDecimal.ZERO) == 0) {
             throw new BusinessException("结算参数金额必填");
         }
-
         //先查询出结算单情况
         SettlementLogisticsDto settlementLogisticsDto = kwpSettlementLogisticsService.detailPayment(id);
         //检查结算单状态和所差金额
@@ -198,114 +200,149 @@ public class KwpSettlementWalletService {
             log.error("本次结算输入金额比剩余付款金额大:ID:" + id + " 剩余金额:" + remainingReceivables + " 本次输入金额:" + price);
             throw new BusinessException("参数错误:输入金额过大 " + price + " 剩余金额最大值:" + remainingReceivables);
         }
-        //累加入库结算单
-        KwpSettlementLogistics settlementLogistics = new KwpSettlementLogistics();
-        settlementLogistics.setId(settlementLogisticsDto.getId());
-        settlementLogistics.setUpdateTime(LocalDateTime.now());
-        //全部结算
-        if (remainingReceivables.compareTo(price) == 0) {
-            settlementLogistics.setStatus(SettlementEnum.ALL_PAYMENT.getStatus());
-        }
-        //部分结算
-        if (remainingReceivables.compareTo(price) > 0) {
-            settlementLogistics.setStatus(SettlementEnum.PARTIAL_PAYMENT.getStatus());
-        }
-        BigDecimal actualPrice = settlementLogisticsDto.getActualPrice();
-        settlementLogistics.setActualPrice((actualPrice == null) ? price : actualPrice.add(price));
-        int upInt = kwpSettlementLogisticsMapper.updateById(settlementLogistics);
-        if (upInt > 0) {
-            //新增一条修改记录
-            String remark = LoginUserHolder.getUserName() + "[" + LoginUserHolder.getUserId() + "]" + "结算[" + settlementLogistics.getId() + "]" + settlementLogistics.getActualPrice() + "(" + SettlementEnum.getStatusDesc(settlementLogistics.getStatus()) + ")";
-            KwpSettlementLogisticsTrack kwpSettlementLogisticsTrack = new KwpSettlementLogisticsTrack();
-            kwpSettlementLogisticsTrack.setId(new IdWorker(1).nextId());
-            kwpSettlementLogisticsTrack.setLSettlementId(settlementLogistics.getId());
-            kwpSettlementLogisticsTrack.setRemark(remark);
-            kwpSettlementLogisticsTrack.setStatus(settlementLogistics.getStatus());
-            kwpSettlementLogisticsTrack.setCreateBy(LoginUserHolder.getUserId());
-            kwpSettlementLogisticsTrack.setCreateTime(LocalDateTime.now());
-            kwpSettlementLogisticsTrack.setUpdateBy(LoginUserHolder.getUserId());
-            kwpSettlementLogisticsTrack.setUpdateTime(LocalDateTime.now());
-            kwpSettlementLogisticsTrack.setDelFlag(0);
-            kwpSettlementLogisticsTrackMapper.insert(kwpSettlementLogisticsTrack);
-
-            //新增一条电子钱包结算记录
-            remainingReceivables = remainingReceivables.subtract(price);
-            KwpSettlementWallet kwpSettlementWallet = new KwpSettlementWallet();
-            kwpSettlementWallet.setId(new IdWorker(1).nextId());
-            kwpSettlementWallet.setEntId(settlementLogisticsDto.getEntId());
-            kwpSettlementWallet.setSettlementId(settlementLogisticsDto.getId());
-            kwpSettlementWallet.setOrderType(SettlementOrderTypeEnum.LOGISTICS.getStatus());
-            //先用数字默认定义为1
-            kwpSettlementWallet.setChannel(WalletChannelEnum.getValue(settlementLogisticsDto.getTrading()));
-            kwpSettlementWallet.setPayTime(LocalDateTime.now());
-            kwpSettlementWallet.setPayPrice(price);
-            kwpSettlementWallet.setTopayPrice(remainingReceivables);
-            kwpSettlementWallet.setType(SettlementPayTypeEnum.CASH_ON_DELIVERY.getStatus());
-            kwpSettlementWallet.setRemark(Global.EMPTY_STRING);
-            kwpSettlementWallet.setStatus(1);
-            kwpSettlementWallet.setCreateBy(LoginUserHolder.getUserId());
-            kwpSettlementWallet.setCreateTime(LocalDateTime.now());
-            kwpSettlementWallet.setUpdateBy(LoginUserHolder.getUserId());
-            kwpSettlementWallet.setUpdateTime(LocalDateTime.now());
-            kwpSettlementWallet.setDelFlag(0);
-            Integer insertKwpSettlementWallet = settlementWalletMapper.insert(kwpSettlementWallet);
-            log.info("新增一条电子钱包结算记录:" + insertKwpSettlementWallet);
-            //需要将金额同步到对应的对账表中
-            KwpLedgerLogistics kwpLedgerLogistics = new KwpLedgerLogistics();
-            kwpLedgerLogistics.setId(settlementLogisticsDto.getLLedgerId());
-            kwpLedgerLogistics.setActualPrice(settlementLogistics.getActualPrice());
-            kwpLedgerLogisticsMapper.updateById(kwpLedgerLogistics);
-
-            //物流货到付款电子钱包逻辑
-            //todo 待处理费电子钱包逻辑
-
-            return insertKwpSettlementWallet;
-        }
-
         //托运方
         KwpLedgerLogisticsUnit logisticsUnit = logisticsUnitService.queryCustomerEnt(settlementLogisticsDto.getLLedgerId(), LogisticsUnitType.SHIPPER);
-        //承运方
+        //承运方(对账发起方,收钱方)
         KwpLedgerLogisticsUnit logisticsUnit2 = logisticsUnitService.queryCustomerEnt(settlementLogisticsDto.getLLedgerId(), LogisticsUnitType.CARRIER);
-
-        //推送双方系统管理员
-        messageSender.sendManager(LoginUserHolder.getUserId(), new HashMap<>() {{
-            put("company", logisticsUnit.getFirmName());
-            put("number", settlementLogisticsDto.getSlOrderNo());
-        }}, logisticsUnit2.getEntId(), MessageEnum.SETTLEMENT_START_CARRIER);
-        messageSender.sendManager(LoginUserHolder.getUserId(), new HashMap<>() {{
-            put("company", logisticsUnit2.getFirmName());
-            put("number", settlementLogisticsDto.getSlOrderNo());
-        }}, logisticsUnit.getEntId(), MessageEnum.SETTLEMENT_START_SHIPPER);
+        String uid = walletRelationService.getRelation(logisticsUnit.getTopEntId());
+        if (StringUtils.isBlank(uid)) {
+            throw new BusinessException("我方单位暂未开通电子钱包");
+        }
+        String filter = walletRelationService.getRelation(logisticsUnit2.getTopEntId());
+        if (StringUtils.isBlank(filter)) {
+            throw new BusinessException("客户单位暂未开通电子钱包");
+        }
+        String trading = settlementLogisticsDto.getTrading();
+        ChannelEnum channelEnum = ChannelEnum.getByTrading(trading);
+        if (Objects.isNull(channelEnum)) {
+            throw new BusinessException("交易方式异常");
+        }
+        //加锁
+        String key = String.format(RedisConstant.SETTLEMENT_KEY, offlinePaymentReq.getId());
+        if (redisLockUtil.tryLock(key)) {
+            try {
+                //钱包余额校验
+                walletBusinessService.checkMoney(uid, filter, channelEnum, price);
+                //累加入库结算单
+                KwpSettlementLogistics settlementLogistics = new KwpSettlementLogistics();
+                settlementLogistics.setId(settlementLogisticsDto.getId());
+                settlementLogistics.setUpdateTime(LocalDateTime.now());
+                //全部结算
+                if (remainingReceivables.compareTo(price) == 0) {
+                    settlementLogistics.setStatus(SettlementEnum.ALL_PAYMENT.getStatus());
+                }
+                //部分结算
+                if (remainingReceivables.compareTo(price) > 0) {
+                    settlementLogistics.setStatus(SettlementEnum.PARTIAL_PAYMENT.getStatus());
+                }
+                BigDecimal actualPrice = settlementLogisticsDto.getActualPrice();
+                settlementLogistics.setActualPrice((actualPrice == null) ? price : actualPrice.add(price));
+                int upInt = kwpSettlementLogisticsMapper.updateById(settlementLogistics);
+                if (upInt > 0) {
+                    //新增一条修改记录
+                    String remark = LoginUserHolder.getUserName() + "[" + LoginUserHolder.getUserId() + "]" + "结算[" + settlementLogistics.getId() + "]" + settlementLogistics.getActualPrice() + "(" + SettlementEnum.getStatusDesc(settlementLogistics.getStatus()) + ")";
+                    KwpSettlementLogisticsTrack kwpSettlementLogisticsTrack = new KwpSettlementLogisticsTrack();
+                    kwpSettlementLogisticsTrack.setId(new IdWorker(1).nextId());
+                    kwpSettlementLogisticsTrack.setLSettlementId(settlementLogistics.getId());
+                    kwpSettlementLogisticsTrack.setRemark(remark);
+                    kwpSettlementLogisticsTrack.setStatus(settlementLogistics.getStatus());
+                    kwpSettlementLogisticsTrack.setCreateBy(LoginUserHolder.getUserId());
+                    kwpSettlementLogisticsTrack.setCreateTime(LocalDateTime.now());
+                    kwpSettlementLogisticsTrack.setUpdateBy(LoginUserHolder.getUserId());
+                    kwpSettlementLogisticsTrack.setUpdateTime(LocalDateTime.now());
+                    kwpSettlementLogisticsTrack.setDelFlag(0);
+                    kwpSettlementLogisticsTrackMapper.insert(kwpSettlementLogisticsTrack);
+
+                    //新增一条电子钱包结算记录
+                    String orderNo = OrderUtils.generateOrderNo("SL");
+                    remainingReceivables = remainingReceivables.subtract(price);
+                    KwpSettlementWallet kwpSettlementWallet = new KwpSettlementWallet();
+                    kwpSettlementWallet.setId(new IdWorker(1).nextId());
+                    kwpSettlementWallet.setEntId(settlementLogisticsDto.getEntId());
+                    kwpSettlementWallet.setOrderNo(orderNo);
+                    kwpSettlementWallet.setSettlementId(settlementLogisticsDto.getId());
+                    kwpSettlementWallet.setOrderType(SettlementOrderTypeEnum.LOGISTICS.getStatus());
+                    //先用数字默认定义为1
+                    kwpSettlementWallet.setChannel(WalletChannelEnum.getValue(settlementLogisticsDto.getTrading()));
+                    kwpSettlementWallet.setPayTime(LocalDateTime.now());
+                    kwpSettlementWallet.setPayPrice(price);
+                    kwpSettlementWallet.setTopayPrice(remainingReceivables);
+                    kwpSettlementWallet.setType(SettlementPayTypeEnum.CASH_ON_DELIVERY.getStatus());
+                    kwpSettlementWallet.setRemark(Global.EMPTY_STRING);
+                    kwpSettlementWallet.setStatus(1);
+                    kwpSettlementWallet.setCreateBy(LoginUserHolder.getUserId());
+                    kwpSettlementWallet.setCreateTime(LocalDateTime.now());
+                    kwpSettlementWallet.setUpdateBy(LoginUserHolder.getUserId());
+                    kwpSettlementWallet.setUpdateTime(LocalDateTime.now());
+                    kwpSettlementWallet.setDelFlag(0);
+                    Integer insertKwpSettlementWallet = settlementWalletMapper.insert(kwpSettlementWallet);
+                    log.info("新增一条电子钱包结算记录:" + insertKwpSettlementWallet);
+                    //需要将金额同步到对应的对账表中
+                    KwpLedgerLogistics kwpLedgerLogistics = new KwpLedgerLogistics();
+                    kwpLedgerLogistics.setId(settlementLogisticsDto.getLLedgerId());
+                    kwpLedgerLogistics.setActualPrice(settlementLogistics.getActualPrice());
+                    kwpLedgerLogisticsMapper.updateById(kwpLedgerLogistics);
+                    //dubbo修改物流订单状态
+                    List<KwpLedgerLogisticsOrder> kwpLedgerLogisticsOrders = kwpLedgerLogisticsOrderService.queryList(settlementLogisticsDto.getLLedgerId());
+                    for (KwpLedgerLogisticsOrder kwpLedgerLogisticsOrder : kwpLedgerLogisticsOrders) {
+                        LogisticsOrderParam logisticsOrderParam = new LogisticsOrderParam();
+                        logisticsOrderParam.setLOrderId(kwpLedgerLogisticsOrder.getLOrderId());
+                        logisticsOrderParam.setStatus(LogisticsOrderEnum.HAVE_ALREADY_SETTLED.getStatus());
+                        logisticsOrderParam.setUpdateBy(LoginUserHolder.getUserId());
+                        logisticsOrderParam.setUpdateTime(new Date());
+                        HttpResult httpResult = transportDubboService.checkLogisticsOrderStatusById(logisticsOrderParam);
+                        if (httpResult.getCode() != HttpStatus.SUCCESS_CODE) {
+                            log.error("更新物流订单状态异常:{}", JSONObject.toJSONString(logisticsOrderParam));
+                            throw new BusinessException(httpResult.getMsg());
+                        }
+                    }
+                    // 调用电子钱包进行清分操作
+                    walletBusinessService.splitMoney(orderNo, uid, filter, channelEnum, price, "2");
+                    //推送双方系统管理员
+                    messageSender.sendManager(LoginUserHolder.getUserId(), new HashMap<>() {{
+                        put("company", logisticsUnit.getFirmName());
+                        put("number", settlementLogisticsDto.getSlOrderNo());
+                    }}, logisticsUnit2.getEntId(), MessageEnum.SETTLEMENT_START_CARRIER);
+                    messageSender.sendManager(LoginUserHolder.getUserId(), new HashMap<>() {{
+                        put("company", logisticsUnit2.getFirmName());
+                        put("number", settlementLogisticsDto.getSlOrderNo());
+                    }}, logisticsUnit.getEntId(), MessageEnum.SETTLEMENT_START_SHIPPER);
+                    return insertKwpSettlementWallet;
+                }
+            } finally {
+                redisLockUtil.unlock(key);
+            }
+        }
         return null;
     }
 
-    public PageRes<SettlementWalletVo> pageListTradePayment(SettlementWalletReq settlementWalletReq) {
-//        //todo 查询缓存,获取客户企业id
-//        String keywords = settlementReq.getKeywords();
-//        if (StringUtils.isNotBlank(keywords)) {
-//            System.out.println("关键之:" + keywords);
+//    public PageRes<SettlementWalletVo> pageListTradePayment(SettlementWalletReq settlementWalletReq) {
+////        //todo 查询缓存,获取客户企业id
+////        String keywords = settlementReq.getKeywords();
+////        if (StringUtils.isNotBlank(keywords)) {
+////            System.out.println("关键之:" + keywords);
+////        }
+//        PageHelper.startPage(settlementWalletReq.getPage(), settlementWalletReq.getPageSize());
+//
+//        List<SettlementWalletDto> settlementWalletLogisticsList = settlementWalletMapper.pageListLogisticsPayment(settlementWalletReq);
+//        for (SettlementWalletDto entity : settlementWalletLogisticsList) {
+//            entity.setCreateByText("创建人名称");
+//            entity.setUpdateByText("更新人名称");
 //        }
-        PageHelper.startPage(settlementWalletReq.getPage(), settlementWalletReq.getPageSize());
-
-        List<SettlementWalletDto> settlementWalletLogisticsList = settlementWalletMapper.pageListLogisticsPayment(settlementWalletReq);
-        for (SettlementWalletDto entity : settlementWalletLogisticsList) {
-            entity.setCreateByText("创建人名称");
-            entity.setUpdateByText("更新人名称");
-        }
-
-        if (CollectionUtils.isEmpty(settlementWalletLogisticsList)) {
-            return new PageRes<>(new PageInfo<>());
-        }
-
-        //指定返回值
-        List<SettlementWalletVo> collect = settlementWalletLogisticsList.stream().map(a -> {
-            SettlementWalletVo settlementWalletVo = new SettlementWalletVo();
-            BeanUtils.copyProperties(a, settlementWalletVo);
-            return settlementWalletVo;
-        }).collect(Collectors.toList());
-
-        return new PageRes<>(new PageInfo<>(collect));
-    }
+//
+//        if (CollectionUtils.isEmpty(settlementWalletLogisticsList)) {
+//            return new PageRes<>(new PageInfo<>());
+//        }
+//
+//        //指定返回值
+//        List<SettlementWalletVo> collect = settlementWalletLogisticsList.stream().map(a -> {
+//            SettlementWalletVo settlementWalletVo = new SettlementWalletVo();
+//            BeanUtils.copyProperties(a, settlementWalletVo);
+//            return settlementWalletVo;
+//        }).collect(Collectors.toList());
+//
+//        return new PageRes<>(new PageInfo<>(collect));
+//    }
 
 
     /**
@@ -393,8 +430,7 @@ public class KwpSettlementWalletService {
                 KwpSettlementTrade kwpSettlementTrade = new KwpSettlementTrade();
                 kwpSettlementTrade.setId(byId.getId());
                 kwpSettlementTrade.setActualPrice(byId.getActualPrice().add(price));
-                int status = subtract.compareTo(new BigDecimal("0.0")) == NumberConstant.ZERO ? SettlementEnum.ALL_PAYMENT.getStatus()
-                        : SettlementEnum.PARTIAL_PAYMENT.getStatus();
+                int status = subtract.compareTo(new BigDecimal("0.0")) == NumberConstant.ZERO ? SettlementEnum.ALL_PAYMENT.getStatus() : SettlementEnum.PARTIAL_PAYMENT.getStatus();
                 kwpSettlementTrade.setStatus(status);
                 kwpSettlementTrade.setUpdateBy(LoginUserHolder.getUserId());
                 kwpSettlementTrade.setUpdateTime(LocalDateTime.now());
@@ -488,47 +524,47 @@ public class KwpSettlementWalletService {
         return PageRes.build(pageInfo, collect);
     }
 
-    public PageRes<SettlementWalletVo> pageListTradeCollection(SettlementWalletReq settlementWalletReq) {
-        PageHelper.startPage(settlementWalletReq.getPage(), settlementWalletReq.getPageSize());
-
-        List<SettlementWalletDto> settlementWalletLogisticsList = settlementWalletMapper.pageListLogisticsPayment(settlementWalletReq);
-        for (SettlementWalletDto entity : settlementWalletLogisticsList) {
-            entity.setCreateByText("创建人名称");
-            entity.setUpdateByText("更新人名称");
-        }
-
-        if (CollectionUtils.isEmpty(settlementWalletLogisticsList)) {
-            return new PageRes<>(new PageInfo<>());
-        }
-
-        Map<Long, UserCacheResDto> map = new HashMap<>(Global.NUMERICAL_SIXTEEN);
-        //指定返回值
-        List<SettlementWalletVo> collect = settlementWalletLogisticsList.stream().map(a -> {
-            SettlementWalletVo settlementWalletVo = new SettlementWalletVo();
-            BeanUtils.copyProperties(a, settlementWalletVo);
-            Long createBy = a.getCreateBy();
-            Long updateBy = a.getUpdateBy();
-            UserCacheResDto userCacheResDto = map.get(createBy);
-            if (Objects.isNull(userCacheResDto)) {
-                userCacheResDto = remoteSystemService.queryUserCacheById(createBy);
-                map.put(createBy, userCacheResDto);
-            }
-            if (Objects.nonNull(userCacheResDto)) {
-                settlementWalletVo.setCreateByText(userCacheResDto.getName());
-            }
-            userCacheResDto = map.get(updateBy);
-            if (Objects.isNull(userCacheResDto)) {
-                userCacheResDto = remoteSystemService.queryUserCacheById(updateBy);
-                map.put(updateBy, userCacheResDto);
-            }
-            if (Objects.nonNull(userCacheResDto)) {
-                settlementWalletVo.setUpdateByText(userCacheResDto.getName());
-            }
-            return settlementWalletVo;
-        }).collect(Collectors.toList());
-
-        return new PageRes<>(new PageInfo<>(collect));
-    }
+//    public PageRes<SettlementWalletVo> pageListTradeCollection(SettlementWalletReq settlementWalletReq) {
+//        PageHelper.startPage(settlementWalletReq.getPage(), settlementWalletReq.getPageSize());
+//
+//        List<SettlementWalletDto> settlementWalletLogisticsList = settlementWalletMapper.pageListLogisticsPayment(settlementWalletReq);
+//        for (SettlementWalletDto entity : settlementWalletLogisticsList) {
+//            entity.setCreateByText("创建人名称");
+//            entity.setUpdateByText("更新人名称");
+//        }
+//
+//        if (CollectionUtils.isEmpty(settlementWalletLogisticsList)) {
+//            return new PageRes<>(new PageInfo<>());
+//        }
+//
+//        Map<Long, UserCacheResDto> map = new HashMap<>(Global.NUMERICAL_SIXTEEN);
+//        //指定返回值
+//        List<SettlementWalletVo> collect = settlementWalletLogisticsList.stream().map(a -> {
+//            SettlementWalletVo settlementWalletVo = new SettlementWalletVo();
+//            BeanUtils.copyProperties(a, settlementWalletVo);
+//            Long createBy = a.getCreateBy();
+//            Long updateBy = a.getUpdateBy();
+//            UserCacheResDto userCacheResDto = map.get(createBy);
+//            if (Objects.isNull(userCacheResDto)) {
+//                userCacheResDto = remoteSystemService.queryUserCacheById(createBy);
+//                map.put(createBy, userCacheResDto);
+//            }
+//            if (Objects.nonNull(userCacheResDto)) {
+//                settlementWalletVo.setCreateByText(userCacheResDto.getName());
+//            }
+//            userCacheResDto = map.get(updateBy);
+//            if (Objects.isNull(userCacheResDto)) {
+//                userCacheResDto = remoteSystemService.queryUserCacheById(updateBy);
+//                map.put(updateBy, userCacheResDto);
+//            }
+//            if (Objects.nonNull(userCacheResDto)) {
+//                settlementWalletVo.setUpdateByText(userCacheResDto.getName());
+//            }
+//            return settlementWalletVo;
+//        }).collect(Collectors.toList());
+//
+//        return new PageRes<>(new PageInfo<>(collect));
+//    }
 
     /**
      * 销售-预付款
@@ -614,36 +650,27 @@ public class KwpSettlementWalletService {
             }
         }
         return "请勿重复提交!";
-
     }
 
+    /**
+     * 物流,货到付款(付钱方) 查询电子钱余额
+     *
+     * @param id
+     * @return
+     */
     public WalletDto getConfirmLogisticsPayment(Long id) {
-        //todo
-        WalletDto walletDto = new WalletDto();
-        walletDto.setName("测试钱宝");
-        walletDto.setMemberName("");
-        walletDto.setUid("kll_0001");
-        walletDto.setChannel("1");
-        walletDto.setCreateTime(LocalDateTime.now());
-        walletDto.setFilter("kll_0002");
-        walletDto.setFreeze(0L);
-        walletDto.setApMoney(0L);
-        walletDto.setTotalMoney(12000L);
-        walletDto.setMoney(1L);
-
-        return walletDto;
-//        SettlementLogisticsDto byId = kwpSettlementLogisticsService.detail(id, LogisticsUnitType.CARRIER, LogisticsUnitType.SHIPPER);
-//        if (Objects.isNull(byId)) {
-//            throw new BusinessException("结算单不存在");
-//        }
-//        if (StringUtils.isNotBlank(byId.getTrading()) && !byId.getTrading().startsWith(TradingEnum.RECEIVE_PAY.getValue())) {
-//            throw new BusinessException("只支持货货到付款方式订单进行当前操作");
-//        }
-//        List<LedgerUnitDto> listById = kwpSettlementLogisticsService.getListById(id);
-//        if (CollectionUtils.isEmpty(listById) || listById.size() != NumberConstant.TWO) {
-//            throw new BusinessException("对账单交易企业双方不存在或缺少");
-//        }
-//        return getWalletBalance(listById, byId.getTrading());
+        SettlementLogisticsDto byId = kwpSettlementLogisticsService.detail(id, LogisticsUnitType.CARRIER, LogisticsUnitType.SHIPPER);
+        if (Objects.isNull(byId)) {
+            throw new BusinessException("结算单不存在");
+        }
+        if (StringUtils.isNotBlank(byId.getTrading()) && !byId.getTrading().startsWith(TradingEnum.RECEIVE_PAY.getValue())) {
+            throw new BusinessException("只支持货货到付款方式订单进行当前操作");
+        }
+        List<LedgerUnitDto> listById = kwpSettlementLogisticsService.getListById(id);
+        if (CollectionUtils.isEmpty(listById) || listById.size() != NumberConstant.TWO) {
+            throw new BusinessException("对账单交易企业双方不存在或缺少");
+        }
+        return getWalletBalance(listById, byId.getTrading());
     }
 
 
@@ -654,58 +681,28 @@ public class KwpSettlementWalletService {
      * @return
      */
     public WalletDto getConfirmTradePayment(Long id) {
-        //todo
-        WalletDto walletDto = new WalletDto();
-        walletDto.setName("测试钱宝");
-        walletDto.setMemberName("");
-        walletDto.setUid("kll_0001");
-        walletDto.setChannel("1");
-        walletDto.setCreateTime(LocalDateTime.now());
-        walletDto.setFilter("kll_0002");
-        walletDto.setFreeze(0L);
-        walletDto.setApMoney(0L);
-        walletDto.setTotalMoney(12000L);
-        walletDto.setMoney(1L);
-
-        return walletDto;
-//        SettlementTradeDto byId = kwpSettlementTradeService.getById(id, TradeUnitType.SELL);
-//        if (Objects.isNull(byId)) {
-//            throw new BusinessException("结算单不存在");
-//        }
-//        if (StringUtils.isNotBlank(byId.getTrading()) && !byId.getTrading().startsWith(TradingEnum.RECEIVE_PAY.getValue())) {
-//            throw new BusinessException("只支持货货到付款方式订单进行当前操作");
-//        }
-//        List<LedgerUnitDto> listById = kwpSettlementTradeService.getListById(id);
-//        if (CollectionUtils.isEmpty(listById) || listById.size() != NumberConstant.TWO) {
-//            throw new BusinessException("对账单交易企业双方不存在或缺少");
-//        }
-//        Long uid = null;
-//        Long filter = null;
-//        for (LedgerUnitDto ledgerUnitDto : listById) {
-//            Integer unitType = ledgerUnitDto.getUnitType();
-//            if (TradeUnitType.PURCHASE.equals(unitType)) {
-//                uid = ledgerUnitDto.getTopEntId();
-//                continue;
-//            }
-//            if (TradeUnitType.SELL.equals(unitType)) {
-//                filter = ledgerUnitDto.getTopEntId();
-//            }
-//        }
-//        String relation = walletRelationService.getRelation(uid);
-//        String filterUser = walletRelationService.getRelation(filter);
-//        if (StringUtils.isBlank(relation) || StringUtils.isBlank(filterUser)) {
-//            throw new BusinessException("顶级企业未开通电子钱包");
-//        }
-//        R<List<WalletDto>> wallet = payCenterService.wallet(relation, ChannelEnum.getByCode(byId.getTrading()), filterUser);
-//        if (CollectionUtils.isEmpty(wallet.getData())) {
-//            throw new BusinessException("暂未开通电子钱包");
-//        }
-//        List<WalletDto> data = wallet.getData();
-//        return data.get(NumberConstant.ZERO);
-//        return BigDecimal.valueOf(data.get(NumberConstant.ZERO).getMoney() / 100.0);
+        SettlementTradeDto byId = kwpSettlementTradeService.getById(id, TradeUnitType.SELL);
+        if (Objects.isNull(byId)) {
+            throw new BusinessException("结算单不存在");
+        }
+        if (StringUtils.isNotBlank(byId.getTrading()) && !byId.getTrading().startsWith(TradingEnum.RECEIVE_PAY.getValue())) {
+            throw new BusinessException("只支持货到付款方式订单进行当前操作");
+        }
+        List<LedgerUnitDto> listById = kwpSettlementTradeService.getListById(id);
+        if (CollectionUtils.isEmpty(listById) || listById.size() != NumberConstant.TWO) {
+            throw new BusinessException("对账单交易企业双方不存在或缺少");
+        }
+        return getWalletBalance(listById, byId.getTrading());
     }
 
-    private BigDecimal getWalletBalance(List<LedgerUnitDto> listById, String trading) {
+    /**
+     * 查询交易双方的电子钱包
+     *
+     * @param listById 双发企业
+     * @param trading  交易方式
+     * @return
+     */
+    private WalletDto getWalletBalance(List<LedgerUnitDto> listById, String trading) {
         Long uid = null;
         Long filter = null;
         for (LedgerUnitDto ledgerUnitDto : listById) {
@@ -723,12 +720,12 @@ public class KwpSettlementWalletService {
         if (StringUtils.isBlank(relation) || StringUtils.isBlank(filterUser)) {
             throw new BusinessException("顶级企业未开通电子钱包");
         }
-        R<List<WalletDto>> wallet = payCenterService.wallet(relation, ChannelEnum.getByCode(trading), filterUser);
+        R<List<WalletDto>> wallet = payCenterService.wallet(relation, ChannelEnum.getByTrading(trading), filterUser);
         if (CollectionUtils.isEmpty(wallet.getData())) {
-            throw new BusinessException("暂未开通电子钱包");
+            throw new BusinessException("交易双方暂未开通电子钱包");
         }
         List<WalletDto> data = wallet.getData();
-        return BigDecimal.valueOf(data.get(NumberConstant.ZERO).getMoney() / 100.0);
+        return data.get(NumberConstant.ZERO);
     }
 
     /**

+ 47 - 33
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/MessageSender.java

@@ -2,6 +2,7 @@ package com.sckw.payment.service;
 
 import com.alibaba.fastjson2.JSON;
 import com.alibaba.fastjson2.JSONObject;
+import com.sckw.payment.job.AsyncPool;
 import com.sckw.payment.model.JumpUrlConfig;
 import com.sckw.payment.model.KwpLedgerLogisticsTrack;
 import com.sckw.payment.model.KwpLedgerTradeTrack;
@@ -47,9 +48,11 @@ public class MessageSender {
      * @param messageEnum
      */
     public void sendCreate(Long createBy, Map<String, Object> map, UserInfo user, MessageEnum messageEnum) {
-        SckwMessage sckwMessage = new SckwMessage(messageEnum).setMsgUrl(jumpUrlConfig.getUrl().get(JumpEnum.getByEnum(messageEnum))).setParams(map).setUserInfos(Collections.singletonList(user)).setCreateBy(createBy);
-        log.info("推送创建人:{}", JSONObject.toJSONString(sckwMessage));
-        streamBridge.send("sckw-message", JSON.toJSONString(sckwMessage));
+        AsyncPool.addTask(() -> {
+            SckwMessage sckwMessage = new SckwMessage(messageEnum).setMsgUrl(jumpUrlConfig.getUrl().get(JumpEnum.getByEnum(messageEnum))).setParams(map).setUserInfos(Collections.singletonList(user)).setCreateBy(createBy);
+            log.info("推送创建人:{}", JSONObject.toJSONString(sckwMessage));
+            streamBridge.send("sckw-message", JSON.toJSONString(sckwMessage));
+        });
     }
 
     /**
@@ -60,12 +63,15 @@ public class MessageSender {
      * @param messageEnum 消息枚举
      */
     public void sendManager(Long createBy, Map<String, Object> map, Long entId, MessageEnum messageEnum) {
-        EntCacheResDto entCacheResDto = remoteSystemService.queryEntCacheById(entId);
-        if (Objects.nonNull(entCacheResDto)) {
-            SckwMessage sckwMessage = new SckwMessage(messageEnum).setMsgUrl(jumpUrlConfig.getUrl().get(JumpEnum.getByEnum(messageEnum))).setParams(map).setUserInfos(Collections.singletonList(new UserInfo(entCacheResDto.getContactsId(), entCacheResDto.getId()))).setCreateBy(createBy);
-            log.info("推送系统管理员:{}", JSONObject.toJSONString(sckwMessage));
-            streamBridge.send("sckw-message", JSON.toJSONString(sckwMessage));
-        }
+        AsyncPool.addTask(() -> {
+            EntCacheResDto entCacheResDto = remoteSystemService.queryEntCacheById(entId);
+            if (Objects.nonNull(entCacheResDto)) {
+                SckwMessage sckwMessage = new SckwMessage(messageEnum).setMsgUrl(jumpUrlConfig.getUrl().get(JumpEnum.getByEnum(messageEnum))).setParams(map).setUserInfos(Collections.singletonList(new UserInfo(entCacheResDto.getContactsId(), entCacheResDto.getId()))).setCreateBy(createBy);
+                log.info("推送系统管理员:{}", JSONObject.toJSONString(sckwMessage));
+                streamBridge.send("sckw-message", JSON.toJSONString(sckwMessage));
+            }
+        });
+
     }
 
     /**
@@ -77,14 +83,16 @@ public class MessageSender {
      * @param messageEnum
      */
     private void sendSellChanger(Long createBy, Map<String, Object> map, Long ledgerId, MessageEnum messageEnum) {
-        KwpLedgerTradeTrack kwpLedgerTradeTrack = tradeTrackService.queryLedgered(ledgerId);
-        if (Objects.nonNull(kwpLedgerTradeTrack)) {
-            UserCacheResDto userCacheResDto = remoteSystemService.queryUserCacheById(kwpLedgerTradeTrack.getCreateBy());
-            EntCacheResDto entCacheResDto = Objects.nonNull(userCacheResDto) ? (Objects.nonNull(userCacheResDto.getEntInfo()) ? userCacheResDto.getEntInfo() : new EntCacheResDto()) : new EntCacheResDto();
-            SckwMessage sckwMessage = new SckwMessage(messageEnum).setMsgUrl(jumpUrlConfig.getUrl().get(JumpEnum.getByEnum(messageEnum))).setParams(map).setUserInfos(Collections.singletonList(new UserInfo(kwpLedgerTradeTrack.getCreateBy(), entCacheResDto.getId()))).setCreateBy(createBy);
-            log.info("推送变更人:{}", JSONObject.toJSONString(sckwMessage));
-            streamBridge.send("sckw-message", JSON.toJSONString(sckwMessage));
-        }
+        AsyncPool.addTask(() -> {
+            KwpLedgerTradeTrack kwpLedgerTradeTrack = tradeTrackService.queryLedgered(ledgerId);
+            if (Objects.nonNull(kwpLedgerTradeTrack)) {
+                UserCacheResDto userCacheResDto = remoteSystemService.queryUserCacheById(kwpLedgerTradeTrack.getCreateBy());
+                EntCacheResDto entCacheResDto = Objects.nonNull(userCacheResDto) ? (Objects.nonNull(userCacheResDto.getEntInfo()) ? userCacheResDto.getEntInfo() : new EntCacheResDto()) : new EntCacheResDto();
+                SckwMessage sckwMessage = new SckwMessage(messageEnum).setMsgUrl(jumpUrlConfig.getUrl().get(JumpEnum.getByEnum(messageEnum))).setParams(map).setUserInfos(Collections.singletonList(new UserInfo(kwpLedgerTradeTrack.getCreateBy(), entCacheResDto.getId()))).setCreateBy(createBy);
+                log.info("推送变更人:{}", JSONObject.toJSONString(sckwMessage));
+                streamBridge.send("sckw-message", JSON.toJSONString(sckwMessage));
+            }
+        });
     }
 
     /**
@@ -96,16 +104,18 @@ public class MessageSender {
      * @param messageEnum
      */
     private void sendPurchaseChanger(Long createBy, Map<String, Object> map, Long ledgerId, MessageEnum messageEnum) {
-        KwpLedgerLogisticsTrack kwpLedgerLogisticsTrack = logisticsTrackService.queryLedgered(ledgerId);
-        if (Objects.nonNull(kwpLedgerLogisticsTrack)) {
-            UserCacheResDto userCacheResDto = remoteSystemService.queryUserCacheById(kwpLedgerLogisticsTrack.getCreateBy());
-            EntCacheResDto entCacheResDto = Objects.nonNull(userCacheResDto) ? (Objects.nonNull(userCacheResDto.getEntInfo()) ? userCacheResDto.getEntInfo() : new EntCacheResDto()) : new EntCacheResDto();
-            SckwMessage sckwMessage = new SckwMessage(messageEnum)
-                    .setMsgUrl(jumpUrlConfig.getUrl().get(JumpEnum.getByEnum(messageEnum)))
-                    .setParams(map).setUserInfos(Collections.singletonList(new UserInfo(kwpLedgerLogisticsTrack.getCreateBy(), entCacheResDto.getId()))).setCreateBy(createBy);
-            log.info("推送变更人:{}", JSONObject.toJSONString(sckwMessage));
-            streamBridge.send("sckw-message", JSON.toJSONString(sckwMessage));
-        }
+        AsyncPool.addTask(() -> {
+            KwpLedgerLogisticsTrack kwpLedgerLogisticsTrack = logisticsTrackService.queryLedgered(ledgerId);
+            if (Objects.nonNull(kwpLedgerLogisticsTrack)) {
+                UserCacheResDto userCacheResDto = remoteSystemService.queryUserCacheById(kwpLedgerLogisticsTrack.getCreateBy());
+                EntCacheResDto entCacheResDto = Objects.nonNull(userCacheResDto) ? (Objects.nonNull(userCacheResDto.getEntInfo()) ? userCacheResDto.getEntInfo() : new EntCacheResDto()) : new EntCacheResDto();
+                SckwMessage sckwMessage = new SckwMessage(messageEnum)
+                        .setMsgUrl(jumpUrlConfig.getUrl().get(JumpEnum.getByEnum(messageEnum)))
+                        .setParams(map).setUserInfos(Collections.singletonList(new UserInfo(kwpLedgerLogisticsTrack.getCreateBy(), entCacheResDto.getId()))).setCreateBy(createBy);
+                log.info("推送变更人:{}", JSONObject.toJSONString(sckwMessage));
+                streamBridge.send("sckw-message", JSON.toJSONString(sckwMessage));
+            }
+        });
     }
 
     /**
@@ -118,8 +128,10 @@ public class MessageSender {
      * @param messageEnum
      */
     public void sendSellBoth(Long createBy, Map<String, Object> map, Long ledgerId, Long entId, MessageEnum messageEnum) {
-        sendManager(createBy, map, entId, messageEnum);
-        sendSellChanger(createBy, map, ledgerId, messageEnum);
+        AsyncPool.addTask(() -> {
+            sendManager(createBy, map, entId, messageEnum);
+            sendSellChanger(createBy, map, ledgerId, messageEnum);
+        });
     }
 
     /**
@@ -127,12 +139,14 @@ public class MessageSender {
      *
      * @param createBy
      * @param map
-     * @param ledgerId 对账单id
-     * @param entId 需要推送的对账单关联的企业
+     * @param ledgerId    对账单id
+     * @param entId       需要推送的对账单关联的企业
      * @param messageEnum
      */
     public void sendPurchaseBoth(Long createBy, Map<String, Object> map, Long ledgerId, Long entId, MessageEnum messageEnum) {
-        sendManager(createBy, map, entId, messageEnum);
-        sendPurchaseChanger(createBy, map, ledgerId, messageEnum);
+        AsyncPool.addTask(() -> {
+            sendManager(createBy, map, entId, messageEnum);
+            sendPurchaseChanger(createBy, map, ledgerId, messageEnum);
+        });
     }
 }

+ 33 - 3
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/PayCenterService.java

@@ -237,11 +237,10 @@ public class PayCenterService {
      * 提现详情
      *
      * @param uid
-     * @param view
      * @param orderNo
      * @return
      */
-    public R<CashDetail> withdrawDetail(String uid, String view, String orderNo) {
+    public R<CashDetail> withdrawDetail(String uid, String orderNo) {
         if (StringUtils.isBlank(uid)) {
             throw new BusinessException("提现用户不能为空");
         }
@@ -250,7 +249,6 @@ public class PayCenterService {
         }
         String sync = getHttp(PayCenterEnum.WITHDRAW_DETAIL, new HashMap<>() {{
             put("uid", uid);
-            put("view", view);
             put("order_no", orderNo);
         }});
         return JSONObject.parseObject(sync, new TypeReference<>() {
@@ -721,6 +719,38 @@ public class PayCenterService {
         return parseArray(sync, SplitDto.class);
     }
 
+    /**
+     * 充值订单详情
+     *
+     * @param uid
+     * @param startDate
+     * @param endDate
+     * @param keyword
+     * @param page
+     * @param pageSize
+     * @return
+     */
+    public R<RechargePage> rechargeOrder(String uid, String startDate, String endDate, String keyword, Integer page, Integer pageSize) {
+        if (Objects.isNull(page)) {
+            page = 1;
+        }
+        if (Objects.isNull(pageSize)) {
+            pageSize = 5;
+        }
+        Integer finalPage = page;
+        Integer finalPageSize = pageSize;
+        String sync = getHttp(PayCenterEnum.RECHARGE_ORDER, new HashMap<>() {{
+            put("uid", uid);
+            put("keyword", keyword);
+            put("startDate", startDate);
+            put("endDate", endDate);
+            put("page", finalPage);
+            put("pageSize", finalPageSize);
+        }});
+        return JSONObject.parseObject(sync, new TypeReference<>() {
+        });
+    }
+
     /**
      * 创建/更新账户
      *

+ 75 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/WalletBusinessService.java

@@ -0,0 +1,75 @@
+package com.sckw.payment.service;
+
+import com.sckw.core.exception.BusinessException;
+import com.sckw.core.utils.StringUtils;
+import com.sckw.payment.api.model.constant.ChannelEnum;
+import com.sckw.payment.api.model.dto.common.R;
+import com.sckw.payment.model.dto.common.BusinessNo;
+import com.sckw.payment.model.dto.wallet.PatchPay;
+import com.sckw.payment.model.dto.wallet.WalletInfo;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * @author xucaiqin
+ * @date 2023-09-20 15:04:06
+ */
+@Slf4j
+@Service
+@RequiredArgsConstructor
+public class WalletBusinessService {
+    private final PayCenterService payCenterService;
+
+    /**
+     * 校验付款金额是否超过钱包可用余额
+     *
+     * @param uid         支付方
+     * @param filter      收款方
+     * @param channelEnum 渠道
+     * @param price       支付金额 元
+     */
+    public void checkMoney(String uid, String filter, ChannelEnum channelEnum, BigDecimal price) {
+        R<WalletInfo> walletInfoR = payCenterService.totalInfo(uid, channelEnum, filter);
+        if (!walletInfoR.getStatus()) {
+            throw new BusinessException(StringUtils.isNotBlank(walletInfoR.getMsg()) ? walletInfoR.getMsg() : "双方企业暂未开通电子钱包");
+        }
+        //钱包余额校验
+        WalletInfo data = Objects.isNull(walletInfoR.getData()) ? new WalletInfo() : walletInfoR.getData();
+        //可用余额 分
+        BigDecimal money = data.getMoney();
+        //付款金额大于钱包可用余额
+        if (price.compareTo(money.divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP)) > 0) {
+            log.error("付款金额:{} 钱包可用余额:{}", price, money);
+            throw new BusinessException("钱包可用余额不足");
+        }
+    }
+
+    /**
+     * 清分金额
+     *
+     * @param businessNo  流水号
+     * @param uid
+     * @param filter
+     * @param channelEnum
+     * @param price       清分金额
+     * @param payType     支付方式 支付类型0-默认1-仅预付支付2-仅余额支付
+     */
+    public void splitMoney(String businessNo, String uid, String filter, ChannelEnum channelEnum, BigDecimal price, String payType) {
+        long value = price.multiply(new BigDecimal("100")).longValueExact();
+        List<PatchPay> split = new ArrayList<>() {{
+            add(new PatchPay(filter, value, uid + "清分" + value + "至" + filter));
+        }};
+        R<BusinessNo> businessNoR = payCenterService.payAgentPayV2(uid, filter, channelEnum, value, split, businessNo, payType);
+        if (!businessNoR.getStatus()) {
+            log.error("流水号:{} uid:{} filter:{} channel:{} price:{} payType:{}", businessNoR, uid, filter, channelEnum, price, payType);
+            throw new BusinessException("清分失败异常");
+        }
+    }
+}

+ 60 - 25
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/WalletService.java

@@ -81,6 +81,20 @@ public class WalletService {
     @DubboReference(version = "1.0.0", group = "design", check = false)
     private RemoteManageService remoteManageService;
 
+    /**
+     * 填充时间等参数
+     *
+     * @param tradeReq 请求参数
+     */
+    private void fillPara(MoneyPage tradeReq) {
+        if (StringUtils.isNotBlank(tradeReq.getStartCreateTime())) {
+            tradeReq.setStartCreateTime(StringTimeUtil.fillStart(tradeReq.getStartCreateTime()));
+        }
+        if (StringUtils.isNotBlank(tradeReq.getEndCreateTime())) {
+            tradeReq.setEndCreateTime(StringTimeUtil.fillEnd(tradeReq.getEndCreateTime()));
+        }
+    }
+
     /**
      * 通过中台用户id转为企业名称
      *
@@ -1268,26 +1282,36 @@ public class WalletService {
      * @return
      */
     public PageRes<ChargeDetailVo> rechargeList(MoneyPage moneyPage) {
-        ChargeDetailVo chargeDetailVo = new ChargeDetailVo();
-        chargeDetailVo.setBalance(new BigDecimal("0"));
-        chargeDetailVo.setOrderNo("");
-        chargeDetailVo.setChannel("");
-        chargeDetailVo.setChannelDict("");
-        chargeDetailVo.setChannelLabel("");
-        chargeDetailVo.setUid("");
-        chargeDetailVo.setUidName("");
-        chargeDetailVo.setFilter("");
-        chargeDetailVo.setFilterName("");
-        chargeDetailVo.setStatus(0);
-        chargeDetailVo.setStatusLabel("");
-        chargeDetailVo.setMoney(new BigDecimal("0"));
-        chargeDetailVo.setRemark("");
-        chargeDetailVo.setCreateTime(LocalDateTime.now());
-        List<ChargeDetailVo> objects = new ArrayList<>() {{
-            add(chargeDetailVo);
-        }};
-        PageInfo<ChargeDetailVo> objectPageInfo = new PageInfo<>();
-        return new PageRes<>(objectPageInfo, objects);
+        fillPara(moneyPage);
+        R<RechargePage> rechargePageR = payCenterService.rechargeOrder(moneyPage.getUid(), moneyPage.getStartCreateTime(), moneyPage.getEndCreateTime(), moneyPage.getKeywords(), moneyPage.getPage(), moneyPage.getPageSize());
+        if (!rechargePageR.getStatus()) {
+            throw new BusinessException(StringUtils.isBlank(rechargePageR.getMsg()) ? "查询失败" : rechargePageR.getMsg());
+        }
+        RechargePage data = rechargePageR.getData();
+        List<Recharge> rows = data.getRows();
+        if (!CollectionUtils.isEmpty(rows)) {
+            List<ChargeDetailVo> collect = rows.stream().map(a -> {
+                ChargeDetailVo chargeDetailVo = new ChargeDetailVo();
+                chargeDetailVo.setOrderNo(a.getOrderNo());
+                chargeDetailVo.setChannel(a.getChannel());
+                chargeDetailVo.setChannelDict(ChannelEnum.getDict(a.getChannel()));
+                chargeDetailVo.setChannelLabel(ChannelEnum.getDesc(a.getChannel()));
+                chargeDetailVo.setUid(a.getUid());
+                chargeDetailVo.setUidName(getFirmName(a.getUid()));
+                chargeDetailVo.setFilter(a.getFilter());
+                chargeDetailVo.setFilterName(getFirmName(a.getFilter()));
+                chargeDetailVo.setStatus(a.getStatus());
+                chargeDetailVo.setStatusLabel(a.getStatusLabel());
+                chargeDetailVo.setMoney(chargeDetailVo.smallMoney(a.getMoney()));
+                chargeDetailVo.setBalance(chargeDetailVo.smallMoney(a.getAfterMoney()));
+                chargeDetailVo.setRemark(a.getRemarks());
+                chargeDetailVo.setCreateTime(a.getCreateTime());
+                chargeDetailVo.setPayTime(a.getPayTime());
+                return chargeDetailVo;
+            }).collect(Collectors.toList());
+            return new PageRes<>(moneyPage.getPage(), moneyPage.getPageSize(), data.getTotal(), (int) (data.getTotal() / data.getPageSize() + 1), collect);
+        }
+        return new PageRes<>(moneyPage.getPage(), moneyPage.getPageSize(), 0, 0, new ArrayList<>());
     }
 
     /**
@@ -1310,7 +1334,7 @@ public class WalletService {
         chargeDetailVo.setStatusLabel("");
         chargeDetailVo.setMoney(new BigDecimal("0"));
         chargeDetailVo.setRemark("");
-        chargeDetailVo.setCreateTime(LocalDateTime.now());
+//        chargeDetailVo.setCreateTime(LocalDateTime.now());
         List<WalletDetailBase> objects = new ArrayList<>() {{
             add(chargeDetailVo);
         }};
@@ -1338,7 +1362,7 @@ public class WalletService {
         chargeDetailVo.setStatusLabel("");
         chargeDetailVo.setMoney(new BigDecimal("0"));
         chargeDetailVo.setRemark("");
-        chargeDetailVo.setCreateTime(LocalDateTime.now());
+//        chargeDetailVo.setCreateTime(LocalDateTime.now());
         List<WalletDetailBase> objects = new ArrayList<>() {{
             add(chargeDetailVo);
         }};
@@ -1367,7 +1391,7 @@ public class WalletService {
         chargeDetailVo.setStatusLabel("");
         chargeDetailVo.setMoney(new BigDecimal("0"));
         chargeDetailVo.setRemark("");
-        chargeDetailVo.setCreateTime(LocalDateTime.now());
+//        chargeDetailVo.setCreateTime(LocalDateTime.now());
         List<ChargeDetailVo> objects = new ArrayList<>() {{
             add(chargeDetailVo);
         }};
@@ -1395,7 +1419,7 @@ public class WalletService {
         chargeDetailVo.setStatusLabel("");
         chargeDetailVo.setMoney(new BigDecimal("0"));
         chargeDetailVo.setRemark("");
-        chargeDetailVo.setCreateTime(LocalDateTime.now());
+//        chargeDetailVo.setCreateTime(LocalDateTime.now());
         List<WalletDetailBase> objects = new ArrayList<>() {{
             add(chargeDetailVo);
         }};
@@ -1423,7 +1447,7 @@ public class WalletService {
         chargeDetailVo.setStatusLabel("");
         chargeDetailVo.setMoney(new BigDecimal("0"));
         chargeDetailVo.setRemark("");
-        chargeDetailVo.setCreateTime(LocalDateTime.now());
+//        chargeDetailVo.setCreateTime(LocalDateTime.now());
         List<WalletDetailBase> objects = new ArrayList<>() {{
             add(chargeDetailVo);
         }};
@@ -1431,6 +1455,17 @@ public class WalletService {
         return new PageRes<>(objectPageInfo, objects);
     }
 
+    /**
+     * 详细记录-提现
+     *
+     * @param cashDetailReq
+     * @return
+     */
+    public String cashDetail(CashDetailReq cashDetailReq) {
+        payCenterService.withdrawDetail(cashDetailReq.getUid(), cashDetailReq.getOrderNo());
+        return null;
+    }
+
     /**
      * 退款处理
      *

+ 35 - 4
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/dubbo/PaymentDubboServiceImpl.java

@@ -1,7 +1,10 @@
 package com.sckw.payment.service.dubbo;
 
 import com.sckw.core.exception.BusinessException;
+import com.sckw.core.utils.OrderUtils;
+import com.sckw.core.web.response.HttpResult;
 import com.sckw.payment.api.dubbo.PaymentDubboService;
+import com.sckw.payment.api.model.constant.ChannelEnum;
 import com.sckw.payment.api.model.constant.OrderEnum;
 import com.sckw.payment.api.model.dto.LedgerCount;
 import com.sckw.payment.api.model.dto.SettlementMoney;
@@ -9,10 +12,7 @@ import com.sckw.payment.model.constant.LogisticsUnitType;
 import com.sckw.payment.model.constant.TradeUnitType;
 import com.sckw.payment.model.dto.LedgerSize;
 import com.sckw.payment.model.dto.MoneyType;
-import com.sckw.payment.service.KwpLedgerLogisticsService;
-import com.sckw.payment.service.KwpLedgerTradeService;
-import com.sckw.payment.service.KwpSettlementLogisticsService;
-import com.sckw.payment.service.KwpSettlementTradeService;
+import com.sckw.payment.service.*;
 import com.sckw.payment.utils.DateTimeUtil;
 import com.sckw.payment.utils.DecimalUtils;
 import lombok.RequiredArgsConstructor;
@@ -38,6 +38,8 @@ public class PaymentDubboServiceImpl implements PaymentDubboService {
     private final KwpLedgerTradeService kwpLedgerTradeService;
     private final KwpSettlementLogisticsService kwpSettlementLogisticsService;
     private final KwpSettlementTradeService kwpSettlementTradeService;
+    private final WalletService walletService;
+    private final KwpTradeFreezeService kwpTradeFreezeService;
 
 
     private SettlementMoney change(List<MoneyType> moneyType) {
@@ -56,6 +58,35 @@ public class PaymentDubboServiceImpl implements PaymentDubboService {
         return new SettlementMoney(df.format(curMoney), df.format(preMoney), percent, flag);
     }
 
+    @Override
+    public HttpResult freezeMoney(Long payEntId, ChannelEnum channel, Long receiveEntId, BigDecimal money, Long tOrderId) {
+        if (Objects.isNull(payEntId)) {
+            return HttpResult.error("支付企业不能为空");
+        }
+        if (Objects.isNull(channel)) {
+            return HttpResult.error("支付企业不能为空");
+        }
+        if (Objects.isNull(receiveEntId)) {
+            return HttpResult.error("收款企业不能为空");
+        }
+        if (Objects.isNull(money)) {
+            return HttpResult.error("订单金额不能为空");
+        }
+        long m;
+        try {
+            m = money.multiply(new BigDecimal("100")).longValueExact();
+        } catch (Exception e) {
+            log.error("金额转换异常:{}", e.getMessage(), e);
+            return HttpResult.error("金额异常");
+        }
+        //settlementTradeFreeze冻结订单编号规则
+        String orderNo = OrderUtils.generateOrderNo("STF");
+        HttpResult httpResult = walletService.freezeMoney(payEntId, channel, receiveEntId, m, orderNo);
+        //记录订单流水号
+        kwpTradeFreezeService.save(tOrderId, orderNo);
+        return httpResult;
+    }
+
     @Override
     public Map<OrderEnum, List<String>> checkLedger(Long entId, Long entTarget) {
         if (Objects.isNull(entId) || Objects.isNull(entTarget)) {

+ 2 - 2
sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerTradeMapper.xml

@@ -303,8 +303,8 @@
         order by klt.generate_time desc
     </select>
     <select id="countSum" resultType="com.sckw.payment.model.vo.res.LedgerCountSumVo">
-        select IFNULL(count(1), 0)  "ledgerCount",
-               sum(klt.total_price) "totalPrice"
+        select IFNULL(count(1), 0)   "ledgerCount",
+               sum(klt.settle_price) "totalPrice"
         from kwp_ledger_trade klt
                  inner join kwp_ledger_trade_unit kltu
                             on klt.id = kltu.t_ledger_id and kltu.del_flag = 0 and

+ 2 - 0
sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementWalletMapper.xml

@@ -6,6 +6,7 @@
         <!--@Table kwp_settlement_wallet-->
         <id column="id" jdbcType="BIGINT" property="id"/>
         <result column="ent_id" jdbcType="BIGINT" property="entId"/>
+        <result column="order_no" jdbcType="VARCHAR" property="orderNo"/>
         <result column="settlement_id" jdbcType="BIGINT" property="settlementId"/>
         <result column="order_type" jdbcType="INTEGER" property="orderType"/>
         <result column="channel" jdbcType="VARCHAR" property="channel"/>
@@ -25,6 +26,7 @@
     <sql id="Base_Column_List">
         id,
         ent_id,
+        order_no,
         settlement_id,
         order_type,
         channel,