Sfoglia il codice sorgente

修改自动派车的贸易订单审核bug

donglang 12 ore fa
parent
commit
84ef774d3c

+ 12 - 15
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/service/operateService/KwcContractTradeService.java

@@ -367,27 +367,16 @@ public class KwcContractTradeService {
      * @param goodsInfo
      */
     private void checkLogContractTime(TradeBaseInfoReqVo baseInfo, List<TradeGoodsInfoReqVo> goodsInfo) {
-        if (true) {
-            return;
-        }
         if (Objects.equals(DispatchWayEnums.AUTO_DISPATCH.getCode(), baseInfo.getDispatchWay())) {
             //商品ids
             List<Long> goodsIdList = goodsInfo.stream().map(TradeGoodsInfoReqVo::getGoodsId).collect(Collectors.toList());
-            //查询满足条件的物合同
+            //查询满足条件的物合同
             List<LogisticsEntDtoVO> logisticsList = queryAutoContractLogOrder(baseInfo.getProvideEntId(), goodsIdList);
-            List<LogisticsEntDtoVO> filteredLogistics  = logisticsList.stream()
-                    .filter(Objects::nonNull)
-                    .filter(log -> log.getStartTime() != null && log.getEndTime() != null)
-                    .filter(log -> {
-                        boolean startTimeOk  = log.getStartTime().after(baseInfo.getStartTime());
-                        boolean endTimeOk = baseInfo.getEndTime() == null || log.getEndTime().before(baseInfo.getEndTime());
-                        return startTimeOk && endTimeOk;
-                    }).collect(Collectors.toList());
-            if (CollectionUtils.isEmpty(filteredLogistics)) {
+            if (CollectionUtils.isEmpty(logisticsList)) {
                 throw new SystemException("请供应商先签订包含贸易商品的自动派车物流合同。");
             }
             //结束时间最早的
-            LogisticsEntDtoVO logEndTimeMin = filteredLogistics.stream()
+            LogisticsEntDtoVO logEndTimeMin = logisticsList.stream()
                     .filter(log -> log.getEndTime() != null)
                     .min(Comparator.comparing(LogisticsEntDtoVO::getEndTime))
                     .orElse(new LogisticsEntDtoVO());
@@ -2240,11 +2229,19 @@ public class KwcContractTradeService {
         if (CollectionUtils.isEmpty(validContractIds)) {
             return Collections.emptyList();
         }
+        //过滤满足商品数据
         List<KwcContractLogistics> finalContractList = contractLogisticsList.stream()
                 .filter(contract -> validContractIds.contains(contract.getId()))
                 .collect(Collectors.toList());
 
-        return toLogisticsEntDtoVO(entId, finalContractList);
+        //过滤有效期合同
+        List<KwcContractLogistics> filteredLogistics = finalContractList.stream().filter(Objects::nonNull)
+                .filter(con -> con.getStartTime() != null)
+                .filter(con -> {
+                    return !con.getStartTime().after(new Date());
+                }).collect(Collectors.toList());
+
+        return toLogisticsEntDtoVO(entId, filteredLogistics);
     }
 
     /**

+ 5 - 18
sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwoTradeOrderService.java

@@ -830,20 +830,13 @@ public class KwoTradeOrderService {
             if (detail.getContractInfo() != null && DispatchWayEnums.AUTO_DISPATCH.getCode().equals(detail.getContractInfo().getDispatchWay())) {
                 //查询销售企业
                 KwoTradeOrderUnit tradeOrderUnit = units.stream().filter(unit -> String.valueOf(Global.NUMERICAL_TWO).equals(unit.getUnitType())).findFirst().orElse(null);
-                //
                 Long goodsId = detail.getGoodsInfo().getGoodsId();
                 //查询满足自动派单的物流合同
                 List<LogisticsEntDtoVO> contractLogisticsList = remoteContractService.queryAutoContractLogOrder(tradeOrderUnit.getEntId(), Lists.newArrayList(goodsId));
-                List<LogisticsEntDtoVO> validContractLogList = contractLogisticsList.stream().filter(Objects::nonNull)
-                        .filter(log -> log.getStartTime() != null)
-                        .filter(log -> {
-                            // 有效期:物流合同开始时间 <= 当前时间
-                            return !log.getStartTime().after(new Date());
-                        }).collect(Collectors.toList());
-                if (CollectionUtils.isEmpty(validContractLogList)) {
+                if (CollectionUtils.isEmpty(contractLogisticsList)) {
                     throw new BusinessException("未找到该商品有效的自动派车物流合同,请先签订自动派车物流合同");
                 }
-                List<ContractInfo> contractInfoList = validContractLogList.stream().map(d -> {
+                List<ContractInfo> contractInfoList = contractLogisticsList.stream().map(d -> {
                     ContractInfo contractInfo = new ContractInfo();
                     contractInfo.setContractId(d.getContractId());
                     contractInfo.setContractNo(d.getContractNo());
@@ -2444,17 +2437,11 @@ public class KwoTradeOrderService {
         KwoTradeOrderUnit tradeOrderUnit = unitMap.get(String.valueOf(Global.NUMERICAL_TWO));
         //查询满足自动派单的物流合同
         List<LogisticsEntDtoVO> contractLogisticsList = remoteContractService.queryAutoContractLogOrder(tradeOrderUnit.getEntId(), Lists.newArrayList(byOrderId.getId()));
-        List<LogisticsEntDtoVO> validContractLog = contractLogisticsList.stream().filter(Objects::nonNull)
-                .filter(log -> log.getStartTime() != null)
-                .filter(log -> {
-                    // 有效期:物流合同开始时间 <= 当前时间
-                    return !log.getStartTime().after(new Date());
-                }).collect(Collectors.toList());
-        if (CollectionUtils.isEmpty(validContractLog)) {
+        if (CollectionUtils.isEmpty(contractLogisticsList)) {
             throw new BusinessException("未找到该商品有效的自动派车物流合同,请先签订自动派车物流合同");
         }
         //填充运输单价
-        for (LogisticsEntDtoVO vo : validContractLog) {
+        for (LogisticsEntDtoVO vo : contractLogisticsList) {
             LogisticsGoodsDto dto = remoteContractService.queryLogGoodsByContractId(vo.getContractId(), byOrderId.getGoodsId());
             if (dto.getPrice() == null || dto.getPrice().compareTo(BigDecimal.ZERO) == 0) {
                 vo.setTransportPrice(vo.getCommonPrice());
@@ -2462,7 +2449,7 @@ public class KwoTradeOrderService {
                 vo.setTransportPrice(dto.getPrice());
             }
         }
-        return validContractLog;
+        return contractLogisticsList;
     }
 
     /**