修复商品索引参数问题

This commit is contained in:
paulGao
2021-06-22 00:07:33 +08:00
parent 337775013e
commit 41a86ff7dc
7 changed files with 73 additions and 58 deletions

View File

@@ -68,23 +68,14 @@ public class ElasticsearchController {
String goodsId = null;
//库存锁是在redis做的所以生成索引同时更新一下redis中的库存数量
for (GoodsSku goodsSku : list) {
boolean needIndex = false;
if (goodsId == null || !goodsId.equals(goodsSku.getGoodsId())) {
goodsId = goodsSku.getGoodsId();
Goods goods = goodsService.getById(goodsId);
EsGoodsIndex index = new EsGoodsIndex(goodsSku);
if (goods.getParams() != null && !goods.getParams().isEmpty()) {
List<GoodsParams> goodsParams = JSONUtil.toList(goods.getParams(), GoodsParams.class);
for (GoodsParams goodsParam : goodsParams) {
Parameters parameters = parametersService.getById(goodsParam.getParamId());
if (parameters.getIsIndex() == 1) {
needIndex = true;
break;
}
}
index = new EsGoodsIndex(goodsSku, goodsParams);
}
}
if (Boolean.TRUE.equals(needIndex)) {
EsGoodsIndex index = new EsGoodsIndex(goodsSku);
Map<String, Object> goodsCurrentPromotionMap = promotionService.getGoodsCurrentPromotionMap(index);
index.setPromotionMap(goodsCurrentPromotionMap);
esGoodsIndices.add(index);