Commit 35c8fa42 by chongfu.liang

优惠券列表优化

parent 8b02c8be
......@@ -573,6 +573,7 @@ public class CouponAdapter {
couponPromotionVO.setCouponCode(baseRequestDTO.getCouponCode());
couponPromotionVO.setOrderType(baseRequestDTO.getOrderType());
couponPromotionVO.setFlg(baseRequestDTO.getFlag());
couponPromotionVO.setUnChooseCouponCode(baseRequestDTO.getUnChooseCouponCode());
return couponPromotionVO;
}
......
......@@ -15,6 +15,7 @@ import cn.freemud.enums.CouponFlag;
import cn.freemud.enums.GoodsTypeEnum;
import cn.freemud.service.CouponService;
import cn.freemud.service.impl.AssortmentSdkService;
import com.freemud.sdk.api.assortment.shoppingcart.constant.CommonsConstant;
import com.freemud.sdk.api.assortment.shoppingcart.service.impl.ShoppingCartBaseServiceImpl;
import com.google.common.collect.Lists;
import org.apache.commons.collections4.CollectionUtils;
......@@ -56,6 +57,12 @@ public class DistributeAdapter {
List<CartGoods> tmpCartGoods = cartGoodsList.parallelStream().filter(k -> CommonUtils.isProductCoupon(k.getCouponCode(), k.getCartGoodsUid())).collect(Collectors.toList());
// 是否存在商品券
boolean hasGoodssCoupon = CollectionUtils.isNotEmpty(tmpCartGoods);
String chooseCouponCode = "";
if (StringUtils.isBlank(couponPromotionVO.getUnChooseCouponCode()) && hasGoodssCoupon){
chooseCouponCode = tmpCartGoods.get(0).getGoodsId().substring(CommonsConstant.COUPON_PREFIX.length());
}
// 构建可用不可用优惠券
ActivityClassifyCouponBean activityClassifyCouponBean = couponService.availableCoupon(cartGoodsList
, couponPromotionVO.getPartnerId()
......@@ -65,7 +72,7 @@ public class DistributeAdapter {
, hasGoodssCoupon
, couponPromotionVO.getOrderType()
, 1
, bo.getAppId(), bo.getMenuType(), ""
, bo.getAppId(), bo.getMenuType(), chooseCouponCode
);
if (Objects.equals(activityClassifyCouponBean, null)) {
// 构建一个空得订单券信息
......
......@@ -105,6 +105,10 @@ public class ListCartGoodsRequestDTO extends BaseRequestDTO {
*/
private String monthlyCardCode;
/**
* 取消选择的商品券
*/
private String unChooseCouponCode;
@Data
public final static class BuyMemberCard {
......
......@@ -101,7 +101,10 @@ public class ListCartGoodsBO extends BaseBo {
private String tableNumber;
/**
* 取消选择的商品券
*/
private String unChooseCouponCode;
}
......@@ -25,6 +25,7 @@ import cn.freemud.entities.vo.*;
import cn.freemud.enums.*;
import cn.freemud.interceptor.ServiceException;
import cn.freemud.redis.RedisCache;
import cn.freemud.service.CouponService;
import cn.freemud.service.impl.AssortmentSdkService;
import cn.freemud.service.impl.calculate.CalculationCommonService;
import cn.freemud.utils.LogUtil;
......@@ -87,6 +88,9 @@ public class AbstractListCartGoodsService implements ListCartGoodsService {
@Autowired
private MessageService messageService;
@Autowired
private CouponService couponService;
private static final String limitCartKey = "ecology:kgd:wxappconfig:open_platform_partner_wxapp_config:appkey_";
......@@ -210,6 +214,29 @@ public class AbstractListCartGoodsService implements ListCartGoodsService {
List<CartGoods> allCartGoodsList = assortmentSdkService.getShoppingCart(baseRequestBO.getPartnerId(), baseRequestBO.getShopId(), userInfo.getUserId(), baseRequestBO.getSessionId(), null, shoppingCartBaseService);
if (CollectionUtils.isEmpty(allCartGoodsList)) {
allCartGoodsList = new ArrayList<>();
} else {
// check是否反选取消商品券
if (StringUtils.isNotBlank(baseRequestBO.getUnChooseCouponCode())){
// 遍历该商品券选择的商品,并将商品券替换为普通商品
for (int i = allCartGoodsList.size() - 1; i >= 0; i--){
CartGoods cartGoods = allCartGoodsList.get(i);
if (GoodsTypeEnum.COUPON_GOODS.getGoodsType().equals(cartGoods.getGoodsType()) || GoodsTypeEnum.HG_COUPON_GOODS.getGoodsType().equals(cartGoods.getGoodsType())){
CheckSpqInfoRequestDto checkSpqInfoRequestDto = new CheckSpqInfoRequestDto(baseRequestBO.getPartnerId(), baseRequestBO.getShopId(), cartGoods.getSpuId(), baseRequestBO.getMenuType());
GetProductsVo productInfo = null;
if (GoodsTypeEnum.HG_COUPON_GOODS.getGoodsType().equals(cartGoods.getGoodsType())) {
productInfo = couponService.getSpqProductInfo(checkSpqInfoRequestDto, cartGoods.getSkuId());
} else {
productInfo = couponService.getSpqProductInfo(checkSpqInfoRequestDto);
}
if (productInfo == null){
allCartGoodsList.remove(i);
} else {
convert2CartGoods(cartGoods, productInfo);
}
}
}
}
}
bo.setCartGoods(allCartGoodsList);
......@@ -1643,4 +1670,31 @@ public class AbstractListCartGoodsService implements ListCartGoodsService {
return chooseGoods;
}
private void convert2CartGoods(CartGoods cartGoods, GetProductsVo productInfo) {
cartGoods.setCartGoodsUid(UUID.randomUUID().toString());
Integer goodsType = GoodsTypeEnum.SPU_GOODS.getGoodsType();
if (productInfo.getType() == null || productInfo.getType() == 1) {
goodsType = GoodsTypeEnum.SPU_GOODS.getGoodsType();
} else {
goodsType = GoodsTypeEnum.SKU_GOODS.getGoodsType();
}
cartGoods.setGoodsType(goodsType);
cartGoods.setAmount(productInfo.getFinalPrice());
cartGoods.setCategoryName(productInfo.getCategoryName());
cartGoods.setCustomerCode(productInfo.getCustomerCode());
cartGoods.setFinalPrice(null);
cartGoods.setGoodsId(cartGoods.getSkuId());
cartGoods.setMaterialAmount(0l);
cartGoods.setName(goodsType == GoodsTypeEnum.SPU_GOODS.getGoodsType() ? productInfo.getSpuName() : productInfo.getSkuName());
cartGoods.setOriginalPrice(productInfo.getFinalPrice());
cartGoods.setOriginalMaterialAmount(0l);
cartGoods.setSpuId(productInfo.getSpuId());
cartGoods.setSkuId(cartGoods.getSkuId());
cartGoods.setSpuName(productInfo.getSpuName());
cartGoods.setSkuName(productInfo.getSkuName());
cartGoods.setCouponCode(null);
}
}
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