Commit 979aefb4 by chongfu.liang

fix

parent 34fe552d
......@@ -36,7 +36,7 @@ public class BaseListCartGoodsVO {
*/
private List<CartGoods.CartGoodsExtra> extra;
private String version;
private Integer version;
/**
* 1.6.0 版本增加 节点ID
......
......@@ -404,7 +404,7 @@ public class AbstractListCartGoodsService implements ListCartGoodsService {
}
}
setToastMsgIfNotExist(shoppingCartGoodsBO, setMessageBO.getToastMsg());
shoppingCartGoodsBO.setVersion(2);
return shoppingCartGoodsBO;
}
......
......@@ -9,8 +9,10 @@ import cn.freemud.demo.entities.bo.store.StoreInfoBO;
import cn.freemud.demo.manager.customer.CustomerManager;
import cn.freemud.demo.manager.store.StoreManager;
import cn.freemud.entities.dto.StoreDeliveryInfoDto;
import cn.freemud.entities.vo.ShoppingCartGoodsResponseVo;
import cn.freemud.enums.CreateOrderType;
import cn.freemud.enums.ScopeConfigType;
import cn.freemud.service.delivery.DeliveryFactory;
import cn.freemud.utils.WebUtil;
import com.freemud.application.sdk.api.log.LogThreadLocal;
import com.freemud.application.sdk.api.storecenter.request.StoreInfoRequest;
......@@ -18,6 +20,7 @@ import com.google.common.collect.Lists;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.awt.geom.Point2D;
......@@ -36,6 +39,13 @@ public class DeliveryService {
@Autowired
private StoreManager storeManager;
@Autowired
private DeliveryFactory deliveryFactory;
// 配送费逻辑是否使用旧的
@Value("${store.delivery.use.old:true}")
private boolean storeDeliveryUseOld;
public Long calculateDeliveryAmount(String receiveId, String partnerId, String storeId, Integer orderType, ManagerServiceBO managerServiceBO) {
Long deliveryAmount = 0L;
// 如果订单的收获地址为空,且订单是外卖单,返回运费
......@@ -43,8 +53,11 @@ public class DeliveryService {
if (StringUtils.isBlank(receiveId) && !Objects.equals(orderType, CreateOrderType.TAKE_OUT.getCode())) {
return deliveryAmount;
}
deliveryAmount = Long.parseLong(getDeliveryAmount(receiveId, partnerId, storeId, managerServiceBO).toString());
// shoppingCartGoodsResponseVo.setDeliveryFeeZeroReason(0);
if (storeDeliveryUseOld) {
deliveryAmount = Long.parseLong(getDeliveryAmount(receiveId, partnerId, storeId, managerServiceBO).toString());
} else {
deliveryAmount = getNewDeliveryAmount(receiveId, partnerId, storeId, orderType);
}
return deliveryAmount;
}
......@@ -98,6 +111,22 @@ public class DeliveryService {
return amount;
}
private Long getNewDeliveryAmount(String receiveId, String partnerId, String storeId, Integer orderType) {
//String trackingNo = LogThreadLocal.getTrackingNo();
Long amount = 0L;
// 如果订单的收获地址为空,且订单是外卖单,返回运费
// 主要是为了兼容coco不传收获地址,需要获取固定运费的情况
if (StringUtils.isBlank(receiveId) && !Objects.equals(orderType, CreateOrderType.TAKE_OUT.getCode())) {
return amount;
}
cn.freemud.service.delivery.DeliveryService deliveryService = deliveryFactory.getCalculateDeliveryAmount(orderType,receiveId);
amount = deliveryService.calculateDeliveryAmount(receiveId,partnerId,storeId);
return amount;
}
/**
* 获取配送范围内集合
*/
......
......@@ -26,4 +26,6 @@ public interface DeliveryService {
* @return
*/
Long calculateDeliveryAmount(String receiveId, String partnerId, String storeId, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo);
Long calculateDeliveryAmount(String receiveId, String partnerId, String storeId);
}
......@@ -55,4 +55,17 @@ public class FixDeliveryServiceImpl extends AbstractDeliveryServiceImpl implemen
return new Double(storeResponse.getBizVO().getDeliveryPrice() * 100).longValue();
}
@Override
public Long calculateDeliveryAmount(String receiveId, String partnerId, String storeId) {
String trackingNo = LogThreadLocal.getTrackingNo();
// 获取门店信息,查询基础配送费用
StoreInfoRequest storeInfoRequest = new StoreInfoRequest(partnerId, storeId,null);
StoreResponse storeResponse = storeCenterService.getStoreInfo(storeInfoRequest, trackingNo);
if (storeResponse == null || storeResponse.getBizVO() == null) {
throw new ServiceException (ResponseResult.STORE_NOT_FOUND);
}
return new Double(storeResponse.getBizVO().getDeliveryPrice() * 100).longValue();
}
}
......@@ -66,4 +66,34 @@ public class GradDeliveryServiceImpl extends AbstractDeliveryServiceImpl impleme
return queryDeliverDetailResponse.getData().getDeliveryAmount();
}
@Override
public Long calculateDeliveryAmount(String receiveId, String partnerId, String storeId) {
String trackingNo = LogThreadLocal.getTrackingNo();
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();
}
}
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