|
@@ -264,35 +264,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
fu.avatar,
|
|
|
fu.phone as phoneNumber,
|
|
|
fu.create_time,
|
|
|
- fcwl.create_time as watchDate,
|
|
|
- ifnull(t1.watchCount, 0) as watchCount,
|
|
|
- ifnull(t1.finishCount, 0) as finishCount,
|
|
|
- ifnull(t1.watchTime, 0 ) as watchTime,
|
|
|
- if(ifnull(t2.redcount, 0) > 0, 1, 0) AS redStatus
|
|
|
+ max(fcwl.create_time) as watchDate
|
|
|
from fs_user_course fuc
|
|
|
inner join fs_course_watch_log fcwl on fcwl.course_id = fuc.course_id
|
|
|
inner join fs_user fu on fu.user_id = fcwl.user_id
|
|
|
- left join (
|
|
|
- select user_id,
|
|
|
- count(log_id) AS watchCount,
|
|
|
- count(case when log_type = 2 then log_id end) AS finishCount,
|
|
|
- sum(duration) AS watchTime
|
|
|
- from fs_course_watch_log
|
|
|
- group by user_id
|
|
|
- ) t1 on t1.user_id = fu.user_id
|
|
|
- left join (
|
|
|
- select user_id, course_id, count(log_id) as redcount
|
|
|
- from fs_course_red_packet_log
|
|
|
- group by user_id, course_id
|
|
|
- ) t2 on t2.user_id = fu.user_id and t2.course_id = fuc.course_id
|
|
|
- <if test="params.type == 0">
|
|
|
- left join (
|
|
|
- select user_id, course_id, count(log_id) as count
|
|
|
- from fs_course_answer_logs
|
|
|
- where is_right = 1
|
|
|
- group by user_id, course_id
|
|
|
- ) t3 on t3.user_id = fu.user_id and t3.course_id = fuc.course_id
|
|
|
- </if>
|
|
|
where fuc.course_id = #{params.courseId}
|
|
|
<if test="params.keyword != null and params.keyword != ''">
|
|
|
and (
|
|
@@ -304,7 +279,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</if>
|
|
|
<choose>
|
|
|
<when test="params.type == 0">
|
|
|
- and t3.count > 0
|
|
|
+ and (
|
|
|
+ select count(log_id) as count
|
|
|
+ from fs_course_answer_logs
|
|
|
+ where user_id = fu.user_id and course_id = fuc.course_id and is_right = 1
|
|
|
+ ) > 0
|
|
|
</when>
|
|
|
<when test="params.type == 1">
|
|
|
and fcwl.log_type = 2
|