!166 修复商品编辑规格时,删除规格后。es中没有删除问题。

Merge pull request !166 from OceansDeep/feature/pg
This commit is contained in:
OceansDeep 2022-05-25 03:25:34 +00:00 committed by Gitee
commit 8596175f8e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -138,7 +138,7 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
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<MessageExt> {
if (goodsById != null) {
this.deleteGoods(goodsById);
this.updateGoodsNum(goodsById);
List<String> skuIdsByGoodsId = this.goodsSkuService.getSkuIdsByGoodsId(goodsId);
if (skuIdsByGoodsId != null && !skuIdsByGoodsId.isEmpty()) {
this.goodsIndexService.deleteIndexByIds(skuIdsByGoodsId);
}
goodsIndexService.deleteIndex(MapUtil.builder(new HashMap<String, Object>()).put("goodsId", goodsId).build());
}
}
@ -392,6 +389,7 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
esGoodsIndices.add(goodsIndex);
}
}
this.goodsIndexService.deleteIndex(MapUtil.builder(new HashMap<String, Object>()).put("goodsId", goods.getId()).build());
this.goodsIndexService.addIndex(esGoodsIndices);
}