Commit 77507b07 by chongfu.liang

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

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