diff --git a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java index 1f6a98bd..fac6d784 100644 --- a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java +++ b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java @@ -294,32 +294,9 @@ public class GoodsMessageListener implements RocketMQListener { * @param goodsList 商品列表消息 */ private void updateGoodsIndex(List goodsList) { - List goodsIndices = new ArrayList<>(); for (Goods goods : goodsList) { - //如果商品通过审核&&并且已上架 - GoodsSearchParams searchParams = new GoodsSearchParams(); - searchParams.setGoodsId(goods.getId()); - searchParams.setGeQuantity(0); - List goodsSkuList = this.goodsSkuService.getGoodsSkuByList(searchParams); - if (goods.getAuthFlag().equals(GoodsAuthEnum.PASS.name()) - && goods.getMarketEnable().equals(GoodsStatusEnum.UPPER.name()) - && Boolean.FALSE.equals(goods.getDeleteFlag())) { - goodsSkuList.forEach(goodsSku -> { - EsGoodsIndex goodsIndex = this.settingUpGoodsIndexData(goods, goodsSku); - goodsIndices.add(goodsIndex); - }); - } - //如果商品状态值不支持es搜索,那么将商品信息做下架处理 - else { - for (GoodsSku goodsSku : goodsSkuList) { - EsGoodsIndex esGoodsOld = goodsIndexService.findById(goodsSku.getId()); - if (esGoodsOld != null) { - goodsIndexService.deleteIndexById(goodsSku.getId()); - } - } - } + this.updateGoodsIndex(goods); } - goodsIndexService.addIndex(goodsIndices); }