Quellcode durchsuchen

fix 录单商品

he2802 vor 3 Jahren
Ursprung
Commit
2388443b0e

+ 10 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/goods/GoodsController.java

@@ -70,6 +70,16 @@ public class GoodsController extends BaseController {
         return getDataTable(list);
     }
 
+
+    @ApiOperation("查询商品列表To录单")
+    @PreAuthorize("@ss.hasPermi('system:goods:list')")
+    @GetMapping("/listToInput")
+    public TableDataInfo<GoodsVo> listToInput(GoodsQueryBo bo) {
+        startPage();
+        List<GoodsVo> list = iGoodsService.selectListToInput(bo);
+        return getDataTable(list);
+    }
+
     /**
      * 导出商品列表
      */

+ 1 - 1
zhongzheng-common/src/main/java/com/zhongzheng/common/core/redis/RedisCache.java

@@ -243,7 +243,7 @@ public class RedisCache
      */
     public boolean lock(RedisLockEntity redisLockEntity) {
         boolean locked = false;
-        int tryCount = 3;
+        int tryCount = 10;
         while (!locked && tryCount > 0) {
             locked = redisTemplate.opsForValue().setIfAbsent(redisLockEntity.getLockKey(), redisLockEntity.getRequestId(), 5, TimeUnit.SECONDS);
             tryCount--;

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/mapper/GoodsMapper.java

@@ -28,4 +28,6 @@ public interface GoodsMapper extends BaseMapper<Goods> {
     Long getQuestionNum(Long goodsId);
 
     int queryUpGoods();
+
+    List<GoodsVo> selectListToInput(GoodsQueryBo bo);
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/IGoodsService.java

@@ -26,6 +26,8 @@ public interface IGoodsService extends IService<Goods> {
 
 	List<GoodsVo> selectList(GoodsQueryBo bo);
 
+	List<GoodsVo> selectListToInput(GoodsQueryBo bo);
+
 	GoodsVo selectDetail(Long goodsId);
 
 	Long getQuestionNum(Long goodsId);

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/impl/GoodsServiceImpl.java

@@ -106,6 +106,11 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
         return baseMapper.selectList(bo);
     }
 
+    @Override
+    public List<GoodsVo> selectListToInput(GoodsQueryBo bo) {
+        return baseMapper.selectListToInput(bo);
+    }
+
     @Override
     public GoodsVo selectDetail(Long goodsId) {
         return baseMapper.selectDetail(goodsId);

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

@@ -258,4 +258,7 @@ public class GoodsVo {
 	@Excel(name = "每天最大节学习数量")
 	@ApiModelProperty("每天最大节学习数量")
 	private Long sectionMaxNum;
+
+	@ApiModelProperty("班级名称")
+	private String gradeName;
 }

+ 10 - 2
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderServiceImpl.java

@@ -300,10 +300,14 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
                 RedisLockEntity redisLockEntity = new RedisLockEntity();
                 redisLockEntity.setLockKey(RedisLockEntity.KEY_LOCK_GRADE);
                 redisLockEntity.setRequestId(requestId);
+                boolean isArrange = false;
                 if (redisCache.lock(redisLockEntity)) {
-                    arrangeGrade(goods.getGoodsName(), goods.getGoodsId(), orderGoods.getOrderGoodsId(), gradeId, add.getUserId(), out_trade_no, goods.getBusinessId());
+                    isArrange = arrangeGrade(goods.getGoodsName(), goods.getGoodsId(), orderGoods.getOrderGoodsId(), gradeId, add.getUserId(), out_trade_no, goods.getBusinessId());
                     redisCache.unlockLua(redisLockEntity);
                 }
+                if(!isArrange){
+                    throw new CustomException("分班错误");
+                }
                 iOrderGoodsService.updateById(orderGoods);
             }
 
@@ -428,10 +432,14 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
                 RedisLockEntity redisLockEntity = new RedisLockEntity();
                 redisLockEntity.setLockKey(RedisLockEntity.KEY_LOCK_GRADE);
                 redisLockEntity.setRequestId(requestId);
+                boolean isArrange = false;
                 if (redisCache.lock(redisLockEntity)) {
-                    arrangeGrade(goods.getGoodsName(), goods.getGoodsId(), orderGoods.getOrderGoodsId(), gradeId, add.getUserId(), out_trade_no, goods.getBusinessId());
+                    isArrange = arrangeGrade(goods.getGoodsName(), goods.getGoodsId(), orderGoods.getOrderGoodsId(), gradeId, add.getUserId(), out_trade_no, goods.getBusinessId());
                     redisCache.unlockLua(redisLockEntity);
                 }
+                if(!isArrange){
+                    throw new CustomException("分班错误");
+                }
                 iOrderGoodsService.updateById(orderGoods);
             }
 

+ 125 - 1
zhongzheng-system/src/main/resources/mapper/modules/goods/GoodsMapper.xml

@@ -104,7 +104,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="serviceTimeType" column="service_time_type"/>
         <result property="serviceTimeNum" column="service_time_num"/>
         <result property="gradeNum" column="grade_num"/>
-
+        <result property="gradeId" column="grade_id"/>
+        <result property="gradeName" column="grade_name"/>
     </resultMap>
 
     <resultMap type="com.zhongzheng.modules.exam.vo.ExamNumberGoodsVo" id="ExamNumberGoodsVoResult">
@@ -243,6 +244,129 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     </select>
 
+    <select id="selectListToInput" parameterType="com.zhongzheng.modules.goods.bo.GoodsQueryBo" resultMap="GoodsResultVo">
+        SELECT
+        g.*,
+        ps.supply_name,
+        cet.education_name,
+        cpt.project_name,
+        cb.business_name,
+        s.school_name,
+        m.category_name,
+        ot.type AS template_type,
+        (SELECT gs.goods_name FROM goods gs where 1=1 and g.make_goods_id = gs.goods_id) as make_goods_name,
+        (SELECT gs.code FROM goods gs where 1=1 and g.make_goods_id = gs.goods_id) as make_goods_code
+        <if test="sectionNum ==1">
+            ,(SELECT COUNT(m.id)+(SELECT COUNT(n.id) FROM course_chapter_section n LEFT JOIN course_module_chapter p on n.chapter_id = p.chapter_id LEFT JOIN course_menu m on m.menu_id = p.module_id LEFT JOIN goods_course gc on gc.course_id = m.course_id  where gc.goods_id =  g.goods_id and m.type in(1))+(SELECT COUNT(n.id) FROM course_chapter_section n  LEFT JOIN course_menu m on m.menu_id = n.chapter_id LEFT JOIN goods_course gc on gc.course_id = m.course_id where gc.goods_id =  g.goods_id and m.type in(2)) FROM course_menu m LEFT JOIN goods_course gc on gc.course_id = m.course_id  where gc.goods_id =  g.goods_id  and m.type in(3)) as section_num
+        </if>
+        <if test="goodsType ==1">
+            , (SELECT count(*) FROM goods_course where goods_id =g.goods_id ) as course_num
+            , (SELECT count(*) FROM class_grade cg  LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id where  cgg.goods_id = g.goods_id and cg.`status` = 1 ) as grade_num
+            , (SELECT cg.grade_id FROM class_grade cg  LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id where  cgg.goods_id = g.goods_id and cg.`status` = 1 limit 1) as grade_id
+            , (SELECT cg.class_name FROM class_grade cg  LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id where  cgg.goods_id = g.goods_id and cg.`status` = 1 limit 1) as grade_name
+        </if>
+        FROM
+        goods g
+        LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
+        LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
+        LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
+        LEFT JOIN course_business cb ON g.business_id = cb.id
+        LEFT JOIN school s ON s.id = g.school_id
+        LEFT JOIN major m ON g.major_id = m.id
+        LEFT JOIN order_input_template ot ON cb.template_status = ot.id
+        WHERE
+        1 = 1
+        <if test="status != null and status.size()!=0 ">
+            AND g.status in
+            <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="goodsIds != null and goodsIds.size()!=0 ">
+            AND g.goods_id in
+            <foreach collection="goodsIds" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="goodsType != null and goodsType != ''">
+            AND g.goods_type = #{goodsType}
+        </if>
+        <if test="makeGoodsId != null and makeGoodsId != ''">
+            AND g.make_goods_id = #{makeGoodsId}
+        </if>
+        <if test="goodsName != null and goodsName != ''">
+            AND g.goods_name like concat('%', #{goodsName}, '%')
+        </if>
+        <if test="educationTypeId != null and educationTypeId != ''">
+            AND g.education_type_id = #{educationTypeId}
+        </if>
+        <if test="businessIds != null and businessIds.size()!=0 ">
+            AND g.business_id in
+            <foreach collection="businessIds" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="businessId != null and businessId != ''">
+            AND g.business_id = #{businessId}
+        </if>
+        <if test="schoolId != null and schoolId != ''">
+            AND g.school_id = #{schoolId}
+        </if>
+        <if test="majorId != null and majorId != ''">
+            AND g.major_id = #{majorId}
+        </if>
+        <if test="standPrice != null and standPrice != ''">
+            AND g.stand_price = #{standPrice}
+        </if>
+        <if test="searchKey != null and searchKey != ''">
+            and (g.goods_name like concat('%', #{searchKey}, '%') or g.code like concat('%', #{searchKey}, '%'))
+        </if>
+        <if test="goodsStatus != null ">
+            AND g.goods_status = #{goodsStatus}
+        </if>
+        <if test="studyStartTime != null and studyStartTime != '' and studyEndTime != null and studyEndTime != ''">
+            and #{studyStartTime} BETWEEN g.validity_start_time and g.validity_end_time or #{studyEndTime} BETWEEN g.validity_start_time and g.validity_end_time
+        </if>
+        <if test="validityStartTime != null or validityEndTime != null ">
+            AND (#{validityStartTime} BETWEEN g.validity_start_time and g.validity_end_time or #{validityEndTime} BETWEEN g.validity_start_time and g.validity_end_time)
+        </if>
+        <if test="goodsType ==1 and subjectId >0">
+            AND (SELECT count(*) from goods_course gc LEFT JOIN course c ON gc.course_id = c.course_id where gc.goods_id = g.goods_id and c.`status` = 1
+            AND c.subject_id = #{subjectId}) >0
+        </if>
+        <if test="goodsType ==1 and haveCourse != null and haveCourse == 1">
+            AND (SELECT count(*) from goods_course gc LEFT JOIN course c ON gc.course_id = c.course_id where gc.goods_id = g.goods_id and c.`status` = 1
+            ) >0
+        </if>
+        <if test="goodsType ==2 and subjectId >0">
+            AND g.goods_id in(
+            SELECT
+            ga.goods_id
+            FROM
+            goods_attached ga
+            LEFT JOIN question_business qb ON ga.major_id = qb.major_id
+            WHERE
+            ((
+            qb.type = 4
+            AND ga.type = 1
+            )
+            OR ( qb.type = 3 AND ga.type = 2 )
+            OR ( qb.type = 2 AND ga.type = 3 ))
+            AND qb.subject_id = #{subjectId}
+            )
+        </if>
+        <if test="sortType != null and sortType == 2">
+            ORDER BY g.stand_price
+        </if>
+        <if test="sortType != null and sortType == 3">
+            ORDER BY g.stand_price DESC
+        </if>
+        <if test="sortType == null or sortType == 1">
+            ORDER BY g.create_time DESC
+        </if>
+
+    </select>
+
     <select id="selectDetail" parameterType="Long" resultMap="GoodsResultVo">
         SELECT
             g.*,