优化商品索引,如数据库中无当前商品则删除商品索引
This commit is contained in:
@@ -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<MessageExt> {
|
||||
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<String, Object>()).put("goodsId", goodsId).build());
|
||||
}
|
||||
goodsIndexService.deleteIndex(MapUtil.builder(new HashMap<String, Object>()).put("goodsId", goodsId).build());
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("删除商品索引事件执行异常,商品信息: " + new String(messageExt.getBody()), e);
|
||||
}
|
||||
@@ -451,6 +445,7 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
|
||||
distributionGoodsService.removeById(distributionGoods.getId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品购买完成
|
||||
* 1.更新商品购买数量
|
||||
|
||||
Reference in New Issue
Block a user