分类查询,不显示过期活动

This commit is contained in:
liyj 2025-11-17 17:52:20 +08:00
parent 33f83bc82d
commit 3d8a84126d

View File

@ -2060,7 +2060,11 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
}
}
List<ShopProductIndex> productIndexList = shopProductIndexService.gets(product_id_row);
//List<ShopProductIndex> productIndexList = shopProductIndexService.gets(product_id_row);
//过滤过期的活动商品 start
List<ShopProductIndex> productIndexList = filterEndActivity(product_id_row);
//过滤过期的活动商品 end
List<Map> product_index_rows = Convert.toList(Map.class, productIndexList);
List<Map> product_info_rows = Convert.toList(Map.class, shopProductInfoService.gets(product_id_row));
@ -6572,5 +6576,37 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
return data;
}
/**
* 过期活动不需要显示关键字
* @param product_id_row
* @return
*/
private List<ShopProductIndex> filterEndActivity(List<Long> product_id_row){
List<ShopProductIndex> productIndexList = shopProductIndexService.gets(product_id_row);
List<Long> hasActivityProductIds=productIndexList.stream().
filter(shopProductIndex -> com.suisung.mall.common.utils.StringUtils.isNotEmpty(shopProductIndex.getActivity_type_ids()))
.map(ShopProductIndex::getProduct_id )
.collect(Collectors.toList());
if(hasActivityProductIds.isEmpty()){
return productIndexList;
}
//过滤过期的活动商品 start
QueryWrapper<ShopStoreActivityItem> queryWrapper = new QueryWrapper<>();
List<Long> productIds=productIndexList.stream().map(ShopProductIndex::getProduct_id).collect(Collectors.toList());
queryWrapper.in("product_id", productIds);
queryWrapper.eq("activity_item_state",StateCode.ACTIVITY_STATE_NORMAL);
List<ShopStoreActivityItem> shopStoreActivityItems= shopStoreActivityItemService.list(queryWrapper);
Map<Long,Integer> activityNomalMap=new HashMap<>();
shopStoreActivityItems.forEach(shopStoreActivityItem -> {
activityNomalMap.put(shopStoreActivityItem.getProduct_id(),shopStoreActivityItem.getActivity_id());
});
productIndexList=productIndexList.stream().peek(shopProductIndex -> {
if(null==activityNomalMap.get(shopProductIndex.getProduct_id())){
shopProductIndex.setActivity_type_ids("");
}
}).collect(Collectors.toList());
//过滤过期的活动商品 end
return productIndexList;
}
}