Commit d5b87e7b by 周晓航

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

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