Commit 77507b07 by chongfu.liang

Merge branch 'feature/20210317-频次券购物车校验每日使用次数-lcf'

parents 9da90a12 8d203da7
...@@ -41,6 +41,6 @@ public class CheckSpqInfoResponseDto { ...@@ -41,6 +41,6 @@ public class CheckSpqInfoResponseDto {
private Integer couponType; private Integer couponType;
private List<CartGoods.CartGoodsExtra> extras; private List<CartGoods.CartGoodsExtra> extras;
private Boolean isMultiCoupon; private Integer todayAvailableTimes;
} }
...@@ -36,6 +36,7 @@ public class GetCouponDetailResponseDto { ...@@ -36,6 +36,7 @@ public class GetCouponDetailResponseDto {
* 可核销周,时间段设置 * 可核销周,时间段设置
*/ */
private List<ActiveRedeemTimeInterval> activeRedeemTimeIntervalList; private List<ActiveRedeemTimeInterval> activeRedeemTimeIntervalList;
private Integer today_available_times;
} }
@Data @Data
public static class Active{ public static class Active{
......
...@@ -115,7 +115,7 @@ public interface ShoppingCartNewService { ...@@ -115,7 +115,7 @@ public interface ShoppingCartNewService {
* @param productIds * @param productIds
* @return * @return
*/ */
default Pair<String, Boolean> validCoupon(String partnerId default Pair<String, Integer> validCoupon(String partnerId
, String storeId , String storeId
, String couponCode , String couponCode
, List<Long> productIds , List<Long> productIds
...@@ -133,7 +133,7 @@ public interface ShoppingCartNewService { ...@@ -133,7 +133,7 @@ public interface ShoppingCartNewService {
} }
productIds.add(Long.parseLong(checkSpqInfoResponseDto.getSkuId())); productIds.add(Long.parseLong(checkSpqInfoResponseDto.getSkuId()));
spuId2 = checkSpqInfoResponseDto.getSkuId(); spuId2 = checkSpqInfoResponseDto.getSkuId();
return new Pair(spuId2, checkSpqInfoResponseDto.getIsMultiCoupon()); return new Pair(spuId2, checkSpqInfoResponseDto.getTodayAvailableTimes());
} }
/** /**
...@@ -147,7 +147,7 @@ public interface ShoppingCartNewService { ...@@ -147,7 +147,7 @@ public interface ShoppingCartNewService {
* @param goodsId * @param goodsId
* @return * @return
*/ */
default Pair<String, Boolean> validCoupon(String partnerId default Pair<String, Integer> validCoupon(String partnerId
, String storeId , String storeId
, String couponCode , String couponCode
, List<Long> productIds , List<Long> productIds
...@@ -165,7 +165,7 @@ public interface ShoppingCartNewService { ...@@ -165,7 +165,7 @@ public interface ShoppingCartNewService {
productIds.add(Long.parseLong(checkSpqInfoResponseDto.getSkuId())); productIds.add(Long.parseLong(checkSpqInfoResponseDto.getSkuId()));
couponProductDto.setType(checkSpqInfoResponseDto.getCouponType()); couponProductDto.setType(checkSpqInfoResponseDto.getCouponType());
spuId2 = checkSpqInfoResponseDto.getSkuId(); spuId2 = checkSpqInfoResponseDto.getSkuId();
return new Pair(spuId2, checkSpqInfoResponseDto.getIsMultiCoupon()); return new Pair(spuId2, checkSpqInfoResponseDto.getTodayAvailableTimes());
} }
/** /**
......
...@@ -778,9 +778,13 @@ public class CouponServiceImpl implements CouponService { ...@@ -778,9 +778,13 @@ public class CouponServiceImpl implements CouponService {
dto.setCouponName(couponDetailResponseDto.getDetails().get(0).getTitle()); dto.setCouponName(couponDetailResponseDto.getDetails().get(0).getTitle());
dto.setActivityName(couponDetailResponseDto.getDetails().get(0).getActive().getActiveName()); dto.setActivityName(couponDetailResponseDto.getDetails().get(0).getActive().getActiveName());
if (couponDetailResponseDto.getDetails().get(0).getActive().getMaxRedeemTimes() != null && couponDetailResponseDto.getDetails().get(0).getActive().getMaxRedeemTimes() > 1){ if (couponDetailResponseDto.getDetails().get(0).getActive().getMaxRedeemTimes() != null && couponDetailResponseDto.getDetails().get(0).getActive().getMaxRedeemTimes() > 1){
dto.setIsMultiCoupon(true); if (couponDetailResponseDto.getDetails().get(0).getToday_available_times() != null){
dto.setTodayAvailableTimes(couponDetailResponseDto.getDetails().get(0).getToday_available_times());
} else {
dto.setTodayAvailableTimes(1);
}
} else { } else {
dto.setIsMultiCoupon(false); dto.setTodayAvailableTimes(1);
} }
dto.setPrice(productsVo.getFinalPrice()); dto.setPrice(productsVo.getFinalPrice());
dto.setSpuId(productsVo.getSpuId()); dto.setSpuId(productsVo.getSpuId());
...@@ -945,9 +949,13 @@ public class CouponServiceImpl implements CouponService { ...@@ -945,9 +949,13 @@ public class CouponServiceImpl implements CouponService {
} }
CheckSpqInfoResponseDto dto = new CheckSpqInfoResponseDto(); CheckSpqInfoResponseDto dto = new CheckSpqInfoResponseDto();
if (couponDetailResponseDto.getDetails().get(0).getActive().getMaxRedeemTimes() != null && couponDetailResponseDto.getDetails().get(0).getActive().getMaxRedeemTimes() > 1){ if (couponDetailResponseDto.getDetails().get(0).getActive().getMaxRedeemTimes() != null && couponDetailResponseDto.getDetails().get(0).getActive().getMaxRedeemTimes() > 1){
dto.setIsMultiCoupon(true); if (couponDetailResponseDto.getDetails().get(0).getToday_available_times() != null){
dto.setTodayAvailableTimes(couponDetailResponseDto.getDetails().get(0).getToday_available_times());
} else {
dto.setTodayAvailableTimes(1);
}
} else { } else {
dto.setIsMultiCoupon(false); dto.setTodayAvailableTimes(1);
} }
dto.setCouponCode(couponCode); dto.setCouponCode(couponCode);
dto.setActiveCode(couponActivityDetail.getActive().getActiveCode()); dto.setActiveCode(couponActivityDetail.getActive().getActiveCode());
......
...@@ -122,7 +122,7 @@ public class ShoppingCartMealServiceImpl implements ShoppingCartNewService { ...@@ -122,7 +122,7 @@ public class ShoppingCartMealServiceImpl implements ShoppingCartNewService {
productIds.add(Long.parseLong(goodsId)); productIds.add(Long.parseLong(goodsId));
} else { } else {
//校验券是否有效 //校验券是否有效
Pair<String, Boolean> pair = validCoupon(partnerId, storeId, spuId, productIds, BusinessTypeEnum.getByType(requestVo.getMenuType()).getCode(), null, null); Pair<String, Integer> pair = validCoupon(partnerId, storeId, spuId, productIds, BusinessTypeEnum.getByType(requestVo.getMenuType()).getCode(), null, null);
spuId2 = pair.getKey(); spuId2 = pair.getKey();
} }
// 获取商品信息 // 获取商品信息
......
...@@ -295,21 +295,21 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -295,21 +295,21 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
//商品skuId或者商品券的商品id //商品skuId或者商品券的商品id
String spuId2 = spuId; String spuId2 = spuId;
CouponProductDto couponProductDto = new CouponProductDto(); CouponProductDto couponProductDto = new CouponProductDto();
Boolean isMultiCoupon = false; Integer todayAvailableTimes = 0;
if (StringUtils.isBlank(couponCode)) { if (StringUtils.isBlank(couponCode)) {
productIds.add(Long.parseLong(goodsId)); productIds.add(Long.parseLong(goodsId));
} else { } else {
//校验券是否有效 这里是新的商品券支持多商品及换购券 //校验券是否有效 这里是新的商品券支持多商品及换购券
if (StringUtils.isNotBlank(skuId)) { if (StringUtils.isNotBlank(skuId)) {
Pair<String, Boolean> pair = validCoupon(partnerId, storeId, couponCode, productIds, BusinessTypeEnum.getByType(addShoppingCartGoodsRequestVo.getMenuType()).getCode(), skuId, couponProductDto); Pair<String, Integer> pair = validCoupon(partnerId, storeId, couponCode, productIds, BusinessTypeEnum.getByType(addShoppingCartGoodsRequestVo.getMenuType()).getCode(), skuId, couponProductDto);
spuId2 = pair.getKey(); spuId2 = pair.getKey();
isMultiCoupon = pair.getValue(); todayAvailableTimes = pair.getValue();
cartGoods.setGoodsId(spuId); cartGoods.setGoodsId(spuId);
} else { } else {
// 老版本商品券 // 老版本商品券
Pair<String, Boolean> pair = validCoupon(partnerId, storeId, couponCode, productIds, BusinessTypeEnum.getByType(addShoppingCartGoodsRequestVo.getMenuType()).getCode(), couponProductDto); Pair<String, Integer> pair = validCoupon(partnerId, storeId, couponCode, productIds, BusinessTypeEnum.getByType(addShoppingCartGoodsRequestVo.getMenuType()).getCode(), couponProductDto);
spuId2 = pair.getKey(); spuId2 = pair.getKey();
isMultiCoupon = pair.getValue(); todayAvailableTimes = pair.getValue();
} }
} }
// // 获取商品详细信息 // // 获取商品详细信息
...@@ -356,7 +356,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -356,7 +356,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
} else { } else {
// 当商品是商品券,里面会判断如果购物车中已有商品券,会将cartGoods的CartGoodsUid设为null // 当商品是商品券,里面会判断如果购物车中已有商品券,会将cartGoods的CartGoodsUid设为null
this.addProductGoods(addShoppingCartGoodsRequestVo, cartGoods, spuId2, userId, shoppingCartGoodsResponseVo, this.addProductGoods(addShoppingCartGoodsRequestVo, cartGoods, spuId2, userId, shoppingCartGoodsResponseVo,
spuId, allCartGoodsList, productBeanListSpuClass, couponProductDto, couponCode, isMultiCoupon); spuId, allCartGoodsList, productBeanListSpuClass, couponProductDto, couponCode, todayAvailableTimes);
} }
Long deliveryAmount = calculateDeliveryAmount(receiveId, partnerId, storeId, userLoginInfoDto.getWxAppid(), shoppingCartGoodsResponseVo,addShoppingCartGoodsRequestVo.getOrderType()); Long deliveryAmount = calculateDeliveryAmount(receiveId, partnerId, storeId, userLoginInfoDto.getWxAppid(), shoppingCartGoodsResponseVo,addShoppingCartGoodsRequestVo.getOrderType());
...@@ -1805,7 +1805,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -1805,7 +1805,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
*/ */
private void addProductGoods(AddShoppingCartGoodsRequestVo addShoppingCartGoodsRequestVo private void addProductGoods(AddShoppingCartGoodsRequestVo addShoppingCartGoodsRequestVo
, CartGoods cartGoods, String spuId2, String userId, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, String spuId , CartGoods cartGoods, String spuId2, String userId, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, String spuId
, List<CartGoods> allCartGoodsList, List<ProductBean> productBeanListSpuClass, CouponProductDto couponProductDto, String couponCode, Boolean isMultiCoupon) { , List<CartGoods> allCartGoodsList, List<ProductBean> productBeanListSpuClass, CouponProductDto couponProductDto, String couponCode, Integer todayAvailableTimes) {
...@@ -1822,9 +1822,9 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -1822,9 +1822,9 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
} }
// 商品券Id // 商品券Id
String spqId = spuId.substring(CommonsConstant.COUPON_PREFIX.length()); String spqId = spuId.substring(CommonsConstant.COUPON_PREFIX.length());
if (CollectionUtils.isNotEmpty(allCartGoodsList) && !isMultiCoupon){ if (CollectionUtils.isNotEmpty(allCartGoodsList)){
CartGoods sameCartGoods = allCartGoodsList.stream().filter(p -> p.getSpuId().equals(spqId)).findFirst().orElse(null); int sum = allCartGoodsList.stream().filter(p -> p.getSpuId().equals(spqId)).mapToInt(CartGoods::getQty).sum();
if (sameCartGoods != null && sameCartGoods.getQty() != null && sameCartGoods.getQty() > 0){ if (sum + cartGoods.getQty() > todayAvailableTimes){
throw new ServiceException(ResponseResult.SHOPPING_CART_GOODS_COUPON_CAN_NOT_USE); throw new ServiceException(ResponseResult.SHOPPING_CART_GOODS_COUPON_CAN_NOT_USE);
} }
} }
......
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