Просмотр исходного кода

Merge branch 'dev' into dev_spt

# Conflicts:
#	sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpSettlementWalletController.java
#	sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementOfflineService.java
#	sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementWalletService.java
sptkw 2 лет назад
Родитель
Сommit
84bfdf30fb
78 измененных файлов с 1992 добавлено и 414 удалено
  1. 13 0
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/exception/GlobalSystemExceptionHandler.java
  2. 9 0
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/model/enums/CarWaybillEnum.java
  3. 22 22
      sckw-common/sckw-common-redis/src/main/java/com/sckw/redis/config/RedisLockUtil.java
  4. 4 0
      sckw-common/sckw-common-redis/src/main/java/com/sckw/redis/constant/RedisConstant.java
  5. 2 1
      sckw-common/sckw-common-redis/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
  6. 73 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/controller/KwpWantBuyController.java
  7. 11 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/dao/KwpWantBuyMapper.java
  8. 5 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/dao/KwpWantBuyTradingMapper.java
  9. 78 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/req/UpdateWantBuyParam.java
  10. 24 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/req/WantBuyDels.java
  11. 75 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/req/WantBuySelectParam.java
  12. 30 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/res/TableTopRes.java
  13. 5 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/res/WantBuyDetailRes.java
  14. 93 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/res/WantBuySelectRes.java
  15. 20 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/res/WantBuyTradingRes.java
  16. 22 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwoWantBuyAddressService.java
  17. 33 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwoWantBuyTradingService.java
  18. 468 3
      sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwpWantBuyService.java
  19. 118 0
      sckw-modules/sckw-order/src/main/resources/mapper/KwoWantBuyMapper.xml
  20. 36 0
      sckw-modules/sckw-order/src/main/resources/mapper/KwoWantBuyTradingMapper.xml
  21. 4 4
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpLedgerLogisticsController.java
  22. 11 7
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpLedgerTradeController.java
  23. 8 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpSettlementTradeController.java
  24. 25 9
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpSettlementWalletController.java
  25. 1 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpLedgerTradeMapper.java
  26. 8 4
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementTradeMapper.java
  27. 1 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpLedgerLogistics.java
  28. 1 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpLedgerTrade.java
  29. 18 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpSettlementTradeTrack.java
  30. 4 5
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpSettlementWallet.java
  31. 3 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/constant/SettlementTrackEnum.java
  32. 0 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/constant/SettlementWalletPayTypeEnum.java
  33. 30 12
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/constant/WalletChannelEnum.java
  34. 2 2
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/ILedger.java
  35. 2 2
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/ISettlement.java
  36. 5 3
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/LedgerCarrierDto.java
  37. 1 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/LedgerLogisticsDto.java
  38. 1 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/LedgerPurchaseDto.java
  39. 1 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/LedgerSellDto.java
  40. 1 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/LedgerShipperDto.java
  41. 1 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/LedgerTradeDto.java
  42. 18 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/LedgerUnitDto.java
  43. 1 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/SettlementPurchaseDto.java
  44. 6 5
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/SettlementSellDto.java
  45. 181 32
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/SettlementTradeDto.java
  46. 1 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/LogisticsReq.java
  47. 1 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/LogisticsSendReq.java
  48. 5 7
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/SettlementOfflinePayReq.java
  49. 1 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/SettlementOfflineReq.java
  50. 7 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/SettlementTradeReq.java
  51. 2 2
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/SettlementWalletReq.java
  52. 1 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/TradeReq.java
  53. 1 2
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/TradeSendReq.java
  54. 29 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/WalletPayReq.java
  55. 1 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/LedgerLogisticsDetailVo.java
  56. 1 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/LedgerTradeDetailVo.java
  57. 2 2
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerLogisticsService.java
  58. 8 6
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerTradeService.java
  59. 85 49
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementOfflineService.java
  60. 9 9
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementTradeService.java
  61. 7 7
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementWalletService.java
  62. 17 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/utils/DecimalUtils.java
  63. 1 1
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerLogisticsMapper.xml
  64. 29 4
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerTradeMapper.xml
  65. 2 2
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementOfflineMapper.xml
  66. 15 0
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementTradeMapper.xml
  67. 3 3
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementWalletMapper.xml
  68. 2 2
      sckw-modules/sckw-report/src/main/java/com/sckw/report/service/KwTransportService.java
  69. 18 1
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/ConsignOrderController.java
  70. 47 9
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/LogisticsConsignmentController.java
  71. 8 8
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/WaybillManagementController.java
  72. 15 5
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/dao/KwtLogisticsOrderMapper.java
  73. 5 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/SubcontractConsignmentVO.java
  74. 1 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/AcceptCarriageOrderService.java
  75. 61 85
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/ConsignOrderService.java
  76. 85 32
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/LogisticsConsignmentService.java
  77. 20 45
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/WaybillManagementService.java
  78. 27 4
      sckw-modules/sckw-transport/src/main/resources/mapper/KwtLogisticsOrderMapper.xml

+ 13 - 0
sckw-common/sckw-common-core/src/main/java/com/sckw/core/exception/GlobalSystemExceptionHandler.java

@@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.bind.annotation.RestControllerAdvice;
 
 import java.util.List;
+import java.util.Objects;
 import java.util.Set;
 
 @Slf4j
@@ -116,6 +117,18 @@ public class GlobalSystemExceptionHandler {
     @ExceptionHandler(Exception.class)
     public HttpResult defaultExceptionHandler(Exception ex) {
         log.error("系统异常", ex);
+        Throwable cause = ex.getCause();
+        int i = 5;
+        do {
+            i--;
+            if (Objects.isNull(cause)) {
+                break;
+            }
+            cause = cause.getCause();
+            if (cause instanceof BusinessException be) {
+                return HttpResult.error(be.getMsg());
+            }
+        } while (cause != null || i > 0);
         return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, HttpStatus.GLOBAL_EXCEPTION_MESSAGE);
     }
 

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

+ 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;
+        }
     }
 
+
     /**
      * 解锁
      *

+ 4 - 0
sckw-common/sckw-common-redis/src/main/java/com/sckw/redis/constant/RedisConstant.java

@@ -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

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

@@ -3,12 +3,17 @@ package com.sckw.order.controller;
 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;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.HashMap;
+import java.util.List;
+
 /**
  * @desc: 求购controller
  * @author: yzc
@@ -21,6 +26,26 @@ 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)
+    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)
+    public HttpResult buyHallList(@RequestBody WantBuySelectParam wantBuySelectParam) {
+        return HttpResult.ok(kwpWantBuyService.buyHallList(wantBuySelectParam));
+    }
+
     /**
      * @desc: 新增求购草稿
      * @author: yzc
@@ -47,6 +72,39 @@ public class KwpWantBuyController {
         return HttpResult.ok("新增求购上架成功");
     }
 
+    /**
+     * @desc: 求购上架
+     * @Author: lt
+     * @Date: 13:39 2023/7/25 0025
+    **/
+    @GetMapping(value = "/putOnShelves", produces = MediaType.APPLICATION_JSON_VALUE)
+    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)
+    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)
+    public HttpResult dels(@RequestBody WantBuyDels ids) {
+        kwpWantBuyService.dels(ids);
+        return HttpResult.ok("批量删除成功");
+    }
+
     /**
      * @desc: 求购详情
      * @author: yzc
@@ -59,10 +117,25 @@ public class KwpWantBuyController {
         return HttpResult.ok(kwpWantBuyService.detail(id));
     }
 
+    /**
+     * @desc: 求购编辑
+     * @author lt
+     * @Date 15:22 2023/7/26 0026
+    **/
     @PostMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
     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)
+    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);
+
 }

+ 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 areaCode;
+
+    /**
+     * 地区级别
+     */
+    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);
+    }
+
 
 
 }

+ 468 - 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,463 @@ 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);
+        System.out.println(wantBuyDto);
+        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(","));
+        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;
     }
 }

+ 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.areaCode != null and wantBuyReq.areaCode != ''">
+            and kba.city_code = #{wantBuyReq.areaCode}
+        </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));
     }
 
     /**

+ 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())) {

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

@@ -5,17 +5,23 @@ 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;
+
 /**
  * 结算-电子钱包结算记录(交易订单结算/物流订单结算)
  *
  * @author Aick Spt
  * @date 2023-07-20 14:42
  */
+@Validated
 @RestController
 @RequestMapping(name = "结算-电子钱包结算记录", path = "/kwpSettlementWallet")
 public class KwpSettlementWalletController {
@@ -61,13 +67,23 @@ public class KwpSettlementWalletController {
     }
 
     /**
-     * 采购-货到付款
+     * 采购-货到付款-查询钱包余额
+     *
+     * @param id 结算单id
      * @author Aick Spt
      * @date 2023-07-25 09:55
      */
-    @GetMapping(name = "销售-付款确认-(新增电子钱包记录-采购货到付款)", path = "confirmTradePayment")
-    public HttpResult confirmTradePayment(@RequestBody @Valid OfflinePaymentReq offlinePaymentReq) {
-        return HttpResult.ok(kwpSettlementWalletService.confirmTradePayment(offlinePaymentReq));
+    @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));
     }
 
     /**
@@ -85,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);
 

+ 8 - 4
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementTradeMapper.java

@@ -2,6 +2,7 @@ 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;
@@ -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);
+    SettlementLogisticsStatusCountVo 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;
 
     /**
      * 总应收/元

+ 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;
 
     /**
      * 回款时间

+ 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/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;
     /**
      * 总应收/元
      */

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

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

@@ -16,7 +16,7 @@ public class SettlementOfflineReq extends BasePara {
      * 结算单id
      */
     @NotBlank(message = "结算单id不能为空")
-    private String settlementId;
+    private String id;
 
     /**
      * 订单类型 1-物流 2-贸易

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

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

@@ -77,8 +77,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)));
 

+ 8 - 6
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpLedgerTradeService.java

@@ -73,8 +73,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 +201,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,8 +444,9 @@ public class KwpLedgerTradeService extends AbsLedger {
         return "对账完成";
     }
 
-    public List<LedgerCountVo> orderCount(Integer unitType) {
-        Map<String, Long> map = tradeMapper.countOrder(LoginUserHolder.getEntId(), unitType);
+    public List<LedgerCountVo> orderCount(TradeReq tradeReq) {
+        tradeReq.setEntId(LoginUserHolder.getEntId());
+        Map<String, Long> map = tradeMapper.countOrder(tradeReq);
         LedgerCountVo ledgerCountVo;
         List<LedgerCountVo> res = new ArrayList<>();
         for (LedgerEnum value : LedgerEnum.values()) {
@@ -472,7 +474,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 +502,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());

+ 85 - 49
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementOfflineService.java

@@ -16,6 +16,10 @@ 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;
@@ -25,10 +29,13 @@ 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;
@@ -54,8 +61,12 @@ 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;
@@ -254,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("实际付款金额大于剩余待付款金额");
-        }
-        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);
+        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);
 
-        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);
 
-        settlementOfflineMapper.insert(kwpSettlementOffline);
-        return "";
+                //记录表记录数据
+                settlementTradeTrackService.save(KwpSettlementTradeTrack.build(byId.getId(), SettlementTrackEnum.OFFLINE_PAY.getStatus()));
+
+                //中台接口 todo-xcq
+                return "确认回款成功";
+            } finally {
+                redisLockUtil.unlock(key);
+            }
+        }
+        return "请勿重复提交";
     }
 }

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

@@ -11,10 +11,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 +38,11 @@ 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 +53,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());
             }
@@ -114,7 +114,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) {

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

@@ -5,23 +5,19 @@ 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.web.context.LoginUserHolder;
 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.KwpSettlementLogisticsTrack;
 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.SettlementPayTypeEnum;
+import com.sckw.payment.model.constant.SettlementWalletPayTypeEnum;
 import com.sckw.payment.model.constant.WalletChannelEnum;
 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.res.SettlementWalletVo;
 import com.sckw.system.api.RemoteSystemService;
@@ -58,9 +54,13 @@ 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;
 

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

+ 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"/>

+ 29 - 4
sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerTradeMapper.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"/>
@@ -188,9 +188,34 @@
                count(IF(klt.status = 6, 1, NULL)) "6"
         FROM kwp_ledger_trade klt
                  inner join kwp_ledger_trade_unit kltu on klt.id = kltu.t_ledger_id and kltu.del_flag = 0
-        WHERE klt.del_flag = 0
-          and kltu.unit_type = #{unitType,jdbcType=INTEGER}
-          and kltu.ent_id = #{entId,jdbcType=BIGINT}
+        <where>
+            klt.del_flag = 0
+              and kltu.unit_type = #{tradeReq.unitType,jdbcType=INTEGER}
+              and kltu.top_ent_id = #{tradeReq.entId,jdbcType=BIGINT}
+            <if test="tradeReq.status != null">
+                and klt.status = #{tradeReq.status}
+            </if>
+            <if test="tradeReq.trading != null">
+                and klt.trading = #{tradeReq.trading,jdbcType=INTEGER}
+            </if>
+            <if test="tradeReq.endCreateTime != null and tradeReq.endCreateTime != '' and tradeReq.startCreateTime != null and tradeReq.startCreateTime != ''">
+                and klt.generate_time between #{tradeReq.startCreateTime,jdbcType=TIMESTAMP}
+                    and #{tradeReq.endCreateTime,jdbcType=TIMESTAMP}
+            </if>
+            <if test="tradeReq.keywords != null and tradeReq.keywords != ''">
+                and (
+                            klt.t_ledger_no like concat('%'
+                            , #{tradeReq.keywords,jdbcType=VARCHAR}
+                            , '%')
+                        or kltu.firm_name like concat('%'
+                        , #{tradeReq.keywords,jdbcType=VARCHAR}
+                        , '%')
+                        or kltu.contacts like concat('%'
+                        , #{tradeReq.keywords,jdbcType=VARCHAR}
+                        , '%')
+                    )
+            </if>
+        </where>
     </select>
 
     <select id="selectSellIds" resultType="com.sckw.payment.model.dto.LedgerSellDto">

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

@@ -57,8 +57,8 @@
             <if test="offlineReq.orderType != null">
                 and order_type = #{offlineReq.orderType,jdbcType=INTEGER}
             </if>
-            <if test="offlineReq.settlementId != null">
-                and settlement_id = #{offlineReq.settlementId,jdbcType=INTEGER}
+            <if test="offlineReq.id != null and offlineReq.id != ''">
+                and settlement_id = #{offlineReq.id,jdbcType=INTEGER}
             </if>
         </where>
     </select>

+ 15 - 0
sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementTradeMapper.xml

@@ -137,6 +137,7 @@
             <foreach collection="ids" open="(" close=")" item="item">
                 #{item,jdbcType=BIGINT}
             </foreach>
+            and kltu.unit_type = #{unitType,jdbcType=INTEGER}
         </where>
     </select>
     <select id="getById" resultType="com.sckw.payment.model.dto.SettlementTradeDto">
@@ -159,6 +160,20 @@
         from kwp_settlement_trade kst
                  inner join kwp_ledger_trade klt on kst.t_ledger_id = klt.id and klt.del_flag = 0
                  inner join kwp_ledger_trade_unit kltu on klt.id = kltu.t_ledger_id and kltu.del_flag = 0
+        <where>
+            kst.del_flag = 0
+              and kst.id = #{id,jdbcType=BIGINT}
+            and kltu.unit_type = #{unitType,jdbcType=INTEGER}
+        </where>
+    </select>
+
+    <select id="getListById" resultType="com.sckw.payment.model.dto.LedgerUnitDto">
+        select kltu.top_ent_id,
+               kltu.ent_id,
+               kltu.unit_type
+        from kwp_settlement_trade kst
+                 inner join kwp_ledger_trade klt on kst.t_ledger_id = klt.id and klt.del_flag = 0
+                 inner join kwp_ledger_trade_unit kltu on klt.id = kltu.t_ledger_id and kltu.del_flag = 0
         <where>
             kst.del_flag = 0
               and kst.id = #{id,jdbcType=BIGINT}

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

@@ -8,7 +8,7 @@
         <result column="ent_id" jdbcType="BIGINT" property="entId"/>
         <result column="settlement_id" jdbcType="BIGINT" property="settlementId"/>
         <result column="order_type" jdbcType="INTEGER" property="orderType"/>
-        <result column="channel" jdbcType="BOOLEAN" property="channel"/>
+        <result column="channel" jdbcType="VARCHAR" property="channel"/>
         <result column="pay_time" jdbcType="TIMESTAMP" property="payTime"/>
         <result column="pay_price" jdbcType="DECIMAL" property="payPrice"/>
         <result column="topay_price" jdbcType="DECIMAL" property="topayPrice"/>
@@ -101,8 +101,8 @@
         from kwp_settlement_wallet ksw
         <where>
             ksw.del_flag = 0
-            <if test="walletReq.settlementId != null and walletReq.settlementId != ''">
-                and ksw.settlement_id = #{walletReq.settlementId,jdbcType=INTEGER}
+            <if test="walletReq.id != null and walletReq.id != ''">
+                and ksw.settlement_id = #{walletReq.id,jdbcType=INTEGER}
             </if>
             <if test="walletReq.orderType != null">
                 and ksw.order_type = #{walletReq.orderType,jdbcType=INTEGER}

+ 2 - 2
sckw-modules/sckw-report/src/main/java/com/sckw/report/service/KwTransportService.java

@@ -251,7 +251,7 @@ public class KwTransportService {
         List<TableTops> list = new ArrayList<>();
         TableTops topTotal = new TableTops();
         topTotal.setName("全部");
-        topTotal.setValue(null);
+        topTotal.setValue("all");
         topTotal.setTotal(0);
         list.add(topTotal);
 
@@ -442,7 +442,7 @@ public class KwTransportService {
             Long settlementCycle1 = logisticsOrder.getSettlementCycle();
             String billingMode = logisticsOrder.getBillingMode();
             SysDictResDto sysDictResDto = chargingType.get(String.valueOf(settlementCycle1));
-            SysDictResDto sysDictResDto1 = settlementCycle.get(String.valueOf(billingMode));
+            SysDictResDto sysDictResDto1 = settlementCycle.get(billingMode);
             if (Objects.nonNull(sysDictResDto)) {
                 logisticsOrder.setSettlementCycleLabel(sysDictResDto.getLabel());
             }

+ 18 - 1
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/ConsignOrderController.java

@@ -46,6 +46,23 @@ public class ConsignOrderController {
         }
     }
 
+    /**
+     * 托运订单/承运订单-获取车辆运单-统计
+     *
+     * @param orderDto
+     * @return
+     */
+    @RequestMapping(value = "/getCarWaybillByOrderCount", method = RequestMethod.POST)
+    public HttpResult getCarWaybillByOrderCount(@Validated @RequestBody OrderDTO orderDto) {
+        try {
+            return consignOrderService.getCarWaybillByOrderCount(orderDto);
+        } catch (Exception e) {
+            log.error("托运订单获取车辆运单失败:订单id {},error {} ", orderDto.getId(), e.getMessage(), e);
+            return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, e.getMessage());
+        }
+    }
+
+
     /**
      * 托运订单查看驳回原因
      *
@@ -66,7 +83,7 @@ public class ConsignOrderController {
     @RequestMapping(value = "/getCarListByOrder", method = RequestMethod.POST)
     public HttpResult getCarListByOrder(@Validated @RequestBody OrderDTO orderDto) {
         try {
-            return consignOrderService.getCarListByOrder(orderDto);
+            return consignOrderService.getCarListByOrder(orderDto,"1");
         } catch (Exception e) {
             log.error("托运订单获取车辆运单失败:订单id {},error {} ", orderDto.getId(), e.getMessage(), e);
             return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, e.getMessage());

+ 47 - 9
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/LogisticsConsignmentController.java

@@ -57,14 +57,31 @@ public class LogisticsConsignmentController {
      * @param id 销售订单id
      * @return
      */
-    @Validated
     @RequestMapping(value = "/purchaseLogisticsOrder", method = RequestMethod.GET)
     public HttpResult purchaseLogisticsOrder(@RequestParam("id") @NotBlank(message = "单据id不能为空") String id,
-                                             @RequestParam("page") @NotBlank(message = "当前页不能为空") int page,
-                                             @RequestParam("pageSize") @NotBlank(message = "每页条数不能为空") int pageSize) {
+                                             @RequestParam("page") @NotNull(message = "当前页不能为空") int page,
+                                             @RequestParam("pageSize") @NotNull(message = "每页条数不能为空") int pageSize) {
+        log.info("采购订单-托运订单列表 传递参数信息:{}", id);
+        try {
+            return logisticsConsignmentService.logisticsOrder(id, page, pageSize, "1");
+        } catch (Exception e) {
+            log.error("采购订单-托运订单列表 error :{}", e.getMessage(), e);
+            return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, e.getMessage());
+        }
+    }
+
+    /**
+     * 采购订单-托运订单列表-下方数据统计-贸易订单id
+     *
+     * @param id 贸易订单id
+     * @return
+     */
+    @Validated
+    @RequestMapping(value = "/purchaseLogisticsOrderCount", method = RequestMethod.GET)
+    public HttpResult purchaseLogisticsOrderCount(@RequestParam("id") @NotBlank(message = "单据id不能为空") String id) {
         log.info("采购订单-托运订单列表 传递参数信息:{}", id);
         try {
-            return logisticsConsignmentService.logisticsOrder(id, page, pageSize);
+            return logisticsConsignmentService.logisticsOrderCount(id,"1");
         } catch (Exception e) {
             log.error("采购订单-托运订单列表 error :{}", e.getMessage(), e);
             return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, e.getMessage());
@@ -103,18 +120,19 @@ public class LogisticsConsignmentController {
     public HttpResult purchaseLogisticsCar(@RequestParam("id") @NotBlank(message = "单据id不能为空") String id,
                                            @RequestParam("page") @NotBlank(message = "当前页不能为空") int page,
                                            @RequestParam("pageSize") @NotBlank(message = "每页条数不能为空") int pageSize) {
-        log.info("采购订单-托运订单列表 传递参数信息:{}", id);
+        log.info("采购订单-车辆详情 传递参数信息:{}", id);
         try {
             return logisticsConsignmentService.purchaseLogisticsCar(id, page, pageSize);
         } catch (Exception e) {
-            log.error("采购订单-托运订单列表 error :{}", e.getMessage(), e);
+            log.error("采购订单-车辆详情 error :{}", e.getMessage(), e);
             return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, e.getMessage());
         }
     }
 
     /**
      * 采购订单-托运订单列表-订单完结-数据查询
-     * @param orderId   物流订单id
+     *
+     * @param orderId 物流订单id
      * @return
      */
     @Validated
@@ -131,6 +149,7 @@ public class LogisticsConsignmentController {
 
     /**
      * 采购订单-托运订单列表-完结订单
+     *
      * @param OrderFinishDTO
      * @return
      */
@@ -176,13 +195,30 @@ public class LogisticsConsignmentController {
                                          @RequestParam("pageSize") @NotBlank(message = "每页条数不能为空") int pageSize) {
         log.info("销售订单-托运订单列表 传递参数信息:{}", id);
         try {
-            return logisticsConsignmentService.logisticsOrder(id, page, pageSize);
+            return logisticsConsignmentService.logisticsOrder(id, page, pageSize, "2");
         } catch (Exception e) {
             log.error("销售订单-托运订单列表 error :{}", e.getMessage(), e);
             return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, e.getMessage());
         }
     }
 
+    /**
+     * 销售订单-托运订单列表-下方数据统计-贸易订单id
+     *
+     * @param id 贸易订单id
+     * @return
+     */
+    @Validated
+    @RequestMapping(value = "/sellLogisticsOrderCount", method = RequestMethod.GET)
+    public HttpResult sellLogisticsOrderCount(@RequestParam("id") @NotBlank(message = "单据id不能为空") String id) {
+        log.info("销售订单-托运订单列表 传递参数信息:{}", id);
+        try {
+            return logisticsConsignmentService.logisticsOrderCount(id,"2");
+        } catch (Exception e) {
+            log.error("销售订单-托运订单列表 error :{}", e.getMessage(), e);
+            return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, e.getMessage());
+        }
+    }
     /**
      * 销售订单-车辆列表-销售订单id
      *
@@ -222,7 +258,8 @@ public class LogisticsConsignmentController {
 
     /**
      * 销售订单-托运订单列表-订单完结-数据查询
-     * @param orderId   物流订单id
+     *
+     * @param orderId 物流订单id
      * @return
      */
     @Validated
@@ -239,6 +276,7 @@ public class LogisticsConsignmentController {
 
     /**
      * 销售订单-托运订单列表-完结订单
+     *
      * @param orderFinishDTO
      * @return
      */

+ 8 - 8
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/WaybillManagementController.java

@@ -9,10 +9,10 @@ import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.List;
 
 
 /**
@@ -40,8 +40,8 @@ public class WaybillManagementController {
         }
     }
 
-    @RequestMapping(name = "运单看板", value = "/waybillIndex", method = RequestMethod.GET)
-    public HttpResult waybillIndex(WaybillOrderDTO waybillOrderDTO) {
+    @RequestMapping(name = "运单看板", value = "/waybillIndex", method = RequestMethod.POST)
+    public HttpResult waybillIndex(@Validated @RequestBody WaybillOrderDTO waybillOrderDTO) {
         try {
             return waybillManagementService.waybillIndex(waybillOrderDTO);
         } catch (Exception e) {
@@ -50,8 +50,8 @@ public class WaybillManagementController {
         }
     }
 
-    @RequestMapping(name = "运单看板TOP", value = "/waybillIndexStatistics", method = RequestMethod.GET)
-    public HttpResult waybillIndexStatistics(WaybillOrderDTO waybillOrderDTO) {
+    @RequestMapping(name = "运单看板TOP", value = "/waybillIndexStatistics", method = RequestMethod.POST)
+    public HttpResult waybillIndexStatistics(@Validated @RequestBody WaybillOrderDTO waybillOrderDTO) {
         try {
             return waybillManagementService.waybillIndexStatistics(waybillOrderDTO);
         } catch (Exception e) {

+ 15 - 5
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/dao/KwtLogisticsOrderMapper.java

@@ -9,7 +9,6 @@ import com.sckw.transport.model.param.LogisticsOrderParam;
 import com.sckw.transport.model.vo.DriverListVo;
 import com.sckw.transport.model.vo.OrderFinishVO;
 import com.sckw.transport.model.vo.SubcontractConsignmentVO;
-import com.sckw.transport.model.vo.WaybillCountVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -52,14 +51,23 @@ public interface KwtLogisticsOrderMapper extends BaseMapper<KwtLogisticsOrder> {
      * @param id
      * @return
      */
-    List<com.sckw.transport.model.dto.LogisticsOrderDTO> selectOrderList(@Param("id") String id,@Param("page") int page,@Param("pageSize") int pageSize);
+    List<com.sckw.transport.model.dto.LogisticsOrderDTO> selectOrderList(@Param("id") String id, @Param("page") int page,
+                                                                         @Param("pageSize") int pageSize,@Param("type") String type);
 
     /**
+     * 销售订单-采购订单-托运列表-数据统计
      *
      * @param id
      * @return
      */
-    Long selectOrderCount(@Param("id") String id);
+    List<com.sckw.transport.model.dto.LogisticsOrderDTO> selectOrderCountByTorderId(@Param("id") String id, @Param("type") String type);
+
+    /**
+     * @param id   贸易订单id
+     * @param type 采购单1/销售单2
+     * @return
+     */
+    Long selectOrderCount(@Param("id") String id, @Param("type") String type);
 
     /**
      * @param logisticsOrderParam
@@ -68,10 +76,11 @@ public interface KwtLogisticsOrderMapper extends BaseMapper<KwtLogisticsOrder> {
      */
     Long selectLogisticOrderCount(@Param("logisticsOrderParam") LogisticsOrderParam logisticsOrderParam, @Param("dictId") Long dictId);
 
-    Map<String, String> getRejectReason(@Param("id") String id,@Param("status") String status);
+    Map<String, String> getRejectReason(@Param("id") String id, @Param("status") String status);
 
     /**
      * 根据承运订单id查看分包数据列表
+     *
      * @param lOrderId
      * @param page
      * @param pageSize
@@ -83,13 +92,13 @@ public interface KwtLogisticsOrderMapper extends BaseMapper<KwtLogisticsOrder> {
 
     /**
      * 通过物流订单查看单据下运力司机数据
+     *
      * @param driverParam
      * @return
      */
     List<DriverListVo> selectDriverListById(@Param("driverParam") DriverParam driverParam);
 
     /**
-     *
      * @param ids
      * @return
      */
@@ -97,6 +106,7 @@ public interface KwtLogisticsOrderMapper extends BaseMapper<KwtLogisticsOrder> {
 
     /**
      * 通过物流订单id获取统计数据
+     *
      * @param orderId
      * @return
      */

+ 5 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/SubcontractConsignmentVO.java

@@ -16,6 +16,11 @@ public class SubcontractConsignmentVO {
      * 状态
      */
     private String status;
+
+    /**
+     * 状态
+     */
+    private String statusLabel;
     /**
      * 数据库表主键id
      */

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

@@ -641,6 +641,7 @@ public class AcceptCarriageOrderService {
         Map<String, String> settlementDictData = getDictData(DictTypeEnum.SETTLEMENT_CYCLE.getType());
         if (CollectionUtils.isNotEmpty(list)) {
             for (SubcontractConsignmentVO subcontractConsignmentVO : list) {
+                subcontractConsignmentVO.setStatusLabel(CarWaybillEnum.getWaybillOrderDestination(subcontractConsignmentVO.getStatus()));
                 subcontractConsignmentVO.setPriceType(priceDictData == null ? null : priceDictData.get(subcontractConsignmentVO.getPriceType()));
                 subcontractConsignmentVO.setLossUnit(weightDictData == null ? null : weightDictData.get(subcontractConsignmentVO.getLossUnit()));
                 subcontractConsignmentVO.setGoodsPriceUnit(priceDictData == null ? null : priceDictData.get(subcontractConsignmentVO.getGoodsPriceUnit()));

+ 61 - 85
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/ConsignOrderService.java

@@ -18,7 +18,6 @@ import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.excel.utils.DateUtil;
 import com.sckw.fleet.api.RemoteFleetService;
-import com.sckw.fleet.api.model.vo.RTruckVo;
 import com.sckw.mongo.enums.BusinessTypeEnum;
 import com.sckw.mongo.model.SckwLogisticsOrder;
 import com.sckw.product.api.dubbo.GoodsInfoService;
@@ -44,8 +43,10 @@ import org.springframework.util.ObjectUtils;
 
 import java.math.BigDecimal;
 import java.text.ParseException;
-import java.util.*;
-import java.util.stream.Collectors;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
 
 /**
  * @author lfdc
@@ -113,9 +114,9 @@ public class ConsignOrderService {
     public HttpResult getCarWaybillByOrder(OrderDTO orderDto) {
         HttpResult httpResult = new HttpResult();
         if (String.valueOf(NumberConstant.ONE).equals(orderDto.getType())) {
-            httpResult = getCarWaybillByOrderByConsign(orderDto);
+            httpResult = getCarWaybillOrderByConsign(orderDto);
         } else if (String.valueOf(NumberConstant.TWO).equals(orderDto.getType())) {
-            httpResult = getCarWaybillByOrderByAcceptCarriage(orderDto);
+            httpResult = getCarWaybillOrderByAcceptCarriage(orderDto);
         } else {
             throw new RuntimeException("单据类型错误");
         }
@@ -131,9 +132,9 @@ public class ConsignOrderService {
     public HttpResult getCarWaybillByOrderCount(OrderDTO orderDto) {
         HttpResult httpResult = new HttpResult();
         if (String.valueOf(NumberConstant.ONE).equals(orderDto.getType())) {
-            httpResult = getCarWaybillByOrderByConsignCount(orderDto);
+            httpResult = getCarWaybillOrderByConsignCount(orderDto);
         } else if (String.valueOf(NumberConstant.TWO).equals(orderDto.getType())) {
-            httpResult = getCarWaybillByOrderByAcceptCarriageCount(orderDto);
+            httpResult = getCarWaybillOrderByAcceptCarriageCount(orderDto);
         } else {
             throw new RuntimeException("单据类型错误");
         }
@@ -146,7 +147,7 @@ public class ConsignOrderService {
      * @param orderDto
      * @return
      */
-    private HttpResult getCarWaybillByOrderByConsignCount(OrderDTO orderDto) {
+    private HttpResult getCarWaybillOrderByConsignCount(OrderDTO orderDto) {
         KwtLogisticsOrder order = kwtLogisticsOrderMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrder>()
                         .eq(StringUtils.isNotBlank(orderDto.getId()), KwtLogisticsOrder::getId, Long.parseLong(orderDto.getId()))
                         .eq(StringUtils.isNotBlank(orderDto.getOrderNo()), KwtLogisticsOrder::getLOrderNo, orderDto.getOrderNo())
@@ -161,31 +162,30 @@ public class ConsignOrderService {
         //合理损耗
         BigDecimal loss = order.getLoss();
         //派车量
-        BigDecimal sendCarWeighNumber = new BigDecimal(NumberConstant.ZERO);
+        BigDecimal sendCarWeighNumber = new BigDecimal("0.00");
         //装货量
-        BigDecimal loadAmountNumber = new BigDecimal(NumberConstant.ZERO);
+        BigDecimal loadAmountNumber = new BigDecimal("0.00");
         //卸货量
-        BigDecimal unloadAmountNumber = new BigDecimal(NumberConstant.ZERO);
+        BigDecimal unloadAmountNumber = new BigDecimal("0.00");
         /**亏吨量/吨->装货量-卸货量
-         扣亏量/吨->亏吨量-合理损耗*/
+         * 合理损耗值=已委托量*合理损耗
+         扣亏量/吨->亏吨量-合理损耗值 扣亏量/吨->亏吨量-合理损耗值(分配量(委托量)*合理损耗)*/
         //亏吨量
-        BigDecimal defectiveWeighNumber = new BigDecimal(NumberConstant.ZERO);
+        BigDecimal defectiveWeighNumber = new BigDecimal("0.00");
         //扣亏量/吨
-        BigDecimal deductWeighNumber = new BigDecimal(NumberConstant.ZERO);
+        BigDecimal deductWeighNumber = new BigDecimal("0.00");
         if (CollectionUtils.isNotEmpty(kwtWaybillOrders)) {
             for (KwtWaybillOrder kwtWaybillOrder : kwtWaybillOrders) {
                 CarWaybillVO carWaybillVo = new CarWaybillVO();
-                //扣亏量/吨->亏吨量-合理损耗值(分配量(委托量)*合理损耗)
-                BigDecimal deduct = null;
-                if (kwtWaybillOrder.getDeficitAmount() != null && (kwtWaybillOrder.getDeficitAmount().compareTo(new BigDecimal(NumberConstant.ZERO)) == NumberConstant.ZERO)) {
-                    deduct = kwtWaybillOrder.getDeficitAmount().subtract(order.getLoss() == null ? new BigDecimal(NumberConstant.ZERO) : order.getLoss());
-                }
                 carWaybillVo.setSendCarWeigh(kwtWaybillOrder.getEntrustAmount() == null ? null : String.valueOf(kwtWaybillOrder.getEntrustAmount()));
                 /**亏吨量/吨->装货量-卸货量
-                 扣亏量/吨->亏吨量*合理损耗*/
+                 * 合理损耗值=已委托量*合理损耗
+                 扣亏量/吨->亏吨量-合理损耗值*/
+                //合理损耗值=已委托量*合理损耗
+                BigDecimal multiply = kwtWaybillOrder.getEntrustAmount().multiply(loss.divide(BigDecimal.valueOf(1000L)));
                 carWaybillVo.setDefectiveWeigh(kwtWaybillOrder.getDeficitAmount() == null ? null : String.valueOf(kwtWaybillOrder.getDeficitAmount()));
                 carWaybillVo.setDeduct(kwtWaybillOrder.getDeficitAmount().compareTo(new BigDecimal(NumberConstant.ZERO)) == 0 ?
-                        new BigDecimal(NumberConstant.ZERO) : kwtWaybillOrder.getDeficitAmount().multiply(loss.divide(BigDecimal.valueOf(1000L))));
+                        new BigDecimal(NumberConstant.ZERO) : kwtWaybillOrder.getDeficitAmount().subtract(multiply));
                 sendCarWeighNumber = sendCarWeighNumber.add(kwtWaybillOrder.getLoadAmount());
                 if (carWaybillVo.getLoadAmount() != null) {
                     loadAmountNumber = loadAmountNumber.add(new BigDecimal(carWaybillVo.getLoadAmount()));
@@ -214,7 +214,7 @@ public class ConsignOrderService {
      * @param orderDto
      * @return
      */
-    private HttpResult getCarWaybillByOrderByAcceptCarriageCount(OrderDTO orderDto) {
+    private HttpResult getCarWaybillOrderByAcceptCarriageCount(OrderDTO orderDto) {
         KwtLogisticsOrder order = kwtLogisticsOrderMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrder>()
                         .eq(StringUtils.isNotBlank(orderDto.getId()), KwtLogisticsOrder::getId, Long.parseLong(orderDto.getId()))
                         .eq(StringUtils.isNotBlank(orderDto.getOrderNo()), KwtLogisticsOrder::getLOrderNo, orderDto.getOrderNo())
@@ -235,7 +235,7 @@ public class ConsignOrderService {
         //卸货量
         BigDecimal unloadAmountNumber = new BigDecimal(NumberConstant.ZERO);
         /**亏吨量/吨->装货量-卸货量
-         扣亏量/吨->亏吨量-合理损耗*/
+         扣亏量/吨->亏吨量-合理损耗 (扣亏量/吨->亏吨量-合理损耗值(分配量(委托量)*合理损耗))*/
         //亏吨量
         BigDecimal defectiveWeighNumber = new BigDecimal(NumberConstant.ZERO);
         //扣亏量/吨
@@ -243,17 +243,14 @@ public class ConsignOrderService {
         if (CollectionUtils.isNotEmpty(kwtWaybillOrders)) {
             for (KwtWaybillOrder kwtWaybillOrder : kwtWaybillOrders) {
                 CarWaybillVO carWaybillVo = new CarWaybillVO();
-                //扣亏量/吨->亏吨量-合理损耗值(分配量(委托量)*合理损耗)
-                BigDecimal deduct = null;
-                if (kwtWaybillOrder.getDeficitAmount() != null && (kwtWaybillOrder.getDeficitAmount().compareTo(new BigDecimal(NumberConstant.ZERO)) == NumberConstant.ZERO)) {
-                    deduct = kwtWaybillOrder.getDeficitAmount().subtract(order.getLoss() == null ? new BigDecimal(NumberConstant.ZERO) : order.getLoss());
-                }
                 carWaybillVo.setSendCarWeigh(kwtWaybillOrder.getEntrustAmount() == null ? null : String.valueOf(kwtWaybillOrder.getEntrustAmount()));
                 /**亏吨量/吨->装货量-卸货量
                  扣亏量/吨->亏吨量*合理损耗*/
+                BigDecimal multiply = kwtWaybillOrder.getEntrustAmount().multiply(loss.divide(BigDecimal.valueOf(1000L)));
                 carWaybillVo.setDefectiveWeigh(kwtWaybillOrder.getDeficitAmount() == null ? null : String.valueOf(kwtWaybillOrder.getDeficitAmount()));
                 carWaybillVo.setDeduct(kwtWaybillOrder.getDeficitAmount().compareTo(new BigDecimal(NumberConstant.ZERO)) == 0 ?
-                        new BigDecimal(NumberConstant.ZERO) : kwtWaybillOrder.getDeficitAmount().multiply(loss.divide(BigDecimal.valueOf(1000L))));
+                        new BigDecimal(NumberConstant.ZERO) : kwtWaybillOrder.getDeficitAmount().subtract(multiply));
+                sendCarWeighNumber = sendCarWeighNumber.add(kwtWaybillOrder.getLoadAmount());
                 sendCarWeighNumber = sendCarWeighNumber.add(kwtWaybillOrder.getLoadAmount());
                 if (carWaybillVo.getLoadAmount() != null) {
                     loadAmountNumber = loadAmountNumber.add(new BigDecimal(carWaybillVo.getLoadAmount()));
@@ -282,7 +279,7 @@ public class ConsignOrderService {
      * @param orderDto
      * @return
      */
-    private HttpResult getCarWaybillByOrderByAcceptCarriage(OrderDTO orderDto) {
+    private HttpResult getCarWaybillOrderByAcceptCarriage(OrderDTO orderDto) {
         List<CarWaybillVO> returnList = new ArrayList<>();
         KwtLogisticsOrder order = kwtLogisticsOrderMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrder>()
                         .eq(StringUtils.isNotBlank(orderDto.getId()), KwtLogisticsOrder::getId, Long.parseLong(orderDto.getId()))
@@ -293,12 +290,8 @@ public class ConsignOrderService {
         }
         List<KwtWaybillOrder> kwtWaybillOrders = kwtWaybillOrderMapper.selectList(new LambdaQueryWrapper<KwtWaybillOrder>()
                         .eq(StringUtils.isNotBlank(order.getId()), KwtWaybillOrder::getLOrderId, order.getId())
+                        .last("limit " + (orderDto.getPage() - 1) + " , " + orderDto.getPageSize())
                 /**.eq(KwtWaybillOrder::getEntId, LoginUserHolder.getEntId())*/);
-        JSONObject statistics = new JSONObject();
-        BigDecimal sendCarWeighNumber = new BigDecimal(NumberConstant.ZERO);
-        BigDecimal loadAmountNumber = new BigDecimal(NumberConstant.ZERO);
-        BigDecimal unloadAmountNumber = new BigDecimal(NumberConstant.ZERO);
-        BigDecimal defectiveWeighNumber = new BigDecimal(NumberConstant.ZERO);
         if (CollectionUtils.isNotEmpty(kwtWaybillOrders)) {
             for (KwtWaybillOrder kwtWaybillOrder : kwtWaybillOrders) {
                 CarWaybillVO carWaybillVo = new CarWaybillVO();
@@ -308,9 +301,6 @@ public class ConsignOrderService {
                 KwtWaybillOrderTicket unloadTicket = kwtWaybillOrderTicketMapper.selectOne(new LambdaQueryWrapper<KwtWaybillOrderTicket>()
                         .eq(StringUtils.isNotBlank(kwtWaybillOrder.getId()), KwtWaybillOrderTicket::getWOrderId, kwtWaybillOrder.getId())
                         .eq(KwtWaybillOrderTicket::getType, NumberConstant.TWO));
-                KwtLogisticsOrderCirculate circulate = kwtLogisticsOrderCirculateMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderCirculate>()
-                        .eq(StringUtils.isNotBlank(kwtWaybillOrder.getId()), KwtLogisticsOrderCirculate::getLOrderId, kwtWaybillOrder.getId())
-                        .eq(KwtLogisticsOrderCirculate::getEntId, order.getEntId()));
                 //扣亏量/吨->亏吨量-合理损耗
                 BigDecimal deduct = null;
                 if (kwtWaybillOrder.getDeficitAmount() != null && (kwtWaybillOrder.getDeficitAmount().compareTo(new BigDecimal(NumberConstant.ZERO)) == NumberConstant.ZERO)) {
@@ -319,7 +309,7 @@ public class ConsignOrderService {
                 carWaybillVo.setWOrderId(String.valueOf(kwtWaybillOrder.getId()));
                 carWaybillVo.setWOrderNo(order.getLOrderNo());
                 carWaybillVo.setTruckNo(kwtWaybillOrder.getTruckNo());
-                carWaybillVo.setStatus(String.valueOf(kwtWaybillOrder.getStatus()));
+                carWaybillVo.setStatus(CarWaybillEnum.getName(kwtWaybillOrder.getStatus()));
                 carWaybillVo.setWaybillType(kwtWaybillOrder.getType());
                 carWaybillVo.setDriverName(kwtWaybillOrder.getDriverName());
                 //todo 取mongo
@@ -327,11 +317,7 @@ public class ConsignOrderService {
                 /** 2023-07-24 原值为承运车队-去除后更换展示为承运公司*/
 //                carWaybillVo.setConsignMotorcade(sckwWaybillOrder == null ? null : sckwWaybillOrder.getCarrierFirmName());
                 carWaybillVo.setSendCarWeigh(kwtWaybillOrder.getEntrustAmount() == null ? null : String.valueOf(kwtWaybillOrder.getEntrustAmount()));
-                if (circulate != null) {
-                    carWaybillVo.setSendCarDate(circulate.getCreateTime() == null ? null : DateUtil.getDateTime(circulate.getCreateTime()));
-                } else {
-                    carWaybillVo.setSendCarDate(null);
-                }
+                carWaybillVo.setSendCarDate(DateUtil.getDateTime(kwtWaybillOrder.getCreateTime()));
                 if (loadTicket != null) {
                     carWaybillVo.setLoadAmount(loadTicket.getAmount() == null ? null : String.valueOf(loadTicket.getAmount()));
                     carWaybillVo.setLoadDateTime(loadTicket.getCreateTime() == null ? null : DateUtil.getDateTime(loadTicket.getCreateTime()));
@@ -339,7 +325,6 @@ public class ConsignOrderService {
                     carWaybillVo.setLoadAmount(null);
                     carWaybillVo.setLoadDateTime(null);
                 }
-                carWaybillVo.setSendCarWeigh(kwtWaybillOrder.getEntrustAmount() == null ? null : String.valueOf(kwtWaybillOrder.getEntrustAmount()));
                 if (unloadTicket != null) {
                     carWaybillVo.setUnloadAmount(unloadTicket.getAmount() == null ? null : String.valueOf(unloadTicket.getAmount()));
                     carWaybillVo.setUnloadDateTime(unloadTicket.getCreateTime() == null ? null : DateUtil.getDateTime(unloadTicket.getCreateTime()));
@@ -353,27 +338,11 @@ public class ConsignOrderService {
                 carWaybillVo.setDeduct(deduct);
 //                carWaybillVo.setAppointor(remoteSystemService.queryUserCacheById(kwtWaybillOrder.getCreateBy()) == null ?
 //                        String.valueOf(kwtWaybillOrder.getCreateBy()) : remoteSystemService.queryUserCacheById(kwtWaybillOrder.getCreateBy()).getName());
-                if (carWaybillVo.getLoadAmount() != null) {
-                    loadAmountNumber = loadAmountNumber.add(new BigDecimal(carWaybillVo.getLoadAmount()));
-                }
-                if (carWaybillVo.getUnloadAmount() != null) {
-                    unloadAmountNumber = unloadAmountNumber.add(new BigDecimal(carWaybillVo.getUnloadAmount()));
-                }
-                if (carWaybillVo.getDefectiveWeigh() != null) {
-                    defectiveWeighNumber = defectiveWeighNumber.add(new BigDecimal(carWaybillVo.getDefectiveWeigh()));
-                }
                 returnList.add(carWaybillVo);
             }
         }
-        statistics.put("count", kwtWaybillOrders.size());
-        statistics.put("sendCarWeighNumber", sendCarWeighNumber);
-        statistics.put("loadAmountNumber", loadAmountNumber);
-        statistics.put("unloadAmountNumber", unloadAmountNumber);
-        statistics.put("defectiveWeighNumber", defectiveWeighNumber);
-        Map map = new HashMap<>(NumberConstant.SIXTEEN);
-        map.put("returnList", returnList);
-        map.put("statistics", statistics);
-        return HttpResult.ok(map);
+        PageResult result = PageResult.build(orderDto.getPage(), orderDto.getPageSize(), returnList.stream().count(), returnList);
+        return HttpResult.ok(result);
     }
 
 
@@ -383,7 +352,7 @@ public class ConsignOrderService {
      * @param orderDto
      * @return
      */
-    private HttpResult getCarWaybillByOrderByConsign(OrderDTO orderDto) {
+    private HttpResult getCarWaybillOrderByConsign(OrderDTO orderDto) {
         List<CarWaybillVO> returnList = new ArrayList<>();
         KwtLogisticsOrder order = kwtLogisticsOrderMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrder>()
                         .eq(StringUtils.isNotBlank(orderDto.getId()), KwtLogisticsOrder::getId, Long.parseLong(orderDto.getId()))
@@ -394,7 +363,7 @@ public class ConsignOrderService {
         }
         List<KwtWaybillOrder> kwtWaybillOrders = kwtWaybillOrderMapper.selectList(new LambdaQueryWrapper<KwtWaybillOrder>()
                         .eq(StringUtils.isNotBlank(order.getId()), KwtWaybillOrder::getLOrderId, order.getId())
-                        .last("limit" + (orderDto.getPage() - 1) + " , " + orderDto.getPageSize())
+                        .last("limit " + (orderDto.getPage() - 1) + " , " + orderDto.getPageSize())
                 /**.eq(KwtWaybillOrder::getEntId, LoginUserHolder.getEntId())*/);
         if (CollectionUtils.isNotEmpty(kwtWaybillOrders)) {
             for (KwtWaybillOrder kwtWaybillOrder : kwtWaybillOrders) {
@@ -405,9 +374,6 @@ public class ConsignOrderService {
                 KwtWaybillOrderTicket unloadTicket = kwtWaybillOrderTicketMapper.selectOne(new LambdaQueryWrapper<KwtWaybillOrderTicket>()
                         .eq(StringUtils.isNotBlank(kwtWaybillOrder.getId()), KwtWaybillOrderTicket::getWOrderId, kwtWaybillOrder.getId())
                         .eq(KwtWaybillOrderTicket::getType, NumberConstant.TWO));
-                KwtLogisticsOrderCirculate circulate = kwtLogisticsOrderCirculateMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderCirculate>()
-                        .eq(StringUtils.isNotBlank(kwtWaybillOrder.getId()), KwtLogisticsOrderCirculate::getLOrderId, kwtWaybillOrder.getId())
-                        .eq(KwtLogisticsOrderCirculate::getEntId, order.getEntId()));
                 //扣亏量/吨->亏吨量-合理损耗
                 BigDecimal deduct = null;
                 if (kwtWaybillOrder.getDeficitAmount() != null && (kwtWaybillOrder.getDeficitAmount().compareTo(new BigDecimal(NumberConstant.ZERO)) == NumberConstant.ZERO)) {
@@ -416,7 +382,7 @@ public class ConsignOrderService {
                 carWaybillVo.setWOrderId(String.valueOf(kwtWaybillOrder.getId()));
                 carWaybillVo.setWOrderNo(order.getLOrderNo());
                 carWaybillVo.setTruckNo(kwtWaybillOrder.getTruckNo());
-                carWaybillVo.setStatus(String.valueOf(kwtWaybillOrder.getStatus()));
+                carWaybillVo.setStatus(CarWaybillEnum.getName(kwtWaybillOrder.getStatus()));
                 carWaybillVo.setWaybillType(kwtWaybillOrder.getType());
                 carWaybillVo.setDriverName(kwtWaybillOrder.getDriverName());
                 //todo 取mongo
@@ -424,11 +390,7 @@ public class ConsignOrderService {
                 /** 2023-07-24 原值为承运车队-去除后更换展示为承运公司*/
 //                carWaybillVo.setConsignMotorcade(sckwWaybillOrder == null ? null : sckwWaybillOrder.getCarrierFirmName());
                 carWaybillVo.setSendCarWeigh(kwtWaybillOrder.getEntrustAmount() == null ? null : String.valueOf(kwtWaybillOrder.getEntrustAmount()));
-                if (circulate != null) {
-                    carWaybillVo.setSendCarDate(circulate.getCreateTime() == null ? null : DateUtil.getDateTime(circulate.getCreateTime()));
-                } else {
-                    carWaybillVo.setSendCarDate(null);
-                }
+                carWaybillVo.setSendCarDate(DateUtil.getDateTime(kwtWaybillOrder.getCreateTime()));
                 if (loadTicket != null) {
                     carWaybillVo.setLoadAmount(loadTicket.getAmount() == null ? null : String.valueOf(loadTicket.getAmount()));
                     carWaybillVo.setLoadDateTime(loadTicket.getCreateTime() == null ? null : DateUtil.getDateTime(loadTicket.getCreateTime()));
@@ -457,12 +419,26 @@ public class ConsignOrderService {
     }
 
     /**
-     * 托运订单获取车辆信息
+     * 托运订单/承运订单-获取车辆信息
      *
      * @param orderDto
      * @return
      */
-    public HttpResult getCarListByOrder(OrderDTO orderDto) {
+    public HttpResult getCarListByOrder(OrderDTO orderDto, String type) {
+        HttpResult httpResult = new HttpResult();
+        if (String.valueOf(NumberConstant.ONE).equals(type)) {
+            //托运
+            httpResult = getAcceptCarListByOrder(orderDto);
+        } else if (String.valueOf(NumberConstant.TWO).equals(type)) {
+            //承运
+            httpResult = getAcceptCarListByOrder(orderDto);
+        } else {
+            return HttpResult.error("单据类型错误!");
+        }
+        return httpResult;
+    }
+
+    private HttpResult getAcceptCarListByOrder(OrderDTO orderDto) {
         KwtLogisticsOrder logisticsOrder = kwtLogisticsOrderMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrder>()
                 .eq(KwtLogisticsOrder::getId, orderDto.getId()));
         if (logisticsOrder == null) {
@@ -470,15 +446,15 @@ public class ConsignOrderService {
             HttpResult.error("物流订单不存在");
         }
         List<OrderCarDTO> list = kwtWaybillOrderMapper.selectWaybillOrderCarListGroupByTruckNo(orderDto.getId(), orderDto.getPage(), orderDto.getPageSize());
-        if (CollectionUtils.isNotEmpty(list)) {
-            List<String> stringList = list.stream().map(OrderCarDTO::getTruckNo).collect(Collectors.toList());
-            Map<String, RTruckVo> truck = remoteFleetService.findTruck(stringList);
-            for (OrderCarDTO dto : list) {
-                dto.setLoadAmount(truck.get(dto.getTruckNo()) == null ?
-                        null : (truck.get(dto.getTruckNo()).getActualWeight() == null ?
-                        null : (String.valueOf(truck.get(dto.getTruckNo()).getActualWeight()))));
-            }
-        }
+//        if (CollectionUtils.isNotEmpty(list)) {
+//            List<String> stringList = list.stream().map(OrderCarDTO::getTruckNo).collect(Collectors.toList());
+//            Map<String, RTruckVo> truck = remoteFleetService.findTruck(stringList);
+//            for (OrderCarDTO dto : list) {
+//                dto.setLoadAmount(truck.get(dto.getTruckNo()) == null ?
+//                        null : (truck.get(dto.getTruckNo()).getActualWeight() == null ?
+//                        null : (String.valueOf(truck.get(dto.getTruckNo()).getActualWeight()))));
+//            }
+//        }
         PageResult build = PageResult.build(orderDto.getPage(), orderDto.getPageSize(), (long) list.size(), list);
         return HttpResult.ok(build);
     }

+ 85 - 32
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/LogisticsConsignmentService.java

@@ -537,28 +537,49 @@ public class LogisticsConsignmentService {
      * @param pageSize
      * @return
      */
-    public HttpResult purchaseLogisticsOrder(String id, Integer page, Integer pageSize) {
-        Long count = getLogisticsOrderCount(id);
+    public HttpResult purchaseLogisticsOrder(String id, Integer page, Integer pageSize, String type) {
+        Long count = getLogisticsOrderCount(id, type);
         Integer newPage = page - 1;
-        List<LogisticsOrderDTO> list = getLogisticsOrderData(id, newPage, pageSize);
+        List<LogisticsOrderDTO> list = getLogisticsOrderData(id, newPage, pageSize, type);
         PageResult build = PageResult.build(page, pageSize, count, list);
         return HttpResult.ok(build);
     }
 
-    private Long getLogisticsOrderCount(String id) {
-        return kwtLogisticsOrderMapper.selectOrderCount(id);
+    private Long getLogisticsOrderCount(String id, String type) {
+        return kwtLogisticsOrderMapper.selectOrderCount(id, type);
     }
 
     /**
      * 销售订单-采购订单-获取托运订单数据
      *
      * @param id       销售订单id
-     * @param page
-     * @param pageSize
+     * @param page     当前页
+     * @param pageSize 每页条数
+     * @param type     属于采购(1)还是销售(2)
      * @return
      */
-    public HttpResult logisticsOrder(String id, Integer page, Integer pageSize) {
+    public HttpResult logisticsOrder(String id, Integer page, Integer pageSize, String type) {
         HttpResult httpResult = new HttpResult();
+        if (String.valueOf(NumberConstant.ONE).equals(type)) {
+            //采购
+            httpResult = logisticsOrderList(id, page, pageSize, type);
+        } else if (String.valueOf(NumberConstant.ONE).equals(type)) {
+            //销售
+            httpResult = logisticsOrderList(id, page, pageSize, type);
+        } else {
+            return HttpResult.error("单据类型错误");
+        }
+        return httpResult;
+    }
+
+    /**
+     * 采购订单/销售订单-托运订单列表-下方数据统计
+     *
+     * @param id   贸易订单id
+     * @param type 采购1 销售2
+     * @return
+     */
+    public HttpResult logisticsOrderCount(String id, String type) {
         OrderDetailRes orderDetailRes = tradeOrderInfoService.getOrderDetailById(Long.parseLong(id));
         /**根据下单方式(代客下单/自主下单)决定托运数据是否展示*/
         boolean flag = false;
@@ -570,41 +591,73 @@ public class LogisticsConsignmentService {
             throw new RuntimeException("获取贸易订单下单方式异常!");
         }
         BigDecimal resAmount = orderDetailRes.getAmount();
+        List<LogisticsOrderDTO> list = new ArrayList<>();
+        JSONObject jsonObject = new JSONObject();
+        //总数
+        Long count = 0L;
+        //计划量
+        BigDecimal amount = new BigDecimal("0.00");
+        //剩余调度量
+        BigDecimal residue = new BigDecimal("0.00");
+        if (flag) {
+            count = getLogisticsOrderCount(id, type);
+            list = kwtLogisticsOrderMapper.selectOrderCountByTorderId(id, type);
+            /**数据统计*/
+            for (LogisticsOrderDTO logisticsOrderDTO : list) {
+                amount = amount.add(logisticsOrderDTO.getAmount() == null ? new BigDecimal("0.00") : logisticsOrderDTO.getAmount());
+            }
+            residue = resAmount.subtract(amount);
+        }
+        jsonObject.put("count", count);
+        jsonObject.put("residue", residue);
+        jsonObject.put("amount", amount);
+        return HttpResult.ok(jsonObject);
+    }
+
+    /**
+     * 销售订单-采购订单-获取托运订单数据
+     *
+     * @param id       销售订单id
+     * @param page     当前页
+     * @param pageSize 每页条数
+     * @param type     属于采购(1)还是销售(2)
+     * @return
+     */
+    private HttpResult logisticsOrderList(String id, Integer page, Integer pageSize, String type) {
+        OrderDetailRes orderDetailRes = tradeOrderInfoService.getOrderDetailById(Long.parseLong(id));
+        /**根据下单方式(代客下单/自主下单)决定托运数据是否展示*/
+        boolean flag = false;
+        if (String.valueOf(NumberConstant.ONE).equals(orderDetailRes.getSource())) {
+            flag = true;
+        } else if (String.valueOf(NumberConstant.TWO).equals(orderDetailRes.getSource())) {
+            flag = true;
+        } else {
+            throw new RuntimeException("获取贸易订单下单方式异常!");
+        }
+        List<LogisticsOrderDTO> list = new ArrayList<>();
+        PageResult build = PageResult.build(page, pageSize, 0L, list);
         if (flag) {
             /**数据展示*/
-            //总数
-            Long count = getLogisticsOrderCount(id);
+            Long count = getLogisticsOrderCount(id, type);
             Integer newPage = page - 1;
-            List<LogisticsOrderDTO> list = getLogisticsOrderData(id, newPage, pageSize);
-            PageResult build = PageResult.build(page, pageSize, count, list);
-            /**数据统计*/
-            //计划量
-            BigDecimal amount = new BigDecimal(NumberConstant.ZERO);
+            list = getLogisticsOrderData(id, newPage, pageSize, type);
             for (LogisticsOrderDTO logisticsOrderDTO : list) {
-                amount = amount.add(logisticsOrderDTO.getAmount() == null ? new BigDecimal(NumberConstant.ZERO) : logisticsOrderDTO.getAmount());
+                logisticsOrderDTO.setStatus(LogisticsOrderEnum.getDestination(logisticsOrderDTO.getStatus()));
             }
-            //剩余调度量
-            BigDecimal residue = resAmount.subtract(amount);
-            JSONObject jsonObject = new JSONObject();
-            jsonObject.put("count", count);
-            jsonObject.put("residue", residue);
-            jsonObject.put("amount", amount);
-            Map<String, Object> map = new HashMap<>(NumberConstant.SIXTEEN);
-            map.put("dataList", build);
-            map.put("TableBottom", jsonObject);
-            httpResult.setData(map);
+            build = PageResult.build(page, pageSize, count, list);
         }
-        return httpResult;
+        return HttpResult.ok(build);
     }
 
     /**
-     * @param id
-     * @param page
-     * @param pageSize
+     * @param id       贸易订单id
+     * @param page     当前页
+     * @param pageSize 每页条数
+     * @param type     采购订单1/销售订单2
      * @return
      */
-    private List<LogisticsOrderDTO> getLogisticsOrderData(String id, Integer page, Integer pageSize) {
-        List<LogisticsOrderDTO> list = kwtLogisticsOrderMapper.selectOrderList(id, page, pageSize);
+    private List<LogisticsOrderDTO> getLogisticsOrderData(String id, Integer page, Integer pageSize, String type) {
+        List<LogisticsOrderDTO> list = kwtLogisticsOrderMapper.selectOrderList(id, page, pageSize, type);
         return list;
     }
 

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

@@ -16,11 +16,8 @@ import com.sckw.mongo.model.SckwWaybillOrder;
 import com.sckw.mongo.model.TableTops;
 import com.sckw.system.api.RemoteSystemService;
 import com.sckw.system.api.model.dto.res.UserCacheResDto;
-import com.sckw.transport.api.model.dto.vo.LogisticsOrderVO;
 import com.sckw.transport.dao.*;
 import com.sckw.transport.model.KwtLogisticsOrder;
-import com.sckw.transport.model.KwtWaybillOrderAddress;
-import com.sckw.transport.model.KwtWaybillOrderTicket;
 import com.sckw.transport.model.KwtWaybillOrderTrack;
 import com.sckw.transport.model.dto.WayBillDetailDTO;
 import com.sckw.transport.model.dto.WaybillOrderDTO;
@@ -39,7 +36,10 @@ import org.springframework.data.mongodb.core.query.Query;
 import org.springframework.stereotype.Service;
 import org.springframework.util.ObjectUtils;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 import java.util.regex.Pattern;
 
 /**
@@ -81,7 +81,7 @@ public class WaybillManagementService {
      * @param id
      * @return
      */
-    public HttpResult waybillData(@Param("id") Long id) {
+    public HttpResult waybillData(Long id) {
         WaybillDataVO waybillDataVO = new WaybillDataVO();
         Criteria criteria = new Criteria();
         criteria.and("wOrderId").is(id);
@@ -118,10 +118,9 @@ public class WaybillManagementService {
             waybillCarVO.setDriverPhone(info.getDriverPhone());
             List<String> list = new ArrayList<>();
             list.add(info.getTruckNo());
-//            Map<String, RTruckVo> trucks = remoteFleetService.findTruck(list);
-            Map<String, RTruckVo> trucks = new HashMap<>();
+            Map<String, RTruckVo> trucks = remoteFleetService.findTruck(list);
             if (CollectionUtils.isNotEmpty(trucks)) {
-                waybillCarVO.setTrailerNo(trucks.get(0).getTrailerNo());
+                waybillCarVO.setTrailerNo(trucks.get(info.getTruckNo()) != null ? trucks.get(info.getTruckNo()).getTrailerNo() : null);
             }
             // 票据
             waybillTicketVO.setLoadTime(DateUtil.getDateTime(info.getLoadTime()));
@@ -138,15 +137,7 @@ public class WaybillManagementService {
             WaybillStatusVO waybillStatusVO = new WaybillStatusVO();
             waybillStatusVO.setStatus(false);
             waybillStatusVO.setCode(e);
-            switch (e){
-                case 2 -> waybillStatusVO.setDestination("已接单");
-                case 3 -> waybillStatusVO.setDestination("已出车");
-                case 4 -> waybillStatusVO.setDestination("到达装货地");
-                case 5 -> waybillStatusVO.setDestination("已装货");
-                case 6 -> waybillStatusVO.setDestination("到达卸货点");
-                case 7 -> waybillStatusVO.setDestination("已卸货");
-                case 8 -> waybillStatusVO.setDestination("已核单");
-            }
+            waybillStatusVO.setDestination(CarWaybillEnum.getName(e));
             statusVOS.add(waybillStatusVO);
         });
         List<KwtWaybillOrderTrack> kwtWaybillOrderTracks = kwtWaybillOrderTrackMapper.selectList(new LambdaQueryWrapper<KwtWaybillOrderTrack>()
@@ -155,8 +146,7 @@ public class WaybillManagementService {
         if (CollectionUtils.isNotEmpty(kwtWaybillOrderTracks)) {
             List<Long> userIds = new ArrayList<>();
             kwtWaybillOrderTracks.forEach(e -> userIds.add(e.getCreateBy()));
-//            List<UserCacheResDto> users = remoteSystemService.queryUserCacheByIds(userIds);
-            List<UserCacheResDto> users = new ArrayList<>();
+            List<UserCacheResDto> users = remoteSystemService.queryUserCacheByIds(userIds);
             Map<Long, String> usersMap = new HashMap<>();
             users.forEach(e -> usersMap.put(e.getId(), e.getName()));
             for (KwtWaybillOrderTrack kwtWaybillOrderTrack: kwtWaybillOrderTracks) {
@@ -165,7 +155,8 @@ public class WaybillManagementService {
                         statusVO.setStatus(true);
                         statusVO.setId(kwtWaybillOrderTrack.getId());
                         statusVO.setCreateTime(DateUtil.getDateTime(kwtWaybillOrderTrack.getCreateTime()));
-                        statusVO.setCreateByName(usersMap.get(kwtWaybillOrderTrack.getCreateBy()));
+                        statusVO.setCreateByName(usersMap.get(kwtWaybillOrderTrack.getCreateBy()) == null
+                                ? null : usersMap.get(kwtWaybillOrderTrack.getCreateBy()));
                         break;
                     }
                 }
@@ -173,7 +164,8 @@ public class WaybillManagementService {
                 waybillTrackVO.setId(String.valueOf(kwtWaybillOrderTrack.getId()))
                         .setRemark(kwtWaybillOrderTrack.getRemark())
                         .setStatus(String.valueOf(kwtWaybillOrderTrack.getStatus()))
-                        .setCreateBy(usersMap.get(String.valueOf(kwtWaybillOrderTrack.getCreateBy())))
+                        .setCreateBy(usersMap.get(kwtWaybillOrderTrack.getCreateBy()) == null
+                                ? null : usersMap.get(kwtWaybillOrderTrack.getCreateBy()))
                         .setCreateTime(DateUtil.getDateTime(kwtWaybillOrderTrack.getCreateTime()));
                 waybillTrackVOS.add(waybillTrackVO);
             }
@@ -203,15 +195,7 @@ public class WaybillManagementService {
             WaybillStatusVO waybillStatusVO = new WaybillStatusVO();
             waybillStatusVO.setStatus(false);
             waybillStatusVO.setCode(e);
-            switch (e){
-                case 2 -> waybillStatusVO.setDestination("司机接单");
-                case 3 -> waybillStatusVO.setDestination("出车");
-                case 4 -> waybillStatusVO.setDestination("到装货地");
-                case 5 -> waybillStatusVO.setDestination("装货");
-                case 6 -> waybillStatusVO.setDestination("到卸货地");
-                case 7 -> waybillStatusVO.setDestination("卸货");
-                case 8 -> waybillStatusVO.setDestination("核单");
-            }
+            waybillStatusVO.setDestination(CarWaybillEnum.getName(e));
             statusVOS.add(waybillStatusVO);
         });
 
@@ -255,8 +239,7 @@ public class WaybillManagementService {
             if (CollectionUtils.isNotEmpty(kwtWaybillOrderTracks)) {
                 List<Long> userIds = new ArrayList<>();
                 kwtWaybillOrderTracks.forEach(e -> userIds.add(e.getCreateBy()));
-//                List<UserCacheResDto> users = remoteSystemService.queryUserCacheByIds(userIds);
-                List<UserCacheResDto> users = new ArrayList<>();
+                List<UserCacheResDto> users = remoteSystemService.queryUserCacheByIds(userIds);
                 Map<Long, String> usersMap = new HashMap<>();
                 users.forEach(e -> usersMap.put(e.getId(), e.getName()));
                 waybillBoardListVO.getTracks().forEach(e -> {
@@ -265,7 +248,7 @@ public class WaybillManagementService {
                             e.setStatus(true);
                             e.setId(e2.getId());
                             e.setCreateTime(DateUtil.getDateTime(e2.getCreateTime()));
-                            e.setCreateByName(usersMap.get(e2.getCreateBy()));
+                            e.setCreateByName(usersMap.get(e2.getCreateBy()) == null ? null : usersMap.get(e2.getCreateBy()));
                         }
                     });
                 });
@@ -309,7 +292,7 @@ public class WaybillManagementService {
             Criteria.where("wOrderId").in(wOrderIds);
         }
 
-        if (StringUtils.isNotBlank(query.getStatus())) {
+        if (StringUtils.isNotBlank(query.getStatus()) && !query.getStatus().equals("all")) {
             criteria.and("status").is(query.getStatus());
         } else {
             criteria.and("status").in(statuses);
@@ -376,22 +359,14 @@ public class WaybillManagementService {
         Map<String, TableTops> listMap = new HashMap<>();
         TableTops topTotal = new TableTops();
         topTotal.setName("全部");
-        topTotal.setValue("");
+        topTotal.setValue("all");
         topTotal.setTotal(0);
         listMap.put("", topTotal);
         statuses.forEach(e -> {
             TableTops top = new TableTops();
             top.setValue(String.valueOf(e));
             top.setTotal(0);
-            switch (e){
-                case 2 -> top.setName("司机接单");
-                case 3 -> top.setName("出车");
-                case 4 -> top.setName("到装货地");
-                case 5 -> top.setName("装货");
-                case 6 -> top.setName("到卸货地");
-                case 7 -> top.setName("卸货");
-                case 8 -> top.setName("核单");
-            }
+            top.setName(CarWaybillEnum.getName(e));
             listMap.put(String.valueOf(e), top);
         });
         if(CollectionUtils.isNotEmpty(results)) {
@@ -399,7 +374,7 @@ public class WaybillManagementService {
                 listMap.get(result.getValue()).setTotal(result.getTotal());
             }
         }
-        listMap.get("").setTotal(listMap.values().parallelStream().mapToInt(e -> e.getTotal()).sum());
+        listMap.get("all").setTotal(listMap.values().parallelStream().mapToInt(e -> e.getTotal()).sum());
         return HttpResult.ok(listMap.values());
     }
 }

+ 27 - 4
sckw-modules/sckw-transport/src/main/resources/mapper/KwtLogisticsOrderMapper.xml

@@ -64,8 +64,8 @@
                a.create_by   as createBy,
                a.create_time as createTime
         FROM kwt_logistics_order a
-                 LEFT JOIN kwt_logistics_order_track b ON a.id = b.l_order_id
-                 LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id AND c.unit_type = '2'
+                 LEFT JOIN kwt_logistics_order_track b ON a.id = b.l_order_id and a.`status`=b.`status`
+                 LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id AND c.unit_type = #{type}
         WHERE a.del_flag = '0'
           AND b.del_flag = '0'
           AND a.t_order_id = #{id,jdbcType=VARCHAR} limit #{page}
@@ -74,8 +74,8 @@
     <select id="selectOrderCount" resultType="java.lang.Long">
         SELECT count(a.id)
         FROM kwt_logistics_order a
-                 LEFT JOIN kwt_logistics_order_track b ON a.id = b.l_order_id
-                 LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id AND c.unit_type = '2'
+                 LEFT JOIN kwt_logistics_order_track b ON a.id = b.l_order_id and a.`status` = b.`status`
+                 LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id AND c.unit_type = #{type}
         WHERE a.del_flag = '0'
           AND b.del_flag = '0'
           AND a.t_order_id = #{id,jdbcType=VARCHAR}
@@ -398,4 +398,27 @@
             and id != #{ownOrderId, jdbcType=BIGINT}
         </if>
     </select>
+    <select id="selectOrderCountByTorderId" resultType="com.sckw.transport.model.dto.LogisticsOrderDTO">
+        SELECT a.id          as lOrderId,
+               a.l_order_no  as lOrderNo,
+               b.`status`    as `status`,
+               a.t_order_id  as tOrderId,
+               a.t_order_no  as tOrderNo,
+               a.payment     as payment,
+               a.amount,
+               a.price,
+               a.loss,
+               a.goods_price as goodsPrice,
+               c.firm_name   as comanyName,
+               c.contacts,
+               c.phone,
+               a.create_by   as createBy,
+               a.create_time as createTime
+        FROM kwt_logistics_order a
+                 LEFT JOIN kwt_logistics_order_track b ON a.id = b.l_order_id
+                 LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id AND c.unit_type = #{type}
+        WHERE a.del_flag = '0'
+          AND b.del_flag = '0'
+          AND a.t_order_id = #{id,jdbcType=VARCHAR}
+    </select>
 </mapper>