|
@@ -224,50 +224,129 @@
|
|
|
GROUP BY company_id
|
|
GROUP BY company_id
|
|
|
limit 10
|
|
limit 10
|
|
|
</select>
|
|
</select>
|
|
|
- <select id="watchCourseTopTen" resultType="com.fs.statis.dto.CourseStatsDTO">
|
|
|
|
|
|
|
+<!-- <select id="watchCourseTopTen" resultType="com.fs.statis.dto.CourseStatsDTO">-->
|
|
|
|
|
+<!-- SELECT-->
|
|
|
|
|
+<!-- w.course_id AS course_id,-->
|
|
|
|
|
+<!-- COUNT(DISTINCT w.user_id) AS watch_user_count,-->
|
|
|
|
|
+<!-- COUNT(DISTINCT CASE WHEN w.log_type = 2 THEN w.user_id END) AS completed_user_count,-->
|
|
|
|
|
+<!-- COUNT(DISTINCT a.user_id) AS answer_user_count,-->
|
|
|
|
|
+<!-- COUNT(DISTINCT CASE WHEN a.is_right = 1 THEN a.user_id END) AS correct_user_count-->
|
|
|
|
|
+<!-- FROM-->
|
|
|
|
|
+<!-- fs_course_watch_log w-->
|
|
|
|
|
+<!-- LEFT JOIN-->
|
|
|
|
|
+<!-- fs_course_answer_logs a ON w.video_id = a.video_id AND w.user_id = a.user_id-->
|
|
|
|
|
+<!-- <where>-->
|
|
|
|
|
+<!-- <if test="startTime != null">-->
|
|
|
|
|
+<!-- w.create_time <![CDATA[>=]]> #{startTime}-->
|
|
|
|
|
+<!-- </if>-->
|
|
|
|
|
+<!-- <if test="endTime != null">-->
|
|
|
|
|
+<!-- AND w.create_time <![CDATA[<]]> #{endTime}-->
|
|
|
|
|
+<!-- </if>-->
|
|
|
|
|
+<!-- <if test="userType != null">-->
|
|
|
|
|
+<!-- AND send_type = ${userType}-->
|
|
|
|
|
+<!-- </if>-->
|
|
|
|
|
+<!-- <if test="companyId != null">-->
|
|
|
|
|
+<!-- AND w.company_id = ${companyId}-->
|
|
|
|
|
+<!-- </if>-->
|
|
|
|
|
+<!-- </where>-->
|
|
|
|
|
+<!-- GROUP BY-->
|
|
|
|
|
+<!-- w.course_id-->
|
|
|
|
|
+<!-- ORDER BY-->
|
|
|
|
|
+<!-- -- 观看人数-->
|
|
|
|
|
+<!-- <if test="statisticalType == 0">-->
|
|
|
|
|
+<!-- COUNT(DISTINCT w.user_id)-->
|
|
|
|
|
+<!-- </if>-->
|
|
|
|
|
+<!-- <if test="statisticalType == 1">-->
|
|
|
|
|
+<!-- COUNT(DISTINCT CASE WHEN w.log_type = 2 THEN w.user_id END)-->
|
|
|
|
|
+<!-- </if>-->
|
|
|
|
|
+<!-- <if test="statisticalType == 2">-->
|
|
|
|
|
+<!-- COUNT(DISTINCT a.user_id)-->
|
|
|
|
|
+<!-- </if>-->
|
|
|
|
|
+<!-- <if test="statisticalType == 3">-->
|
|
|
|
|
+<!-- COUNT(DISTINCT CASE WHEN a.is_right = 1 THEN a.user_id END)-->
|
|
|
|
|
+<!-- </if>-->
|
|
|
|
|
+<!-- ${sort}-->
|
|
|
|
|
+<!-- LIMIT 10-->
|
|
|
|
|
+<!-- </select>-->
|
|
|
|
|
+ <select id="watchCourseTopTen"
|
|
|
|
|
+ resultType="com.fs.statis.dto.CourseStatsDTO">
|
|
|
|
|
+
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ t.courseId,
|
|
|
|
|
+ t.watchUserCount,
|
|
|
|
|
+ t.completedUserCount,
|
|
|
|
|
+ t.answerUserCount,
|
|
|
|
|
+ t.correctUserCount
|
|
|
|
|
+ FROM (
|
|
|
SELECT
|
|
SELECT
|
|
|
- w.course_id AS course_id,
|
|
|
|
|
- COUNT(DISTINCT w.user_id) AS watch_user_count,
|
|
|
|
|
- COUNT(DISTINCT CASE WHEN w.log_type = 2 THEN w.user_id END) AS completed_user_count,
|
|
|
|
|
- COUNT(DISTINCT a.user_id) AS answer_user_count,
|
|
|
|
|
- COUNT(DISTINCT CASE WHEN a.is_right = 1 THEN a.user_id END) AS correct_user_count
|
|
|
|
|
|
|
+ w.course_id AS courseId,
|
|
|
|
|
+ COUNT(w.user_id) AS watchUserCount,
|
|
|
|
|
+ SUM(w.completed_flag) AS completedUserCount,
|
|
|
|
|
+ COUNT(a.user_id) AS answerUserCount,
|
|
|
|
|
+ SUM(a.correct_flag) AS correctUserCount
|
|
|
FROM
|
|
FROM
|
|
|
- fs_course_watch_log w
|
|
|
|
|
- LEFT JOIN
|
|
|
|
|
- fs_course_answer_logs a ON w.video_id = a.video_id AND w.user_id = a.user_id
|
|
|
|
|
|
|
+ (
|
|
|
|
|
+ /* 看课用户去重 + 是否完课 */
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ course_id,
|
|
|
|
|
+ user_id,
|
|
|
|
|
+ MAX(CASE WHEN log_type = 2 THEN 1 ELSE 0 END) AS completed_flag
|
|
|
|
|
+ FROM fs_course_watch_log
|
|
|
<where>
|
|
<where>
|
|
|
- <if test="startTime != null">
|
|
|
|
|
- w.create_time <![CDATA[>=]]> #{startTime}
|
|
|
|
|
|
|
+ <if test="startTime != null and startTime != ''">
|
|
|
|
|
+ AND create_time <![CDATA[>=]]> #{startTime}
|
|
|
</if>
|
|
</if>
|
|
|
- <if test="endTime != null">
|
|
|
|
|
- AND w.create_time <![CDATA[<]]> #{endTime}
|
|
|
|
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
|
|
+ AND create_time <![CDATA[<]]> #{endTime}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="userType != null">
|
|
<if test="userType != null">
|
|
|
- AND send_type = ${userType}
|
|
|
|
|
|
|
+ AND send_type = #{userType}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="companyId != null">
|
|
<if test="companyId != null">
|
|
|
- AND w.company_id = ${companyId}
|
|
|
|
|
|
|
+ AND company_id = #{companyId}
|
|
|
</if>
|
|
</if>
|
|
|
</where>
|
|
</where>
|
|
|
- GROUP BY
|
|
|
|
|
- w.course_id
|
|
|
|
|
- ORDER BY
|
|
|
|
|
- -- 观看人数
|
|
|
|
|
- <if test="statisticalType == 0">
|
|
|
|
|
- COUNT(DISTINCT w.user_id)
|
|
|
|
|
- </if>
|
|
|
|
|
- <if test="statisticalType == 1">
|
|
|
|
|
- COUNT(DISTINCT CASE WHEN w.log_type = 2 THEN w.user_id END)
|
|
|
|
|
- </if>
|
|
|
|
|
- <if test="statisticalType == 2">
|
|
|
|
|
- COUNT(DISTINCT a.user_id)
|
|
|
|
|
|
|
+ GROUP BY course_id, user_id
|
|
|
|
|
+ ) w
|
|
|
|
|
+ LEFT JOIN
|
|
|
|
|
+ (
|
|
|
|
|
+ /* 答题用户去重 + 是否答对 */
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ course_id,
|
|
|
|
|
+ user_id,
|
|
|
|
|
+ MAX(CASE WHEN is_right = 1 THEN 1 ELSE 0 END) AS correct_flag
|
|
|
|
|
+ FROM fs_course_answer_logs
|
|
|
|
|
+ <where>
|
|
|
|
|
+ <if test="startTime != null and startTime != ''">
|
|
|
|
|
+ AND create_time <![CDATA[>=]]> #{startTime}
|
|
|
</if>
|
|
</if>
|
|
|
- <if test="statisticalType == 3">
|
|
|
|
|
- COUNT(DISTINCT CASE WHEN a.is_right = 1 THEN a.user_id END)
|
|
|
|
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
|
|
+ AND create_time <![CDATA[<]]> #{endTime}
|
|
|
</if>
|
|
</if>
|
|
|
- ${sort}
|
|
|
|
|
|
|
+ </where>
|
|
|
|
|
+ GROUP BY course_id, user_id
|
|
|
|
|
+ ) a
|
|
|
|
|
+ ON w.course_id = a.course_id
|
|
|
|
|
+ AND w.user_id = a.user_id
|
|
|
|
|
+ GROUP BY w.course_id
|
|
|
|
|
+ ) t
|
|
|
|
|
+ ORDER BY
|
|
|
|
|
+ <choose>
|
|
|
|
|
+ <when test="statisticalType == 0">t.watchUserCount</when>
|
|
|
|
|
+ <when test="statisticalType == 1">t.completedUserCount</when>
|
|
|
|
|
+ <when test="statisticalType == 2">t.answerUserCount</when>
|
|
|
|
|
+ <when test="statisticalType == 3">t.correctUserCount</when>
|
|
|
|
|
+ <otherwise>t.watchUserCount</otherwise>
|
|
|
|
|
+ </choose>
|
|
|
|
|
+ <choose>
|
|
|
|
|
+ <when test="sort == 'ASC'">ASC</when>
|
|
|
|
|
+ <otherwise>DESC</otherwise>
|
|
|
|
|
+ </choose>
|
|
|
LIMIT 10
|
|
LIMIT 10
|
|
|
|
|
+
|
|
|
</select>
|
|
</select>
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
<select id="rewardMoneyTopTen" resultType="com.fs.statis.dto.RewardMoneyTopTenDTO">
|
|
<select id="rewardMoneyTopTen" resultType="com.fs.statis.dto.RewardMoneyTopTenDTO">
|
|
|
SELECT
|
|
SELECT
|
|
|
-- 按公司
|
|
-- 按公司
|