!90 修复优化促销

Merge pull request !90 from OceansDeep/feature/pg
This commit is contained in:
OceansDeep 2021-12-25 11:08:54 +00:00 committed by Gitee
commit dbcee40b93
37 changed files with 180 additions and 197 deletions

View File

@ -5,6 +5,7 @@ import cn.lili.common.vo.PageVO;
import cn.lili.common.vo.ResultMessage; import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.promotion.entity.dos.PointsGoods; import cn.lili.modules.promotion.entity.dos.PointsGoods;
import cn.lili.modules.promotion.entity.dos.PointsGoodsCategory; import cn.lili.modules.promotion.entity.dos.PointsGoodsCategory;
import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum;
import cn.lili.modules.promotion.entity.vos.PointsGoodsSearchParams; import cn.lili.modules.promotion.entity.vos.PointsGoodsSearchParams;
import cn.lili.modules.promotion.entity.vos.PointsGoodsVO; import cn.lili.modules.promotion.entity.vos.PointsGoodsVO;
import cn.lili.modules.promotion.service.PointsGoodsCategoryService; import cn.lili.modules.promotion.service.PointsGoodsCategoryService;
@ -37,6 +38,7 @@ public class PointsGoodsBuyerController {
@GetMapping @GetMapping
@ApiOperation(value = "分页获取积分商品") @ApiOperation(value = "分页获取积分商品")
public ResultMessage<IPage<PointsGoods>> getPointsGoodsPage(PointsGoodsSearchParams searchParams, PageVO page) { public ResultMessage<IPage<PointsGoods>> getPointsGoodsPage(PointsGoodsSearchParams searchParams, PageVO page) {
searchParams.setPromotionStatus(PromotionsStatusEnum.START.name());
IPage<PointsGoods> pointsGoodsByPage = pointsGoodsService.pageFindAll(searchParams, page); IPage<PointsGoods> pointsGoodsByPage = pointsGoodsService.pageFindAll(searchParams, page);
return ResultUtil.data(pointsGoodsByPage); return ResultUtil.data(pointsGoodsByPage);
} }

View File

@ -1,18 +1,16 @@
package cn.lili.event.impl; package cn.lili.event.impl;
import cn.hutool.core.date.DateUtil;
import cn.lili.event.MemberRegisterEvent; import cn.lili.event.MemberRegisterEvent;
import cn.lili.modules.member.entity.dos.Member; import cn.lili.modules.member.entity.dos.Member;
import cn.lili.modules.promotion.entity.dos.CouponActivity; import cn.lili.modules.promotion.entity.dos.CouponActivity;
import cn.lili.modules.promotion.entity.dto.BasePromotions;
import cn.lili.modules.promotion.entity.enums.CouponActivityTypeEnum; import cn.lili.modules.promotion.entity.enums.CouponActivityTypeEnum;
import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum; import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum;
import cn.lili.modules.promotion.service.CouponActivityService; import cn.lili.modules.promotion.service.CouponActivityService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import cn.lili.modules.promotion.tools.PromotionTools;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@ -35,10 +33,9 @@ public class RegisteredCouponActivityExecute implements MemberRegisterEvent {
*/ */
@Override @Override
public void memberRegister(Member member) { public void memberRegister(Member member) {
List<CouponActivity> couponActivities = couponActivityService.list(new LambdaQueryWrapper<CouponActivity>() List<CouponActivity> couponActivities = couponActivityService.list(new QueryWrapper<CouponActivity>()
.eq(CouponActivity::getCouponActivityType, CouponActivityTypeEnum.REGISTERED.name()) .eq("coupon_activity_type", CouponActivityTypeEnum.REGISTERED.name())
.ge(BasePromotions::getEndTime, new Date()) .and(PromotionTools.queryPromotionStatus(PromotionsStatusEnum.START)));
.le(BasePromotions::getStartTime, new Date()));
couponActivityService.registered(couponActivities, member); couponActivityService.registered(couponActivities, member);
} }
} }

View File

@ -27,6 +27,7 @@ import cn.lili.modules.promotion.entity.dto.BasePromotions;
import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum; import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum;
import cn.lili.modules.promotion.entity.vos.PromotionGoodsSearchParams; import cn.lili.modules.promotion.entity.vos.PromotionGoodsSearchParams;
import cn.lili.modules.promotion.service.PromotionGoodsService; import cn.lili.modules.promotion.service.PromotionGoodsService;
import cn.lili.modules.promotion.service.PromotionService;
import cn.lili.modules.search.entity.dos.EsGoodsIndex; import cn.lili.modules.search.entity.dos.EsGoodsIndex;
import cn.lili.modules.search.service.EsGoodsIndexService; import cn.lili.modules.search.service.EsGoodsIndexService;
import cn.lili.modules.store.service.StoreService; import cn.lili.modules.store.service.StoreService;
@ -113,6 +114,9 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
@Autowired @Autowired
private StoreGoodsLabelService storeGoodsLabelService; private StoreGoodsLabelService storeGoodsLabelService;
@Autowired
private PromotionService promotionService;
@Autowired @Autowired
private PromotionGoodsService promotionGoodsService; private PromotionGoodsService promotionGoodsService;
@ -362,6 +366,11 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
goodsIndex.setStoreCategoryNamePath(ArrayUtil.join(storeGoodsLabels.stream().map(StoreGoodsLabel::getLabelName).toArray(), ",")); goodsIndex.setStoreCategoryNamePath(ArrayUtil.join(storeGoodsLabels.stream().map(StoreGoodsLabel::getLabelName).toArray(), ","));
} }
} }
if (goodsIndex.getPromotionMap() == null || goodsIndex.getPromotionMap().isEmpty()) {
Map<String, Object> goodsCurrentPromotionMap = promotionService.getGoodsPromotionMap(goodsIndex);
goodsIndex.setPromotionMap(goodsCurrentPromotionMap);
}
} }

View File

@ -67,6 +67,7 @@ public enum ResultCode {
GOODS_AUTH_ERROR(11005, "商品审核失败"), GOODS_AUTH_ERROR(11005, "商品审核失败"),
POINT_GOODS_ERROR(11006, "积分商品业务异常,请稍后重试"), POINT_GOODS_ERROR(11006, "积分商品业务异常,请稍后重试"),
POINT_GOODS_NOT_EXIST(11020, "积分商品不存在"), POINT_GOODS_NOT_EXIST(11020, "积分商品不存在"),
POINT_GOODS_CATEGORY_EXIST(11021, "当前积分商品分类已存在"),
GOODS_SKU_SN_ERROR(11007, "商品SKU货号不能为空"), GOODS_SKU_SN_ERROR(11007, "商品SKU货号不能为空"),
GOODS_SKU_PRICE_ERROR(11008, "商品SKU价格不能小于等于0"), GOODS_SKU_PRICE_ERROR(11008, "商品SKU价格不能小于等于0"),
GOODS_SKU_COST_ERROR(11009, "商品SKU成本价不能小于等于0"), GOODS_SKU_COST_ERROR(11009, "商品SKU成本价不能小于等于0"),
@ -179,6 +180,7 @@ public enum ResultCode {
ORDER_CAN_NOT_CANCEL(31012, "当前订单状态不可取消"), ORDER_CAN_NOT_CANCEL(31012, "当前订单状态不可取消"),
ORDER_BATCH_DELIVER_ERROR(31013, "批量发货,文件读取失败"), ORDER_BATCH_DELIVER_ERROR(31013, "批量发货,文件读取失败"),
ORDER_ITEM_NOT_EXIST(31014, "当前订单项不存在!"), ORDER_ITEM_NOT_EXIST(31014, "当前订单项不存在!"),
POINT_NOT_ENOUGH(31015, "当前会员积分不足购买当前积分商品!"),
/** /**

View File

@ -8,6 +8,7 @@ import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.modules.goods.entity.dto.GoodsOperationDTO; import cn.lili.modules.goods.entity.dto.GoodsOperationDTO;
import cn.lili.modules.goods.entity.enums.GoodsStatusEnum; import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;
import cn.lili.modules.goods.entity.enums.GoodsTypeEnum;
import cn.lili.mybatis.BaseEntity; import cn.lili.mybatis.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
@ -181,7 +182,7 @@ public class Goods extends BaseEntity {
throw new ServiceException(ResultCode.GOODS_SKU_COST_ERROR); throw new ServiceException(ResultCode.GOODS_SKU_COST_ERROR);
} }
//虚拟商品没有重量字段 //虚拟商品没有重量字段
if (!sku.containsKey("weight") || sku.containsKey("weight") && (StringUtil.isEmpty(sku.get("weight").toString()) || Convert.toDouble(sku.get("weight").toString()) < 0)) { if (this.goodsType.equals(GoodsTypeEnum.PHYSICAL_GOODS.name()) && (!sku.containsKey("weight") || sku.containsKey("weight") && (StringUtil.isEmpty(sku.get("weight").toString()) || Convert.toDouble(sku.get("weight").toString()) < 0))) {
throw new ServiceException(ResultCode.GOODS_SKU_WEIGHT_ERROR); throw new ServiceException(ResultCode.GOODS_SKU_WEIGHT_ERROR);
} }
if (!sku.containsKey("quantity") || StringUtil.isEmpty(sku.get("quantity").toString()) || Convert.toInt(sku.get("quantity").toString()) < 0) { if (!sku.containsKey("quantity") || StringUtil.isEmpty(sku.get("quantity").toString()) || Convert.toInt(sku.get("quantity").toString()) < 0) {

View File

@ -241,7 +241,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
//获取当前商品的索引信息 //获取当前商品的索引信息
EsGoodsIndex goodsIndex = goodsIndexService.findById(skuId); EsGoodsIndex goodsIndex = goodsIndexService.findById(skuId);
if (goodsIndex == null) { if (goodsIndex == null) {
goodsIndex = goodsIndexService.resetEsGoodsIndex(goodsSku, goodsVO.getGoodsParamsDTOList()); goodsIndex = goodsIndexService.getTempEsGoodsIndex(goodsSku, goodsVO.getGoodsParamsDTOList());
//发送mq消息 //发送mq消息
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.RESET_GOODS_INDEX.name(); String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.RESET_GOODS_INDEX.name();

View File

@ -85,6 +85,7 @@ public class CartVO extends CartBase implements Serializable {
this.setCouponList(new ArrayList<>()); this.setCouponList(new ArrayList<>());
this.setGiftList(new ArrayList<>()); this.setGiftList(new ArrayList<>());
this.setGiftCouponList(new ArrayList<>()); this.setGiftCouponList(new ArrayList<>());
this.setCanReceiveCoupon(new ArrayList<>());
this.setChecked(false); this.setChecked(false);
this.isFull = false; this.isFull = false;
this.weight = 0d; this.weight = 0d;

View File

@ -44,6 +44,7 @@ public class RenderStepStatement {
public static RenderStepEnums[] checkedSingleRender = { public static RenderStepEnums[] checkedSingleRender = {
RenderStepEnums.CHECK_DATA, RenderStepEnums.CHECK_DATA,
RenderStepEnums.SKU_PROMOTION, RenderStepEnums.SKU_PROMOTION,
RenderStepEnums.COUPON,
RenderStepEnums.SKU_FREIGHT, RenderStepEnums.SKU_FREIGHT,
RenderStepEnums.CART_PRICE RenderStepEnums.CART_PRICE
}; };

View File

@ -20,9 +20,12 @@ import cn.lili.modules.order.cart.entity.vo.CartVO;
import cn.lili.modules.order.cart.render.CartRenderStep; import cn.lili.modules.order.cart.render.CartRenderStep;
import cn.lili.modules.order.order.entity.dos.Order; import cn.lili.modules.order.order.entity.dos.Order;
import cn.lili.modules.order.order.service.OrderService; import cn.lili.modules.order.order.service.OrderService;
import cn.lili.modules.promotion.entity.dos.Coupon;
import cn.lili.modules.promotion.entity.dos.Pintuan; import cn.lili.modules.promotion.entity.dos.Pintuan;
import cn.lili.modules.promotion.entity.dos.PointsGoods; import cn.lili.modules.promotion.entity.dos.PointsGoods;
import cn.lili.modules.promotion.entity.dto.BasePromotions; import cn.lili.modules.promotion.entity.dto.BasePromotions;
import cn.lili.modules.promotion.entity.vos.CouponVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -39,6 +42,7 @@ import java.util.stream.Collectors;
* @since 2020-07-02 14:47 * @since 2020-07-02 14:47
*/ */
@Service @Service
@Slf4j
public class CheckDataRender implements CartRenderStep { public class CheckDataRender implements CartRenderStep {
@Autowired @Autowired
@ -144,6 +148,16 @@ public class CheckDataRender implements CartRenderStep {
cartVO.setDeliveryMethod(DeliveryMethodEnum.LOGISTICS.name()); cartVO.setDeliveryMethod(DeliveryMethodEnum.LOGISTICS.name());
} }
cartVO.setSkuList(storeCart.getValue()); cartVO.setSkuList(storeCart.getValue());
try {
//筛选属于当前店铺的优惠券
storeCart.getValue().forEach(i -> i.getPromotionMap().forEach((key, value) -> {
if (key.contains(PromotionTypeEnum.COUPON.name()) && ((Coupon) value).getStoreId().equals(storeCart.getKey())) {
cartVO.getCanReceiveCoupon().add(new CouponVO((Coupon) value));
}
}));
} catch (Exception e) {
log.error("筛选属于当前店铺的优惠券发生异常!", e);
}
storeCart.getValue().stream().filter(i -> Boolean.TRUE.equals(i.getChecked())).findFirst().ifPresent(cartSkuVO -> cartVO.setChecked(true)); storeCart.getValue().stream().filter(i -> Boolean.TRUE.equals(i.getChecked())).findFirst().ifPresent(cartSkuVO -> cartVO.setChecked(true));
cartList.add(cartVO); cartList.add(cartVO);
} }

View File

@ -1,8 +1,12 @@
package cn.lili.modules.order.cart.render.impl; package cn.lili.modules.order.cart.render.impl;
import cn.lili.common.enums.PromotionTypeEnum; import cn.lili.common.enums.PromotionTypeEnum;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException;
import cn.lili.common.security.context.UserContext; import cn.lili.common.security.context.UserContext;
import cn.lili.common.utils.CurrencyUtil; import cn.lili.common.utils.CurrencyUtil;
import cn.lili.modules.member.entity.dos.Member;
import cn.lili.modules.member.service.MemberService;
import cn.lili.modules.order.cart.entity.dto.TradeDTO; import cn.lili.modules.order.cart.entity.dto.TradeDTO;
import cn.lili.modules.order.cart.entity.enums.RenderStepEnums; import cn.lili.modules.order.cart.entity.enums.RenderStepEnums;
import cn.lili.modules.order.cart.entity.vo.CartSkuVO; import cn.lili.modules.order.cart.entity.vo.CartSkuVO;
@ -34,6 +38,9 @@ public class SkuPromotionRender implements CartRenderStep {
@Autowired @Autowired
private KanjiaActivityService kanjiaActivityService; private KanjiaActivityService kanjiaActivityService;
@Autowired
private MemberService memberService;
@Override @Override
public RenderStepEnums step() { public RenderStepEnums step() {
return RenderStepEnums.SKU_PROMOTION; return RenderStepEnums.SKU_PROMOTION;
@ -76,14 +83,20 @@ public class SkuPromotionRender implements CartRenderStep {
//这里是双重循环但是实际积分购买或者是砍价购买时购物车只有一个商品所以没有循环操作数据库或者其他的问题 //这里是双重循环但是实际积分购买或者是砍价购买时购物车只有一个商品所以没有循环操作数据库或者其他的问题
case POINTS: case POINTS:
Member userInfo = memberService.getUserInfo();
long totalPayPoints = 0;
//处理积分商品购买 //处理积分商品购买
for (CartVO cartVO : tradeDTO.getCartList()) { for (CartVO cartVO : tradeDTO.getCartList()) {
for (CartSkuVO cartSkuVO : cartVO.getCheckedSkuList()) { for (CartSkuVO cartSkuVO : cartVO.getCheckedSkuList()) {
cartSkuVO.getPriceDetailDTO().setPayPoint(cartSkuVO.getPoint()); cartSkuVO.getPriceDetailDTO().setPayPoint(cartSkuVO.getPoint());
PromotionSkuVO promotionSkuVO = new PromotionSkuVO(PromotionTypeEnum.POINTS_GOODS.name(), cartSkuVO.getPointsId()); PromotionSkuVO promotionSkuVO = new PromotionSkuVO(PromotionTypeEnum.POINTS_GOODS.name(), cartSkuVO.getPointsId());
cartSkuVO.getPriceDetailDTO().getJoinPromotion().add(promotionSkuVO); cartSkuVO.getPriceDetailDTO().getJoinPromotion().add(promotionSkuVO);
totalPayPoints += cartSkuVO.getPoint();
} }
} }
if (userInfo.getPoint() < totalPayPoints) {
throw new ServiceException(ResultCode.POINT_NOT_ENOUGH);
}
return; return;
case KANJIA: case KANJIA:
for (CartVO cartVO : tradeDTO.getCartList()) { for (CartVO cartVO : tradeDTO.getCartList()) {

View File

@ -16,8 +16,10 @@ import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;
import cn.lili.modules.goods.entity.vos.GoodsVO; import cn.lili.modules.goods.entity.vos.GoodsVO;
import cn.lili.modules.goods.service.GoodsService; import cn.lili.modules.goods.service.GoodsService;
import cn.lili.modules.goods.service.GoodsSkuService; import cn.lili.modules.goods.service.GoodsSkuService;
import cn.lili.modules.member.entity.dos.Member;
import cn.lili.modules.member.entity.dos.MemberAddress; import cn.lili.modules.member.entity.dos.MemberAddress;
import cn.lili.modules.member.service.MemberAddressService; import cn.lili.modules.member.service.MemberAddressService;
import cn.lili.modules.member.service.MemberService;
import cn.lili.modules.order.cart.entity.dto.MemberCouponDTO; import cn.lili.modules.order.cart.entity.dto.MemberCouponDTO;
import cn.lili.modules.order.cart.entity.dto.TradeDTO; 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.CartTypeEnum;
@ -127,34 +129,19 @@ public class CartServiceImpl implements CartService {
@Autowired @Autowired
private TradeBuilder tradeBuilder; private TradeBuilder tradeBuilder;
@Autowired
private MemberService memberService;
@Override @Override
public void add(String skuId, Integer num, String cartType, Boolean cover) { public void add(String skuId, Integer num, String cartType, Boolean cover) {
AuthUser currentUser = Objects.requireNonNull(UserContext.getCurrentUser());
if (num <= 0) { if (num <= 0) {
throw new ServiceException(ResultCode.CART_NUM_ERROR); throw new ServiceException(ResultCode.CART_NUM_ERROR);
} }
CartTypeEnum cartTypeEnum = getCartType(cartType); CartTypeEnum cartTypeEnum = getCartType(cartType);
GoodsSku dataSku = checkGoods(skuId); GoodsSku dataSku = checkGoods(skuId);
Map<String, Object> promotionMap; Map<String, Object> promotionMap = this.getCurrentGoodsPromotion(dataSku, cartType);
EsGoodsIndex goodsIndex = goodsIndexService.findById(skuId);
if (goodsIndex == null) {
GoodsVO goodsVO = this.goodsService.getGoodsVO(dataSku.getGoodsId());
goodsIndex = goodsIndexService.resetEsGoodsIndex(dataSku, goodsVO.getGoodsParamsDTOList());
//发送mq消息
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.RESET_GOODS_INDEX.name();
rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(Collections.singletonList(goodsIndex)), RocketmqSendCallbackBuilder.commonCallback());
}
if (goodsIndex.getPromotionMap() != null && !goodsIndex.getPromotionMap().isEmpty()) {
if (goodsIndex.getPromotionMap().keySet().stream().anyMatch(i -> i.contains(PromotionTypeEnum.SECKILL.name())) ||
(goodsIndex.getPromotionMap().keySet().stream().anyMatch(i -> i.contains(PromotionTypeEnum.PINTUAN.name()))
&& CartTypeEnum.PINTUAN.name().equals(cartType))) {
dataSku.setPromotionFlag(true);
dataSku.setPromotionPrice(goodsIndex.getPromotionPrice());
}
promotionMap = goodsIndex.getPromotionMap();
} else {
promotionMap = null;
}
try { try {
//购物车方式购买需要保存之前的选择其他方式购买则直接抹除掉之前的记录 //购物车方式购买需要保存之前的选择其他方式购买则直接抹除掉之前的记录
TradeDTO tradeDTO; TradeDTO tradeDTO;
@ -200,7 +187,6 @@ public class CartServiceImpl implements CartService {
cartSkuVO.setChecked(true); cartSkuVO.setChecked(true);
} else { } else {
tradeDTO = new TradeDTO(cartTypeEnum); tradeDTO = new TradeDTO(cartTypeEnum);
AuthUser currentUser = UserContext.getCurrentUser();
tradeDTO.setMemberId(currentUser.getId()); tradeDTO.setMemberId(currentUser.getId());
tradeDTO.setMemberName(currentUser.getUsername()); tradeDTO.setMemberName(currentUser.getUsername());
List<CartSkuVO> cartSkuVOS = tradeDTO.getSkuList(); List<CartSkuVO> cartSkuVOS = tradeDTO.getSkuList();
@ -569,6 +555,31 @@ public class CartServiceImpl implements CartService {
return trade; return trade;
} }
private Map<String, Object> getCurrentGoodsPromotion(GoodsSku dataSku, String cartType) {
Map<String, Object> promotionMap;
EsGoodsIndex goodsIndex = goodsIndexService.findById(dataSku.getId());
if (goodsIndex == null) {
GoodsVO goodsVO = this.goodsService.getGoodsVO(dataSku.getGoodsId());
goodsIndex = goodsIndexService.getTempEsGoodsIndex(dataSku, goodsVO.getGoodsParamsDTOList());
//发送mq消息
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.RESET_GOODS_INDEX.name();
rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(Collections.singletonList(goodsIndex)), RocketmqSendCallbackBuilder.commonCallback());
}
if (goodsIndex.getPromotionMap() != null && !goodsIndex.getPromotionMap().isEmpty()) {
if (goodsIndex.getPromotionMap().keySet().stream().anyMatch(i -> i.contains(PromotionTypeEnum.SECKILL.name())) ||
(goodsIndex.getPromotionMap().keySet().stream().anyMatch(i -> i.contains(PromotionTypeEnum.PINTUAN.name()))
&& CartTypeEnum.PINTUAN.name().equals(cartType))) {
dataSku.setPromotionFlag(true);
dataSku.setPromotionPrice(goodsIndex.getPromotionPrice());
}
promotionMap = goodsIndex.getPromotionMap();
} else {
promotionMap = null;
}
return promotionMap;
}
/** /**
* 获取购物车类型 * 获取购物车类型
@ -763,7 +774,10 @@ public class CartServiceImpl implements CartService {
PointsGoodsVO pointsGoodsVO = pointsGoodsService.getPointsGoodsDetailBySkuId(cartSkuVO.getGoodsSku().getId()); PointsGoodsVO pointsGoodsVO = pointsGoodsService.getPointsGoodsDetailBySkuId(cartSkuVO.getGoodsSku().getId());
if (pointsGoodsVO != null) { if (pointsGoodsVO != null) {
Member userInfo = memberService.getUserInfo();
if (userInfo.getPoint() < pointsGoodsVO.getPoints()) {
throw new ServiceException(ResultCode.POINT_NOT_ENOUGH);
}
if (pointsGoodsVO.getActiveStock() < 1) { if (pointsGoodsVO.getActiveStock() < 1) {
throw new ServiceException(ResultCode.POINT_GOODS_ACTIVE_STOCK_INSUFFICIENT); throw new ServiceException(ResultCode.POINT_GOODS_ACTIVE_STOCK_INSUFFICIENT);
} }

View File

@ -121,15 +121,22 @@ public class PromotionGoods extends BaseEntity {
this.promotionId = pointsGoods.getId(); this.promotionId = pointsGoods.getId();
this.quantity = pointsGoods.getActiveStock(); this.quantity = pointsGoods.getActiveStock();
this.originalPrice = sku.getPrice(); this.originalPrice = sku.getPrice();
this.promotionType = PromotionTypeEnum.POINTS_GOODS.name();
this.scopeId = sku.getId();
} }
} }
public PromotionGoods(KanjiaActivityGoodsDTO kanjiaActivityGoodsDTO) { public PromotionGoods(KanjiaActivityGoodsDTO kanjiaActivityGoodsDTO) {
if (kanjiaActivityGoodsDTO != null) { if (kanjiaActivityGoodsDTO != null) {
BeanUtil.copyProperties(kanjiaActivityGoodsDTO, this, "id"); BeanUtil.copyProperties(kanjiaActivityGoodsDTO, this, "id");
BeanUtil.copyProperties(kanjiaActivityGoodsDTO.getGoodsSku(), this, "id"); BeanUtil.copyProperties(kanjiaActivityGoodsDTO.getGoodsSku(), this, "id");
this.setQuantity(kanjiaActivityGoodsDTO.getStock());
this.setPromotionId(kanjiaActivityGoodsDTO.getId());
this.setPromotionType(PromotionTypeEnum.KANJIA.name());
this.setTitle(PromotionTypeEnum.KANJIA.name() + "-" + kanjiaActivityGoodsDTO.getGoodsName());
this.setScopeType(PromotionsScopeTypeEnum.PORTION_GOODS.name());
this.setPromotionType(PromotionTypeEnum.KANJIA.name());
} }
} }
} }

View File

@ -5,6 +5,7 @@ import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.lili.modules.promotion.entity.dto.BasePromotions; import cn.lili.modules.promotion.entity.dto.BasePromotions;
import cn.lili.modules.promotion.entity.vos.SeckillVO; import cn.lili.modules.promotion.entity.vos.SeckillVO;
import cn.lili.modules.promotion.tools.PromotionTools;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
@ -61,8 +62,8 @@ public class Seckill extends BasePromotions {
this.seckillRule = seckillRule; this.seckillRule = seckillRule;
this.goodsNum = 0; this.goodsNum = 0;
//BasePromotion //BasePromotion
this.setStoreName("platform"); this.setStoreName(PromotionTools.PLATFORM_NAME);
this.setStoreId("platform"); this.setStoreId(PromotionTools.PLATFORM_ID);
this.setPromotionName(DateUtil.formatDate(dateTime) + " 秒杀活动"); this.setPromotionName(DateUtil.formatDate(dateTime) + " 秒杀活动");
this.setStartTime(dateTime); this.setStartTime(dateTime);
this.setEndTime(DateUtil.endOfDay(dateTime)); this.setEndTime(DateUtil.endOfDay(dateTime));

View File

@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
/** /**
@ -29,7 +30,7 @@ public class BasePromotionsSearchParams {
/** /**
* @see PromotionsStatusEnum * @see PromotionsStatusEnum
*/ */
@ApiModelProperty(value = "活动状态") @ApiModelProperty(value = "活动状态 如需同时判断多个活动状态','分割")
private String promotionStatus; private String promotionStatus;
/** /**
@ -38,6 +39,9 @@ public class BasePromotionsSearchParams {
@ApiModelProperty(value = "关联范围类型") @ApiModelProperty(value = "关联范围类型")
private String scopeType; private String scopeType;
@ApiModelProperty(value = "店铺编号 如有多个','分割")
private String storeId;
public <T> QueryWrapper<T> queryWrapper() { public <T> QueryWrapper<T> queryWrapper() {
QueryWrapper<T> queryWrapper = new QueryWrapper<>(); QueryWrapper<T> queryWrapper = new QueryWrapper<>();
@ -51,11 +55,18 @@ public class BasePromotionsSearchParams {
queryWrapper.le("end_time", new Date(endTime)); queryWrapper.le("end_time", new Date(endTime));
} }
if (CharSequenceUtil.isNotEmpty(promotionStatus)) { if (CharSequenceUtil.isNotEmpty(promotionStatus)) {
queryWrapper.and(PromotionTools.queryPromotionStatus(PromotionsStatusEnum.valueOf(promotionStatus))); queryWrapper.and(i -> {
for (String status : promotionStatus.split(",")) {
i.or(PromotionTools.queryPromotionStatus(PromotionsStatusEnum.valueOf(status)));
}
});
} }
if (CharSequenceUtil.isNotEmpty(scopeType)) { if (CharSequenceUtil.isNotEmpty(scopeType)) {
queryWrapper.eq("scope_type", scopeType); queryWrapper.eq("scope_type", scopeType);
} }
if (CharSequenceUtil.isNotEmpty(storeId)) {
queryWrapper.in("store_id", Arrays.asList(storeId.split(",")));
}
queryWrapper.eq("delete_flag", false); queryWrapper.eq("delete_flag", false);
return queryWrapper; return queryWrapper;
} }

View File

@ -9,7 +9,6 @@ import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.io.Serializable; import java.io.Serializable;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
/** /**
@ -27,9 +26,6 @@ public class CouponSearchParams extends BasePromotionsSearchParams implements Se
private static final String PRICE_COLUMN = "price"; private static final String PRICE_COLUMN = "price";
private static final String RANGE_DAY_TYPE_COLUMN = "range_day_type"; private static final String RANGE_DAY_TYPE_COLUMN = "range_day_type";
@ApiModelProperty(value = "店铺编号")
private String storeId;
@ApiModelProperty(value = "会员id") @ApiModelProperty(value = "会员id")
private String memberId; private String memberId;
@ -69,10 +65,7 @@ public class CouponSearchParams extends BasePromotionsSearchParams implements Se
@Override @Override
public <T> QueryWrapper<T> queryWrapper() { public <T> QueryWrapper<T> queryWrapper() {
QueryWrapper<T> queryWrapper = new QueryWrapper<>(); QueryWrapper<T> queryWrapper = super.queryWrapper();
if (storeId != null) {
queryWrapper.in("store_id", Arrays.asList(storeId.split(",")));
}
if (CharSequenceUtil.isNotEmpty(couponName)) { if (CharSequenceUtil.isNotEmpty(couponName)) {
queryWrapper.like("coupon_name", couponName); queryWrapper.like("coupon_name", couponName);
} }

View File

@ -7,7 +7,6 @@ import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.io.Serializable; import java.io.Serializable;
import java.util.Arrays;
/** /**
* 满优惠查询通用类 * 满优惠查询通用类
@ -25,9 +24,6 @@ public class FullDiscountSearchParams extends BasePromotionsSearchParams impleme
@ApiModelProperty(value = "活动名称") @ApiModelProperty(value = "活动名称")
private String promotionName; private String promotionName;
@ApiModelProperty(value = "店铺编号 如有多个','分割")
private String storeId;
@ApiModelProperty(value = "是否赠优惠券") @ApiModelProperty(value = "是否赠优惠券")
private Boolean couponFlag; private Boolean couponFlag;
@ -40,9 +36,6 @@ public class FullDiscountSearchParams extends BasePromotionsSearchParams impleme
if (CharSequenceUtil.isNotEmpty(promotionName)) { if (CharSequenceUtil.isNotEmpty(promotionName)) {
queryWrapper.like("title", promotionName); queryWrapper.like("title", promotionName);
} }
if (storeId != null) {
queryWrapper.in("store_id", Arrays.asList(storeId.split(",")));
}
if (couponFlag != null) { if (couponFlag != null) {
queryWrapper.eq("coupon_flag", couponFlag); queryWrapper.eq("coupon_flag", couponFlag);
} }

View File

@ -18,9 +18,6 @@ import javax.validation.constraints.NotEmpty;
@Data @Data
public class PintuanSearchParams extends BasePromotionsSearchParams { public class PintuanSearchParams extends BasePromotionsSearchParams {
@ApiModelProperty(value = "商家id")
private String storeId;
@ApiModelProperty(value = "商家名称,如果是平台,这个值为 platform") @ApiModelProperty(value = "商家名称,如果是平台,这个值为 platform")
private String storeName; private String storeName;
@ -38,9 +35,6 @@ public class PintuanSearchParams extends BasePromotionsSearchParams {
if (CharSequenceUtil.isNotEmpty(storeName)) { if (CharSequenceUtil.isNotEmpty(storeName)) {
queryWrapper.like("store_name", storeName); queryWrapper.like("store_name", storeName);
} }
if (CharSequenceUtil.isNotEmpty(storeId)) {
queryWrapper.eq("store_id", storeId);
}
return queryWrapper; return queryWrapper;
} }

View File

@ -26,9 +26,6 @@ public class PromotionGoodsSearchParams extends BasePromotionsSearchParams {
@ApiModelProperty(value = "促销类型") @ApiModelProperty(value = "促销类型")
private String promotionType; private String promotionType;
@ApiModelProperty(value = "商品活动id")
private String storeId;
@ApiModelProperty(value = "商品名称") @ApiModelProperty(value = "商品名称")
private String goodsName; private String goodsName;
@ -63,9 +60,6 @@ public class PromotionGoodsSearchParams extends BasePromotionsSearchParams {
if (CharSequenceUtil.isNotEmpty(categoryPath)) { if (CharSequenceUtil.isNotEmpty(categoryPath)) {
queryWrapper.like("category_path", categoryPath); queryWrapper.like("category_path", categoryPath);
} }
if (CharSequenceUtil.isNotEmpty(storeId)) {
queryWrapper.in("store_id", Arrays.asList(storeId.split(",")));
}
if (CharSequenceUtil.isNotEmpty(skuId)) { if (CharSequenceUtil.isNotEmpty(skuId)) {
queryWrapper.in("sku_id", Arrays.asList(skuId.split(","))); queryWrapper.in("sku_id", Arrays.asList(skuId.split(",")));
} }

View File

@ -34,9 +34,6 @@ public class SeckillSearchParams extends BasePromotionsSearchParams implements S
@ApiModelProperty(value = "商家id") @ApiModelProperty(value = "商家id")
private String[] storeIds; private String[] storeIds;
@ApiModelProperty(value = "商家编号")
private String storeId;
@ApiModelProperty(value = "商品名称") @ApiModelProperty(value = "商品名称")
private String goodsName; private String goodsName;

View File

@ -3,7 +3,6 @@ package cn.lili.modules.promotion.service;
import cn.lili.cache.CachePrefix; import cn.lili.cache.CachePrefix;
import cn.lili.common.enums.PromotionTypeEnum; import cn.lili.common.enums.PromotionTypeEnum;
import cn.lili.common.vo.PageVO; import cn.lili.common.vo.PageVO;
import cn.lili.modules.order.cart.entity.vo.CartSkuVO;
import cn.lili.modules.promotion.entity.dos.PromotionGoods; import cn.lili.modules.promotion.entity.dos.PromotionGoods;
import cn.lili.modules.promotion.entity.vos.PromotionGoodsSearchParams; import cn.lili.modules.promotion.entity.vos.PromotionGoodsSearchParams;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
@ -34,19 +33,13 @@ public interface PromotionGoodsService extends IService<PromotionGoods> {
} }
/** /**
* 更新促销活动 * 获取某sku所有有效活动
*
* @param cartSkuVO 购物车中的产品
*/
void updatePromotion(CartSkuVO cartSkuVO);
/**
* 获取某sku当日所有活动
* *
* @param skuId 商品skuId * @param skuId 商品skuId
* @param storeIds 店铺id
* @return 促销商品集合 * @return 促销商品集合
*/ */
List<PromotionGoods> findNowSkuPromotion(String skuId); List<PromotionGoods> findSkuValidPromotion(String skuId, String storeIds);
/** /**
* 分页获取促销商品信息 * 分页获取促销商品信息

View File

@ -25,6 +25,6 @@ public interface PromotionService {
* @param index 商品索引 * @param index 商品索引
* @return 当前促销活动集合 * @return 当前促销活动集合
*/ */
Map<String, Object> getGoodsCurrentPromotionMap(EsGoodsIndex index); Map<String, Object> getGoodsPromotionMap(EsGoodsIndex index);
} }

View File

@ -220,8 +220,9 @@ public abstract class AbstractPromotionsServiceImpl<M extends BaseMapper<T>, T e
this.promotionGoodsService.deletePromotionGoods(Collections.singletonList(promotions.getId())); this.promotionGoodsService.deletePromotionGoods(Collections.singletonList(promotions.getId()));
return; return;
} }
if (PromotionsScopeTypeEnum.ALL.name().equals(promotions.getScopeType())) { if (CharSequenceUtil.equalsAny(promotions.getScopeType(), PromotionsScopeTypeEnum.ALL.name(), PromotionsScopeTypeEnum.PORTION_GOODS_CATEGORY.name())) {
PromotionGoods promotionGoods = new PromotionGoods(); PromotionGoods promotionGoods = new PromotionGoods();
promotionGoods.setScopeId(promotions.getScopeId());
promotionGoods.setScopeType(promotions.getScopeType()); promotionGoods.setScopeType(promotions.getScopeType());
promotionGoods.setPromotionId(promotions.getId()); promotionGoods.setPromotionId(promotions.getId());
promotionGoods.setStoreId(promotions.getStoreId()); promotionGoods.setStoreId(promotions.getStoreId());

View File

@ -19,6 +19,7 @@ import cn.lili.modules.promotion.service.CouponActivityItemService;
import cn.lili.modules.promotion.service.CouponActivityService; import cn.lili.modules.promotion.service.CouponActivityService;
import cn.lili.modules.promotion.service.CouponService; import cn.lili.modules.promotion.service.CouponService;
import cn.lili.modules.promotion.service.MemberCouponService; import cn.lili.modules.promotion.service.MemberCouponService;
import cn.lili.modules.promotion.tools.PromotionTools;
import groovy.util.logging.Slf4j; import groovy.util.logging.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -203,7 +204,7 @@ public class CouponActivityServiceImpl extends AbstractPromotionsServiceImpl<Cou
memberCoupon.setMemberId(map.get("id").toString()); memberCoupon.setMemberId(map.get("id").toString());
memberCoupon.setMemberName(map.get("nick_name").toString()); memberCoupon.setMemberName(map.get("nick_name").toString());
memberCoupon.setMemberCouponStatus(MemberCouponStatusEnum.NEW.name()); memberCoupon.setMemberCouponStatus(MemberCouponStatusEnum.NEW.name());
memberCoupon.setPlatformFlag("platform".equals(coupon.getStoreId())); memberCoupon.setPlatformFlag(PromotionTools.PLATFORM_ID.equals(coupon.getStoreId()));
memberCouponList.add(memberCoupon); memberCouponList.add(memberCoupon);
} }
} }

View File

@ -213,6 +213,7 @@ public class CouponServiceImpl extends AbstractPromotionsServiceImpl<CouponMappe
FullDiscountSearchParams searchParams = new FullDiscountSearchParams(); FullDiscountSearchParams searchParams = new FullDiscountSearchParams();
searchParams.setCouponFlag(true); searchParams.setCouponFlag(true);
searchParams.setCouponId(promotions.getId()); searchParams.setCouponId(promotions.getId());
searchParams.setPromotionStatus(PromotionsStatusEnum.START.name());
List<FullDiscount> fullDiscounts = fullDiscountService.listFindAll(searchParams); List<FullDiscount> fullDiscounts = fullDiscountService.listFindAll(searchParams);
if (fullDiscounts != null && !fullDiscounts.isEmpty()) { if (fullDiscounts != null && !fullDiscounts.isEmpty()) {
throw new ServiceException("当前优惠券参与了促销活动【" + fullDiscounts.get(0).getPromotionName() + "】不能进行编辑删除操作"); throw new ServiceException("当前优惠券参与了促销活动【" + fullDiscounts.get(0).getPromotionName() + "】不能进行编辑删除操作");
@ -228,6 +229,10 @@ public class CouponServiceImpl extends AbstractPromotionsServiceImpl<CouponMappe
CouponVO couponVO = (CouponVO) promotions; CouponVO couponVO = (CouponVO) promotions;
this.promotionGoodsService.deletePromotionGoods(Collections.singletonList(promotions.getId())); this.promotionGoodsService.deletePromotionGoods(Collections.singletonList(promotions.getId()));
List<PromotionGoods> promotionGoodsList = PromotionTools.promotionGoodsInit(couponVO.getPromotionGoodsList(), couponVO, this.getPromotionType()); List<PromotionGoods> promotionGoodsList = PromotionTools.promotionGoodsInit(couponVO.getPromotionGoodsList(), couponVO, this.getPromotionType());
for (PromotionGoods promotionGoods : promotionGoodsList) {
promotionGoods.setStoreId(promotions.getStoreId());
promotionGoods.setStoreName(promotions.getStoreName());
}
//促销活动商品更新 //促销活动商品更新
this.promotionGoodsService.saveBatch(promotionGoodsList); this.promotionGoodsService.saveBatch(promotionGoodsList);
} }

View File

@ -11,7 +11,6 @@ import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;
import cn.lili.modules.goods.service.GoodsSkuService; import cn.lili.modules.goods.service.GoodsSkuService;
import cn.lili.modules.promotion.entity.dos.KanjiaActivityGoods; import cn.lili.modules.promotion.entity.dos.KanjiaActivityGoods;
import cn.lili.modules.promotion.entity.dos.PromotionGoods; import cn.lili.modules.promotion.entity.dos.PromotionGoods;
import cn.lili.modules.promotion.entity.dto.BasePromotions;
import cn.lili.modules.promotion.entity.dto.KanjiaActivityGoodsDTO; import cn.lili.modules.promotion.entity.dto.KanjiaActivityGoodsDTO;
import cn.lili.modules.promotion.entity.dto.KanjiaActivityGoodsOperationDTO; import cn.lili.modules.promotion.entity.dto.KanjiaActivityGoodsOperationDTO;
import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum; import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum;
@ -268,7 +267,8 @@ public class KanjiaActivityGoodsServiceImpl extends AbstractPromotionsServiceImp
throw new ServiceException("商品id为" + goodsSku.getId() + "的商品已参加砍价商品活动!"); throw new ServiceException("商品id为" + goodsSku.getId() + "的商品已参加砍价商品活动!");
} }
this.promotionGoodsService.deletePromotionGoods(Collections.singletonList(kanJiaActivityGoodsDTO.getId())); this.promotionGoodsService.deletePromotionGoods(Collections.singletonList(kanJiaActivityGoodsDTO.getId()));
this.updatePromotionsGoods(kanJiaActivityGoodsDTO); PromotionGoods promotionGoods = new PromotionGoods(kanJiaActivityGoodsDTO);
this.promotionGoodsService.save(promotionGoods);
this.updateEsGoodsIndex(kanJiaActivityGoodsDTO); this.updateEsGoodsIndex(kanJiaActivityGoodsDTO);
//修改数据库 //修改数据库
return this.updateById(kanJiaActivityGoodsDTO); return this.updateById(kanJiaActivityGoodsDTO);

View File

@ -15,6 +15,7 @@ import cn.lili.modules.promotion.entity.vos.CouponSearchParams;
import cn.lili.modules.promotion.mapper.MemberCouponMapper; import cn.lili.modules.promotion.mapper.MemberCouponMapper;
import cn.lili.modules.promotion.service.CouponService; import cn.lili.modules.promotion.service.CouponService;
import cn.lili.modules.promotion.service.MemberCouponService; import cn.lili.modules.promotion.service.MemberCouponService;
import cn.lili.modules.promotion.tools.PromotionTools;
import cn.lili.mybatis.util.PageUtil; import cn.lili.mybatis.util.PageUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@ -118,7 +119,7 @@ public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper, Mem
public IPage<MemberCoupon> getMemberCouponsByCanUse(CouponSearchParams param, Double totalPrice, PageVO pageVo) { public IPage<MemberCoupon> getMemberCouponsByCanUse(CouponSearchParams param, Double totalPrice, PageVO pageVo) {
LambdaQueryWrapper<MemberCoupon> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<MemberCoupon> queryWrapper = new LambdaQueryWrapper<>();
List<String> storeIds = new ArrayList<>(Arrays.asList(param.getStoreId().split(","))); List<String> storeIds = new ArrayList<>(Arrays.asList(param.getStoreId().split(",")));
storeIds.add("platform"); storeIds.add(PromotionTools.PLATFORM_ID);
queryWrapper.in(MemberCoupon::getStoreId, storeIds); queryWrapper.in(MemberCoupon::getStoreId, storeIds);
queryWrapper.eq(MemberCoupon::getMemberId, param.getMemberId()); queryWrapper.eq(MemberCoupon::getMemberId, param.getMemberId());
queryWrapper.and( queryWrapper.and(
@ -253,7 +254,7 @@ public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper, Mem
memberCoupon.setMemberId(memberId); memberCoupon.setMemberId(memberId);
memberCoupon.setMemberName(memberName); memberCoupon.setMemberName(memberName);
memberCoupon.setMemberCouponStatus(MemberCouponStatusEnum.NEW.name()); memberCoupon.setMemberCouponStatus(MemberCouponStatusEnum.NEW.name());
memberCoupon.setPlatformFlag(("platform").equals(coupon.getStoreId())); memberCoupon.setPlatformFlag((PromotionTools.PLATFORM_ID).equals(coupon.getStoreId()));
this.save(memberCoupon); this.save(memberCoupon);
couponService.receiveCoupon(couponId, 1); couponService.receiveCoupon(couponId, 1);
} }

View File

@ -1,6 +1,7 @@
package cn.lili.modules.promotion.serviceimpl; package cn.lili.modules.promotion.serviceimpl;
import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.text.CharSequenceUtil;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.common.vo.PageVO; import cn.lili.common.vo.PageVO;
import cn.lili.modules.promotion.entity.dos.PointsGoodsCategory; import cn.lili.modules.promotion.entity.dos.PointsGoodsCategory;
@ -96,7 +97,7 @@ public class PointsGoodsCategoryServiceImpl extends ServiceImpl<PointsGoodsCateg
} }
if (this.getOne(queryWrapper) != null) { if (this.getOne(queryWrapper) != null) {
log.error("当前积分商品分类名称" + name + "已存在!"); log.error("当前积分商品分类名称" + name + "已存在!");
throw new ServiceException(); throw new ServiceException(ResultCode.POINT_GOODS_CATEGORY_EXIST);
} }
} }

View File

@ -20,7 +20,6 @@ import cn.lili.modules.promotion.tools.PromotionTools;
import cn.lili.modules.search.utils.EsIndexUtil; import cn.lili.modules.search.utils.EsIndexUtil;
import cn.lili.rocketmq.RocketmqSendCallbackBuilder; import cn.lili.rocketmq.RocketmqSendCallbackBuilder;
import cn.lili.rocketmq.tags.GoodsTagsEnum; import cn.lili.rocketmq.tags.GoodsTagsEnum;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.apache.rocketmq.spring.core.RocketMQTemplate;
@ -29,10 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* 积分商品业务层实现 * 积分商品业务层实现
@ -166,7 +162,9 @@ public class PointsGoodsServiceImpl extends AbstractPromotionsServiceImpl<Points
*/ */
@Override @Override
public PointsGoodsVO getPointsGoodsDetailBySkuId(String skuId) { public PointsGoodsVO getPointsGoodsDetailBySkuId(String skuId) {
PointsGoods pointsGoods = this.getOne(new LambdaQueryWrapper<PointsGoods>().eq(PointsGoods::getSkuId, skuId), false); QueryWrapper<PointsGoods> queryWrapper = new QueryWrapper<PointsGoods>().eq("sku_id", skuId);
queryWrapper.and(PromotionTools.queryPromotionStatus(PromotionsStatusEnum.START));
PointsGoods pointsGoods = this.getOne(queryWrapper, false);
if (pointsGoods == null) { if (pointsGoods == null) {
log.error("skuId为" + skuId + "的积分商品不存在!"); log.error("skuId为" + skuId + "的积分商品不存在!");
throw new ServiceException(); throw new ServiceException();
@ -208,7 +206,7 @@ public class PointsGoodsServiceImpl extends AbstractPromotionsServiceImpl<Points
*/ */
@Override @Override
public void updatePromotionsGoods(PointsGoods promotions) { public void updatePromotionsGoods(PointsGoods promotions) {
this.promotionGoodsService.remove(new LambdaQueryWrapper<PromotionGoods>().eq(PromotionGoods::getPromotionId, promotions.getId())); this.promotionGoodsService.deletePromotionGoods(Collections.singletonList(promotions.getId()));
this.promotionGoodsService.save(new PromotionGoods(promotions, this.checkSkuExist(promotions.getSkuId()))); this.promotionGoodsService.save(new PromotionGoods(promotions, this.checkSkuExist(promotions.getSkuId())));
} }

View File

@ -5,18 +5,13 @@ import cn.hutool.core.text.CharSequenceUtil;
import cn.lili.common.enums.PromotionTypeEnum; import cn.lili.common.enums.PromotionTypeEnum;
import cn.lili.common.enums.ResultCode; import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.common.utils.DateUtil;
import cn.lili.common.vo.PageVO; import cn.lili.common.vo.PageVO;
import cn.lili.modules.goods.entity.dos.GoodsSku; import cn.lili.modules.goods.entity.dos.GoodsSku;
import cn.lili.modules.goods.service.GoodsSkuService; import cn.lili.modules.goods.service.GoodsSkuService;
import cn.lili.modules.order.cart.entity.vo.CartSkuVO;
import cn.lili.modules.promotion.entity.dos.Coupon;
import cn.lili.modules.promotion.entity.dos.FullDiscount;
import cn.lili.modules.promotion.entity.dos.PromotionGoods; import cn.lili.modules.promotion.entity.dos.PromotionGoods;
import cn.lili.modules.promotion.entity.dos.SeckillApply; import cn.lili.modules.promotion.entity.dos.SeckillApply;
import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum; import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum;
import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum; import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum;
import cn.lili.modules.promotion.entity.vos.BasePromotionsSearchParams;
import cn.lili.modules.promotion.entity.vos.PromotionGoodsSearchParams; import cn.lili.modules.promotion.entity.vos.PromotionGoodsSearchParams;
import cn.lili.modules.promotion.entity.vos.SeckillSearchParams; import cn.lili.modules.promotion.entity.vos.SeckillSearchParams;
import cn.lili.modules.promotion.mapper.PromotionGoodsMapper; import cn.lili.modules.promotion.mapper.PromotionGoodsMapper;
@ -37,6 +32,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -73,7 +69,7 @@ public class PromotionGoodsServiceImpl extends ServiceImpl<PromotionGoodsMapper,
private CouponService couponService; private CouponService couponService;
@Override @Override
public List<PromotionGoods> findNowSkuPromotion(String skuId) { public List<PromotionGoods> findSkuValidPromotion(String skuId, String storeIds) {
GoodsSku sku = goodsSkuService.getGoodsSkuByIdFromCache(skuId); GoodsSku sku = goodsSkuService.getGoodsSkuByIdFromCache(skuId);
if (sku == null) { if (sku == null) {
@ -81,48 +77,13 @@ public class PromotionGoodsServiceImpl extends ServiceImpl<PromotionGoodsMapper,
} }
QueryWrapper<PromotionGoods> queryWrapper = new QueryWrapper<>(); QueryWrapper<PromotionGoods> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("sku_id", skuId); queryWrapper.and(i -> i.or(j -> j.eq("sku_id", skuId))
queryWrapper.and(PromotionTools.queryPromotionStatus(PromotionsStatusEnum.START)); .or(n -> n.eq("scope_type", PromotionsScopeTypeEnum.ALL.name()))
.or(n -> n.and(k -> k.eq("scope_type", PromotionsScopeTypeEnum.PORTION_GOODS_CATEGORY.name())
List<PromotionGoods> promotionGoods = this.list(queryWrapper); .and(l -> l.like("scope_id", sku.getCategoryPath())))));
queryWrapper.and(i -> i.or(PromotionTools.queryPromotionStatus(PromotionsStatusEnum.START)).or(PromotionTools.queryPromotionStatus(PromotionsStatusEnum.NEW)));
queryWrapper.in("store_id", Arrays.asList(storeIds.split(",")));
BasePromotionsSearchParams searchParams = new BasePromotionsSearchParams(); return this.list(queryWrapper);
searchParams.setPromotionStatus(PromotionsStatusEnum.START.name());
searchParams.setScopeType(PromotionsScopeTypeEnum.ALL.name());
//单独检查添加适用于全品类的满优惠活动
List<FullDiscount> fullDiscountVOS = this.fullDiscountService.listFindAll(searchParams);
for (FullDiscount fullDiscountVO : fullDiscountVOS) {
PromotionGoods p = new PromotionGoods(sku);
p.setPromotionId(fullDiscountVO.getId());
p.setPromotionType(PromotionTypeEnum.FULL_DISCOUNT.name());
p.setStartTime(fullDiscountVO.getStartTime());
p.setEndTime(fullDiscountVO.getEndTime());
promotionGoods.add(p);
}
//单独检查添加适用于全品类的全平台或属于当前店铺的优惠券活动
List<Coupon> couponVOS = this.couponService.listFindAll(searchParams);
for (Coupon couponVO : couponVOS) {
PromotionGoods p = new PromotionGoods(sku);
p.setPromotionId(couponVO.getId());
p.setPromotionType(PromotionTypeEnum.COUPON.name());
p.setStartTime(couponVO.getStartTime());
p.setEndTime(couponVO.getEndTime());
promotionGoods.add(p);
}
return promotionGoods;
}
@Override
public void updatePromotion(CartSkuVO cartSkuVO) {
Date date = DateUtil.getCurrentDayEndTime();
//如果商品的促销更新时间在当前时间之前则更新促销
if (cartSkuVO.getUpdatePromotionTime().before(date)) {
List<PromotionGoods> promotionGoods = this.findNowSkuPromotion(cartSkuVO.getGoodsSku().getId());
cartSkuVO.setPromotions(promotionGoods);
//下一次更新时间
cartSkuVO.setUpdatePromotionTime(date);
}
} }
@Override @Override

View File

@ -2,11 +2,12 @@ package cn.lili.modules.promotion.serviceimpl;
import cn.lili.common.enums.PromotionTypeEnum; import cn.lili.common.enums.PromotionTypeEnum;
import cn.lili.modules.promotion.entity.dos.*; import cn.lili.modules.promotion.entity.dos.*;
import cn.lili.modules.promotion.entity.enums.CouponGetEnum;
import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum;
import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum; import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum;
import cn.lili.modules.promotion.entity.vos.*; import cn.lili.modules.promotion.entity.vos.FullDiscountSearchParams;
import cn.lili.modules.promotion.entity.vos.PintuanSearchParams;
import cn.lili.modules.promotion.entity.vos.SeckillSearchParams;
import cn.lili.modules.promotion.service.*; import cn.lili.modules.promotion.service.*;
import cn.lili.modules.promotion.tools.PromotionTools;
import cn.lili.modules.search.entity.dos.EsGoodsIndex; import cn.lili.modules.search.entity.dos.EsGoodsIndex;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -111,33 +112,10 @@ public class PromotionServiceImpl implements PromotionService {
* @return 当前促销活动集合 * @return 当前促销活动集合
*/ */
@Override @Override
public Map<String, Object> getGoodsCurrentPromotionMap(EsGoodsIndex index) { public Map<String, Object> getGoodsPromotionMap(EsGoodsIndex index) {
String storeIds = index.getStoreId() + "," + PromotionTools.PLATFORM_ID;
Map<String, Object> promotionMap = new HashMap<>(); Map<String, Object> promotionMap = new HashMap<>();
FullDiscountSearchParams fullDiscountSearchParams = new FullDiscountSearchParams(); List<PromotionGoods> promotionGoodsList = promotionGoodsService.findSkuValidPromotion(index.getId(), storeIds);
fullDiscountSearchParams.setScopeType(PromotionsScopeTypeEnum.ALL.name());
fullDiscountSearchParams.setPromotionStatus(PromotionsStatusEnum.START.name());
List<FullDiscount> fullDiscountVOS = this.fullDiscountService.listFindAll(fullDiscountSearchParams);
for (FullDiscount fullDiscount : fullDiscountVOS) {
if (index.getStoreId().equals(fullDiscount.getStoreId())) {
String fullDiscountKey = PromotionTypeEnum.FULL_DISCOUNT.name() + "-" + fullDiscount.getId();
promotionMap.put(fullDiscountKey, fullDiscount);
}
}
CouponSearchParams couponSearchParams = new CouponSearchParams();
couponSearchParams.setScopeType(PromotionsScopeTypeEnum.ALL.name());
couponSearchParams.setPromotionStatus(PromotionsStatusEnum.START.name());
couponSearchParams.setGetType(CouponGetEnum.FREE.name());
List<Coupon> couponVOS = this.couponService.listFindAll(couponSearchParams);
for (Coupon coupon : couponVOS) {
if (("platform").equals(coupon.getStoreId()) || index.getStoreId().equals(coupon.getStoreId())) {
String couponKey = PromotionTypeEnum.COUPON.name() + "-" + coupon.getId();
promotionMap.put(couponKey, coupon);
}
}
PromotionGoodsSearchParams promotionGoodsSearchParams = new PromotionGoodsSearchParams();
promotionGoodsSearchParams.setSkuId(index.getId());
promotionGoodsSearchParams.setPromotionStatus(PromotionsStatusEnum.START.name());
List<PromotionGoods> promotionGoodsList = promotionGoodsService.listFindAll(promotionGoodsSearchParams);
for (PromotionGoods promotionGoods : promotionGoodsList) { for (PromotionGoods promotionGoods : promotionGoodsList) {
String esPromotionKey = promotionGoods.getPromotionType() + "-" + promotionGoods.getPromotionId(); String esPromotionKey = promotionGoods.getPromotionType() + "-" + promotionGoods.getPromotionId();
switch (PromotionTypeEnum.valueOf(promotionGoods.getPromotionType())) { switch (PromotionTypeEnum.valueOf(promotionGoods.getPromotionType())) {

View File

@ -189,7 +189,6 @@ public class SeckillApplyServiceImpl extends ServiceImpl<SeckillApplyMapper, Sec
} }
this.remove(new LambdaQueryWrapper<SeckillApply>().eq(SeckillApply::getSeckillId, seckillId).in(SeckillApply::getSkuId, skuIds)); this.remove(new LambdaQueryWrapper<SeckillApply>().eq(SeckillApply::getSeckillId, seckillId).in(SeckillApply::getSkuId, skuIds));
this.saveBatch(originList); this.saveBatch(originList);
this.seckillService.updateEsGoodsSeckill(seckill, originList);
//保存促销活动商品信息 //保存促销活动商品信息
if (!promotionGoodsList.isEmpty()) { if (!promotionGoodsList.isEmpty()) {
PromotionGoodsSearchParams searchParams = new PromotionGoodsSearchParams(); PromotionGoodsSearchParams searchParams = new PromotionGoodsSearchParams();
@ -203,6 +202,7 @@ public class SeckillApplyServiceImpl extends ServiceImpl<SeckillApplyMapper, Sec
//设置秒杀活动的商品数量店铺数量 //设置秒杀活动的商品数量店铺数量
seckillService.updateSeckillGoodsNum(seckillId); seckillService.updateSeckillGoodsNum(seckillId);
cache.vagueDel(CachePrefix.STORE_ID_SECKILL); cache.vagueDel(CachePrefix.STORE_ID_SECKILL);
this.seckillService.updateEsGoodsSeckill(seckill, originList);
} }

View File

@ -41,7 +41,6 @@ import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
/** /**
* 秒杀活动业务层实现 * 秒杀活动业务层实现
@ -142,8 +141,7 @@ public class SeckillServiceImpl extends AbstractPromotionsServiceImpl<SeckillMap
public void updateEsGoodsSeckill(Seckill seckill, List<SeckillApply> seckillApplies) { public void updateEsGoodsSeckill(Seckill seckill, List<SeckillApply> seckillApplies) {
if (seckillApplies != null && !seckillApplies.isEmpty()) { if (seckillApplies != null && !seckillApplies.isEmpty()) {
// 更新促销范围 // 更新促销范围
List<String> skuIds = seckillApplies.stream().map(SeckillApply::getSkuId).collect(Collectors.toList()); seckill.setScopeId(ArrayUtil.join(seckillApplies.stream().map(SeckillApply::getSkuId).toArray(), ","));
seckill.setScopeId(ArrayUtil.join(skuIds.toArray(), ","));
UpdateWrapper<Seckill> updateWrapper = new UpdateWrapper<>(); UpdateWrapper<Seckill> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id", seckill.getId()); updateWrapper.eq("id", seckill.getId());
updateWrapper.set("scope_id", seckill.getScopeId()); updateWrapper.set("scope_id", seckill.getScopeId());
@ -153,7 +151,7 @@ public class SeckillServiceImpl extends AbstractPromotionsServiceImpl<SeckillMap
if (seckillApply.getPromotionApplyStatus().equals(PromotionsApplyStatusEnum.PASS.name())) { if (seckillApply.getPromotionApplyStatus().equals(PromotionsApplyStatusEnum.PASS.name())) {
this.setSeckillApplyTime(seckill, seckillApply); this.setSeckillApplyTime(seckill, seckillApply);
log.info("更新限时抢购商品状态:{}", seckill); log.info("更新限时抢购商品状态:{}", seckill);
String promotionKey = PromotionTypeEnum.SECKILL.name() + "-" + seckillApply.getTimeLine(); String promotionKey = PromotionTypeEnum.SECKILL.name() + "-" + seckill.getId();
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
// es促销key // es促销key
map.put("esPromotionKey", promotionKey); map.put("esPromotionKey", promotionKey);

View File

@ -2,6 +2,7 @@ package cn.lili.modules.promotion.tools;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.lili.common.enums.PromotionTypeEnum; import cn.lili.common.enums.PromotionTypeEnum;
import cn.lili.common.enums.ResultCode; import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
@ -26,6 +27,8 @@ public class PromotionTools {
public static final String START_TIME_COLUMN = "start_time"; public static final String START_TIME_COLUMN = "start_time";
public static final String END_TIME_COLUMN = "end_time"; public static final String END_TIME_COLUMN = "end_time";
public static final String PLATFORM_ID = "platform";
public static final String PLATFORM_NAME = "platform";
/** /**
* 参数验证 * 参数验证
@ -119,7 +122,12 @@ public class PromotionTools {
//本次促销商品入库 //本次促销商品入库
for (PromotionGoods promotionGoods : originList) { for (PromotionGoods promotionGoods : originList) {
promotionGoods.setPromotionId(promotion.getId()); promotionGoods.setPromotionId(promotion.getId());
if (CharSequenceUtil.isEmpty(promotionGoods.getStoreId())) {
promotionGoods.setStoreId(promotion.getStoreId());
}
if (CharSequenceUtil.isEmpty(promotionGoods.getStoreName())) {
promotionGoods.setStoreName(promotion.getStoreName()); promotionGoods.setStoreName(promotion.getStoreName());
}
promotionGoods.setTitle(promotion.getPromotionName()); promotionGoods.setTitle(promotion.getPromotionName());
if (promotionGoods.getStartTime() == null) { if (promotionGoods.getStartTime() == null) {
promotionGoods.setStartTime(promotion.getStartTime()); promotionGoods.setStartTime(promotion.getStartTime());

View File

@ -169,11 +169,11 @@ public interface EsGoodsIndexService {
List<String> getPromotionIdByPromotionType(String id, PromotionTypeEnum promotionTypeEnum); List<String> getPromotionIdByPromotionType(String id, PromotionTypeEnum promotionTypeEnum);
/** /**
* 重置当前商品索引 * 获取临时拼装的商品索引
* *
* @param goodsSku 商品sku信息 * @param goodsSku 商品sku信息
* @param goodsParamDTOS 商品参数 * @param goodsParamDTOS 商品参数
* @return 商品索引 * @return 商品索引
*/ */
EsGoodsIndex resetEsGoodsIndex(GoodsSku goodsSku, List<GoodsParamsDTO> goodsParamDTOS); EsGoodsIndex getTempEsGoodsIndex(GoodsSku goodsSku, List<GoodsParamsDTO> goodsParamDTOS);
} }

View File

@ -28,6 +28,7 @@ import cn.lili.modules.promotion.entity.dos.Seckill;
import cn.lili.modules.promotion.entity.dto.BasePromotions; import cn.lili.modules.promotion.entity.dto.BasePromotions;
import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum; import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum;
import cn.lili.modules.promotion.service.PromotionService; import cn.lili.modules.promotion.service.PromotionService;
import cn.lili.modules.promotion.tools.PromotionTools;
import cn.lili.modules.search.entity.dos.EsGoodsIndex; import cn.lili.modules.search.entity.dos.EsGoodsIndex;
import cn.lili.modules.search.entity.dto.EsGoodsSearchDTO; import cn.lili.modules.search.entity.dto.EsGoodsSearchDTO;
import cn.lili.modules.search.repository.EsGoodsIndexRepository; import cn.lili.modules.search.repository.EsGoodsIndexRepository;
@ -390,7 +391,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
public void updateEsGoodsIndexAllByList(BasePromotions promotion, String key) { public void updateEsGoodsIndexAllByList(BasePromotions promotion, String key) {
List<EsGoodsIndex> goodsIndices = new ArrayList<>(); List<EsGoodsIndex> goodsIndices = new ArrayList<>();
//如果storeId不为空则表示是店铺活动 //如果storeId不为空则表示是店铺活动
if (promotion.getStoreId() != null) { if (promotion.getStoreId() != null && !promotion.getStoreId().equals(PromotionTools.PLATFORM_ID)) {
EsGoodsSearchDTO searchDTO = new EsGoodsSearchDTO(); EsGoodsSearchDTO searchDTO = new EsGoodsSearchDTO();
searchDTO.setStoreId(promotion.getStoreId()); searchDTO.setStoreId(promotion.getStoreId());
//查询出店铺商品 //查询出店铺商品
@ -552,17 +553,17 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
} }
/** /**
* 重置当前商品索引 * 获取临时拼装的商品索引
* *
* @param goodsSku 商品sku信息 * @param goodsSku 商品sku信息
* @param goodsParamDTOS 商品参数 * @param goodsParamDTOS 商品参数
* @return 商品索引 * @return 商品索引
*/ */
@Override @Override
public EsGoodsIndex resetEsGoodsIndex(GoodsSku goodsSku, List<GoodsParamsDTO> goodsParamDTOS) { public EsGoodsIndex getTempEsGoodsIndex(GoodsSku goodsSku, List<GoodsParamsDTO> goodsParamDTOS) {
EsGoodsIndex index = new EsGoodsIndex(goodsSku, goodsParamDTOS); EsGoodsIndex index = new EsGoodsIndex(goodsSku, goodsParamDTOS);
//获取活动信息 //获取活动信息
Map<String, Object> goodsCurrentPromotionMap = promotionService.getGoodsCurrentPromotionMap(index); Map<String, Object> goodsCurrentPromotionMap = promotionService.getGoodsPromotionMap(index);
//写入促销信息 //写入促销信息
index.setPromotionMap(goodsCurrentPromotionMap); index.setPromotionMap(goodsCurrentPromotionMap);
return index; return index;
@ -588,18 +589,10 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
promotionMap = goodsIndex.getPromotionMap(); promotionMap = goodsIndex.getPromotionMap();
} }
//如果活动已结束 //如果活动已结束
if (promotion.getPromotionStatus().equals(PromotionsStatusEnum.END.name()) || promotion.getPromotionStatus().equals(PromotionsStatusEnum.CLOSE.name())) { if (promotion.getPromotionStatus().equals(PromotionsStatusEnum.END.name()) || promotion.getPromotionStatus().equals(PromotionsStatusEnum.CLOSE.name())) {//如果存在活动
//如果存在活动
if (promotionMap.containsKey(key)) {
//删除活动 //删除活动
promotionMap.remove(key); promotionMap.remove(key);
} else { } else {
//不存在则说明是秒杀活动尝试删除秒杀信息
this.removePromotionKey(key, promotionMap, PromotionTypeEnum.SECKILL.name());
}
} else {
//添加促销活动前如果是同一时间只可以有一个的活动但商品索引的促销活动里存在其他同一时间只可以有一个的活动则清除
this.removePromotionKey(key, promotionMap, PromotionTypeEnum.PINTUAN.name(), PromotionTypeEnum.SECKILL.name(), PromotionTypeEnum.FULL_DISCOUNT.name());
promotionMap.put(key, promotion); promotionMap.put(key, promotion);
} }
goodsIndex.setPromotionMap(promotionMap); goodsIndex.setPromotionMap(promotionMap);
@ -695,7 +688,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
} }
} }
//促销索引 //促销索引
Map<String, Object> goodsCurrentPromotionMap = promotionService.getGoodsCurrentPromotionMap(index); Map<String, Object> goodsCurrentPromotionMap = promotionService.getGoodsPromotionMap(index);
index.setPromotionMap(goodsCurrentPromotionMap); index.setPromotionMap(goodsCurrentPromotionMap);
return index; return index;
} }

View File

@ -13,6 +13,7 @@ import cn.lili.modules.promotion.entity.vos.CouponSearchParams;
import cn.lili.modules.promotion.entity.vos.CouponVO; import cn.lili.modules.promotion.entity.vos.CouponVO;
import cn.lili.modules.promotion.service.CouponService; import cn.lili.modules.promotion.service.CouponService;
import cn.lili.modules.promotion.service.MemberCouponService; import cn.lili.modules.promotion.service.MemberCouponService;
import cn.lili.modules.promotion.tools.PromotionTools;
import cn.lili.mybatis.util.PageUtil; import cn.lili.mybatis.util.PageUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
@ -42,7 +43,7 @@ public class CouponManagerController {
@ApiOperation(value = "获取优惠券列表") @ApiOperation(value = "获取优惠券列表")
@GetMapping @GetMapping
public ResultMessage<IPage<CouponVO>> getCouponList(CouponSearchParams queryParam, PageVO page) { public ResultMessage<IPage<CouponVO>> getCouponList(CouponSearchParams queryParam, PageVO page) {
queryParam.setStoreId("platform"); queryParam.setStoreId(PromotionTools.PLATFORM_ID);
return ResultUtil.data(couponService.pageVOFindAll(queryParam, page)); return ResultUtil.data(couponService.pageVOFindAll(queryParam, page));
} }
@ -111,8 +112,8 @@ public class CouponManagerController {
if (currentUser == null) { if (currentUser == null) {
throw new ServiceException(ResultCode.USER_NOT_EXIST); throw new ServiceException(ResultCode.USER_NOT_EXIST);
} }
couponVO.setStoreId("platform"); couponVO.setStoreId(PromotionTools.PLATFORM_ID);
couponVO.setStoreName("platform"); couponVO.setStoreName(PromotionTools.PLATFORM_NAME);
} }
} }

View File

@ -136,7 +136,7 @@ class EsTest {
List<EsGoodsIndex> esGoodsIndices = new ArrayList<>(); List<EsGoodsIndex> esGoodsIndices = new ArrayList<>();
for (GoodsSku goodsSku : list) { for (GoodsSku goodsSku : list) {
EsGoodsIndex index = new EsGoodsIndex(goodsSku); EsGoodsIndex index = new EsGoodsIndex(goodsSku);
Map<String, Object> goodsCurrentPromotionMap = promotionService.getGoodsCurrentPromotionMap(index); Map<String, Object> goodsCurrentPromotionMap = promotionService.getGoodsPromotionMap(index);
index.setPromotionMap(goodsCurrentPromotionMap); index.setPromotionMap(goodsCurrentPromotionMap);
esGoodsIndices.add(index); esGoodsIndices.add(index);
cache.put(GoodsSkuService.getStockCacheKey(goodsSku.getId()), goodsSku.getQuantity()); cache.put(GoodsSkuService.getStockCacheKey(goodsSku.getId()), goodsSku.getQuantity());