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); }