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