Explorar o código

fix 学习记录

he2802 %!s(int64=3) %!d(string=hai) anos
pai
achega
cc0a83a895

+ 16 - 9
zhongzheng-system/src/main/resources/mapper/modules/user/UserStudyRecordMapper.xml

@@ -170,9 +170,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         (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
-        <if test="courseId != null and courseId !=''">
-            AND  c.course_id = r.course_id
-        </if>
+        AND  c.course_id = r.course_id
          and c.current_status=1 and  c.grade_id=#{gradeId} and c.user_id=#{userId} and c.status = 1 and c.goods_id = #{goodsId}) as record_num
         FROM
         course r
@@ -213,7 +211,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             s.duration_time,
         usr1.start_time,
         usr1.end_time,
-        usr1.`status`,
+        IFNULL(usr1.`status`,0) `status`,
         usr1.video_current_time
         FROM
             course_menu m
@@ -222,7 +220,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         any_value ( usr.first_start_time ) start_time,
         any_value ( usr.video_current_time ) video_current_time,
         any_value ( usr.end_time ) end_time,
-        IFNULL(MAX ( usr.`status` ),0) `status`,
+        MAX ( usr.`status` ) `status`,
         any_value ( usr.section_id ) section_id
         FROM
         ( SELECT * FROM user_study_record WHERE 1=1
@@ -232,6 +230,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </if>
         <if test="goodsId != null and goodsId !=''">
             AND goods_id = #{goodsId}
+        </if>
+        <if test="gradeId != null and gradeId !=''">
+            AND grade_id = #{gradeId}
         </if>
                  AND course_id = #{courseId} ORDER BY record_id DESC LIMIT 9999 ) usr
         GROUP BY
@@ -250,7 +251,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             s.duration_time,
         usr1.start_time,
         usr1.end_time,
-        usr1.`status`,
+        IFNULL(usr1.`status`,0) `status`,
         usr1.video_current_time
         FROM
             course_chapter_section c
@@ -260,7 +261,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             any_value ( usr.first_start_time ) start_time,
             any_value ( usr.video_current_time ) video_current_time,
             any_value ( usr.end_time ) end_time,
-            any_value ( usr.`status` ) `status`,
+            MAX ( usr.`status` ) `status`,
             any_value ( usr.section_id ) section_id
             FROM
             ( SELECT * FROM user_study_record WHERE 1=1
@@ -270,6 +271,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="userId != null and userId !=''">
                 AND goods_id = #{goodsId}
             </if>
+            <if test="gradeId != null and gradeId !=''">
+                AND grade_id = #{gradeId}
+            </if>
             AND course_id = #{courseId} ORDER BY record_id DESC LIMIT 9999 ) usr
             GROUP BY
             usr.section_id) usr1 on s.section_id = usr1.section_id
@@ -287,7 +291,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             s.duration_time,
         usr1.start_time,
         usr1.end_time,
-        usr1.`status`,
+        IFNULL(usr1.`status`,0) `status`,
         usr1.video_current_time
         FROM
             course_chapter_section c
@@ -298,7 +302,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         any_value ( usr.first_start_time ) start_time,
         any_value ( usr.video_current_time ) video_current_time,
         any_value ( usr.end_time ) end_time,
-        any_value ( usr.`status` ) `status`,
+        MAX ( usr.`status` ) `status`,
         any_value ( usr.section_id ) section_id
         FROM
         ( SELECT * FROM user_study_record WHERE 1=1
@@ -308,6 +312,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="userId != null and userId !=''">
             AND goods_id = #{goodsId}
         </if>
+        <if test="gradeId != null and gradeId !=''">
+            AND grade_id = #{gradeId}
+        </if>
         AND course_id = #{courseId} ORDER BY record_id DESC LIMIT 9999 ) usr
         GROUP BY
         usr.section_id) usr1 on s.section_id = usr1.section_id