Przeglądaj źródła

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

# Conflicts:
#	sckw-common/sckw-common-core/src/main/java/com/sckw/core/exception/GlobalSystemExceptionHandler.java
czh 2 lat temu
rodzic
commit
bdc0b6878a
100 zmienionych plików z 2688 dodań i 757 usunięć
  1. 20 0
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/annotation/Log.java
  2. 79 0
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/aspect/LogAspect.java
  3. 3 0
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/common/enums/enums/DictEnum.java
  4. 1 0
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/common/enums/enums/DictTypeEnum.java
  5. 9 0
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/model/enums/CarWaybillEnum.java
  6. 4 0
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/model/enums/LogisticsOrderEnum.java
  7. 2 1
      sckw-common/sckw-common-core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
  8. 1 2
      sckw-common/sckw-common-mongo/src/main/java/com/sckw/mongo/model/SckwLogisticsOrder.java
  9. 10 0
      sckw-common/sckw-common-mongo/src/main/java/com/sckw/mongo/model/SckwWaybillOrder.java
  10. 22 22
      sckw-common/sckw-common-redis/src/main/java/com/sckw/redis/config/RedisLockUtil.java
  11. 6 2
      sckw-common/sckw-common-redis/src/main/java/com/sckw/redis/constant/RedisConstant.java
  12. 2 1
      sckw-common/sckw-common-redis/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
  13. 6 1
      sckw-common/sckw-common-stream/src/main/java/com/sckw/stream/model/SckwSms.java
  14. 1 1
      sckw-modules-api/sckw-message-api/src/main/java/com/sckw/message/api/dubbo/SmsInfoService.java
  15. 2 1
      sckw-modules/sckw-example/src/main/java/com/sckw/example/controller/MessageApiController.java
  16. 7 0
      sckw-modules/sckw-message/src/main/java/com/sckw/message/controller/MessageController.java
  17. 2 2
      sckw-modules/sckw-message/src/main/java/com/sckw/message/controller/SmsController.java
  18. 0 80
      sckw-modules/sckw-message/src/main/java/com/sckw/message/controller/TestMqController.java
  19. 2 2
      sckw-modules/sckw-message/src/main/java/com/sckw/message/dubbo/SmsInfoServiceImpl.java
  20. 2 0
      sckw-modules/sckw-message/src/main/java/com/sckw/message/model/vo/req/SendSmsVerifyCoderReqVO.java
  21. 1 0
      sckw-modules/sckw-message/src/main/java/com/sckw/message/service/SckwMessageHandlerService.java
  22. 25 19
      sckw-modules/sckw-message/src/main/java/com/sckw/message/service/SckwSmsHandlerService.java
  23. 14 10
      sckw-modules/sckw-message/src/main/java/com/sckw/message/service/SmsService.java
  24. 4 0
      sckw-modules/sckw-message/src/main/resources/bootstrap-test.yml
  25. 12 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/controller/KwoTradeOrderController.java
  26. 11 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/controller/KwoTransportDemandController.java
  27. 81 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/controller/KwpWantBuyController.java
  28. 11 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/dao/KwpWantBuyMapper.java
  29. 5 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/dao/KwpWantBuyTradingMapper.java
  30. 39 35
      sckw-modules/sckw-order/src/main/java/com/sckw/order/dubbo/TradeOrderInfoServiceImpl.java
  31. 78 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/req/UpdateWantBuyParam.java
  32. 24 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/req/WantBuyDels.java
  33. 75 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/req/WantBuySelectParam.java
  34. 30 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/res/TableTopRes.java
  35. 5 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/res/WantBuyDetailRes.java
  36. 93 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/res/WantBuySelectRes.java
  37. 20 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/res/WantBuyTradingRes.java
  38. 22 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwoWantBuyAddressService.java
  39. 33 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwoWantBuyTradingService.java
  40. 467 3
      sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwpWantBuyService.java
  41. 5 0
      sckw-modules/sckw-order/src/main/resources/bootstrap-test.yml
  42. 118 0
      sckw-modules/sckw-order/src/main/resources/mapper/KwoWantBuyMapper.xml
  43. 36 0
      sckw-modules/sckw-order/src/main/resources/mapper/KwoWantBuyTradingMapper.xml
  44. 4 4
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpLedgerLogisticsController.java
  45. 11 7
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpLedgerTradeController.java
  46. 4 29
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpSettlementLogisticsController.java
  47. 5 4
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpSettlementOfflineController.java
  48. 8 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpSettlementTradeController.java
  49. 27 16
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpSettlementWalletController.java
  50. 1 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpLedgerTradeMapper.java
  51. 12 39
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementLogisticsMapper.java
  52. 9 5
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementTradeMapper.java
  53. 1 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpLedgerLogistics.java
  54. 1 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpLedgerTrade.java
  55. 1 4
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpSettlementLogisticsTrack.java
  56. 11 4
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpSettlementOffline.java
  57. 18 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpSettlementTradeTrack.java
  58. 4 5
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpSettlementWallet.java
  59. 18 18
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/constant/LedgerEnum.java
  60. 13 14
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/constant/SettlementEnum.java
  61. 36 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/constant/SettlementPayTypeEnum.java
  62. 3 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/constant/SettlementTrackEnum.java
  63. 0 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/constant/SettlementWalletPayTypeEnum.java
  64. 30 12
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/constant/WalletChannelEnum.java
  65. 2 2
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/ILedger.java
  66. 2 2
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/ISettlement.java
  67. 5 3
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/LedgerCarrierDto.java
  68. 1 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/LedgerLogisticsDto.java
  69. 1 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/LedgerPurchaseDto.java
  70. 1 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/LedgerSellDto.java
  71. 1 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/LedgerShipperDto.java
  72. 1 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/LedgerTradeDto.java
  73. 18 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/LedgerUnitDto.java
  74. 1 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/SettlementLogisticsDto.java
  75. 1 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/SettlementPurchaseDto.java
  76. 6 5
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/SettlementSellDto.java
  77. 181 32
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/SettlementTradeDto.java
  78. 1 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/LogisticsReq.java
  79. 1 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/LogisticsSendReq.java
  80. 43 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/OfflinePaymentReq.java
  81. 5 7
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/SettlementOfflinePayReq.java
  82. 29 4
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/SettlementOfflineReq.java
  83. 26 12
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/SettlementReq.java
  84. 7 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/SettlementTradeReq.java
  85. 2 2
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/SettlementWalletReq.java
  86. 1 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/TradeReq.java
  87. 1 2
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/TradeSendReq.java
  88. 29 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/WalletPayReq.java
  89. 1 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/LedgerLogisticsDetailVo.java
  90. 1 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/LedgerTradeDetailVo.java
  91. 11 14
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerLogisticsService.java
  92. 15 12
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerTradeService.java
  93. 158 100
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementLogisticsService.java
  94. 202 70
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementOfflineService.java
  95. 22 11
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementTradeService.java
  96. 283 116
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementWalletService.java
  97. 1 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/utils/CommonValidator.java
  98. 17 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/utils/DecimalUtils.java
  99. 3 0
      sckw-modules/sckw-payment/src/main/resources/META-INF/MANIFEST.MF
  100. 1 1
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerLogisticsMapper.xml

+ 20 - 0
sckw-common/sckw-common-core/src/main/java/com/sckw/core/annotation/Log.java

@@ -0,0 +1,20 @@
+package com.sckw.core.annotation;
+
+import java.lang.annotation.*;
+
+/**
+ * @desc: 自定义日志注解
+ * @author: yzc
+ * @date: 2023-08-02 9:20
+ */
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface Log {
+
+    /**
+     * 日志描述
+     * @return
+     */
+    String description() default "";
+}

+ 79 - 0
sckw-common/sckw-common-core/src/main/java/com/sckw/core/aspect/LogAspect.java

@@ -0,0 +1,79 @@
+package com.sckw.core.aspect;
+
+import com.alibaba.fastjson.JSON;
+import com.sckw.core.annotation.Log;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.time.DateFormatUtils;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+import org.springframework.stereotype.Component;
+
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+/**
+ * @desc: controller请求切面增强
+ * @author: yzc
+ * @date: 2023-08-02 9:21
+ */
+@Aspect
+@Component
+@Slf4j
+public class LogAspect {
+    private static final String TIME_PATTERN = "yyyy-MM-dd HH:mm:ss:SSS";
+
+    @Pointcut("@annotation(l)")
+    public void loggerPointcut(Log l) {
+    }
+
+    @Around("loggerPointcut(l)")
+    public Object around(ProceedingJoinPoint p, Log l) throws Throwable {
+        Object result = null;
+        //开始时间
+        Date startTime = new Date();
+        String targetName = p.getTarget().getClass().getName();
+        String methodName = p.getSignature().getName();
+        Object[] args = p.getArgs();
+        Stream<?> stream = ArrayUtils.isEmpty(args) ? Stream.empty() : Arrays.stream(args);
+        List<Object> logArgs = stream
+                .filter(arg -> (!(arg instanceof HttpServletRequest) && !(arg instanceof HttpServletResponse)))
+                .collect(Collectors.toList());
+        //过滤后序列化无异常
+        String param = JSON.toJSONString(logArgs);
+        String exception = "";
+        try {
+            //执行结果,返回参数
+            result = p.proceed();
+        } catch (Throwable e) {
+            exception = e.getMessage();
+            //异常抛出
+            throw e;
+        } finally {
+            Date endTime = new Date();
+            long time = endTime.getTime() - startTime.getTime();
+            Boolean slowRequest = (time > 1500L);
+            log.info("{}:{}.{}," +
+                            "param={}," +
+                            "result={}," +
+                            "exception={}," +
+                            "[{}->{}],slowRequest{}=[{}]", l.description(), targetName, methodName,
+                    param,
+                    JSON.toJSONString(result),
+                    exception,
+                    DateFormatUtils.format(startTime, TIME_PATTERN),
+                    DateFormatUtils.format(endTime, TIME_PATTERN),
+                    slowRequest,
+                    time);
+        }
+        return result;
+    }
+
+}

+ 3 - 0
sckw-common/sckw-common-core/src/main/java/com/sckw/core/common/enums/enums/DictEnum.java

@@ -15,6 +15,9 @@ import java.util.List;
 @Getter
 @AllArgsConstructor
 public enum DictEnum {
+    SMS_REGISTER("send_sms_type", "register", "短信注册"),
+    SMS_LOGIN("send_sms_type", "login", "短信登录"),
+    SMS_UPDATE_PASSWORD("send_sms_type", "updatePassword", "短信修改密码"),
     PRICE_TYPE_0("price_type", "0", "元/吨"),
     PRICE_TYPE_1("price_type", "1", "元/车"),
     WEIGHT_CAR_0("weight_car", "0", "吨/车"),

+ 1 - 0
sckw-common/sckw-common-core/src/main/java/com/sckw/core/common/enums/enums/DictTypeEnum.java

@@ -11,6 +11,7 @@ import lombok.Getter;
 @Getter
 @AllArgsConstructor
 public enum DictTypeEnum {
+    SEND_SMS_TYPE("send_sms_type", "发送短信类型"),
     INTEGRAL_TYPE("integral_type", "积分类型"),
     UNIT_TYPE("unit_type", "商品单位类型"),
     TAX_RATE("tax_rate", "商品税率"),

+ 9 - 0
sckw-common/sckw-common-core/src/main/java/com/sckw/core/model/enums/CarWaybillEnum.java

@@ -93,6 +93,15 @@ public enum CarWaybillEnum {
         return null;
     }
 
+    public static String getWaybillOrderDestination(String status) {
+        for (CarWaybillEnum waybillEnum : CarWaybillEnum.values()) {
+            if (waybillEnum.getStatus().equals(status)) {
+                return waybillEnum.getDestination();
+            }
+        }
+        return null;
+    }
+
     public static String getName(Integer code) {
         for (CarWaybillEnum waybillEnum : CarWaybillEnum.values()) {
             if (waybillEnum.getCode().equals(code)) {

+ 4 - 0
sckw-common/sckw-common-core/src/main/java/com/sckw/core/model/enums/LogisticsOrderEnum.java

@@ -102,6 +102,10 @@ public enum LogisticsOrderEnum {
         return codeList;
     }
 
+    /**
+     * 获取所有的状态
+     * @return
+     */
     public static List<String> getCodeStringList() {
         List<String> codeList = new ArrayList<>(NumberConstant.SIXTEEN);
         for (LogisticsOrderEnum value : LogisticsOrderEnum.values()) {

+ 2 - 1
sckw-common/sckw-common-core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

@@ -4,4 +4,5 @@ com.sckw.core.web.config.CustomConfig
 com.sckw.core.filter.LoginFilter
 com.sckw.core.config.MybatisPlusConfig
 com.sckw.core.config.JacksonConfig
-com.sckw.core.filter.ExceptionFilterConfig
+com.sckw.core.filter.ExceptionFilterConfig
+com.sckw.core.aspect.LogAspect

+ 1 - 2
sckw-common/sckw-common-mongo/src/main/java/com/sckw/mongo/model/SckwLogisticsOrder.java

@@ -417,8 +417,7 @@ public class SckwLogisticsOrder {
     /**
      * 是否删除(0未删除,1删除)
      */
-    @TableLogic("0")
-    private String delFlag = "0";
+    private String delFlag;
 
     /**
      * 关联的承运订单号

+ 10 - 0
sckw-common/sckw-common-mongo/src/main/java/com/sckw/mongo/model/SckwWaybillOrder.java

@@ -296,6 +296,11 @@ public class SckwWaybillOrder{
     private String carrierPhone;
 
 
+    /**
+     * 装货地址名称
+     */
+    private String loadName;
+
     /**
      * 装货地址类型
      */
@@ -336,6 +341,11 @@ public class SckwWaybillOrder{
      */
     private String loadLng;
 
+    /**
+     * 卸货地址名称
+     */
+    private String unloadName;
+
     /**
      * 卸货地址类型
      */

+ 22 - 22
sckw-common/sckw-common-redis/src/main/java/com/sckw/redis/config/RedisLockUtil.java

@@ -19,56 +19,56 @@ public class RedisLockUtil {
     private RedissonClient redissonClient;
 
     /**
-     * 
+     * 获取
      *
      * @param lockKey 锁的key
-     * @return
      */
-    public boolean tryLock(String lockKey) {
-        return tryLock(lockKey, 5, 10);
+    public RLock getLock(String lockKey) {
+        return redissonClient.getLock(lockKey);
     }
 
     /**
      * 加锁
+     * 默认加锁时间30秒
      *
      * @param lockKey 锁的key
      * @return
      */
-    public boolean tryLock(String lockKey, int waitTime, int leaseTime) {
+    public boolean tryLock(String lockKey) {
         RLock lock = redissonClient.getLock(lockKey);
-        try {
-            return lock.tryLock(waitTime, leaseTime, TimeUnit.SECONDS);
-        } catch (InterruptedException e) {
-            log.info("tryLock lockKey:{} waitTime:{} leaseTime:{}", lockKey, waitTime, leaseTime);
-            return false;
-        }
+        return lock.tryLock();
     }
 
     /**
      * 加锁
+     * 默认加锁时间30秒
      *
-     * @param lockKey 锁的key
+     * @param lockKey  持有的锁key
+     * @param waitTime 加锁等待时间
      * @return
      */
-    public RLock lock(String lockKey) {
-        RLock lock = redissonClient.getLock(lockKey);
-        lock.lock();
-        return lock;
+    public boolean tryLock(String lockKey, int waitTime) {
+        return tryLock(lockKey, waitTime, -1);
     }
 
     /**
      * 加锁
      *
-     * @param lockKey 锁的key
-     * @param timeout 超时时间
-     * @return
+     * @param lockKey   锁的key
+     * @param waitTime  加锁等待时间
+     * @param leaseTime 锁自动释放时间
      */
-    public RLock lock(String lockKey, long timeout) {
+    public boolean tryLock(String lockKey, int waitTime, int leaseTime) {
         RLock lock = redissonClient.getLock(lockKey);
-        lock.lock(timeout, TimeUnit.SECONDS);
-        return lock;
+        try {
+            return lock.tryLock(waitTime, leaseTime, TimeUnit.SECONDS);
+        } catch (InterruptedException e) {
+            log.info("tryLock lockKey:{} waitTime:{} leaseTime:{}", lockKey, waitTime, leaseTime);
+            return false;
+        }
     }
 
+
     /**
      * 解锁
      *

+ 6 - 2
sckw-common/sckw-common-redis/src/main/java/com/sckw/redis/constant/RedisConstant.java

@@ -10,11 +10,11 @@ public class RedisConstant {
     /**
      * 短信验证码值key
      */
-    public static final String MESSAGE_SMS_VERIFY_CODE_VALUE_KEY = "sckw:sms:verifyCode:value:%s";
+    public static final String MESSAGE_SMS_VERIFY_CODE_VALUE_KEY = "sckw:sms:verifyCode:value:%s:%s";
     /**
      * 短信验证码请求key
      */
-    public static final String MESSAGE_SMS_VERIFY_CODE_REQUEST_KEY = "sckw:sms:verifyCode:request:%s";
+    public static final String MESSAGE_SMS_VERIFY_CODE_REQUEST_KEY = "sckw:sms:verifyCode:request:%s:%s";
     /**
      * 短信验证码有效时间(秒)
      */
@@ -38,5 +38,9 @@ public class RedisConstant {
      * 消费请求有效时间(秒)
      */
     public static final Long CONSUMER_REQUEST_VALID_TIME = 180L;
+    /**
+     * 结算单锁
+     */
+    public static final String SETTLEMENT_KEY = "sckw:kst:%s";
 
 }

+ 2 - 1
sckw-common/sckw-common-redis/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

@@ -1 +1,2 @@
-com.sckw.redis.config.RedissonConfig
+com.sckw.redis.config.RedissonConfig
+com.sckw.redis.config.RedisLockUtil

+ 6 - 1
sckw-common/sckw-common-stream/src/main/java/com/sckw/stream/model/SckwSms.java

@@ -3,8 +3,8 @@ package com.sckw.stream.model;
 import com.sckw.stream.enums.SmsCodeEnum;
 import lombok.AllArgsConstructor;
 import lombok.Data;
-import lombok.NoArgsConstructor;
 import lombok.experimental.Accessors;
+
 import java.util.Map;
 
 /**
@@ -31,6 +31,11 @@ public class SckwSms {
      */
     private String phone;
 
+    /**
+     * 短信类型
+     */
+    private String type;
+
     /**
      * 手机号集合(腾讯短信)
      */

+ 1 - 1
sckw-modules-api/sckw-message-api/src/main/java/com/sckw/message/api/dubbo/SmsInfoService.java

@@ -13,6 +13,6 @@ public interface SmsInfoService {
      * @Param phone:
      * @return: java.lang.String
      */
-    String getVerifyCode(String phone);
+    String getVerifyCode(String type, String phone);
 
 }

+ 2 - 1
sckw-modules/sckw-example/src/main/java/com/sckw/example/controller/MessageApiController.java

@@ -1,5 +1,6 @@
 package com.sckw.example.controller;
 
+import com.sckw.core.common.enums.enums.DictEnum;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.message.api.dubbo.SmsInfoService;
 import com.sckw.order.api.dubbo.TradeOrderInfoService;
@@ -27,7 +28,7 @@ public class MessageApiController {
 
     @GetMapping("/getVerifyCode")
     public HttpResult getVerifyCode() {
-        String verifyCode = smsInfoService.getVerifyCode("17780832879");
+        String verifyCode = smsInfoService.getVerifyCode(DictEnum.SMS_REGISTER.getValue(),"17780832879");
         return HttpResult.ok("获取验证码成功", verifyCode);
     }
 

+ 7 - 0
sckw-modules/sckw-message/src/main/java/com/sckw/message/controller/MessageController.java

@@ -2,6 +2,7 @@ package com.sckw.message.controller;
 
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import com.sckw.core.annotation.Log;
 import com.sckw.core.model.page.PageHelperUtil;
 import com.sckw.core.model.page.PageResult;
 import com.sckw.core.web.response.HttpResult;
@@ -38,6 +39,7 @@ public class MessageController {
      * @date: 2023-06-13 16:17
      */
     @GetMapping("/detail")
+    @Log(description = "获取消息详情")
     public HttpResult detail(@RequestParam Long id) {
         KwmMessage message = messageService.detail(id);
         return HttpResult.ok(message);
@@ -51,6 +53,7 @@ public class MessageController {
      * @date: 2023-06-09 15:12
      */
     @PostMapping(value = "/select", produces = MediaType.APPLICATION_JSON_VALUE)
+    @Log(description = "分页查询消息列表")
     public HttpResult select(@RequestBody @Valid SelectMessagesReqVO params) {
         PageHelper.startPage(params.getPage(), params.getPageSize());
         List<KwmMessage> list = messageService.select(params);
@@ -66,6 +69,7 @@ public class MessageController {
      * @date: 2023-06-09 14:21
      */
     @PostMapping(value = "/read", produces = MediaType.APPLICATION_JSON_VALUE)
+    @Log(description = "消息已读")
     public HttpResult read(@RequestBody ReadMessagesReqVO readMessagesReqVO) {
         messageService.read(readMessagesReqVO);
         return HttpResult.ok();
@@ -79,6 +83,7 @@ public class MessageController {
      * @date: 2023-06-09 14:21
      */
     @PostMapping(value = "/delete", produces = MediaType.APPLICATION_JSON_VALUE)
+    @Log(description = "删除消息")
     public HttpResult delete(@RequestBody DeleteMessagesReqVO deleteMessagesReqVO) {
         messageService.delete(deleteMessagesReqVO);
         return HttpResult.ok();
@@ -92,6 +97,7 @@ public class MessageController {
      * @return com.sckw.core.web.response.HttpResult
      */
     @GetMapping(value = "/statistics")
+    @Log(description = "消息统计查询")
     public HttpResult statistics(@RequestParam(required = false) String category) {
         List<MessagesStatisticsResVO> result = messageService.statistics(category);
         return HttpResult.ok(result);
@@ -105,6 +111,7 @@ public class MessageController {
      * @date: 2023-06-09 15:12
      */
     @PostMapping(value = "/findList", produces = MediaType.APPLICATION_JSON_VALUE)
+    @Log(description = "查找消息列表")
     public HttpResult findList(@RequestBody FindMessagesReqVO findMessagesReqVO) {
         return HttpResult.ok(messageService.selectMessages(findMessagesReqVO));
     }

+ 2 - 2
sckw-modules/sckw-message/src/main/java/com/sckw/message/controller/SmsController.java

@@ -1,6 +1,6 @@
 package com.sckw.message.controller;
 
-import com.alibaba.fastjson.JSON;
+import com.sckw.core.annotation.Log;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.message.model.vo.req.SendSmsVerifyCoderReqVO;
 import com.sckw.message.service.SmsService;
@@ -35,8 +35,8 @@ public class SmsController {
      * @return: com.sckw.core.web.response.HttpResult
      */
     @PostMapping(value = "/sendVerifyCode", produces = MediaType.APPLICATION_JSON_VALUE)
+    @Log(description = "发送短信验证码")
     public HttpResult sendVerifyCode(@Valid @RequestBody SendSmsVerifyCoderReqVO param) {
-        log.info("发送验证码参数:{}", JSON.toJSONString(param));
         smsService.sendVerifyCode(param);
         return HttpResult.ok();
     }

+ 0 - 80
sckw-modules/sckw-message/src/main/java/com/sckw/message/controller/TestMqController.java

@@ -1,80 +0,0 @@
-package com.sckw.message.controller;
-
-import cn.hutool.core.lang.UUID;
-import com.alibaba.fastjson2.JSON;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.sckw.core.web.response.HttpResult;
-import com.sckw.stream.enums.SmsCodeEnum;
-import com.sckw.stream.model.Person;
-import com.sckw.message.producer.DelayProducer;
-import com.sckw.stream.enums.MessageEnum;
-import com.sckw.stream.model.SckwMessage;
-import com.sckw.stream.model.SckwSms;
-import jakarta.annotation.Resource;
-import lombok.AllArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.cloud.stream.function.StreamBridge;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import java.util.Date;
-import java.util.HashMap;
-
-/**
- * 测试mq
- */
-@Slf4j
-@RestController
-@AllArgsConstructor
-@RequestMapping("/test-mq")
-public class TestMqController {
-
-    private final DelayProducer delayProducer;
-
-    @GetMapping("/index")
-    public HttpResult index() {
-        return HttpResult.ok(System.currentTimeMillis());
-    }
-
-
-    /**
-     * 发送消息Rabbitmq
-     * @param msg 消息内容
-     * @param delay 延时时间
-     */
-    @GetMapping("/sendRabbitmq")
-    public HttpResult sendRabbitmq(String msg, Long delay) {
-        delayProducer.sendMsg(msg, delay);
-        return HttpResult.ok();
-    }
-
-    @Resource
-    private StreamBridge streamBridge;
-    @Autowired
-    private ObjectMapper objectMapper;
-
-    @GetMapping("/sendTest")
-    public HttpResult sendRabbitMq(String name) {
-        String uuid = UUID.fastUUID().toString();
-        SckwSms sckwSms = new SckwSms();
-        sckwSms.setPhone("17358629955");
-        sckwSms.setSignName("矿拉拉");
-        sckwSms.setTemplateCode(SmsCodeEnum.VERIFICATION_CODE);
-        sckwSms.setParams(new HashMap(){{put("code", "123456");}});
-        streamBridge.send("sckw-sms", JSON.toJSONString(sckwSms));
-
-
-        SckwMessage message = new SckwMessage();
-        //person.setName(String.valueOf(System.currentTimeMillis()));
-        message.setMsgUrl("---");
-        message.setPushType("====");
-        message.setClientId("111111111111111");
-        streamBridge.send("sckw-message", JSON.toJSONString(message));
-        return HttpResult.ok(uuid);
-
-    }
-
-
-}

+ 2 - 2
sckw-modules/sckw-message/src/main/java/com/sckw/message/dubbo/SmsInfoServiceImpl.java

@@ -13,8 +13,8 @@ import org.apache.dubbo.config.annotation.DubboService;
 @DubboService(group = "design", version = "2.0.0")
 public class SmsInfoServiceImpl implements SmsInfoService {
     @Override
-    public String getVerifyCode(String phone) {
-        String key = String.format(RedisConstant.MESSAGE_SMS_VERIFY_CODE_VALUE_KEY, phone);
+    public String getVerifyCode(String type, String phone) {
+        String key = String.format(RedisConstant.MESSAGE_SMS_VERIFY_CODE_VALUE_KEY, type, phone);
         return RedissonUtils.getString(key);
     }
 }

+ 2 - 0
sckw-modules/sckw-message/src/main/java/com/sckw/message/model/vo/req/SendSmsVerifyCoderReqVO.java

@@ -21,4 +21,6 @@ public class SendSmsVerifyCoderReqVO {
     @Pattern(regexp = "^1[3456789]\\d{9}$", message = "非法的手机号")
     private String phone;
 
+    @NotBlank(message = "短信类型不能为空")
+    private String type;
 }

+ 1 - 0
sckw-modules/sckw-message/src/main/java/com/sckw/message/service/SckwMessageHandlerService.java

@@ -40,6 +40,7 @@ public class SckwMessageHandlerService {
      */
     @Transactional(rollbackFor = Exception.class)
     public void handler(SckwMessage sckwMessage) {
+        log.info("SckwMessageHandler:{}", JSON.toJSONString(sckwMessage));
         if (Boolean.FALSE.equals(RedissonUtils.tryLock(getKey(sckwMessage.getRequestId()), 10L, RedisConstant.CONSUMER_REQUEST_VALID_TIME))) {
             log.info("重复message消息:{},不处理", sckwMessage.getRequestId());
             return;

+ 25 - 19
sckw-modules/sckw-message/src/main/java/com/sckw/message/service/SckwSmsHandlerService.java

@@ -1,8 +1,8 @@
 package com.sckw.message.service;
 
 import com.alibaba.fastjson2.JSON;
-import com.sckw.redis.constant.RedisConstant;
 import com.sckw.message.model.KwmSms;
+import com.sckw.redis.constant.RedisConstant;
 import com.sckw.redis.utils.RedissonUtils;
 import com.sckw.stream.enums.SmsCodeEnum;
 import com.sckw.stream.model.SckwSms;
@@ -32,27 +32,33 @@ public class SckwSmsHandlerService {
      */
     public void handler(SckwSms sckwSms) {
         log.info("接收到发送短信消息:{},开始处理", JSON.toJSONString(sckwSms));
-        String requestKey = getKey(RedisConstant.MESSAGE_SMS_VERIFY_CODE_REQUEST_KEY, sckwSms.getPhone());
-        if (Boolean.FALSE.equals(RedissonUtils.tryLock(requestKey, 10L, RedisConstant.SMS_VERIFY_CODE_VALID_TIME))) {
-            log.info("重复发送短信消息,不处理");
+        String type = sckwSms.getType();
+        String phone = sckwSms.getPhone();
+        String requestKey = getKey(RedisConstant.MESSAGE_SMS_VERIFY_CODE_REQUEST_KEY, type, phone);
+        if (Boolean.FALSE.equals(RedissonUtils.tryLock(requestKey, 10L, 30L))) {
+            log.info("获取发送短信锁失败,不处理");
             return;
         }
-        String valueKey = getKey(RedisConstant.MESSAGE_SMS_VERIFY_CODE_VALUE_KEY, sckwSms.getPhone());
-        //发送短信
-        RedissonUtils.putString(valueKey, String.valueOf(sckwSms.getParams().get("code")), RedisConstant.SMS_VERIFY_CODE_VALID_TIME);
-        //发送短信
-        SmsUtil.sendSms(sckwSms.getPhone(), sckwSms.getSignName(), sckwSms.getTemplateCode().getName(), JSON.toJSONString(sckwSms.getParams()));
-        //数据入库
-        SmsCodeEnum smsCodeEnum = sckwSms.getTemplateCode();
-        KwmSms kwmSms = KwmSms.builder().type(smsCodeEnum.getType()).code(smsCodeEnum.getName())
-                .phone(sckwSms.getPhone()).content(smsCodeEnum.getValue())
-                .params(JSON.toJSONString(sckwSms.getParams())).build();
-        kwmSms.setCreateBy(sckwSms.getCreateBy());
-        kwmSms.setUpdateBy(sckwSms.getCreateBy());
-        kwmSmsService.add(kwmSms);
+        try {
+            String valueKey = getKey(RedisConstant.MESSAGE_SMS_VERIFY_CODE_VALUE_KEY, type, phone);
+            //发送短信
+            SmsUtil.sendSms(sckwSms.getPhone(), sckwSms.getSignName(), sckwSms.getTemplateCode().getName(), JSON.toJSONString(sckwSms.getParams()));
+            //放入缓存
+            RedissonUtils.putString(valueKey, String.valueOf(sckwSms.getParams().get("code")), RedisConstant.SMS_VERIFY_CODE_VALID_TIME);
+            //数据入库
+            SmsCodeEnum smsCodeEnum = sckwSms.getTemplateCode();
+            KwmSms kwmSms = KwmSms.builder().type(smsCodeEnum.getType()).code(smsCodeEnum.getName())
+                    .phone(sckwSms.getPhone()).content(smsCodeEnum.getValue())
+                    .params(JSON.toJSONString(sckwSms.getParams())).build();
+            kwmSms.setCreateBy(sckwSms.getCreateBy());
+            kwmSms.setUpdateBy(sckwSms.getCreateBy());
+            kwmSmsService.add(kwmSms);
+        } finally {
+            RedissonUtils.unlock(requestKey);
+        }
     }
 
-    private String getKey(String prefix, String args) {
-        return String.format(prefix, args);
+    private String getKey(String prefix, String args1, String args2) {
+        return String.format(prefix, args1, args2);
     }
 }

+ 14 - 10
sckw-modules/sckw-message/src/main/java/com/sckw/message/service/SmsService.java

@@ -1,6 +1,8 @@
 package com.sckw.message.service;
 
 import com.alibaba.fastjson2.JSON;
+import com.sckw.core.common.enums.enums.DictEnum;
+import com.sckw.core.common.enums.enums.DictTypeEnum;
 import com.sckw.core.exception.BusinessException;
 import com.sckw.core.utils.NumberUtils;
 import com.sckw.core.web.context.LoginUserHolder;
@@ -16,6 +18,7 @@ import org.springframework.stereotype.Service;
 
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Objects;
 
 /**
  * @author: yzc
@@ -37,23 +40,24 @@ public class SmsService {
      * @date: 2023-06-13 13:43
      */
     public void sendVerifyCode(SendSmsVerifyCoderReqVO param) {
+        String type = param.getType();
+        if (Objects.isNull(DictEnum.getLabel(DictTypeEnum.SEND_SMS_TYPE.getType(), type))) {
+            throw new BusinessException("非法短信类型!");
+        }
         String phone = param.getPhone();
-        // 防重攻击
-        String messageSmsVerifyCodeKey = getMessageSmsVerifyCodeKey(phone);
+        String messageSmsVerifyCodeKey = getMessageSmsVerifyCodeKey(type, phone);
         if (Boolean.TRUE.equals(RedissonUtils.exists(messageSmsVerifyCodeKey))) {
-            throw new BusinessException("请勿频繁获取短信验证码");
+            throw new BusinessException("请勿频繁获取短信验证码");
         }
-        SckwSms sckwSms = new SckwSms();
-        sckwSms.setPhone(param.getPhone());
-        sckwSms.setTemplateCode(SmsCodeEnum.VERIFICATION_CODE);
         Map<String, Object> params = new HashMap<>();
         params.put("code", NumberUtils.createRandomVcode());
-        sckwSms.setParams(params);
-        sckwSms.setCreateBy(LoginUserHolder.getUserId());
+        SckwSms sckwSms = new SckwSms();
+        sckwSms.setPhone(param.getPhone()).setType(type).setTemplateCode(SmsCodeEnum.VERIFICATION_CODE)
+                .setParams(params).setCreateBy(LoginUserHolder.getUserId());
         streamBridge.send("sckw-sms", JSON.toJSONString(sckwSms));
     }
 
-    private String getMessageSmsVerifyCodeKey(String phone) {
-        return String.format(RedisConstant.MESSAGE_SMS_VERIFY_CODE_VALUE_KEY, phone);
+    private String getMessageSmsVerifyCodeKey(String type, String phone) {
+        return String.format(RedisConstant.MESSAGE_SMS_VERIFY_CODE_VALUE_KEY, type, phone);
     }
 }

+ 4 - 0
sckw-modules/sckw-message/src/main/resources/bootstrap-test.yml

@@ -17,6 +17,10 @@ spring:
         group: sckw-service-platform
         # 配置文件格式
         file-extension: yaml
+        shared-configs:
+          - data-id: sckw-common.yml
+            group: sckw-common
+            refresh: true
         extension-configs:
           - dataId: sckw-common.yml
             group: sckw-service-platform

+ 12 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/controller/KwoTradeOrderController.java

@@ -1,5 +1,6 @@
 package com.sckw.order.controller;
 
+import com.sckw.core.annotation.Log;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.order.model.vo.req.*;
 import com.sckw.order.serivce.KwoTradeOrderService;
@@ -30,6 +31,7 @@ public class KwoTradeOrderController {
      */
     @GlobalTransactional(name = "default_tx_group")
     @PostMapping(value = "/addPurchaseOrderDraft", produces = MediaType.APPLICATION_JSON_VALUE)
+    @Log(description = "采购下单草稿")
     public HttpResult addPurchaseOrderDraft(@RequestBody @Validated PurchaseOrderDraftParam param) {
         kwoTradeOrderService.addPurchaseOrderDraft(param);
         return HttpResult.ok("采购下单草稿保存成功");
@@ -44,6 +46,7 @@ public class KwoTradeOrderController {
      */
     @GlobalTransactional(name = "default_tx_group")
     @PostMapping(value = "/addPurchaseOrderSubmit", produces = MediaType.APPLICATION_JSON_VALUE)
+    @Log(description = "采购下单提交")
     public HttpResult addPurchaseOrderSubmit(@RequestBody @Validated PurchaseOrderParam purchaseOrderParam) {
         kwoTradeOrderService.addPurchaseOrderSubmit(purchaseOrderParam);
         return HttpResult.ok("采购下单提交成功");
@@ -58,6 +61,7 @@ public class KwoTradeOrderController {
      */
     @GlobalTransactional(name = "default_tx_group")
     @PostMapping(value = "/addValetOrderDraft", produces = MediaType.APPLICATION_JSON_VALUE)
+    @Log(description = "代客下单草稿")
     public HttpResult addValetOrderDraft(@RequestBody @Validated ValetOrderDraftParam param) {
         kwoTradeOrderService.addValetOrderDraft(param);
         return HttpResult.ok("代客下单草稿保存成功");
@@ -73,6 +77,7 @@ public class KwoTradeOrderController {
      */
     @GlobalTransactional(name = "default_tx_group")
     @PostMapping(value = "/addValetOrderSubmit", produces = MediaType.APPLICATION_JSON_VALUE)
+    @Log(description = "代客下单提交")
     public HttpResult addValetOrderSubmit(@RequestBody @Validated ValetOrderParam valetOrderParam) {
         kwoTradeOrderService.addValetOrderSubmit(valetOrderParam);
         return HttpResult.ok("代客下单提交成功");
@@ -86,6 +91,7 @@ public class KwoTradeOrderController {
      * @return: com.sckw.core.web.response.HttpResult
      */
     @GetMapping("/detail")
+    @Log(description = "贸易订单详情")
     public HttpResult detail(@RequestParam Long id) {
         return HttpResult.ok(kwoTradeOrderService.detail(id));
     }
@@ -99,6 +105,7 @@ public class KwoTradeOrderController {
      */
     @GlobalTransactional(name = "default_tx_group")
     @PostMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
+    @Log(description = "贸易订单修改")
     public HttpResult update(@RequestBody @Validated UpdateOrderParam updateOrderParam) {
         kwoTradeOrderService.update(updateOrderParam);
         return HttpResult.ok("订单修改成功");
@@ -113,6 +120,7 @@ public class KwoTradeOrderController {
      */
     @GlobalTransactional(name = "default_tx_group")
     @PostMapping(value = "/acceptanceOrder", produces = MediaType.APPLICATION_JSON_VALUE)
+    @Log(description = "贸易订单受理")
     public HttpResult acceptanceOrder(@RequestBody @Validated AcceptanceOrderParam acceptanceOrderParam) {
         kwoTradeOrderService.acceptanceOrder(acceptanceOrderParam);
         return HttpResult.ok("订单受理成功");
@@ -127,6 +135,7 @@ public class KwoTradeOrderController {
      */
     @GlobalTransactional(name = "default_tx_group")
     @PostMapping(value = "/rejectOrder", produces = MediaType.APPLICATION_JSON_VALUE)
+    @Log(description = "贸易订单驳回")
     public HttpResult rejectOrder(@RequestBody @Validated RejectOrderParam rejectOrderParam) {
         kwoTradeOrderService.rejectOrder(rejectOrderParam);
         return HttpResult.ok("订单驳回成功");
@@ -140,6 +149,7 @@ public class KwoTradeOrderController {
      * @return: com.sckw.core.web.response.HttpResult
      */
     @GetMapping("/rejectReason")
+    @Log(description = "贸易订单驳回原因查询")
     public HttpResult rejectReason(@RequestParam Long id) {
         return HttpResult.ok("驳回订单原因查询成功", kwoTradeOrderService.rejectReason(id));
     }
@@ -153,6 +163,7 @@ public class KwoTradeOrderController {
      */
     @GlobalTransactional(name = "default_tx_group")
     @PostMapping(value = "/completeOrder", produces = MediaType.APPLICATION_JSON_VALUE)
+    @Log(description = "完结贸易订单")
     public HttpResult completeOrder(@RequestBody @Validated CompleteOrderParam completeOrderParam) {
         kwoTradeOrderService.completeOrder(completeOrderParam);
         return HttpResult.ok("订单完结成功");
@@ -168,6 +179,7 @@ public class KwoTradeOrderController {
      */
     @GlobalTransactional(name = "default_tx_group")
     @PostMapping(value = "/batchDelete", produces = MediaType.APPLICATION_JSON_VALUE)
+    @Log(description = "批量删除贸易订单")
     public HttpResult batchDelete(@RequestBody @Validated BatchDeleteParam param) {
         kwoTradeOrderService.batchDelete(param);
         return HttpResult.ok("订单批量删除成功");

+ 11 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/controller/KwoTransportDemandController.java

@@ -1,5 +1,6 @@
 package com.sckw.order.controller;
 
+import com.sckw.core.annotation.Log;
 import com.sckw.core.exception.BusinessException;
 import com.sckw.core.utils.CollectionUtils;
 import com.sckw.core.utils.StringUtils;
@@ -36,6 +37,7 @@ public class KwoTransportDemandController {
      * @return: com.sckw.core.web.response.HttpResult
      */
     @PostMapping(value = "/addDraft", produces = MediaType.APPLICATION_JSON_VALUE)
+    @Log(description = "新增运需草稿")
     public HttpResult addDraft(@RequestBody @Validated AddTransportDemandDraftParam param) {
         kwoTransportDemandService.addDraft(param);
         return HttpResult.ok("新增运需草稿成功");
@@ -50,6 +52,7 @@ public class KwoTransportDemandController {
      * @return: com.sckw.core.web.response.HttpResult
      */
     @PostMapping(value = "/addShelves", produces = MediaType.APPLICATION_JSON_VALUE)
+    @Log(description = "新增运需上架")
     public HttpResult addShelves(@RequestBody @Validated AddTransportDemandParam param) {
         kwoTransportDemandService.addShelves(param);
         return HttpResult.ok("新增运需上架成功");
@@ -64,6 +67,7 @@ public class KwoTransportDemandController {
      * @return: com.sckw.core.web.response.HttpResult
      */
     @GetMapping("/detail")
+    @Log(description = "获取运需详情")
     public HttpResult detail(@RequestParam Long id) {
         return HttpResult.ok(kwoTransportDemandService.detail(id));
     }
@@ -76,6 +80,7 @@ public class KwoTransportDemandController {
      * @return: com.sckw.core.web.response.HttpResult
      */
     @PostMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
+    @Log(description = "运需修改")
     public HttpResult update(@RequestBody @Validated UpdateTransportDemandParam param) {
         kwoTransportDemandService.update(param);
         return HttpResult.ok("运需修改成功!");
@@ -89,6 +94,7 @@ public class KwoTransportDemandController {
      * @return: com.sckw.core.web.response.HttpResult
      */
     @PostMapping(value = "/select", produces = MediaType.APPLICATION_JSON_VALUE)
+    @Log(description = "运需分页查询")
     public HttpResult select(@RequestBody @Validated SelectTransportDemandParam param) {
         return HttpResult.ok(kwoTransportDemandService.select(param));
     }
@@ -101,6 +107,7 @@ public class KwoTransportDemandController {
      * @return: com.sckw.core.web.response.HttpResult
      */
     @PostMapping(value = "/statistic", produces = MediaType.APPLICATION_JSON_VALUE)
+    @Log(description = "运需统计")
     public HttpResult statistic(@RequestBody StatisticTransportDemandParam param) {
         return HttpResult.ok(kwoTransportDemandService.statistic(param));
     }
@@ -130,6 +137,7 @@ public class KwoTransportDemandController {
      * @return: com.sckw.core.web.response.HttpResult
      */
     @GetMapping("/putOnShelves")
+    @Log(description = "运需上架")
     public HttpResult putOnShelves(@RequestParam Long id) {
         kwoTransportDemandService.putOnShelves(id);
         return HttpResult.ok("上架成功");
@@ -143,6 +151,7 @@ public class KwoTransportDemandController {
      * @return: com.sckw.core.web.response.HttpResult
      */
     @GetMapping("/batchTakeOffShelves")
+    @Log(description = "运需批量下架")
     public HttpResult batchTakeOffShelves(@RequestParam String ids) {
         List<Long> list = StringUtils.splitStrToList(ids, ",", Long.class);
         kwoTransportDemandService.batchTakeOffShelves(list);
@@ -157,6 +166,7 @@ public class KwoTransportDemandController {
      * @return: com.sckw.core.web.response.HttpResult
      */
     @GetMapping("/batchDelete")
+    @Log(description = "运需批量删除")
     public HttpResult batchDelete(@RequestParam String ids) {
         List<Long> list = StringUtils.splitStrToList(ids, ",", Long.class);
         kwoTransportDemandService.batchDelete(list);
@@ -171,6 +181,7 @@ public class KwoTransportDemandController {
      * @return: com.sckw.core.web.response.HttpResult
      */
     @PostMapping(value = "/demandSquaresList", produces = MediaType.APPLICATION_JSON_VALUE)
+    @Log(description = "运需广场列表")
     public HttpResult demandSquaresList(@RequestBody @Validated TransportDemandSquaresParam param) {
         return HttpResult.ok(kwoTransportDemandService.demandSquaresList(param));
     }

+ 81 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/controller/KwpWantBuyController.java

@@ -1,8 +1,11 @@
 package com.sckw.order.controller;
 
+import com.sckw.core.annotation.Log;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.order.model.vo.req.AddWantBuyParam;
 import com.sckw.order.model.vo.req.UpdateWantBuyParam;
+import com.sckw.order.model.vo.req.WantBuyDels;
+import com.sckw.order.model.vo.req.WantBuySelectParam;
 import com.sckw.order.serivce.KwpWantBuyService;
 import lombok.RequiredArgsConstructor;
 import org.springframework.http.MediaType;
@@ -21,6 +24,28 @@ public class KwpWantBuyController {
 
     private final KwpWantBuyService kwpWantBuyService;
 
+    /**
+     * @desc: 求购分页查询
+     * @author lt
+     * @Date 15:34 2023/7/26 0026
+    **/
+    @PostMapping(value = "/select", produces = MediaType.APPLICATION_JSON_VALUE)
+    @Log(description = "求购分页查询")
+    public HttpResult select(@RequestBody WantBuySelectParam wantBuySelectParam) {
+        return HttpResult.ok(kwpWantBuyService.select(wantBuySelectParam));
+    }
+
+    /**
+     * @desc: 求购大厅
+     * @author lt
+     * @Date 15:34 2023/7/26 0026
+    **/
+    @PostMapping(value = "/buyHallList", produces = MediaType.APPLICATION_JSON_VALUE)
+    @Log(description = "求购大厅")
+    public HttpResult buyHallList(@RequestBody WantBuySelectParam wantBuySelectParam) {
+        return HttpResult.ok(kwpWantBuyService.buyHallList(wantBuySelectParam));
+    }
+
     /**
      * @desc: 新增求购草稿
      * @author: yzc
@@ -29,6 +54,7 @@ public class KwpWantBuyController {
      * @return: com.sckw.core.web.response.HttpResult
      */
     @PostMapping(value = "/addDraft", produces = MediaType.APPLICATION_JSON_VALUE)
+    @Log(description = "新增求购草稿")
     public HttpResult addDraft(@RequestBody AddWantBuyParam addWantBuyParam) {
         kwpWantBuyService.addDraft(addWantBuyParam);
         return HttpResult.ok("新增求购草稿成功");
@@ -42,11 +68,48 @@ public class KwpWantBuyController {
      * @return: com.sckw.core.web.response.HttpResult
      */
     @PostMapping(value = "/addShelves", produces = MediaType.APPLICATION_JSON_VALUE)
+    @Log(description = "新增求购上架")
     public HttpResult addShelves(@RequestBody @Validated AddWantBuyParam addWantBuyParam) {
         kwpWantBuyService.addShelves(addWantBuyParam);
         return HttpResult.ok("新增求购上架成功");
     }
 
+    /**
+     * @desc: 求购上架
+     * @Author: lt
+     * @Date: 13:39 2023/7/25 0025
+    **/
+    @GetMapping(value = "/putOnShelves", produces = MediaType.APPLICATION_JSON_VALUE)
+    @Log(description = "求购上架")
+    public HttpResult putOnShelves(@RequestParam Long id) {
+        kwpWantBuyService.putOnShelves(id);
+        return HttpResult.ok("求购上架成功");
+    }
+
+    /**
+     * @desc: 求购批量下架
+     * @Author: lt
+     * @Date: 13:39 2023/7/25 0025
+    **/
+    @PostMapping(value = "/batchTakeOffShelves", produces = MediaType.APPLICATION_JSON_VALUE)
+    @Log(description = "求购批量下架")
+    public HttpResult batchTakeOffShelves(@RequestBody WantBuyDels ids) {
+        kwpWantBuyService.batchTakeOffShelves(ids);
+        return HttpResult.ok("批量下架成功");
+    }
+
+    /**
+     * @desc: 求购批量删除
+     * @Author: lt
+     * @Date: 13:39 2023/7/25 0025
+    **/
+    @DeleteMapping(value = "/dels", produces = MediaType.APPLICATION_JSON_VALUE)
+    @Log(description = "求购批量删除")
+    public HttpResult dels(@RequestBody WantBuyDels ids) {
+        kwpWantBuyService.dels(ids);
+        return HttpResult.ok("批量删除成功");
+    }
+
     /**
      * @desc: 求购详情
      * @author: yzc
@@ -55,14 +118,32 @@ public class KwpWantBuyController {
      * @return: com.sckw.core.web.response.HttpResult
      */
     @GetMapping("/detail")
+    @Log(description = "求购详情")
     public HttpResult detail(@RequestParam Long id) {
         return HttpResult.ok(kwpWantBuyService.detail(id));
     }
 
+    /**
+     * @desc: 求购编辑
+     * @author lt
+     * @Date 15:22 2023/7/26 0026
+    **/
     @PostMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
+    @Log(description = "求购编辑")
     public HttpResult update(@RequestBody @Validated UpdateWantBuyParam updateWantBuyParam) {
         kwpWantBuyService.update(updateWantBuyParam);
         return HttpResult.ok("求购修改成功!");
     }
 
+    /**
+     * @desc 求购角标统计
+     * @author lt
+     * @Date 15:23 2023/7/26 0026
+    **/
+    @PostMapping(value = "/statistic", produces = MediaType.APPLICATION_JSON_VALUE)
+    @Log(description = "求购统计")
+    public HttpResult statistic(@RequestBody WantBuySelectParam params)
+    {
+        return HttpResult.ok(kwpWantBuyService.statistic(params));
+    }
 }

+ 11 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/dao/KwpWantBuyMapper.java

@@ -2,7 +2,13 @@ package com.sckw.order.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.order.model.KwoWantBuy;
+import com.sckw.order.model.vo.req.WantBuySelectParam;
+import com.sckw.order.model.vo.res.TableTopRes;
+import com.sckw.order.model.vo.res.WantBuySelectRes;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * @desc: 求购mapper
@@ -12,4 +18,9 @@ import org.apache.ibatis.annotations.Mapper;
 @Mapper
 public interface KwpWantBuyMapper extends BaseMapper<KwoWantBuy> {
 
+    List<WantBuySelectRes> queryBuyHallList(@Param("wantBuyReq") WantBuySelectParam wantBuyReq);
+
+    List<WantBuySelectRes> pageSelect(@Param("wantBuyReq") WantBuySelectParam wantBuyReq);
+
+    List<TableTopRes> statisticsCount(@Param("wantBuyReq") WantBuySelectParam wantBuyReq);
 }

+ 5 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/dao/KwpWantBuyTradingMapper.java

@@ -3,6 +3,9 @@ package com.sckw.order.dao;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.order.model.KwoWantBuyTrading;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * @desc: 求购支付方式mapper
@@ -12,4 +15,6 @@ import org.apache.ibatis.annotations.Mapper;
 @Mapper
 public interface KwpWantBuyTradingMapper extends BaseMapper<KwoWantBuyTrading> {
 
+    void insertBatch(@Param(value = "list") List<KwoWantBuyTrading> list);
+
 }

+ 39 - 35
sckw-modules/sckw-order/src/main/java/com/sckw/order/dubbo/TradeOrderInfoServiceImpl.java

@@ -105,46 +105,50 @@ public class TradeOrderInfoServiceImpl implements TradeOrderInfoService {
         Long id = param.getTOrderId();
         Long updateBy = param.getUpdateBy();
         String lockKey = String.format(RedisConstant.GOODS_UPDATE_AMOUNT_KEY, id);
-        if (Boolean.FALSE.equals(RedissonUtils.tryLock(lockKey, 3L, 3L))) {
+        if (Boolean.FALSE.equals(RedissonUtils.tryLock(lockKey, 10L, 30L))) {
             return HttpResult.error("业务繁忙,请稍后再试!");
         }
-        KwoTradeOrder order = kwoTradeOrderService.getById(id);
-        if (Objects.isNull(order)) {
-            return HttpResult.error("订单不存在!");
-        }
-        if (!Objects.equals(String.valueOf(order.getStatus()), DictEnum.TORDER_STATUS_4.getValue())) {
-            return HttpResult.error("执行中的订单才可物流托运!");
-        }
-        BigDecimal amount = order.getAmount();
-        BigDecimal addEntrustAmount = order.getEntrustAmount();
-        if (Objects.nonNull(param.getEntrustAmount())) {
-            addEntrustAmount = addEntrustAmount.add(param.getActualAmount());
-            if (amount.compareTo(addEntrustAmount) < 0) {
-                return HttpResult.error("物流已委托总量不可大于订单总量!");
+        try {
+            KwoTradeOrder order = kwoTradeOrderService.getById(id);
+            if (Objects.isNull(order)) {
+                return HttpResult.error("订单不存在!");
             }
-        }
-        BigDecimal addActualAmount = order.getActualAmount();
-        if (Objects.nonNull(param.getActualAmount())) {
-            addActualAmount = addActualAmount.add(param.getActualAmount());
-            if (amount.compareTo(addActualAmount) < 0) {
-                return HttpResult.error("物流实际交付总量不可大于订单总量!");
+            if (!Objects.equals(String.valueOf(order.getStatus()), DictEnum.TORDER_STATUS_4.getValue())) {
+                return HttpResult.error("执行中的订单才可物流托运!");
             }
+            BigDecimal amount = order.getAmount();
+            BigDecimal addEntrustAmount = order.getEntrustAmount();
+            if (Objects.nonNull(param.getEntrustAmount())) {
+                addEntrustAmount = addEntrustAmount.add(param.getActualAmount());
+                if (amount.compareTo(addEntrustAmount) < 0) {
+                    return HttpResult.error("物流已委托总量不可大于订单总量!");
+                }
+            }
+            BigDecimal addActualAmount = order.getActualAmount();
+            if (Objects.nonNull(param.getActualAmount())) {
+                addActualAmount = addActualAmount.add(param.getActualAmount());
+                if (amount.compareTo(addActualAmount) < 0) {
+                    return HttpResult.error("物流实际交付总量不可大于订单总量!");
+                }
+            }
+            order.setEntrustAmount(addEntrustAmount).setActualAmount(addActualAmount).setUpdateBy(param.getUpdateBy());
+            //已履约量等于订单总量自动完结订单
+            if (amount.compareTo(addActualAmount) == 0) {
+                order.setStatus(Integer.valueOf(DictEnum.TORDER_STATUS_5.getValue()));
+                KwoTradeOrderTrack track = new KwoTradeOrderTrack();
+                track.setTOrderId(order.getId()).setTOrderNo(order.getTOrderNo()).setStatus(order.getStatus())
+                        .setCreateBy(updateBy).setUpdateBy(updateBy);
+                kwoTradeOrderTrackService.insert(track);
+            }
+            kwoTradeOrderService.updateById(order);
+            //更新mongodb
+            SckwTradeOrder updateParam = new SckwTradeOrder();
+            updateParam.setTOrderId(order.getId()).setEntrustAmount(addEntrustAmount).setActualAmount(addActualAmount)
+                    .setStatus(order.getStatus()).setUpdateBy(param.getUpdateBy()).setUpdateByName(param.getUpdateByName()).setUpdateTime(new Date());
+            saveMongoDb(3, updateParam);
+        } finally {
+            RedissonUtils.unlock(lockKey);
         }
-        order.setEntrustAmount(addEntrustAmount).setActualAmount(addActualAmount).setUpdateBy(param.getUpdateBy());
-        //已履约量等于订单总量自动完结订单
-        if (amount.compareTo(addActualAmount) == 0) {
-            order.setStatus(Integer.valueOf(DictEnum.TORDER_STATUS_5.getValue()));
-            KwoTradeOrderTrack track = new KwoTradeOrderTrack();
-            track.setTOrderId(order.getId()).setTOrderNo(order.getTOrderNo()).setStatus(order.getStatus())
-                    .setCreateBy(updateBy).setUpdateBy(updateBy);
-            kwoTradeOrderTrackService.insert(track);
-        }
-        kwoTradeOrderService.updateById(order);
-        //更新mongodb
-        SckwTradeOrder updateParam = new SckwTradeOrder();
-        updateParam.setTOrderId(order.getId()).setEntrustAmount(addEntrustAmount).setActualAmount(addActualAmount)
-                .setStatus(order.getStatus()).setUpdateBy(param.getUpdateBy()).setUpdateByName(param.getUpdateByName()).setUpdateTime(new Date());
-        saveMongoDb(3, updateParam);
         return HttpResult.ok();
     }
 

+ 78 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/req/UpdateWantBuyParam.java

@@ -1,8 +1,15 @@
 package com.sckw.order.model.vo.req;
 
+import jakarta.validation.Valid;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
+import jakarta.validation.constraints.Pattern;
 import lombok.Getter;
 import lombok.Setter;
 import lombok.ToString;
+import org.hibernate.validator.constraints.Length;
+
+import java.util.List;
 
 /**
  * @desc: 修改求购请求参数
@@ -13,4 +20,75 @@ import lombok.ToString;
 @Setter
 @ToString
 public class UpdateWantBuyParam {
+
+    /**
+     * 求购单id
+     */
+    @NotNull(message = "求购单id不能为空")
+    private Long id;
+
+    /**
+     * 商品名称
+     */
+    @NotBlank(message = "商品名称不能为空")
+    @Length(max = 50, message = "商品名称最多支持50字")
+    private String name;
+
+    /**
+     * 商品分类
+     */
+    @Length(max = 32, message = "商品分类最多支持32字")
+    private String goodsType;
+
+    /**
+     * 商品规格
+     */
+    @Length(max = 20, message = "商品规格最多支持20字")
+    private String spec;
+
+    /**
+     * 支付方式集合
+     */
+    private List<String> tradings;
+
+    /**
+     * 求购单价
+     */
+    @NotBlank(message = "求购单价不能为空")
+    @Length(max = 20, message = "求购单价最多支持20字")
+    private String price;
+
+    /**
+     * 求购总量
+     */
+    @NotBlank(message = "求购总量不能为空")
+    @Length(max = 20, message = "求购总量最多支持20字")
+    private String amount;
+
+    /**
+     * 联系人姓名
+     */
+    @NotBlank(message = "联系人姓名不能为空")
+    @Length(max = 32, message = "联系人姓名最多支持32字")
+    private String contacts;
+
+    /**
+     * 联系电话
+     */
+    @NotBlank(message = "联系电话不能为空")
+    @Pattern(regexp = "^1[3456789]\\d{9}$", message = "非法手机号格式")
+    private String phone;
+
+    /**
+     * 地址信息
+     */
+    @Valid
+    private WantBuyAddressParam addressInfo;
+
+    @Length(max = 200, message = "备注最多支持200字")
+    private String remark;
+
+
+
+
 }

+ 24 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/req/WantBuyDels.java

@@ -0,0 +1,24 @@
+package com.sckw.order.model.vo.req;
+
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotEmpty;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.sckw.core.utils.LongToStringUtils;
+import java.util.List;
+
+/**
+ * @Description:
+ * @Author: lt
+ * @Date: 2023-07-25-15:10
+ */
+@Getter
+@Setter
+@ToString
+public class WantBuyDels {
+
+    @NotBlank(message = "ids不能为空")
+    private String ids;
+}

+ 75 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/req/WantBuySelectParam.java

@@ -0,0 +1,75 @@
+package com.sckw.order.model.vo.req;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.sckw.core.model.page.PageRequest;
+import jakarta.validation.constraints.NotNull;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serial;
+import java.time.LocalDateTime;
+import java.util.List;
+
+/**
+ * @Description:
+ * @Author: lt
+ * @Date: 2023-07-26-15:43
+ */
+@Getter
+@Setter
+public class WantBuySelectParam extends PageRequest {
+
+    @Serial
+    private static final long serialVersionUID = 1881051859375157819L;
+
+    /**
+     * 关键字搜索
+     */
+    private String keywords;
+
+    /**
+     * 状态 来自com.sckw.core.common.enums.enums.DictEnum.GOODS_STATUS_0
+     */
+    private String status;
+
+    /**
+     * 支付集合字符串
+     */
+    private String trading;
+
+    /**
+     * 字符串转集合进行筛选
+     */
+    private List<String> tradings;
+
+    /**
+     * 地区编码
+     */
+    private String cityCode;
+
+    /**
+     * 地区级别
+     */
+    private String areaLevel;
+
+    /**
+     * 商品类型
+     */
+    private String goodsType;
+
+    /**
+     * 商品类型type值
+     */
+    private String goodsTypeValue;
+
+    private List<String> goodsTypeValueSearch;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @NotNull(message = "生成开始时间不能为空")
+    private LocalDateTime startCreateTime;
+
+    @NotNull(message = "生成结束时间不能为空")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private LocalDateTime endCreateTime;
+
+}

+ 30 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/res/TableTopRes.java

@@ -0,0 +1,30 @@
+package com.sckw.order.model.vo.res;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+/**
+ * @Description:
+ * @Author: lt
+ * @Date: 2023-07-27-10:57
+ */
+@Getter
+@Setter
+@ToString
+public class TableTopRes {
+    /**
+     * tab名称
+     */
+    private String name;
+
+    /**
+     * 状态值
+     */
+    private String value;
+
+    /**
+     * 统计值
+     */
+    private long total;
+}

+ 5 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/res/WantBuyDetailRes.java

@@ -31,6 +31,11 @@ public class WantBuyDetailRes implements Serializable {
      * 商品名称
      */
     private String name;
+
+    /**
+     * 求购企业name
+     */
+    private String entName;
     /**
      * 商品类型
      */

+ 93 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/res/WantBuySelectRes.java

@@ -0,0 +1,93 @@
+package com.sckw.order.model.vo.res;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.sckw.order.model.KwoWantBuyTrading;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @Description:
+ * @Author: lt
+ * @Date: 2023-07-26-15:48
+ */
+@Getter
+@Setter
+public class WantBuySelectRes {
+
+    private Long id;
+
+    /**
+     * 商品名称
+     */
+    private String name;
+
+    private Long entId;
+
+
+    private String entName;
+
+    /**
+     * 商品分类
+     */
+    private String goodsType;
+
+    /**
+     * 商品分类label
+     */
+    private String goodsTypeLabel;
+
+    /**
+     * 规格
+     */
+    private String spec;
+
+    /**
+     * 地址信息
+     */
+    private String addressName;
+
+    /**
+     * 支付方式
+     */
+    private String tradings;
+
+    /**
+     * 求购单价
+     */
+    private String price;
+
+    /**
+     * 求购总量
+     */
+    private String amount;
+
+    /**
+     * 常见时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" ,timezone = "GMT+8")
+    private Date createTime;
+    /**
+     * 更新时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" ,timezone = "GMT+8")
+    private Date updateTime;
+
+    /**
+     * 状态
+     */
+    private Integer status;
+    private String statusLabel;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    //private List<KwoWantBuyTrading> wantBuyTradings;
+    private List<WantBuyTradingRes> wantBuyTradings;
+
+
+}

+ 20 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/res/WantBuyTradingRes.java

@@ -0,0 +1,20 @@
+package com.sckw.order.model.vo.res;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @Author: lt
+ * @Date: 2023-07-26-20:26
+ */
+@Getter
+@Setter
+public class WantBuyTradingRes {
+
+    private Long wantBuyId;
+
+    private String trading;
+
+
+}

+ 22 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwoWantBuyAddressService.java

@@ -1,10 +1,18 @@
 package com.sckw.order.serivce;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.sckw.core.model.constant.Global;
+import com.sckw.core.utils.CollectionUtils;
 import com.sckw.order.dao.KwpWantBuyAddressMapper;
+import com.sckw.order.model.KwoTradeOrderAddress;
+import com.sckw.order.model.KwoWantBuyAddress;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * @desc: 求购地址信息service
  * @author: yzc
@@ -17,4 +25,18 @@ public class KwoWantBuyAddressService {
 
     private final KwpWantBuyAddressMapper kwpWantBuyAddress;
 
+    public List<KwoWantBuyAddress> getByAddressId(Long addressId) {
+        LambdaQueryWrapper<KwoWantBuyAddress> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(KwoWantBuyAddress::getWantBuyId, addressId).eq(KwoWantBuyAddress::getDelFlag, Global.NO);
+        List<KwoWantBuyAddress> list = kwpWantBuyAddress.selectList(wrapper);
+        return CollectionUtils.emptyIfNull(list);
+    }
+
+    public void delAddressByWantBuyIds(List<String> wantBuyIds) {
+        LambdaUpdateWrapper<KwoWantBuyAddress> wrapper = new LambdaUpdateWrapper<>();
+        wrapper.in(KwoWantBuyAddress::getWantBuyId, wantBuyIds).eq(KwoWantBuyAddress::getDelFlag, Global.NO)
+                        .set(KwoWantBuyAddress::getDelFlag, Global.YES);
+        kwpWantBuyAddress.update(null,wrapper);
+    }
+
 }

+ 33 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwoWantBuyTradingService.java

@@ -1,10 +1,17 @@
 package com.sckw.order.serivce;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.sckw.core.model.constant.Global;
 import com.sckw.order.dao.KwpWantBuyTradingMapper;
+import com.sckw.order.model.KwoTradeOrderAddress;
+import com.sckw.order.model.KwoWantBuyTrading;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * @desc: 求购支付service
  * @author: yzc
@@ -17,6 +24,32 @@ public class KwoWantBuyTradingService {
 
     private final KwpWantBuyTradingMapper kwpWantBuyTradingMapper;
 
+    public void insertBatch(List<KwoWantBuyTrading> list) {
+        kwpWantBuyTradingMapper.insertBatch(list);
+    }
+
+    public List<KwoWantBuyTrading> getByWantBuyId(Long wantBuyId) {
+        LambdaQueryWrapper<KwoWantBuyTrading> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(KwoWantBuyTrading::getWantBuyId, wantBuyId).eq(KwoWantBuyTrading::getDelFlag, Global.NO);
+        List<KwoWantBuyTrading> list = kwpWantBuyTradingMapper.selectList(wrapper);
+        return list;
+    }
+
+    //根据wangtBuyId删除
+    public Integer deleteByWantBuyid(Long wantBuyid){
+        LambdaUpdateWrapper<KwoWantBuyTrading> wrapper = new LambdaUpdateWrapper<>();
+        wrapper.eq(KwoWantBuyTrading::getWantBuyId, wantBuyid).set(KwoWantBuyTrading::getDelFlag, Global.YES);
+        return kwpWantBuyTradingMapper.update(null,wrapper);
+    }
+
+    //根据wangtBuyIds批量删除
+    public void delTradingByWantBuyids(List<String> ids)
+    {
+        LambdaUpdateWrapper<KwoWantBuyTrading> wrapper = new LambdaUpdateWrapper<>();
+        wrapper.in(KwoWantBuyTrading::getWantBuyId, ids).eq(KwoWantBuyTrading::getDelFlag, Global.NO).set(KwoWantBuyTrading::getDelFlag, Global.YES);
+        kwpWantBuyTradingMapper.update(null,wrapper);
+    }
+
 
 
 }

+ 467 - 3
sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwpWantBuyService.java

@@ -1,12 +1,39 @@
 package com.sckw.order.serivce;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.sckw.core.common.enums.enums.DictEnum;
+import com.sckw.core.common.enums.enums.DictTypeEnum;
+import com.sckw.core.exception.BusinessException;
+import com.sckw.core.model.constant.Global;
+import com.sckw.core.model.page.PageRes;
+import com.sckw.core.utils.BeanUtils;
+import com.sckw.core.utils.CollectionUtils;
+import com.sckw.core.utils.IdWorker;
+import com.sckw.core.utils.StringUtils;
+import com.sckw.core.web.context.LoginUserHolder;
+import com.sckw.order.dao.KwpWantBuyAddressMapper;
 import com.sckw.order.dao.KwpWantBuyMapper;
+import com.sckw.order.dao.KwpWantBuyTradingMapper;
+import com.sckw.order.model.*;
 import com.sckw.order.model.vo.req.AddWantBuyParam;
 import com.sckw.order.model.vo.req.UpdateWantBuyParam;
-import com.sckw.order.model.vo.res.WantBuyDetailRes;
+import com.sckw.order.model.vo.req.WantBuyDels;
+import com.sckw.order.model.vo.req.WantBuySelectParam;
+import com.sckw.order.model.vo.res.*;
+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 lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * @desc: 求购service
@@ -17,25 +44,462 @@ import org.springframework.stereotype.Service;
 @Slf4j
 @RequiredArgsConstructor
 public class KwpWantBuyService {
-
+    @DubboReference(version = "2.0.0", group = "design", check = false)
+    private RemoteSystemService remoteSystemService;
     private final KwpWantBuyMapper kwpWantBuyMapper;
+    private final KwpWantBuyTradingMapper kwpWantBuyTradingMapper;
+    private final KwpWantBuyAddressMapper kwpWantBuyAddressMapper;
     private final KwoWantBuyAddressService kwoWantBuyAddressService;
     private final KwoWantBuyTradingService kwoWantBuyTradingService;
 
+    /**
+     * @desc: 求购大厅列表查询
+     * @author lt
+     * @Date 11:50 2023/8/1 0001
+    **/
+    public PageRes<WantBuySelectRes> buyHallList(WantBuySelectParam wantBuySelectParam){
+        // 如果有求购方式的查询条件,需要先查询出求购方式的id
+        if (StringUtils.isNotBlank(wantBuySelectParam.getTrading())) {
+            List<String> longList = stringToLongList(wantBuySelectParam.getTrading());
+            wantBuySelectParam.setTradings(longList);
+        }
+        // 商品分类筛选处理
+        if (StringUtils.isNotBlank(wantBuySelectParam.getGoodsType()) && StringUtils.isNotBlank(wantBuySelectParam.getGoodsTypeValue())) {
+            List<String> goodsTypes = goodsTypeHandle(wantBuySelectParam);
+            wantBuySelectParam.setGoodsTypeValueSearch(goodsTypes);
+        }
+
+        // 分页查询求购列表
+        PageHelper.startPage(wantBuySelectParam.getPage(), wantBuySelectParam.getPageSize());
+        List<WantBuySelectRes> wantBuyDto = kwpWantBuyMapper.queryBuyHallList(wantBuySelectParam);
+
+        if (CollectionUtils.isEmpty(wantBuyDto)) {
+            return new PageRes<>();
+        }
+
+        // 获取供应企业信息
+        List<Long> supplyEntIds = wantBuyDto.stream()
+                .map(WantBuySelectRes::getEntId)
+                .collect(Collectors.toList());
+        // 通过企业id查询企业信息
+        List<EntCacheResDto> entList = remoteSystemService.queryEntCacheByIds(supplyEntIds);
+        Map<Long, String> entMap = entList.stream()
+                .collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName, (k1, k2) -> k1));
+
+        // 对求购列表进行数据处理
+        wantBuyDto.forEach(wantBuySelectRes -> {
+            List<String> tradings = wantBuySelectRes.getWantBuyTradings().stream()
+                    .map(wantBuyTradingRes -> DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), wantBuyTradingRes.getTrading()))
+                    .collect(Collectors.toList());
+            wantBuySelectRes.setTradings(String.join(Global.COMMA, tradings));
+            wantBuySelectRes.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), wantBuySelectRes.getGoodsType()));
+            wantBuySelectRes.setStatusLabel(DictEnum.getLabel(DictTypeEnum.GOODS_STATUS.getType(), String.valueOf(wantBuySelectRes.getStatus())));
+            wantBuySelectRes.setEntName(Objects.nonNull(entMap.get(wantBuySelectRes.getEntId())) ? entMap.get(wantBuySelectRes.getEntId()) : null);
+        });
+
+        return new PageRes<>(new PageInfo<>(wantBuyDto));
+    }
+
+    /**
+     * @desc 求购列表查询
+     * @author lt
+     * @Date 11:50 2023/8/1 0001
+    **/
+    public PageRes<WantBuySelectRes> select(WantBuySelectParam wantBuySelectParam) {
+
+        if (StringUtils.isNotBlank(wantBuySelectParam.getTrading())) {
+            List<String> longList = stringToLongList(wantBuySelectParam.getTrading());
+            wantBuySelectParam.setTradings(longList);
+        }
+        if (StringUtils.isNotBlank(wantBuySelectParam.getStatus())) {
+            wantBuySelectParam.setStatus(wantBuySelectParam.getStatus());
+        }
 
+        //商品分类筛选处理
+        if (StringUtils.isNotBlank(wantBuySelectParam.getGoodsType()) && StringUtils.isNotBlank(wantBuySelectParam.getGoodsTypeValue())) {
+            List<String> goodsTypes = goodsTypeHandle(wantBuySelectParam);
+            wantBuySelectParam.setGoodsTypeValueSearch(goodsTypes);
+        }
+        PageHelper.startPage(wantBuySelectParam.getPage(), wantBuySelectParam.getPageSize());
+        List<WantBuySelectRes> wantBuyDto = kwpWantBuyMapper.pageSelect(wantBuySelectParam);
+        if (CollectionUtils.isEmpty(wantBuyDto)) {
+            return new PageRes<>();
+        }
+        // 获取供应企业信息
+        List<Long> supplyEntIds = wantBuyDto.stream()
+                .map(WantBuySelectRes::getEntId)
+                .collect(Collectors.toList());
+        // 通过企业id查询企业信息
+        List<EntCacheResDto> entList = remoteSystemService.queryEntCacheByIds(supplyEntIds);
+        Map<Long, String> entMap = entList.stream()
+                .collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName, (k1, k2) -> k1));
+        //把查询出来的集合wantBuyTradings里面对的tranding 转成字符串放在String里面
+        wantBuyDto.forEach(wantBuySelectRes -> {
+            List<String> tradings = wantBuySelectRes.getWantBuyTradings().stream()
+                    .map(wantBuyTradingRes -> DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), wantBuyTradingRes.getTrading()))
+                    .collect(Collectors.toList());
+            wantBuySelectRes.setTradings(String.join(Global.COMMA, tradings));
+            wantBuySelectRes.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), wantBuySelectRes.getGoodsType()));
+            wantBuySelectRes.setStatusLabel(DictEnum.getLabel(DictTypeEnum.GOODS_STATUS.getType(), String.valueOf(wantBuySelectRes.getStatus())));
+            wantBuySelectRes.setEntName(Objects.nonNull(entMap.get(wantBuySelectRes.getEntId())) ? entMap.get(wantBuySelectRes.getEntId()) : null);
+        });
+
+        return new PageRes<>(new PageInfo<>(wantBuyDto));
+    }
+
+    /**
+     * @Desc 求购列表查询
+     * @param wantBuySelectParam
+     * @return
+     */
+    private List<String> goodsTypeHandle(WantBuySelectParam wantBuySelectParam) {
+        List<SysDictResDto> goodsTypeList = remoteSystemService.queryDictBottom(wantBuySelectParam.getGoodsType(), wantBuySelectParam.getGoodsTypeValue());
+        if (CollectionUtils.isNotEmpty(goodsTypeList)) {
+            return  goodsTypeList.stream().map(SysDictResDto::getValue).toList();
+        }
+        return null;
+    }
+
+    /**
+     * @Desc 字符串转数组
+     * @return
+     */
+    private List<String> stringToLongList(String str) {
+        if (StringUtils.isBlank(str)) {
+            return null;
+        }
+// 使用逗号分隔字符串,并去除两端空格
+        String[] stringArray = str.split(Global.COMMA);
+        return Arrays.asList(stringArray);
+    }
+
+    /**
+     * @Desc 求购草稿新增
+     * @Author lt
+     * @Param
+     * @Return
+     * @Date 11:56 2023/7/25 0025
+     **/
     public void addDraft(AddWantBuyParam param) {
+        Integer status = Integer.valueOf(DictEnum.GOODS_STATUS_0.getValue());  //保存草稿
+        String message = "求购草稿";
+        addWantBuy(param, message, status);
 
     }
 
+    /**
+     * @Desc 求购上架新增
+     * @Author lt
+     * @Param
+     * @Return
+     * @Date 11:57 2023/7/25 0025
+     **/
     public void addShelves(AddWantBuyParam param) {
+        Integer status = Integer.valueOf(DictEnum.GOODS_STATUS_1.getValue());   //上架
+        String message = "求购上架";
+        addWantBuy(param, message, status);
+    }
 
+    /**
+     * @desc 新增求购统一方法
+     * @author lt
+     * @Date 11:52 2023/8/1 0001
+    **/
+    @Transactional(rollbackFor = Exception.class)
+    public void addWantBuy(AddWantBuyParam param, String message, Integer status) {
+        Date currentDate = new Date();
+        Long entId = LoginUserHolder.getEntId();
+        if (Objects.isNull(entId)) {
+            throw new BusinessException("企业ID不存在,请重新登录");
+        }
+//        KwoWantBuy kwoWantBuy = BeanUtils.copyProperties(param, KwoWantBuy.class);
+        KwoWantBuy kwoWantBuy = new KwoWantBuy();
+        Long userId = LoginUserHolder.getUserId();
+        kwoWantBuy.setEntId(LoginUserHolder.getEntId())
+                .setName(param.getName()).setGoodsType(param.getGoodsType())
+                .setSpec(param.getSpec()).setPrice(param.getPrice())
+                .setAmount(param.getAmount()).setContacts(param.getContacts())
+                .setPhone(param.getPhone()).setId(new IdWorker(1L).nextId())
+                .setRemark(param.getRemark()).setStatus(status).setCreateBy(userId)
+                .setCreateTime(currentDate).setUpdateBy(userId)
+                .setUpdateTime(currentDate).setDelFlag(Global.NO);
+        kwpWantBuyMapper.insert(kwoWantBuy);
+        if (Objects.isNull(kwoWantBuy.getId())) {
+            throw new BusinessException(message + "失败");
+        }
+        /*
+        支付方式添加
+         */
+        List<String> list = param.getTradings();
+        if (list != null && !list.isEmpty()) {
+            Date currentDateTime = new Date();
+            List<KwoWantBuyTrading> tradingList = list.stream()
+                    .map(item -> {
+                        KwoWantBuyTrading kwoWantBuyTrading = new KwoWantBuyTrading();
+                        kwoWantBuyTrading.setWantBuyId(kwoWantBuy.getId());
+                        kwoWantBuyTrading.setTrading(item);
+                        kwoWantBuyTrading.setCreateBy(userId);
+                        kwoWantBuyTrading.setCreateTime(currentDateTime);
+                        kwoWantBuyTrading.setUpdateTime(currentDateTime);
+                        kwoWantBuyTrading.setStatus(status);
+                        return kwoWantBuyTrading;
+                    })
+                    .collect(Collectors.toList());
+            kwoWantBuyTradingService.insertBatch(tradingList);
+        }
+        /*
+        地址信息添加,如果存在地址信息-新增入库
+         */
+        if (Objects.nonNull(param.getAddressInfo())) {
+            KwoWantBuyAddress address = new KwoWantBuyAddress();
+            Long idWorker = new IdWorker(1L).nextId();
+            address.setWantBuyId(kwoWantBuy.getId());
+            address.setName(param.getAddressInfo().getName());
+            address.setType(param.getAddressInfo().getType());
+            address.setContacts(param.getAddressInfo().getContacts());
+            address.setPhone(param.getAddressInfo().getPhone());
+            address.setCityCode(param.getAddressInfo().getCityCode());
+            address.setCityName(param.getAddressInfo().getCityName());
+            address.setDetailAddress(param.getAddressInfo().getDetailAddress());
+            address.setLat(param.getAddressInfo().getLat());
+            address.setLng(param.getAddressInfo().getLng());
+            address.setFence(param.getAddressInfo().getFence());
+            address.setId(idWorker);
+            address.setCreateBy(LoginUserHolder.getUserId());
+            address.setCreateTime(new Date());
+            address.setUpdateTime(new Date());
+            kwpWantBuyAddressMapper.insert(address);
+        }
     }
 
+    /**
+     * @Desc: 求购上架
+     * @Author: lt
+     * @Date: 13:38 2023/7/25 0025
+     **/
+    public void putOnShelves(Long id) {
+        KwoWantBuy kwoWantBuy = kwpWantBuyMapper.selectById(id);
+        if (Objects.isNull(kwoWantBuy)) {
+            throw new BusinessException("求购信息不存在");
+        }
+        if (kwoWantBuy.getStatus().equals(Integer.valueOf(DictEnum.GOODS_STATUS_1.getValue()))) {
+            throw new BusinessException("求购信息已上架");
+        }
+        kwoWantBuy.setStatus(Integer.valueOf(DictEnum.GOODS_STATUS_1.getValue()));
+        kwpWantBuyMapper.updateById(kwoWantBuy);
+    }
+
+    /**
+     * @desc 求购批量下架
+     * @author lt
+     * @Date 14:56 2023/7/25 0025
+     **/
+    public void batchTakeOffShelves(WantBuyDels param) {
+        if (BeanUtils.isEmpty(param)) {
+            throw new BusinessException("请提供需要下架的产品");
+        }
+        List<String> ids = List.of(param.getIds().split(Global.COMMA));
+        //1.查询ids所属产品只有status=1的才能下架,如果存在其它状态的则不能下架
+        LambdaUpdateWrapper<KwoWantBuy> updateWrapper = new LambdaUpdateWrapper<>();
+        updateWrapper.eq(KwoWantBuy::getDelFlag, Global.NO).in(KwoWantBuy::getId, ids);
+        updateWrapper.set(KwoWantBuy::getStatus, DictEnum.GOODS_STATUS_2.getValue())
+                .set(KwoWantBuy::getUpdateBy, LoginUserHolder.getUserId())
+                .set(KwoWantBuy::getUpdateTime, new Date());
+        kwpWantBuyMapper.update(null, updateWrapper);
+    }
+
+    /**
+     * @desc 求购删除
+     * @author lt
+     * @Date 10:15 2023/8/1 0001
+    **/
+    @Transactional(rollbackFor = Exception.class)
+    public void dels(WantBuyDels param) {
+        List<String> ids = List.of(param.getIds().split(Global.COMMA));
+        LambdaUpdateWrapper<KwoWantBuy> updateWrapper = new LambdaUpdateWrapper<>();
+        updateWrapper.in(KwoWantBuy::getId, ids).eq(KwoWantBuy::getDelFlag, Global.NO)
+                .set(KwoWantBuy::getDelFlag, Global.YES)
+                .set(KwoWantBuy::getUpdateBy, LoginUserHolder.getUserId())
+                .set(KwoWantBuy::getUpdateTime, new Date());
+        kwpWantBuyMapper.update(null, updateWrapper);
+        //删除地址信息
+        kwoWantBuyAddressService.delAddressByWantBuyIds(ids);
+        //删除支付方式
+        kwoWantBuyTradingService.delTradingByWantBuyids(ids);
+
+    }
+
+    /**
+     * @desc 求购详情查询
+     * @author lt
+     * @Date 10:15 2023/8/1 0001
+    **/
     public WantBuyDetailRes detail(Long id) {
-        return null;
+        //先判断求购订单是否存在
+        KwoWantBuy kwoWantBuy = kwpWantBuyMapper.selectById(id);
+        if (Objects.isNull(kwoWantBuy)) {
+            throw new BusinessException("求购信息不存在");
+        }
+        WantBuyDetailRes responseData = BeanUtils.copyProperties(kwoWantBuy, WantBuyDetailRes.class);
+        //TODO 还未定义好求购状态(从表里面拿还是enum)
+        responseData.setStatusLabel(DictEnum.getLabel(DictTypeEnum.GOODS_STATUS.getType(), String.valueOf(responseData.getStatus())));
+        //求购地址信息
+        KwoWantBuyAddress address = kwpWantBuyAddressMapper.selectOne(new LambdaQueryWrapper<KwoWantBuyAddress>()
+                .eq(KwoWantBuyAddress::getWantBuyId, id).eq(KwoWantBuyAddress::getDelFlag, Global.NO));
+        if (Objects.nonNull(address)) {
+            WantBuyAddressDetailRes wantBuyAddressInfo = BeanUtils.copyProperties(address, WantBuyAddressDetailRes.class);
+            wantBuyAddressInfo.setTypeLabel(DictEnum.getLabel(DictTypeEnum.TORDER_ADDRESS_TYPE.getType(), String.valueOf(wantBuyAddressInfo.getType())));
+            System.out.println(wantBuyAddressInfo);
+            responseData.setAddressInfo(wantBuyAddressInfo);
+        }
+        //获取求购企业信息
+        EntCacheResDto entCacheResDto = remoteSystemService.queryEntCacheById(kwoWantBuy.getEntId());
+        if (Objects.nonNull(entCacheResDto)) {
+            responseData.setEntName(entCacheResDto.getFirmName());
+        }
+        //求购支付方式集合
+        List<KwoWantBuyTrading> tradingList = kwoWantBuyTradingService.getByWantBuyId(id);
+        if (Objects.nonNull(tradingList) && !tradingList.isEmpty()) {
+            List<String> tradings = tradingList.stream().map(KwoWantBuyTrading::getTrading).collect(Collectors.toList());
+            responseData.setTradings(tradings);
+            //改成stream流的方式
+            List<String> result = tradings.stream()
+                    .map(trading -> DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), trading))
+                    .collect(Collectors.toList());
+            String tradingLabels = String.join(Global.COMMA, result);
+            //获取到的是一个集合,需要转换成字符串
+            responseData.setTradingLabels(tradingLabels);
+        }
+        return responseData;
     }
 
+    /**
+     * @desc: 更新求购信息
+     * @author lt
+     * @Date 15:20 2023/7/26 0026
+     **/
     public void update(UpdateWantBuyParam param) {
+        Long id = param.getId();
+        KwoWantBuy kwoWantBuy = selectOneById(id);
+        if (Objects.isNull(kwoWantBuy)) throw new BusinessException("求购信息不存在");
+        //1.更新求购信息
+        Date currentDate = new Date();
+        Long userId = LoginUserHolder.getUserId();
+        KwoWantBuy wantBuy = BeanUtils.copyProperties(param, KwoWantBuy.class);
+        wantBuy.setUpdateBy(userId);
+        wantBuy.setUpdateTime(currentDate);
+        kwpWantBuyMapper.updateById(wantBuy);
+        //int i = kwpWantBuyMapper.updateById(wantBuy);
+        //2.更新求购地址信息,判断是否存在地址信息
+
+        if (Objects.nonNull(param.getAddressInfo())) {
+            //判断是否存在地址信息
+            LambdaQueryWrapper<KwoWantBuyAddress> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.eq(KwoWantBuyAddress::getWantBuyId, id).eq(KwoWantBuyAddress::getDelFlag, Global.NO);
+            KwoWantBuyAddress kwoWantBuyAddress = kwpWantBuyAddressMapper.selectOne(queryWrapper);
+            //存在地址信息则更新,不存在则新增
+
+            KwoWantBuyAddress kwoWantBuyAddress1 = BeanUtils.copyProperties(param.getAddressInfo(), KwoWantBuyAddress.class);
+            kwoWantBuyAddress1.setUpdateTime(currentDate);
+            kwoWantBuyAddress1.setUpdateBy(userId);
+            if (Objects.nonNull(kwoWantBuyAddress)) {
+                kwoWantBuyAddress1.setId(kwoWantBuyAddress.getId());
+                kwpWantBuyAddressMapper.updateById(kwoWantBuyAddress1);
+            } else {
+                //不存在则新增地址信息
+                kwoWantBuyAddress1.setWantBuyId(id);
+                kwoWantBuyAddress1.setCreateTime(currentDate);
+                kwoWantBuyAddress1.setCreateBy(userId);
+                kwpWantBuyAddressMapper.insert(kwoWantBuyAddress1);
+            }
+        }
+        //3.更新求购支付方式
+        List<String> tradings = param.getTradings();
+        if (CollectionUtils.isNotEmpty(tradings)) {
+            kwoWantBuyTradingService.deleteByWantBuyid(id);
+            ArrayList<KwoWantBuyTrading> list = new ArrayList<>(param.getTradings().size());
+            for (String trading : tradings) {
+                KwoWantBuyTrading kwoWantBuyTrading = new KwoWantBuyTrading();
+                kwoWantBuyTrading.setWantBuyId(id);
+                kwoWantBuyTrading.setTrading(trading);
+                kwoWantBuyTrading.setCreateTime(currentDate);
+                kwoWantBuyTrading.setUpdateTime(currentDate);
+                kwoWantBuyTrading.setCreateBy(userId);
+                list.add(kwoWantBuyTrading);
+            }
+            kwpWantBuyTradingMapper.insertBatch(list);
+        }
+
+
+    }
+
+    /**
+     * @Desc: 根据id查询求购信息
+     * @param id
+     * @return
+     */
+    public KwoWantBuy selectOneById(Long id) {
+        LambdaQueryWrapper<KwoWantBuy> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(KwoWantBuy::getId, id)
+                .eq(KwoWantBuy::getDelFlag, Global.NO);
+        return kwpWantBuyMapper.selectOne(queryWrapper);
+    }
+
+    /**
+     * @Desc: 查询求购角标统计数量
+     * @param
+     * @return
+     */
+    public Map statistic(WantBuySelectParam params) {
+        if (StringUtils.isNotBlank(params.getTrading())) {
+            List<String> longList = stringToLongList(params.getTrading());
+            params.setTradings(longList);
+        }
+        if (StringUtils.isNotBlank(params.getStatus())) {
+            params.setStatus(params.getStatus());
+        }
+        //商品分类筛选处理
+        if (StringUtils.isNotBlank(params.getGoodsType()) && StringUtils.isNotBlank(params.getGoodsTypeValue())) {
+            List<String> goodsTypes = goodsTypeHandle(params);
+            params.setGoodsTypeValueSearch(goodsTypes);
+        }
+        /**统计数据**/
+        List<TableTopRes> counts = kwpWantBuyMapper.statisticsCount(params);
+        long tatol = counts.size();
+        System.out.println(counts);
+
+        /**全部数据-处理**/
+        List<TableTopRes> countList = new ArrayList();
+        TableTopRes allCount = new TableTopRes();
+//        allCount.setValue(String.valueOf(DictEnum.GOODS_STATUS_0));
+        allCount.setTotal(tatol);
+        allCount.setName("全部");
+        countList.add(allCount);
+
+        /**数据处理**/
+        Map<String, Integer> statusMap = new HashMap<>();
+        statusMap.put("保存", Integer.valueOf(DictEnum.GOODS_STATUS_0.getValue()));
+        statusMap.put("下架", Integer.valueOf(DictEnum.GOODS_STATUS_2.getValue()));
+        statusMap.put("上架", Integer.valueOf(DictEnum.GOODS_STATUS_1.getValue()));
+        for (Map.Entry<String, Integer> entry : statusMap.entrySet()) {
+            System.out.println(entry.getKey() + "--->" + entry.getValue());
+            TableTopRes count = new TableTopRes();
+            int smlTotal = 0;
+            for (TableTopRes topCount : counts) {
+                if (topCount.getValue() != null && !topCount.getValue().isEmpty() && Integer.parseInt(topCount.getValue()) == entry.getValue()) {
+                    smlTotal++;
+                }
+            }
+            count.setName(entry.getKey());
+            count.setValue(String.valueOf(entry.getValue()));
+            count.setTotal(smlTotal);
+            countList.add(count);
+        }
 
+        /**数据组装**/
+        Map tableCount = new HashMap();
+        tableCount.put("tableTop", countList);
+        tableCount.put("tableBottom", tatol);
+        return tableCount;
     }
 }

+ 5 - 0
sckw-modules/sckw-order/src/main/resources/bootstrap-test.yml

@@ -17,6 +17,11 @@ spring:
         group: sckw-service-platform
         # 配置文件格式
         file-extension: yaml
+        shared-configs:
+          - data-id: sckw-common.yml
+            group: sckw-common
+            refresh: true
+
         extension-configs:
           - dataId: sckw-common.yml
             group: sckw-service-platform

+ 118 - 0
sckw-modules/sckw-order/src/main/resources/mapper/KwoWantBuyMapper.xml

@@ -0,0 +1,118 @@
+<?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.order.dao.KwpWantBuyMapper">
+
+    <sql id="Base_Column_List">
+        kb.id
+        ,kb.`name`
+        ,kb.ent_id
+        , kb.goods_type goodsType
+        , kb.spec
+        , kb.price
+        , kb.amount
+        , kb.status
+        , kb.remark
+        , kb.create_time createTime
+        , kt.want_buy_id wantBuyId
+        , kt.trading trading
+        , kba.name addressName
+    </sql>
+
+    <resultMap id="wangBuyResultMap" type="com.sckw.order.model.vo.res.WantBuySelectRes">
+        <id column="id" property="id"/>
+        <result column="name" property="name"/>
+        <result column="goodsType" property="goodsType"/>
+        <result column="spec" property="spec"/>
+        <result column="price" property="price"/>
+        <result column="amount" property="amount"/>
+        <result column="status" property="status"/>
+        <result column="remark" property="remark"/>
+        <result column="createTime" property="createTime"/>
+        <result column="updateTime" property="updateTime"/>
+        <collection property="wantBuyTradings" column="id" ofType="com.sckw.order.model.vo.res.WantBuyTradingRes" javaType="java.util.List" select="tradingSql" >
+            <id column="wantBuyId" property="wantBuyId"/>
+            <result column="trading" property="trading"/>
+        </collection>
+    </resultMap>
+
+    <sql id="where">
+        kb.del_flag = 0 and kt.del_flag = 0
+        <if test="wantBuyReq.startCreateTime != null and wantBuyReq.endCreateTime != null">
+            and kb.create_time between #{wantBuyReq.startCreateTime,jdbcType=TIMESTAMP} and
+            #{wantBuyReq.endCreateTime,jdbcType=TIMESTAMP}
+        </if>
+        <if test="wantBuyReq.tradings != null and wantBuyReq.tradings.size() > 0">
+            and kt.trading in
+            <foreach collection="wantBuyReq.tradings" item="item" open="(" close=")" separator=",">
+                #{item,jdbcType=VARCHAR}
+            </foreach>
+        </if>
+        <if test="wantBuyReq.status != null and wantBuyReq.status != ''">
+            and kb.status = #{wantBuyReq.status}
+        </if>
+        <if test="wantBuyReq.keywords != null and wantBuyReq.keywords != ''">
+            and (
+            kb.`name` like concat('%', #{wantBuyReq.keywords,jdbcType=VARCHAR}, '%')
+            )
+        </if>
+        <if test="wantBuyReq.goodsTypeValueSearch != null and wantBuyReq.goodsTypeValueSearch.size() > 0">
+            and kb.goods_type in
+            <foreach collection="wantBuyReq.goodsTypeValueSearch" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="wantBuyReq.cityCode != null and wantBuyReq.cityCode != ''">
+            and kba.city_code = #{wantBuyReq.cityCode}
+        </if>
+    </sql>
+
+    <select id="pageSelect" resultMap="wangBuyResultMap" resultType="com.sckw.order.model.vo.res.WantBuySelectRes">
+        select
+        <include refid="Base_Column_List" />
+        from kwo_want_buy kb left join kwo_want_buy_trading kt on kb.id = kt.want_buy_id
+        join kwo_want_buy_address kba on kb.id = kba.want_buy_id
+        <where>
+            <include refid="where" />
+        </where>
+        group by kb.id
+        order by kb.create_time desc
+    </select>
+
+<!--    <resultMap id="tradIngMap" type="com.sckw.order.model.KwoWantBuyTrading">-->
+    <resultMap id="tradIngMap" type="com.sckw.order.model.vo.res.WantBuyTradingRes">
+        <id column="wantBuyId" property="wantBuyId"/>
+        <result column="trading" property="trading"/>
+    </resultMap>
+
+
+    <select id="tradingSql" resultMap="tradIngMap">
+        select want_buy_id wantBuyId, trading
+        from kwo_want_buy_trading
+        where want_buy_id = #{wantBuyId}
+    </select>
+
+
+
+    <select id="statisticsCount"  resultType="com.sckw.order.model.vo.res.TableTopRes" parameterType="java.util.Map">
+        select kb.`status` value
+        from kwo_want_buy kb left join kwo_want_buy_trading kt on kb.id = kt.want_buy_id
+        <where>
+            <include refid="where" />
+        </where>
+        group by kb.id
+        order by kb.create_time desc
+    </select>
+
+
+    <select id="queryBuyHallList"  resultMap="wangBuyResultMap" resultType="com.sckw.order.model.vo.res.WantBuySelectRes">
+        select
+            <include refid="Base_Column_List" />
+        from kwo_want_buy kb left join kwo_want_buy_trading kt on kb.id = kt.want_buy_id
+        join kwo_want_buy_address kba on kb.id = kba.want_buy_id
+        <where>
+            <include refid="where" />
+        </where>
+        group by kb.id
+        order by kb.create_time desc
+    </select>
+</mapper>

+ 36 - 0
sckw-modules/sckw-order/src/main/resources/mapper/KwoWantBuyTradingMapper.xml

@@ -0,0 +1,36 @@
+<?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.order.dao.KwpWantBuyTradingMapper">
+
+    <insert id="insertBatch">
+        insert into kwo_want_buy_trading
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            id,
+            want_buy_id,
+            trading,
+            remark,
+            status,
+            create_by,
+            create_time,
+            update_by,
+            update_time,
+            del_flag
+        </trim>
+        values
+        <foreach collection="list" item="item" separator=",">
+            <trim prefix="(" suffix=")" suffixOverrides=",">
+                #{item.id,jdbcType=BIGINT},
+                #{item.wantBuyId,jdbcType=BIGINT},
+                #{item.trading,jdbcType=VARCHAR},
+                #{item.remark,jdbcType=VARCHAR},
+                #{item.status,jdbcType=VARCHAR},
+                #{item.createBy,jdbcType=VARCHAR},
+                #{item.createTime,jdbcType=VARCHAR},
+                #{item.updateBy,jdbcType=VARCHAR},
+                #{item.updateTime,jdbcType=VARCHAR},
+                #{item.delFlag,jdbcType=VARCHAR}
+            </trim>
+        </foreach>
+    </insert>
+
+</mapper>

+ 4 - 4
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpLedgerLogisticsController.java

@@ -111,8 +111,8 @@ public class KwpLedgerLogisticsController {
      *
      * @return
      */
-    @GetMapping("shipperCount")
-    public HttpResult shipperCount(@Valid LogisticsReq logisticsReq) {
+    @PostMapping("shipperCount")
+    public HttpResult shipperCount(@RequestBody @Valid LogisticsReq logisticsReq) {
         return HttpResult.ok(kwpLedgerLogisticsService.orderCount(logisticsReq, 1));
     }
 
@@ -121,8 +121,8 @@ public class KwpLedgerLogisticsController {
      *
      * @return
      */
-    @GetMapping("carrierCount")
-    public HttpResult carrierCount(@Valid LogisticsReq logisticsReq) {
+    @PostMapping("carrierCount")
+    public HttpResult carrierCount(@RequestBody @Valid LogisticsReq logisticsReq) {
         return HttpResult.ok(kwpLedgerLogisticsService.orderCount(logisticsReq, 2));
     }
 

+ 11 - 7
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpLedgerTradeController.java

@@ -87,6 +87,7 @@ public class KwpLedgerTradeController {
     public HttpResult querySellDetail(@RequestParam("id") String id) {
         return HttpResult.ok(kwpLedgerTradeService.queryDetail(Long.valueOf(id), TradeUnitType.PURCHASE));
     }
+
     /**
      * 采购-查询贸易对账单详情
      *
@@ -95,8 +96,9 @@ public class KwpLedgerTradeController {
      */
     @GetMapping("queryPurchaseDetail")
     public HttpResult queryPurchaseDetail(@RequestParam("id") String id) {
-        return HttpResult.ok(kwpLedgerTradeService.queryDetail(Long.valueOf(id),TradeUnitType.SELL));
+        return HttpResult.ok(kwpLedgerTradeService.queryDetail(Long.valueOf(id), TradeUnitType.SELL));
     }
+
     /**
      * 修改贸易对账单详情(修改物流对账单接口使用)
      *
@@ -113,9 +115,10 @@ public class KwpLedgerTradeController {
      *
      * @return
      */
-    @GetMapping("sellCount")
-    public HttpResult sellCount() {
-        return HttpResult.ok(kwpLedgerTradeService.orderCount(1));
+    @PostMapping("sellCount")
+    public HttpResult sellCount(@RequestBody @Valid TradeReq tradeReq) {
+        tradeReq.setUnitType(TradeUnitType.PURCHASE);
+        return HttpResult.ok(kwpLedgerTradeService.orderCount(tradeReq));
     }
 
     /**
@@ -123,9 +126,10 @@ public class KwpLedgerTradeController {
      *
      * @return
      */
-    @GetMapping("purchaseCount")
-    public HttpResult purchaseCount() {
-        return HttpResult.ok(kwpLedgerTradeService.orderCount(2));
+    @PostMapping("purchaseCount")
+    public HttpResult purchaseCount(@RequestBody @Valid TradeReq tradeReq) {
+        tradeReq.setUnitType(TradeUnitType.SELL);
+        return HttpResult.ok(kwpLedgerTradeService.orderCount(tradeReq));
     }
 
     /**

+ 4 - 29
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpSettlementLogisticsController.java

@@ -1,6 +1,5 @@
 package com.sckw.payment.controller;
 
-import com.sckw.core.model.page.PageRes;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.excel.utils.ExcelUtil;
 import com.sckw.payment.model.constant.LogisticsUnitType;
@@ -36,15 +35,9 @@ public class KwpSettlementLogisticsController {
     //   ========= 运费收款 承运方 =========
     @PostMapping(name = "运费收款-物流订单列表", path = "pageListCollection")
     public HttpResult pageSelectCollection(@RequestBody @Valid SettlementReq settlementReq) {
-        List<Long> idList = settlementReq.getIdList();
         return HttpResult.ok(kwpSettlementLogisticsService.pageSelectCollection(settlementReq));
     }
 
-//    @PostMapping(name = "物流-电子钱 -列表", path = "testpageSelectCollection")
-//    public HttpResult testpageSelectCollection(@RequestBody @Valid SettlementReq settlementReq) {
-//       System.out.println(settlementReq.getIds());
-//        return HttpResult.ok(settlementReq);
-//    }
     @PostMapping(name = "运费收款-物流订单各状态列表总数", path = "getCountListCollection")
     public HttpResult getCountListCollection(@RequestBody @Valid SettlementReq settlementReq) {
         return HttpResult.ok(kwpSettlementLogisticsService.getCountListCollection(settlementReq));
@@ -52,18 +45,9 @@ public class KwpSettlementLogisticsController {
 
     @PostMapping(name = "运费收款-根据条件导出物流订单表数据", path = "exportCollection")
     public HttpResult exportCollection(HttpServletResponse response, @RequestBody @Valid SettlementReq settlementReq) {
+        settlementReq.setUnitType(LogisticsUnitType.CARRIER);
         List<SettlementLogisticsDto> list;
-        if (CollectionUtils.isEmpty(settlementReq.getIdList()) && settlementReq.getPage() != 0 && settlementReq.getPageSize() != 0) {
-            //有page、pageSize,无ids
-            PageRes<SettlementLogisticsDto> pageResult = kwpSettlementLogisticsService.pageSelectCollection(settlementReq);
-            list = pageResult.getList();
-        } else if (CollectionUtils.isEmpty(settlementReq.getIdList())) {
-            //无page、pageSize,无ids
-            list = kwpSettlementLogisticsService.selectList(LogisticsUnitType.CARRIER);
-        } else {
-            //有ids
-            list = kwpSettlementLogisticsService.selectList(settlementReq.getIdList());
-        }
+        list = kwpSettlementLogisticsService.selectList(settlementReq);
         return this.export(response, list);
     }
 
@@ -86,18 +70,9 @@ public class KwpSettlementLogisticsController {
 
     @PostMapping(name = "运费付款-根据条件导出物流订单表数据", path = "exportPayment")
     public HttpResult exportPayment(HttpServletResponse response, @RequestBody @Valid SettlementReq settlementReq) {
+        settlementReq.setUnitType(LogisticsUnitType.SHIPPER);
         List<SettlementLogisticsDto> list;
-        if (CollectionUtils.isEmpty(settlementReq.getIdList()) && settlementReq.getPage() != 0 && settlementReq.getPageSize() != 0) {
-            //有page、pageSize,无ids
-            PageRes<SettlementLogisticsDto> pageResult = kwpSettlementLogisticsService.pageSelectPayment(settlementReq);
-            list = pageResult.getList();
-        } else if (CollectionUtils.isEmpty(settlementReq.getIdList())) {
-            //无page、pageSize,无ids
-            list = kwpSettlementLogisticsService.selectList(LogisticsUnitType.SHIPPER);
-        } else {
-            //有ids
-            list = kwpSettlementLogisticsService.selectList(settlementReq.getIdList());
-        }
+        list = kwpSettlementLogisticsService.selectList(settlementReq);
         return this.export(response, list);
     }
 

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

@@ -1,6 +1,7 @@
 package com.sckw.payment.controller;
 
 import com.sckw.core.web.response.HttpResult;
+import com.sckw.payment.model.vo.req.OfflinePaymentReq;
 import com.sckw.payment.model.constant.SettlementOrderTypeEnum;
 import com.sckw.payment.model.vo.req.SettlementOfflinePayReq;
 import com.sckw.payment.model.vo.req.SettlementOfflineReq;
@@ -25,7 +26,7 @@ public class KwpSettlementOfflineController {
     //  =========  运费收款  =========
 
     @PostMapping(name = "物流-线下付款(运费收款)记录-列表", path = "pageListLogisticsCollection")
-    public HttpResult pageListLogisticsCollection(@RequestBody @Valid SettlementOfflineReq settlementOfflineReq) {
+    public HttpResult pageListLogisticsCollection(SettlementOfflineReq settlementOfflineReq) {
         return HttpResult.ok(kwpSettlementOfflineService.pageListLogisticsCollection(settlementOfflineReq));
     }
 
@@ -34,9 +35,9 @@ public class KwpSettlementOfflineController {
         return HttpResult.ok(kwpSettlementOfflineService.detailLogisticsCollection(id));
     }
 
-    @GetMapping(name = "物流-线下付款(运费收款)记录-新增", path = "confirmLogisticsCollection")
-    public HttpResult confirmLogisticsCollection(@RequestParam("id") Long id, @RequestParam("price") Float price) {
-        return HttpResult.ok(kwpSettlementOfflineService.confirmLogisticsCollection(id, price));
+    @PostMapping(name = "物流-线下付款(运费收款)记录-新增", path = "confirmLogisticsCollection")
+    public HttpResult confirmLogisticsCollection(@RequestBody @Valid OfflinePaymentReq offlinePaymentReq) {
+        return HttpResult.ok(kwpSettlementOfflineService.confirmLogisticsCollection(offlinePaymentReq));
     }
 
 

+ 8 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpSettlementTradeController.java

@@ -41,6 +41,7 @@ public class KwpSettlementTradeController {
     @PostMapping(name = "收款-销售结算单列表", path = "pageSellList")
     public HttpResult pageListCollection(@RequestBody @Valid SettlementTradeReq settlementReq) {
         settlementReq.setUnitType(TradeUnitType.PURCHASE);
+        settlementReq.check();
         return HttpResult.ok(kwpSettlementTradeService.pageListCollection(settlementReq));
     }
 
@@ -53,6 +54,7 @@ public class KwpSettlementTradeController {
     @PostMapping(name = "收款-表头统计数量", path = "getSellCount")
     public HttpResult getCount(@RequestBody @Valid SettlementTradeReq settlementReq) {
         settlementReq.setUnitType(TradeUnitType.PURCHASE);
+        settlementReq.check();
         return HttpResult.ok(kwpSettlementTradeService.getCount(settlementReq));
     }
 
@@ -64,12 +66,14 @@ public class KwpSettlementTradeController {
      */
     @PostMapping(name = "收款-表尾金额结算数据", path = "getSellSum")
     public HttpResult getSellSum(@RequestBody @Valid SettlementTradeReq settlementReq) {
+        settlementReq.check();
         settlementReq.setUnitType(TradeUnitType.PURCHASE);
         return HttpResult.ok(kwpSettlementTradeService.getCountListCollection(settlementReq));
     }
 
     @PostMapping(name = "收款-根据ids导出销售结算单列表", path = "exportCollection")
     public HttpResult exportCollection(HttpServletResponse response, @RequestBody @Valid SettlementTradeReq settlementReq) {
+        settlementReq.check();
         List<ISettlement> list;
         settlementReq.setUnitType(TradeUnitType.PURCHASE);
         if (CollectionUtils.isEmpty(settlementReq.getIdList())) {
@@ -97,6 +101,7 @@ public class KwpSettlementTradeController {
      */
     @PostMapping(name = "付款-采购结算单列表", path = "pagePurchaseList")
     public HttpResult pageListPayment(@RequestBody @Valid SettlementTradeReq settlementReq) {
+        settlementReq.check();
         settlementReq.setUnitType(TradeUnitType.SELL);
         return HttpResult.ok(kwpSettlementTradeService.pageListCollection(settlementReq));
     }
@@ -109,6 +114,7 @@ public class KwpSettlementTradeController {
      */
     @PostMapping(name = "收款-表头统计数量", path = "getPurchaseCount")
     public HttpResult getPurchaseCount(@RequestBody @Valid SettlementTradeReq settlementReq) {
+        settlementReq.check();
         settlementReq.setUnitType(TradeUnitType.SELL);
         return HttpResult.ok(kwpSettlementTradeService.getCount(settlementReq));
     }
@@ -121,12 +127,14 @@ public class KwpSettlementTradeController {
      */
     @PostMapping(name = "收款-物流结算订单列表头部汇总数量", path = "getPurchaseSum")
     public HttpResult getCountListPayment(@RequestBody @Valid SettlementTradeReq settlementReq) {
+        settlementReq.check();
         settlementReq.setUnitType(TradeUnitType.SELL);
         return HttpResult.ok(kwpSettlementTradeService.getCountListCollection(settlementReq));
     }
 
     @PostMapping(name = "付款-根据ids导出采购结算单列表", path = "exportPayment")
     public HttpResult exportPayment(HttpServletResponse response, @RequestBody @Valid SettlementTradeReq settlementReq) {
+        settlementReq.check();
         List<ISettlement> list;
         settlementReq.setUnitType(TradeUnitType.SELL);
         if (CollectionUtils.isEmpty(settlementReq.getIdList())) {

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

@@ -3,10 +3,14 @@ package com.sckw.payment.controller;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.payment.model.constant.SettlementOrderTypeEnum;
 import com.sckw.payment.model.constant.SettlementWalletPayTypeEnum;
+import com.sckw.payment.model.vo.req.OfflinePaymentReq;
 import com.sckw.payment.model.vo.req.SettlementWalletReq;
+import com.sckw.payment.model.vo.req.WalletPayReq;
 import com.sckw.payment.service.KwpSettlementWalletService;
 import jakarta.annotation.Resource;
 import jakarta.validation.Valid;
+import jakarta.validation.constraints.NotBlank;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import java.math.BigDecimal;
@@ -17,6 +21,7 @@ import java.math.BigDecimal;
  * @author Aick Spt
  * @date 2023-07-20 14:42
  */
+@Validated
 @RestController
 @RequestMapping(name = "结算-电子钱包结算记录", path = "/kwpSettlementWallet")
 public class KwpSettlementWalletController {
@@ -37,14 +42,12 @@ public class KwpSettlementWalletController {
     }
 
     /**
-     * @param id    结算单id
-     * @param price 本次付款金额
      * @author Aick Spt
      * @date 2023-07-25 09:55
      */
-    @GetMapping(name = "物流-电子钱包付款(货到付款)结算记录-新增", path = "confirmLogisticsPayment")
-    public HttpResult confirmLogisticsPayment(@RequestParam("id") Long id, @RequestParam("price") BigDecimal price) {
-        return HttpResult.ok(kwpSettlementWalletService.confirmLogisticsPayment(id, price));
+    @PostMapping(name = "物流-电子钱包付款(货到付款)结算记录-新增", path = "confirmLogisticsPayment")
+    public HttpResult confirmLogisticsPayment(@RequestBody @Valid OfflinePaymentReq offlinePaymentReq) {
+        return HttpResult.ok(kwpSettlementWalletService.confirmLogisticsPayment(offlinePaymentReq));
     }
 
 
@@ -64,15 +67,23 @@ public class KwpSettlementWalletController {
     }
 
     /**
-     * 采购-货到付款
-     * @param id    结算单id
-     * @param price 本次付款金额
+     * 采购-货到付款-查询钱包余额
+     *
+     * @param id 结算单id
      * @author Aick Spt
      * @date 2023-07-25 09:55
      */
-    @GetMapping(name = "销售-付款确认-(新增电子钱包记录-采购货到付款)", path = "confirmTradePayment")
-    public HttpResult confirmTradePayment(@RequestParam("id") Long id, @RequestParam("price") BigDecimal price) {
-        return HttpResult.ok(kwpSettlementWalletService.confirmTradePayment(id, price));
+    @GetMapping(name = "采购-货到付款-查询钱包余额", path = "getConfirmPay")
+    public HttpResult getConfirmPay(@RequestParam("id") @NotBlank(message = "id不能为空") String id) {
+        return HttpResult.ok(kwpSettlementWalletService.getConfirmTradePayment(Long.parseLong(id)));
+    }
+
+    /**
+     * 采购-货到付款
+     */
+    @PostMapping(name = "销售-付款确认-(新增电子钱包记录-采购货到付款)", path = "confirmReceive")
+    public HttpResult confirmTradePayment(@RequestBody @Valid WalletPayReq payReq) {
+        return HttpResult.ok(kwpSettlementWalletService.confirmTradePayment(payReq));
     }
 
     /**
@@ -90,14 +101,14 @@ public class KwpSettlementWalletController {
 
     /**
      * 销售-预付款
-     * @param id    结算单id
-     * @param price 本次付款金额
+     *
+     * @param id 结算单id
      * @author Aick Spt
      * @date 2023-07-25 09:55
      */
-    @GetMapping(name = "销售-收款确认-预付款(电子钱包)", path = "confirmTradeCollection")
-    public HttpResult confirmTradeCollection(@RequestParam("id") Long id, @RequestParam("price") Float price) {
-        return HttpResult.ok(kwpSettlementWalletService.confirmTradeCollection(id, price));
+    @PostMapping(name = "销售-收款确认-预付款(电子钱包)", path = "confirmPrePay")
+    public HttpResult confirmTradeCollection(@RequestParam("id") @NotBlank(message = "id不能为空") String id) {
+        return HttpResult.ok(kwpSettlementWalletService.confirmTradeCollection(Long.parseLong(id)));
     }
 
 

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

@@ -24,7 +24,7 @@ public interface KwpLedgerTradeMapper extends BaseMapper<KwpLedgerTrade> {
 
     List<LedgerPurchaseDto> purchaseList(@Param("tradeReq") TradeReq tradeReq);
 
-    Map<String, Long> countOrder(@Param("entId") Long entId, @Param("unitType") Integer unitType);
+    Map<String, Long> countOrder(@Param("tradeReq") TradeReq tradeReq);
 
     LedgerTradeDto selectId(@Param("id") Long id, @Param("unitType") Integer unitType);
 

+ 12 - 39
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementLogisticsMapper.java

@@ -18,64 +18,37 @@ import java.util.List;
 public interface KwpSettlementLogisticsMapper extends BaseMapper<KwpSettlementLogistics> {
 
     /**
-     * 运费收款-物流订单列表
-     *
-     * @author Aick Spt
-     * @date 2023-07-24 16:21
-     */
-    List<SettlementLogisticsDto> pageSelectCollection(@Param("settlementReq") SettlementReq settlementReq);
-
-
-    SettlementLogisticsSumVo selectCollectionSum(@Param("settlementReq") SettlementReq settlementReq);
-
-
-    /**
-     * 运费收款-物流订单各状态列表总数
-     *
-     * @author Aick Spt
-     * @date 2023-07-24 16:21
-     */
-    Long getCountListCollection(@Param("settlementReq") SettlementReq settlementReq);
-
-    /**
-     * 运费收款-物流订单详情
-     *
+     * 运费付款-物流订单列表
      * @author Aick Spt
-     * @date 2023-07-24 16:22
+     * @date 2023-07-24 16:23
      */
-    SettlementLogisticsDto detailCollection(@Param("id") Long id);
-
+    List<SettlementLogisticsDto> pageSelect(@Param("settlementReq") SettlementReq settlementReq);
 
     /**
-     * 运费付款-物流订单列表
-     *
+     * 运费-物流订单各状态列表总数
      * @author Aick Spt
      * @date 2023-07-24 16:23
      */
-    List<SettlementLogisticsDto> pageSelectPayment(@Param("settlementReq") SettlementReq settlementReq);
+    Long getCountList(@Param("settlementReq") SettlementReq settlementReq);
 
     /**
-     * 运费付款-物流订单各状态列表总数
-     *
+     * 运费-物流订单列表查询合计
      * @author Aick Spt
-     * @date 2023-07-24 16:23
+     * @date 2023-07-28 09:49
      */
-    Long getCountListPayment(@Param("settlementReq") SettlementReq settlementReq);
+    SettlementLogisticsSumVo selectSum(@Param("settlementReq") SettlementReq settlementReq);
 
     /**
-     * 运费付款-物流订单详情
-     *
+     * 运费-物流订单详情
      * @author Aick Spt
      * @date 2023-07-24 16:24
      */
-    SettlementLogisticsDto detailPayment(@Param("id") Long id);
+    SettlementLogisticsDto detail(@Param("id") Long id, @Param("unitType") Integer unitType);
 
     /**
-     * 根据id查物流结算订单
-     *
+     * 根据条件查物流结算订单-导出
      * @author Aick Spt
      * @date 2023-07-24 16:24
      */
-    List<SettlementLogisticsDto> selectIds(@Param("ids") List<Long> ids);
-    List<SettlementLogisticsDto> selectList(@Param("unitType") Integer unitType);
+    List<SettlementLogisticsDto> selectLogisticsList(@Param("settlementReq") SettlementReq settlementReq, @Param("ids") List<Long> ids);
 }

+ 9 - 5
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementTradeMapper.java

@@ -2,14 +2,15 @@ package com.sckw.payment.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.payment.model.KwpSettlementTrade;
+import com.sckw.payment.model.dto.LedgerUnitDto;
 import com.sckw.payment.model.dto.SettlementTradeDto;
 import com.sckw.payment.model.vo.req.SettlementTradeReq;
-import com.sckw.payment.model.vo.res.SettlementLogisticsStatusCountVo;
 import com.sckw.payment.model.vo.res.SettlementSumVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * @author xucaiqin
@@ -20,10 +21,13 @@ import java.util.List;
 public interface KwpSettlementTradeMapper extends BaseMapper<KwpSettlementTrade> {
     List<SettlementTradeDto> pageSelect(@Param("settlementReq") SettlementTradeReq settlementReq);
 
-    SettlementSumVo sumMoney(@Param("settlementReq")SettlementTradeReq settlementReq);
+    SettlementSumVo sumMoney(@Param("settlementReq") SettlementTradeReq settlementReq);
 
-    SettlementLogisticsStatusCountVo countOrder(@Param("settlementReq")SettlementTradeReq settlementReq);
+    Map<String, Long> countOrder(@Param("settlementReq") SettlementTradeReq settlementReq);
 
-    List<SettlementTradeDto> selectByIds(@Param("ids") List<Long> ids);
-    SettlementTradeDto getById(@Param("id") Long id);
+    List<SettlementTradeDto> selectByIds(@Param("ids") List<Long> ids, @Param("unitType") Integer unitType);
+
+    SettlementTradeDto getById(@Param("id") Long id, @Param("unitType") Integer unitType);
+
+    List<LedgerUnitDto> getListById(@Param("id") Long id);
 }

+ 1 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpLedgerLogistics.java

@@ -70,7 +70,7 @@ public class KwpLedgerLogistics {
      * 交易方式(预付款、货到付款)
      */
     @TableField(value = "trading")
-    private Integer trading;
+    private String trading;
 
     /**
      * 总应收/元

+ 1 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpLedgerTrade.java

@@ -70,7 +70,7 @@ public class KwpLedgerTrade {
      * 交易方式(预付款、货到付款)
      */
     @TableField(value = "trading")
-    private Integer trading;
+    private String trading;
 
     /**
      * 总应收/元

+ 1 - 4
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpSettlementLogisticsTrack.java

@@ -13,9 +13,6 @@ import java.time.LocalDateTime;
 /**
  * @author xucaiqin
  * @date 2023-07-10 16:42:20
- */
-
-/**
  * 结算-物流订单-状态信息
  */
 @Getter
@@ -42,7 +39,7 @@ public class KwpSettlementLogisticsTrack {
     private String remark;
 
     /**
-     * 用户状态(0正常、1已锁
+     * 用户状态(1待结算,2部分结算,3全部结算
      */
     @TableField(value = "`status`")
     private Integer status;

+ 11 - 4
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpSettlementOffline.java

@@ -4,15 +4,17 @@ 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.Getter;
-import lombok.Setter;
-import lombok.ToString;
 
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
 
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
 /**
  * 线下结算记录(交易订单结算/物流订单结算)
+ *
  * @author xucaiqin
  * @date 2023-07-10 16:42:19
  */
@@ -21,6 +23,9 @@ import java.time.LocalDateTime;
 @ToString
 @TableName(value = "kwp_settlement_offline")
 public class KwpSettlementOffline {
+    /**
+     * 主键
+     */
     @TableId(value = "id", type = IdType.INPUT)
     private Long id;
 
@@ -75,7 +80,7 @@ public class KwpSettlementOffline {
     /**
      * 状态(1正常 、2异常)
      */
-    @TableField(value = "`status`")
+    @TableField(value = "status")
     private Integer status;
 
     /**
@@ -107,4 +112,6 @@ public class KwpSettlementOffline {
      */
     @TableField(value = "del_flag")
     private Integer delFlag;
+
+
 }

+ 18 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpSettlementTradeTrack.java

@@ -4,11 +4,14 @@ 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 java.time.LocalDateTime;
+import com.sckw.core.utils.IdWorker;
+import com.sckw.core.web.context.LoginUserHolder;
 import lombok.Getter;
 import lombok.Setter;
 import lombok.ToString;
 
+import java.time.LocalDateTime;
+
 /**
  * @author xucaiqin
  * @date 2023-07-10 16:42:19
@@ -66,4 +69,18 @@ public class KwpSettlementTradeTrack {
      */
     @TableField(value = "del_flag")
     private Integer delFlag;
+
+    public static KwpSettlementTradeTrack build(Long tSettlementId, Integer status) {
+        KwpSettlementTradeTrack kwpSettlementTradeTrack = new KwpSettlementTradeTrack();
+        kwpSettlementTradeTrack.setId(new IdWorker(1).nextId());
+        kwpSettlementTradeTrack.setTSettlementId(tSettlementId);
+        kwpSettlementTradeTrack.setRemark("");
+        kwpSettlementTradeTrack.setStatus(status);
+        kwpSettlementTradeTrack.setCreateBy(LoginUserHolder.getUserId());
+        kwpSettlementTradeTrack.setCreateTime(LocalDateTime.now());
+        kwpSettlementTradeTrack.setUpdateBy(LoginUserHolder.getUserId());
+        kwpSettlementTradeTrack.setUpdateTime(LocalDateTime.now());
+        kwpSettlementTradeTrack.setDelFlag(0);
+        return kwpSettlementTradeTrack;
+    }
 }

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

@@ -4,15 +4,14 @@ 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 java.math.BigDecimal;
-import java.math.BigInteger;
-import java.time.LocalDateTime;
-
 import lombok.Data;
 import lombok.Getter;
 import lombok.Setter;
 import lombok.ToString;
 
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
 /**
  * 电子钱包结算记录(交易订单结算/物流订单结算)
  *
@@ -54,7 +53,7 @@ public class KwpSettlementWallet {
      * 线上渠道 1-huifu
      */
     @TableField(value = "channel")
-    private Integer channel;
+    private String channel;
 
     /**
      * 回款时间

+ 18 - 18
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/constant/LedgerEnum.java

@@ -10,19 +10,21 @@ import java.util.Objects;
  * @date 2023-07-11 12:00:52
  */
 public enum LedgerEnum {
-    ALL(0, "全部"),
-    SAVE(1, "已保存"),
-    TO_LEDGER(2, "待对账"),
-    LEDGERED(3, "已对账"),
-    SUCCESS(4, "已完成"),
-    BACK(5, "已退回"),
-    REVOCATION(6, "已撤回");
-
-    private int status;
-    private String desc;
-
-    LedgerEnum(int status, String desc) {
+    ALL(0, "全部", "0"),
+    SAVE(1, "已保存", "1"),
+    TO_LEDGER(2, "待对账", "2"),
+    LEDGERED(3, "已对账", "3"),
+    SUCCESS(4, "已完成", "4"),
+    BACK(5, "已退回", "5"),
+    REVOCATION(6, "已撤回", "6");
+
+    private final int status;
+    private final String desc;
+    private final String label;
+
+    LedgerEnum(int status, String desc, String label) {
         this.status = status;
+        this.label = label;
         this.desc = desc;
     }
 
@@ -38,19 +40,17 @@ public enum LedgerEnum {
         return "";
     }
 
+    public String getLabel() {
+        return label;
+    }
+
     public int getStatus() {
         return status;
     }
 
-    public void setStatus(int status) {
-        this.status = status;
-    }
 
     public String getDesc() {
         return desc;
     }
 
-    public void setDesc(String desc) {
-        this.desc = desc;
-    }
 }

+ 13 - 14
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/constant/SettlementEnum.java

@@ -8,35 +8,34 @@ package com.sckw.payment.model.constant;
  * @date 2023-07-11 12:00:52
  */
 public enum SettlementEnum {
-    ALL(0, "全部"),
-    WAITING_PAYMENT(1, "待结算"),
-    PARTIAL_PAYMENT(2, "部分结算"),
-    ALL_PAYMENT(3, "全部结算");
+    ALL(0, "全部", "0"),
+    WAITING_PAYMENT(1, "待结算", "1"),
+    PARTIAL_PAYMENT(2, "部分结算", "2"),
+    ALL_PAYMENT(3, "全部结算", "3");
 
-    private int status;
-    private String desc;
+    private final int status;
+    private final String desc;
+    private final String label;
 
-    SettlementEnum(int status, String desc) {
+    SettlementEnum(int status, String desc, String label) {
         this.status = status;
         this.desc = desc;
+        this.label = label;
+    }
+
+    public String getLabel() {
+        return label;
     }
 
     public int getStatus() {
         return status;
     }
 
-    public void setStatus(int status) {
-        this.status = status;
-    }
 
     public String getDesc() {
         return desc;
     }
 
-    public void setDesc(String desc) {
-        this.desc = desc;
-    }
-
     // 添加静态方法,根据 status 获取对应的 desc
     public static String getStatusDesc(int status) {
         for (SettlementEnum settlementEnum : values()) {

+ 36 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/constant/SettlementPayTypeEnum.java

@@ -0,0 +1,36 @@
+package com.sckw.payment.model.constant;
+
+/**
+ * Desc: 暂不明确是否使用
+ * @author Aick Spt
+ * @date 2023-07-20 08:35
+ */
+public enum SettlementPayTypeEnum {
+    ADVANCE_PAYMENT(1, "预付款"),
+    CASH_ON_DELIVERY(2, "货到付款"),
+    OFFLINE_PAYMENT(3, "线下付款");
+
+    private int status;
+    private String desc;
+
+    SettlementPayTypeEnum(int status, String desc) {
+        this.status = status;
+        this.desc = desc;
+    }
+
+    public int getStatus() {
+        return status;
+    }
+
+    public void setStatus(int status) {
+        this.status = status;
+    }
+
+    public String getDesc() {
+        return desc;
+    }
+
+    public void setDesc(String desc) {
+        this.desc = desc;
+    }
+}

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

@@ -8,7 +8,9 @@ package com.sckw.payment.model.constant;
  */
 public enum SettlementTrackEnum {
 
-    SUCCESS(7,"对账完成");
+    PRE_PAY(1, "收款确认-预付款"),
+    RECEIVE_PAY(2, "付款确认-货到付款"),
+    OFFLINE_PAY(3, "收款确认-线下付款");
 
     private int status;
     private String desc;

+ 0 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/constant/SettlementWalletPayTypeEnum.java

@@ -8,7 +8,6 @@ package com.sckw.payment.model.constant;
 public enum SettlementWalletPayTypeEnum {
     ADVANCE_PAYMENT(1, "预付款"),
     CASH_ON_DELIVERY(2, "货到付款");
-//    OFFLINE_PAYMENT(3, "线下付款");
 
     private int status;
     private String desc;

+ 30 - 12
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/constant/WalletChannelEnum.java

@@ -1,19 +1,23 @@
 package com.sckw.payment.model.constant;
 
+import org.apache.commons.lang3.StringUtils;
+
 /**
  * @author Aick Spt
  * @date 2023-07-27 12:54
  */
 public enum WalletChannelEnum {
-    HF(1, "huifu"),//汇付
-    XS(2, "xinsheng"),//新生
-    ZX(3, "zhongxin");//中信
+    HF(1, "1", "huifu"),//汇付
+    XS(2, "2", "xinsheng"),//新生
+    ZX(3, "3", "zhongxin");//中信
 
-    private int status;
-    private String desc;
+    private final int status;
+    private final String value;
+    private final String desc;
 
-    WalletChannelEnum(int status, String desc) {
+    WalletChannelEnum(int status, String value, String desc) {
         this.status = status;
+        this.value = value;
         this.desc = desc;
     }
 
@@ -21,16 +25,12 @@ public enum WalletChannelEnum {
         return status;
     }
 
-    public void setStatus(int status) {
-        this.status = status;
-    }
-
     public String getDesc() {
         return desc;
     }
 
-    public void setDesc(String desc) {
-        this.desc = desc;
+    public String getValue() {
+        return value;
     }
 
     // 添加静态方法,根据 status 获取对应的 desc
@@ -43,5 +43,23 @@ public enum WalletChannelEnum {
         return null; // 可根据实际需求返回默认值或其他处理
     }
 
+    /**
+     * 通过交易方式字典获取渠道
+     *
+     * @param trading
+     * @return
+     */
+    public static String getValue(String trading) {
+        if (StringUtils.isBlank(trading)) {
+            return null;
+        }
+        String substring = trading.substring(1);
+        for (WalletChannelEnum walletChannelEnum : values()) {
+            if (StringUtils.equals(walletChannelEnum.getValue(), substring)) {
+                return walletChannelEnum.getValue();
+            }
+        }
+        return null; // 可根据实际需求返回默认值或其他处理
+    }
 
 }

+ 2 - 2
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/ILedger.java

@@ -15,9 +15,9 @@ public interface ILedger {
     Integer getTaxRate();
 
 
-    void setTrading(Integer trading);
+    void setTrading(String trading);
 
-    Integer getTrading();
+    String getTrading();
 
     void setTradingLabel(String tradingLabel);
 

+ 2 - 2
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/ISettlement.java

@@ -10,9 +10,9 @@ import java.util.Objects;
  */
 public interface ISettlement {
 
-    void setTrading(Integer trading);
+    void setTrading(String trading);
 
-    Integer getTrading();
+    String getTrading();
 
     void setTradingLabel(String tradingLabel);
 

+ 5 - 3
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/LedgerCarrierDto.java

@@ -65,7 +65,7 @@ public class LedgerCarrierDto implements ILedger {
     /**
      * 交易方式(预付款、货到付款)
      */
-    private Integer trading;
+    private String trading;
     private String tradingLabel;
 
 
@@ -210,11 +210,13 @@ public class LedgerCarrierDto implements ILedger {
         this.taxRate = taxRate;
     }
 
-    public Integer getTrading() {
+    @Override
+    public String getTrading() {
         return trading;
     }
 
-    public void setTrading(Integer trading) {
+    @Override
+    public void setTrading(String trading) {
         this.trading = trading;
     }
 

+ 1 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/LedgerLogisticsDto.java

@@ -68,7 +68,7 @@ public class LedgerLogisticsDto implements ILedger {
     /**
      * 交易方式(预付款、货到付款)
      */
-    private Integer trading;
+    private String trading;
     private String tradingLabel;
 
 

+ 1 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/LedgerPurchaseDto.java

@@ -52,7 +52,7 @@ public class LedgerPurchaseDto implements ILedger {
     /**
      * 交易方式(预付款、货到付款)
      */
-    private Integer trading;
+    private String trading;
     private String tradingLabel;
 
 

+ 1 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/LedgerSellDto.java

@@ -52,7 +52,7 @@ public class LedgerSellDto implements ILedger {
     /**
      * 交易方式(预付款、货到付款)
      */
-    private Integer trading;
+    private String trading;
     private String tradingLabel;
 
 

+ 1 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/LedgerShipperDto.java

@@ -51,7 +51,7 @@ public class LedgerShipperDto implements ILedger {
     /**
      * 交易方式(预付款、货到付款)
      */
-    private Integer trading;
+    private String trading;
     private String tradingLabel;
 
 

+ 1 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/LedgerTradeDto.java

@@ -52,7 +52,7 @@ public class LedgerTradeDto implements ILedger {
     /**
      * 交易方式(预付款、货到付款)
      */
-    private Integer trading;
+    private String trading;
     private String tradingLabel;
 
 

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

@@ -0,0 +1,18 @@
+package com.sckw.payment.model.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 对账单关联的企业信息
+ *
+ * @author Aick Spt
+ * @date 2023-07-20 12:26
+ */
+@Getter
+@Setter
+public class LedgerUnitDto  {
+    private Long topEntId;
+    private Long entId;
+    private Integer unitType;
+}

+ 1 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/SettlementLogisticsDto.java

@@ -143,7 +143,7 @@ public class SettlementLogisticsDto {
     /**
      * 交易方式
      */
-    private Integer ledgerTrading;
+    private String ledgerTrading;
 
     /**
      * 对账单编号

+ 1 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/SettlementPurchaseDto.java

@@ -63,7 +63,7 @@ public class SettlementPurchaseDto implements ISettlement {
     /**
      * 交易方式
      */
-    private Integer trading;
+    private String trading;
     private String tradingLabel;
 
     /**

+ 6 - 5
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/SettlementSellDto.java

@@ -63,7 +63,7 @@ public class SettlementSellDto implements ISettlement {
     /**
      * 交易方式(预付款、货到付款)
      */
-    private Integer trading;
+    private String trading;
     private String tradingLabel;
 
     /**
@@ -113,15 +113,16 @@ public class SettlementSellDto implements ISettlement {
         return auditPhone;
     }
 
-    @Override
-    public Integer getTrading() {
-        return trading;
-    }
 
     public String getTradingLabel() {
         return tradingLabel;
     }
 
+    @Override
+    public String getTrading() {
+        return trading;
+    }
+
     @Override
     public Integer getStatus() {
         return status;

+ 181 - 32
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/SettlementTradeDto.java

@@ -1,11 +1,10 @@
 package com.sckw.payment.model.dto;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
-import lombok.Getter;
-import lombok.Setter;
 
 import java.math.BigDecimal;
 import java.util.Date;
+import java.util.Objects;
 
 /**
  * 结算-交易订单
@@ -13,8 +12,6 @@ import java.util.Date;
  * @author Aick Spt
  * @date 2023-07-20 12:26
  */
-@Getter
-@Setter
 public class SettlementTradeDto implements ISettlement {
 
     /**
@@ -55,6 +52,8 @@ public class SettlementTradeDto implements ISettlement {
      * 带回款金额(扩展的计算字段)
      */
     private BigDecimal waitPrice;
+    private String trading;
+    private String tradingLabel;
 
     /**
      * 预计收款日期
@@ -91,6 +90,7 @@ public class SettlementTradeDto implements ISettlement {
      * 状态(待回款、部分回款、全部回款、回退)
      */
     private Integer status;
+    private String statusLabel;
 
     /**
      * 创建人
@@ -119,50 +119,199 @@ public class SettlementTradeDto implements ISettlement {
      */
     private Integer delFlag;
 
-    // 添加构造函数,getter和setter方法,以及其他业务逻辑方法(根据需要)
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getEntId() {
+        return entId;
+    }
+
+    public void setEntId(Long entId) {
+        this.entId = entId;
+    }
+
+    public Long gettLedgerId() {
+        return tLedgerId;
+    }
+
+    public void settLedgerId(Long tLedgerId) {
+        this.tLedgerId = tLedgerId;
+    }
+
+    public String getStOrderNo() {
+        return stOrderNo;
+    }
+
+    public void setStOrderNo(String stOrderNo) {
+        this.stOrderNo = stOrderNo;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public BigDecimal getTotalPrice() {
+        return totalPrice;
+    }
+
+    public void setTotalPrice(BigDecimal totalPrice) {
+        this.totalPrice = totalPrice;
+    }
+
+    public BigDecimal getActualPrice() {
+        if (Objects.isNull(actualPrice)) {
+            return new BigDecimal("0.0");
+        }
+        return actualPrice;
+    }
+
+    public void setActualPrice(BigDecimal actualPrice) {
+        this.actualPrice = actualPrice;
+    }
+
+    public BigDecimal getWaitPrice() {
+        if (Objects.isNull(waitPrice)) {
+            return new BigDecimal("0.0");
+        }
+        return waitPrice;
+    }
+
+    public void setWaitPrice(BigDecimal waitPrice) {
+        this.waitPrice = waitPrice;
+    }
+
+    public String getTradingLabel() {
+        return tradingLabel;
+    }
+
+    public Date getReceiptTime() {
+        return receiptTime;
+    }
+
+    public void setReceiptTime(Date receiptTime) {
+        this.receiptTime = receiptTime;
+    }
+
+    public String getAuditUser() {
+        return auditUser;
+    }
+
+    public void setAuditUser(String auditUser) {
+        this.auditUser = auditUser;
+    }
+
+    public String getAuditPhone() {
+        return auditPhone;
+    }
+
+    public void setAuditPhone(String auditPhone) {
+        this.auditPhone = auditPhone;
+    }
+
+    public String getSuccessUser() {
+        return successUser;
+    }
+
+    public void setSuccessUser(String successUser) {
+        this.successUser = successUser;
+    }
+
+    public String getSuccessPhone() {
+        return successPhone;
+    }
+
+    public void setSuccessPhone(String successPhone) {
+        this.successPhone = successPhone;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
 
     @Override
-    public String toString() {
-        return "SettlementTradeDto{" +
-                "id=" + id +
-                ", entId=" + entId +
-                ", tLedgerId=" + tLedgerId +
-                ", stOrderNo='" + stOrderNo + '\'' +
-                ", name='" + name + '\'' +
-                ", totalPrice=" + totalPrice +
-                ", actualPrice=" + actualPrice +
-                ", receiptTime=" + receiptTime +
-                ", auditUser='" + auditUser + '\'' +
-                ", auditPhone='" + auditPhone + '\'' +
-                ", successUser='" + successUser + '\'' +
-                ", successPhone='" + successPhone + '\'' +
-                ", remark='" + remark + '\'' +
-                ", status=" + status +
-                ", createBy=" + createBy +
-                ", createTime=" + createTime +
-                ", updateBy=" + updateBy +
-                ", updateTime=" + updateTime +
-                ", delFlag=" + delFlag +
-                '}';
+    public Integer getStatus() {
+        return status;
     }
 
     @Override
-    public void setTrading(Integer trading) {
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
 
+    public String getStatusLabel() {
+        return statusLabel;
+    }
+
+    public Long getCreateBy() {
+        return createBy;
+    }
+
+    public void setCreateBy(Long createBy) {
+        this.createBy = createBy;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Long getUpdateBy() {
+        return updateBy;
+    }
+
+    public void setUpdateBy(Long updateBy) {
+        this.updateBy = updateBy;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public Integer getDelFlag() {
+        return delFlag;
+    }
+
+    public void setDelFlag(Integer delFlag) {
+        this.delFlag = delFlag;
     }
 
     @Override
-    public Integer getTrading() {
-        return null;
+    public void setTrading(String trading) {
+        this.trading = trading;
     }
 
     @Override
-    public void setTradingLabel(String tradingLabel) {
+    public String getTrading() {
+        return trading;
+    }
 
+    @Override
+    public void setTradingLabel(String tradingLabel) {
+        this.tradingLabel = tradingLabel;
     }
 
     @Override
     public void setStatusLabel(String statusLabel) {
-
+        this.statusLabel = statusLabel;
     }
 }

+ 1 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/LogisticsReq.java

@@ -21,7 +21,7 @@ public class LogisticsReq extends BasePara {
     private String startCreateTime;
     @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
     private String endCreateTime;
-    private Integer trading;
+    private String trading;
     /**
      * @see LedgerEnum
      */

+ 1 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/LogisticsSendReq.java

@@ -60,7 +60,7 @@ public class LogisticsSendReq implements IdsList {
      * 交易方式
      */
     @NotNull(message = "付款方式不能为空")
-    private Integer trading;
+    private String trading;
     /**
      * 总应收/元
      */

+ 43 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/OfflinePaymentReq.java

@@ -0,0 +1,43 @@
+package com.sckw.payment.model.vo.req;
+
+import com.sckw.core.model.vo.BasePara;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
+import lombok.Getter;
+import lombok.NonNull;
+import lombok.Setter;
+
+import java.io.Serial;
+import java.math.BigDecimal;
+
+/**
+ * @author Aick Spt
+ * @date 2023-07-27 19:52
+ */
+@Getter
+@Setter
+public class OfflinePaymentReq extends BasePara {
+
+    @Serial
+    private static final long serialVersionUID = -4568239842231210898L;
+
+    /**
+     * 结算单id
+     */
+    @NotBlank
+    private String id;
+
+    /**
+     * 付款金额
+     */
+    @NotNull
+    private BigDecimal price;
+
+
+    /**
+     * 附件地址
+     */
+    private String url;
+
+
+}

+ 5 - 7
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/SettlementOfflinePayReq.java

@@ -1,12 +1,13 @@
 package com.sckw.payment.model.vo.req;
 
-import com.sckw.core.model.vo.BasePara;
+import com.sckw.core.model.base.IdsList;
 import jakarta.validation.constraints.NotBlank;
 import jakarta.validation.constraints.NotNull;
 import lombok.Getter;
 import lombok.Setter;
 
 import java.io.Serial;
+import java.io.Serializable;
 import java.math.BigDecimal;
 
 /**
@@ -17,19 +18,16 @@ import java.math.BigDecimal;
  */
 @Getter
 @Setter
-public class SettlementOfflinePayReq extends BasePara {
+public class SettlementOfflinePayReq implements IdsList, Serializable {
     @Serial
-    private static final long serialVersionUID = 6537008434516489423L;
+    private static final long serialVersionUID = -4521836357698982285L;
     private Integer orderType;
 
     @NotBlank(message = "结算单id不能为空")
-    private String settlementId;
+    private String id;
     @NotNull(message = "结算单金额不能为空")
     private BigDecimal payPrice;
     @NotBlank(message = "相关附近不能为空")
     private String url;
 
-    public Long getSettlementIdLong(){
-        return changeId(settlementId);
-    }
 }

+ 29 - 4
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/SettlementOfflineReq.java

@@ -12,14 +12,39 @@ import lombok.Setter;
 @Getter
 @Setter
 public class SettlementOfflineReq extends BasePara {
+//    /**
+//     * 结算单id
+//     */
+//    @NotBlank(message = "结算单id不能为空")
+//    private String id;
+//
+//    /**
+//     * 订单类型 1-物流 2-贸易
+//     */
+//    private Integer orderType;
+
+
+
     /**
-     * 结算单id
+     * 交易方式
      */
-    @NotBlank(message = "结算单id不能为空")
-    private String settlementId;
+    private String trading;
 
     /**
-     * 订单类型 1-物流 2-贸易
+     * 支付方式 预付款、货到付款
+     */
+    private Integer payType;
+    /**
+     * 订单类型  1-物流 2-贸易
      */
     private Integer orderType;
+    /**
+     * 结算单id
+     */
+    @NotBlank(message = "结算单id不能为空")
+    private String id;
+
+
+
+
 }

+ 26 - 12
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/SettlementReq.java

@@ -20,30 +20,44 @@ public class SettlementReq extends BasePara {
     @Serial
     private static final long serialVersionUID = 6537008434516489423L;
 
-    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd")
 //    @NotNull(message = "创建时间开始日期不能为空")
-    private LocalDateTime startCreateTime;
+    private String startCreateTime;
 
-    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd")
 //    @NotNull(message = "创建时间结束日期不能为空")
-    private LocalDateTime endCreateTime;
+    private String endCreateTime;
 
-        @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+        @DateTimeFormat(pattern = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd")
 //    @NotNull(message = "预计回款开始日期不能为空")
-    private LocalDateTime startReceiptTime;
+    private String startReceiptTime;
 
-    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd")
 //    @NotNull(message = "预计回款结束日期不能为空")
-    private LocalDateTime endReceiptTime;
+    private String endReceiptTime;
 
     /**
      * @see SettlementEnum
      */
     private Integer status;
 
+    /**
+     * 多用于导出时的id集合
+     */
     private String ids;
+
+    /**
+     * 用于过滤当前登录者企业id
+     */
+    private Long entId;
+
+    /**
+     * 筛选交易方
+     */
+    private Integer unitType;
+
 }

+ 7 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/SettlementTradeReq.java

@@ -95,4 +95,11 @@ public class SettlementTradeReq extends BasePara implements TimeBase {
     public void setIds(String ids) {
         this.ids = ids;
     }
+
+    public void check() {
+        getStartCreateTime();
+        getEndCreateTime();
+        getStartReceiptTime();
+        getEndReceiptTime();
+    }
 }

+ 2 - 2
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/SettlementWalletReq.java

@@ -16,7 +16,7 @@ public class SettlementWalletReq extends BasePara {
     /**
      * 交易方式
      */
-    private Integer trading;
+    private String trading;
 
     /**
      * 支付方式 预付款、货到付款
@@ -30,7 +30,7 @@ public class SettlementWalletReq extends BasePara {
      * 结算单id
      */
     @NotBlank(message = "结算单id不能为空")
-    private String settlementId;
+    private String id;
 
 
 }

+ 1 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/TradeReq.java

@@ -18,7 +18,7 @@ public class TradeReq extends BasePara {
     private static final long serialVersionUID = 5328731681168692784L;
     private String startCreateTime;
     private String endCreateTime;
-    private Integer trading;
+    private String trading;
     /**
      * @see LedgerEnum
      */

+ 1 - 2
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/TradeSendReq.java

@@ -12,7 +12,6 @@ import org.springframework.format.annotation.DateTimeFormat;
 
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
-import java.util.List;
 
 /**
  * 贸易对账单
@@ -65,7 +64,7 @@ public class TradeSendReq implements IdsList {
      * 交易方式
      */
     @NotNull(message = "付款方式不能为空")
-    private Integer trading;
+    private String trading;
     /**
      * 总应收/元
      */

+ 29 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/WalletPayReq.java

@@ -0,0 +1,29 @@
+package com.sckw.payment.model.vo.req;
+
+import com.sckw.core.model.base.IdsList;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+
+/**
+ * @author: xucaiqin
+ * @date: 2023-07-31 18:13:26
+ */
+@Getter
+@Setter
+public class WalletPayReq implements IdsList {
+
+    /**
+     * 结算单id
+     */
+    @NotBlank(message = "结算单id不能为空")
+    private String id;
+    /**
+     * 金额
+     */
+    @NotNull(message = "付款金额不能为空")
+    private BigDecimal price;
+}

+ 1 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/LedgerLogisticsDetailVo.java

@@ -22,7 +22,7 @@ public class LedgerLogisticsDetailVo {
     private String lLedgerNo;
     private String name;
     private String firmName;
-    private Integer trading;
+    private String trading;
     private Integer taxRate;
     private BigDecimal totalPrice;
     private BigDecimal actualPrice;

+ 1 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/LedgerTradeDetailVo.java

@@ -22,7 +22,7 @@ public class LedgerTradeDetailVo {
     private String tLedgerNo;
     private String name;
     private String firmName;
-    private Integer trading;
+    private String trading;
     private Integer taxRate;
     private BigDecimal totalPrice;
     private BigDecimal actualPrice;

+ 11 - 14
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerLogisticsService.java

@@ -5,16 +5,13 @@ import com.github.pagehelper.PageInfo;
 import com.sckw.core.common.enums.enums.DictTypeEnum;
 import com.sckw.core.exception.BusinessException;
 import com.sckw.core.model.page.PageRes;
+import com.sckw.core.model.vo.TableTop;
 import com.sckw.core.utils.CollectionUtils;
 import com.sckw.core.utils.IdWorker;
 import com.sckw.core.utils.OrderGenerateUtils;
 import com.sckw.core.utils.StringTimeUtil;
-import com.sckw.payment.dao.KwpLedgerLogisticsMapper;
-import com.sckw.payment.model.KwpLedgerLogistics;
-import com.sckw.payment.model.KwpLedgerLogisticsTrack;
-import com.sckw.payment.model.KwpLedgerLogisticsUnit;
-import com.sckw.payment.model.KwpSettlementLogistics;
 import com.sckw.core.web.context.LoginUserHolder;
+import com.sckw.payment.dao.KwpLedgerLogisticsMapper;
 import com.sckw.payment.model.*;
 import com.sckw.payment.model.constant.LedgerEnum;
 import com.sckw.payment.model.constant.LedgerTrackEnum;
@@ -77,8 +74,8 @@ public class KwpLedgerLogisticsService extends AbsLedger {
             tradingMap = tradingDict.stream().collect(Collectors.toMap(SysDictResDto::getValue, SysDictResDto::getLabel, (a, b) -> a));
         }
         for (ILedger logisticsDto : list) {
-            Integer trading = logisticsDto.getTrading();
-            logisticsDto.setTradingLabel(tradingMap.get(String.valueOf(trading)));
+            String trading = logisticsDto.getTrading();
+            logisticsDto.setTradingLabel(tradingMap.get(trading));
             Integer taxRate = logisticsDto.getTaxRate();
             logisticsDto.setTaxRateLabel(taxRateMap.get(String.valueOf(taxRate)));
 
@@ -439,16 +436,16 @@ public class KwpLedgerLogisticsService extends AbsLedger {
      * @param unitType 1-托运方 2-承运方
      * @return
      */
-    public List<LedgerCountVo> orderCount(LogisticsReq logisticsReq, Integer unitType) {
+    public List<TableTop> orderCount(LogisticsReq logisticsReq, Integer unitType) {
         logisticsReq.setEntId(LoginUserHolder.getEntId());
         Map<String, Long> map = logisticsMapper.countOrder(logisticsReq, unitType);
-        LedgerCountVo ledgerCountVo;
-        List<LedgerCountVo> res = new ArrayList<>();
+        TableTop ledgerCountVo;
+        List<TableTop> res = new ArrayList<>();
         for (LedgerEnum value : LedgerEnum.values()) {
-            ledgerCountVo = new LedgerCountVo();
-            ledgerCountVo.setCount(map.get(String.valueOf(value.getStatus())));
-            ledgerCountVo.setLabel(value.getDesc());
-            ledgerCountVo.setStatus(value.getStatus());
+            ledgerCountVo = new TableTop();
+            ledgerCountVo.setTotal(Math.toIntExact(map.get(value.getLabel())));
+            ledgerCountVo.setName(value.getDesc());
+            ledgerCountVo.setValue(value.getStatus());
             res.add(ledgerCountVo);
         }
         return res;

+ 15 - 12
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerTradeService.java

@@ -6,6 +6,7 @@ import com.github.pagehelper.PageInfo;
 import com.sckw.core.common.enums.enums.DictTypeEnum;
 import com.sckw.core.exception.BusinessException;
 import com.sckw.core.model.page.PageRes;
+import com.sckw.core.model.vo.TableTop;
 import com.sckw.core.utils.CollectionUtils;
 import com.sckw.core.utils.IdWorker;
 import com.sckw.core.utils.OrderGenerateUtils;
@@ -73,8 +74,8 @@ public class KwpLedgerTradeService extends AbsLedger {
             tradingMap = tradingDict.stream().collect(Collectors.toMap(SysDictResDto::getValue, SysDictResDto::getLabel, (a, b) -> a));
         }
         for (ILedger tradeDto : list) {
-            Integer trading = tradeDto.getTrading();
-            tradeDto.setTradingLabel(tradingMap.get(String.valueOf(trading)));
+            String trading = tradeDto.getTrading();
+            tradeDto.setTradingLabel(tradingMap.get(trading));
             Integer taxRate = tradeDto.getTaxRate();
             tradeDto.setTaxRateLabel(taxRateMap.get(String.valueOf(taxRate)));
 
@@ -201,6 +202,7 @@ public class KwpLedgerTradeService extends AbsLedger {
             kwpLedgerTradeOrder.setId(new IdWorker(1).nextId());
             kwpLedgerTradeOrder.setTLedgerId(kwpLedgerTrade.getId());
             kwpLedgerTradeOrder.setTOrderId(a.getId());
+            kwpLedgerTradeOrder.setTOrderNo(a.getTOrderNo());
             kwpLedgerTradeOrder.setRemark("");
             kwpLedgerTradeOrder.setStatus(0);
             kwpLedgerTradeOrder.setCreateBy(LoginUserHolder.getUserId());
@@ -443,15 +445,16 @@ public class KwpLedgerTradeService extends AbsLedger {
         return "对账完成";
     }
 
-    public List<LedgerCountVo> orderCount(Integer unitType) {
-        Map<String, Long> map = tradeMapper.countOrder(LoginUserHolder.getEntId(), unitType);
-        LedgerCountVo ledgerCountVo;
-        List<LedgerCountVo> res = new ArrayList<>();
+    public List<TableTop> orderCount(TradeReq tradeReq) {
+        tradeReq.setEntId(LoginUserHolder.getEntId());
+        Map<String, Long> map = tradeMapper.countOrder(tradeReq);
+        TableTop ledgerCountVo;
+        List<TableTop> res = new ArrayList<>();
         for (LedgerEnum value : LedgerEnum.values()) {
-            ledgerCountVo = new LedgerCountVo();
-            ledgerCountVo.setCount(map.get(String.valueOf(value.getStatus())));
-            ledgerCountVo.setLabel(value.getDesc());
-            ledgerCountVo.setStatus(value.getStatus());
+            ledgerCountVo = new TableTop();
+            ledgerCountVo.setTotal(Math.toIntExact(map.get(String.valueOf(value.getLabel()))));
+            ledgerCountVo.setName(value.getDesc());
+            ledgerCountVo.setValue(value.getStatus());
             res.add(ledgerCountVo);
         }
         return res;
@@ -472,7 +475,7 @@ public class KwpLedgerTradeService extends AbsLedger {
     }
 
     public LedgerTradeDetailVo queryUpdate(Long id) {
-        LedgerTradeDto ledgerTradeDto = tradeMapper.selectId(id,TradeUnitType.PURCHASE);
+        LedgerTradeDto ledgerTradeDto = tradeMapper.selectId(id, TradeUnitType.PURCHASE);
         orderCheck(ledgerTradeDto);
         updateCheck(ledgerTradeDto.getStatus());
         List<KwpLedgerTradeOrder> kwpLedgerTradeOrders = tradeOrderService.queryList(ledgerTradeDto.getId());
@@ -500,7 +503,7 @@ public class KwpLedgerTradeService extends AbsLedger {
     }
 
     public LedgerTradeDetailVo queryDetail(Long id, Integer unitType) {
-        LedgerTradeDto ledgerTradeDto = tradeMapper.selectId(id,unitType);
+        LedgerTradeDto ledgerTradeDto = tradeMapper.selectId(id, unitType);
         orderCheck(ledgerTradeDto);
 
         List<KwpLedgerTradeOrder> kwpLedgerTradeOrders = tradeOrderService.queryList(ledgerTradeDto.getId());

+ 158 - 100
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementLogisticsService.java

@@ -2,22 +2,33 @@ package com.sckw.payment.service;
 
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
-import com.sckw.core.model.page.PageRes;
+import com.sckw.core.exception.BusinessException;
+import com.sckw.core.model.vo.TableTop;
+import com.sckw.core.utils.StringTimeUtil;
+import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.payment.dao.KwpSettlementLogisticsMapper;
 import com.sckw.payment.model.KwpSettlementLogistics;
+import com.sckw.payment.model.constant.LogisticsUnitType;
 import com.sckw.payment.model.constant.SettlementEnum;
 import com.sckw.payment.model.dto.SettlementLogisticsDto;
 import com.sckw.payment.model.vo.req.SettlementReq;
 import com.sckw.payment.model.vo.res.SettlementLogisticsStatusCountVo;
 import com.sckw.payment.model.vo.res.SettlementLogisticsSumVo;
+import com.sckw.payment.model.vo.res.SettlementWalletVo;
 import com.sckw.payment.utils.CommonValidator;
 import com.sckw.payment.utils.PageMoreRes;
+import com.sckw.system.api.RemoteSystemService;
+import com.sckw.system.api.model.dto.res.UserCacheResDto;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
-import org.jetbrains.annotations.NotNull;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.dubbo.config.annotation.DubboReference;
+import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 
-import java.util.List;
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * @author Aick Spt
@@ -27,30 +38,13 @@ import java.util.List;
 @Service
 @Slf4j
 public class KwpSettlementLogisticsService {
+    @DubboReference(version = "2.0.0", group = "design", check = false)
+    private RemoteSystemService remoteSystemService;
     private final KwpSettlementLogisticsMapper settlementLogisticsMapper;
 
     public void save(KwpSettlementLogistics settlementLogistics) {
         settlementLogisticsMapper.insert(settlementLogistics);
     }
-//    public SettlementLogisticsStatusCountVo getCountList() {
-//        SettlementLogisticsStatusCountVo settlementLogisticsStatusCountVos = new SettlementLogisticsStatusCountVo();
-//        LambdaQueryWrapper<KwpSettlementLogistics> wrapper = new LambdaQueryWrapper<>();
-//
-//        settlementLogisticsStatusCountVos.setAllCount(settlementLogisticsMapper.selectCount(wrapper));
-//
-//        wrapper.eq(KwpSettlementLogistics::getStatus, SettlementEnum.WAITING_PAYMENT.getStatus());//待结算
-//        settlementLogisticsStatusCountVos.setWaitingPaymentCount(settlementLogisticsMapper.selectCount(wrapper));
-//
-//        wrapper.clear();
-//        wrapper.eq(KwpSettlementLogistics::getStatus, SettlementEnum.PARTIAL_PAYMENT.getStatus());//部分结算
-//        settlementLogisticsStatusCountVos.setPartialPaymentCount(settlementLogisticsMapper.selectCount(wrapper));
-//
-//        wrapper.clear();
-//        wrapper.eq(KwpSettlementLogistics::getStatus, SettlementEnum.ALL_PAYMENT.getStatus());//全部结算
-//        settlementLogisticsStatusCountVos.setAllPaymentCount(settlementLogisticsMapper.selectCount(wrapper));
-//
-//        return settlementLogisticsStatusCountVos;
-//    }
 
     /**
      * 运费收款-物流订单各状态列表总数
@@ -58,25 +52,9 @@ public class KwpSettlementLogisticsService {
      * @author Aick Spt
      * @date 2023-07-24 16:21
      */
-    public SettlementLogisticsStatusCountVo getCountListCollection(SettlementReq settlementReq) {
-        SettlementLogisticsStatusCountVo settlementLogisticsStatusCountVos = new SettlementLogisticsStatusCountVo();
-        //总
-        settlementReq.setStatus(null);
-        settlementLogisticsStatusCountVos.setAllCount(settlementLogisticsMapper.getCountListCollection(settlementReq));
-
-        //待结算
-        settlementReq.setStatus(SettlementEnum.WAITING_PAYMENT.getStatus());
-        settlementLogisticsStatusCountVos.setWaitingPaymentCount(settlementLogisticsMapper.getCountListCollection(settlementReq));
-
-        //部分结算
-        settlementReq.setStatus(SettlementEnum.PARTIAL_PAYMENT.getStatus());
-        settlementLogisticsStatusCountVos.setPartialPaymentCount(settlementLogisticsMapper.getCountListCollection(settlementReq));
-
-        //全部结算
-        settlementReq.setStatus(SettlementEnum.ALL_PAYMENT.getStatus());
-        settlementLogisticsStatusCountVos.setAllPaymentCount(settlementLogisticsMapper.getCountListCollection(settlementReq));
-
-        return settlementLogisticsStatusCountVos;
+    public List<TableTop> getCountListCollection(SettlementReq settlementReq) {
+        settlementReq.setUnitType(LogisticsUnitType.SHIPPER);
+        return getCountList(settlementReq);
     }
 
     /**
@@ -85,25 +63,9 @@ public class KwpSettlementLogisticsService {
      * @author Aick Spt
      * @date 2023-07-24 16:23
      */
-    public SettlementLogisticsStatusCountVo getCountListPayment(SettlementReq settlementReq) {
-        SettlementLogisticsStatusCountVo settlementLogisticsStatusCountVos = new SettlementLogisticsStatusCountVo();
-        //总
-        settlementReq.setStatus(null);
-        settlementLogisticsStatusCountVos.setAllCount(settlementLogisticsMapper.getCountListPayment(settlementReq));
-
-        //待结算
-        settlementReq.setStatus(SettlementEnum.WAITING_PAYMENT.getStatus());
-        settlementLogisticsStatusCountVos.setWaitingPaymentCount(settlementLogisticsMapper.getCountListPayment(settlementReq));
-
-        //部分结算
-        settlementReq.setStatus(SettlementEnum.PARTIAL_PAYMENT.getStatus());
-        settlementLogisticsStatusCountVos.setPartialPaymentCount(settlementLogisticsMapper.getCountListPayment(settlementReq));
-
-        //全部结算
-        settlementReq.setStatus(SettlementEnum.ALL_PAYMENT.getStatus());
-        settlementLogisticsStatusCountVos.setAllPaymentCount(settlementLogisticsMapper.getCountListPayment(settlementReq));
-
-        return settlementLogisticsStatusCountVos;
+    public List<TableTop> getCountListPayment(SettlementReq settlementReq) {
+        settlementReq.setUnitType(LogisticsUnitType.CARRIER);
+        return getCountList(settlementReq);
     }
 
     /**
@@ -113,47 +75,21 @@ public class KwpSettlementLogisticsService {
      * @date 2023-07-24 16:21
      */
     public PageMoreRes<SettlementLogisticsDto> pageSelectCollection(SettlementReq settlementReq) {
-        CommonValidator.isValidCoexisting(settlementReq.getStartCreateTime(), settlementReq.getEndCreateTime(), "");
-        CommonValidator.isValidCoexisting(settlementReq.getStartReceiptTime(), settlementReq.getEndReceiptTime(), "预计收款开始和结束时间");
-
-        PageHelper.startPage(settlementReq.getPage(), settlementReq.getPageSize());
-        List<SettlementLogisticsDto> kwpLedgerLogisticsList = settlementLogisticsMapper.pageSelectCollection(settlementReq);
-        SettlementLogisticsSumVo settlementLogisticsSum = settlementLogisticsMapper.selectCollectionSum(settlementReq);
-
-        // 对查询结果进行处理,转换 status 到 desc
-        return new PageMoreRes<>(getSettlementLogisticsDtoPageRes(kwpLedgerLogisticsList), settlementLogisticsSum);
+        settlementReq.setUnitType(LogisticsUnitType.SHIPPER);
+        return pageSelect(settlementReq);
     }
 
-
     /**
      * 运费付款-物流订单列表
      *
      * @author Aick Spt
      * @date 2023-07-24 16:23
      */
-    public PageRes<SettlementLogisticsDto> pageSelectPayment(SettlementReq settlementReq) {
-        CommonValidator.isValidCoexisting(settlementReq.getStartCreateTime(), settlementReq.getEndCreateTime(), "");
-        CommonValidator.isValidCoexisting(settlementReq.getStartReceiptTime(), settlementReq.getEndReceiptTime(), "预计付款开始和结束时间");
-
-        PageHelper.startPage(settlementReq.getPage(), settlementReq.getPageSize());
-        List<SettlementLogisticsDto> kwpLedgerLogisticsList = settlementLogisticsMapper.pageSelectPayment(settlementReq);
-
-        // 对查询结果进行处理,转换 status 到 desc
-        return new PageRes<>(getSettlementLogisticsDtoPageRes(kwpLedgerLogisticsList));
-    }
-
-    @NotNull
-    private PageInfo<SettlementLogisticsDto> getSettlementLogisticsDtoPageRes(List<SettlementLogisticsDto> kwpLedgerLogisticsList) {
-        for (SettlementLogisticsDto entity : kwpLedgerLogisticsList) {
-            entity.setStatusText(SettlementEnum.getStatusDesc(entity.getStatus()));
-            entity.setResiduePrice(entity.getLedgerSettlePrice().subtract(entity.getActualPrice()));
-            entity.setCreateByText("创建人名称");
-            entity.setUpdateByText("更新人名称");
-        }
-        return new PageInfo<>(kwpLedgerLogisticsList);
+    public PageMoreRes<SettlementLogisticsDto> pageSelectPayment(SettlementReq settlementReq) {
+        settlementReq.setUnitType(LogisticsUnitType.CARRIER);
+        return pageSelect(settlementReq);
     }
 
-
     /**
      * 运费收款-物流订单详情
      *
@@ -161,7 +97,10 @@ public class KwpSettlementLogisticsService {
      * @date 2023-07-24 16:22
      */
     public SettlementLogisticsDto detailCollection(Long id) {
-        return settlementLogisticsMapper.detailCollection(id);
+        if (id == null) {
+            throw new BusinessException("结算单ID必传");
+        }
+        return detail(id, LogisticsUnitType.SHIPPER);
     }
 
     /**
@@ -171,23 +110,142 @@ public class KwpSettlementLogisticsService {
      * @date 2023-07-24 16:24
      */
     public SettlementLogisticsDto detailPayment(Long id) {
-        return settlementLogisticsMapper.detailPayment(id);
+        return detail(id, LogisticsUnitType.CARRIER);
     }
 
-
     /**
-     * 根据id查物流结算订单
+     * 根据条件查物流结算订单-导出
      *
-     * @param ids 物流结算订单集合List<Long>
      * @author Aick Spt
      * @date 2023-07-21 16:16
      */
-    public List<SettlementLogisticsDto> selectList(List<Long> ids) {
-        return settlementLogisticsMapper.selectIds(ids);
+    public List<SettlementLogisticsDto> selectList(SettlementReq settlementReq) {
+        validSettlementReq(settlementReq);
+        return settlementLogisticsMapper.selectLogisticsList(settlementReq, settlementReq.getIdList());
     }
 
-    public List<SettlementLogisticsDto> selectList(Integer unitType) {
-        return settlementLogisticsMapper.selectList(unitType);
+    /**
+     * 验证过滤信息
+     *
+     * @param settlementReq
+     * @author Aick Spt
+     * @date 2023-08-01 10:45
+     */
+    private void validSettlementReq(SettlementReq settlementReq) {
+        //判断时间是否成对
+        CommonValidator.isValidCoexisting(settlementReq.getStartCreateTime(), settlementReq.getEndCreateTime(), "");
+        CommonValidator.isValidCoexisting(settlementReq.getStartReceiptTime(), settlementReq.getEndReceiptTime(), "预计付款开始和结束时间");
+        //补全时间信息
+        if (StringUtils.isNotBlank(settlementReq.getStartCreateTime())) {
+            settlementReq.setStartCreateTime(StringTimeUtil.fillStart(settlementReq.getStartCreateTime()));
+        }
+        if (StringUtils.isNotBlank(settlementReq.getEndCreateTime())) {
+            settlementReq.setEndCreateTime(StringTimeUtil.fillEnd(settlementReq.getEndCreateTime()));
+        }
+        //加上当前登录者顶级企业id用于过滤数据
+        settlementReq.setEntId(LoginUserHolder.getEntId());
+    }
+
+    private PageMoreRes<SettlementLogisticsDto> pageSelect(SettlementReq settlementReq) {
+        validSettlementReq(settlementReq);
+        PageHelper.startPage(settlementReq.getPage(), settlementReq.getPageSize());
+        List<SettlementLogisticsDto> kwpLedgerLogisticsList = settlementLogisticsMapper.pageSelect(settlementReq);
+        SettlementLogisticsSumVo settlementLogisticsSum = settlementLogisticsMapper.selectSum(settlementReq);
+
+        // 对查询结果进行处理,转换 status 到 desc
+        return new PageMoreRes<>(getSettlementLogisticsDtoPageRes(kwpLedgerLogisticsList), settlementLogisticsSum);
+    }
+
+    private PageInfo<SettlementLogisticsDto> getSettlementLogisticsDtoPageRes(List<SettlementLogisticsDto> kwpLedgerLogisticsList) {
+        for (SettlementLogisticsDto entity : kwpLedgerLogisticsList) {
+            setDetailDesc(entity);
+        }
+        return new PageInfo<>(kwpLedgerLogisticsList);
+    }
+
+    public List<TableTop> getCountList(SettlementReq settlementReq) {
+        validSettlementReq(settlementReq);
+        SettlementLogisticsStatusCountVo settlementLogisticsStatusCountVos = new SettlementLogisticsStatusCountVo();
+
+        //加上当前登录者顶级企业id用于过滤数据
+        settlementReq.setEntId(LoginUserHolder.getEntId());
+
+        List<TableTop> tableTops = new ArrayList<>();
+        TableTop tableTop = new TableTop();
+        //总
+        settlementReq.setStatus(null);
+        settlementLogisticsStatusCountVos.setAllCount(settlementLogisticsMapper.getCountList(settlementReq));
+        tableTop.setName("全部").setValue(settlementReq.getStatus()).setTotal(Math.toIntExact(settlementLogisticsStatusCountVos.getAllCount()));
+        tableTops.add(tableTop);
+
+        //待结算
+        settlementReq.setStatus(SettlementEnum.WAITING_PAYMENT.getStatus());
+//        settlementLogisticsStatusCountVos.setWaitingPaymentCount(settlementLogisticsMapper.getCountList(settlementReq));
+        Long a = settlementLogisticsMapper.getCountList(settlementReq);
+        settlementLogisticsStatusCountVos.setWaitingPaymentCount(a);
+        TableTop tableTop1 = new TableTop();
+        tableTop1.setName("待结算").setValue(SettlementEnum.WAITING_PAYMENT.getStatus()).setTotal(Math.toIntExact(a));
+        tableTops.add(tableTop1);
+
+        //部分结算
+        settlementReq.setStatus(SettlementEnum.PARTIAL_PAYMENT.getStatus());
+        settlementLogisticsStatusCountVos.setPartialPaymentCount(settlementLogisticsMapper.getCountList(settlementReq));
+        TableTop tableTop2 = new TableTop();
+        tableTop2.setName("部分结算").setValue(SettlementEnum.PARTIAL_PAYMENT.getStatus()).setTotal(Math.toIntExact(settlementLogisticsStatusCountVos.getPartialPaymentCount()));
+        tableTops.add(tableTop2);
+
+        //全部结算
+        settlementReq.setStatus(SettlementEnum.ALL_PAYMENT.getStatus());
+        settlementLogisticsStatusCountVos.setAllPaymentCount(settlementLogisticsMapper.getCountList(settlementReq));
+        TableTop tableTop3 = new TableTop();
+        tableTop3.setName("全部结算").setValue(SettlementEnum.ALL_PAYMENT.getStatus()).setTotal(Math.toIntExact(settlementLogisticsStatusCountVos.getAllPaymentCount()));
+        tableTops.add(tableTop3);
+
+        return tableTops;
+    }
+
+    private SettlementLogisticsDto detail(Long id, Integer unitType) {
+        SettlementLogisticsDto settlementLogisticsDto = settlementLogisticsMapper.detail(id, unitType);
+        if (settlementLogisticsDto == null) {
+            throw new BusinessException("查无数据");
+        }
+        setDetailDesc(settlementLogisticsDto);
+        return settlementLogisticsDto;
+    }
+
+    private void setDetailDesc(SettlementLogisticsDto settlementLogisticsDto) {
+        settlementLogisticsDto.setStatusText(SettlementEnum.getStatusDesc(settlementLogisticsDto.getStatus()));
+        if (settlementLogisticsDto.getLedgerSettlePrice() != null) {
+            if (settlementLogisticsDto.getActualPrice() != null) {
+                settlementLogisticsDto.setResiduePrice(settlementLogisticsDto.getLedgerSettlePrice().subtract(settlementLogisticsDto.getActualPrice()));
+            } else {
+                settlementLogisticsDto.setResiduePrice(settlementLogisticsDto.getLedgerSettlePrice());
+            }
+        } else {
+            settlementLogisticsDto.setResiduePrice(new BigDecimal(0));
+        }
+        settlementLogisticsDto.setCreateByText("创建人名称");//"创建人名称"
+        settlementLogisticsDto.setUpdateByText("更新人名称");//"更新人名称"
+
+        Map<Long, UserCacheResDto> map = new HashMap<>();
+        Long createBy = settlementLogisticsDto.getCreateBy();
+        Long updateBy = settlementLogisticsDto.getUpdateBy();
+        UserCacheResDto userCacheResDto = map.get(createBy);
+        if (Objects.isNull(userCacheResDto)) {
+            userCacheResDto = remoteSystemService.queryUserCacheById(createBy);
+            map.put(createBy, userCacheResDto);
+        }
+        if (Objects.nonNull(userCacheResDto)) {
+            settlementLogisticsDto.setCreateByText(userCacheResDto.getName());
+        }
+        userCacheResDto = map.get(updateBy);
+        if (Objects.isNull(userCacheResDto)) {
+            userCacheResDto = remoteSystemService.queryUserCacheById(updateBy);
+            map.put(updateBy, userCacheResDto);
+        }
+        if (Objects.nonNull(userCacheResDto)) {
+            settlementLogisticsDto.setUpdateByText(userCacheResDto.getName());
+        }
     }
 
 }

+ 202 - 70
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementOfflineService.java

@@ -6,19 +6,35 @@ import com.sckw.core.exception.BusinessException;
 import com.sckw.core.model.page.PageRes;
 import com.sckw.core.utils.IdWorker;
 import com.sckw.core.web.context.LoginUserHolder;
+import com.sckw.payment.dao.KwpSettlementLogisticsMapper;
+import com.sckw.payment.dao.KwpSettlementLogisticsTrackMapper;
 import com.sckw.payment.dao.KwpSettlementOfflineMapper;
+import com.sckw.payment.model.KwpSettlementLogistics;
+import com.sckw.payment.model.KwpSettlementLogisticsTrack;
 import com.sckw.payment.model.KwpSettlementOffline;
 import com.sckw.payment.model.KwpSettlementTrade;
+import com.sckw.payment.model.constant.SettlementEnum;
+import com.sckw.payment.model.constant.SettlementOrderTypeEnum;
+import com.sckw.payment.model.KwpSettlementTradeTrack;
+import com.sckw.payment.model.constant.SettlementEnum;
+import com.sckw.payment.model.constant.SettlementTrackEnum;
+import com.sckw.payment.model.constant.TradeUnitType;
 import com.sckw.payment.model.constant.TradingEnum;
+import com.sckw.payment.model.dto.SettlementLogisticsDto;
 import com.sckw.payment.model.dto.SettlementOfflineDto;
 import com.sckw.payment.model.dto.SettlementTradeDto;
+import com.sckw.payment.model.vo.req.OfflinePaymentReq;
 import com.sckw.payment.model.vo.req.SettlementOfflinePayReq;
 import com.sckw.payment.model.vo.req.SettlementOfflineReq;
 import com.sckw.payment.model.vo.res.SettlementOfflineVo;
+import com.sckw.payment.model.vo.res.SettlementWalletVo;
+import com.sckw.redis.config.RedisLockUtil;
+import com.sckw.redis.constant.RedisConstant;
 import com.sckw.system.api.RemoteSystemService;
 import com.sckw.system.api.model.dto.res.UserCacheResDto;
 import jakarta.annotation.Resource;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
@@ -44,8 +60,19 @@ public class KwpSettlementOfflineService {
     private KwpSettlementOfflineMapper settlementOfflineMapper;
     @Resource
     private KwpSettlementTradeService settlementTradeService;
+    @Resource
+    private KwpSettlementTradeTrackService settlementTradeTrackService;
     @DubboReference(version = "2.0.0", group = "design", check = false)
     private RemoteSystemService remoteSystemService;
+    @Resource
+    private RedisLockUtil redisLockUtil;
+
+    @Resource
+    private KwpSettlementLogisticsService kwpSettlementLogisticsService;
+    @Resource
+    private KwpSettlementLogisticsMapper kwpSettlementLogisticsMapper;
+    @Resource
+    private KwpSettlementLogisticsTrackMapper kwpSettlementLogisticsTrackMapper;
 
     /**
      * 物流-线下付款(运费收款)记录-列表
@@ -54,11 +81,6 @@ public class KwpSettlementOfflineService {
      * @date 2023-07-26 17:15
      */
     public PageRes<SettlementOfflineVo> pageListLogisticsCollection(SettlementOfflineReq settlementOfflineReq) {
-//        //todo 查询缓存,获取客户企业id
-//        String keywords = settlementReq.getKeywords();
-//        if (StringUtils.isNotBlank(keywords)) {
-//            System.out.println("关键之:" + keywords);
-//        }
         PageHelper.startPage(settlementOfflineReq.getPage(), settlementOfflineReq.getPageSize());
 
         List<SettlementOfflineDto> settlementOfflineLogisticsList = settlementOfflineMapper.pageListLogisticsCollection(settlementOfflineReq);
@@ -72,10 +94,29 @@ public class KwpSettlementOfflineService {
             entity.setUpdateByText("更新人名称");
         }
 
+        Map<Long, UserCacheResDto> map = new HashMap<>();
         //指定返回值
         List<SettlementOfflineVo> collect = settlementOfflineLogisticsList.stream().map(a -> {
             SettlementOfflineVo settlementOfflineVo = new SettlementOfflineVo();
             BeanUtils.copyProperties(a, settlementOfflineVo);
+            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)) {
+                settlementOfflineVo.setCreateByText(userCacheResDto.getName());
+            }
+            userCacheResDto = map.get(updateBy);
+            if (Objects.isNull(userCacheResDto)) {
+                userCacheResDto = remoteSystemService.queryUserCacheById(updateBy);
+                map.put(updateBy, userCacheResDto);
+            }
+            if (Objects.nonNull(userCacheResDto)) {
+                settlementOfflineVo.setUpdateByText(userCacheResDto.getName());
+            }
             return settlementOfflineVo;
         }).collect(Collectors.toList());
 
@@ -97,30 +138,96 @@ public class KwpSettlementOfflineService {
     /**
      * 物流-线下付款(运费收款)记录-新增
      *
-     * @param id    结算单id
-     * @param price 付款金额
      * @return InsertId
      * @author Aick Spt
      * @date 2023-07-20 14:23
      */
-    public Integer confirmLogisticsCollection(Long id, Float price) {
-        log.info("接收到数据,开始物流-物流-线下付款(运费收款)记录-新增,待完善");
-        //todo 待完善
+    public Integer confirmLogisticsCollection(OfflinePaymentReq offlinePaymentReq) {
+        log.info("接收到数据,开始物流-物流-线下付款(运费收款)记录-新增");
         //先查询出结算单情况
-
+        Long id = offlinePaymentReq.getIdLong();
+        BigDecimal price = offlinePaymentReq.getPrice();
+        String url = offlinePaymentReq.getUrl();
+        if (id == 0) {
+            throw new BusinessException("结算参数ID必填");
+        }
+        if (price == null || price.compareTo(BigDecimal.ZERO) == 0) {
+            throw new BusinessException("结算参数金额必填");
+        }
+        if (StringUtils.isBlank(url)) {
+            throw new BusinessException("附件必传");
+        }
+        SettlementLogisticsDto settlementLogisticsDto = kwpSettlementLogisticsService.detailPayment(id);
+        log.info(String.valueOf(settlementLogisticsDto));
         //检查结算单状态和所差金额
+        if (settlementLogisticsDto == null) {
+            log.error("非法请求,查无数据:" + id);
+            throw new BusinessException("非法请求运费结算参数ID");
+        }
+        if (settlementLogisticsDto.getStatus() == SettlementEnum.ALL_PAYMENT.getStatus()) {
+            log.error("非法请求,该订单已结算完成:" + id);
+            throw new BusinessException("该订单已结算完成,无法操作");
+        }
+        BigDecimal remainingReceivables = settlementLogisticsDto.getTotalPrice();
+        if (settlementLogisticsDto.getActualPrice() != null) {//剩余金额
+            remainingReceivables = settlementLogisticsDto.getTotalPrice().subtract(settlementLogisticsDto.getActualPrice());
+        }
 
-        //对比金额
-
+        if (remainingReceivables.compareTo(price) < 0) {//-1表示小于,0是等于,1是大于
+            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);
 
-        //新增电子钱包结算记录
-        KwpSettlementOffline kwpSettlementOffline = new KwpSettlementOffline();
-        kwpSettlementOffline.setId(new IdWorker(1).nextId());
-
-        //todo 待完善
-        settlementOfflineMapper.insert(kwpSettlementOffline);
-        return settlementOfflineMapper.confirmLogisticsCollection(id, price);
+            //新增一条线下结算记录
+            //当前剩余金额
+            remainingReceivables = remainingReceivables.subtract(price);
+            //入库
+            KwpSettlementOffline kwpSettlementOffline = new KwpSettlementOffline();
+            kwpSettlementOffline.setId(new IdWorker(1).nextId());
+            kwpSettlementOffline.setEntId(settlementLogisticsDto.getEntId());
+            kwpSettlementOffline.setSettlementId(settlementLogisticsDto.getId());
+            kwpSettlementOffline.setOrderType(SettlementOrderTypeEnum.LOGISTICS.getStatus());
+            kwpSettlementOffline.setPayTime(LocalDateTime.now());
+            kwpSettlementOffline.setPayPrice(price);
+            kwpSettlementOffline.setTopayPrice(remainingReceivables);
+            kwpSettlementOffline.setUrl(url);
+            kwpSettlementOffline.setRemark(remark);
+            kwpSettlementOffline.setStatus(1);
+            kwpSettlementOffline.setCreateBy(LoginUserHolder.getUserId());
+            kwpSettlementOffline.setCreateTime(LocalDateTime.now());
+            kwpSettlementOffline.setUpdateBy(LoginUserHolder.getUserId());
+            kwpSettlementOffline.setUpdateTime(LocalDateTime.now());
+            kwpSettlementOffline.setDelFlag(0);
+            return settlementOfflineMapper.insert(kwpSettlementOffline);
+        }
+        return null;
     }
 
     public PageRes<SettlementOfflineVo> pageListTradeCollection(SettlementOfflineReq settlementOfflineReq) {
@@ -158,58 +265,83 @@ public class KwpSettlementOfflineService {
         return new PageRes<>(new PageInfo<>(collect));
     }
 
+    /**
+     * 线下付款
+     *
+     * @param payReq
+     * @return
+     */
     @Transactional(rollbackFor = Exception.class)
     public String confirmTradeCollection(SettlementOfflinePayReq payReq) {
-        SettlementTradeDto byId = settlementTradeService.getById(payReq.getSettlementIdLong());
-        if (Objects.isNull(byId)) {
-            throw new BusinessException("结算单不存在");
-        }
-        if (TradingEnum.OFFLINE_PAY.getStatus() != byId.getTrading()) {
-            throw new BusinessException("只支持线下付款交易方法进行线下结算");
-        }
-        BigDecimal totalPrice = byId.getTotalPrice();
-        BigDecimal actualPrice = byId.getActualPrice();
-        if (Objects.isNull(totalPrice)) {
-            throw new BusinessException("总应收异常");
-        }
-        if (Objects.isNull(actualPrice)) {
-            throw new BusinessException("已收款金额异常");
-        }
-        //总应收-已收款=剩余待付款
-        BigDecimal subtract = totalPrice.subtract(actualPrice);
-        //本次付款金额
-        BigDecimal payPrice = payReq.getPayPrice();
-        //剩余待付款-本次付款=下次剩余待付款
-        BigDecimal subtract1 = subtract.subtract(payPrice);
-        if (subtract1.compareTo(new BigDecimal("0.0")) < 0) {
-            throw new BusinessException("实际付款金额大于剩余待付款金额");
+        String key = String.format(RedisConstant.SETTLEMENT_KEY, payReq.getId());
+        if (redisLockUtil.tryLock(key)) {
+            try {
+                SettlementTradeDto byId = settlementTradeService.getById(payReq.getIdLong(), TradeUnitType.PURCHASE);
+                if (Objects.isNull(byId)) {
+                    throw new BusinessException("结算单不存在");
+                }
+                if (!StringUtils.equals(TradingEnum.OFFLINE_PAY.getValue(), byId.getTrading())) {
+                    throw new BusinessException("只支持线下付款交易方法进行线下结算");
+                }
+                BigDecimal totalPrice = byId.getTotalPrice();
+                BigDecimal actualPrice = byId.getActualPrice();
+                if (Objects.isNull(totalPrice)) {
+                    throw new BusinessException("总应收异常");
+                }
+                if (Objects.isNull(actualPrice)) {
+                    throw new BusinessException("已收款金额异常");
+                }
+                //总应收-已收款=剩余待付款
+                BigDecimal subtract = totalPrice.subtract(actualPrice);
+                //本次付款金额
+                BigDecimal payPrice = payReq.getPayPrice();
+                //剩余待付款-本次付款=下次剩余待付款
+                BigDecimal subtract1 = subtract.subtract(payPrice);
+                if (subtract1.compareTo(new BigDecimal("0.0")) < 0) {
+                    throw new BusinessException("实际付款金额大于剩余待付款金额");
+                }
+                KwpSettlementTrade kwpSettlementTrade = new KwpSettlementTrade();
+                kwpSettlementTrade.setId(byId.getId());
+                kwpSettlementTrade.setActualPrice(actualPrice.add(payPrice));//已收款加本次收款
+                int status = 0;
+                if (subtract1.compareTo(new BigDecimal("0.0")) == 0) {
+                    status = SettlementEnum.ALL_PAYMENT.getStatus();
+                } else if (subtract1.compareTo(new BigDecimal("0.0")) > 0) {
+                    status = SettlementEnum.PARTIAL_PAYMENT.getStatus();
+                }
+                kwpSettlementTrade.setStatus(status);
+                kwpSettlementTrade.setUpdateBy(LoginUserHolder.getUserId());
+                kwpSettlementTrade.setUpdateTime(LocalDateTime.now());
+                settlementTradeService.updateById(kwpSettlementTrade);
+
+                KwpSettlementOffline kwpSettlementOffline = new KwpSettlementOffline();
+                kwpSettlementOffline.setId(new IdWorker(1).nextId());
+                kwpSettlementOffline.setEntId(LoginUserHolder.getEntId());
+                kwpSettlementOffline.setSettlementId(byId.getId());
+                kwpSettlementOffline.setOrderType(payReq.getOrderType());
+                kwpSettlementOffline.setPayTime(LocalDateTime.now());
+                kwpSettlementOffline.setPayPrice(payReq.getPayPrice());
+                kwpSettlementOffline.setTopayPrice(subtract1);
+                kwpSettlementOffline.setUrl(payReq.getUrl());
+                kwpSettlementOffline.setRemark("");
+                kwpSettlementOffline.setStatus(0);
+                kwpSettlementOffline.setCreateBy(LoginUserHolder.getUserId());
+                kwpSettlementOffline.setCreateTime(LocalDateTime.now());
+                kwpSettlementOffline.setUpdateBy(LoginUserHolder.getUserId());
+                kwpSettlementOffline.setUpdateTime(LocalDateTime.now());
+                kwpSettlementOffline.setDelFlag(0);
+
+                settlementOfflineMapper.insert(kwpSettlementOffline);
+
+                //记录表记录数据
+                settlementTradeTrackService.save(KwpSettlementTradeTrack.build(byId.getId(), SettlementTrackEnum.OFFLINE_PAY.getStatus()));
+
+                //中台接口 todo-xcq
+                return "确认回款成功";
+            } finally {
+                redisLockUtil.unlock(key);
+            }
         }
-        KwpSettlementTrade kwpSettlementTrade = new KwpSettlementTrade();
-        kwpSettlementTrade.setId(byId.getId());
-        kwpSettlementTrade.setActualPrice(actualPrice.add(payPrice));//已收款加本次收款
-        kwpSettlementTrade.setStatus(1);
-        kwpSettlementTrade.setUpdateBy(LoginUserHolder.getUserId());
-        kwpSettlementTrade.setUpdateTime(LocalDateTime.now());
-        settlementTradeService.updateById(kwpSettlementTrade);
-
-        KwpSettlementOffline kwpSettlementOffline = new KwpSettlementOffline();
-        kwpSettlementOffline.setId(new IdWorker(1).nextId());
-        kwpSettlementOffline.setEntId(LoginUserHolder.getEntId());
-        kwpSettlementOffline.setSettlementId(byId.getId());
-        kwpSettlementOffline.setOrderType(payReq.getOrderType());
-        kwpSettlementOffline.setPayTime(LocalDateTime.now());
-        kwpSettlementOffline.setPayPrice(payReq.getPayPrice());
-        kwpSettlementOffline.setTopayPrice(subtract1);
-        kwpSettlementOffline.setUrl(payReq.getUrl());
-        kwpSettlementOffline.setRemark("");
-        kwpSettlementOffline.setStatus(0);
-        kwpSettlementOffline.setCreateBy(LoginUserHolder.getUserId());
-        kwpSettlementOffline.setCreateTime(LocalDateTime.now());
-        kwpSettlementOffline.setUpdateBy(LoginUserHolder.getUserId());
-        kwpSettlementOffline.setUpdateTime(LocalDateTime.now());
-        kwpSettlementOffline.setDelFlag(0);
-
-        settlementOfflineMapper.insert(kwpSettlementOffline);
-        return "";
+        return "请勿重复提交";
     }
 }

+ 22 - 11
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementTradeService.java

@@ -4,6 +4,7 @@ import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.sckw.core.common.enums.enums.DictTypeEnum;
 import com.sckw.core.model.page.PageRes;
+import com.sckw.core.model.vo.TableTop;
 import com.sckw.core.utils.BeanUtils;
 import com.sckw.core.utils.CollectionUtils;
 import com.sckw.core.web.context.LoginUserHolder;
@@ -11,10 +12,7 @@ import com.sckw.payment.dao.KwpSettlementTradeMapper;
 import com.sckw.payment.model.KwpSettlementTrade;
 import com.sckw.payment.model.constant.SettlementEnum;
 import com.sckw.payment.model.constant.TradeUnitType;
-import com.sckw.payment.model.dto.ISettlement;
-import com.sckw.payment.model.dto.SettlementPurchaseDto;
-import com.sckw.payment.model.dto.SettlementSellDto;
-import com.sckw.payment.model.dto.SettlementTradeDto;
+import com.sckw.payment.model.dto.*;
 import com.sckw.payment.model.vo.req.SettlementReq;
 import com.sckw.payment.model.vo.req.SettlementTradeReq;
 import com.sckw.payment.model.vo.res.SettlementLogisticsStatusCountVo;
@@ -41,8 +39,12 @@ public class KwpSettlementTradeService {
     @DubboReference(version = "2.0.0", group = "design", check = false)
     private RemoteSystemService remoteSystemService;
 
-    public SettlementTradeDto getById(Long id) {
-        return settlementTradeMapper.getById(id);
+    public SettlementTradeDto getById(Long id, Integer unitType) {
+        return settlementTradeMapper.getById(id, unitType);
+    }
+
+    public List<LedgerUnitDto> getListById(Long id) {
+        return settlementTradeMapper.getListById(id);
     }
 
     public void save(KwpSettlementTrade kwpSettlementTrade) {
@@ -53,8 +55,8 @@ public class KwpSettlementTradeService {
         //字典等数据转换
         Map<String, SysDictResDto> dictResDtoMap = remoteSystemService.queryDictMapByType(DictTypeEnum.TRADE_TYPE.getType());
         for (ISettlement iSettlement : list) {
-            Integer trading = iSettlement.getTrading();
-            SysDictResDto sysDictResDto = dictResDtoMap.get(String.valueOf(trading));
+            String trading = iSettlement.getTrading();
+            SysDictResDto sysDictResDto = dictResDtoMap.get(trading);
             if (Objects.nonNull(sysDictResDto)) {
                 iSettlement.setTradingLabel(sysDictResDto.getLabel());
             }
@@ -98,8 +100,17 @@ public class KwpSettlementTradeService {
         return new PageRes<>(new PageInfo<>());
     }
 
-    public SettlementLogisticsStatusCountVo getCount(SettlementTradeReq settlementReq) {
-        return settlementTradeMapper.countOrder(settlementReq);
+    public List<TableTop> getCount(SettlementTradeReq settlementReq) {
+        Map<String, Long> stringIntegerMap = settlementTradeMapper.countOrder(settlementReq);
+        List<TableTop> res = new ArrayList<>(4);
+        for (SettlementEnum value : SettlementEnum.values()) {
+            TableTop tableTop = new TableTop();
+            tableTop.setName(value.getDesc());
+            tableTop.setValue(value.getStatus());
+            tableTop.setTotal(Math.toIntExact(stringIntegerMap.get(value.getLabel())));
+            res.add(tableTop);
+        }
+        return res;
     }
 
     /**
@@ -114,7 +125,7 @@ public class KwpSettlementTradeService {
 
 
     public List<ISettlement> selectList(List<Long> ids, int unitType) {
-        List<SettlementTradeDto> kwpSettlementTrades = settlementTradeMapper.selectByIds(ids);
+        List<SettlementTradeDto> kwpSettlementTrades = settlementTradeMapper.selectByIds(ids, unitType);
         if (!CollectionUtils.isEmpty(kwpSettlementTrades)) {
             //根据企业类型进行对应的数据
             if (unitType == TradeUnitType.PURCHASE) {

+ 283 - 116
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementWalletService.java

@@ -5,21 +5,27 @@ import com.github.pagehelper.PageInfo;
 import com.sckw.core.exception.BusinessException;
 import com.sckw.core.model.page.PageRes;
 import com.sckw.core.utils.IdWorker;
+import com.sckw.core.utils.StringUtils;
+import com.sckw.core.web.context.LoginUserHolder;
+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;
 import com.sckw.payment.dao.KwpSettlementLogisticsMapper;
+import com.sckw.payment.dao.KwpSettlementLogisticsTrackMapper;
 import com.sckw.payment.dao.KwpSettlementTradeMapper;
 import com.sckw.payment.dao.KwpSettlementWalletMapper;
-import com.sckw.payment.model.KwpSettlementLogistics;
-import com.sckw.payment.model.KwpSettlementTrade;
-import com.sckw.payment.model.KwpSettlementWallet;
-import com.sckw.payment.model.constant.SettlementEnum;
-import com.sckw.payment.model.constant.SettlementOrderTypeEnum;
-import com.sckw.payment.model.constant.SettlementWalletPayTypeEnum;
-import com.sckw.payment.model.constant.WalletChannelEnum;
+import com.sckw.payment.model.*;
+import com.sckw.payment.model.constant.*;
+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.vo.req.OfflinePaymentReq;
 import com.sckw.payment.model.vo.req.SettlementWalletReq;
+import com.sckw.payment.model.vo.req.WalletPayReq;
 import com.sckw.payment.model.vo.res.SettlementWalletVo;
+import com.sckw.redis.config.RedisLockUtil;
+import com.sckw.redis.constant.RedisConstant;
 import com.sckw.system.api.RemoteSystemService;
 import com.sckw.system.api.model.dto.res.UserCacheResDto;
 import jakarta.annotation.Resource;
@@ -54,12 +60,19 @@ public class KwpSettlementWalletService {
     @Resource
     private KwpSettlementTradeService kwpSettlementTradeService;
     @Resource
-    private KwpSettlementTradeMapper kwpSettlementTradeMapper;
+    private PayCenterService payCenterService;
     @Resource
-    private KwpLedgerTradeService ledgerTradeService;
+    private KwpWalletRelationService walletRelationService;
+    @Resource
+    private RedisLockUtil redisLockUtil;
+    @Resource
+    private KwpSettlementTradeTrackService settlementTradeTrackService;
     @DubboReference(version = "2.0.0", group = "design", check = false)
     private RemoteSystemService remoteSystemService;
 
+    @Resource
+    private KwpSettlementLogisticsTrackMapper kwpSettlementLogisticsTrackMapper;
+
     /**
      * 物流-电子钱包付款(货到付款)结算记录-列表
      *
@@ -67,13 +80,8 @@ public class KwpSettlementWalletService {
      * @date 2023-07-26 16:43
      */
     public PageRes<SettlementWalletVo> pageListLogisticsPayment(SettlementWalletReq settlementWalletReq) {
-//        //todo 查询缓存,获取客户企业id
-//        String keywords = settlementReq.getKeywords();
-//        if (StringUtils.isNotBlank(keywords)) {
-//            System.out.println("关键之:" + keywords);
-//        }
         PageHelper.startPage(settlementWalletReq.getPage(), settlementWalletReq.getPageSize());
-        settlementWalletReq.setPayType(SettlementWalletPayTypeEnum.CASH_ON_DELIVERY.getStatus());//只筛选 货到付款
+        settlementWalletReq.setPayType(SettlementPayTypeEnum.CASH_ON_DELIVERY.getStatus());//只筛选 货到付款
         List<SettlementWalletDto> settlementWalletLogisticsList = settlementWalletMapper.pageListLogisticsPayment(settlementWalletReq);
 
         if (CollectionUtils.isEmpty(settlementWalletLogisticsList)) {
@@ -85,10 +93,29 @@ public class KwpSettlementWalletService {
             entity.setUpdateByText("更新人名称");
         }
 
+        Map<Long, UserCacheResDto> map = new HashMap<>();
         //指定返回值
         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());
 
@@ -110,8 +137,6 @@ public class KwpSettlementWalletService {
     /**
      * 物流-电子钱包付款(货到付款)结算记录-新增
      *
-     * @param id    结算单id
-     * @param price 付款金额
      * @return InsertId
      * @author Aick Spt
      * @date 2023-07-20 14:23
@@ -119,10 +144,18 @@ public class KwpSettlementWalletService {
      * Transactional// isolation:事务的隔离级别,此处使用后端数据库的默认隔离级别, propagation: 如果当前没有事务,就新建一个事务,如果已经存在一个事务中,加入到这个事务中(常见)。(rollbackFor = Exception.class, isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
      */
     @Transactional
-    public Integer confirmLogisticsPayment(Long id, BigDecimal price) {
+    public Integer confirmLogisticsPayment(OfflinePaymentReq offlinePaymentReq) {
+        Long id = offlinePaymentReq.getIdLong();
+        BigDecimal price = offlinePaymentReq.getPrice();
+        if (id == 0) {
+            throw new BusinessException("结算参数ID必填");
+        }
+        if (price == null || price.compareTo(BigDecimal.ZERO) == 0) {
+            throw new BusinessException("结算参数金额必填");
+        }
+
         //先查询出结算单情况
         SettlementLogisticsDto settlementLogisticsDto = kwpSettlementLogisticsService.detailPayment(id);
-        log.info(String.valueOf(settlementLogisticsDto));
         //检查结算单状态和所差金额
         if (settlementLogisticsDto == null) {
             log.error("非法请求,查无数据:" + id);
@@ -142,19 +175,33 @@ public class KwpSettlementWalletService {
             throw new BusinessException("参数错误:输入金额过大 " + price + " 剩余金额最大值:" + remainingReceivables);
         }
         //累加入库结算单
-        KwpSettlementLogistics settlementLogistics1 = new KwpSettlementLogistics();
-        settlementLogistics1.setId(settlementLogisticsDto.getId());
-        settlementLogistics1.setUpdateTime(LocalDateTime.now());
+        KwpSettlementLogistics settlementLogistics = new KwpSettlementLogistics();
+        settlementLogistics.setId(settlementLogisticsDto.getId());
+        settlementLogistics.setUpdateTime(LocalDateTime.now());
         if (remainingReceivables.compareTo(price) == 0) {//全部结算
-            settlementLogistics1.setStatus(SettlementEnum.ALL_PAYMENT.getStatus());
+            settlementLogistics.setStatus(SettlementEnum.ALL_PAYMENT.getStatus());
         }
         if (remainingReceivables.compareTo(price) > 0) {//部分结算
-            settlementLogistics1.setStatus(SettlementEnum.PARTIAL_PAYMENT.getStatus());
+            settlementLogistics.setStatus(SettlementEnum.PARTIAL_PAYMENT.getStatus());
         }
         BigDecimal actualPrice = settlementLogisticsDto.getActualPrice();
-        settlementLogistics1.setActualPrice((actualPrice == null) ? price : actualPrice.add(price));
-        int upInt = kwpSettlementLogisticsMapper.updateById(settlementLogistics1);
+        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();
@@ -162,16 +209,16 @@ public class KwpSettlementWalletService {
             kwpSettlementWallet.setEntId(settlementLogisticsDto.getEntId());
             kwpSettlementWallet.setSettlementId(settlementLogisticsDto.getId());
             kwpSettlementWallet.setOrderType(SettlementOrderTypeEnum.LOGISTICS.getStatus());
-            kwpSettlementWallet.setChannel(WalletChannelEnum.HF.getStatus());//先用数字默认定义为1
+            kwpSettlementWallet.setChannel(WalletChannelEnum.getValue(settlementLogisticsDto.getLedgerTrading()));//先用数字默认定义为1
             kwpSettlementWallet.setPayTime(LocalDateTime.now());
             kwpSettlementWallet.setPayPrice(price);
             kwpSettlementWallet.setTopayPrice(remainingReceivables);
-            kwpSettlementWallet.setType(SettlementWalletPayTypeEnum.CASH_ON_DELIVERY.getStatus());
+            kwpSettlementWallet.setType(SettlementPayTypeEnum.CASH_ON_DELIVERY.getStatus());
             kwpSettlementWallet.setRemark("");
             kwpSettlementWallet.setStatus(1);
-            kwpSettlementWallet.setCreateBy(1L);//todo 待处理明确创建人
+            kwpSettlementWallet.setCreateBy(LoginUserHolder.getUserId());
             kwpSettlementWallet.setCreateTime(LocalDateTime.now());
-            kwpSettlementWallet.setUpdateBy(1L);//todo 待处理明确更新人
+            kwpSettlementWallet.setUpdateBy(LoginUserHolder.getUserId());
             kwpSettlementWallet.setUpdateTime(LocalDateTime.now());
             kwpSettlementWallet.setDelFlag(0);
             Integer insertKwpSettlementWallet = settlementWalletMapper.insert(kwpSettlementWallet);
@@ -214,74 +261,102 @@ public class KwpSettlementWalletService {
 
 
     /**
-     * 销售-付款确认-(新增电子钱包记录-采购货到付款)
+     * 销售-付款确认-货到付款
      *
      * @author Aick Spt
      * @date 2023-07-27 16:13
      */
-    public Integer confirmTradePayment(Long id, BigDecimal price) {
-        //先查询出结算单情况
-        SettlementTradeDto settlementTradeDto = kwpSettlementTradeService.detailPayment(id);
-        log.info(String.valueOf(settlementTradeDto));
-        //检查结算单状态和所差金额
-        if (settlementTradeDto == null) {
-            log.error("非法请求,查无数据:" + id);
-            throw new BusinessException("非法请求运费结算参数ID");
-        }
-        if (settlementTradeDto.getStatus() == SettlementEnum.ALL_PAYMENT.getStatus()) {
-            log.error("非法请求,该订单已结算完成:" + id);
-            throw new BusinessException("该订单已结算完成,无法操作");
-        }
-        BigDecimal remainingReceivables = settlementTradeDto.getTotalPrice();
-        if (settlementTradeDto.getActualPrice() != null) {//剩余金额
-            remainingReceivables = settlementTradeDto.getTotalPrice().subtract(settlementTradeDto.getActualPrice());
-        }
-
-        if (remainingReceivables.compareTo(price) < 0) {//-1表示小于,0是等于,1是大于
-            log.error("本次结算输入金额比剩余付款金额大:ID:" + id + " 剩余金额:" + remainingReceivables + " 本次输入金额:" + price);
-            throw new BusinessException("参数错误:输入金额过大 " + price + " 剩余金额最大值:" + remainingReceivables);
-        }
-        //累加入库结算单
-        KwpSettlementTrade kwpSettlementTrade = new KwpSettlementTrade();
-        kwpSettlementTrade.setId(settlementTradeDto.getId());
-        kwpSettlementTrade.setUpdateTime(LocalDateTime.now());
-        if (remainingReceivables.compareTo(price) == 0) {//全部结算
-            kwpSettlementTrade.setStatus(SettlementEnum.ALL_PAYMENT.getStatus());
-        }
-        if (remainingReceivables.compareTo(price) > 0) {//部分结算
-            kwpSettlementTrade.setStatus(SettlementEnum.PARTIAL_PAYMENT.getStatus());
-        }
-        BigDecimal actualPrice = settlementTradeDto.getActualPrice();
-        kwpSettlementTrade.setActualPrice((actualPrice == null) ? price : actualPrice.add(price));
-        int upInt = kwpSettlementTradeMapper.updateById(kwpSettlementTrade);
-        if (upInt > 0) {
-            //新增一条电子钱包结算记录
-            remainingReceivables = remainingReceivables.subtract(price);
-            KwpSettlementWallet kwpSettlementWallet = new KwpSettlementWallet();
-            kwpSettlementWallet.setId(new IdWorker(1).nextId());
-            kwpSettlementWallet.setEntId(settlementTradeDto.getEntId());
-            kwpSettlementWallet.setSettlementId(settlementTradeDto.getId());
-            kwpSettlementWallet.setOrderType(SettlementOrderTypeEnum.LOGISTICS.getStatus());
-            kwpSettlementWallet.setChannel(WalletChannelEnum.HF.getStatus());//先用数字默认定义为1
-            kwpSettlementWallet.setPayTime(LocalDateTime.now());
-            kwpSettlementWallet.setPayPrice(price);
-            kwpSettlementWallet.setTopayPrice(remainingReceivables);
-            kwpSettlementWallet.setType(SettlementWalletPayTypeEnum.CASH_ON_DELIVERY.getStatus());
-            kwpSettlementWallet.setRemark("");
-            kwpSettlementWallet.setStatus(1);
-            kwpSettlementWallet.setCreateBy(1L);//todo 待处理明确创建人
-            kwpSettlementWallet.setCreateTime(LocalDateTime.now());
-            kwpSettlementWallet.setUpdateBy(1L);//todo 待处理明确更新人
-            kwpSettlementWallet.setUpdateTime(LocalDateTime.now());
-            kwpSettlementWallet.setDelFlag(0);
-            Integer insertKwpSettlementWallet = settlementWalletMapper.insert(kwpSettlementWallet);
-
-            //物流货到付款电子钱包逻辑
-            //todo 待处理费电子钱包逻辑
-
-            return insertKwpSettlementWallet;
+    @Transactional(rollbackFor = Exception.class)
+    public String confirmTradePayment(WalletPayReq walletPayReq) {
+        String key = String.format(RedisConstant.SETTLEMENT_KEY, walletPayReq.getId());
+        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() != 2) {
+                    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("钱包可用余额不足");
+//        }
+                //待付款金额-本次付款金额= 剩余待付款金额
+                BigDecimal subtract = byId.getWaitPrice().subtract(walletPayReq.getPrice());
+                if (subtract.compareTo(new BigDecimal("0.0")) < 0) {
+                    throw new BusinessException("付款金额不能大于待付款金额");
+                }
+                //新增电子钱包结算记录
+                KwpSettlementWallet kwpSettlementWallet = new KwpSettlementWallet();
+                kwpSettlementWallet.setId(new IdWorker(1).nextId());
+                kwpSettlementWallet.setEntId(LoginUserHolder.getEntId());
+                kwpSettlementWallet.setSettlementId(walletPayReq.getIdLong());
+                kwpSettlementWallet.setOrderType(SettlementOrderTypeEnum.TRADE.getStatus());
+                kwpSettlementWallet.setChannel(WalletChannelEnum.getValue(byId.getTrading()));
+                kwpSettlementWallet.setPayTime(LocalDateTime.now());
+                kwpSettlementWallet.setPayPrice(walletPayReq.getPrice());
+                kwpSettlementWallet.setTopayPrice(subtract);
+                kwpSettlementWallet.setType(SettlementWalletPayTypeEnum.CASH_ON_DELIVERY.getStatus());
+                kwpSettlementWallet.setRemark("");
+                kwpSettlementWallet.setStatus(0);
+                kwpSettlementWallet.setCreateBy(LoginUserHolder.getUserId());
+                kwpSettlementWallet.setCreateTime(LocalDateTime.now());
+                kwpSettlementWallet.setUpdateBy(LoginUserHolder.getUserId());
+                kwpSettlementWallet.setUpdateTime(LocalDateTime.now());
+                kwpSettlementWallet.setDelFlag(0);
+                settlementWalletMapper.insert(kwpSettlementWallet);
+
+                //更新交易结算单状态和金额
+                KwpSettlementTrade kwpSettlementTrade = new KwpSettlementTrade();
+                kwpSettlementTrade.setId(byId.getId());
+                kwpSettlementTrade.setActualPrice(byId.getActualPrice().add(price));
+                kwpSettlementTrade.setStatus(subtract.compareTo(new BigDecimal("0.0")) == 0 ? SettlementEnum.ALL_PAYMENT.getStatus()
+                        : SettlementEnum.PARTIAL_PAYMENT.getStatus());
+                kwpSettlementTrade.setUpdateBy(LoginUserHolder.getUserId());
+                kwpSettlementTrade.setUpdateTime(LocalDateTime.now());
+                kwpSettlementTradeService.updateById(kwpSettlementTrade);
+
+                settlementTradeTrackService.save(KwpSettlementTradeTrack.build(byId.getId(), SettlementTrackEnum.RECEIVE_PAY.getStatus()));
+                //todo-xcq 调用中台接口
+
+                return "付款确认成功";
+            } finally {
+                redisLockUtil.unlock(key);
+            }
         }
-        return null;
+        return "请勿重复提交!";
     }
 
     /**
@@ -328,11 +403,6 @@ public class KwpSettlementWalletService {
     }
 
     public PageRes<SettlementWalletVo> pageListTradeCollection(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);
@@ -345,36 +415,133 @@ public class KwpSettlementWalletService {
             return new PageRes<>(new PageInfo<>());
         }
 
+        Map<Long, UserCacheResDto> map = new HashMap<>();
         //指定返回值
         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
+     * @return
+     */
+    public String confirmTradeCollection(Long id) {
+        String key = String.format(RedisConstant.SETTLEMENT_KEY, id);
+
+        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("只支持预付款交易方式进行预付款确认操作");
+                }
+                //更新交易结算单状态和金额
+                KwpSettlementTrade kwpSettlementTrade = new KwpSettlementTrade();
+                kwpSettlementTrade.setId(byId.getId());
+                kwpSettlementTrade.setActualPrice(byId.getTotalPrice());
+                kwpSettlementTrade.setStatus(SettlementEnum.ALL_PAYMENT.getStatus());
+                kwpSettlementTrade.setUpdateBy(LoginUserHolder.getUserId());
+                kwpSettlementTrade.setUpdateTime(LocalDateTime.now());
+                kwpSettlementTradeService.updateById(kwpSettlementTrade);
+                //新增电子钱包结算记录
+                KwpSettlementWallet kwpSettlementWallet = new KwpSettlementWallet();
+                kwpSettlementWallet.setId(new IdWorker(1).nextId());
+                kwpSettlementWallet.setEntId(LoginUserHolder.getEntId());
+                kwpSettlementWallet.setSettlementId(byId.getId());
+                kwpSettlementWallet.setOrderType(SettlementOrderTypeEnum.TRADE.getStatus());
+                kwpSettlementWallet.setChannel(WalletChannelEnum.getValue(byId.getTrading()));
+                kwpSettlementWallet.setPayTime(LocalDateTime.now());
+                kwpSettlementWallet.setPayPrice(byId.getTotalPrice());
+                kwpSettlementWallet.setTopayPrice(new BigDecimal("0.0"));
+                kwpSettlementWallet.setType(SettlementWalletPayTypeEnum.ADVANCE_PAYMENT.getStatus());
+                kwpSettlementWallet.setRemark("");
+                kwpSettlementWallet.setStatus(0);
+                kwpSettlementWallet.setCreateBy(LoginUserHolder.getUserId());
+                kwpSettlementWallet.setCreateTime(LocalDateTime.now());
+                kwpSettlementWallet.setUpdateBy(LoginUserHolder.getUserId());
+                kwpSettlementWallet.setUpdateTime(LocalDateTime.now());
+                kwpSettlementWallet.setDelFlag(0);
+                settlementWalletMapper.insert(kwpSettlementWallet);
+                settlementTradeTrackService.save(KwpSettlementTradeTrack.build(byId.getId(), SettlementTrackEnum.PRE_PAY.getStatus()));
+                //todo-xcq 调用中台接口
+                //todo-xcq 调用订单接口,更新订单状态
+                return "确认回款成功";
+            } finally {
+                redisLockUtil.unlock(key);
+            }
+        }
+        return "请勿重复提交!";
 
-    public Integer confirmTradeCollection(Long id, Float price) {
-        log.info("接收到数据,开始物流-销售-收款确认-预付款(电子钱包)-新增,待完善");
-        //todo 待完善
-        //先查询出结算单情况
-
-        //检查结算单状态和所差金额
-
-        //对比金额
-
-        //累加入库结算单
-
-        //扣费电子钱包
+    }
 
-        //新增电子钱包结算记录
-        KwpSettlementWallet kwpSettlementWallet = new KwpSettlementWallet();
-        kwpSettlementWallet.setId(new IdWorker(1).nextId());
-        //todo 待完善
-        settlementWalletMapper.insert(kwpSettlementWallet);
-        return settlementWalletMapper.confirmLogisticsPayment(id, price);
+    /**
+     * 电子钱包余额
+     *
+     * @param id
+     * @return
+     */
+    public BigDecimal getConfirmTradePayment(Long id) {
+        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() != 2) {
+            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 BigDecimal.valueOf(data.get(0).getMoney() / 100.0);
     }
 }
 

+ 1 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/utils/CommonValidator.java

@@ -38,7 +38,7 @@ public class CommonValidator {
         return startMatcher.matches() && endMatcher.matches();
     }
 
-    public static void isValidCoexisting(LocalDateTime startCreateTime, LocalDateTime endCreateTime, String msg) {
+    public static void isValidCoexisting(String startCreateTime, String endCreateTime, String msg) {
         if (!((startCreateTime == null && endCreateTime == null) || (startCreateTime != null && endCreateTime != null))) {
             throw new BusinessException("请正确填写" + (StringUtils.isNotBlank(msg) ? msg : "开始和结束时间"));
         }

+ 17 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/utils/DecimalUtils.java

@@ -0,0 +1,17 @@
+package com.sckw.payment.utils;
+
+import java.math.BigDecimal;
+import java.util.Objects;
+
+/**
+ * @author xucaiqin
+ * @date 2023-07-31 15:25:57
+ */
+public class DecimalUtils {
+    public static BigDecimal add(BigDecimal one,BigDecimal two){
+        if(Objects.isNull(one)&&Objects.isNull(two)){
+            return null;
+        }
+        return null;
+    }
+}

+ 3 - 0
sckw-modules/sckw-payment/src/main/resources/META-INF/MANIFEST.MF

@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: com.sckw.payment.PaymentApplication
+

+ 1 - 1
sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerLogisticsMapper.xml

@@ -11,7 +11,7 @@
         <result column="start_time" jdbcType="TIMESTAMP" property="startTime"/>
         <result column="end_time" jdbcType="TIMESTAMP" property="endTime"/>
         <result column="tax_rate" jdbcType="INTEGER" property="taxRate"/>
-        <result column="trading" jdbcType="INTEGER" property="trading"/>
+        <result column="trading" jdbcType="VARCHAR" property="trading"/>
         <result column="total_price" jdbcType="DECIMAL" property="totalPrice"/>
         <result column="ex_tax_price" jdbcType="DECIMAL" property="exTaxPrice"/>
         <result column="settle_price" jdbcType="DECIMAL" property="settlePrice"/>

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików