Эх сурвалжийг харах

up:直播提醒列表BUG处理

yangdamao 3 жил өмнө
parent
commit
cc2e8a33a0

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

@@ -6,6 +6,7 @@ import com.zhongzheng.modules.course.domain.CourseMenu;
 import com.zhongzheng.modules.course.vo.CourseMenuVo;
 import com.zhongzheng.modules.course.vo.CourseUserMenuVo;
 import com.zhongzheng.modules.course.vo.CourseVo;
+import com.zhongzheng.modules.course.vo.LiveListVo;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -33,5 +34,5 @@ public interface CourseMenuMapper extends BaseMapper<CourseMenu> {
 
     Integer auditCheck(@Param("sectionId") Long id,@Param("gradeId") Long gradeId,@Param("userId")Long userId,@Param("courseId")Long courseId);
 
-    List<Long> getSectionIds(@Param("chapterIds") List<Long> chapterIds);
+    List<LiveListVo> getSectionIds(@Param("moduleId") Long moduleId);
 }

+ 3 - 2
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/ICourseMenuService.java

@@ -8,6 +8,7 @@ import com.zhongzheng.modules.course.bo.CourseMenuQueryBo;
 import com.zhongzheng.modules.course.domain.CourseMenu;
 import com.zhongzheng.modules.course.vo.CourseMenuVo;
 import com.zhongzheng.modules.course.vo.CourseUserMenuVo;
+import com.zhongzheng.modules.course.vo.LiveListVo;
 
 import java.util.Collection;
 import java.util.List;
@@ -62,8 +63,8 @@ public interface ICourseMenuService extends IService<CourseMenu> {
 	 * 获取节ID
 	 * @author yangdamao
 	 * @date 2022/7/14 9:44
-	 * @param chapterIds
+	 * @param moduleId
 	 * @return java.util.List<java.lang.Long>
 	 */
-	List<Long> getSectionIds(List<Long> chapterIds);
+	List<LiveListVo> getSectionIds(Long moduleId);
 }

+ 3 - 2
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseMenuServiceImpl.java

@@ -18,6 +18,7 @@ import com.zhongzheng.modules.course.service.ICourseService;
 import com.zhongzheng.modules.course.vo.CourseMenuVo;
 import com.zhongzheng.modules.course.vo.CourseUserChapterSectionVo;
 import com.zhongzheng.modules.course.vo.CourseUserMenuVo;
+import com.zhongzheng.modules.course.vo.LiveListVo;
 import com.zhongzheng.modules.goods.bo.GoodsCourseAddBo;
 import com.zhongzheng.modules.goods.service.IGoodsCourseService;
 import com.zhongzheng.modules.goods.service.IGoodsService;
@@ -274,7 +275,7 @@ public class CourseMenuServiceImpl extends ServiceImpl<CourseMenuMapper, CourseM
     }
 
     @Override
-    public List<Long> getSectionIds(List<Long> chapterIds) {
-        return baseMapper.getSectionIds(chapterIds);
+    public List<LiveListVo> getSectionIds(Long moduleId) {
+        return baseMapper.getSectionIds(moduleId);
     }
 }

+ 9 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/vo/CourseLiveVo.java

@@ -92,4 +92,13 @@ public class CourseLiveVo implements Serializable {
 
     @ApiModelProperty("订单ID")
     private Long orderId;
+
+    @ApiModelProperty("订单商品关联ID")
+    private Long orderGoodId;
+
+    @ApiModelProperty("章ID")
+    private Long chapterId;
+
+    @ApiModelProperty("模块ID")
+    private Long moduleId;
 }

+ 32 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/vo/LiveListVo.java

@@ -0,0 +1,32 @@
+package com.zhongzheng.modules.course.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author yangdamao
+ * @date 2022年07月22日 16:52
+ */
+@Data
+public class LiveListVo implements Serializable {
+
+    @ApiModelProperty("课程ID")
+    private Long courseId;
+
+    @ApiModelProperty("订单商品关联ID")
+    private Long orderGoodId;
+
+    @ApiModelProperty("章ID")
+    private Long chapterId;
+
+    @ApiModelProperty("模块ID")
+    private Long moduleId;
+
+    @ApiModelProperty("节ID")
+    private Long sectionId;
+
+    @ApiModelProperty("商品ID")
+    private Long goodId;
+}

+ 2 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/mapper/OrderGoodsMapper.java

@@ -1,6 +1,7 @@
 package com.zhongzheng.modules.order.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.zhongzheng.modules.course.vo.LiveListVo;
 import com.zhongzheng.modules.goods.bo.GoodsQueryBo;
 import com.zhongzheng.modules.order.bo.OrderGoodsQueryBo;
 import com.zhongzheng.modules.order.domain.OrderGoods;
@@ -45,7 +46,7 @@ public interface OrderGoodsMapper extends BaseMapper<OrderGoods> {
 
     List<OrderGoodsVo> selectBuyUserList(Long mockMajorSubjectId);
 
-    List<Long> getCourseIdByLive(Long userId);
+    List<LiveListVo> getCourseIdByLive(Long userId);
 
     List<OrderGoodsVo> listUserVideoLive(GoodsQueryBo bo);
 }

+ 91 - 22
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderGoodsServiceImpl.java

@@ -22,6 +22,7 @@ import com.zhongzheng.modules.course.service.ICourseMenuService;
 import com.zhongzheng.modules.course.service.ICourseSectionService;
 import com.zhongzheng.modules.course.vo.CourseLiveVo;
 import com.zhongzheng.modules.course.vo.CourseVo;
+import com.zhongzheng.modules.course.vo.LiveListVo;
 import com.zhongzheng.modules.goods.bo.GoodsQueryBo;
 import com.zhongzheng.modules.goods.service.IGoodsCourseService;
 import com.zhongzheng.modules.goods.service.IGoodsService;
@@ -490,37 +491,97 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
         info.setCode(HttpStatus.HTTP_OK);
         info.setMsg("查询成功");
         //获取所有直播课程ID
-        List<Long> courseIds = orderGoodsMapper.getCourseIdByLive(userId);
-        if (CollectionUtils.isEmpty(courseIds)){
+        List<LiveListVo> liveVos = orderGoodsMapper.getCourseIdByLive(userId);
+        if (CollectionUtils.isEmpty(liveVos)){
             return info;
         }
+        List<Long> courseIds = liveVos.stream().map(LiveListVo::getCourseId).collect(Collectors.toList());
         //课程目录
         List<CourseMenu> menus = courseMenuService.list(new LambdaQueryWrapper<CourseMenu>()
                 .in(CourseMenu::getCourseId, courseIds));
         if (CollectionUtils.isEmpty(menus)){
             return info;
         }
-
-        //节ID
-        List<Long> sectionIds = menus.stream().filter(x -> x.getType() == 3).map(CourseMenu::getMenuId).collect(Collectors.toList());
-        //章ID
-        List<Long> chapterIds = menus.stream().filter(x -> x.getType() == 2).map(CourseMenu::getMenuId).collect(Collectors.toList());
-        if (!CollectionUtils.isEmpty(chapterIds)){
-            List<CourseChapterSection> chapterSections = courseChapterSectionService.list(new LambdaQueryWrapper<CourseChapterSection>()
-                    .in(CourseChapterSection::getChapterId, chapterIds));
-            if (!CollectionUtils.isEmpty(chapterSections)){
-                List<Long> ids = chapterSections.stream().map(CourseChapterSection::getSectionId).collect(Collectors.toList());
-                sectionIds.addAll(ids);
-            }
-        }
-        //模块ID
-        List<Long> moduleIds = menus.stream().filter(x -> x.getType() == 1).map(CourseMenu::getMenuId).collect(Collectors.toList());
-        if (!CollectionUtils.isEmpty(moduleIds)){
-            List<Long> ids = courseMenuService.getSectionIds(moduleIds);
-            if (!CollectionUtils.isEmpty(ids)){
-                sectionIds.addAll(ids);
+        List<LiveListVo> listVoList = new ArrayList<>();
+        menus.forEach(item -> {
+            switch (item.getType()){
+                case 3://节
+                    LiveListVo vo = new LiveListVo();
+                    vo.setCourseId(item.getCourseId());
+                    vo.setSectionId(item.getMenuId());
+                    listVoList.add(vo);
+                    break;
+                case 2://章
+                    List<CourseChapterSection> chapterSections = courseChapterSectionService
+                            .list(new LambdaQueryWrapper<CourseChapterSection>()
+                            .eq(CourseChapterSection::getChapterId, item.getMenuId()));
+                    if (!CollectionUtils.isEmpty(chapterSections)){
+                        List<LiveListVo> collect = chapterSections.stream().map(chapter -> {
+                            LiveListVo chapterVo = new LiveListVo();
+                            chapterVo.setCourseId(item.getCourseId());
+                            chapterVo.setChapterId(item.getMenuId());
+                            chapterVo.setSectionId(chapter.getSectionId());
+                            return chapterVo;
+                        }).collect(Collectors.toList());
+                        listVoList.addAll(collect);
+                    }
+                    break;
+                case 1://模块
+                    List<LiveListVo> listVos = courseMenuService.getSectionIds(item.getMenuId());
+                    if (!CollectionUtils.isEmpty(listVos)){
+                        List<LiveListVo> collect = listVos.stream().map(module -> {
+                            LiveListVo chapterVo = new LiveListVo();
+                            chapterVo.setCourseId(item.getCourseId());
+                            chapterVo.setModuleId(item.getMenuId());
+                            chapterVo.setChapterId(module.getChapterId());
+                            chapterVo.setSectionId(module.getSectionId());
+                            return chapterVo;
+                        }).collect(Collectors.toList());
+                        listVoList.addAll(collect);
+                    }
             }
-        }
+        });
+        listVoList.forEach(vo -> {
+            liveVos.forEach(item -> {
+                if (vo.getCourseId().equals(item.getCourseId())){
+                    vo.setGoodId(item.getGoodId());
+                    vo.setOrderGoodId(item.getOrderGoodId());
+                }
+            });
+        });
+//        //节ID
+//        List<LiveListVo> liveListVos = menus.stream().filter(x -> x.getType() == 3).map(item -> {
+//            LiveListVo vo = new LiveListVo();
+//            vo.setCourseId(item.getCourseId());
+//            vo.setSectionId(item.getMenuId());
+//            return vo;
+//        }).collect(Collectors.toList());
+//
+//        //章ID
+//        List<Long> chapterIds = menus.stream().filter(x -> x.getType() == 2).map(CourseMenu::getMenuId).collect(Collectors.toList());
+//        if (!CollectionUtils.isEmpty(chapterIds)){
+//            List<CourseChapterSection> chapterSections = courseChapterSectionService.list(new LambdaQueryWrapper<CourseChapterSection>()
+//                    .in(CourseChapterSection::getChapterId, chapterIds));
+//            if (!CollectionUtils.isEmpty(chapterSections)){
+//                chapterSections.stream().map(item -> {
+//                    LiveListVo vo = new LiveListVo();
+//                    vo.setCourseId(item.getCourseId());
+//                    vo.setSectionId(item.getMenuId());
+//                    return vo;
+//                })
+//                List<Long> ids = chapterSections.stream().map(CourseChapterSection::getSectionId).collect(Collectors.toList());
+//                sectionIds.addAll(ids);
+//            }
+//        }
+//        //模块ID
+//        List<Long> moduleIds = menus.stream().filter(x -> x.getType() == 1).map(CourseMenu::getMenuId).collect(Collectors.toList());
+//        if (!CollectionUtils.isEmpty(moduleIds)){
+//            List<Long> ids = courseMenuService.getSectionIds(moduleIds);
+//            if (!CollectionUtils.isEmpty(ids)){
+//                sectionIds.addAll(ids);
+//            }
+//        }
+        List<Long> sectionIds = listVoList.stream().map(LiveListVo::getSectionId).collect(Collectors.toList());
         if (CollectionUtils.isEmpty(sectionIds)){
             return info;
         }
@@ -551,6 +612,14 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
             return response;
         }).collect(Collectors.toList());
         list.forEach(item -> {
+            listVoList.forEach(live -> {
+                if (item.getSectionId().equals(live.getSectionId())){
+                    item.setOrderGoodId(live.getOrderGoodId());
+                    item.setGoodsId(live.getGoodId());
+                    item.setModuleId(live.getModuleId());
+                    item.setChapterId(live.getChapterId());
+                }
+            });
             for (LiveChannelBasicInfoResponse response : result) {
                 if (StringUtils.isNotBlank(item.getLiveUrl()) && item.getLiveUrl().equals(response.getChannelId())){
                     item.setWatchStatus(response.getWatchStatus());

+ 5 - 10
zhongzheng-system/src/main/resources/mapper/modules/course/CourseMenuMapper.xml

@@ -289,20 +289,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             AND usr.current_status =1
     </select>
 
-    <select id="getSectionIds" parameterType="Integer"  resultType="Integer">
+    <select id="getSectionIds" parameterType="Integer"  resultType="com.zhongzheng.modules.course.vo.LiveListVo">
         SELECT
-            cs.section_id
+            cm.module_id as moduleId,
+            cm.chapter_id as chapterId,
+            cs.section_id as sectionId
         FROM
             course_module_chapter cm
                 LEFT JOIN course_chapter_section cs ON cm.chapter_id = cs.chapter_id
         WHERE
-             1=1
-             <if test="chapterIds != null and chapterIds.size() > 0">
-             AND cm.module_id IN
-                 <foreach item="id" index="index" collection="chapterIds"
-                          open="(" separator="," close=")">
-                     # {id}
-                 </foreach>
-             </if>
+            cm.module_id = #{moduleId}
     </select>
 </mapper>

+ 4 - 2
zhongzheng-system/src/main/resources/mapper/modules/order/OrderGoodsMapper.xml

@@ -510,9 +510,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 			and og.`status` = 1
 			and mmsg.mock_major_subject_id = #{mockMajorSubjectId}
     </select>
-    <select id="getCourseIdByLive" parameterType="java.lang.Long" resultType="java.lang.Long">
+    <select id="getCourseIdByLive" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.course.vo.LiveListVo">
         SELECT
-            gc.course_id
+            gc.course_id as courseId,
+            og.order_goods_id as orderGoodId,
+            g.goods_id as goodId
         FROM
             `order` o
                 LEFT JOIN order_goods og ON o.order_sn = og.order_sn