From e9fdec6bb0872d0b57313e129200a56f011a9bbd Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 25 May 2022 11:22:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=95=86=E5=93=81=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E8=A7=84=E6=A0=BC=E6=97=B6=EF=BC=8C=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E8=A7=84=E6=A0=BC=E5=90=8E=E3=80=82es=E4=B8=AD=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E5=88=A0=E9=99=A4=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/cn/lili/listener/GoodsMessageListener.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java index 7e9b9aa3..ab19413d 100644 --- a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java +++ b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java @@ -138,7 +138,7 @@ public class GoodsMessageListener implements RocketMQListener { String goodsId = new String(messageExt.getBody()); log.info("生成索引: {}", goodsId); Goods goods = this.goodsService.getById(goodsId); - updateGoodsIndex(goods); + this.updateGoodsIndex(goods); } catch (Exception e) { log.error("生成商品索引事件执行异常,商品信息: " + new String(messageExt.getBody()), e); } @@ -214,10 +214,7 @@ public class GoodsMessageListener implements RocketMQListener { if (goodsById != null) { this.deleteGoods(goodsById); this.updateGoodsNum(goodsById); - List skuIdsByGoodsId = this.goodsSkuService.getSkuIdsByGoodsId(goodsId); - if (skuIdsByGoodsId != null && !skuIdsByGoodsId.isEmpty()) { - this.goodsIndexService.deleteIndexByIds(skuIdsByGoodsId); - } + goodsIndexService.deleteIndex(MapUtil.builder(new HashMap()).put("goodsId", goodsId).build()); } } @@ -392,6 +389,7 @@ public class GoodsMessageListener implements RocketMQListener { esGoodsIndices.add(goodsIndex); } } + this.goodsIndexService.deleteIndex(MapUtil.builder(new HashMap()).put("goodsId", goods.getId()).build()); this.goodsIndexService.addIndex(esGoodsIndices); }