Commit 370dc895 authored by lanbaoming's avatar lanbaoming

2024-06-21提交

parent 22776506
package cn.iocoder.yudao.framework.toolkit;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ZTestMapper extends BaseMapper<zTest> {
}
...@@ -661,8 +661,8 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order ...@@ -661,8 +661,8 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
if (freightCurrencyId.equals(it.getSeaFreightCurrency())) { if (freightCurrencyId.equals(it.getSeaFreightCurrency())) {
sR += " freightCurrencyId=it.getSeaFreightCurrency"; sR += " freightCurrencyId=it.getSeaFreightCurrency";
} else { } else {
sR += " freightCurrencyId"+freightCurrencyId sR += " freightCurrencyId" + freightCurrencyId
+"<>it.getSeaFreightCurrency"+it.getSeaFreightCurrency(); + "<>it.getSeaFreightCurrency" + it.getSeaFreightCurrency();
return sR; return sR;
} }
...@@ -672,9 +672,9 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order ...@@ -672,9 +672,9 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
} }
if (freightUnitId.equals(it.getSeaFreightVolume())) { if (freightUnitId.equals(it.getSeaFreightVolume())) {
sR+="freightUnitId=it.getSeaFreightVolume"; sR += "freightUnitId=it.getSeaFreightVolume";
} else { } else {
sR+="freightUnitId"+freightUnitId+"<>it.getSeaFreightVolume"+ sR += "freightUnitId" + freightUnitId + "<>it.getSeaFreightVolume" +
it.getSeaFreightVolume(); it.getSeaFreightVolume();
} }
return sR; return sR;
...@@ -727,7 +727,7 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order ...@@ -727,7 +727,7 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
currencyApi.getAllCurrency(); currencyApi.getAllCurrency();
List<ApplyInfoVO> applyInfoVOList = new ArrayList<>(); List<ApplyInfoVO> applyInfoVOList = new ArrayList<>();
for (OrderItemDO it : orderItemDOList) { for (OrderItemDO it : orderItemDOList) {
String sLog = getLog(it,freightFee,freightCurrencyId,freightUnitId); String sLog = getLog(it, freightFee, freightCurrencyId, freightUnitId);
// 只针对已入仓的品名进行加价处理 // 只针对已入仓的品名进行加价处理
if (Objects.nonNull(it.getWarehouseInInfoVO()) && if (Objects.nonNull(it.getWarehouseInInfoVO()) &&
it.getWarehouseInInfoVO().getCartonsNum() > 0) { it.getWarehouseInInfoVO().getCartonsNum() > 0) {
...@@ -956,12 +956,14 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order ...@@ -956,12 +956,14 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
return newOrderNo; return newOrderNo;
} }
//费用来源:1 订单计算 2 费用申请 3 特需费用
@Override @Override
public boolean addOrderReceivable(OrderDO orderDO, Integer type) { public boolean addOrderReceivable(OrderDO orderDO, Integer type) {
boolean isPayAdvanceException = false; boolean isPayAdvanceException = false;
// 查询订单已添加的费用类型 // 查询订单已添加的费用类型
List<ReceivableDO> receivableDOList = receivableService.list(new LambdaQueryWrapper<ReceivableDO>().eq(ReceivableDO::getOrderId, orderDO.getOrderId()).eq(ReceivableDO::getDeleted, false)); List<ReceivableDO> receivableDOList =
receivableService.list(
new LambdaQueryWrapper<ReceivableDO>().eq(ReceivableDO::getOrderId, orderDO.getOrderId()).eq(ReceivableDO::getDeleted, false));
// TODO 处理订单项 // TODO 处理订单项
CostVO costVO = JSONObject.parseObject(orderDO.getCost(), CostVO.class); CostVO costVO = JSONObject.parseObject(orderDO.getCost(), CostVO.class);
FeeDto premiumFeeDto = null; FeeDto premiumFeeDto = null;
...@@ -973,7 +975,8 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order ...@@ -973,7 +975,8 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
worthFeeDto = costVO.getFeeDtoList().stream().filter(fee -> Objects.equals(fee.getFeeType(), FeeTypeEnum.WORTH.getType())).findFirst().orElse(null); worthFeeDto = costVO.getFeeDtoList().stream().filter(fee -> Objects.equals(fee.getFeeType(), FeeTypeEnum.WORTH.getType())).findFirst().orElse(null);
} }
} }
List<OrderItemDO> itemDOList = orderItemMapper.selectList(new LambdaQueryWrapper<OrderItemDO>().eq(OrderItemDO::getOrderId, orderDO.getOrderId())); List<OrderItemDO> itemDOList =
orderItemMapper.selectList(new LambdaQueryWrapper<OrderItemDO>().eq(OrderItemDO::getOrderId, orderDO.getOrderId()));
if (CollectionUtil.isNotEmpty(receivableDOList)) { if (CollectionUtil.isNotEmpty(receivableDOList)) {
// TODO 处理保价费 // TODO 处理保价费
ReceivableDO premiumReceivable = receivableDOList.stream().filter(r -> r.getFeeType() == 6 && Objects.nonNull(r.getFeeSource()) && 1 == r.getFeeSource()).findFirst().orElse(null); ReceivableDO premiumReceivable = receivableDOList.stream().filter(r -> r.getFeeType() == 6 && Objects.nonNull(r.getFeeSource()) && 1 == r.getFeeSource()).findFirst().orElse(null);
...@@ -987,12 +990,13 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order ...@@ -987,12 +990,13 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
reqVO.setPaymentUser(String.valueOf(orderDO.getDrawee() != 3 ? orderDO.getDrawee() : orderQueryService.customDrawee(orderDO, 6))); reqVO.setPaymentUser(String.valueOf(orderDO.getDrawee() != 3 ? orderDO.getDrawee() : orderQueryService.customDrawee(orderDO, 6)));
reqVO.setIsPayAdvance(0); reqVO.setIsPayAdvance(0);
reqVO.setCollectionType(4);// 到付 reqVO.setCollectionType(4);// 到付
reqVO.setFeeType(6); reqVO.setFeeType(6);//保价费
reqVO.setFeeSource(1); reqVO.setFeeSource(1);//费用来源,订单计算
if (Objects.nonNull(premiumFeeDto)) { if (Objects.nonNull(premiumFeeDto)) {
reqVO.setAmountWorth(Objects.isNull(worthFeeDto) ? BigDecimal.ZERO : worthFeeDto.getAmount()); reqVO.setAmountWorth(Objects.isNull(worthFeeDto) ? BigDecimal.ZERO : worthFeeDto.getAmount());
reqVO.setUnitPrice(premiumFeeDto.getAmount().setScale(0, RoundingMode.HALF_UP)); reqVO.setUnitPrice(premiumFeeDto.getAmount().setScale(0, RoundingMode.HALF_UP));
reqVO.setTotalAmount(premiumFeeDto.getAmount().setScale(0, RoundingMode.HALF_UP)); reqVO.setTotalAmount(
premiumFeeDto.getAmount().setScale(0, RoundingMode.HALF_UP));
reqVO.setTaxAmount(premiumFeeDto.getAmount().setScale(0, RoundingMode.HALF_UP)); reqVO.setTaxAmount(premiumFeeDto.getAmount().setScale(0, RoundingMode.HALF_UP));
reqVO.setCurrencyId(Long.valueOf(premiumFeeDto.getCurrencyId())); reqVO.setCurrencyId(Long.valueOf(premiumFeeDto.getCurrencyId()));
receivableService.createReceivable(reqVO); receivableService.createReceivable(reqVO);
...@@ -1000,20 +1004,24 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order ...@@ -1000,20 +1004,24 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
} }
} else { } else {
// TODO 已经付款的应收单不允许修改 // TODO 已经付款的应收单不允许修改
if (Objects.nonNull(premiumFeeDto) && premiumReceivable.getState() == 0) { if (Objects.nonNull(premiumFeeDto) &&
premiumReceivable.getState() == 0) {
premiumReceivable.setTitleZh(null); premiumReceivable.setTitleZh(null);
premiumReceivable.setTitleEn(null); premiumReceivable.setTitleEn(null);
premiumReceivable.setPaymentUser(String.valueOf(orderDO.getDrawee() != 3 ? orderDO.getDrawee() : orderQueryService.customDrawee(orderDO, 6))); premiumReceivable.setPaymentUser(String.valueOf(orderDO.getDrawee() != 3 ? orderDO.getDrawee() : orderQueryService.customDrawee(orderDO, 6)));
premiumReceivable.setAmountWorth(Objects.isNull(worthFeeDto) ? BigDecimal.ZERO : worthFeeDto.getAmount()); premiumReceivable.setAmountWorth(Objects.isNull(worthFeeDto) ? BigDecimal.ZERO : worthFeeDto.getAmount());
premiumReceivable.setUnitPrice(premiumFeeDto.getAmount().setScale(0, RoundingMode.HALF_UP)); premiumReceivable.setUnitPrice(premiumFeeDto.getAmount().setScale(0, RoundingMode.HALF_UP));
premiumReceivable.setTotalAmount(premiumFeeDto.getAmount().setScale(0, RoundingMode.HALF_UP)); premiumReceivable.setTotalAmount(
premiumFeeDto.getAmount().setScale(0, RoundingMode.HALF_UP));
premiumReceivable.setTaxAmount(premiumFeeDto.getAmount().setScale(0, RoundingMode.HALF_UP)); premiumReceivable.setTaxAmount(premiumFeeDto.getAmount().setScale(0, RoundingMode.HALF_UP));
premiumReceivable.setCurrencyId(Long.valueOf(premiumFeeDto.getCurrencyId())); premiumReceivable.setCurrencyId(Long.valueOf(premiumFeeDto.getCurrencyId()));
premiumReceivable.setFeeSource(1); premiumReceivable.setFeeSource(1);//费用来源,订单计算
try { try {
receivableService.updateReceivableById(premiumReceivable); receivableService.updateReceivableById(premiumReceivable);
} catch (Exception e) { } catch (Exception e) {
log.error(String.format("订单号[%s]的保价费应收单更新失败,失败原因:%s", orderDO.getOrderNo(), e.getMessage())); log.error(String.format("订单号[%s]的保价费应收单更新失败,失败原因:%s",
orderDO.getOrderNo(),
e.getMessage()));
} }
} }
} }
...@@ -1044,7 +1052,12 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order ...@@ -1044,7 +1052,12 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
continue; continue;
} }
} }
this.createReceivable(orderDO, orderItemDO, 1, orderItemDO.getOneSeaFreight(), orderItemDO.getSeaFreight(), orderItemDO.getSeaFreightCurrency()); //运费
this.createReceivable(orderDO,
orderItemDO, 1,
orderItemDO.getOneSeaFreight(),
orderItemDO.getSeaFreight(),
orderItemDO.getSeaFreightCurrency());
} }
} else { } else {
if (freightReceivable.getState() == 0) { if (freightReceivable.getState() == 0) {
...@@ -1055,7 +1068,8 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order ...@@ -1055,7 +1068,8 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
freightReceivable.setPaymentUser(String.valueOf(orderDO.getDrawee() != 3 ? orderDO.getDrawee() : orderQueryService.customDrawee(orderDO, 1))); freightReceivable.setPaymentUser(String.valueOf(orderDO.getDrawee() != 3 ? orderDO.getDrawee() : orderQueryService.customDrawee(orderDO, 1)));
freightReceivable.setAmountWorth(orderItemDO.getWorth()); freightReceivable.setAmountWorth(orderItemDO.getWorth());
freightReceivable.setUnitPrice(orderItemDO.getOneSeaFreight()); freightReceivable.setUnitPrice(orderItemDO.getOneSeaFreight());
freightReceivable.setTotalAmount(orderItemDO.getSeaFreight().setScale(0, RoundingMode.HALF_UP)); freightReceivable.setTotalAmount(
orderItemDO.getSeaFreight().setScale(0, RoundingMode.HALF_UP));
freightReceivable.setTaxAmount(orderItemDO.getSeaFreight().setScale(0, RoundingMode.HALF_UP)); freightReceivable.setTaxAmount(orderItemDO.getSeaFreight().setScale(0, RoundingMode.HALF_UP));
freightReceivable.setFeeSource(1); freightReceivable.setFeeSource(1);
if (Objects.isNull(orderItemDO.getWarehouseInInfoVO()) || orderItemDO.getWarehouseInInfoVO().getCartonsNum() == 0) { if (Objects.isNull(orderItemDO.getWarehouseInInfoVO()) || orderItemDO.getWarehouseInInfoVO().getCartonsNum() == 0) {
...@@ -1077,9 +1091,11 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order ...@@ -1077,9 +1091,11 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
} }
} }
} }
ReceivableDO clearanceFeeReceivable = receivableDOList.stream().filter(r -> r.getFeeType() == 2 && ReceivableDO clearanceFeeReceivable =
receivableDOList.stream().filter(r -> r.getFeeType() == 2 &&
Objects.nonNull(r.getFeeSource()) && 1 == r.getFeeSource() && Objects.equals(r.getOrderItemId(), Objects.nonNull(r.getFeeSource()) && 1 == r.getFeeSource() && Objects.equals(r.getOrderItemId(),
orderItemDO.getOrderItemId())).findFirst().orElse(null); orderItemDO.getOrderItemId())).findFirst().orElse(null);
if (orderItemDO.getCharging() == 0) { if (orderItemDO.getCharging() == 0) {
// 清关费 // 清关费
if (Objects.isNull(clearanceFeeReceivable)) { if (Objects.isNull(clearanceFeeReceivable)) {
...@@ -1126,9 +1142,12 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order ...@@ -1126,9 +1142,12 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
} }
clearanceFeeReceivable.setAmountWorth(orderItemDO.getWorth()); clearanceFeeReceivable.setAmountWorth(orderItemDO.getWorth());
clearanceFeeReceivable.setUnitPrice(orderItemDO.getOneClearanceFreight()); clearanceFeeReceivable.setUnitPrice(orderItemDO.getOneClearanceFreight());
clearanceFeeReceivable.setTotalAmount(orderItemDO.getClearanceFreight().setScale(0, RoundingMode.HALF_UP)); clearanceFeeReceivable.setTotalAmount(
clearanceFeeReceivable.setTaxAmount(orderItemDO.getClearanceFreight().setScale(0, RoundingMode.HALF_UP)); orderItemDO.getClearanceFreight().setScale(0, RoundingMode.HALF_UP));
clearanceFeeReceivable.setCurrencyId(Long.valueOf(orderItemDO.getClearanceFreightCurrency())); clearanceFeeReceivable.setTaxAmount(
orderItemDO.getClearanceFreight().setScale(0, RoundingMode.HALF_UP));
clearanceFeeReceivable.setCurrencyId(
Long.valueOf(orderItemDO.getClearanceFreightCurrency()));
try { try {
receivableService.updateReceivableById(clearanceFeeReceivable); receivableService.updateReceivableById(clearanceFeeReceivable);
} catch (Exception e) { } catch (Exception e) {
...@@ -1202,8 +1221,10 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order ...@@ -1202,8 +1221,10 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
* @param totalAmount 总额 * @param totalAmount 总额
* @param currencyId 货币ID * @param currencyId 货币ID
*/ */
private void createReceivable(OrderDO orderDO, OrderItemDO orderItemDO, Integer feeType, BigDecimal private void createReceivable(OrderDO orderDO,
unitPrice, BigDecimal totalAmount, Integer currencyId) { OrderItemDO orderItemDO,
Integer feeType, BigDecimal
unitPrice, BigDecimal totalAmount, Integer currencyId) {
if (Objects.nonNull(orderItemDO.getWarehouseInInfoVO()) && orderItemDO.getWarehouseInInfoVO().getCartonsNum() > 0) { if (Objects.nonNull(orderItemDO.getWarehouseInInfoVO()) && orderItemDO.getWarehouseInInfoVO().getCartonsNum() > 0) {
if (Objects.isNull(orderItemDO.getIsPayAdvance())) { if (Objects.isNull(orderItemDO.getIsPayAdvance())) {
// TODO 这里来生成应收的都不可能为0, 在这里兼容可能发生的插件查询结果导致null值报空,默认给到付状态 // TODO 这里来生成应收的都不可能为0, 在这里兼容可能发生的插件查询结果导致null值报空,默认给到付状态
...@@ -1239,8 +1260,11 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order ...@@ -1239,8 +1260,11 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
} }
reqVO.setAmountWorth(orderItemDO.getWorth()); reqVO.setAmountWorth(orderItemDO.getWorth());
reqVO.setUnitPrice(unitPrice); reqVO.setUnitPrice(unitPrice);
reqVO.setTotalAmount(totalAmount.setScale(0, RoundingMode.HALF_UP)); //四舍五入取整数
reqVO.setTaxAmount(totalAmount.setScale(0, RoundingMode.HALF_UP)); reqVO.setTotalAmount(totalAmount.setScale(0,
RoundingMode.HALF_UP));
reqVO.setTaxAmount(totalAmount.setScale(0,
RoundingMode.HALF_UP));
reqVO.setCurrencyId(Long.valueOf(currencyId)); reqVO.setCurrencyId(Long.valueOf(currencyId));
receivableService.createReceivable(reqVO); receivableService.createReceivable(reqVO);
} }
...@@ -2144,6 +2168,7 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order ...@@ -2144,6 +2168,7 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
//14 是批量加价 //14 是批量加价
//15 是费用计算
public void costCalculation(String userId, public void costCalculation(String userId,
OrderDO orderDO, OrderDO orderDO,
Long consignorCustomerId, Long consignorCustomerId,
...@@ -2152,6 +2177,8 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order ...@@ -2152,6 +2177,8 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
Long consigneeCustomerContactsId, Long consigneeCustomerContactsId,
List<OrderItemDO> orderItemDOList, List<OrderItemDO> orderItemDOList,
Integer type) { Integer type) {
//2023-7月之前应收金额没有按四舍五入取整,之后都是按四舍五入取整处理的
//lanbm 2024-06-20 添加注释说明逻辑
LogisticsInfoDto logisticsInfoDto = LogisticsInfoDto logisticsInfoDto =
warehouseLineMapper.getStartInfoAndDestInfoByLineId( warehouseLineMapper.getStartInfoAndDestInfoByLineId(
...@@ -2213,10 +2240,12 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order ...@@ -2213,10 +2240,12 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
orderDO.setVWeight(vWeight); orderDO.setVWeight(vWeight);
} else { } else {
// 当订单开始入仓时,对订单进行原始重泡货基数初始化 // 当订单开始入仓时,对订单进行原始重泡货基数初始化
if (Objects.isNull(orderDO.getOrgWeightUnit()) || orderDO.getOrgWeightUnit().compareTo(BigDecimal.ZERO) == 0) { if (Objects.isNull(orderDO.getOrgWeightUnit()) ||
orderDO.getOrgWeightUnit().compareTo(BigDecimal.ZERO) == 0) {
orderDO.setOrgWeightUnit(orgZhongPaoBestVO.getZhongEdge()); orderDO.setOrgWeightUnit(orgZhongPaoBestVO.getZhongEdge());
} }
if (Objects.isNull(orderDO.getOrgVolumeUnit()) || orderDO.getOrgVolumeUnit().compareTo(BigDecimal.ZERO) == 0) { if (Objects.isNull(orderDO.getOrgVolumeUnit()) ||
orderDO.getOrgVolumeUnit().compareTo(BigDecimal.ZERO) == 0) {
orderDO.setOrgVolumeUnit(orgZhongPaoBestVO.getPaoEdge()); orderDO.setOrgVolumeUnit(orgZhongPaoBestVO.getPaoEdge());
} }
// 保存当前计价使用的 // 保存当前计价使用的
...@@ -2251,40 +2280,61 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order ...@@ -2251,40 +2280,61 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
// 新运费和清关费的金额与老运费和清关费的金额变动 // 新运费和清关费的金额与老运费和清关费的金额变动
BigDecimal oldFreightAndClearanceFee = BigDecimal.ZERO; BigDecimal oldFreightAndClearanceFee = BigDecimal.ZERO;
BigDecimal newFreightAndClearanceFee = BigDecimal.ZERO; BigDecimal newFreightAndClearanceFee = BigDecimal.ZERO;
if (StringUtils.isNotBlank(orderDO.getCost())) { if (StringUtils.isNotBlank(orderDO.getCost())) {
CostVO oldCostVO = JSONObject.parseObject(orderDO.getCost(), CostVO.class); CostVO oldCostVO = JSONObject.parseObject(orderDO.getCost(),
CostVO.class);
List<FeeDto> oldFeeDtoList = oldCostVO.getFeeDtoList(); List<FeeDto> oldFeeDtoList = oldCostVO.getFeeDtoList();
Map<Long, ExchangeRateRespDTO> oldExchangeRateRespDTOMap = null; Map<Long, ExchangeRateRespDTO> oldExchangeRateRespDTOMap = null;
Map<Long, ExchangeRateRespDTO> newExchangeRateRespDTOMap = null; Map<Long, ExchangeRateRespDTO> newExchangeRateRespDTOMap = null;
if (CollectionUtil.isNotEmpty(oldFeeDtoList) && CollectionUtil.isNotEmpty(newFeeDtoList)) { if (CollectionUtil.isNotEmpty(oldFeeDtoList) &&
Set<Long> oldCurrencyIdList = oldFeeDtoList.stream().filter(feeDto -> Objects.equals(feeDto.getFeeType(), FeeTypeEnum.FREIGHT.getType()) || Objects.equals(feeDto.getFeeType(), FeeTypeEnum.CLEARANCE_FEE.getType())).map(FeeDto::getCurrencyId).map(c -> Long.parseLong(String.valueOf(c))).collect(Collectors.toSet()); CollectionUtil.isNotEmpty(newFeeDtoList)) {
Set<Long> newCurrencyIdList = newFeeDtoList.stream().filter(feeDto -> Objects.equals(feeDto.getFeeType(), FeeTypeEnum.FREIGHT.getType()) || Objects.equals(feeDto.getFeeType(), FeeTypeEnum.CLEARANCE_FEE.getType())).map(FeeDto::getCurrencyId).map(c -> Long.parseLong(String.valueOf(c))).collect(Collectors.toSet());
if (type == 10 && (oldCurrencyIdList.size() > 1 || newCurrencyIdList.size() > 1)) { Set<Long> oldCurrencyIdList = oldFeeDtoList.stream().filter(
List<ExchangeRateRespDTO> oldExchangeRateRespDTOList = currencyApi.getCurrencyRateList(oldCurrencyIdList, 1L); feeDto -> Objects.equals(feeDto.getFeeType(),
FeeTypeEnum.FREIGHT.getType()) || Objects.equals(feeDto.getFeeType(), FeeTypeEnum.CLEARANCE_FEE.getType())).map(FeeDto::getCurrencyId).map(c -> Long.parseLong(String.valueOf(c))).collect(Collectors.toSet());
Set<Long> newCurrencyIdList = newFeeDtoList.stream().filter(
feeDto -> Objects.equals(feeDto.getFeeType(),
FeeTypeEnum.FREIGHT.getType()) || Objects.equals(feeDto.getFeeType(), FeeTypeEnum.CLEARANCE_FEE.getType())).map(FeeDto::getCurrencyId).map(c -> Long.parseLong(String.valueOf(c))).collect(Collectors.toSet());
if (type == 10 && (oldCurrencyIdList.size() > 1 ||
newCurrencyIdList.size() > 1)) {
List<ExchangeRateRespDTO> oldExchangeRateRespDTOList =
currencyApi.getCurrencyRateList(oldCurrencyIdList,
1L);
if (CollectionUtil.isNotEmpty(oldExchangeRateRespDTOList)) { if (CollectionUtil.isNotEmpty(oldExchangeRateRespDTOList)) {
oldExchangeRateRespDTOMap = oldExchangeRateRespDTOList.stream().collect(Collectors.toMap(ExchangeRateRespDTO::getSourceCurrencyId, v -> v, (v1, v2) -> v2)); oldExchangeRateRespDTOMap =
oldExchangeRateRespDTOList.stream().collect(Collectors.toMap(ExchangeRateRespDTO::getSourceCurrencyId, v -> v, (v1, v2) -> v2));
} }
List<ExchangeRateRespDTO> newExchangeRateRespDTOList = currencyApi.getCurrencyRateList(newCurrencyIdList, 1L); List<ExchangeRateRespDTO> newExchangeRateRespDTOList =
currencyApi.getCurrencyRateList(newCurrencyIdList,
1L);
if (CollectionUtil.isNotEmpty(newExchangeRateRespDTOList)) { if (CollectionUtil.isNotEmpty(newExchangeRateRespDTOList)) {
newExchangeRateRespDTOMap = newExchangeRateRespDTOList.stream().collect(Collectors.toMap(ExchangeRateRespDTO::getSourceCurrencyId, v -> v, (v1, v2) -> v2)); newExchangeRateRespDTOMap = newExchangeRateRespDTOList.stream().collect(Collectors.toMap(ExchangeRateRespDTO::getSourceCurrencyId, v -> v, (v1, v2) -> v2));
} }
} }
} }
if (CollectionUtil.isNotEmpty(oldFeeDtoList)) { if (CollectionUtil.isNotEmpty(oldFeeDtoList)) {
Map<Integer, CurrencyRespDTO> currencyRespDTOMap = currencyApi.getAllCurrency(); Map<Integer, CurrencyRespDTO> currencyRespDTOMap =
currencyApi.getAllCurrency();
for (FeeDto feeDto : oldFeeDtoList) { for (FeeDto feeDto : oldFeeDtoList) {
if (type == 10 && (Objects.equals(feeDto.getFeeType(), FeeTypeEnum.FREIGHT.getType()) || Objects.equals(feeDto.getFeeType(), FeeTypeEnum.CLEARANCE_FEE.getType()))) { if (type == 10 && (Objects.equals(feeDto.getFeeType(), FeeTypeEnum.FREIGHT.getType()) || Objects.equals(feeDto.getFeeType(), FeeTypeEnum.CLEARANCE_FEE.getType()))) {
if (Objects.nonNull(oldExchangeRateRespDTOMap)) { if (Objects.nonNull(oldExchangeRateRespDTOMap)) {
ExchangeRateRespDTO exchangeRateRespDTO = oldExchangeRateRespDTOMap.get(Long.parseLong(String.valueOf(feeDto.getCurrencyId()))); ExchangeRateRespDTO exchangeRateRespDTO =
oldExchangeRateRespDTOMap.get(Long.parseLong(String.valueOf(feeDto.getCurrencyId())));
if (Objects.isNull(exchangeRateRespDTO)) { if (Objects.isNull(exchangeRateRespDTO)) {
throw exception(EXCHANGE_RATE_NOT_EXISTS_PARAM, currencyRespDTOMap.get(feeDto.getCurrencyId()).getFuhao(), currencyRespDTOMap.get(1).getFuhao()); throw exception(EXCHANGE_RATE_NOT_EXISTS_PARAM, currencyRespDTOMap.get(feeDto.getCurrencyId()).getFuhao(), currencyRespDTOMap.get(1).getFuhao());
} }
oldFreightAndClearanceFee = oldFreightAndClearanceFee.add(feeDto.getAmount().multiply(exchangeRateRespDTO.getCurrencyRate())); oldFreightAndClearanceFee =
oldFreightAndClearanceFee.add(feeDto.getAmount().multiply(exchangeRateRespDTO.getCurrencyRate()));
} else { } else {
oldFreightAndClearanceFee = oldFreightAndClearanceFee.add(feeDto.getAmount()); oldFreightAndClearanceFee =
oldFreightAndClearanceFee.add(feeDto.getAmount());
} }
} }
if (!Objects.equals(feeDto.getFeeType(), FeeTypeEnum.FREIGHT.getType()) && !Objects.equals(feeDto.getFeeType(), FeeTypeEnum.CLEARANCE_FEE.getType()) && !Objects.equals(feeDto.getFeeType(), FeeTypeEnum.INSURANCE_FEE.getType()) && !Objects.equals(feeDto.getFeeType(), FeeTypeEnum.WORTH.getType())) { if (!Objects.equals(feeDto.getFeeType(), FeeTypeEnum.FREIGHT.getType()) &&
!Objects.equals(feeDto.getFeeType(), FeeTypeEnum.CLEARANCE_FEE.getType())
&& !Objects.equals(feeDto.getFeeType(), FeeTypeEnum.INSURANCE_FEE.getType()) &&
!Objects.equals(feeDto.getFeeType(), FeeTypeEnum.WORTH.getType())) {
newFeeDtoList.add(feeDto); newFeeDtoList.add(feeDto);
} }
} }
...@@ -2340,10 +2390,14 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order ...@@ -2340,10 +2390,14 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
} }
// } // }
newCostVO.setFeeDtoList(newFeeDtoList); newCostVO.setFeeDtoList(newFeeDtoList);
newCostVO.setTotalVolume(newOrderItemDOList.stream().map(OrderItemDO::getVolume).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add)); newCostVO.setTotalVolume(newOrderItemDOList.stream().map(
newCostVO.setTotalWeight(newOrderItemDOList.stream().map(OrderItemDO::getWeight).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add)); OrderItemDO::getVolume).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
newCostVO.setTotalNum(newOrderItemDOList.stream().mapToInt(OrderItemDO::getNum).filter(Objects::nonNull).sum()); newCostVO.setTotalWeight(newOrderItemDOList.stream().map(
newCostVO.setTotalQuantity(newOrderItemDOList.stream().mapToInt(OrderItemDO::getQuantity).filter(Objects::nonNull).sum()); OrderItemDO::getWeight).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
newCostVO.setTotalNum(newOrderItemDOList.stream().mapToInt(
OrderItemDO::getNum).filter(Objects::nonNull).sum());
newCostVO.setTotalQuantity(newOrderItemDOList.stream().mapToInt(
OrderItemDO::getQuantity).filter(Objects::nonNull).sum());
if (typeSet.size() > 0) { if (typeSet.size() > 0) {
...@@ -2486,9 +2540,11 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order ...@@ -2486,9 +2540,11 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
} else { } else {
if (type == 6 && Objects.equals(orderDO.getInWarehouseState(), OrderWarehouseInStatusEnum.warehouse_finished.getValue())) { if (type == 6 && Objects.equals(orderDO.getInWarehouseState(), OrderWarehouseInStatusEnum.warehouse_finished.getValue())) {
// 处理未报价时,如果是已入仓产品去生成应收 // 处理未报价时,如果是已入仓产品去生成应收
isPayAdvanceException = this.addOrderReceivable(orderDO, 1); isPayAdvanceException = this.addOrderReceivable(orderDO,
1);
} else { } else {
isPayAdvanceException = this.addOrderReceivable(orderDO, 2); isPayAdvanceException = this.addOrderReceivable(orderDO,
2);
} }
} }
} }
......
...@@ -6271,7 +6271,9 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl ...@@ -6271,7 +6271,9 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
OrderConsigneeDO orderConsigneeDO = OrderConsigneeDO orderConsigneeDO =
orderConsigneeService.getOne(new LambdaQueryWrapper<OrderConsigneeDO>().eq(OrderConsigneeDO::getOrderId, orderDO.getOrderId()).orderByDesc(OrderConsigneeDO::getId).last("limit 1")); orderConsigneeService.getOne(new LambdaQueryWrapper<OrderConsigneeDO>().eq(OrderConsigneeDO::getOrderId, orderDO.getOrderId()).orderByDesc(OrderConsigneeDO::getId).last("limit 1"));
// 更新所属客户经理(业务员) // 更新所属客户经理(业务员)
if (Objects.isNull(orderDO.getParentOrderId()) || orderDO.getParentOrderId() == 0 || orderDO.getSplitSeparateOrder()) { if (Objects.isNull(orderDO.getParentOrderId()) ||
orderDO.getParentOrderId() == 0 ||
orderDO.getSplitSeparateOrder()) {
// 拆单子订单不执行客户经理分配规则,以原单为主 // 拆单子订单不执行客户经理分配规则,以原单为主
if (Objects.nonNull(orderDO.getCustomerId()) && orderDO.getCustomerId() > 0) { if (Objects.nonNull(orderDO.getCustomerId()) && orderDO.getCustomerId() > 0) {
addOrderCustomerService(orderDO, addOrderCustomerService(orderDO,
...@@ -6279,8 +6281,14 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl ...@@ -6279,8 +6281,14 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
orderDO.getCustomerId()) ? 1 : 2); orderDO.getCustomerId()) ? 1 : 2);
} }
} }
orderBusinessService.costCalculation(userId, orderDO, orderConsignorDO.getCustomerId(), orderConsigneeDO.getCustomerId(),
orderConsignorDO.getCustomerContactsId(), orderConsigneeDO.getCustomerContactsId(), orderItemDOList, 15); orderBusinessService.costCalculation(userId,
orderDO,
orderConsignorDO.getCustomerId(),
orderConsigneeDO.getCustomerId(),
orderConsignorDO.getCustomerContactsId(),
orderConsigneeDO.getCustomerContactsId(),
orderItemDOList, 15);
} }
@Override @Override
...@@ -6297,8 +6305,14 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl ...@@ -6297,8 +6305,14 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
addOrderCustomerService(orderDO, Objects.equals(orderConsignorDO.getCustomerId(), orderDO.getCustomerId()) ? 1 : 2); addOrderCustomerService(orderDO, Objects.equals(orderConsignorDO.getCustomerId(), orderDO.getCustomerId()) ? 1 : 2);
} }
} }
orderBusinessService.costCalculation(userId, orderDO, orderConsignorDO.getCustomerId(), orderConsigneeDO.getCustomerId(), orderBusinessService.costCalculation(userId,
orderConsignorDO.getCustomerContactsId(), orderConsigneeDO.getCustomerContactsId(), orderItemDOList, 10); orderDO,
orderConsignorDO.getCustomerId(),
orderConsigneeDO.getCustomerId(),
orderConsignorDO.getCustomerContactsId(),
orderConsigneeDO.getCustomerContactsId(),
orderItemDOList,
10);
} }
@Override @Override
......
...@@ -353,9 +353,12 @@ public class OrderSpecialNeedServiceImpl extends AbstractService<OrderSpecialNee ...@@ -353,9 +353,12 @@ public class OrderSpecialNeedServiceImpl extends AbstractService<OrderSpecialNee
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void buildSpecialReceivable(Long orderId, int type) { public void buildSpecialReceivable(Long orderId, int type) {
List<OrderSpecialNeedDO> orderSpecialNeedDOS = orderSpecialNeedMapper.selectList(OrderSpecialNeedDO::getOrderId, orderId); List<OrderSpecialNeedDO> orderSpecialNeedDOS =
orderSpecialNeedMapper.selectList(OrderSpecialNeedDO::getOrderId,
orderId);
if (CollectionUtil.isNotEmpty(orderSpecialNeedDOS)) { if (CollectionUtil.isNotEmpty(orderSpecialNeedDOS)) {
orderSpecialNeedDOS.stream().filter(item -> item.getTransFee().compareTo(BigDecimal.ZERO) == 1).forEach(item -> build(item, type)); orderSpecialNeedDOS.stream().filter(
item -> item.getTransFee().compareTo(BigDecimal.ZERO) == 1).forEach(item -> build(item, type));
} }
} }
......
...@@ -1074,9 +1074,7 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI ...@@ -1074,9 +1074,7 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public boolean finishWarehouseIn(OrderWarehouseInFinishReqVO finishReqVO) { public boolean finishWarehouseIn(OrderWarehouseInFinishReqVO finishReqVO) {
String msg = "完成入仓"; String msg = "完成入仓";
Long orderId = finishReqVO.getOrderId(); Long orderId = finishReqVO.getOrderId();
OrderDO orderDO = orderService.getById(orderId); OrderDO orderDO = orderService.getById(orderId);
if (orderDO == null) { if (orderDO == null) {
...@@ -1283,6 +1281,7 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI ...@@ -1283,6 +1281,7 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
boolean firstRucang = orderDO.getRucangTime() == null; boolean firstRucang = orderDO.getRucangTime() == null;
if (firstRucang) { if (firstRucang) {
//在下面的函数中弯沉费用计算 lanbm 2024-06-20 添加注释
orderService.finishOrderWarehouseIn(orderDO.getOrderId()); orderService.finishOrderWarehouseIn(orderDO.getOrderId());
} else { } else {
orderService.finishOrderWarehouseInUpdate(orderDO.getOrderId()); orderService.finishOrderWarehouseInUpdate(orderDO.getOrderId());
......
...@@ -138,7 +138,11 @@ public class OrderCommissionPayableJob implements JobHandler { ...@@ -138,7 +138,11 @@ public class OrderCommissionPayableJob implements JobHandler {
return ""; return "";
} }
private void addCommissionPayable(CommissionPayableDO commissionPayable, OrderItemDO orderItemDO, OrderDO orderDO, Integer feeType, BigDecimal amount) { private void addCommissionPayable(CommissionPayableDO commissionPayable,
OrderItemDO orderItemDO,
OrderDO orderDO,
Integer feeType,
BigDecimal amount) {
commissionPayable.setOrderId(orderItemDO.getOrderId()); commissionPayable.setOrderId(orderItemDO.getOrderId());
commissionPayable.setOrderNo(orderItemDO.getOrderNo()); commissionPayable.setOrderNo(orderItemDO.getOrderNo());
commissionPayable.setPayableNo(orderDO.getContainerNumber()); commissionPayable.setPayableNo(orderDO.getContainerNumber());
...@@ -168,7 +172,8 @@ public class OrderCommissionPayableJob implements JobHandler { ...@@ -168,7 +172,8 @@ public class OrderCommissionPayableJob implements JobHandler {
commissionPayable.setTotalAmount(amount.multiply(orderItemDO.getChargeVolume()).setScale(2, RoundingMode.HALF_UP)); commissionPayable.setTotalAmount(amount.multiply(orderItemDO.getChargeVolume()).setScale(2, RoundingMode.HALF_UP));
} else if (StringUtils.equals("kg", unitDO.getFuhao())) { } else if (StringUtils.equals("kg", unitDO.getFuhao())) {
// 重量 // 重量
commissionPayable.setTotalAmount(amount.multiply(orderItemDO.getChargeWeight()).setScale(2, RoundingMode.HALF_UP)); commissionPayable.setTotalAmount(
amount.multiply(orderItemDO.getChargeWeight()).setScale(2, RoundingMode.HALF_UP));
} else if (StringUtils.equals("a", unitDO.getFuhao())) { } else if (StringUtils.equals("a", unitDO.getFuhao())) {
// 数量 // 数量
commissionPayable.setTotalAmount(amount.multiply(orderItemDO.getChargeQuantity()).setScale(2, RoundingMode.HALF_UP)); commissionPayable.setTotalAmount(amount.multiply(orderItemDO.getChargeQuantity()).setScale(2, RoundingMode.HALF_UP));
......
...@@ -22,8 +22,10 @@ import cn.iocoder.yudao.module.ecw.dal.dataobject.currency.CurrencyDO; ...@@ -22,8 +22,10 @@ import cn.iocoder.yudao.module.ecw.dal.dataobject.currency.CurrencyDO;
import cn.iocoder.yudao.module.customer.dto.CustomerCommissionDto; import cn.iocoder.yudao.module.customer.dto.CustomerCommissionDto;
import cn.iocoder.yudao.module.customer.dto.CustomerCommissionQueryDto; import cn.iocoder.yudao.module.customer.dto.CustomerCommissionQueryDto;
import cn.iocoder.yudao.module.customer.service.customer.commission.CustomerCommissionInfoService; import cn.iocoder.yudao.module.customer.service.customer.commission.CustomerCommissionInfoService;
import cn.iocoder.yudao.module.product.dal.dataobject.coupon.zTest3;
import cn.iocoder.yudao.module.product.dal.dataobject.product.*; import cn.iocoder.yudao.module.product.dal.dataobject.product.*;
import cn.iocoder.yudao.module.ecw.dal.dataobject.unit.UnitDO; import cn.iocoder.yudao.module.ecw.dal.dataobject.unit.UnitDO;
import cn.iocoder.yudao.module.product.dal.mysql.coupon.ZTestMapper3;
import cn.iocoder.yudao.module.product.dal.mysql.product.ProductAttrMapper; import cn.iocoder.yudao.module.product.dal.mysql.product.ProductAttrMapper;
import cn.iocoder.yudao.module.ecw.service.currency.CurrencyService; import cn.iocoder.yudao.module.ecw.service.currency.CurrencyService;
import cn.iocoder.yudao.module.product.dal.mysql.product.ProductPricePackagingMapper; import cn.iocoder.yudao.module.product.dal.mysql.product.ProductPricePackagingMapper;
...@@ -47,6 +49,7 @@ import org.apache.commons.lang3.StringUtils; ...@@ -47,6 +49,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.util.*; import java.util.*;
...@@ -79,13 +82,25 @@ public class ProdCostCalculation { ...@@ -79,13 +82,25 @@ public class ProdCostCalculation {
private final WarehouseLineMapper warehouseLineMapper; private final WarehouseLineMapper warehouseLineMapper;
private final CustomerCommissionInfoService customerCommissionInfoService; private final CustomerCommissionInfoService customerCommissionInfoService;
private final DictDataApi dictDataApi; private final DictDataApi dictDataApi;
private final LineChannelPackagingService lineChannelPackagingService; private final LineChannelPackagingService
private final LineChannelPriceStepClearanceMapper lineChannelPriceStepClearanceMapper; lineChannelPackagingService;
private final LineChannelPriceStepClearanceMapper
lineChannelPriceStepClearanceMapper;
public List<ProdConditionParam> obtainProdLineOnePrice(List<ProdConditionParam> prodConditionParamList, String no,
Integer customsType, Long customerId, Integer transportId, Long lineId, //lanbm 2024-06-21 add
Long channelId, Boolean isWarehouseIn) { @Resource
private ZTestMapper3 zTestMapper;
public List<ProdConditionParam> obtainProdLineOnePrice(
List<ProdConditionParam> prodConditionParamList,
String no,
Integer customsType,
Long customerId,
Integer transportId,
Long lineId,
Long channelId,
Boolean isWarehouseIn) {
if (CollectionUtil.isEmpty(prodConditionParamList)) { if (CollectionUtil.isEmpty(prodConditionParamList)) {
throw exception(PROD_PARAM_NOT_NULL); throw exception(PROD_PARAM_NOT_NULL);
...@@ -93,7 +108,9 @@ public class ProdCostCalculation { ...@@ -93,7 +108,9 @@ public class ProdCostCalculation {
// 获取所有单位 // 获取所有单位
List<UnitDO> unitDOList = unitService.list(); List<UnitDO> unitDOList = unitService.list();
Map<Integer, UnitDO> unitDOMap = unitDOList.stream() Map<Integer, UnitDO> unitDOMap = unitDOList.stream()
.collect(Collectors.toMap(UnitDO::getId, Function.identity(), (key1, key2) -> key2)); .collect(Collectors.toMap(UnitDO::getId,
Function.identity(),
(key1, key2) -> key2));
// 单价查询计算 // 单价查询计算
long index = 1; long index = 1;
...@@ -115,7 +132,14 @@ public class ProdCostCalculation { ...@@ -115,7 +132,14 @@ public class ProdCostCalculation {
prodParam.setItemId(index++); prodParam.setItemId(index++);
} }
// 查询价格 // 查询价格
this.queryPrice(no, customsType, customerId, transportId, lineId, channelId, unitDOMap, prodParam); this.queryPrice(no,
customsType,
customerId,
transportId,
lineId,
channelId,
unitDOMap, prodParam);
if (transportId == 3) { if (transportId == 3) {
// 空运的阶梯价格需要计算出订单的所有品名总收费值来匹配价格-->统计品名的总值 // 空运的阶梯价格需要计算出订单的所有品名总收费值来匹配价格-->统计品名的总值
BigDecimal quantity = BigDecimal.valueOf(prodParam.getQuantity()); BigDecimal quantity = BigDecimal.valueOf(prodParam.getQuantity());
...@@ -123,10 +147,12 @@ public class ProdCostCalculation { ...@@ -123,10 +147,12 @@ public class ProdCostCalculation {
totalVolume = totalVolume.add(prodParam.getVolume().compareTo(prodParam.getMinMeteringVolume()) > 0 ? prodParam.getVolume() : prodParam.getMinMeteringVolume()); totalVolume = totalVolume.add(prodParam.getVolume().compareTo(prodParam.getMinMeteringVolume()) > 0 ? prodParam.getVolume() : prodParam.getMinMeteringVolume());
totalWeight = totalWeight.add(prodParam.getWeight().compareTo(prodParam.getMinMeteringWeight()) > 0 ? prodParam.getWeight() : prodParam.getMinMeteringWeight()); totalWeight = totalWeight.add(prodParam.getWeight().compareTo(prodParam.getMinMeteringWeight()) > 0 ? prodParam.getWeight() : prodParam.getMinMeteringWeight());
if (Objects.nonNull(prodParam.getChargeQuantity())) { if (Objects.nonNull(prodParam.getChargeQuantity())) {
chargeTotalQuantity = chargeTotalQuantity.add(prodParam.getChargeQuantity().compareTo(prodParam.getMinMeteringQuantity()) > 0 ? prodParam.getChargeQuantity() : prodParam.getMinMeteringQuantity()); chargeTotalQuantity =
chargeTotalQuantity.add(prodParam.getChargeQuantity().compareTo(prodParam.getMinMeteringQuantity()) > 0 ? prodParam.getChargeQuantity() : prodParam.getMinMeteringQuantity());
} }
if (Objects.nonNull(prodParam.getChargeVolume())) { if (Objects.nonNull(prodParam.getChargeVolume())) {
chargeTotalVolume = chargeTotalVolume.add(prodParam.getChargeVolume().compareTo(prodParam.getMinMeteringVolume()) > 0 ? prodParam.getChargeVolume() : prodParam.getMinMeteringVolume()); chargeTotalVolume =
chargeTotalVolume.add(prodParam.getChargeVolume().compareTo(prodParam.getMinMeteringVolume()) > 0 ? prodParam.getChargeVolume() : prodParam.getMinMeteringVolume());
} }
if (Objects.nonNull(prodParam.getChargeWeight())) { if (Objects.nonNull(prodParam.getChargeWeight())) {
chargeTotalWeight = chargeTotalWeight.add(prodParam.getChargeWeight().compareTo(prodParam.getMinMeteringWeight()) > 0 ? prodParam.getChargeWeight() : prodParam.getMinMeteringWeight()); chargeTotalWeight = chargeTotalWeight.add(prodParam.getChargeWeight().compareTo(prodParam.getMinMeteringWeight()) > 0 ? prodParam.getChargeWeight() : prodParam.getMinMeteringWeight());
...@@ -148,33 +174,48 @@ public class ProdCostCalculation { ...@@ -148,33 +174,48 @@ public class ProdCostCalculation {
param.setChargeTotalQuantity(chargeTotalQuantity); param.setChargeTotalQuantity(chargeTotalQuantity);
param.setChargeTotalVolume(chargeTotalVolume); param.setChargeTotalVolume(chargeTotalVolume);
param.setChargeTotalWeight(chargeTotalWeight); param.setChargeTotalWeight(chargeTotalWeight);
//param.setOneClearanceFee();
} }
} }
// 定价计算 // 定价计算
for (ProdConditionParam prodParam : prodConditionParamList) { for (ProdConditionParam prodParam : prodConditionParamList) {
// 品名定价 // 品名定价
this.fixPrice(no, customsType, customerId, transportId, lineId, channelId, unitDOMap, prodParam); this.fixPrice(no,
customsType,
customerId,
transportId,
lineId,
channelId,
unitDOMap,
prodParam);
// 应收运费单价(原始价格(无牌无液无电)+特殊加价+明佣) // 应收运费单价(原始价格(无牌无液无电)+特殊加价+明佣)
BigDecimal receivableOneSeaFreight = prodParam.getOrgFreightPrice().add(prodParam.getElectrifiedFreightPrice()) BigDecimal receivableOneSeaFreight =
.add(prodParam.getLiquidFreightPrice()).add(prodParam.getBrandFreightPrice()).add(prodParam.getPlainCommission()); prodParam.getOrgFreightPrice().add(prodParam.getElectrifiedFreightPrice())
.add(prodParam.getLiquidFreightPrice()).add(prodParam.getBrandFreightPrice()).add(prodParam.getPlainCommission());
prodParam.setReceivableOneSeaFreight(receivableOneSeaFreight); prodParam.setReceivableOneSeaFreight(receivableOneSeaFreight);
// 应收运费 // 应收运费
this.setReceivableTransportPrice(unitDOMap, prodParam); this.setReceivableTransportPrice(unitDOMap, prodParam);
if (prodParam.getCharging() == 0) { if (prodParam.getCharging() == 0) {
// 应收清关费 // 应收清关费
// 应收清关费单价(原始价格(无牌无液无电)+特殊加价)") // 应收清关费单价(原始价格(无牌无液无电)+特殊加价)")
BigDecimal receivableOneClearanceFreight = prodParam.getOrgClearanceFeePrice().add(prodParam.getElectrifiedClearanceFeePrice()) BigDecimal receivableOneClearanceFreight =
.add(prodParam.getLiquidClearanceFeePrice()).add(prodParam.getBrandClearanceFeePrice()); prodParam.getOrgClearanceFeePrice().add(
prodParam.setReceivableOneClearanceFreight(receivableOneClearanceFreight); prodParam.getElectrifiedClearanceFeePrice())
this.setReceivableClearancePrice(unitDOMap, prodParam, transportId); .add(prodParam.getLiquidClearanceFeePrice()).
add(prodParam.getBrandClearanceFeePrice());
prodParam.setReceivableOneClearanceFreight(
receivableOneClearanceFreight);
this.setReceivableClearancePrice(unitDOMap,
prodParam, transportId);
} else { } else {
// 全价计算,都以运费计算完成,不再计算清关费 // 全价计算,都以运费计算完成,不再计算清关费
if (!prodParam.getSpecialPriceType()) { if (!prodParam.getSpecialPriceType()) {
prodParam.setOneClearanceFee(BigDecimal.ZERO); prodParam.setOneClearanceFee(BigDecimal.ZERO);
prodParam.setReceivableOneClearanceFreight(BigDecimal.ZERO); prodParam.setReceivableOneClearanceFreight(BigDecimal.ZERO);
} }
prodParam.setReceivableClearanceFreight(prodParam.getReceivableOneClearanceFreight()); prodParam.setReceivableClearanceFreight(
prodParam.getReceivableOneClearanceFreight());
} }
} }
return prodConditionParamList; return prodConditionParamList;
...@@ -199,12 +240,19 @@ public class ProdCostCalculation { ...@@ -199,12 +240,19 @@ public class ProdCostCalculation {
* @param channelId 渠道ID * @param channelId 渠道ID
* @return 商品列表计费后信息 * @return 商品列表计费后信息
*/ */
public CalculationCostResultDto calculationProdCost(List<ProdConditionParam> prodConditionParamList, String no, public CalculationCostResultDto calculationProdCost(List<ProdConditionParam> prodConditionParamList,
Integer orderType, Integer customsType, Integer isControl, String no,
Long userId, Long customerId, Integer orderType,
Long consignorCustomerId, Long consigneeCustomerId, Integer customsType,
Long consignorCustomerContactsId, Long consigneeCustomerContactsId, Integer isControl,
Integer transportId, Long lineId, Long channelId) { Long userId,
Long customerId,
Long consignorCustomerId,
Long consigneeCustomerId,
Long consignorCustomerContactsId,
Long consigneeCustomerContactsId,
Integer transportId,
Long lineId, Long channelId) {
//获取所有货币 //获取所有货币
List<CurrencyDO> currencyDOList = currencyService.list(); List<CurrencyDO> currencyDOList = currencyService.list();
if (CollectionUtil.isEmpty(currencyDOList)) { if (CollectionUtil.isEmpty(currencyDOList)) {
...@@ -224,7 +272,10 @@ public class ProdCostCalculation { ...@@ -224,7 +272,10 @@ public class ProdCostCalculation {
// // 获取所有单位 // // 获取所有单位
List<UnitDO> unitDOList = unitService.list(); List<UnitDO> unitDOList = unitService.list();
Map<Integer, UnitDO> unitDOMap = unitDOList.stream() Map<Integer, UnitDO> unitDOMap = unitDOList.stream()
.collect(Collectors.toMap(UnitDO::getId, Function.identity(), (key1, key2) -> key2)); .collect(Collectors.toMap(UnitDO::getId,
Function.identity(), (key1, key2) -> key2));
//prodCostDtoList 计价返回值 lanbm 2024-06-20 添加注释
List<ProdCostDto> prodCostDtoList = new ArrayList<>(); List<ProdCostDto> prodCostDtoList = new ArrayList<>();
// 统计箱规 // 统计箱规
String l = "0"; String l = "0";
...@@ -232,7 +283,13 @@ public class ProdCostCalculation { ...@@ -232,7 +283,13 @@ public class ProdCostCalculation {
String h = "0"; String h = "0";
List<CouponAvailableGroupDto> couponAvailableGroupDtoList = new ArrayList<>(); List<CouponAvailableGroupDto> couponAvailableGroupDtoList = new ArrayList<>();
couponService.getCouponUserAvailableDto(transportId, orderType, customsType, isControl, userId, consignorCustomerContactsId, consigneeCustomerContactsId, lineId, channelId, prodConditionParamList, rmbCurrency, unitDOMap); couponService.getCouponUserAvailableDto(transportId,
orderType, customsType, isControl,
userId, consignorCustomerContactsId,
consigneeCustomerContactsId,
lineId, channelId,
prodConditionParamList,
rmbCurrency, unitDOMap);
// 计算订单费用 // 计算订单费用
for (ProdConditionParam prodParam : prodConditionParamList) { for (ProdConditionParam prodParam : prodConditionParamList) {
// 优惠金额:优惠活动减免 // 优惠金额:优惠活动减免
...@@ -418,7 +475,9 @@ public class ProdCostCalculation { ...@@ -418,7 +475,9 @@ public class ProdCostCalculation {
* @param prodParam 品名 * @param prodParam 品名
* @param groupDto 优惠信息 * @param groupDto 优惠信息
*/ */
private void costEncapsulation(List<ProdCostDto> prodCostDtoList, ProdConditionParam prodParam, CouponAvailableGroupDto groupDto) { private void costEncapsulation(List<ProdCostDto> prodCostDtoList,
ProdConditionParam prodParam,
CouponAvailableGroupDto groupDto) {
ProdCostDto prodCostDto = new ProdCostDto(); ProdCostDto prodCostDto = new ProdCostDto();
BeanUtils.copyProperties(prodParam, prodCostDto); BeanUtils.copyProperties(prodParam, prodCostDto);
prodCostDto.setProdId(prodParam.getProdId()); prodCostDto.setProdId(prodParam.getProdId());
...@@ -444,6 +503,7 @@ public class ProdCostCalculation { ...@@ -444,6 +503,7 @@ public class ProdCostCalculation {
prodCostDto.setHiddenCommission(prodParam.getHiddenCommission()); prodCostDto.setHiddenCommission(prodParam.getHiddenCommission());
prodCostDto.setOneClearanceFee(prodParam.getOneClearanceFee()); prodCostDto.setOneClearanceFee(prodParam.getOneClearanceFee());
prodCostDto.setOrgClearanceFeePrice(prodParam.getOrgClearanceFeePrice()); prodCostDto.setOrgClearanceFeePrice(prodParam.getOrgClearanceFeePrice());
//清关费
prodCostDto.setClearanceFee(prodParam.getClearanceFee()); prodCostDto.setClearanceFee(prodParam.getClearanceFee());
prodCostDto.setProductPriceEmptyType(prodParam.getProductPriceEmptyType()); prodCostDto.setProductPriceEmptyType(prodParam.getProductPriceEmptyType());
prodCostDto.setChannelPriceEmptyType(prodParam.getChannelPriceEmptyType()); prodCostDto.setChannelPriceEmptyType(prodParam.getChannelPriceEmptyType());
...@@ -458,6 +518,7 @@ public class ProdCostCalculation { ...@@ -458,6 +518,7 @@ public class ProdCostCalculation {
prodCostDto.setClearanceFeeCurrency(prodParam.getClearanceFeeCurrency()); prodCostDto.setClearanceFeeCurrency(prodParam.getClearanceFeeCurrency());
prodCostDto.setOneFreight(prodParam.getOneFreight()); prodCostDto.setOneFreight(prodParam.getOneFreight());
prodCostDto.setOrgFreightPrice(prodParam.getOrgFreightPrice()); prodCostDto.setOrgFreightPrice(prodParam.getOrgFreightPrice());
//运费
prodCostDto.setFreight(prodParam.getFreight()); prodCostDto.setFreight(prodParam.getFreight());
prodCostDto.setReceivableSeaFreight(prodParam.getReceivableSeaFreight()); prodCostDto.setReceivableSeaFreight(prodParam.getReceivableSeaFreight());
prodCostDto.setDiscountFreightPrice(prodParam.getDiscountFreightPrice()); prodCostDto.setDiscountFreightPrice(prodParam.getDiscountFreightPrice());
...@@ -469,6 +530,7 @@ public class ProdCostCalculation { ...@@ -469,6 +530,7 @@ public class ProdCostCalculation {
prodCostDto.setCharging(prodParam.getCharging()); prodCostDto.setCharging(prodParam.getCharging());
prodCostDto.setNeedOrderInquiry(prodParam.getNeedOrderInquiry()); prodCostDto.setNeedOrderInquiry(prodParam.getNeedOrderInquiry());
prodCostDto.setItemId(prodParam.getItemId()); prodCostDto.setItemId(prodParam.getItemId());
prodCostDtoList.add(prodCostDto); prodCostDtoList.add(prodCostDto);
} }
...@@ -478,7 +540,8 @@ public class ProdCostCalculation { ...@@ -478,7 +540,8 @@ public class ProdCostCalculation {
* @param prodParam 商品信息 * @param prodParam 商品信息
* @param groupDto 可用优惠信息 * @param groupDto 可用优惠信息
*/ */
private void discountCalculation(ProdConditionParam prodParam, CouponAvailableGroupDto groupDto) { private void discountCalculation(ProdConditionParam prodParam,
CouponAvailableGroupDto groupDto) {
// 没有定价或者指定更新订单品名优惠,并且成交单价大于0时,去实时更新品名的优惠信息 // 没有定价或者指定更新订单品名优惠,并且成交单价大于0时,去实时更新品名的优惠信息
if ((Objects.isNull(prodParam.getIsPriced()) || !prodParam.getIsPriced() || prodParam.getCalculationType() == 6) && !prodParam.getSplitCustomPriceType() && !prodParam.getSpecialPriceType() && !prodParam.getChannelManualPricing() && prodParam.getOneFreight().compareTo(BigDecimal.ZERO) > 0) { if ((Objects.isNull(prodParam.getIsPriced()) || !prodParam.getIsPriced() || prodParam.getCalculationType() == 6) && !prodParam.getSplitCustomPriceType() && !prodParam.getSpecialPriceType() && !prodParam.getChannelManualPricing() && prodParam.getOneFreight().compareTo(BigDecimal.ZERO) > 0) {
BigDecimal orgFreightReduceAmount = BigDecimal.ZERO; BigDecimal orgFreightReduceAmount = BigDecimal.ZERO;
...@@ -526,13 +589,23 @@ public class ProdCostCalculation { ...@@ -526,13 +589,23 @@ public class ProdCostCalculation {
prodParam.setDiscountClearanceFeePrice(BigDecimal.ZERO); prodParam.setDiscountClearanceFeePrice(BigDecimal.ZERO);
} }
if (!prodParam.getSpecialPriceType()) { if (!prodParam.getSpecialPriceType()) {
prodParam.setOneClearanceFee(prodParam.getOneClearanceFee().add(orgClearanceReduceAmount).subtract(prodParam.getDiscountClearanceFeePrice())); prodParam.setOneClearanceFee(
prodParam.getOneClearanceFee().
add(orgClearanceReduceAmount).
subtract(prodParam.getDiscountClearanceFeePrice()));
} }
} }
} }
} }
private void queryPrice(String no, Integer customsType, Long customerId, Integer transportId, Long lineId, Long channelId, Map<Integer, UnitDO> unitDOMap, ProdConditionParam prodParam) { private void queryPrice(String no,
Integer customsType,
Long customerId,
Integer transportId,
Long lineId,
Long channelId,
Map<Integer, UnitDO> unitDOMap,
ProdConditionParam prodParam) {
if (null == prodParam.getWorth()) { if (null == prodParam.getWorth()) {
prodParam.setWorth(BigDecimal.ZERO); prodParam.setWorth(BigDecimal.ZERO);
} }
...@@ -548,7 +621,9 @@ public class ProdCostCalculation { ...@@ -548,7 +621,9 @@ public class ProdCostCalculation {
if (null == prodParam.getNum()) { if (null == prodParam.getNum()) {
prodParam.setNum(0); prodParam.setNum(0);
} }
if (Objects.nonNull(prodParam.getSpecialPriceType()) && prodParam.getSpecialPriceType()) { if (Objects.nonNull(prodParam.getSpecialPriceType()) &&
prodParam.getSpecialPriceType()) {
if (Objects.isNull(prodParam.getOneFreight())) { if (Objects.isNull(prodParam.getOneFreight())) {
throw exception(SPECIAL_PRICE_ONE_FREIGHT_NOT_NULL); throw exception(SPECIAL_PRICE_ONE_FREIGHT_NOT_NULL);
} }
...@@ -559,25 +634,33 @@ public class ProdCostCalculation { ...@@ -559,25 +634,33 @@ public class ProdCostCalculation {
} }
} }
if ((Objects.isNull(prodParam.getIsPriced()) || !prodParam.getIsPriced() || prodParam.getIsChangeFeeValue()) && !prodParam.getSplitCustomPriceType() && !prodParam.getSpecialPriceType() && !prodParam.getChannelManualPricing()) { if ((Objects.isNull(prodParam.getIsPriced()) ||
!prodParam.getIsPriced() || prodParam.getIsChangeFeeValue())
&& !prodParam.getSplitCustomPriceType() &&
!prodParam.getSpecialPriceType() &&
!prodParam.getChannelManualPricing()) {
// 根据商品ID与线路ID获取商品运费与清关费的单价 // 根据商品ID与线路ID获取商品运费与清关费的单价
ProductPriceDO productPriceDO = productPriceService.getOne(new LambdaQueryWrapper<ProductPriceDO>() ProductPriceDO productPriceDO =
.eq(ProductPriceDO::getProductId, prodParam.getProdId()) productPriceService.getOne(new LambdaQueryWrapper<ProductPriceDO>()
.eq(ProductPriceDO::getWarehouseLineId, lineId) .eq(ProductPriceDO::getProductId, prodParam.getProdId())
.and(we -> we.le(ProductPriceDO::getValidateStartDate, DateUtil.date()) .eq(ProductPriceDO::getWarehouseLineId, lineId)
.or() .and(we -> we.le(ProductPriceDO::getValidateStartDate, DateUtil.date())
.isNull(ProductPriceDO::getValidateStartDate)) .or()
.and(we -> we.ge(ProductPriceDO::getValidateEndDate, DateUtil.date()) .isNull(ProductPriceDO::getValidateStartDate))
.or() .and(we -> we.ge(ProductPriceDO::getValidateEndDate, DateUtil.date())
.isNull(ProductPriceDO::getValidateEndDate)) .or()
.eq(Objects.nonNull(transportId) && (3 == transportId || 4 == transportId) && .isNull(ProductPriceDO::getValidateEndDate))
null != channelId && 0 != channelId, ProductPriceDO::getShippingChannelId, channelId) .eq(Objects.nonNull(transportId) && (3 == transportId || 4 == transportId) &&
.eq(ProductPriceDO::getDeleted, false) null != channelId && 0 != channelId, ProductPriceDO::getShippingChannelId, channelId)
.last("limit 1")); .eq(ProductPriceDO::getDeleted, false)
.last("limit 1"));
if (Objects.nonNull(productPriceDO)) { if (Objects.nonNull(productPriceDO)) {
if (Objects.nonNull(prodParam.getIsPriced()) && prodParam.getIsPriced()) { if (Objects.nonNull(prodParam.getIsPriced()) &&
if (productPriceDO.getStepPrice() == 0 && prodParam.getIsChangeFeeValue()) { prodParam.getIsPriced()) {
if (productPriceDO.getStepPrice() == 0 &&
prodParam.getIsChangeFeeValue()) {
return; return;
} }
} }
...@@ -644,7 +727,9 @@ public class ProdCostCalculation { ...@@ -644,7 +727,9 @@ public class ProdCostCalculation {
} }
prodParam.setUnitDO(unitDO); prodParam.setUnitDO(unitDO);
} }
if (productPriceDO.getPriceType() == 0 && Objects.nonNull(productPriceDO.getClearanceVolumeUnit())) { if (productPriceDO.getPriceType() == 0 &&
Objects.nonNull(productPriceDO.getClearanceVolumeUnit())) {
prodParam.setClearanceFeeVolume(productPriceDO.getClearanceVolumeUnit()); prodParam.setClearanceFeeVolume(productPriceDO.getClearanceVolumeUnit());
UnitDO clearanceUnitDO = unitDOMap.get(Integer.valueOf(prodParam.getClearanceFeeVolume().toString())); UnitDO clearanceUnitDO = unitDOMap.get(Integer.valueOf(prodParam.getClearanceFeeVolume().toString()));
prodParam.setClearanceUnitDO(clearanceUnitDO); prodParam.setClearanceUnitDO(clearanceUnitDO);
...@@ -666,19 +751,41 @@ public class ProdCostCalculation { ...@@ -666,19 +751,41 @@ public class ProdCostCalculation {
* @param unitDOMap 计量单位map * @param unitDOMap 计量单位map
* @param prodParam 品名信息 * @param prodParam 品名信息
*/ */
private void fixPrice(String no, Integer customsType, Long customerId, Integer transportId, Long lineId, Long channelId, Map<Integer, UnitDO> unitDOMap, ProdConditionParam prodParam) { private void fixPrice(String no,
Integer customsType,
Long customerId,
Integer transportId,
Long lineId,
Long channelId,
Map<Integer, UnitDO> unitDOMap,
ProdConditionParam prodParam) {
BigDecimal transportPrice = BigDecimal.ZERO;// 初始化商品单价运费 BigDecimal transportPrice = BigDecimal.ZERO;// 初始化商品单价运费
BigDecimal clearancePrice = BigDecimal.ZERO;// 初始化商品单价清关费 BigDecimal clearancePrice = BigDecimal.ZERO;// 初始化商品单价清关费
if ((Objects.isNull(prodParam.getIsPriced()) || !prodParam.getIsPriced()) && !prodParam.getSplitCustomPriceType() && !prodParam.getSpecialPriceType() && !prodParam.getChannelManualPricing()) { if ((Objects.isNull(prodParam.getIsPriced()) || !prodParam.getIsPriced())
&& !prodParam.getSplitCustomPriceType() &&
!prodParam.getSpecialPriceType() &&
!prodParam.getChannelManualPricing()) {
// 根据商品ID与线路ID获取商品运费与清关费的单价 // 根据商品ID与线路ID获取商品运费与清关费的单价
ProductPriceDO productPriceDO = prodParam.getProductPriceDO(); ProductPriceDO productPriceDO = prodParam.getProductPriceDO();
if (Objects.nonNull(productPriceDO)) { if (Objects.nonNull(productPriceDO)) {
if (productPriceDO.getStepPrice() == 1) { if (productPriceDO.getStepPrice() == 1) {
// 阶梯价格查询 // 阶梯价格查询
if (transportId == 1 || transportId == 2) { if (transportId == 1 || transportId == 2) {
//海运拼柜
this.stepSelect(unitDOMap, prodParam, productPriceDO); this.stepSelect(unitDOMap, prodParam, productPriceDO);
} else { } else {
this.airStepSelect(unitDOMap, prodParam, productPriceDO, lineId, channelId); //专线空运
zTest3 z = new zTest3();
z.setCreatedate(new Date());
String s = "开始计算空运清关价 airStepSelect,lineId=" + lineId +
" 渠道channelId=" + channelId;
z.setTestname(s);
zTestMapper.insert(z);
this.airStepSelect(unitDOMap, prodParam,
productPriceDO, lineId, channelId);
} }
} }
...@@ -694,62 +801,22 @@ public class ProdCostCalculation { ...@@ -694,62 +801,22 @@ public class ProdCostCalculation {
prodParam.setFreightCurrency(Math.toIntExact(productPriceDO.getPriceType() == 0 ? productPriceDO.getTransportPriceUnit() : productPriceDO.getAllPriceUnit())); prodParam.setFreightCurrency(Math.toIntExact(productPriceDO.getPriceType() == 0 ? productPriceDO.getTransportPriceUnit() : productPriceDO.getAllPriceUnit()));
// 清关费 // 清关费
if (productPriceDO.getPriceType() == 0) { if (productPriceDO.getPriceType() == 0) {
//如果是运费加清关费
if (!prodParam.getSpecialPriceType()) { if (!prodParam.getSpecialPriceType()) {
prodParam.setOneClearanceFee(productPriceDO.getClearancePrice()); //不是特价
prodParam.setOneClearanceFee(
productPriceDO.getClearancePrice());
} }
prodParam.setOrgClearanceFeePrice(productPriceDO.getClearancePrice()); prodParam.setOrgClearanceFeePrice(
prodParam.setClearanceFeeCurrency(Math.toIntExact(productPriceDO.getClearancePriceUnit())); productPriceDO.getClearancePrice());
prodParam.setClearanceFeeVolume(productPriceDO.getClearanceVolumeUnit()); prodParam.setClearanceFeeCurrency(
Math.toIntExact(productPriceDO.getClearancePriceUnit()));
prodParam.setClearanceFeeVolume(
productPriceDO.getClearanceVolumeUnit());
if (transportId == 3) { if (transportId == 3) {
prodParam.setProductPriceEmptyType(productPriceDO.getProductPriceEmptyType()); prodParam.setProductPriceEmptyType(
productPriceDO.getProductPriceEmptyType());
} }
// if (productPriceDO.getProductPriceEmptyType() == 0 && Objects.nonNull(productPriceDO.getClearancePrice()) && productPriceDO.getClearancePrice().compareTo(BigDecimal.ZERO) > 0 && transportId == 3) {
// prodParam.setAirClearanceSource(1);// 默认先获取的商品线路清关费
// prodParam.setAirClearanceInfo(productPriceDO.getAirClearanceInfo());// 默认先获取的商品线路清关费
// // TODO 获取线路设置的空运清关费
// List<LineChannelPackagingDO> packagingDOList = lineChannelPackagingService.queryAirClearancePrice(CollectionUtil.isNotEmpty(prodParam.getPackages()) ? prodParam.getPackages() : Collections.singletonList(prodParam.getPackaging()), lineId, channelId);
// if (CollectionUtil.isNotEmpty(packagingDOList)) {
//
// }
// }
// if (transportId == 1 || transportId == 2) {
// if (!prodParam.getSpecialPriceType()) {
// prodParam.setOneClearanceFee(productPriceDO.getClearancePrice());
// }
// prodParam.setOrgClearanceFeePrice(productPriceDO.getClearancePrice());
// prodParam.setClearanceFeeCurrency(Math.toIntExact(productPriceDO.getClearancePriceUnit()));
// prodParam.setClearanceFeeVolume(productPriceDO.getClearanceVolumeUnit());
//
// } else
// if (transportId == 3) {
// //空运清关费
// AirClearancePriceResultDto airClearancePriceResultDto = new AirClearancePriceResultDto();
// if (CollectionUtil.isNotEmpty(prodParam.getPackages())) {
// airClearancePriceResultDto = productPriceService.queryAirClearancePrice(prodParam.getProdId(), prodParam.getPackages(), channelId,
// prodParam.getTotalWeight(), prodParam.getTotalVolume(), Objects.isNull(prodParam.getTotalQuantity()) ? BigDecimal.ZERO : prodParam.getTotalQuantity());
// } else {
// airClearancePriceResultDto = productPriceService.queryAirClearancePrice(prodParam.getProdId(), prodParam.getPackaging(), channelId,
// prodParam.getTotalWeight(), prodParam.getTotalVolume(), Objects.isNull(prodParam.getTotalQuantity()) ? BigDecimal.ZERO : prodParam.getTotalQuantity());
// }
// BasePrice basePrice = airClearancePriceResultDto.getClearancePrice();
// log.info("空运渠道清关费:{}", Objects.nonNull(basePrice) ? JSONObject.toJSONString(basePrice) : null);
// prodParam.setProductPriceEmptyType(airClearancePriceResultDto.getProductPriceEmptyType());
// prodParam.setChannelPriceEmptyType(airClearancePriceResultDto.getChannelPriceEmptyType());
// if (Objects.nonNull(basePrice)) {
// prodParam.setOneClearanceFee(basePrice.getClearancePrice());
// prodParam.setOrgClearanceFeePrice(basePrice.getClearancePrice());
// prodParam.setClearanceFeeVolume(basePrice.getClearanceVolumeUnit());
// prodParam.setClearanceFeeCurrency(Math.toIntExact(basePrice.getClearancePriceUnit()));
// prodParam.setAirClearanceSource(basePrice.getAirClearanceSource());
// prodParam.setAirClearanceInfo(basePrice.getAirClearanceInfo());
// } else {
// prodParam.setClearanceFee(BigDecimal.ZERO);
// prodParam.setOneClearanceFee(BigDecimal.ZERO);
// prodParam.setOrgClearanceFeePrice(BigDecimal.ZERO);
// prodParam.setClearanceFeeVolume(0L);
// prodParam.setClearanceFeeCurrency(0);
// }
// }
} else { } else {
prodParam.setClearanceFee(BigDecimal.ZERO); prodParam.setClearanceFee(BigDecimal.ZERO);
prodParam.setOneClearanceFee(BigDecimal.ZERO); prodParam.setOneClearanceFee(BigDecimal.ZERO);
...@@ -782,9 +849,10 @@ public class ProdCostCalculation { ...@@ -782,9 +849,10 @@ public class ProdCostCalculation {
} else { } else {
// TODO 指定包装类型的包装加价 // TODO 指定包装类型的包装加价
if (CollectionUtil.isNotEmpty(prodParam.getPackages())) { if (CollectionUtil.isNotEmpty(prodParam.getPackages())) {
List<ProductPricePackagingDO> pricePackagingDOList = pricePackagingMapper.selectList(new LambdaQueryWrapper<ProductPricePackagingDO>() List<ProductPricePackagingDO> pricePackagingDOList =
.eq(ProductPricePackagingDO::getDeleted, 0) pricePackagingMapper.selectList(new LambdaQueryWrapper<ProductPricePackagingDO>()
.eq(ProductPricePackagingDO::getProductPriceId, productPriceDO.getId())); .eq(ProductPricePackagingDO::getDeleted, 0)
.eq(ProductPricePackagingDO::getProductPriceId, productPriceDO.getId()));
// 筛选匹配包装类型,并比较金额大小,取最大值 // 筛选匹配包装类型,并比较金额大小,取最大值
List<ProductPricePackagingDO> packagingDOList = new ArrayList<>(); List<ProductPricePackagingDO> packagingDOList = new ArrayList<>();
List<ProductPricePackagingDO> clearancePackagingDOList = new ArrayList<>(); List<ProductPricePackagingDO> clearancePackagingDOList = new ArrayList<>();
...@@ -813,7 +881,8 @@ public class ProdCostCalculation { ...@@ -813,7 +881,8 @@ public class ProdCostCalculation {
} }
if (CollectionUtil.isNotEmpty(packagingDOList)) { if (CollectionUtil.isNotEmpty(packagingDOList)) {
// 运费、全包价包装价格计算最大值 // 运费、全包价包装价格计算最大值
ProductPricePackagingDO packagingDO = packagingDOList.stream().max(Comparator.comparing(ProductPricePackagingDO::getPackagingPrice)).orElse(null); ProductPricePackagingDO packagingDO =
packagingDOList.stream().max(Comparator.comparing(ProductPricePackagingDO::getPackagingPrice)).orElse(null);
if (Objects.nonNull(packagingDO)) { if (Objects.nonNull(packagingDO)) {
prodParam.setPackagingFreightPrice(packagingDO.getPackagingPrice()); prodParam.setPackagingFreightPrice(packagingDO.getPackagingPrice());
if (!prodParam.getSpecialPriceType()) { if (!prodParam.getSpecialPriceType()) {
...@@ -825,7 +894,8 @@ public class ProdCostCalculation { ...@@ -825,7 +894,8 @@ public class ProdCostCalculation {
} }
if (CollectionUtil.isNotEmpty(clearancePackagingDOList)) { if (CollectionUtil.isNotEmpty(clearancePackagingDOList)) {
// 清关费包装价格计算最大值 // 清关费包装价格计算最大值
ProductPricePackagingDO clearancePackagingDO = clearancePackagingDOList.stream().max(Comparator.comparing(ProductPricePackagingDO::getPackagingPrice)).orElse(null); ProductPricePackagingDO clearancePackagingDO =
clearancePackagingDOList.stream().max(Comparator.comparing(ProductPricePackagingDO::getPackagingPrice)).orElse(null);
if (Objects.nonNull(clearancePackagingDO)) { if (Objects.nonNull(clearancePackagingDO)) {
prodParam.setPackagingClearanceFeePrice(clearancePackagingDO.getPackagingPrice()); prodParam.setPackagingClearanceFeePrice(clearancePackagingDO.getPackagingPrice());
if (!prodParam.getSpecialPriceType()) { if (!prodParam.getSpecialPriceType()) {
...@@ -912,7 +982,6 @@ public class ProdCostCalculation { ...@@ -912,7 +982,6 @@ public class ProdCostCalculation {
} }
} else { } else {
if (!prodParam.getSpecialPriceType()) { if (!prodParam.getSpecialPriceType()) {
prodParam.setOneFreight(transportPrice); prodParam.setOneFreight(transportPrice);
prodParam.setOneClearanceFee(clearancePrice); prodParam.setOneClearanceFee(clearancePrice);
...@@ -1176,130 +1245,242 @@ public class ProdCostCalculation { ...@@ -1176,130 +1245,242 @@ public class ProdCostCalculation {
* @param lineId 线路ID * @param lineId 线路ID
* @param channelId 渠道ID * @param channelId 渠道ID
*/ */
private void airStepSelect(Map<Integer, UnitDO> unitDOMap, ProdConditionParam prodParam, ProductPriceDO private void airStepSelect(Map<Integer, UnitDO> unitDOMap,
productPriceDO, Long lineId, Long channelId) { ProdConditionParam prodParam,
ProductPriceDO productPriceDO,
Long lineId, Long channelId) {
if (prodParam.getUnitDO() == null) { if (prodParam.getUnitDO() == null) {
//运费计量单位信息
if (productPriceDO.getPriceType() == 0) { if (productPriceDO.getPriceType() == 0) {
//单价模式,0-运费+清关费,1-全包价
productPriceDO.setTransportPrice(BigDecimal.ZERO); productPriceDO.setTransportPrice(BigDecimal.ZERO);
} else { } else {
productPriceDO.setAllPrice(BigDecimal.ZERO); productPriceDO.setAllPrice(BigDecimal.ZERO);
} }
// if (!prodParam.getSpecialPriceType()) { return;
// prodParam.setOneFreight(productPriceDO.getPriceType() == 0 ? productPriceDO.getTransportPrice() : productPriceDO.getAllPrice()); }
// }
BigDecimal num = this.calculationUnitAsValue(prodParam,
productPriceDO,
prodParam.getUnitDO(),
1);
//lanbm 2024-06-21 添加的逻辑
if (productPriceDO.getPriceType() == null) return;
//全包价
if (productPriceDO.getPriceType() == 1) {
BasePrice allBasePrice =
productPriceStepService.getProductPriceStep(
productPriceDO.getId(), num, 1);
if (Objects.nonNull(allBasePrice)) {
log.info("===== 线路无牌无液无电全包阶梯价:{} =====",
JSONObject.toJSONString(allBasePrice));
productPriceDO.setAllPrice(allBasePrice.getAllPrice());
productPriceDO.setAllStepPriceId(allBasePrice.getAllStepPriceId());
} else {
log.info("===== 线路无牌无液无电全包阶梯价不存在【{} {}】该档次 =====",
num, prodParam.getUnitDO().getFuhao());
productPriceDO.setNeedPay(null);
productPriceDO.setAllPrice(BigDecimal.ZERO);
}
return;
}
//0-运费+清关费 才走下面的逻辑
//单价模式,0-运费+清关费,1-全包价
BasePrice transportBasePrice =
productPriceStepService.getProductPriceStep(
productPriceDO.getId(), num, 0);
if (Objects.nonNull(transportBasePrice)) {
log.info("===== 线路无牌无液无电运费阶梯价:{} =====",
JSONObject.toJSONString(transportBasePrice));
productPriceDO.setTransportPrice(transportBasePrice.getTransportPrice());
productPriceDO.setTransportStepPriceId(transportBasePrice.getTransportStepPriceId());
} else { } else {
BigDecimal num = this.calculationUnitAsValue(prodParam, productPriceDO, prodParam.getUnitDO(), 1); log.info("===== 线路无牌无液无电运费阶梯价不存在【{} {}】该档次 =====",
num, prodParam.getUnitDO().getFuhao());
productPriceDO.setNeedPay(null);
productPriceDO.setTransportPrice(BigDecimal.ZERO);
}
if (prodParam.getClearanceUnitDO() == null) {
//清关费单位为空,设置清关费为0
productPriceDO.setClearancePrice(BigDecimal.ZERO);
return;
}
if (productPriceDO.getPriceType() == 0) {
BasePrice transportBasePrice = productPriceStepService.getProductPriceStep(productPriceDO.getId(), num, 0); // 清关费以实际入仓值来匹配
if (Objects.nonNull(transportBasePrice)) { // 2024-1-17 空运清关费改为和空运运费一样使用订单总收费值来匹配
log.info("===== 线路无牌无液无电运费阶梯价:{} =====", JSONObject.toJSONString(transportBasePrice)); //BigDecimal clearanceNum = this.calculationUnitAsValue(prodParam, productPriceDO, prodParam.getClearanceUnitDO(), 0);
productPriceDO.setTransportPrice(transportBasePrice.getTransportPrice()); BigDecimal clearanceNum = num;
productPriceDO.setTransportStepPriceId(transportBasePrice.getTransportStepPriceId()); //获取阶梯价
} else { BasePrice clearanceBasePrice =
log.info("===== 线路无牌无液无电运费阶梯价不存在【{} {}】该档次 =====", num, prodParam.getUnitDO().getFuhao()); productPriceStepService.getProductPriceStep(
productPriceDO.setNeedPay(null); productPriceDO.getId(),
productPriceDO.setTransportPrice(BigDecimal.ZERO); clearanceNum, 2);
} clearanceBasePrice.setClearancePriceUnit(
if (prodParam.getClearanceUnitDO() == null) { productPriceDO.getClearancePriceUnit());
productPriceDO.setClearancePrice(BigDecimal.ZERO); clearanceBasePrice.setClearanceVolumeUnit(
} else { productPriceDO.getClearanceVolumeUnit());
// 清关费以实际入仓值来匹配
// 2024-1-17 空运清关费改为和空运运费一样使用订单总收费值来匹配 log.info("===== 线路无牌无液无电清关费阶梯价:{} =====",
// BigDecimal clearanceNum = this.calculationUnitAsValue(prodParam, productPriceDO, prodParam.getClearanceUnitDO(), 0); JSONObject.toJSONString(clearanceBasePrice));
BigDecimal clearanceNum = num;
BasePrice clearanceBasePrice = productPriceStepService.getProductPriceStep(productPriceDO.getId(), clearanceNum, 2); int airClearanceSource = 3;
clearanceBasePrice.setClearancePriceUnit(productPriceDO.getClearancePriceUnit()); BasePrice clearancePrice;
clearanceBasePrice.setClearanceVolumeUnit(productPriceDO.getClearanceVolumeUnit()); //clearanceBasePrice 阶梯价
log.info("===== 线路无牌无液无电清关费阶梯价:{} =====", JSONObject.toJSONString(clearanceBasePrice)); //线路存在,产品路线价格存在清关价
int airClearanceSource = 3; if (clearanceBasePrice.getProductPriceEmptyType() == 0 &&
BasePrice clearancePrice; Objects.nonNull(lineId) && lineId > 0
if (clearanceBasePrice.getProductPriceEmptyType() == 0 && Objects.nonNull(lineId) && lineId > 0 && Objects.nonNull(productPriceDO.getClearancePrice())
&& Objects.nonNull(productPriceDO.getClearancePrice()) && productPriceDO.getClearancePrice().compareTo(BigDecimal.ZERO) > 0) { && productPriceDO.getClearancePrice().compareTo(BigDecimal.ZERO) > 0) {
// TODO 获取线路设置的空运清关费
List<LineChannelPackagingDO> lineChannelPackagingDOList = lineChannelPackagingService.queryAirClearancePrice(CollectionUtil.isNotEmpty(prodParam.getPackages()) ? prodParam.getPackages() : Collections.singletonList(prodParam.getPackaging()), channelId, lineId); if (CollectionUtil.isNotEmpty(prodParam.getPackages())) {
if (CollectionUtil.isNotEmpty(lineChannelPackagingDOList)) { zTest3 z = new zTest3();
BasePrice lineClearanceBasePrice = null; z.setCreatedate(new Date());
for (LineChannelPackagingDO lineChannelPackagingDO : lineChannelPackagingDOList) { z.setTestname("产品包装类型为:"+prodParam.getPackages().toString());
UnitDO lineClearanceUnitDO = unitDOMap.get(Integer.valueOf(lineChannelPackagingDO.getClearanceVolumeUnit().toString())); zTestMapper.insert(z);
if (lineClearanceUnitDO == null) { }
continue; //TODO 获取线路设置的空运清关费
} //线路渠道清关费包装类型表 ecw_line_channel_packaging
if (Objects.isNull(lineClearanceBasePrice)) { List<LineChannelPackagingDO> lineChannelPackagingDOList =
lineClearanceBasePrice = new BasePrice(); lineChannelPackagingService.queryAirClearancePrice(
lineClearanceBasePrice.setClearancePrice(BigDecimal.ZERO); CollectionUtil.isNotEmpty(prodParam.getPackages()) ?
lineClearanceBasePrice.setProductClearanceAsExchangePrice(BigDecimal.ZERO); prodParam.getPackages() :
} Collections.singletonList(prodParam.getPackaging()),
lineClearanceBasePrice.setClearancePriceUnit(lineChannelPackagingDO.getClearancePriceUnit()); channelId, lineId);
lineClearanceBasePrice.setClearanceVolumeUnit(lineChannelPackagingDO.getClearanceVolumeUnit());
BigDecimal lineClearanceNum = this.calculationUnitAsValue(prodParam, productPriceDO, lineClearanceUnitDO, 0); if (CollectionUtil.isNotEmpty(lineChannelPackagingDOList)) {
List<LineChannelPriceStepClearanceDO> packagingStepPriceDOList = lineChannelPackagingDO.getLineChannelPriceStepClearanceDOList(); //如果线路渠道的包装类型为空,就取阶梯价的清关价 lanbm 2024-06-21 添加注释
ExchangeRateRespDTO productExchangeRate = currencyApi.getCurrencyRate(lineClearanceBasePrice.getClearancePriceUnit(), 1L); BasePrice lineClearanceBasePrice = null;
if (CollectionUtil.isNotEmpty(packagingStepPriceDOList)) {
LineChannelPriceStepClearanceDO priceStepDO = packagingStepPriceDOList.stream().filter(priceStep -> priceStep.getStartNum().compareTo(lineClearanceNum) <= 0 && priceStep.getEndNum().compareTo(lineClearanceNum) >= 0).findFirst().orElse(null); for (LineChannelPackagingDO lineChannelPackagingDO :
if (Objects.nonNull(priceStepDO)) { lineChannelPackagingDOList) {
BigDecimal productClearancePrice = productExchangeRate.getCurrencyRate().multiply(priceStepDO.getClearancePrice()).setScale(2, BigDecimal.ROUND_HALF_UP);
if (lineClearanceBasePrice.getClearancePrice().compareTo(BigDecimal.ZERO) > 0) { //计量单位
if (productClearancePrice.compareTo(lineClearanceBasePrice.getProductClearanceAsExchangePrice()) > 0) { UnitDO lineClearanceUnitDO =
lineClearanceBasePrice.setClearanceStepPriceId(priceStepDO.getId()); unitDOMap.get(Integer.valueOf(
lineClearanceBasePrice.setAirClearanceSource(4); lineChannelPackagingDO.getClearanceVolumeUnit().toString()));
lineClearanceBasePrice.setClearancePrice(priceStepDO.getClearancePrice()); if (lineClearanceUnitDO == null) {
lineClearanceBasePrice.setAirClearanceInfo(JSONObject.toJSONString(priceStepDO)); continue;
} }
} else {
BeanUtils.copyProperties(priceStepDO, lineClearanceBasePrice); if (Objects.isNull(lineClearanceBasePrice)) {
lineClearanceBasePrice.setClearanceStepPriceId(priceStepDO.getId()); lineClearanceBasePrice = new BasePrice();
lineClearanceBasePrice.setAirClearanceSource(4); lineClearanceBasePrice.setClearancePrice(BigDecimal.ZERO);
lineClearanceBasePrice.setClearancePrice(priceStepDO.getClearancePrice()); lineClearanceBasePrice.setProductClearanceAsExchangePrice(BigDecimal.ZERO);
lineClearanceBasePrice.setAirClearanceInfo(JSONObject.toJSONString(priceStepDO)); }
lineClearanceBasePrice.setProductClearanceAsExchangePrice(productClearancePrice); lineClearanceBasePrice.setClearancePriceUnit(
} lineChannelPackagingDO.getClearancePriceUnit());
} lineClearanceBasePrice.setClearanceVolumeUnit(
} lineChannelPackagingDO.getClearanceVolumeUnit());
} BigDecimal lineClearanceNum =
if (lineClearanceBasePrice != null) { this.calculationUnitAsValue(prodParam,
int result = 0; productPriceDO, lineClearanceUnitDO, 0);
if (!clearanceBasePrice.getClearancePriceUnit().equals(lineClearanceBasePrice.getClearancePriceUnit())) { //ecw_line_channel_price_step_clearance
ExchangeRateRespDTO productExchangeRate = currencyApi.getCurrencyRate(clearanceBasePrice.getClearancePriceUnit(), 1L); //线路渠道清关费阶梯价格
BigDecimal productClearancePrice = productExchangeRate.getCurrencyRate().multiply(clearanceBasePrice.getClearancePrice()).setScale(2, BigDecimal.ROUND_HALF_UP); List<LineChannelPriceStepClearanceDO>
BigDecimal lineClearancePrice = lineClearanceBasePrice.getProductClearanceAsExchangePrice(); packagingStepPriceDOList =
result = productClearancePrice.compareTo(lineClearancePrice); lineChannelPackagingDO.getLineChannelPriceStepClearanceDOList();
} else { //币种
result = clearanceBasePrice.getClearancePrice().compareTo(lineClearanceBasePrice.getClearancePrice()); ExchangeRateRespDTO productExchangeRate =
currencyApi.getCurrencyRate(
lineClearanceBasePrice.getClearancePriceUnit(),
1L);
//线路渠道清关费阶梯价格
if (CollectionUtil.isNotEmpty(packagingStepPriceDOList)) {
LineChannelPriceStepClearanceDO priceStepDO =
packagingStepPriceDOList.stream().
filter(priceStep -> priceStep.getStartNum().
compareTo(lineClearanceNum) <= 0
&& priceStep.getEndNum().compareTo(lineClearanceNum) >= 0).findFirst().orElse(null);
if (Objects.nonNull(priceStepDO)) {
BigDecimal productClearancePrice =
productExchangeRate.getCurrencyRate().multiply(priceStepDO.getClearancePrice()).setScale(2, BigDecimal.ROUND_HALF_UP);
if (lineClearanceBasePrice.getClearancePrice().compareTo(BigDecimal.ZERO) > 0) {
if (productClearancePrice.compareTo(lineClearanceBasePrice.getProductClearanceAsExchangePrice()) > 0) {
lineClearanceBasePrice.setClearanceStepPriceId(priceStepDO.getId());
lineClearanceBasePrice.setAirClearanceSource(4);
lineClearanceBasePrice.setClearancePrice(priceStepDO.getClearancePrice());
lineClearanceBasePrice.setAirClearanceInfo(JSONObject.toJSONString(priceStepDO));
} }
airClearanceSource = result >= 0 ? 3 : 4;
clearancePrice = result >= 0 ? clearanceBasePrice : lineClearanceBasePrice;
} else { } else {
clearancePrice = clearanceBasePrice; BeanUtils.copyProperties(priceStepDO, lineClearanceBasePrice);
lineClearanceBasePrice.setClearanceStepPriceId(priceStepDO.getId());
lineClearanceBasePrice.setAirClearanceSource(4);
lineClearanceBasePrice.setClearancePrice(priceStepDO.getClearancePrice());
lineClearanceBasePrice.setAirClearanceInfo(JSONObject.toJSONString(priceStepDO));
lineClearanceBasePrice.setProductClearanceAsExchangePrice(productClearancePrice);
} }
} else {
clearancePrice = clearanceBasePrice;
} }
productPriceDO.setClearancePrice(clearancePrice.getClearancePrice());
productPriceDO.setClearanceStepPriceId(clearancePrice.getClearanceStepPriceId());
productPriceDO.setProductPriceEmptyType(clearancePrice.getProductPriceEmptyType());
productPriceDO.setAirClearanceInfo(clearancePrice.getAirClearanceInfo());// 清关费详情
prodParam.setAirClearanceSource(airClearanceSource);// 清关费来源
prodParam.setAirClearanceInfo(productPriceDO.getAirClearanceInfo());// 清关费详情
} else { } else {
log.info("===== 线路无牌无液无电清关费阶梯价不存在【{} {}】该档次 =====", num, prodParam.getClearanceUnitDO().getFuhao()); //线路渠道清关费阶梯价格 为空
productPriceDO.setClearancePrice(BigDecimal.ZERO); zTest3 z = new zTest3();
z.setCreatedate(new Date());
z.setTestname("线路渠道清关费阶梯价格 为空");
zTestMapper.insert(z);
} }
} }
} else { if (lineClearanceBasePrice != null) {
BasePrice allBasePrice = productPriceStepService.getProductPriceStep(productPriceDO.getId(), num, 1); int result = 0;
if (Objects.nonNull(allBasePrice)) { if (!clearanceBasePrice.getClearancePriceUnit().
log.info("===== 线路无牌无液无电全包阶梯价:{} =====", JSONObject.toJSONString(allBasePrice)); equals(lineClearanceBasePrice.getClearancePriceUnit())) {
productPriceDO.setAllPrice(allBasePrice.getAllPrice()); ExchangeRateRespDTO productExchangeRate =
productPriceDO.setAllStepPriceId(allBasePrice.getAllStepPriceId()); currencyApi.getCurrencyRate(
clearanceBasePrice.getClearancePriceUnit(), 1L);
BigDecimal productClearancePrice =
productExchangeRate.getCurrencyRate().
multiply(clearanceBasePrice.getClearancePrice()).setScale(2, BigDecimal.ROUND_HALF_UP);
BigDecimal lineClearancePrice =
lineClearanceBasePrice.getProductClearanceAsExchangePrice();
result = productClearancePrice.compareTo(lineClearancePrice);
} else {
result = clearanceBasePrice.getClearancePrice().
compareTo(lineClearanceBasePrice.getClearancePrice());
}
airClearanceSource = result >= 0 ? 3 : 4;
clearancePrice = result >= 0 ? clearanceBasePrice : lineClearanceBasePrice;
} else { } else {
log.info("===== 线路无牌无液无电全包阶梯价不存在【{} {}】该档次 =====", num, prodParam.getUnitDO().getFuhao()); clearancePrice = clearanceBasePrice;
productPriceDO.setNeedPay(null);
productPriceDO.setAllPrice(BigDecimal.ZERO);
} }
} else {
zTest3 z = new zTest3();
z.setCreatedate(new Date());
z.setTestname("线路渠道包装类型为空");
zTestMapper.insert(z);
clearancePrice = clearanceBasePrice;
} }
//设置清关价
//lanbm 2024-06-21 注释此处
productPriceDO.setClearancePrice(
clearancePrice.getClearancePrice());
productPriceDO.setClearanceStepPriceId(
clearancePrice.getClearanceStepPriceId());
productPriceDO.setProductPriceEmptyType(
clearancePrice.getProductPriceEmptyType());
productPriceDO.setAirClearanceInfo(
clearancePrice.getAirClearanceInfo());// 清关费详情
prodParam.setAirClearanceSource(airClearanceSource);// 清关费来源
prodParam.setAirClearanceInfo(
productPriceDO.getAirClearanceInfo());// 清关费详情
} else {
zTest3 z = new zTest3();
z.setCreatedate(new Date());
z.setTestname("线路无牌无液无电清关费阶梯价不存在【"
+ num +
prodParam.getClearanceUnitDO().getFuhao() + "】该档次"
);
zTestMapper.insert(z);
productPriceDO.setClearancePrice(BigDecimal.ZERO);
} }
} }
......
package cn.iocoder.yudao.framework.toolkit; package cn.iocoder.yudao.module.product.dal.dataobject.coupon;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data; import lombok.Data;
import java.util.Date; import java.util.Date;
@TableName("z_test") @TableName("z_test")
@Data @Data
public class zTest { public class zTest3 {
private Long id; private Long id;
private String testname; private String testname;
......
...@@ -67,6 +67,7 @@ public class BasePrice extends BaseDO { ...@@ -67,6 +67,7 @@ public class BasePrice extends BaseDO {
* 全包价金额单位 * 全包价金额单位
*/ */
private Long allPriceUnit; private Long allPriceUnit;
/** /**
* 全包价体积单位 * 全包价体积单位
*/ */
......
package cn.iocoder.yudao.module.product.dal.mysql.coupon;
import cn.iocoder.yudao.framework.mybatis.core.mapper.AbstractMapper;
import cn.iocoder.yudao.module.product.dal.dataobject.coupon.zTest3;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ZTestMapper3 extends AbstractMapper<zTest3> {
}
...@@ -81,6 +81,7 @@ public class ProdCostDto { ...@@ -81,6 +81,7 @@ public class ProdCostDto {
*/ */
private Long freightVolume; private Long freightVolume;
//返回给前端页面的清关价
@ApiModelProperty(value = "商品清关费单价(成交)") @ApiModelProperty(value = "商品清关费单价(成交)")
private BigDecimal oneClearanceFee; private BigDecimal oneClearanceFee;
......
...@@ -58,9 +58,15 @@ public class ProductPriceStepServiceImpl extends AbstractService<ProductPriceSte ...@@ -58,9 +58,15 @@ public class ProductPriceStepServiceImpl extends AbstractService<ProductPriceSte
); );
} }
//获取阶梯价
@Override @Override
public BasePrice getProductPriceStep(Long productPriceId, BigDecimal num, Integer priceType) { public BasePrice getProductPriceStep(Long productPriceId,
List<ProductPriceStepDO> list = this.list(new LambdaQueryWrapperX<ProductPriceStepDO>() BigDecimal num,
Integer priceType) {
//0-运费,1-全包价, 2-清关费
List<ProductPriceStepDO> list = this.list(
new LambdaQueryWrapperX<ProductPriceStepDO>()
.eq(ProductPriceStepDO::getProductPriceId, productPriceId) .eq(ProductPriceStepDO::getProductPriceId, productPriceId)
.eq(ProductPriceStepDO::getPriceType, priceType) .eq(ProductPriceStepDO::getPriceType, priceType)
.eq(ProductPriceStepDO::getDeleted, 0) .eq(ProductPriceStepDO::getDeleted, 0)
...@@ -72,7 +78,10 @@ public class ProductPriceStepServiceImpl extends AbstractService<ProductPriceSte ...@@ -72,7 +78,10 @@ public class ProductPriceStepServiceImpl extends AbstractService<ProductPriceSte
if (CollectionUtil.isEmpty(list)){ if (CollectionUtil.isEmpty(list)){
productPriceEmptyType = 1; productPriceEmptyType = 1;
}else { }else {
ProductPriceStepDO priceStepDO = list.stream().filter(priceStep -> priceStep.getStartNum().compareTo(num) <= 0 && priceStep.getEndNum().compareTo(num) >= 0).findFirst().orElse(null); ProductPriceStepDO priceStepDO =
list.stream().filter(priceStep ->
priceStep.getStartNum().compareTo(num) <= 0 &&
priceStep.getEndNum().compareTo(num) >= 0).findFirst().orElse(null);
basePrice = new BasePrice(); basePrice = new BasePrice();
if (Objects.isNull(priceStepDO)){ if (Objects.isNull(priceStepDO)){
productPriceEmptyType = 2; productPriceEmptyType = 2;
......
...@@ -2,11 +2,13 @@ package cn.iocoder.yudao.module.product.controller.admin.prod; ...@@ -2,11 +2,13 @@ package cn.iocoder.yudao.module.product.controller.admin.prod;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
import cn.iocoder.yudao.module.product.component.ProdCostCalculation; import cn.iocoder.yudao.module.product.component.ProdCostCalculation;
import cn.iocoder.yudao.module.product.dto.CalculationCostResultDto; import cn.iocoder.yudao.module.product.dto.CalculationCostResultDto;
import cn.iocoder.yudao.module.product.param.ConditionParam; import cn.iocoder.yudao.module.product.param.ConditionParam;
import cn.iocoder.yudao.module.product.param.ProdConditionParam; import cn.iocoder.yudao.module.product.param.ProdConditionParam;
import cn.iocoder.yudao.module.product.service.coupon.CouponService; import cn.iocoder.yudao.module.product.service.coupon.CouponService;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -44,11 +46,20 @@ public class ProdLinePriceController { ...@@ -44,11 +46,20 @@ public class ProdLinePriceController {
public CommonResult<CalculationCostResultDto> calculationProdCost( public CommonResult<CalculationCostResultDto> calculationProdCost(
@RequestBody ConditionParam param) { @RequestBody ConditionParam param) {
//lanbm 2024-06-20 记录的参数日志
//String listToString = JSON.toJSONString(param);
//JsonUtils.SaveLog(listToString);
if (CollectionUtil.isEmpty(param.getProdConditionParamList())) { if (CollectionUtil.isEmpty(param.getProdConditionParamList())) {
return error(ORDER_ITEM_PROD_NOT_EXISTS); return error(ORDER_ITEM_PROD_NOT_EXISTS);
} }
// 前端实时计价时需要将订单的固定价格参数进行格式化,转为未定价,否则不会去查询当前实时价格 // 前端实时计价时需要将订单的固定价格参数进行格式化,转为未定价,否则不会去查询当前实时价格
param.setProdConditionParamList(param.getProdConditionParamList().stream().peek(it -> it.setIsPriced(false)).collect(Collectors.toList())); param.setProdConditionParamList(
param.getProdConditionParamList().stream().
peek(it -> it.setIsPriced(false)).
collect(Collectors.toList()));
//获取价格信息 lanbm 2024-06-20 添加注释
List<ProdConditionParam> prodConditionParams = List<ProdConditionParam> prodConditionParams =
prodCostCalculation.obtainProdLineOnePrice( prodCostCalculation.obtainProdLineOnePrice(
param.getProdConditionParamList(), param.getProdConditionParamList(),
...@@ -59,6 +70,7 @@ public class ProdLinePriceController { ...@@ -59,6 +70,7 @@ public class ProdLinePriceController {
param.getLineId(), param.getLineId(),
param.getChannelId(), param.getChannelId(),
false); false);
CalculationCostResultDto dto = CalculationCostResultDto dto =
prodCostCalculation.calculationProdCost(prodConditionParams, prodCostCalculation.calculationProdCost(prodConditionParams,
"", "",
......
...@@ -63,7 +63,9 @@ public class ReceivableController { ...@@ -63,7 +63,9 @@ public class ReceivableController {
@GetMapping("/getReceivableListByOrderId") @GetMapping("/getReceivableListByOrderId")
@ApiOperation("根据订单ID获得应收款列表") @ApiOperation("根据订单ID获得应收款列表")
@ApiImplicitParam(name = "id", value = "订单ID", required = true, example = "1024", dataTypeClass = Long.class) @ApiImplicitParam(name = "id", value = "订单ID", required = true, example = "1024", dataTypeClass = Long.class)
public CommonResult<List<ReceivableBackVO>> getReceivableListByOrderId(@RequestParam("id") Long id) { public CommonResult<List<ReceivableBackVO>> getReceivableListByOrderId(
@RequestParam("id") Long id) {
//lanbm 2024-06-20 添加注释
return success(receivableService.getReceivableListByOrderId(id)); return success(receivableService.getReceivableListByOrderId(id));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment