Browse Source

Merge branch 'dev' into pre-production

pre-production
zhaoqiaobo 4 days ago
parent
commit
dde34170f4
  1. 87
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/DeliverFinishReportListener.java

87
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/DeliverFinishReportListener.java

@ -210,6 +210,7 @@ public class DeliverFinishReportListener implements ReportService {
continue;
}
ExpenseDispatchClientDTO expenseDispatchClientDTO = expenseDispatchClient.findPriceByDriverId(qualityDeliverEntity.getWarehouseId(), driverId, qualityDeliverEntity.getSignCarTypeId(), qualityDeliverEntity.getDeliveryType());
log.info("车次完成计算价格,价格:{}", JSONUtil.toJsonStr(expenseDispatchClientDTO));
if (ObjectUtil.isNotEmpty(expenseDispatchClientDTO)) {
ExpenseDispatchPriceVO priceVO = expenseDispatchClientDTO.getPriceVO();
// 整车计费,则车内的每个包件分摊整车成本费用
@ -253,6 +254,11 @@ public class DeliverFinishReportListener implements ReportService {
}
// 计算配送成本
if (CollUtil.isNotEmpty(priceList)) {
List<ExpenseDispatchPriceCategoryVO> bzjs = priceList.stream().filter(v -> ObjectUtil.equals("标准件", v.getCategoryName())).collect(Collectors.toList());
ExpenseDispatchPriceCategoryVO bzj = null;
if(CollUtil.isNotEmpty(bzjs)){
bzj = bzjs.get(0);
}
Map<Long, ExpenseDispatchPriceCategoryVO> priceMap = priceList.stream().collect(Collectors.toMap(ExpenseDispatchPriceCategoryVO::getCategoryId, v -> v));
// 车的总运费 用于计算是否触发保底
for (QualityDeliverEntity entity : value) {
@ -260,33 +266,10 @@ public class DeliverFinishReportListener implements ReportService {
QualityDeliverEntity entity1 = valueMap.get(id);
if (ObjectUtil.isNotEmpty(entity1.getCostCategoryId()) && priceMap.containsKey(entity1.getCostCategoryId())) {
ExpenseDispatchPriceCategoryVO expenseDispatchPriceCategoryVO = priceMap.get(entity1.getCostCategoryId());
String cost = expenseDispatchPriceCategoryVO.getCost();
Integer unit = expenseDispatchPriceCategoryVO.getUnit();
if (StrUtil.isNotEmpty(cost)) {
if (NumberUtil.equals(unit, 1)) {
// 按件 成本就是单价
BigDecimal mul = NumberUtil.mul(entity.getSignNum(), new BigDecimal(cost));
entity1.setDistributionCost(mul);
totalFreight = totalFreight.add(mul);
}
if (NumberUtil.equals(unit, 2)) {
// 按方 成本 = 总体积 * 单价
BigDecimal volume = entity.getVolume();
if (ObjectUtil.isNotEmpty(volume)) {
BigDecimal mul = NumberUtil.mul(volume, new BigDecimal(cost));
entity1.setDistributionCost(mul);
totalFreight = totalFreight.add(mul);
}
}
if (NumberUtil.equals(unit, 3)) {
// 按重量 成本 = 总重量 * 单价
BigDecimal weight = entity.getWeight();
if (ObjectUtil.isNotEmpty(weight)) {
BigDecimal mul = NumberUtil.mul(weight, new BigDecimal(cost));
entity1.setDistributionCost(mul);
totalFreight = totalFreight.add(mul);
}
}
totalFreight = buildDisCost(entity, expenseDispatchPriceCategoryVO, entity1, totalFreight);
}else {
if(ObjectUtil.isNotEmpty(bzj)){
totalFreight = buildDisCost(entity, bzj, entity1, totalFreight);
}
}
}
@ -615,7 +598,7 @@ public class DeliverFinishReportListener implements ReportService {
String overZoneKilometer = priceVO.getOverZoneKilometer();
if (StrUtil.isNotEmpty(overZoneKilometer)) {
if (total.compareTo(new BigDecimal(overZoneKilometer)) > 0) {
String overZoneKilometerCost = StrUtil.isNotEmpty(priceVO.getOverZoneKilometerCost()) ? "0" : priceVO.getOverZoneKilometerCost();
String overZoneKilometerCost = StrUtil.isEmpty(priceVO.getOverZoneKilometerCost()) ? "0" : priceVO.getOverZoneKilometerCost();
BigDecimal mul = NumberUtil.mul(NumberUtil.sub(total, new BigDecimal(overZoneKilometerCost)), new BigDecimal(overZoneKilometer));
buildUltrAllpwCost(valueMap, mul, totalNum);
}
@ -643,7 +626,7 @@ public class DeliverFinishReportListener implements ReportService {
String overZoneKilometer = priceVO.getOverZoneKilometer();
if (StrUtil.isNotEmpty(overZoneKilometer)) {
if (total.compareTo(new BigDecimal(overZoneKilometer)) > 0) {
String overZoneKilometerCost = StrUtil.isNotEmpty(priceVO.getOverZoneKilometerCost()) ? "0" : priceVO.getOverZoneKilometerCost();
String overZoneKilometerCost = StrUtil.isEmpty(priceVO.getOverZoneKilometerCost()) ? "0" : priceVO.getOverZoneKilometerCost();
BigDecimal mul = NumberUtil.mul(NumberUtil.sub(total, new BigDecimal(overZoneKilometerCost)), new BigDecimal(overZoneKilometer));
buildUltrAllpwCost(valueMap, mul, totalNum);
}
@ -705,7 +688,7 @@ public class DeliverFinishReportListener implements ReportService {
String overZoneKilometer = priceVO.getOverZoneKilometer();
if (StrUtil.isNotEmpty(overZoneKilometer)) {
if (total.compareTo(new BigDecimal(overZoneKilometer)) > 0) {
String overZoneKilometerCost = StrUtil.isNotEmpty(priceVO.getOverZoneKilometerCost()) ? "0" : priceVO.getOverZoneKilometerCost();
String overZoneKilometerCost = StrUtil.isEmpty(priceVO.getOverZoneKilometerCost()) ? "0" : priceVO.getOverZoneKilometerCost();
BigDecimal mul = NumberUtil.mul(NumberUtil.sub(total, new BigDecimal(overZoneKilometerCost)), new BigDecimal(overZoneKilometer));
buildUltrAllpwCost(valueMap, mul, totalNum);
}
@ -768,7 +751,7 @@ public class DeliverFinishReportListener implements ReportService {
if (!NumberUtil.equals(dkp, 0)) {
dkp = dkp - 1;
}
String siteSubsidyCost = StrUtil.isNotEmpty(priceVO.getSiteSubsidyCost()) ? "0" : priceVO.getSiteSubsidyCost();
String siteSubsidyCost = StrUtil.isEmpty(priceVO.getSiteSubsidyCost()) ? "0" : priceVO.getSiteSubsidyCost();
BigDecimal mul = NumberUtil.mul(dkp, new BigDecimal(siteSubsidyCost));
buildPointAllowCost(valueMap, mul, totalNum);
}
@ -804,7 +787,7 @@ public class DeliverFinishReportListener implements ReportService {
}
}
// 总公里数成本 = (总公里数 * 油费单价) / 总件数
String fuelCost = StrUtil.isNotEmpty(priceVO.getFuelCost()) ? "0" : priceVO.getFuelCost();
String fuelCost = StrUtil.isEmpty(priceVO.getFuelCost()) ? "0" : priceVO.getFuelCost();
BigDecimal mul = NumberUtil.mul(total, new BigDecimal(fuelCost));
buildFuelCost(valueMap, mul, totalNum);
}
@ -832,7 +815,7 @@ public class DeliverFinishReportListener implements ReportService {
}
}
// 总公里数成本 = (总公里数 * 油费单价) / 总件数
String fuelCost = StrUtil.isNotEmpty(priceVO.getFuelCost()) ? "0" : priceVO.getFuelCost();
String fuelCost = StrUtil.isEmpty(priceVO.getFuelCost()) ? "0" : priceVO.getFuelCost();
BigDecimal mul = NumberUtil.mul(total, new BigDecimal(fuelCost));
buildFuelCost(valueMap, mul, totalNum);
}
@ -869,7 +852,7 @@ public class DeliverFinishReportListener implements ReportService {
}
}
// 总公里数成本 = (总公里数 * 油费单价) / 总件数
String fuelCost = StrUtil.isNotEmpty(priceVO.getFuelCost()) ? "0" : priceVO.getFuelCost();
String fuelCost = StrUtil.isEmpty(priceVO.getFuelCost()) ? "0" : priceVO.getFuelCost();
BigDecimal mul = NumberUtil.mul(total, new BigDecimal(fuelCost));
buildFuelCost(valueMap, mul, totalNum);
}
@ -940,6 +923,38 @@ public class DeliverFinishReportListener implements ReportService {
}
private static BigDecimal buildDisCost(QualityDeliverEntity entity, ExpenseDispatchPriceCategoryVO expenseDispatchPriceCategoryVO, QualityDeliverEntity entity1, BigDecimal totalFreight) {
String cost = expenseDispatchPriceCategoryVO.getCost();
Integer unit = expenseDispatchPriceCategoryVO.getUnit();
if (StrUtil.isNotEmpty(cost)) {
if (NumberUtil.equals(unit, 1)) {
// 按件 成本就是单价
BigDecimal mul = NumberUtil.mul(entity.getSignNum(), new BigDecimal(cost));
entity1.setDistributionCost(mul);
totalFreight = totalFreight.add(mul);
}
if (NumberUtil.equals(unit, 2)) {
// 按方 成本 = 总体积 * 单价
BigDecimal volume = entity.getVolume();
if (ObjectUtil.isNotEmpty(volume)) {
BigDecimal mul = NumberUtil.mul(volume, new BigDecimal(cost));
entity1.setDistributionCost(mul);
totalFreight = totalFreight.add(mul);
}
}
if (NumberUtil.equals(unit, 3)) {
// 按重量 成本 = 总重量 * 单价
BigDecimal weight = entity.getWeight();
if (ObjectUtil.isNotEmpty(weight)) {
BigDecimal mul = NumberUtil.mul(weight, new BigDecimal(cost));
entity1.setDistributionCost(mul);
totalFreight = totalFreight.add(mul);
}
}
}
return totalFreight;
}
private static void buildUltrAllpwCost(Map<Long, QualityDeliverEntity> valueMap, BigDecimal mul, Integer totalNum) {
BigDecimal deliveryFeeSum = BigDecimal.ZERO;
int idex = 0;
@ -995,7 +1010,7 @@ public class DeliverFinishReportListener implements ReportService {
}
private static void buildAllowKilowCost(ExpenseDispatchPriceVO priceVO, BigDecimal total, String subsidyInitKilometer, Map<Long, QualityDeliverEntity> valueMap, Integer totalNum) {
String subsidyCost = StrUtil.isNotEmpty(priceVO.getSubsidyCost()) ? "0" : priceVO.getSubsidyCost();
String subsidyCost = StrUtil.isEmpty(priceVO.getSubsidyCost()) ? "0" : priceVO.getSubsidyCost();
BigDecimal mul = NumberUtil.mul(NumberUtil.sub(total, new BigDecimal(subsidyInitKilometer)), new BigDecimal(subsidyCost));
BigDecimal deliveryFeeSum = BigDecimal.ZERO;
int idex = 0;
@ -1015,7 +1030,7 @@ public class DeliverFinishReportListener implements ReportService {
}
private static void buildKilometerCost(ExpenseDispatchPriceVO priceVO, BigDecimal total, Map<Long, QualityDeliverEntity> valueMap, Integer totalNum) {
String kilometerCost = StrUtil.isNotEmpty(priceVO.getKilometerCost()) ? "0" : priceVO.getKilometerCost();
String kilometerCost = StrUtil.isEmpty(priceVO.getKilometerCost()) ? "0" : priceVO.getKilometerCost();
BigDecimal mul = NumberUtil.mul(total, new BigDecimal(kilometerCost));
BigDecimal deliveryFeeSum = BigDecimal.ZERO;
int idex = 0;

Loading…
Cancel
Save