Selaa lähdekoodia

Merge branch 'dev' into sky_v1

15928045575 2 vuotta sitten
vanhempi
commit
848fb3da00
91 muutettua tiedostoa jossa 4281 lisäystä ja 731 poistoa
  1. 0 6
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/exception/GlobalSystemExceptionHandler.java
  2. 0 35
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/exception/SuccessBusinessException.java
  3. 1 1
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/web/constant/HttpStatus.java
  4. 1 1
      sckw-common/sckw-common-redis/src/main/java/com/sckw/redis/config/RedisLockUtil.java
  5. 1 0
      sckw-common/sckw-common-redis/src/main/java/com/sckw/redis/constant/RedisLockKey.java
  6. 15 0
      sckw-modules-api/sckw-payment-api/src/main/java/com/sckw/payment/api/model/constant/ChannelEnum.java
  7. 10 0
      sckw-modules-api/sckw-system-api/src/main/java/com/sckw/system/api/model/dto/res/EntCacheResDto.java
  8. 5 0
      sckw-modules/sckw-manage/src/main/java/com/sckw/manage/model/dto/res/CooperateManageQueryResDto.java
  9. 32 22
      sckw-modules/sckw-manage/src/main/java/com/sckw/manage/service/CommonBusinessService.java
  10. 42 30
      sckw-modules/sckw-manage/src/main/java/com/sckw/manage/service/KwmCooperateApplyService.java
  11. 23 10
      sckw-modules/sckw-manage/src/main/java/com/sckw/manage/service/KwmCooperateManageService.java
  12. 2 1
      sckw-modules/sckw-manage/src/main/resources/mapper/KwmCooperateMapper.xml
  13. 1 1
      sckw-modules/sckw-message/src/main/java/com/sckw/message/model/vo/res/KwmMessageListResVO.java
  14. 14 12
      sckw-modules/sckw-order/src/main/java/com/sckw/order/dubbo/TradeOrderInfoServiceImpl.java
  15. 23 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/enums/ContractStatusEnum.java
  16. 30 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/enums/DeliveryTypeEnum.java
  17. 30 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/enums/OrderAddressTypeEnum.java
  18. 30 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/enums/OrderSourceEnum.java
  19. 39 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/enums/OrderStatusEnum.java
  20. 30 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/enums/OrderUnitTypeEnum.java
  21. 46 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/enums/TransportDemandStatusEnum.java
  22. 47 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/enums/WantBuyStatusEnum.java
  23. 10 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/res/GoodsInfoDetailRes.java
  24. 97 63
      sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwoTradeOrderService.java
  25. 77 22
      sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwoTransportDemandService.java
  26. 95 27
      sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwpWantBuyService.java
  27. 63 3
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/WalletController.java
  28. 11 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpWalletRefundMapper.java
  29. 13 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpWalletRefundSubMapper.java
  30. 1 4
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpWalletRefund.java
  31. 73 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpWalletRefundSub.java
  32. 50 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/WalletInfoDto.java
  33. 3 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/wallet/MemberCreate.java
  34. 11 4
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/PrePayWalletVo.java
  35. 23 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/AppendPayCheck.java
  36. 43 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/ApplyRefundReq.java
  37. 16 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/CreateUserReq.java
  38. 1 2
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/FinanceCount.java
  39. 24 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/RefundBackReq.java
  40. 32 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/RefundCheckReq.java
  41. 33 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/RefundPage.java
  42. 2 12
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/RefundReq.java
  43. 14 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/MoneyChange.java
  44. 91 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/WalletRefundVo.java
  45. 8 6
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementLogisticsService.java
  46. 43 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpWalletRefundSubService.java
  47. 9 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpWalletRelationService.java
  48. 6 6
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/PayCenterService.java
  49. 113 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/WalletOrderService.java
  50. 310 75
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/WalletService.java
  51. 201 0
      sckw-modules/sckw-payment/src/main/resources/bootstrap-lfdc.yml
  52. 45 25
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpWalletRefundMapper.xml
  53. 22 0
      sckw-modules/sckw-payment/src/main/resources/mapper/KwpWalletRefundSubMapper.xml
  54. 1 1
      sckw-modules/sckw-product/src/main/java/com/sckw/product/enums/GoodsStatusEnum.java
  55. 10 0
      sckw-modules/sckw-product/src/main/java/com/sckw/product/model/vo/res/GoodsList.java
  56. 78 20
      sckw-modules/sckw-product/src/main/java/com/sckw/product/service/KwpGoodsService.java
  57. 13 7
      sckw-modules/sckw-product/src/main/java/com/sckw/product/service/KwpGoodsStatisticsService.java
  58. 23 142
      sckw-modules/sckw-product/src/main/java/com/sckw/product/service/operation/GoodsManagerService.java
  59. 6 4
      sckw-modules/sckw-report/src/main/java/com/sckw/report/controller/KwFleetController.java
  60. 47 0
      sckw-modules/sckw-report/src/main/java/com/sckw/report/enums/TOrderStatusEnum.java
  61. 80 64
      sckw-modules/sckw-report/src/main/java/com/sckw/report/service/KwOrderService.java
  62. 18 4
      sckw-modules/sckw-report/src/main/java/com/sckw/report/service/KwOrderStatisticsService.java
  63. 6 5
      sckw-modules/sckw-report/src/main/java/com/sckw/report/service/operator/TradeOrderManageService.java
  64. 1 1
      sckw-modules/sckw-report/src/main/java/com/sckw/report/service/param/WaybillOrderListExport.java
  65. 6 1
      sckw-modules/sckw-report/src/main/java/com/sckw/report/service/param/WaybillOrderListSelect.java
  66. 5 3
      sckw-modules/sckw-report/src/main/java/com/sckw/report/service/param/WaybillOrderQuery.java
  67. 1 1
      sckw-modules/sckw-report/src/test/java/com/sckw/report/SckwTradeOrderTest.java
  68. 5 0
      sckw-modules/sckw-system/src/main/java/com/sckw/system/model/pojo/FindMenuTreePojo.java
  69. 6 0
      sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsMenuService.java
  70. 6 0
      sckw-modules/sckw-system/src/main/resources/mapper/KwsMenuDao.xml
  71. 5 0
      sckw-modules/sckw-transport/pom.xml
  72. 19 6
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/AcceptCarriageOrderController.java
  73. 2 2
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/ConsignOrderController.java
  74. 3 3
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/enterpriseApp/AppConsignController.java
  75. 126 20
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/dao/KwtLogisticsOrderMapper.java
  76. 1 1
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/dao/KwtWaybillOrderMapper.java
  77. 203 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/KwtLogisticsOrderTreeVo.java
  78. 55 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/LogisticsCountVo.java
  79. 39 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/StatisticsAmountVO.java
  80. 34 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/StatisticsMoneyVO.java
  81. 18 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/StatisticsResultVO.java
  82. 39 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/StatisticsTotalPriceVO.java
  83. 39 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/StatisticsWaitingAmountVO.java
  84. 156 11
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/AcceptCarriageOrderService.java
  85. 122 37
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/ConsignOrderService.java
  86. 139 6
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/KwtWaybillOrderService.java
  87. 239 5
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/TransportCommonService.java
  88. 1 1
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/dubbo/TransportDubboServiceImpl.java
  89. 6 8
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/dubbo/TransportStatisticsServiceImpl.java
  90. 749 10
      sckw-modules/sckw-transport/src/main/resources/mapper/KwtLogisticsOrderMapper.xml
  91. 12 0
      sckw-modules/sckw-transport/src/main/resources/mapper/KwtWaybillOrderMapper.xml

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

@@ -28,12 +28,6 @@ public class GlobalSystemExceptionHandler {
         log.error("业务异常:", e);
         return HttpResult.error(e.getCode(), e.getMessage());
     }
-    @ExceptionHandler(value = SuccessBusinessException.class)
-    @ResponseBody
-    public HttpResult handlerRuntimeException(SuccessBusinessException e) {
-        log.error("状态码为正常的业务:", e);
-        return HttpResult.error(HttpStatus.SUCCESS_CODE, e.getMessage());
-    }
 
     @ExceptionHandler(value = RuntimeException.class)
     @ResponseBody

+ 0 - 35
sckw-common/sckw-common-core/src/main/java/com/sckw/core/exception/SuccessBusinessException.java

@@ -1,35 +0,0 @@
-package com.sckw.core.exception;
-
-import lombok.Getter;
-
-import java.io.Serial;
-
-/**
- * 状态码为正常的业务异常
- *
- * @Author yzc
- * @Description 自定义业务异常
- * @createTime 2023年06月08日 10:05:00
- */
-@Getter
-public class SuccessBusinessException extends RuntimeException {
-    @Serial
-    private static final long serialVersionUID = 6955463132739776238L;
-    /**
-     * 异常信息
-     **/
-    private final String msg;
-    private Object[] param;
-
-    public SuccessBusinessException(String msg) {
-        super(msg);
-        this.msg = msg;
-    }
-
-    public SuccessBusinessException(String msg, Object... param) {
-        super(msg);
-        this.msg = msg;
-        this.param = param;
-    }
-
-}

+ 1 - 1
sckw-common/sckw-common-core/src/main/java/com/sckw/core/web/constant/HttpStatus.java

@@ -89,7 +89,7 @@ public class HttpStatus {
     public static final String LEGAL_NAME_ERROR = "法人格式不正确";
     public static final String LEGAL_PHONE_ERROR = "法人手机号格式不正确";
     public static final String LEGAL_ID_CARD_ERROR = "法人身份证号格式不正确";
-    public static final String ENT_CODE_ERROR = "企业编号格式不正确";
+    public static final String ENT_CODE_ERROR = "营业执照编号格式不正确";
 
     /**账号在别处登录状态码*/
     public static final int ACCOUNT_OTHER_LOGIN_CODE = 60900;

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

@@ -76,7 +76,7 @@ public class RedisLockUtil {
      */
     public void unlock(String lockKey) {
         RLock lock = redissonClient.getLock(lockKey);
-        if (lock.isHeldByCurrentThread()) {
+        if (lock.isHeldByCurrentThread() && lock.isLocked()) {
             lock.unlock();
         }
     }

+ 1 - 0
sckw-common/sckw-common-redis/src/main/java/com/sckw/redis/constant/RedisLockKey.java

@@ -6,4 +6,5 @@ package com.sckw.redis.constant;
  */
 public interface RedisLockKey {
     String TRANSFER = "transfer:";
+    String REFUND = "refund:";
 }

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

@@ -75,4 +75,19 @@ public enum ChannelEnum {
         }
         return null;
     }
+
+    /**
+     * 字典值转
+     *
+     * @param value 渠道字典值 1
+     * @return huifu
+     */
+    public static String valueToChannel(String value) {
+        for (ChannelEnum channelEnum : ChannelEnum.values()) {
+            if (channelEnum.getValue().equals(value)) {
+                return channelEnum.getChannel();
+            }
+        }
+        return null;
+    }
 }

+ 10 - 0
sckw-modules-api/sckw-system-api/src/main/java/com/sckw/system/api/model/dto/res/EntCacheResDto.java

@@ -117,4 +117,14 @@ public class EntCacheResDto implements Serializable {
 
     private Integer status;
 
+    /**
+     * 法人姓名
+     */
+    private String legalName;
+
+    /**
+     * 法人姓名
+     */
+    private String legalPhone;
+
 }

+ 5 - 0
sckw-modules/sckw-manage/src/main/java/com/sckw/manage/model/dto/res/CooperateManageQueryResDto.java

@@ -77,6 +77,11 @@ public class CooperateManageQueryResDto {
      */
     private Long createBy;
 
+    /**
+     * 创建人
+     */
+    private String createByStr;
+
     /**
      * 创建时间
      */

+ 32 - 22
sckw-modules/sckw-manage/src/main/java/com/sckw/manage/service/CommonBusinessService.java

@@ -93,7 +93,7 @@ public class CommonBusinessService {
      * @author: czh
      * @date: 2023/7/12
      */
-    public Map<Long, UserCacheResDto> queryUserCacheMapByIds(List<Long> userIds){
+    public Map<Long, UserCacheResDto> queryUserCacheMapByIds(List<Long> userIds) {
         return remoteSystemService.queryUserCacheMapByIds(userIds);
     }
 
@@ -174,19 +174,23 @@ public class CommonBusinessService {
     public List<CooperateManageQueryResVo> getCooperateManageQueryResVos(List<CooperateManageQueryResDto> list) {
         //dubbo接口查用户和企业
         Long entId = LoginUserHolder.getEntId();
-        List<Long> userIds = list.stream().map(CooperateManageQueryResDto::getCreateBy).distinct().toList();
+        List<String> createByList = list.stream().map(CooperateManageQueryResDto::getCreateByStr).toList();
+        List<Long> userIds = new ArrayList<>();
+        for (String createByStr : createByList) {
+            String[] split = createByStr.split(Global.COMMA);
+            for (int n = 0; n < split.length; n ++) {
+                userIds.add(Long.valueOf(split[n]));
+            }
+        }
+
         List<Long> allEntIds = new ArrayList<>();
         List<Long> targetEntIds = list.stream().map(CooperateManageQueryResDto::getTargetEntId).distinct().toList();
         List<Long> ourEntIds = list.stream().map(CooperateManageQueryResDto::getOurEntId).distinct().toList();
         allEntIds.addAll(targetEntIds);
         allEntIds.addAll(ourEntIds);
-        List<UserCacheResDto> userCacheResDtos = remoteSystemService.queryUserCacheByIds(userIds);
+        Map<Long, UserCacheResDto> userCacheResDtoMap = remoteSystemService.queryUserCacheMapByIds(userIds);
         List<EntCacheResDto> entCacheResDtos = remoteSystemService.queryEntCacheByIds(allEntIds);
-        Map<Long, String> userMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
         Map<Long, String> entMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
-        if (!CollectionUtils.isEmpty(userCacheResDtos)) {
-            userMap = userCacheResDtos.stream().collect(Collectors.toMap(UserCacheResDto::getId, UserCacheResDto::getName, (oldValue, newValue) -> newValue));
-        }
         if (!CollectionUtils.isEmpty(entCacheResDtos)) {
             entMap = entCacheResDtos.stream().collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName, (oldValue, newValue) -> newValue));
         }
@@ -201,7 +205,6 @@ public class CommonBusinessService {
             cooperateManageQueryResVo.setRemark(cooperateManageQueryResDto.getRemark());
             cooperateManageQueryResVo.setStatus(cooperateManageQueryResDto.getStatus());
             cooperateManageQueryResVo.setApplyTypeCode(cooperateManageQueryResDto.getApplyTypeCode());
-            cooperateManageQueryResVo.setCreateByName(userMap.get(cooperateManageQueryResDto.getCreateBy()));
             cooperateManageQueryResVo.setCreateTime(cooperateManageQueryResDto.getCreateTime());
             cooperateManageQueryResVo.setTargetEntName(targetEntName);
             cooperateManageQueryResVo.setTargetEntId(targetEntId);
@@ -209,15 +212,34 @@ public class CommonBusinessService {
             cooperateManageQueryResVo.setEntName(entMap.get(cooperateManageQueryResDto.getOurEntId()));
             cooperateManageQueryResVo.setApprovalRemark(cooperateManageQueryResDto.getApprovalRemark());
 
+            UserCacheResDto userCacheResDto = userCacheResDtoMap.get(cooperateManageQueryResDto.getCreateBy());
+            cooperateManageQueryResVo.setCreateByName(userCacheResDto.getName());
+
+            String typesStr = cooperateManageQueryResDto.getTypes();
+            List<Integer> typelist = new ArrayList<>();
+            String[] split = typesStr.split(Global.COMMA);
+            for (String typeStr : split) {
+                String[] split1 = typeStr.split(Global.POUND);
+                Integer type = Integer.valueOf(split1[0]);
+                Long userId = Long.valueOf(split1[1]);
+                UserCacheResDto userCacheResDto1 = userCacheResDtoMap.get(userId);
+                if (userCacheResDto1.getEntInfo().getId().equals(entId)) {
+                    typelist.add(type);
+                } else {
+                    typelist.add(changeAttribute(type));
+                }
+            }
+            cooperateManageQueryResVo.setCooperateTypes(String.join(Global.COMMA, typelist.stream().distinct().map(String::valueOf).toList()));
+
             //我方是发起方
-            if (entId.compareTo(cooperateManageQueryResDto.getEntId()) == 0) {
+            if (entId.equals(cooperateManageQueryResDto.getEntId())) {
                 cooperateManageQueryResVo.setContacts(cooperateManageQueryResDto.getInviteeContacts());
                 cooperateManageQueryResVo.setPhone(cooperateManageQueryResDto.getInviteePhone());
                 cooperateManageQueryResVo.setContactsId(cooperateManageQueryResDto.getInviteeContactsId());
                 cooperateManageQueryResVo.setManager(cooperateManageQueryResDto.getInviterContacts());
                 cooperateManageQueryResVo.setManagerPhone(cooperateManageQueryResDto.getInviterPhone());
                 cooperateManageQueryResVo.setManagerId(cooperateManageQueryResDto.getInviterContactsId());
-                cooperateManageQueryResVo.setCooperateTypes(cooperateManageQueryResDto.getTypes());
+
             } else {
                 cooperateManageQueryResVo.setContacts(cooperateManageQueryResDto.getInviterContacts());
                 cooperateManageQueryResVo.setPhone(cooperateManageQueryResDto.getInviterPhone());
@@ -225,18 +247,6 @@ public class CommonBusinessService {
                 cooperateManageQueryResVo.setManager(cooperateManageQueryResDto.getInviteeContacts());
                 cooperateManageQueryResVo.setManagerPhone(cooperateManageQueryResDto.getInviteePhone());
                 cooperateManageQueryResVo.setManagerId(cooperateManageQueryResDto.getInviteeContactsId());
-                cooperateManageQueryResVo.setCooperateTypes(changeCooperateType(cooperateManageQueryResDto.getTypes()));
-            }
-
-            //转换合作属性
-            String types = cooperateManageQueryResDto.getTypes();
-            List<Integer> typeList = Arrays.stream(types.split(Global.COMMA)).map(Integer::parseInt).distinct().toList();
-            if (!Objects.equals(LoginUserHolder.getEntId(), cooperateManageQueryResDto.getEntId())) {
-                List<Integer> targetTypes = new ArrayList<>();
-                for (Integer type : typeList) {
-                    targetTypes.add(changeCooperateType(type));
-                }
-                cooperateManageQueryResVo.setCooperateTypes(String.join(Global.COMMA,targetTypes.stream().distinct().map(String::valueOf).toList()));
             }
 
             result.add(cooperateManageQueryResVo);

+ 42 - 30
sckw-modules/sckw-manage/src/main/java/com/sckw/manage/service/KwmCooperateApplyService.java

@@ -114,13 +114,9 @@ public class KwmCooperateApplyService {
         List<Long> ourEntIds = list.stream().map(CooperateManageQueryResDto::getOurEntId).distinct().toList();
         allEntIds.addAll(ourEntIds);
         allEntIds.addAll(targetEntIds);
-        List<UserCacheResDto> userCacheResDtos = remoteSystemService.queryUserCacheByIds(userIds);
+        Map<Long, UserCacheResDto> userCacheResDtoMap = remoteSystemService.queryUserCacheMapByIds(userIds);
         List<EntCacheResDto> entCacheResDtos = remoteSystemService.queryEntCacheByIds(allEntIds);
-        Map<Long, String> userMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
         Map<Long, String> entMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
-        if (!CollectionUtils.isEmpty(userCacheResDtos)) {
-            userMap = userCacheResDtos.stream().collect(Collectors.toMap(UserCacheResDto::getId, UserCacheResDto::getName, (oldValue, newValue) -> newValue));
-        }
         if (!CollectionUtils.isEmpty(entCacheResDtos)) {
             entMap = entCacheResDtos.stream().collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName, (oldValue, newValue) -> newValue));
         }
@@ -135,8 +131,13 @@ public class KwmCooperateApplyService {
             cooperateManageQueryResVo.setCreateTime(cooperateManageQueryResDto.getCreateTime());
             cooperateManageQueryResVo.setRemark(cooperateManageQueryResDto.getRemark());
             cooperateManageQueryResVo.setStatus(cooperateManageQueryResDto.getStatus());
-            cooperateManageQueryResVo.setApplyTypeCode(cooperateManageQueryResDto.getApplyTypeCode());
-            cooperateManageQueryResVo.setCreateByName(userMap.get(cooperateManageQueryResDto.getCreateBy()));
+
+            UserCacheResDto userCacheResDto = userCacheResDtoMap.get(cooperateManageQueryResDto.getCreateBy());
+            cooperateManageQueryResVo.setCreateByName(userCacheResDto.getName());
+            EntCacheResDto entInfo = userCacheResDto.getEntInfo();
+            boolean isOur = entId.equals(entInfo.getId());
+            cooperateManageQueryResVo.setApplyTypeCode(isOur ? Global.NUMERICAL_ONE : Global.NUMERICAL_TWO);
+
             cooperateManageQueryResVo.setTargetEntName(targetEntName);
             cooperateManageQueryResVo.setTargetEntId(targetEntId);
             cooperateManageQueryResVo.setEntId(cooperateManageQueryResDto.getOurEntId());
@@ -144,7 +145,7 @@ public class KwmCooperateApplyService {
             cooperateManageQueryResVo.setApprovalRemark(cooperateManageQueryResDto.getApprovalRemark());
 
             //我方是发起方
-            if (entId.compareTo(cooperateManageQueryResDto.getEntId()) == 0) {
+            if (isOur) {
                 cooperateManageQueryResVo.setContacts(cooperateManageQueryResDto.getInviteeContacts());
                 cooperateManageQueryResVo.setPhone(cooperateManageQueryResDto.getInviteePhone());
                 cooperateManageQueryResVo.setContactsId(cooperateManageQueryResDto.getInviteeContactsId());
@@ -152,7 +153,6 @@ public class KwmCooperateApplyService {
                 cooperateManageQueryResVo.setManagerPhone(cooperateManageQueryResDto.getInviterPhone());
                 cooperateManageQueryResVo.setManagerId(cooperateManageQueryResDto.getInviterContactsId());
                 cooperateManageQueryResVo.setCooperateTypes(cooperateManageQueryResDto.getTypes());
-
             } else {
                 cooperateManageQueryResVo.setContacts(cooperateManageQueryResDto.getInviterContacts());
                 cooperateManageQueryResVo.setPhone(cooperateManageQueryResDto.getInviterPhone());
@@ -161,7 +161,6 @@ public class KwmCooperateApplyService {
                 cooperateManageQueryResVo.setManagerPhone(cooperateManageQueryResDto.getInviteePhone());
                 cooperateManageQueryResVo.setManagerId(cooperateManageQueryResDto.getInviteeContactsId());
                 cooperateManageQueryResVo.setCooperateTypes(commonBusinessService.changeCooperateType(cooperateManageQueryResDto.getTypes()));
-
             }
 
             result.add(cooperateManageQueryResVo);
@@ -253,30 +252,28 @@ public class KwmCooperateApplyService {
                 }
 
                 for (KwmCooperateType kwmCooperateType : kwmCooperateTypeList) {
-                    if (cooperateQueryDto.getKwmCooperate().getEntId().equals(currentEntId) && kwmCooperateType.getStatus() == CooperateStatusEnum.PROCESS.getCode()) {
+                    if (kwmCooperateType.getStatus().equals(CooperateStatusEnum.PROCESS.getCode())) {
                         throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.MSG_015);
                     }
                 }
 
                 //已合作的可以新增,但不能重复新增
                 List<Integer> typeList = kwmCooperateTypeList.stream().map(KwmCooperateType::getType).toList();
-                if (cooperateQueryDto.getKwmCooperate().getInviterEntId().equals(currentEntId)) {
-                    chooseCooperateTypes.forEach(item -> {
-                        if (typeList.contains(item)) {
-                            throw new SystemException(HttpStatus.CODE_10301, HttpStatus.MSG_016);
-                        }
-                    });
-                }
+                chooseCooperateTypes.forEach(item -> {
+                    if (typeList.contains(item)) {
+                        throw new SystemException(HttpStatus.CODE_10301, HttpStatus.MSG_016);
+                    }
+                });
 
-                //对方发起了与之相对的申请,也不能再申请
-                if (cooperateQueryDto.getKwmCooperate().getInviteeEntId().equals(currentEntId)) {
-                    chooseCooperateTypes.forEach(item -> {
-                        Integer relative = commonBusinessService.changeAttribute(item);
-                        if (typeList.contains(relative)) {
-                            throw new SystemException(HttpStatus.CODE_10301, HttpStatus.MSG_016);
-                        }
-                    });
-                }
+//                //对方发起了与之相对的申请,也不能再申请
+//                if (cooperateQueryDto.getKwmCooperate().getInviteeEntId().equals(currentEntId)) {
+//                    chooseCooperateTypes.forEach(item -> {
+//                        Integer relative = commonBusinessService.changeAttribute(item);
+//                        if (typeList.contains(relative)) {
+//                            throw new SystemException(HttpStatus.CODE_10301, HttpStatus.MSG_016);
+//                        }
+//                    });
+//                }
             }
         }
         //保存发起申请
@@ -444,10 +441,25 @@ public class KwmCooperateApplyService {
         }
 
         List<CooperateQueryDto> list = new ArrayList<>();
+        EntCacheResDto entCacheResDto = remoteSystemService.queryEntTreeById(currentEntId);
+
         for (KwmCooperate kwmCooperate : kwmCooperates) {
             CooperateQueryDto cooperateQueryDto = new CooperateQueryDto();
             cooperateQueryDto.setKwmCooperate(kwmCooperate);
-            cooperateQueryDto.setKwmCooperateTypeList(map.get(kwmCooperate.getId()));
+
+            List<KwmCooperateType> kwmCooperateTypeList = map.get(kwmCooperate.getId());
+            if (CollectionUtils.isNotEmpty(kwmCooperateTypeList)) {
+                List<Long> longs = kwmCooperateTypeList.stream().map(KwmCooperateType::getCreateBy).toList();
+                Map<Long, UserCacheResDto> longUserCacheResDtoMap = remoteSystemService.queryUserCacheMapByIds(longs);
+                for (KwmCooperateType kwmCooperateType : kwmCooperateTypeList) {
+                    Long createBy = kwmCooperateType.getCreateBy();
+                    if (!entCacheResDto.getId().equals(longUserCacheResDtoMap.get(createBy).getEntInfo().getId())) {
+                        kwmCooperateType.setType(commonBusinessService.changeCooperateType(kwmCooperateType.getType()));
+                    }
+                }
+            }
+
+            cooperateQueryDto.setKwmCooperateTypeList(kwmCooperateTypeList);
             list.add(cooperateQueryDto);
         }
 
@@ -494,7 +506,6 @@ public class KwmCooperateApplyService {
                     in(KwmCooperateType::getStatus, statusList).
                     eq(KwmCooperateType::getDelFlag, Global.NO));
             List<KwmCooperateType> updateKwmCooperateTypes = kwmCooperateTypes.stream().filter(x -> x.getStatus().equals(CooperateStatusEnum.PROCESS.getCode())).toList();
-            List<Integer> currentStatusList = updateKwmCooperateTypes.stream().map(KwmCooperateType::getStatus).toList();
             if (CollectionUtils.isEmpty(updateKwmCooperateTypes)) {
                 throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.COOPERATE_CANCEL_EXISTS);
             }
@@ -512,7 +523,8 @@ public class KwmCooperateApplyService {
             item.setUpdateBy(userId);
             item.setUpdateTime(date);
             item.setApprovalRemark(remark);
-            if (!currentStatusList.contains(CooperateStatusEnum.OK.getCode())) {
+            List<Integer> currentStatusList = kwmCooperateTypes.stream().map(KwmCooperateType::getStatus).toList();
+            if (type.equals(CooperateStatusEnum.OK.getCode()) || (type.equals(CooperateStatusEnum.CANCEL.getCode()) && !currentStatusList.contains(CooperateStatusEnum.OK.getCode()))) {
                 item.setStatus(type);
             }
             if (kwmCooperateMapper.updateById(item) <= 0) {

+ 23 - 10
sckw-modules/sckw-manage/src/main/java/com/sckw/manage/service/KwmCooperateManageService.java

@@ -423,7 +423,7 @@ public class KwmCooperateManageService {
         Long id = reqVo.getId();
         List<KwmCooperate> kwmCooperates = kwmCooperateMapper.findEntCooperate(reqVo);
         if (CollectionUtils.isEmpty(kwmCooperates)) {
-            return null;
+            return Collections.emptyList();
         }
 
         List<KwmCooperateType> kwmCooperateTypeList = new ArrayList<>();
@@ -517,6 +517,7 @@ public class KwmCooperateManageService {
         LambdaQueryWrapper<KwmCooperateType> wrapper = new LambdaQueryWrapper<>();
         wrapper.in(KwmCooperateType::getCooperateId, cooperateIdList);
         wrapper.eq(KwmCooperateType::getDelFlag, Global.NO);
+        wrapper.eq(KwmCooperateType::getStatus, CooperateStatusEnum.OK.getCode());
         List<KwmCooperateType> kwmCooperateTypes = kwmCooperateTypeMapper.selectList(wrapper);
         Map<Long, List<KwmCooperateType>> collect = new HashMap<>(Global.NUMERICAL_SIXTEEN);
         if (CollectionUtils.isNotEmpty(kwmCooperateTypes)) {
@@ -537,16 +538,11 @@ public class KwmCooperateManageService {
         }
 
         List<FindCooperateByEntResVo> list = new ArrayList<>();
+        List<Integer> cooperateTypeList = new ArrayList<>();
         for (KwmCooperate kwmCooperate : kwmCooperates) {
             FindCooperateByEntResVo findCooperateByEntResVo = new FindCooperateByEntResVo();
             findCooperateByEntResVo.setId(kwmCooperate.getId());
             findCooperateByEntResVo.setRemark(kwmCooperate.getRemark());
-            //设置合作属性
-            List<KwmCooperateType> kwmCooperateTypes1 = collect.get(kwmCooperate.getId());
-            if (CollectionUtils.isNotEmpty(kwmCooperateTypes1)) {
-                findCooperateByEntResVo.setCooperateTypes(String.join(Global.COMMA, kwmCooperateTypes1.stream().map(KwmCooperateType::getType).map(String::valueOf).toList()));
-            }
-
             //设置发起企业
             EntCacheResDto entCacheResDto = entMap.get(kwmCooperate.getEntId());
             findCooperateByEntResVo.setInitiateEntId(kwmCooperate.getEntId());
@@ -561,9 +557,24 @@ public class KwmCooperateManageService {
 
 
             Long entId = reqVo.getEntId();
-
-            Map<Long, EntCacheResDto> longEntCacheResDtoMap = remoteSystemService.queryEntTreeByIds(Collections.singletonList(entId));
-            Long topId = longEntCacheResDtoMap.get(entId).getId();
+            Map<Long, EntCacheResDto> entCacheResDtoMap = remoteSystemService.queryEntTreeByIds(Collections.singletonList(entId));
+            Long topId = entCacheResDtoMap.get(entId).getId();
+            //设置合作属性
+            List<KwmCooperateType> kwmCooperateTypeList = collect.get(kwmCooperate.getId());
+            List<Long> userIds = kwmCooperateTypeList.stream().map(KwmCooperateType::getCreateBy).toList();
+            Map<Long, UserCacheResDto> userCacheResDtoMap = remoteSystemService.queryUserCacheMapByIds(userIds);
+            for (KwmCooperateType kwmCooperateType : kwmCooperateTypeList) {
+                Long createBy = kwmCooperateType.getCreateBy();
+                UserCacheResDto userCacheResDto = userCacheResDtoMap.get(createBy);
+                Long id = userCacheResDto.getEntInfo().getId();
+                if (id.equals(topId)) {
+                    cooperateTypeList.add(kwmCooperateType.getType());
+                } else {
+                    cooperateTypeList.add(commonBusinessService.changeCooperateType(kwmCooperateType.getType()));
+                }
+            }
+            String cooperateTypes = String.join(Global.COMMA, cooperateTypeList.stream().map(String::valueOf).distinct().toList());
+            findCooperateByEntResVo.setCooperateTypes(cooperateTypes);
             //设置我方和对方企业信息、联系人
             if (topId.equals(kwmCooperate.getEntId())) {
                 findCooperateByEntResVo.setEntId(kwmCooperate.getInviterEntId());
@@ -589,10 +600,12 @@ public class KwmCooperateManageService {
                 findCooperateByEntResVo.setTargetPhone(kwmCooperate.getInviterPhone());
             }
             list.add(findCooperateByEntResVo);
+            cooperateTypeList.clear();
         }
         return list;
     }
 
+
     public void restore(String ids, Integer type) {
         dissolve(ids, type);
     }

+ 2 - 1
sckw-modules/sckw-manage/src/main/resources/mapper/KwmCooperateMapper.xml

@@ -134,7 +134,7 @@
     <select id="findManageList" resultType="com.sckw.manage.model.dto.res.CooperateManageQueryResDto">
         SELECT a.id,
                 min(a.status) status,
-                group_concat(b.type) types,
+                group_concat(concat(b.type, '#', b.create_by)) types,
                 min(a.ent_id) entId,
                 min(a.invitee_ent_id) inviteeEntId,
                 min(a.inviter_ent_id) inviterEntId,
@@ -146,6 +146,7 @@
                 min(a.inviter_phone) inviterPhone,
                 min(b.create_time) createTime,
                 min(b.create_by) createBy,
+                group_concat(b.create_by) createByStr,
                 min(a.remark) remark,
                 min(a.approval_remark) approvalRemark,
                 case when min(a.ent_id) = #{reqDto.currentEntId} then min(a.invitee_ent_id) else min(a.inviter_ent_id) end targetEntId,

+ 1 - 1
sckw-modules/sckw-message/src/main/java/com/sckw/message/model/vo/res/KwmMessageListResVO.java

@@ -59,7 +59,7 @@ public class KwmMessageListResVO implements Serializable {
     /**
      * 提交人
      */
-    private Long creatBy;
+    private Long createBy;
 
     /**
      * 提交人姓名

+ 14 - 12
sckw-modules/sckw-order/src/main/java/com/sckw/order/dubbo/TradeOrderInfoServiceImpl.java

@@ -3,7 +3,6 @@ package com.sckw.order.dubbo;
 import com.alibaba.fastjson2.JSON;
 import com.google.common.collect.Lists;
 import com.sckw.contract.api.RemoteContractService;
-import com.sckw.core.common.enums.enums.DictEnum;
 import com.sckw.core.exception.BusinessException;
 import com.sckw.core.utils.BeanUtils;
 import com.sckw.core.utils.CollectionUtils;
@@ -12,6 +11,8 @@ import com.sckw.core.web.response.HttpResult;
 import com.sckw.mongo.model.SckwTradeOrder;
 import com.sckw.order.api.dubbo.TradeOrderInfoService;
 import com.sckw.order.api.model.*;
+import com.sckw.order.enums.DeliveryTypeEnum;
+import com.sckw.order.enums.OrderStatusEnum;
 import com.sckw.order.model.KwoTradeOrder;
 import com.sckw.order.model.KwoTradeOrderContract;
 import com.sckw.order.model.KwoTradeOrderTrack;
@@ -76,12 +77,12 @@ public class TradeOrderInfoServiceImpl implements TradeOrderInfoService {
         }
         Integer status = param.getStatus();
         Long updateBy = param.getUpdateBy();
-        if (Objects.equals(String.valueOf(status), DictEnum.TORDER_STATUS_6.getValue())) {
-            if (!Objects.equals(String.valueOf(order.getStatus()), DictEnum.TORDER_STATUS_5.getValue())) {
+        if (Objects.equals(status, OrderStatusEnum.RECONCILED.getCode())) {
+            if (!Objects.equals(order.getStatus(), OrderStatusEnum.FINISHED.getCode())) {
                 throw new BusinessException("已完结的订单才可对账!");
             }
-        } else if (Objects.equals(String.valueOf(status), DictEnum.TORDER_STATUS_7.getValue())) {
-            if (!Objects.equals(String.valueOf(order.getStatus()), DictEnum.TORDER_STATUS_6.getValue())) {
+        } else if (Objects.equals(status, OrderStatusEnum.SETTLED.getCode())) {
+            if (!Objects.equals(order.getStatus(), OrderStatusEnum.RECONCILED.getCode())) {
                 throw new BusinessException("已对账的订单才可结算!");
             }
         } else {
@@ -123,7 +124,7 @@ public class TradeOrderInfoServiceImpl implements TradeOrderInfoService {
             if (Objects.isNull(order)) {
                 return HttpResult.error("订单不存在!");
             }
-            if (!Objects.equals(String.valueOf(order.getStatus()), DictEnum.TORDER_STATUS_4.getValue())) {
+            if (!Objects.equals(order.getStatus(), OrderStatusEnum.EXECUTING.getCode())) {
                 return HttpResult.error("执行中的订单才可物流托运!");
             }
             BigDecimal totalEntrustAmount = Objects.isNull(order.getEntrustAmount()) ?
@@ -170,18 +171,18 @@ public class TradeOrderInfoServiceImpl implements TradeOrderInfoService {
             if (Objects.isNull(order)) {
                 return HttpResult.error("订单不存在!");
             }
-            if (!Objects.equals(String.valueOf(order.getStatus()), DictEnum.TORDER_STATUS_4.getValue())) {
+            if (!Objects.equals(order.getStatus(), OrderStatusEnum.EXECUTING.getCode())) {
                 return HttpResult.error("执行中的订单才可物流托运!");
             }
             BigDecimal actualAmount = Objects.isNull(order.getActualAmount()) ? BigDecimal.ZERO : order.getActualAmount();
-            BigDecimal addActualAmount = Objects.equals(order.getDeliveryType(), DictEnum.DELIVERY_TYPE_0.getValue())
+            BigDecimal addActualAmount = Objects.equals(order.getDeliveryType(), DeliveryTypeEnum.ISSUE.getType())
                     ? actualLoadAmount : actualUnloadAmount;
             BigDecimal totalActualAmount = actualAmount.add(addActualAmount);
             order.setActualAmount(totalActualAmount).setUpdateBy(param.getUpdateBy());
             //不走自然完结
 //            if (param.getIsAllComplete() && actualAmount.compareTo(order.getAmount()) >= 0) {
 //                //完结订单
-//                order.setStatus(Integer.valueOf(DictEnum.TORDER_STATUS_5.getValue()));
+//                order.setStatus(OrderStatusEnum.FINISHED.getCode());
 //                //记录状态
 //                KwoTradeOrderTrack track = new KwoTradeOrderTrack();
 //                track.setTOrderId(order.getId()).setTOrderNo(order.getTOrderNo()).setStatus(order.getStatus())
@@ -235,11 +236,12 @@ public class TradeOrderInfoServiceImpl implements TradeOrderInfoService {
             kwoTradeOrderService.contractCompletedUpdate(ids, updateBy);
             orders.forEach(e -> {
                 KwoTradeOrderTrack track = new KwoTradeOrderTrack();
-                track.setTOrderId(e.getId()).setTOrderNo(e.getTOrderNo()).setStatus(Integer.valueOf(DictEnum.TORDER_STATUS_4.getValue()))
+                track.setTOrderId(e.getId()).setTOrderNo(e.getTOrderNo())
+                        .setStatus(OrderStatusEnum.EXECUTING.getCode())
                         .setCreateBy(updateBy).setUpdateBy(updateBy);
                 tracks.add(track);
                 SckwTradeOrder updateParam = new SckwTradeOrder();
-                updateParam.setTOrderId(e.getId()).setStatus(Integer.valueOf(DictEnum.TORDER_STATUS_4.getValue()))
+                updateParam.setTOrderId(e.getId()).setStatus(OrderStatusEnum.EXECUTING.getCode())
                         .setUpdateBy(updateBy).setUpdateByName(param.getUpdateByName()).setUpdateTime(new Date());
                 tradeOrders.add(updateParam);
             });
@@ -266,7 +268,7 @@ public class TradeOrderInfoServiceImpl implements TradeOrderInfoService {
         if (Objects.isNull(order)) {
             throw new BusinessException("订单不存在!");
         }
-        if (!Objects.equals(String.valueOf(order.getStatus()), DictEnum.TORDER_STATUS_5.getValue())) {
+        if (!Objects.equals(order.getStatus(), OrderStatusEnum.FINISHED.getCode())) {
             throw new BusinessException("已完结的订单才可对账!");
         }
         order.setAssociateStatement(associateStatement).setUpdateBy(updateBy).setUpdateTime(new Date());

+ 23 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/enums/ContractStatusEnum.java

@@ -0,0 +1,23 @@
+package com.sckw.order.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * @desc: 合同状态枚举
+ * @author: yzc
+ * @date: 2023-09-18 16:03
+ */
+@Getter
+@AllArgsConstructor
+public enum ContractStatusEnum {
+
+    /**
+     * 合同状态枚举
+     */
+    SIGNED("0", "已签约"),
+    WAIT_SIGNED("1", "待签约");
+
+    private final String code;
+    private final String msg;
+}

+ 30 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/enums/DeliveryTypeEnum.java

@@ -0,0 +1,30 @@
+package com.sckw.order.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * @desc: 交付类型枚举
+ * @author: yzc
+ * @date: 2023-09-18 15:42
+ */
+@Getter
+@AllArgsConstructor
+public enum DeliveryTypeEnum {
+
+    ISSUE("0", "签发交付"),
+    SIGN("1", "签收交付");
+
+    private final String type;
+
+    private final String label;
+
+    public static String getLabel(String type) {
+        for (DeliveryTypeEnum ele : DeliveryTypeEnum.values()) {
+            if (ele.getType().equals(type)) {
+                return ele.getLabel();
+            }
+        }
+        return null;
+    }
+}

+ 30 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/enums/OrderAddressTypeEnum.java

@@ -0,0 +1,30 @@
+package com.sckw.order.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * @desc: 订单地址类型枚举
+ * @author: yzc
+ * @date: 2023-09-18 15:42
+ */
+@Getter
+@AllArgsConstructor
+public enum OrderAddressTypeEnum {
+
+    LOAD("1", "装货地址"),
+    UNLOAD("2", "卸货地址");
+
+    private final String type;
+
+    private final String label;
+
+    public static String getLabel(String type) {
+        for (OrderAddressTypeEnum ele : OrderAddressTypeEnum.values()) {
+            if (ele.getType().equals(type)) {
+                return ele.getLabel();
+            }
+        }
+        return null;
+    }
+}

+ 30 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/enums/OrderSourceEnum.java

@@ -0,0 +1,30 @@
+package com.sckw.order.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * @desc: 订单来源枚举
+ * @author: yzc
+ * @date: 2023-09-18 15:42
+ */
+@Getter
+@AllArgsConstructor
+public enum OrderSourceEnum {
+
+    PURCHASE("1", "采购下单"),
+    SALE("2", "代客下单");
+
+    private final String type;
+
+    private final String label;
+
+    public static String getLabel(String type) {
+        for (OrderSourceEnum ele : OrderSourceEnum.values()) {
+            if (ele.getType().equals(type)) {
+                return ele.getLabel();
+            }
+        }
+        return null;
+    }
+}

+ 39 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/enums/OrderStatusEnum.java

@@ -0,0 +1,39 @@
+package com.sckw.order.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * @desc: 订单状态枚举
+ * @author: yzc
+ * @date: 2023-09-18 15:32
+ */
+@Getter
+@AllArgsConstructor
+public enum OrderStatusEnum {
+
+    /**
+     * 订单状态枚举
+     */
+    SAVED(0, "已保存"),
+    WAIT_ACCEPTED(1, "待受理"),
+    RETURNED(2, "已退回"),
+    WAIT_SIGNED(3, "待签约"),
+    EXECUTING(4, "执行中"),
+    FINISHED(5, "已完结"),
+    RECONCILED(6, "已对账"),
+    SETTLED(7, "已结算");
+
+    private final Integer code;
+    private final String msg;
+
+    public static String getMsg(Integer code) {
+        for (OrderStatusEnum ele : OrderStatusEnum.values()) {
+            if (ele.getCode().equals(code)) {
+                return ele.getMsg();
+            }
+        }
+        return null;
+    }
+
+}

+ 30 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/enums/OrderUnitTypeEnum.java

@@ -0,0 +1,30 @@
+package com.sckw.order.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * @desc: 订单单位类型枚举
+ * @author: yzc
+ * @date: 2023-09-18 15:42
+ */
+@Getter
+@AllArgsConstructor
+public enum OrderUnitTypeEnum {
+
+    PURCHASE("1", "采购单位"),
+    SALE("2", "销售单位");
+
+    private final String type;
+
+    private final String label;
+
+    public static String getLabel(String type) {
+        for (OrderUnitTypeEnum ele : OrderUnitTypeEnum.values()) {
+            if (ele.getType().equals(type)) {
+                return ele.getLabel();
+            }
+        }
+        return null;
+    }
+}

+ 46 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/enums/TransportDemandStatusEnum.java

@@ -0,0 +1,46 @@
+package com.sckw.order.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+/**
+ * @desc: 运需状态枚举
+ * @author: yzc
+ * @date: 2023-09-19 9:42
+ */
+@AllArgsConstructor
+@Getter
+public enum TransportDemandStatusEnum {
+
+    /**
+     * 运需状态枚举
+     */
+    SAVED(0, "已保存"),
+    PUT_ON_SHELVES(1, "已上架"),
+    TAKE_OFF_SHELVES(2, "已下架");
+
+    private final Integer code;
+    private final String msg;
+
+
+    public static String getNameByCode(Integer code) {
+        TransportDemandStatusEnum[] enums = TransportDemandStatusEnum.values();
+        for (TransportDemandStatusEnum instance : enums) {
+            if (Objects.equals(instance.getCode(), code)) {
+                return instance.getMsg();
+            }
+        }
+        return null;
+    }
+
+    public static List<TransportDemandStatusEnum> getSortList() {
+        TransportDemandStatusEnum[] enums = TransportDemandStatusEnum.values();
+        return Arrays.stream(enums).sorted(Comparator.comparingInt(TransportDemandStatusEnum::getCode)).collect(Collectors.toList());
+    }
+}

+ 47 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/enums/WantBuyStatusEnum.java

@@ -0,0 +1,47 @@
+package com.sckw.order.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+/**
+ * @desc: 求购状态枚举
+ * @author: yzc
+ * @date: 2023-07-06 13:53
+ */
+@AllArgsConstructor
+@Getter
+public enum WantBuyStatusEnum {
+
+    /**
+     * 求购状态枚举
+     */
+    SAVED(0, "已保存"),
+    PUT_ON_SHELVES(1, "已上架"),
+    TAKE_OFF_SHELVES(2, "已下架");
+
+    private final Integer code;
+    private final String msg;
+
+
+    public static String getNameByCode(Integer code) {
+        WantBuyStatusEnum[] enums = WantBuyStatusEnum.values();
+        for (WantBuyStatusEnum instance : enums) {
+            if (Objects.equals(instance.getCode(), code)) {
+                return instance.getMsg();
+            }
+        }
+        return null;
+    }
+
+    public static List<WantBuyStatusEnum> getSortList() {
+        WantBuyStatusEnum[] enums = WantBuyStatusEnum.values();
+        return Arrays.stream(enums).sorted(Comparator.comparingInt(WantBuyStatusEnum::getCode)).collect(Collectors.toList());
+    }
+
+}

+ 10 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/res/GoodsInfoDetailRes.java

@@ -48,6 +48,16 @@ public class GoodsInfoDetailRes implements Serializable {
      */
     private String taxRate;
 
+    /**
+     * 是否设置预付限额0否1是
+     */
+    private Integer prepaidLimit;
+
+    /**
+     * 预付款最低限额
+     */
+    private BigDecimal advancePrice;
+
     /**
      * 商品尺寸大小
      */

+ 97 - 63
sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwoTradeOrderService.java

@@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.sckw.contract.api.RemoteContractService;
 import com.sckw.contract.api.model.dto.res.ContractCommonInfoResDto;
-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.exception.CustomPromptException;
@@ -24,6 +23,7 @@ import com.sckw.manage.api.model.dto.res.FindEntCooperateResVo;
 import com.sckw.mongo.model.SckwTradeOrder;
 import com.sckw.order.api.model.TradeOrderCountStatisticsDTO;
 import com.sckw.order.dao.KwoTradeOrderMapper;
+import com.sckw.order.enums.*;
 import com.sckw.order.model.*;
 import com.sckw.order.model.dto.OrderCheckDTO;
 import com.sckw.order.model.dto.WbTOrderExcelStsReqDTO;
@@ -120,7 +120,7 @@ public class KwoTradeOrderService {
         KwoTradeOrder order = BeanUtils.copyProperties(param, KwoTradeOrder.class);
         order.setEntId(LoginUserHolder.getEntId()).setTOrderNo(getOrderNo())
                 .setUnit(Objects.nonNull(param.getGoodsInfo()) ? param.getGoodsInfo().getUnit() : null)
-                .setSource(DictEnum.TORDER_SOURCE_1.getValue()).setStatus(Integer.valueOf(DictEnum.TORDER_STATUS_0.getValue()));
+                .setSource(OrderSourceEnum.PURCHASE.getType()).setStatus(OrderStatusEnum.SAVED.getCode());
         kwoTradeOrderMapper.insert(order);
         addOtherOrderInfo(order, BeanUtils.copyProperties(param, ValetOrderParam.class), false);
     }
@@ -183,7 +183,7 @@ public class KwoTradeOrderService {
                 KwoTradeOrderUnit unit = BeanUtils.copyProperties(e, KwoTradeOrderUnit.class);
                 unit.setTOrderId(id).setTOrderNo(tOrderNo).setTopEntId(ent.getId());
                 list.add(unit);
-                if (Objects.equals(e.getUnitType(), DictEnum.TORDER_UNIT_TYPE_1.getValue())) {
+                if (Objects.equals(e.getUnitType(), OrderUnitTypeEnum.PURCHASE.getType())) {
                     order.setProcureEntId(e.getEntId()).setProcureTopEntId(unit.getTopEntId()).setProcureFirmName(e.getFirmName())
                             .setProcureContacts(e.getContacts()).setProcurePhone(e.getPhone()).setProcureContactsId(e.getContactsId());
                 } else {
@@ -202,7 +202,7 @@ public class KwoTradeOrderService {
                 KwoTradeOrderAddress address = BeanUtils.copyProperties(e, KwoTradeOrderAddress.class);
                 address.setTOrderId(id).setTOrderNo(tOrderNo);
                 list.add(address);
-                if (Objects.equals(e.getAddressType(), DictEnum.TORDER_ADDRESS_TYPE_1.getValue())) {
+                if (Objects.equals(e.getAddressType(), OrderAddressTypeEnum.LOAD.getType())) {
                     order.setLoadName(e.getName()).setLoadType(e.getType()).setLoadContacts(e.getContacts())
                             .setLoadPhone(e.getPhone()).setLoadCityCode(String.valueOf(e.getCityCode())).setLoadCityName(e.getCityName())
                             .setLoadDetailAddress(e.getDetailAddress()).setLoadLat(e.getLat()).setLoadLng(e.getLng());
@@ -224,7 +224,7 @@ public class KwoTradeOrderService {
             BeanUtils.copyProperties(contractInfo, order);
         }
         //状态信息(草稿更新不加状态记录)
-        if (!isUpdate || !Objects.equals(DictEnum.TORDER_STATUS_0.getValue(), String.valueOf(tradeOrder.getStatus()))) {
+        if (!isUpdate || !Objects.equals(OrderStatusEnum.SAVED.getCode(), tradeOrder.getStatus())) {
             KwoTradeOrderTrack track = new KwoTradeOrderTrack();
             track.setTOrderId(id).setTOrderNo(tOrderNo).setStatus(tradeOrder.getStatus()).setRemark(tradeOrder.getRemark());
             kwoTradeOrderTrackService.insert(track);
@@ -262,7 +262,7 @@ public class KwoTradeOrderService {
         KwoTradeOrder order = BeanUtils.copyProperties(param, KwoTradeOrder.class);
         order.setEntId(LoginUserHolder.getEntId()).setTOrderNo(getOrderNo())
                 .setUnit(Objects.nonNull(param.getGoodsInfo()) ? param.getGoodsInfo().getUnit() : null)
-                .setSource(DictEnum.TORDER_SOURCE_2.getValue()).setStatus(Integer.valueOf(DictEnum.TORDER_STATUS_0.getValue()));
+                .setSource(OrderSourceEnum.SALE.getType()).setStatus(OrderStatusEnum.SAVED.getCode());
         kwoTradeOrderMapper.insert(order);
         addOtherOrderInfo(order, BeanUtils.copyProperties(param, ValetOrderParam.class), false);
     }
@@ -282,12 +282,13 @@ public class KwoTradeOrderService {
         OrderCheckDTO orderCheck = BeanUtils.copyProperties(param, OrderCheckDTO.class);
         getTopEnt(orderCheck, param.getUnitInfo());
         orderCheck.setGoodsId(goodsInfo.getGoodsId()).setUnitPrice(goodsInfo.getUnitPrice())
-                .setOrderSource(DictEnum.TORDER_SOURCE_1.getValue());
+                .setOrderSource(OrderSourceEnum.PURCHASE.getType());
         orderCheck(orderCheck, false);
         KwoTradeOrder order = BeanUtils.copyProperties(param, KwoTradeOrder.class);
         order.setEntId(LoginUserHolder.getEntId()).setTOrderNo(getOrderNo())
-                .setUnit(param.getGoodsInfo().getUnit()).setSource(DictEnum.TORDER_SOURCE_1.getValue())
-                .setStatus(Integer.valueOf(DictEnum.TORDER_STATUS_1.getValue()));
+                .setUnit(param.getGoodsInfo().getUnit())
+                .setSource(OrderSourceEnum.PURCHASE.getType())
+                .setStatus(OrderStatusEnum.WAIT_ACCEPTED.getCode());
         kwoTradeOrderMapper.insert(order);
         //扣减库存
         HttpResult updateResult = goodsInfoService.updateGoodsAmount(param.getGoodsInfo().getGoodsId(), param.getAmount());
@@ -316,7 +317,7 @@ public class KwoTradeOrderService {
         UserInfo createUser = new UserInfo();
         createUser.setUserId(LoginUserHolder.getUserId()).setEntId(LoginUserHolder.getEntId());
         userInfos.add(createUser);
-        boolean flag = Objects.equals(orderCheck.getOrderSource(), DictEnum.TORDER_SOURCE_1.getValue());
+        boolean flag = Objects.equals(orderCheck.getOrderSource(), OrderSourceEnum.PURCHASE.getType());
         UserInfo procureUser = orderCheck.getProcureUser();
         String procureFireName = orderCheck.getProcureFireName();
         UserInfo supplyUser = orderCheck.getSupplyUser();
@@ -388,7 +389,7 @@ public class KwoTradeOrderService {
                 log.error("企业:{}找不到对应一级企业信息", entId);
                 throw new BusinessException("一级企业信息不存在!");
             }
-            if (Objects.equals(e.getUnitType(), DictEnum.TORDER_UNIT_TYPE_1.getValue())) {
+            if (Objects.equals(e.getUnitType(), OrderUnitTypeEnum.PURCHASE.getType())) {
                 UserInfo procureUser = new UserInfo();
                 orderCheck.setProcureTopEntId(ent.getId());
                 orderCheck.setProcureEntId(entId);
@@ -423,7 +424,7 @@ public class KwoTradeOrderService {
                 throw new BusinessException("订单总金额不等于商品单价*订单总量!");
             }
             List<FindEntCooperateResVo> entCooperate;
-            if (DictEnum.TORDER_SOURCE_1.getValue().equals(param.getOrderSource())) {
+            if (OrderSourceEnum.PURCHASE.getType().equals(param.getOrderSource())) {
                 entCooperate = remoteManageService.findEntCooperate(param.getProcureEntId()
                         , param.getSupplyEntId(), CooperateTypeEnum.SUPPLIER.getCode());
             } else {
@@ -445,7 +446,7 @@ public class KwoTradeOrderService {
         if (trading.startsWith("1")) {
             BigDecimal advancePrice = goods.getAdvancePrice().multiply(new BigDecimal("10000"));
             //直接采购下单才校验预付款限额
-            if (Objects.equals(param.getOrderSource(), DictEnum.TORDER_SOURCE_1.getValue()) && price.compareTo(advancePrice) < 0) {
+            if (Objects.equals(param.getOrderSource(), OrderSourceEnum.PURCHASE.getType()) && price.compareTo(advancePrice) < 0) {
                 throw new BusinessException("您的订单总额未达到预付限额,请确认");
             }
             R<List<WalletDto>> wallet = payCenterDubboService.wallet(param.getProcureTopEntId(), ChannelEnum.getByCode(trading), param.getSupplyTopEntId());
@@ -474,19 +475,19 @@ public class KwoTradeOrderService {
         OrderCheckDTO orderCheck = BeanUtils.copyProperties(param, OrderCheckDTO.class);
         getTopEnt(orderCheck, param.getUnitInfo());
         orderCheck.setGoodsId(param.getGoodsInfo().getGoodsId()).setUnitPrice(param.getGoodsInfo().getUnitPrice())
-                .setOrderSource(DictEnum.TORDER_SOURCE_2.getValue());
+                .setOrderSource(OrderSourceEnum.SALE.getType());
         orderCheck(orderCheck, false);
         ContractInfo contract = param.getContractInfo();
         contractCheck(contract);
         param.setContractInfo(contract);
         KwoTradeOrder order = BeanUtils.copyProperties(param, KwoTradeOrder.class);
         order.setEntId(LoginUserHolder.getEntId()).setTOrderNo(getOrderNo())
-                .setUnit(param.getGoodsInfo().getUnit()).setSource(DictEnum.TORDER_SOURCE_2.getValue());
+                .setUnit(param.getGoodsInfo().getUnit()).setSource(OrderSourceEnum.SALE.getType());
         String contractStatus = contract.getContractStatus();
-        if (Objects.equals(contractStatus, DictEnum.CONTRACT_STATUS_0.getValue())) {
-            order.setStatus(Integer.valueOf(DictEnum.TORDER_STATUS_3.getValue()));
-        } else if (Objects.equals(contractStatus, DictEnum.CONTRACT_STATUS_1.getValue())) {
-            order.setStatus(Integer.valueOf(DictEnum.TORDER_STATUS_4.getValue()));
+        if (Objects.equals(contractStatus, ContractStatusEnum.WAIT_SIGNED.getCode())) {
+            order.setStatus(OrderStatusEnum.WAIT_SIGNED.getCode());
+        } else if (Objects.equals(contractStatus, ContractStatusEnum.SIGNED.getCode())) {
+            order.setStatus(OrderStatusEnum.EXECUTING.getCode());
         } else {
             throw new BusinessException("Invalid contract status");
         }
@@ -578,7 +579,7 @@ public class KwoTradeOrderService {
                     process.setRoleName(String.join(",", roleNames));
                 }
             }
-            process.setStatusLabel(DictEnum.getLabel(DictTypeEnum.TORDER_STATUS.getType(), String.valueOf(process.getStatus())));
+            process.setStatusLabel(OrderStatusEnum.getMsg(process.getStatus()));
             orderProcesses.add(process);
         });
         detail.setOrderProcess(orderProcesses);
@@ -597,17 +598,48 @@ public class KwoTradeOrderService {
         if (Objects.isNull(order)) {
             throw new BusinessException("不存在该订单!");
         }
+        Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(
+                List.of(DictTypeEnum.TRADE_TYPE.getType(), DictTypeEnum.PICKUP_TYPE.getType(),
+                        DictTypeEnum.DELIVERY_TYPE.getType(), DictTypeEnum.TORDER_SOURCE.getType(), DictTypeEnum.TORDER_STATUS.getType(),
+                        DictTypeEnum.PRODUCT_NAME_TYPE.getType(), DictTypeEnum.UNIT_TYPE.getType(), DictTypeEnum.TAX_RATE.getType(),
+                        DictTypeEnum.TORDER_UNIT_TYPE.getType(), DictTypeEnum.TORDER_ADDRESS_TYPE.getType(), DictTypeEnum.ADDRESS_TYPE.getType()));
+        Map<String, String> tradeMap = new HashMap<>();
+        Map<String, String> pickupMap = new HashMap<>();
+        Map<String, String> deleveryMap = new HashMap<>();
+        Map<String, String> sourceMap = new HashMap<>();
+        Map<String, String> statusMap = new HashMap<>();
+        Map<String, String> prodcutNameMap = new HashMap<>();
+        Map<String, String> unitMap = new HashMap<>();
+        Map<String, String> taxRateMap = new HashMap<>();
+        Map<String, String> orderUnitMap, orderAddressMap, addressMap;
+        if (CollectionUtils.isNotEmpty(dict)) {
+            tradeMap = dict.get(DictTypeEnum.TRADE_TYPE.getType());
+            pickupMap = dict.get(DictTypeEnum.PICKUP_TYPE.getType());
+            deleveryMap = dict.get(DictTypeEnum.DELIVERY_TYPE.getType());
+            sourceMap = dict.get(DictTypeEnum.TORDER_SOURCE.getType());
+            statusMap = dict.get(DictTypeEnum.TORDER_STATUS.getType());
+            prodcutNameMap = dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType());
+            unitMap = dict.get(DictTypeEnum.UNIT_TYPE.getType());
+            taxRateMap = dict.get(DictTypeEnum.TAX_RATE.getType());
+            orderUnitMap = dict.get(DictTypeEnum.TORDER_UNIT_TYPE.getType());
+            orderAddressMap = dict.get(DictTypeEnum.TORDER_ADDRESS_TYPE.getType());
+            addressMap = dict.get(DictTypeEnum.ADDRESS_TYPE.getType());
+        } else {
+            orderUnitMap = new HashMap<>();
+            orderAddressMap = new HashMap<>();
+            addressMap = new HashMap<>();
+        }
         //订单基本信息
         OrderDetailRes detail = BeanUtils.copyProperties(order, OrderDetailRes.class);
         UserCacheResDto createUser = remoteSystemService.queryUserCacheById(detail.getCreateBy());
         EntCacheResDto ent = remoteSystemService.queryEntCacheById(detail.getEntId());
         detail.setFirmName(Objects.isNull(ent) ? null : ent.getFirmName())
                 .setCreateByName(Objects.isNull(createUser) ? null : createUser.getName())
-                .setTradingLabel(DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), detail.getTrading()))
-                .setPickupTypeLabel(DictEnum.getLabel(DictTypeEnum.PICKUP_TYPE.getType(), detail.getPickupType()))
-                .setDeliveryTypeLabel(DictEnum.getLabel(DictTypeEnum.DELIVERY_TYPE.getType(), detail.getDeliveryType()))
-                .setSourceLabel(DictEnum.getLabel(DictTypeEnum.TORDER_SOURCE.getType(), detail.getSource()))
-                .setStatusLabel(DictEnum.getLabel(DictTypeEnum.TORDER_STATUS.getType(), String.valueOf(detail.getStatus())));
+                .setTradingLabel(CollectionUtils.isNotEmpty(tradeMap) ? tradeMap.get(detail.getTrading()) : null)
+                .setPickupTypeLabel(CollectionUtils.isNotEmpty(pickupMap) ? pickupMap.get(detail.getPickupType()) : null)
+                .setDeliveryTypeLabel(CollectionUtils.isNotEmpty(deleveryMap) ? deleveryMap.get(detail.getDeliveryType()) : null)
+                .setSourceLabel(CollectionUtils.isNotEmpty(sourceMap) ? sourceMap.get(detail.getSource()) : null)
+                .setStatusLabel(CollectionUtils.isNotEmpty(statusMap) ? statusMap.get(String.valueOf(detail.getStatus())) : null);
         //商品信息
         KwoTradeOrderGoods orderGoods = kwoTradeOrderGoodsService.getByOrderId(id);
         if (Objects.nonNull(orderGoods)) {
@@ -615,13 +647,15 @@ public class KwoTradeOrderService {
             if (Objects.nonNull(goods)) {
                 EntCacheResDto entCache = remoteSystemService.queryEntCacheById(goods.getEntId());
                 GoodsInfoDetailRes goodsDetail = new GoodsInfoDetailRes();
-                goodsDetail.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), goods.getGoodsType()))
-                        .setUnitLabel(DictEnum.getLabel(DictTypeEnum.UNIT_TYPE.getType(), goods.getUnit())).setGoodsAmount(goods.getAmount())
-                        .setTaxRateLabel(DictEnum.getLabel(DictTypeEnum.TAX_RATE.getType(), goods.getTaxRate()))
+                goodsDetail.setGoodsTypeLabel(CollectionUtils.isNotEmpty(prodcutNameMap) ? prodcutNameMap.get(goods.getGoodsType()) : null)
+                        .setUnitLabel(CollectionUtils.isNotEmpty(unitMap) ? unitMap.get(goods.getUnit()) : null)
+                        .setTaxRateLabel(CollectionUtils.isNotEmpty(taxRateMap) ? taxRateMap.get(goods.getTaxRate()) : null)
+                        .setGoodsAmount(goods.getAmount())
                         .setGoodsId(goods.getId()).setCode(goods.getCode()).setName(goods.getName())
                         .setGoodsType(goods.getGoodsType()).setTaxRate(goods.getTaxRate()).setSpec(goods.getSpec())
                         .setUnit(goods.getUnit()).setPriceRangeId(orderGoods.getPriceRangeId()).setUnitPrice(orderGoods.getUnitPrice())
                         .setSkuId(orderGoods.getSkuId()).setCollectionUnitId(goods.getEntId()).setGoodsThumb(goods.getThumb())
+                        .setPrepaidLimit(goods.getPrepaidLimit()).setAdvancePrice(goods.getAdvancePrice())
                         .setCollectionUnit(Objects.isNull(entCache) ? null : entCache.getFirmName());
                 detail.setGoodsInfo(goodsDetail);
             }
@@ -633,7 +667,7 @@ public class KwoTradeOrderService {
             List<UnitInfoDetailRes> unitInfos = new ArrayList<>(units.size());
             units.forEach(e -> {
                 UnitInfoDetailRes unit = BeanUtils.copyProperties(e, UnitInfoDetailRes.class);
-                unit.setUnitTypeLabel(DictEnum.getLabel(DictTypeEnum.TORDER_UNIT_TYPE.getType(), unit.getUnitType()));
+                unit.setUnitTypeLabel(CollectionUtils.isNotEmpty(orderUnitMap) ? orderUnitMap.get(unit.getUnitType()) : null);
                 unitInfos.add(unit);
             });
             detail.setUnitInfo(unitInfos);
@@ -644,8 +678,8 @@ public class KwoTradeOrderService {
             List<AddressInfoDetailRes> addressInfoDetails = new ArrayList<>(addressList.size());
             addressList.forEach(e -> {
                 AddressInfoDetailRes address = BeanUtils.copyProperties(e, AddressInfoDetailRes.class);
-                address.setAddressTypeLabel(DictEnum.getLabel(DictTypeEnum.TORDER_ADDRESS_TYPE.getType(), address.getAddressType()));
-                address.setTypeLabel(DictEnum.getLabel(DictTypeEnum.ADDRESS_TYPE.getType(), address.getType()));
+                address.setAddressTypeLabel(CollectionUtils.isNotEmpty(orderAddressMap) ? orderAddressMap.get(address.getAddressType()) : null);
+                address.setTypeLabel(CollectionUtils.isNotEmpty(addressMap) ? addressMap.get(address.getType()) : null);
                 addressInfoDetails.add(address);
             });
             detail.setAddressInfo(addressInfoDetails);
@@ -679,12 +713,12 @@ public class KwoTradeOrderService {
             throw new BusinessException("Order not found");
         }
         String source = order.getSource();
-        String status = String.valueOf(order.getStatus());
-        if ((!Objects.equals(status, DictEnum.TORDER_STATUS_0.getValue()) && !Objects.equals(status, DictEnum.TORDER_STATUS_2.getValue()))
-                && Objects.equals(source, DictEnum.TORDER_SOURCE_1.getValue())) {
+        Integer status = order.getStatus();
+        if ((!Objects.equals(status, OrderStatusEnum.SAVED.getCode()) && !Objects.equals(status, OrderStatusEnum.RETURNED.getCode()))
+                && Objects.equals(source, OrderSourceEnum.PURCHASE.getType())) {
             throw new BusinessException("采购下单只能修改已保存及已退回状态的订单!");
         }
-        if (Objects.equals(source, DictEnum.TORDER_SOURCE_2.getValue()) && !Objects.equals(status, DictEnum.TORDER_STATUS_0.getValue())) {
+        if (Objects.equals(source, OrderSourceEnum.SALE.getType()) && !Objects.equals(status, OrderStatusEnum.SAVED.getCode())) {
             throw new BusinessException("代客下单只能修改已保存状态的订单!");
         }
         if (!Objects.equals(0, order.getStatus())
@@ -694,17 +728,17 @@ public class KwoTradeOrderService {
         OrderCheckDTO orderCheck = new OrderCheckDTO();
         if (Objects.equals(param.getOperateType(), 1)) {
             checkParams(param, source);
-            if (Objects.equals(source, DictEnum.TORDER_SOURCE_1.getValue())) {
-                order.setStatus(Integer.valueOf(DictEnum.TORDER_STATUS_1.getValue()));
+            if (Objects.equals(source, OrderSourceEnum.PURCHASE.getType())) {
+                order.setStatus(OrderStatusEnum.WAIT_ACCEPTED.getCode());
             } else {
                 ContractInfo contract = param.getContractInfo();
                 contractCheck(contract);
                 param.setContractInfo(contract);
                 String contractStatus = contract.getContractStatus();
-                if (Objects.equals(contractStatus, DictEnum.CONTRACT_STATUS_0.getValue())) {
-                    order.setStatus(Integer.valueOf(DictEnum.TORDER_STATUS_3.getValue()));
-                } else if (Objects.equals(contractStatus, DictEnum.CONTRACT_STATUS_1.getValue())) {
-                    order.setStatus(Integer.valueOf(DictEnum.TORDER_STATUS_4.getValue()));
+                if (Objects.equals(contractStatus, ContractStatusEnum.WAIT_SIGNED.getCode())) {
+                    order.setStatus(OrderStatusEnum.WAIT_SIGNED.getCode());
+                } else if (Objects.equals(contractStatus, ContractStatusEnum.SIGNED.getCode())) {
+                    order.setStatus(OrderStatusEnum.EXECUTING.getCode());
                 } else {
                     throw new BusinessException("Invalid contract status");
                 }
@@ -755,7 +789,7 @@ public class KwoTradeOrderService {
             throw new BusinessException("结束时间不能为空!");
         }
         ContractInfo contractInfo = param.getContractInfo();
-        if (Objects.equals(source, DictEnum.TORDER_SOURCE_2.getValue())) {
+        if (Objects.equals(source, OrderSourceEnum.SALE.getType())) {
             if (StringUtils.isBlank(param.getDeliveryType())) {
                 throw new BusinessException("交付类型不能为空!");
             }
@@ -776,7 +810,7 @@ public class KwoTradeOrderService {
         if (StringUtils.isBlank(goodsInfo.getUnit())) {
             throw new BusinessException("商品单位不能为空!");
         }
-        if (Objects.isNull(goodsInfo.getPriceRangeId()) && Objects.equals(source, DictEnum.TORDER_SOURCE_1.getValue())) {
+        if (Objects.isNull(goodsInfo.getPriceRangeId()) && Objects.equals(source, OrderSourceEnum.PURCHASE.getType())) {
             throw new BusinessException("价格段id不能为空!");
         }
         if (Objects.isNull(goodsInfo.getUnitPrice()) || goodsInfo.getUnitPrice().compareTo(BigDecimal.ZERO) <= 0) {
@@ -861,10 +895,10 @@ public class KwoTradeOrderService {
         if (Objects.isNull(order)) {
             throw new BusinessException("Order not found");
         }
-        if (!Objects.equals(DictEnum.TORDER_STATUS_1.getValue(), String.valueOf(order.getStatus()))) {
+        if (!Objects.equals(OrderStatusEnum.WAIT_ACCEPTED.getCode(), order.getStatus())) {
             throw new BusinessException("订单状态不为待受理!");
         }
-        if (kwoTradeOrderUnitService.entMatch(order.getId(), LoginUserHolder.getEntId(), DictEnum.TORDER_UNIT_TYPE_2.getValue())) {
+        if (kwoTradeOrderUnitService.entMatch(order.getId(), LoginUserHolder.getEntId(), OrderUnitTypeEnum.SALE.getType())) {
             throw new BusinessException("无订单操作权限!");
         }
         KwoTradeOrderGoods goods = kwoTradeOrderGoodsService.getByOrderId(order.getId());
@@ -887,10 +921,10 @@ public class KwoTradeOrderService {
         ContractInfo contractInfo = param.getContractInfo();
         contractCheck(contractInfo);
         String contractStatus = contractInfo.getContractStatus();
-        if (Objects.equals(contractStatus, DictEnum.CONTRACT_STATUS_0.getValue())) {
-            order.setStatus(Integer.valueOf(DictEnum.TORDER_STATUS_3.getValue()));
-        } else if (Objects.equals(contractStatus, DictEnum.CONTRACT_STATUS_1.getValue())) {
-            order.setStatus(Integer.valueOf(DictEnum.TORDER_STATUS_4.getValue()));
+        if (Objects.equals(contractStatus, ContractStatusEnum.WAIT_SIGNED.getCode())) {
+            order.setStatus(OrderStatusEnum.WAIT_SIGNED.getCode());
+        } else if (Objects.equals(contractStatus, ContractStatusEnum.SIGNED.getCode())) {
+            order.setStatus(OrderStatusEnum.EXECUTING.getCode());
         } else {
             throw new BusinessException("Invalid contract status");
         }
@@ -942,13 +976,13 @@ public class KwoTradeOrderService {
         if (Objects.isNull(order)) {
             throw new BusinessException("Order not found");
         }
-        if (!Objects.equals(DictEnum.TORDER_STATUS_1.getValue(), String.valueOf(order.getStatus()))) {
+        if (!Objects.equals(OrderStatusEnum.WAIT_ACCEPTED.getCode(), order.getStatus())) {
             throw new BusinessException("订单状态不为待受理!");
         }
-        if (kwoTradeOrderUnitService.entMatch(order.getId(), LoginUserHolder.getEntId(), DictEnum.TORDER_UNIT_TYPE_2.getValue())) {
+        if (kwoTradeOrderUnitService.entMatch(order.getId(), LoginUserHolder.getEntId(), OrderUnitTypeEnum.SALE.getType())) {
             throw new BusinessException("无订单操作权限!");
         }
-        order.setStatus(Integer.valueOf(DictEnum.TORDER_STATUS_2.getValue()));
+        order.setStatus(OrderStatusEnum.RETURNED.getCode());
         kwoTradeOrderMapper.updateById(order);
         //订单状态记录
         KwoTradeOrderTrack track = new KwoTradeOrderTrack();
@@ -983,8 +1017,8 @@ public class KwoTradeOrderService {
         map.put("orderNo", order.getTOrderNo());
         Map<String, KwoTradeOrderUnit> unitMap = units.stream().collect
                 (Collectors.toMap(KwoTradeOrderUnit::getUnitType, Function.identity()));
-        KwoTradeOrderUnit purchase = unitMap.get(DictEnum.TORDER_UNIT_TYPE_1.getValue());
-        KwoTradeOrderUnit supply = unitMap.get(DictEnum.TORDER_UNIT_TYPE_2.getValue());
+        KwoTradeOrderUnit purchase = unitMap.get(OrderUnitTypeEnum.PURCHASE.getType());
+        KwoTradeOrderUnit supply = unitMap.get(OrderUnitTypeEnum.SALE.getType());
         //给供应企业联系人发消息
         map.put("firmName", purchase.getFirmName());
         UserInfo supplyUser = new UserInfo();
@@ -1019,7 +1053,7 @@ public class KwoTradeOrderService {
         if (kwoTradeOrderUnitService.entMatch(order.getId(), LoginUserHolder.getEntId(), null)) {
             throw new BusinessException("无订单操作权限!");
         }
-        KwoTradeOrderTrack track = kwoTradeOrderTrackService.getByOrderId(id, Integer.valueOf(DictEnum.TORDER_STATUS_2.getValue()));
+        KwoTradeOrderTrack track = kwoTradeOrderTrackService.getByOrderId(id, OrderStatusEnum.RETURNED.getCode());
 
         return Objects.isNull(track) ? null : track.getRemark();
     }
@@ -1038,10 +1072,10 @@ public class KwoTradeOrderService {
         if (Objects.isNull(order)) {
             throw new BusinessException("Order not found");
         }
-        if (!Objects.equals(String.valueOf(order.getStatus()), DictEnum.TORDER_STATUS_4.getValue())) {
+        if (!Objects.equals(order.getStatus(), OrderStatusEnum.EXECUTING.getCode())) {
             throw new BusinessException("执行中的订单才能完结订单!");
         }
-        if (kwoTradeOrderUnitService.entMatch(param.getId(), LoginUserHolder.getEntId(), DictEnum.TORDER_UNIT_TYPE_2.getValue())) {
+        if (kwoTradeOrderUnitService.entMatch(param.getId(), LoginUserHolder.getEntId(), OrderUnitTypeEnum.SALE.getType())) {
             throw new BusinessException("无订单操作权限!");
         }
         if (transportDubboService.checkLogisticsOrderByTradeOrderId(tOrderId)) {
@@ -1052,7 +1086,7 @@ public class KwoTradeOrderService {
             throw new BusinessException("业务繁忙,请稍后再试!");
         }
         try {
-            order.setActualAmount(actualAmount).setStatus(Integer.valueOf(DictEnum.TORDER_STATUS_5.getValue()));
+            order.setActualAmount(actualAmount).setStatus(OrderStatusEnum.FINISHED.getCode());
             kwoTradeOrderMapper.updateById(order);
             //订单状态记录
             KwoTradeOrderTrack track = new KwoTradeOrderTrack();
@@ -1160,7 +1194,7 @@ public class KwoTradeOrderService {
      */
     public List<KwoTradeOrder> getWaitSignByIds(List<Long> tOrderIds) {
         LambdaQueryWrapper<KwoTradeOrder> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(KwoTradeOrder::getStatus, Integer.valueOf(DictEnum.TORDER_STATUS_3.getValue()))
+        wrapper.eq(KwoTradeOrder::getStatus, OrderStatusEnum.WAIT_SIGNED.getCode())
                 .in(KwoTradeOrder::getId, tOrderIds).eq(KwoTradeOrder::getDelFlag, Global.NO);
         List<KwoTradeOrder> list = kwoTradeOrderMapper.selectList(wrapper);
         return CollectionUtils.emptyIfNull(list);
@@ -1176,9 +1210,9 @@ public class KwoTradeOrderService {
      */
     public void contractCompletedUpdate(List<Long> tOrderIds, Long updateBy) {
         LambdaUpdateWrapper<KwoTradeOrder> wrapper = new LambdaUpdateWrapper<>();
-        wrapper.in(KwoTradeOrder::getId, tOrderIds).eq(KwoTradeOrder::getStatus, Integer.valueOf(DictEnum.TORDER_STATUS_3.getValue()))
+        wrapper.in(KwoTradeOrder::getId, tOrderIds).eq(KwoTradeOrder::getStatus, OrderStatusEnum.WAIT_SIGNED.getCode())
                 .eq(KwoTradeOrder::getDelFlag, Global.NO).set(KwoTradeOrder::getUpdateBy, updateBy)
-                .set(KwoTradeOrder::getStatus, Integer.valueOf(DictEnum.TORDER_STATUS_4.getValue()));
+                .set(KwoTradeOrder::getStatus, OrderStatusEnum.EXECUTING.getCode());
         kwoTradeOrderMapper.update(null, wrapper);
     }
 
@@ -1206,9 +1240,9 @@ public class KwoTradeOrderService {
         Map<String, List<Integer>> map = addressList.stream().collect(Collectors.
                 groupingBy(KwoTradeOrderAddress::getAddressType, Collectors.mapping(KwoTradeOrderAddress::getCityCode, Collectors.toList())));
         //装货地址下拉列表树
-        List<AreaTreeFrontResDto> loadTree = remoteSystemService.queryAreaTreeFrontByCodeList(map.get(DictEnum.TORDER_ADDRESS_TYPE_1.getValue()));
+        List<AreaTreeFrontResDto> loadTree = remoteSystemService.queryAreaTreeFrontByCodeList(map.get(OrderAddressTypeEnum.LOAD.getType()));
         //卸货地址下拉列表树
-        List<AreaTreeFrontResDto> unloadTree = remoteSystemService.queryAreaTreeFrontByCodeList(map.get(DictEnum.TORDER_ADDRESS_TYPE_2.getValue()));
+        List<AreaTreeFrontResDto> unloadTree = remoteSystemService.queryAreaTreeFrontByCodeList(map.get(OrderAddressTypeEnum.UNLOAD.getType()));
         res.setLoadAddressList(loadTree).setUnloadAddressList(unloadTree);
         return res;
     }

+ 77 - 22
sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwoTransportDemandService.java

@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.google.common.collect.Lists;
-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;
@@ -21,6 +20,7 @@ import com.sckw.core.utils.StringUtils;
 import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.excel.utils.DateUtil;
 import com.sckw.order.dao.KwoTransportDemandMapper;
+import com.sckw.order.enums.TransportDemandStatusEnum;
 import com.sckw.order.model.KwoTransportDemand;
 import com.sckw.order.model.dto.TransportDemandExport;
 import com.sckw.order.model.vo.req.*;
@@ -65,7 +65,7 @@ public class KwoTransportDemandService {
      */
     public void addDraft(AddTransportDemandDraftParam param) {
         KwoTransportDemand transportDemand = BeanUtils.copyProperties(param, KwoTransportDemand.class);
-        transportDemand.setEntId(LoginUserHolder.getEntId()).setStatus(Integer.valueOf(DictEnum.TRANSPORT_DEMAND_STATUS_0.getValue()));
+        transportDemand.setEntId(LoginUserHolder.getEntId()).setStatus(TransportDemandStatusEnum.SAVED.getCode());
         kwoTransportDemandMapper.insert(transportDemand);
     }
 
@@ -78,7 +78,7 @@ public class KwoTransportDemandService {
      */
     public void addShelves(AddTransportDemandParam param) {
         KwoTransportDemand transportDemand = BeanUtils.copyProperties(param, KwoTransportDemand.class);
-        transportDemand.setEntId(LoginUserHolder.getEntId()).setStatus(Integer.valueOf(DictEnum.TRANSPORT_DEMAND_STATUS_1.getValue()));
+        transportDemand.setEntId(LoginUserHolder.getEntId()).setStatus(TransportDemandStatusEnum.PUT_ON_SHELVES.getCode());
         kwoTransportDemandMapper.insert(transportDemand);
     }
 
@@ -94,10 +94,25 @@ public class KwoTransportDemandService {
         if (Objects.isNull(transportDemand)) {
             throw new BusinessException("数据不存在!");
         }
+        Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(List.of(DictTypeEnum.PRODUCT_NAME_TYPE.getType(),
+                DictTypeEnum.TRADE_TYPE.getType(), DictTypeEnum.TRANSPORT_DEMAND_STATUS.getType()));
+        Map<String, String> productNameMap, tradeMap, statusMap;
+        if (CollectionUtils.isEmpty(dict)) {
+            productNameMap = new HashMap<>();
+            tradeMap = new HashMap<>();
+            statusMap = new HashMap<>();
+        } else {
+            productNameMap = CollectionUtils.isEmpty(dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType())) ?
+                    new HashMap<>() : dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType());
+            tradeMap = CollectionUtils.isEmpty(dict.get(DictTypeEnum.TRADE_TYPE.getType())) ?
+                    new HashMap<>() : dict.get(DictTypeEnum.TRADE_TYPE.getType());
+            statusMap = CollectionUtils.isEmpty(dict.get(DictTypeEnum.TRANSPORT_DEMAND_STATUS.getType())) ?
+                    new HashMap<>() : dict.get(DictTypeEnum.TRANSPORT_DEMAND_STATUS.getType());
+        }
         TransportDemandDetailRes res = BeanUtils.copyProperties(transportDemand, TransportDemandDetailRes.class);
-        res.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), res.getGoodsType()))
-                .setTradingLabel(DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), res.getTrading()))
-                .setStatusLabel(DictEnum.getLabel(DictTypeEnum.TRANSPORT_DEMAND_STATUS.getType(), String.valueOf(res.getStatus())));
+        res.setGoodsTypeLabel(productNameMap.get(res.getGoodsType()))
+                .setTradingLabel(tradeMap.get(res.getTrading()))
+                .setStatusLabel(statusMap.get(String.valueOf(res.getStatus())));
         return res;
     }
 
@@ -193,6 +208,21 @@ public class KwoTransportDemandService {
         List<EntCacheResDto> entList = remoteSystemService.queryEntCacheByIds(supplyEntIds);
         Map<Long, String> entMap = entList.stream().collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName, (k1, k2) -> k1));
 
+        Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(List.of(DictTypeEnum.PRODUCT_NAME_TYPE.getType(),
+                DictTypeEnum.TRADE_TYPE.getType(), DictTypeEnum.TRANSPORT_DEMAND_STATUS.getType()));
+        Map<String, String> productNameMap, tradeMap, statusMap;
+        if (CollectionUtils.isNotEmpty(dict)) {
+            productNameMap = CollectionUtils.isNotEmpty(dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType())) ?
+                    dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType()) : new HashMap<>();
+            tradeMap = CollectionUtils.isNotEmpty(dict.get(DictTypeEnum.TRADE_TYPE.getType())) ?
+                    dict.get(DictTypeEnum.TRADE_TYPE.getType()) : new HashMap<>();
+            statusMap = CollectionUtils.isNotEmpty(dict.get(DictTypeEnum.TRANSPORT_DEMAND_STATUS.getType())) ?
+                    dict.get(DictTypeEnum.TRANSPORT_DEMAND_STATUS.getType()) : new HashMap<>();
+        } else {
+            productNameMap = new HashMap<>();
+            tradeMap = new HashMap<>();
+            statusMap = new HashMap<>();
+        }
         List<TransportDemandListRes> result = Lists.newArrayList();
         list.forEach(e -> {
             TransportDemandListRes demand = BeanUtils.copyProperties(e, TransportDemandListRes.class);
@@ -200,9 +230,9 @@ public class KwoTransportDemandService {
             String loadDetailAddress = Objects.nonNull(e.getLoadDetailAddress()) ? e.getLoadDetailAddress() : "";
             String unloadAreaName = Objects.nonNull(e.getUnloadAreaName()) ? e.getUnloadAreaName() : "";
             String unloadDetailAddress = Objects.nonNull(e.getUnloadDetailAddress()) ? e.getUnloadDetailAddress() : "";
-            demand.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), e.getGoodsType()))
-                    .setTradingLabel(DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), e.getTrading()))
-                    .setStatusLabel(DictEnum.getLabel(DictTypeEnum.TRANSPORT_DEMAND_STATUS.getType(), String.valueOf(e.getStatus())))
+            demand.setGoodsTypeLabel(productNameMap.get(e.getGoodsType()))
+                    .setTradingLabel(tradeMap.get(e.getTrading()))
+                    .setStatusLabel(statusMap.get(String.valueOf(e.getStatus())))
                     .setLoadAddress(loadAreaName + loadDetailAddress)
                     .setUnloadAddress(unloadAreaName + unloadDetailAddress)
                     .setEntName(entMap.get(e.getEntId()));
@@ -278,9 +308,9 @@ public class KwoTransportDemandService {
         all.setName("全部").setTotal(CollectionUtils.isEmpty(demands) ? 0 : demands.size());
         tableTops.add(all);
 
-        List<DictEnum> enums = DictEnum.getEnumsByType(DictTypeEnum.TRANSPORT_DEMAND_STATUS.getType());
+        List<TransportDemandStatusEnum> enums = TransportDemandStatusEnum.getSortList();
         enums.forEach(e -> {
-            Integer value = Integer.valueOf(e.getValue());
+            Integer value = e.getCode();
             Integer systemType = LoginUserHolder.getSystemType();
             if (Objects.equals(systemType, SystemTypeEnum.MANAGE.getCode()) && Objects.equals(value, Global.NO)) {
                 return;
@@ -288,7 +318,7 @@ public class KwoTransportDemandService {
             List<KwoTransportDemand> list = map.get(value);
             int total = CollectionUtils.isEmpty(list) ? 0 : list.size();
             TableTop tableTop = new TableTop();
-            tableTop.setName(e.getLabel()).setValue(value).setTotal(total);
+            tableTop.setName(e.getMsg()).setValue(value).setTotal(total);
             tableTops.add(tableTop);
 
         });
@@ -319,18 +349,30 @@ public class KwoTransportDemandService {
         List<EntCacheResDto> entList = remoteSystemService.queryEntCacheByIds(supplyEntIds);
         Map<Long, String> entMap = entList.stream().collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName, (k1, k2) -> k1));
 
+        Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(List.of(DictTypeEnum.PRODUCT_NAME_TYPE.getType(),
+                DictTypeEnum.TRANSPORT_DEMAND_STATUS.getType()));
+        Map<String, String> productNameMap, statusMap;
+        if (CollectionUtils.isEmpty(dict)) {
+            productNameMap = new HashMap<>();
+            statusMap = new HashMap<>();
+        } else {
+            productNameMap = CollectionUtils.isEmpty(dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType())) ?
+                    new HashMap<>() : dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType());
+            statusMap = CollectionUtils.isEmpty(dict.get(DictTypeEnum.TRANSPORT_DEMAND_STATUS.getType())) ?
+                    new HashMap<>() : dict.get(DictTypeEnum.TRANSPORT_DEMAND_STATUS.getType());
+        }
         List<TransportDemandExport> result = Lists.newArrayList();
         AtomicInteger i = new AtomicInteger(1);
         demands.forEach(e -> {
             TransportDemandExport export = BeanUtils.copyProperties(e, TransportDemandExport.class);
-            export.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), e.getGoodsType()))
-                    .setStatusLabel(DictEnum.getLabel(DictTypeEnum.TRANSPORT_DEMAND_STATUS.getType(), String.valueOf(e.getStatus())))
+            export.setGoodsTypeLabel(productNameMap.get(e.getGoodsType()))
+                    .setStatusLabel(statusMap.get(String.valueOf(e.getStatus())))
                     .setLoadAddress(e.getLoadAreaName() + e.getLoadDetailAddress()).setSerialNumber(String.valueOf(i.getAndIncrement()))
                     .setUnloadAddress(e.getUnloadAreaName() + e.getUnloadDetailAddress())
                     .setDeadline(Objects.isNull(e.getDeadline()) ? null : DateUtil.dateToStr(e.getDeadline()))
                     .setCreateTime(Objects.isNull(e.getCreateTime()) ? null : DateUtil.getDateTime(e.getCreateTime()))
                     .setUpdateTime(Objects.isNull(e.getUpdateTime()) ? null : DateUtil.getDateTime(e.getUpdateTime()))
-                    .setEntName(entMap != null ? entMap.get(e.getEntId()) : null);
+                    .setEntName(entMap.get(e.getEntId()));
             result.add(export);
         });
         return result;
@@ -346,14 +388,14 @@ public class KwoTransportDemandService {
     public void batchPutOnShelves(List<Long> ids) {
         LambdaQueryWrapper<KwoTransportDemand> wrapper = new LambdaQueryWrapper<>();
         wrapper.in(KwoTransportDemand::getId, ids)
-                .ne(KwoTransportDemand::getStatus, Integer.valueOf(DictEnum.TRANSPORT_DEMAND_STATUS_1.getValue()))
+                .ne(KwoTransportDemand::getStatus, TransportDemandStatusEnum.PUT_ON_SHELVES.getCode())
                 .eq(KwoTransportDemand::getEntId, LoginUserHolder.getEntId()).eq(KwoTransportDemand::getDelFlag, Global.NO);
         List<KwoTransportDemand> list = kwoTransportDemandMapper.selectList(wrapper);
         if (!Objects.equals(ids.size(), list.size())) {
             throw new BusinessException("上架操作仅针对“已下架”“草稿”状态的单据!");
         }
         LambdaUpdateWrapper<KwoTransportDemand> updateWrapper = new LambdaUpdateWrapper<>();
-        updateWrapper.set(KwoTransportDemand::getStatus, Integer.valueOf(DictEnum.TRANSPORT_DEMAND_STATUS_1.getValue()))
+        updateWrapper.set(KwoTransportDemand::getStatus, TransportDemandStatusEnum.PUT_ON_SHELVES.getCode())
                 .in(KwoTransportDemand::getId, ids);
         kwoTransportDemandMapper.update(null, updateWrapper);
     }
@@ -368,14 +410,14 @@ public class KwoTransportDemandService {
     public void batchTakeOffShelves(List<Long> ids) {
         LambdaQueryWrapper<KwoTransportDemand> wrapper = new LambdaQueryWrapper<>();
         wrapper.in(KwoTransportDemand::getId, ids)
-                .eq(KwoTransportDemand::getStatus, Integer.valueOf(DictEnum.TRANSPORT_DEMAND_STATUS_1.getValue()))
+                .eq(KwoTransportDemand::getStatus, TransportDemandStatusEnum.PUT_ON_SHELVES.getCode())
                 .eq(KwoTransportDemand::getEntId, LoginUserHolder.getEntId()).eq(KwoTransportDemand::getDelFlag, Global.NO);
         List<KwoTransportDemand> list = kwoTransportDemandMapper.selectList(wrapper);
         if (!Objects.equals(ids.size(), list.size())) {
             throw new BusinessException("下架操作仅针对“已上架”状态的单据");
         }
         LambdaUpdateWrapper<KwoTransportDemand> updateWrapper = new LambdaUpdateWrapper<>();
-        updateWrapper.set(KwoTransportDemand::getStatus, Integer.valueOf(DictEnum.TRANSPORT_DEMAND_STATUS_2.getValue()))
+        updateWrapper.set(KwoTransportDemand::getStatus, TransportDemandStatusEnum.TAKE_OFF_SHELVES.getCode())
                 .in(KwoTransportDemand::getId, ids);
         kwoTransportDemandMapper.update(null, updateWrapper);
     }
@@ -417,7 +459,7 @@ public class KwoTransportDemandService {
                 wrapper.in(KwoTransportDemand::getGoodsType, goodsTypes);
             }
         }
-        wrapper.eq(KwoTransportDemand::getStatus, Integer.valueOf(DictEnum.TRANSPORT_DEMAND_STATUS_1.getValue()))
+        wrapper.eq(KwoTransportDemand::getStatus, TransportDemandStatusEnum.PUT_ON_SHELVES.getCode())
                 .eq(KwoTransportDemand::getDelFlag, Global.NO);
         Integer loadCode = param.getLoadAreaCode();
         if (Objects.nonNull(loadCode) && Objects.nonNull(param.getLoadAreaLevel())) {
@@ -456,12 +498,25 @@ public class KwoTransportDemandService {
         }
         List<Long> entIds = list.stream().map(KwoTransportDemand::getEntId).toList();
         Map<Long, EntCacheResDto> entMap = remoteSystemService.queryEntCacheMapByIds(entIds);
+
+        Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(List.of(DictTypeEnum.PRODUCT_NAME_TYPE.getType(),
+                DictTypeEnum.TRADE_TYPE.getType()));
+        Map<String, String> productNameMap, tradeMap;
+        if (CollectionUtils.isEmpty(dict)) {
+            productNameMap = new HashMap<>();
+            tradeMap = new HashMap<>();
+        } else {
+            productNameMap = CollectionUtils.isEmpty(dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType())) ?
+                    new HashMap<>() : dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType());
+            tradeMap = CollectionUtils.isEmpty(dict.get(DictTypeEnum.TRADE_TYPE.getType())) ?
+                    new HashMap<>() : dict.get(DictTypeEnum.TRADE_TYPE.getType());
+        }
         List<TransportDemandSquaresListRes> result = Lists.newArrayList();
         list.forEach(e -> {
             TransportDemandSquaresListRes res = BeanUtils.copyProperties(e, TransportDemandSquaresListRes.class);
             EntCacheResDto ent = entMap.get(e.getEntId());
-            res.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), e.getGoodsType()))
-                    .setTradingLabel(DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), e.getTrading()))
+            res.setGoodsTypeLabel(productNameMap.get(e.getGoodsType()))
+                    .setTradingLabel(tradeMap.get(e.getTrading()))
                     .setLoadAddress(e.getLoadAreaName() + e.getLoadDetailAddress())
                     .setUnloadAddress(e.getUnloadAreaName() + e.getUnloadDetailAddress())
                     .setCreateTime(DateUtils.format(e.getCreateTime()))

+ 95 - 27
sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwpWantBuyService.java

@@ -4,7 +4,6 @@ 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;
@@ -21,6 +20,7 @@ import com.sckw.excel.utils.DateUtil;
 import com.sckw.order.dao.KwpWantBuyAddressMapper;
 import com.sckw.order.dao.KwpWantBuyMapper;
 import com.sckw.order.dao.KwpWantBuyTradingMapper;
+import com.sckw.order.enums.WantBuyStatusEnum;
 import com.sckw.order.model.KwoWantBuy;
 import com.sckw.order.model.KwoWantBuyAddress;
 import com.sckw.order.model.KwoWantBuyTrading;
@@ -92,7 +92,7 @@ public class KwpWantBuyService {
                 wantBuySelectParam.setEntIds(entIds);
             }
         }
-        wantBuySelectParam.setStatus(Integer.valueOf(DictEnum.WANT_BUY_STATUS_1.getValue()));
+        wantBuySelectParam.setStatus(WantBuyStatusEnum.PUT_ON_SHELVES.getCode());
 
         // 分页查询求购列表
         PageHelper.startPage(wantBuySelectParam.getPage(), wantBuySelectParam.getPageSize());
@@ -112,14 +112,29 @@ public class KwpWantBuyService {
         Map<Long, String> entMap = entList.stream()
                 .collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName, (k1, k2) -> k1));
 
+        Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(List.of(DictTypeEnum.TRADE_TYPE.getType(),
+                DictTypeEnum.PRODUCT_NAME_TYPE.getType(), DictTypeEnum.GOODS_STATUS.getType()));
+        Map<String, String> tradeMap, productNameMap, goodsStatusMap;
+        if (CollectionUtils.isNotEmpty(dict)) {
+            tradeMap = CollectionUtils.isNotEmpty(dict.get(DictTypeEnum.TRADE_TYPE.getType())) ?
+                    dict.get(DictTypeEnum.TRADE_TYPE.getType()) : new HashMap<>();
+            productNameMap = CollectionUtils.isNotEmpty(dict.get(DictTypeEnum.TRADE_TYPE.getType())) ?
+                    dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType()) : new HashMap<>();
+            goodsStatusMap = CollectionUtils.isNotEmpty(dict.get(DictTypeEnum.TRADE_TYPE.getType())) ?
+                    dict.get(DictTypeEnum.GOODS_STATUS.getType()) : new HashMap<>();
+        } else {
+            tradeMap = new HashMap<>();
+            productNameMap = new HashMap<>();
+            goodsStatusMap = new HashMap<>();
+        }
         // 对求购列表进行数据处理
         res.forEach(e -> {
             List<String> tradings = e.getWantBuyTradings().stream()
-                    .map(f -> DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), f.getTrading()))
+                    .map(f -> tradeMap.get(f.getTrading()))
                     .collect(Collectors.toList());
             e.setTradings(String.join(Global.COMMA, tradings));
-            e.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), e.getGoodsType()));
-            e.setStatusLabel(DictEnum.getLabel(DictTypeEnum.GOODS_STATUS.getType(), String.valueOf(e.getStatus())));
+            e.setGoodsTypeLabel(productNameMap.get(e.getGoodsType()));
+            e.setStatusLabel(goodsStatusMap.get(String.valueOf(e.getStatus())));
             e.setEntName(Objects.nonNull(entMap.get(e.getEntId())) ? entMap.get(e.getEntId()) : null);
         });
 
@@ -157,14 +172,29 @@ public class KwpWantBuyService {
         List<EntCacheResDto> entList = remoteSystemService.queryEntCacheByIds(supplyEntIds);
         Map<Long, String> entMap = entList.stream()
                 .collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName, (k1, k2) -> k1));
+        Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(List.of(DictTypeEnum.TRADE_TYPE.getType(),
+                DictTypeEnum.PRODUCT_NAME_TYPE.getType(), DictTypeEnum.WANT_BUY_STATUS.getType()));
+        Map<String, String> tradeMap, productNameMap, statusMap;
+        if (CollectionUtils.isEmpty(dict)) {
+            tradeMap = new HashMap<>();
+            productNameMap = new HashMap<>();
+            statusMap = new HashMap<>();
+        } else {
+            tradeMap = CollectionUtils.isEmpty(dict.get(DictTypeEnum.TRADE_TYPE.getType())) ?
+                    new HashMap<>() : dict.get(DictTypeEnum.TRADE_TYPE.getType());
+            productNameMap = CollectionUtils.isEmpty(dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType())) ?
+                    new HashMap<>() : dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType());
+            statusMap = CollectionUtils.isEmpty(dict.get(DictTypeEnum.WANT_BUY_STATUS.getType())) ?
+                    new HashMap<>() : dict.get(DictTypeEnum.WANT_BUY_STATUS.getType());
+        }
         //把查询出来的集合wantBuyTradings里面对的tranding 转成字符串放在String里面
         wantBuyDto.forEach(wantBuySelectRes -> {
             List<String> tradings = wantBuySelectRes.getWantBuyTradings().stream()
-                    .map(wantBuyTradingRes -> DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), wantBuyTradingRes.getTrading()))
+                    .map(wantBuyTradingRes -> tradeMap.get(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.setGoodsTypeLabel(productNameMap.get(wantBuySelectRes.getGoodsType()));
+            wantBuySelectRes.setStatusLabel(statusMap.get(String.valueOf(wantBuySelectRes.getStatus())));
             wantBuySelectRes.setEntName(Objects.nonNull(entMap.get(wantBuySelectRes.getEntId())) ? entMap.get(wantBuySelectRes.getEntId()) : null);
         });
 
@@ -206,8 +236,7 @@ public class KwpWantBuyService {
      **/
     @Transactional(rollbackFor = Exception.class)
     public void addDraft(AddDraftWantBuyParam param) {
-        Integer status = Integer.valueOf(DictEnum.WANT_BUY_STATUS_0.getValue());
-        addWantBuy(BeanUtils.copyProperties(param, AddWantBuyParam.class), status);
+        addWantBuy(BeanUtils.copyProperties(param, AddWantBuyParam.class), WantBuyStatusEnum.SAVED.getCode());
     }
 
     /**
@@ -219,8 +248,7 @@ public class KwpWantBuyService {
      **/
     @Transactional(rollbackFor = Exception.class)
     public void addShelves(AddWantBuyParam param) {
-        Integer status = Integer.valueOf(DictEnum.WANT_BUY_STATUS_1.getValue());
-        addWantBuy(param, status);
+        addWantBuy(param, WantBuyStatusEnum.PUT_ON_SHELVES.getCode());
     }
 
     /**
@@ -263,14 +291,14 @@ public class KwpWantBuyService {
      **/
     public void batchPutOnShelves(List<Long> ids) {
         LambdaQueryWrapper<KwoWantBuy> wrapper = new LambdaQueryWrapper<>();
-        wrapper.in(KwoWantBuy::getId, ids).ne(KwoWantBuy::getStatus, Integer.valueOf(DictEnum.WANT_BUY_STATUS_1.getValue()))
+        wrapper.in(KwoWantBuy::getId, ids).ne(KwoWantBuy::getStatus, WantBuyStatusEnum.PUT_ON_SHELVES.getCode())
                 .eq(KwoWantBuy::getEntId, LoginUserHolder.getEntId()).eq(KwoWantBuy::getDelFlag, Global.NO);
         List<KwoWantBuy> list = kwpWantBuyMapper.selectList(wrapper);
         if (!Objects.equals(ids.size(), list.size())) {
             throw new BusinessException("上架操作仅针对“已下架”“草稿”状态的单据!");
         }
         LambdaUpdateWrapper<KwoWantBuy> updateWrapper = new LambdaUpdateWrapper<>();
-        updateWrapper.set(KwoWantBuy::getStatus, Integer.valueOf(DictEnum.WANT_BUY_STATUS_1.getValue()))
+        updateWrapper.set(KwoWantBuy::getStatus, WantBuyStatusEnum.PUT_ON_SHELVES.getCode())
                 .in(KwoWantBuy::getId, ids);
         kwpWantBuyMapper.update(null, updateWrapper);
     }
@@ -283,14 +311,14 @@ public class KwpWantBuyService {
     public void batchTakeOffShelves(WantBuyDels param) {
         List<Long> ids = StringUtils.splitStrToList(param.getIds(), Long.class);
         LambdaQueryWrapper<KwoWantBuy> wrapper = new LambdaQueryWrapper<>();
-        wrapper.in(KwoWantBuy::getId, ids).eq(KwoWantBuy::getStatus, Integer.valueOf(DictEnum.WANT_BUY_STATUS_1.getValue()))
+        wrapper.in(KwoWantBuy::getId, ids).eq(KwoWantBuy::getStatus, WantBuyStatusEnum.PUT_ON_SHELVES.getCode())
                 .eq(KwoWantBuy::getEntId, LoginUserHolder.getEntId()).eq(KwoWantBuy::getDelFlag, Global.NO);
         List<KwoWantBuy> list = kwpWantBuyMapper.selectList(wrapper);
         if (!Objects.equals(ids.size(), list.size())) {
             throw new BusinessException("下架操作仅针对“已上架”状态的单据");
         }
         LambdaUpdateWrapper<KwoWantBuy> updateWrapper = new LambdaUpdateWrapper<>();
-        updateWrapper.set(KwoWantBuy::getStatus, Integer.valueOf(DictEnum.WANT_BUY_STATUS_2.getValue())).in(KwoWantBuy::getId, ids);
+        updateWrapper.set(KwoWantBuy::getStatus, WantBuyStatusEnum.TAKE_OFF_SHELVES.getCode()).in(KwoWantBuy::getId, ids);
         kwpWantBuyMapper.update(null, updateWrapper);
     }
 
@@ -331,14 +359,32 @@ public class KwpWantBuyService {
             throw new BusinessException("求购信息不存在");
         }
         WantBuyDetailRes responseData = BeanUtils.copyProperties(kwoWantBuy, WantBuyDetailRes.class);
-        responseData.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), responseData.getGoodsType()))
-                .setStatusLabel(DictEnum.getLabel(DictTypeEnum.WANT_BUY_STATUS.getType(), String.valueOf(responseData.getStatus())));
+        Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(List.of(DictTypeEnum.PRODUCT_NAME_TYPE.getType(),
+                DictTypeEnum.WANT_BUY_STATUS.getType(), DictTypeEnum.TORDER_ADDRESS_TYPE.getType(), DictTypeEnum.TRADE_TYPE.getType()));
+        Map<String, String> productNameMap, wantBuyStatusMap, orderAddressMap, tradeMap;
+        if (CollectionUtils.isEmpty(dict)) {
+            productNameMap = new HashMap<>();
+            wantBuyStatusMap = new HashMap<>();
+            orderAddressMap = new HashMap<>();
+            tradeMap = new HashMap<>();
+        } else {
+            productNameMap = CollectionUtils.isEmpty(dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType())) ?
+                    new HashMap<>() : dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType());
+            wantBuyStatusMap = CollectionUtils.isEmpty(dict.get(DictTypeEnum.WANT_BUY_STATUS.getType())) ?
+                    new HashMap<>() : dict.get(DictTypeEnum.WANT_BUY_STATUS.getType());
+            orderAddressMap = CollectionUtils.isEmpty(dict.get(DictTypeEnum.TORDER_ADDRESS_TYPE.getType())) ?
+                    new HashMap<>() : dict.get(DictTypeEnum.TORDER_ADDRESS_TYPE.getType());
+            tradeMap = CollectionUtils.isEmpty(dict.get(DictTypeEnum.TRADE_TYPE.getType())) ?
+                    new HashMap<>() : dict.get(DictTypeEnum.TRADE_TYPE.getType());
+        }
+        responseData.setGoodsTypeLabel(productNameMap.get(responseData.getGoodsType()))
+                .setStatusLabel(wantBuyStatusMap.get(String.valueOf(responseData.getStatus())));
         //求购地址信息
         KwoWantBuyAddress address = kwpWantBuyAddressMapper.selectOne(new LambdaQueryWrapper<KwoWantBuyAddress>()
                 .eq(KwoWantBuyAddress::getWantBuyId, id).eq(KwoWantBuyAddress::getDelFlag, Global.NO).last("LIMIT 1"));
         if (Objects.nonNull(address)) {
             WantBuyAddressDetailRes wantBuyAddressInfo = BeanUtils.copyProperties(address, WantBuyAddressDetailRes.class);
-            wantBuyAddressInfo.setTypeLabel(DictEnum.getLabel(DictTypeEnum.TORDER_ADDRESS_TYPE.getType(), wantBuyAddressInfo.getType()));
+            wantBuyAddressInfo.setTypeLabel(orderAddressMap.get(wantBuyAddressInfo.getType()));
             responseData.setAddressInfo(wantBuyAddressInfo);
         }
         //获取求购企业信息
@@ -353,7 +399,7 @@ public class KwpWantBuyService {
             responseData.setTradings(tradings);
             //改成stream流的方式
             List<String> result = tradings.stream()
-                    .map(trading -> DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), trading))
+                    .map(tradeMap::get)
                     .collect(Collectors.toList());
             String tradingLabels = String.join(Global.COMMA, result);
             //获取到的是一个集合,需要转换成字符串
@@ -454,9 +500,9 @@ public class KwpWantBuyService {
         TableTop all = new TableTop();
         all.setName("全部").setTotal(CollectionUtils.isEmpty(result) ? 0 : result.size());
         tableTops.add(all);
-        List<DictEnum> enums = DictEnum.getEnumsByType(DictTypeEnum.WANT_BUY_STATUS.getType());
+        List<WantBuyStatusEnum> enums = WantBuyStatusEnum.getSortList();
         enums.forEach(e -> {
-            Integer value = Integer.valueOf(e.getValue());
+            Integer value = e.getCode();
             Integer systemType = LoginUserHolder.getSystemType();
             if (Objects.equals(systemType, SystemTypeEnum.MANAGE.getCode()) && Objects.equals(value, Global.NO)) {
                 return;
@@ -464,7 +510,7 @@ public class KwpWantBuyService {
             List<WantBuySelectRes> list = map.get(value);
             int total = CollectionUtils.isEmpty(list) ? 0 : list.size();
             TableTop tableTop = new TableTop();
-            tableTop.setName(e.getLabel()).setValue(value).setTotal(total);
+            tableTop.setName(e.getMsg()).setValue(value).setTotal(total);
             tableTops.add(tableTop);
         });
         TableBottom tableBottom = new TableBottom();
@@ -497,15 +543,37 @@ public class KwpWantBuyService {
         if (CollectionUtils.isEmpty(wantBuyDto)) {
             return Collections.emptyList();
         }
+        // 获取供应企业信息
+        Map<Long, EntCacheResDto> entMap = remoteSystemService.queryEntCacheMapByIds(
+                wantBuyDto.stream().map(WantBuySelectRes::getEntId).collect(Collectors.toList()));
+        // 字典信息
+        Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(List.of(DictTypeEnum.TRADE_TYPE.getType(),
+                DictTypeEnum.PRODUCT_NAME_TYPE.getType(), DictTypeEnum.WANT_BUY_STATUS.getType()));
+        Map<String, String> tradeMap, productNameMap, statusMap;
+        if (CollectionUtils.isEmpty(dict)) {
+            tradeMap = new HashMap<>();
+            productNameMap = new HashMap<>();
+            statusMap = new HashMap<>();
+        } else {
+            tradeMap = CollectionUtils.isEmpty(dict.get(DictTypeEnum.TRADE_TYPE.getType())) ?
+                    new HashMap<>() : dict.get(DictTypeEnum.TRADE_TYPE.getType());
+            productNameMap = CollectionUtils.isEmpty(dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType())) ?
+                    new HashMap<>() : dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType());
+            statusMap = CollectionUtils.isEmpty(dict.get(DictTypeEnum.WANT_BUY_STATUS.getType())) ?
+                    new HashMap<>() : dict.get(DictTypeEnum.WANT_BUY_STATUS.getType());
+        }
         List<WantBuyExport> result = new ArrayList<>();
         AtomicInteger i = new AtomicInteger(1);
         wantBuyDto.forEach(e -> {
             WantBuyExport export = BeanUtils.copyProperties(e, WantBuyExport.class);
             List<String> tradings = e.getWantBuyTradings().stream()
-                    .map(wantBuyTradingRes -> DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), wantBuyTradingRes.getTrading()))
+                    .map(wantBuyTradingRes -> tradeMap.get(wantBuyTradingRes.getTrading()))
                     .collect(Collectors.toList());
-            export.setSerialNumber(String.valueOf(i.getAndIncrement())).setTradings(String.join(Global.COMMA, tradings))
-                    .setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), e.getGoodsType()))
+            export.setSerialNumber(String.valueOf(i.getAndIncrement()))
+                    .setStatusLabel(statusMap.get(String.valueOf(e.getStatus())))
+                    .setEntName(Objects.nonNull(entMap.get(e.getEntId())) ? entMap.get(e.getEntId()).getFirmName() : null)
+                    .setTradings(String.join(Global.COMMA, tradings))
+                    .setGoodsTypeLabel(productNameMap.get(e.getGoodsType()))
                     .setCreateTime(Objects.isNull(e.getCreateTime()) ? null : DateUtil.getDateTime(e.getCreateTime()))
                     .setUpdateTime(Objects.isNull(e.getUpdateTime()) ? null : DateUtil.getDateTime(e.getUpdateTime()));
             result.add(export);
@@ -526,7 +594,7 @@ public class KwpWantBuyService {
                 .eq(KwoWantBuy::getDelFlag, Global.NO)
                 .last("LIMIT 1");
         KwoWantBuy wantBuy = kwpWantBuyMapper.selectOne(wrapper);
-        if (Objects.isNull(wantBuy)){
+        if (Objects.isNull(wantBuy)) {
             throw new BusinessException("求购信息不存在");
         }
         WantBuyContactInfoRes res = new WantBuyContactInfoRes();

+ 63 - 3
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/WalletController.java

@@ -1,6 +1,7 @@
 package com.sckw.payment.controller;
 
 import com.sckw.core.web.response.HttpResult;
+import com.sckw.payment.model.dto.Id;
 import com.sckw.payment.model.vo.req.*;
 import com.sckw.payment.service.WalletService;
 import jakarta.annotation.Resource;
@@ -23,6 +24,16 @@ public class WalletController {
     @Resource
     private WalletService walletService;
 
+    /**
+     * 开户
+     *
+     * @return
+     */
+    @PostMapping("createUser")
+    public HttpResult createUser(@RequestBody @Valid CreateUserReq createUserReq) {
+        return HttpResult.ok(walletService.createUser(createUserReq));
+    }
+
     /**
      * 钱包总览信息
      *
@@ -204,6 +215,17 @@ public class WalletController {
         return HttpResult.ok(walletService.addPrePay(prePay));
     }
 
+    /**
+     * 预付追加校验
+     *
+     * @param appendPayCheck
+     * @return
+     */
+    @PostMapping("appendCheck")
+    public HttpResult prePayAppendCheck(@RequestBody @Valid AppendPayCheck appendPayCheck) {
+        return HttpResult.ok(walletService.appendCheck(appendPayCheck));
+    }
+
     /**
      * 预付追加
      *
@@ -215,19 +237,46 @@ public class WalletController {
         return HttpResult.ok(walletService.prePayAppend(prePay));
     }
 
+
+    /*退款*/
+
     /**
-     * 申请退款
+     * 申请退款(预付方)
      *
      * @param refundReq
      * @return
      */
     @PostMapping("applyRefund")
-    public HttpResult applyRefund(@RequestBody @Valid RefundReq refundReq) {
+    public HttpResult applyRefund(@RequestBody @Valid ApplyRefundReq refundReq) {
         return HttpResult.ok(walletService.applyRefund(refundReq));
     }
 
+
     /**
-     * 退款
+     * 查询退款列表(预收方)
+     *
+     * @param refundPage
+     * @return
+     */
+    @PostMapping("refundList")
+    public HttpResult refundList(@RequestBody @Valid RefundPage refundPage) {
+        return HttpResult.ok(walletService.refundList(refundPage));
+    }
+
+
+    /**
+     * 发起退款(预收方)余额查询及校验
+     *
+     * @param id 退款单id
+     * @return
+     */
+    @PostMapping("refundCheck")
+    public HttpResult refundCheck(@RequestBody @Valid Id id) {
+        return HttpResult.ok(walletService.refundCheck(id.getIdLong()));
+    }
+
+    /**
+     * 确认退款
      *
      * @param refundReq
      * @return
@@ -236,4 +285,15 @@ public class WalletController {
     public HttpResult refund(@RequestBody @Valid RefundReq refundReq) {
         return HttpResult.ok(walletService.launchRefund(refundReq));
     }
+
+    /**
+     * 驳回退款
+     *
+     * @param refundReq
+     * @return
+     */
+    @PostMapping("backRefund")
+    public HttpResult back(@RequestBody @Valid RefundBackReq refundReq) {
+        return HttpResult.ok(walletService.backRefund(refundReq));
+    }
 }

+ 11 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpWalletRefundMapper.java

@@ -2,7 +2,11 @@ package com.sckw.payment.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.payment.model.KwpWalletRefund;
+import com.sckw.payment.model.vo.req.RefundPage;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * @author xucaiqin
@@ -10,4 +14,11 @@ import org.apache.ibatis.annotations.Mapper;
  */
 @Mapper
 public interface KwpWalletRefundMapper extends BaseMapper<KwpWalletRefund> {
+    /**
+     * 查询退款中的 退款单列表
+     *
+     * @param refundPage
+     * @return
+     */
+    List<KwpWalletRefund> pageList(@Param("refundPage") RefundPage refundPage);
 }

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

@@ -0,0 +1,13 @@
+package com.sckw.payment.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.sckw.payment.model.KwpWalletRefundSub;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+* @date 2023-09-19 10:26:44
+* @author xucaiqin
+*/
+@Mapper
+public interface KwpWalletRefundSubMapper extends BaseMapper<KwpWalletRefundSub> {
+}

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

@@ -10,13 +10,10 @@ import java.math.BigDecimal;
 import java.time.LocalDateTime;
 
 /**
+ * 退款记录表
  * @date 2023-09-05 17:53:14
  * @author xucaiqin
  */
-
-/**
- * 退款记录表
- */
 @Data
 @TableName(value = "kwp_wallet_refund")
 public class KwpWalletRefund {

+ 73 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpWalletRefundSub.java

@@ -0,0 +1,73 @@
+package com.sckw.payment.model;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+/**
+ * 退款操作记录表
+* @date 2023-09-19 10:26:44
+* @author xucaiqin
+*/
+
+@Data
+@TableName(value = "kwp_wallet_refund_sub")
+public class KwpWalletRefundSub {
+    /**
+     * 主键
+     */
+    @TableId(value = "id", type = IdType.INPUT)
+    private Long id;
+
+    /**
+     * 退款单id
+     */
+    @TableField(value = "refund_id")
+    private Long refundId;
+
+    /**
+     * 备注
+     */
+    @TableField(value = "remark")
+    private String remark;
+
+    /**
+     * 创建人
+     */
+    @TableField(value = "create_by")
+    private Long createBy;
+
+    /**
+     * 创建时间
+     */
+    @TableField(value = "create_time")
+    private LocalDateTime createTime;
+
+    /**
+     * 更新人
+     */
+    @TableField(value = "update_by")
+    private Long updateBy;
+
+    /**
+     * 更新时间
+     */
+    @TableField(value = "update_time")
+    private LocalDateTime updateTime;
+
+    /**
+     * 0-正常 1-删除
+     */
+    @TableField(value = "del_flag")
+    private Integer delFlag;
+
+    /**
+     * 1-申请退款 发起退款 退款驳回
+     */
+    @TableField(value = "`status`")
+    private Integer status;
+}

+ 50 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/WalletInfoDto.java

@@ -0,0 +1,50 @@
+package com.sckw.payment.model.dto;
+
+import com.alibaba.fastjson2.annotation.JSONField;
+import com.sckw.payment.model.vo.res.MoneyChange;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * 钱包清单
+ */
+@Data
+public class WalletInfoDto implements MoneyChange, Serializable {
+    /**
+     * 是否开通钱包
+     */
+    private Boolean openFlag;
+    /**
+     * 渠道
+     */
+    private String channel;
+    /**
+     * 预付金额(分)
+     */
+    @JSONField(name = "ap_money")
+    private BigDecimal apMoney;
+    /**
+     * 提现余额
+     */
+    @JSONField(name = "wd_money")
+    private BigDecimal wdMoney;
+    /**
+     * 可用余额
+     */
+    private BigDecimal money;
+
+    /**
+     * 申请退款金额
+     */
+    private BigDecimal refundMoney;
+
+
+    //拓展字段
+    private String channelLabel;
+    private String uid;
+    private String uidName;
+    private String filter;
+    private String filterName;
+}

+ 3 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/wallet/MemberCreate.java

@@ -22,6 +22,9 @@ public class MemberCreate implements Serializable {
     private String legalName;
     @JSONField(name = "legalPhone")
     private String legalPhone;
+    /**
+     * 法人身份证号
+     */
     @JSONField(name = "legalIds")
     private String legalIds;
     @JSONField(name = "accountNo")

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

@@ -1,11 +1,13 @@
 package com.sckw.payment.model.vo;
 
 import com.alibaba.fastjson.annotation.JSONField;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Getter;
 import lombok.Setter;
 
 import java.io.Serial;
 import java.io.Serializable;
+import java.time.LocalDateTime;
 
 /**
  * 预付预收数据
@@ -22,6 +24,7 @@ public class PrePayWalletVo implements Serializable {
     @JSONField(name = "uid")
     private String uid;
     private String uidName;
+    private Long uidEnt;
 
     /**
      * 预付时,代表收款人
@@ -30,9 +33,14 @@ public class PrePayWalletVo implements Serializable {
     @JSONField(name = "filter")
     private String filter;
     private String filterName;
+    private Long filterEnt;
 
     @JSONField(name = "channel")
     private String channel;
+    /**
+     * 字典渠道
+     */
+    private String channelDict;
 
     @JSONField(name = "channel_label")
     private String channelLabel;
@@ -61,10 +69,9 @@ public class PrePayWalletVo implements Serializable {
      */
     @JSONField(name = "total_ap_money")
     private String totalApMoney;
-    /**
-     * 相关操作
-     */
-    private String action;
+
+    @JsonFormat(timezone = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime updateTime;
 
 
 }

+ 23 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/AppendPayCheck.java

@@ -0,0 +1,23 @@
+package com.sckw.payment.model.vo.req;
+
+import jakarta.validation.constraints.NotBlank;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 预付钱包可用余额校验
+ *
+ * @author xucaiqin
+ * @date 2023-08-29 09:14:04
+ */
+@Getter
+@Setter
+public class AppendPayCheck {
+    /**
+     * 支付通道 huifu
+     */
+    @NotBlank(message = "支付通道不能为空")
+    private String channel;
+    @NotBlank(message = "合作企业不能为空")
+    private String filter;
+}

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

@@ -0,0 +1,43 @@
+package com.sckw.payment.model.vo.req;
+
+import com.sckw.core.model.base.IdsList;
+import com.sckw.payment.model.vo.res.MoneyChange;
+import jakarta.validation.constraints.Digits;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.Positive;
+import jakarta.validation.constraints.Size;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+
+/**
+ * 申请退款参数
+ *
+ * @author xucaiqin
+ * @date 2023-08-29 09:14:04
+ */
+@Getter
+@Setter
+public class ApplyRefundReq implements MoneyChange, IdsList {
+    @NotBlank(message = "当前企业不能为空")
+    private String uid;
+    /**
+     * 支付通道字典值
+     */
+    @NotBlank(message = "支付通道不能为空")
+    private String channel;
+
+    @NotBlank(message = "合作企业不能为空")
+    private String filter;
+    /**
+     * 单位元
+     */
+    @Positive(message = "退款金额必须大于0")
+    @Digits(message = "小数位数过长或金额过大", integer = 10, fraction = 2)
+    private BigDecimal money;
+
+    @Size(message = "备注不能超过200字")
+    private String remark;
+
+}

+ 16 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/CreateUserReq.java

@@ -0,0 +1,16 @@
+package com.sckw.payment.model.vo.req;
+
+import jakarta.validation.constraints.NotBlank;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @author xucaiqin
+ * @date 2023-09-18 16:19:31
+ */
+@Getter
+@Setter
+public class CreateUserReq {
+    @NotBlank(message = "支付渠道不能为空")
+    private String channel;
+}

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

@@ -1,6 +1,5 @@
 package com.sckw.payment.model.vo.req;
 
-import jakarta.validation.constraints.NotBlank;
 import jakarta.validation.constraints.NotNull;
 import jakarta.validation.constraints.Size;
 import lombok.Getter;
@@ -20,7 +19,7 @@ public class FinanceCount {
     /**
      * 周期维度 1-日、2-周、3-月 4-年
      */
-    @NotBlank(message = "周期维度不能为空")
+    @NotNull(message = "周期维度不能为空")
     private Integer circle;
     /**
      * 开始时间

+ 24 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/RefundBackReq.java

@@ -0,0 +1,24 @@
+package com.sckw.payment.model.vo.req;
+
+import com.sckw.core.model.base.IdsList;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.Size;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 退款驳回
+ *
+ * @author xucaiqin
+ * @date 2023-08-29 09:14:04
+ */
+@Getter
+@Setter
+public class RefundBackReq implements IdsList {
+    @NotBlank(message = "退款单id不能为空")
+    private String id;
+
+    @NotBlank(message = "驳回原因不能为空")
+    @Size(message = "驳回原因不能超过200字")
+    private String remark;
+}

+ 32 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/RefundCheckReq.java

@@ -0,0 +1,32 @@
+package com.sckw.payment.model.vo.req;
+
+import com.sckw.payment.model.vo.res.MoneyChange;
+import jakarta.validation.constraints.NotBlank;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 预收-退款校验参数
+ *
+ * @author xucaiqin
+ * @date 2023-08-29 09:14:04
+ */
+@Getter
+@Setter
+public class RefundCheckReq implements MoneyChange {
+    /**
+     * 预收时,收款人 当前登录企业
+     */
+    @NotBlank(message = "当前企业不能为空")
+    private String uid;
+    /**
+     * 支付通道 huifu
+     */
+    @NotBlank(message = "支付通道不能为空")
+    private String channel;
+    /**
+     * 预收时,付款方
+     */
+    @NotBlank(message = "合作企业不能为空")
+    private String filter;
+}

+ 33 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/RefundPage.java

@@ -0,0 +1,33 @@
+package com.sckw.payment.model.vo.req;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.sckw.core.model.vo.BasePara;
+import com.sckw.payment.model.vo.res.MoneyChange;
+import jakarta.validation.constraints.NotBlank;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 退款
+ *
+ * @author xucaiqin
+ * @date 2023-08-29 09:14:04
+ */
+@Getter
+@Setter
+public class RefundPage extends BasePara implements MoneyChange {
+    @NotBlank(message = "当前企业不能为空")
+    private String uid;
+    /**
+     * 支付通道字典值
+     */
+    @NotBlank(message = "支付通道不能为空")
+    private String channel;
+    @NotBlank(message = "合作企业不能为空")
+    private String filter;
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private String startCreateTime;
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private String endCreateTime;
+
+}

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

@@ -1,8 +1,8 @@
 package com.sckw.payment.model.vo.req;
 
+import com.sckw.payment.model.dto.Id;
 import com.sckw.payment.model.vo.res.MoneyChange;
 import jakarta.validation.constraints.Digits;
-import jakarta.validation.constraints.NotBlank;
 import jakarta.validation.constraints.Positive;
 import jakarta.validation.constraints.Size;
 import lombok.Getter;
@@ -18,17 +18,7 @@ import java.math.BigDecimal;
  */
 @Getter
 @Setter
-public class RefundReq implements MoneyChange {
-    @NotBlank(message = "当前企业不能为空")
-    private String uid;
-    /**
-     * 支付通道字典值
-     */
-    @NotBlank(message = "支付通道不能为空")
-    private String channel;
-
-    @NotBlank(message = "合作企业不能为空")
-    private String filter;
+public class RefundReq extends Id implements MoneyChange {
 
     @Positive(message = "提现金额必须大于0")
     @Digits(message = "小数位数过长或金额过大", integer = 10, fraction = 2)

+ 14 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/MoneyChange.java

@@ -1,6 +1,7 @@
 package com.sckw.payment.model.vo.res;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.Objects;
 
 /**
@@ -24,4 +25,17 @@ public interface MoneyChange {
         return divide.longValueExact();
     }
 
+    /**
+     * 分转元
+     *
+     * @param big
+     * @return
+     */
+    default BigDecimal smallMoney(BigDecimal big) {
+        if (Objects.isNull(big)) {
+            return new BigDecimal("0.00");
+        }
+        return big.divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP);
+    }
+
 }

+ 91 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/WalletRefundVo.java

@@ -0,0 +1,91 @@
+package com.sckw.payment.model.vo.res;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+/**
+ * 退款记录表
+ */
+@Data
+public class WalletRefundVo {
+    /**
+     * 主键
+     */
+    private Long id;
+
+    /**
+     * 流水号
+     */
+    private String orderNo;
+
+    /**
+     * uid
+     */
+    private String uid;
+    private String uidName;
+
+    /**
+     * 退款企业id
+     */
+    private Long fromEnt;
+
+    /**
+     * filter
+     */
+    private String filter;
+    private String filterName;
+
+    /**
+     * 收款企业id
+     */
+    private Long toEnt;
+
+    /**
+     * 电子钱包渠道
+     */
+    private String channel;
+    /**
+     * 备注
+     */
+    private String remark;
+
+    /**
+     * 退款金额
+     */
+    private BigDecimal money;
+
+    /**
+     * 实际退款金额
+     */
+    private BigDecimal actualMoney;
+
+    /**
+     * 创建人
+     */
+    private Long createBy;
+
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime createTime;
+
+    /**
+     * 更新人
+     */
+    private Long updateBy;
+
+    /**
+     * 更新时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime updateTime;
+
+    /**
+     * 1-申请退款 2-退款中 3-退款失败 4-退款驳回 5-退款成功
+     */
+    private Integer status;
+}

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

@@ -103,6 +103,7 @@ public class KwpSettlementLogisticsService {
         settlementReq.setUnitTypeTwo(LogisticsUnitType.SHIPPER);
         return pageSelect(settlementReq);
     }
+
     /**
      * 查询贸易结算详情
      *
@@ -126,15 +127,15 @@ public class KwpSettlementLogisticsService {
         Integer payType = TradingEnum.getPrefix(trading);
         List<SettlementVo> settlementVoList = new ArrayList<>();
         if (Objects.nonNull(payType)) {
-            if(payType==TradingEnum.OFFLINE_PAY.getStatus()){
+            if (payType == TradingEnum.OFFLINE_PAY.getStatus()) {
                 settlementVoList = kwpSettlementOfflineService.queryList(id, SettlementOrderTypeEnum.LOGISTICS.getStatus(), payType);
-            }else {
+            } else {
                 settlementVoList = kwpSettlementWalletService.queryList(id, SettlementOrderTypeEnum.LOGISTICS.getStatus(), payType);
             }
         }
-        List<SettlementVo> settlementWallet = kwpSettlementWalletService.queryList(id, SettlementOrderTypeEnum.LOGISTICS.getStatus(), TradingEnum.getPrefix(trading));
         return new SettlementDetailDto<>(settlementLogisticsDto, settlementVoList);
     }
+
     /**
      * 运费收款-物流订单详情
      *
@@ -375,14 +376,15 @@ public class KwpSettlementLogisticsService {
     public List<String> checkOrder(Long entId, Long entTarget) {
         return settlementLogisticsMapper.selectJoin(entId, entTarget);
     }
+
     /**
      * @param entId    顶级企业id
-     * @param cur       当月/周
-     * @param pre       上月/周
+     * @param cur      当月/周
+     * @param pre      上月/周
      * @param unitType 企业类型 2-销售 1-采购
      */
     public List<MoneyType> moneySum(Long entId, List<LocalDateTime> cur, List<LocalDateTime> pre, Integer unitType) {
-        return settlementLogisticsMapper.sumMoneyType(entId,  cur, pre,  unitType);
+        return settlementLogisticsMapper.sumMoneyType(entId, cur, pre, unitType);
 
     }
 }

+ 43 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpWalletRefundSubService.java

@@ -0,0 +1,43 @@
+package com.sckw.payment.service;
+
+import com.sckw.core.common.enums.NumberConstant;
+import com.sckw.core.model.constant.Global;
+import com.sckw.core.utils.IdWorker;
+import com.sckw.core.web.context.LoginUserHolder;
+import com.sckw.payment.dao.KwpWalletRefundSubMapper;
+import com.sckw.payment.model.KwpWalletRefundSub;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+
+import java.time.LocalDateTime;
+
+/**
+ *
+ * @author xucaiqin
+ * @date 2023-09-19 10:26:44
+ */
+@Service
+@RequiredArgsConstructor
+public class KwpWalletRefundSubService {
+    private final KwpWalletRefundSubMapper kwpWalletRefundSubMapper;
+
+    /**
+     * 保存关联的操作记录
+     * @param refundId
+     * @param remark
+     * @param status
+     */
+    public void saveRecord(Long refundId, String remark, int status) {
+        KwpWalletRefundSub kwpWalletRefundSub = new KwpWalletRefundSub();
+        kwpWalletRefundSub.setId(new IdWorker(NumberConstant.ONE).nextId());
+        kwpWalletRefundSub.setRefundId(refundId);
+        kwpWalletRefundSub.setRemark(remark);
+        kwpWalletRefundSub.setCreateBy(LoginUserHolder.getUserId());
+        kwpWalletRefundSub.setCreateTime(LocalDateTime.now());
+        kwpWalletRefundSub.setUpdateBy(LoginUserHolder.getUserId());
+        kwpWalletRefundSub.setUpdateTime(LocalDateTime.now());
+        kwpWalletRefundSub.setDelFlag(Global.UN_DELETED);
+        kwpWalletRefundSub.setStatus(status);
+        kwpWalletRefundSubMapper.insert(kwpWalletRefundSub);
+    }
+}

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

@@ -2,6 +2,7 @@ package com.sckw.payment.service;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.sckw.core.common.enums.NumberConstant;
+import com.sckw.core.model.constant.Global;
 import com.sckw.core.utils.IdWorker;
 import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.payment.dao.KwpWalletRelationMapper;
@@ -97,5 +98,13 @@ public class KwpWalletRelationService {
         relationMapper.insert(kwpWalletRelation);
     }
 
+    public KwpWalletRelation query(WalletRelationDto walletRelationDto) {
+        LambdaQueryWrapper<KwpWalletRelation> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(KwpWalletRelation::getEntId, walletRelationDto.entId())
+                .eq(KwpWalletRelation::getUid, walletRelationDto.uid())
+                .eq(KwpWalletRelation::getDelFlag, Global.UN_DELETED).last("limit 1");
+        return relationMapper.selectOne(wrapper);
+    }
+
 
 }

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

@@ -55,7 +55,7 @@ public class PayCenterService {
     }
 
     private String getHttp(PayCenterEnum payCenterEnum, Map<String, Object> para) {
-        log.debug("{}入参->{}", payCenterEnum.getDesc(), JSONObject.toJSONString(para));
+        log.info("{}入参->{}", payCenterEnum.getDesc(), JSONObject.toJSONString(para));
         OkHttpUtils okHttpUtils = OkHttpUtils.builder().url(payCenterAddr + payCenterEnum.getAddr());
         if (!CollectionUtils.isEmpty(para)) {
             for (Map.Entry<String, Object> p : para.entrySet()) {
@@ -90,12 +90,12 @@ public class PayCenterService {
             log.error("中台服务异常", e.getCause());
             throw new RuntimeException("支付服务异常!");
         }
-        log.debug("{}返回值->{}", payCenterEnum.getDesc(), sync);
+        log.info("{}返回值->{}", payCenterEnum.getDesc(), sync);
         return changeRes(sync);
     }
 
     private String postHttp(PayCenterEnum payCenterEnum, Map<String, Object> para) {
-        log.debug("{}入参->{}", payCenterEnum.getDesc(), JSONObject.toJSONString(para));
+        log.info("{}入参->{}", payCenterEnum.getDesc(), JSONObject.toJSONString(para));
         OkHttpUtils okHttpUtils = OkHttpUtils.builder().url(payCenterAddr + payCenterEnum.getAddr());
         if (!CollectionUtils.isEmpty(para)) {
             for (Map.Entry<String, Object> p : para.entrySet()) {
@@ -129,13 +129,13 @@ public class PayCenterService {
             log.error("中台服务异常", e.getCause());
             throw new RuntimeException("支付服务异常!");
         }
-        log.debug("{}返回值->{}", payCenterEnum.getDesc(), sync);
+        log.info("{}返回值->{}", payCenterEnum.getDesc(), sync);
         return changeRes(sync);
     }
 
     private String jsonHttp(PayCenterEnum payCenterEnum, Object object) {
         String para = object instanceof JSONObject jsonObject ? jsonObject.toJSONString() : JSONObject.toJSONString(object);
-        log.debug("{}入参->{}", payCenterEnum.getDesc(), para);
+        log.info("{}入参->{}", payCenterEnum.getDesc(), para);
         OkHttpUtils okHttpUtils = OkHttpUtils.builder().url(payCenterAddr + payCenterEnum.getAddr());
         okHttpUtils.addBodyJsonStr(para);
         String sync;
@@ -145,7 +145,7 @@ public class PayCenterService {
             log.error("中台服务异常", e.getCause());
             throw new RuntimeException("支付服务异常!");
         }
-        log.debug("{}返回值->{}", payCenterEnum.getDesc(), sync);
+        log.info("{}返回值->{}", payCenterEnum.getDesc(), sync);
         return changeRes(sync);
     }
 

+ 113 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/WalletOrderService.java

@@ -0,0 +1,113 @@
+package com.sckw.payment.service;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.sckw.core.model.page.PageRes;
+import com.sckw.core.utils.BeanUtils;
+import com.sckw.payment.dao.KwpWalletRefundMapper;
+import com.sckw.payment.dao.KwpWalletTransferMapper;
+import com.sckw.payment.model.KwpWalletRefund;
+import com.sckw.payment.model.constant.RefundEnum;
+import com.sckw.payment.model.vo.req.RefundPage;
+import com.sckw.payment.model.vo.res.WalletRefundVo;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 钱包订单相关业务
+ *
+ * @author xucaiqin
+ * @date 2023-09-18 19:20:02
+ */
+@Slf4j
+@Service
+@RequiredArgsConstructor
+public class WalletOrderService {
+    private final KwpWalletRefundMapper kwpWalletRefundMapper;
+    private final KwpWalletTransferMapper kwpWalletTransferMapper;
+
+    /**
+     * 预付、预收 查询退款中金额
+     *
+     * @param change  true-预收,需要转换双方企业
+     * @param channel huifu-汇付渠道
+     */
+    public List<KwpWalletRefund> query(boolean change, String uid, String filter, String channel) {
+        LambdaQueryWrapper<KwpWalletRefund> wrapper = new LambdaQueryWrapper<>();
+        //预收时,切换预收预付的双方人员
+        if (change) {
+            wrapper.eq(KwpWalletRefund::getUid, filter).eq(KwpWalletRefund::getFilter, uid);
+        } else {
+            wrapper.eq(KwpWalletRefund::getUid, uid).eq(KwpWalletRefund::getFilter, filter);
+        }
+        wrapper.eq(KwpWalletRefund::getChannel, channel)
+                .eq(KwpWalletRefund::getStatus, RefundEnum.REFUNDING.getStatus());
+        return kwpWalletRefundMapper.selectList(wrapper);
+    }
+
+    /**
+     * 查询退款中的订单
+     *
+     * @param uid
+     * @param filter
+     * @param channel
+     * @return
+     */
+    public List<KwpWalletRefund> queryList(String uid, String filter, String channel, RefundEnum refundEnum) {
+        LambdaQueryWrapper<KwpWalletRefund> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(KwpWalletRefund::getUid, uid).eq(KwpWalletRefund::getFilter, filter);
+        wrapper.eq(KwpWalletRefund::getChannel, channel)
+                .eq(KwpWalletRefund::getStatus, refundEnum.getStatus());
+        return kwpWalletRefundMapper.selectList(wrapper);
+    }
+
+    public KwpWalletRefund queryOne(String uid, String filter, String channel, RefundEnum refundEnum) {
+        LambdaQueryWrapper<KwpWalletRefund> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(KwpWalletRefund::getUid, uid).eq(KwpWalletRefund::getFilter, filter);
+        wrapper.eq(KwpWalletRefund::getChannel, channel)
+                .eq(KwpWalletRefund::getStatus, refundEnum.getStatus()).last("limit 1");
+        return kwpWalletRefundMapper.selectOne(wrapper);
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    public KwpWalletRefund queryById(Long id) {
+        return kwpWalletRefundMapper.selectById(id);
+    }
+
+    /**
+     * 更新
+     *
+     * @param kwpWalletRefund
+     * @return
+     */
+    public void updateById(KwpWalletRefund kwpWalletRefund) {
+        kwpWalletRefundMapper.updateById(kwpWalletRefund);
+    }
+
+    /**
+     * 分页查询
+     *
+     * @param refundPage
+     * @return
+     */
+    public PageRes<WalletRefundVo> queryRefundList(RefundPage refundPage) {
+        PageHelper.startPage(refundPage.getPage(), refundPage.getPageSize());
+        List<KwpWalletRefund> kwpWalletRefunds = kwpWalletRefundMapper.pageList(refundPage);
+        PageInfo<KwpWalletRefund> pageInfo = new PageInfo<>(kwpWalletRefunds);
+        List<WalletRefundVo> list = kwpWalletRefunds.stream().map(a -> {
+            WalletRefundVo walletRefundVo = new WalletRefundVo();
+            BeanUtils.copyProperties(a, walletRefundVo);
+            return walletRefundVo;
+        }).toList();
+        return PageRes.build(pageInfo, list);
+    }
+}

+ 310 - 75
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/WalletService.java

@@ -4,12 +4,12 @@ import com.alibaba.fastjson2.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.sckw.core.common.enums.NumberConstant;
 import com.sckw.core.exception.BusinessException;
-import com.sckw.core.exception.SuccessBusinessException;
 import com.sckw.core.model.constant.Global;
 import com.sckw.core.model.page.PageRes;
 import com.sckw.core.utils.CollectionUtils;
 import com.sckw.core.utils.IdWorker;
 import com.sckw.core.utils.OrderUtils;
+import com.sckw.core.utils.StringTimeUtil;
 import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.manage.api.RemoteManageService;
 import com.sckw.manage.api.model.dto.res.FindEntCooperateResVo;
@@ -20,15 +20,17 @@ import com.sckw.payment.dao.KwpWalletRefundMapper;
 import com.sckw.payment.dao.KwpWalletTransferMapper;
 import com.sckw.payment.job.AsyncPool;
 import com.sckw.payment.model.KwpWalletRefund;
+import com.sckw.payment.model.KwpWalletRelation;
 import com.sckw.payment.model.KwpWalletTransfer;
 import com.sckw.payment.model.constant.RefundEnum;
 import com.sckw.payment.model.constant.TransferEnum;
 import com.sckw.payment.model.constant.WalletChannelEnum;
+import com.sckw.payment.model.dto.WalletInfoDto;
+import com.sckw.payment.model.dto.WalletRelationDto;
 import com.sckw.payment.model.dto.common.BusinessNo;
 import com.sckw.payment.model.dto.page.CashPage;
 import com.sckw.payment.model.dto.page.PrePayWalletPage;
 import com.sckw.payment.model.dto.wallet.*;
-import com.sckw.payment.model.dto.wallet.ChannelStatistics;
 import com.sckw.payment.model.vo.PrePayWalletVo;
 import com.sckw.payment.model.vo.req.*;
 import com.sckw.payment.model.vo.res.*;
@@ -36,6 +38,7 @@ import com.sckw.redis.config.RedisLockUtil;
 import com.sckw.redis.constant.RedisLockKey;
 import com.sckw.system.api.RemoteSystemService;
 import com.sckw.system.api.model.dto.res.EntCacheResDto;
+import com.sckw.system.api.model.dto.res.EntCertificateResDto;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
@@ -44,6 +47,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
 import java.text.DecimalFormat;
@@ -63,9 +67,11 @@ import java.util.stream.Collectors;
 public class WalletService {
     private final PayCenterService payCenterService;
     private final KwpWalletRelationService walletRelationService;
+    private final WalletOrderService walletOrderService;
     private final KwpWalletRefundMapper kwpWalletRefundMapper;
     private final KwpWalletTransferMapper kwpWalletTransferMapper;
     private final RedisLockUtil redisLockUtil;
+    private final KwpWalletRefundSubService kwpWalletRefundSubService;
     @DubboReference(version = "1.0.0", group = "design", check = false)
     private RemoteSystemService remoteSystemService;
     @DubboReference(version = "1.0.0", group = "design", check = false)
@@ -91,6 +97,19 @@ public class WalletService {
         return "";
     }
 
+    /**
+     * 根据中台用户id查询企业id
+     *
+     * @param id 中台用户id
+     * @return
+     */
+    private Long getEnt(String id) {
+        if (StringUtils.isBlank(id)) {
+            return null;
+        }
+        return walletRelationService.getEnt(id);
+    }
+
     /**
      * 通过企业名称查询关联的中台用户id
      *
@@ -102,7 +121,7 @@ public class WalletService {
             Long entId = LoginUserHolder.getEntId();
             List<FindEntCooperateResVo> allCooperateEnt = remoteManageService.findAllCooperateEnt(entId);
             if (!CollectionUtils.isEmpty(allCooperateEnt)) {
-                List<Long> collect = allCooperateEnt.stream().filter(a -> StringUtils.contains(a.getEntName(), entName)).map(FindEntCooperateResVo::getEntId).collect(Collectors.toList());
+                List<Long> collect = allCooperateEnt.stream().filter(a -> StringUtils.contains(a.getEntName(), entName)).map(FindEntCooperateResVo::getEntId).toList();
                 List<String> res = new ArrayList<>();
                 for (Long aLong : collect) {
                     String relation = walletRelationService.getRelation(aLong);
@@ -149,21 +168,17 @@ public class WalletService {
      */
     private void refundMoney(PrePayWallet prePayWallet, PrePayWalletVo prePayWalletVo, boolean change) {
         DecimalFormat df = new DecimalFormat("0.00");
-        LambdaQueryWrapper<KwpWalletRefund> wrapper = new LambdaQueryWrapper<>();
-        //预收时,切换预收预付的双方人员
-        if (change) {
-            wrapper.eq(KwpWalletRefund::getUid, prePayWallet.getFilter()).eq(KwpWalletRefund::getFilter, prePayWallet.getUid());
-        } else {
-            wrapper.eq(KwpWalletRefund::getUid, prePayWallet.getUid()).eq(KwpWalletRefund::getFilter, prePayWallet.getFilter());
-        }
-        wrapper.eq(KwpWalletRefund::getChannel, prePayWallet.getChannel()).eq(KwpWalletRefund::getStatus, RefundEnum.REFUNDING.getStatus()).last("limit 1");
-        KwpWalletRefund kwpWalletRefund = kwpWalletRefundMapper.selectOne(wrapper);
-        if (Objects.nonNull(kwpWalletRefund)) {
-            prePayWalletVo.setRefundApMoney(df.format(kwpWalletRefund.getActualMoney()));
-            prePayWalletVo.setAction(RefundEnum.getDesc(kwpWalletRefund.getStatus()));
+        List<KwpWalletRefund> query = walletOrderService.query(change, prePayWallet.getUid(), prePayWallet.getFilter(), prePayWallet.getChannel());
+        if (!CollectionUtils.isEmpty(query)) {
+            BigDecimal reduce = query.stream().map(KwpWalletRefund::getMoney).reduce(BigDecimal.ZERO, (o, n) -> {
+                if (Objects.isNull(n)) {
+                    return o.add(new BigDecimal("0.0"));
+                }
+                return o.add(n);
+            });
+            prePayWalletVo.setRefundApMoney(df.format(reduce));
         } else {
             prePayWalletVo.setRefundApMoney("0.00");
-            prePayWalletVo.setAction("");
         }
     }
 
@@ -174,11 +189,15 @@ public class WalletService {
      */
     private void refundMoney2(FundVo fundVo) {
         DecimalFormat df = new DecimalFormat("0.00");
-        LambdaQueryWrapper<KwpWalletRefund> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(KwpWalletRefund::getUid, fundVo.getUid()).eq(KwpWalletRefund::getFilter, fundVo.getFilter()).eq(KwpWalletRefund::getChannel, fundVo.getChannel()).eq(KwpWalletRefund::getStatus, RefundEnum.REFUNDING.getStatus()).last("limit 1");
-        KwpWalletRefund kwpWalletRefund = kwpWalletRefundMapper.selectOne(wrapper);
-        if (Objects.nonNull(kwpWalletRefund)) {
-            fundVo.setRefundMoney(df.format(kwpWalletRefund.getActualMoney()));
+        List<KwpWalletRefund> kwpWalletRefunds = walletOrderService.queryList(fundVo.getUid(), fundVo.getFilter(), fundVo.getChannel(), RefundEnum.REFUNDING);
+        if (!CollectionUtils.isEmpty(kwpWalletRefunds)) {
+            BigDecimal reduce = kwpWalletRefunds.stream().map(KwpWalletRefund::getMoney).reduce(BigDecimal.ZERO, (o, n) -> {
+                if (Objects.isNull(n)) {
+                    return o.add(new BigDecimal("0.0"));
+                }
+                return o.add(n);
+            });
+            fundVo.setRefundMoney(df.format(reduce));
         } else {
             fundVo.setRefundMoney("0.00");
         }
@@ -253,8 +272,7 @@ public class WalletService {
         Long entId = LoginUserHolder.getEntId();
         String uid = walletRelationService.getRelation(entId);
         if (StringUtils.isBlank(uid)) {
-            throw new SuccessBusinessException("暂未开通电子钱包");
-//            return new WalletDetail(LoginUserHolder.getEntName(), "-", "-", "-", 0, new ArrayList<>());
+            return new WalletDetail(LoginUserHolder.getEntName(), "-", "-", "-", 0, new ArrayList<>());
         }
         //钱包总览信息
         R<WalletOverview> wallet = payCenterService.general(uid);
@@ -320,28 +338,26 @@ public class WalletService {
      * @return
      */
     public Object channel() {
-        Long entId = LoginUserHolder.getEntId();
-        String uid = walletRelationService.getRelation(entId);
-        if (StringUtils.isBlank(uid)) {
-            throw new BusinessException("暂未开通电子钱包");
-        }
-        R<WalletOverview> wallet = payCenterService.general(uid);
-        if (wallet.getStatus()) {
-            WalletOverview data = wallet.getData();
-            //已开通的渠道
-            List<String> channels = data.getChannels();
+        String uid = walletRelationService.getRelation(LoginUserHolder.getEntId());
+        if (StringUtils.isNotBlank(uid)) {
+            R<WalletOverview> wallet = payCenterService.general(uid);
+            if (wallet.getStatus()) {
+                WalletOverview data = wallet.getData();
+                //已开通的渠道
+                List<String> channels = data.getChannels();
 
-            List<ChannelDetail> res = new ArrayList<>();
-            for (WalletChannelEnum value : WalletChannelEnum.channelEnumList()) {
-                ChannelDetail channelDetail = new ChannelDetail();
-                channelDetail.setChannel(value.getChannel());
-                channelDetail.setName(value.getDesc());
-                channelDetail.setMoney("-");
-                channelDetail.setTotalMoney("-");
-                channelDetail.setOpenFlag(channels.contains(value.getChannel()));
-                res.add(channelDetail);
+                List<ChannelDetail> res = new ArrayList<>();
+                for (WalletChannelEnum value : WalletChannelEnum.channelEnumList()) {
+                    ChannelDetail channelDetail = new ChannelDetail();
+                    channelDetail.setChannel(value.getChannel());
+                    channelDetail.setName(value.getDesc());
+                    channelDetail.setMoney("-");
+                    channelDetail.setTotalMoney("-");
+                    channelDetail.setOpenFlag(channels.contains(value.getChannel()));
+                    res.add(channelDetail);
+                }
+                return res;
             }
-            return res;
         }
         return WalletChannelEnum.channelEnumList().stream().map(a -> {
             ChannelDetail channelDetail = new ChannelDetail();
@@ -694,9 +710,13 @@ public class WalletService {
                 for (PrePayWallet row : data.getRows()) {
                     prePayWalletVo = new PrePayWalletVo();
                     BeanUtils.copyProperties(row, prePayWalletVo);
+                    ChannelEnum byChannel = ChannelEnum.getByChannel(row.getChannel());
+                    prePayWalletVo.setChannelDict(Objects.nonNull(byChannel) ? byChannel.getValue() : "");
                     prePayWalletVo.setApMoney(dfMoney(row.getApMoney()));
                     prePayWalletVo.setUidName(getFirmName(row.getUid()));
+                    prePayWalletVo.setUidEnt(getEnt(row.getUid()));
                     prePayWalletVo.setFilterName(getFirmName(row.getFilter()));
+                    prePayWalletVo.setFilterEnt(getEnt(row.getFilter()));
                     prePayWalletVo.setUsingApMoney(dfMoney(row.getUsingApMoney()));
                     prePayWalletVo.setSettlingApMoney(dfMoney(row.getSettlingApMoney()));
                     prePayWalletVo.setTotalApMoney(dfMoney(row.getTotalApMoney()));
@@ -797,9 +817,13 @@ public class WalletService {
                 for (PrePayWallet row : data.getRows()) {
                     prePayWalletVo = new PrePayWalletVo();
                     BeanUtils.copyProperties(row, prePayWalletVo);
+                    ChannelEnum byChannel = ChannelEnum.getByChannel(row.getChannel());
+                    prePayWalletVo.setChannelDict(Objects.nonNull(byChannel) ? byChannel.getValue() : "");
                     prePayWalletVo.setApMoney(dfMoney(row.getApMoney()));
                     prePayWalletVo.setUidName(getFirmName(row.getUid()));
+                    prePayWalletVo.setUidEnt(getEnt(row.getUid()));
                     prePayWalletVo.setFilterName(getFirmName(row.getFilter()));
+                    prePayWalletVo.setFilterEnt(getEnt(row.getFilter()));
                     prePayWalletVo.setUsingApMoney(dfMoney(row.getUsingApMoney()));
                     prePayWalletVo.setSettlingApMoney(dfMoney(row.getSettlingApMoney()));
                     prePayWalletVo.setTotalApMoney(dfMoney(row.getTotalApMoney()));
@@ -891,7 +915,12 @@ public class WalletService {
         if (Objects.isNull(data)) {
             throw new BusinessException("不存在交易");
         }
-        return data;
+        WalletInfoDto walletInfoDto = new WalletInfoDto();
+        walletInfoDto.setChannel(data.getChannel());
+        walletInfoDto.setApMoney(walletInfoDto.smallMoney(data.getApMoney()));
+        walletInfoDto.setWdMoney(walletInfoDto.smallMoney(data.getWdMoney()));
+        walletInfoDto.setMoney(walletInfoDto.smallMoney(data.getMoney()));
+        return walletInfoDto;
     }
 
     /**
@@ -945,20 +974,37 @@ public class WalletService {
 
     /**
      * 申请退款
+     * 校验预付可用余额和退款金额,退款金额不能大于预付可用余额
      *
      * @return
      */
-    public Object applyRefund(RefundReq refundReq) {
-        LambdaQueryWrapper<KwpWalletRefund> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(KwpWalletRefund::getChannel, refundReq.getChannel()).eq(KwpWalletRefund::getUid, refundReq.getUid()).eq(KwpWalletRefund::getFilter, refundReq.getFilter()).eq(KwpWalletRefund::getStatus, RefundEnum.APPLY.getStatus()).last("limit 1");
-        KwpWalletRefund kwpWalletRefund = kwpWalletRefundMapper.selectOne(wrapper);
-        if (Objects.nonNull(kwpWalletRefund)) {
-            throw new BusinessException("存在未完成的退款订单");
-        }
+    @Transactional(rollbackFor = Exception.class)
+    public Object applyRefund(ApplyRefundReq refundReq) {
         ChannelEnum channelEnum = ChannelEnum.getByChannel(refundReq.getChannel());
         if (Objects.isNull(channelEnum)) {
             throw new BusinessException("支付通道不存在");
         }
+        //校验余额
+        R<WalletInfo> walletInfoR = payCenterService.totalInfo(refundReq.getUid(), channelEnum, refundReq.getFilter());
+        if (!walletInfoR.getStatus()) {
+            throw new BusinessException(StringUtils.isNotBlank(walletInfoR.getMsg()) ? walletInfoR.getMsg() : "未找到交易方");
+        }
+        WalletInfo data = walletInfoR.getData();
+        if (Objects.isNull(data)) {
+            throw new BusinessException("不存在交易");
+        }
+        //预付可用余额 分
+        BigDecimal apMoney = data.getApMoney();
+        apMoney = Objects.isNull(apMoney) ? BigDecimal.ZERO : apMoney;
+        //退款金额 元
+        BigDecimal money = refundReq.getMoney();
+        //退款金额 分
+        BigDecimal multiply = money.multiply(new BigDecimal("100"));
+        if (multiply.compareTo(apMoney) > 0) {
+            throw new BusinessException("退款金额不能大于预付可用金额");
+        }
+
+        //新增退款单
         KwpWalletRefund kwpWalletRefundAdd = new KwpWalletRefund();
         kwpWalletRefundAdd.setId(new IdWorker(NumberConstant.ONE).nextId());
         kwpWalletRefundAdd.setOrderNo(OrderUtils.generateOrderNo("RF"));
@@ -977,6 +1023,7 @@ public class WalletService {
         kwpWalletRefundAdd.setDelFlag(0);
         kwpWalletRefundAdd.setStatus(RefundEnum.APPLY.getStatus());
         kwpWalletRefundMapper.insert(kwpWalletRefundAdd);
+        kwpWalletRefundSubService.saveRecord(kwpWalletRefundAdd.getId(), refundReq.getRemark(), RefundEnum.APPLY.getStatus());
         return "提交成功";
     }
 
@@ -990,33 +1037,221 @@ public class WalletService {
      *
      * @return
      */
+    @Transactional(rollbackFor = Exception.class)
     public Object launchRefund(RefundReq refundReq) {
-        LambdaQueryWrapper<KwpWalletRefund> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(KwpWalletRefund::getChannel, refundReq.getChannel());
-        wrapper.eq(KwpWalletRefund::getUid, refundReq.getUid()).eq(KwpWalletRefund::getFilter, refundReq.getFilter()).eq(KwpWalletRefund::getStatus, RefundEnum.APPLY.getStatus()).last("limit 1");
-        KwpWalletRefund kwpWalletRefund = kwpWalletRefundMapper.selectOne(wrapper);
+        KwpWalletRefund kwpWalletRefund = walletOrderService.queryById(refundReq.getIdLong());
         if (Objects.isNull(kwpWalletRefund)) {
-            throw new BusinessException("未找到待完成的退款订单");
+            throw new BusinessException("退款订单不存在");
         }
-        ChannelEnum channelEnum = ChannelEnum.getByChannel(refundReq.getChannel());
+        String key = RedisLockKey.REFUND + refundReq.getIdLong();
+        if (redisLockUtil.tryLock(key)) {
+            try {
+                if (kwpWalletRefund.getStatus() != RefundEnum.APPLY.getStatus()) {
+                    throw new BusinessException("当前退款单已提交退款申请");
+                }
+                ChannelEnum channelEnum = ChannelEnum.getByChannel(kwpWalletRefund.getChannel());
+                if (Objects.isNull(channelEnum)) {
+                    throw new BusinessException("支付通道不存在");
+                }
+                // 1.记账
+                List<PatchPay> list = new ArrayList<>();
+                PatchPay patchPay = new PatchPay();
+                patchPay.setUid(kwpWalletRefund.getFilter());
+                patchPay.setMoney(refundReq.bigMoney(refundReq.getMoney()));
+                patchPay.setRemark(StringUtils.isBlank(refundReq.getRemark()) ? "" : refundReq.getRemark());
+                list.add(patchPay);
+                R<BusinessNo> businessNoR = payCenterService.payAgentPayV2(kwpWalletRefund.getUid(), kwpWalletRefund.getFilter(), channelEnum, refundReq.bigMoney(refundReq.getMoney()), list, OrderUtils.generateOrderNo("SEQ"), "1");
+                if (!businessNoR.getStatus()) {
+                    throw new BusinessException(StringUtils.isNotBlank(businessNoR.getMsg()) ? businessNoR.getMsg() : "退款失败");
+                }
+                //保存操作记录
+                kwpWalletRefundSubService.saveRecord(kwpWalletRefund.getId(), refundReq.getRemark(), RefundEnum.REFUNDING.getStatus());
+
+                Long userId = LoginUserHolder.getUserId();
+                //异步提交清分退款任务
+                AsyncPool.addTask(new Refund(refundReq, kwpWalletRefund, payCenterService, kwpWalletRefundMapper, userId));
+                return businessNoR;
+            } finally {
+                redisLockUtil.unlock(key);
+            }
+        }
+        throw new BusinessException("请勿重复提交退款操作");
+    }
+
+    /**
+     * 发起退款校验
+     *
+     * @param id
+     * @return
+     */
+    public WalletInfoDto refundCheck(Long id) {
+        KwpWalletRefund kwpWalletRefund = walletOrderService.queryById(id);
+        if (Objects.isNull(kwpWalletRefund)) {
+            throw new BusinessException("退款订单不存在");
+        }
+        ChannelEnum channelEnum = ChannelEnum.getByChannel(kwpWalletRefund.getChannel());
+        if (Objects.isNull(channelEnum)) {
+            throw new BusinessException("支付通道不存在");
+        }
+        //发起退款是预收业务,uid和filter是相反的,查询时需要方向查询钱包
+        R<WalletInfo> walletInfoR = payCenterService.totalInfo(kwpWalletRefund.getFilter(), channelEnum, kwpWalletRefund.getUid());
+        // 未开通钱包
+        if (!walletInfoR.getStatus()) {
+            WalletInfoDto walletInfoDto = new WalletInfoDto();
+            walletInfoDto.setOpenFlag(false);
+            return walletInfoDto;
+        }
+        WalletInfo data = walletInfoR.getData();
+        if (Objects.isNull(data)) {
+            WalletInfoDto walletInfoDto = new WalletInfoDto();
+            walletInfoDto.setOpenFlag(false);
+            return walletInfoDto;
+        }
+        WalletInfoDto walletInfoDto = new WalletInfoDto();
+        walletInfoDto.setOpenFlag(true);
+        walletInfoDto.setChannel(data.getChannel());
+        walletInfoDto.setApMoney(walletInfoDto.smallMoney(data.getApMoney()));
+        walletInfoDto.setWdMoney(walletInfoDto.smallMoney(data.getWdMoney()));
+        walletInfoDto.setMoney(walletInfoDto.smallMoney(data.getMoney()));
+        //申请退款金额
+        walletInfoDto.setRefundMoney(kwpWalletRefund.getMoney());
+
+        walletInfoDto.setChannelLabel(channelEnum.getDesc());
+        walletInfoDto.setUid(kwpWalletRefund.getUid());
+        walletInfoDto.setUidName(getFirmName(kwpWalletRefund.getUid()));
+        walletInfoDto.setFilter(kwpWalletRefund.getFilter());
+        walletInfoDto.setFilterName(getFirmName(kwpWalletRefund.getFilter()));
+        return walletInfoDto;
+    }
+
+    /**
+     * 预付追加校验
+     *
+     * @param appendPayCheck
+     * @return
+     */
+    public Object appendCheck(AppendPayCheck appendPayCheck) {
+        String uid = walletRelationService.getRelation(LoginUserHolder.getEntId());
+        if (StringUtils.isBlank(uid)) {
+            throw new BusinessException("您暂未开通电子钱包");
+        }
+        //字典
+        ChannelEnum channelEnum = ChannelEnum.getByChannel(appendPayCheck.getChannel());
+        if (Objects.isNull(channelEnum)) {
+            throw new BusinessException("支付通道不存在");
+        }
+        R<WalletInfo> walletInfoR = payCenterService.totalInfo(uid, channelEnum, appendPayCheck.getFilter());
+        if (!walletInfoR.getStatus()) {
+            throw new BusinessException(StringUtils.isNotBlank(walletInfoR.getMsg()) ? walletInfoR.getMsg() : "未找到交易方");
+        }
+        WalletInfo data = walletInfoR.getData();
+        if (Objects.isNull(data)) {
+            throw new BusinessException("不存在交易");
+        }
+        WalletInfoDto walletInfoDto = new WalletInfoDto();
+        walletInfoDto.setOpenFlag(true);
+        walletInfoDto.setChannel(data.getChannel());
+        walletInfoDto.setApMoney(walletInfoDto.smallMoney(data.getApMoney()));
+        walletInfoDto.setWdMoney(walletInfoDto.smallMoney(data.getWdMoney()));
+        walletInfoDto.setMoney(walletInfoDto.smallMoney(data.getMoney()));
+        return walletInfoDto;
+    }
+
+    /**
+     * 渠道开通
+     *
+     * @param createUserReq
+     * @return
+     */
+    public Object createUser(CreateUserReq createUserReq) {
+        Long entId = LoginUserHolder.getEntId();
+        ChannelEnum channelEnum = ChannelEnum.getByChannel(createUserReq.getChannel());
         if (Objects.isNull(channelEnum)) {
             throw new BusinessException("支付通道不存在");
         }
-        // 1.记账
-        List<PatchPay> list = new ArrayList<>();
-        PatchPay patchPay = new PatchPay();
-        patchPay.setUid(refundReq.getFilter());
-        patchPay.setMoney(refundReq.bigMoney(refundReq.getMoney()));
-        patchPay.setRemark(refundReq.getRemark());
-        list.add(patchPay);
-        R<BusinessNo> businessNoR = payCenterService.payAgentPayV2(refundReq.getUid(), refundReq.getFilter(), channelEnum, refundReq.bigMoney(refundReq.getMoney()), list, OrderUtils.generateOrderNo("SEQ"), "1");
-        if (!businessNoR.getStatus()) {
-            throw new BusinessException(StringUtils.isNotBlank(businessNoR.getMsg()) ? businessNoR.getMsg() : "退款失败");
-        }
-        Long userId = LoginUserHolder.getUserId();
-        //异步提交清分退款任务
-        AsyncPool.addTask(new Refund(refundReq, kwpWalletRefund, payCenterService, kwpWalletRefundMapper, userId));
-        return businessNoR;
+        EntCacheResDto entCacheResDto = remoteSystemService.queryEntCacheById(entId);
+        if (Objects.isNull(entCacheResDto)) {
+            throw new BusinessException("未找到企业信息");
+        }
+        MemberCreate memberCreate = new MemberCreate();
+        List<EntCertificateResDto> certificateInfo = entCacheResDto.getCertificateInfo();
+        Map<Integer, String> certMap = new HashMap<>();
+        if (!CollectionUtils.isEmpty(certificateInfo)) {
+            certMap = certificateInfo.stream().collect(Collectors.toMap(EntCertificateResDto::getType, EntCertificateResDto::getCode, (a, b) -> a));
+        }
+        memberCreate.setCompanyName(entCacheResDto.getFirmName());
+        memberCreate.setLicense(certMap.get(3));
+        memberCreate.setLegalName(entCacheResDto.getLegalName());
+        memberCreate.setLegalPhone(entCacheResDto.getLegalPhone());
+        //法人身份证号
+        memberCreate.setLegalIds(certMap.get(2));
+        memberCreate.setAccountNo("");
+        memberCreate.setParentBankName("");
+        memberCreate.setUnionBank("");
+        memberCreate.setBankName("");
+        memberCreate.setChannel(createUserReq.getChannel());
+        //开通用户
+        R<MemberRes> memberResR = payCenterService.memberIndex(memberCreate);
+        if (!memberResR.getStatus()) {
+            throw new BusinessException(StringUtils.isNotBlank(memberResR.getMsg()) ? memberResR.getMsg() : "开户失败");
+        }
+        MemberRes data = memberResR.getData();
+        WalletRelationDto walletRelationDto = new WalletRelationDto(entId, data.getUid());
+        KwpWalletRelation query = walletRelationService.query(walletRelationDto);
+        if (Objects.isNull(query)) {
+            walletRelationService.save(walletRelationDto);
+        }
+        return data;
+    }
+
+    /**
+     * 驳回退款
+     *
+     * @param refundReq
+     * @return
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public String backRefund(RefundBackReq refundReq) {
+        KwpWalletRefund kwpWalletRefund = walletOrderService.queryById(refundReq.getIdLong());
+        if (Objects.isNull(kwpWalletRefund)) {
+            throw new BusinessException("退款订单不存在");
+        }
+        if (kwpWalletRefund.getStatus() != RefundEnum.APPLY.getStatus()) {
+            throw new BusinessException("请勿重复提交");
+        }
+        kwpWalletRefund.setStatus(RefundEnum.BACK.getStatus());
+        kwpWalletRefund.setRemark(refundReq.getRemark());
+        kwpWalletRefund.setUpdateBy(LoginUserHolder.getUserId());
+        kwpWalletRefund.setUpdateTime(LocalDateTime.now());
+        walletOrderService.updateById(kwpWalletRefund);
+        //保存操作记录
+        kwpWalletRefundSubService.saveRecord(kwpWalletRefund.getId(), refundReq.getRemark(), RefundEnum.BACK.getStatus());
+        return "驳回成功";
+    }
+
+    /**
+     * 查询退款列表
+     *
+     * @param refundPage
+     * @return
+     */
+    public Object refundList(RefundPage refundPage) {
+        if (StringUtils.isNotBlank(refundPage.getChannel())) {
+            refundPage.setChannel(ChannelEnum.valueToChannel(refundPage.getChannel()));
+        }
+        if (StringUtils.isNotBlank(refundPage.getStartCreateTime())) {
+            refundPage.setStartCreateTime(StringTimeUtil.fillStart(refundPage.getStartCreateTime()));
+        }
+        if (StringUtils.isNotBlank(refundPage.getEndCreateTime())) {
+            refundPage.setEndCreateTime(StringTimeUtil.fillEnd(refundPage.getEndCreateTime()));
+        }
+        PageRes<WalletRefundVo> walletRefundVoPageRes = walletOrderService.queryRefundList(refundPage);
+        List<WalletRefundVo> list = walletRefundVoPageRes.getList();
+        for (WalletRefundVo walletRefundVo : list) {
+            walletRefundVo.setUidName(getFirmName(walletRefundVo.getUid()));
+            walletRefundVo.setFilterName(getFirmName(walletRefundVo.getFilter()));
+        }
+        return walletRefundVoPageRes;
     }
 
     /**
@@ -1034,15 +1269,15 @@ public class WalletService {
 
         @Override
         public void run() {
-            ChannelEnum channelEnum = ChannelEnum.getByChannel(refundReq.getChannel());
+            ChannelEnum channelEnum = ChannelEnum.getByChannel(kwpWalletRefund.getChannel());
             List<PatchPay> list = new ArrayList<>();
             PatchPay patchPay = new PatchPay();
-            patchPay.setUid(refundReq.getFilter());
+            patchPay.setUid(kwpWalletRefund.getFilter());
             patchPay.setMoney(refundReq.bigMoney(refundReq.getMoney()));
             patchPay.setRemark(refundReq.getRemark());
             list.add(patchPay);
             log.info("异步提交清分退款任务");
-            R<BusinessNo> businessNoR1 = payCenterService.payAgentPayV2(refundReq.getFilter(), refundReq.getUid(), channelEnum, refundReq.bigMoney(refundReq.getMoney()), list, OrderUtils.generateOrderNo("SEQ"), "2");
+            R<BusinessNo> businessNoR1 = payCenterService.payAgentPayV2(kwpWalletRefund.getFilter(), kwpWalletRefund.getUid(), channelEnum, refundReq.bigMoney(refundReq.getMoney()), list, OrderUtils.generateOrderNo("SEQ"), "2");
             if (businessNoR1.getStatus()) {
                 kwpWalletRefund.setActualMoney(refundReq.getMoney());
                 kwpWalletRefund.setUpdateBy(userId);

+ 201 - 0
sckw-modules/sckw-payment/src/main/resources/bootstrap-lfdc.yml

@@ -0,0 +1,201 @@
+spring:
+  cloud:
+    nacos:
+      discovery:
+        # 服务注册地址
+        server-addr: 10.10.10.230:8848
+        # 命名空间
+        namespace: sckw_lfdc
+        # 共享配置
+        group: sckw-service-platform
+      config:
+        # 配置中心地址
+        server-addr: 10.10.10.230:8848
+        # 配置文件格式
+        file-extension: yaml
+        # 命名空间
+        namespace: sckw_lfdc
+        # 共享配置
+        group: sckw-service-platform
+        #可以读多个配置文件  需要在同一个命名空间下面可以是不同的组
+        extension-configs:
+          - dataId: sckw-common.yml
+            group: sckw-service-platform
+            refresh: true
+#spring:
+#  rabbitmq:
+#    username: admin
+#    password: admin
+#    host: 10.10.10.138
+#    port: 5672
+#    virtual-host: /
+#  cloud:
+#    nacos:
+#      discovery:
+#        # 服务注册地址
+##        server-addr: 47.108.162.14:8848
+#        server-addr: 127.0.0.1:8848
+#        # 命名空间
+#        namespace: sckw-service-platform-dev
+#        # nacos用户名
+#        username: nacos
+#        # nacos密码
+#        password: nacos
+#        # 共享配置
+#        group: sckw-service-platform
+#        # 权重 1-100 数值越大权重越大分配的流量就越大,通常结合权重负载均衡策略
+#      #        weight: 100
+#      config:
+#        # 配置中心地址
+##        server-addr: 47.108.162.14:8848
+#        server-addr: 127.0.0.1:8848
+#        # 配置文件格式
+#        file-extension: yaml
+#        # 命名空间
+#        namespace: sckw-service-platform-dev
+#        # 共享配置
+#        group: sckw-service-platform
+#        enabled: true
+#    stream:
+#      bindings:
+#        sckwSms-out-0:
+#          destination: sckw-sms
+#          content-type: application/json
+#          default-binder: defaultRabbit
+#          group: sckw
+#        sckwMessage-out-0:
+#          destination: sckw-message
+#          content-type: application/json
+#          default-binder: defaultRabbit
+#          group: sckw
+#      binders:
+#        defaultRabbit:
+#          type: rabbit
+#          environment:
+#            spring:
+#              rabbitmq:
+#                virtual-host: /
+#                host: 39.104.134.114
+#                port: 5672
+#                username: wph
+#                password: Yy123...
+#    # sentinel降级配置
+#    sentinel:
+#      transport:
+#        client-ip: ${spring.cloud.client.ip-address} # 获取本机IP地址
+#        port: 8719  #默认8719端口,如果被占用会向上扫描。
+#        #控制台地址
+#        #dashboard: 47.108.162.14:19527
+#        dashboard: 127.0.0.1:19527
+#      log:
+#        #日志路径
+#        dir: logs/sentinel
+#        # 默认将调用链路收敛,导致链路流控效果无效
+#        web-context-unify: false
+#        #持久化nacos配置中
+#      datasource:
+#        #sentinel-rule: # 唯一名称可自定义
+#        #限流
+#        flow:
+#          nacos:
+#            # 设置Nacos的连接地址、命名空间和Group ID
+#            namespace:  sckw-service-platform-dev
+#            server-addr:  ${spring.cloud.nacos.discovery.server-addr}
+#            # username: ${spring.cloud.nacos.discovery.username}
+#            # password: ${spring.cloud.nacos.discovery.password}
+#            # 设置Nacos中配置文件的命名规则
+#            #            data-id:  ${spring.application.name}-sentinel-flow-rules
+#            data-id:  sckw-file-sentinel-flow-rules
+#            group-id: SENTINEL_GROUP
+#            data-type: json
+#            # 必填的重要字段,指定当前规则类型是"限流"
+#            rule-type: flow
+#        #熔断
+#        degrade:
+#          nacos:
+#            namespace:  sckw-service-platform-dev
+#            server-addr: ${spring.cloud.nacos.discovery.server-addr}
+#            #data-id: ${spring.application.name}-sentinel-degrade-rules
+#            data-id: sckw-file-sentinel-degrade-rules
+#            group-id: SENTINEL_GROUP
+#            #熔断
+#            rule-type: degrade
+#      #取消慢加载
+#      eager: true
+#  datasource:
+#    dynamic:
+#      seata: true
+##sfs:
+##  nacos:
+##    server-addr: 127.0.0.1:8848
+##    namespace: 967df0d8-156b-441a-a5ab-615b4a865168
+##    group: MY_GROUP
+##
+##    nacos:
+##      server-addr: ${sfs.nacos.server-addr}
+##      namespace: ${sfs.nacos.namespace}
+##      group: ${sfs.nacos.group}
+#
+##seata:
+##  # seata 服务分组,要与服务端nacos-config.txt中service.vgroup_mapping的后缀对应
+##  # 事务分组名称,要和服务端对应
+##  tx-service-group: sckw-transport-seata-service-group
+##  service:
+##    vgroup-mapping:
+##      # key是事务分组名称 value要和服务端的机房名称保持一致
+##      sckw-transport-seata-service-group: default
+##  registry:
+##    # 指定nacos作为注册中心
+##    type: nacos
+##    nacos:
+##      server-addr: ${spring.cloud.nacos.discovery.server-addr}
+##      #server-addr: 47.108.162.14:8848
+##      namespace: ${spring.cloud.nacos.discovery.namespace}
+##      #      group: SEATA_GROUP
+##      group: ${spring.cloud.nacos.discovery.group}
+##  config:
+##    # 指定nacos作为配置中心
+##    type: nacos
+##    nacos:
+##      server-addr: ${spring.cloud.nacos.discovery.server-addr}
+##      #server-addr: 47.108.162.14:8848
+##      namespace: ${spring.cloud.nacos.discovery.namespace}
+##      group: ${spring.cloud.nacos.discovery.group}
+##  application-id: ${spring.application.name}
+##  #  当前不生效,使用驼峰
+##  enabled: true
+##  #  enable-auto-data-source-proxy: false
+##  enableAutoDataSourceProxy: false
+##  application-id: sckw-seata-file
+## 支持feign对sentinel支持
+##feign:
+##  sentinel:
+##    enabled: true
+#
+#dubbo:
+#  application:
+#    # 此处没有延用spring.application.name是因为当前项目本身也会注册到nacos中,如果dubbo也延用相同的名称,在nacos服务里会看到注册的producer-server服务数为2
+#    name: transport-dubbo-server
+#  protocol:
+#    name: dubbo
+#    port: -1
+#    prefer-serialization: java
+#  registry:
+#    # 配置dubbo的注册中心为nacos
+#    address: nacos://${spring.cloud.nacos.discovery.server-addr}
+#    group: ${spring.cloud.nacos.config.group}
+#    protocol: nacos
+#    #use-as-config-center: false
+#    #use-as-metadata-center: false
+#aliyun:
+#  oss:
+#    endpoint: oss-cn-chengdu.aliyuncs.com
+#    accessKeyId: LTAI5tPEbubCGq5Rdwygbz4Q
+#    secret: 7mQLWMaBJeZPRV1SRGogctYGXwppjQ
+#    bucket: kaiwu-saas
+#links:
+#isBindManyRole:
+#mybatis-plus:
+#  configuration:
+#    # 是否将sql打印到控制面板(该配置会将sql语句和查询的结果都打印到控制台)
+#    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

+ 45 - 25
sckw-modules/sckw-payment/src/main/resources/mapper/KwpWalletRefundMapper.xml

@@ -1,29 +1,49 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.sckw.payment.dao.KwpWalletRefundMapper">
-  <resultMap id="BaseResultMap" type="com.sckw.payment.model.KwpWalletRefund">
-    <!--@mbg.generated-->
-    <!--@Table kwp_wallet_refund-->
-    <id column="id" jdbcType="BIGINT" property="id" />
-    <result column="order_no" jdbcType="VARCHAR" property="orderNo" />
-    <result column="uid" jdbcType="VARCHAR" property="uid" />
-    <result column="from_ent" jdbcType="BIGINT" property="fromEnt" />
-    <result column="filter" jdbcType="VARCHAR" property="filter" />
-    <result column="to_ent" jdbcType="BIGINT" property="toEnt" />
-    <result column="channel" jdbcType="VARCHAR" property="channel" />
-    <result column="money" jdbcType="DECIMAL" property="money" />
-    <result column="actual_money" jdbcType="DECIMAL" property="actualMoney" />
-    <result column="remark" jdbcType="VARCHAR" property="remark" />
-    <result column="create_by" jdbcType="BIGINT" property="createBy" />
-    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
-    <result column="update_by" jdbcType="BIGINT" property="updateBy" />
-    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
-    <result column="del_flag" jdbcType="INTEGER" property="delFlag" />
-    <result column="status" jdbcType="INTEGER" property="status" />
-  </resultMap>
-  <sql id="Base_Column_List">
-    <!--@mbg.generated-->
-    id, order_no, `uid`, from_ent, `filter`, to_ent, channel, money,actual_money,remark, create_by, create_time,
-    update_by, update_time, del_flag, `status`
-  </sql>
+    <resultMap id="BaseResultMap" type="com.sckw.payment.model.KwpWalletRefund">
+        <!--@mbg.generated-->
+        <!--@Table kwp_wallet_refund-->
+        <id column="id" jdbcType="BIGINT" property="id"/>
+        <result column="order_no" jdbcType="VARCHAR" property="orderNo"/>
+        <result column="uid" jdbcType="VARCHAR" property="uid"/>
+        <result column="from_ent" jdbcType="BIGINT" property="fromEnt"/>
+        <result column="filter" jdbcType="VARCHAR" property="filter"/>
+        <result column="to_ent" jdbcType="BIGINT" property="toEnt"/>
+        <result column="channel" jdbcType="VARCHAR" property="channel"/>
+        <result column="money" jdbcType="DECIMAL" property="money"/>
+        <result column="actual_money" jdbcType="DECIMAL" property="actualMoney"/>
+        <result column="remark" jdbcType="VARCHAR" property="remark"/>
+        <result column="create_by" jdbcType="BIGINT" property="createBy"/>
+        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
+        <result column="update_by" jdbcType="BIGINT" property="updateBy"/>
+        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
+        <result column="del_flag" jdbcType="INTEGER" property="delFlag"/>
+        <result column="status" jdbcType="INTEGER" property="status"/>
+    </resultMap>
+
+    <select id="pageList" resultMap="BaseResultMap">
+        select kwr.*
+        from kwp_wallet_refund kwr
+        <where>
+            kwr.del_flag = 0
+              and kwr.status = 1
+            <if test="refundPage.uid != null and refundPage.uid != ''">
+                and kwr.uid = #{refundPage.uid,jdbcType=VARCHAR}
+            </if>
+            <if test="refundPage.filter != null and refundPage.filter != ''">
+                and kwr.filter = #{refundPage.filter,jdbcType=VARCHAR}
+            </if>
+            <if test="refundPage.channel != null and refundPage.channel != ''">
+                and kwr.channel = #{refundPage.channel,jdbcType=VARCHAR}
+            </if>
+            <if test="refundPage.keywords != null and refundPage.keywords != ''">
+                and kwr.order_no like concat('%', #{refundPage.keywords,jdbcType=VARCHAR}, '%')
+            </if>
+
+            <if test="refundPage.startCreateTime != null and refundPage.startCreateTime != '' and refundPage.endCreateTime != null and refundPage.endCreateTime != ''">
+                and kwr.create_time between #{refundPage.startCreateTime,jdbcType=TIMESTAMP} and #{refundPage.endCreateTime,jdbcType=TIMESTAMP}
+            </if>
+        </where>
+    </select>
 </mapper>

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

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

+ 1 - 1
sckw-modules/sckw-product/src/main/java/com/sckw/product/enums/GoodsStatusEnum.java

@@ -22,7 +22,7 @@ public enum GoodsStatusEnum {
      * 产品状态枚举
      */
     SAVED(0, "已保存"),
-    PUT_ON_SHELVES(1, "上架"),
+    PUT_ON_SHELVES(1, "上架"),
     TAKE_OFF_SHELVES(2, "已下架");
 
     private final Integer code;

+ 10 - 0
sckw-modules/sckw-product/src/main/java/com/sckw/product/model/vo/res/GoodsList.java

@@ -25,6 +25,11 @@ public class GoodsList {
      */
     private Long id;
 
+    /**
+     * 商品编号
+     */
+    private String code;
+
     /**
      * 状态:0草稿/1上架/2下架
      */
@@ -95,6 +100,11 @@ public class GoodsList {
      */
     private String prepaidLimitLabel;
 
+    /**
+     * 预付款最低限额
+     */
+    private BigDecimal advancePrice;
+
     /**
      * 最高单价
      */

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

@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-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.exception.CustomPromptException;
@@ -204,6 +203,13 @@ public class KwpGoodsService {
         if (CollectionUtils.isEmpty(list)) {
             return detail;
         }
+        Map<String, String> unitMap;
+        Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(List.of(DictTypeEnum.UNIT_TYPE.getType()));
+        if (CollectionUtils.isNotEmpty(dict)) {
+            unitMap = dict.get(DictTypeEnum.UNIT_TYPE.getType());
+        } else {
+            unitMap = new HashMap<>();
+        }
         List<Long> goodsIds = list.stream().map(KwpGoods::getId).toList();
         Map<Long, List<KwpGoodsPriceRange>> map = kwpGoodsPriceRangeService.getByGoodsIds(goodsIds).stream()
                 .collect(Collectors.groupingBy(KwpGoodsPriceRange::getGoodsId));
@@ -211,7 +217,7 @@ public class KwpGoodsService {
         list.forEach(e -> {
             RecommendGoods recommendGoods = BeanUtils.copyProperties(e, RecommendGoods.class);
             List<KwpGoodsPriceRange> prices = map.get(recommendGoods.getId());
-            recommendGoods.setUnitLabel(DictEnum.getLabel(DictTypeEnum.UNIT_TYPE.getType(), recommendGoods.getUnit()))
+            recommendGoods.setUnitLabel(CollectionUtils.isNotEmpty(unitMap) ? unitMap.get(recommendGoods.getUnit()) : null)
                     .setPrice(CollectionUtils.isNotEmpty(prices) ? prices.get(0).getPrice() : null);
             recommendGoodsList.add(recommendGoods);
         });
@@ -246,10 +252,24 @@ public class KwpGoodsService {
         if (Objects.nonNull(managerInfo)) {
             detail.setManagerName(managerInfo.getName()).setManagerPhone(managerInfo.getPhone());
         }
-        detail.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), detail.getGoodsType()))
-                .setUnitLabel(DictEnum.getLabel(DictTypeEnum.UNIT_TYPE.getType(), detail.getUnit()))
-                .setTaxRateLabel(DictEnum.getLabel(DictTypeEnum.TAX_RATE.getType(), detail.getTaxRate()))
-                .setStatusLabel(DictEnum.getLabel(DictTypeEnum.GOODS_STATUS.getType(), String.valueOf(detail.getStatus())))
+        Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(List.of(DictTypeEnum.PRODUCT_NAME_TYPE.getType(),
+                DictTypeEnum.UNIT_TYPE.getType(), DictTypeEnum.TAX_RATE.getType(), DictTypeEnum.GOODS_STATUS.getType(), DictTypeEnum.ADDRESS_TYPE.getType()));
+        Map<String, String> productNameMap = new HashMap<>();
+        Map<String, String> unitMap = new HashMap<>();
+        Map<String, String> taxRateMap = new HashMap<>();
+        Map<String, String> goodsStatusMap = new HashMap<>();
+        Map<String, String> addressMap = new HashMap<>();
+        if (CollectionUtils.isNotEmpty(dict)) {
+            productNameMap = dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType());
+            unitMap = dict.get(DictTypeEnum.UNIT_TYPE.getType());
+            taxRateMap = dict.get(DictTypeEnum.TAX_RATE.getType());
+            goodsStatusMap = dict.get(DictTypeEnum.GOODS_STATUS.getType());
+            addressMap = dict.get(DictTypeEnum.ADDRESS_TYPE.getType());
+        }
+        detail.setGoodsTypeLabel(CollectionUtils.isNotEmpty(productNameMap) ? productNameMap.get(detail.getGoodsType()) : null)
+                .setUnitLabel(CollectionUtils.isNotEmpty(unitMap) ? unitMap.get(detail.getUnit()) : null)
+                .setTaxRateLabel(CollectionUtils.isNotEmpty(taxRateMap) ? taxRateMap.get(detail.getTaxRate()) : null)
+                .setStatusLabel(CollectionUtils.isNotEmpty(goodsStatusMap) ? goodsStatusMap.get(String.valueOf(detail.getStatus())) : null)
                 .setPrepaidLimitLabel(Objects.equals(detail.getPrepaidLimit(), 1) ? "是" : "否");
         //商品图片信息
         List<KwpGoodsImage> goodsImages = kwpGoodsImageService.getByGoodsId(id);
@@ -268,7 +288,7 @@ public class KwpGoodsService {
         KwpGoodsAddress goodsAddress = kwpGoodsAddressService.getByGoodsId(id);
         AddressInfoDetail addressInfo = BeanUtils.copyProperties(goodsAddress, AddressInfoDetail.class);
         if (Objects.nonNull(addressInfo)) {
-            addressInfo.setTypeName(DictEnum.getLabel(DictTypeEnum.ADDRESS_TYPE.getType(), addressInfo.getType()));
+            addressInfo.setTypeName(CollectionUtils.isNotEmpty(addressMap) ? addressMap.get(addressInfo.getType()) : null);
         }
         detail.setImages(images).setPriceRanges(ranges).setAttributes(attributes).setAddressInfo(addressInfo);
 
@@ -531,11 +551,23 @@ public class KwpGoodsService {
     public List<GoodsListExport> export(ExportStatisticGoodsListParam params) {
         LambdaQueryWrapper<KwpGoods> wrapper = buildWrapper(params);
         List<KwpGoods> list = kwpGoodsMapper.selectList(wrapper);
-        List<GoodsList> goodsLists = buildGoodLists(list);
-        if (CollectionUtils.isEmpty(goodsLists)) {
+        if (CollectionUtils.isEmpty(list)) {
             return Collections.emptyList();
         }
-        List<GoodsListExport> result = new ArrayList<>();
+        return getExportResults(list);
+
+    }
+
+    /**
+     * @desc: 获取导出结果
+     * @author: yzc
+     * @date: 2023-09-18 15:19
+     * @Param list:
+     * @return: java.util.List<com.sckw.product.model.GoodsListExport>
+     */
+    public List<GoodsListExport> getExportResults(List<KwpGoods> list) {
+        List<GoodsList> goodsLists = buildGoodLists(list);
+        List<GoodsListExport> result = new ArrayList<>(list.size());
         AtomicInteger i = new AtomicInteger(1);
         goodsLists.forEach(e -> {
             GoodsListExport export = BeanUtils.copyProperties(e, GoodsListExport.class);
@@ -604,7 +636,7 @@ public class KwpGoodsService {
      * @Param list:
      * @return: java.util.List<com.sckw.product.model.vo.res.GoodsList>
      */
-    private List<GoodsList> buildGoodLists(List<KwpGoods> list) {
+    public List<GoodsList> buildGoodLists(List<KwpGoods> list) {
         List<GoodsList> result = new ArrayList<>(list.size());
         List<Long> goodsIds = new ArrayList<>(list.size());
         List<Long> supplyEntIds = new ArrayList<>(list.size());
@@ -634,16 +666,30 @@ public class KwpGoodsService {
         if (CollectionUtils.isNotEmpty(supplyEntIds)) {
             entList = remoteSystemService.queryEntCacheByIds(supplyEntIds);
         }
+        Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(List.of(DictTypeEnum.PRODUCT_NAME_TYPE.getType(),
+                DictTypeEnum.UNIT_TYPE.getType(), DictTypeEnum.TAX_RATE.getType(), DictTypeEnum.GOODS_STATUS.getType()));
+        Map<String, String> productNameMap, unitMap, taxRateMap, goodsStatusMap;
+        if (CollectionUtils.isNotEmpty(dict)) {
+            productNameMap = dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType());
+            unitMap = dict.get(DictTypeEnum.UNIT_TYPE.getType());
+            taxRateMap = dict.get(DictTypeEnum.TAX_RATE.getType());
+            goodsStatusMap = dict.get(DictTypeEnum.GOODS_STATUS.getType());
+        } else {
+            productNameMap = new HashMap<>();
+            unitMap = new HashMap<>();
+            taxRateMap = new HashMap<>();
+            goodsStatusMap = new HashMap<>();
+        }
         Map<Long, String> entMap = entList.stream().collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName, (k1, k2) -> k1));
         list.forEach(e -> {
             Long id = e.getId();
             GoodsList goodsList = BeanUtils.copyProperties(e, GoodsList.class);
             UserCacheResDto manager = userMap.get(e.getManager());
             UserCacheResDto createUser = userMap.get(e.getCreateBy());
-            goodsList.setStatusLabel(DictEnum.getLabel(DictTypeEnum.GOODS_STATUS.getType(), String.valueOf(goodsList.getStatus())))
-                    .setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), goodsList.getGoodsType()))
-                    .setUnitLabel(DictEnum.getLabel(DictTypeEnum.UNIT_TYPE.getType(), goodsList.getUnit()))
-                    .setTaxRateLabel(DictEnum.getLabel(DictTypeEnum.TAX_RATE.getType(), goodsList.getTaxRate()))
+            goodsList.setStatusLabel(CollectionUtils.isNotEmpty(goodsStatusMap) ? goodsStatusMap.get(String.valueOf(goodsList.getStatus())) : null)
+                    .setGoodsTypeLabel(CollectionUtils.isNotEmpty(productNameMap) ? productNameMap.get(goodsList.getGoodsType()) : null)
+                    .setUnitLabel(CollectionUtils.isNotEmpty(unitMap) ? unitMap.get(goodsList.getUnit()) : null)
+                    .setTaxRateLabel(CollectionUtils.isNotEmpty(taxRateMap) ? taxRateMap.get(goodsList.getTaxRate()) : null)
                     .setPrepaidLimitLabel(Objects.equals(e.getPrepaidLimit(), 1) ? "是" : "否")
                     .setAddress(addressMap.get(id)).setSupplyEnt(entMap.get(e.getSupplyEntId()))
                     .setManageName(Objects.nonNull(manager) ? manager.getName() : null)
@@ -651,7 +697,8 @@ public class KwpGoodsService {
                     .setCreateByName(Objects.nonNull(createUser) ? createUser.getName() : null);
             List<KwpGoodsPriceRange> priceRanges = priceRangeMap.get(id);
             if (CollectionUtils.isNotEmpty(priceRanges)) {
-                goodsList.setHighestPrice(priceRanges.get(priceRanges.size() - 1).getPrice()).setLowestPrice(priceRanges.get(0).getPrice());
+                goodsList.setHighestPrice(priceRanges.get(priceRanges.size() - 1).getPrice())
+                        .setLowestPrice(priceRanges.get(0).getPrice());
             }
             result.add(goodsList);
         });
@@ -835,13 +882,22 @@ public class KwpGoodsService {
         //供应企业信息
         List<EntCacheResDto> entList = remoteSystemService.queryEntCacheByIds(supplyEntIds);
         Map<Long, String> entMap = entList.stream().collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName, (k1, k2) -> k1));
-
+        Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(List.of(DictTypeEnum.PRODUCT_NAME_TYPE.getType(),
+                DictTypeEnum.UNIT_TYPE.getType()));
+        Map<String, String> productNameMap, unitMap;
+        if (CollectionUtils.isNotEmpty(dict)) {
+            productNameMap = dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType());
+            unitMap = dict.get(DictTypeEnum.UNIT_TYPE.getType());
+        } else {
+            productNameMap = new HashMap<>();
+            unitMap = new HashMap<>();
+        }
         list.forEach(e -> {
             BuildingMaterialsMarketList materials = BeanUtils.copyProperties(e, BuildingMaterialsMarketList.class);
             KwpGoodsAddress address = addressMap.get(e.getId());
             List<KwpGoodsPriceRange> priceRanges = priceRangeMap.get(e.getId());
-            materials.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), e.getGoodsType()))
-                    .setUnitLabel(DictEnum.getLabel(DictTypeEnum.UNIT_TYPE.getType(), e.getUnit()))
+            materials.setGoodsTypeLabel(CollectionUtils.isNotEmpty(productNameMap) ? productNameMap.get(e.getGoodsType()) : null)
+                    .setUnitLabel(CollectionUtils.isNotEmpty(unitMap) ? unitMap.get(e.getUnit()) : null)
                     .setAddressName(Objects.isNull(address) ? null : address.getCityName())
                     .setDetailAddress(Objects.isNull(address) ? null : address.getDetailAddress())
                     .setPrice(CollectionUtils.isEmpty(priceRanges) ? null : priceRanges.get(0).getPrice())
@@ -1012,7 +1068,9 @@ public class KwpGoodsService {
         }
         try {
             LambdaQueryWrapper<KwpGoods> wrapper = new LambdaQueryWrapper<>();
-            wrapper.eq(KwpGoods::getId, id).eq(KwpGoods::getStatus, GoodsStatusEnum.PUT_ON_SHELVES.getCode()).eq(KwpGoods::getDelFlag, Global.NO).last("LIMIT 1");
+            wrapper.eq(KwpGoods::getId, id)
+                    .eq(KwpGoods::getStatus, GoodsStatusEnum.PUT_ON_SHELVES.getCode())
+                    .eq(KwpGoods::getDelFlag, Global.NO).last("LIMIT 1");
             KwpGoods goods = kwpGoodsMapper.selectOne(wrapper);
             if (Objects.isNull(goods)) {
                 throw new BusinessException("商品不存在或已下架!");

+ 13 - 7
sckw-modules/sckw-product/src/main/java/com/sckw/product/service/KwpGoodsStatisticsService.java

@@ -1,6 +1,5 @@
 package com.sckw.product.service;
 
-import com.sckw.core.common.enums.enums.DictEnum;
 import com.sckw.core.common.enums.enums.DictTypeEnum;
 import com.sckw.core.utils.BeanUtils;
 import com.sckw.core.utils.CollectionUtils;
@@ -14,10 +13,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -57,11 +53,21 @@ public class KwpGoodsStatisticsService {
         if (CollectionUtils.isNotEmpty(supplyEntIds)) {
             entList = remoteSystemService.queryEntCacheByIds(supplyEntIds);
         }
+        Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(List.of(DictTypeEnum.PRODUCT_NAME_TYPE.getType(),
+                DictTypeEnum.UNIT_TYPE.getType()));
+        Map<String, String> productNameMap, unitMap;
+        if (CollectionUtils.isEmpty(dict)) {
+            productNameMap = new HashMap<>();
+            unitMap = new HashMap<>();
+        } else {
+            productNameMap = dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType());
+            unitMap = dict.get(DictTypeEnum.UNIT_TYPE.getType());
+        }
         Map<Long, String> entMap = entList.stream().collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName, (k1, k2) -> k1));
         goodsList.forEach(e -> {
             WorkbenchGoodsRes goods = BeanUtils.copyProperties(e, WorkbenchGoodsRes.class);
-            goods.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), e.getGoodsType()))
-                    .setUnitLabel(DictEnum.getLabel(DictTypeEnum.UNIT_TYPE.getType(), e.getUnit()))
+            goods.setGoodsTypeLabel(CollectionUtils.isNotEmpty(productNameMap) ? productNameMap.get(e.getGoodsType()) : null)
+                    .setUnitLabel(CollectionUtils.isNotEmpty(unitMap) ? unitMap.get(e.getUnit()) : null)
                     .setSupplyFireName(entMap.get(e.getSupplyEntId()));
             List<KwpGoodsPriceRange> priceRanges = priceRangeMap.get(e.getId());
             if (CollectionUtils.isNotEmpty(priceRanges)) {

+ 23 - 142
sckw-modules/sckw-product/src/main/java/com/sckw/product/service/operation/GoodsManagerService.java

@@ -3,9 +3,6 @@ package com.sckw.product.service.operation;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-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.PageResult;
 import com.sckw.core.model.vo.TableBottom;
@@ -14,33 +11,30 @@ import com.sckw.core.model.vo.TableTop;
 import com.sckw.core.utils.BeanUtils;
 import com.sckw.core.utils.CollectionUtils;
 import com.sckw.core.utils.StringUtils;
-import com.sckw.excel.utils.DateUtil;
 import com.sckw.product.dao.KwpGoodsMapper;
 import com.sckw.product.enums.GoodsStatusEnum;
-import com.sckw.product.model.*;
+import com.sckw.product.model.GoodsListExport;
+import com.sckw.product.model.KwpGoods;
+import com.sckw.product.model.OperationGoodsListExport;
 import com.sckw.product.model.dto.OperatorGoodsListQueryDTO;
 import com.sckw.product.model.vo.req.OperatorGoodsExportQueryVO;
 import com.sckw.product.model.vo.req.OperatorGoodsListQueryVO;
 import com.sckw.product.model.vo.req.OperatorGoodsStsQueryVO;
-import com.sckw.product.model.vo.res.*;
-import com.sckw.product.service.KwpGoodsAddressService;
-import com.sckw.product.service.KwpGoodsAttributeService;
-import com.sckw.product.service.KwpGoodsImageService;
-import com.sckw.product.service.KwpGoodsPriceRangeService;
+import com.sckw.product.model.vo.res.GoodsDetail;
+import com.sckw.product.model.vo.res.GoodsList;
+import com.sckw.product.model.vo.res.OperationGoodsDetail;
+import com.sckw.product.model.vo.res.OperationGoodsList;
+import com.sckw.product.service.KwpGoodsService;
 import com.sckw.system.api.RemoteSystemService;
 import com.sckw.system.api.RemoteUserService;
-import com.sckw.system.api.model.dto.res.EntCacheResDto;
 import com.sckw.system.api.model.dto.res.KwsUserResDto;
 import com.sckw.system.api.model.dto.res.SysDictResDto;
-import com.sckw.system.api.model.dto.res.UserCacheResDto;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.stereotype.Service;
 
-import java.math.BigDecimal;
 import java.util.*;
-import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
 
 /**
@@ -60,13 +54,17 @@ public class GoodsManagerService {
     private RemoteUserService remoteUserService;
 
 
+    private final KwpGoodsService kwpGoodsService;
     private final KwpGoodsMapper kwpGoodsMapper;
-    private final KwpGoodsAddressService kwpGoodsAddressService;
-    private final KwpGoodsAttributeService kwpGoodsAttributeService;
-    private final KwpGoodsImageService kwpGoodsImageService;
-    private final KwpGoodsPriceRangeService kwpGoodsPriceRangeService;
 
 
+    /**
+     * @desc: 分页查询
+     * @author: yzc
+     * @date: 2023-09-18 15:19
+     * @Param params:
+     * @return: com.sckw.core.model.page.PageResult
+     */
     public PageResult select(OperatorGoodsListQueryVO params) {
         LambdaQueryWrapper<KwpGoods> wrapper = buildWrapper(BeanUtils.copyProperties(params, OperatorGoodsListQueryDTO.class));
         Page<KwpGoods> page = new Page<>(params.getPage(), params.getPageSize());
@@ -75,7 +73,8 @@ public class GoodsManagerService {
         if (CollectionUtils.isEmpty(list)) {
             return PageResult.build(params.getPage(), params.getPageSize(), goodsIpage.getTotal(), Collections.emptyList());
         }
-        List<OperationGoodsList> result = buildGoodLists(list);
+        List<GoodsList> goodsLists = kwpGoodsService.buildGoodLists(list);
+        List<OperationGoodsList> result = BeanUtils.copyToList(goodsLists, OperationGoodsList.class);
         return PageResult.build(params.getPage(), params.getPageSize(), goodsIpage.getTotal(), result);
     }
 
@@ -129,67 +128,6 @@ public class GoodsManagerService {
         return wrapper;
     }
 
-    /**
-     * @desc: 构建商品列表
-     * @author: lt
-     * @date: 2023-09-14 10:14
-     * @Param list:
-     * @return: java.util.List<com.sckw.product.model.vo.res.GoodsList>
-     */
-    private List<OperationGoodsList> buildGoodLists(List<KwpGoods> list) {
-        List<OperationGoodsList> result = new ArrayList<>(list.size());
-        List<Long> goodsIds = new ArrayList<>(list.size());
-        List<Long> supplyEntIds = new ArrayList<>(list.size());
-        List<Long> userIds = new ArrayList<>();
-        list.forEach(e -> {
-            goodsIds.add(e.getId());
-            if (Objects.nonNull(e.getSupplyEntId())) {
-                supplyEntIds.add(e.getSupplyEntId());
-            }
-            if (Objects.nonNull(e.getManager())) {
-                userIds.add(e.getManager());
-            }
-            if (Objects.nonNull(e.getCreateBy())) {
-                userIds.add(e.getCreateBy());
-            }
-        });
-        //地址信息
-        Map<Long, String> addressMap = kwpGoodsAddressService.getByGoodsIds(goodsIds).stream()
-                .collect(Collectors.toMap(KwpGoodsAddress::getGoodsId, KwpGoodsAddress::getName, (k1, k2) -> k1));
-        //价格梯度信息
-        Map<Long, List<KwpGoodsPriceRange>> priceRangeMap = kwpGoodsPriceRangeService.getByGoodsIds(goodsIds).stream()
-                .collect(Collectors.groupingBy(KwpGoodsPriceRange::getGoodsId));
-        //用户信息
-        Map<Long, UserCacheResDto> userMap = remoteSystemService.queryUserCacheMapByIds(userIds);
-        //供应企业信息
-        List<EntCacheResDto> entList = new ArrayList<>();
-        if (CollectionUtils.isNotEmpty(supplyEntIds)) {
-            entList = remoteSystemService.queryEntCacheByIds(supplyEntIds);
-        }
-        Map<Long, String> entMap = entList.stream().collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName, (k1, k2) -> k1));
-        list.forEach(e -> {
-            Long id = e.getId();
-            OperationGoodsList operationGoodsList = BeanUtils.copyProperties(e, OperationGoodsList.class);
-            UserCacheResDto manager = userMap.get(e.getManager());
-            UserCacheResDto createUser = userMap.get(e.getCreateBy());
-            operationGoodsList.setStatusLabel(DictEnum.getLabel(DictTypeEnum.GOODS_STATUS.getType(), String.valueOf(operationGoodsList.getStatus())))
-                    .setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), operationGoodsList.getGoodsType()))
-                    .setUnitLabel(DictEnum.getLabel(DictTypeEnum.UNIT_TYPE.getType(), operationGoodsList.getUnit()))
-                    .setTaxRateLabel(DictEnum.getLabel(DictTypeEnum.TAX_RATE.getType(), operationGoodsList.getTaxRate()))
-                    .setPrepaidLimitLabel(Objects.equals(e.getPrepaidLimit(), 1) ? "是" : "否")
-                    .setAddress(addressMap.get(id)).setSupplyEnt(entMap.get(e.getSupplyEntId()))
-                    .setManageName(Objects.nonNull(manager) ? manager.getName() : null)
-                    .setPhone(Objects.nonNull(manager) ? manager.getPhone() : null)
-                    .setCreateByName(Objects.nonNull(createUser) ? createUser.getName() : null);
-            List<KwpGoodsPriceRange> priceRanges = priceRangeMap.get(id);
-            if (CollectionUtils.isNotEmpty(priceRanges)) {
-                operationGoodsList.setHighestPrice(priceRanges.get(priceRanges.size() - 1).getPrice()).setLowestPrice(priceRanges.get(0).getPrice());
-            }
-            result.add(operationGoodsList);
-        });
-        return result;
-    }
-
     /**
      * @desc: 获取商品详情
      * @author: lt
@@ -198,52 +136,8 @@ public class GoodsManagerService {
      * @return: com.sckw.product.model.vo.res.GoodsDetail
      */
     public OperationGoodsDetail getDetail(Long id) {
-        KwpGoods goods = kwpGoodsMapper.selectById(id);
-        if (Objects.isNull(goods)) {
-            throw new BusinessException("当前商品不存在!");
-        }
-        OperationGoodsDetail detail = BeanUtils.copyProperties(goods, OperationGoodsDetail.class);
-        Map<Long, EntCacheResDto> entMap = remoteSystemService.queryEntCacheMapByIds(Arrays.asList(detail.getEntId(), detail.getSupplyEntId()));
-        EntCacheResDto ent = entMap.get(detail.getEntId());
-        if (Objects.nonNull(ent)) {
-            detail.setEnt(ent.getFirmName()).setEntHead(ent.getHead())
-                    .setEntBusiness(ent.getBusiness()).setEntAddress(ent.getCityName());
-        }
-        EntCacheResDto supplyEnt = entMap.get(detail.getSupplyEntId());
-        if (Objects.nonNull(supplyEnt)) {
-            detail.setSupplyEnt(supplyEnt.getFirmName());
-        }
-        UserCacheResDto managerInfo = remoteSystemService.queryUserCacheById(detail.getManager());
-        if (Objects.nonNull(managerInfo)) {
-            detail.setManagerName(managerInfo.getName()).setManagerPhone(managerInfo.getPhone());
-        }
-        detail.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), detail.getGoodsType()))
-                .setUnitLabel(DictEnum.getLabel(DictTypeEnum.UNIT_TYPE.getType(), detail.getUnit()))
-                .setTaxRateLabel(DictEnum.getLabel(DictTypeEnum.TAX_RATE.getType(), detail.getTaxRate()))
-                .setStatusLabel(DictEnum.getLabel(DictTypeEnum.GOODS_STATUS.getType(), String.valueOf(detail.getStatus())))
-                .setPrepaidLimitLabel(Objects.equals(detail.getPrepaidLimit(), 1) ? "是" : "否");
-        //商品图片信息
-        List<KwpGoodsImage> goodsImages = kwpGoodsImageService.getByGoodsId(id);
-        List<GoodsImagesDetail> images = BeanUtils.copyToList(goodsImages, GoodsImagesDetail.class);
-        //商品价格段信息
-        List<KwpGoodsPriceRange> priceRanges = kwpGoodsPriceRangeService.getByGoodsId(id);
-        List<GoodsPriceRangesDetail> ranges = BeanUtils.copyToList(priceRanges, GoodsPriceRangesDetail.class);
-        ranges.stream().filter(r -> r.getEndAmount().compareTo(new BigDecimal("-1.00")) == 0)
-                .forEach(r -> {
-                    r.setEndAmountLabel("不限");
-                });
-        //商品属性信息
-        List<KwpGoodsAttribute> attributesList = kwpGoodsAttributeService.getByGoodsId(id);
-        List<GoodsAttributesDetail> attributes = BeanUtils.copyToList(attributesList, GoodsAttributesDetail.class);
-        //商品地址信息
-        KwpGoodsAddress goodsAddress = kwpGoodsAddressService.getByGoodsId(id);
-        AddressInfoDetail addressInfo = BeanUtils.copyProperties(goodsAddress, AddressInfoDetail.class);
-        if (Objects.nonNull(addressInfo)) {
-            addressInfo.setTypeName(DictEnum.getLabel(DictTypeEnum.ADDRESS_TYPE.getType(), addressInfo.getType()));
-        }
-        detail.setImages(images).setPriceRanges(ranges).setAttributes(attributes).setAddressInfo(addressInfo);
-
-        return detail;
+        GoodsDetail goodsDetail = kwpGoodsService.detail(id);
+        return BeanUtils.copyProperties(goodsDetail, OperationGoodsDetail.class);
     }
 
     /**
@@ -287,24 +181,11 @@ public class GoodsManagerService {
     public List<OperationGoodsListExport> export(OperatorGoodsExportQueryVO params) {
         LambdaQueryWrapper<KwpGoods> wrapper = buildWrapper(BeanUtils.copyProperties(params, OperatorGoodsListQueryDTO.class));
         List<KwpGoods> list = kwpGoodsMapper.selectList(wrapper);
-        List<OperationGoodsList> goodsLists = buildGoodLists(list);
-        if (CollectionUtils.isEmpty(goodsLists)) {
+        if (CollectionUtils.isEmpty(list)) {
             return Collections.emptyList();
         }
-        List<OperationGoodsListExport> result = new ArrayList<>();
-        AtomicInteger i = new AtomicInteger(1);
-        goodsLists.forEach(e -> {
-            OperationGoodsListExport export = BeanUtils.copyProperties(e, OperationGoodsListExport.class);
-            export.setSerialNumber(String.valueOf(i.getAndIncrement()))
-                    .setAmount(Objects.isNull(e.getAmount()) ? null : String.valueOf(e.getAmount()))
-                    .setHighestPrice(Objects.isNull(e.getHighestPrice()) ? null : String.valueOf(e.getHighestPrice()))
-                    .setLowestPrice(Objects.isNull(e.getLowestPrice()) ? null : String.valueOf(e.getLowestPrice()))
-                    .setAddedTime(Objects.isNull(e.getAddedTime()) ? null : DateUtil.getDateTime(e.getAddedTime()))
-                    .setShelfTime(Objects.isNull(e.getShelfTime()) ? null : DateUtil.getDateTime(e.getShelfTime()))
-                    .setCreateTime(Objects.isNull(e.getCreateTime()) ? null : DateUtil.getDateTime(e.getCreateTime()));
-            result.add(export);
-        });
-        return result;
+        List<GoodsListExport> exportResults = kwpGoodsService.getExportResults(list);
+        return BeanUtils.copyToList(exportResults, OperationGoodsListExport.class);
     }
 
 

+ 6 - 4
sckw-modules/sckw-report/src/main/java/com/sckw/report/controller/KwFleetController.java

@@ -1,18 +1,20 @@
 package com.sckw.report.controller;
 
-import com.sckw.core.exception.SystemException;
 import com.sckw.core.model.page.PageResult;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.report.service.KwFleetService;
 import lombok.AllArgsConstructor;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
 import java.util.HashMap;
-import java.util.Map;
 
 /**
  * @author zk
- * @desc TODO
+ * @desc 运力报表
  * @date 2023/7/8 0008
  */
 @AllArgsConstructor

+ 47 - 0
sckw-modules/sckw-report/src/main/java/com/sckw/report/enums/TOrderStatusEnum.java

@@ -0,0 +1,47 @@
+package com.sckw.report.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * @desc: 订单状态枚举
+ * @author: yzc
+ * @date: 2023-09-18 15:32
+ */
+@Getter
+@AllArgsConstructor
+public enum TOrderStatusEnum {
+
+    /**
+     * 订单状态枚举
+     */
+    SAVED(0, "已保存"),
+    WAIT_ACCEPTED(1, "待受理"),
+    RETURNED(2, "已退回"),
+    WAIT_SIGNED(3, "待签约"),
+    EXECUTING(4, "执行中"),
+    FINISHED(5, "已完结"),
+    RECONCILED(6, "已对账"),
+    SETTLED(7, "已结算");
+
+    private final Integer code;
+    private final String msg;
+
+    public static String getMsg(Integer code) {
+        for (TOrderStatusEnum ele : TOrderStatusEnum.values()) {
+            if (ele.getCode().equals(code)) {
+                return ele.getMsg();
+            }
+        }
+        return null;
+    }
+    public static List<TOrderStatusEnum> getSortList() {
+        TOrderStatusEnum[] enums = TOrderStatusEnum.values();
+        return Arrays.stream(enums).sorted(Comparator.comparingInt(TOrderStatusEnum::getCode)).collect(Collectors.toList());
+    }
+}

+ 80 - 64
sckw-modules/sckw-report/src/main/java/com/sckw/report/service/KwOrderService.java

@@ -1,6 +1,5 @@
 package com.sckw.report.service;
 
-import com.sckw.core.common.enums.enums.DictEnum;
 import com.sckw.core.common.enums.enums.DictTypeEnum;
 import com.sckw.core.model.page.PageResult;
 import com.sckw.core.model.vo.TableBottom;
@@ -12,11 +11,14 @@ import com.sckw.core.utils.StringUtils;
 import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.excel.utils.DateUtil;
 import com.sckw.mongo.model.SckwTradeOrder;
+import com.sckw.report.enums.TOrderStatusEnum;
 import com.sckw.report.service.param.*;
 import com.sckw.report.service.vo.OrderListRes;
 import com.sckw.report.service.vo.TradeOrderAppStatisticVO;
+import com.sckw.system.api.RemoteSystemService;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.data.domain.Sort;
 import org.springframework.data.mongodb.core.MongoTemplate;
 import org.springframework.data.mongodb.core.aggregation.Aggregation;
@@ -43,6 +45,9 @@ public class KwOrderService {
 
     private final MongoTemplate mongoTemplate;
 
+    @DubboReference(version = "1.0.0", group = "design", check = false)
+    private RemoteSystemService remoteSystemService;
+
     /**
      * @desc: 贸易订单详情
      * @author: yzc
@@ -69,7 +74,8 @@ public class KwOrderService {
      */
     public PageResult tradeOrderSelect(TradeOrderListSelectParam params) {
         Criteria criteria = buildCriteria(params, false);
-        return getResult(criteria, params.getPage(), params.getPageSize());
+        Sort sort = Sort.by(Sort.Direction.DESC, "createTime");
+        return getResult(criteria, sort, params.getPage(), params.getPageSize());
     }
 
     /**
@@ -77,18 +83,43 @@ public class KwOrderService {
      * @author: yzc
      * @date: 2023-07-20 15:02
      * @Param criteria:
+     * @Param sort:
      * @Param page:
      * @Param pageSize:
      * @return: com.sckw.core.model.page.PageResult
      */
-    public PageResult getResult(Criteria criteria, Integer page, Integer pageSize) {
+    public PageResult getResult(Criteria criteria, Sort sort, Integer page, Integer pageSize) {
         Query query = new Query();
         query.addCriteria(criteria);
         long count = mongoTemplate.count(query, SckwTradeOrder.class);
-        Sort sort = Sort.by(Sort.Direction.DESC, "createTime");
         SpringDataPageAble pageAble = new SpringDataPageAble(page, pageSize, sort);
         query.with(pageAble);
         List<SckwTradeOrder> list = mongoTemplate.find(query, SckwTradeOrder.class);
+        if (CollectionUtils.isEmpty(list)) {
+            return PageResult.build(page, pageSize, count, Collections.emptyList());
+        }
+        Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(List.of(
+                DictTypeEnum.TORDER_STATUS.getType(), DictTypeEnum.TRADE_TYPE.getType(), DictTypeEnum.DELIVERY_TYPE.getType(),
+                DictTypeEnum.PICKUP_TYPE.getType(), DictTypeEnum.TORDER_SOURCE.getType()));
+        Map<String, String> statusMap, tradeMap, deliveryMap, pickupMap, sourceMap;
+        if (CollectionUtils.isNotEmpty(dict)) {
+            statusMap = CollectionUtils.isNotEmpty(dict.get(DictTypeEnum.TORDER_STATUS.getType())) ?
+                    dict.get(DictTypeEnum.TORDER_STATUS.getType()) : new HashMap<>();
+            tradeMap = CollectionUtils.isNotEmpty(dict.get(DictTypeEnum.TRADE_TYPE.getType())) ?
+                    dict.get(DictTypeEnum.TRADE_TYPE.getType()) : new HashMap<>();
+            deliveryMap = CollectionUtils.isNotEmpty(dict.get(DictTypeEnum.DELIVERY_TYPE.getType())) ?
+                    dict.get(DictTypeEnum.DELIVERY_TYPE.getType()) : new HashMap<>();
+            pickupMap = CollectionUtils.isNotEmpty(dict.get(DictTypeEnum.PICKUP_TYPE.getType())) ?
+                    dict.get(DictTypeEnum.PICKUP_TYPE.getType()) : new HashMap<>();
+            sourceMap = CollectionUtils.isNotEmpty(dict.get(DictTypeEnum.TORDER_SOURCE.getType())) ?
+                    dict.get(DictTypeEnum.TORDER_SOURCE.getType()) : new HashMap<>();
+        } else {
+            statusMap = new HashMap<>();
+            tradeMap = new HashMap<>();
+            deliveryMap = new HashMap<>();
+            pickupMap = new HashMap<>();
+            sourceMap = new HashMap<>();
+        }
         List<OrderListRes> result = new ArrayList<>();
         list.forEach(e -> {
             BigDecimal actualAmount = Objects.isNull(e.getActualAmount()) ? BigDecimal.ZERO : BigDecimal.valueOf(e.getActualAmount());
@@ -98,14 +129,14 @@ public class KwOrderService {
             String unloadCityName = Objects.isNull(e.getUnloadCityName()) ? "" : e.getUnloadCityName();
             String loadDetailAddress = Objects.isNull(e.getLoadDetailAddress()) ? "" : e.getLoadDetailAddress();
             String unloadDetailAddress = Objects.isNull(e.getUnloadDetailAddress()) ? "" : e.getUnloadDetailAddress();
-            order.setStatusLabel(DictEnum.getLabel(DictTypeEnum.TORDER_STATUS.getType(), String.valueOf(e.getStatus())))
-                    .setTradingLabel(DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), e.getTrading()))
-                    .setTrading(DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), e.getTrading()))
-                    .setDeliveryTypeLabel(DictEnum.getLabel(DictTypeEnum.DELIVERY_TYPE.getType(), e.getDeliveryType()))
-                    .setDeliveryType(DictEnum.getLabel(DictTypeEnum.DELIVERY_TYPE.getType(), e.getDeliveryType()))
-                    .setPickupTypeLabel(DictEnum.getLabel(DictTypeEnum.PICKUP_TYPE.getType(), e.getPickupType()))
-                    .setSourceLabel(DictEnum.getLabel(DictTypeEnum.TORDER_SOURCE.getType(), e.getSource()))
-                    .setSource(DictEnum.getLabel(DictTypeEnum.TORDER_SOURCE.getType(), e.getSource()))
+            order.setStatusLabel(statusMap.get(String.valueOf(e.getStatus())))
+                    .setTradingLabel(tradeMap.get(e.getTrading()))
+                    .setTrading(tradeMap.get(e.getTrading()))
+                    .setDeliveryTypeLabel(deliveryMap.get(e.getDeliveryType()))
+                    .setDeliveryType(deliveryMap.get(e.getDeliveryType()))
+                    .setPickupTypeLabel(pickupMap.get(e.getPickupType()))
+                    .setSourceLabel(sourceMap.get(e.getSource()))
+                    .setSource(sourceMap.get(e.getSource()))
                     .setLoadDetailAddressInfo(loadCityName + loadDetailAddress)
                     .setUnloadDetailAddressInfo(unloadCityName + unloadDetailAddress)
                     .setWaitEntrustAmount(getWaitEntrustAmount(e.getAmount(), e.getEntrustAmount()))
@@ -255,7 +286,7 @@ public class KwOrderService {
      */
     public TableStatisticRes tradeOrderStatistic(TradeOrderListStatisticParam params) {
         Criteria criteria = buildCriteria(params, true);
-        return getTableStatistic(criteria, DictEnum.getEnumsByType(DictTypeEnum.TORDER_STATUS.getType()));
+        return getTableStatistic(criteria, TOrderStatusEnum.getSortList());
     }
 
     /**
@@ -266,7 +297,7 @@ public class KwOrderService {
      * @Param enums:
      * @return: com.sckw.core.model.vo.TableStatisticRes
      */
-    public TableStatisticRes getTableStatistic(Criteria criteria, List<DictEnum> enums) {
+    public TableStatisticRes getTableStatistic(Criteria criteria, List<TOrderStatusEnum> enums) {
         TableStatisticRes res = new TableStatisticRes();
         Aggregation aggregation = Aggregation.newAggregation(
                 Aggregation.match(criteria),
@@ -283,11 +314,11 @@ public class KwOrderService {
         }
         List<TableTop> list = new ArrayList<>();
         int count = 0;
-        for (DictEnum e : enums) {
-            Integer value = Integer.valueOf(e.getValue());
+        for (TOrderStatusEnum e : enums) {
+            Integer value = e.getCode();
             int total = Objects.isNull(map.get(value)) ? 0 : map.get(value);
             TableTop tableTop = new TableTop();
-            tableTop.setName(e.getLabel()).setValue(value).setTotal(total);
+            tableTop.setName(e.getMsg()).setValue(value).setTotal(total);
             list.add(tableTop);
             count = count + total;
         }
@@ -373,6 +404,28 @@ public class KwOrderService {
         if (CollectionUtils.isEmpty(orders)) {
             return Collections.emptyList();
         }
+        Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(List.of(
+                DictTypeEnum.TORDER_STATUS.getType(), DictTypeEnum.PICKUP_TYPE.getType(), DictTypeEnum.DELIVERY_TYPE.getType(),
+                DictTypeEnum.TORDER_SOURCE.getType(), DictTypeEnum.TRADE_TYPE.getType()));
+        Map<String, String> statusMap, pickupMap, deliveryMap, sourceMap, tradeMap;
+        if (CollectionUtils.isNotEmpty(dict)) {
+            statusMap = CollectionUtils.isNotEmpty(dict.get(DictTypeEnum.TORDER_STATUS.getType())) ?
+                    dict.get(DictTypeEnum.TORDER_STATUS.getType()) : new HashMap<>();
+            pickupMap = CollectionUtils.isNotEmpty(dict.get(DictTypeEnum.PICKUP_TYPE.getType())) ?
+                    dict.get(DictTypeEnum.PICKUP_TYPE.getType()) : new HashMap<>();
+            deliveryMap = CollectionUtils.isNotEmpty(dict.get(DictTypeEnum.DELIVERY_TYPE.getType())) ?
+                    dict.get(DictTypeEnum.DELIVERY_TYPE.getType()) : new HashMap<>();
+            sourceMap = CollectionUtils.isNotEmpty(dict.get(DictTypeEnum.TORDER_SOURCE.getType())) ?
+                    dict.get(DictTypeEnum.TORDER_SOURCE.getType()) : new HashMap<>();
+            tradeMap = CollectionUtils.isNotEmpty(dict.get(DictTypeEnum.TRADE_TYPE.getType())) ?
+                    dict.get(DictTypeEnum.TRADE_TYPE.getType()) : new HashMap<>();
+        } else {
+            statusMap = new HashMap<>();
+            pickupMap = new HashMap<>();
+            deliveryMap = new HashMap<>();
+            sourceMap = new HashMap<>();
+            tradeMap = new HashMap<>();
+        }
         List<TradeOrderListExport> list = new ArrayList<>();
         AtomicInteger i = new AtomicInteger(1);
         orders.forEach(e -> {
@@ -383,17 +436,17 @@ public class KwOrderService {
             String unloadDetailAddress = Objects.isNull(e.getUnloadDetailAddress()) ? "" : e.getUnloadDetailAddress();
             TradeOrderListExport export = BeanUtils.copyProperties(e, TradeOrderListExport.class);
             export.setSerialNumber(String.valueOf(i.getAndIncrement()))
-                    .setStatus(DictEnum.getLabel(DictTypeEnum.TORDER_STATUS.getType(), String.valueOf(e.getStatus())))
+                    .setStatus(statusMap.get(String.valueOf(e.getStatus())))
                     .setUnitPrice(Objects.isNull(e.getUnitPrice()) ? "0.00" : String.valueOf(e.getUnitPrice()))
                     .setAmount(Objects.isNull(e.getAmount()) ? "0.00" : String.valueOf(e.getAmount()))
                     .setPrice(Objects.isNull(e.getPrice()) ? "0.00" : String.valueOf(e.getPrice()))
                     .setEntrustAmount(Objects.isNull(e.getEntrustAmount()) ? "0.00" : String.valueOf(e.getEntrustAmount()))
                     .setActualAmount(Objects.isNull(e.getActualAmount()) ? "0.00" : String.valueOf(e.getActualAmount()))
                     .setWaitEntrustAmount(Objects.isNull(waitEntrustAmount) ? "0.00" : String.valueOf(waitEntrustAmount))
-                    .setPickupType(DictEnum.getLabel(DictTypeEnum.PICKUP_TYPE.getType(), e.getPickupType()))
-                    .setDeliveryType(DictEnum.getLabel(DictTypeEnum.DELIVERY_TYPE.getType(), e.getDeliveryType()))
-                    .setSource(DictEnum.getLabel(DictTypeEnum.TORDER_SOURCE.getType(), e.getSource()))
-                    .setTrading(DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), e.getTrading()))
+                    .setPickupType(pickupMap.get(e.getPickupType()))
+                    .setDeliveryType(deliveryMap.get(e.getDeliveryType()))
+                    .setSource(sourceMap.get(e.getSource()))
+                    .setTrading(tradeMap.get(e.getTrading()))
                     .setLoadDetailAddressInfo(loadCityName + loadDetailAddress)
                     .setUnloadDetailAddressInfo(unloadCityName + unloadDetailAddress)
                     .setStartTime(Objects.isNull(e.getStartTime()) ? null : DateUtil.dateToStr(e.getStartTime()))
@@ -415,7 +468,7 @@ public class KwOrderService {
         Long entId = LoginUserHolder.getEntId();
         Criteria criteria = new Criteria();
         String topEnt = Objects.equals(params.getOrderType(), 1) ? "procureTopEntId" : "supplyTopEntId";
-        criteria.and(topEnt).is(entId).and("status").is(Integer.valueOf(DictEnum.TORDER_STATUS_5.getValue()))
+        criteria.and(topEnt).is(entId).and("status").is(TOrderStatusEnum.FINISHED.getCode())
                 .and("associateStatement").ne(1).and("delFlag").is(0);
         //排除订单ids
         if (StringUtils.isNotBlank(params.getExcludeIds())) {
@@ -447,7 +500,8 @@ public class KwOrderService {
             Pattern pattern = Pattern.compile("^.*" + params.getGoodsName() + ".*$", Pattern.CASE_INSENSITIVE);
             criteria.and("goodsName").regex(pattern);
         }
-        return getResult(criteria, params.getPage(), params.getPageSize());
+        Sort sort = Sort.by(Sort.Direction.DESC, "createTime");
+        return getResult(criteria, sort, params.getPage(), params.getPageSize());
     }
 
     /**
@@ -463,46 +517,8 @@ public class KwOrderService {
         String topEnt = Objects.equals(params.getOrderType(), 1) ? "procureTopEntId" : "supplyTopEntId";
         List<Long> ids = StringUtils.splitStrToList(params.getContractIds(), ",", Long.class);
         criteria.and("contractId").in(ids).and(topEnt).is(entId).and("delFlag").is(0);
-        return getContractResult(criteria, params.getPage(), params.getPageSize());
-    }
-
-    /**
-     * @desc: 获取关联合同结果
-     * @author: yzc
-     * @date: 2023-09-14 14:58
-     * @Param criteria:
-     * @Param page:
-     * @Param pageSize:
-     * @return: com.sckw.core.model.page.PageResult
-     */
-    public PageResult getContractResult(Criteria criteria, Integer page, Integer pageSize) {
-        Query query = new Query();
-        query.addCriteria(criteria);
-        long count = mongoTemplate.count(query, SckwTradeOrder.class);
         Sort sort = Sort.by(Sort.Direction.DESC, "contractId", "createTime");
-        SpringDataPageAble pageAble = new SpringDataPageAble(page, pageSize, sort);
-        query.with(pageAble);
-        List<SckwTradeOrder> list = mongoTemplate.find(query, SckwTradeOrder.class);
-        List<OrderListRes> result = new ArrayList<>();
-        list.forEach(e -> {
-            String loadCityName = Objects.isNull(e.getLoadCityName()) ? "" : e.getLoadCityName();
-            String loadDetailAddress = Objects.isNull(e.getLoadDetailAddress()) ? "" : e.getLoadDetailAddress();
-            String unloadCityName = Objects.isNull(e.getUnloadCityName()) ? "" : e.getUnloadCityName();
-            String unloadDetailAddress = Objects.isNull(e.getUnloadDetailAddress()) ? "" : e.getUnloadDetailAddress();
-            OrderListRes order = BeanUtils.copyProperties(e, OrderListRes.class);
-            order.setStatusLabel(DictEnum.getLabel(DictTypeEnum.TORDER_STATUS.getType(), String.valueOf(e.getStatus())))
-                    .setTrading(DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), e.getTrading()))
-                    .setTradingLabel(DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), e.getTrading()))
-                    .setDeliveryType(DictEnum.getLabel(DictTypeEnum.DELIVERY_TYPE.getType(), e.getDeliveryType()))
-                    .setDeliveryTypeLabel(DictEnum.getLabel(DictTypeEnum.DELIVERY_TYPE.getType(), e.getDeliveryType()))
-                    .setPickupTypeLabel(DictEnum.getLabel(DictTypeEnum.PICKUP_TYPE.getType(), e.getPickupType()))
-                    .setLoadDetailAddressInfo(loadCityName + loadDetailAddress)
-                    .setUnloadDetailAddressInfo(unloadCityName + unloadDetailAddress)
-                    .setWaitEntrustAmount(getWaitEntrustAmount(e.getAmount(), e.getActualAmount()))
-                    .setSource(DictEnum.getLabel(DictTypeEnum.TORDER_SOURCE.getType(), e.getSource()))
-                    .setSourceLabel(DictEnum.getLabel(DictTypeEnum.TORDER_SOURCE.getType(), e.getSource()));
-            result.add(order);
-        });
-        return PageResult.build(page, pageSize, count, result);
+        return getResult(criteria, sort, params.getPage(), params.getPageSize());
     }
+
 }

+ 18 - 4
sckw-modules/sckw-report/src/main/java/com/sckw/report/service/KwOrderStatisticsService.java

@@ -1,7 +1,6 @@
 package com.sckw.report.service;
 
 import com.sckw.core.common.enums.NumberConstant;
-import com.sckw.core.common.enums.enums.DictEnum;
 import com.sckw.core.common.enums.enums.DictTypeEnum;
 import com.sckw.core.utils.BeanUtils;
 import com.sckw.core.utils.CollectionUtils;
@@ -18,6 +17,7 @@ import com.sckw.report.model.vo.TOrderDataStsResVO;
 import com.sckw.report.model.vo.WbTOrderDataStsParam;
 import com.sckw.report.model.vo.WbTOrderDataStsResVO;
 import com.sckw.report.model.vo.WorkbenchPurchaseVO;
+import com.sckw.system.api.RemoteSystemService;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboReference;
@@ -35,7 +35,7 @@ import java.time.LocalDateTime;
 import java.util.*;
 
 /**
- * @desc: TODO
+ * @desc: 贸易订单统计
  * @author: yzc
  * @date: 2023-09-11 14:33
  */
@@ -50,6 +50,8 @@ public class KwOrderStatisticsService {
     private GoodsStatisticsService goodsStatisticsService;
     @DubboReference(version = "1.0.0", group = "design", check = false)
     private PaymentDubboService paymentDubboService;
+    @DubboReference(version = "1.0.0", group = "design", check = false)
+    private RemoteSystemService remoteSystemService;
 
 
     /**
@@ -207,11 +209,23 @@ public class KwOrderStatisticsService {
         if (CollectionUtils.isEmpty(orders)) {
             return Collections.emptyList();
         }
+        Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(List.of(
+                DictTypeEnum.UNIT_TYPE.getType(), DictTypeEnum.PRODUCT_NAME_TYPE.getType()));
+        Map<String, String> unitMap, goodsNameMap;
+        if (CollectionUtils.isNotEmpty(dict)) {
+            unitMap = CollectionUtils.isNotEmpty(dict.get(DictTypeEnum.UNIT_TYPE.getType())) ?
+                    dict.get(DictTypeEnum.UNIT_TYPE.getType()) : new HashMap<>();
+            goodsNameMap = CollectionUtils.isNotEmpty(dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType())) ?
+                    dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType()) : new HashMap<>();
+        } else {
+            unitMap = new HashMap<>();
+            goodsNameMap = new HashMap<>();
+        }
         List<WorkbenchPurchaseVO> result = new ArrayList<>();
         orders.forEach(e -> {
             WorkbenchPurchaseVO vo = BeanUtils.copyProperties(e, WorkbenchPurchaseVO.class);
-            vo.setUnitLabel(DictEnum.getLabel(DictTypeEnum.UNIT_TYPE.getType(), e.getUnit()))
-                    .setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), e.getGoodsType()));
+            vo.setUnitLabel(unitMap.get(e.getUnit()))
+                    .setGoodsTypeLabel(goodsNameMap.get(e.getGoodsType()));
             result.add(vo);
         });
         return result;

+ 6 - 5
sckw-modules/sckw-report/src/main/java/com/sckw/report/service/operator/TradeOrderManageService.java

@@ -1,11 +1,10 @@
 package com.sckw.report.service.operator;
 
-import com.sckw.core.common.enums.enums.DictEnum;
-import com.sckw.core.common.enums.enums.DictTypeEnum;
 import com.sckw.core.model.page.PageResult;
 import com.sckw.core.model.vo.TableStatisticRes;
 import com.sckw.core.utils.BeanUtils;
 import com.sckw.core.utils.StringUtils;
+import com.sckw.report.enums.TOrderStatusEnum;
 import com.sckw.report.model.dto.OperatorTOrderListStsConditionDTO;
 import com.sckw.report.model.vo.OperatorTOrderContractParam;
 import com.sckw.report.model.vo.OperatorTOrderExportQueryVO;
@@ -46,7 +45,8 @@ public class TradeOrderManageService {
      */
     public PageResult listPaging(OperatorTOrderListQueryVO params) {
         Criteria criteria = buildCriteria(BeanUtils.copyProperties(params, OperatorTOrderListStsConditionDTO.class), false);
-        return kwOrderService.getResult(criteria, params.getPage(), params.getPageSize());
+        Sort sort = Sort.by(Sort.Direction.DESC, "createTime");
+        return kwOrderService.getResult(criteria, sort, params.getPage(), params.getPageSize());
     }
 
     /**
@@ -58,7 +58,7 @@ public class TradeOrderManageService {
      */
     public TableStatisticRes listStatistic(OperatorTOrderStsQueryVO params) {
         Criteria criteria = buildCriteria(BeanUtils.copyProperties(params, OperatorTOrderListStsConditionDTO.class), true);
-        List<DictEnum> enums = DictEnum.getEnumsByType(DictTypeEnum.TORDER_STATUS.getType());
+        List<TOrderStatusEnum> enums = TOrderStatusEnum.getSortList();
         enums.remove(0);
         return kwOrderService.getTableStatistic(criteria, enums);
     }
@@ -169,6 +169,7 @@ public class TradeOrderManageService {
         Criteria criteria = new Criteria();
         List<Long> ids = StringUtils.splitStrToList(params.getContractIds(), ",", Long.class);
         criteria.and("contractId").in(ids).and("delFlag").is(0);
-        return kwOrderService.getContractResult(criteria, params.getPage(), params.getPageSize());
+        Sort sort = Sort.by(Sort.Direction.DESC, "contractId", "createTime");
+        return kwOrderService.getResult(criteria, sort, params.getPage(), params.getPageSize());
     }
 }

+ 1 - 1
sckw-modules/sckw-report/src/main/java/com/sckw/report/service/param/WaybillOrderListExport.java

@@ -11,7 +11,7 @@ import java.io.Serializable;
 /**
  * @author JC
  * @version 1.0
- * @desc TODO
+ * @desc 运单列表信息导出实体
  * @date 2023/{07}/19 10:20:44
  **/
 @Data

+ 6 - 1
sckw-modules/sckw-report/src/main/java/com/sckw/report/service/param/WaybillOrderListSelect.java

@@ -2,15 +2,20 @@ package com.sckw.report.service.param;
 import lombok.Data;
 import lombok.experimental.Accessors;
 
+import java.io.Serial;
+
 /**
  * @author JC
  * @version 1.0
- * @desc TODO
+ * @desc 运单列表查询参数
  * @date 2023/{07}/19 10:20:44
  **/
 @Data
 @Accessors(chain = true)
 public class WaybillOrderListSelect extends WaybillOrderQuery {
+    @Serial
+    private static final long serialVersionUID = -6295422760052056637L;
+
     /**
      * 当前页码
      */

+ 5 - 3
sckw-modules/sckw-report/src/main/java/com/sckw/report/service/param/WaybillOrderQuery.java

@@ -2,24 +2,26 @@ package com.sckw.report.service.param;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fasterxml.jackson.annotation.JsonProperty;
-import com.sckw.core.model.page.PageRequest;
 import jakarta.validation.constraints.NotNull;
 import lombok.Data;
 import lombok.experimental.Accessors;
 
+import java.io.Serial;
 import java.io.Serializable;
 import java.util.Date;
-import java.util.List;
 
 /**
  * @author JC
  * @version 1.0
- * @desc TODO
+ * @desc 运单列表查询参数
  * @date 2023/{07}/19 10:20:44
  **/
 @Data
 @Accessors(chain = true)
 public class WaybillOrderQuery implements Serializable {
+    @Serial
+    private static final long serialVersionUID = 2807043861611224384L;
+
     private String ids;
     /**
      * 派车开始时间

+ 1 - 1
sckw-modules/sckw-report/src/test/java/com/sckw/report/SckwTradeOrderTest.java

@@ -10,7 +10,7 @@ import java.util.List;
 
 /**
  * @author zk
- * @desc TODO
+ * @desc 贸易订单测试
  * @date 2023/7/8 0008
  */
 @SpringBootTest

+ 5 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/model/pojo/FindMenuTreePojo.java

@@ -37,4 +37,9 @@ public class FindMenuTreePojo {
      */
     private List<Long> roleIds;
 
+    /**
+     * 企业类型
+     */
+    private List<String> entTypeList;
+
 }

+ 6 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsMenuService.java

@@ -53,6 +53,9 @@ public class KwsMenuService {
     @Autowired
     KwsMenuMappingDao kwsMenuMappingDao;
 
+    @Autowired
+    KwsEntTypeDao kwsEntTypeDao;
+
     /**
      * @param params 实体
      * @desc: 添加新纪录
@@ -319,6 +322,9 @@ public class KwsMenuService {
             return;
         }
         if (Objects.equals(LoginUserHolder.getIsMain(), Global.YES)) {
+            Long entId = LoginUserHolder.getEntId();
+            List<KwsEntType> listByEntId = kwsEntTypeDao.findListByEntId(entId);
+            findMenuTreePojo.setEntTypeList(listByEntId.stream().map(KwsEntType::getType).map(String::valueOf).toList());
             findMenuTreePojo.setEntId(LoginUserHolder.getEntId());
             return;
         }

+ 6 - 0
sckw-modules/sckw-system/src/main/resources/mapper/KwsMenuDao.xml

@@ -276,6 +276,12 @@
     <if test="name != null and name != ''">
       and sm.name = #{name, jdbcType=VARCHAR}
     </if>
+      <if test="entTypeList != null and entTypeList.size() > 0">
+        and
+        <foreach collection="entTypeList" item="item" open="(" close=")" separator=" or ">
+          using_roles like concat('%', #{item}, '%')
+        </foreach>
+      </if>
     <if test="entId != null">
       and smr.ent_id = #{entId}
       and smr.role_id is null

+ 5 - 0
sckw-modules/sckw-transport/pom.xml

@@ -65,6 +65,11 @@
             <version>1.0.0</version>
         </dependency>
 
+        <dependency>
+            <groupId>com.sckw</groupId>
+            <artifactId>sckw-payment-api</artifactId>
+        </dependency>
+
         <dependency>
             <groupId>com.sckw</groupId>
             <artifactId>sckw-common-seata</artifactId>

+ 19 - 6
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/AcceptCarriageOrderController.java

@@ -12,10 +12,7 @@ import com.sckw.core.web.response.HttpResult;
 import com.sckw.excel.config.easyexcel.RequestHolder;
 import com.sckw.excel.utils.ExcelUtil;
 import com.sckw.transport.model.dto.*;
-import com.sckw.transport.model.param.AcceptCarriageOrderQuery;
-import com.sckw.transport.model.param.ContractParam;
-import com.sckw.transport.model.param.DriverParam;
-import com.sckw.transport.model.param.LogisticsOrderParam;
+import com.sckw.transport.model.param.*;
 import com.sckw.transport.model.vo.execlVo.AcceptCarriageOrderExcelVo;
 import com.sckw.transport.service.AcceptCarriageOrderService;
 import com.sckw.transport.service.TransportCommonService;
@@ -389,10 +386,10 @@ public class AcceptCarriageOrderController {
 
     /**
      * 工作台-承运业务统计
-     *
+     * @param dateType 1代表周 2代表月
      * @return
      */
-    @RequestMapping(value = "/workbenchStatistics", method = RequestMethod.GET)
+    @RequestMapping(value = "/workbenchStatisticsByAcceptCarriage", method = RequestMethod.GET)
     public HttpResult workbenchStatistics(@RequestParam("dateType") @NotBlank(message = "类型不能为空") String dateType) {
         log.info("工作台-承运业务统计 {}", dateType);
         try {
@@ -402,4 +399,20 @@ public class AcceptCarriageOrderController {
             return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, e.getMessage());
         }
     }
+
+    /**
+     * 工作台-物流运输数据统计-承运
+     *
+     * @return
+     */
+    @RequestMapping(value = "/workbenchLogisticsOrderStatistics", method = RequestMethod.POST)
+    public HttpResult workbenchLogisticsOrderStatistics(@RequestBody LogisticsOrderStatisticsParam logisticsOrderStatistics) {
+        log.info("工作台-物流运输数据统计-承运 {}", JSONObject.toJSONString(logisticsOrderStatistics));
+        try {
+            return acceptCarriageOrderService.workbenchLogisticsOrderStatistics(logisticsOrderStatistics);
+        } catch (Exception e) {
+            log.error("工工作台-承运业务统计-承运 error:{}", e.getMessage(), e);
+            return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, e.getMessage());
+        }
+    }
 }

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

@@ -334,13 +334,13 @@ public class ConsignOrderController {
 
 
     /**
-     * 工作台-物流运输数据统计
+     * 工作台-物流运输数据统计-托运业务
      *
      * @return
      */
     @RequestMapping(value = "/workbenchLogisticsOrderStatistics", method = RequestMethod.POST)
     public HttpResult workbenchLogisticsOrderStatistics(@RequestBody LogisticsOrderStatisticsParam logisticsOrderStatistics) {
-        log.info("工作台-物流运输数据统计 {}", JSONObject.toJSONString(logisticsOrderStatistics));
+        log.info("工作台-物流运输数据统计-托运业务 {}", JSONObject.toJSONString(logisticsOrderStatistics));
         try {
             return consignOrderService.workbenchLogisticsOrderStatistics(logisticsOrderStatistics);
         } catch (Exception e) {

+ 3 - 3
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/enterpriseApp/AppConsignController.java

@@ -47,17 +47,17 @@ public class AppConsignController {
     }
 
     /**
-     * 企业app托运订单详情统计
+     * 企业app托运订单详情统计-统计车辆运单
      * @param orderId
      * @return
      */
     @RequestMapping(name = "企业app托运订单详情统计", path = "/statisticsConsignByOrderId", method = RequestMethod.GET)
     public HttpResult statisticsConsignByOrderId(@NotBlank(message = "订单id不能为空") @RequestParam("orderId") String orderId) {
-        log.info("企业app托运订单详情统计 query :{}",orderId);
+        log.info("企业app托运订单详情统计-统计车辆运单 query :{}",orderId);
         try {
             return HttpResult.ok(waybillOrderService.statisticsByOrderId(orderId,"1"));
         } catch (Exception e) {
-            log.error("企业app托运订单详情统计失败  query:{}, error:{}", orderId, e.getMessage(), e);
+            log.error("企业app托运订单详情统计失败-统计车辆运单  query:{}, error:{}", orderId, e.getMessage(), e);
             return HttpResult.error(e.getMessage());
         }
     }

+ 126 - 20
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/dao/KwtLogisticsOrderMapper.java

@@ -12,7 +12,6 @@ import com.sckw.transport.model.vo.execlVo.AcceptCarriageOrderExcelVo;
 import com.sckw.transport.model.vo.AcceptCarriageOrderVO;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
-
 import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
@@ -31,12 +30,15 @@ public interface KwtLogisticsOrderMapper extends BaseMapper<KwtLogisticsOrder> {
      * @param logisticsOrderParam 查询参数
      * @param dictValue           字典id
      * @param entId               托运角色
-     * @param dictValue           承运角色
+     * @param ids                 承运角色
+     * @param orderStatusList     单据状态
      * @return
      */
     List<LogisticsOrderVO> selectLogisticOrderData(@Param("logisticsOrderParam") LogisticsOrderParam logisticsOrderParam,
                                                    @Param("dictValue") String dictValue, @Param("entId") Long entId,
-                                                   @Param("ids") List<Long> ids);
+                                                   @Param("ids") List<Long> ids,
+                                                   @Param("orderStatusList") List<Integer> orderStatusList
+    );
 
 
     /**
@@ -93,7 +95,8 @@ public interface KwtLogisticsOrderMapper extends BaseMapper<KwtLogisticsOrder> {
      */
     Long selectLogisticOrderCount(@Param("logisticsOrderParam") LogisticsOrderParam logisticsOrderParam,
                                   @Param("dictValue") String dictValue, @Param("entId") Long entId,
-                                  @Param("ids") List<Long> ids
+                                  @Param("ids") List<Long> ids,
+                                  @Param("orderStatusList") List<Integer> orderStatusList
     );
 
     Map<String, String> getRejectReason(@Param("id") String id, @Param("status") Integer status);
@@ -132,7 +135,7 @@ public interface KwtLogisticsOrderMapper extends BaseMapper<KwtLogisticsOrder> {
      * @param ids
      * @return
      */
-    List<LogisticsOrderDTO> selectLogisticOrderList(@Param("ids") List<String> ids);
+    List<LogisticsOrderDTO> selectLogisticOrderList(@Param("ids") List<String> ids,@Param("status") Integer status);
 
     /**
      * 通过物流订单id获取统计数据
@@ -147,7 +150,8 @@ public interface KwtLogisticsOrderMapper extends BaseMapper<KwtLogisticsOrder> {
      * @desc 查询分包物流订单
      * @author zk
      * @date 2023/7/20
-     **/
+     *
+     * @return*/
     List<KwtLogisticsOrder> findLogisticsOrder(Map params);
 
     /**
@@ -241,6 +245,24 @@ public interface KwtLogisticsOrderMapper extends BaseMapper<KwtLogisticsOrder> {
                                                          @Param("idsList") List<Long> idsList
     );
 
+    /**
+     * 托运数据查询
+     *
+     * @param query
+     * @param orderList
+     * @param type
+     * @param entId
+     * @return
+     */
+    List<ConsignOrderVO> selectConsignLogisticsOrderListByConsign(@Param("query") ConsignOrderQuery query,
+                                                                  @Param("orderList") List<Integer> orderList,
+                                                                  @Param("type") String type,
+                                                                  @Param("entId") Long entId,
+                                                                  @Param("contactsIds") List<Long> contactsIds,
+                                                                  @Param("userIds") List<Long> userIds,
+                                                                  @Param("idsList") List<Long> idsList
+    );
+
     /**
      * 首页查询导出
      *
@@ -274,6 +296,25 @@ public interface KwtLogisticsOrderMapper extends BaseMapper<KwtLogisticsOrder> {
                                                     @Param("idsList") List<Long> idsList
     );
 
+    /**
+     * 承运订单
+     *
+     * @param query
+     * @param orderList   单据状态
+     * @param type        代表承运或者托运
+     * @param entId       企业id
+     * @param contactsIds 联系人id
+     * @return
+     */
+    List<TableTops> countLogisticsOrderListByAcceptCarriageStatus(@Param("query") AcceptCarriageOrderQuery query,
+                                                                  @Param("orderList") List<Integer> orderList,
+                                                                  @Param("type") String type,
+                                                                  @Param("entId") Long entId,
+                                                                  @Param("contactsIds") List<Long> contactsIds,
+                                                                  @Param("userIds") List<Long> userIds,
+                                                                  @Param("idsList") List<Long> idsList
+    );
+
 
     /**
      * @param query
@@ -309,23 +350,21 @@ public interface KwtLogisticsOrderMapper extends BaseMapper<KwtLogisticsOrder> {
     Integer statisticsLogisticsByTopEntIdAndOrderStatus(@Param("topEntId") Long topEntId, @Param("orderList") List<Integer> orderList);
 
     /**
-     *
      * @param statusList 单据状态集合
-     * @param dateStart 开始时间
-     * @param dateEnd   结束时间
-     * @param topId 顶级企业id
-     * @param unitType  企业类型【1托运2承运】
+     * @param dateStart  开始时间
+     * @param dateEnd    结束时间
+     * @param topId      顶级企业id
+     * @param unitType   企业类型【1托运2承运】
      * @return
      */
     StatisticsByOrderVO selectAcceptCarriageFinishOrder(@Param("statusList") List<Integer> statusList, @Param("dateStart") String dateStart, @Param("dateEnd") String dateEnd, @Param("topId") Long topId, @Param("unitType") Integer unitType);
 
     /**
-     *
      * @param statusList 单据状态集合
-     * @param dateStart 开始时间
-     * @param dateEnd   结束时间
-     * @param topId 顶级企业id
-     * @param unitType  企业类型【1托运2承运】
+     * @param dateStart  开始时间
+     * @param dateEnd    结束时间
+     * @param topId      顶级企业id
+     * @param unitType   企业类型【1托运2承运】
      * @return
      */
     StatisticsByOrderVO selectAcceptCarriageAwaitFinishOrder(@Param("statusList") List<Integer> statusList, @Param("dateStart") String dateStart, @Param("dateEnd") String dateEnd, @Param("topId") Long topId, @Param("unitType") Integer unitType);
@@ -333,14 +372,81 @@ public interface KwtLogisticsOrderMapper extends BaseMapper<KwtLogisticsOrder> {
 
     StatisticsByOrderVO selectStatisticsByOrder(@Param("statusList") List<Integer> statusList, @Param("dateStart") String dateStart, @Param("dateEnd") String dateEnd, @Param("topId") Long topId, @Param("unitType") Integer unitType);
 
-    List<LogisticsOrderStatisticsVO> workbenchLogisticsOrderStatisticsByMonth(@Param("id") Long id, @Param("statusList") List<Integer> statusList,@Param("type") Integer type, @Param("dateStart") String dateStart, @Param("dateEnd") String dateEnd);
+    List<LogisticsOrderStatisticsVO> workbenchLogisticsOrderStatisticsByMonth(@Param("id") Long id, @Param("statusList") List<Integer> statusList, @Param("type") Integer type, @Param("dateStart") String dateStart, @Param("dateEnd") String dateEnd);
 
 
-    List<LogisticsOrderStatisticsVO> workbenchLogisticsOrderStatisticsByDays(@Param("id") Long id, @Param("statusList") List<Integer> statusList,@Param("type") Integer type, @Param("dateStart") String dateStart, @Param("dateEnd") String dateEnd);
+    List<LogisticsOrderStatisticsVO> workbenchLogisticsOrderStatisticsByDays(@Param("id") Long id, @Param("statusList") List<Integer> statusList, @Param("type") Integer type, @Param("dateStart") String dateStart, @Param("dateEnd") String dateEnd);
 
     List<com.sckw.transport.model.dto.LogisticsOrderDTO> selectOrderListByTradeOrderIds(@Param("tradeOrderIds") List<Long> tradeOrderIds, @Param("unitType") String unitType);
 
+    /**
+     * 承运订单数据查询
+     *
+     * @param query
+     * @param orderList
+     * @param type
+     * @param entId
+     * @param contactsIds
+     * @param userIds
+     * @param idsList
+     * @return
+     */
+    List<AcceptCarriageOrderVO> selectLogisticsOrderListByAcceptCarriage(@Param("query") AcceptCarriageOrderQuery query,
+                                                                         @Param("orderList") List<Integer> orderList,
+                                                                         @Param("type") String type,
+                                                                         @Param("entId") Long entId,
+                                                                         @Param("contactsIds") List<Long> contactsIds,
+                                                                         @Param("userIds") List<Long> userIds,
+                                                                         @Param("idsList") List<Long> idsList
+
+    );
+
+    /**
+     * 托运订单数据查询
+     *
+     * @param query
+     * @param orderList
+     * @param type
+     * @param entId
+     * @param contactsIds
+     * @param userIds
+     * @param idsList
+     * @return
+     */
+    List<AcceptCarriageOrderVO> selectLogisticsOrderListByConsign(
+            @Param("query") AcceptCarriageOrderQuery query,
+            @Param("orderList") List<Integer> orderList,
+            @Param("type") String type,
+            @Param("entId") Long entId,
+            @Param("contactsIds") List<Long> contactsIds,
+            @Param("userIds") List<Long> userIds,
+            @Param("idsList") List<Long> idsList
+    );
 
-//    List<TableTops> countAppLogisticsOrderListByStatus(@Param("type") String type,@Param("entId") Long entId
-//    );
+    /**
+     * 托运订单数据统计
+     *
+     * @param query
+     * @param orderList   单据状态
+     * @param type        代表承运或者托运
+     * @param entId       企业id
+     * @param contactsIds 联系人id
+     * @return
+     */
+    List<TableTops> countLogisticsOrderListByConsignStatus(@Param("query") AcceptCarriageOrderQuery query,
+                                                           @Param("orderList") List<Integer> orderList,
+                                                           @Param("type") String type,
+                                                           @Param("entId") Long entId,
+                                                           @Param("contactsIds") List<Long> contactsIds,
+                                                           @Param("userIds") List<Long> userIds,
+                                                           @Param("idsList") List<Long> idsList
+    );
+
+    /**
+     * @param params {lOrderId 物流订单id, tOrderId 贸易订单id, upperlOrderId 下级分包物流订单, belowlOrderId 所属上级分包, status 状态}
+     * @desc 统计物流订单
+     * @author zk
+     * @date 2023/9/18
+     **/
+    LogisticsCountVo findLogisticsOrderCount(Map<String, Object> params);
 }

+ 1 - 1
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/dao/KwtWaybillOrderMapper.java

@@ -83,7 +83,7 @@ public interface KwtWaybillOrderMapper extends BaseMapper<KwtWaybillOrder> {
      * @author zk
      * @date 2023/7/31
      **/
-    WaybillCountVo findWaybillOrderCount(Map params);
+    WaybillCountVo findWaybillOrderCount(Map<String, Object> params);
 
     /**
      * @param driverId 司机ID

+ 203 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/KwtLogisticsOrderTreeVo.java

@@ -0,0 +1,203 @@
+package com.sckw.transport.model.vo;
+
+import jakarta.validation.constraints.DecimalMin;
+import jakarta.validation.constraints.Digits;
+import jakarta.validation.constraints.Max;
+import jakarta.validation.constraints.Min;
+import lombok.Data;
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * desc 物流订单层级关系
+ * author zk
+ * date 2023/9/18 0018
+ */
+@Data
+public class KwtLogisticsOrderTreeVo implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键
+     */
+    private Long id;
+
+    /**
+     * 企业id
+     */
+    private Long entId;
+
+    /**
+     * 物流订单类型(1 贸易订单生成物流订单、2 自建物流订单)
+     */
+    private String type;
+
+    /**
+     * 交易订单id(kwo_trade_order)
+     */
+    private Long tOrderId;
+
+    /**
+     * 交易订单编号(kwo_trade_order)
+     */
+    private String tOrderNo;
+
+    /**
+     * 物流订单编号
+     */
+    private String lOrderNo;
+
+    /**
+     * 分包上级物流订单id
+     */
+    private Long pid;
+
+    /**
+     * 分包所有物流订单id
+     */
+    private String pids;
+
+    /**
+     * 当前单据所属等级
+     */
+    private String level;
+
+    /**
+     * 结算周期(周结、月结、季结)
+     */
+    private Long settlementCycle;
+    /**
+     * 计费方式
+     */
+    private String billingMode;
+
+    /**
+     * 运价
+     */
+    private BigDecimal price;
+
+    /**
+     * 运价方式(元/吨、元/车)
+     */
+    @Min(value = 0,message = "运价方式类型不能大于等于{value}")
+    @Max(value = 4,message = "运价方式类型不能大于等于{value}")
+    private Long priceType;
+
+    /**
+     * 已委托量
+     */
+    @Digits(integer = 10,fraction = 2,message = "委托量格式不正确")
+    @DecimalMin(value = "0.00",message = "委托量不能小于{value}")
+    private BigDecimal amount;
+
+    /**
+     * 单位(吨、方、箱、件)
+     */
+    private String unit;
+
+    /**
+     * 合理损耗
+     */
+    private BigDecimal loss;
+
+    /**
+     * 合理损耗单位(‰/kG)
+     */
+    private String lossUnit;
+
+    /**
+     * 商品价值(扣亏货值)
+     */
+    private BigDecimal goodsPrice;
+
+    /**
+     * 商品价值(扣亏货值)单位
+     */
+    private String goodsPriceUnit;
+
+    /**
+     * 计划开始日期
+     */
+    private LocalDate startTime;
+
+    /**
+     * 计划结束日期
+     */
+    private LocalDate endTime;
+
+    /**
+     * 分包量
+     */
+    private BigDecimal subcontractAmount;
+
+    /**
+     * 已委托量
+     */
+    private BigDecimal entrustAmount;
+
+    /**
+     * 卸货量
+     */
+    private BigDecimal unloadAmount;
+
+    /**
+     * 装货量
+     */
+    private BigDecimal loadAmount;
+
+    /**
+     * 忽略剩余量
+     */
+    private BigDecimal ignoreAmount;
+
+    /**
+     * 亏吨量(装货量-卸货量)
+     */
+    private BigDecimal deficitAmount;
+
+    /**
+     * 亏吨扣款
+     */
+    private BigDecimal deficitPrice;
+
+    /**
+     * 卸货-履约量(自己+下游承运总卸货量)
+     */
+    private BigDecimal totalUnloadAmount;
+
+    /**
+     * 装货-履约量(自己+下游承运总装货量)
+     */
+    private BigDecimal totalLoadAmount;
+
+    /**
+     * 实际开始时间(装货)
+     */
+    private Date loadTime;
+
+    /**
+     * 实际结束时间(卸货)
+     */
+    private Date unloadTime;
+
+    /**
+     * 付款方式(预付款、线下支付、第三方支付)
+     */
+    private Long payment;
+
+    /**
+     * 发票税率(%)
+     */
+    private BigDecimal taxRate;
+
+    /**
+     * 用户状态(0正常、1已锁)
+     */
+    private Integer status;
+
+    private List<KwtLogisticsOrderTreeVo> children;
+}

+ 55 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/LogisticsCountVo.java

@@ -0,0 +1,55 @@
+package com.sckw.transport.model.vo;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * desc 物流订单统计
+ * author zk
+ * date 2023/9/18 0018
+ */
+@Data
+public class LogisticsCountVo {
+
+    /**
+     * 已委托量
+     */
+    private BigDecimal entrustAmount;
+
+    /**
+     * 装货量
+     */
+    private BigDecimal loadAmount;
+
+    /**
+     * 卸货量
+     */
+    private BigDecimal unloadAmount;
+
+    /**
+     * 亏吨量
+     */
+    private BigDecimal deficitAmount;
+
+    /**
+     * 装货时间(第一单车辆运单装货时间)
+     */
+    private Date loadTime;
+
+    /**
+     * 卸货时间(最后一单车辆运单卸货时间)
+     */
+    private Date unloadTime;
+
+    /**
+     * 装货量
+     */
+    private BigDecimal totalLoadAmount;
+
+    /**
+     * 卸货量
+     */
+    private BigDecimal totalUnloadAmount;
+}

+ 39 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/StatisticsAmountVO.java

@@ -0,0 +1,39 @@
+package com.sckw.transport.model.vo;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * @author lfdc
+ * @description 工作台-统计承运量
+ * @date 2023-09-18 18:09:06
+ */
+@Data
+public class StatisticsAmountVO implements Serializable {
+    /**
+     * 承运量/托运量
+     */
+    @JsonProperty("amount")
+    private BigDecimal amount;
+
+    /**
+     * 环比
+     */
+    @JsonProperty("chainRatio")
+    private String chainRatio;
+
+    /**
+     * 1 增长 2下降
+     */
+    @JsonProperty("flag")
+    private Integer flag;
+
+    /**
+     * 环比上次承运量
+     */
+    @JsonProperty("lastAmount")
+    private BigDecimal lastAmount;
+}

+ 34 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/StatisticsMoneyVO.java

@@ -0,0 +1,34 @@
+package com.sckw.transport.model.vo;
+
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * @author lfdc
+ * @description 工作台-统计未履约量
+ * @date 2023-09-18 18:09:06
+ */
+@Data
+public class StatisticsMoneyVO implements Serializable {
+    @Serial
+    private static final long serialVersionUID = 339614434734438926L;
+    /**
+     * 当月/周 金额
+     */
+    private String current;
+    /**
+     * 上月/周 金额
+     */
+    private String before;
+    /**
+     * 环比
+     */
+    private String chainRatio;
+    /**
+     * 1-增长 2-下降
+     */
+    private Integer flag;
+
+}

+ 18 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/StatisticsResultVO.java

@@ -0,0 +1,18 @@
+package com.sckw.transport.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author lfdc
+ * @description 工作台-统计承运量
+ * @date 2023-09-18 18:09:06
+ */
+@Data
+public class StatisticsResultVO implements Serializable {
+   private StatisticsWaitingAmountVO waitingAmountVO;
+   private StatisticsAmountVO amountVO;
+   private StatisticsTotalPriceVO totalPriceVO;
+   private StatisticsMoneyVO moneyVO;
+}

+ 39 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/StatisticsTotalPriceVO.java

@@ -0,0 +1,39 @@
+package com.sckw.transport.model.vo;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * @author lfdc
+ * @description 工作台-总金额(费用)
+ * @date 2023-09-18 18:09:06
+ */
+@Data
+public class StatisticsTotalPriceVO implements Serializable {
+    /**
+     * 承运收入/托运费用
+     */
+    @JsonProperty("totalPrice")
+    private BigDecimal totalPrice;
+
+    /**
+     * 环比
+     */
+    @JsonProperty("chainRatio")
+    private String chainRatio;
+
+    /**
+     * 1 增长 2下降
+     */
+    @JsonProperty("flag")
+    private Integer flag;
+
+    /**
+     * 环比上次待分配量
+     */
+    @JsonProperty("lastTotalPrice")
+    private BigDecimal lastTotalPrice;
+}

+ 39 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/StatisticsWaitingAmountVO.java

@@ -0,0 +1,39 @@
+package com.sckw.transport.model.vo;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * @author lfdc
+ * @description 工作台-统计未履约量
+ * @date 2023-09-18 18:09:06
+ */
+@Data
+public class StatisticsWaitingAmountVO implements Serializable {
+    /**
+     * 待分配量
+     */
+    @JsonProperty("waitingAmount")
+    private BigDecimal waitingAmount;
+
+    /**
+     * 环比
+     */
+    @JsonProperty("chainRatio")
+    private String chainRatio;
+
+    /**
+     * 1 增长 2下降
+     */
+    @JsonProperty("flag")
+    private Integer flag;
+
+    /**
+     * 环比上次待分配量
+     */
+    @JsonProperty("lastWaitingAmount")
+    private BigDecimal lastWaitingAmount;
+}

+ 156 - 11
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/AcceptCarriageOrderService.java

@@ -1,5 +1,7 @@
 package com.sckw.transport.service;
 
+import cn.hutool.core.date.DateField;
+import cn.hutool.core.date.DateTime;
 import cn.hutool.core.util.ArrayUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
@@ -36,6 +38,8 @@ import com.sckw.order.api.model.CompleteLogisticsOrderParam;
 import com.sckw.order.api.model.CreateOrCancelLogisticsOrderParam;
 import com.sckw.order.api.model.OrderDetailRes;
 import com.sckw.order.api.model.UnitInfoDetailRes;
+import com.sckw.payment.api.dubbo.PaymentDubboService;
+import com.sckw.payment.api.model.dto.SettlementMoney;
 import com.sckw.product.api.dubbo.GoodsInfoService;
 import com.sckw.product.api.model.KwpGoods;
 import com.sckw.stream.enums.MessageEnum;
@@ -50,6 +54,7 @@ import com.sckw.transport.model.*;
 import com.sckw.transport.model.dto.*;
 import com.sckw.transport.model.param.AcceptCarriageOrderQuery;
 import com.sckw.transport.model.param.DriverParam;
+import com.sckw.transport.model.param.LogisticsOrderStatisticsParam;
 import com.sckw.transport.model.vo.*;
 import com.sckw.transport.model.vo.execlVo.AcceptCarriageOrderExcelVo;
 import jakarta.annotation.Resource;
@@ -65,11 +70,14 @@ import org.springframework.util.ObjectUtils;
 
 import java.math.BigDecimal;
 import java.text.DecimalFormat;
+import java.text.ParseException;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.*;
 import java.util.stream.Collectors;
 
+import static com.sckw.excel.utils.DateUtil.DEF_DATE_FORMAT;
+
 /**
  * @author lfdc
  * @description 承运订单service
@@ -96,6 +104,9 @@ public class AcceptCarriageOrderService {
     @DubboReference(version = "1.0.0", group = "design", check = false, timeout = 6000)
     RemoteManageService remoteManageService;
 
+    @DubboReference(version = "1.0.0", group = "design", check = false, timeout = 6000)
+    PaymentDubboService paymentDubboService;
+
     @Autowired
     public CommonService commonService;
 
@@ -2317,7 +2328,7 @@ public class AcceptCarriageOrderService {
         if (StringUtils.isNotBlank(query.getIds())) {
             idsList = StringUtils.splitStrToList(query.getIds(), Long.class);
         }
-        List<AcceptCarriageOrderVO> list = logisticsOrderMapper.selectLogisticsOrderList(query, orderList, type, entId, longList, longList,idsList);
+        List<AcceptCarriageOrderVO> list = logisticsOrderMapper.selectLogisticsOrderListByAcceptCarriage(query, orderList, type, entId, longList, longList, idsList);
         PageInfo<AcceptCarriageOrderVO> pageInfo = new PageInfo<>(list);
         if (CollectionUtils.isEmpty(list)) {
             return PageRes.build(pageInfo, list);
@@ -2436,7 +2447,7 @@ public class AcceptCarriageOrderService {
         longs.add(LoginUserHolder.getUserId());
         List<Long> longList = longs.stream().distinct().collect(Collectors.toList());
         List<Long> idsList = StringUtils.splitStrToList(query.getIds(), Long.class);
-        List<TableTops> list = logisticsOrderMapper.countLogisticsOrderListByStatus(query, orderList, type, entId, longList, longList,idsList);
+        List<TableTops> list = logisticsOrderMapper.countLogisticsOrderListByAcceptCarriageStatus(query, orderList, type, entId, longList, longList, idsList);
         List<TableTops> arrayList = new ArrayList<>();
         arrayList.addAll(list);
         /**补全数据状态不齐的情况*/
@@ -2560,7 +2571,7 @@ public class AcceptCarriageOrderService {
         List<Long> longs = LoginUserHolder.getAuthUserIdList();
         longs.add(LoginUserHolder.getUserId());
         List<Long> longList = longs.stream().distinct().collect(Collectors.toList());
-        List<AcceptCarriageOrderVO> list = logisticsOrderMapper.selectLogisticsOrderList(query, orderList, type, entId, longList, longList,idsList);
+        List<AcceptCarriageOrderVO> list = logisticsOrderMapper.selectLogisticsOrderListByAcceptCarriage(query, orderList, type, entId, longList, longList, idsList);
         /**计费方式*/
         Map<String, String> chargingDictData = getDictData(DictTypeEnum.CHARGING_TYPE.getType());
         /**结算周期*/
@@ -2630,7 +2641,7 @@ public class AcceptCarriageOrderService {
                         }
                     }
                 } catch (Exception e) {
-                    log.error("tradeOrderInfoService.getOrderDetailById error id:{}.errorMessage:{}",vo.getTOrderId(),e.getMessage(),e);
+                    log.error("tradeOrderInfoService.getOrderDetailById error id:{}.errorMessage:{}", vo.getTOrderId(), e.getMessage(), e);
                 }
             }
             carriageOrderExcelVo.setSubcontractAmount(Objects.isNull(vo.getSubcontractAmount()) ? null : df.format(vo.getSubcontractAmount()) + priceType.get(vo.getPriceType()));
@@ -2665,7 +2676,7 @@ public class AcceptCarriageOrderService {
             String lastWeekDateStart = DateUtil.getLastWeekDateStartToString(LocalDate.now(), 13);
             //结束时间
             String lastWeekDateEnd = DateUtil.getLastWeekDateEndToString(7);
-            return computeCompare(id, weekDateStart, weekDateEnd, lastWeekDateStart, lastWeekDateEnd);
+            return computeCompare(id, weekDateStart, weekDateEnd, lastWeekDateStart, lastWeekDateEnd, 2);
         } else if (String.valueOf(NumberConstant.TWO).equals(dateType)) {
 
             //本月
@@ -2682,7 +2693,7 @@ public class AcceptCarriageOrderService {
             String lastMonthDateStart = DateUtil.getBeforeMonthDateAndDaysStartToString(LocalDateTime.now(), 2, -1);
             //结束时间
             String lastMonthDateEnd = DateUtil.getBeforeMonthDateAndDaysEndToString(LocalDateTime.now(), 1, 0);
-            return computeCompare(id, monthDateStart, monthDateEnd, lastMonthDateStart, lastMonthDateEnd);
+            return computeCompare(id, monthDateStart, monthDateEnd, lastMonthDateStart, lastMonthDateEnd, 3);
         } else if (String.valueOf(NumberConstant.THREE).equals(dateType)) {
             //年
             // 获取当前日期
@@ -2708,8 +2719,9 @@ public class AcceptCarriageOrderService {
      * @param lastWeekDateEnd   环比上次结束时间
      * @return
      */
-    private HttpResult computeCompare(Long id, String weekDateStart, String weekDateEnd, String lastWeekDateStart, String lastWeekDateEnd) {
+    private HttpResult computeCompare(Long id, String weekDateStart, String weekDateEnd, String lastWeekDateStart, String lastWeekDateEnd, Integer dateType) {
         HttpResult httpResult = new HttpResult();
+        StatisticsResultVO resultVO = new StatisticsResultVO();
         //获取完结的单据-排除掉不做统计中的数据
         List<Integer> statusList = new ArrayList<>();
         statusList.add(LogisticsOrderEnum.TO_BE_PLANNED.getCode());
@@ -2737,6 +2749,83 @@ public class AcceptCarriageOrderService {
         vo.setLastEntrustAmount(lastWeek.getEntrustAmount());
         vo.setLastSubcontractAmount(lastWeek.getSubcontractAmount());
         vo.setLastTotalPrice(lastWeek.getTotalPrice());
+
+        /**计算待承运量*/
+        computeCompareWaitingAmount(resultVO,currentWeek,lastWeek);
+
+        /**承运量*/
+        computeCompareAmount(resultVO,currentWeek,lastWeek);
+
+        /**总金额(费用)*/
+        computeCompareTotalPrice(resultVO,currentWeek,lastWeek);
+
+        /**待处理的金额*/
+        SettlementMoney settlementMoney = paymentDubboService.countCarrier(id, dateType);
+        StatisticsMoneyVO moneyVO = new StatisticsMoneyVO();
+        moneyVO.setCurrent(settlementMoney.getCurrent());
+        moneyVO.setBefore(settlementMoney.getBefore());
+        moneyVO.setChainRatio(settlementMoney.getPercent());
+        moneyVO.setFlag(settlementMoney.getFlag());
+        resultVO.setMoneyVO(moneyVO);
+        httpResult.setData(resultVO);
+        return httpResult;
+    }
+
+    private void computeCompareTotalPrice(StatisticsResultVO resultVO, StatisticsByOrderVO currentWeek, StatisticsByOrderVO lastWeek) {
+        Integer flag = 1;
+        BigDecimal chainRatio = new BigDecimal("0.00");
+        if (currentWeek.getTotalPrice().compareTo(new BigDecimal("0.00")) == 0
+                && lastWeek.getTotalPrice().compareTo(new BigDecimal("0.00")) == 0) {
+            chainRatio = new BigDecimal("0.00");
+        } else if (currentWeek.getTotalPrice().compareTo(new BigDecimal("0.00")) == 0) {
+            chainRatio = chainRatio.subtract(new BigDecimal("100.00"));
+            flag = 2;
+        } else if (lastWeek.getTotalPrice().compareTo(new BigDecimal("0.00")) == 0) {
+            chainRatio = new BigDecimal("100.00").subtract(chainRatio);
+        } else {
+            chainRatio = (currentWeek.getTotalPrice().subtract(lastWeek.getTotalPrice())).divide(lastWeek.getTotalPrice(), NumberConstant.SIX, BigDecimal.ROUND_HALF_UP)
+                    .multiply(new BigDecimal("100.00")).setScale(NumberConstant.TWO, BigDecimal.ROUND_HALF_UP);
+        }
+        if (chainRatio.compareTo(new BigDecimal("0.00")) == -1) {
+            flag = 2;
+        }
+        StatisticsTotalPriceVO priceVO = new StatisticsTotalPriceVO();
+        priceVO.setTotalPrice(currentWeek.getTotalPrice());
+        priceVO.setChainRatio(chainRatio.abs() + "%");
+        priceVO.setFlag(flag);
+        priceVO.setLastTotalPrice(lastWeek.getTotalPrice());
+        resultVO.setTotalPriceVO(priceVO);
+    }
+
+    private void computeCompareAmount(StatisticsResultVO resultVO, StatisticsByOrderVO currentWeek, StatisticsByOrderVO lastWeek) {
+        Integer amountFlag = 1;
+        BigDecimal amountChainRatio = new BigDecimal("0.00");
+        if (currentWeek.getAmount().compareTo(new BigDecimal("0.00")) == 0
+                && lastWeek.getAmount().compareTo(new BigDecimal("0.00")) == 0) {
+            amountChainRatio = new BigDecimal("0.00");
+        } else if (currentWeek.getAmount().compareTo(new BigDecimal("0.00")) == 0) {
+            amountChainRatio = amountChainRatio.subtract(new BigDecimal("100.00"));
+            amountFlag = 2;
+        } else if (lastWeek.getAmount().compareTo(new BigDecimal("0.00")) == 0) {
+            amountChainRatio = new BigDecimal("100.00").subtract(amountChainRatio);
+        } else {
+            amountChainRatio = (currentWeek.getAmount().subtract(lastWeek.getAmount())).divide(lastWeek.getAmount(), NumberConstant.SIX, BigDecimal.ROUND_HALF_UP)
+                    .multiply(new BigDecimal("100.00")).setScale(NumberConstant.TWO, BigDecimal.ROUND_HALF_UP);
+        }
+        if (amountChainRatio.compareTo(new BigDecimal("0.00")) == -1) {
+            amountFlag = 2;
+        }
+
+        /**承运量*/
+        StatisticsAmountVO amountVO = new StatisticsAmountVO();
+        amountVO.setAmount(currentWeek.getAmount());
+        amountVO.setChainRatio(amountChainRatio.abs() + "%");
+        amountVO.setFlag(amountFlag);
+        amountVO.setLastAmount(lastWeek.getAmount());
+        resultVO.setAmountVO(amountVO);
+    }
+
+    private void computeCompareWaitingAmount(StatisticsResultVO resultVO,StatisticsByOrderVO currentWeek,StatisticsByOrderVO lastWeek) {
         Integer flag = 1;
         BigDecimal chainRatio = new BigDecimal("0.00");
         if (currentWeek.getWaitingAmount().compareTo(new BigDecimal("0.00")) == 0
@@ -2754,9 +2843,65 @@ public class AcceptCarriageOrderService {
         if (chainRatio.compareTo(new BigDecimal("0.00")) == -1) {
             flag = 2;
         }
-        vo.setFlag(flag);
-        vo.setChainRatio(chainRatio.abs() + "%");
-        httpResult.setData(vo);
-        return httpResult;
+        /**待分配量*/
+        StatisticsWaitingAmountVO waitingAmountVO = new StatisticsWaitingAmountVO();
+        waitingAmountVO.setWaitingAmount(currentWeek.getWaitingAmount());
+        waitingAmountVO.setChainRatio(chainRatio.abs() + "%");
+        waitingAmountVO.setFlag(flag);
+        waitingAmountVO.setLastWaitingAmount(lastWeek.getWaitingAmount());
+        resultVO.setWaitingAmountVO(waitingAmountVO);
+    }
+
+    /**
+     * 工作台-物流运输数据统计
+     *
+     * @return
+     */
+    public HttpResult workbenchLogisticsOrderStatistics(LogisticsOrderStatisticsParam logisticsOrderStatistics) {
+//        List<String> stringList = StringUtils.splitStrToList(logisticsOrderStatistics.getTypes(), String.class);
+        EntCacheResDto entCacheResDto = remoteSystemService.queryEntCacheById(LoginUserHolder.getEntId());
+        if (entCacheResDto == null) {
+            return HttpResult.ok();
+        }
+        Long id = entCacheResDto.getId();
+        //获取完结的单据-排除掉不做统计中的数据
+        List<Integer> statusList = new ArrayList<>();
+        statusList.add(LogisticsOrderEnum.TO_BE_PLANNED.getCode());
+        statusList.add(LogisticsOrderEnum.PENDING_ORDER.getCode());
+        statusList.add(LogisticsOrderEnum.WAIT_DELIVERY.getCode());
+        statusList.add(LogisticsOrderEnum.IN_TRANSIT.getCode());
+        statusList.add(LogisticsOrderEnum.HAVE_FINISHED.getCode());
+        statusList.add(LogisticsOrderEnum.HAVE_RECONCILED.getCode());
+        statusList.add(LogisticsOrderEnum.HAVE_ALREADY_SETTLED.getCode());
+
+        /**1.目前只统计承运单位属性的数据
+         * 2.月统计->默认当前往前推12个月
+         * 3.日统计->默认当前往前推30天*/
+        if (String.valueOf(NumberConstant.THREE).equals(logisticsOrderStatistics.getDateType())) {
+            //本月
+            //开始时间
+            DateTime dateTime = cn.hutool.core.date.DateUtil.truncate(new Date(), DateField.MONTH);
+            LocalDateTime localDateTime = dateTime.toLocalDateTime().minusMonths(11);
+            String dateStart = cn.hutool.core.date.DateUtil.format(localDateTime, DEF_DATE_FORMAT);
+            //结束时间
+            String dateEnd = cn.hutool.core.date.DateUtil.format(dateTime, DEF_DATE_FORMAT);
+
+            List<LogisticsOrderStatisticsVO> list = logisticsOrderMapper.workbenchLogisticsOrderStatisticsByMonth(id, statusList, OrderTypeEnum.ACCEPT_CARRIAGE_ORDER.getType(), dateStart, dateEnd);
+            return HttpResult.ok(list);
+        } else if (String.valueOf(NumberConstant.ONE).equals(logisticsOrderStatistics.getDateType())) {
+            //开始时间
+            String format = cn.hutool.core.date.DateUtil.format(LocalDateTime.now(), DEF_DATE_FORMAT);
+            String dateStart = null;
+            try {
+                dateStart = DateUtil.getThirtyDaysDate(format, 29);
+            } catch (ParseException e) {
+                throw new RuntimeException(e);
+            }
+            //结束时间
+            String dateEnd = DateUtil.getLastWeekDateEndToString(0);
+            List<LogisticsOrderStatisticsVO> list = logisticsOrderMapper.workbenchLogisticsOrderStatisticsByDays(id, statusList, OrderTypeEnum.ACCEPT_CARRIAGE_ORDER.getType(), dateStart, dateEnd);
+            return HttpResult.ok(list);
+        }
+        return null;
     }
 }

+ 122 - 37
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/ConsignOrderService.java

@@ -36,6 +36,8 @@ import com.sckw.order.api.dubbo.TradeOrderInfoService;
 import com.sckw.order.api.model.CompleteLogisticsOrderParam;
 import com.sckw.order.api.model.OrderDetailRes;
 import com.sckw.order.api.model.UnitInfoDetailRes;
+import com.sckw.payment.api.dubbo.PaymentDubboService;
+import com.sckw.payment.api.model.dto.SettlementMoney;
 import com.sckw.stream.model.SckwBusSum;
 import com.sckw.system.api.RemoteSystemService;
 import com.sckw.system.api.model.dto.res.AreaTreeFrontResDto;
@@ -99,6 +101,9 @@ public class ConsignOrderService {
     @DubboReference(version = "1.0.0", group = "design", check = false, timeout = 8000)
     RemoteFleetService fleetService;
 
+    @DubboReference(version = "1.0.0", group = "design", check = false, timeout = 6000)
+    PaymentDubboService paymentDubboService;
+
     @Autowired
     public CommonService commonService;
 
@@ -1652,7 +1657,7 @@ public class ConsignOrderService {
         if (StringUtils.isNotBlank(query.getIds())) {
             idsList = StringUtils.splitStrToList(query.getIds(), Long.class);
         }
-        List<AcceptCarriageOrderVO> list = kwtLogisticsOrderMapper.selectLogisticsOrderList(query, orderList, type, entId, longList, longList,idsList);
+        List<AcceptCarriageOrderVO> list = kwtLogisticsOrderMapper.selectLogisticsOrderListByConsign(query, orderList, type, entId, longList, longList,idsList);
         PageInfo<AcceptCarriageOrderVO> pageInfo = new PageInfo<>(list);
         if (CollectionUtils.isEmpty(list)) {
             return PageRes.build(pageInfo, list);
@@ -1771,7 +1776,8 @@ public class ConsignOrderService {
         longs.add(LoginUserHolder.getUserId());
         List<Long> longList = longs.stream().distinct().collect(Collectors.toList());
         List<Long> idsList = StringUtils.splitStrToList(query.getIds(), Long.class);
-        List<TableTops> list = kwtLogisticsOrderMapper.countLogisticsOrderListByStatus(query, orderList, type, entId, longList, longList,idsList);
+//        List<TableTops> list = kwtLogisticsOrderMapper.countLogisticsOrderListByStatus(query, orderList, type, entId, longList, longList,idsList);
+        List<TableTops> list = kwtLogisticsOrderMapper.countLogisticsOrderListByConsignStatus(query, orderList, type, entId, longList, longList,idsList);
         List<TableTops> arrayList = new ArrayList<>();
         arrayList.addAll(list);
         /**补全数据状态不齐的情况*/
@@ -1866,7 +1872,9 @@ public class ConsignOrderService {
         longs.add(LoginUserHolder.getUserId());
         List<Long> longList = longs.stream().distinct().collect(Collectors.toList());
         List<Long> idsList = StringUtils.splitStrToList(query.getIds(), Long.class);
-        List<ConsignOrderVO> list = kwtLogisticsOrderMapper.selectConsignLogisticsOrderList(query, orderList, type, entId, longList, longList,idsList);
+//        List<ConsignOrderVO> list = kwtLogisticsOrderMapper.selectConsignLogisticsOrderList(query, orderList, type, entId, longList, longList,idsList);
+        List<ConsignOrderVO> list = kwtLogisticsOrderMapper.selectConsignLogisticsOrderListByConsign(query, orderList, type, entId, longList, longList,idsList);
+//        List<ConsignOrderVO> list = kwtLogisticsOrderMapper.selectLogisticsOrderListByConsign(query, orderList, type, entId, longList, longList,idsList);
         /**计费方式*/
         Map<String, String> chargingDictData = commonService.getDictData(DictTypeEnum.CHARGING_TYPE.getType());
         /**结算周期*/
@@ -1962,7 +1970,7 @@ public class ConsignOrderService {
             String lastWeekDateStart = DateUtil.getLastWeekDateStartToString(LocalDate.now(), 13);
             //结束时间
             String lastWeekDateEnd = DateUtil.getLastWeekDateEndToString(7);
-            return computeCompare(entCacheResDto.getId(), weekDateStart, weekDateEnd, lastWeekDateStart, lastWeekDateEnd);
+            return computeCompare(entCacheResDto.getId(), weekDateStart, weekDateEnd, lastWeekDateStart, lastWeekDateEnd,2);
         } else if (String.valueOf(NumberConstant.TWO).equals(dateType)) {
             //月
             //开始时间
@@ -1974,7 +1982,7 @@ public class ConsignOrderService {
             String lastMonthDateStart = DateUtil.getBeforeMonthDateAndDaysStartToString(LocalDateTime.now(), 2, -1);
             //结束时间
             String lastMonthDateEnd = DateUtil.getBeforeMonthDateAndDaysEndToString(LocalDateTime.now(), 1, 0);
-            return computeCompare(entCacheResDto.getId(), monthDateStart, monthDateEnd, lastMonthDateStart, lastMonthDateEnd);
+            return computeCompare(entCacheResDto.getId(), monthDateStart, monthDateEnd, lastMonthDateStart, lastMonthDateEnd,3);
         } else if (String.valueOf(NumberConstant.THREE).equals(dateType)) {
             //年
 
@@ -1995,8 +2003,9 @@ public class ConsignOrderService {
      * @param lastWeekDateEnd   环比上次结束时间
      * @return
      */
-    private HttpResult computeCompare(Long id, String weekDateStart, String weekDateEnd, String lastWeekDateStart, String lastWeekDateEnd) {
+    private HttpResult computeCompare(Long id, String weekDateStart, String weekDateEnd, String lastWeekDateStart, String lastWeekDateEnd,Integer dateType) {
         HttpResult httpResult = new HttpResult();
+        StatisticsResultVO resultVO = new StatisticsResultVO();
         //本周
         //排除掉不做统计中的数据
         //获取完结的单据
@@ -2004,28 +2013,28 @@ public class ConsignOrderService {
         statusList.add(LogisticsOrderEnum.HAVE_FINISHED.getCode());
         statusList.add(LogisticsOrderEnum.HAVE_RECONCILED.getCode());
         statusList.add(LogisticsOrderEnum.HAVE_ALREADY_SETTLED.getCode());
-        StatisticsByOrderVO statistics = kwtLogisticsOrderMapper.selectAcceptCarriageFinishOrder(statusList, weekDateStart, weekDateEnd, id, OrderTypeEnum.CONSIGN_ORDER.getType());
+        StatisticsByOrderVO currentFinish = kwtLogisticsOrderMapper.selectAcceptCarriageFinishOrder(statusList, weekDateStart, weekDateEnd, id, OrderTypeEnum.CONSIGN_ORDER.getType());
         //获取完结中的单据
         statusList.clear();
         statusList.add(LogisticsOrderEnum.TO_BE_PLANNED.getCode());
         statusList.add(LogisticsOrderEnum.PENDING_ORDER.getCode());
         statusList.add(LogisticsOrderEnum.WAIT_DELIVERY.getCode());
         statusList.add(LogisticsOrderEnum.IN_TRANSIT.getCode());
-        StatisticsByOrderVO statisticsByOrderVO = kwtLogisticsOrderMapper.selectAcceptCarriageAwaitFinishOrder(statusList, weekDateStart, weekDateEnd, id, OrderTypeEnum.CONSIGN_ORDER.getType());
+        StatisticsByOrderVO currentFinishIng= kwtLogisticsOrderMapper.selectAcceptCarriageAwaitFinishOrder(statusList, weekDateStart, weekDateEnd, id, OrderTypeEnum.CONSIGN_ORDER.getType());
         //全部的未履约量
-        BigDecimal waitingAmount = statistics.getWaitingAmount().add(statisticsByOrderVO.getWaitingAmount());
-        BigDecimal amount = statistics.getAmount().add(statisticsByOrderVO.getAmount());
-        BigDecimal entrustAmount = statistics.getEntrustAmount().add(statisticsByOrderVO.getEntrustAmount());
-        BigDecimal subcontractAmount = statistics.getSubcontractAmount().add(statisticsByOrderVO.getSubcontractAmount());
-        BigDecimal totalPrice = statistics.getTotalPrice().add(statisticsByOrderVO.getTotalPrice());
+        BigDecimal waitingAmount = currentFinish.getWaitingAmount().add(currentFinishIng.getWaitingAmount());
+        BigDecimal amount = currentFinish.getAmount().add(currentFinishIng.getAmount());
+        BigDecimal entrustAmount = currentFinish.getEntrustAmount().add(currentFinishIng.getEntrustAmount());
+        BigDecimal subcontractAmount = currentFinish.getSubcontractAmount().add(currentFinishIng.getSubcontractAmount());
+        BigDecimal totalPrice = currentFinish.getTotalPrice().add(currentFinishIng.getTotalPrice());
 
 
-        StatisticsByOrderVO vo = new StatisticsByOrderVO();
-        vo.setWaitingAmount(waitingAmount);
-        vo.setAmount(amount);
-        vo.setEntrustAmount(entrustAmount);
-        vo.setSubcontractAmount(subcontractAmount);
-        vo.setTotalPrice(totalPrice);
+        StatisticsByOrderVO current = new StatisticsByOrderVO();
+        current.setWaitingAmount(waitingAmount);
+        current.setAmount(amount);
+        current.setEntrustAmount(entrustAmount);
+        current.setSubcontractAmount(subcontractAmount);
+        current.setTotalPrice(totalPrice);
 
         //上周
 
@@ -2049,37 +2058,113 @@ public class ConsignOrderService {
         BigDecimal lastSubcontractAmount = lastStatistics.getSubcontractAmount().add(lastStatisticsByOrderVO.getSubcontractAmount());
         BigDecimal lastTotalPrice = lastStatistics.getTotalPrice().add(lastStatisticsByOrderVO.getTotalPrice());
 
-        vo.setLastWaitingAmount(lastWaitingAmount);
-        vo.setLastAmount(lastAmount);
-        vo.setLastEntrustAmount(lastEntrustAmount);
-        vo.setLastSubcontractAmount(lastSubcontractAmount);
-        vo.setLastTotalPrice(lastTotalPrice);
+        StatisticsByOrderVO last = new StatisticsByOrderVO();
+        last.setWaitingAmount(lastWaitingAmount);
+        last.setAmount(lastAmount);
+        last.setEntrustAmount(lastEntrustAmount);
+        last.setSubcontractAmount(lastSubcontractAmount);
+        last.setTotalPrice(lastTotalPrice);
+
+        /**计算待承运量*/
+        computeCompareWaitingAmount(resultVO,current,last);
+
+        /**承运量*/
+        computeCompareAmount(resultVO,current,last);
+
+        /**总金额(费用)*/
+        computeCompareTotalPrice(resultVO,current,last);
+
+        /**待处理的金额*/
+        SettlementMoney settlementMoney = paymentDubboService.countShipper(id, dateType);
+        StatisticsMoneyVO moneyVO = new StatisticsMoneyVO();
+        moneyVO.setCurrent(settlementMoney.getCurrent());
+        moneyVO.setBefore(settlementMoney.getBefore());
+        moneyVO.setChainRatio(settlementMoney.getPercent());
+        moneyVO.setFlag(settlementMoney.getFlag());
+        resultVO.setMoneyVO(moneyVO);
+        httpResult.setData(resultVO);
+        return httpResult;
+    }
 
-        //环比计算
-        BigDecimal chainRatio = new BigDecimal("0.00");
+    private void computeCompareTotalPrice(StatisticsResultVO resultVO, StatisticsByOrderVO currentWeek, StatisticsByOrderVO lastWeek) {
         Integer flag = 1;
-        if (waitingAmount.compareTo(new BigDecimal("0.00")) == 0
-                && lastWaitingAmount.compareTo(new BigDecimal("0.00")) == 0) {
+        BigDecimal chainRatio = new BigDecimal("0.00");
+        if (currentWeek.getTotalPrice().compareTo(new BigDecimal("0.00")) == 0
+                && lastWeek.getTotalPrice().compareTo(new BigDecimal("0.00")) == 0) {
             chainRatio = new BigDecimal("0.00");
-        } else if (waitingAmount.compareTo(new BigDecimal("0.00")) == 0) {
+        } else if (currentWeek.getTotalPrice().compareTo(new BigDecimal("0.00")) == 0) {
             chainRatio = chainRatio.subtract(new BigDecimal("100.00"));
             flag = 2;
-        } else if (lastWaitingAmount.compareTo(new BigDecimal("0.00")) == 0) {
+        } else if (lastWeek.getTotalPrice().compareTo(new BigDecimal("0.00")) == 0) {
             chainRatio = new BigDecimal("100.00").subtract(chainRatio);
         } else {
-            chainRatio = (waitingAmount.subtract(lastWaitingAmount)).divide(lastWaitingAmount, NumberConstant.SIX, BigDecimal.ROUND_HALF_UP)
+            chainRatio = (currentWeek.getTotalPrice().subtract(lastWeek.getTotalPrice())).divide(lastWeek.getTotalPrice(), NumberConstant.SIX, BigDecimal.ROUND_HALF_UP)
                     .multiply(new BigDecimal("100.00")).setScale(NumberConstant.TWO, BigDecimal.ROUND_HALF_UP);
         }
         if (chainRatio.compareTo(new BigDecimal("0.00")) == -1) {
             flag = 2;
         }
-        vo.setFlag(flag);
-        vo.setChainRatio(chainRatio.abs() + "%");
-        httpResult.setData(vo);
-        return httpResult;
+        StatisticsTotalPriceVO priceVO = new StatisticsTotalPriceVO();
+        priceVO.setTotalPrice(currentWeek.getTotalPrice());
+        priceVO.setChainRatio(chainRatio.abs() + "%");
+        priceVO.setFlag(flag);
+        priceVO.setLastTotalPrice(lastWeek.getTotalPrice());
+        resultVO.setTotalPriceVO(priceVO);
     }
 
+    private void computeCompareAmount(StatisticsResultVO resultVO, StatisticsByOrderVO currentWeek, StatisticsByOrderVO lastWeek) {
+        Integer amountFlag = 1;
+        BigDecimal amountChainRatio = new BigDecimal("0.00");
+        if (currentWeek.getAmount().compareTo(new BigDecimal("0.00")) == 0
+                && lastWeek.getAmount().compareTo(new BigDecimal("0.00")) == 0) {
+            amountChainRatio = new BigDecimal("0.00");
+        } else if (currentWeek.getAmount().compareTo(new BigDecimal("0.00")) == 0) {
+            amountChainRatio = amountChainRatio.subtract(new BigDecimal("100.00"));
+            amountFlag = 2;
+        } else if (lastWeek.getAmount().compareTo(new BigDecimal("0.00")) == 0) {
+            amountChainRatio = new BigDecimal("100.00").subtract(amountChainRatio);
+        } else {
+            amountChainRatio = (currentWeek.getAmount().subtract(lastWeek.getAmount())).divide(lastWeek.getAmount(), NumberConstant.SIX, BigDecimal.ROUND_HALF_UP)
+                    .multiply(new BigDecimal("100.00")).setScale(NumberConstant.TWO, BigDecimal.ROUND_HALF_UP);
+        }
+        if (amountChainRatio.compareTo(new BigDecimal("0.00")) == -1) {
+            amountFlag = 2;
+        }
 
+        /**承运量*/
+        StatisticsAmountVO amountVO = new StatisticsAmountVO();
+        amountVO.setAmount(currentWeek.getAmount());
+        amountVO.setChainRatio(amountChainRatio.abs() + "%");
+        amountVO.setFlag(amountFlag);
+        amountVO.setLastAmount(lastWeek.getAmount());
+        resultVO.setAmountVO(amountVO);
+    }
+    private void computeCompareWaitingAmount(StatisticsResultVO resultVO,StatisticsByOrderVO currentWeek,StatisticsByOrderVO lastWeek) {
+        Integer flag = 1;
+        BigDecimal chainRatio = new BigDecimal("0.00");
+        if (currentWeek.getWaitingAmount().compareTo(new BigDecimal("0.00")) == 0
+                && lastWeek.getWaitingAmount().compareTo(new BigDecimal("0.00")) == 0) {
+            chainRatio = new BigDecimal("0.00");
+        } else if (currentWeek.getWaitingAmount().compareTo(new BigDecimal("0.00")) == 0) {
+            chainRatio = chainRatio.subtract(new BigDecimal("100.00"));
+            flag = 2;
+        } else if (lastWeek.getWaitingAmount().compareTo(new BigDecimal("0.00")) == 0) {
+            chainRatio = new BigDecimal("100.00").subtract(chainRatio);
+        } else {
+            chainRatio = (currentWeek.getWaitingAmount().subtract(lastWeek.getWaitingAmount())).divide(lastWeek.getWaitingAmount(), NumberConstant.SIX, BigDecimal.ROUND_HALF_UP)
+                    .multiply(new BigDecimal("100.00")).setScale(NumberConstant.TWO, BigDecimal.ROUND_HALF_UP);
+        }
+        if (chainRatio.compareTo(new BigDecimal("0.00")) == -1) {
+            flag = 2;
+        }
+        /**待分配量*/
+        StatisticsWaitingAmountVO waitingAmountVO = new StatisticsWaitingAmountVO();
+        waitingAmountVO.setWaitingAmount(currentWeek.getWaitingAmount());
+        waitingAmountVO.setChainRatio(chainRatio.abs() + "%");
+        waitingAmountVO.setFlag(flag);
+        waitingAmountVO.setLastWaitingAmount(lastWeek.getWaitingAmount());
+        resultVO.setWaitingAmountVO(waitingAmountVO);
+    }
     /**
      * 工作台-物流运输数据统计
      *
@@ -2114,7 +2199,7 @@ public class ConsignOrderService {
             //结束时间
             String dateEnd = cn.hutool.core.date.DateUtil.format(dateTime, DEF_DATE_FORMAT);
 
-            List<LogisticsOrderStatisticsVO> list = kwtLogisticsOrderMapper.workbenchLogisticsOrderStatisticsByMonth(id, statusList, OrderTypeEnum.ACCEPT_CARRIAGE_ORDER.getType(), dateStart, dateEnd);
+            List<LogisticsOrderStatisticsVO> list = kwtLogisticsOrderMapper.workbenchLogisticsOrderStatisticsByMonth(id, statusList, OrderTypeEnum.CONSIGN_ORDER.getType(), dateStart, dateEnd);
             return HttpResult.ok(list);
         } else if (String.valueOf(NumberConstant.ONE).equals(logisticsOrderStatistics.getDateType())) {
             //开始时间
@@ -2127,7 +2212,7 @@ public class ConsignOrderService {
             }
             //结束时间
             String dateEnd = DateUtil.getLastWeekDateEndToString(0);
-            List<LogisticsOrderStatisticsVO> list = kwtLogisticsOrderMapper.workbenchLogisticsOrderStatisticsByDays(id, statusList, OrderTypeEnum.ACCEPT_CARRIAGE_ORDER.getType(), dateStart, dateEnd);
+            List<LogisticsOrderStatisticsVO> list = kwtLogisticsOrderMapper.workbenchLogisticsOrderStatisticsByDays(id, statusList, OrderTypeEnum.CONSIGN_ORDER.getType(), dateStart, dateEnd);
             return HttpResult.ok(list);
         }
         return null;

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

@@ -34,6 +34,7 @@ import com.sckw.system.api.model.dto.res.UserCacheResDto;
 import com.sckw.transport.dao.*;
 import com.sckw.transport.model.*;
 import com.sckw.transport.model.dto.*;
+import com.sckw.transport.model.vo.LogisticsCountVo;
 import com.sckw.transport.model.vo.UserInfoVo;
 import com.sckw.transport.model.vo.WaybillCountVo;
 import com.sckw.transport.model.vo.WaybillOrderDriverVo;
@@ -1069,6 +1070,52 @@ public class KwtWaybillOrderService {
         return HttpResult.ok("车辆运单撤回成功!");
     }
 
+    /**
+     * @param lorderId 物流运单id
+     * @desc 取消派车-物流订单完结(趟次/循环派车)
+     * @author zk
+     * @date 2023/7/24
+     **/
+    public void cancelSendCar(Long lorderId) {
+        /**1数据校验**/
+        KwtLogisticsOrder order = logisticsOrderDao.selectById(lorderId);
+        if (order == null) {
+            return;
+        }
+
+        /**1-5循环派车失效kwt_logistics_order_circulate**/
+        //趟次派车信息
+        List<KwtWaybillOrder> waybillOrders = waybillOrderDao.findWaybillOrder(new HashMap<>(Global.NUMERICAL_SIXTEEN){{
+            put("lOrderId", lorderId);
+            put("status", CarWaybillEnum.PENDING_ORDER.getCode());
+        }});
+        for (KwtWaybillOrder waybillOrder:waybillOrders) {
+            waybillOrder.setStatus(CarWaybillEnum.REVOKED.getCode());
+            waybillOrderDao.updateById(waybillOrder);
+
+            //车辆订单-Mongodb数据更新
+            SckwWaybillOrder wOrder = new SckwWaybillOrder();
+            wOrder.set_id(waybillOrder.getId());
+            editSckwWaybillOrder(wOrder, waybillOrder, 2);
+        }
+
+        //循环派车信息
+        List<KwtLogisticsOrderCirculate> circulates = logisticsOrderCirculateDao.findCirculateList(lorderId, null, null, 0);
+        for (KwtLogisticsOrderCirculate circulate : circulates) {
+            circulate.setStatus(Global.NUMERICAL_ONE);
+            logisticsOrderCirculateDao.updateById(circulate);
+
+            //车辆订单-Mongodb数据更新
+            SckwWaybillOrder wOrder = new SckwWaybillOrder();
+            wOrder.set_id(circulate.getId());
+            KwtWaybillOrder waybillOrder = new KwtWaybillOrder();
+            waybillOrder.setStatus(CarWaybillEnum.REVOKED.getCode());
+            waybillOrder.setUpdateTime(circulate.getUpdateTime());
+            waybillOrder.setUpdateBy(circulate.getUpdateBy());
+            editSckwWaybillOrder(wOrder, waybillOrder, 2);
+        }
+    }
+
     /**
      * @param wOrder mongodb中车辆运单信息
      * @param order  车辆运单信息
@@ -1742,13 +1789,99 @@ public class KwtWaybillOrderService {
         boolean subcontractBool = checkSubcontract(logisticsOrder);
 
         /**1-2校验当前承运订单是否运输完成**/
-        //车辆运单统计
+        //车辆运单统计(运输中的物流订单+车辆运单审核通过)
+        WaybillCountVo waybillCount = waybillOrderDao.findWaybillOrderCount(new HashMap() {{
+            put("upperlOrderId", logisticsOrder.getId());
+            put("passStatus", Global.NUMERICAL_ONE);
+            put("logisticsStatus", LogisticsOrderEnum.IN_TRANSIT.getCode());
+        }});
+        //物流订单统计(运输完成后的物流订单)
+        LogisticsCountVo LogisticsCount = logisticsOrderDao.findLogisticsOrderCount(new HashMap(){{
+            put("upperlOrderId", logisticsOrder.getId());
+            put("finishedStatus", Global.NUMERICAL_ONE);
+        }});
+
+        logisticsOrder.setTotalLoadAmount(waybillCount.getLoadAmount().add(LogisticsCount.getLoadAmount()));
+        logisticsOrder.setTotalUnloadAmount(waybillCount.getUnloadAmount().add(LogisticsCount.getUnloadAmount()));
+        logisticsOrderDao.updateById(logisticsOrder);
+
+        /**1-3更新贸易订单总量**/
+        if (logisticsLevel(logisticsOrder) == Global.NUMERICAL_ONE) {
+            //物流订单统计(运输完成后的物流订单)
+            LogisticsCountVo tradeCount = logisticsOrderDao.findLogisticsOrderCount(new HashMap(){{
+                put("tOrderId", logisticsOrder.getTOrderId());
+                put("finishedStatus", Global.NUMERICAL_ONE);
+            }});
+            //查询贸易订单关联物流运单是否全部完结-totalUnfinished
+            WaybillCountVo tradeCount1 = waybillOrderDao.findWaybillOrderCount(new HashMap() {{
+                put("tOrderId", logisticsOrder.getTOrderId());
+            }});
+            CompleteLogisticsOrderParam tradeOrder = new CompleteLogisticsOrderParam();
+            tradeOrder.setTOrderId(logisticsOrder.getTOrderId());
+            tradeOrder.setActualLoadAmount(tradeCount.getLoadAmount());
+            tradeOrder.setActualUnloadAmount(tradeCount.getUnloadAmount());
+            tradeOrder.setIsAllComplete(tradeCount1.getTotalUnfinished() > 0 ? false : true);
+            tradeOrder.setUpdateBy(LoginUserHolder.getUserId());
+            tradeOrder.setUpdateByName(LoginUserHolder.getUserName());
+            tradeOrderInfoService.completeLogisticsOrder(tradeOrder);
+        }
+
+        /**1-4Mongodb数据更新**/
+        //承运订单
+        SckwLogisticsOrder lOrder = new SckwLogisticsOrder();
+        lOrder.setTotalLoadAmount(logisticsOrder.getTotalLoadAmount());
+        lOrder.setTotalUnloadAmount(logisticsOrder.getTotalUnloadAmount());
+        editSckwLogisticsOrder(lOrder, logisticsOrder);
+
+        /**2当前物流订单属于分包(存在上级物流订单)**/
+        //获取所有上级物流订单ID(当前物流订单ID除外)
+        String pids = logisticsOrder.getPids();
+        if (StringUtils.isNotBlank(pids)) {
+            String[] idArray = pids.split(Global.COMMA);
+            for (String id : idArray) {
+                Long pid = Long.parseLong(id);
+                //当前物流订单ID除外
+                if (!pid.equals(lOrderId)) {
+                    /**校验当前承运订单是否运输完成**/
+                    checkLogisticsByStatus(pid);
+                }
+            }
+        }
+    }
+
+    /**
+     * @param lOrderId 承运订单ID
+     * @description 校验当前承运订单是否运输完成(修改状态 + 统计量)
+     * @author zk
+     * @date 2023/7/27
+     **/
+    public void checkLogisticsByStatusV1(Long lOrderId) {
+        /**
+         校验当前承运订单是否运输完成(虑该当前承运订单上下级物流订单)
+         1存在下级分包,下级物流订单和当前物流订单全部运输完成则修改当前物流订单状态为已完成(HAVE_FINISHED)、统计值
+         2当前物流订单属于分包:需要判断上级及同级分包全部运输完成修改上级物流订单状态为已完成(HAVE_FINISHED)、统计值-一直向上到一级物流订单
+         **/
+
+        /**1存在下级分包**/
+        KwtLogisticsOrder logisticsOrder = logisticsOrderDao.selectById(lOrderId);
+        /**1-1校验下级分包是否全部运输完成**/
+        boolean subcontractBool = checkSubcontract(logisticsOrder);
+
+        /**1-2校验当前承运订单是否运输完成**/
+        //车辆运单统计(运输中的物流订单+车辆运单审核通过)
         WaybillCountVo waybillCount = waybillOrderDao.findWaybillOrderCount(new HashMap() {{
             put("upperlOrderId", logisticsOrder.getId());
-            put("passStatus", 1);
+            put("passStatus", Global.NUMERICAL_ONE);
+            put("logisticsStatus", LogisticsOrderEnum.IN_TRANSIT.getCode());
         }});
-        logisticsOrder.setTotalLoadAmount(waybillCount.getLoadAmount());
-        logisticsOrder.setTotalUnloadAmount(waybillCount.getUnloadAmount());
+        //物流订单统计(运输完成后的物流订单)
+        LogisticsCountVo LogisticsCount = logisticsOrderDao.findLogisticsOrderCount(new HashMap(){{
+            put("upperlOrderId", logisticsOrder.getId());
+            put("finishedStatus", Global.NUMERICAL_ONE);
+        }});
+
+        logisticsOrder.setTotalLoadAmount(waybillCount.getLoadAmount().add(LogisticsCount.getLoadAmount()));
+        logisticsOrder.setTotalUnloadAmount(waybillCount.getUnloadAmount().add(LogisticsCount.getUnloadAmount()));
         BigDecimal subcontractAmount = logisticsOrder.getSubcontractAmount() == null ? new BigDecimal(Global.AMOUNT) : logisticsOrder.getSubcontractAmount();
         //物流运单状态(不包含已完成、已对账、已结算)+ 物流订单上级委派量-下游分包总量 <= 自己承运总装货量 + 下级分包全部运输完成
         if (!LogisticsOrderEnum.transportCompleted(logisticsOrder.getStatus())
@@ -1756,7 +1889,7 @@ public class KwtWaybillOrderService {
                 && subcontractBool) {
             //---------------------------------------------zk 2023-08-01 全量可运
             /**1-3下级分包承运订单运输完成**/
-            //logisticsOrder.setStatus(LogisticsOrderEnum.HAVE_FINISHED.getCode());//取消自动完结
+            logisticsOrder.setStatus(LogisticsOrderEnum.HAVE_FINISHED.getCode());//取消自动完结
             logisticsOrderDao.updateById(logisticsOrder);
 
             /**1-4承运订单状态记录**/
@@ -1791,7 +1924,7 @@ public class KwtWaybillOrderService {
             //查询贸易订单总装货量/总卸货量
             WaybillCountVo tradeCount = waybillOrderDao.findWaybillOrderCount(new HashMap() {{
                 put("tOrderId", logisticsOrder.getTOrderId());
-                put("passStatus", 1);
+                put("passStatus", Global.NUMERICAL_ONE);
             }});
             //查询贸易订单关联物流运单是否全部完结-totalUnfinished
             WaybillCountVo tradeCount1 = waybillOrderDao.findWaybillOrderCount(new HashMap() {{

+ 239 - 5
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/TransportCommonService.java

@@ -1,16 +1,20 @@
 package com.sckw.transport.service;
 
+import cn.hutool.core.collection.CollectionUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.sckw.contract.api.RemoteContractService;
 import com.sckw.contract.api.model.dto.res.ContractCommonInfoResDto;
+import com.sckw.core.annotation.Log;
 import com.sckw.core.common.enums.NumberConstant;
 import com.sckw.core.common.enums.enums.DictEnum;
 import com.sckw.core.common.enums.enums.DictTypeEnum;
+import com.sckw.core.model.constant.Global;
 import com.sckw.core.model.enums.LogisticsOrderEnum;
 import com.sckw.core.model.page.PageResult;
+import com.sckw.core.utils.BeanUtils;
 import com.sckw.core.utils.CollectionUtils;
 import com.sckw.core.utils.IdWorker;
 import com.sckw.core.utils.StringUtils;
@@ -36,8 +40,7 @@ import com.sckw.transport.model.dto.CancelOrderDTO;
 import com.sckw.transport.model.dto.DocumentParamDTO;
 import com.sckw.transport.model.param.ContractParam;
 import com.sckw.transport.model.param.LogisticsOrderParam;
-import com.sckw.transport.model.vo.OrderDetailVO;
-import com.sckw.transport.model.vo.SckwLogisticsOrderVO;
+import com.sckw.transport.model.vo.*;
 import jakarta.annotation.Resource;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboReference;
@@ -519,10 +522,12 @@ public class TransportCommonService {
         if (entCacheResDto != null) {
             ids.add(entCacheResDto.getId());
         }
+        List<Integer> orderStatusList = new ArrayList<>();
+        orderStatusList.add(LogisticsOrderEnum.HAVE_FINISHED.getCode());
         ids = ids.stream().distinct().collect(Collectors.toList());
         logisticsOrderParam.setPage((logisticsOrderParam.getPage() - 1) * logisticsOrderParam.getPageSize());
-        List<LogisticsOrderVO> list = logisticsOrderMapper.selectLogisticOrderData(logisticsOrderParam, dictValue, LoginUserHolder.getEntId(), ids);
-        Long count = logisticsOrderMapper.selectLogisticOrderCount(logisticsOrderParam, dictValue, LoginUserHolder.getEntId(), ids);
+        List<LogisticsOrderVO> list = logisticsOrderMapper.selectLogisticOrderData(logisticsOrderParam, dictValue, LoginUserHolder.getEntId(), ids,orderStatusList);
+        Long count = logisticsOrderMapper.selectLogisticOrderCount(logisticsOrderParam, dictValue, LoginUserHolder.getEntId(), ids,orderStatusList);
         /**计量单位*/
         Map<String, String> unitTypeDictData = getDictData(DictTypeEnum.UNIT_TYPE.getType());
         /**运价方式*/
@@ -657,6 +662,8 @@ public class TransportCommonService {
                 logisticsOrderDTO.setLossUnitLabel(taxRateTypeDictData.get(logisticsOrderDTO.getLossUnit()));
                 logisticsOrderDTO.setAmountLabel(unitTypeDictData.get(logisticsOrderDTO.getUnit()));
                 logisticsOrderDTO.setIgnoreAmountLabel(unitTypeDictData.get(logisticsOrderDTO.getUnit()));
+                logisticsOrderDTO.setLoadAmount(logisticsOrderDTO.getTotalLoadAmount());
+                logisticsOrderDTO.setUnloadAmount(logisticsOrderDTO.getTotalUnloadAmount());
                 if (logisticsOrderDTO.getTOrderId() != null) {
                     try {
                         OrderDetailRes orderDetailRes = tradeOrderInfoService.getOrderDetailById(Long.valueOf(logisticsOrderDTO.getTOrderId()));
@@ -675,7 +682,7 @@ public class TransportCommonService {
                             }
                         }
                     } catch (Exception e) {
-                        log.error("tradeOrderInfoService.getOrderDetailById error id:{},errorMessage:{}",logisticsOrderDTO.getTOrderId(),e.getMessage(),e);
+                        log.error("tradeOrderInfoService.getOrderDetailById error id:{},errorMessage:{}", logisticsOrderDTO.getTOrderId(), e.getMessage(), e);
                     }
                 }
 //                logisticsOrderDTO.setCount(waybillOrderMapper.selectCount(new LambdaQueryWrapper<KwtWaybillOrder>().eq(KwtWaybillOrder::getLOrderId, logisticsOrderDTO.getLOrderId())));
@@ -729,4 +736,231 @@ public class TransportCommonService {
         PageResult build = PageResult.build(contractParam.getPage(), contractParam.getPageSize(), list.stream().count(), returnList);
         return HttpResult.ok(build);
     }
+
+    /**
+     * @param lOrderId 承运订单ID
+     * @desc 完结物流订单数据处理
+     * @author zk
+     * @date 2023/9/18
+     **/
+    public void closeHandle(Long lOrderId) {
+        /**1数据校验**/
+        KwtLogisticsOrder logisticsOrder = logisticsOrderMapper.selectById(lOrderId);
+        if (logisticsOrder == null) {
+            return;
+        }
+
+        /**2物流订单树形数据结构**/
+        //所有管理物流订单
+        List<KwtLogisticsOrder> orders = logisticsOrderMapper.findLogisticsOrder(new HashMap<>(){{
+            put("upperlOrderId", lOrderId);
+            put("belowlOrderId", logisticsOrder.getPids());
+        }});
+        //数据copy
+        List<KwtLogisticsOrderTreeVo> logisticsOrders = orders.stream().map( order -> {
+                            KwtLogisticsOrderTreeVo logisticsOrderVo = new KwtLogisticsOrderTreeVo();
+                            BeanUtils.copyPropertiesValue(order, logisticsOrderVo);
+                            return logisticsOrderVo;
+                        }
+                ).collect(Collectors.toList());
+        List<KwtLogisticsOrderTreeVo> treeData = findTree(logisticsOrders);
+        /**数据去除已完结订单下级*/
+        orderTreeHandle(treeData);
+
+        /**3链路数据组装*/
+        List<List<KwtLogisticsOrderTreeVo>> orderLinks = new ArrayList<>();
+        for (KwtLogisticsOrderTreeVo order:treeData) {
+            Stack<KwtLogisticsOrderTreeVo> pathStack = new Stack<>();
+            iteratorNode(order, pathStack, orderLinks);
+        }
+        List<KwtLogisticsOrderTreeVo> orderLink = findLink(orderLinks, lOrderId);
+        //倒序
+        Collections.reverse(orderLink);
+
+        /**4数据处理**/
+        for (KwtLogisticsOrderTreeVo order:orderLink) {
+            //排除已完结订单
+            if (Objects.equals(order.getStatus(), LogisticsOrderEnum.HAVE_FINISHED.getCode())) {
+                //计算总装总卸向上级统计
+                continue;
+            }
+
+            //车辆运单统计(运输中的物流订单+车辆运单审核通过)
+            WaybillCountVo waybillCount = waybillOrderMapper.findWaybillOrderCount(new HashMap() {{
+                put("upperlOrderId", order.getId());
+                put("passStatus", Global.NUMERICAL_ONE);
+                put("logisticsStatus", LogisticsOrderEnum.IN_TRANSIT.getCode());
+            }});
+            //物流订单统计(运输完成后的物流订单)
+            LogisticsCountVo LogisticsCount = logisticsOrderMapper.findLogisticsOrderCount(new HashMap(){{
+                put("upperlOrderId", order.getId());
+                put("finishedStatus", Global.NUMERICAL_ONE);
+            }});
+
+            KwtLogisticsOrder currentOrder = logisticsOrderMapper.selectById(lOrderId);
+            currentOrder.setTotalLoadAmount(waybillCount.getLoadAmount().add(LogisticsCount.getLoadAmount()));
+            currentOrder.setTotalUnloadAmount(waybillCount.getUnloadAmount().add(LogisticsCount.getUnloadAmount()));
+            logisticsOrderMapper.updateById(currentOrder);
+
+            /**Mongodb数据更新**/
+            SckwLogisticsOrder lOrder = new SckwLogisticsOrder();
+            lOrder.setTotalLoadAmount(waybillCount.getLoadAmount());
+            lOrder.setTotalUnloadAmount(waybillCount.getUnloadAmount());
+            SckwBusSum busSum = new SckwBusSum();
+            //业务汇总类型
+            busSum.setBusSumType(BusinessTypeEnum.LOGISTICS_ORDER_TYPE.getName());
+            //操作对象(1新增/2修改)
+            busSum.setMethod(NumberConstant.TWO);
+            //业务汇总数据对象
+            busSum.setObject(order);
+            streamBridge.send("sckw-busSum", JSON.toJSONString(busSum));
+
+            //一级物流订单向贸易订单推送数据
+            if (order.getPid() == null) {
+
+            }
+        }
+    }
+
+    /**
+     * @param treeData 物流订单树形数据
+     * @desc 数据去除已完结订单下级
+     * @author zk
+     * @date 2023/9/18
+     **/
+    public static void orderTreeHandle(List<KwtLogisticsOrderTreeVo> treeData){
+        if (CollectionUtil.isEmpty(treeData)) {
+            return;
+        }
+
+        for (KwtLogisticsOrderTreeVo order:treeData) {
+            orderTreeHandle(order.getChildren());
+            if (order.getStatus() == 4) {
+                order.setChildren(null);
+            }
+        }
+    }
+
+    /**
+     * @param orders 物流订单
+     * @desc 树形数据处理
+     * @author zk
+     * @date 2023/9/18
+     **/
+    public static List<KwtLogisticsOrderTreeVo> findTree(List<KwtLogisticsOrderTreeVo> orders) {
+        //跟节点
+        List<KwtLogisticsOrderTreeVo> rootList = new ArrayList();
+
+        //获取根节点数据
+        if (CollectionUtil.isNotEmpty(orders)) {
+            for(KwtLogisticsOrderTreeVo order:orders){
+                if (order.getPid() == null) {
+                    rootList.add(order);
+                }
+            }
+        }
+
+        //遍历,找到二级节点(根节点的id和所有节点中的pid比较)
+        for (KwtLogisticsOrderTreeVo order : rootList) {
+            List<KwtLogisticsOrderTreeVo> child = getChild(order.getId(), orders);
+            order.setChildren(child);
+        }
+
+        return rootList;
+    }
+
+    /**
+     * @param pid 上级物流订单ID
+     * @param orders 物流订单
+     * @desc 树形数据处理-递归
+     * @author zk
+     * @date 2023/9/18
+     **/
+    public static List<KwtLogisticsOrderTreeVo> getChild(Long pid, List<KwtLogisticsOrderTreeVo> orders) {
+        List<KwtLogisticsOrderTreeVo> childList = new ArrayList();
+        for (KwtLogisticsOrderTreeVo order : orders) {
+            if(pid.equals(order.getPid())){
+                //获取当前节点id的所有子列表
+                childList.add(order);
+            }
+        }
+        for (KwtLogisticsOrderTreeVo order : childList) {
+            //将该id的子节点进行遍历,通过递归调用,获取每一个子节点的子节点数据
+            List<KwtLogisticsOrderTreeVo> child = getChild(order.getId(), orders);
+            order.setChildren(child);
+        }
+        if(childList.size()==0){
+            //子节点的长度为0,返回null,null不会被阿里的FastJson包解析
+            return  null;
+        }
+        return childList;
+    }
+
+    /**
+     * @param: order 当前节点
+     * @param: pathstack 栈
+     * @param: orderLinks 设备链路信息
+     * @desc 链路组装
+     * @author zk
+     * @date 2023/8/8
+     **/
+    public static void iteratorNode(KwtLogisticsOrderTreeVo order, Stack<KwtLogisticsOrderTreeVo> pathstack, List orderLinks) {
+        //入栈
+        pathstack.push(order);
+        List childlist = order.getChildren();
+        //没有子节点 说明是叶子结点
+        if (childlist == null){
+            List list = new ArrayList();
+            Iterator stackIt = pathstack.iterator();
+            while (stackIt.hasNext()) {
+                list.add(stackIt.next());
+            }
+            List<KwtLogisticsOrderTreeVo> orders = print(list);
+            orderLinks.add(orders);
+        } else {
+            Iterator iterator = childlist.iterator();
+            while (iterator.hasNext()) {
+                KwtLogisticsOrderTreeVo child = (KwtLogisticsOrderTreeVo) iterator.next();
+                //深度优先 进入递归
+                iteratorNode(child, pathstack, orderLinks);
+                //回溯时候出栈
+                pathstack.pop();
+            }
+        }
+    }
+
+    /**
+     * @param list 树形数据
+     * @desc 链路组装
+     * @author zk
+     * @date 2023/8/8
+     **/
+    private static List<KwtLogisticsOrderTreeVo> print(List list) {
+        List<KwtLogisticsOrderTreeVo> orders = new ArrayList();
+        Iterator iterator = list.iterator();
+        while (iterator.hasNext()) {
+            KwtLogisticsOrderTreeVo order = (KwtLogisticsOrderTreeVo) iterator.next();
+            order.setChildren(null);
+            orders.add(order);
+        }
+        return orders;
+    }
+
+    /**
+     * @param orderLinks 物流订单链路信息
+     * @param lOrderId 物流订单id
+     * @desc 获取当前物流订单垂直链路
+     * @author zk
+     * @date 2023/9/18
+     **/
+    public static List<KwtLogisticsOrderTreeVo> findLink(List<List<KwtLogisticsOrderTreeVo>> orderLinks, Long lOrderId) {
+        for (List<KwtLogisticsOrderTreeVo> logisticsOrders:orderLinks) {
+            for (KwtLogisticsOrderTreeVo order:logisticsOrders) {
+                if (Objects.equals(lOrderId, order.getId())) {
+                    return logisticsOrders;
+                }
+            }
+        }
+        return null;
+    }
 }

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

@@ -123,7 +123,7 @@ public class TransportDubboServiceImpl implements TransportDubboService {
      */
     @Override
     public List<LogisticsOrderDTO> getAcceptCarriageOrderList(List<String> ids) {
-        List<LogisticsOrderDTO> list = logisticsOrderMapper.selectLogisticOrderList(ids);
+        List<LogisticsOrderDTO> list = logisticsOrderMapper.selectLogisticOrderList(ids,LogisticsOrderEnum.HAVE_FINISHED.getCode());
         /**计量单位*/
         Map<String, String> unitTypeDictData = getDictData(DictTypeEnum.UNIT_TYPE.getType());
         /**运价方式*/

+ 6 - 8
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/dubbo/TransportStatisticsServiceImpl.java

@@ -1,7 +1,6 @@
 package com.sckw.transport.service.dubbo;
 
 import com.sckw.core.common.enums.NumberConstant;
-import com.sckw.core.exception.BusinessException;
 import com.sckw.core.model.enums.CarWaybillEnum;
 import com.sckw.core.model.enums.LogisticsOrderEnum;
 import com.sckw.transport.api.dubbo.TransportStatisticsService;
@@ -14,7 +13,6 @@ import org.springframework.util.CollectionUtils;
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Objects;
 
 /**
  * @author lfdc
@@ -40,9 +38,9 @@ public class TransportStatisticsServiceImpl implements TransportStatisticsServic
     @Override
     public Integer statisticsWaybillSendCar(Long topEntId) {
         Integer returnCount = 0;
-        if (Objects.isNull(topEntId)) {
-            throw new BusinessException("请求参数不能为空");
-        }
+//        if (Objects.isNull(topEntId)) {
+//            throw new BusinessException("请求参数不能为空");
+//        }
         List<Long> ids = logisticsOrderMapper.statisticsLogistics(topEntId);
         if (CollectionUtils.isEmpty(ids)) {
             return returnCount;
@@ -70,9 +68,9 @@ public class TransportStatisticsServiceImpl implements TransportStatisticsServic
     @Override
     public Integer statisticsPendingVerificationWaybill(Long topEntId) {
         Integer returnCount = 0;
-        if (Objects.isNull(topEntId)) {
-            throw new BusinessException("请求参数不能为空");
-        }
+//        if (Objects.isNull(topEntId)) {
+//            throw new BusinessException("请求参数不能为空");
+//        }
         List<Long> ids = logisticsOrderMapper.statisticsLogistics(topEntId);
         if (CollectionUtils.isEmpty(ids)) {
             return returnCount;

+ 749 - 10
sckw-modules/sckw-transport/src/main/resources/mapper/KwtLogisticsOrderMapper.xml

@@ -304,6 +304,12 @@
             <if test="logisticsOrderParam.endTime != null and logisticsOrderParam.endTime !=''">
                 AND a.end_time &lt;= #{logisticsOrderParam.endTime}
             </if>
+            <if test="orderStatusList != null and orderStatusList.size()>0">
+                and a.status in
+                <foreach collection="orderStatusList" separator="," open="(" close=")" item="item" >
+                    #{item,jdbcType=INTEGER}
+                </foreach>
+            </if>
         </where>
         ORDER BY a.create_time DESC
         <if test="logisticsOrderParam.page != null and logisticsOrderParam.pageSize != null ">
@@ -350,6 +356,12 @@
             <if test="logisticsOrderParam.endTime != null and logisticsOrderParam.endTime !=''">
                 AND a.end_time &lt;= #{logisticsOrderParam.endTime}
             </if>
+            <if test="orderStatusList != null  and orderStatusList.size()>0">
+                and a.status in
+                <foreach collection="orderStatusList" item="item" close=")" open="(" separator=",">
+                    #{item,jdbcType=INTEGER}
+                </foreach>
+            </if>
         </where>
         ORDER BY a.create_time DESC
     </select>
@@ -632,6 +644,7 @@
                 </foreach>
             </if>
         </where>
+        and a.status = #{status,jdbcType=INTEGER}
         ORDER BY a.create_time DESC
     </select>
 
@@ -673,6 +686,12 @@
             and FIND_IN_SET(id, #{belowlOrderId, jdbcType=VARCHAR})
             and id != #{ownOrderId, jdbcType=BIGINT}
         </if>
+        <if test="upperlOrderId != null and upperlOrderId != ''">
+            and FIND_IN_SET(#{upperlOrderId, jdbcType=BIGINT}, pids)
+        </if>
+        <if test="belowlOrderId != null and belowlOrderId != ''">
+            and FIND_IN_SET(id, #{belowlOrderId, jdbcType=VARCHAR})
+        </if>
     </select>
     <select id="selectOrderCountByTorderId" resultType="com.sckw.transport.model.dto.LogisticsOrderDTO">
         SELECT a.id          as lOrderId,
@@ -868,6 +887,8 @@
         d.top_ent_id AS consignTopEntId,
         d.firm_name AS consignCompany,
         d.contacts AS consignContacts,
+        d.contacts_id AS consignContactsId,
+        e.contacts_id AS carrierContactsId,
         d.phone AS consignPhone,
         e.ent_id AS carrierCompanyId,
         e.firm_name AS carrierCompany,
@@ -892,15 +913,237 @@
         c.lat AS unloadLat,
         c.lng AS unloadLng,
         f.contract_name as contract
-        <!--        ,-->
-        <!--            a.del_flag,-->
-        <!--            b.del_flag,-->
-        <!--            c.del_flag,-->
-        <!--            d.del_flag,-->
-        <!--            e.del_flag,-->
-        <!--            f.del_flag,-->
-        <!--            g.del_flag-->
+        ,a.del_flag as delFlag
+    </sql>
+
+    <sql id="Query_Column_List_Accept_Carriage">
+        a.id AS lOrderId,
+        a.l_order_no AS lOrderNo,
+        a.t_order_id AS tOrderId,
+        a.t_order_no AS tOrderNo,
+        a.loss AS loss,
+        a.loss_unit AS lossUnit,
+        a.settlement_cycle AS accountsCycle,
+        a.billing_mode AS billingMode,
+        a.amount AS carryingCapacity,
+        a.goods_price AS goodsPrice,
+        a.goods_price_unit AS goodsPriceUnit,
+        a.`status` AS status,
+        a.settlement_cycle AS settlementCycle,
+        a.price AS price,
+        a.price_type AS priceType,
+        a.type AS type,
+        a.unit AS unit,
+        a.subcontract_amount AS subcontractAmount,
+        a.entrust_amount AS entrustAmount,
+        a.unload_amount AS unloadAmount,
+        a.load_amount AS loadAmount,
+        a.ignore_amount AS ignoreAmount,
+        a.deficit_amount AS deficitAmount,
+        a.deficit_price AS deficitPrice,
+        a.total_load_amount AS totalLoadAmount,
+        a.total_unload_amount AS totalUnloadAmount,
+        a.payment AS payment,
+        a.tax_rate AS taxRate,
+        a.ent_id AS entId,
+        a.create_by AS createBy,
+        a.create_time AS createTime,
+        a.update_by AS updateBy,
+        a.update_time AS updateTime,
+        a.start_time AS shipmentsDateTime,
+        a.end_time AS receiveGoodsDateTime,
+        a.remark AS remark,
+        g.goods_id AS goodsId,
+        g.goods_name AS goodsName,
+        g.goods_type AS goodsType,
+        f.contract_id AS contractId,
+        f.contract_no AS contractNo,
+        f.signing_way AS signing,
+        d.ent_id AS consignCompanyId,
+        d.top_ent_id AS consignTopEntId,
+        d.firm_name AS consignCompany,
+        d.contacts AS consignContacts,
+        d.contacts_id AS consignContactsId,
+        e.contacts_id AS carrierContactsId,
+        d.phone AS consignPhone,
+        e.ent_id AS carrierCompanyId,
+        e.firm_name AS carrierCompany,
+        e.top_ent_id AS carrierTopEntId,
+        e.contacts AS carrierContacts,
+        e.phone AS carrierPhone,
+        b.`name` AS loadName,
+        b.address_type AS loadType,
+        b.city_name AS loadCityName,
+        b.city_code AS loadCityCode,
+        b.detail_address AS loadAddress,
+        b.contacts AS shipmentsContacts,
+        b.phone AS shipmentsPhone,
+        b.lat AS loadLat,
+        b.lng AS loadLng,
+        c.address_type AS unloadType,
+        c.contacts AS receiveGoodsContacts,
+        c.phone AS receiveGoodsPhone,
+        c.city_name AS unloadCityName,
+        c.city_code AS unloadCityCode,
+        c.detail_address AS unloadAddress,
+        c.lat AS unloadLat,
+        c.lng AS unloadLng,
+        f.contract_name as contract
+        ,a.del_flag as delFlag,
+        case when a.ent_id = e.top_ent_id then 1 ELSE 2 end as createType
+    </sql>
+
+    <sql id="Query_Column_List_Cogsign">
+        a.id AS lOrderId,
+        a.l_order_no AS lOrderNo,
+        a.t_order_id AS tOrderId,
+        a.t_order_no AS tOrderNo,
+        a.loss AS loss,
+        a.loss_unit AS lossUnit,
+        a.settlement_cycle AS accountsCycle,
+        a.billing_mode AS billingMode,
+        a.amount AS carryingCapacity,
+        a.goods_price AS goodsPrice,
+        a.goods_price_unit AS goodsPriceUnit,
+        a.`status` AS status,
+        a.settlement_cycle AS settlementCycle,
+        a.price AS price,
+        a.price_type AS priceType,
+        a.type AS type,
+        a.unit AS unit,
+        a.subcontract_amount AS subcontractAmount,
+        a.entrust_amount AS entrustAmount,
+        a.unload_amount AS unloadAmount,
+        a.load_amount AS loadAmount,
+        a.ignore_amount AS ignoreAmount,
+        a.deficit_amount AS deficitAmount,
+        a.deficit_price AS deficitPrice,
+        a.total_load_amount AS totalLoadAmount,
+        a.total_unload_amount AS totalUnloadAmount,
+        a.payment AS payment,
+        a.tax_rate AS taxRate,
+        a.ent_id AS entId,
+        a.create_by AS createBy,
+        a.create_time AS createTime,
+        a.update_by AS updateBy,
+        a.update_time AS updateTime,
+        a.start_time AS shipmentsDateTime,
+        a.end_time AS receiveGoodsDateTime,
+        a.remark AS remark,
+        g.goods_id AS goodsId,
+        g.goods_name AS goodsName,
+        g.goods_type AS goodsType,
+        f.contract_id AS contractId,
+        f.contract_no AS contractNo,
+        f.signing_way AS signing,
+        d.ent_id AS consignCompanyId,
+        d.top_ent_id AS consignTopEntId,
+        d.firm_name AS consignCompany,
+        d.contacts AS consignContacts,
+        d.contacts_id AS consignContactsId,
+        e.contacts_id AS carrierContactsId,
+        d.phone AS consignPhone,
+        e.ent_id AS carrierCompanyId,
+        e.firm_name AS carrierCompany,
+        e.top_ent_id AS carrierTopEntId,
+        e.contacts AS carrierContacts,
+        e.phone AS carrierPhone,
+        b.`name` AS loadName,
+        b.address_type AS loadType,
+        b.city_name AS loadCityName,
+        b.city_code AS loadCityCode,
+        b.detail_address AS loadAddress,
+        b.contacts AS shipmentsContacts,
+        b.phone AS shipmentsPhone,
+        b.lat AS loadLat,
+        b.lng AS loadLng,
+        c.address_type AS unloadType,
+        c.contacts AS receiveGoodsContacts,
+        c.phone AS receiveGoodsPhone,
+        c.city_name AS unloadCityName,
+        c.city_code AS unloadCityCode,
+        c.detail_address AS unloadAddress,
+        c.lat AS unloadLat,
+        c.lng AS unloadLng,
+        f.contract_name as contract
+                ,a.del_flag as delFlag,
+        case when a.ent_id = d.top_ent_id then 1 ELSE 2 end as createType
+    </sql>
+
+    <sql id="New_Query_Column_List">
+        lOrderId,
+        lOrderNo,
+        tOrderId,
+        tOrderNo,
+        loss,
+        lossUnit,
+        accountsCycle,
+        billingMode,
+        carryingCapacity,
+        goodsPrice,
+        goodsPriceUnit,
+        STATUS,
+        settlementCycle,
+        price,
+        priceType,
+        type,
+        unit,
+        subcontractAmount,
+        entrustAmount,
+        unloadAmount,
+        loadAmount,
+        ignoreAmount,
+        deficitAmount,
+        deficitPrice,
+        totalLoadAmount,
+        totalUnloadAmount,
+        payment,
+        taxRate,
+        entId,
+        createBy,
+        createTime,
+        updateBy,
+        updateTime,
+        shipmentsDateTime,
+        receiveGoodsDateTime,
+        remark,
+        goodsId,
+        goodsName,
+        goodsType,
+        contractId,
+        contractNo,
+        signing,
+        consignCompanyId,
+        consignTopEntId,
+        consignCompany,
+        consignContacts,
+        consignPhone,
+        carrierCompanyId,
+        carrierCompany,
+        carrierTopEntId,
+        carrierContacts,
+        carrierPhone,
+        loadName,
+        loadType,
+        loadCityName,
+        loadCityCode,
+        loadAddress,
+        shipmentsContacts,
+        shipmentsPhone,
+        loadLat,
+        loadLng,
+        unloadType,
+        receiveGoodsContacts,
+        receiveGoodsPhone,
+        unloadCityName,
+        unloadCityCode,
+        unloadAddress,
+        unloadLat,
+        unloadLng,
+        contract,
+        createType
     </sql>
+
     <select id="selectLogisticsOrderList" resultType="com.sckw.transport.model.vo.AcceptCarriageOrderVO">
         SELECT
         <include refid="Query_Column_List">
@@ -1593,7 +1836,9 @@
                  LEFT JOIN kwt_logistics_order_unit b ON b.l_order_id = a.id
         WHERE a.del_flag = 0
           AND b.del_flag = 0
-          AND (b.ent_id = #{topEntId} OR b.top_ent_id = #{topEntId})
+        <if test="topEntId != null and topEntId != ''">
+            AND (b.ent_id = #{topEntId} OR b.top_ent_id = #{topEntId})
+        </if>
     </select>
 
     <select id="statisticsLogisticsByTopEntIdAndOrderStatus" resultType="java.lang.Integer">
@@ -1605,7 +1850,9 @@
         WHERE
         a.del_flag = 0
         AND b.del_flag = 0
-        AND ( b.ent_id = #{topEntId} OR b.top_ent_id = #{topEntId} )
+        <if test="topEntId != null and topEntId != ''">
+            AND ( b.ent_id = #{topEntId} OR b.top_ent_id = #{topEntId} )
+        </if>
         And a.status in
         <foreach collection="orderList" open="(" close=")" separator="," item="item">
             #{item}
@@ -1811,4 +2058,496 @@
         ) B
         ON  A.date= B.date_time;
     </select>
+    <select id="selectLogisticsOrderListByAcceptCarriage"
+            resultType="com.sckw.transport.model.vo.AcceptCarriageOrderVO">
+        SELECT <include refid="New_Query_Column_List"></include> FROM (
+        SELECT
+        <include refid="Query_Column_List_Accept_Carriage">
+        </include>
+        FROM
+        kwt_logistics_order a
+        LEFT JOIN kwt_logistics_order_address b ON a.id = b.l_order_id
+        AND b.address_type = 1 AND b.del_flag = 0
+        LEFT JOIN kwt_logistics_order_address c ON a.id = c.l_order_id
+        AND c.address_type = 2 AND c.del_flag = 0
+        LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
+        AND d.unit_type = 1 AND d.del_flag = 0
+        LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
+        AND e.unit_type = 2
+        LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
+        LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
+        <where>
+            a.del_flag = 0
+            <if test="query.keywords != null and query.keywords != ''">
+                and (
+                a.t_order_no like concat('%',#{query.keywords},'%')
+                or a.l_order_no like concat('%',#{query.keywords},'%')
+                or d.firm_name like concat('%',#{query.keywords},'%')
+                or e.firm_name like concat('%',#{query.keywords},'%')
+                or g.goods_name like concat('%',#{query.keywords},'%'))
+            </if>
+            <if test="orderList != null and orderList.size() > 0 ">
+                and a.status in
+                <foreach collection="orderList" item="status" open="(" close=")" separator=",">
+                    #{status}
+                </foreach>
+            </if>
+            <if test="idsList != null and idsList.size()>0">
+                and a.id in
+                <foreach collection="idsList" close=")" open="(" separator="," item="item">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="query.endBeginDateTime != null and query.endBeginDateTime != '' ">
+                and DATE( a.end_time) <![CDATA[ >= ]]> #{query.endBeginDateTime}
+            </if>
+            <if test="query.endOverDateTime != null and query.endOverDateTime != '' ">
+                and DATE( a.end_time ) <![CDATA[ <= ]]> #{query.endOverDateTime}
+            </if>
+            <if test="query.startBeginDateTime != null and query.startBeginDateTime != '' ">
+                and DATE( a.start_time) <![CDATA[ >= ]]> #{query.startBeginDateTime}
+            </if>
+            <if test="query.startOverDateTime != null and query.startOverDateTime != '' ">
+                and DATE( a.start_time ) <![CDATA[ <= ]]> #{query.startOverDateTime}
+            </if>
+            <if test="query.createStartTime != null and query.createStartTime != '' ">
+                and a.create_time &gt;=#{query.createStartTime}
+            </if>
+            <if test="query.createEndTime != null and query.createEndTime != ''">
+                and a.create_time &lt;=#{query.createEndTime}
+            </if>
+            <if test="query.loadAddressCode != null and query.loadAddressCode != ''">
+                and b.city_code = #{query.loadAddressCode}
+            </if>
+            <if test="query.unloadAddressCode != null and query.unloadAddressCode != ''">
+                and c.city_code = #{query.unloadAddressCode}
+            </if>
+            <if test="query.billingMode != null and query.billingMode != ''">
+                and a.billing_mode =#{query.billingMode}
+            </if>
+        </where>
+        ORDER BY a.create_time DESC
+        ) tab
+        <where>
+            tab.delFlag = 0
+            AND ((
+            tab.createType = 1
+            and tab.entId = #{entId}
+            <if test="userIds != null and userIds.size()>0">
+                AND tab.createBy IN
+                <foreach collection="userIds" open="(" close=")" item="item" separator=",">
+                    #{item}
+                </foreach>
+            </if>
+            )
+            OR (
+            tab.carrierTopEntId = #{entId}
+            <if test="contactsIds != null and contactsIds.size()>0">
+                AND tab.carrierContactsId IN
+                <foreach collection="contactsIds" separator="," item="item" close=")" open="(">
+                    #{item}
+                </foreach>
+            </if>
+            ))
+        </where>
+    </select>
+    <select id="selectLogisticsOrderListByConsign" resultType="com.sckw.transport.model.vo.AcceptCarriageOrderVO">
+        SELECT <include refid="New_Query_Column_List"></include> FROM (
+        SELECT
+        <include refid="Query_Column_List_Cogsign">
+        </include>
+        FROM
+        kwt_logistics_order a
+        LEFT JOIN kwt_logistics_order_address b ON a.id = b.l_order_id
+        AND b.address_type = 1 AND b.del_flag = 0
+        LEFT JOIN kwt_logistics_order_address c ON a.id = c.l_order_id
+        AND c.address_type = 2 AND c.del_flag = 0
+        LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
+        AND d.unit_type = 1 AND d.del_flag = 0
+        LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
+        AND e.unit_type = 2
+        LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
+        LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
+        <where>
+            a.del_flag = 0
+            <if test="query.keywords != null and query.keywords != ''">
+                and (
+                a.t_order_no like concat('%',#{query.keywords},'%')
+                or a.l_order_no like concat('%',#{query.keywords},'%')
+                or d.firm_name like concat('%',#{query.keywords},'%')
+                or e.firm_name like concat('%',#{query.keywords},'%')
+                or g.goods_name like concat('%',#{query.keywords},'%'))
+            </if>
+            <if test="orderList != null and orderList.size() > 0 ">
+                and a.status in
+                <foreach collection="orderList" item="status" open="(" close=")" separator=",">
+                    #{status}
+                </foreach>
+            </if>
+            <if test="idsList != null and idsList.size()>0">
+                and a.id in
+                <foreach collection="idsList" close=")" open="(" separator="," item="item">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="query.endBeginDateTime != null and query.endBeginDateTime != '' ">
+                and DATE( a.end_time) <![CDATA[ >= ]]> #{query.endBeginDateTime}
+            </if>
+            <if test="query.endOverDateTime != null and query.endOverDateTime != '' ">
+                and DATE( a.end_time ) <![CDATA[ <= ]]> #{query.endOverDateTime}
+            </if>
+            <if test="query.startBeginDateTime != null and query.startBeginDateTime != '' ">
+                and DATE( a.start_time) <![CDATA[ >= ]]> #{query.startBeginDateTime}
+            </if>
+            <if test="query.startOverDateTime != null and query.startOverDateTime != '' ">
+                and DATE( a.start_time ) <![CDATA[ <= ]]> #{query.startOverDateTime}
+            </if>
+            <if test="query.createStartTime != null and query.createStartTime != '' ">
+                and a.create_time &gt;=#{query.createStartTime}
+            </if>
+            <if test="query.createEndTime != null and query.createEndTime != ''">
+                and a.create_time &lt;=#{query.createEndTime}
+            </if>
+            <if test="query.loadAddressCode != null and query.loadAddressCode != ''">
+                and b.city_code = #{query.loadAddressCode}
+            </if>
+            <if test="query.unloadAddressCode != null and query.unloadAddressCode != ''">
+                and c.city_code = #{query.unloadAddressCode}
+            </if>
+            <if test="query.billingMode != null and query.billingMode != ''">
+                and a.billing_mode =#{query.billingMode}
+            </if>
+        </where>
+        ORDER BY a.create_time DESC
+        ) tab
+        <where>
+            tab.delFlag = 0
+            AND ((
+            tab.createType = 1
+            and tab.entId = #{entId}
+            <if test="userIds != null and userIds.size()>0">
+                AND tab.createBy IN
+                <foreach collection="userIds" open="(" close=")" item="item" separator=",">
+                    #{item}
+                </foreach>
+            </if>
+            )
+            OR (
+            tab.consignTopEntId = #{entId}
+            <if test="contactsIds != null and contactsIds.size()>0">
+                AND tab.consignContactsId IN
+                <foreach collection="contactsIds" separator="," item="item" close=")" open="(">
+                    #{item}
+                </foreach>
+            </if>
+            ))
+        </where>
+        ORDER BY tab.createTime DESC
+    </select>
+    <select id="countLogisticsOrderListByConsignStatus" resultType="com.sckw.mongo.model.TableTops">
+        select  status AS value ,
+        COUNT(status) AS total  FROM (
+        SELECT
+        <include refid="Query_Column_List_Cogsign">
+        </include>
+        FROM
+        kwt_logistics_order a
+        LEFT JOIN kwt_logistics_order_address b ON a.id = b.l_order_id
+        AND b.address_type = 1 AND b.del_flag = 0
+        LEFT JOIN kwt_logistics_order_address c ON a.id = c.l_order_id
+        AND c.address_type = 2 AND c.del_flag = 0
+        LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
+        AND d.unit_type = 1 AND d.del_flag = 0
+        LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
+        AND e.unit_type = 2
+        LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
+        LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
+        <where>
+            a.del_flag = 0
+            <if test="query.keywords != null and query.keywords != ''">
+                and (
+                a.t_order_no like concat('%',#{query.keywords},'%')
+                or a.l_order_no like concat('%',#{query.keywords},'%')
+                or d.firm_name like concat('%',#{query.keywords},'%')
+                or e.firm_name like concat('%',#{query.keywords},'%')
+                or g.goods_name like concat('%',#{query.keywords},'%'))
+            </if>
+            <if test="orderList != null and orderList.size() > 0 ">
+                and a.status in
+                <foreach collection="orderList" item="status" open="(" close=")" separator=",">
+                    #{status}
+                </foreach>
+            </if>
+            <if test="idsList != null and idsList.size()>0">
+                and a.id in
+                <foreach collection="idsList" close=")" open="(" separator="," item="item">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="query.endBeginDateTime != null and query.endBeginDateTime != '' ">
+                and DATE( a.end_time) <![CDATA[ >= ]]> #{query.endBeginDateTime}
+            </if>
+            <if test="query.endOverDateTime != null and query.endOverDateTime != '' ">
+                and DATE( a.end_time ) <![CDATA[ <= ]]> #{query.endOverDateTime}
+            </if>
+            <if test="query.startBeginDateTime != null and query.startBeginDateTime != '' ">
+                and DATE( a.start_time) <![CDATA[ >= ]]> #{query.startBeginDateTime}
+            </if>
+            <if test="query.startOverDateTime != null and query.startOverDateTime != '' ">
+                and DATE( a.start_time ) <![CDATA[ <= ]]> #{query.startOverDateTime}
+            </if>
+            <if test="query.createStartTime != null and query.createStartTime != '' ">
+                and a.create_time &gt;=#{query.createStartTime}
+            </if>
+            <if test="query.createEndTime != null and query.createEndTime != ''">
+                and a.create_time &lt;=#{query.createEndTime}
+            </if>
+            <if test="query.loadAddressCode != null and query.loadAddressCode != ''">
+                and b.city_code = #{query.loadAddressCode}
+            </if>
+            <if test="query.unloadAddressCode != null and query.unloadAddressCode != ''">
+                and c.city_code = #{query.unloadAddressCode}
+            </if>
+            <if test="query.billingMode != null and query.billingMode != ''">
+                and a.billing_mode =#{query.billingMode}
+            </if>
+        </where>
+        ORDER BY a.create_time DESC
+        ) tab
+        <where>
+            tab.delFlag = 0
+            AND ((
+            tab.createType = 1
+            and tab.entId = #{entId}
+            <if test="userIds != null and userIds.size()>0">
+                AND tab.createBy IN
+                <foreach collection="userIds" open="(" close=")" item="item" separator=",">
+                    #{item}
+                </foreach>
+            </if>
+            )
+            OR (
+            tab.consignTopEntId = #{entId}
+            <if test="contactsIds != null and contactsIds.size()>0">
+                AND tab.consignContactsId IN
+                <foreach collection="contactsIds" separator="," item="item" close=")" open="(">
+                    #{item}
+                </foreach>
+            </if>
+            ))
+        </where>
+        group by status
+    </select>
+    <select id="countLogisticsOrderListByAcceptCarriageStatus" resultType="com.sckw.mongo.model.TableTops">
+        SELECT status as value,
+            COUNT( status ) AS total  FROM (
+        SELECT
+        <include refid="Query_Column_List_Accept_Carriage">
+        </include>
+        FROM
+        kwt_logistics_order a
+        LEFT JOIN kwt_logistics_order_address b ON a.id = b.l_order_id
+        AND b.address_type = 1 AND b.del_flag = 0
+        LEFT JOIN kwt_logistics_order_address c ON a.id = c.l_order_id
+        AND c.address_type = 2 AND c.del_flag = 0
+        LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
+        AND d.unit_type = 1 AND d.del_flag = 0
+        LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
+        AND e.unit_type = 2
+        LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
+        LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
+        <where>
+            a.del_flag = 0
+            <if test="query.keywords != null and query.keywords != ''">
+                and (
+                a.t_order_no like concat('%',#{query.keywords},'%')
+                or a.l_order_no like concat('%',#{query.keywords},'%')
+                or d.firm_name like concat('%',#{query.keywords},'%')
+                or e.firm_name like concat('%',#{query.keywords},'%')
+                or g.goods_name like concat('%',#{query.keywords},'%'))
+            </if>
+            <if test="orderList != null and orderList.size() > 0 ">
+                and a.status in
+                <foreach collection="orderList" item="status" open="(" close=")" separator=",">
+                    #{status}
+                </foreach>
+            </if>
+            <if test="idsList != null and idsList.size()>0">
+                and a.id in
+                <foreach collection="idsList" close=")" open="(" separator="," item="item">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="query.endBeginDateTime != null and query.endBeginDateTime != '' ">
+                and DATE( a.end_time) <![CDATA[ >= ]]> #{query.endBeginDateTime}
+            </if>
+            <if test="query.endOverDateTime != null and query.endOverDateTime != '' ">
+                and DATE( a.end_time ) <![CDATA[ <= ]]> #{query.endOverDateTime}
+            </if>
+            <if test="query.startBeginDateTime != null and query.startBeginDateTime != '' ">
+                and DATE( a.start_time) <![CDATA[ >= ]]> #{query.startBeginDateTime}
+            </if>
+            <if test="query.startOverDateTime != null and query.startOverDateTime != '' ">
+                and DATE( a.start_time ) <![CDATA[ <= ]]> #{query.startOverDateTime}
+            </if>
+            <if test="query.createStartTime != null and query.createStartTime != '' ">
+                and a.create_time &gt;=#{query.createStartTime}
+            </if>
+            <if test="query.createEndTime != null and query.createEndTime != ''">
+                and a.create_time &lt;=#{query.createEndTime}
+            </if>
+            <if test="query.loadAddressCode != null and query.loadAddressCode != ''">
+                and b.city_code = #{query.loadAddressCode}
+            </if>
+            <if test="query.unloadAddressCode != null and query.unloadAddressCode != ''">
+                and c.city_code = #{query.unloadAddressCode}
+            </if>
+            <if test="query.billingMode != null and query.billingMode != ''">
+                and a.billing_mode =#{query.billingMode}
+            </if>
+        </where>
+        ORDER BY a.create_time DESC
+        ) tab
+        <where>
+            tab.delFlag = 0
+            AND ((
+            tab.createType = 1
+            and tab.entId = #{entId}
+            <if test="userIds != null and userIds.size()>0">
+                AND tab.createBy IN
+                <foreach collection="userIds" open="(" close=")" item="item" separator=",">
+                    #{item}
+                </foreach>
+            </if>
+            )
+            OR (
+            tab.carrierTopEntId = #{entId}
+            <if test="contactsIds != null and contactsIds.size()>0">
+                AND tab.carrierContactsId IN
+                <foreach collection="contactsIds" separator="," item="item" close=")" open="(">
+                    #{item}
+                </foreach>
+            </if>
+            ))
+        </where>
+        group by status
+    </select>
+    <select id="selectConsignLogisticsOrderListByConsign" resultType="com.sckw.transport.model.vo.ConsignOrderVO">
+        SELECT <include refid="New_Query_Column_List"></include> FROM (
+        SELECT
+        <include refid="Query_Column_List_Cogsign">
+        </include>
+        FROM
+        kwt_logistics_order a
+        LEFT JOIN kwt_logistics_order_address b ON a.id = b.l_order_id
+        AND b.address_type = 1 AND b.del_flag = 0
+        LEFT JOIN kwt_logistics_order_address c ON a.id = c.l_order_id
+        AND c.address_type = 2 AND c.del_flag = 0
+        LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
+        AND d.unit_type = 1 AND d.del_flag = 0
+        LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
+        AND e.unit_type = 2
+        LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
+        LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
+        <where>
+            a.del_flag = 0
+            <if test="query.keywords != null and query.keywords != ''">
+                and (
+                a.t_order_no like concat('%',#{query.keywords},'%')
+                or a.l_order_no like concat('%',#{query.keywords},'%')
+                or d.firm_name like concat('%',#{query.keywords},'%')
+                or e.firm_name like concat('%',#{query.keywords},'%')
+                or g.goods_name like concat('%',#{query.keywords},'%'))
+            </if>
+            <if test="orderList != null and orderList.size() > 0 ">
+                and a.status in
+                <foreach collection="orderList" item="status" open="(" close=")" separator=",">
+                    #{status}
+                </foreach>
+            </if>
+            <if test="idsList != null and idsList.size()>0">
+                and a.id in
+                <foreach collection="idsList" close=")" open="(" separator="," item="item">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="query.endBeginDateTime != null and query.endBeginDateTime != '' ">
+                and DATE( a.end_time) <![CDATA[ >= ]]> #{query.endBeginDateTime}
+            </if>
+            <if test="query.endOverDateTime != null and query.endOverDateTime != '' ">
+                and DATE( a.end_time ) <![CDATA[ <= ]]> #{query.endOverDateTime}
+            </if>
+            <if test="query.startBeginDateTime != null and query.startBeginDateTime != '' ">
+                and DATE( a.start_time) <![CDATA[ >= ]]> #{query.startBeginDateTime}
+            </if>
+            <if test="query.startOverDateTime != null and query.startOverDateTime != '' ">
+                and DATE( a.start_time ) <![CDATA[ <= ]]> #{query.startOverDateTime}
+            </if>
+            <if test="query.createStartTime != null and query.createStartTime != '' ">
+                and a.create_time &gt;=#{query.createStartTime}
+            </if>
+            <if test="query.createEndTime != null and query.createEndTime != ''">
+                and a.create_time &lt;=#{query.createEndTime}
+            </if>
+            <if test="query.loadAddressCode != null and query.loadAddressCode != ''">
+                and b.city_code = #{query.loadAddressCode}
+            </if>
+            <if test="query.unloadAddressCode != null and query.unloadAddressCode != ''">
+                and c.city_code = #{query.unloadAddressCode}
+            </if>
+            <if test="query.billingMode != null and query.billingMode != ''">
+                and a.billing_mode =#{query.billingMode}
+            </if>
+        </where>
+        ORDER BY a.create_time DESC
+        ) tab
+        <where>
+            tab.delFlag = 0
+            AND ((
+            tab.createType = 1
+            and tab.entId = #{entId}
+            <if test="userIds != null and userIds.size()>0">
+                AND tab.createBy IN
+                <foreach collection="userIds" open="(" close=")" item="item" separator=",">
+                    #{item}
+                </foreach>
+            </if>
+            )
+            OR (
+            tab.consignTopEntId = #{entId}
+            <if test="contactsIds != null and contactsIds.size()>0">
+                AND tab.consignContactsId IN
+                <foreach collection="contactsIds" separator="," item="item" close=")" open="(">
+                    #{item}
+                </foreach>
+            </if>
+            ))
+        </where>
+        ORDER BY tab.createTime DESC
+    </select>
+
+    <select id="findLogisticsOrderCount" resultType="com.sckw.transport.model.vo.LogisticsCountVo" parameterType="java.util.Map">
+        SELECT
+        sum(load_amount) loadAmount, sum(unload_amount) unloadAmount,
+        sum(total_load_amount) totalLoadAmount, sum(total_unload_amount) totalUnloadAmount
+        from kwt_logistics_order where del_flag = 0
+        <if test="tOrderId != null and tOrderId != ''">
+            and t_order_id = #{tOrderId, jdbcType=BIGINT}
+        </if>
+        <if test="lOrderId != null and lOrderId != ''">
+            and id = #{lOrderId, jdbcType=BIGINT}
+        </if>
+        <if test="finishedStatus != null and finishedStatus != ''">
+            and status in (4, 5, 6)
+        </if>
+        <if test="status != null and status != ''">
+            and status = #{lOrderId, jdbcType=INTEGER}
+        </if>
+        <if test="upperlOrderId != null and upperlOrderId != ''">
+            and FIND_IN_SET(#{upperlOrderId, jdbcType=BIGINT}, pids)
+        </if>
+        <if test="belowlOrderId != null and belowlOrderId != ''">
+            and FIND_IN_SET(id, #{belowlOrderId, jdbcType=VARCHAR})
+        </if>
+    </select>
 </mapper>

+ 12 - 0
sckw-modules/sckw-transport/src/main/resources/mapper/KwtWaybillOrderMapper.xml

@@ -177,6 +177,9 @@
         <if test="truckId != null and truckId != ''">
             and wo.truck_id = #{truckId, jdbcType=BIGINT}
         </if>
+        <if test="logisticsStatus != null and logisticsStatus != ''">
+            and lo.status  = #{logisticsStatus, jdbcType=INTEGER}
+        </if>
         <if test="passStatus != null and passStatus != ''">
             and wo.status = 8
         </if>
@@ -522,12 +525,21 @@
         kwo.create_time createTime, kwo.driver_id driverId, kwo.driver_name driverName, kwo.driver_phone driverPhone
         FROM kwt_waybill_order kwo
         where kwo.del_flag = 0
+        <if test="tOrderId != null and tOrderId != ''">
+            and kwo.t_order_id = #{tOrderId, jdbcType=BIGINT}
+        </if>
+        <if test="lOrderId != null and lOrderId != ''">
+            and kwo.id = #{lOrderId, jdbcType=BIGINT}
+        </if>
         <if test="driverId != null and driverId != ''">
             and kwo.driver_id = #{driverId, jdbcType=BIGINT}
         </if>
         <if test="truckNo != null and truckNo != ''">
             and kwo.truck_no = #{truckNo, jdbcType=VARCHAR}
         </if>
+        <if test="status != null and status != ''">
+            and kwo.status = #{status, jdbcType=INTEGER}
+        </if>
         <if test="busStatus != null and busStatus == 2">
             and kwo.status = 2
         </if>