Commit 367adc5c by 周晓航

修改bug

parent 19f439d2
...@@ -27,7 +27,6 @@ public class DeliverySdkAdapter { ...@@ -27,7 +27,6 @@ public class DeliverySdkAdapter {
*/ */
public CreateDeliveryOrderRequestDto buildDeliveryOrderRequestDto(OrderBeanV1 order public CreateDeliveryOrderRequestDto buildDeliveryOrderRequestDto(OrderBeanV1 order
, ConsoleResponseDTO<BizDTO> bizDTO, String deliveryCallBackUrl) { , ConsoleResponseDTO<BizDTO> bizDTO, String deliveryCallBackUrl) {
StoreInfoDTO storeInfo = bizDTO.getBizVO().getStoreInfo();
CreateDeliveryOrderRequestDto deliveryOrderRequestDto = new CreateDeliveryOrderRequestDto(); CreateDeliveryOrderRequestDto deliveryOrderRequestDto = new CreateDeliveryOrderRequestDto();
deliveryOrderRequestDto.setDepatchWeight(this.getDepatchWeightByOrder(order.getProductList())); deliveryOrderRequestDto.setDepatchWeight(this.getDepatchWeightByOrder(order.getProductList()));
deliveryOrderRequestDto.setSerialNumber(order.getOtherCode()); deliveryOrderRequestDto.setSerialNumber(order.getOtherCode());
...@@ -37,6 +36,7 @@ public class DeliverySdkAdapter { ...@@ -37,6 +36,7 @@ public class DeliverySdkAdapter {
deliveryOrderRequestDto.setOrderActualAmount(order.getAmount().intValue()); deliveryOrderRequestDto.setOrderActualAmount(order.getAmount().intValue());
deliveryOrderRequestDto.setPartnerId(order.getCompanyId()); deliveryOrderRequestDto.setPartnerId(order.getCompanyId());
deliveryOrderRequestDto.setOrderChannel(order.getSource()); deliveryOrderRequestDto.setOrderChannel(order.getSource());
StoreInfoDTO storeInfo = bizDTO.getBizVO().getStoreInfo();
deliveryOrderRequestDto.setStoreId(storeInfo.getStoreId()); deliveryOrderRequestDto.setStoreId(storeInfo.getStoreId());
deliveryOrderRequestDto.setStoreCode(storeInfo.getStoreCode()); deliveryOrderRequestDto.setStoreCode(storeInfo.getStoreCode());
StringBuffer address = new StringBuffer(storeInfo.getCity()) StringBuffer address = new StringBuffer(storeInfo.getCity())
...@@ -83,27 +83,32 @@ public class DeliverySdkAdapter { ...@@ -83,27 +83,32 @@ public class DeliverySdkAdapter {
return new BigDecimal("0.5"); return new BigDecimal("0.5");
} }
BigDecimal result = BigDecimal.ZERO; BigDecimal result = BigDecimal.ZERO;
productList.forEach(p -> { for (ProductBeanV1 p : productList) {
BigDecimal sum = p.getWeight().multiply(new BigDecimal(p.getNumber())); BigDecimal sum = p.getWeight().multiply(new BigDecimal(p.getNumber()));
if (CollectionUtils.isNotEmpty(p.getComboProduct())) { BigDecimal comboSum = this.sumWeightByProduct(p.getComboProduct());
long comboProductSum = p.getComboProduct().stream().mapToLong(value -> value.getWeight().multiply(new BigDecimal(value.getNumber())).longValue()).sum(); BigDecimal materSum = this.sumWeightByProduct(p.getMaterialProduct());
if (CollectionUtils.isNotEmpty(p.getMaterialProduct())) { BigDecimal sendSum = this.sumWeightByProduct(p.getSendProduct());
long materialProductSum = p.getMaterialProduct().stream().mapToLong(value -> value.getWeight().multiply(new BigDecimal(value.getNumber())).longValue()).sum(); result = result.add(sum).add(comboSum).add(materSum).add(sendSum);
comboProductSum += materialProductSum; }
}
if (CollectionUtils.isNotEmpty(p.getSendProduct())) {
long sendProductSum = p.getSendProduct().stream().mapToLong(value -> value.getWeight().multiply(new BigDecimal(value.getNumber())).longValue()).sum();
comboProductSum += sendProductSum;
}
BigDecimal otherProductSum = new BigDecimal(comboProductSum);
sum.add(otherProductSum);
}
result.add(sum);
});
if (result.compareTo(BigDecimal.ZERO) <= 0) { if (result.compareTo(BigDecimal.ZERO) <= 0) {
return new BigDecimal("0.5"); return new BigDecimal("0.5");
} }
// 这里 计算的结果是 g 需要变成 kg 给接口 保留3位小数 后面多余直接舍弃 // 这里 计算的结果是 g 需要变成 kg 给接口 保留3位小数 后面多余直接舍弃
return result.divide(new BigDecimal("1000"), 3, BigDecimal.ROUND_DOWN); return result.divide(new BigDecimal("1000"), 3, BigDecimal.ROUND_DOWN);
} }
private BigDecimal sumWeightByProduct(List<ProductBeanV1> productBeanV) {
BigDecimal result = BigDecimal.ZERO;
if (CollectionUtils.isEmpty(productBeanV)) {
return result;
}
for (ProductBeanV1 p : productBeanV) {
BigDecimal weight = p.getWeight();
int number = p.getNumber();
BigDecimal multiply = weight.multiply(new BigDecimal(number));
result = result.add(multiply);
}
return result;
}
} }
...@@ -102,7 +102,7 @@ public class DeliveryHandle { ...@@ -102,7 +102,7 @@ public class DeliveryHandle {
} }
// 调用配送系统创建配送单 // 调用配送系统创建配送单
CreateDeliveryOrderRequestDto requestDto = deliverySdkAdapter.buildDeliveryOrderRequestDto(orderBean, storeInfo, deliveryCallBackUrl); CreateDeliveryOrderRequestDto requestDto = deliverySdkAdapter.buildDeliveryOrderRequestDto(orderBean, storeInfo, deliveryCallBackUrl);
logUtil.info("fisherman -> 配送计算金额 ",orderBean.getOid(),JSON.toJSONString(requestDto)); logUtil.info("fisherman -> 配送计算金额 ",orderBean.getOid(),JSON.toJSONString(requestDto),JSON.toJSONString(orderBean.getProductList()));
CreateDeliveryOrderResponseDto deliveryResponse = deliveryService.deliveryOrderAdd(requestDto, LogThreadLocal.getTrackingNo()); CreateDeliveryOrderResponseDto deliveryResponse = deliveryService.deliveryOrderAdd(requestDto, LogThreadLocal.getTrackingNo());
String operator = request == null || StringUtils.isBlank(request.getOperator()) ? "系统" : request.getOperator(); String operator = request == null || StringUtils.isBlank(request.getOperator()) ? "系统" : request.getOperator();
......
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