代码优化
This commit is contained in:
parent
1c28e0bd5f
commit
9e74c15413
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测会员
|
||||
*
|
||||
|
@ -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())) ||
|
||||
|
@ -96,6 +96,14 @@ public interface MemberCouponService extends IService<MemberCoupon> {
|
||||
*/
|
||||
List<MemberCoupon> getAllScopeMemberCoupon(String memberId, List<String> storeId);
|
||||
|
||||
/**
|
||||
* 获取会员优惠券
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return 会员优惠券列表
|
||||
*/
|
||||
MemberCoupon getMemberCoupon(MemberCouponSearchParams param);
|
||||
|
||||
/**
|
||||
* 获取会员优惠券数量
|
||||
*
|
||||
|
@ -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);
|
||||
|
||||
}
|
@ -196,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());
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user