From 074e4ed5b78f1477e62a8e8e530b92d3203dad41 Mon Sep 17 00:00:00 2001 From: misworga831 Date: Tue, 17 Oct 2023 08:26:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=95=86=E5=93=81=E7=B4=A2=E5=BC=95=E8=AF=84=E8=AE=BA,?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E5=AE=9E=E6=97=B6=E7=BB=9F=E8=AE=A1spu?= =?UTF-8?q?=E7=9A=84=E8=AF=84=E8=AE=BA=E6=80=BB=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/promotion/PromotionEverydayExecute.java | 1 + .../lili/modules/goods/service/GoodsService.java | 3 ++- .../goods/serviceimpl/GoodsServiceImpl.java | 7 ++++++- .../goods/serviceimpl/GoodsSkuServiceImpl.java | 15 +-------------- 4 files changed, 10 insertions(+), 16 deletions(-) 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 2e285823..a9fa7fcc 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 290f62c5..7f3c3536 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 bab43739..3119b1fc 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 6ace49da..c5e86f9b 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); }