he2802 3 лет назад
Родитель
Сommit
30a9412243

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

@@ -6,6 +6,7 @@ import com.zhongzheng.modules.goods.bo.GoodsCourseQueryBo;
 import com.zhongzheng.modules.goods.bo.GoodsQueryBo;
 import com.zhongzheng.modules.goods.domain.GoodsCourse;
 import com.zhongzheng.modules.goods.vo.GoodsCourseMoreVo;
+import com.zhongzheng.modules.goods.vo.GoodsCourseVo;
 import com.zhongzheng.modules.goods.vo.GoodsVo;
 
 import java.util.List;
@@ -19,4 +20,5 @@ import java.util.List;
 public interface GoodsCourseMapper extends BaseMapper<GoodsCourse> {
     List<CourseVo> getList(Long goodsId);
     List<GoodsCourseMoreVo> selectListMore(GoodsCourseQueryBo bo);
+    List<GoodsCourseVo> selectGoodsList(Long courseId);
 }

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

@@ -34,6 +34,8 @@ public interface IGoodsCourseService extends IService<GoodsCourse> {
 
 	List<GoodsCourseMoreVo> selectListMore(List<Long> goodsIds);
 
+	List<GoodsCourseVo> selectGoodsList(Long courseId);
+
 	/**
 	 * 根据新增业务对象插入商品课程关系
 	 * @param bo 商品课程关系新增业务对象

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

@@ -62,6 +62,11 @@ public class GoodsCourseServiceImpl extends ServiceImpl<GoodsCourseMapper, Goods
         return this.baseMapper.selectListMore(bo);
     }
 
+    @Override
+    public List<GoodsCourseVo> selectGoodsList(Long courseId) {
+        return this.baseMapper.selectGoodsList(courseId);
+    }
+
     /**
     * 实体类转化成视图对象
     *

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/vo/GoodsCourseVo.java

@@ -35,4 +35,6 @@ public class GoodsCourseVo {
 	/** 排序 */
 	@ApiModelProperty("排序")
 	private Integer sort;
+	@ApiModelProperty("商品类型")
+	private Integer goodsType;
 }

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/vo/ClassPeriodVo.java

@@ -184,6 +184,10 @@ public class ClassPeriodVo implements Comparable<ClassPeriodVo> {
 	private Long realDuration;
 	@ApiModelProperty("节名称")
 	private String sectionName;
+	@ApiModelProperty("订单商品ID")
+	private Long orderGoodsId;
+
+
 
 	@Override
 	public int compareTo(ClassPeriodVo o) {

+ 66 - 19
zhongzheng-system/src/main/java/com/zhongzheng/modules/schedule/service/impl/ScheduleServiceImpl.java

@@ -15,6 +15,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.github.pagehelper.Page;
 import com.zhongzheng.common.core.redis.RedisCache;
+import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.common.utils.http.HttpUtils;
 import com.zhongzheng.common.utils.polyv.PolyvUtils;
@@ -50,6 +51,7 @@ import com.zhongzheng.modules.exam.vo.ExamBeforeVo;
 import com.zhongzheng.modules.exam.vo.ExamNumberVo;
 import com.zhongzheng.modules.exam.vo.ExamUserApplyVo;
 import com.zhongzheng.modules.goods.bo.GoodsCourseQueryBo;
+import com.zhongzheng.modules.goods.bo.GoodsQueryBo;
 import com.zhongzheng.modules.goods.service.IGoodsCourseService;
 import com.zhongzheng.modules.goods.service.IGoodsService;
 import com.zhongzheng.modules.goods.vo.GoodsCourseVo;
@@ -75,6 +77,7 @@ import com.zhongzheng.modules.inform.vo.InformRemindVo;
 import com.zhongzheng.modules.inform.vo.InformVo;
 import com.zhongzheng.modules.order.bo.OrderQueryBo;
 import com.zhongzheng.modules.order.domain.Order;
+import com.zhongzheng.modules.order.mapper.OrderGoodsMapper;
 import com.zhongzheng.modules.order.mapper.OrderMapper;
 import com.zhongzheng.modules.order.service.IOrderBusinessService;
 import com.zhongzheng.modules.order.service.IOrderGoodsService;
@@ -224,6 +227,9 @@ public class ScheduleServiceImpl extends ServiceImpl<PolyvVideoMapper, PolyvVide
     @Autowired
     private UserStudyRecordMapper userStudyRecordMapper;
 
+    @Autowired
+    private OrderGoodsMapper orderGoodsMapper;
+
     @Value("${aliyun.sms.OpenTheGoodsCode}")
     private String OpenTheGoodsCode;
 
@@ -951,6 +957,7 @@ public class ScheduleServiceImpl extends ServiceImpl<PolyvVideoMapper, PolyvVide
         List<CourseSectionVo> list = iCourseSectionService.overSectionList(startTime, nowTime);
         List<Long> courseIds = new ArrayList<>();//课程ID
         List<ClassPeriodVo> periodList = new ArrayList<>();//学时列表
+        List<ClassPeriodVo> liveList = new ArrayList<>();//直播列表
         for (CourseSectionVo sectionVo : list) {
             //当节为根目录时
             CourseMenuQueryBo menuQueryBo = new CourseMenuQueryBo();
@@ -958,9 +965,7 @@ public class ScheduleServiceImpl extends ServiceImpl<PolyvVideoMapper, PolyvVide
             menuQueryBo.setMenuId(sectionVo.getSectionId());
             List<CourseMenuVo> menuList = iCourseMenuService.queryList(menuQueryBo);
             for (CourseMenuVo menuVo : menuList) {
-                GoodsCourseQueryBo courseQueryBo = new GoodsCourseQueryBo();
-                courseQueryBo.setCourseId(menuVo.getCourseId());
-                List<GoodsCourseVo> goodsList = iGoodsCourseService.queryList(courseQueryBo);
+                List<GoodsCourseVo> goodsList = iGoodsCourseService.selectGoodsList(menuVo.getCourseId());
                 for (GoodsCourseVo goodsCourseVo : goodsList) {
                     ClassPeriodVo periodVo = new ClassPeriodVo();
                     periodVo.setGoodsId(goodsCourseVo.getGoodsId());
@@ -968,7 +973,14 @@ public class ScheduleServiceImpl extends ServiceImpl<PolyvVideoMapper, PolyvVide
                     periodVo.setModuleId(0L);
                     periodVo.setChapterId(0L);
                     periodVo.setSectionId(sectionVo.getSectionId());
-                    periodList.add(periodVo);
+                    periodVo.setLiveStartTime(sectionVo.getLiveStartTime());
+                    periodVo.setLiveEndTime(sectionVo.getLiveEndTime());
+                    if(goodsCourseVo.getGoodsType()==1){  //课程商品
+                        periodList.add(periodVo);
+                    }
+                    if(goodsCourseVo.getGoodsType()==6){  //直播商品
+                        liveList.add(periodVo);
+                    }
                 }
             }
 
@@ -983,9 +995,7 @@ public class ScheduleServiceImpl extends ServiceImpl<PolyvVideoMapper, PolyvVide
                 menuQueryBo2.setMenuId(chapterSectionVo.getChapterId());
                 List<CourseMenuVo> menuList2 = iCourseMenuService.queryList(menuQueryBo2);
                 for (CourseMenuVo menuVo : menuList2) {
-                    GoodsCourseQueryBo courseQueryBo = new GoodsCourseQueryBo();
-                    courseQueryBo.setCourseId(menuVo.getCourseId());
-                    List<GoodsCourseVo> goodsList = iGoodsCourseService.queryList(courseQueryBo);
+                    List<GoodsCourseVo> goodsList = iGoodsCourseService.selectGoodsList(menuVo.getCourseId());
                     for (GoodsCourseVo goodsCourseVo : goodsList) {
                         ClassPeriodVo periodVo = new ClassPeriodVo();
                         periodVo.setGoodsId(goodsCourseVo.getGoodsId());
@@ -993,7 +1003,15 @@ public class ScheduleServiceImpl extends ServiceImpl<PolyvVideoMapper, PolyvVide
                         periodVo.setModuleId(0L);
                         periodVo.setChapterId(chapterSectionVo.getChapterId());
                         periodVo.setSectionId(sectionVo.getSectionId());
-                        periodList.add(periodVo);
+                        periodVo.setLiveStartTime(sectionVo.getLiveStartTime());
+                        periodVo.setLiveEndTime(sectionVo.getLiveEndTime());
+                        if(goodsCourseVo.getGoodsType()==1){  //课程商品
+                            periodList.add(periodVo);
+                        }
+                        if(goodsCourseVo.getGoodsType()==6){
+                            liveList.add(periodVo);
+                        }
+
                     }
                 }
 
@@ -1008,9 +1026,7 @@ public class ScheduleServiceImpl extends ServiceImpl<PolyvVideoMapper, PolyvVide
                     menuQueryBo3.setMenuId(moduleChapterVo.getModuleId());
                     List<CourseMenuVo> menuList3 = iCourseMenuService.queryList(menuQueryBo3);
                     for (CourseMenuVo menuVo : menuList3) {
-                        GoodsCourseQueryBo courseQueryBo = new GoodsCourseQueryBo();
-                        courseQueryBo.setCourseId(menuVo.getCourseId());
-                        List<GoodsCourseVo> goodsList = iGoodsCourseService.queryList(courseQueryBo);
+                        List<GoodsCourseVo> goodsList = iGoodsCourseService.selectGoodsList(menuVo.getCourseId());
                         for (GoodsCourseVo goodsCourseVo : goodsList) {
                             ClassPeriodVo periodVo = new ClassPeriodVo();
                             periodVo.setGoodsId(goodsCourseVo.getGoodsId());
@@ -1018,21 +1034,27 @@ public class ScheduleServiceImpl extends ServiceImpl<PolyvVideoMapper, PolyvVide
                             periodVo.setModuleId(moduleChapterVo.getModuleId());
                             periodVo.setChapterId(chapterSectionVo.getChapterId());
                             periodVo.setSectionId(sectionVo.getSectionId());
-                            periodList.add(periodVo);
+                            periodVo.setLiveStartTime(sectionVo.getLiveStartTime());
+                            periodVo.setLiveEndTime(sectionVo.getLiveEndTime());
+                            if(goodsCourseVo.getGoodsType()==1){
+                                periodList.add(periodVo);
+                            }
+                            if(goodsCourseVo.getGoodsType()==6){
+                                liveList.add(periodVo);
+                            }
                         }
                     }
                 }
             }
         }
 
-        //获取所有直播结束节对应的用户班级列表
+        //视频商品获取所有直播结束节对应的用户班级列表
         for (ClassPeriodVo periodVo : periodList) {
             List<ClassGradeUserGoodsVo> gradeList = iClassGradeUserService.selectGoodsGradeList(periodVo.getGoodsId());
             for (ClassGradeUserGoodsVo gradeUserGoodsVo : gradeList) {
                 UserStudyRecord entity = BeanUtil.toBean(periodVo, UserStudyRecord.class);
                 entity.setGradeId(gradeUserGoodsVo.getGradeId());
                 entity.setUserId(gradeUserGoodsVo.getUserId());
-                System.out.println(entity);
                 Long periodId = null;
                 // 学习无记录加一条学时审核记录
                 if (userStudyRecordMapper.selectStudyRecord(entity) < 1) {
@@ -1055,10 +1077,9 @@ public class ScheduleServiceImpl extends ServiceImpl<PolyvVideoMapper, PolyvVide
                     userPeriodStatusAddBo.setPeriodId(userPeriod.getId());
                     userPeriodStatusAddBo.setCreateTime(DateUtils.getNowTime());
                     userPeriodStatusAddBo.setUpdateTime(DateUtils.getNowTime());
-                    userPeriodStatusAddBo.setRecordEndTime(DateUtils.getNowTime());
+                    userPeriodStatusAddBo.setRecordEndTime(periodVo.getLiveEndTime());
                     iUserPeriodStatusService.save(userPeriodStatusAddBo);
                     periodId = userPeriodStatusAddBo.getId();
-
                 }
                 ClassPeriodVo queryBo = BeanUtil.toBean(entity, ClassPeriodVo.class);
                 Integer status = iUserStudyRecordService.getStudyStatus(queryBo);
@@ -1067,18 +1088,44 @@ public class ScheduleServiceImpl extends ServiceImpl<PolyvVideoMapper, PolyvVide
                     add.setCreateTime(DateUtils.getNowTime());
                     add.setUpdateTime(DateUtils.getNowTime());
                     add.setCurrentStatus(1);
+                    add.setEndTime(periodVo.getLiveEndTime());
                     add.setStatus(1);
+                    add.setOrderGoodsId(gradeUserGoodsVo.getOrderGoodsId());
                     iUserStudyRecordService.save(add);
                     iUserStudyRecordService.studyFinish(add);
                     UserPeriodStatus userPeriodStatus = userStudyRecordMapper.selectPeriodCount(entity);
-                    userPeriodStatus.setRecordEndTime(DateUtils.getNowTime());
+                    userPeriodStatus.setRecordEndTime(periodVo.getLiveEndTime());
                     userPeriodStatus.setUpdateTime(DateUtils.getNowTime());
                     iUserPeriodStatusService.updateById(userPeriodStatus);
                 }
-
             }
         }
-
+        //直播商品
+        for (ClassPeriodVo periodVo : liveList) {
+            GoodsQueryBo goodsQueryBo = new GoodsQueryBo();
+            //购买此商品得订单列表
+            List<OrderGoodsVo> orderGoodsVoList = orderGoodsMapper.listLiveGoodsList(goodsQueryBo);
+            for(OrderGoodsVo orderGoodsVo : orderGoodsVoList){
+                ClassPeriodVo queryBo = BeanUtil.toBean(periodVo, ClassPeriodVo.class);
+                if(Validator.isEmpty(orderGoodsVo.getOrderGoodsId())){
+                    throw new CustomException("学习订单商品ID缺失");
+                }
+                queryBo.setOrderGoodsId(orderGoodsVo.getOrderGoodsId());
+                queryBo.setUserId(orderGoodsVo.getUserId());
+                Integer status = iUserStudyRecordService.getStudyStatus(queryBo);
+                if (Validator.isEmpty(status) || status != 1) {
+                    UserStudyRecord add = BeanUtil.toBean(queryBo, UserStudyRecord.class);
+                    add.setCreateTime(DateUtils.getNowTime());
+                    add.setUpdateTime(DateUtils.getNowTime());
+                    add.setCurrentStatus(1);
+                    add.setStatus(1);
+                    add.setEndTime(periodVo.getLiveEndTime());
+                    add.setStartTime(periodVo.getLiveStartTime());
+                    add.setFirstStartTime(periodVo.getLiveStartTime());
+                    iUserStudyRecordService.save(add);
+                }
+            }
+        }
     }
 
     @Override

+ 12 - 0
zhongzheng-system/src/main/resources/mapper/modules/goods/GoodsCourseMapper.xml

@@ -11,6 +11,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="sort" column="sort"/>
     </resultMap>
 
+    <resultMap type="com.zhongzheng.modules.goods.vo.GoodsCourseVo" id="GoodsCourseVoResult">
+        <result property="id" column="id"/>
+        <result property="goodsId" column="goods_id"/>
+        <result property="courseId" column="course_id"/>
+        <result property="sort" column="sort"/>
+        <result property="goodsType" column="goods_type"/>
+    </resultMap>
+
     <resultMap type="com.zhongzheng.modules.course.vo.CourseVo" id="CourseResultVo">
         <result property="courseId" column="course_id"/>
         <result property="prefixName" column="prefix_name"/>
@@ -47,6 +55,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <collection property="courseList" column="goods_id" select="findCourseList"/>
     </resultMap>
 
+    <select id="selectGoodsList" parameterType="Long" resultMap="GoodsCourseVoResult">
+        SELECT
+            gc.*,g.goods_type from goods_course gc LEFT JOIN goods g ON gc.goods_id = g.goods_id where gc.course_id = #{courseId}
+    </select>
 
     <select id="getList" parameterType="Long" resultMap="CourseResultVo">
         SELECT

+ 2 - 1
zhongzheng-system/src/main/resources/mapper/modules/grade/ClassGradeUserMapper.xml

@@ -1188,7 +1188,8 @@
         SELECT
             cgg.goods_id,
             cgg.grade_id,
-            cgu.user_id
+            cgu.user_id,
+            cgu.order_goods_id
         FROM
             class_grade_goods cgg
                 LEFT JOIN class_grade_user cgu ON cgg.grade_id = cgu.grade_id

+ 0 - 15
zhongzheng-system/src/main/resources/mapper/modules/order/OrderGoodsMapper.xml

@@ -338,9 +338,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="listLiveGoodsList" parameterType="com.zhongzheng.modules.goods.bo.GoodsQueryBo" resultMap="OrderGoodsResultVo">
         SELECT
         g.*,
-        cet.education_name,
-        cpt.project_name,
-        cb.business_name,
         o.user_id,
         o.order_sn,
         og.service_start_time,
@@ -354,9 +351,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         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
-        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 `user` u ON u.user_id = o.user_id
         LEFT JOIN (SELECT
         usr.order_goods_id,
@@ -377,15 +371,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="goodsId != null and goodsId != ''">
             AND og.goods_id = #{goodsId}
         </if>
-        <if test="educationTypeId != null and educationTypeId != ''">
-            AND g.education_type_id = #{educationTypeId}
-        </if>
-        <if test="businessId != null and businessId != ''">
-            AND g.business_id = #{businessId}
-        </if>
-        <if test="majorId != null and majorId != ''">
-            AND g.major_id = #{majorId}
-        </if>
         <if test="searchKey != null and searchKey != ''">
             and (g.goods_name like concat('%', #{searchKey}, '%') or g.code like concat('%', #{searchKey}, '%') or u.realname like concat('%', #{searchKey}, '%') or u.id_card like concat('%', #{searchKey}, '%'))
         </if>

+ 21 - 3
zhongzheng-system/src/main/resources/mapper/modules/user/UserStudyRecordMapper.xml

@@ -1238,13 +1238,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         FROM
             user_study_record
         WHERE
-            user_id = #{userId}
+              1=1
+        <if test="userId != null and userId !='' ">
+            AND user_id = #{userId}
+        </if>
+        <if test="gradeId != null and gradeId !='' ">
           AND grade_id = #{gradeId}
+        </if>
+        <if test="courseId != null and courseId !='' ">
           AND course_id = #{courseId}
+        </if>
+        <if test="moduleId != null and moduleId !='' ">
           AND module_id = #{moduleId}
+        </if>
+        <if test="chapterId != null and chapterId !='' ">
           AND chapter_id = #{chapterId}
-          AND section_id = #{sectionId}
-          AND goods_id = #{goodsId}
+        </if>
+        <if test="sectionId != null and sectionId !='' ">
+            AND section_id = #{sectionId}
+        </if>
+        <if test="goodsId != null and goodsId !='' ">
+            AND goods_id = #{goodsId}
+        </if>
+        <if test="orderGoodsId != null and orderGoodsId !='' ">
+            AND order_goods_id = #{orderGoodsId}
+        </if>
           AND `status` = 1
           AND current_status = 1
     </select>