commit
dbcee40b93
@ -5,6 +5,7 @@ import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.promotion.entity.dos.PointsGoods;
|
||||
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.PointsGoodsVO;
|
||||
import cn.lili.modules.promotion.service.PointsGoodsCategoryService;
|
||||
@ -37,6 +38,7 @@ public class PointsGoodsBuyerController {
|
||||
@GetMapping
|
||||
@ApiOperation(value = "分页获取积分商品")
|
||||
public ResultMessage<IPage<PointsGoods>> getPointsGoodsPage(PointsGoodsSearchParams searchParams, PageVO page) {
|
||||
searchParams.setPromotionStatus(PromotionsStatusEnum.START.name());
|
||||
IPage<PointsGoods> pointsGoodsByPage = pointsGoodsService.pageFindAll(searchParams, page);
|
||||
return ResultUtil.data(pointsGoodsByPage);
|
||||
}
|
||||
|
@ -1,18 +1,16 @@
|
||||
package cn.lili.event.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.lili.event.MemberRegisterEvent;
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
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.PromotionsStatusEnum;
|
||||
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.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -35,10 +33,9 @@ public class RegisteredCouponActivityExecute implements MemberRegisterEvent {
|
||||
*/
|
||||
@Override
|
||||
public void memberRegister(Member member) {
|
||||
List<CouponActivity> couponActivities = couponActivityService.list(new LambdaQueryWrapper<CouponActivity>()
|
||||
.eq(CouponActivity::getCouponActivityType, CouponActivityTypeEnum.REGISTERED.name())
|
||||
.ge(BasePromotions::getEndTime, new Date())
|
||||
.le(BasePromotions::getStartTime, new Date()));
|
||||
List<CouponActivity> couponActivities = couponActivityService.list(new QueryWrapper<CouponActivity>()
|
||||
.eq("coupon_activity_type", CouponActivityTypeEnum.REGISTERED.name())
|
||||
.and(PromotionTools.queryPromotionStatus(PromotionsStatusEnum.START)));
|
||||
couponActivityService.registered(couponActivities, member);
|
||||
}
|
||||
}
|
||||
|
@ -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.vos.PromotionGoodsSearchParams;
|
||||
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.service.EsGoodsIndexService;
|
||||
import cn.lili.modules.store.service.StoreService;
|
||||
@ -113,6 +114,9 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
|
||||
@Autowired
|
||||
private StoreGoodsLabelService storeGoodsLabelService;
|
||||
|
||||
@Autowired
|
||||
private PromotionService promotionService;
|
||||
|
||||
@Autowired
|
||||
private PromotionGoodsService promotionGoodsService;
|
||||
|
||||
@ -362,6 +366,11 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -67,6 +67,7 @@ public enum ResultCode {
|
||||
GOODS_AUTH_ERROR(11005, "商品审核失败"),
|
||||
POINT_GOODS_ERROR(11006, "积分商品业务异常,请稍后重试"),
|
||||
POINT_GOODS_NOT_EXIST(11020, "积分商品不存在"),
|
||||
POINT_GOODS_CATEGORY_EXIST(11021, "当前积分商品分类已存在"),
|
||||
GOODS_SKU_SN_ERROR(11007, "商品SKU货号不能为空"),
|
||||
GOODS_SKU_PRICE_ERROR(11008, "商品SKU价格不能小于等于0"),
|
||||
GOODS_SKU_COST_ERROR(11009, "商品SKU成本价不能小于等于0"),
|
||||
@ -179,6 +180,7 @@ public enum ResultCode {
|
||||
ORDER_CAN_NOT_CANCEL(31012, "当前订单状态不可取消"),
|
||||
ORDER_BATCH_DELIVER_ERROR(31013, "批量发货,文件读取失败"),
|
||||
ORDER_ITEM_NOT_EXIST(31014, "当前订单项不存在!"),
|
||||
POINT_NOT_ENOUGH(31015, "当前会员积分不足购买当前积分商品!"),
|
||||
|
||||
|
||||
/**
|
||||
|
@ -8,6 +8,7 @@ import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.modules.goods.entity.dto.GoodsOperationDTO;
|
||||
import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;
|
||||
import cn.lili.modules.goods.entity.enums.GoodsTypeEnum;
|
||||
import cn.lili.mybatis.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
@ -181,7 +182,7 @@ public class Goods extends BaseEntity {
|
||||
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);
|
||||
}
|
||||
if (!sku.containsKey("quantity") || StringUtil.isEmpty(sku.get("quantity").toString()) || Convert.toInt(sku.get("quantity").toString()) < 0) {
|
||||
|
@ -241,7 +241,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
//获取当前商品的索引信息
|
||||
EsGoodsIndex goodsIndex = goodsIndexService.findById(skuId);
|
||||
if (goodsIndex == null) {
|
||||
goodsIndex = goodsIndexService.resetEsGoodsIndex(goodsSku, goodsVO.getGoodsParamsDTOList());
|
||||
goodsIndex = goodsIndexService.getTempEsGoodsIndex(goodsSku, goodsVO.getGoodsParamsDTOList());
|
||||
|
||||
//发送mq消息
|
||||
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.RESET_GOODS_INDEX.name();
|
||||
|
@ -85,6 +85,7 @@ public class CartVO extends CartBase implements Serializable {
|
||||
this.setCouponList(new ArrayList<>());
|
||||
this.setGiftList(new ArrayList<>());
|
||||
this.setGiftCouponList(new ArrayList<>());
|
||||
this.setCanReceiveCoupon(new ArrayList<>());
|
||||
this.setChecked(false);
|
||||
this.isFull = false;
|
||||
this.weight = 0d;
|
||||
|
@ -44,6 +44,7 @@ public class RenderStepStatement {
|
||||
public static RenderStepEnums[] checkedSingleRender = {
|
||||
RenderStepEnums.CHECK_DATA,
|
||||
RenderStepEnums.SKU_PROMOTION,
|
||||
RenderStepEnums.COUPON,
|
||||
RenderStepEnums.SKU_FREIGHT,
|
||||
RenderStepEnums.CART_PRICE
|
||||
};
|
||||
|
@ -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.order.entity.dos.Order;
|
||||
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.PointsGoods;
|
||||
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.stereotype.Service;
|
||||
|
||||
@ -39,6 +42,7 @@ import java.util.stream.Collectors;
|
||||
* @since 2020-07-02 14:47
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class CheckDataRender implements CartRenderStep {
|
||||
|
||||
@Autowired
|
||||
@ -144,6 +148,16 @@ public class CheckDataRender implements CartRenderStep {
|
||||
cartVO.setDeliveryMethod(DeliveryMethodEnum.LOGISTICS.name());
|
||||
}
|
||||
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));
|
||||
cartList.add(cartVO);
|
||||
}
|
||||
|
@ -1,8 +1,12 @@
|
||||
package cn.lili.modules.order.cart.render.impl;
|
||||
|
||||
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.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.enums.RenderStepEnums;
|
||||
import cn.lili.modules.order.cart.entity.vo.CartSkuVO;
|
||||
@ -34,6 +38,9 @@ public class SkuPromotionRender implements CartRenderStep {
|
||||
@Autowired
|
||||
private KanjiaActivityService kanjiaActivityService;
|
||||
|
||||
@Autowired
|
||||
private MemberService memberService;
|
||||
|
||||
@Override
|
||||
public RenderStepEnums step() {
|
||||
return RenderStepEnums.SKU_PROMOTION;
|
||||
@ -76,14 +83,20 @@ public class SkuPromotionRender implements CartRenderStep {
|
||||
|
||||
//这里是双重循环,但是实际积分购买或者是砍价购买时,购物车只有一个商品,所以没有循环操作数据库或者其他的问题
|
||||
case POINTS:
|
||||
Member userInfo = memberService.getUserInfo();
|
||||
long totalPayPoints = 0;
|
||||
//处理积分商品购买
|
||||
for (CartVO cartVO : tradeDTO.getCartList()) {
|
||||
for (CartSkuVO cartSkuVO : cartVO.getCheckedSkuList()) {
|
||||
cartSkuVO.getPriceDetailDTO().setPayPoint(cartSkuVO.getPoint());
|
||||
PromotionSkuVO promotionSkuVO = new PromotionSkuVO(PromotionTypeEnum.POINTS_GOODS.name(), cartSkuVO.getPointsId());
|
||||
cartSkuVO.getPriceDetailDTO().getJoinPromotion().add(promotionSkuVO);
|
||||
totalPayPoints += cartSkuVO.getPoint();
|
||||
}
|
||||
}
|
||||
if (userInfo.getPoint() < totalPayPoints) {
|
||||
throw new ServiceException(ResultCode.POINT_NOT_ENOUGH);
|
||||
}
|
||||
return;
|
||||
case KANJIA:
|
||||
for (CartVO cartVO : tradeDTO.getCartList()) {
|
||||
|
@ -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.service.GoodsService;
|
||||
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.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.TradeDTO;
|
||||
import cn.lili.modules.order.cart.entity.enums.CartTypeEnum;
|
||||
@ -127,34 +129,19 @@ public class CartServiceImpl implements CartService {
|
||||
@Autowired
|
||||
private TradeBuilder tradeBuilder;
|
||||
|
||||
@Autowired
|
||||
private MemberService memberService;
|
||||
|
||||
@Override
|
||||
public void add(String skuId, Integer num, String cartType, Boolean cover) {
|
||||
AuthUser currentUser = Objects.requireNonNull(UserContext.getCurrentUser());
|
||||
if (num <= 0) {
|
||||
throw new ServiceException(ResultCode.CART_NUM_ERROR);
|
||||
}
|
||||
CartTypeEnum cartTypeEnum = getCartType(cartType);
|
||||
GoodsSku dataSku = checkGoods(skuId);
|
||||
Map<String, Object> promotionMap;
|
||||
EsGoodsIndex goodsIndex = goodsIndexService.findById(skuId);
|
||||
if (goodsIndex == null) {
|
||||
GoodsVO goodsVO = this.goodsService.getGoodsVO(dataSku.getGoodsId());
|
||||
goodsIndex = goodsIndexService.resetEsGoodsIndex(dataSku, goodsVO.getGoodsParamsDTOList());
|
||||
Map<String, Object> promotionMap = this.getCurrentGoodsPromotion(dataSku, cartType);
|
||||
|
||||
//发送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 {
|
||||
//购物车方式购买需要保存之前的选择,其他方式购买,则直接抹除掉之前的记录
|
||||
TradeDTO tradeDTO;
|
||||
@ -200,7 +187,6 @@ public class CartServiceImpl implements CartService {
|
||||
cartSkuVO.setChecked(true);
|
||||
} else {
|
||||
tradeDTO = new TradeDTO(cartTypeEnum);
|
||||
AuthUser currentUser = UserContext.getCurrentUser();
|
||||
tradeDTO.setMemberId(currentUser.getId());
|
||||
tradeDTO.setMemberName(currentUser.getUsername());
|
||||
List<CartSkuVO> cartSkuVOS = tradeDTO.getSkuList();
|
||||
@ -569,6 +555,31 @@ public class CartServiceImpl implements CartService {
|
||||
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());
|
||||
|
||||
if (pointsGoodsVO != null) {
|
||||
|
||||
Member userInfo = memberService.getUserInfo();
|
||||
if (userInfo.getPoint() < pointsGoodsVO.getPoints()) {
|
||||
throw new ServiceException(ResultCode.POINT_NOT_ENOUGH);
|
||||
}
|
||||
if (pointsGoodsVO.getActiveStock() < 1) {
|
||||
throw new ServiceException(ResultCode.POINT_GOODS_ACTIVE_STOCK_INSUFFICIENT);
|
||||
}
|
||||
|
@ -121,15 +121,22 @@ public class PromotionGoods extends BaseEntity {
|
||||
this.promotionId = pointsGoods.getId();
|
||||
this.quantity = pointsGoods.getActiveStock();
|
||||
this.originalPrice = sku.getPrice();
|
||||
this.promotionType = PromotionTypeEnum.POINTS_GOODS.name();
|
||||
this.scopeId = sku.getId();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public PromotionGoods(KanjiaActivityGoodsDTO kanjiaActivityGoodsDTO) {
|
||||
if (kanjiaActivityGoodsDTO != null) {
|
||||
BeanUtil.copyProperties(kanjiaActivityGoodsDTO, 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());
|
||||
}
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.lili.modules.promotion.entity.dto.BasePromotions;
|
||||
import cn.lili.modules.promotion.entity.vos.SeckillVO;
|
||||
import cn.lili.modules.promotion.tools.PromotionTools;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
@ -61,8 +62,8 @@ public class Seckill extends BasePromotions {
|
||||
this.seckillRule = seckillRule;
|
||||
this.goodsNum = 0;
|
||||
//BasePromotion
|
||||
this.setStoreName("platform");
|
||||
this.setStoreId("platform");
|
||||
this.setStoreName(PromotionTools.PLATFORM_NAME);
|
||||
this.setStoreId(PromotionTools.PLATFORM_ID);
|
||||
this.setPromotionName(DateUtil.formatDate(dateTime) + " 秒杀活动");
|
||||
this.setStartTime(dateTime);
|
||||
this.setEndTime(DateUtil.endOfDay(dateTime));
|
||||
|
@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
@ -29,7 +30,7 @@ public class BasePromotionsSearchParams {
|
||||
/**
|
||||
* @see PromotionsStatusEnum
|
||||
*/
|
||||
@ApiModelProperty(value = "活动状态")
|
||||
@ApiModelProperty(value = "活动状态 如需同时判断多个活动状态','分割")
|
||||
private String promotionStatus;
|
||||
|
||||
/**
|
||||
@ -38,6 +39,9 @@ public class BasePromotionsSearchParams {
|
||||
@ApiModelProperty(value = "关联范围类型")
|
||||
private String scopeType;
|
||||
|
||||
@ApiModelProperty(value = "店铺编号 如有多个','分割")
|
||||
private String storeId;
|
||||
|
||||
public <T> QueryWrapper<T> queryWrapper() {
|
||||
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
|
||||
|
||||
@ -51,11 +55,18 @@ public class BasePromotionsSearchParams {
|
||||
queryWrapper.le("end_time", new Date(endTime));
|
||||
}
|
||||
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)) {
|
||||
queryWrapper.eq("scope_type", scopeType);
|
||||
}
|
||||
if (CharSequenceUtil.isNotEmpty(storeId)) {
|
||||
queryWrapper.in("store_id", Arrays.asList(storeId.split(",")));
|
||||
}
|
||||
queryWrapper.eq("delete_flag", false);
|
||||
return queryWrapper;
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
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 RANGE_DAY_TYPE_COLUMN = "range_day_type";
|
||||
|
||||
@ApiModelProperty(value = "店铺编号")
|
||||
private String storeId;
|
||||
|
||||
@ApiModelProperty(value = "会员id")
|
||||
private String memberId;
|
||||
|
||||
@ -69,10 +65,7 @@ public class CouponSearchParams extends BasePromotionsSearchParams implements Se
|
||||
|
||||
@Override
|
||||
public <T> QueryWrapper<T> queryWrapper() {
|
||||
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
|
||||
if (storeId != null) {
|
||||
queryWrapper.in("store_id", Arrays.asList(storeId.split(",")));
|
||||
}
|
||||
QueryWrapper<T> queryWrapper = super.queryWrapper();
|
||||
if (CharSequenceUtil.isNotEmpty(couponName)) {
|
||||
queryWrapper.like("coupon_name", couponName);
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 满优惠查询通用类
|
||||
@ -25,9 +24,6 @@ public class FullDiscountSearchParams extends BasePromotionsSearchParams impleme
|
||||
@ApiModelProperty(value = "活动名称")
|
||||
private String promotionName;
|
||||
|
||||
@ApiModelProperty(value = "店铺编号 如有多个','分割")
|
||||
private String storeId;
|
||||
|
||||
@ApiModelProperty(value = "是否赠优惠券")
|
||||
private Boolean couponFlag;
|
||||
|
||||
@ -40,9 +36,6 @@ public class FullDiscountSearchParams extends BasePromotionsSearchParams impleme
|
||||
if (CharSequenceUtil.isNotEmpty(promotionName)) {
|
||||
queryWrapper.like("title", promotionName);
|
||||
}
|
||||
if (storeId != null) {
|
||||
queryWrapper.in("store_id", Arrays.asList(storeId.split(",")));
|
||||
}
|
||||
if (couponFlag != null) {
|
||||
queryWrapper.eq("coupon_flag", couponFlag);
|
||||
}
|
||||
|
@ -18,9 +18,6 @@ import javax.validation.constraints.NotEmpty;
|
||||
@Data
|
||||
public class PintuanSearchParams extends BasePromotionsSearchParams {
|
||||
|
||||
@ApiModelProperty(value = "商家id")
|
||||
private String storeId;
|
||||
|
||||
@ApiModelProperty(value = "商家名称,如果是平台,这个值为 platform")
|
||||
private String storeName;
|
||||
|
||||
@ -38,9 +35,6 @@ public class PintuanSearchParams extends BasePromotionsSearchParams {
|
||||
if (CharSequenceUtil.isNotEmpty(storeName)) {
|
||||
queryWrapper.like("store_name", storeName);
|
||||
}
|
||||
if (CharSequenceUtil.isNotEmpty(storeId)) {
|
||||
queryWrapper.eq("store_id", storeId);
|
||||
}
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
|
@ -26,9 +26,6 @@ public class PromotionGoodsSearchParams extends BasePromotionsSearchParams {
|
||||
@ApiModelProperty(value = "促销类型")
|
||||
private String promotionType;
|
||||
|
||||
@ApiModelProperty(value = "商品活动id")
|
||||
private String storeId;
|
||||
|
||||
@ApiModelProperty(value = "商品名称")
|
||||
private String goodsName;
|
||||
|
||||
@ -63,9 +60,6 @@ public class PromotionGoodsSearchParams extends BasePromotionsSearchParams {
|
||||
if (CharSequenceUtil.isNotEmpty(categoryPath)) {
|
||||
queryWrapper.like("category_path", categoryPath);
|
||||
}
|
||||
if (CharSequenceUtil.isNotEmpty(storeId)) {
|
||||
queryWrapper.in("store_id", Arrays.asList(storeId.split(",")));
|
||||
}
|
||||
if (CharSequenceUtil.isNotEmpty(skuId)) {
|
||||
queryWrapper.in("sku_id", Arrays.asList(skuId.split(",")));
|
||||
}
|
||||
|
@ -34,9 +34,6 @@ public class SeckillSearchParams extends BasePromotionsSearchParams implements S
|
||||
@ApiModelProperty(value = "商家id")
|
||||
private String[] storeIds;
|
||||
|
||||
@ApiModelProperty(value = "商家编号")
|
||||
private String storeId;
|
||||
|
||||
@ApiModelProperty(value = "商品名称")
|
||||
private String goodsName;
|
||||
|
||||
|
@ -3,7 +3,6 @@ package cn.lili.modules.promotion.service;
|
||||
import cn.lili.cache.CachePrefix;
|
||||
import cn.lili.common.enums.PromotionTypeEnum;
|
||||
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.vos.PromotionGoodsSearchParams;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@ -34,19 +33,13 @@ public interface PromotionGoodsService extends IService<PromotionGoods> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新促销活动
|
||||
*
|
||||
* @param cartSkuVO 购物车中的产品
|
||||
*/
|
||||
void updatePromotion(CartSkuVO cartSkuVO);
|
||||
|
||||
/**
|
||||
* 获取某sku当日所有活动
|
||||
* 获取某sku所有有效活动
|
||||
*
|
||||
* @param skuId 商品skuId
|
||||
* @param storeIds 店铺id
|
||||
* @return 促销商品集合
|
||||
*/
|
||||
List<PromotionGoods> findNowSkuPromotion(String skuId);
|
||||
List<PromotionGoods> findSkuValidPromotion(String skuId, String storeIds);
|
||||
|
||||
/**
|
||||
* 分页获取促销商品信息
|
||||
|
@ -25,6 +25,6 @@ public interface PromotionService {
|
||||
* @param index 商品索引
|
||||
* @return 当前促销活动集合
|
||||
*/
|
||||
Map<String, Object> getGoodsCurrentPromotionMap(EsGoodsIndex index);
|
||||
Map<String, Object> getGoodsPromotionMap(EsGoodsIndex index);
|
||||
|
||||
}
|
@ -220,8 +220,9 @@ public abstract class AbstractPromotionsServiceImpl<M extends BaseMapper<T>, T e
|
||||
this.promotionGoodsService.deletePromotionGoods(Collections.singletonList(promotions.getId()));
|
||||
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.setScopeId(promotions.getScopeId());
|
||||
promotionGoods.setScopeType(promotions.getScopeType());
|
||||
promotionGoods.setPromotionId(promotions.getId());
|
||||
promotionGoods.setStoreId(promotions.getStoreId());
|
||||
|
@ -19,6 +19,7 @@ import cn.lili.modules.promotion.service.CouponActivityItemService;
|
||||
import cn.lili.modules.promotion.service.CouponActivityService;
|
||||
import cn.lili.modules.promotion.service.CouponService;
|
||||
import cn.lili.modules.promotion.service.MemberCouponService;
|
||||
import cn.lili.modules.promotion.tools.PromotionTools;
|
||||
import groovy.util.logging.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -203,7 +204,7 @@ public class CouponActivityServiceImpl extends AbstractPromotionsServiceImpl<Cou
|
||||
memberCoupon.setMemberId(map.get("id").toString());
|
||||
memberCoupon.setMemberName(map.get("nick_name").toString());
|
||||
memberCoupon.setMemberCouponStatus(MemberCouponStatusEnum.NEW.name());
|
||||
memberCoupon.setPlatformFlag("platform".equals(coupon.getStoreId()));
|
||||
memberCoupon.setPlatformFlag(PromotionTools.PLATFORM_ID.equals(coupon.getStoreId()));
|
||||
memberCouponList.add(memberCoupon);
|
||||
}
|
||||
}
|
||||
|
@ -213,6 +213,7 @@ public class CouponServiceImpl extends AbstractPromotionsServiceImpl<CouponMappe
|
||||
FullDiscountSearchParams searchParams = new FullDiscountSearchParams();
|
||||
searchParams.setCouponFlag(true);
|
||||
searchParams.setCouponId(promotions.getId());
|
||||
searchParams.setPromotionStatus(PromotionsStatusEnum.START.name());
|
||||
List<FullDiscount> fullDiscounts = fullDiscountService.listFindAll(searchParams);
|
||||
if (fullDiscounts != null && !fullDiscounts.isEmpty()) {
|
||||
throw new ServiceException("当前优惠券参与了促销活动【" + fullDiscounts.get(0).getPromotionName() + "】不能进行编辑删除操作");
|
||||
@ -228,6 +229,10 @@ public class CouponServiceImpl extends AbstractPromotionsServiceImpl<CouponMappe
|
||||
CouponVO couponVO = (CouponVO) promotions;
|
||||
this.promotionGoodsService.deletePromotionGoods(Collections.singletonList(promotions.getId()));
|
||||
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);
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;
|
||||
import cn.lili.modules.goods.service.GoodsSkuService;
|
||||
import cn.lili.modules.promotion.entity.dos.KanjiaActivityGoods;
|
||||
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.KanjiaActivityGoodsOperationDTO;
|
||||
import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum;
|
||||
@ -268,7 +267,8 @@ public class KanjiaActivityGoodsServiceImpl extends AbstractPromotionsServiceImp
|
||||
throw new ServiceException("商品id为" + goodsSku.getId() + "的商品已参加砍价商品活动!");
|
||||
}
|
||||
this.promotionGoodsService.deletePromotionGoods(Collections.singletonList(kanJiaActivityGoodsDTO.getId()));
|
||||
this.updatePromotionsGoods(kanJiaActivityGoodsDTO);
|
||||
PromotionGoods promotionGoods = new PromotionGoods(kanJiaActivityGoodsDTO);
|
||||
this.promotionGoodsService.save(promotionGoods);
|
||||
this.updateEsGoodsIndex(kanJiaActivityGoodsDTO);
|
||||
//修改数据库
|
||||
return this.updateById(kanJiaActivityGoodsDTO);
|
||||
|
@ -15,6 +15,7 @@ import cn.lili.modules.promotion.entity.vos.CouponSearchParams;
|
||||
import cn.lili.modules.promotion.mapper.MemberCouponMapper;
|
||||
import cn.lili.modules.promotion.service.CouponService;
|
||||
import cn.lili.modules.promotion.service.MemberCouponService;
|
||||
import cn.lili.modules.promotion.tools.PromotionTools;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
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) {
|
||||
LambdaQueryWrapper<MemberCoupon> queryWrapper = new LambdaQueryWrapper<>();
|
||||
List<String> storeIds = new ArrayList<>(Arrays.asList(param.getStoreId().split(",")));
|
||||
storeIds.add("platform");
|
||||
storeIds.add(PromotionTools.PLATFORM_ID);
|
||||
queryWrapper.in(MemberCoupon::getStoreId, storeIds);
|
||||
queryWrapper.eq(MemberCoupon::getMemberId, param.getMemberId());
|
||||
queryWrapper.and(
|
||||
@ -253,7 +254,7 @@ public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper, Mem
|
||||
memberCoupon.setMemberId(memberId);
|
||||
memberCoupon.setMemberName(memberName);
|
||||
memberCoupon.setMemberCouponStatus(MemberCouponStatusEnum.NEW.name());
|
||||
memberCoupon.setPlatformFlag(("platform").equals(coupon.getStoreId()));
|
||||
memberCoupon.setPlatformFlag((PromotionTools.PLATFORM_ID).equals(coupon.getStoreId()));
|
||||
this.save(memberCoupon);
|
||||
couponService.receiveCoupon(couponId, 1);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.lili.modules.promotion.serviceimpl;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.modules.promotion.entity.dos.PointsGoodsCategory;
|
||||
@ -96,7 +97,7 @@ public class PointsGoodsCategoryServiceImpl extends ServiceImpl<PointsGoodsCateg
|
||||
}
|
||||
if (this.getOne(queryWrapper) != null) {
|
||||
log.error("当前积分商品分类名称" + name + "已存在!");
|
||||
throw new ServiceException();
|
||||
throw new ServiceException(ResultCode.POINT_GOODS_CATEGORY_EXIST);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,6 @@ import cn.lili.modules.promotion.tools.PromotionTools;
|
||||
import cn.lili.modules.search.utils.EsIndexUtil;
|
||||
import cn.lili.rocketmq.RocketmqSendCallbackBuilder;
|
||||
import cn.lili.rocketmq.tags.GoodsTagsEnum;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 积分商品业务层实现
|
||||
@ -166,7 +162,9 @@ public class PointsGoodsServiceImpl extends AbstractPromotionsServiceImpl<Points
|
||||
*/
|
||||
@Override
|
||||
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) {
|
||||
log.error("skuId为" + skuId + "的积分商品不存在!");
|
||||
throw new ServiceException();
|
||||
@ -208,7 +206,7 @@ public class PointsGoodsServiceImpl extends AbstractPromotionsServiceImpl<Points
|
||||
*/
|
||||
@Override
|
||||
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())));
|
||||
}
|
||||
|
||||
|
@ -5,18 +5,13 @@ import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.common.enums.PromotionTypeEnum;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.utils.DateUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.modules.goods.entity.dos.GoodsSku;
|
||||
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.SeckillApply;
|
||||
import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum;
|
||||
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.SeckillSearchParams;
|
||||
import cn.lili.modules.promotion.mapper.PromotionGoodsMapper;
|
||||
@ -37,6 +32,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@ -73,7 +69,7 @@ public class PromotionGoodsServiceImpl extends ServiceImpl<PromotionGoodsMapper,
|
||||
private CouponService couponService;
|
||||
|
||||
@Override
|
||||
public List<PromotionGoods> findNowSkuPromotion(String skuId) {
|
||||
public List<PromotionGoods> findSkuValidPromotion(String skuId, String storeIds) {
|
||||
|
||||
GoodsSku sku = goodsSkuService.getGoodsSkuByIdFromCache(skuId);
|
||||
if (sku == null) {
|
||||
@ -81,48 +77,13 @@ public class PromotionGoodsServiceImpl extends ServiceImpl<PromotionGoodsMapper,
|
||||
}
|
||||
QueryWrapper<PromotionGoods> queryWrapper = new QueryWrapper<>();
|
||||
|
||||
queryWrapper.eq("sku_id", skuId);
|
||||
queryWrapper.and(PromotionTools.queryPromotionStatus(PromotionsStatusEnum.START));
|
||||
|
||||
List<PromotionGoods> promotionGoods = this.list(queryWrapper);
|
||||
|
||||
|
||||
BasePromotionsSearchParams searchParams = new BasePromotionsSearchParams();
|
||||
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);
|
||||
}
|
||||
queryWrapper.and(i -> i.or(j -> j.eq("sku_id", skuId))
|
||||
.or(n -> n.eq("scope_type", PromotionsScopeTypeEnum.ALL.name()))
|
||||
.or(n -> n.and(k -> k.eq("scope_type", PromotionsScopeTypeEnum.PORTION_GOODS_CATEGORY.name())
|
||||
.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(",")));
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,11 +2,12 @@ package cn.lili.modules.promotion.serviceimpl;
|
||||
|
||||
import cn.lili.common.enums.PromotionTypeEnum;
|
||||
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.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.tools.PromotionTools;
|
||||
import cn.lili.modules.search.entity.dos.EsGoodsIndex;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -111,33 +112,10 @@ public class PromotionServiceImpl implements PromotionService {
|
||||
* @return 当前促销活动集合
|
||||
*/
|
||||
@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<>();
|
||||
FullDiscountSearchParams fullDiscountSearchParams = new FullDiscountSearchParams();
|
||||
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);
|
||||
List<PromotionGoods> promotionGoodsList = promotionGoodsService.findSkuValidPromotion(index.getId(), storeIds);
|
||||
for (PromotionGoods promotionGoods : promotionGoodsList) {
|
||||
String esPromotionKey = promotionGoods.getPromotionType() + "-" + promotionGoods.getPromotionId();
|
||||
switch (PromotionTypeEnum.valueOf(promotionGoods.getPromotionType())) {
|
||||
|
@ -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.saveBatch(originList);
|
||||
this.seckillService.updateEsGoodsSeckill(seckill, originList);
|
||||
//保存促销活动商品信息
|
||||
if (!promotionGoodsList.isEmpty()) {
|
||||
PromotionGoodsSearchParams searchParams = new PromotionGoodsSearchParams();
|
||||
@ -203,6 +202,7 @@ public class SeckillApplyServiceImpl extends ServiceImpl<SeckillApplyMapper, Sec
|
||||
//设置秒杀活动的商品数量、店铺数量
|
||||
seckillService.updateSeckillGoodsNum(seckillId);
|
||||
cache.vagueDel(CachePrefix.STORE_ID_SECKILL);
|
||||
this.seckillService.updateEsGoodsSeckill(seckill, originList);
|
||||
}
|
||||
|
||||
|
||||
|
@ -41,7 +41,6 @@ import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
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) {
|
||||
if (seckillApplies != null && !seckillApplies.isEmpty()) {
|
||||
// 更新促销范围
|
||||
List<String> skuIds = seckillApplies.stream().map(SeckillApply::getSkuId).collect(Collectors.toList());
|
||||
seckill.setScopeId(ArrayUtil.join(skuIds.toArray(), ","));
|
||||
seckill.setScopeId(ArrayUtil.join(seckillApplies.stream().map(SeckillApply::getSkuId).toArray(), ","));
|
||||
UpdateWrapper<Seckill> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.eq("id", seckill.getId());
|
||||
updateWrapper.set("scope_id", seckill.getScopeId());
|
||||
@ -153,7 +151,7 @@ public class SeckillServiceImpl extends AbstractPromotionsServiceImpl<SeckillMap
|
||||
if (seckillApply.getPromotionApplyStatus().equals(PromotionsApplyStatusEnum.PASS.name())) {
|
||||
this.setSeckillApplyTime(seckill, seckillApply);
|
||||
log.info("更新限时抢购商品状态:{}", seckill);
|
||||
String promotionKey = PromotionTypeEnum.SECKILL.name() + "-" + seckillApply.getTimeLine();
|
||||
String promotionKey = PromotionTypeEnum.SECKILL.name() + "-" + seckill.getId();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
// es促销key
|
||||
map.put("esPromotionKey", promotionKey);
|
||||
|
@ -2,6 +2,7 @@ package cn.lili.modules.promotion.tools;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.common.enums.PromotionTypeEnum;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
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 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) {
|
||||
promotionGoods.setPromotionId(promotion.getId());
|
||||
promotionGoods.setStoreName(promotion.getStoreName());
|
||||
if (CharSequenceUtil.isEmpty(promotionGoods.getStoreId())) {
|
||||
promotionGoods.setStoreId(promotion.getStoreId());
|
||||
}
|
||||
if (CharSequenceUtil.isEmpty(promotionGoods.getStoreName())) {
|
||||
promotionGoods.setStoreName(promotion.getStoreName());
|
||||
}
|
||||
promotionGoods.setTitle(promotion.getPromotionName());
|
||||
if (promotionGoods.getStartTime() == null) {
|
||||
promotionGoods.setStartTime(promotion.getStartTime());
|
||||
|
@ -169,11 +169,11 @@ public interface EsGoodsIndexService {
|
||||
List<String> getPromotionIdByPromotionType(String id, PromotionTypeEnum promotionTypeEnum);
|
||||
|
||||
/**
|
||||
* 重置当前商品索引
|
||||
* 获取临时拼装的商品索引
|
||||
*
|
||||
* @param goodsSku 商品sku信息
|
||||
* @param goodsParamDTOS 商品参数
|
||||
* @return 商品索引
|
||||
*/
|
||||
EsGoodsIndex resetEsGoodsIndex(GoodsSku goodsSku, List<GoodsParamsDTO> goodsParamDTOS);
|
||||
EsGoodsIndex getTempEsGoodsIndex(GoodsSku goodsSku, List<GoodsParamsDTO> goodsParamDTOS);
|
||||
}
|
||||
|
@ -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.enums.PromotionsStatusEnum;
|
||||
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.dto.EsGoodsSearchDTO;
|
||||
import cn.lili.modules.search.repository.EsGoodsIndexRepository;
|
||||
@ -390,7 +391,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
public void updateEsGoodsIndexAllByList(BasePromotions promotion, String key) {
|
||||
List<EsGoodsIndex> goodsIndices = new ArrayList<>();
|
||||
//如果storeId不为空,则表示是店铺活动
|
||||
if (promotion.getStoreId() != null) {
|
||||
if (promotion.getStoreId() != null && !promotion.getStoreId().equals(PromotionTools.PLATFORM_ID)) {
|
||||
EsGoodsSearchDTO searchDTO = new EsGoodsSearchDTO();
|
||||
searchDTO.setStoreId(promotion.getStoreId());
|
||||
//查询出店铺商品
|
||||
@ -552,17 +553,17 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置当前商品索引
|
||||
* 获取临时拼装的商品索引
|
||||
*
|
||||
* @param goodsSku 商品sku信息
|
||||
* @param goodsParamDTOS 商品参数
|
||||
* @return 商品索引
|
||||
*/
|
||||
@Override
|
||||
public EsGoodsIndex resetEsGoodsIndex(GoodsSku goodsSku, List<GoodsParamsDTO> goodsParamDTOS) {
|
||||
public EsGoodsIndex getTempEsGoodsIndex(GoodsSku goodsSku, List<GoodsParamsDTO> goodsParamDTOS) {
|
||||
EsGoodsIndex index = new EsGoodsIndex(goodsSku, goodsParamDTOS);
|
||||
//获取活动信息
|
||||
Map<String, Object> goodsCurrentPromotionMap = promotionService.getGoodsCurrentPromotionMap(index);
|
||||
Map<String, Object> goodsCurrentPromotionMap = promotionService.getGoodsPromotionMap(index);
|
||||
//写入促销信息
|
||||
index.setPromotionMap(goodsCurrentPromotionMap);
|
||||
return index;
|
||||
@ -588,18 +589,10 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
promotionMap = goodsIndex.getPromotionMap();
|
||||
}
|
||||
//如果活动已结束
|
||||
if (promotion.getPromotionStatus().equals(PromotionsStatusEnum.END.name()) || promotion.getPromotionStatus().equals(PromotionsStatusEnum.CLOSE.name())) {
|
||||
//如果存在活动
|
||||
if (promotionMap.containsKey(key)) {
|
||||
//删除活动
|
||||
promotionMap.remove(key);
|
||||
} else {
|
||||
//不存在则说明是秒杀活动,尝试删除秒杀信息
|
||||
this.removePromotionKey(key, promotionMap, PromotionTypeEnum.SECKILL.name());
|
||||
}
|
||||
if (promotion.getPromotionStatus().equals(PromotionsStatusEnum.END.name()) || promotion.getPromotionStatus().equals(PromotionsStatusEnum.CLOSE.name())) {//如果存在活动
|
||||
//删除活动
|
||||
promotionMap.remove(key);
|
||||
} else {
|
||||
//添加促销活动前,如果是同一时间只可以有一个的活动,但商品索引的促销活动里存在其他(同一时间只可以有一个)的活动,则清除
|
||||
this.removePromotionKey(key, promotionMap, PromotionTypeEnum.PINTUAN.name(), PromotionTypeEnum.SECKILL.name(), PromotionTypeEnum.FULL_DISCOUNT.name());
|
||||
promotionMap.put(key, promotion);
|
||||
}
|
||||
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);
|
||||
return index;
|
||||
}
|
||||
|
@ -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.service.CouponService;
|
||||
import cn.lili.modules.promotion.service.MemberCouponService;
|
||||
import cn.lili.modules.promotion.tools.PromotionTools;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@ -42,7 +43,7 @@ public class CouponManagerController {
|
||||
@ApiOperation(value = "获取优惠券列表")
|
||||
@GetMapping
|
||||
public ResultMessage<IPage<CouponVO>> getCouponList(CouponSearchParams queryParam, PageVO page) {
|
||||
queryParam.setStoreId("platform");
|
||||
queryParam.setStoreId(PromotionTools.PLATFORM_ID);
|
||||
return ResultUtil.data(couponService.pageVOFindAll(queryParam, page));
|
||||
}
|
||||
|
||||
@ -111,8 +112,8 @@ public class CouponManagerController {
|
||||
if (currentUser == null) {
|
||||
throw new ServiceException(ResultCode.USER_NOT_EXIST);
|
||||
}
|
||||
couponVO.setStoreId("platform");
|
||||
couponVO.setStoreName("platform");
|
||||
couponVO.setStoreId(PromotionTools.PLATFORM_ID);
|
||||
couponVO.setStoreName(PromotionTools.PLATFORM_NAME);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ class EsTest {
|
||||
List<EsGoodsIndex> esGoodsIndices = new ArrayList<>();
|
||||
for (GoodsSku goodsSku : list) {
|
||||
EsGoodsIndex index = new EsGoodsIndex(goodsSku);
|
||||
Map<String, Object> goodsCurrentPromotionMap = promotionService.getGoodsCurrentPromotionMap(index);
|
||||
Map<String, Object> goodsCurrentPromotionMap = promotionService.getGoodsPromotionMap(index);
|
||||
index.setPromotionMap(goodsCurrentPromotionMap);
|
||||
esGoodsIndices.add(index);
|
||||
cache.put(GoodsSkuService.getStockCacheKey(goodsSku.getId()), goodsSku.getQuantity());
|
||||
|
Loading…
x
Reference in New Issue
Block a user