Commit ca98850b by zhiheng.zhang

华莱士升级

parent 500ed0b8
...@@ -64,4 +64,11 @@ public class DeliveryController { ...@@ -64,4 +64,11 @@ public class DeliveryController {
public BaseResponse queryDeliveryAmount(@Valid @LogParams @RequestBody WeixinDeliveryAddressDto request) { public BaseResponse queryDeliveryAmount(@Valid @LogParams @RequestBody WeixinDeliveryAddressDto request) {
return deliveryService.queryDeliveryAmount(request); return deliveryService.queryDeliveryAmount(request);
} }
@ApiAnnotation(logMessage = "获取微商城快递配送费")
@ApiOperation(value = "queryMallOrderDeliveryAmount", notes = "获取微商城快递配送费", produces = "application/json")
@PostMapping("/delivery/queryMallOrderDeliveryAmount")
public BaseResponse queryMallOrderDeliveryAmount(@Valid @LogParams @RequestBody WeixinDeliveryAddressDto request) {
return deliveryService.queryMallOrderDeliveryAmount(request);
}
} }
package cn.freemud.entities.dto.delivery;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
/**
* 查询省份对应配送费价格响应对象
* @version V1.0
* @author: zhiheng.zhang
* @date:
* @Copyright: 2018 www.freemud.cn Inc. All rights reserved.
* All rights Reserved, Designed By www.freemud.cn
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目的
*/
@Data
public class QueryDeliveryTemplateResponseDto {
private Integer code;
private String msg;
private List<DispatchCost> data;
@Data
public static class DispatchCost {
private Long addCost;
/**
* 商户ID
*/
private Long firstCost;
/**
* 配送费 单位:分
*/
private firstStandard deliveryAmount;
/**
* 收件人省份编码
*/
private String provinceCode;
/**
* 收件人省份
*/
private String sendProvince;
/**
* 状态 1启用 2禁用
*/
private Integer status;
}
}
...@@ -31,4 +31,9 @@ public interface ThirdDeliveryService { ...@@ -31,4 +31,9 @@ public interface ThirdDeliveryService {
*/ */
BaseResponse<DeliveryAmountVo> queryDeliveryAmount(WeixinDeliveryAddressDto request); BaseResponse<DeliveryAmountVo> queryDeliveryAmount(WeixinDeliveryAddressDto request);
/**
* 获取微商城快递配送费
*/
BaseResponse<DeliveryAmountVo> queryMallOrderDeliveryAmount(WeixinDeliveryAddressDto request);
} }
...@@ -562,4 +562,30 @@ public class ThirdDeliveryServiceImpl implements ThirdDeliveryService { ...@@ -562,4 +562,30 @@ public class ThirdDeliveryServiceImpl implements ThirdDeliveryService {
log.error("调用生态返回参数失败,订单编号:{},失败原因:{}",orderId,e.getMessage()); log.error("调用生态返回参数失败,订单编号:{},失败原因:{}",orderId,e.getMessage());
} }
} }
/**
* 获取微商城快递费
* @param request
* @return
*/
@Override
public BaseResponse<DeliveryAmountVo> queryMallOrderDeliveryAmount(WeixinDeliveryAddressDto request) {
QueryDeliveryAmountRequestDto requestDto = new QueryDeliveryAmountRequestDto();
requestDto.setPartnerId(request.getPartnerId());
requestDto.setProvince(request.getProvinceName());
QueryDeliveryAmountResponseDto responseDto = deliveryFeiginClient.queryDeliveryAmount(requestDto);
if(responseDto == null || SUCCESS_RESPONSE_CODE != responseDto.getCode() || CollectionUtils.isEmpty(responseDto.getData())) {
return ResponseUtil.error(ResponseResult.DELIVERY_INFO_NOT_DELIVERY);
}
DeliveryAmountVo deliveryAmountVo = new DeliveryAmountVo();
QueryDeliveryAmountResponseDto.QueryDeliveryAmountResult amountResult = responseDto.getData().get(0);
deliveryAmountVo.setId(amountResult.getId());
deliveryAmountVo.setPartnerId(amountResult.getPartnerId());
deliveryAmountVo.setProvinceName(amountResult.getSendProvince());
deliveryAmountVo.setDeliveryAmount(amountResult.getDeliveryAmount().intValue());
return ResponseUtil.success(deliveryAmountVo);
}
} }
...@@ -31,4 +31,7 @@ public interface DeliveryFeiginClient { ...@@ -31,4 +31,7 @@ public interface DeliveryFeiginClient {
@PostMapping("/delivery/getThirdDeliveryFlag") @PostMapping("/delivery/getThirdDeliveryFlag")
DeliveryBaseResponse<GetDeliveryFlagResponseDto> getThirdDeliveryFlag(@RequestBody GetDeliveryFlagRequest getDeliveryFlagRequest); DeliveryBaseResponse<GetDeliveryFlagResponseDto> getThirdDeliveryFlag(@RequestBody GetDeliveryFlagRequest getDeliveryFlagRequest);
@PostMapping("/delivery/queryDeliveryTemplate")
QueryDeliveryTemplateResponseDto queryDeliveryTemplate(@RequestBody QueryDeliveryAmountRequestDto request);
} }
...@@ -39,11 +39,16 @@ import cn.freemud.utils.PromotionFactory; ...@@ -39,11 +39,16 @@ import cn.freemud.utils.PromotionFactory;
import cn.freemud.utils.ResponseUtil; import cn.freemud.utils.ResponseUtil;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.freemud.api.assortment.datamanager.entity.db.AssortmentOpenPlatformPartnerStoreDeliveryConfig;
import com.freemud.api.assortment.datamanager.entity.vo.AssortmentCustomerInfoVo; import com.freemud.api.assortment.datamanager.entity.vo.AssortmentCustomerInfoVo;
import com.freemud.api.assortment.datamanager.manager.customer.AssortmentCustomerInfoManager; import com.freemud.api.assortment.datamanager.manager.customer.AssortmentCustomerInfoManager;
import com.freemud.application.sdk.api.log.ApiLog; import com.freemud.application.sdk.api.log.ApiLog;
import com.freemud.application.sdk.api.log.LogThreadLocal; import com.freemud.application.sdk.api.log.LogThreadLocal;
import com.freemud.application.sdk.api.membercenter.request.QueryReceiveAddressRequest;
import com.freemud.application.sdk.api.membercenter.response.QueryReceiveAddressResponse;
import com.freemud.application.sdk.api.productcenter.domain.ProductBeanDTO; import com.freemud.application.sdk.api.productcenter.domain.ProductBeanDTO;
import com.freemud.application.sdk.api.storecenter.request.StoreInfoRequest;
import com.freemud.application.sdk.api.storecenter.response.StoreResponse;
import com.freemud.sdk.api.assortment.shoppingcart.constant.CommonsConstant; import com.freemud.sdk.api.assortment.shoppingcart.constant.CommonsConstant;
import com.freemud.sdk.api.assortment.shoppingcart.enums.BusinessTypeEnum; import com.freemud.sdk.api.assortment.shoppingcart.enums.BusinessTypeEnum;
import com.freemud.sdk.api.assortment.shoppingcart.request.CheckCartRequest; import com.freemud.sdk.api.assortment.shoppingcart.request.CheckCartRequest;
...@@ -348,7 +353,7 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService { ...@@ -348,7 +353,7 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService {
buildCoupons(coupons,shoppingCartInfoRequestVo.getCouponCodes()); buildCoupons(coupons,shoppingCartInfoRequestVo.getCouponCodes());
Long deliveryAmount = calculateDeliveryAmount(receiveId, partnerId, storeId, userLoginInfoDto.getWxAppid(), shoppingCartGoodsResponseVo,shoppingCartInfoRequestVo.getOrderType()); Long deliveryAmount = calculateDeliveryAmount(partnerId, userLoginInfoDto.getWxAppid());
ActivityQueryDto activityQueryDto = activityAdapter.getActivityQueryDto(partnerId, storeId, userId, appId, shoppingCartInfoRequestVo.getOrderType()); ActivityQueryDto activityQueryDto = activityAdapter.getActivityQueryDto(partnerId, storeId, userId, appId, shoppingCartInfoRequestVo.getOrderType());
...@@ -876,4 +881,78 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService { ...@@ -876,4 +881,78 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService {
return oldCoupons; return oldCoupons;
} }
public Long calculateDeliveryAmount(String partnerId) {
Long deliveryAmount = 0L;
// 如果订单的收获地址为空,且订单是外卖单,返回运费
// 主要是为了兼容coco不传收获地址,需要获取固定运费的情况
if (StringUtils.isBlank(receiveId) && !Objects.equals(orderType, CreateOrderType.TAKE_OUT.getCode())) {
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());
shoppingCartGoodsResponseVo.setDeliveryFeeZeroReason(0);
} else {
deliveryAmount = getNewDeliveryAmount(receiveId, partnerId, storeId, shoppingCartGoodsResponseVo,orderType);
}
return deliveryAmount;
}
/**
* 储值卡支付查询配送费
*
* @return
*/
private Integer getDeliveryAmount(String receiveId, String partnerId, String storeId) {
String trackingNo = LogThreadLocal.getTrackingNo();
Integer amount = 0;
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);
}
StoreInfoRequest request = new StoreInfoRequest();
request.setPartnerId(partnerId);
request.setStoreCode(storeId);
//查询门店信息,获取门店经纬度
StoreResponse storeResponse = storeCenterService.getStoreInfo(request, trackingNo);
if (storeResponse == null || storeResponse.getStatusCode() != 100 || storeResponse.getBizVO() == null) {
throw new ServiceException(ResponseResult.STORE_NOT_FOUND);
}
//查询门店外卖配送配置
AssortmentOpenPlatformPartnerStoreDeliveryConfig deliveryConfig = deliveryConfigManager.findByPartnerIdAndStoreCode(partnerId, storeId);
if (deliveryConfig == null) {
throw new ServiceException(ResponseResult.STORE_ITEM_NOT_DELIVERY);
}
StoreDeliveryInfoDto storeDeliveryInfoDto = new StoreDeliveryInfoDto();
storeDeliveryInfoDto.setPartnerId(partnerId);
storeDeliveryInfoDto.setStoreId(storeId);
storeDeliveryInfoDto.setStoreName(storeResponse.getBizVO().getStoreName());
storeDeliveryInfoDto.setDeliveryLimitAmount(deliveryConfig == null ? 0 : deliveryConfig.getDeliveryLimitAmount());
storeDeliveryInfoDto.setDeliveryAmount(deliveryConfig == null ? 0 : deliveryConfig.getDeliveryAmount());
storeDeliveryInfoDto.setDefaultDeliveryRange(deliveryConfig == null ? 0L : deliveryConfig.getDefaultDeliveryRange());
storeDeliveryInfoDto.setAddRangeAmount(deliveryConfig == null ? 0L : deliveryConfig.getAddRangeAmount());
storeDeliveryInfoDto.setAddRangeCount(deliveryConfig == null ? 0L : deliveryConfig.getAddRangeCount());
storeDeliveryInfoDto.setPoint2DList(getDeliveryPoint2DList(storeResponse.getBizVO().getDistributionScope()));
storeDeliveryInfoDto.setDeliveryHoursDay(storeResponse.getBizVO().getDeliveryHoursDay());
storeDeliveryInfoDto.setLongitude(storeResponse.getBizVO().getLongitude());
storeDeliveryInfoDto.setLatitude(storeResponse.getBizVO().getLatitude());
storeDeliveryInfoDto.setScopeConfig(storeResponse.getBizVO().getScopeConfig());
if (StringUtils.isNotEmpty(storeResponse.getBizVO().getDeliveryRadius())) {
storeDeliveryInfoDto.setDeliveryRadius(Integer.valueOf(storeResponse.getBizVO().getDeliveryRadius()));
} else {
storeDeliveryInfoDto.setDeliveryRadius(0);
}
storeDeliveryInfoDto.setEnableTakeaway(true);
String userLongitude = queryReceiveAddressResponse.getData().getLongitude();
String userLatitude = queryReceiveAddressResponse.getData().getLatitude();
amount = storeService.getUserRealDeliveryAmount(storeDeliveryInfoDto, userLongitude, userLatitude).intValue();
return amount;
}
} }
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