Commit 935e7036 by 查志伟

订单支持满M件N折活动

parent 55342d46
...@@ -1529,6 +1529,9 @@ public class OrderSdkAdapter { ...@@ -1529,6 +1529,9 @@ public class OrderSdkAdapter {
case "SINGLE_PRODUCT_REDUCTION": case "SINGLE_PRODUCT_REDUCTION":
type = 22; type = 22;
break; break;
case "FULL_M_COUNT_N_FOLD":
type = 83;
break;
default: default:
break; break;
} }
......
...@@ -50,6 +50,7 @@ public enum OldOrderAccountType { ...@@ -50,6 +50,7 @@ public enum OldOrderAccountType {
MEMBER_PRICE_DISCOUNT(220, "会员价优惠", "MEMBER_PRICE_DISCOUNT"), MEMBER_PRICE_DISCOUNT(220, "会员价优惠", "MEMBER_PRICE_DISCOUNT"),
COCO_PRODUCT_CASH_COUPON(36, "coco商品代金券","COCO_PRODUCT_CASH_COUPON"), COCO_PRODUCT_CASH_COUPON(36, "coco商品代金券","COCO_PRODUCT_CASH_COUPON"),
FULL_BUYM_SENDN(230, "满赠","FULL_BUYM_SENDN"), FULL_BUYM_SENDN(230, "满赠","FULL_BUYM_SENDN"),
FULL_M_COUNT_N_FOLD(83, "满M件N折", "FULL_M_COUNT_N_FOLD"),
SINGLE_PRODUCT_REDUCTION(22, "单品立减","SINGLE_PRODUCT_REDUCTION"); SINGLE_PRODUCT_REDUCTION(22, "单品立减","SINGLE_PRODUCT_REDUCTION");
private Integer code; private Integer code;
......
...@@ -49,6 +49,7 @@ public enum QueryOrderAccountType { ...@@ -49,6 +49,7 @@ public enum QueryOrderAccountType {
WITH_ORDER_BUY_COUPON_FEE("WITH_ORDER_BUY_COUPON_FEE", "随单买月卡"), WITH_ORDER_BUY_COUPON_FEE("WITH_ORDER_BUY_COUPON_FEE", "随单买月卡"),
COCO_PRODUCT_CASH_COUPON("COCO_PRODUCT_CASH_COUPON", "coco商品代金券"), COCO_PRODUCT_CASH_COUPON("COCO_PRODUCT_CASH_COUPON", "coco商品代金券"),
FULL_BUYM_SENDN("FULL_BUYM_SENDN", "满赠"), FULL_BUYM_SENDN("FULL_BUYM_SENDN", "满赠"),
FULL_M_COUNT_N_FOLD("FULL_M_COUNT_N_FOLD", "满M件N折"),
SINGLE_PRODUCT_REDUCTION("SINGLE_PRODUCT_REDUCTION", "单品立减") SINGLE_PRODUCT_REDUCTION("SINGLE_PRODUCT_REDUCTION", "单品立减")
; ;
private String code; private String code;
......
...@@ -2913,6 +2913,9 @@ public class OrderAdapter { ...@@ -2913,6 +2913,9 @@ public class OrderAdapter {
if (ActivityTypeEnum.TYPE_231.getCode().equals(activityType)) { if (ActivityTypeEnum.TYPE_231.getCode().equals(activityType)) {
return OldOrderAccountType.MONTH_CARD_TOTAL_DISCOUNT; return OldOrderAccountType.MONTH_CARD_TOTAL_DISCOUNT;
} }
if (ActivityTypeEnum.TYPE_83.getCode().equals(activityType)) {
return OldOrderAccountType.FULL_M_COUNT_N_FOLD;
}
return OldOrderAccountType.BUYM_SENDN; return OldOrderAccountType.BUYM_SENDN;
} }
......
...@@ -19,6 +19,7 @@ public enum ActivityTypeEnum { ...@@ -19,6 +19,7 @@ public enum ActivityTypeEnum {
TYPE_13(13, "新用户立减"), TYPE_13(13, "新用户立减"),
TYPE_14(14, "满减配送费"), TYPE_14(14, "满减配送费"),
TYPE_104(104,"x件y折"), TYPE_104(104,"x件y折"),
TYPE_83(83, "满M件N折"),
/** /**
* 限时特价 * 限时特价
*/ */
......
...@@ -2,6 +2,7 @@ package cn.freemud.service.impl; ...@@ -2,6 +2,7 @@ package cn.freemud.service.impl;
import cn.freemud.entities.dto.ActivityCalculationDiscountResponseDto; import cn.freemud.entities.dto.ActivityCalculationDiscountResponseDto;
import cn.freemud.entities.dto.UserLoginInfoDto; import cn.freemud.entities.dto.UserLoginInfoDto;
import cn.freemud.entities.dto.activity.ActivityDiscountsDto;
import cn.freemud.entities.dto.activity.ActivityQueryDto; import cn.freemud.entities.dto.activity.ActivityQueryDto;
import cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto; import cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto;
import cn.freemud.entities.vo.*; import cn.freemud.entities.vo.*;
...@@ -25,13 +26,7 @@ public class FullMCountNFoldPromotionService implements IPromotionService { ...@@ -25,13 +26,7 @@ public class FullMCountNFoldPromotionService implements IPromotionService {
@Override @Override
public void updateShoppingCartGoodsDiscount(CouponPromotionVO couponPromotionVO, ActivityQueryDto activityQueryDto, ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult, List<CartGoods> cartGoodsList, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, UserLoginInfoDto userLoginInfoDto, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo) { public void updateShoppingCartGoodsDiscount(CouponPromotionVO couponPromotionVO, ActivityQueryDto activityQueryDto, ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult, List<CartGoods> cartGoodsList, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, UserLoginInfoDto userLoginInfoDto, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo) {
if (calculationDiscountResult == null || CollectionUtils.isEmpty(calculationDiscountResult.getDiscounts())) if (! assertHasDiscount(calculationDiscountResult)) return;
return;
List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Discount> discountList
= calculationDiscountResult.getDiscounts().stream().filter(discount -> ActivityTypeEnum.TYPE_83.getCode().equals(discount.getType())).collect(Collectors.toList());
if (CollectionUtils.isEmpty(discountList))
return;
// 转换一下结构,方便匹配购物车商品的活动信息 // 转换一下结构,方便匹配购物车商品的活动信息
Map<String, ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods> map = calculationDiscountResult.getGoods().stream() Map<String, ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods> map = calculationDiscountResult.getGoods().stream()
...@@ -40,18 +35,67 @@ public class FullMCountNFoldPromotionService implements IPromotionService { ...@@ -40,18 +35,67 @@ public class FullMCountNFoldPromotionService implements IPromotionService {
cartGoodsList.forEach(cartGoods -> { cartGoodsList.forEach(cartGoods -> {
ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods discountGoods = map.get(cartGoods.getCartGoodsUid()); ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods discountGoods = map.get(cartGoods.getCartGoodsUid());
if (null != discountGoods && CollectionUtils.isNotEmpty(discountGoods.getDiscounts())) { if (null != discountGoods && CollectionUtils.isNotEmpty(discountGoods.getDiscounts())) {
ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount discount = getDiscount(discountGoods.getDiscounts());
Long originPrice = cartGoods.getFinalPrice() * cartGoods.getQty(); Long originPrice = cartGoods.getFinalPrice() * cartGoods.getQty();
Long discountPrice = 0L; cartGoods.setAmount(originPrice - discount.getDiscount());
for (ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount discount : discountGoods.getDiscounts()) { cartGoods.setActivityNumber(discount.getActualGoodsNumber());
discountPrice += discount.getDiscount();
}
cartGoods.setAmount(originPrice - discountPrice);
} }
}); });
} }
@Override @Override
public void updateShoppingCartGoodsApportion(ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult, ShoppingCartGoodsDto shoppingCartGoodsDto, CreateOrderVo.PremiumExchangeActivity premiumExchangeActivity, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo) { public void updateShoppingCartGoodsApportion(ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult, ShoppingCartGoodsDto shoppingCartGoodsDto, CreateOrderVo.PremiumExchangeActivity premiumExchangeActivity, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo) {
if (! assertHasDiscount(calculationDiscountResult)) return;
// 转换一下结构,方便匹配购物车商品的活动信息
Map<String, ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods> map = calculationDiscountResult.getGoods().stream()
.collect(Collectors.toMap(ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods::getCartGoodsUid, Function.identity(), (k1, k2) -> k1));
for (ShoppingCartGoodsDto.CartGoodsDetailDto cartGoods : shoppingCartGoodsDto.getProducts()) {
ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods discountGoods = map.get(cartGoods.getCartGoodsUid());
if (null != discountGoods && CollectionUtils.isNotEmpty(discountGoods.getDiscounts())) {
ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount discount = getDiscount(discountGoods.getDiscounts());
ActivityDiscountsDto activityDiscountsDto = new ActivityDiscountsDto();
activityDiscountsDto.setActivityCode(discount.getActivityCode());
activityDiscountsDto.setActivityName(discount.getActivityName());
activityDiscountsDto.setActivityType(ActivityTypeEnum.TYPE_83.getCode());
activityDiscountsDto.setDiscountAmount(discount.getDiscount().intValue());
cartGoods.getActivityDiscountsDtos().add(activityDiscountsDto);
cartGoods.setTotalDiscountAmount(cartGoods.getTotalDiscountAmount() + discount.getDiscount().intValue());
}
}
}
/**
* 判断是否符合优惠
* @param calculationDiscountResult
* @return
*/
private boolean assertHasDiscount(ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult) {
if (calculationDiscountResult == null || CollectionUtils.isEmpty(calculationDiscountResult.getDiscounts()))
return false;
List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Discount> discountList
= calculationDiscountResult.getDiscounts().stream().filter(discount -> ActivityTypeEnum.TYPE_83.getCode().equals(discount.getType())).collect(Collectors.toList());
if (CollectionUtils.isEmpty(discountList))
return false;
return true;
}
/**
* 返回商品参与的满M件N折的活动信息
* @param goodsDiscounts
* @return
*/
private ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount getDiscount(List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount> goodsDiscounts) {
for (ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount discount : goodsDiscounts) {
if (ActivityTypeEnum.TYPE_83.getCode().equals(discount.getType())) {
return discount;
}
}
return null;
} }
} }
...@@ -1965,6 +1965,11 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -1965,6 +1965,11 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
*/ */
MaterialPromotionService materialPromotionService = (MaterialPromotionService) PromotionFactory.getPromotionService(ShoppingCartPromotionEnum.Material); MaterialPromotionService materialPromotionService = (MaterialPromotionService) PromotionFactory.getPromotionService(ShoppingCartPromotionEnum.Material);
materialPromotionService.updateShoppingCartGoodsApportion(shoppingCartGoodsResponseVo, calculationDiscountResult, shoppingCartGoodsDto, premiumExchangeActivity, shoppingCartInfoRequestVo); materialPromotionService.updateShoppingCartGoodsApportion(shoppingCartGoodsResponseVo, calculationDiscountResult, shoppingCartGoodsDto, premiumExchangeActivity, shoppingCartInfoRequestVo);
// 满M件N折活动
IPromotionService fullMCountNFoldService = PromotionFactory.getPromotionService(ShoppingCartPromotionEnum.FULL_M_COUNT_N_FOLD);
fullMCountNFoldService.updateShoppingCartGoodsApportion(shoppingCartGoodsResponseVo, calculationDiscountResult, shoppingCartGoodsDto, premiumExchangeActivity, shoppingCartInfoRequestVo);
} }
......
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