Przeglądaj źródła

submit:12.01需求

yangdamao 3 lat temu
rodzic
commit
0080943b51

+ 7 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/domain/CourseTopicGoods.java

@@ -1,6 +1,7 @@
 package com.zhongzheng.modules.course.domain;
 
 import com.baomidou.mybatisplus.annotation.*;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 import lombok.experimental.Accessors;
@@ -36,6 +37,12 @@ private static final long serialVersionUID=1L;
     private Long goodsId;
     /** 商品名称 */
     private String goodsName;
+    /** 标准价格 */
+    private BigDecimal standPrice;
+    /** 最低价格 */
+    private BigDecimal lowestPrice;
+    /** 商品划线价 */
+    private BigDecimal linePrice;
     /** 1有效 0无效 */
     private Integer status;
     /** 创建时间 */

+ 6 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/bo/GoodsAddBo.java

@@ -178,4 +178,10 @@ public class GoodsAddBo {
     /** 商品划线价格 */
     @ApiModelProperty("商品划线价格")
     private BigDecimal linePrice;
+    /** 是否显示:0否 1是 */
+    @ApiModelProperty("是否显示:0否 1是")
+    private Integer showStatus;
+    /** 显示排序字段 */
+    @ApiModelProperty("显示排序字段")
+    private Long showSort;
 }

+ 6 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/bo/GoodsEditBo.java

@@ -212,4 +212,10 @@ public class GoodsEditBo {
     /** 商品划线价格 */
     @ApiModelProperty("商品划线价格")
     private BigDecimal linePrice;
+    /** 是否显示:0否 1是 */
+    @ApiModelProperty("是否显示:0否 1是")
+    private Integer showStatus;
+    /** 显示排序字段 */
+    @ApiModelProperty("显示排序字段")
+    private Long showSort;
 }

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/domain/Goods.java

@@ -141,4 +141,8 @@ private static final long serialVersionUID=1L;
     private BigDecimal linePrice;
     /** 默认规格模板ID */
     private Long specTemplateId;
+    /** 是否显示:0否 1是 */
+    private Integer showStatus;
+    /** 显示排序字段 */
+    private Long showSort;
 }

+ 53 - 25
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/impl/GoodsServiceImpl.java

@@ -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;

+ 13 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/vo/GoodsVo.java

@@ -328,4 +328,17 @@ public class GoodsVo {
 	@ApiModelProperty("是否包含每日一练试卷:1是 0否")
 	private Integer examRecord;
 
+	@ApiModelProperty("最小价格")
+	private BigDecimal minPrice;
+
+	@ApiModelProperty("最大价格")
+	private BigDecimal maxPrice;
+
+	/** 是否显示:0否 1是 */
+	@ApiModelProperty("是否显示:0否 1是")
+	private Integer showStatus;
+	/** 显示排序字段 */
+	@ApiModelProperty("显示排序字段")
+	private Long showSort;
+
 }

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/UserQueryBo.java

@@ -208,4 +208,7 @@ public class UserQueryBo extends BaseEntity {
 
 	@ApiModelProperty("统计结束时间")
 	private Long statsEndTime;
+
+	@ApiModelProperty("学员搜索关键字")
+	private String userKerWord;
 }

+ 6 - 4
zhongzheng-system/src/main/resources/mapper/modules/goods/GoodsMapper.xml

@@ -92,6 +92,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="goodsExamConfig" column="goods_exam_config"/>
         <result property="sectionMaxNum" column="section_max_num"/>
         <result property="specTemplateId" column="spec_template_id"/>
+        <result property="showStatus" column="show_status"/>
+        <result property="showSort" column="show_sort"/>
 
         <result property="supplyName" column="supply_name"/>
         <result property="educationName" column="education_name"/>
@@ -238,7 +240,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </if>
         WHERE
         1 = 1
-        AND g.goods_type != 5
+        AND g.goods_type != 5 AND g.show_status = 1
         <if test="status != null and status.size()!=0 ">
             AND g.status in
             <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
@@ -330,13 +332,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <!-- 数据范围过滤 -->
         ${params.dataScope}
         <if test="sortType != null and sortType == 2">
-            ORDER BY g.stand_price
+            ORDER BY g.show_sort DESC,g.stand_price ASC
         </if>
         <if test="sortType != null and sortType == 3">
-            ORDER BY g.stand_price DESC
+            ORDER BY g.show_sort DESC,g.stand_price DESC
         </if>
         <if test="sortType == null or sortType == 1">
-            ORDER BY g.create_time DESC
+            ORDER BY g.show_sort DESC,g.create_time DESC
         </if>
 
     </select>

+ 3 - 0
zhongzheng-system/src/main/resources/mapper/modules/user/UserMapper.xml

@@ -201,6 +201,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="endTime != null and endTime != ''">
             AND u.create_time &lt; #{endTime}
         </if>
+        <if test="userKerWord != null and userKerWord != ''" >
+            AND (u.realname like concat('%', #{userKerWord}, '%') OR u.telphone like concat('%', #{userKerWord}, '%') OR u.id_card like concat('%', #{userKerWord}, '%'))
+        </if>
         <if test="nickname != null and nickname != ''" >
             AND u.nickname like concat('%', #{nickname}, '%')
         </if>