Commit b651af2e by dingkai

购物车配送费

parent 731cade8
......@@ -59,7 +59,7 @@
</dependency>
<dependency>
<groupId>com.freemud.application.service.sdk</groupId>
<version>1.4.1-SNAPSHOT</version>
<version>2.6.1-SNAPSHOT</version>
<artifactId>storecenter-sdk</artifactId>
</dependency>
......
......@@ -58,6 +58,7 @@ public enum ResponseResult {
STORE_BUSINESS_HOUR_ERROR("43010", "门店营业时间错误"),
STORE_NOT_ENABLE_COLLECT_GOODS("43011", "门店不支持到店"),
STORE_MALL_NOT_FOUND("43012", "商城门店不存在"),
STORE_DELIVERY_AMOUNT_ERROR("43013", "配送费错误"),
/**
* 购物车状态码
......
......@@ -50,7 +50,9 @@ import com.freemud.application.sdk.api.paymentcenter.client.response.SVCCardAmou
import com.freemud.application.sdk.api.paymentcenter.client.service.PaymentNewService;
import com.freemud.application.sdk.api.productcenter.domain.ProductBeanDTO;
import com.freemud.application.sdk.api.promotioncenter.response.ActivityResponse;
import com.freemud.application.sdk.api.storecenter.request.QueryDeliveryRequest;
import com.freemud.application.sdk.api.storecenter.request.StoreInfoRequest;
import com.freemud.application.sdk.api.storecenter.response.QueryDeliverDetailResponse;
import com.freemud.application.sdk.api.storecenter.response.StoreResponse;
import com.freemud.application.sdk.api.storecenter.service.StoreCenterService;
import com.freemud.sdk.api.assortment.shoppingcart.constant.CommonsConstant;
......@@ -84,6 +86,10 @@ import static java.util.stream.Collectors.toList;
@Service
public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
// 配送费逻辑是否使用旧的
@Value("${store.delivery.use:old:false}")
private boolean storeDeliveryUseOld;
@Autowired
private ActivityAdapter activityAdapter;
@Autowired
......@@ -1439,6 +1445,34 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
return amount;
}
private Long getNewDeliveryAmount(String receiveId, String partnerId, String storeId) {
String trackingNo = LogThreadLocal.getTrackingNo();
Long amount = 0L;
if (StringUtils.isBlank(receiveId)) {
return amount;
}
QueryReceiveAddressRequest queryReceive = new QueryReceiveAddressRequest(receiveId, partnerId);
//查询会员后货地址经纬度
com.freemud.application.sdk.api.base.BaseResponse<QueryReceiveAddressResponse> queryReceiveAddressResponse = memberCenterService.queryReceiveAddressById(queryReceive, trackingNo);
if (!ResponseResult.SUCCESS.getCode().equals(queryReceiveAddressResponse.getCode()) || queryReceiveAddressResponse.getData() == null) {
throw new ServiceException(ResponseResult.USER_GETRECEIVEADDRESS_ERROR);
}
QueryDeliveryRequest queryDeliveryRequest = new QueryDeliveryRequest();
queryDeliveryRequest.setPartnerId(partnerId);
queryDeliveryRequest.setStoreCode(storeId);
queryDeliveryRequest.setUserLatitude(queryReceiveAddressResponse.getData().getLatitude());
queryDeliveryRequest.setUserLongitude(queryReceiveAddressResponse.getData().getLongitude());
com.freemud.application.sdk.api.base.BaseResponse<QueryDeliverDetailResponse> queryDeliverDetailResponse = storeCenterService.queryDeliverDetail(queryDeliveryRequest, trackingNo);
if (queryDeliverDetailResponse == null || queryDeliverDetailResponse.getStatusCode() != 100 || queryDeliverDetailResponse.getData() == null) {
throw new ServiceException(ResponseResult.STORE_ITEM_NOT_DELIVERY);
}
if(queryDeliverDetailResponse.getData().getDeliveryAmount() == null) {
throw new ServiceException(ResponseResult.STORE_DELIVERY_AMOUNT_ERROR);
}
return queryDeliverDetailResponse.getData().getDeliveryAmount();
}
/**
* 获取配送范围内集合
*/
......@@ -1484,12 +1518,18 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
}
private Long calculateDeliveryAmount(String receiveId,String partnerId,String storeId,String wxappid){
Long deliveryAmount = 0l;
if(receiveId==null) {
}else{
Long deliveryAmount = 0L;
if(StringUtils.isBlank(receiveId)) {
return deliveryAmount;
}
log.info("获取配送配逻辑 tackingNo:{},storeDeliveryUseOld:{},receiveId:{},partnerId:{},storeId:{}", LogThreadLocal.getTrackingNo(), storeDeliveryUseOld, receiveId, partnerId, storeId);
if(storeDeliveryUseOld) {
deliveryAmount = Long.parseLong(getDeliveryAmount(receiveId,partnerId,storeId).toString());
} else {
deliveryAmount = getNewDeliveryAmount(receiveId, partnerId, storeId);
}
return deliveryAmount;
}
}
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