|
@@ -210,19 +210,34 @@ public class ActivityRecommendServiceImpl extends ServiceImpl<ActivityRecommendM
|
|
}
|
|
}
|
|
page.getRecords().forEach(item -> {
|
|
page.getRecords().forEach(item -> {
|
|
Goods goods = iGoodsService.getById(item.getGoodsId());
|
|
Goods goods = iGoodsService.getById(item.getGoodsId());
|
|
- if (ObjectUtils.isNotNull(goods.getSpecTemplateId()) &&
|
|
|
|
- goodsSpecTemplateService.count(new LambdaQueryWrapper<GoodsSpecTemplate>()
|
|
|
|
- .eq(GoodsSpecTemplate::getSpecTemplateId,goods.getSpecTemplateId())
|
|
|
|
- .eq(GoodsSpecTemplate::getStatus,1)) > 0){
|
|
|
|
|
|
+// if (ObjectUtils.isNotNull(goods.getSpecTemplateId()) &&
|
|
|
|
+// goodsSpecTemplateService.count(new LambdaQueryWrapper<GoodsSpecTemplate>()
|
|
|
|
+// .eq(GoodsSpecTemplate::getSpecTemplateId,goods.getSpecTemplateId())
|
|
|
|
+// .eq(GoodsSpecTemplate::getStatus,1)) > 0){
|
|
|
|
+// item.setSpecTemplateId(goods.getSpecTemplateId());
|
|
|
|
+// }else {
|
|
|
|
+// List<GoodsSpecAttributeRelation> list = goodsSpecAttributeRelationService.list(new LambdaQueryWrapper<GoodsSpecAttributeRelation>()
|
|
|
|
+// .eq(GoodsSpecAttributeRelation::getGoodsId, item.getGoodsId())
|
|
|
|
+// .orderByAsc(GoodsSpecAttributeRelation::getCreateTime)
|
|
|
|
+// .last("LIMIT 1"));
|
|
|
|
+// if (CollectionUtils.isNotEmpty(list)){
|
|
|
|
+// GoodsSpecAttributeRelation relation = list.stream().findFirst().get();
|
|
|
|
+// item.setSpecTemplateId(relation.getSpecTemplateId());
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+ //多规格下的价格区间
|
|
|
|
+ if (ObjectUtils.isNotNull(goods.getSpecTemplateId())){
|
|
item.setSpecTemplateId(goods.getSpecTemplateId());
|
|
item.setSpecTemplateId(goods.getSpecTemplateId());
|
|
- }else {
|
|
|
|
- List<GoodsSpecAttributeRelation> list = goodsSpecAttributeRelationService.list(new LambdaQueryWrapper<GoodsSpecAttributeRelation>()
|
|
|
|
- .eq(GoodsSpecAttributeRelation::getGoodsId, item.getGoodsId())
|
|
|
|
- .orderByAsc(GoodsSpecAttributeRelation::getCreateTime)
|
|
|
|
- .last("LIMIT 1"));
|
|
|
|
- if (CollectionUtils.isNotEmpty(list)){
|
|
|
|
- GoodsSpecAttributeRelation relation = list.stream().findFirst().get();
|
|
|
|
- item.setSpecTemplateId(relation.getSpecTemplateId());
|
|
|
|
|
|
+ List<GoodsSpecAttributeRelation> specAttributeRelations = goodsSpecAttributeRelationService
|
|
|
|
+ .list(new LambdaQueryWrapper<GoodsSpecAttributeRelation>()
|
|
|
|
+ .eq(GoodsSpecAttributeRelation::getSpecTemplateId, goods.getSpecTemplateId()));
|
|
|
|
+ if (CollectionUtils.isNotEmpty(specAttributeRelations)){
|
|
|
|
+ List<Long> goodsIds = specAttributeRelations.stream().filter(x -> ObjectUtils.isNotNull(x.getGoodsId())).map(GoodsSpecAttributeRelation::getGoodsId).collect(Collectors.toList());
|
|
|
|
+ List<Goods> goodsList = iGoodsService.listByIds(goodsIds);
|
|
|
|
+ //从小到大排序
|
|
|
|
+ List<Goods> collect = goodsList.stream().filter(x -> ObjectUtils.isNotNull(x.getStandPrice())).sorted(Comparator.comparing(Goods::getStandPrice)).collect(Collectors.toList());
|
|
|
|
+ item.setMinPrice(collect.get(0).getStandPrice());
|
|
|
|
+ item.setMaxPrice(collect.get(collect.size() - 1).getStandPrice());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|