Explorar o código

提交:BUG处理

yangdamao %!s(int64=3) %!d(string=hai) anos
pai
achega
0c0cfb1345

+ 1 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/IUserPeriodService.java

@@ -6,6 +6,7 @@ import com.zhongzheng.modules.grade.bo.UserPeriodQueryBo;
 import com.zhongzheng.modules.grade.bo.UserPeriodAddBo;
 import com.zhongzheng.modules.grade.bo.UserPeriodEditBo;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.zhongzheng.modules.user.domain.UserStudyRecord;
 
 import java.util.Collection;
 import java.util.List;

+ 7 - 3
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/impl/UserPeriodServiceImpl.java

@@ -170,9 +170,9 @@ public class UserPeriodServiceImpl extends ServiceImpl<UserPeriodMapper, UserPer
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Boolean updateByEditBo(UserPeriodEditBo bo) {
-        LoginUser loginUser = SecurityUtils.getLoginUser();
         UserPeriodStatusVo oldData = userPeriodStatusService.queryById(bo.getId());
         Long goodsId;
+        String userName = "系统自动审核通过";
         if (ObjectUtils.isNotNull(bo.getGoodsId())){
             goodsId = bo.getGoodsId();
         }else {
@@ -185,6 +185,8 @@ public class UserPeriodServiceImpl extends ServiceImpl<UserPeriodMapper, UserPer
         if (ObjectUtils.isNull(business.getPeriodType()) || business.getPeriodType() == 1){
             //人工审核
             //查询此人学时审核是否有权限
+            LoginUser loginUser = SecurityUtils.getLoginUser();
+            userName = SecurityUtils.getUsername();
             if (!loginUser.getUser().isAdmin()) {
                 if (baseMapper.selectCountPeriod(loginUser.getUser().getUserId(), bo.getId()) < 1) {
                     throw new IllegalArgumentException("您没有审核权限");
@@ -202,7 +204,7 @@ public class UserPeriodServiceImpl extends ServiceImpl<UserPeriodMapper, UserPer
         userUp.setStatus(bo.getStatus());
         userUp.setUpdateTime(DateUtils.getNowTime());
         userUp.setAuditTime(DateUtils.getNowTime());
-        userUp.setAuditUserName(SecurityUtils.getUsername());
+        userUp.setAuditUserName(userName);
         userUp.setAuditReason(bo.getAuditReason());
         userPeriodStatusService.updateById(userUp);
 
@@ -315,6 +317,7 @@ public class UserPeriodServiceImpl extends ServiceImpl<UserPeriodMapper, UserPer
         //获取业务学时审核数据
         Goods goods = iGoodsService.getById(bo.getGoodsId());
         CourseBusiness business = iCourseBusinessService.getById(goods.getBusinessId());
+        String userName = "系统自动审核通过";
         if (ObjectUtils.isNull(business.getPeriodType()) || business.getPeriodType() == 1){
             //人工审核
             if (Validator.isEmpty(bo.getUserId()) || Validator.isEmpty(bo.getGoodsId()) || Validator.isEmpty(bo.getGradeId())) {
@@ -324,6 +327,7 @@ public class UserPeriodServiceImpl extends ServiceImpl<UserPeriodMapper, UserPer
                 throw new CustomException("非审核中状态无法确认审核");
             }
             LoginUser loginUser = SecurityUtils.getLoginUser();
+            userName = SecurityUtils.getUsername();
             //查询此人学时审核是否有权限
             if (!loginUser.getUser().isAdmin()) {
                 if (baseMapper.selectCountConfirmPeriod(loginUser.getUser().getUserId(), bo.getGoodsId()) < 1) {
@@ -336,7 +340,7 @@ public class UserPeriodServiceImpl extends ServiceImpl<UserPeriodMapper, UserPer
         objectLambdaUpdateWrapper.set(ClassGradeUser::getPeriodStatus, 1);
         objectLambdaUpdateWrapper.set(ClassGradeUser::getUpdateTime, DateUtils.getNowTime());
         objectLambdaUpdateWrapper.set(ClassGradeUser::getPeriodTime, DateUtils.getNowTime());
-        objectLambdaUpdateWrapper.set(ClassGradeUser::getAuditUserName, SecurityUtils.getUsername());
+        objectLambdaUpdateWrapper.set(ClassGradeUser::getAuditUserName, userName);
         //判断结业
         long nowTime = System.currentTimeMillis() / 1000;
         ClassGradeUserQueryBo queryBo = new ClassGradeUserQueryBo();

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/mapper/UserStudyRecordMapper.java

@@ -98,4 +98,6 @@ public interface UserStudyRecordMapper extends BaseMapper<UserStudyRecord> {
     List<CourseSectionDetailVo> getUserByRecord(CourseSectionDetailBo bo);
 
     List<CourseStatementVo> getCourseStatement(CourseStatementBo bo);
+
+    Long getPeriodIdByQuery(UserStudyRecord bo);
 }

+ 11 - 2
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserStudyRecordServiceImpl.java

@@ -431,12 +431,21 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
                     CourseBusiness business = iCourseBusinessService.getById(goods.getBusinessId());
                     if (ObjectUtils.isNotNull(business) && ObjectUtils.isNotNull(business.getPeriodType()) && business.getPeriodType() == 2){
                         //自动审核
+                        //初审
+                        Long id = baseMapper.getPeriodIdByQuery(bo);
                         UserPeriodEditBo editBo = new UserPeriodEditBo();
+                        editBo.setId(id);
+                        editBo.setStatus(1);
                         editBo.setGoodsId(bo.getGoodsId());
                         editBo.setGradeId(bo.getGradeId());
                         editBo.setUserId(bo.getUserId());
                         iUserPeriodService.updateByEditBo(editBo);
-                        iUserPeriodService.confirmPeriod(editBo);
+                        //复审
+                        UserPeriodEditBo confirm = new UserPeriodEditBo();
+                        confirm.setGoodsId(bo.getGoodsId());
+                        confirm.setGradeId(bo.getGradeId());
+                        confirm.setUserId(bo.getUserId());
+                        iUserPeriodService.confirmPeriod(confirm);
                         return;
                     }
 
@@ -494,7 +503,7 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
             }
 
         }
-    }
+     }
 
     //判断学习顺序1
     @Override

+ 448 - 415
zhongzheng-system/src/main/resources/mapper/modules/user/UserStudyRecordMapper.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper
-PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.zhongzheng.modules.user.mapper.UserStudyRecordMapper">
 
     <resultMap type="com.zhongzheng.modules.user.domain.UserStudyRecord" id="UserStudyRecordResult">
@@ -154,8 +154,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
 
-
-    <select id="getListByBo" parameterType="com.zhongzheng.modules.user.bo.UserStudyRecordQueryBo"  resultMap="UserStudyRecordResult">
+    <select id="getListByBo" parameterType="com.zhongzheng.modules.user.bo.UserStudyRecordQueryBo"
+            resultMap="UserStudyRecordResult">
         SELECT DISTINCT
         temp.course_id,
         c.cover_url,
@@ -163,13 +163,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         FROM
         ( SELECT course_id FROM user_study_record WHERE 1 = 1
         <if test="userId != null and userId != ''">
-            AND  user_id = #{userId}
+            AND user_id = #{userId}
         </if>
         ORDER BY record_id DESC LIMIT 30 ) temp
         LEFT JOIN course c ON temp.course_id = c.course_id
     </select>
 
-    <select id="selectUserStudy" parameterType="map"  resultMap="UserStudyRecordResult">
+    <select id="selectUserStudy" parameterType="map" resultMap="UserStudyRecordResult">
         select * FROM user_study_record where 1=1
         <if test="userId != null and userId != ''">
             and user_id =#{userId}
@@ -180,7 +180,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         and study_duration > 360
     </select>
 
-    <select id="queryGoods" parameterType="com.zhongzheng.modules.user.bo.UserQueryBo"  resultMap="GoodsStudyRecordVoResult">
+    <select id="queryGoods" parameterType="com.zhongzheng.modules.user.bo.UserQueryBo"
+            resultMap="GoodsStudyRecordVoResult">
         SELECT
         g.goods_name,
         g.`code`,
@@ -191,14 +192,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         g.goods_id,
         u.grade_id,
         u.user_id,
-        (SELECT og.service_start_time FROM order_goods og  where og.order_goods_id = u.order_goods_id ) as service_start_time,
-        (SELECT og.service_end_time FROM order_goods og  where og.order_goods_id = u.order_goods_id ) as service_end_time,
+        (SELECT og.service_start_time FROM order_goods og where og.order_goods_id = u.order_goods_id ) as
+        service_start_time,
+        (SELECT og.service_end_time FROM order_goods og where og.order_goods_id = u.order_goods_id ) as
+        service_end_time,
         (SELECT i.business_name FROM course_business i where i.id = g.business_id) as business_name,
         (SELECT p.project_name FROM course_project_type p where p.id = g.project_id) as project_name,
-        (SELECT s.school_name FROM school s  where s.id = g.school_id) as school_name,
-        (SELECT e.education_name FROM course_education_type e  where e.id = g.education_type_id) as education_name,
-        (SELECT r.start_time FROM user_study_record r  where 1=1  and r.user_id = #{userId} AND g.goods_id=r.goods_id ORDER BY r.start_time ASC LIMIT 1) as start_time,
-        (SELECT r.end_time FROM user_study_record r  where 1=1 and r.user_id = #{userId} AND g.goods_id=r.goods_id ORDER BY r.start_time DESC LIMIT 1) as end_time
+        (SELECT s.school_name FROM school s where s.id = g.school_id) as school_name,
+        (SELECT e.education_name FROM course_education_type e where e.id = g.education_type_id) as education_name,
+        (SELECT r.start_time FROM user_study_record r where 1=1 and r.user_id = #{userId} AND g.goods_id=r.goods_id
+        ORDER BY r.start_time ASC LIMIT 1) as start_time,
+        (SELECT r.end_time FROM user_study_record r where 1=1 and r.user_id = #{userId} AND g.goods_id=r.goods_id ORDER
+        BY r.start_time DESC LIMIT 1) as end_time
         FROM
         class_grade_user u
         LEFT JOIN class_grade_goods d ON u.grade_id = d.grade_id
@@ -212,7 +217,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         ORDER BY u.create_time desc
     </select>
 
-    <select id="queryLiveGoods" parameterType="com.zhongzheng.modules.user.bo.UserQueryBo"  resultMap="GoodsStudyRecordVoResult">
+    <select id="queryLiveGoods" parameterType="com.zhongzheng.modules.user.bo.UserQueryBo"
+            resultMap="GoodsStudyRecordVoResult">
         SELECT
         g.goods_name,
         g.`code`,
@@ -227,9 +233,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         og.order_goods_id,
         (SELECT i.business_name FROM course_business i where i.id = g.business_id) as business_name,
         (SELECT p.project_name FROM course_project_type p where p.id = g.project_id) as project_name,
-        (SELECT e.education_name FROM course_education_type e  where e.id = g.education_type_id) as education_name,
-        (SELECT r.start_time FROM user_study_record r  where 1=1  and r.user_id = #{userId} AND g.goods_id=r.goods_id ORDER BY r.start_time ASC LIMIT 1) as start_time,
-        (SELECT r.end_time FROM user_study_record r  where 1=1 and r.user_id = #{userId} AND g.goods_id=r.goods_id ORDER BY r.start_time DESC LIMIT 1) as end_time
+        (SELECT e.education_name FROM course_education_type e where e.id = g.education_type_id) as education_name,
+        (SELECT r.start_time FROM user_study_record r where 1=1 and r.user_id = #{userId} AND g.goods_id=r.goods_id
+        ORDER BY r.start_time ASC LIMIT 1) as start_time,
+        (SELECT r.end_time FROM user_study_record r where 1=1 and r.user_id = #{userId} AND g.goods_id=r.goods_id ORDER
+        BY r.start_time DESC LIMIT 1) as end_time
         FROM
         `order` o
         LEFT JOIN order_goods og ON o.order_sn = og.order_sn
@@ -246,27 +254,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
 
-    <select id="listSubject" parameterType="com.zhongzheng.modules.user.bo.SubjectStudyRecordQueryBo"  resultMap="SubjectStudyRecordVoResult">
+    <select id="listSubject" parameterType="com.zhongzheng.modules.user.bo.SubjectStudyRecordQueryBo"
+            resultMap="SubjectStudyRecordVoResult">
         SELECT
         #{userId} as user_id,
         r.subject_id,
         r.course_id,
         r.course_name,
-        (SELECT subject_name FROM course_subject s where  s.id = r.subject_id) as subject_name,
-        (CASE WHEN (SELECT COUNT(id) FROM course_menu m where  m.course_id = r.course_id and m.type in(1,2,3))> 0 THEN '1' ELSE '0' END) as begin_status,
-        (SELECT COUNT(id) FROM course_menu m where  m.course_id = r.course_id and m.type in(1)) as module_num,
-        (SELECT COUNT(id)+(SELECT COUNT(p.id) FROM course_module_chapter p LEFT JOIN course_menu m  on m.menu_id = p.module_id where  m.course_id = r.course_id and m.type in(1)) FROM course_menu m where  m.course_id = r.course_id and m.type in(2)) as chapter_num,
-        (SELECT COUNT(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 where m.course_id =  r.course_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 where m.course_id = r.course_id and m.type in(2)) FROM course_menu m where  m.course_id = r.course_id and m.type in(3)) as section_num,
+        (SELECT subject_name FROM course_subject s where s.id = r.subject_id) as subject_name,
+        (CASE WHEN (SELECT COUNT(id) FROM course_menu m where m.course_id = r.course_id and m.type in(1,2,3))> 0 THEN
+        '1' ELSE '0' END) as begin_status,
+        (SELECT COUNT(id) FROM course_menu m where m.course_id = r.course_id and m.type in(1)) as module_num,
+        (SELECT COUNT(id)+(SELECT COUNT(p.id) FROM course_module_chapter p LEFT JOIN course_menu m on m.menu_id =
+        p.module_id where m.course_id = r.course_id and m.type in(1)) FROM course_menu m where m.course_id = r.course_id
+        and m.type in(2)) as chapter_num,
+        (SELECT COUNT(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 where m.course_id = r.course_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 where m.course_id = r.course_id and m.type in(2)) FROM course_menu m where m.course_id =
+        r.course_id and m.type in(3)) as section_num,
         (select COUNT(DISTINCT course_id,module_id,chapter_id,section_id) FROM user_study_record c where 1=1
-        AND  c.course_id = r.course_id
-         and c.current_status=1
+        AND c.course_id = r.course_id
+        and c.current_status=1
         <if test="gradeId != null and gradeId !=''">
             and c.grade_id=#{gradeId}
         </if>
         <if test="orderGoodsId != null and orderGoodsId !=''">
             and c.order_goods_id=#{orderGoodsId}
         </if>
-         and c.user_id=#{userId} and c.status = 1 and c.goods_id = #{goodsId}) as record_num
+        and c.user_id=#{userId} and c.status = 1 and c.goods_id = #{goodsId}) as record_num
         FROM
         course r
         LEFT JOIN goods_course c ON c.course_id = r.course_id
@@ -279,13 +295,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </if>
     </select>
 
-    <select id="listExamRecord" parameterType="com.zhongzheng.modules.user.bo.SubjectStudyRecordQueryBo"  resultMap="SectionStudyRecordVoResult">
+    <select id="listExamRecord" parameterType="com.zhongzheng.modules.user.bo.SubjectStudyRecordQueryBo"
+            resultMap="SectionStudyRecordVoResult">
         SELECT (SELECT COUNT(m.id) FROM course_menu_exam m LEFT JOIN goods_course c on m.course_id=c.course_id LEFT JOIN
-                                        class_grade_goods cgg on cgg.goods_id = c.goods_id where cgu.grade_id=cgg.grade_id and m.type = 1 ) as exam_num,
-               (SELECT COUNT(DISTINCT ubr.chapter_id, ubr.exam_id) FROM user_bank_record ubr
-                    where ubr.`status`=1 and ubr.report_status =1 and ubr.user_id=#{userId} and cgu.grade_id=ubr.grade_id and ubr.current_status=1 ) as exam_record_num
+        class_grade_goods cgg on cgg.goods_id = c.goods_id where cgu.grade_id=cgg.grade_id and m.type = 1 ) as exam_num,
+        (SELECT COUNT(DISTINCT ubr.chapter_id, ubr.exam_id) FROM user_bank_record ubr
+        where ubr.`status`=1 and ubr.report_status =1 and ubr.user_id=#{userId} and cgu.grade_id=ubr.grade_id and
+        ubr.current_status=1 ) as exam_record_num
         FROM
-             class_grade_user cgu
+        class_grade_user cgu
         where 1=1
         <if test="userId != null and userId !='' ">
             and cgu.user_id = #{userId}
@@ -297,20 +315,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         LIMIT 1
     </select>
 
-    <select id="listSection" parameterType="com.zhongzheng.modules.user.bo.SubjectStudyRecordQueryBo"  resultMap="SectionStudyRecordVoResult">
+    <select id="listSection" parameterType="com.zhongzheng.modules.user.bo.SubjectStudyRecordQueryBo"
+            resultMap="SectionStudyRecordVoResult">
         SELECT
-            s.section_id,
-            s.name as section_name,
-            NULL as chapter_name,
-            NULL as module_name,
-            s.duration_time,
+        s.section_id,
+        s.name as section_name,
+        NULL as chapter_name,
+        NULL as module_name,
+        s.duration_time,
         usr1.start_time,
         usr1.end_time,
         IFNULL(usr1.`status`,0) `status`,
         usr1.video_current_time
         FROM
-            course_menu m
-            LEFT JOIN course_section s ON m.menu_id = s.section_id
+        course_menu m
+        LEFT JOIN course_section s ON m.menu_id = s.section_id
         RIGHT JOIN (SELECT
         any_value ( usr.first_start_time ) start_time,
         any_value ( usr.video_current_time ) video_current_time,
@@ -321,9 +340,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         ( SELECT * FROM user_study_record WHERE 1=1
         AND module_id = 0
         AND chapter_id = 0
-         AND current_status = 1
+        AND current_status = 1
         <if test="userId != null and userId !=''">
-                AND user_id = #{userId}
+            AND user_id = #{userId}
         </if>
         <if test="goodsId != null and goodsId !=''">
             AND goods_id = #{goodsId}
@@ -331,72 +350,72 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="gradeId != null and gradeId !=''">
             AND grade_id = #{gradeId}
         </if>
-                 AND course_id = #{courseId} ORDER BY record_id DESC LIMIT 9999 ) usr
+        AND course_id = #{courseId} ORDER BY record_id DESC LIMIT 9999 ) usr
         GROUP BY
         usr.section_id) usr1 on m.menu_id = usr1.section_id
         WHERE
-            m.type =3
+        m.type =3
         <if test="courseId != null and courseId !=''">
             and m.course_id=#{courseId}
         </if>
         UNION
         SELECT
-            s.section_id,
-            s.name as section_name,
-            (SELECT t.`name` FROM course_chapter t where m.menu_id = t.chapter_id ) as chapter_name,
-            NULL as module_name,
-            s.duration_time,
+        s.section_id,
+        s.name as section_name,
+        (SELECT t.`name` FROM course_chapter t where m.menu_id = t.chapter_id ) as chapter_name,
+        NULL as module_name,
+        s.duration_time,
         usr1.start_time,
         usr1.end_time,
         IFNULL(usr1.`status`,0) `status`,
         usr1.video_current_time
         FROM
-            course_chapter_section c
-            LEFT JOIN course_menu m on m.menu_id = c.chapter_id
-            LEFT JOIN course_section s ON c.section_id = s.section_id
-            RIGHT JOIN (SELECT
-            usr.chapter_id,
-            any_value ( usr.first_start_time ) start_time,
-            any_value ( usr.video_current_time ) video_current_time,
-            any_value ( usr.end_time ) end_time,
-            MAX ( usr.`status` ) `status`,
-            any_value ( usr.section_id ) section_id
-            FROM
-            ( SELECT * FROM user_study_record WHERE 1=1
-            <if test="userId != null and userId !=''">
-                AND user_id = #{userId}
-            </if>
-            <if test="userId != null and userId !=''">
-                AND goods_id = #{goodsId}
-            </if>
-            <if test="gradeId != null and gradeId !=''">
-                AND grade_id = #{gradeId}
-            </if>
-            AND module_id = 0
-            AND course_id = #{courseId} ORDER BY record_id DESC LIMIT 9999 ) usr
-            GROUP BY
-            usr.chapter_id,usr.section_id) usr1 on s.section_id = usr1.section_id
+        course_chapter_section c
+        LEFT JOIN course_menu m on m.menu_id = c.chapter_id
+        LEFT JOIN course_section s ON c.section_id = s.section_id
+        RIGHT JOIN (SELECT
+        usr.chapter_id,
+        any_value ( usr.first_start_time ) start_time,
+        any_value ( usr.video_current_time ) video_current_time,
+        any_value ( usr.end_time ) end_time,
+        MAX ( usr.`status` ) `status`,
+        any_value ( usr.section_id ) section_id
+        FROM
+        ( SELECT * FROM user_study_record WHERE 1=1
+        <if test="userId != null and userId !=''">
+            AND user_id = #{userId}
+        </if>
+        <if test="userId != null and userId !=''">
+            AND goods_id = #{goodsId}
+        </if>
+        <if test="gradeId != null and gradeId !=''">
+            AND grade_id = #{gradeId}
+        </if>
+        AND module_id = 0
+        AND course_id = #{courseId} ORDER BY record_id DESC LIMIT 9999 ) usr
+        GROUP BY
+        usr.chapter_id,usr.section_id) usr1 on s.section_id = usr1.section_id
         WHERE
-            m.type =2 AND usr1.chapter_id = c.chapter_id
+        m.type =2 AND usr1.chapter_id = c.chapter_id
         <if test="courseId != null and courseId !=''">
             and m.course_id=#{courseId}
         </if>
         UNION
         SELECT
-            s.section_id,
-            s.name as section_name,
-            (SELECT t.`name` FROM course_chapter t where e.chapter_id = t.chapter_id ) as chapter_name,
-            (SELECT t.module_name FROM course_module t where e.module_id = t.module_id ) as module_name,
-            s.duration_time,
+        s.section_id,
+        s.name as section_name,
+        (SELECT t.`name` FROM course_chapter t where e.chapter_id = t.chapter_id ) as chapter_name,
+        (SELECT t.module_name FROM course_module t where e.module_id = t.module_id ) as module_name,
+        s.duration_time,
         usr1.start_time,
         usr1.end_time,
         IFNULL(usr1.`status`,0) `status`,
         usr1.video_current_time
         FROM
-            course_chapter_section c
-            LEFT JOIN course_module_chapter e on c.chapter_id = e.chapter_id
-            LEFT JOIN course_menu m on m.menu_id = e.module_id
-            LEFT JOIN course_section s ON c.section_id = s.section_id
+        course_chapter_section c
+        LEFT JOIN course_module_chapter e on c.chapter_id = e.chapter_id
+        LEFT JOIN course_menu m on m.menu_id = e.module_id
+        LEFT JOIN course_section s ON c.section_id = s.section_id
         RIGHT JOIN (SELECT
         usr.module_id,
         usr.chapter_id,
@@ -422,7 +441,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         usr.section_id,usr.module_id,
         usr.chapter_id) usr1 on s.section_id = usr1.section_id
         WHERE
-            m.type =1 and usr1.module_id = e.module_id and usr1.chapter_id = e.chapter_id
+        m.type =1 and usr1.module_id = e.module_id and usr1.chapter_id = e.chapter_id
         <if test="courseId != null and courseId !=''">
             and m.course_id=#{courseId}
         </if>
@@ -430,42 +449,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
 
-    <select id="sectionType" parameterType="map"  resultType="Long">
-        SELECT
-            s.section_id
-        FROM
-            course_menu m
-                LEFT JOIN course_section s ON m.menu_id = s.section_id
-        WHERE
-            m.type =3
-          and m.course_id=#{courseId}
-          and s.section_type=#{sectionType}
+    <select id="sectionType" parameterType="map" resultType="Long">
+        SELECT s.section_id
+        FROM course_menu m
+                 LEFT JOIN course_section s ON m.menu_id = s.section_id
+        WHERE m.type = 3
+          and m.course_id = #{courseId}
+          and s.section_type = #{sectionType}
         UNION
-        SELECT
-            s.section_id
-        FROM
-            course_chapter_section c
-                LEFT JOIN course_menu m on m.menu_id = c.chapter_id
-                LEFT JOIN course_section s ON c.section_id = s.section_id
-        WHERE
-            m.type =2
-          and m.course_id=#{courseId}
-          and s.section_type=#{sectionType}
+        SELECT s.section_id
+        FROM course_chapter_section c
+                 LEFT JOIN course_menu m on m.menu_id = c.chapter_id
+                 LEFT JOIN course_section s ON c.section_id = s.section_id
+        WHERE m.type = 2
+          and m.course_id = #{courseId}
+          and s.section_type = #{sectionType}
         UNION
-        SELECT
-            s.section_id
-        FROM
-            course_chapter_section c
-                LEFT JOIN course_module_chapter e on c.chapter_id = e.chapter_id
-                LEFT JOIN course_menu m on m.menu_id = e.module_id
-                LEFT JOIN course_section s ON c.section_id = s.section_id
-        WHERE
-            m.type =1
-          and m.course_id=#{courseId}
-          and s.section_type=#{sectionType}
+        SELECT s.section_id
+        FROM course_chapter_section c
+                 LEFT JOIN course_module_chapter e on c.chapter_id = e.chapter_id
+                 LEFT JOIN course_menu m on m.menu_id = e.module_id
+                 LEFT JOIN course_section s ON c.section_id = s.section_id
+        WHERE m.type = 1
+          and m.course_id = #{courseId}
+          and s.section_type = #{sectionType}
     </select>
 
-    <select id="querExamStudy" parameterType="com.zhongzheng.modules.user.bo.UserQueryBo"  resultMap="ExamStudyRecordVoResult">
+    <select id="querExamStudy" parameterType="com.zhongzheng.modules.user.bo.UserQueryBo"
+            resultMap="ExamStudyRecordVoResult">
         SELECT
         DISTINCT g.goods_id,
         #{userId} as user_id,
@@ -483,10 +494,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         ( SELECT p.project_name FROM course_project_type p WHERE p.id = g.project_id ) AS project_name,
         ( SELECT s.school_name FROM school s WHERE s.id = g.school_id ) AS school_name,
         ( SELECT e.education_name FROM course_education_type e WHERE e.id = g.education_type_id ) AS education_name,
-        (SELECT COUNT(a.id)+(SELECT COUNT(a.id) FROM goods_attached e LEFT JOIN question_chapter_exam a on e.major_id = a.chapter_exam_id where e.goods_id = g.goods_id and e.type=2)+(SELECT COUNT(h.id) FROM goods_attached e LEFT JOIN question_module_chapter a on e.major_id = a.module_exam_id LEFT JOIN question_chapter_exam h on a.chapter_exam_id = h.chapter_exam_id  where e.goods_id = g.goods_id and e.type=1) FROM goods_attached a where a.goods_id=g.goods_id and a.type = 3) as exam_num,
-        (SELECT create_time FROM user_exam_record r where r.goods_id=g.goods_id AND r.user_id = #{userId} ORDER BY create_time ASC LIMIT 1) as start_time,
-        (SELECT create_time FROM user_exam_record r where r.goods_id=g.goods_id AND r.user_id = #{userId} ORDER BY create_time DESC LIMIT 1) as end_time,
-        (SELECT COUNT(DISTINCT exam_id) FROM user_exam_record r where r.goods_id=g.goods_id  AND r.user_id = #{userId}) as stu_all_num,
+        (SELECT COUNT(a.id)+(SELECT COUNT(a.id) FROM goods_attached e LEFT JOIN question_chapter_exam a on e.major_id =
+        a.chapter_exam_id where e.goods_id = g.goods_id and e.type=2)+(SELECT COUNT(h.id) FROM goods_attached e LEFT
+        JOIN question_module_chapter a on e.major_id = a.module_exam_id LEFT JOIN question_chapter_exam h on
+        a.chapter_exam_id = h.chapter_exam_id where e.goods_id = g.goods_id and e.type=1) FROM goods_attached a where
+        a.goods_id=g.goods_id and a.type = 3) as exam_num,
+        (SELECT create_time FROM user_exam_record r where r.goods_id=g.goods_id AND r.user_id = #{userId} ORDER BY
+        create_time ASC LIMIT 1) as start_time,
+        (SELECT create_time FROM user_exam_record r where r.goods_id=g.goods_id AND r.user_id = #{userId} ORDER BY
+        create_time DESC LIMIT 1) as end_time,
+        (SELECT COUNT(DISTINCT exam_id) FROM user_exam_record r where r.goods_id=g.goods_id AND r.user_id = #{userId})
+        as stu_all_num,
         s.service_start_time,
         s.service_end_time
         FROM
@@ -501,16 +519,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         ORDER BY s.create_time DESC
     </select>
 
-    <select id="listExamSon" parameterType="com.zhongzheng.modules.user.bo.SubjectStudyRecordQueryBo"  resultMap="ExamSonStudyRecordVoResult">
+    <select id="listExamSon" parameterType="com.zhongzheng.modules.user.bo.SubjectStudyRecordQueryBo"
+            resultMap="ExamSonStudyRecordVoResult">
         SELECT
         a.id as question_id,
         e.exam_name as question_name,
-        (SELECT s.subject_name FROM question_business b LEFT JOIN course_subject s on b.subject_id= s.id where b.type =2 and b.major_id =a.major_id) as subject_name,
+        (SELECT s.subject_name FROM question_business b LEFT JOIN course_subject s on b.subject_id= s.id where b.type =2
+        and b.major_id =a.major_id) as subject_name,
         0 as module_num,
         0 as chapter_num,
         1 as exam_num,
         (select COUNT(q.id) FROM exam_question q where e.exam_id = q.exam_id) as question_num,
-        (SELECT COUNT(DISTINCT r.exam_id) FROM user_exam_record r where r.goods_id = a.goods_id and r.exam_id = e.exam_id  <if test="userId != null and userId !=''">
+        (SELECT COUNT(DISTINCT r.exam_id) FROM user_exam_record r where r.goods_id = a.goods_id and r.exam_id =
+        e.exam_id  <if test="userId != null and userId !=''">
         AND r.user_id = #{userId}
     </if> ) as record_num
         FROM
@@ -525,12 +546,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         SELECT
         a.id as question_id,
         c.`name` as question_name,
-        (SELECT s.subject_name FROM question_business b LEFT JOIN course_subject s on b.subject_id= s.id where b.type =3 and b.major_id =a.major_id) as subject_name,
+        (SELECT s.subject_name FROM question_business b LEFT JOIN course_subject s on b.subject_id= s.id where b.type =3
+        and b.major_id =a.major_id) as subject_name,
         0 as module_num,
         1 as chapter_num,
         (SELECT COUNT(e.id) FROM question_chapter_exam e where c.chapter_exam_id=e.chapter_exam_id) as exam_num,
-        (select COUNT(q.id) FROM exam_question q LEFT JOIN question_chapter_exam m  on m.exam_id = q.exam_id where m.chapter_exam_id = a.major_id) as question_num,
-        (SELECT COUNT(DISTINCT r.exam_id) FROM user_exam_record r LEFT JOIN question_chapter_exam m on r.exam_id = m.exam_id  where r.goods_id = a.goods_id and m.chapter_exam_id=c.chapter_exam_id   <if test="userId != null and userId !=''">
+        (select COUNT(q.id) FROM exam_question q LEFT JOIN question_chapter_exam m on m.exam_id = q.exam_id where
+        m.chapter_exam_id = a.major_id) as question_num,
+        (SELECT COUNT(DISTINCT r.exam_id) FROM user_exam_record r LEFT JOIN question_chapter_exam m on r.exam_id =
+        m.exam_id where r.goods_id = a.goods_id and m.chapter_exam_id=c.chapter_exam_id   <if
+            test="userId != null and userId !=''">
         AND r.user_id = #{userId}
     </if> ) as record_num
         FROM
@@ -545,12 +570,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         SELECT
         a.id as question_id,
         c.module_name as question_name,
-        (SELECT s.subject_name FROM question_business b LEFT JOIN course_subject s on b.subject_id= s.id where b.type =4 and b.major_id =a.major_id) as subject_name,
+        (SELECT s.subject_name FROM question_business b LEFT JOIN course_subject s on b.subject_id= s.id where b.type =4
+        and b.major_id =a.major_id) as subject_name,
         1 as module_num,
         (SELECT COUNT(e.id) FROM question_module_chapter e where c.module_exam_id=e.module_exam_id) as chapter_num,
-        (SELECT COUNT(e.id) FROM question_chapter_exam e LEFT JOIN question_module_chapter r on e.chapter_exam_id = r.chapter_exam_id  where c.module_exam_id=r.module_exam_id) as exam_num,
-        (select COUNT(q.id) FROM exam_question q LEFT JOIN question_chapter_exam m on m.exam_id = q.exam_id LEFT JOIN question_module_chapter r on m.chapter_exam_id = r.chapter_exam_id where r.module_exam_id = a.major_id) as question_num,
-        (SELECT COUNT(DISTINCT r.exam_id) FROM user_exam_record r LEFT JOIN question_chapter_exam m on r.exam_id = m.exam_id LEFT JOIN question_module_chapter l on l.chapter_exam_id = m.chapter_exam_id where r.goods_id = a.goods_id and l.module_exam_id = a.major_id  <if test="userId != null and userId !=''">
+        (SELECT COUNT(e.id) FROM question_chapter_exam e LEFT JOIN question_module_chapter r on e.chapter_exam_id =
+        r.chapter_exam_id where c.module_exam_id=r.module_exam_id) as exam_num,
+        (select COUNT(q.id) FROM exam_question q LEFT JOIN question_chapter_exam m on m.exam_id = q.exam_id LEFT JOIN
+        question_module_chapter r on m.chapter_exam_id = r.chapter_exam_id where r.module_exam_id = a.major_id) as
+        question_num,
+        (SELECT COUNT(DISTINCT r.exam_id) FROM user_exam_record r LEFT JOIN question_chapter_exam m on r.exam_id =
+        m.exam_id LEFT JOIN question_module_chapter l on l.chapter_exam_id = m.chapter_exam_id where r.goods_id =
+        a.goods_id and l.module_exam_id = a.major_id  <if test="userId != null and userId !=''">
         AND r.user_id = #{userId}
     </if> ) as record_num
         FROM
@@ -566,40 +597,40 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="examTypes" parameterType="Long" resultType="String">
         SELECT
-            ( SELECT DISTINCT ep.paper_name FROM exam_paper ep WHERE ep.paper_id = e.exam_paper_id ) AS paper_name
+        ( SELECT DISTINCT ep.paper_name FROM exam_paper ep WHERE ep.paper_id = e.exam_paper_id ) AS paper_name
         FROM
-            goods_attached a
-                LEFT JOIN exam e ON a.major_id = e.exam_id
+        goods_attached a
+        LEFT JOIN exam e ON a.major_id = e.exam_id
         WHERE
-            a.type = 3
+        a.type = 3
         <if test="id != null and id !=''">
             and a.id =#{id}
         </if>
         UNION
         SELECT
-            ( SELECT DISTINCT ep.paper_name FROM exam_paper ep WHERE ep.paper_id = e.exam_paper_id ) AS paper_name
+        ( SELECT DISTINCT ep.paper_name FROM exam_paper ep WHERE ep.paper_id = e.exam_paper_id ) AS paper_name
         FROM
-            goods_attached a
-                LEFT JOIN question_chapter c ON a.major_id = c.chapter_exam_id
-                LEFT JOIN question_chapter_exam qce ON qce.chapter_exam_id = c.chapter_exam_id
-                LEFT JOIN exam e ON e.exam_id = qce.exam_id
+        goods_attached a
+        LEFT JOIN question_chapter c ON a.major_id = c.chapter_exam_id
+        LEFT JOIN question_chapter_exam qce ON qce.chapter_exam_id = c.chapter_exam_id
+        LEFT JOIN exam e ON e.exam_id = qce.exam_id
         WHERE
-            a.type = 2
+        a.type = 2
         <if test="id != null and id !=''">
             and a.id =#{id}
         </if>
         UNION
         SELECT
-            ( SELECT DISTINCT ep.paper_name FROM exam_paper ep WHERE ep.paper_id = e.exam_paper_id ) AS paper_name
+        ( SELECT DISTINCT ep.paper_name FROM exam_paper ep WHERE ep.paper_id = e.exam_paper_id ) AS paper_name
         FROM
-            goods_attached a
-                LEFT JOIN question_module c ON a.major_id = c.module_exam_id
-                LEFT JOIN question_module_chapter qmc ON c.module_exam_id = qmc.module_exam_id
-                LEFT JOIN question_chapter qc ON qmc.chapter_exam_id = qc.chapter_exam_id
-                LEFT JOIN question_chapter_exam qce ON qce.chapter_exam_id = qc.chapter_exam_id
-                LEFT JOIN exam e ON e.exam_id = qce.exam_id
+        goods_attached a
+        LEFT JOIN question_module c ON a.major_id = c.module_exam_id
+        LEFT JOIN question_module_chapter qmc ON c.module_exam_id = qmc.module_exam_id
+        LEFT JOIN question_chapter qc ON qmc.chapter_exam_id = qc.chapter_exam_id
+        LEFT JOIN question_chapter_exam qce ON qce.chapter_exam_id = qc.chapter_exam_id
+        LEFT JOIN exam e ON e.exam_id = qce.exam_id
         WHERE
-            a.type = 1
+        a.type = 1
         <if test="id != null and id !=''">
             and a.id =#{id}
         </if>
@@ -661,10 +692,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 AND up.goods_id = 0
             </otherwise>
         </choose>
-          AND up.user_id = #{userId}
+        AND up.user_id = #{userId}
     </select>
 
-    <select id="selectStudyExamRecord" parameterType="com.zhongzheng.modules.user.vo.UserBankRecordVo" resultType="Long">
+    <select id="selectStudyExamRecord" parameterType="com.zhongzheng.modules.user.vo.UserBankRecordVo"
+            resultType="Long">
         SELECT
         COUNT( 1 )
         FROM
@@ -732,65 +764,65 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
     <select id="selectPeriod" parameterType="com.zhongzheng.modules.user.domain.UserStudyRecord" resultType="Long">
-    SELECT
-    COUNT( 1 )
-    FROM
-    user_period up
-    LEFT JOIN user_period_status ups on up.id = ups.period_id
-    WHERE
-    1 =1
-    <choose>
-        <when test="chapterId != null and chapterId !=''">
-            AND up.chapter_id = #{chapterId}
-        </when>
-        <otherwise>
-            AND up.chapter_id = 0
-        </otherwise>
-    </choose>
-    <choose>
-        <when test="sectionId != null and sectionId !=''">
-            AND up.section_id = #{sectionId}
-        </when>
-        <otherwise>
-            AND up.section_id = 0
-        </otherwise>
-    </choose>
-    <choose>
-        <when test="moduleId != null and moduleId !=''">
-            AND up.module_id = #{moduleId}
-        </when>
-        <otherwise>
-            AND up.module_id = 0
-        </otherwise>
-    </choose>
-    <choose>
-        <when test="courseId != null and courseId !=''">
-            AND up.course_id = #{courseId}
-        </when>
-        <otherwise>
-            AND up.course_id = 0
-        </otherwise>
-    </choose>
-    <choose>
-        <when test="gradeId != null and gradeId !=''">
-            AND up.grade_id = #{gradeId}
-        </when>
-        <otherwise>
-            AND up.grade_id = 0
-        </otherwise>
-    </choose>
-    <choose>
-        <when test="goodsId != null and goodsId !=''">
-            AND up.goods_id = #{goodsId}
-        </when>
-        <otherwise>
-            AND up.goods_id = 0
-        </otherwise>
-    </choose>
-    AND up.user_id = #{userId}
-    AND ups.period_status = 1
-    AND ups.`status` =2
-    AND ups.record_end_time is NOT NULL
+        SELECT
+        COUNT( 1 )
+        FROM
+        user_period up
+        LEFT JOIN user_period_status ups on up.id = ups.period_id
+        WHERE
+        1 =1
+        <choose>
+            <when test="chapterId != null and chapterId !=''">
+                AND up.chapter_id = #{chapterId}
+            </when>
+            <otherwise>
+                AND up.chapter_id = 0
+            </otherwise>
+        </choose>
+        <choose>
+            <when test="sectionId != null and sectionId !=''">
+                AND up.section_id = #{sectionId}
+            </when>
+            <otherwise>
+                AND up.section_id = 0
+            </otherwise>
+        </choose>
+        <choose>
+            <when test="moduleId != null and moduleId !=''">
+                AND up.module_id = #{moduleId}
+            </when>
+            <otherwise>
+                AND up.module_id = 0
+            </otherwise>
+        </choose>
+        <choose>
+            <when test="courseId != null and courseId !=''">
+                AND up.course_id = #{courseId}
+            </when>
+            <otherwise>
+                AND up.course_id = 0
+            </otherwise>
+        </choose>
+        <choose>
+            <when test="gradeId != null and gradeId !=''">
+                AND up.grade_id = #{gradeId}
+            </when>
+            <otherwise>
+                AND up.grade_id = 0
+            </otherwise>
+        </choose>
+        <choose>
+            <when test="goodsId != null and goodsId !=''">
+                AND up.goods_id = #{goodsId}
+            </when>
+            <otherwise>
+                AND up.goods_id = 0
+            </otherwise>
+        </choose>
+        AND up.user_id = #{userId}
+        AND ups.period_status = 1
+        AND ups.`status` =2
+        AND ups.record_end_time is NOT NULL
     </select>
 
     <resultMap type="com.zhongzheng.modules.grade.domain.UserPeriodStatus" id="UserPeriodStatus">
@@ -802,7 +834,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="periodStatus" column="period_status"/>
     </resultMap>
 
-    <select id="selectPeriodCount" parameterType="com.zhongzheng.modules.user.domain.UserStudyRecord" resultMap="UserPeriodStatus">
+    <select id="selectPeriodCount" parameterType="com.zhongzheng.modules.user.domain.UserStudyRecord"
+            resultMap="UserPeriodStatus">
         SELECT
         ups.*
         FROM
@@ -863,35 +896,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
     <select id="userPlanSave" parameterType="Long" resultType="Long">
-        SELECT
-            COUNT(1)
-        FROM
-            user_plan_goods upg
-                LEFT JOIN user_plan up	on upg.plan_id = up.plan_id
-        WHERE
-            upg.source_id = #{goodsId}
+        SELECT COUNT(1)
+        FROM user_plan_goods upg
+                 LEFT JOIN user_plan up on upg.plan_id = up.plan_id
+        WHERE upg.source_id = #{goodsId}
           and up.`status` = 1
     </select>
 
     <select id="userPlanSaveId" parameterType="Long" resultType="Long">
-        SELECT
-            upg.plan_id
-        FROM
-            user_plan_goods upg
-                LEFT JOIN user_plan up	on upg.plan_id = up.plan_id
-        WHERE
-            upg.source_id = #{goodsId}
-          and up.`status` = 1
-            LIMIT 1
+        SELECT upg.plan_id
+        FROM user_plan_goods upg
+                 LEFT JOIN user_plan up on upg.plan_id = up.plan_id
+        WHERE upg.source_id = #{goodsId}
+          and up.`status` = 1 LIMIT 1
     </select>
 
     <select id="selectPland" parameterType="com.zhongzheng.modules.user.domain.UserStudyRecord" resultType="Long">
         SELECT
-            COUNT( 1 )
+        COUNT( 1 )
         FROM
-            user_study_record usr
+        user_study_record usr
         WHERE
-            1 = 1
+        1 = 1
         <choose>
             <when test="chapterId != null and chapterId !=''">
                 AND usr.chapter_id = #{chapterId}
@@ -940,31 +966,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 AND usr.goods_id = 0
             </otherwise>
         </choose>
-          AND usr.plan_id =#{planId}
+        AND usr.plan_id =#{planId}
     </select>
 
     <select id="getPlanGoods" parameterType="Long" resultType="Long">
-        SELECT
-            upg.source_id
-        FROM
-            user_plan_goods upg
-                LEFT JOIN user_plan up	on upg.plan_id = up.plan_id
-        WHERE
-            upg.plan_id =#{planId}
+        SELECT upg.source_id
+        FROM user_plan_goods upg
+                 LEFT JOIN user_plan up on upg.plan_id = up.plan_id
+        WHERE upg.plan_id = #{planId}
           and up.`status` = 1
     </select>
 
     <select id="selectPlandCount" parameterType="map" resultType="Long">
-        SELECT
-            COUNT(1)
-        FROM
-            user_study_record usr
-        WHERE 1=1
+        SELECT COUNT(1)
+        FROM user_study_record usr
+        WHERE 1 = 1
           and usr.plan_id = #{planId}
           and usr.goods_id = #{goodsId}
     </select>
 
-    <select id="selectStudyExamRecordOr" parameterType="com.zhongzheng.modules.user.vo.UserBankRecordVo" resultType="Long">
+    <select id="selectStudyExamRecordOr" parameterType="com.zhongzheng.modules.user.vo.UserBankRecordVo"
+            resultType="Long">
         SELECT
         COUNT( 1 )
         FROM
@@ -972,8 +994,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         LEFT JOIN user_period_status ups on up.id = ups.period_id
         WHERE
         1 =1
-          and ups.period_status = 1
-          and ups.status = 3
+        and ups.period_status = 1
+        and ups.status = 3
         <choose>
             <when test="chapterId != null and chapterId !=''">
                 AND up.chapter_id = #{chapterId}
@@ -1033,7 +1055,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         AND up.user_id = #{userId}
     </select>
 
-    <select id="selectStudyExamRecordCount" parameterType="com.zhongzheng.modules.user.vo.UserBankRecordVo" resultMap="UserPeriodStatus">
+    <select id="selectStudyExamRecordCount" parameterType="com.zhongzheng.modules.user.vo.UserBankRecordVo"
+            resultMap="UserPeriodStatus">
         SELECT
         ups.*
         FROM
@@ -1102,35 +1125,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
     <select id="selectCountPlan" parameterType="Long" resultType="Long">
-        SELECT COUNT(1) FROM user_study_record usr where usr.plan_id =#{planId}
+        SELECT COUNT(1)
+        FROM user_study_record usr
+        where usr.plan_id = #{planId}
     </select>
 
     <select id="getUserSeeTime" parameterType="com.zhongzheng.modules.user.domain.UserStudyRecord" resultType="Long">
-        SELECT
-            IFNULL(SUM( a.study_duration ),0)
-        FROM
-            (
-                SELECT
-                    MAX( usr.video_current_time ) study_duration
-                FROM
-                    user_study_record usr
-                WHERE
-                    usr.user_id = #{userId}
-                  AND usr.goods_id = #{goodsId}
-                  AND usr.grade_id = #{gradeId}
-                GROUP BY
-                    usr.section_id
-            )a
+        SELECT IFNULL(SUM(a.study_duration), 0)
+        FROM (
+                 SELECT MAX(usr.video_current_time) study_duration
+                 FROM user_study_record usr
+                 WHERE usr.user_id = #{userId}
+                   AND usr.goods_id = #{goodsId}
+                   AND usr.grade_id = #{gradeId}
+                 GROUP BY usr.section_id
+             ) a
     </select>
 
 
-    <select id="selectChapterSectionRecord" parameterType="com.zhongzheng.modules.user.bo.UserStudyRecordQueryBo"  resultType="Long">
-        SELECT
-            count(DISTINCT section_id)
-        FROM
-            user_study_record
-        WHERE
-            user_id = #{userId}
+    <select id="selectChapterSectionRecord" parameterType="com.zhongzheng.modules.user.bo.UserStudyRecordQueryBo"
+            resultType="Long">
+        SELECT count(DISTINCT section_id)
+        FROM user_study_record
+        WHERE user_id = #{userId}
           AND grade_id = #{gradeId}
           AND course_id = #{courseId}
           AND module_id = #{moduleId}
@@ -1201,7 +1218,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         AND cm.type=3
     </select>
 
-    <select id="listChapterSection" parameterType="com.zhongzheng.modules.user.bo.UserStudyRecordQueryBo" resultMap="ClassPeriodVo">
+    <select id="listChapterSection" parameterType="com.zhongzheng.modules.user.bo.UserStudyRecordQueryBo"
+            resultMap="ClassPeriodVo">
         SELECT
         ccs.sort,
         ccs.section_id AS id,
@@ -1222,13 +1240,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </if>
     </select>
 
-    <select id="listModuleChapter" parameterType="com.zhongzheng.modules.user.bo.UserStudyRecordQueryBo" resultMap="ClassPeriodVo">
+    <select id="listModuleChapter" parameterType="com.zhongzheng.modules.user.bo.UserStudyRecordQueryBo"
+            resultMap="ClassPeriodVo">
         SELECT
         cmc.sort,
         cmc.chapter_id as id,
         2 AS type
         FROM
-         course_module_chapter cmc
+        course_module_chapter cmc
         WHERE
         1 = 1
         <if test="moduleId != null and moduleId !='' ">
@@ -1238,25 +1257,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="getStudyStatus" parameterType="com.zhongzheng.modules.grade.vo.ClassPeriodVo" resultType="Integer">
         SELECT
-            IFNULL(MAX(status),-1)
+        IFNULL(MAX(status),-1)
         FROM
-            user_study_record
+        user_study_record
         WHERE
-              1=1
+        1=1
         <if test="userId != null and userId !='' ">
             AND user_id = #{userId}
         </if>
         <if test="gradeId != null and gradeId !='' ">
-          AND grade_id = #{gradeId}
+            AND grade_id = #{gradeId}
         </if>
         <if test="courseId != null and courseId !='' ">
-          AND course_id = #{courseId}
+            AND course_id = #{courseId}
         </if>
         <if test="moduleId != null and moduleId !='' ">
-          AND module_id = #{moduleId}
+            AND module_id = #{moduleId}
         </if>
         <if test="chapterId != null and chapterId !='' ">
-          AND chapter_id = #{chapterId}
+            AND chapter_id = #{chapterId}
         </if>
         <if test="sectionId != null and sectionId !='' ">
             AND section_id = #{sectionId}
@@ -1267,28 +1286,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="orderGoodsId != null and orderGoodsId !='' ">
             AND order_goods_id = #{orderGoodsId}
         </if>
-          AND `status` = 1
-          AND current_status = 1
+        AND `status` = 1
+        AND current_status = 1
     </select>
 
-    <select id="listUserRecord" parameterType="com.zhongzheng.modules.user.bo.UserStudyRecordQueryBo" resultMap="SectionStudyRecordVoResult">
-        SELECT
-            cs.`name` as section_name,
-            cs.cover_url,
-            cs.duration_time,
-            cs.section_type,
-            r.*,
-            g.goods_name,
-            g.goods_type,
-            r.order_goods_id,
-           cs.recording_url,
-           cs.live_url,
-           cs.live_start_time,
-           cs.live_end_time
-        FROM
-            (
-                SELECT
-                    from_unixtime( usr.update_time, '%Y-%m-%d' ) date,
+    <select id="listUserRecord" parameterType="com.zhongzheng.modules.user.bo.UserStudyRecordQueryBo"
+            resultMap="SectionStudyRecordVoResult">
+        SELECT cs.`name` as section_name,
+               cs.cover_url,
+               cs.duration_time,
+               cs.section_type,
+               r.*,
+               g.goods_name,
+               g.goods_type,
+               r.order_goods_id,
+               cs.recording_url,
+               cs.live_url,
+               cs.live_start_time,
+               cs.live_end_time
+        FROM (
+                 SELECT from_unixtime(usr.update_time, '%Y-%m-%d') date,
         MAX( usr.update_time ) sort_time,
 		section_id,
 		MAX( usr.video_current_time ) video_current_time,
@@ -1298,164 +1315,180 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		usr.chapter_id,
         usr.grade_id,
         usr.order_goods_id
-                FROM
-                    user_study_record usr
-                WHERE
-                    usr.user_id = #{userId}
-                GROUP BY
-                    from_unixtime( usr.update_time, '%Y-%m-%d' ),
-                    usr.section_id,
-                    usr.goods_id,
-                    usr.course_id,
-                    usr.module_id,
-                    usr.chapter_id,
-                    usr.grade_id,
-                    usr.grade_id,
-                    usr.order_goods_id
-
-            ) r
-                LEFT JOIN course_section cs ON r.section_id = cs.section_id
-                LEFT JOIN goods g ON g.goods_id = r.goods_id
-                LEFT JOIN class_grade_user cgu ON cgu.grade_id = r.grade_id and cgu.user_id = #{userId}
-        ORDER BY
-            r.sort_time DESC
+                 FROM
+                     user_study_record usr
+                 WHERE
+                     usr.user_id = #{userId}
+                 GROUP BY
+                     from_unixtime( usr.update_time, '%Y-%m-%d' ),
+                     usr.section_id,
+                     usr.goods_id,
+                     usr.course_id,
+                     usr.module_id,
+                     usr.chapter_id,
+                     usr.grade_id,
+                     usr.grade_id,
+                     usr.order_goods_id
+             ) r
+                 LEFT JOIN course_section cs ON r.section_id = cs.section_id
+                 LEFT JOIN goods g ON g.goods_id = r.goods_id
+                 LEFT JOIN class_grade_user cgu ON cgu.grade_id = r.grade_id and cgu.user_id = #{userId}
+        ORDER BY r.sort_time DESC
     </select>
 
-    <select id="getLastLive" parameterType="com.zhongzheng.modules.user.bo.UserStudyRecordQueryBo" resultMap="SectionStudyRecordVoResult">
-        SELECT
-            usr.*,
-            cs.live_url
-        FROM
-            user_study_record usr
-                LEFT JOIN course_section cs ON usr.section_id = cs.section_id
-        WHERE
-            cs.section_type = 2
+    <select id="getLastLive" parameterType="com.zhongzheng.modules.user.bo.UserStudyRecordQueryBo"
+            resultMap="SectionStudyRecordVoResult">
+        SELECT usr.*,
+               cs.live_url
+        FROM user_study_record usr
+                 LEFT JOIN course_section cs ON usr.section_id = cs.section_id
+        WHERE cs.section_type = 2
           AND usr.user_id = #{userId}
           AND usr.order_goods_id = #{orderGoodsId}
           AND usr.course_id = #{courseId}
-        ORDER BY
-            usr.update_time
-            LIMIT 1
+        ORDER BY usr.update_time LIMIT 1
     </select>
 
-    <select id="getUserWatchLast" parameterType="com.zhongzheng.modules.user.bo.UserStudyRecordQueryBo" resultMap="SectionStudyRecordVoResult">
+    <select id="getUserWatchLast" parameterType="com.zhongzheng.modules.user.bo.UserStudyRecordQueryBo"
+            resultMap="SectionStudyRecordVoResult">
         SELECT
-            usr.*
+        usr.*
         FROM
-            user_study_record usr
+        user_study_record usr
         WHERE
-           usr.user_id = #{userId}
+        usr.user_id = #{userId}
         <if test="goodsId != null and goodsId !='' ">
-            AND usr.goods_id  = #{goodsId}
+            AND usr.goods_id = #{goodsId}
         </if>
         ORDER BY
-            usr.update_time DESC
-            LIMIT 1
+        usr.update_time DESC
+        LIMIT 1
     </select>
 
-    <select id="getUserByRecord" parameterType="com.zhongzheng.modules.course.bo.CourseSectionDetailBo" resultType="com.zhongzheng.modules.course.bo.CourseSectionDetailVo">
+    <select id="getUserByRecord" parameterType="com.zhongzheng.modules.course.bo.CourseSectionDetailBo"
+            resultType="com.zhongzheng.modules.course.bo.CourseSectionDetailVo">
         SELECT
-            ur.user_id as userId,
-            u.realname as userName,
-            u.id_card as idCard,
-            u.telphone as phone
+        ur.user_id as userId,
+        u.realname as userName,
+        u.id_card as idCard,
+        u.telphone as phone
         FROM
-            user_study_record ur
-                LEFT JOIN `user` u ON ur.user_id = u.user_id
+        user_study_record ur
+        LEFT JOIN `user` u ON ur.user_id = u.user_id
         WHERE
-            u.`status` = 1
-          AND ur.goods_id = #{goodsId}
-          AND ur.section_id = #{sectionId}
+        u.`status` = 1
+        AND ur.goods_id = #{goodsId}
+        AND ur.section_id = #{sectionId}
         <if test="userName != null and userName !='' ">
-            AND u.realname  like concat('%', #{userName}, '%')
+            AND u.realname like concat('%', #{userName}, '%')
         </if>
         <if test="idCard != null and idCard !='' ">
-            AND u.id_card  like concat('%', #{idCard}, '%')
+            AND u.id_card like concat('%', #{idCard}, '%')
         </if>
         <if test="phone != null and phone !='' ">
-            AND u.telphone  like concat('%', #{phone}, '%')
+            AND u.telphone like concat('%', #{phone}, '%')
         </if>
         <if test="purchaseStatus != null and purchaseStatus !='' ">
             AND ur.buy_course = #{purchaseStatus}
         </if>
         GROUP BY
-            ur.user_id
+        ur.user_id
     </select>
 
-    <select id="getCourseStatement" parameterType="com.zhongzheng.modules.course.bo.CourseStatementBo" resultType="com.zhongzheng.modules.course.bo.CourseStatementVo">
+    <select id="getCourseStatement" parameterType="com.zhongzheng.modules.course.bo.CourseStatementBo"
+            resultType="com.zhongzheng.modules.course.bo.CourseStatementVo">
         SELECT
-            ur.goods_id as goodsId,
-            ur.section_id as sectionId,
-            cs.name as sectionName,
-            cs.live_start_time as liveStartTime,
-            cs.live_end_time as liveEndTime,
-            cs.live_url as liveUrl
+        ur.goods_id as goodsId,
+        ur.section_id as sectionId,
+        cs.name as sectionName,
+        cs.live_start_time as liveStartTime,
+        cs.live_end_time as liveEndTime,
+        cs.live_url as liveUrl
         FROM
-            user_study_record ur
-            LEFT JOIN `course_section` cs ON ur.section_id = cs.section_id
+        user_study_record ur
+        LEFT JOIN `course_section` cs ON ur.section_id = cs.section_id
         WHERE
-            ur.goods_id = #{goodsId}
-            <if test="sectionName != null and sectionName !='' ">
-                AND cs.name  like concat('%', #{sectionName}, '%')
-            </if>
-            GROUP BY
-            ur.section_id
+        ur.goods_id = #{goodsId}
+        <if test="sectionName != null and sectionName !='' ">
+            AND cs.name like concat('%', #{sectionName}, '%')
+        </if>
+        GROUP BY
+        ur.section_id
     </select>
 
-    <select id="userSectionLiveList" parameterType="com.zhongzheng.modules.user.bo.UserStudyRecordQueryBo" resultMap="SectionStudyRecordVoResult">
+    <select id="getPeriodIdByQuery" parameterType="com.zhongzheng.modules.user.domain.UserStudyRecord"
+            resultType="java.lang.Long">
         SELECT
-            r.*,
-            cs.section_type,
-            cs.real_duration,
-            cs.duration_time,
-            u.realname,
-            u.id_card,
-            cs.`name` as section_name,
-            cm.module_name,
-            cc.`name` as chapter_name
+        ups.id
         FROM
-            (
-                SELECT
-                    usr.module_id,
-                    usr.chapter_id,
-                    usr.section_id,
-                    usr.user_id,
-                    sum( usr.study_duration ) study_duration,
-                    MIN( usr.first_start_time ) first_start_time
-                FROM
-                    user_study_record usr
-                WHERE
-                    usr.order_goods_id = #{orderGoodsId}
-                GROUP BY
-                    usr.module_id,
-                    usr.chapter_id,
-                    usr.section_id,
-                    usr.user_id
-            ) r
-                LEFT JOIN course_section cs ON r.section_id = cs.section_id
-                LEFT JOIN `user` u ON r.user_id = u.user_id
-                LEFT JOIN course_module cm ON r.module_id = cm.module_id
-                LEFT JOIN course_chapter cc ON r.chapter_id = cc.chapter_id
-            where
-                1=1
-            <if test="moduleName != null and moduleName != ''" >
-                AND cm.module_name like concat('%', #{moduleName}, '%')
-            </if>
-            <if test="chapterName != null and chapterName != ''" >
-                AND cc.`name` like concat('%', #{chapterName}, '%')
-            </if>
-            <if test="sectionName != null and sectionName != ''" >
-                AND cs.`name` like concat('%', #{sectionName}, '%')
-            </if>
+        user_period up
+        LEFT JOIN user_period_status ups ON up.id = ups.period_id
+        WHERE
+        up.goods_id = #{goodsId}
+        AND up.course_id = #{courseId}
+        AND up.section_id = #{sectionId}
+        <if test="moduleId != null and moduleId !='' and moduleId != 0">
+            AND up.module_id = #{moduleId}
+        </if>
+        <if test="chapterId != null and chapterId !='' and chapterId != 0">
+            AND up.chapter_id = #{chapterId}
+        </if>
+        LIMIT 1
     </select>
 
-    <select id="selectSectionRecord" parameterType="com.zhongzheng.modules.user.bo.UserStudyRecordQueryBo"  resultMap="SectionStudyRecordVoResult">
+    <select id="userSectionLiveList" parameterType="com.zhongzheng.modules.user.bo.UserStudyRecordQueryBo"
+            resultMap="SectionStudyRecordVoResult">
+        SELECT
+        r.*,
+        cs.section_type,
+        cs.real_duration,
+        cs.duration_time,
+        u.realname,
+        u.id_card,
+        cs.`name` as section_name,
+        cm.module_name,
+        cc.`name` as chapter_name
+        FROM
+        (
         SELECT
-            *
+        usr.module_id,
+        usr.chapter_id,
+        usr.section_id,
+        usr.user_id,
+        sum( usr.study_duration ) study_duration,
+        MIN( usr.first_start_time ) first_start_time
         FROM
-            user_study_record
+        user_study_record usr
         WHERE
-            user_id = #{userId}
+        usr.order_goods_id = #{orderGoodsId}
+        GROUP BY
+        usr.module_id,
+        usr.chapter_id,
+        usr.section_id,
+        usr.user_id
+        ) r
+        LEFT JOIN course_section cs ON r.section_id = cs.section_id
+        LEFT JOIN `user` u ON r.user_id = u.user_id
+        LEFT JOIN course_module cm ON r.module_id = cm.module_id
+        LEFT JOIN course_chapter cc ON r.chapter_id = cc.chapter_id
+        where
+        1=1
+        <if test="moduleName != null and moduleName != ''">
+            AND cm.module_name like concat('%', #{moduleName}, '%')
+        </if>
+        <if test="chapterName != null and chapterName != ''">
+            AND cc.`name` like concat('%', #{chapterName}, '%')
+        </if>
+        <if test="sectionName != null and sectionName != ''">
+            AND cs.`name` like concat('%', #{sectionName}, '%')
+        </if>
+    </select>
+
+    <select id="selectSectionRecord" parameterType="com.zhongzheng.modules.user.bo.UserStudyRecordQueryBo"
+            resultMap="SectionStudyRecordVoResult">
+        SELECT *
+        FROM user_study_record
+        WHERE user_id = #{userId}
           AND grade_id = #{gradeId}
           AND course_id = #{courseId}
           AND module_id = #{moduleId}