update framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java.
fix: 修复商品索引无效促销活动清理逻辑,方法(executeCleanInvalidPromotions) - 修复分页查询起始索引错误,从1改为0,避免跳过第一页数据 - 修复促销活动清洗后未同步更新到索引的问题,清洗后的promotionMap需重新序列化并设置回goodsIndex Signed-off-by: 羚羊跳 <zxc2399897@vip.qq.com>
This commit is contained in:
@@ -743,7 +743,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void executeCleanInvalidPromotions() {
|
private void executeCleanInvalidPromotions() {
|
||||||
for (int i = 1; ; i++) {
|
for (int i = 0; ; i++) {
|
||||||
org.springframework.data.domain.Page<EsGoodsIndex> all = goodsIndexRepository.findAll(PageRequest.of(i, 1000));
|
org.springframework.data.domain.Page<EsGoodsIndex> all = goodsIndexRepository.findAll(PageRequest.of(i, 1000));
|
||||||
if (all.isEmpty()) {
|
if (all.isEmpty()) {
|
||||||
break;
|
break;
|
||||||
@@ -758,6 +758,9 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
|||||||
BasePromotions promotion = promotionJson.toBean(BasePromotions.class);
|
BasePromotions promotion = promotionJson.toBean(BasePromotions.class);
|
||||||
return promotion.getEndTime() != null && promotion.getEndTime().getTime() < DateUtil.date().getTime();
|
return promotion.getEndTime() != null && promotion.getEndTime().getTime() < DateUtil.date().getTime();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 更新回 goodsIndex 对象
|
||||||
|
goodsIndex.setPromotionMapJson(JSONUtil.toJsonStr(promotionMap));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
goodsIndexRepository.saveAll(all);
|
goodsIndexRepository.saveAll(all);
|
||||||
|
|||||||
Reference in New Issue
Block a user