拼团活动同一店铺同一时间限制一个活动取消。

积分订单库存扣减,积分返还处理。
其他促销相关优化
This commit is contained in:
Chopper
2021-09-01 19:10:16 +08:00
parent 42e9ee06f4
commit fb006e13a0
11 changed files with 183 additions and 28 deletions

View File

@@ -23,7 +23,7 @@ public enum PromotionTypeEnum {
/**
* 有促销库存的活动类型
*/
static PromotionTypeEnum[] haveStockPromotion = new PromotionTypeEnum[]{SECKILL, KANJIA, POINTS_GOODS};
static PromotionTypeEnum[] haveStockPromotion = new PromotionTypeEnum[]{PINTUAN, SECKILL, KANJIA, POINTS_GOODS};
private final String description;

View File

@@ -1,5 +1,6 @@
package cn.lili.modules.order.cart.render;
import cn.lili.common.exception.ServiceException;
import cn.lili.modules.order.cart.entity.dto.TradeDTO;
import cn.lili.modules.order.cart.entity.enums.CartTypeEnum;
import cn.lili.modules.order.cart.entity.enums.RenderStepEnums;
@@ -125,6 +126,8 @@ public class TradeBuilder {
if (render.step().equals(step)) {
render.render(tradeDTO);
}
} catch (ServiceException e) {
throw e;
} catch (Exception e) {
log.error("购物车{}渲染异常:", render.getClass(), e);
}

View File

@@ -58,6 +58,9 @@ public class CartPriceRender implements CartRenderStep {
List<CartVO> cartVOS = tradeDTO.getCartList();
cartVOS.forEach(cartVO -> {
List<PriceDetailDTO> skuPrices = cartVO.getSkuList().stream().filter(CartSkuVO::getChecked)
.map(CartSkuVO::getPriceDetailDTO).collect(Collectors.toList());
cartVO.getPriceDetailDTO().accumulationPriceDTO(
cartVO.getSkuList().stream().filter(CartSkuVO::getChecked)
.map(CartSkuVO::getPriceDetailDTO).collect(Collectors.toList())

View File

@@ -85,6 +85,13 @@ public class CheckDataRender implements CartRenderStep {
private void checkData(TradeDTO tradeDTO) {
//循环购物车中的商品
for (CartSkuVO cartSkuVO : tradeDTO.getSkuList()) {
//如果失效确认sku为未选中状态
if (cartSkuVO.getInvalid()) {
//设置购物车未选中
cartSkuVO.setChecked(false);
}
//缓存中的商品信息
GoodsSku dataSku = goodsSkuService.getGoodsSkuByIdFromCache(cartSkuVO.getGoodsSku().getId());
//商品有效性判定

View File

@@ -86,7 +86,7 @@ public class SkuPromotionRender implements CartRenderStep {
for (CartVO cartVO : tradeDTO.getCartList()) {
for (CartSkuVO cartSkuVO : cartVO.getSkuList()) {
cartSkuVO.getPriceDetailDTO().setPayPoint(cartSkuVO.getPoint());
PromotionSkuVO promotionSkuVO = new PromotionSkuVO(PromotionTypeEnum.PINTUAN.name(), cartSkuVO.getPointsId());
PromotionSkuVO promotionSkuVO = new PromotionSkuVO(PromotionTypeEnum.POINTS_GOODS.name(), cartSkuVO.getPointsId());
cartSkuVO.getPriceDetailDTO().getJoinPromotion().add(promotionSkuVO);
}
}

View File

@@ -206,7 +206,6 @@ public class PintuanServiceImpl extends ServiceImpl<PintuanMapper, Pintuan> impl
@Override
public boolean addPintuan(PintuanVO pintuan) {
PromotionTools.checkPromotionTime(pintuan.getStartTime().getTime(), pintuan.getEndTime().getTime());
this.checkSamePromotion(pintuan.getStartTime(), pintuan.getEndTime(), pintuan.getStoreId(), null);
pintuan.setPromotionStatus(PromotionStatusEnum.NEW.name());
//保存到MYSQL中
boolean result = this.save(pintuan);
@@ -224,8 +223,6 @@ public class PintuanServiceImpl extends ServiceImpl<PintuanMapper, Pintuan> impl
}
//检查促销时间
PromotionTools.checkPromotionTime(pintuan.getStartTime().getTime(), pintuan.getEndTime().getTime());
//检查同一时间,同一店铺,同一类型的促销活动
this.checkSamePromotion(pintuan.getStartTime(), pintuan.getEndTime(), pintuan.getStoreId(), pintuan.getId());
boolean result = this.updateById(pintuan);
if (pintuan.getPromotionGoodsList() != null) {
this.updatePintuanPromotionGoods(pintuan);
@@ -393,14 +390,10 @@ public class PintuanServiceImpl extends ServiceImpl<PintuanMapper, Pintuan> impl
}
}
private void checkSamePromotion(Date startTime, Date endTime, String storeId, String pintuanId) {
QueryWrapper<Pintuan> queryWrapper = PromotionTools.checkActiveTime(startTime, endTime, PromotionTypeEnum.PINTUAN, storeId, pintuanId);
List<Pintuan> list = this.list(queryWrapper);
if (!list.isEmpty()) {
throw new ServiceException(ResultCode.PROMOTION_SAME_ERROR);
}
}
/**
* 增加拼团定时任务
* @param pintuan
*/
private void addPintuanStartTask(PintuanVO pintuan) {
PromotionMessage promotionMessage = new PromotionMessage(pintuan.getId(), PromotionTypeEnum.PINTUAN.name(), PromotionStatusEnum.START.name(), pintuan.getStartTime(), pintuan.getEndTime());
TimeTriggerMsg timeTriggerMsg = new TimeTriggerMsg(TimeExecuteConstant.PROMOTION_EXECUTOR,

View File

@@ -2,6 +2,8 @@ package cn.lili.modules.promotion.serviceimpl;
import cn.hutool.core.util.StrUtil;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.security.context.UserContext;
import cn.lili.common.security.enums.UserEnums;
import cn.lili.trigger.util.DelayQueueTools;
import cn.lili.trigger.enums.DelayTypeEnums;
import cn.lili.trigger.message.PromotionMessage;
@@ -226,6 +228,9 @@ public class PointsGoodsServiceImpl extends ServiceImpl<PointsGoodsMapper, Point
@Override
public IPage<PointsGoodsVO> getPointsGoodsByPage(PointsGoodsSearchParams searchParams, PageVO page) {
IPage<PointsGoodsVO> pointsGoodsPage = new Page<>();
if (UserContext.getCurrentUser().getRole().equals(UserEnums.MEMBER)) {
searchParams.setPromotionStatus(PromotionStatusEnum.START.name());
}
Query query = searchParams.mongoQuery();
if (page != null) {
PromotionTools.mongoQueryPageParam(query, page);