fix: 优化生成es索引,只生成库存大于0的商品

This commit is contained in:
misworga831 2023-03-31 16:58:34 +08:00
parent 9f01078fe0
commit 4ebe0d4f43
2 changed files with 3 additions and 0 deletions

View File

@ -343,6 +343,7 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
searchParams.setGoodsId(goods.getId());
searchParams.setPageNumber(i);
searchParams.setPageSize(BATCH_SIZE);
searchParams.setGeQuantity(0);
IPage<GoodsSku> goodsSkuByPage = this.goodsSkuService.getGoodsSkuByPage(searchParams);
if (goodsSkuByPage == null || goodsSkuByPage.getRecords().isEmpty()) {
break;

View File

@ -167,6 +167,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
skuQueryWrapper.eq("gs.auth_flag", GoodsAuthEnum.PASS.name());
skuQueryWrapper.eq("gs.market_enable", GoodsStatusEnum.UPPER.name());
skuQueryWrapper.eq("gs.delete_flag", false);
skuQueryWrapper.ge("gs.quantity", 0);
Map<String, Long> resultMap = (Map<String, Long>) cache.get(CachePrefix.INIT_INDEX_PROCESS.getPrefix());
@ -176,6 +177,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
skuCountQueryWrapper.eq("auth_flag", GoodsAuthEnum.PASS.name());
skuCountQueryWrapper.eq("market_enable", GoodsStatusEnum.UPPER.name());
skuCountQueryWrapper.eq("delete_flag", false);
skuCountQueryWrapper.ge("gs.quantity", 0);
resultMap = new HashMap<>();
resultMap.put(KEY_SUCCESS, 0L);
resultMap.put(KEY_FAIL, 0L);