!114 修复店铺优惠券为部分商品。部分商品使用优惠券无效
Merge pull request !114 from OceansDeep/feature/pg
This commit is contained in:
commit
801f1cbd4c
@ -390,7 +390,7 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
|
||||
}
|
||||
|
||||
if (goodsIndex.getPromotionMap() == null || goodsIndex.getPromotionMap().isEmpty()) {
|
||||
Map<String, Object> goodsCurrentPromotionMap = promotionService.getGoodsPromotionMap(goodsIndex);
|
||||
Map<String, Object> goodsCurrentPromotionMap = promotionService.getGoodsSkuPromotionMap(goodsIndex.getStoreId(), goodsIndex.getId());
|
||||
goodsIndex.setPromotionMapJson(JSONUtil.toJsonStr(goodsCurrentPromotionMap));
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import cn.lili.common.enums.SwitchEnum;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.modules.member.entity.vo.MemberSearchVO;
|
||||
import cn.lili.modules.member.entity.vo.MemberVO;
|
||||
import cn.lili.modules.member.mapper.MemberMapper;
|
||||
import cn.lili.modules.member.service.MemberService;
|
||||
import cn.lili.modules.message.entity.dos.MemberMessage;
|
||||
import cn.lili.modules.message.entity.dos.Message;
|
||||
@ -28,7 +27,6 @@ import org.apache.rocketmq.spring.core.RocketMQListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -42,11 +40,6 @@ import java.util.List;
|
||||
@RocketMQMessageListener(topic = "${lili.data.rocketmq.notice-send-topic}", consumerGroup = "${lili.data.rocketmq.notice-send-group}")
|
||||
public class NoticeSendMessageListener implements RocketMQListener<MessageExt> {
|
||||
|
||||
/**
|
||||
* 会员
|
||||
*/
|
||||
@Resource
|
||||
private MemberMapper memberMapper;
|
||||
/**
|
||||
* 短信
|
||||
*/
|
||||
@ -82,7 +75,7 @@ public class NoticeSendMessageListener implements RocketMQListener<MessageExt> {
|
||||
//发送全部会员
|
||||
if (smsReachDTO.getSmsRange().equals(RangeEnum.ALL.name())) {
|
||||
//获取所有会员的手机号
|
||||
List<String> list = memberMapper.getAllMemberMobile();
|
||||
List<String> list = memberService.getAllMemberMobile();
|
||||
smsUtil.sendBatchSms(smsReachDTO.getSignName(), list, smsReachDTO.getMessageCode());
|
||||
//判断为发送部分用户
|
||||
} else {
|
||||
|
@ -195,14 +195,6 @@ public interface GoodsSkuService extends IService<GoodsSku> {
|
||||
*/
|
||||
void updateGoodsSkuCommentNum(String skuId);
|
||||
|
||||
/**
|
||||
* 更新商品sku促销价格
|
||||
*
|
||||
* @param skuId skuId
|
||||
* @param promotionPrice 促销价格
|
||||
*/
|
||||
void updateGoodsSkuPromotion(String skuId, Double promotionPrice);
|
||||
|
||||
/**
|
||||
* 根据商品id获取全部skuId的集合
|
||||
*
|
||||
|
@ -28,7 +28,7 @@ import cn.lili.modules.goods.service.GoodsGalleryService;
|
||||
import cn.lili.modules.goods.service.GoodsService;
|
||||
import cn.lili.modules.goods.service.GoodsSkuService;
|
||||
import cn.lili.modules.member.entity.dos.FootPrint;
|
||||
import cn.lili.modules.member.entity.dos.MemberEvaluation;
|
||||
import cn.lili.modules.member.entity.dto.EvaluationQueryParams;
|
||||
import cn.lili.modules.member.entity.enums.EvaluationGradeEnum;
|
||||
import cn.lili.modules.member.service.MemberEvaluationService;
|
||||
import cn.lili.modules.promotion.entity.dos.PromotionGoods;
|
||||
@ -251,11 +251,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
//获取当前商品的索引信息
|
||||
EsGoodsIndex goodsIndex = goodsIndexService.findById(skuId);
|
||||
if (goodsIndex == null) {
|
||||
goodsIndex = goodsIndexService.getTempEsGoodsIndex(goodsSku, goodsVO.getGoodsParamsDTOList());
|
||||
|
||||
//发送mq消息
|
||||
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.RESET_GOODS_INDEX.name();
|
||||
rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(Collections.singletonList(goodsIndex)), RocketmqSendCallbackBuilder.commonCallback());
|
||||
goodsIndex = goodsIndexService.getResetEsGoodsIndex(goodsSku, goodsVO.getGoodsParamsDTOList());
|
||||
}
|
||||
|
||||
//商品规格
|
||||
@ -503,12 +499,11 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
//获取商品信息
|
||||
GoodsSku goodsSku = this.getGoodsSkuByIdFromCache(skuId);
|
||||
|
||||
LambdaQueryWrapper<MemberEvaluation> goodEvaluationQueryWrapper = new LambdaQueryWrapper<>();
|
||||
goodEvaluationQueryWrapper.eq(MemberEvaluation::getSkuId, goodsSku.getId());
|
||||
goodEvaluationQueryWrapper.eq(MemberEvaluation::getGrade, EvaluationGradeEnum.GOOD.name());
|
||||
|
||||
EvaluationQueryParams queryParams = new EvaluationQueryParams();
|
||||
queryParams.setGrade(EvaluationGradeEnum.GOOD.name());
|
||||
queryParams.setSkuId(goodsSku.getId());
|
||||
//好评数量
|
||||
long highPraiseNum = memberEvaluationService.count(goodEvaluationQueryWrapper);
|
||||
long highPraiseNum = memberEvaluationService.getEvaluationCount(queryParams);
|
||||
|
||||
//更新商品评价数量
|
||||
goodsSku.setCommentNum(goodsSku.getCommentNum() != null ? goodsSku.getCommentNum() + 1 : 1);
|
||||
@ -532,22 +527,6 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
goodsService.updateGoodsCommentNum(goodsSku.getGoodsId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新商品sku促销价格
|
||||
*
|
||||
* @param skuId skuId
|
||||
* @param promotionPrice 促销价格
|
||||
*/
|
||||
@Override
|
||||
public void updateGoodsSkuPromotion(String skuId, Double promotionPrice) {
|
||||
LambdaUpdateWrapper<GoodsSku> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(GoodsSku::getId, skuId);
|
||||
updateWrapper.set(GoodsSku::getPromotionPrice, promotionPrice);
|
||||
updateWrapper.set(GoodsSku::getPromotionFlag, true);
|
||||
this.update(updateWrapper);
|
||||
cache.remove(GoodsSkuService.getCacheKeys(skuId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据商品id获取全部skuId的集合
|
||||
*
|
||||
|
@ -1,12 +1,11 @@
|
||||
package cn.lili.modules.member.entity.dto;
|
||||
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 评价查询条件
|
||||
@ -14,13 +13,19 @@ import lombok.Data;
|
||||
* @author Bulbasaur
|
||||
* @since 2020/11/30 14:52
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class EvaluationQueryParams extends PageVO {
|
||||
|
||||
@ApiModelProperty(value = "ID")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "买家ID")
|
||||
private String memberId;
|
||||
|
||||
@ApiModelProperty(value = "skuID")
|
||||
private String skuId;
|
||||
|
||||
@ApiModelProperty(value = "会员名称")
|
||||
private String memberName;
|
||||
|
||||
@ -51,40 +56,42 @@ public class EvaluationQueryParams extends PageVO {
|
||||
@ApiModelProperty(value = "状态")
|
||||
private String status;
|
||||
|
||||
public EvaluationQueryParams() {
|
||||
|
||||
}
|
||||
|
||||
public <T> QueryWrapper<T> queryWrapper() {
|
||||
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
|
||||
if (StringUtils.isNotEmpty(startTime) && StringUtils.isNotEmpty(endTime)) {
|
||||
if (CharSequenceUtil.isNotEmpty(id)) {
|
||||
queryWrapper.eq("id", id);
|
||||
}
|
||||
if (CharSequenceUtil.isNotEmpty(startTime) && CharSequenceUtil.isNotEmpty(endTime)) {
|
||||
queryWrapper.between("create_time", startTime, endTime);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(grade)) {
|
||||
if (CharSequenceUtil.isNotEmpty(grade)) {
|
||||
queryWrapper.eq("grade", grade);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(goodsName)) {
|
||||
if (CharSequenceUtil.isNotEmpty(goodsName)) {
|
||||
queryWrapper.like("goods_name", goodsName);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(storeName)) {
|
||||
if (CharSequenceUtil.isNotEmpty(storeName)) {
|
||||
queryWrapper.like("store_name", storeName);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(memberName)) {
|
||||
if (CharSequenceUtil.isNotEmpty(memberName)) {
|
||||
queryWrapper.like("member_name", memberName);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(goodsId)) {
|
||||
if (CharSequenceUtil.isNotEmpty(goodsId)) {
|
||||
queryWrapper.eq("goods_id", goodsId);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(storeId)) {
|
||||
if (CharSequenceUtil.isNotEmpty(skuId)) {
|
||||
queryWrapper.eq("sku_id", skuId);
|
||||
}
|
||||
if (CharSequenceUtil.isNotEmpty(storeId)) {
|
||||
queryWrapper.eq("store_id", storeId);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(memberId)) {
|
||||
if (CharSequenceUtil.isNotEmpty(memberId)) {
|
||||
queryWrapper.eq("member_id", memberId);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(haveImage)) {
|
||||
if (CharSequenceUtil.isNotEmpty(haveImage)) {
|
||||
queryWrapper.eq("have_image", haveImage);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(status)) {
|
||||
if (CharSequenceUtil.isNotEmpty(status)) {
|
||||
queryWrapper.eq("status", status);
|
||||
}
|
||||
queryWrapper.eq("delete_flag", false);
|
||||
|
@ -88,5 +88,26 @@ public interface MemberEvaluationService extends IService<MemberEvaluation> {
|
||||
*/
|
||||
EvaluationNumberVO getEvaluationNumber(String goodsId);
|
||||
|
||||
/**
|
||||
* 获取今天新增的评价数量
|
||||
*
|
||||
* @return 今日评价数量
|
||||
*/
|
||||
long todayMemberEvaluation();
|
||||
|
||||
/**
|
||||
* 获取等待回复评价数量
|
||||
*
|
||||
* @return 等待回复评价数量
|
||||
*/
|
||||
long getWaitReplyNum();
|
||||
|
||||
/**
|
||||
* 统计商品评价数量
|
||||
*
|
||||
* @param evaluationQueryParams 查询条件
|
||||
* @return 商品评价数量
|
||||
*/
|
||||
long getEvaluationCount(EvaluationQueryParams evaluationQueryParams);
|
||||
|
||||
}
|
@ -220,4 +220,11 @@ public interface MemberService extends IService<Member> {
|
||||
* @param userEnums token角色类型
|
||||
*/
|
||||
void logout(UserEnums userEnums);
|
||||
|
||||
/**
|
||||
* 获取所有会员的手机号
|
||||
*
|
||||
* @return 所有会员的手机号
|
||||
*/
|
||||
List<String> getAllMemberMobile();
|
||||
}
|
@ -1,11 +1,15 @@
|
||||
package cn.lili.modules.member.serviceimpl;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.enums.SwitchEnum;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.properties.RocketmqCustomProperties;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.common.sensitive.SensitiveWordsFilter;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.modules.goods.entity.dos.GoodsSku;
|
||||
@ -29,6 +33,7 @@ import cn.lili.modules.order.order.service.OrderService;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
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 com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
@ -191,6 +196,31 @@ public class MemberEvaluationServiceImpl extends ServiceImpl<MemberEvaluationMap
|
||||
return evaluationNumberVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long todayMemberEvaluation() {
|
||||
return this.count(new LambdaQueryWrapper<MemberEvaluation>().ge(MemberEvaluation::getCreateTime, DateUtil.beginOfDay(new DateTime())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getWaitReplyNum() {
|
||||
QueryWrapper<MemberEvaluation> queryWrapper = Wrappers.query();
|
||||
queryWrapper.eq(CharSequenceUtil.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.STORE.name()),
|
||||
"store_id", UserContext.getCurrentUser().getStoreId());
|
||||
queryWrapper.eq("reply_status", false);
|
||||
return this.count(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计商品评价数量
|
||||
*
|
||||
* @param evaluationQueryParams 查询条件
|
||||
* @return 商品评价数量
|
||||
*/
|
||||
@Override
|
||||
public long getEvaluationCount(EvaluationQueryParams evaluationQueryParams) {
|
||||
return this.count(evaluationQueryParams.queryWrapper());
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测会员评价
|
||||
*
|
||||
|
@ -582,6 +582,16 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有会员的手机号
|
||||
*
|
||||
* @return 所有会员的手机号
|
||||
*/
|
||||
@Override
|
||||
public List<String> getAllMemberMobile() {
|
||||
return this.baseMapper.getAllMemberMobile();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测会员
|
||||
*
|
||||
|
@ -2,7 +2,6 @@ package cn.lili.modules.order.cart.render.impl;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.common.enums.PromotionTypeEnum;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.utils.CurrencyUtil;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.modules.order.cart.entity.dto.MemberCouponDTO;
|
||||
@ -13,11 +12,8 @@ import cn.lili.modules.order.cart.render.CartRenderStep;
|
||||
import cn.lili.modules.order.cart.render.util.PromotionPriceUtil;
|
||||
import cn.lili.modules.order.order.entity.dto.PriceDetailDTO;
|
||||
import cn.lili.modules.promotion.entity.dos.MemberCoupon;
|
||||
import cn.lili.modules.promotion.entity.dto.search.MemberCouponSearchParams;
|
||||
import cn.lili.modules.promotion.entity.enums.CouponTypeEnum;
|
||||
import cn.lili.modules.promotion.entity.enums.MemberCouponStatusEnum;
|
||||
import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum;
|
||||
import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum;
|
||||
import cn.lili.modules.promotion.entity.vos.MemberCouponVO;
|
||||
import cn.lili.modules.promotion.service.MemberCouponService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -64,11 +60,7 @@ public class CouponRender implements CartRenderStep {
|
||||
* @param tradeDTO 交易dto
|
||||
*/
|
||||
private void renderCouponRule(TradeDTO tradeDTO) {
|
||||
MemberCouponSearchParams searchParams = new MemberCouponSearchParams();
|
||||
searchParams.setMemberId(UserContext.getCurrentUser().getId());
|
||||
searchParams.setMemberCouponStatus(MemberCouponStatusEnum.NEW.name());
|
||||
searchParams.setPromotionStatus(PromotionsStatusEnum.START.name());
|
||||
List<MemberCoupon> memberCouponList = memberCouponService.getMemberCoupons(searchParams);
|
||||
List<MemberCoupon> memberCouponList = memberCouponService.getMemberCoupons(tradeDTO.getMemberId());
|
||||
|
||||
if (!memberCouponList.isEmpty()) {
|
||||
this.checkMemberExistCoupon(tradeDTO, memberCouponList);
|
||||
|
@ -7,7 +7,6 @@ import cn.lili.cache.Cache;
|
||||
import cn.lili.common.enums.PromotionTypeEnum;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.properties.RocketmqCustomProperties;
|
||||
import cn.lili.common.security.AuthUser;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.utils.CurrencyUtil;
|
||||
@ -35,6 +34,7 @@ import cn.lili.modules.promotion.entity.dos.KanjiaActivity;
|
||||
import cn.lili.modules.promotion.entity.dos.MemberCoupon;
|
||||
import cn.lili.modules.promotion.entity.dos.PromotionGoods;
|
||||
import cn.lili.modules.promotion.entity.dto.search.KanjiaActivitySearchParams;
|
||||
import cn.lili.modules.promotion.entity.dto.search.MemberCouponSearchParams;
|
||||
import cn.lili.modules.promotion.entity.dto.search.PromotionGoodsSearchParams;
|
||||
import cn.lili.modules.promotion.entity.enums.KanJiaStatusEnum;
|
||||
import cn.lili.modules.promotion.entity.enums.MemberCouponStatusEnum;
|
||||
@ -47,11 +47,7 @@ import cn.lili.modules.promotion.service.PromotionGoodsService;
|
||||
import cn.lili.modules.search.entity.dos.EsGoodsIndex;
|
||||
import cn.lili.modules.search.service.EsGoodsIndexService;
|
||||
import cn.lili.modules.search.service.EsGoodsSearchService;
|
||||
import cn.lili.rocketmq.RocketmqSendCallbackBuilder;
|
||||
import cn.lili.rocketmq.tags.GoodsTagsEnum;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -115,16 +111,6 @@ public class CartServiceImpl implements CartService {
|
||||
*/
|
||||
@Autowired
|
||||
private KanjiaActivityService kanjiaActivityService;
|
||||
/**
|
||||
* rocketMq
|
||||
*/
|
||||
@Autowired
|
||||
private RocketMQTemplate rocketMQTemplate;
|
||||
/**
|
||||
* rocketMq配置
|
||||
*/
|
||||
@Autowired
|
||||
private RocketmqCustomProperties rocketmqCustomProperties;
|
||||
/**
|
||||
* 交易
|
||||
*/
|
||||
@ -516,12 +502,11 @@ public class CartServiceImpl implements CartService {
|
||||
CartTypeEnum cartTypeEnum = getCartType(way);
|
||||
TradeDTO tradeDTO = this.readDTO(cartTypeEnum);
|
||||
|
||||
MemberCoupon memberCoupon =
|
||||
memberCouponService.getOne(
|
||||
new LambdaQueryWrapper<MemberCoupon>()
|
||||
.eq(MemberCoupon::getMemberCouponStatus, MemberCouponStatusEnum.NEW.name())
|
||||
.eq(MemberCoupon::getMemberId, currentUser.getId())
|
||||
.eq(MemberCoupon::getId, couponId));
|
||||
MemberCouponSearchParams searchParams = new MemberCouponSearchParams();
|
||||
searchParams.setMemberCouponStatus(MemberCouponStatusEnum.NEW.name());
|
||||
searchParams.setMemberId(currentUser.getId());
|
||||
searchParams.setId(couponId);
|
||||
MemberCoupon memberCoupon = memberCouponService.getMemberCoupon(searchParams);
|
||||
if (memberCoupon == null) {
|
||||
throw new ServiceException(ResultCode.COUPON_EXPIRED);
|
||||
}
|
||||
@ -565,11 +550,7 @@ public class CartServiceImpl implements CartService {
|
||||
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());
|
||||
goodsIndex = goodsIndexService.getResetEsGoodsIndex(dataSku, goodsVO.getGoodsParamsDTOList());
|
||||
}
|
||||
if (goodsIndex.getPromotionMap() != null && !goodsIndex.getPromotionMap().isEmpty()) {
|
||||
if (goodsIndex.getPromotionMap().keySet().stream().anyMatch(i -> i.contains(PromotionTypeEnum.SECKILL.name())) ||
|
||||
@ -695,7 +676,7 @@ public class CartServiceImpl implements CartService {
|
||||
return cartSkuVOS.stream().filter(i -> i.getGoodsSku().getCategoryPath().indexOf("," + memberCoupon.getScopeId() + ",") <= 0).collect(Collectors.toList());
|
||||
} else if (memberCoupon.getScopeType().equals(PromotionsScopeTypeEnum.PORTION_GOODS.name())) {
|
||||
//范围关联ID是否包含
|
||||
return cartSkuVOS.stream().filter(i -> memberCoupon.getScopeId().indexOf("," + i.getGoodsSku().getId() + ",") <= 0).collect(Collectors.toList());
|
||||
return cartSkuVOS.stream().filter(i -> CharSequenceUtil.contains(memberCoupon.getScopeId(), i.getGoodsSku().getId())).collect(Collectors.toList());
|
||||
} else if (memberCoupon.getScopeType().equals(PromotionsScopeTypeEnum.PORTION_SHOP_CATEGORY.name())) {
|
||||
//店铺分类路径是否包含
|
||||
return cartSkuVOS.stream().filter(i -> i.getGoodsSku().getStoreCategoryPath().indexOf("," + memberCoupon.getScopeId() + ",") <= 0).collect(Collectors.toList());
|
||||
|
File diff suppressed because one or more lines are too long
@ -3,7 +3,6 @@ package cn.lili.modules.promotion.service;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.modules.promotion.entity.dos.MemberCoupon;
|
||||
import cn.lili.modules.promotion.entity.dto.search.MemberCouponSearchParams;
|
||||
import cn.lili.modules.promotion.entity.enums.MemberCouponStatusEnum;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
@ -55,12 +54,19 @@ public interface MemberCouponService extends IService<MemberCoupon> {
|
||||
/**
|
||||
* 获取会员优惠券列表
|
||||
*
|
||||
* @param pageVo 分页参数
|
||||
* @param param 查询参数
|
||||
* @return 会员优惠券列表
|
||||
*/
|
||||
List<MemberCoupon> getMemberCoupons(MemberCouponSearchParams param);
|
||||
|
||||
/**
|
||||
* 获取当前用户的优惠券列表(优先读取缓存)
|
||||
*
|
||||
* @param memberId 会员id
|
||||
* @return 会员优惠券列表
|
||||
*/
|
||||
List<MemberCoupon> getMemberCoupons(String memberId);
|
||||
|
||||
/**
|
||||
* 获取会员优惠券列表
|
||||
*
|
||||
@ -90,6 +96,14 @@ public interface MemberCouponService extends IService<MemberCoupon> {
|
||||
*/
|
||||
List<MemberCoupon> getAllScopeMemberCoupon(String memberId, List<String> storeId);
|
||||
|
||||
/**
|
||||
* 获取会员优惠券
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return 会员优惠券列表
|
||||
*/
|
||||
MemberCoupon getMemberCoupon(MemberCouponSearchParams param);
|
||||
|
||||
/**
|
||||
* 获取会员优惠券数量
|
||||
*
|
||||
@ -97,27 +111,19 @@ public interface MemberCouponService extends IService<MemberCoupon> {
|
||||
*/
|
||||
long getMemberCouponsNum();
|
||||
|
||||
/**
|
||||
* 更新会员优惠券状态
|
||||
*
|
||||
* @param status 要变更的状态
|
||||
* @param id 会员优惠券id
|
||||
*/
|
||||
void updateMemberCouponStatus(MemberCouponStatusEnum status, String id);
|
||||
|
||||
/**
|
||||
* 使用优惠券
|
||||
*
|
||||
* @param ids 会员优惠券id
|
||||
*/
|
||||
void used(List<String> ids);
|
||||
void used(String memberId, List<String> ids);
|
||||
|
||||
/**
|
||||
* 作废当前会员优惠券
|
||||
*
|
||||
* @param id id
|
||||
*/
|
||||
void cancellation(String id);
|
||||
void cancellation(String memberId, String id);
|
||||
|
||||
/**
|
||||
* 关闭会员优惠券
|
||||
|
@ -1,7 +1,5 @@
|
||||
package cn.lili.modules.promotion.service;
|
||||
|
||||
import cn.lili.modules.search.entity.dos.EsGoodsIndex;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -22,9 +20,10 @@ public interface PromotionService {
|
||||
/**
|
||||
* 根据商品索引获取当前商品索引的所有促销活动信息
|
||||
*
|
||||
* @param index 商品索引
|
||||
* @param storeId 店铺id
|
||||
* @param goodsSkuId 商品skuId
|
||||
* @return 当前促销活动集合
|
||||
*/
|
||||
Map<String, Object> getGoodsPromotionMap(EsGoodsIndex index);
|
||||
Map<String, Object> getGoodsSkuPromotionMap(String storeId, String goodsSkuId);
|
||||
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package cn.lili.modules.promotion.serviceimpl;
|
||||
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.security.AuthUser;
|
||||
@ -24,6 +25,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@ -37,6 +41,7 @@ import java.util.*;
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@CacheConfig(cacheNames = "{MemberCoupon}")
|
||||
public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper, MemberCoupon> implements MemberCouponService {
|
||||
|
||||
/**
|
||||
@ -45,6 +50,12 @@ public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper, Mem
|
||||
@Autowired
|
||||
private CouponService couponService;
|
||||
|
||||
/**
|
||||
* 缓存
|
||||
*/
|
||||
@Autowired
|
||||
private Cache cache;
|
||||
|
||||
@Override
|
||||
public void checkCouponLimit(String couponId, String memberId) {
|
||||
Coupon coupon = couponService.getById(couponId);
|
||||
@ -71,6 +82,7 @@ public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper, Mem
|
||||
* @param memberName 会员名称
|
||||
*/
|
||||
@Override
|
||||
@CacheEvict(key = "#memberId")
|
||||
public void receiveBuyerCoupon(String couponId, String memberId, String memberName) {
|
||||
Coupon coupon = couponService.getById(couponId);
|
||||
if (coupon != null && !CouponGetEnum.FREE.name().equals(coupon.getGetType())) {
|
||||
@ -82,6 +94,7 @@ public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper, Mem
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(key = "#memberId")
|
||||
public void receiveCoupon(String couponId, String memberId, String memberName) {
|
||||
Coupon coupon = couponService.getById(couponId);
|
||||
if (coupon != null) {
|
||||
@ -108,6 +121,22 @@ public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper, Mem
|
||||
return this.list(param.queryWrapper());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户的优惠券列表(优先读取缓存)
|
||||
*
|
||||
* @param memberId 会员id
|
||||
* @return 会员优惠券列表
|
||||
*/
|
||||
@Override
|
||||
@Cacheable(key = "#memberId")
|
||||
public List<MemberCoupon> getMemberCoupons(String memberId) {
|
||||
MemberCouponSearchParams searchParams = new MemberCouponSearchParams();
|
||||
searchParams.setMemberId(Objects.requireNonNull(UserContext.getCurrentUser()).getId());
|
||||
searchParams.setMemberCouponStatus(MemberCouponStatusEnum.NEW.name());
|
||||
searchParams.setPromotionStatus(PromotionsStatusEnum.START.name());
|
||||
return this.getMemberCoupons(searchParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员优惠券列表
|
||||
*
|
||||
@ -167,6 +196,17 @@ public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper, Mem
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前会员全品类优惠券
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return 会员优惠券列表
|
||||
*/
|
||||
@Override
|
||||
public MemberCoupon getMemberCoupon(MemberCouponSearchParams param) {
|
||||
return this.getOne(param.queryWrapper(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMemberCouponsNum() {
|
||||
AuthUser authUser = Objects.requireNonNull(UserContext.getCurrentUser());
|
||||
@ -177,31 +217,10 @@ public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper, Mem
|
||||
return this.count(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新会员优惠券状态
|
||||
*
|
||||
* @param status 要变更的状态
|
||||
* @param id 会员优惠券id
|
||||
*/
|
||||
@Override
|
||||
public void updateMemberCouponStatus(MemberCouponStatusEnum status, String id) {
|
||||
MemberCoupon memberCoupon = this.getById(id);
|
||||
if (memberCoupon == null) {
|
||||
throw new ServiceException(ResultCode.COUPON_MEMBER_NOT_EXIST);
|
||||
}
|
||||
String memberCouponStatus = memberCoupon.getMemberCouponStatus();
|
||||
if (memberCouponStatus.equals(MemberCouponStatusEnum.NEW.name()) || memberCouponStatus.equals(MemberCouponStatusEnum.USED.name())) {
|
||||
LambdaUpdateWrapper<MemberCoupon> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(MemberCoupon::getId, id).set(MemberCoupon::getMemberCouponStatus, status.name());
|
||||
this.update(updateWrapper);
|
||||
} else {
|
||||
throw new ServiceException(ResultCode.COUPON_MEMBER_STATUS_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void used(List<String> ids) {
|
||||
@CacheEvict(key = "#memberId")
|
||||
public void used(String memberId, List<String> ids) {
|
||||
if (ids != null && !ids.isEmpty()) {
|
||||
List<MemberCoupon> memberCoupons = this.listByIds(ids);
|
||||
|
||||
@ -228,7 +247,8 @@ public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper, Mem
|
||||
* @param id id
|
||||
*/
|
||||
@Override
|
||||
public void cancellation(String id) {
|
||||
@CacheEvict(key = "#memberId")
|
||||
public void cancellation(String memberId, String id) {
|
||||
LambdaUpdateWrapper<MemberCoupon> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(MemberCoupon::getId, id);
|
||||
updateWrapper.set(MemberCoupon::getMemberCouponStatus, MemberCouponStatusEnum.CLOSED.name());
|
||||
@ -245,6 +265,7 @@ public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper, Mem
|
||||
LambdaUpdateWrapper<MemberCoupon> memberCouponLambdaUpdateWrapper = new LambdaUpdateWrapper<MemberCoupon>()
|
||||
.in(MemberCoupon::getCouponId, couponIds)
|
||||
.set(MemberCoupon::getMemberCouponStatus, MemberCouponStatusEnum.CLOSED.name());
|
||||
this.cache.vagueDel("{MemberCoupon}");
|
||||
this.update(memberCouponLambdaUpdateWrapper);
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,6 @@ import cn.lili.modules.promotion.entity.dto.search.SeckillSearchParams;
|
||||
import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum;
|
||||
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;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -108,14 +107,14 @@ public class PromotionServiceImpl implements PromotionService {
|
||||
/**
|
||||
* 根据商品索引获取当前商品索引的所有促销活动信息
|
||||
*
|
||||
* @param index 商品索引
|
||||
* @param storeId 店铺id
|
||||
* @param goodsSkuId 商品skuId
|
||||
* @return 当前促销活动集合
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> getGoodsPromotionMap(EsGoodsIndex index) {
|
||||
String storeIds = index.getStoreId() + "," + PromotionTools.PLATFORM_ID;
|
||||
public Map<String, Object> getGoodsSkuPromotionMap(String storeId, String goodsSkuId) {
|
||||
String storeIds = storeId + "," + PromotionTools.PLATFORM_ID;
|
||||
Map<String, Object> promotionMap = new HashMap<>();
|
||||
List<PromotionGoods> promotionGoodsList = promotionGoodsService.findSkuValidPromotion(index.getId(), storeIds);
|
||||
List<PromotionGoods> promotionGoodsList = promotionGoodsService.findSkuValidPromotion(goodsSkuId, storeIds);
|
||||
for (PromotionGoods promotionGoods : promotionGoodsList) {
|
||||
String esPromotionKey = promotionGoods.getPromotionType() + "-" + promotionGoods.getPromotionId();
|
||||
switch (PromotionTypeEnum.valueOf(promotionGoods.getPromotionType())) {
|
||||
@ -132,7 +131,7 @@ public class PromotionServiceImpl implements PromotionService {
|
||||
promotionMap.put(esPromotionKey, fullDiscount);
|
||||
break;
|
||||
case SECKILL:
|
||||
this.getGoodsCurrentSeckill(promotionGoods, promotionMap, index);
|
||||
this.getGoodsCurrentSeckill(promotionGoods, promotionMap);
|
||||
break;
|
||||
case POINTS_GOODS:
|
||||
PointsGoods pointsGoods = pointsGoodsService.getById(promotionGoods.getPromotionId());
|
||||
@ -146,7 +145,7 @@ public class PromotionServiceImpl implements PromotionService {
|
||||
}
|
||||
|
||||
|
||||
private void getGoodsCurrentSeckill(PromotionGoods promotionGoods, Map<String, Object> promotionMap, EsGoodsIndex index) {
|
||||
private void getGoodsCurrentSeckill(PromotionGoods promotionGoods, Map<String, Object> promotionMap) {
|
||||
Seckill seckill = seckillService.getById(promotionGoods.getPromotionId());
|
||||
SeckillSearchParams searchParams = new SeckillSearchParams();
|
||||
searchParams.setSeckillId(promotionGoods.getPromotionId());
|
||||
|
@ -178,11 +178,11 @@ public interface EsGoodsIndexService {
|
||||
List<String> getPromotionIdByPromotionType(String id, PromotionTypeEnum promotionTypeEnum);
|
||||
|
||||
/**
|
||||
* 获取临时拼装的商品索引
|
||||
* 获取重置的商品索引
|
||||
*
|
||||
* @param goodsSku 商品sku信息
|
||||
* @param goodsParamDTOS 商品参数
|
||||
* @return 商品索引
|
||||
*/
|
||||
EsGoodsIndex getTempEsGoodsIndex(GoodsSku goodsSku, List<GoodsParamsDTO> goodsParamDTOS);
|
||||
EsGoodsIndex getResetEsGoodsIndex(GoodsSku goodsSku, List<GoodsParamsDTO> goodsParamDTOS);
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import cn.lili.cache.CachePrefix;
|
||||
import cn.lili.common.enums.PromotionTypeEnum;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.properties.RocketmqCustomProperties;
|
||||
import cn.lili.elasticsearch.BaseElasticsearchService;
|
||||
import cn.lili.elasticsearch.EsSuffix;
|
||||
import cn.lili.elasticsearch.config.ElasticsearchProperties;
|
||||
@ -32,8 +33,11 @@ import cn.lili.modules.search.entity.dto.EsGoodsSearchDTO;
|
||||
import cn.lili.modules.search.repository.EsGoodsIndexRepository;
|
||||
import cn.lili.modules.search.service.EsGoodsIndexService;
|
||||
import cn.lili.modules.search.service.EsGoodsSearchService;
|
||||
import cn.lili.rocketmq.RocketmqSendCallbackBuilder;
|
||||
import cn.lili.rocketmq.tags.GoodsTagsEnum;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
||||
import org.assertj.core.util.IterableUtil;
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.bulk.BulkRequest;
|
||||
@ -102,7 +106,16 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
private StoreGoodsLabelService storeGoodsLabelService;
|
||||
@Autowired
|
||||
private Cache<Object> cache;
|
||||
|
||||
/**
|
||||
* rocketMq
|
||||
*/
|
||||
@Autowired
|
||||
private RocketMQTemplate rocketMQTemplate;
|
||||
/**
|
||||
* rocketMq配置
|
||||
*/
|
||||
@Autowired
|
||||
private RocketmqCustomProperties rocketmqCustomProperties;
|
||||
@Autowired
|
||||
@Qualifier("elasticsearchRestTemplate")
|
||||
private ElasticsearchRestTemplate restTemplate;
|
||||
@ -587,19 +600,23 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取临时拼装的商品索引
|
||||
* 获取重置的商品索引
|
||||
*
|
||||
* @param goodsSku 商品sku信息
|
||||
* @param goodsParamDTOS 商品参数
|
||||
* @return 商品索引
|
||||
*/
|
||||
@Override
|
||||
public EsGoodsIndex getTempEsGoodsIndex(GoodsSku goodsSku, List<GoodsParamsDTO> goodsParamDTOS) {
|
||||
public EsGoodsIndex getResetEsGoodsIndex(GoodsSku goodsSku, List<GoodsParamsDTO> goodsParamDTOS) {
|
||||
EsGoodsIndex index = new EsGoodsIndex(goodsSku, goodsParamDTOS);
|
||||
//获取活动信息
|
||||
Map<String, Object> goodsCurrentPromotionMap = promotionService.getGoodsPromotionMap(index);
|
||||
Map<String, Object> goodsCurrentPromotionMap = promotionService.getGoodsSkuPromotionMap(index.getStoreId(), index.getId());
|
||||
//写入促销信息
|
||||
index.setPromotionMapJson(JSONUtil.toJsonStr(goodsCurrentPromotionMap));
|
||||
|
||||
//发送mq消息
|
||||
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.RESET_GOODS_INDEX.name();
|
||||
rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(Collections.singletonList(index)), RocketmqSendCallbackBuilder.commonCallback());
|
||||
return index;
|
||||
}
|
||||
|
||||
@ -756,7 +773,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
}
|
||||
}
|
||||
//促销索引
|
||||
Map<String, Object> goodsCurrentPromotionMap = promotionService.getGoodsPromotionMap(index);
|
||||
Map<String, Object> goodsCurrentPromotionMap = promotionService.getGoodsSkuPromotionMap(index.getStoreId(), index.getId());
|
||||
index.setPromotionMapJson(JSONUtil.toJsonStr(goodsCurrentPromotionMap));
|
||||
return index;
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 管理端,优惠券接口
|
||||
@ -91,7 +92,8 @@ public class CouponManagerController {
|
||||
@ApiOperation(value = "会员优惠券作废")
|
||||
@PutMapping(value = "/member/cancellation/{id}")
|
||||
public ResultMessage<Object> cancellation(@PathVariable String id) {
|
||||
memberCouponService.cancellation(id);
|
||||
AuthUser currentUser = Objects.requireNonNull(UserContext.getCurrentUser());
|
||||
memberCouponService.cancellation(currentUser.getId(), id);
|
||||
return ResultUtil.success(ResultCode.COUPON_CANCELLATION_SUCCESS);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user