Procházet zdrojové kódy

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

czh před 2 roky
rodič
revize
7704e993ab
54 změnil soubory, kde provedl 1570 přidání a 597 odebrání
  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. 0 3
      sckw-modules/sckw-order/src/main/java/com/sckw/order/dubbo/TradeOrderInfoServiceImpl.java
  10. 23 2
      sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwoTradeOrderService.java
  11. 5 5
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpSettlementWalletController.java
  12. 14 2
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/WalletController.java
  13. 7 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpLedgerTradeMapper.java
  14. 13 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpTradeFreezeMapper.java
  15. 5 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpWalletTransferMapper.java
  16. 2 2
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/job/AsyncPool.java
  17. 9 3
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpLedgerTradeOrder.java
  18. 5 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpSettlementWallet.java
  19. 69 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpTradeFreeze.java
  20. 3 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/constant/PayCenterEnum.java
  21. 25 2
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/wallet/CashDetail.java
  22. 0 15
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/wallet/CashDetailItem.java
  23. 22 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/wallet/CashLog.java
  24. 5 2
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/wallet/PatchPay.java
  25. 64 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/wallet/Recharge.java
  26. 18 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/wallet/RechargePage.java
  27. 17 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/CashDetailReq.java
  28. 40 3
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/CashDetailVo.java
  29. 3 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/ChargeDetailVo.java
  30. 19 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/Logs.java
  31. 23 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/PrePayDetailVo.java
  32. 4 4
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/WalletDetailBase.java
  33. 1 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerLogisticsOrderService.java
  34. 10 2
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerTradeService.java
  35. 306 292
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementWalletService.java
  36. 51 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpTradeFreezeService.java
  37. 47 33
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/MessageSender.java
  38. 34 4
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/PayCenterService.java
  39. 75 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/WalletBusinessService.java
  40. 287 99
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/WalletService.java
  41. 41 4
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/dubbo/PaymentDubboServiceImpl.java
  42. 2 2
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerTradeMapper.xml
  43. 14 3
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerTradeOrderMapper.xml
  44. 2 0
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementWalletMapper.xml
  45. 22 0
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpTradeFreezeMapper.xml
  46. 54 24
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpWalletTransferMapper.xml
  47. 1 1
      sckw-modules/sckw-product/src/main/java/com/sckw/product/service/KwpGoodsService.java
  48. 1 1
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/WaybillOrderDriverVo.java
  49. 75 20
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/CommonService.java
  50. 1 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/ConsignOrderService.java
  51. 11 6
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/KwtWaybillOrderService.java
  52. 1 1
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/WaybillManagementService.java
  53. 2 2
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/dubbo/TransportDubboServiceImpl.java
  54. 10 3
      sckw-modules/sckw-transport/src/main/resources/mapper/KwtWaybillOrderMapper.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

+ 0 - 3
sckw-modules/sckw-order/src/main/java/com/sckw/order/dubbo/TradeOrderInfoServiceImpl.java

@@ -129,9 +129,6 @@ public class TradeOrderInfoServiceImpl implements TradeOrderInfoService {
             }
             BigDecimal totalEntrustAmount = Objects.isNull(order.getEntrustAmount()) ?
                     entrustAmount : entrustAmount.add(order.getEntrustAmount());
-            if (order.getAmount().compareTo(totalEntrustAmount) < 0) {
-                return HttpResult.error("物流已委托总量不可大于订单总量!");
-            }
             order.setEntrustAmount(totalEntrustAmount).setUpdateBy(param.getUpdateBy());
             kwoTradeOrderService.updateById(order);
             //更新mongodb

+ 23 - 2
sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwoTradeOrderService.java

@@ -31,6 +31,7 @@ import com.sckw.order.model.dto.WbTOrderExcelStsResDTO;
 import com.sckw.order.model.vo.req.*;
 import com.sckw.order.model.vo.res.*;
 import com.sckw.payment.api.dubbo.PayCenterDubboService;
+import com.sckw.payment.api.dubbo.PaymentDubboService;
 import com.sckw.payment.api.model.constant.ChannelEnum;
 import com.sckw.payment.api.model.dto.WalletDto;
 import com.sckw.payment.api.model.dto.common.R;
@@ -86,6 +87,9 @@ public class KwoTradeOrderService {
     @DubboReference(version = "1.0.0", group = "design", check = false)
     private PayCenterDubboService payCenterDubboService;
 
+    @DubboReference(version = "1.0.0", group = "design", check = false)
+    private PaymentDubboService paymentDubboService;
+
     @DubboReference(version = "1.0.0", group = "design", check = false)
     private TransportDubboService transportDubboService;
 
@@ -444,7 +448,8 @@ public class KwoTradeOrderService {
         }
         //支付方式预付款校验
         if (trading.startsWith("1")) {
-            BigDecimal advancePrice = goods.getAdvancePrice().multiply(new BigDecimal("10000"));
+            BigDecimal decimal = Objects.isNull(goods.getAdvancePrice()) ? BigDecimal.ZERO : goods.getAdvancePrice();
+            BigDecimal advancePrice = decimal.multiply(new BigDecimal("10000"));
             //直接采购下单才校验预付款限额
             if (Objects.equals(param.getOrderSource(), OrderSourceEnum.PURCHASE.getType()) && price.compareTo(advancePrice) < 0) {
                 throw new BusinessException("您的订单总额未达到预付限额,请确认");
@@ -457,7 +462,7 @@ public class KwoTradeOrderService {
             if (CollectionUtils.isEmpty(data)) {
                 throw new BusinessException("检测尚未创建对应预付款清单,请先创建!");
             }
-            long money = data.get(0).getMoney();
+            long money = data.get(0).getApMoney();
             if (money < advancePrice.multiply(new BigDecimal("100")).longValueExact()) {
                 throw new BusinessException("您的预付清单可用余额不足,请先充值!");
             }
@@ -497,6 +502,14 @@ public class KwoTradeOrderService {
         if (!Objects.equals(HttpStatus.SUCCESS_CODE, updateResult.getCode())) {
             throw new BusinessException(updateResult.getMsg());
         }
+        //冻结金额
+        if (param.getTrading().startsWith("1")) {
+            HttpResult freezeResult = paymentDubboService.freezeMoney(orderCheck.getProcureTopEntId(),
+                    ChannelEnum.getByTrading(param.getTrading()), orderCheck.getSupplyTopEntId(), param.getPrice(), order.getId());
+            if (!Objects.equals(HttpStatus.SUCCESS_CODE, freezeResult.getCode())) {
+                throw new BusinessException(freezeResult.getMsg());
+            }
+        }
         addOtherOrderInfo(order, BeanUtils.copyProperties(param, ValetOrderParam.class), false);
         //发送消息提醒
         submitOrderSendMsg(orderCheck, order.getTOrderNo());
@@ -916,6 +929,14 @@ public class KwoTradeOrderService {
         getTopEnt(orderCheck, unitInfos);
         orderCheck.setGoodsId(goods.getGoodsId()).setAmount(amount);
         orderCheck(orderCheck, true);
+        //冻结金额
+        if (param.getTrading().startsWith("1")) {
+            HttpResult freezeResult = paymentDubboService.freezeMoney(orderCheck.getProcureTopEntId(),
+                    ChannelEnum.getByTrading(param.getTrading()), orderCheck.getSupplyTopEntId(), param.getPrice(), order.getId());
+            if (!Objects.equals(HttpStatus.SUCCESS_CODE, freezeResult.getCode())) {
+                throw new BusinessException(freezeResult.getMsg());
+            }
+        }
         //更新订单信息
         BeanUtils.copyProperties(param, order);
         ContractInfo contractInfo = param.getContractInfo();

+ 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

+ 14 - 2
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));
+    }
     /*预付-详细记录*/
 
     /**
@@ -358,7 +370,7 @@ public class WalletController {
      */
     @PostMapping("prePayOrder")
     public HttpResult prePayOrder(@RequestBody @Valid MoneyPage moneyPage) {
-        return HttpResult.ok(walletService.cashOrder(moneyPage));
+        return HttpResult.ok(walletService.prePayOrder(moneyPage));
     }
 
     /**
@@ -381,7 +393,7 @@ public class WalletController {
      */
     @PostMapping("preReceiveOrder")
     public HttpResult preReceiveOrder(@RequestBody @Valid MoneyPage moneyPage) {
-        return HttpResult.ok(walletService.cashOrder(moneyPage));
+        return HttpResult.ok(walletService.preReceiveOrder(moneyPage));
     }
 
     /**

+ 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);

+ 13 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpTradeFreezeMapper.java

@@ -0,0 +1,13 @@
+package com.sckw.payment.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.sckw.payment.model.KwpTradeFreeze;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+* @date 2023-09-20 17:32:24
+* @author xucaiqin
+*/
+@Mapper
+public interface KwpTradeFreezeMapper extends BaseMapper<KwpTradeFreeze> {
+}

+ 5 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpWalletTransferMapper.java

@@ -2,7 +2,11 @@ package com.sckw.payment.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.payment.model.KwpWalletTransfer;
+import com.sckw.payment.model.vo.req.page.MoneyPage;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
 * @date 2023-09-06 16:42:08
@@ -10,4 +14,5 @@ import org.apache.ibatis.annotations.Mapper;
 */
 @Mapper
 public interface KwpWalletTransferMapper extends BaseMapper<KwpWalletTransfer> {
+    List<KwpWalletTransfer> pageList(@Param("moneyPage") MoneyPage moneyPage);
 }

+ 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));

+ 9 - 3
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpLedgerTradeOrder.java

@@ -10,9 +10,10 @@ import java.time.LocalDateTime;
 
 /**
  * 对账-交易订单-对账关联交易订单
-* @date 2023-07-27 12:45:43
-* @author xucaiqin
-*/
+ *
+ * @author xucaiqin
+ * @date 2023-07-27 12:45:43
+ */
 @Data
 @TableName(value = "kwp_ledger_trade_order")
 public class KwpLedgerTradeOrder {
@@ -27,6 +28,11 @@ public class KwpLedgerTradeOrder {
      */
     @TableField(value = "t_ledger_id")
     private Long tLedgerId;
+    /**
+     * 中台订单号-冻结订单号
+     */
+    @TableField(value = "order_no")
+    private String orderNo;
 
     /**
      * 交易订单id(kwo_trade_order)

+ 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(交易订单结算/物流订单结算)

+ 69 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpTradeFreeze.java

@@ -0,0 +1,69 @@
+package com.sckw.payment.model;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+/**
+ * 贸易订单冻结单表
+* @date 2023-09-20 17:32:24
+* @author xucaiqin
+*/
+@Data
+@TableName(value = "kwp_trade_freeze")
+public class KwpTradeFreeze {
+    /**
+     * id
+     */
+    @TableId(value = "id", type = IdType.INPUT)
+    private Long id;
+
+    /**
+     * 贸易订单id
+     */
+    @TableField(value = "t_order_id")
+    private Long tOrderId;
+
+    /**
+     * 中台冻结订单号
+     */
+    @TableField(value = "order_no")
+    private String orderNo;
+
+    @TableField(value = "`status`")
+    private Integer status;
+
+    /**
+     * 创建人
+     */
+    @TableField(value = "create_by")
+    private Long createBy;
+
+    /**
+     * 创建时间
+     */
+    @TableField(value = "create_time")
+    private LocalDateTime createTime;
+
+    /**
+     * 更新人
+     */
+    @TableField(value = "update_by")
+    private Long updateBy;
+
+    /**
+     * 更新时间
+     */
+    @TableField(value = "update_time")
+    private LocalDateTime updateTime;
+
+    /**
+     * 0-正常 1-删除
+     */
+    @TableField(value = "del_flag")
+    private Integer delFlag;
+}

+ 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", "清分"),

+ 25 - 2
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/wallet/CashDetail.java

@@ -1,11 +1,34 @@
 package com.sckw.payment.model.dto.wallet;
 
+import com.alibaba.fastjson2.annotation.JSONField;
 import lombok.Data;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 @Data
 public class CashDetail {
-    private List<CashDetailItem> timeline;
-    private List<List<CashDetailItem>> content;
+
+    @JSONField(name = "uid")
+    private String uid;
+
+    private String channel;
+
+    @JSONField(name = "channel_label")
+    private String channelLabel;
+
+    @JSONField(name = "order_no")
+    private String orderNo;
+
+    private BigDecimal money;
+    @JSONField(name = "status")
+    private Integer status;
+    @JSONField(name = "status_label")
+    private String statusLabel;
+    @JSONField(name = "create_time")
+    private String createTime;
+    @JSONField(name = "finish_time")
+    private String finishTime;
+    private List<CashLog> logs;
+
 }

+ 0 - 15
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/wallet/CashDetailItem.java

@@ -1,15 +0,0 @@
-package com.sckw.payment.model.dto.wallet;
-
-import lombok.Data;
-
-import java.io.Serial;
-import java.io.Serializable;
-
-@Data
-public class CashDetailItem implements Serializable {
-    @Serial
-    private static final long serialVersionUID = 7233982475006805580L;
-    private String color;
-    private String title;
-    private String value;
-}

+ 22 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/wallet/CashLog.java

@@ -0,0 +1,22 @@
+package com.sckw.payment.model.dto.wallet;
+
+import com.alibaba.fastjson2.annotation.JSONField;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+@Data
+public class CashLog implements Serializable {
+    @Serial
+    private static final long serialVersionUID = 7233982475006805580L;
+    private String orderNo;
+    @JSONField(name = "status")
+    private Integer status;
+    @JSONField(name = "status_label")
+    private String statusLabel;
+    @JSONField(name = "content")
+    private String content;
+    @JSONField(name = "create_time")
+    private String createTime;
+}

+ 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;
+}

+ 40 - 3
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/CashDetailVo.java

@@ -1,8 +1,12 @@
 package com.sckw.payment.model.vo.res;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.math.BigDecimal;
+import java.util.List;
+
 /**
  * 提现详情信息
  *
@@ -11,10 +15,43 @@ import lombok.Setter;
  */
 @Getter
 @Setter
-public class CashDetailVo extends WalletDetailBase {
+public class CashDetailVo implements MoneyChange {
+    /**
+     * 业务流水号
+     */
+    private String orderNo;
+    /**
+     * 渠道
+     */
+    private String channel;
+    private String channelDict;
+    private String channelLabel;
+
+    private String uid;
+    private String uidName;
     /**
-     * 操作说明
+     * 业务明细
      */
-    private String desc;
+    private Integer status;
+    private String statusLabel;
 
+    /**
+     * 提现金额
+     */
+    private BigDecimal money;
+
+    /**
+     * 创建时间
+     */
+    @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 finishTime;
+    /**
+     * 明细
+     */
+    private List<Logs> logs;
 }

+ 3 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/ChargeDetailVo.java

@@ -1,5 +1,6 @@
 package com.sckw.payment.model.vo.res;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -18,5 +19,7 @@ public class ChargeDetailVo extends WalletDetailBase {
      * 变更后余额
      */
     private BigDecimal balance;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private String payTime;
 
 }

+ 19 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/Logs.java

@@ -0,0 +1,19 @@
+package com.sckw.payment.model.vo.res;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @author xucaiqin
+ * @date 2023-09-21 09:51:56
+ */
+@Getter
+@Setter
+public class Logs {
+    private String orderNo;
+    private String channelLabel;
+    private Integer status;
+    private String statusLabel;
+    private String remark;
+    private String createTime;
+}

+ 23 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/PrePayDetailVo.java

@@ -0,0 +1,23 @@
+package com.sckw.payment.model.vo.res;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+
+/**
+ * 预付详细记录
+ *
+ * @author xucaiqin
+ * @date 2023-08-28 15:43:49
+ */
+@Getter
+@Setter
+public class PrePayDetailVo extends WalletDetailBase {
+    /**
+     * 变更后余额
+     */
+    private BigDecimal balance;
+
+
+}

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

@@ -5,7 +5,6 @@ import lombok.Getter;
 import lombok.Setter;
 
 import java.math.BigDecimal;
-import java.time.LocalDateTime;
 
 /**
  * 钱包详情基础信息
@@ -15,7 +14,7 @@ import java.time.LocalDateTime;
  */
 @Getter
 @Setter
-public class WalletDetailBase {
+public class WalletDetailBase implements MoneyChange {
     /**
      * 业务流水号
      */
@@ -49,6 +48,7 @@ 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;
+
 }

+ 1 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerLogisticsOrderService.java

@@ -51,7 +51,7 @@ public class KwpLedgerLogisticsOrderService {
     /**
      * 根据id查询
      *
-     * @param id
+     * @param id 物流对账单id
      * @return
      */
     public List<KwpLedgerLogisticsOrder> queryList(Long id) {

+ 10 - 2
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerTradeService.java

@@ -59,6 +59,7 @@ public class KwpLedgerTradeService extends AbsLedger {
     private final KwpLedgerTradeTrackService tradeTrackService;
     private final KwpLedgerTradeOrderService tradeOrderService;
     private final KwpLedgerTradeUnitService tradeUnitService;
+    private final KwpTradeFreezeService kwpTradeFreezeService;
     private final MessageSender messageSender;
     @Resource
     private KwpSettlementTradeService kwpSettlementTradeService;
@@ -146,7 +147,7 @@ public class KwpLedgerTradeService extends AbsLedger {
         tradeReq.setUnitType(TradeUnitType.PURCHASE);
         tradeReq.setUnitTypeTwo(TradeUnitType.SELL);
         List<Integer> status = new ArrayList<>();
-        return tradeMapper.countSum(tradeReq,status);
+        return tradeMapper.countSum(tradeReq, status);
     }
 
     /**
@@ -246,11 +247,18 @@ public class KwpLedgerTradeService extends AbsLedger {
         //校验当前订单是否已存在绑定的对账单
         tradeOrderService.check(ids);
         List<OrderDetailRes> resList = new ArrayList<>();
+        Map<Long, String> map = new HashMap<>();
+
         for (Long id : ids) {
             OrderDetailRes orderDetailById = tradeOrderInfoService.getOrderDetailById(id);
             if (Objects.isNull(orderDetailById)) {
                 throw new BusinessException("订单未找到");
             }
+            KwpTradeFreeze byTOrderId = kwpTradeFreezeService.getByTOrderId(id);
+            if (Objects.isNull(byTOrderId)) {
+                throw new BusinessException("未找到关联的冻结单");
+            }
+            map.put(id, byTOrderId.getOrderNo());
             resList.add(orderDetailById);
         }
         for (Long id : ids) {
@@ -262,10 +270,10 @@ public class KwpLedgerTradeService extends AbsLedger {
             updateAssociateStatementParam.setUpdateByName(LoginUserHolder.getUserName());
             tradeOrderInfoService.updateAssociateStatement(updateAssociateStatementParam);
         }
-
         List<KwpLedgerTradeOrder> collect = resList.stream().map(a -> {
             KwpLedgerTradeOrder kwpLedgerTradeOrder = new KwpLedgerTradeOrder();
             kwpLedgerTradeOrder.setId(new IdWorker(NumberConstant.ONE).nextId());
+            kwpLedgerTradeOrder.setOrderNo(map.get(a.getId()));
             kwpLedgerTradeOrder.setTLedgerId(kwpLedgerTrade.getId());
             kwpLedgerTradeOrder.setTOrderId(a.getId());
             kwpLedgerTradeOrder.setTOrderNo(a.getTOrderNo());

+ 306 - 292
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;
@@ -26,6 +30,7 @@ import com.sckw.payment.model.dto.LedgerUnitDto;
 import com.sckw.payment.model.dto.SettlementLogisticsDto;
 import com.sckw.payment.model.dto.SettlementTradeDto;
 import com.sckw.payment.model.dto.SettlementWalletDto;
+import com.sckw.payment.model.dto.common.BusinessNo;
 import com.sckw.payment.model.vo.SettlementVo;
 import com.sckw.payment.model.vo.req.OfflinePaymentReq;
 import com.sckw.payment.model.vo.req.SettlementWalletReq;
@@ -37,6 +42,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 +50,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 +70,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 +169,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 +179,6 @@ public class KwpSettlementWalletService {
         if (price == null || price.compareTo(BigDecimal.ZERO) == 0) {
             throw new BusinessException("结算参数金额必填");
         }
-
         //先查询出结算单情况
         SettlementLogisticsDto settlementLogisticsDto = kwpSettlementLogisticsService.detailPayment(id);
         //检查结算单状态和所差金额
@@ -198,114 +201,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));
+//    }
 
 
     /**
@@ -318,50 +356,33 @@ public class KwpSettlementWalletService {
     public String confirmTradePayment(WalletPayReq walletPayReq) {
         log.info("采购-付款确认-货到付款:{}", JSONObject.toJSONString(walletPayReq));
         String key = String.format(RedisConstant.SETTLEMENT_KEY, walletPayReq.getId());
+        SettlementTradeDto byId = kwpSettlementTradeService.getById(walletPayReq.getIdLong(), TradeUnitType.SELL);
+        if (Objects.isNull(byId)) {
+            throw new BusinessException("结算单不存在");
+        }
+        if (StringUtils.isNotBlank(byId.getTrading()) && !byId.getTrading().startsWith(TradingEnum.RECEIVE_PAY.getValue())) {
+            throw new BusinessException("只支持货货到付款方式订单进行当前操作");
+        }
+        KwpLedgerTradeUnit kwpLedgerTradeUnit = tradeUnitService.queryCustomerEnt(byId.getLedgerId(), TradeUnitType.PURCHASE);
+        KwpLedgerTradeUnit kwpLedgerTradeUnit2 = tradeUnitService.queryCustomerEnt(byId.getLedgerId(), TradeUnitType.SELL);
+        String uid = walletRelationService.getRelation(kwpLedgerTradeUnit.getTopEntId());
+        String filter = walletRelationService.getRelation(kwpLedgerTradeUnit2.getTopEntId());
+        if (StringUtils.isBlank(uid)) {
+            throw new BusinessException("我方企业暂未开通电子钱包");
+        }
+        if (StringUtils.isBlank(filter)) {
+            throw new BusinessException("客户企业暂未开通电子钱包");
+        }
+        ChannelEnum channelEnum = ChannelEnum.getByTrading(byId.getTrading());
+        if (Objects.isNull(channelEnum)) {
+            throw new BusinessException("交易方式不存在");
+        }
+        //付款金额
+        BigDecimal price = walletPayReq.getPrice();
         if (redisLockUtil.tryLock(key)) {
             try {
-                SettlementTradeDto byId = kwpSettlementTradeService.getById(walletPayReq.getIdLong(), 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(walletPayReq.getIdLong());
-                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("顶级企业未开通电子钱包");
-                }
-                //付款金额
-                BigDecimal price = walletPayReq.getPrice();
-                //todo-xcq-完善
-
-//        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();
-//        BigDecimal bigDecimal = BigDecimal.valueOf(data.get(0).getMoney()).divide(new BigDecimal("100.0"), RoundingMode.UNNECESSARY);
-//
-//        if (bigDecimal.compareTo(price) < 0) {
-//            throw new BusinessException("钱包可用余额不足");
-//        }
+                //电子钱包余额校验
+                walletBusinessService.checkMoney(uid, filter, channelEnum, price);
                 //待付款金额-本次付款金额= 剩余待付款金额
                 BigDecimal subtract = byId.getWaitPrice().subtract(walletPayReq.getPrice());
                 if (subtract.compareTo(new BigDecimal("0.0")) < NumberConstant.ZERO) {
@@ -369,9 +390,11 @@ public class KwpSettlementWalletService {
                 }
                 /*新增记录*/
                 //新增电子钱包结算记录
+                String orderNo = OrderUtils.generateOrderNo("ST");
                 KwpSettlementWallet kwpSettlementWallet = new KwpSettlementWallet();
                 kwpSettlementWallet.setId(new IdWorker(NumberConstant.ONE).nextId());
                 kwpSettlementWallet.setEntId(LoginUserHolder.getEntId());
+                kwpSettlementWallet.setOrderNo(orderNo);
                 kwpSettlementWallet.setSettlementId(walletPayReq.getIdLong());
                 kwpSettlementWallet.setOrderType(SettlementOrderTypeEnum.TRADE.getStatus());
                 kwpSettlementWallet.setChannel(WalletChannelEnum.getValue(byId.getTrading()));
@@ -393,8 +416,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());
@@ -418,9 +440,9 @@ public class KwpSettlementWalletService {
                         tradeOrderInfoService.updateOrderStatus(updateOrderStatusParam);
                     }
                 }
+                //电子钱包清分接口
+                walletBusinessService.splitMoney(orderNo, uid, filter, channelEnum, price, "2");
 
-                KwpLedgerTradeUnit kwpLedgerTradeUnit = tradeUnitService.queryCustomerEnt(byId.getLedgerId(), TradeUnitType.PURCHASE);
-                KwpLedgerTradeUnit kwpLedgerTradeUnit2 = tradeUnitService.queryCustomerEnt(byId.getLedgerId(), TradeUnitType.SELL);
                 //推送双方系统管理员
                 messageSender.sendManager(LoginUserHolder.getUserId(), new HashMap<>() {{
                     put("company", kwpLedgerTradeUnit.getFirmName());
@@ -430,9 +452,6 @@ public class KwpSettlementWalletService {
                     put("company", kwpLedgerTradeUnit2.getFirmName());
                     put("number", kwpSettlementTrade.getStOrderNo());
                 }}, kwpLedgerTradeUnit.getEntId(), MessageEnum.SETTLEMENT_START_PURCHASE);
-
-                //todo-xcq 调用中台接口
-
                 return "付款确认成功";
             } finally {
                 redisLockUtil.unlock(key);
@@ -488,50 +507,52 @@ 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));
+//    }
 
     /**
      * 销售-预付款
+     * 贸易订单下单时,冻结资金
+     * 预付款结算时,解冻资金。在进行清分。
      *
      * @param id 结算单id
      * @return
@@ -540,20 +561,39 @@ public class KwpSettlementWalletService {
     public String confirmTradeCollection(Long id) {
         log.info("销售预付款确认,结算单id:{}", id);
         String key = String.format(RedisConstant.SETTLEMENT_KEY, id);
-
+        SettlementTradeDto byId = kwpSettlementTradeService.getById(id, TradeUnitType.PURCHASE);
+        if (Objects.isNull(byId)) {
+            throw new BusinessException("结算单不存在");
+        }
+        if (StringUtils.isNotBlank(byId.getTrading()) && !byId.getTrading().startsWith(TradingEnum.PRE_PAY.getValue())) {
+            throw new BusinessException("只支持预付款交易方式进行预付款确认操作");
+        }
+        //冻结编号非空校验
+        List<KwpLedgerTradeOrder> kwpLedgerTradeOrders = tradeOrderService.queryList(byId.getLedgerId());
+        if (CollectionUtils.isEmpty(kwpLedgerTradeOrders)) {
+            throw new BusinessException("未找到关联的贸易订单");
+        }
+        for (KwpLedgerTradeOrder kwpLedgerTradeOrder : kwpLedgerTradeOrders) {
+            if (StringUtils.isBlank(kwpLedgerTradeOrder.getOrderNo())) {
+                throw new BusinessException(String.format("为找到贸易订单id[%s]的冻结单号", kwpLedgerTradeOrder.getTOrderId()));
+            }
+        }
+        KwpLedgerTradeUnit kwpLedgerTradeUnit = tradeUnitService.queryCustomerEnt(byId.getLedgerId(), TradeUnitType.PURCHASE);
+        KwpLedgerTradeUnit kwpLedgerTradeUnit2 = tradeUnitService.queryCustomerEnt(byId.getLedgerId(), TradeUnitType.SELL);
+        String uid = walletRelationService.getRelation(kwpLedgerTradeUnit.getTopEntId());
+        if (StringUtils.isBlank(uid)) {
+            throw new BusinessException("客户单位暂未开通电子钱包");
+        }
+        String filter = walletRelationService.getRelation(kwpLedgerTradeUnit2.getTopEntId());
+        if (StringUtils.isBlank(filter)) {
+            throw new BusinessException("我方单位暂未开通电子钱包");
+        }
+        ChannelEnum channelEnum = ChannelEnum.getByTrading(byId.getTrading());
+        if (Objects.isNull(channelEnum)) {
+            throw new BusinessException("交易方式不存在");
+        }
         if (redisLockUtil.tryLock(key)) {
             try {
-                SettlementTradeDto byId = kwpSettlementTradeService.getById(id, TradeUnitType.PURCHASE);
-                if (Objects.isNull(byId)) {
-                    throw new BusinessException("结算单不存在");
-                }
-                if (StringUtils.isNotBlank(byId.getTrading()) && !byId.getTrading().startsWith(TradingEnum.PRE_PAY.getValue())) {
-                    throw new BusinessException("只支持预付款交易方式进行预付款确认操作");
-                }
-                List<KwpLedgerTradeOrder> kwpLedgerTradeOrders = tradeOrderService.queryList(byId.getLedgerId());
-                if (CollectionUtils.isEmpty(kwpLedgerTradeOrders)) {
-                    throw new BusinessException("未找到关联的贸易订单");
-                }
                 //更新交易结算单状态和金额
                 KwpSettlementTrade kwpSettlementTrade = new KwpSettlementTrade();
                 kwpSettlementTrade.setId(byId.getId());
@@ -565,9 +605,12 @@ public class KwpSettlementWalletService {
                 //预付款-更新对账单已付金额
                 kwpLedgerTradeService.updateActualPrice(byId.gettLedgerId(), byId.getTotalPrice());
                 //新增电子钱包结算记录
+                //清分单号
+                String orderNo = OrderUtils.generateOrderNo("ST");
                 KwpSettlementWallet kwpSettlementWallet = new KwpSettlementWallet();
                 kwpSettlementWallet.setId(new IdWorker(1).nextId());
                 kwpSettlementWallet.setEntId(LoginUserHolder.getEntId());
+                kwpSettlementWallet.setOrderNo(orderNo);
                 kwpSettlementWallet.setSettlementId(byId.getId());
                 kwpSettlementWallet.setOrderType(SettlementOrderTypeEnum.TRADE.getStatus());
                 kwpSettlementWallet.setChannel(WalletChannelEnum.getValue(byId.getTrading()));
@@ -594,8 +637,17 @@ public class KwpSettlementWalletService {
                     tradeOrderInfoService.updateOrderStatus(updateOrderStatusParam);
                 }
 
-                KwpLedgerTradeUnit kwpLedgerTradeUnit = tradeUnitService.queryCustomerEnt(byId.getLedgerId(), TradeUnitType.PURCHASE);
-                KwpLedgerTradeUnit kwpLedgerTradeUnit2 = tradeUnitService.queryCustomerEnt(byId.getLedgerId(), TradeUnitType.SELL);
+
+                /*电子钱包相关业务*/
+                //批量获取对账单关联的贸易订单 再获取冻结编号,批量解冻
+                for (KwpLedgerTradeOrder kwpLedgerTradeOrder : kwpLedgerTradeOrders) {
+                    R<BusinessNo> businessNoR = payCenterService.walletUnFreeze(kwpLedgerTradeOrder.getOrderNo());
+                    if (!businessNoR.getStatus()) {
+                        throw new BusinessException(businessNoR.getMsg());
+                    }
+                }
+                //对结算单中的总计金额进行清分
+                walletBusinessService.splitMoney(orderNo, uid, filter, channelEnum, byId.getTotalPrice(), "1");
                 //推送双方系统管理员
                 messageSender.sendManager(LoginUserHolder.getUserId(), new HashMap<>() {{
                     put("company", kwpLedgerTradeUnit.getFirmName());
@@ -608,42 +660,34 @@ public class KwpSettlementWalletService {
 
                 //todo-xcq 调用中台接口
 
+
                 return "确认回款成功";
             } finally {
                 redisLockUtil.unlock(key);
             }
         }
         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 +698,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 +737,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);
     }
 
     /**

+ 51 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpTradeFreezeService.java

@@ -0,0 +1,51 @@
+package com.sckw.payment.service;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.sckw.core.common.enums.NumberConstant;
+import com.sckw.core.model.constant.Global;
+import com.sckw.core.utils.IdWorker;
+import com.sckw.core.web.context.LoginUserHolder;
+import com.sckw.payment.dao.KwpTradeFreezeMapper;
+import com.sckw.payment.model.KwpTradeFreeze;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+
+import java.time.LocalDateTime;
+
+/**
+ * @author xucaiqin
+ * @date 2023-09-20 17:32:24
+ */
+@Service
+@RequiredArgsConstructor
+public class KwpTradeFreezeService {
+    private final KwpTradeFreezeMapper kwpTradeFreezeMapper;
+
+    /**
+     * 通过贸易订单id查询
+     *
+     * @param tOrderId 贸易订单id
+     * @return 冻结订单号
+     */
+    public KwpTradeFreeze getByTOrderId(Long tOrderId) {
+        LambdaQueryWrapper<KwpTradeFreeze> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(KwpTradeFreeze::getTOrderId, tOrderId)
+                .eq(KwpTradeFreeze::getDelFlag, Global.UN_DELETED).last("limit 1");
+        return kwpTradeFreezeMapper.selectOne(wrapper);
+    }
+
+    public void save(Long tOrderId, String orderNo) {
+        KwpTradeFreeze kwpTradeFreeze = new KwpTradeFreeze();
+        kwpTradeFreeze.setId(new IdWorker(NumberConstant.ONE).nextId());
+        kwpTradeFreeze.setTOrderId(tOrderId);
+        kwpTradeFreeze.setOrderNo(orderNo);
+        kwpTradeFreeze.setStatus(0);
+        kwpTradeFreeze.setCreateBy(LoginUserHolder.getUserId());
+        kwpTradeFreeze.setCreateTime(LocalDateTime.now());
+        kwpTradeFreeze.setUpdateBy(LoginUserHolder.getUserId());
+        kwpTradeFreeze.setUpdateTime(LocalDateTime.now());
+        kwpTradeFreeze.setDelFlag(Global.UN_DELETED);
+        kwpTradeFreezeMapper.insert(kwpTradeFreeze);
+    }
+
+}

+ 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);
+        });
     }
 }

+ 34 - 4
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<>() {
+        });
+    }
+
     /**
      * 创建/更新账户
      *
@@ -774,7 +804,7 @@ public class PayCenterService {
             put("filter", filter);
             put("channel", channel);
             put("money", money);
-            put("businessNo", businessNo);
+            put("business_no", businessNo);
         }});
         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(businessNoR.getMsg());
+        }
+    }
+}

+ 287 - 99
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/WalletService.java

@@ -2,6 +2,7 @@ package com.sckw.payment.service;
 
 import com.alibaba.fastjson2.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.sckw.core.common.enums.NumberConstant;
 import com.sckw.core.exception.BusinessException;
@@ -12,6 +13,7 @@ import com.sckw.core.utils.IdWorker;
 import com.sckw.core.utils.OrderUtils;
 import com.sckw.core.utils.StringTimeUtil;
 import com.sckw.core.web.context.LoginUserHolder;
+import com.sckw.core.web.response.HttpResult;
 import com.sckw.manage.api.RemoteManageService;
 import com.sckw.manage.api.model.dto.res.FindEntCooperateResVo;
 import com.sckw.payment.api.model.constant.ChannelEnum;
@@ -34,10 +36,11 @@ import com.sckw.payment.model.dto.page.PrePayWalletPage;
 import com.sckw.payment.model.dto.wallet.*;
 import com.sckw.payment.model.vo.PrePayWalletVo;
 import com.sckw.payment.model.vo.req.*;
-import com.sckw.payment.model.vo.req.page.PrePayPage;
 import com.sckw.payment.model.vo.req.page.MoneyPage;
+import com.sckw.payment.model.vo.req.page.PrePayPage;
 import com.sckw.payment.model.vo.req.page.RefundPage;
 import com.sckw.payment.model.vo.res.*;
+import com.sckw.payment.utils.DateTimeUtil;
 import com.sckw.redis.config.RedisLockUtil;
 import com.sckw.redis.constant.RedisLockKey;
 import com.sckw.system.api.RemoteSystemService;
@@ -81,6 +84,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转为企业名称
      *
@@ -114,6 +131,19 @@ public class WalletService {
         return walletRelationService.getEnt(id);
     }
 
+    /**
+     * 查询中台用户id
+     *
+     * @param id
+     * @return
+     */
+    private String getUid(Long id) {
+        if (Objects.isNull(id)) {
+            return null;
+        }
+        return walletRelationService.getRelation(id);
+    }
+
     /**
      * 通过企业名称查询关联的中台用户id
      *
@@ -1268,26 +1298,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<>());
     }
 
     /**
@@ -1297,25 +1337,31 @@ public class WalletService {
      * @return
      */
     public PageRes<WalletDetailBase> transferOrder(MoneyPage moneyPage) {
-        WalletDetailBase chargeDetailVo = new WalletDetailBase();
-        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<WalletDetailBase> objects = new ArrayList<>() {{
-            add(chargeDetailVo);
-        }};
-        PageInfo<WalletDetailBase> objectPageInfo = new PageInfo<>();
-        return new PageRes<>(objectPageInfo, objects);
+        fillPara(moneyPage);
+        PageHelper.startPage(moneyPage.getPage(), moneyPage.getPageSize());
+        List<KwpWalletTransfer> kwpWalletTransfers = kwpWalletTransferMapper.pageList(moneyPage);
+        PageInfo<KwpWalletTransfer> pageInfo = new PageInfo<>(kwpWalletTransfers);
+        ArrayList<WalletDetailBase> res = new ArrayList<>();
+        WalletDetailBase walletDetailBase;
+
+        for (KwpWalletTransfer kwpWalletTransfer : kwpWalletTransfers) {
+            walletDetailBase = new WalletDetailBase();
+            walletDetailBase.setOrderNo(kwpWalletTransfer.getOrderNo());
+            walletDetailBase.setChannel(kwpWalletTransfer.getChannel());
+            walletDetailBase.setChannelDict(ChannelEnum.getDict(kwpWalletTransfer.getChannel()));
+            walletDetailBase.setChannelLabel(ChannelEnum.getDesc(kwpWalletTransfer.getChannel()));
+            walletDetailBase.setUid(kwpWalletTransfer.getUid());
+            walletDetailBase.setUidName(getFirmName(kwpWalletTransfer.getUid()));
+            walletDetailBase.setFilter(kwpWalletTransfer.getFilter());
+            walletDetailBase.setFilterName(getFirmName(kwpWalletTransfer.getFilter()));
+            walletDetailBase.setStatus(kwpWalletTransfer.getStatus());
+            walletDetailBase.setStatusLabel(TransferEnum.getDesc(kwpWalletTransfer.getStatus()));
+            walletDetailBase.setMoney(kwpWalletTransfer.getMoney());
+            walletDetailBase.setRemark(kwpWalletTransfer.getRemark());
+            walletDetailBase.setCreateTime(DateTimeUtil.format(kwpWalletTransfer.getCreateTime()));
+            res.add(walletDetailBase);
+        }
+        return PageRes.build(pageInfo, res);
     }
 
     /**
@@ -1325,25 +1371,36 @@ public class WalletService {
      * @return
      */
     public PageRes<WalletDetailBase> refundOrder(MoneyPage moneyPage) {
-        WalletDetailBase chargeDetailVo = new WalletDetailBase();
-        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<WalletDetailBase> objects = new ArrayList<>() {{
-            add(chargeDetailVo);
-        }};
-        PageInfo<WalletDetailBase> objectPageInfo = new PageInfo<>();
-        return new PageRes<>(objectPageInfo, objects);
+        if (StringUtils.isNotBlank(moneyPage.getStartCreateTime())) {
+            moneyPage.setStartCreateTime(StringTimeUtil.fillStart(moneyPage.getStartCreateTime()));
+        }
+        if (StringUtils.isNotBlank(moneyPage.getEndCreateTime())) {
+            moneyPage.setEndCreateTime(StringTimeUtil.fillEnd(moneyPage.getEndCreateTime()));
+        }
+        RefundPage refundPage = new RefundPage();
+        BeanUtils.copyProperties(moneyPage, refundPage);
+        PageRes<WalletRefundVo> walletRefundVoPageRes = walletOrderService.queryRefundList(refundPage);
+        List<WalletRefundVo> list = walletRefundVoPageRes.getList();
+        List<WalletDetailBase> res = new ArrayList<>();
+        WalletDetailBase walletDetailBase;
+        for (WalletRefundVo walletRefundVo : list) {
+            walletDetailBase = new WalletDetailBase();
+            walletDetailBase.setOrderNo(walletRefundVo.getOrderNo());
+            walletDetailBase.setChannel(walletRefundVo.getChannel());
+            walletDetailBase.setChannelDict(ChannelEnum.getDict(walletRefundVo.getChannel()));
+            walletDetailBase.setChannelLabel(ChannelEnum.getDesc(walletRefundVo.getChannel()));
+            walletDetailBase.setUid(walletRefundVo.getUid());
+            walletDetailBase.setUidName(getFirmName(walletRefundVo.getUid()));
+            walletDetailBase.setFilter(walletRefundVo.getFilter());
+            walletDetailBase.setFilterName(getFirmName(walletRefundVo.getFilter()));
+            walletDetailBase.setStatus(walletRefundVo.getStatus());
+            walletDetailBase.setStatusLabel(RefundEnum.getDesc(walletRefundVo.getStatus()));
+            walletDetailBase.setMoney(walletRefundVo.getMoney());
+            walletDetailBase.setRemark(walletRefundVo.getRemark());
+            walletDetailBase.setCreateTime(DateTimeUtil.format(walletRefundVo.getCreateTime()));
+            res.add(walletDetailBase);
+        }
+        return new PageRes<>(walletRefundVoPageRes.getPage(), walletRefundVoPageRes.getPageSize(), walletRefundVoPageRes.getSize(), walletRefundVoPageRes.getPages(), res);
     }
 
     /**
@@ -1352,9 +1409,8 @@ public class WalletService {
      * @param moneyPage
      * @return
      */
-    public PageRes<ChargeDetailVo> cashOrder(MoneyPage moneyPage) {
-        ChargeDetailVo chargeDetailVo = new ChargeDetailVo();
-        chargeDetailVo.setBalance(new BigDecimal("0"));
+    public PageRes<WalletDetailBase> cashOrder(MoneyPage moneyPage) {
+        WalletDetailBase chargeDetailVo = new WalletDetailBase();
         chargeDetailVo.setOrderNo("");
         chargeDetailVo.setChannel("");
         chargeDetailVo.setChannelDict("");
@@ -1367,11 +1423,11 @@ public class WalletService {
         chargeDetailVo.setStatusLabel("");
         chargeDetailVo.setMoney(new BigDecimal("0"));
         chargeDetailVo.setRemark("");
-        chargeDetailVo.setCreateTime(LocalDateTime.now());
-        List<ChargeDetailVo> objects = new ArrayList<>() {{
+//        chargeDetailVo.setCreateTime(LocalDateTime.now());
+        List<WalletDetailBase> objects = new ArrayList<>() {{
             add(chargeDetailVo);
         }};
-        PageInfo<ChargeDetailVo> objectPageInfo = new PageInfo<>();
+        PageInfo<WalletDetailBase> objectPageInfo = new PageInfo<>();
         return new PageRes<>(objectPageInfo, objects);
     }
 
@@ -1382,25 +1438,36 @@ public class WalletService {
      * @return
      */
     public PageRes<WalletDetailBase> prePayRefund(MoneyPage moneyPage) {
-        WalletDetailBase chargeDetailVo = new WalletDetailBase();
-        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<WalletDetailBase> objects = new ArrayList<>() {{
-            add(chargeDetailVo);
-        }};
-        PageInfo<WalletDetailBase> objectPageInfo = new PageInfo<>();
-        return new PageRes<>(objectPageInfo, objects);
+        if (StringUtils.isNotBlank(moneyPage.getStartCreateTime())) {
+            moneyPage.setStartCreateTime(StringTimeUtil.fillStart(moneyPage.getStartCreateTime()));
+        }
+        if (StringUtils.isNotBlank(moneyPage.getEndCreateTime())) {
+            moneyPage.setEndCreateTime(StringTimeUtil.fillEnd(moneyPage.getEndCreateTime()));
+        }
+        RefundPage refundPage = new RefundPage();
+        BeanUtils.copyProperties(moneyPage, refundPage);
+        PageRes<WalletRefundVo> walletRefundVoPageRes = walletOrderService.queryRefundList(refundPage);
+        List<WalletRefundVo> list = walletRefundVoPageRes.getList();
+        List<WalletDetailBase> res = new ArrayList<>();
+        WalletDetailBase walletDetailBase;
+        for (WalletRefundVo walletRefundVo : list) {
+            walletDetailBase = new WalletDetailBase();
+            walletDetailBase.setOrderNo(walletRefundVo.getOrderNo());
+            walletDetailBase.setChannel(walletRefundVo.getChannel());
+            walletDetailBase.setChannelDict(ChannelEnum.getDict(walletRefundVo.getChannel()));
+            walletDetailBase.setChannelLabel(ChannelEnum.getDesc(walletRefundVo.getChannel()));
+            walletDetailBase.setUid(walletRefundVo.getUid());
+            walletDetailBase.setUidName(getFirmName(walletRefundVo.getUid()));
+            walletDetailBase.setFilter(walletRefundVo.getFilter());
+            walletDetailBase.setFilterName(getFirmName(walletRefundVo.getFilter()));
+            walletDetailBase.setStatus(walletRefundVo.getStatus());
+            walletDetailBase.setStatusLabel(RefundEnum.getDesc(walletRefundVo.getStatus()));
+            walletDetailBase.setMoney(walletRefundVo.getMoney());
+            walletDetailBase.setRemark(walletRefundVo.getRemark());
+            walletDetailBase.setCreateTime(DateTimeUtil.format(walletRefundVo.getCreateTime()));
+            res.add(walletDetailBase);
+        }
+        return new PageRes<>(walletRefundVoPageRes.getPage(), walletRefundVoPageRes.getPageSize(), walletRefundVoPageRes.getSize(), walletRefundVoPageRes.getPages(), res);
     }
 
     /**
@@ -1410,24 +1477,145 @@ public class WalletService {
      * @return
      */
     public PageRes<WalletDetailBase> preReceiveRefund(MoneyPage moneyPage) {
-        WalletDetailBase chargeDetailVo = new WalletDetailBase();
-        chargeDetailVo.setOrderNo("");
-        chargeDetailVo.setChannel("");
-        chargeDetailVo.setChannelDict("");
-        chargeDetailVo.setChannelLabel("");
-        chargeDetailVo.setUid("");
-        chargeDetailVo.setUidName("");
-        chargeDetailVo.setFilter("");
-        chargeDetailVo.setFilterName("");
+        if (StringUtils.isNotBlank(moneyPage.getStartCreateTime())) {
+            moneyPage.setStartCreateTime(StringTimeUtil.fillStart(moneyPage.getStartCreateTime()));
+        }
+        if (StringUtils.isNotBlank(moneyPage.getEndCreateTime())) {
+            moneyPage.setEndCreateTime(StringTimeUtil.fillEnd(moneyPage.getEndCreateTime()));
+        }
+        String uid = moneyPage.getUid();
+        String filter = moneyPage.getFilter();
+        moneyPage.setUid(filter);
+        moneyPage.setFilter(uid);
+        RefundPage refundPage = new RefundPage();
+        BeanUtils.copyProperties(moneyPage, refundPage);
+        PageRes<WalletRefundVo> walletRefundVoPageRes = walletOrderService.queryRefundList(refundPage);
+        List<WalletRefundVo> list = walletRefundVoPageRes.getList();
+        List<WalletDetailBase> res = new ArrayList<>();
+        WalletDetailBase walletDetailBase;
+        for (WalletRefundVo walletRefundVo : list) {
+            walletDetailBase = new WalletDetailBase();
+            walletDetailBase.setOrderNo(walletRefundVo.getOrderNo());
+            walletDetailBase.setChannel(walletRefundVo.getChannel());
+            walletDetailBase.setChannelDict(ChannelEnum.getDict(walletRefundVo.getChannel()));
+            walletDetailBase.setChannelLabel(ChannelEnum.getDesc(walletRefundVo.getChannel()));
+            walletDetailBase.setUid(walletRefundVo.getUid());
+            walletDetailBase.setUidName(getFirmName(walletRefundVo.getUid()));
+            walletDetailBase.setFilter(walletRefundVo.getFilter());
+            walletDetailBase.setFilterName(getFirmName(walletRefundVo.getFilter()));
+            walletDetailBase.setStatus(walletRefundVo.getStatus());
+            walletDetailBase.setStatusLabel(RefundEnum.getDesc(walletRefundVo.getStatus()));
+            walletDetailBase.setMoney(walletRefundVo.getMoney());
+            walletDetailBase.setRemark(walletRefundVo.getRemark());
+            walletDetailBase.setCreateTime(DateTimeUtil.format(walletRefundVo.getCreateTime()));
+            res.add(walletDetailBase);
+        }
+        return new PageRes<>(walletRefundVoPageRes.getPage(), walletRefundVoPageRes.getPageSize(), walletRefundVoPageRes.getSize(), walletRefundVoPageRes.getPages(), res);
+    }
+
+    /**
+     * 详细记录-提现
+     *
+     * @param cashDetailReq
+     * @return
+     */
+    public CashDetailVo cashDetail(CashDetailReq cashDetailReq) {
+        R<CashDetail> cashDetailR = payCenterService.withdrawDetail(cashDetailReq.getUid(), cashDetailReq.getOrderNo());
+        if (!cashDetailR.getStatus()) {
+            throw new BusinessException(cashDetailR.getMsg());
+        }
+        CashDetail data = cashDetailR.getData();
+        CashDetailVo cashDetailVo = new CashDetailVo();
+        cashDetailVo.setOrderNo(data.getOrderNo());
+        cashDetailVo.setChannel(data.getChannel());
+        cashDetailVo.setChannelDict(ChannelEnum.getDict(data.getChannel()));
+        cashDetailVo.setChannelLabel(ChannelEnum.getDesc(data.getChannel()));
+        cashDetailVo.setUid(data.getUid());
+        cashDetailVo.setUidName(getFirmName(data.getUid()));
+        cashDetailVo.setStatus(data.getStatus());
+        cashDetailVo.setStatusLabel(data.getStatusLabel());
+        cashDetailVo.setMoney(cashDetailVo.smallMoney(data.getMoney()));
+        cashDetailVo.setCreateTime(data.getCreateTime());
+        cashDetailVo.setFinishTime(data.getFinishTime());
+        List<CashLog> cashLogs = data.getLogs();
+        if (!CollectionUtils.isEmpty(cashLogs)) {
+            List<Logs> collect = cashLogs.stream().map(a -> {
+                Logs logs = new Logs();
+                logs.setOrderNo(a.getOrderNo());
+                logs.setChannelLabel(ChannelEnum.getDesc(data.getChannel()));
+                logs.setStatus(a.getStatus());
+                logs.setStatusLabel(a.getStatusLabel());
+                logs.setRemark(a.getContent());
+                logs.setCreateTime(a.getCreateTime());
+                return logs;
+            }).collect(Collectors.toList());
+            cashDetailVo.setLogs(collect);
+        }
+        return cashDetailVo;
+    }
+
+    /**
+     * 贸易订单预支付下单时,冻结预付款金额
+     *
+     * @param payEntId     支付方企业
+     * @param channel      渠道
+     * @param receiveEntId 收款方企业
+     * @param money        冻结金额(分)
+     * @param orderNo      订单流水
+     * @return
+     */
+    public HttpResult freezeMoney(Long payEntId, ChannelEnum channel, Long receiveEntId, Long money, String orderNo) {
+        String uid = getUid(payEntId);
+        String filter = getUid(receiveEntId);
+        R<Freeze> freezeR = payCenterService.walletFreeze(uid, channel, filter, money, orderNo);
+        if (!freezeR.getStatus()) {
+            log.error("资金冻结异常:{}", JSONObject.toJSONString(freezeR));
+            return HttpResult.error(freezeR.getMsg());
+        }
+        return HttpResult.ok("冻结成功");
+    }
+
+    public PageRes<PrePayDetailVo> prePayOrder(MoneyPage moneyPage) {
+        PrePayDetailVo chargeDetailVo = new PrePayDetailVo();
+        chargeDetailVo.setOrderNo("123");
+        chargeDetailVo.setChannel("huifu");
+        chargeDetailVo.setChannelDict("1");
+        chargeDetailVo.setChannelLabel("汇付天下");
+        chargeDetailVo.setUid("kll_001");
+        chargeDetailVo.setUidName("uid名称");
+        chargeDetailVo.setFilter("kll_002");
+        chargeDetailVo.setFilterName("filterName");
         chargeDetailVo.setStatus(0);
-        chargeDetailVo.setStatusLabel("");
-        chargeDetailVo.setMoney(new BigDecimal("0"));
-        chargeDetailVo.setRemark("");
-        chargeDetailVo.setCreateTime(LocalDateTime.now());
-        List<WalletDetailBase> objects = new ArrayList<>() {{
+        chargeDetailVo.setStatusLabel("测试");
+        chargeDetailVo.setMoney(new BigDecimal("12"));
+        chargeDetailVo.setRemark("测试");
+        chargeDetailVo.setCreateTime(DateTimeUtil.format(LocalDateTime.now()));
+        List<PrePayDetailVo> objects = new ArrayList<>() {{
             add(chargeDetailVo);
         }};
-        PageInfo<WalletDetailBase> objectPageInfo = new PageInfo<>();
+        PageInfo<PrePayDetailVo> objectPageInfo = new PageInfo<>();
+        return new PageRes<>(objectPageInfo, objects);
+    }
+
+    public PageRes<PrePayDetailVo> preReceiveOrder(MoneyPage moneyPage) {
+        PrePayDetailVo chargeDetailVo = new PrePayDetailVo();
+        chargeDetailVo.setOrderNo("123");
+        chargeDetailVo.setChannel("huifu");
+        chargeDetailVo.setChannelDict("1");
+        chargeDetailVo.setChannelLabel("汇付天下");
+        chargeDetailVo.setUid("kll_001");
+        chargeDetailVo.setUidName("uid名称");
+        chargeDetailVo.setFilter("kll_002");
+        chargeDetailVo.setFilterName("filterName");
+        chargeDetailVo.setStatus(0);
+        chargeDetailVo.setStatusLabel("测试");
+        chargeDetailVo.setMoney(new BigDecimal("12"));
+        chargeDetailVo.setRemark("测试");
+        chargeDetailVo.setCreateTime(DateTimeUtil.format(LocalDateTime.now()));
+        List<PrePayDetailVo> objects = new ArrayList<>() {{
+            add(chargeDetailVo);
+        }};
+        PageInfo<PrePayDetailVo> objectPageInfo = new PageInfo<>();
         return new PageRes<>(objectPageInfo, objects);
     }
 

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

@@ -1,7 +1,11 @@
 package com.sckw.payment.service.dubbo;
 
 import com.sckw.core.exception.BusinessException;
+import com.sckw.core.utils.OrderUtils;
+import com.sckw.core.web.constant.HttpStatus;
+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 +13,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 +39,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 +59,40 @@ 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("订单金额不能为空");
+        }
+        if (Objects.isNull(tOrderId)) {
+            return HttpResult.error("贸易订单id不能为空");
+        }
+        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);
+        //记录订单流水号
+        if (httpResult.getCode() == HttpStatus.SUCCESS_CODE) {
+            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

+ 14 - 3
sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerTradeOrderMapper.xml

@@ -6,6 +6,7 @@
     <!--@Table kwp_ledger_trade_order-->
     <id column="id" jdbcType="BIGINT" property="id" />
     <result column="t_ledger_id" jdbcType="BIGINT" property="tLedgerId" />
+    <result column="order_no" jdbcType="VARCHAR" property="orderNo" />
     <result column="t_order_id" jdbcType="BIGINT" property="tOrderId" />
     <result column="t_order_no" jdbcType="VARCHAR" property="tOrderNo" />
     <result column="remark" jdbcType="VARCHAR" property="remark" />
@@ -17,8 +18,18 @@
     <result column="del_flag" jdbcType="INTEGER" property="delFlag" />
   </resultMap>
   <sql id="Base_Column_List">
-    <!--@mbg.generated-->
-    id, t_ledger_id, t_order_id, t_order_no, remark, `status`, create_by, create_time, 
-    update_by, update_time, del_flag
+      <!--@mbg.generated-->
+      id,
+      t_ledger_id,
+      order_no,
+      t_order_id,
+      t_order_no,
+      remark,
+      `status`,
+      create_by,
+      create_time,
+      update_by,
+      update_time,
+      del_flag
   </sql>
 </mapper>

+ 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,

+ 22 - 0
sckw-modules/sckw-payment/src/main/resources/mapper/KwpTradeFreezeMapper.xml

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.sckw.payment.dao.KwpTradeFreezeMapper">
+  <resultMap id="BaseResultMap" type="com.sckw.payment.model.KwpTradeFreeze">
+    <!--@mbg.generated-->
+    <!--@Table kwp_trade_freeze-->
+    <id column="id" jdbcType="BIGINT" property="id" />
+    <result column="t_order_id" jdbcType="BIGINT" property="tOrderId" />
+    <result column="order_no" jdbcType="VARCHAR" property="orderNo" />
+    <result column="status" jdbcType="INTEGER" property="status" />
+    <result column="create_by" jdbcType="BIGINT" property="createBy" />
+    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
+    <result column="update_by" jdbcType="BIGINT" property="updateBy" />
+    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
+    <result column="del_flag" jdbcType="INTEGER" property="delFlag" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    <!--@mbg.generated-->
+    id, t_order_id, order_no, `status`, create_by, create_time, update_by, update_time, 
+    del_flag
+  </sql>
+</mapper>

+ 54 - 24
sckw-modules/sckw-payment/src/main/resources/mapper/KwpWalletTransferMapper.xml

@@ -1,28 +1,58 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.sckw.payment.dao.KwpWalletTransferMapper">
-  <resultMap id="BaseResultMap" type="com.sckw.payment.model.KwpWalletTransfer">
-    <!--@mbg.generated-->
-    <!--@Table kwp_wallet_transfer-->
-    <id column="id" jdbcType="BIGINT" property="id" />
-    <result column="order_no" jdbcType="VARCHAR" property="orderNo" />
-    <result column="uid" jdbcType="VARCHAR" property="uid" />
-    <result column="from_ent" jdbcType="BIGINT" property="fromEnt" />
-    <result column="filter" jdbcType="VARCHAR" property="filter" />
-    <result column="to_ent" jdbcType="BIGINT" property="toEnt" />
-    <result column="channel" jdbcType="VARCHAR" property="channel" />
-    <result column="money" jdbcType="DECIMAL" property="money" />
-    <result column="remark" jdbcType="VARCHAR" property="remark" />
-    <result column="create_by" jdbcType="BIGINT" property="createBy" />
-    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
-    <result column="update_by" jdbcType="BIGINT" property="updateBy" />
-    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
-    <result column="del_flag" jdbcType="INTEGER" property="delFlag" />
-    <result column="status" jdbcType="INTEGER" property="status" />
-  </resultMap>
-  <sql id="Base_Column_List">
-    <!--@mbg.generated-->
-    id, order_no, `uid`, from_ent, `filter`, to_ent, channel, money, remark, create_by, 
-    create_time, update_by, update_time, del_flag, `status`
-  </sql>
+    <resultMap id="BaseResultMap" type="com.sckw.payment.model.KwpWalletTransfer">
+        <!--@mbg.generated-->
+        <!--@Table kwp_wallet_transfer-->
+        <id column="id" jdbcType="BIGINT" property="id"/>
+        <result column="order_no" jdbcType="VARCHAR" property="orderNo"/>
+        <result column="uid" jdbcType="VARCHAR" property="uid"/>
+        <result column="from_ent" jdbcType="BIGINT" property="fromEnt"/>
+        <result column="filter" jdbcType="VARCHAR" property="filter"/>
+        <result column="to_ent" jdbcType="BIGINT" property="toEnt"/>
+        <result column="channel" jdbcType="VARCHAR" property="channel"/>
+        <result column="money" jdbcType="DECIMAL" property="money"/>
+        <result column="remark" jdbcType="VARCHAR" property="remark"/>
+        <result column="create_by" jdbcType="BIGINT" property="createBy"/>
+        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
+        <result column="update_by" jdbcType="BIGINT" property="updateBy"/>
+        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
+        <result column="del_flag" jdbcType="INTEGER" property="delFlag"/>
+        <result column="status" jdbcType="INTEGER" property="status"/>
+    </resultMap>
+    <sql id="Base_Column_List">
+        <!--@mbg.generated-->
+        id,
+        order_no,
+        `uid`,
+        from_ent,
+        `filter`,
+        to_ent,
+        channel,
+        money,
+        remark,
+        create_by,
+        create_time,
+        update_by,
+        update_time,
+        del_flag,
+        `status`
+    </sql>
+
+    <select id="pageList" resultMap="BaseResultMap">
+        select *
+        from kwp_wallet_transfer kwt
+        <where>
+            kwt.del_flag = 0
+            <if test="moneyPage.channel != null and moneyPage.channel != ''">
+                and kwt.channel = #{moneyPage.channel,jdbcType=VARCHAR}
+            </if>
+            <if test="moneyPage.uid != null and moneyPage.uid != ''">
+                and kwt.uid = #{moneyPage.uid,jdbcType=VARCHAR}
+            </if>
+            <if test="moneyPage.filter != null and moneyPage.filter != ''">
+                and kwt.filter = #{moneyPage.filter,jdbcType=VARCHAR}
+            </if>
+        </where>
+    </select>
 </mapper>

+ 1 - 1
sckw-modules/sckw-product/src/main/java/com/sckw/product/service/KwpGoodsService.java

@@ -1047,7 +1047,7 @@ public class KwpGoodsService {
         if (CollectionUtils.isEmpty(data)) {
             throw new BusinessException("检测尚未创建对应预付款清单,请先创建!");
         }
-        long money = data.get(0).getMoney();
+        long money = data.get(0).getApMoney();
         BigDecimal divide = new BigDecimal(money).divide(param.getUtilPrice().multiply(new BigDecimal("100")), 2, RoundingMode.HALF_UP);
         return amount.compareTo(divide) < 0 ? amount : divide;
     }

+ 1 - 1
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/WaybillOrderDriverVo.java

@@ -235,7 +235,7 @@ public class WaybillOrderDriverVo {
             }
         }
         //扣亏量=亏吨量-合理损耗值【要求大于0,如果小于0则扣亏货量取0】
-        BigDecimal deficitPrice = deficitAmount.subtract(loadAmount.multiply(loss).setScale(4, RoundingMode.HALF_UP));
+        BigDecimal deficitPrice = deficitAmount.subtract(loadAmount.multiply(loss).setScale(2, RoundingMode.HALF_UP));
         if (deficitPrice.doubleValue() <= 0) {
             return new BigDecimal(Global.AMOUNT);
         }

+ 75 - 20
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/CommonService.java

@@ -253,7 +253,7 @@ public class CommonService {
      * @param appConsignUrl  app托运地址
      * @param pcCarriageUrl  PC承运地址
      * @param appCarriageUrl app承运地址
-     * @param type 1代表给托运创建人发 2代表给承运创建人发
+     * @param type           1代表给托运创建人发 2代表给承运创建人发
      */
     public void newSendLogisticsOrderToMessage(KwtLogisticsOrderUnit consignUnit, KwtLogisticsOrderUnit carriageUnit,
                                                String orderNo, Long createBy, Long entId,
@@ -269,25 +269,25 @@ public class CommonService {
         Map<String, Object> map = new HashMap<>(NumberConstant.SIXTEEN);
         map.put("orderNo", orderNo);
         if (flag && createBy.equals(consignUnit.getContactsId())) {
-            sendLogisticsConsignMessage(consignUnit, map, pcConsignUrl, appConsignUrl,consignMessageEnum);
-            sendLogisticsCarriageMessage(carriageUnit, map, pcCarriageUrl, appCarriageUrl,carriageMessageEnum);
+            sendLogisticsConsignMessage(consignUnit, map, pcConsignUrl, appConsignUrl, consignMessageEnum);
+            sendLogisticsCarriageMessage(carriageUnit, map, pcCarriageUrl, appCarriageUrl, carriageMessageEnum);
         } else if (flag && createBy.equals(carriageUnit.getContactsId())) {
-            sendLogisticsCarriageMessage(carriageUnit, map, pcCarriageUrl, appCarriageUrl,carriageMessageEnum);
-            sendLogisticsConsignMessage(consignUnit, map, pcConsignUrl, appConsignUrl,consignMessageEnum);
+            sendLogisticsCarriageMessage(carriageUnit, map, pcCarriageUrl, appCarriageUrl, carriageMessageEnum);
+            sendLogisticsConsignMessage(consignUnit, map, pcConsignUrl, appConsignUrl, consignMessageEnum);
         } else {
-            sendLogisticsConsignMessage(consignUnit, map, pcConsignUrl, appConsignUrl,consignMessageEnum);
-            sendLogisticsCarriageMessage(carriageUnit, map, pcCarriageUrl, appCarriageUrl,carriageMessageEnum);
+            sendLogisticsConsignMessage(consignUnit, map, pcConsignUrl, appConsignUrl, consignMessageEnum);
+            sendLogisticsCarriageMessage(carriageUnit, map, pcCarriageUrl, appCarriageUrl, carriageMessageEnum);
             if (type.equals("1")) {
-                sendLogisticsCreateByMessage(createBy, entId, map,pcConsignUrl,appConsignUrl,consignMessageEnum);
+                sendLogisticsCreateByMessage(createBy, entId, map, pcConsignUrl, appConsignUrl, consignMessageEnum);
             } else {
-                sendLogisticsCreateByMessage(createBy, entId, map, pcCarriageUrl, appCarriageUrl,carriageMessageEnum);
+                sendLogisticsCreateByMessage(createBy, entId, map, pcCarriageUrl, appCarriageUrl, carriageMessageEnum);
             }
 
         }
 
     }
 
-    private void sendLogisticsCreateByMessage(Long createBy, Long entId, Map<String, Object> map, String pcUrl, String appUrl,MessageEnum messageEnum) {
+    private void sendLogisticsCreateByMessage(Long createBy, Long entId, Map<String, Object> map, String pcUrl, String appUrl, MessageEnum messageEnum) {
         UserCacheResDto userCacheResDto = remoteSystemService.queryUserCacheById(createBy);
         //给订单创建人发消息
         List<UserInfo> userInfos = new ArrayList<>();
@@ -311,7 +311,7 @@ public class CommonService {
         streamBridge.send("sckw-message", JSON.toJSONString(msg));
     }
 
-    private void sendLogisticsCarriageMessage(KwtLogisticsOrderUnit carriageUnit, Map<String, Object> map, String pcUrl, String appUrl,MessageEnum messageEnum) {
+    private void sendLogisticsCarriageMessage(KwtLogisticsOrderUnit carriageUnit, Map<String, Object> map, String pcUrl, String appUrl, MessageEnum messageEnum) {
         //给业务联系人发消息[承运方]
         List<UserInfo> userInfoList = new ArrayList<>();
         UserInfo userInfo = new UserInfo();
@@ -332,7 +332,7 @@ public class CommonService {
         streamBridge.send("sckw-message", JSON.toJSONString(sckwMessage));
     }
 
-    private void sendLogisticsConsignMessage(KwtLogisticsOrderUnit consignUnit, Map<String, Object> map, String pcUrl, String appUrl,MessageEnum messageEnum) {
+    private void sendLogisticsConsignMessage(KwtLogisticsOrderUnit consignUnit, Map<String, Object> map, String pcUrl, String appUrl, MessageEnum messageEnum) {
         //给业务联系人发消息[托运方]
         List<UserInfo> list = new ArrayList<>();
         UserInfo userInfo = new UserInfo();
@@ -419,7 +419,10 @@ public class CommonService {
         sckwMessage.setRequestId(UUIDUtils.get32UUID())
                 .setMessageEnum(MessageEnum.INITIATING_LOGISTICS_CONSIGNMENT)
                 .setParams(map)
-                .setMsgUrls(new HashMap<>(){{put("app",consignLogisticsOrderUrl);put("pc",carriageLogisticsOrderUrl);}})
+                .setMsgUrls(new HashMap<>() {{
+                    put("app", consignLogisticsOrderUrl);
+                    put("pc", carriageLogisticsOrderUrl);
+                }})
                 .setUserInfos(userInfoList)
                 .setCreateBy(LoginUserHolder.getUserId());
         log.info("发起物流托运-[贸易订单物流托运确认/承运订单分包托运确认]-[承运方]-业务联系人:{}", JSON.toJSONString(sckwMessage));
@@ -435,7 +438,10 @@ public class CommonService {
         message.setRequestId(UUIDUtils.get32UUID())
                 .setMessageEnum(MessageEnum.NEW_CARRIAGE_ORDER)
                 .setParams(map)
-                .setMsgUrls(new HashMap<>(){{put("app",consignLogisticsOrderUrl);put("pc",carriageLogisticsOrderUrl);}})
+                .setMsgUrls(new HashMap<>() {{
+                    put("app", consignLogisticsOrderUrl);
+                    put("pc", carriageLogisticsOrderUrl);
+                }})
                 .setUserInfos(list)
                 .setCreateBy(LoginUserHolder.getUserId());
         log.info("发起物流托运-[贸易订单物流托运确认/承运订单分包托运确认]-[托运方]-业务联系人:{}", JSON.toJSONString(message));
@@ -463,10 +469,10 @@ public class CommonService {
         carriageUnit.setContactsId(Long.parseLong(addOrderDTO.getAcceptContactsId()));
         carriageUnit.setFirmName(addOrderDTO.getConsignCompany());
         carriageUnit.setTopEntId(acceptMap == null ? null : acceptMap.getId());
-        newSendLogisticsOrderToMessage(checkUnit,carriageUnit,lOrderNo,createBy,entId
-                ,messageUrlConfig.getPc().getConsignLogisticsAddOrderUrl(),messageUrlConfig.getApp().getConsignLogisticsAddOrderUrl(),
-                messageUrlConfig.getPc().getCarriageLogisticsAddOrderUrl(),messageUrlConfig.getApp().getCarriageLogisticsAddOrderUrl(),
-                MessageEnum.NEW_LOGISTICS_ORDER,MessageEnum.NEW_CARRIAGE_ORDER,"1"
+        newSendLogisticsOrderToMessage(checkUnit, carriageUnit, lOrderNo, createBy, entId
+                , messageUrlConfig.getPc().getConsignLogisticsAddOrderUrl(), messageUrlConfig.getApp().getConsignLogisticsAddOrderUrl(),
+                messageUrlConfig.getPc().getCarriageLogisticsAddOrderUrl(), messageUrlConfig.getApp().getCarriageLogisticsAddOrderUrl(),
+                MessageEnum.NEW_LOGISTICS_ORDER, MessageEnum.NEW_CARRIAGE_ORDER, "1"
         );
 
     }
@@ -491,7 +497,10 @@ public class CommonService {
         sckwMessage.setRequestId(UUIDUtils.get32UUID())
                 .setMessageEnum(messageEnum)
                 .setParams(map)
-                .setMsgUrls(new HashMap<>(){{put("app",consignLogisticsOrderUrl);put("pc",carriageLogisticsOrderUrl);}})
+                .setMsgUrls(new HashMap<>() {{
+                    put("app", consignLogisticsOrderUrl);
+                    put("pc", carriageLogisticsOrderUrl);
+                }})
                 .setUserInfos(userInfoList)
                 .setCreateBy(LoginUserHolder.getUserId());
         log.info("托运订单/承运订单自建物流订单-业务联系人:{}", JSON.toJSONString(sckwMessage));
@@ -740,6 +749,52 @@ public class CommonService {
         streamBridge.send("sckw-message", JSON.toJSONString(message));
     }
 
+
+    /**
+     * @param loadAmount    装货量
+     * @param deficitAmount 亏吨量
+     * @param loss          合理损耗
+     * @desc 计算扣亏量
+     **/
+    public BigDecimal deficitAmount(BigDecimal loadAmount, BigDecimal deficitAmount, BigDecimal entrustAmount, BigDecimal loss, String lossUnit) {
+        //亏吨<=0
+        if (deficitAmount.compareTo(new BigDecimal(Global.AMOUNT)) <= 0) {
+            return new BigDecimal(Global.AMOUNT);
+        }
+        //合理损耗
+        loss = loss == null ? new BigDecimal("0.00") : loss;
+        if (loss.doubleValue() > 0 && StringUtils.isNotBlank(lossUnit)) {
+            if (lossUnit.equals(String.valueOf(TaxRateTypeEnum.PERCENT.getCode()))) {
+                loss = loss.divide(new BigDecimal(TaxRateTypeEnum.PERCENT.getValue()));
+            }
+            if (lossUnit.equals(String.valueOf(TaxRateTypeEnum.MILLIMETER.getCode()))) {
+                loss = loss.divide(new BigDecimal(TaxRateTypeEnum.MILLIMETER.getValue()));
+            }
+        }
+        /**
+         * 一、罚款值计算:
+         * 1、合理损耗值=实装量*合理损耗(‰)
+         * 1.1 亏吨量= 实装量-实卸量
+         * 2、扣亏量=亏吨量-合理损耗值【要求大于0,如果小于0则扣亏货量取0】
+         * 3、罚款值=扣亏量 * 扣亏货值
+         *
+         * 二、运价计算:
+         * 1、按装货量:总运价=实装量*运价
+         * 2、按卸货量:总运价=实卸量*运价-罚款值
+         * 3、按趟次:总运价=运价*趟次【后期加】
+         */
+        loadAmount = loadAmount == null ? new BigDecimal("0.00") : loadAmount;
+        //已委托量
+        entrustAmount = entrustAmount == null ? new BigDecimal("0.00") : entrustAmount;
+        //合理损耗值
+        BigDecimal multiply = loadAmount.multiply(loss.divide(BigDecimal.valueOf(1000L)));
+        //亏吨量
+        deficitAmount = deficitAmount == null ? new BigDecimal("0.00") : deficitAmount;
+        //扣亏量/吨
+        deficitAmount = deficitAmount.compareTo(new BigDecimal("0.00")) == 0 ? new BigDecimal("0.00") : deficitAmount.subtract(multiply);
+        return deficitAmount;
+    }
+
     /**
      * @param loadAmount    装货量
      * @param deficitAmount 亏吨量
@@ -748,7 +803,7 @@ public class CommonService {
      * @author zk
      * @date 2023/7/27
      **/
-    public BigDecimal deficitPrice(BigDecimal loadAmount, BigDecimal deficitAmount, BigDecimal loss,String lossUnit) {
+    public BigDecimal deficitPrice(BigDecimal loadAmount, BigDecimal deficitAmount, BigDecimal loss, String lossUnit) {
         //亏吨<=0
         if (deficitAmount.compareTo(new BigDecimal(Global.AMOUNT)) <= 0) {
             return new BigDecimal(Global.AMOUNT);

+ 1 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/ConsignOrderService.java

@@ -648,6 +648,7 @@ public class ConsignOrderService {
                     BigDecimal defectiveWeigh = kwtWaybillOrder.getDeficitAmount() == null ? new BigDecimal("0.00") : kwtWaybillOrder.getDeficitAmount();
                     //扣亏量/吨
 //                    BigDecimal deduct = defectiveWeigh.compareTo(new BigDecimal("0.00")) == 0 ? new BigDecimal("0.00") : defectiveWeigh.subtract(multiply);
+//                    BigDecimal decimal = commonService.deficitAmount();
                     BigDecimal deduct = commonService.deficitPrice(loadAmount, defectiveWeigh, loss, order.getLossUnit());
                     carWaybillVo.setWOrderId(String.valueOf(kwtWaybillOrder.getId()));
                     carWaybillVo.setWOrderNo(kwtWaybillOrder.getWOrderNo());

+ 11 - 6
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/KwtWaybillOrderService.java

@@ -31,7 +31,6 @@ import com.sckw.stream.model.UserInfo;
 import com.sckw.system.api.RemoteSystemService;
 import com.sckw.system.api.model.dto.res.EntCacheResDto;
 import com.sckw.system.api.model.dto.res.SysDictResDto;
-import com.sckw.system.api.model.dto.res.UserCacheResDto;
 import com.sckw.transport.dao.*;
 import com.sckw.transport.model.*;
 import com.sckw.transport.model.dto.*;
@@ -1768,7 +1767,7 @@ public class KwtWaybillOrderService {
         }
 
         goodsPrice = goodsPrice == null ? new BigDecimal(Global.AMOUNT) : goodsPrice;
-        BigDecimal deficitLossAmount = deficitAmount.subtract(loadAmount.multiply(loss).setScale(4, RoundingMode.HALF_UP));
+        BigDecimal deficitLossAmount = deficitAmount.subtract(loadAmount.multiply(loss).setScale(2, RoundingMode.HALF_UP));
         //扣亏量=亏吨量-合理损耗值【要求大于0,如果小于0则扣亏货量取0】
         if (deficitLossAmount.doubleValue() <= 0) {
             return new BigDecimal(Global.AMOUNT);
@@ -2151,7 +2150,7 @@ public class KwtWaybillOrderService {
         //商品信息
         KwtLogisticsOrderGoods goods = logisticsOrderGoodsDao.findByGoods(waybillOrder.getLOrderId());
         //审批意见
-        KwtWaybillOrderTrack track = waybillOrderTrackDao.findWaybillOrderTrack(waybillOrder.getLOrderId(), CarWaybillEnum.APPROVAL_NO_PASS.getCode());
+        KwtWaybillOrderTrack track = waybillOrderTrackDao.findWaybillOrderTrack(waybillOrder.getId(), CarWaybillEnum.APPROVAL_NO_PASS.getCode());
 
         //用户数据集
         List<Long> createBys = new ArrayList() {{
@@ -2189,7 +2188,7 @@ public class KwtWaybillOrderService {
         result.put("unloadCreateByName", usersMap.get(unloadTicket.getUpdateBy()));
         result.put("unloadCityName", unloadAddress != null ? unloadAddress.getCityName() : null);
         result.put("unloadDetailAddress", unloadAddress != null ? unloadAddress.getDetailAddress() : null);
-        result.put("approvalTime", track != null ? track.getCreateTime() : null);
+        result.put("approvalTime", track != null ? DateUtils.formatV1(track.getCreateTime()) : null);
         result.put("approvalOpinions", track != null ? track.getRemark() : null);
         result.put("approver", usersMap.get(track != null ? track.getUpdateBy() : null));
         return HttpResult.ok(result);
@@ -2210,7 +2209,8 @@ public class KwtWaybillOrderService {
         }
         //已卸货/审批不通过车辆运单才能审核
         if (waybillOrder.getStatus() != CarWaybillEnum.COMPLETION_UNLOADING.getCode()
-                && waybillOrder.getStatus() != CarWaybillEnum.APPROVAL_NO_PASS.getCode()) {
+                && waybillOrder.getStatus() != CarWaybillEnum.APPROVAL_NO_PASS.getCode()
+                && waybillOrder.getStatus() != CarWaybillEnum.APPROVAL_IN.getCode()) {
             return HttpResult.error("车辆运单当前状态已不能审核!");
         }
         //已卸货/审批不通过车辆运单只能审批通过或审批不通过
@@ -2295,7 +2295,8 @@ public class KwtWaybillOrderService {
         }
         //已卸货/审批不通过车辆运单才能审核
         if (waybillOrder.getStatus() != CarWaybillEnum.COMPLETION_UNLOADING.getCode()
-                && waybillOrder.getStatus() != CarWaybillEnum.APPROVAL_NO_PASS.getCode()) {
+                && waybillOrder.getStatus() != CarWaybillEnum.APPROVAL_NO_PASS.getCode()
+                && waybillOrder.getStatus() != CarWaybillEnum.APPROVAL_IN.getCode()) {
             return HttpResult.error("车辆运单当前状态已不能审核!");
         }
         //已卸货/审批不通过车辆运单只能审批通过或审批不通过
@@ -2554,6 +2555,8 @@ public class KwtWaybillOrderService {
         orderStatusList.add(CarWaybillEnum.WAIT_LOADING.getCode());
         orderStatusList.add(CarWaybillEnum.COMPLETION_LOADING.getCode());
         orderStatusList.add(CarWaybillEnum.WAIT_UNLOADING.getCode());
+        orderStatusList.add(CarWaybillEnum.APPROVAL_NO_PASS.getCode());
+        orderStatusList.add(CarWaybillEnum.APPROVAL_IN.getCode());
         Integer proceed = logisticsOrderDao.selectCountByLorderId(orderId, orderStatusList);
         map.put("proceed", proceed);
 
@@ -2596,6 +2599,8 @@ public class KwtWaybillOrderService {
         orderStatusList.add(CarWaybillEnum.WAIT_LOADING.getCode());
         orderStatusList.add(CarWaybillEnum.COMPLETION_LOADING.getCode());
         orderStatusList.add(CarWaybillEnum.WAIT_UNLOADING.getCode());
+        orderStatusList.add(CarWaybillEnum.APPROVAL_NO_PASS.getCode());
+        orderStatusList.add(CarWaybillEnum.APPROVAL_IN.getCode());
         Integer proceed = logisticsOrderDao.selectCountByLorderId(orderId, orderStatusList);
         map.put("proceed", proceed);
 

+ 1 - 1
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/WaybillManagementService.java

@@ -417,7 +417,7 @@ public class WaybillManagementService {
         // 执行查询
         for (SckwWaybillOrder sckwWaybillOrder : list) {
             WaybillBoardListVO waybillBoardListVO = new WaybillBoardListVO();
-            waybillBoardListVO.setWOrderId(String.valueOf(sckwWaybillOrder.getWOrderId()));
+            waybillBoardListVO.setWOrderId(sckwWaybillOrder.getWOrderId() != null ? String.valueOf(sckwWaybillOrder.getWOrderId()) : String.valueOf(sckwWaybillOrder.get_id()));
             waybillBoardListVO.setWOrderNo(sckwWaybillOrder.getWOrderNo() == null ? null : sckwWaybillOrder.getWOrderNo());
             waybillBoardListVO.setStatus(String.valueOf(sckwWaybillOrder.getStatus()));
             waybillBoardListVO.setType(String.valueOf(sckwWaybillOrder.getType()));

+ 2 - 2
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/dubbo/TransportDubboServiceImpl.java

@@ -353,13 +353,13 @@ public class TransportDubboServiceImpl implements TransportDubboService {
         }
 
         if (LogisticsOrderEnum.HAVE_RECONCILED.getStatus().equals(status)) {
-            if (!LogisticsOrderEnum.HAVE_FINISHED.getStatus().equals(status)) {
+            if (!LogisticsOrderEnum.HAVE_FINISHED.getStatus().equals(String.valueOf(kwtLogisticsOrder.getStatus()))) {
                 httpResult.setMsg("物流单据状态有误,不能修改");
                 httpResult.setCode(HttpStatus.GLOBAL_EXCEPTION_CODE);
                 return httpResult;
             }
         } else if (LogisticsOrderEnum.HAVE_ALREADY_SETTLED.getStatus().equals(status)) {
-            if (!LogisticsOrderEnum.HAVE_RECONCILED.getStatus().equals(status)) {
+            if (!LogisticsOrderEnum.HAVE_RECONCILED.getStatus().equals(String.valueOf(kwtLogisticsOrder.getStatus()))) {
                 httpResult.setMsg("物流单据状态有误,不能修改");
                 httpResult.setCode(HttpStatus.GLOBAL_EXCEPTION_CODE);
                 return httpResult;

+ 10 - 3
sckw-modules/sckw-transport/src/main/resources/mapper/KwtWaybillOrderMapper.xml

@@ -343,7 +343,6 @@
         ) tab1
     </select>
 
-
     <select id="findWaitWaybillOrderByDriver" resultType="com.sckw.transport.model.vo.WaybillOrderDriverVo"
             parameterType="java.util.Map">
         SELECT *
@@ -424,8 +423,9 @@
                 and lo.del_flag = 0
                 and loc.status = 0
                 and loc.w_order_id is null
-                and loc.driver_id = #{driverId, jdbcType=BIGINT}) tab
-        order by createTime desc
+                and loc.driver_id = #{driverId, jdbcType=BIGINT}
+        ) tab
+        order by startTime
     </select>
 
     <select id="findOtherWaybillOrderByDriver" resultType="com.sckw.transport.model.vo.WaybillOrderDriverVo"
@@ -466,6 +466,13 @@
         <if test="endTime != null and endTime != ''">
             and DATE(wo.create_time) <![CDATA[ <= ]]> #{endTime,jdbcType=TIMESTAMP}
         </if>
+
+        <if test="busStatus != null and busStatus == 2">
+            ORDER BY wo.start_time
+        </if>
+        <if test="busStatus != null and busStatus == 4">
+            ORDER BY wo.update_time desc
+        </if>
     </select>
 
     <select id="selectWaybillOrderCarListNotPage" resultType="com.sckw.transport.model.dto.OrderCarDTO">