Browse Source

up:直播提醒接口修改

yangdamao 3 years ago
parent
commit
dca3f293d8

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

@@ -243,8 +243,9 @@ public class GoodsController extends BaseController {
     @ApiOperation("获取直播提醒列表")
     @GetMapping("/getLiveList")
     public TableDataInfo<CourseLiveVo> liveList() {
+        startPage();
         ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
-        PageDomain pageDomain = TableSupport.getPageDomain();
-        return iOrderGoodsService.getLiveList(pageDomain,loginUser.getUser().getUserId());
+        List<CourseLiveVo> list = iOrderGoodsService.getLiveList(loginUser.getUser().getUserId());
+        return getDataTable(list);
     }
 }

+ 0 - 4
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/mapper/CourseMenuMapper.java

@@ -5,8 +5,6 @@ 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.CourseVo;
-import com.zhongzheng.modules.course.vo.LiveListVo;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -33,6 +31,4 @@ public interface CourseMenuMapper extends BaseMapper<CourseMenu> {
     Long getStudyDuration(@Param("sectionId") Long id,@Param("gradeId") Long gradeId,@Param("userId")Long userId,@Param("courseId")Long courseId);
 
     Integer auditCheck(@Param("sectionId") Long id,@Param("gradeId") Long gradeId,@Param("userId")Long userId,@Param("courseId")Long courseId);
-
-    List<LiveListVo> getSectionIds(@Param("moduleId") Long moduleId);
 }

+ 0 - 12
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/ICourseMenuService.java

@@ -1,14 +1,11 @@
 package com.zhongzheng.modules.course.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
-import com.zhongzheng.modules.course.bo.CourseMenuAddBo;
-import com.zhongzheng.modules.course.bo.CourseMenuEditBo;
 import com.zhongzheng.modules.course.bo.CourseMenuListAddBo;
 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;
@@ -58,13 +55,4 @@ public interface ICourseMenuService extends IService<CourseMenu> {
 	Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
 
 	List<CourseUserMenuVo> menuList(CourseMenuQueryBo bo);
-
-	/**
-	 * 获取节ID
-	 * @author yangdamao
-	 * @date 2022/7/14 9:44
-	 * @param moduleId
-	 * @return java.util.List<java.lang.Long>
-	 */
-	List<LiveListVo> getSectionIds(Long moduleId);
 }

+ 7 - 18
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseMenuServiceImpl.java

@@ -2,38 +2,32 @@ package com.zhongzheng.modules.course.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.lang.Validator;
-import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.Page;
 import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.DateUtils;
-import com.zhongzheng.modules.course.bo.*;
+import com.zhongzheng.modules.course.bo.CourseAddBo;
+import com.zhongzheng.modules.course.bo.CourseMenuListAddBo;
+import com.zhongzheng.modules.course.bo.CourseMenuQueryBo;
 import com.zhongzheng.modules.course.domain.CourseMenu;
 import com.zhongzheng.modules.course.domain.CourseMenuExam;
-import com.zhongzheng.modules.course.domain.CourseModuleBusiness;
-import com.zhongzheng.modules.course.domain.CourseModuleChapter;
-import com.zhongzheng.modules.course.mapper.CourseChapterMapper;
 import com.zhongzheng.modules.course.mapper.CourseMenuMapper;
 import com.zhongzheng.modules.course.service.ICourseMenuExamService;
 import com.zhongzheng.modules.course.service.ICourseMenuService;
 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;
 import com.zhongzheng.modules.goods.vo.GoodsVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.github.pagehelper.Page;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.util.CollectionUtils;
 
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -273,9 +267,4 @@ public class CourseMenuServiceImpl extends ServiceImpl<CourseMenuMapper, CourseM
         }
         return courseMenuVos;
     }
-
-    @Override
-    public List<LiveListVo> getSectionIds(Long moduleId) {
-        return baseMapper.getSectionIds(moduleId);
-    }
 }

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

@@ -1,32 +0,0 @@
-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;
-}

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

@@ -1,7 +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.course.vo.CourseLiveVo;
 import com.zhongzheng.modules.goods.bo.GoodsQueryBo;
 import com.zhongzheng.modules.order.bo.OrderGoodsQueryBo;
 import com.zhongzheng.modules.order.domain.OrderGoods;
@@ -46,7 +46,7 @@ public interface OrderGoodsMapper extends BaseMapper<OrderGoods> {
 
     List<OrderGoodsVo> selectBuyUserList(Long mockMajorSubjectId);
 
-    List<LiveListVo> getCourseIdByLive(Long userId);
-
     List<OrderGoodsVo> listUserVideoLive(GoodsQueryBo bo);
+
+    List<CourseLiveVo> getLiveList(Long userId);
 }

+ 1 - 2
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/IOrderGoodsService.java

@@ -96,11 +96,10 @@ public interface IOrderGoodsService extends IService<OrderGoods> {
      *
      * @author 获取直播提醒列表
      * @date 2022/7/14 8:52
-     * @param pageDomain
      * @param userId
      * @return com.zhongzheng.common.core.page.TableDataInfo<com.zhongzheng.modules.course.vo.CourseLiveVo>
      */
-    TableDataInfo<CourseLiveVo> getLiveList(PageDomain pageDomain,Long userId);
+    List<CourseLiveVo> getLiveList(Long userId);
 
     List<OrderGoodsVo> listUserVideoLive(GoodsQueryBo bo);
 }

+ 42 - 129
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderGoodsServiceImpl.java

@@ -3,26 +3,22 @@ package com.zhongzheng.modules.order.service.impl;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.lang.Validator;
 import cn.hutool.core.util.StrUtil;
-import cn.hutool.http.HttpStatus;
 import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
-import com.zhongzheng.common.core.page.PageDomain;
-import com.zhongzheng.common.core.page.TableDataInfo;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.Page;
 import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.common.utils.SecurityUtils;
 import com.zhongzheng.modules.base.bo.ConsoleQueryBo;
-import com.zhongzheng.modules.course.domain.CourseChapterSection;
-import com.zhongzheng.modules.course.domain.CourseMenu;
-import com.zhongzheng.modules.course.domain.CourseSection;
 import com.zhongzheng.modules.course.service.ICourseChapterSectionService;
-import com.zhongzheng.modules.course.service.ICourseChapterService;
 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;
@@ -34,7 +30,10 @@ import com.zhongzheng.modules.grade.service.IClassGradeService;
 import com.zhongzheng.modules.grade.service.IClassGradeUserService;
 import com.zhongzheng.modules.grade.vo.ClassGradeVo;
 import com.zhongzheng.modules.grade.vo.ClassPeriodVo;
-import com.zhongzheng.modules.order.bo.*;
+import com.zhongzheng.modules.order.bo.OrderGoodsAddBo;
+import com.zhongzheng.modules.order.bo.OrderGoodsEditBo;
+import com.zhongzheng.modules.order.bo.OrderGoodsQueryBo;
+import com.zhongzheng.modules.order.bo.OrderSubjectUserBuyBo;
 import com.zhongzheng.modules.order.domain.OrderGoods;
 import com.zhongzheng.modules.order.mapper.OrderGoodsMapper;
 import com.zhongzheng.modules.order.service.IOrderGoodsService;
@@ -55,17 +54,15 @@ import com.zhongzheng.modules.user.service.IUserSubscribeService;
 import com.zhongzheng.modules.user.vo.SubjectStudyRecordVo;
 import net.polyv.common.v1.util.StringUtils;
 import net.polyv.live.v1.entity.channel.operate.LiveChannelBasicInfoResponse;
-import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.github.pagehelper.Page;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
 import java.util.stream.Collectors;
 
 /**
@@ -485,88 +482,40 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
         return baseMapper.selectBuyUserList(mockMajorSubjectId);
     }
 
+    /**
+     * 查询用户拥有视频+直播商品
+     * @param bo
+     * @return
+     */
     @Override
-    public TableDataInfo<CourseLiveVo> getLiveList(PageDomain pageDomain, Long userId) {
-        TableDataInfo<CourseLiveVo> info = new TableDataInfo<>();
-        info.setCode(HttpStatus.HTTP_OK);
-        info.setMsg("查询成功");
-        //获取所有直播课程ID
-        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;
-        }
-        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);
-                    }
-                    break;
+    public List<OrderGoodsVo> listUserVideoLive(GoodsQueryBo bo) {
+        List<OrderGoodsVo> list = this.baseMapper.listUserVideoLive(bo);
+        for(OrderGoodsVo goodsVo : list){
+            Long secLong = 0L;
+            Long studyLong = 0L;
+            SubjectStudyRecordQueryBo subjectStudyRecordQueryBo = new SubjectStudyRecordQueryBo();
+            subjectStudyRecordQueryBo.setGoodsId(goodsVo.getGoodsId());
+            subjectStudyRecordQueryBo.setUserId(bo.getUserId());
+            subjectStudyRecordQueryBo.setOrderGoodsId(goodsVo.getOrderGoodsId());
+            List<SubjectStudyRecordVo> subjectStudyRecordVos = iUserStudyRecordService.listSubject(subjectStudyRecordQueryBo);
+            for (SubjectStudyRecordVo subjectStudyRecordVo : subjectStudyRecordVos) {
+                secLong = new BigDecimal(secLong.toString()).add(new BigDecimal(subjectStudyRecordVo.getSectionNum().toString())).longValue();
+                studyLong = new BigDecimal(studyLong.toString()).add(new BigDecimal(subjectStudyRecordVo.getRecordNum().toString())).longValue();
             }
-        });
-        listVoList.forEach(vo -> {
-            liveVos.forEach(item -> {
-                if (vo.getCourseId().equals(item.getCourseId())){
-                    vo.setGoodId(item.getGoodId());
-                    vo.setOrderGoodId(item.getOrderGoodId());
-                }
-            });
-        });
-        List<Long> sectionIds = listVoList.stream().map(LiveListVo::getSectionId).collect(Collectors.toList());
-        if (CollectionUtils.isEmpty(sectionIds)){
-            return info;
+            goodsVo.setSecAllNum(secLong);
+            goodsVo.setStuAllNum(studyLong);
         }
+        return list;
+    }
 
-        //分页查询节直播信息
-        com.baomidou.mybatisplus.extension.plugins.pagination.Page<CourseSection> page = courseSectionService.page(new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(pageDomain.getPageNum(), pageDomain.getPageSize()),
-                new LambdaQueryWrapper<CourseSection>()
-                        .in(CourseSection::getSectionId, sectionIds)
-                        .eq(CourseSection::getSectionType,2)//类型为直播
-                        .orderByAsc(CourseSection::getLiveStartTime));
-        if (CollectionUtils.isEmpty(page.getRecords())){
-            return info;
+    @Override
+    public List<CourseLiveVo> getLiveList(Long userId) {
+        List<CourseLiveVo> liveVos = orderGoodsMapper.getLiveList(userId);
+        if (CollectionUtils.isEmpty(liveVos)){
+            return new ArrayList<>();
         }
-        List<CourseLiveVo> list = page.getRecords().stream().map(item -> BeanUtil.copyProperties(item, CourseLiveVo.class)).collect(Collectors.toList());
         //获取保利威直播状态
-        Set<String> setUrl = list.stream().filter(x -> StringUtils.isNotBlank(x.getLiveUrl())).map(CourseLiveVo::getLiveUrl).collect(Collectors.toSet());
+        Set<String> setUrl = liveVos.stream().filter(x -> StringUtils.isNotBlank(x.getLiveUrl())).map(CourseLiveVo::getLiveUrl).collect(Collectors.toSet());
         List<LiveChannelBasicInfoResponse> result = setUrl.stream().map(url -> {
             PolyvLiveQueryBo bo = new PolyvLiveQueryBo();
             bo.setChannelId(url);
@@ -580,50 +529,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());
-                }
-            });
+        liveVos.forEach(item -> {
             for (LiveChannelBasicInfoResponse response : result) {
                 if (StringUtils.isNotBlank(item.getLiveUrl()) && item.getLiveUrl().equals(response.getChannelId())){
                     item.setWatchStatus(response.getWatchStatus());
                 }
             }
         });
-        info.setTotal(page.getTotal());
-        info.setRows(list);
-        return info;
-    }
-
-    /**
-     * 查询用户拥有视频+直播商品
-     * @param bo
-     * @return
-     */
-    @Override
-    public List<OrderGoodsVo> listUserVideoLive(GoodsQueryBo bo) {
-        List<OrderGoodsVo> list = this.baseMapper.listUserVideoLive(bo);
-        for(OrderGoodsVo goodsVo : list){
-            Long secLong = 0L;
-            Long studyLong = 0L;
-            SubjectStudyRecordQueryBo subjectStudyRecordQueryBo = new SubjectStudyRecordQueryBo();
-            subjectStudyRecordQueryBo.setGoodsId(goodsVo.getGoodsId());
-            subjectStudyRecordQueryBo.setUserId(bo.getUserId());
-            subjectStudyRecordQueryBo.setOrderGoodsId(goodsVo.getOrderGoodsId());
-            List<SubjectStudyRecordVo> subjectStudyRecordVos = iUserStudyRecordService.listSubject(subjectStudyRecordQueryBo);
-            for (SubjectStudyRecordVo subjectStudyRecordVo : subjectStudyRecordVos) {
-                secLong = new BigDecimal(secLong.toString()).add(new BigDecimal(subjectStudyRecordVo.getSectionNum().toString())).longValue();
-                studyLong = new BigDecimal(studyLong.toString()).add(new BigDecimal(subjectStudyRecordVo.getRecordNum().toString())).longValue();
-            }
-            goodsVo.setSecAllNum(secLong);
-            goodsVo.setStuAllNum(studyLong);
-        }
-        return list;
+        return liveVos;
     }
 
     public boolean joinGrade(Long orderGoodsId, Long gradeId, Long userId, Long goodsId) {

+ 0 - 12
zhongzheng-system/src/main/resources/mapper/modules/course/CourseMenuMapper.xml

@@ -288,16 +288,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             and usr.course_id=#{courseId}
             AND usr.current_status =1
     </select>
-
-    <select id="getSectionIds" parameterType="Integer"  resultType="com.zhongzheng.modules.course.vo.LiveListVo">
-        SELECT
-            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
-            cm.module_id = #{moduleId}
-    </select>
 </mapper>

+ 84 - 17
zhongzheng-system/src/main/resources/mapper/modules/order/OrderGoodsMapper.xml

@@ -510,24 +510,91 @@ 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="com.zhongzheng.modules.course.vo.LiveListVo">
+    <select id="getLiveList" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.course.vo.CourseLiveVo">
         SELECT
-            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
-                LEFT JOIN goods g ON og.goods_id = g.goods_id
-                INNER JOIN goods_course gc ON g.goods_id = gc.goods_id
-        WHERE
-            o.user_id = #{userId}
-          AND o.order_status = 1
-          AND og.pay_status in (2,3,4)
-          AND og.refund_status != 2
-          AND og.status = 1
-          AND o.`status` = 1
-          AND g.`status` = 1
-          AND g.goods_type = 6
+            (
+                SELECT
+                    gc.course_id AS courseId,
+                    og.order_goods_id AS orderGoodId,
+                    g.goods_id AS goodId,
+                    cm.menu_id AS chapterId,
+                    '' AS moduleId,
+                    ct.*
+                FROM
+                    `order` o
+                        LEFT JOIN order_goods og ON o.order_sn = og.order_sn
+                        LEFT JOIN goods g ON og.goods_id = g.goods_id
+                        INNER JOIN goods_course gc ON g.goods_id = gc.goods_id
+                        LEFT JOIN course_menu cm ON gc.course_id = cm.course_id
+                        LEFT JOIN course_chapter_section cs ON cm.menu_id = cs.chapter_id
+                        LEFT JOIN course_section ct ON cs.section_id = ct.section_id
+                WHERE
+                    o.user_id = #{userId}
+                  AND o.order_status = 1
+                  AND og.pay_status IN ( 2, 3, 4 )
+                  AND og.refund_status != 2
+		          AND og.STATUS = 1
+		          AND o.`status` = 1
+		          AND g.`status` = 1
+		          AND g.goods_type = 6
+		          AND cm.type = 2
+		          AND ct.section_type = 2 UNION ALL
+                SELECT
+                    gc.course_id AS courseId,
+                    og.order_goods_id AS orderGoodId,
+                    g.goods_id AS goodId,
+                    '' AS chapterId,
+                    '' AS moduleId,
+                    ct.*
+                FROM
+                    `order` o
+                    LEFT JOIN order_goods og ON o.order_sn = og.order_sn
+                    LEFT JOIN goods g ON og.goods_id = g.goods_id
+                    INNER JOIN goods_course gc ON g.goods_id = gc.goods_id
+                    LEFT JOIN course_menu cm ON gc.course_id = cm.course_id
+                    LEFT JOIN course_section ct ON cm.menu_id = ct.section_id
+                WHERE
+                    o.user_id = #{userId}
+                  AND o.order_status = 1
+                  AND og.pay_status IN ( 2, 3, 4 )
+                  AND og.refund_status != 2
+                  AND og.STATUS = 1
+                  AND o.`status` = 1
+                  AND g.`status` = 1
+                  AND g.goods_type = 6
+                  AND cm.type = 3
+                  AND ct.section_type = 2 UNION ALL
+                SELECT
+                    gc.course_id AS courseId,
+                    og.order_goods_id AS orderGoodId,
+                    g.goods_id AS goodId,
+                    cmc.chapter_id AS chapterId,
+                    cmc.module_id AS moduleId,
+                    ct.*
+                FROM
+                    `order` o
+                    LEFT JOIN order_goods og ON o.order_sn = og.order_sn
+                    LEFT JOIN goods g ON og.goods_id = g.goods_id
+                    INNER JOIN goods_course gc ON g.goods_id = gc.goods_id
+                    LEFT JOIN course_menu cm ON gc.course_id = cm.course_id
+                    LEFT JOIN course_module_chapter cmc ON cm.menu_id = cmc.module_id
+                    LEFT JOIN course_chapter_section ccs ON cmc.chapter_id = ccs.chapter_id
+                    LEFT JOIN course_section ct ON ccs.section_id = ct.section_id
+                WHERE
+                    o.user_id = #{userId}
+                  AND o.order_status = 1
+                  AND og.pay_status IN ( 2, 3, 4 )
+                  AND og.refund_status != 2
+                  AND og.STATUS = 1
+                  AND o.`status` = 1
+                  AND g.`status` = 1
+                  AND g.goods_type = 6
+                  AND cm.type = 1
+                  AND ct.section_type = 2
+            ) a
+        ORDER BY
+            a.live_start_time ASC
     </select>
 </mapper>