Sfoglia il codice sorgente

1.修改对账需要的含税金额以及罚款值计算,新增计费方式

lengfaqiang 1 anno fa
parent
commit
a4c8ba37d5

+ 1 - 1
sckw-modules-api/sckw-transport-api/src/main/java/com/sckw/transport/api/dubbo/TransportRemoteLineFreightRateService.java → sckw-modules-api/sckw-transport-api/src/main/java/com/sckw/transport/api/dubbo/RemoteTransportLineFreightRateService.java

@@ -2,7 +2,7 @@ package com.sckw.transport.api.dubbo;
 
 import java.util.List;
 
-public interface TransportRemoteLineFreightRateService {
+public interface RemoteTransportLineFreightRateService {
 
     /**
      * 路径id是否被关联

+ 23 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/KwtLogisticsConsignmentController.java

@@ -14,6 +14,7 @@ import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.excel.utils.ExcelUtil;
 import com.sckw.transport.model.dto.LogisticsConsignmentDto;
+import com.sckw.transport.model.dto.LogisticsOrderFinishDto;
 import com.sckw.transport.model.dto.LogisticsOrderSubcontractDto;
 import com.sckw.transport.model.dto.OrderManualCompletionDto;
 import com.sckw.transport.model.param.AddLogisticsOrderParam;
@@ -426,5 +427,27 @@ public class KwtLogisticsConsignmentController {
         }
     }
 
+    /**
+     * 物流订单-完结订单-V4.2
+     *
+     * @param logisticsOrderSubcontractDto 页面请求参数
+     * @return  响应结果
+     */
+    @Validated
+    @RepeatSubmit(interval = 1000,message ="前方拥堵,请稍后尝试")
+    @RequestMapping(value = "/logisticsOrderFinish", method = RequestMethod.POST)
+    public HttpResult logisticsOrderFinish(@Valid @RequestBody LogisticsOrderFinishDto logisticsOrderSubcontractDto) {
+        log.info("物流订单-完结订单传递参数信息:{}", JSONObject.toJSONString(logisticsOrderSubcontractDto));
+        try {
+            return transportCommonService.logisticsOrderFinish(logisticsOrderSubcontractDto);
+        } 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/dubbo/TransportRemoteLineFreightRateServiceImpl.java

@@ -1,7 +1,7 @@
 package com.sckw.transport.dubbo;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.sckw.transport.api.dubbo.TransportRemoteLineFreightRateService;
+import com.sckw.transport.api.dubbo.RemoteTransportLineFreightRateService;
 import com.sckw.transport.dao.KwtLogisticsOrderLineFreightRateMapper;
 import com.sckw.transport.model.KwtLogisticsOrderLineFreightRate;
 import lombok.extern.slf4j.Slf4j;
@@ -19,7 +19,7 @@ import java.util.List;
 @Slf4j
 @Service
 @DubboService(group = "design", version = "1.0.0")
-public class TransportRemoteLineFreightRateServiceImpl implements TransportRemoteLineFreightRateService {
+public class TransportRemoteLineFreightRateServiceImpl implements RemoteTransportLineFreightRateService {
 
     @Autowired
     KwtLogisticsOrderLineFreightRateMapper lineFreightRateMapper;

+ 63 - 20
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/dubbo/TransportServiceImpl.java

@@ -18,6 +18,8 @@ import com.sckw.core.utils.StringUtils;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.core.web.response.HttpResult;
+import com.sckw.manage.api.RemoteManageService;
+import com.sckw.manage.api.model.dto.res.LineFreightAddressRes;
 import com.sckw.mongo.enums.BusinessTypeEnum;
 import com.sckw.mongo.model.SckwLogisticsOrder;
 import com.sckw.order.api.dubbo.TradeOrderInfoService;
@@ -51,6 +53,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -73,6 +76,9 @@ public class TransportServiceImpl implements TransportRemoteService {
     @DubboReference(version = "1.0.0", group = "design", check = false)
     RemoteSystemService remoteSystemService;
 
+    @DubboReference(version = "1.0.0", group = "design", check = false)
+    RemoteManageService manageService;
+
     @DubboReference(version = "1.0.0", group = "design", check = false, timeout = 6000)
     private TradeOrderInfoService tradeOrderInfoService;
 
@@ -97,6 +103,9 @@ public class TransportServiceImpl implements TransportRemoteService {
     @Autowired
     private KwtWaybillOrderMapper waybillOrderDao;
 
+    @Autowired
+    private KwtLogisticsOrderLineFreightRateMapper lineFreightRateMapper;
+
     @Autowired
     private KwtWaybillOrderTrackMapper waybillOrderTrackDao;
 
@@ -231,22 +240,7 @@ public class TransportServiceImpl implements TransportRemoteService {
                  */
                 //todo 2023-10-10 含税金额不减去罚款值 另指定罚款值进行返回数据
                 BigDecimal actualAmount = NumberConstant.ZERO_TWO;
-                if (DictEnum.CHARGING_TYPE_1.getValue().equals(billingMode)) {
-                    actualAmount = (logisticsOrderDTO.getTotalLoadAmount() == null ? NumberConstant.ZERO_TWO : logisticsOrderDTO.getTotalLoadAmount()).multiply(price);
-//                    actualAmount = (logisticsOrderDTO.getTotalLoadAmount() == null ? NumberConstant.ZERO_TWO : logisticsOrderDTO.getTotalLoadAmount()).multiply(price).subtract(fineValue);
-                } else if (DictEnum.CHARGING_TYPE_2.getValue().equals(billingMode)) {
-                    actualAmount = (logisticsOrderDTO.getTotalUnloadAmount() == null ? NumberConstant.ZERO_TWO : logisticsOrderDTO.getTotalUnloadAmount()).multiply(price);
-//                    actualAmount = (logisticsOrderDTO.getTotalUnloadAmount() == null ? NumberConstant.ZERO_TWO : logisticsOrderDTO.getTotalUnloadAmount()).multiply(price).subtract(fineValue);
-                } else if (DictEnum.CHARGING_TYPE_3.getValue().equals(billingMode)) {
-                    // 物流订单运单趟次数量
-                    Map<String, Object> map = new HashMap<>(NumberConstant.SIXTEEN){{
-                        put("upperlOrderId", logisticsOrderDTO.getLOrderId());
-                        put("passStatus", Global.NUMERICAL_ONE);
-                    }};
-                    WaybillCountVo waybillOrderCount = waybillOrderDao.findWaybillOrderCount(map);
-                    BigDecimal totalComplete = waybillOrderCount == null ? NumberConstant.ZERO_TWO : new BigDecimal(waybillOrderCount.getTotalComplete());
-                    actualAmount = totalComplete.multiply(price);
-                }
+                actualAmount = computeAmount(actualAmount, logisticsOrderDTO, billingMode, price);
                 logisticsOrderDTO.setDeductPrice(fineValue);
                 logisticsOrderDTO.setTaxMoney(actualAmount);
                 logisticsOrderDTO.setContractName(contract.getContractName());
@@ -281,6 +275,55 @@ public class TransportServiceImpl implements TransportRemoteService {
         return list;
     }
 
+    /**
+     * 含税金额计算
+     *
+     * @param actualAmount      初始化值
+     * @param logisticsOrderDTO 物流订单
+     * @param billingMode       计算方式
+     * @param price             运价
+     * @return 计算后的值
+     */
+    private BigDecimal computeAmount(BigDecimal actualAmount, AcceptCarriageLogisticsOrderDto logisticsOrderDTO, String billingMode, BigDecimal price) {
+        if (DictEnum.CHARGING_TYPE_1.getValue().equals(billingMode)) {
+            actualAmount = (logisticsOrderDTO.getTotalLoadAmount() == null ? NumberConstant.ZERO_TWO : logisticsOrderDTO.getTotalLoadAmount()).multiply(price);
+//                    actualAmount = (logisticsOrderDTO.getTotalLoadAmount() == null ? NumberConstant.ZERO_TWO : logisticsOrderDTO.getTotalLoadAmount()).multiply(price).subtract(fineValue);
+        } else if (DictEnum.CHARGING_TYPE_2.getValue().equals(billingMode)) {
+            actualAmount = (logisticsOrderDTO.getTotalUnloadAmount() == null ? NumberConstant.ZERO_TWO : logisticsOrderDTO.getTotalUnloadAmount()).multiply(price);
+//                    actualAmount = (logisticsOrderDTO.getTotalUnloadAmount() == null ? NumberConstant.ZERO_TWO : logisticsOrderDTO.getTotalUnloadAmount()).multiply(price).subtract(fineValue);
+        } else if (DictEnum.CHARGING_TYPE_3.getValue().equals(billingMode)) {
+            // 物流订单运单趟次数量
+            Map<String, Object> map = new HashMap<>(NumberConstant.SIXTEEN) {{
+                put("upperlOrderId", logisticsOrderDTO.getLOrderId());
+                put("passStatus", Global.NUMERICAL_ONE);
+            }};
+            WaybillCountVo waybillOrderCount = waybillOrderDao.findWaybillOrderCount(map);
+            BigDecimal totalComplete = waybillOrderCount == null ? NumberConstant.ZERO_TWO : new BigDecimal(waybillOrderCount.getTotalComplete());
+            actualAmount = totalComplete.multiply(price);
+        } else if (DictEnum.CHARGING_TYPE_4.getValue().equals(billingMode)) {
+            String lOrderId = logisticsOrderDTO.getLOrderId();
+            List<KwtLogisticsOrderLineFreightRate> lineFreightRates = lineFreightRateMapper.selectList(new LambdaQueryWrapper<KwtLogisticsOrderLineFreightRate>()
+                    .eq(KwtLogisticsOrderLineFreightRate::getLOrderId, lOrderId)
+                    .eq(KwtLogisticsOrderLineFreightRate::getDelFlag, 0)
+            );
+            if (CollectionUtils.isNotEmpty(lineFreightRates)) {
+                Map<Long, BigDecimal> amountMap = lineFreightRates.stream().collect(Collectors.toMap(KwtLogisticsOrderLineFreightRate::getLineFreightRateId, KwtLogisticsOrderLineFreightRate::getSettlementAmount));
+                List<Long> lineFreightRateIds = lineFreightRates.stream().map(KwtLogisticsOrderLineFreightRate::getLineFreightRateId).collect(Collectors.toList());
+                Map<Long, LineFreightAddressRes> lineFreightAddress = manageService.findLineFreightAddress(lineFreightRateIds);
+                if (lineFreightAddress != null) {
+                    for (LineFreightAddressRes address : lineFreightAddress.values()) {
+                        BigDecimal decimal = amountMap.get(address.getId());
+                        if (decimal != null) {
+                            BigDecimal sum = address.getTransportPrice().multiply(decimal).setScale(2, RoundingMode.HALF_UP);
+                            actualAmount = actualAmount.add(sum);
+                        }
+                    }
+                }
+            }
+        }
+        return actualAmount;
+    }
+
     public Map<String, String> getDictData(String type) {
         Map<String, String> maps = new HashMap<>(NumberConstant.SIXTEEN);
         List<SysDictResDto> list = remoteSystemService.queryDictByType(type);
@@ -648,7 +691,7 @@ public class TransportServiceImpl implements TransportRemoteService {
     public List<RTruckMonitorVo> truckInTask(Long checkEntId) {
         //查询物流订单
         List<Long> orderIds = new ArrayList<>();
-        Map<String, Object> params = new HashMap<>(Global.NUMERICAL_SIXTEEN){{
+        Map<String, Object> params = new HashMap<>(Global.NUMERICAL_SIXTEEN) {{
             put("status", LogisticsOrderEnum.IN_TRANSIT.getCode());
             put("checkEntId", checkEntId);
         }};
@@ -662,7 +705,7 @@ public class TransportServiceImpl implements TransportRemoteService {
 
         //查询运单
         List<RTruckMonitorVo> trucks = new ArrayList<>();
-        params = new HashMap<>(Global.NUMERICAL_SIXTEEN){{
+        params = new HashMap<>(Global.NUMERICAL_SIXTEEN) {{
             put("busStatus", Global.NUMERICAL_THREE);
             put("lOrderIds", orderIds);
         }};
@@ -673,13 +716,13 @@ public class TransportServiceImpl implements TransportRemoteService {
 
     /**
      * @param orderIds 物流订单ID集合
-     * @param ids 当前物流订单ID
+     * @param ids      当前物流订单ID
      * @desc 查询下级分包 物流订单
      * @author zk
      * @date 2023/10/8
      **/
     public void findLogisticsOrderChild(List<Long> orderIds, String ids) {
-        Map<String, Object> params = new HashMap<>(Global.NUMERICAL_SIXTEEN){{
+        Map<String, Object> params = new HashMap<>(Global.NUMERICAL_SIXTEEN) {{
             put("status", LogisticsOrderEnum.IN_TRANSIT.getCode());
             put("pid", ids);
         }};

+ 1 - 1
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/dto/LogisticsOrderFinishDto.java

@@ -33,7 +33,7 @@ public class LogisticsOrderFinishDto implements Serializable {
 
 
     /**
-     * 装卸货信息
+     * 线路信息
      */
     private List<LogisticsOrderLineFreightRateDto> lineFreightRate;
 

+ 5 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/KwtLogisticsConsignmentService.java

@@ -2202,6 +2202,11 @@ public class KwtLogisticsConsignmentService {
         return logisticsOrderConsignmentService.addLogisticsOrder(addLogisticsOrderParam);
     }
 
+    /**
+     * 物流订单-分包托运-v4.2
+     * @param logisticsOrderSubcontractDto
+     * @return
+     */
     public HttpResult logisticsOrderSubcontract(LogisticsOrderSubcontractDto logisticsOrderSubcontractDto) {
         return logisticsOrderConsignmentService.logisticsOrderSubcontract(logisticsOrderSubcontractDto);
     }

+ 54 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/KwtTransportCommonService.java

@@ -18,6 +18,8 @@ import com.sckw.core.utils.*;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.core.web.response.HttpResult;
+import com.sckw.manage.api.RemoteManageService;
+import com.sckw.manage.api.model.dto.res.LineFreightAddressRes;
 import com.sckw.mongo.enums.BusinessTypeEnum;
 import com.sckw.mongo.model.SckwLogisticsOrder;
 import com.sckw.order.api.dubbo.RemoteTradeOrderAmountService;
@@ -50,6 +52,7 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.ObjectUtils;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -74,6 +77,9 @@ public class KwtTransportCommonService {
     @DubboReference(version = "1.0.0", group = "design", check = false, timeout = 10000)
     RemoteContractService remoteContractService;
 
+    @DubboReference(version = "1.0.0", group = "design", check = false)
+    RemoteManageService manageService;
+
     @Autowired
     MessageUrlConfig messageUrlConfig;
 
@@ -93,6 +99,9 @@ public class KwtTransportCommonService {
     @Autowired
     public KwtLogisticsOrderContractMapper logisticsOrderContractMapper;
 
+    @Autowired
+    public KwtLogisticsOrderLineFreightRateMapper lineFreightRateMapper;
+
     @Autowired
     public KwtLogisticsOrderAddressMapper logisticsOrderAddressMapper;
 
@@ -726,6 +735,26 @@ public class KwtTransportCommonService {
                     WaybillCountVo waybillOrderCount = waybillOrderMapper.findWaybillOrderCount(map);
                     BigDecimal totalComplete = waybillOrderCount == null ? NumberConstant.ZERO_TWO : new BigDecimal(waybillOrderCount.getTotalComplete());
                     actualAmount = totalComplete.multiply(price);
+                } else if (DictEnum.CHARGING_TYPE_4.getValue().equals(billingMode)) {
+                    String lOrderId = logisticsOrderDTO.getLOrderId();
+                    List<KwtLogisticsOrderLineFreightRate> lineFreightRates = lineFreightRateMapper.selectList(new LambdaQueryWrapper<KwtLogisticsOrderLineFreightRate>()
+                            .eq(KwtLogisticsOrderLineFreightRate::getLOrderId, lOrderId)
+                            .eq(KwtLogisticsOrderLineFreightRate::getDelFlag, 0)
+                    );
+                    if (CollectionUtils.isNotEmpty(lineFreightRates)) {
+                        Map<Long, BigDecimal> amountMap = lineFreightRates.stream().collect(Collectors.toMap(KwtLogisticsOrderLineFreightRate::getLineFreightRateId, KwtLogisticsOrderLineFreightRate::getSettlementAmount));
+                        List<Long> lineFreightRateIds = lineFreightRates.stream().map(KwtLogisticsOrderLineFreightRate::getLineFreightRateId).collect(Collectors.toList());
+                        Map<Long, LineFreightAddressRes> lineFreightAddress = manageService.findLineFreightAddress(lineFreightRateIds);
+                        if (lineFreightAddress != null) {
+                            for (LineFreightAddressRes address : lineFreightAddress.values()) {
+                                BigDecimal decimal = amountMap.get(address.getId());
+                                if (decimal != null) {
+                                    BigDecimal sum = address.getTransportPrice().multiply(decimal).setScale(2, RoundingMode.HALF_UP);
+                                    actualAmount = actualAmount.add(sum);
+                                }
+                            }
+                        }
+                    }
                 }
                 logisticsOrderDTO.setDeductPrice(fineValue);
                 logisticsOrderDTO.setTaxMoney(actualAmount);
@@ -1505,6 +1534,9 @@ public class KwtTransportCommonService {
                 logisticsOrder.setUpdateTime(new Date());
                 logisticsOrder.setUpdateBy(LoginUserHolder.getUserId());
                 logisticsOrder.setIgnoreAmount(ignoreAmount);
+                if (DictEnum.CHARGING_TYPE_4.getValue().equals(logisticsOrder.getBillingMode())) {
+                    updateLogisticsOrderLineFreightRate(logisticsOrder, params);
+                }
                 logisticsOrderMapper.updateById(logisticsOrder);
                 //物流订单状态记录
                 updateLogisticOrderTrack(logisticsOrder.getId(), LogisticsOrderEnum.HAVE_FINISHED.getCode(), params.getRemark());
@@ -1580,6 +1612,28 @@ public class KwtTransportCommonService {
         return HttpResult.ok("托运订单-完结订单成功");
     }
 
+    /**
+     * 修改线路数据
+     *
+     * @param logisticsOrder
+     * @param params
+     */
+    private void updateLogisticsOrderLineFreightRate(KwtLogisticsOrder logisticsOrder, LogisticsOrderFinishDto params) {
+        Long orderId = logisticsOrder.getId();
+        List<LogisticsOrderLineFreightRateDto> lineFreightRate = params.getLineFreightRate();
+        lineFreightRate.forEach(dto -> {
+            Long lineFreightRateId = dto.getLineFreightRateId();
+            KwtLogisticsOrderLineFreightRate orderLineFreightRate = lineFreightRateMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderLineFreightRate>()
+                    .eq(KwtLogisticsOrderLineFreightRate::getLOrderId, orderId)
+                    .eq(KwtLogisticsOrderLineFreightRate::getLineFreightRateId, lineFreightRateId)
+            );
+            if (orderLineFreightRate != null) {
+                orderLineFreightRate.setSettlementAmount(dto.getAmount());
+                lineFreightRateMapper.updateById(orderLineFreightRate);
+            }
+        });
+    }
+
     private void updateTradeOrderAddressAmount(KwtLogisticsOrder logisticsOrder) {
         Long tOrderId = logisticsOrder.getTOrderId();
         if (!Objects.isNull(tOrderId)) {