Commit d7210f5d by dingkai

Merge branch 'feature/1.9.21-配送费20200424-dingkai'

parents 206c3f1d 6c5a379e
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
<dependency> <dependency>
<groupId>com.freemud.application.service.sdk</groupId> <groupId>com.freemud.application.service.sdk</groupId>
<artifactId>storecenter-sdk</artifactId> <artifactId>storecenter-sdk</artifactId>
<version>2.3.3-SNAPSHOT</version> <version>2.6.1-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>cn.freemud</groupId> <groupId>cn.freemud</groupId>
......
...@@ -763,12 +763,23 @@ public class OrderAdapter { ...@@ -763,12 +763,23 @@ public class OrderAdapter {
fatherOrderInfo.setPayChannel("10102"); fatherOrderInfo.setPayChannel("10102");
fatherOrderInfo.setPayChannelName("储值卡支付"); fatherOrderInfo.setPayChannelName("储值卡支付");
} }
/**
long deliveryAmount = 0; long deliveryAmount = 0;
if (userDeliveryInfoDto != null) { if (userDeliveryInfoDto != null) {
deliveryAmount = getUserRealDeliveryAmount(userDeliveryInfoDto.getStoreDeliveryInfoDto(), userDeliveryInfoDto.getUserLongitude(), userDeliveryInfoDto.getUserLatitude()); deliveryAmount = getUserRealDeliveryAmount(userDeliveryInfoDto.getStoreDeliveryInfoDto(), userDeliveryInfoDto.getUserLongitude(), userDeliveryInfoDto.getUserLatitude());
}*/
long discountDeliveryAmount = 0;
if (BusinessTypeEnum.SAAS_DELIVERY.getCode().equals(createOrderVo.getMenuType())) {
long deliveryAmount = shoppingCartGoodsDto.getDeliveryAmount();
discountDeliveryAmount = shoppingCartGoodsDto.getDeliveryAmount();
if(shoppingCartGoodsDto.getIsDiscountDelivery() && deliveryAmount > shoppingCartGoodsDto.getDiscountDeliveryAmount()){
discountDeliveryAmount = shoppingCartGoodsDto.getDiscountDeliveryAmount();
}
} }
Long packageAmount = shoppingCartGoodsDto.getPackageAmount() == null ? 0 : shoppingCartGoodsDto.getPackageAmount(); Long packageAmount = shoppingCartGoodsDto.getPackageAmount() == null ? 0 : shoppingCartGoodsDto.getPackageAmount();
fatherOrderInfo.setAmount(shoppingCartGoodsDto.getTotalAmount() + deliveryAmount + packageAmount); fatherOrderInfo.setAmount(shoppingCartGoodsDto.getTotalAmount() + discountDeliveryAmount + packageAmount);
return fatherOrderInfo; return fatherOrderInfo;
} }
......
...@@ -46,7 +46,9 @@ import com.freemud.application.sdk.api.membercenter.response.GetSvcInfoByMemberI ...@@ -46,7 +46,9 @@ import com.freemud.application.sdk.api.membercenter.response.GetSvcInfoByMemberI
import com.freemud.application.sdk.api.membercenter.response.QueryReceiveAddressResponse; import com.freemud.application.sdk.api.membercenter.response.QueryReceiveAddressResponse;
import com.freemud.application.sdk.api.membercenter.service.MemberCenterService; import com.freemud.application.sdk.api.membercenter.service.MemberCenterService;
import com.freemud.application.sdk.api.membercenter.service.MemberPropertyService; import com.freemud.application.sdk.api.membercenter.service.MemberPropertyService;
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.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.response.StoreResponse;
import com.freemud.application.sdk.api.storecenter.service.StoreCenterService; import com.freemud.application.sdk.api.storecenter.service.StoreCenterService;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
...@@ -55,6 +57,7 @@ import org.apache.commons.collections4.CollectionUtils; ...@@ -55,6 +57,7 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
...@@ -66,6 +69,10 @@ import java.util.stream.Collectors; ...@@ -66,6 +69,10 @@ import java.util.stream.Collectors;
@Component @Component
public class CheckOrder { public class CheckOrder {
// 配送费逻辑是否使用旧的
@Value("${store.delivery.use.old:true}")
private boolean storeDeliveryUseOld;
@Autowired @Autowired
private StoreTableNumberManager storeTableNumberManager; private StoreTableNumberManager storeTableNumberManager;
@Autowired @Autowired
...@@ -242,7 +249,12 @@ public class CheckOrder { ...@@ -242,7 +249,12 @@ public class CheckOrder {
throw new ServiceException(ResponseResult.STORE_ITEM_NOT_DELIVERY); throw new ServiceException(ResponseResult.STORE_ITEM_NOT_DELIVERY);
} }
//获取门店配送信息 //获取门店配送信息
StoreDeliveryInfoDto storeDeliveryInfoDto = getStoreDeliveryInfo(storeResponseDto, config, appId); StoreDeliveryInfoDto storeDeliveryInfoDto = null;
if(storeDeliveryUseOld) {
storeDeliveryInfoDto = getStoreDeliveryInfo(storeResponseDto, config, appId);
} else {
storeDeliveryInfoDto = getNewStoreDeliveryInfo(storeResponseDto, config, appId, trackingNo);
}
//订单金额小于起送费提示 //订单金额小于起送费提示
if (storeDeliveryInfoDto.getDeliveryLimitAmount() > totalAmount) { if (storeDeliveryInfoDto.getDeliveryLimitAmount() > totalAmount) {
throw new ServiceException(ResponseResult.STORE_DISCONTENT_DELIVERY_FEE); throw new ServiceException(ResponseResult.STORE_DISCONTENT_DELIVERY_FEE);
...@@ -410,6 +422,59 @@ public class CheckOrder { ...@@ -410,6 +422,59 @@ public class CheckOrder {
} }
/** /**
* 获取门店配送信息
*/
public StoreDeliveryInfoDto getNewStoreDeliveryInfo(StoreResponse.BizVO storeResponseDto,
OpenPlatformIappWxappConfig openPlatformIappWxappConfig, String wxAppid, String trackingNo) {
StoreDeliveryInfoDto storeDeliveryInfoDto = new StoreDeliveryInfoDto();
storeDeliveryInfoDto.setPartnerId(storeResponseDto.getPartnerId());
storeDeliveryInfoDto.setStoreId(storeResponseDto.getStoreCode());
storeDeliveryInfoDto.setStoreName(storeResponseDto.getStoreName());
// 查询外卖配送信息
QueryDeliveryRequest queryDeliveryRequest = new QueryDeliveryRequest();
queryDeliveryRequest.setPartnerId(storeResponseDto.getPartnerId());
queryDeliveryRequest.setStoreCode(storeResponseDto.getStoreCode());
BaseResponse<QueryDeliverDetailResponse> queryDeliverDetailResponse = storeCenterService.queryDeliverDetail(queryDeliveryRequest, trackingNo);
if (queryDeliverDetailResponse == null || !ResponseResult.SUCCESS.getCode().equals(queryDeliverDetailResponse.getCode()) || queryDeliverDetailResponse.getData() == null) {
throw new ServiceException(ResponseResult.STORE_ITEM_NOT_DELIVERY);
}
QueryDeliverDetailResponse deliveryDetail = queryDeliverDetailResponse.getData();
// 判断门店是否启用外卖,只有当小程序开通外卖,且门店开通外卖,设置 外卖配送时间 才开启外卖功能
storeDeliveryInfoDto.setDeliveryLimitAmount(StringUtils.isBlank(deliveryDetail.getMinOrderPrice()) ? 0L : Long.parseLong(deliveryDetail.getMinOrderPrice()));
storeDeliveryInfoDto.setDeliveryAmount(StringUtils.isBlank(deliveryDetail.getDeliveryFee()) ? 0L : Long.parseLong(deliveryDetail.getDeliveryFee()));
storeDeliveryInfoDto.setDefaultDeliveryRange(StringUtils.isBlank(deliveryDetail.getDeliveryRange()) ? 0L : Long.parseLong(deliveryDetail.getDeliveryRange()));
storeDeliveryInfoDto.setAddRangeAmount(StringUtils.isBlank(deliveryDetail.getAddRangeAmount()) ? 0L : Long.parseLong(deliveryDetail.getAddRangeAmount()));
storeDeliveryInfoDto.setAddRangeCount(StringUtils.isBlank(deliveryDetail.getAddRange()) ? 0L : Long.parseLong(deliveryDetail.getAddRange()));
storeDeliveryInfoDto.setPoint2DList(getDeliveryPoint2DList(storeResponseDto.getDistributionScope()));
storeDeliveryInfoDto.setDeliveryHoursDay(storeResponseDto.getDeliveryHoursDay());
storeDeliveryInfoDto.setLongitude(storeResponseDto.getLongitude());
storeDeliveryInfoDto.setLatitude(storeResponseDto.getLatitude());
storeDeliveryInfoDto.setScopeConfig(storeResponseDto.getScopeConfig());
if (StringUtils.isNotEmpty(storeResponseDto.getDeliveryRadius())) {
storeDeliveryInfoDto.setDeliveryRadius(Integer.valueOf(storeResponseDto.getDeliveryRadius()));
} else {
storeDeliveryInfoDto.setDeliveryRadius(0);
}
// 只有小程序设置了外卖,并且开通了第三方配送账户,才是第三方配送单
if (openPlatformIappWxappConfig == null) {
openPlatformIappWxappConfig = openPlatformIappWxappConfigManager.selectIappWxappConfigByWxAppId(wxAppid);
}
if (openPlatformIappWxappConfig == null) {
storeDeliveryInfoDto.setDeliveryType("self");
storeDeliveryInfoDto.setPushOrderTime(0);
} else {
if (ObjectUtils.equals(openPlatformIappWxappConfig.getTakeType(), 1)) {
storeDeliveryInfoDto.setDeliveryType("self");
storeDeliveryInfoDto.setPushOrderTime(0);
} else {
storeDeliveryInfoDto.setDeliveryType("third");
storeDeliveryInfoDto.setPushOrderTime(0);
}
}
return storeDeliveryInfoDto;
}
/**
* 获取配送范围内集合 * 获取配送范围内集合
*/ */
public List<Point2D.Double> getDeliveryPoint2DList(String distributionScope) { public List<Point2D.Double> getDeliveryPoint2DList(String distributionScope) {
......
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.freemud.application.service.sdk</groupId> <groupId>com.freemud.application.service.sdk</groupId>
<version>1.4.1-SNAPSHOT</version> <version>2.6.1-SNAPSHOT</version>
<artifactId>storecenter-sdk</artifactId> <artifactId>storecenter-sdk</artifactId>
</dependency> </dependency>
......
...@@ -58,6 +58,7 @@ public enum ResponseResult { ...@@ -58,6 +58,7 @@ public enum ResponseResult {
STORE_BUSINESS_HOUR_ERROR("43010", "门店营业时间错误"), STORE_BUSINESS_HOUR_ERROR("43010", "门店营业时间错误"),
STORE_NOT_ENABLE_COLLECT_GOODS("43011", "门店不支持到店"), STORE_NOT_ENABLE_COLLECT_GOODS("43011", "门店不支持到店"),
STORE_MALL_NOT_FOUND("43012", "商城门店不存在"), STORE_MALL_NOT_FOUND("43012", "商城门店不存在"),
STORE_DELIVERY_AMOUNT_ERROR("43013", "配送费错误"),
/** /**
* 购物车状态码 * 购物车状态码
......
...@@ -50,7 +50,9 @@ import com.freemud.application.sdk.api.paymentcenter.client.response.SVCCardAmou ...@@ -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.paymentcenter.client.service.PaymentNewService;
import com.freemud.application.sdk.api.productcenter.domain.ProductBeanDTO; import com.freemud.application.sdk.api.productcenter.domain.ProductBeanDTO;
import com.freemud.application.sdk.api.promotioncenter.response.ActivityResponse; 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.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.response.StoreResponse;
import com.freemud.application.sdk.api.storecenter.service.StoreCenterService; import com.freemud.application.sdk.api.storecenter.service.StoreCenterService;
import com.freemud.sdk.api.assortment.shoppingcart.constant.CommonsConstant; import com.freemud.sdk.api.assortment.shoppingcart.constant.CommonsConstant;
...@@ -84,6 +86,10 @@ import static java.util.stream.Collectors.toList; ...@@ -84,6 +86,10 @@ import static java.util.stream.Collectors.toList;
@Service @Service
public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
// 配送费逻辑是否使用旧的
@Value("${store.delivery.use.old:true}")
private boolean storeDeliveryUseOld;
@Autowired @Autowired
private ActivityAdapter activityAdapter; private ActivityAdapter activityAdapter;
@Autowired @Autowired
...@@ -1439,6 +1445,34 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -1439,6 +1445,34 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
return amount; 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 || !ResponseResult.SUCCESS.getCode().equals(queryDeliverDetailResponse.getCode()) || 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 { ...@@ -1484,12 +1518,18 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
} }
private Long calculateDeliveryAmount(String receiveId,String partnerId,String storeId,String wxappid){ private Long calculateDeliveryAmount(String receiveId,String partnerId,String storeId,String wxappid){
Long deliveryAmount = 0l; Long deliveryAmount = 0L;
if(receiveId==null) { if(StringUtils.isBlank(receiveId)) {
}else{ 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()); deliveryAmount = Long.parseLong(getDeliveryAmount(receiveId,partnerId,storeId).toString());
} else {
deliveryAmount = getNewDeliveryAmount(receiveId, partnerId, storeId);
} }
return deliveryAmount; 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