From 1a221eefe340395758467bd641b6359c7c9cd94c Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 22 Jun 2022 18:42:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=95=86=E5=93=81=E7=B4=A2?= =?UTF-8?q?=E5=BC=95=EF=BC=8C=E5=A6=82=E6=95=B0=E6=8D=AE=E5=BA=93=E4=B8=AD?= =?UTF-8?q?=E6=97=A0=E5=BD=93=E5=89=8D=E5=95=86=E5=93=81=E5=88=99=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=95=86=E5=93=81=E7=B4=A2=E5=BC=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/cn/lili/listener/GoodsMessageListener.java | 9 ++------- .../modules/goods/serviceimpl/GoodsSkuServiceImpl.java | 5 +++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java index f8f8a35e..82df940e 100644 --- a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java +++ b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java @@ -32,7 +32,6 @@ 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; import cn.lili.rocketmq.tags.GoodsTagsEnum; import lombok.extern.slf4j.Slf4j; import org.apache.rocketmq.common.message.MessageExt; @@ -204,13 +203,8 @@ public class GoodsMessageListener implements RocketMQListener { try { String goodsIdsJsonStr = new String(messageExt.getBody()); for (String goodsId : JSONUtil.toList(goodsIdsJsonStr, String.class)) { - Goods goodsById = this.goodsService.getById(goodsId); - if (goodsById != null) { - this.deleteGoods(goodsById); - goodsIndexService.deleteIndex(MapUtil.builder(new HashMap()).put("goodsId", goodsId).build()); - } + goodsIndexService.deleteIndex(MapUtil.builder(new HashMap()).put("goodsId", goodsId).build()); } - } catch (Exception e) { log.error("删除商品索引事件执行异常,商品信息: " + new String(messageExt.getBody()), e); } @@ -451,6 +445,7 @@ public class GoodsMessageListener implements RocketMQListener { distributionGoodsService.removeById(distributionGoods.getId()); } } + /** * 商品购买完成 * 1.更新商品购买数量 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 94bec3dc..65baa2b9 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 @@ -250,11 +250,16 @@ public class GoodsSkuServiceImpl extends ServiceImpl i GoodsSku goodsSku = this.getGoodsSkuByIdFromCache(skuId); //如果使用商品ID无法查询SKU则返回错误 if (goodsVO == null || goodsSku == null) { + //发送mq消息 + String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GOODS_DELETE.name(); + rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(Collections.singletonList(goodsId)), RocketmqSendCallbackBuilder.commonCallback()); throw new ServiceException(ResultCode.GOODS_NOT_EXIST); } //商品下架||商品未审核通过||商品删除,则提示:商品已下架 if (GoodsStatusEnum.DOWN.name().equals(goodsVO.getMarketEnable()) || !GoodsAuthEnum.PASS.name().equals(goodsVO.getAuthFlag()) || Boolean.TRUE.equals(goodsVO.getDeleteFlag())) { + String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GOODS_DELETE.name(); + rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(Collections.singletonList(goodsId)), RocketmqSendCallbackBuilder.commonCallback()); throw new ServiceException(ResultCode.GOODS_NOT_EXIST); }