diff --git a/consumer/src/main/java/cn/lili/timetask/handler/impl/promotion/PromotionEverydayExecute.java b/consumer/src/main/java/cn/lili/timetask/handler/impl/promotion/PromotionEverydayExecute.java index 2e285823b..a9fa7fcc1 100644 --- a/consumer/src/main/java/cn/lili/timetask/handler/impl/promotion/PromotionEverydayExecute.java +++ b/consumer/src/main/java/cn/lili/timetask/handler/impl/promotion/PromotionEverydayExecute.java @@ -72,6 +72,7 @@ public class PromotionEverydayExecute implements EveryDayExecute { log.info("生成秒杀活动设置:{}", seckillSetting); for (int i = 1; i <= SeckillService.PRE_CREATION; i++) { Seckill seckill = new Seckill(i, seckillSetting.getHours(), seckillSetting.getSeckillRule()); + seckill.setApplyEndTime(null); //如果已经存在促销,则不再次保存 if (seckillService.list( diff --git a/framework/src/main/java/cn/lili/modules/goods/service/GoodsService.java b/framework/src/main/java/cn/lili/modules/goods/service/GoodsService.java index 290f62c5f..7f3c3536d 100644 --- a/framework/src/main/java/cn/lili/modules/goods/service/GoodsService.java +++ b/framework/src/main/java/cn/lili/modules/goods/service/GoodsService.java @@ -161,8 +161,9 @@ public interface GoodsService extends IService { * 更新商品评价数量 * * @param goodsId 商品ID + * @param skuId skuID */ - void updateGoodsCommentNum(String goodsId); + void updateGoodsCommentNum(String goodsId, String skuId); /** * 更新商品的购买数量 diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java index bab43739b..3119b1fc9 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java @@ -1,6 +1,7 @@ package cn.lili.modules.goods.serviceimpl; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.map.MapUtil; import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.util.NumberUtil; import cn.hutool.json.JSONUtil; @@ -29,6 +30,7 @@ import cn.lili.modules.goods.service.*; 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.search.utils.EsIndexUtil; import cn.lili.modules.store.entity.dos.FreightTemplate; import cn.lili.modules.store.entity.dos.Store; import cn.lili.modules.store.entity.vos.StoreVO; @@ -442,7 +444,7 @@ public class GoodsServiceImpl extends ServiceImpl implements } @Override - public void updateGoodsCommentNum(String goodsId) { + public void updateGoodsCommentNum(String goodsId, String skuId) { //获取商品信息 Goods goods = this.getById(goodsId); @@ -459,6 +461,9 @@ public class GoodsServiceImpl extends ServiceImpl implements this.updateById(goods); cache.remove(CachePrefix.GOODS.getPrefix() + goodsId); + + Map updateIndexFieldsMap = EsIndexUtil.getUpdateIndexFieldsMap(MapUtil.builder(new HashMap()).put("id", skuId).build(), MapUtil.builder(new HashMap()).put("commentNum", goods.getCommentNum()).put("highPraiseNum", highPraiseNum).put("grade", grade).build()); + applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("更新商品索引信息", rocketmqCustomProperties.getGoodsTopic(), GoodsTagsEnum.UPDATE_GOODS_INDEX_FIELD.name(), JSONUtil.toJsonStr(updateIndexFieldsMap))); } /** diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java index 6ace49da8..c5e86f9bd 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java @@ -1,6 +1,5 @@ package cn.lili.modules.goods.serviceimpl; -import cn.hutool.core.map.MapUtil; import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.util.NumberUtil; import cn.hutool.json.JSONObject; @@ -49,7 +48,6 @@ import cn.lili.modules.promotion.service.MemberCouponService; 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.utils.EsIndexUtil; import cn.lili.mybatis.BaseEntity; import cn.lili.mybatis.util.PageUtil; import cn.lili.rocketmq.RocketmqSendCallbackBuilder; @@ -625,19 +623,8 @@ public class GoodsSkuServiceImpl extends ServiceImpl i //修改规格 this.updateGoodsSkuGrade(skuId, grade, goodsSku.getCommentNum()); - - //修改规格索引,发送mq消息 - Map updateIndexFieldsMap = - EsIndexUtil.getUpdateIndexFieldsMap(MapUtil.builder(new HashMap()).put("id", - goodsSku.getId()).build(), MapUtil.builder(new HashMap()).put("commentNum", - goodsSku.getCommentNum()).put("highPraiseNum", highPraiseNum).put("grade", grade).build()); - String destination = - rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.UPDATE_GOODS_INDEX_FIELD.name(); - rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(updateIndexFieldsMap), - RocketmqSendCallbackBuilder.commonCallback()); - //修改商品的评价数量 - goodsService.updateGoodsCommentNum(goodsSku.getGoodsId()); + goodsService.updateGoodsCommentNum(goodsSku.getGoodsId(), skuId); clearCache(skuId); }