Commit 4ba08330 by chongfu.liang

商品券多次添加fix

parent c2e6e6dc
...@@ -17,6 +17,7 @@ import com.alibaba.fastjson.JSON; ...@@ -17,6 +17,7 @@ import com.alibaba.fastjson.JSON;
import com.freemud.application.sdk.api.base.SDKCommonBaseContextWare; import com.freemud.application.sdk.api.base.SDKCommonBaseContextWare;
import com.freemud.application.sdk.api.productcenter.domain.ProductBeanDTO; import com.freemud.application.sdk.api.productcenter.domain.ProductBeanDTO;
import com.freemud.sdk.api.assortment.shoppingcart.constant.CommonsConstant; import com.freemud.sdk.api.assortment.shoppingcart.constant.CommonsConstant;
import javafx.util.Pair;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
...@@ -114,12 +115,12 @@ public interface ShoppingCartNewService { ...@@ -114,12 +115,12 @@ public interface ShoppingCartNewService {
* @param productIds * @param productIds
* @return * @return
*/ */
default String validCoupon(String partnerId default Pair<String, Boolean> validCoupon(String partnerId
, String storeId , String storeId
, String couponCode , String couponCode
, List<Long> productIds , List<Long> productIds
, String menuType , String menuType
, CouponProductDto couponProductDto, Integer couponQty) { , CouponProductDto couponProductDto) {
String spuId2; String spuId2;
CheckSpqInfoRequestDto checkSpqInfoRequestDto = new CheckSpqInfoRequestDto(partnerId, storeId, couponCode, menuType); CheckSpqInfoRequestDto checkSpqInfoRequestDto = new CheckSpqInfoRequestDto(partnerId, storeId, couponCode, menuType);
CouponService couponService = SDKCommonBaseContextWare.getBean(CouponService.class); CouponService couponService = SDKCommonBaseContextWare.getBean(CouponService.class);
...@@ -127,15 +128,12 @@ public interface ShoppingCartNewService { ...@@ -127,15 +128,12 @@ public interface ShoppingCartNewService {
if (checkSpqInfoResponseDto == null) { if (checkSpqInfoResponseDto == null) {
throw new ServiceException(ResponseResult.SHOPPING_CART_COUPON_NOT_EXIST); throw new ServiceException(ResponseResult.SHOPPING_CART_COUPON_NOT_EXIST);
} }
if (!checkSpqInfoResponseDto.getIsMultiCoupon() && couponQty != null && couponQty > 1) {
throw new ServiceException(ResponseResult.SHOPPING_CART_GOODS_COUPON_CAN_NOT_USE);
}
if (couponProductDto != null) { if (couponProductDto != null) {
couponProductDto.setType(checkSpqInfoResponseDto.getCouponType()); couponProductDto.setType(checkSpqInfoResponseDto.getCouponType());
} }
productIds.add(Long.parseLong(checkSpqInfoResponseDto.getSkuId())); productIds.add(Long.parseLong(checkSpqInfoResponseDto.getSkuId()));
spuId2 = checkSpqInfoResponseDto.getSkuId(); spuId2 = checkSpqInfoResponseDto.getSkuId();
return spuId2; return new Pair(spuId2, checkSpqInfoResponseDto.getIsMultiCoupon());
} }
/** /**
...@@ -149,13 +147,13 @@ public interface ShoppingCartNewService { ...@@ -149,13 +147,13 @@ public interface ShoppingCartNewService {
* @param goodsId * @param goodsId
* @return * @return
*/ */
default String validCoupon(String partnerId default Pair<String, Boolean> validCoupon(String partnerId
, String storeId , String storeId
, String couponCode , String couponCode
, List<Long> productIds , List<Long> productIds
, String menuType , String menuType
, String goodsId , String goodsId
, CouponProductDto couponProductDto, Integer couponQty) { , CouponProductDto couponProductDto) {
String spuId2; String spuId2;
CheckSpqInfoRequestDto checkSpqInfoRequestDto = new CheckSpqInfoRequestDto(partnerId, storeId, couponCode, menuType); CheckSpqInfoRequestDto checkSpqInfoRequestDto = new CheckSpqInfoRequestDto(partnerId, storeId, couponCode, menuType);
CouponService couponService = SDKCommonBaseContextWare.getBean(CouponService.class); CouponService couponService = SDKCommonBaseContextWare.getBean(CouponService.class);
...@@ -164,13 +162,10 @@ public interface ShoppingCartNewService { ...@@ -164,13 +162,10 @@ public interface ShoppingCartNewService {
if (checkSpqInfoResponseDto == null) { if (checkSpqInfoResponseDto == null) {
throw new ServiceException(ResponseResult.SHOPPING_CART_COUPON_MIX_NOT_EXIST); throw new ServiceException(ResponseResult.SHOPPING_CART_COUPON_MIX_NOT_EXIST);
} }
if (!checkSpqInfoResponseDto.getIsMultiCoupon() && couponQty != null && couponQty > 1) {
throw new ServiceException(ResponseResult.SHOPPING_CART_GOODS_COUPON_CAN_NOT_USE);
}
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 spuId2; return new Pair(spuId2, checkSpqInfoResponseDto.getIsMultiCoupon());
} }
/** /**
......
...@@ -43,6 +43,7 @@ import com.freemud.sdk.api.assortment.shoppingcart.domain.CartParamDto; ...@@ -43,6 +43,7 @@ import com.freemud.sdk.api.assortment.shoppingcart.domain.CartParamDto;
import com.freemud.sdk.api.assortment.shoppingcart.enums.BusinessTypeEnum; import com.freemud.sdk.api.assortment.shoppingcart.enums.BusinessTypeEnum;
import com.freemud.sdk.api.assortment.shoppingcart.request.CheckCartRequest; import com.freemud.sdk.api.assortment.shoppingcart.request.CheckCartRequest;
import com.freemud.sdk.api.assortment.shoppingcart.service.impl.MealCartBaseServiceImpl; import com.freemud.sdk.api.assortment.shoppingcart.service.impl.MealCartBaseServiceImpl;
import javafx.util.Pair;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -121,7 +122,8 @@ public class ShoppingCartMealServiceImpl implements ShoppingCartNewService { ...@@ -121,7 +122,8 @@ public class ShoppingCartMealServiceImpl implements ShoppingCartNewService {
productIds.add(Long.parseLong(goodsId)); productIds.add(Long.parseLong(goodsId));
} else { } else {
//校验券是否有效 //校验券是否有效
spuId2 = validCoupon(partnerId, storeId, spuId, productIds, BusinessTypeEnum.getByType(requestVo.getMenuType()).getCode(), null, null); Pair<String, Boolean> pair = validCoupon(partnerId, storeId, spuId, productIds, BusinessTypeEnum.getByType(requestVo.getMenuType()).getCode(), null, null);
spuId2 = pair.getKey();
} }
// 获取商品信息 // 获取商品信息
List<ProductBeanDTO> productBeanListSpuClass = List<ProductBeanDTO> productBeanListSpuClass =
......
...@@ -75,6 +75,7 @@ import com.freemud.sdk.api.assortment.shoppingcart.request.CheckCartRequest; ...@@ -75,6 +75,7 @@ import com.freemud.sdk.api.assortment.shoppingcart.request.CheckCartRequest;
import com.freemud.sdk.api.assortment.shoppingcart.service.ShoppingCartBaseService; import com.freemud.sdk.api.assortment.shoppingcart.service.ShoppingCartBaseService;
import com.freemud.sdk.api.assortment.shoppingcart.service.impl.ShoppingCartBaseServiceImpl; import com.freemud.sdk.api.assortment.shoppingcart.service.impl.ShoppingCartBaseServiceImpl;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import javafx.util.Pair;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.ObjectUtils;
...@@ -291,16 +292,21 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -291,16 +292,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;
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)) {
spuId2 = validCoupon(partnerId, storeId, couponCode, productIds, BusinessTypeEnum.getByType(addShoppingCartGoodsRequestVo.getMenuType()).getCode(), skuId, couponProductDto, addShoppingCartGoodsRequestVo.getQty()); Pair<String, Boolean> pair = validCoupon(partnerId, storeId, couponCode, productIds, BusinessTypeEnum.getByType(addShoppingCartGoodsRequestVo.getMenuType()).getCode(), skuId, couponProductDto);
spuId2 = pair.getKey();
isMultiCoupon = pair.getValue();
cartGoods.setGoodsId(spuId); cartGoods.setGoodsId(spuId);
} else { } else {
// 老版本商品券 // 老版本商品券
spuId2 = validCoupon(partnerId, storeId, couponCode, productIds, BusinessTypeEnum.getByType(addShoppingCartGoodsRequestVo.getMenuType()).getCode(), couponProductDto, addShoppingCartGoodsRequestVo.getQty()); Pair<String, Boolean> pair = validCoupon(partnerId, storeId, couponCode, productIds, BusinessTypeEnum.getByType(addShoppingCartGoodsRequestVo.getMenuType()).getCode(), couponProductDto);
spuId2 = pair.getKey();
isMultiCoupon = pair.getValue();
} }
} }
// 获取商品详细信息 // 获取商品详细信息
...@@ -330,6 +336,9 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -330,6 +336,9 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
allCartGoodsList.get(allCartGoodsList.indexOf(cartGoods)).getQty() + cartGoods.getQty() : cartGoods.getQty(); allCartGoodsList.get(allCartGoodsList.indexOf(cartGoods)).getQty() + cartGoods.getQty() : cartGoods.getQty();
*/ */
Integer checkQty = this.checkSkuQty(allCartGoodsList, cartGoods); Integer checkQty = this.checkSkuQty(allCartGoodsList, cartGoods);
if (checkQty > 1 && !isMultiCoupon){
throw new ServiceException(ResponseResult.SHOPPING_CART_GOODS_COUPON_CAN_NOT_USE);
}
//购物车添加数量限制 //购物车添加数量限制
Integer productsCount = limitGoodsQty(allCartGoodsList,cartGoods,appId); Integer productsCount = limitGoodsQty(allCartGoodsList,cartGoods,appId);
//查询多个商品库存信息 TODO //查询多个商品库存信息 TODO
......
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