Commit d5b87e7b by 周晓航

新增配置规则 走重量计算, 没配置按照原始逻辑 1kg传值

parent d59212aa
......@@ -9,6 +9,7 @@ import com.freemud.application.sdk.api.ordercenter.entities.v1.ProductBeanV1;
import com.freemud.application.sdk.api.ordercenter.enums.OrderType;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
......@@ -17,6 +18,10 @@ import java.util.stream.Collectors;
@Component
public class DeliverySdkAdapter {
@Value("${calculate.depatch.weight.partnerId:}")
private List<String> calculateWeightPartnerId;
/**
* 创建配送单请求对象
*
......@@ -28,7 +33,7 @@ public class DeliverySdkAdapter {
public CreateDeliveryOrderRequestDto buildDeliveryOrderRequestDto(OrderBeanV1 order
, ConsoleResponseDTO<BizDTO> bizDTO, String deliveryCallBackUrl) {
CreateDeliveryOrderRequestDto deliveryOrderRequestDto = new CreateDeliveryOrderRequestDto();
deliveryOrderRequestDto.setDepatchWeight(this.getDepatchWeightByOrder(order.getProductList()));
deliveryOrderRequestDto.setDepatchWeight(this.getDepatchWeightByOrder(order.getProductList(), order.getCompanyId()));
deliveryOrderRequestDto.setSerialNumber(order.getOtherCode());
deliveryOrderRequestDto.setOrderId(order.getOid());
deliveryOrderRequestDto.setOrderRemark(order.getRemark());
......@@ -78,7 +83,11 @@ public class DeliverySdkAdapter {
return deliveryOrderRequestDto;
}
private BigDecimal getDepatchWeightByOrder(List<ProductBeanV1> productList) {
private BigDecimal getDepatchWeightByOrder(List<ProductBeanV1> productList, String partnerId) {
if (CollectionUtils.isEmpty(calculateWeightPartnerId) || !calculateWeightPartnerId.contains(partnerId)) {
// 原始逻辑,都是默认传递 1kg给到配送
return new BigDecimal("1");
}
if (CollectionUtils.isEmpty(productList)) {
return new BigDecimal("0.5");
}
......
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