he2802 3 éve
szülő
commit
974acfc8da

+ 1 - 1
zhongzheng-api/src/main/java/com/zhongzheng/controller/goods/GoodsController.java

@@ -209,7 +209,7 @@ public class GoodsController extends BaseController {
     /**
      * 获取商品详细信息
      */
-    @ApiOperation("查用户有哪些商品节正在直播")
+    @ApiOperation("查用户有哪些商品节正在直播")
     @GetMapping("/livingSectionList")
     public AjaxResult<List<CourseSectionVo>> livingSectionList() {
         ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/mapper/CourseSectionMapper.java

@@ -23,5 +23,5 @@ public interface CourseSectionMapper extends BaseMapper<CourseSection> {
 
     List<CourseSectionVo> livingSectionList(@Param("nowTime") Long nowTime);
 
-    Integer checkUserHaveLiveGoods(@Param("userId") Long userId,@Param("goodsIds") List<Long> goodsIds);
+    Long checkUserHaveLiveGoods(@Param("userId") Long userId,@Param("goodsId") Long goodsId);
 }

+ 34 - 6
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseSectionServiceImpl.java

@@ -361,7 +361,7 @@ public class CourseSectionServiceImpl extends ServiceImpl<CourseSectionMapper, C
     }
 
     /**
-     * 查用户有哪些商品节正在直播
+     * 查用户有哪些商品节正在直播
      * @param userId
      * @return
      */
@@ -371,6 +371,7 @@ public class CourseSectionServiceImpl extends ServiceImpl<CourseSectionMapper, C
         List<CourseSectionVo> userList = new ArrayList<>();
         for(CourseSectionVo sectionVo : list){
             List<Long> goodsIds = new ArrayList<>();//商品ID
+            List<ClassPeriodVo> periodList = new ArrayList<>();//学时列表
             //当节为根目录时
             CourseMenuQueryBo menuQueryBo = new CourseMenuQueryBo();
             menuQueryBo.setType(3);
@@ -381,7 +382,13 @@ public class CourseSectionServiceImpl extends ServiceImpl<CourseSectionMapper, C
                 courseQueryBo.setCourseId(menuVo.getCourseId());
                 List<GoodsCourseVo> goodsList = iGoodsCourseService.queryList(courseQueryBo);
                 for (GoodsCourseVo goodsCourseVo : goodsList) {
-                    goodsIds.add(goodsCourseVo.getGoodsId());
+                    ClassPeriodVo periodVo = new ClassPeriodVo();
+                    periodVo.setGoodsId(goodsCourseVo.getGoodsId());
+                    periodVo.setCourseId(menuVo.getCourseId());
+                    periodVo.setModuleId(0L);
+                    periodVo.setChapterId(0L);
+                    periodVo.setSectionId(sectionVo.getSectionId());
+                    periodList.add(periodVo);
                 }
             }
 
@@ -400,7 +407,13 @@ public class CourseSectionServiceImpl extends ServiceImpl<CourseSectionMapper, C
                     courseQueryBo.setCourseId(menuVo.getCourseId());
                     List<GoodsCourseVo> goodsList = iGoodsCourseService.queryList(courseQueryBo);
                     for (GoodsCourseVo goodsCourseVo : goodsList) {
-                        goodsIds.add(goodsCourseVo.getGoodsId());
+                        ClassPeriodVo periodVo = new ClassPeriodVo();
+                        periodVo.setGoodsId(goodsCourseVo.getGoodsId());
+                        periodVo.setCourseId(menuVo.getCourseId());
+                        periodVo.setModuleId(0L);
+                        periodVo.setChapterId(0L);
+                        periodVo.setSectionId(sectionVo.getSectionId());
+                        periodList.add(periodVo);
                     }
                 }
 
@@ -419,14 +432,29 @@ public class CourseSectionServiceImpl extends ServiceImpl<CourseSectionMapper, C
                         courseQueryBo.setCourseId(menuVo.getCourseId());
                         List<GoodsCourseVo> goodsList = iGoodsCourseService.queryList(courseQueryBo);
                         for (GoodsCourseVo goodsCourseVo : goodsList) {
-                            goodsIds.add(goodsCourseVo.getGoodsId());
+                            ClassPeriodVo periodVo = new ClassPeriodVo();
+                            periodVo.setGoodsId(goodsCourseVo.getGoodsId());
+                            periodVo.setCourseId(menuVo.getCourseId());
+                            periodVo.setModuleId(0L);
+                            periodVo.setChapterId(0L);
+                            periodVo.setSectionId(sectionVo.getSectionId());
+                            periodList.add(periodVo);
                         }
                     }
                 }
             }
-            if(baseMapper.checkUserHaveLiveGoods(userId,goodsIds)>0){
-                userList.add(sectionVo);
+            for(ClassPeriodVo periodVo : periodList){
+                Long orderGoodsId = baseMapper.checkUserHaveLiveGoods(userId,periodVo.getGoodsId());
+                if(Validator.isNotEmpty(orderGoodsId)){
+                    sectionVo.setOrderGoodsId(orderGoodsId);
+                    sectionVo.setModuleId(periodVo.getModuleId());
+                    sectionVo.setCourseId(periodVo.getCourseId());
+                    sectionVo.setChapterId(periodVo.getChapterId());
+                    sectionVo.setGoodsId(periodVo.getGoodsId());
+                    userList.add(sectionVo);
+                }
             }
+
         }
         return userList;
     }

+ 15 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/vo/CourseSectionVo.java

@@ -114,4 +114,19 @@ public class CourseSectionVo {
 	@Excel(name = "保利威真实直播时长,单位秒")
 	@ApiModelProperty("保利威真实直播时长,单位秒")
 	private Long realDuration;
+	private Long orderGoodsId;
+	/** 学员ID */
+	@Excel(name = "课程id")
+	@ApiModelProperty("课程id")
+	private Long courseId;
+	/** 章ID */
+	@ApiModelProperty("章ID")
+	private Long chapterId;
+
+	/** 模塊ID */
+	@ApiModelProperty("模塊ID")
+	private Long moduleId;
+	/** 商品ID */
+	@ApiModelProperty("商品ID")
+	private Long goodsId;
 }

+ 4 - 8
zhongzheng-system/src/main/resources/mapper/modules/course/CourseSectionMapper.xml

@@ -223,22 +223,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         SELECT * from course_section cs where cs.section_type = 2 and cs.live_end_time >= #{nowTime} and  #{nowTime} >= cs.live_start_time
     </select>
 
-    <select id="checkUserHaveLiveGoods" parameterType="map" resultType="int">
+    <select id="checkUserHaveLiveGoods" parameterType="map" resultType="long">
         SELECT
-            count(*)
+            og.order_goods_id
         FROM
             `order` o
                 LEFT JOIN order_goods og ON o.order_sn = og.order_sn
         WHERE
             o.user_id = #{userId}
-        <if test="goodsIds != null and goodsIds.size()!=0 ">
-            AND og.goods_id in
-            <foreach collection="goodsIds" item="item" index="index" open="(" close=")" separator=",">
-                #{item}
-            </foreach>
-        </if>
+          AND og.goods_id = #{goodsId}
         and og.`status` = 1
         and og.refund_status in (0,1,3)
         and og.pay_status in (2,3,4)
+        limit 1
     </select>
 </mapper>