Commit 131e11f1 by 刘鹏飞

创单获取购物数据增加买一赠一寄件用户选择的验证

parent f0c19ab4
......@@ -95,6 +95,9 @@ public enum ResponseResult {
SHOPPING_CART_HG_COUPON_NOT_EXIST("44027", "换购券不存在"),
SHOPPING_CART_LIMIT_ADD("44025", "加购数量超过限制"),
SHOPPING_CART_GOODS_CHECK_ERROR("44028", "当前餐盘中没有可用券的饮品"),
SHOPPING_CART_REQUEST_NOT_EMPTY("44029", "购物车查询条件不能为空"),
SHOPPING_CART_BUY_ONE_SEND_GOODS_NOT_EMPTY("44030", "未查询到寄件活动商品"),
SHOPPING_CART_BUY_ONE_SEND_GOODS_ERR("44031", "寄件活动商品错误"),
/**
* 订单状态码
......
......@@ -37,10 +37,7 @@ import cn.freemud.redis.RedisCache;
import cn.freemud.service.*;
import cn.freemud.service.delivery.DeliveryFactory;
import cn.freemud.service.delivery.DeliveryService;
import cn.freemud.service.impl.calculate.CalculateCenter;
import cn.freemud.service.impl.calculate.CalculationSharingCartService;
import cn.freemud.service.impl.calculate.CalculationSharingDiscountService;
import cn.freemud.service.impl.calculate.CalculationSharingEquallyService;
import cn.freemud.service.impl.calculate.*;
import cn.freemud.service.thirdparty.*;
import cn.freemud.utils.BeanUtil;
import cn.freemud.utils.PromotionFactory;
......@@ -166,6 +163,10 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
private CalculationSharingCartService sharingCartService;
@Autowired
private CalculationSharingEquallyService sharingEquallyService;
@Autowired
private CalculationSharingValidatorService calculationSharingValidatorService;
@Value("${saas.cart.sharing}")
private String sharing;
......@@ -808,6 +809,18 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
, deliveryAmount
, shoppingCartInfoRequestVo);
// 活动校验
calculationSharingValidatorService.validator(discountResult
, cartGoodsList
, shoppingCartGoodsResponseVo
, shoppingCartInfoRequestVo
, userLoginInfoDto
, couponPromotionVO
, activityQueryDto
, menuType
, deliveryAmount
, ShoppingCartConstant.QUERY_INFO);
//直接利用促销返回做均摊
sharingEquallyService.equally(discountResult
, cartGoodsList
......
package cn.freemud.service.impl.calculate;
import cn.freemud.entities.dto.UserLoginInfoDto;
import cn.freemud.entities.dto.activity.ActivityQueryDto;
import cn.freemud.entities.dto.calculate.CalculationSharingDiscountResponseDto;
import cn.freemud.entities.vo.CartGoods;
import cn.freemud.entities.vo.CouponPromotionVO;
import cn.freemud.entities.vo.ShoppingCartGoodsResponseVo;
import cn.freemud.entities.vo.ShoppingCartInfoRequestVo;
import cn.freemud.service.impl.calculate.promotion.BuyOneGiveOneSendService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: cn.freemud.service.impl.calculate CalculationSharingDiscountServiceImpl
* @Description: 校验活动信息
* @author: pengfei.liu
* @date: 2020/11/27
* @Copyright: www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
@Service
@Slf4j
public class CalculationSharingValidatorService {
@Autowired
private BuyOneGiveOneSendService buyOneGiveOneSendService;
public void validator(CalculationSharingDiscountResponseDto.CalculationDiscountResult discountResult
, List<CartGoods> cartGoodsList
, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo
, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo
, UserLoginInfoDto userLoginInfoDto
, CouponPromotionVO couponPromotionVO
, ActivityQueryDto activityQueryDto
, String menuType
, Long deliveryAmount
, String opt) {
// 买一赠一寄件活动
buyOneGiveOneSendService.validator(discountResult,cartGoodsList,shoppingCartInfoRequestVo,activityQueryDto,shoppingCartGoodsResponseVo);
}
}
......@@ -248,5 +248,69 @@ public class BuyOneGiveOneSendService {
}
public void validator(CalculationSharingDiscountResponseDto.CalculationDiscountResult discountResult
, List<CartGoods> cartGoodsList
, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo
, ActivityQueryDto activityQueryDto
, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo) {
// 用户选择的商品、数量不在促销返回的优惠信息中,返回错误
if(shoppingCartInfoRequestVo == null ){
throw new ServiceException(ResponseResult.SHOPPING_CART_REQUEST_NOT_EMPTY);
}
// 用户选择的商品信息
List<ShoppingCartInfoRequestVo.ChooseGood> chooseGoods = shoppingCartInfoRequestVo.getChooseGoods();
// 用户没有选择商品,不做校验
if(chooseGoods == null || chooseGoods.isEmpty()){
return;
}
// 促销返回的赠送信息
List<CalculationSharingDiscountResponseDto.CalculationDiscountResult.SendActivity> sendGoods = discountResult.getSendGoods();
if(sendGoods == null || sendGoods.isEmpty()){
throw new ServiceException(ResponseResult.SHOPPING_CART_BUY_ONE_SEND_GOODS_NOT_EMPTY);
}
List<CalculationSharingDiscountResponseDto.CalculationDiscountResult.SendActivity> sendActivityList = sendGoods
.stream()
.filter(sendActivity -> ObjectUtils.equals(sendActivity.getActivityType(),ActivityTypeEnum.TYPE_63.getCode()))
.collect(Collectors.toList());
// 校验用户选择的商品、优惠券是否在促销返回的买一赠一寄件活动中
// 没有返回错误
for(ShoppingCartInfoRequestVo.ChooseGood chooseGood : chooseGoods){
boolean flag = true;
if(sendActivityList == null || sendActivityList.isEmpty()){
throw new ServiceException(ResponseResult.SHOPPING_CART_BUY_ONE_SEND_GOODS_NOT_EMPTY);
}
for(CalculationSharingDiscountResponseDto.CalculationDiscountResult.SendActivity sendActivity : sendActivityList){
List<CalculationSharingDiscountResponseDto.CalculationDiscountResult.SendActivity.SendGoods> innerSendGoods = sendActivity.getSendGoods();
if(innerSendGoods == null || innerSendGoods.isEmpty()){
break;
}
for(CalculationSharingDiscountResponseDto.CalculationDiscountResult.SendActivity.SendGoods innerSendGood : innerSendGoods){
if(ObjectUtils.equals(chooseGood.getGoodsId(),innerSendGood.getGoodsId())){
if(ObjectUtils.equals(chooseGood.getCouponCode(),innerSendGood.getSendCouponCode())){
flag = false;
}
}
}
}
if(flag){
throw new ServiceException(ResponseResult.SHOPPING_CART_BUY_ONE_SEND_GOODS_ERR);
}
}
}
}
\ No newline at end of file
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