|
|
@@ -1206,6 +1206,106 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</select>
|
|
|
|
|
|
|
|
|
+ <!-- 查询观看和完成人数 -->
|
|
|
+ <select id="countUserWatchStats" resultType="Map">
|
|
|
+ SELECT
|
|
|
+ COUNT(DISTINCT CASE WHEN l.log_type != 3 AND l.send_type = 1 THEN l.user_id END) AS courseWatchNum,
|
|
|
+ COUNT(DISTINCT CASE WHEN l.log_type = 2 AND l.send_type = 1 THEN l.user_id END) AS courseCompleteNum
|
|
|
+ FROM fs_course_watch_log l
|
|
|
+ LEFT JOIN fs_user u ON u.user_id = l.user_id
|
|
|
+ LEFT JOIN company_user cu_l ON l.company_user_id = cu_l.user_id
|
|
|
+ <where>
|
|
|
+ <if test="userId != null and userId != 0">
|
|
|
+ AND (cu_l.user_id = #{userId} OR cu_l.parent_id = #{userId})
|
|
|
+ </if>
|
|
|
+ <if test="userId != null and userId == 0">
|
|
|
+ AND l.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ <if test="periodId != null and periodId != ''">
|
|
|
+ AND l.period_id = #{periodId}
|
|
|
+ </if>
|
|
|
+ <if test="videoId != null and videoId != ''">
|
|
|
+ AND l.video_id = #{videoId}
|
|
|
+ </if>
|
|
|
+ <if test="startTime != null and startTime != ''">
|
|
|
+ AND l.create_time >= #{startTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
+ AND l.create_time <= #{endTime}
|
|
|
+ </if>
|
|
|
+ <if test="companyUserId != null and companyUserId != ''">
|
|
|
+ AND l.company_user_id = #{companyUserId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 查询答题人数和答对人数 -->
|
|
|
+ <select id="countUserAnswerStats" resultType="Map">
|
|
|
+ SELECT
|
|
|
+ COUNT(DISTINCT CASE WHEN a.user_id THEN a.user_id END) AS answerNum,
|
|
|
+ COUNT(DISTINCT CASE WHEN a.is_right = 1 THEN a.user_id END) AS answerRightNum
|
|
|
+ FROM fs_course_answer_logs a
|
|
|
+ LEFT JOIN fs_user u ON u.user_id = a.user_id
|
|
|
+ LEFT JOIN company_user cu_a ON a.company_user_id = cu_a.user_id
|
|
|
+ <where>
|
|
|
+ <if test="userId != null and userId != 0">
|
|
|
+ AND (cu_a.user_id = #{userId} OR cu_a.parent_id = #{userId})
|
|
|
+ </if>
|
|
|
+ <if test="userId != null and userId == 0">
|
|
|
+ AND a.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ <if test="periodId != null and periodId != ''">
|
|
|
+ AND a.period_id = #{periodId}
|
|
|
+ </if>
|
|
|
+ <if test="videoId != null and videoId != ''">
|
|
|
+ AND a.video_id = #{videoId}
|
|
|
+ </if>
|
|
|
+ <if test="startTime != null and startTime != ''">
|
|
|
+ AND a.create_time >= #{startTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
+ AND a.create_time <= #{endTime}
|
|
|
+ </if>
|
|
|
+ <if test="companyUserId != null and companyUserId != ''">
|
|
|
+ AND a.company_user_id = #{companyUserId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 查询红包数量和红包金额 -->
|
|
|
+ <select id="countUserRedPacketStats" resultType="Map">
|
|
|
+ SELECT
|
|
|
+ COUNT(CASE WHEN flog.status = 1 THEN flog.log_id END) AS redPacketNum,
|
|
|
+ IFNULL(SUM(CASE WHEN flog.status = 1 THEN flog.amount END), 0) AS redPacketAmount
|
|
|
+ FROM fs_course_red_packet_log flog
|
|
|
+ LEFT JOIN fs_user u ON u.user_id = flog.user_id
|
|
|
+ LEFT JOIN company_user cu_flog ON flog.company_user_id = cu_flog.user_id
|
|
|
+ <where>
|
|
|
+ <if test="userId != null and userId != 0">
|
|
|
+ AND (cu_flog.user_id = #{userId} OR cu_flog.parent_id = #{userId})
|
|
|
+ </if>
|
|
|
+ <if test="userId != null and userId == 0">
|
|
|
+ AND flog.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ <if test="periodId != null and periodId != ''">
|
|
|
+ AND flog.period_id = #{periodId}
|
|
|
+ </if>
|
|
|
+ <if test="videoId != null and videoId != ''">
|
|
|
+ AND flog.video_id = #{videoId}
|
|
|
+ </if>
|
|
|
+ <if test="startTime != null and startTime != ''">
|
|
|
+ AND flog.create_time >= #{startTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
+ AND flog.create_time <= #{endTime}
|
|
|
+ </if>
|
|
|
+ <if test="companyUserId != null and companyUserId != ''">
|
|
|
+ AND flog.company_user_id = #{companyUserId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
<select id="countUserAnswer" resultType="Map">
|
|
|
SELECT
|
|
|
(
|