Commit cc2fcc06 by ping.wu

餐盒费规则匹配实际餐盒费

parent 45d28a08
package cn.freemud.entities.dto.order;
import lombok.Data;
import java.util.List;
@Data
public class PackAmountConfig {
private List<CollectType> collectType;
@Data
public static class CollectType {
//订单金额
private Integer orderAmount;
//餐盒费
private Integer fee;
}
}
package cn.freemud.handle; package cn.freemud.handle;
import cn.freemud.entities.dto.console.*; import cn.freemud.entities.dto.console.*;
import cn.freemud.entities.dto.order.PackAmountConfig;
import cn.freemud.entities.vo.ShoppingCartInfoRequestVo; import cn.freemud.entities.vo.ShoppingCartInfoRequestVo;
import cn.freemud.enums.CreateOrderType; import cn.freemud.enums.CreateOrderType;
import cn.freemud.enums.OrderType; import cn.freemud.enums.OrderType;
import cn.freemud.redis.RedisCache;
import cn.freemud.service.thirdparty.ConsoleApiClient; import cn.freemud.service.thirdparty.ConsoleApiClient;
import cn.freemud.utils.RedisUtil;
import com.alibaba.fastjson.JSONObject;
import com.freemud.application.sdk.api.log.ApiLog; import com.freemud.application.sdk.api.log.ApiLog;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.Objects; import java.util.Objects;
/** /**
...@@ -23,6 +30,38 @@ public class CommonFunctionHandle { ...@@ -23,6 +30,38 @@ public class CommonFunctionHandle {
@Autowired @Autowired
private ConsoleApiClient consoleApiClient; private ConsoleApiClient consoleApiClient;
@Autowired
private RedisCache redisCache;
/**
* 查询配置,比较配送费
*/
public Long packAmountConfig(ShoppingCartInfoRequestVo shoppingCartInfoRequestVo, Long newPackAmount,Long totalAmount) {
if(newPackAmount == 0){
return newPackAmount;
}
String redisKey = RedisUtil.packAmountConfig + "1865" + "_" + null;
String value = redisCache.hashGet(redisKey, "packAmountType");
if(StringUtils.isEmpty(value)){
return newPackAmount;
}
PackAmountConfig packAmountConfig = JSONObject.parseObject(value, PackAmountConfig.class);
if(packAmountConfig == null || CollectionUtils.isEmpty(packAmountConfig.getCollectType())){
return newPackAmount;
}
List<PackAmountConfig.CollectType> collectTypes = packAmountConfig.getCollectType();
collectTypes.sort((p1, p2) -> p2.getOrderAmount() - p1.getOrderAmount());
newPackAmount = 0L;
for (PackAmountConfig.CollectType collectType: collectTypes){
if(totalAmount > collectType.getOrderAmount()){
newPackAmount = collectType.getFee().longValue();
break;
}
}
return newPackAmount;
}
/** /**
* fisherman 【ID1033456】自提根据模板配置计算餐具包装费 * fisherman 【ID1033456】自提根据模板配置计算餐具包装费
...@@ -31,10 +70,11 @@ public class CommonFunctionHandle { ...@@ -31,10 +70,11 @@ public class CommonFunctionHandle {
* @param newPackAmount * @param newPackAmount
* @return 外卖 true 打包带走 false null 为其他业务问题 不进入需求 * @return 外卖 true 打包带走 false null 为其他业务问题 不进入需求
*/ */
public Long getPackAmountByStoreConfig(ShoppingCartInfoRequestVo shoppingCartInfoRequestVo, Long newPackAmount) { public Long getPackAmountByStoreConfig(ShoppingCartInfoRequestVo shoppingCartInfoRequestVo, Long newPackAmount,Long totalAmount) {
if (Objects.isNull(shoppingCartInfoRequestVo)) { if (Objects.isNull(shoppingCartInfoRequestVo)) {
return newPackAmount; return newPackAmount;
} }
newPackAmount = packAmountConfig(shoppingCartInfoRequestVo, newPackAmount, totalAmount);
Boolean isTakeOut = null; Boolean isTakeOut = null;
if (Objects.equals(shoppingCartInfoRequestVo.getOrderType(), CreateOrderType.TAKE_OUT.getCode())) { if (Objects.equals(shoppingCartInfoRequestVo.getOrderType(), CreateOrderType.TAKE_OUT.getCode())) {
isTakeOut = true; isTakeOut = true;
......
...@@ -2313,7 +2313,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -2313,7 +2313,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
} else if ((Objects.equals(shoppingCartInfoRequestVo.getOrderType(), CreateOrderType.TAKE_OUT.getCode()) } else if ((Objects.equals(shoppingCartInfoRequestVo.getOrderType(), CreateOrderType.TAKE_OUT.getCode())
|| Objects.equals(shoppingCartInfoRequestVo.getReachStoreType(), OrderType.COLLECT_GOODS.getCode()))) { || Objects.equals(shoppingCartInfoRequestVo.getReachStoreType(), OrderType.COLLECT_GOODS.getCode()))) {
//fisherman 【ID1033456】自提根据模板配置计算餐具包装费 //fisherman 【ID1033456】自提根据模板配置计算餐具包装费
Long packAmount = commonFunctionHandle.getPackAmountByStoreConfig(shoppingCartInfoRequestVo, shoppingCartGoodsResponseVo.getNewPackAmount()); Long packAmount = commonFunctionHandle.getPackAmountByStoreConfig(shoppingCartInfoRequestVo, shoppingCartGoodsResponseVo.getNewPackAmount(),shoppingCartGoodsResponseVo.getTotalAmount());
shoppingCartGoodsResponseVo.setNewPackAmount(packAmount); shoppingCartGoodsResponseVo.setNewPackAmount(packAmount);
if (Objects.equals(shoppingCartInfoRequestVo.getFlag(), SubmitPageEnum.YES.getCode())) { if (Objects.equals(shoppingCartInfoRequestVo.getFlag(), SubmitPageEnum.YES.getCode())) {
Long originalTotalAmount = shoppingCartGoodsResponseVo.getOriginalTotalAmount() + packAmount; Long originalTotalAmount = shoppingCartGoodsResponseVo.getOriginalTotalAmount() + packAmount;
......
...@@ -104,7 +104,7 @@ public class CalculationCommonService { ...@@ -104,7 +104,7 @@ public class CalculationCommonService {
shoppingCartGoodsResponseVo.setShoppingCartGoodsAmount(shoppingCartGoodsResponseVo.getTotalAmount()); shoppingCartGoodsResponseVo.setShoppingCartGoodsAmount(shoppingCartGoodsResponseVo.getTotalAmount());
shoppingCartGoodsResponseVo.setShoppingCartOriginalGoodsAmount(shoppingCartGoodsResponseVo.getOriginalTotalAmount()); shoppingCartGoodsResponseVo.setShoppingCartOriginalGoodsAmount(shoppingCartGoodsResponseVo.getOriginalTotalAmount());
//fisherman 【ID1033456】自提根据模板配置计算餐具包装费 新算价一起处理 //fisherman 【ID1033456】自提根据模板配置计算餐具包装费 新算价一起处理
shoppingCartGoodsResponseVo.setNewPackAmount(commonFunctionHandle.getPackAmountByStoreConfig(shoppingCartInfoRequestVo,totalPackageAmount)); shoppingCartGoodsResponseVo.setNewPackAmount(commonFunctionHandle.getPackAmountByStoreConfig(shoppingCartInfoRequestVo,totalPackageAmount,shoppingCartGoodsResponseVo.getTotalAmount()));
// fisehrman 总优惠金额 需要+配送券的优惠金额 // fisehrman 总优惠金额 需要+配送券的优惠金额
if (discountResult == null) { if (discountResult == null) {
shoppingCartGoodsResponseVo.setTotalDiscountAmount(0L); shoppingCartGoodsResponseVo.setTotalDiscountAmount(0L);
......
...@@ -6,6 +6,7 @@ public class RedisUtil { ...@@ -6,6 +6,7 @@ public class RedisUtil {
private final static String JOIN_FISSION_ACTIVITIES_KEY = BASE_URL + "JOIN_FISSION_ACTIVITIES_KEY_"; private final static String JOIN_FISSION_ACTIVITIES_KEY = BASE_URL + "JOIN_FISSION_ACTIVITIES_KEY_";
private final static String COUPON_APP_SECRET = "coupon:app_secret_"; private final static String COUPON_APP_SECRET = "coupon:app_secret_";
public static String limitCart = "kgd:open_store_cart_limit_"; public static String limitCart = "kgd:open_store_cart_limit_";
public static String packAmountConfig = "kgd:order_pack_config_";
public static String getEnterShopKey(String userId) { public static String getEnterShopKey(String userId) {
return ENTER_SHOP_KEY + userId; return ENTER_SHOP_KEY + userId;
......
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