he2802 %!s(int64=2) %!d(string=hai) anos
pai
achega
4162c6367d

+ 27 - 12
zhongzheng-system/src/main/java/com/zhongzheng/modules/activity/service/impl/ActivityRecommendServiceImpl.java

@@ -210,19 +210,34 @@ public class ActivityRecommendServiceImpl extends ServiceImpl<ActivityRecommendM
         }
         page.getRecords().forEach(item -> {
             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());
-            }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());
                 }
             }
         });

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/activity/vo/ActivityRecommendGoodsVo.java

@@ -60,4 +60,9 @@ public class ActivityRecommendGoodsVo {
 	private String coverUrl;
 	@ApiModelProperty("规格模板ID")
 	private Long specTemplateId;
+	@ApiModelProperty("最小价格")
+	private BigDecimal minPrice;
+
+	@ApiModelProperty("最大价格")
+	private BigDecimal maxPrice;
 }

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/domain/ClassGrade.java

@@ -21,7 +21,7 @@ import com.zhongzheng.common.annotation.Excel;
 @Accessors(chain = true)
 @TableName("class_grade")
 public class ClassGrade implements Serializable {
-    public static final Integer INIT_UPPER = 300;  //初始人数
+    public static final Integer INIT_UPPER = 5;  //初始人数
     public static final Integer INIT_UPPER2 = 1000000;  //初始人数
 
 private static final long serialVersionUID=1L;