|
|
@@ -156,19 +156,33 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
}
|
|
|
}
|
|
|
list.forEach(goods -> {
|
|
|
- if (ObjectUtils.isNotNull(goods.getSpecTemplateId()) &&
|
|
|
- goodsSpecTemplateService.count(new LambdaQueryWrapper<GoodsSpecTemplate>()
|
|
|
- .eq(GoodsSpecTemplate::getSpecTemplateId,goods.getSpecTemplateId())
|
|
|
- .eq(GoodsSpecTemplate::getStatus,1)) > 0){
|
|
|
- goods.setSpecTemplateId(goods.getSpecTemplateId());
|
|
|
- }else {
|
|
|
- List<GoodsSpecAttributeRelation> relationList = goodsSpecAttributeRelationService.list(new LambdaQueryWrapper<GoodsSpecAttributeRelation>()
|
|
|
- .eq(GoodsSpecAttributeRelation::getGoodsId, goods.getGoodsId())
|
|
|
- .orderByAsc(GoodsSpecAttributeRelation::getCreateTime)
|
|
|
- .last("LIMIT 1"));
|
|
|
- if (CollectionUtils.isNotEmpty(relationList)){
|
|
|
- GoodsSpecAttributeRelation relation = relationList.stream().findFirst().get();
|
|
|
- goods.setSpecTemplateId(relation.getSpecTemplateId());
|
|
|
+// if (ObjectUtils.isNotNull(goods.getSpecTemplateId()) &&
|
|
|
+// goodsSpecTemplateService.count(new LambdaQueryWrapper<GoodsSpecTemplate>()
|
|
|
+// .eq(GoodsSpecTemplate::getSpecTemplateId,goods.getSpecTemplateId())
|
|
|
+// .eq(GoodsSpecTemplate::getStatus,1)) > 0){
|
|
|
+// goods.setSpecTemplateId(goods.getSpecTemplateId());
|
|
|
+// }else {
|
|
|
+// List<GoodsSpecAttributeRelation> relationList = goodsSpecAttributeRelationService.list(new LambdaQueryWrapper<GoodsSpecAttributeRelation>()
|
|
|
+// .eq(GoodsSpecAttributeRelation::getGoodsId, goods.getGoodsId())
|
|
|
+// .orderByAsc(GoodsSpecAttributeRelation::getCreateTime)
|
|
|
+// .last("LIMIT 1"));
|
|
|
+// if (CollectionUtils.isNotEmpty(relationList)){
|
|
|
+// GoodsSpecAttributeRelation relation = relationList.stream().findFirst().get();
|
|
|
+// goods.setSpecTemplateId(relation.getSpecTemplateId());
|
|
|
+// }
|
|
|
+// }
|
|
|
+ //多规格下的价格区间
|
|
|
+ if (ObjectUtils.isNotNull(goods.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 = listByIds(goodsIds);
|
|
|
+ //从小到大排序
|
|
|
+ List<Goods> collect = goodsList.stream().filter(x -> ObjectUtils.isNotNull(x.getStandPrice())).sorted(Comparator.comparing(Goods::getStandPrice)).collect(Collectors.toList());
|
|
|
+ goods.setMinPrice(collect.get(0).getStandPrice());
|
|
|
+ goods.setMaxPrice(collect.get(collect.size() - 1).getStandPrice());
|
|
|
}
|
|
|
}
|
|
|
//是否包含每日一练试卷
|
|
|
@@ -234,21 +248,35 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
@Override
|
|
|
public GoodsVo selectDetail(Long goodsId) {
|
|
|
GoodsVo goodsVo = baseMapper.selectDetail(goodsId);
|
|
|
- if (ObjectUtils.isNull(goodsVo.getSpecTemplateId()) ||
|
|
|
- goodsSpecTemplateService.count(new LambdaQueryWrapper<GoodsSpecTemplate>()
|
|
|
- .eq(GoodsSpecTemplate::getSpecTemplateId,goodsVo.getSpecTemplateId())
|
|
|
- .eq(GoodsSpecTemplate::getStatus,1)) < 1){
|
|
|
- //没有绑定规格模板
|
|
|
- //查询是否有绑定的模板
|
|
|
+// if (ObjectUtils.isNull(goodsVo.getSpecTemplateId()) ||
|
|
|
+// goodsSpecTemplateService.count(new LambdaQueryWrapper<GoodsSpecTemplate>()
|
|
|
+// .eq(GoodsSpecTemplate::getSpecTemplateId,goodsVo.getSpecTemplateId())
|
|
|
+// .eq(GoodsSpecTemplate::getStatus,1)) < 1){
|
|
|
+// //没有绑定规格模板
|
|
|
+// //查询是否有绑定的模板
|
|
|
+// List<GoodsSpecAttributeRelation> list = goodsSpecAttributeRelationService
|
|
|
+// .list(new LambdaQueryWrapper<GoodsSpecAttributeRelation>()
|
|
|
+// .eq(GoodsSpecAttributeRelation::getStatus, 1)
|
|
|
+// .eq(GoodsSpecAttributeRelation::getGoodsId, goodsId)
|
|
|
+// .orderByDesc(GoodsSpecAttributeRelation::getCreateTime)
|
|
|
+// .last("LIMIT 1"));
|
|
|
+// if (CollectionUtils.isNotEmpty(list)){
|
|
|
+// GoodsSpecAttributeRelation relation = list.stream().findFirst().get();
|
|
|
+// goodsVo.setSpecTemplateId(relation.getSpecTemplateId());
|
|
|
+// }
|
|
|
+// }
|
|
|
+ //多规格下的价格区间
|
|
|
+ if (ObjectUtils.isNotNull(goodsVo.getSpecTemplateId())){
|
|
|
List<GoodsSpecAttributeRelation> list = goodsSpecAttributeRelationService
|
|
|
.list(new LambdaQueryWrapper<GoodsSpecAttributeRelation>()
|
|
|
- .eq(GoodsSpecAttributeRelation::getStatus, 1)
|
|
|
- .eq(GoodsSpecAttributeRelation::getGoodsId, goodsId)
|
|
|
- .orderByDesc(GoodsSpecAttributeRelation::getCreateTime)
|
|
|
- .last("LIMIT 1"));
|
|
|
+ .eq(GoodsSpecAttributeRelation::getSpecTemplateId, goodsVo.getSpecTemplateId()));
|
|
|
if (CollectionUtils.isNotEmpty(list)){
|
|
|
- GoodsSpecAttributeRelation relation = list.stream().findFirst().get();
|
|
|
- goodsVo.setSpecTemplateId(relation.getSpecTemplateId());
|
|
|
+ List<Long> goodsIds = list.stream().filter(x -> ObjectUtils.isNotNull(x.getGoodsId())).map(GoodsSpecAttributeRelation::getGoodsId).collect(Collectors.toList());
|
|
|
+ List<Goods> goodsList = listByIds(goodsIds);
|
|
|
+ //从小到大排序
|
|
|
+ List<Goods> collect = goodsList.stream().filter(x -> ObjectUtils.isNotNull(x.getStandPrice())).sorted(Comparator.comparing(Goods::getStandPrice)).collect(Collectors.toList());
|
|
|
+ goodsVo.setMinPrice(collect.get(0).getStandPrice());
|
|
|
+ goodsVo.setMaxPrice(collect.get(collect.size() - 1).getStandPrice());
|
|
|
}
|
|
|
}
|
|
|
return goodsVo;
|