|
@@ -249,4 +249,68 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
ORDER BY
|
|
|
c.course_id
|
|
|
</select>
|
|
|
+
|
|
|
+ <!-- 查询用户参与记录 -->
|
|
|
+ <select id="getParticipationRecordByMap" resultType="com.fs.course.vo.FsUserCourseParticipationRecordVO">
|
|
|
+ select distinct
|
|
|
+ fu.user_id,
|
|
|
+ fuc.course_id,
|
|
|
+ fu.nickname as nickName,
|
|
|
+ fu.username as userName,
|
|
|
+ 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
|
|
|
+ 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 (
|
|
|
+ fu.user_id = #{params.keyword}
|
|
|
+ or fu.nickname like concat('%', #{params.keyword}, '%')
|
|
|
+ or fu.username like concat('%', #{params.keyword}, '%')
|
|
|
+ or fu.phone = #{params.keyword}
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ <choose>
|
|
|
+ <when test="params.type == 0">
|
|
|
+ and t3.count > 0
|
|
|
+ </when>
|
|
|
+ <when test="params.type == 1">
|
|
|
+ and fcwl.log_type = 2
|
|
|
+ </when>
|
|
|
+ <when test="params.type == 2">
|
|
|
+ and fcwl.log_type in (1,4)
|
|
|
+ </when>
|
|
|
+ <otherwise>
|
|
|
+ and fcwl.log_type = 3
|
|
|
+ </otherwise>
|
|
|
+ </choose>
|
|
|
+ </select>
|
|
|
</mapper>
|