|
|
@@ -1173,7 +1173,7 @@ FROM
|
|
|
WHERE log.send_type =1
|
|
|
<include refid="commonConditions"/>
|
|
|
<if test="orderSTime != null and orderETime != null">
|
|
|
- AND po.create_time BETWEEN #{orderSTime} AND #{orderETime}
|
|
|
+ AND DATE(po.create_time) BETWEEN #{orderSTime} AND #{orderETime}
|
|
|
</if>
|
|
|
ORDER BY u.register_date DESC
|
|
|
</select>
|
|
|
@@ -1207,10 +1207,10 @@ FROM
|
|
|
</if>
|
|
|
WHERE log.send_type =1
|
|
|
<if test="sTime != null and eTime != null">
|
|
|
- AND log.create_time BETWEEN #{sTime} AND #{eTime}
|
|
|
+ AND DATE(log.create_time) BETWEEN #{sTime} AND #{eTime}
|
|
|
</if>
|
|
|
<if test="orderSTime != null and orderETime != null">
|
|
|
- AND po.create_time BETWEEN #{orderSTime} AND #{orderETime}
|
|
|
+ AND DATE(po.create_time) BETWEEN #{orderSTime} AND #{orderETime}
|
|
|
</if>
|
|
|
<!-- 销售公司 -->
|
|
|
<if test="companyId != null and companyId != ''">
|
|
|
@@ -1276,10 +1276,10 @@ FROM
|
|
|
</if>
|
|
|
WHERE log.send_type =1
|
|
|
<if test="sTime != null and eTime != null">
|
|
|
- AND log.create_time BETWEEN #{sTime} AND #{eTime}
|
|
|
+ AND DATE(log.create_time) BETWEEN #{sTime} AND #{eTime}
|
|
|
</if>
|
|
|
<if test="orderSTime != null and orderETime != null">
|
|
|
- AND po.create_time BETWEEN #{orderSTime} AND #{orderETime}
|
|
|
+ AND DATE(po.create_time) BETWEEN #{orderSTime} AND #{orderETime}
|
|
|
</if>
|
|
|
<!-- 销售公司 -->
|
|
|
<if test="companyId != null and companyId != ''">
|
|
|
@@ -1392,7 +1392,7 @@ FROM
|
|
|
</foreach>
|
|
|
<!--下单时间-->
|
|
|
<if test="watchParam.orderSTime != null and watchParam.orderETime != null">
|
|
|
- AND create_time BETWEEN #{watchParam.orderSTime} AND #{watchParam.orderETime}
|
|
|
+ AND DATE(create_time) BETWEEN #{watchParam.orderSTime} AND #{watchParam.orderETime}
|
|
|
</if>
|
|
|
GROUP BY user_id
|
|
|
</select>
|
|
|
@@ -1424,39 +1424,40 @@ FROM
|
|
|
c.company_id AS companyId,
|
|
|
c.company_name AS companyName
|
|
|
FROM company c
|
|
|
- <where>
|
|
|
- <if test="companyId != null and companyId != ''">
|
|
|
- AND company_id = #{companyId}
|
|
|
- </if>
|
|
|
- <if test="trainingCampId != null">
|
|
|
- AND EXISTS (
|
|
|
- SELECT 1 FROM fs_course_watch_log w
|
|
|
- INNER JOIN fs_user_course_period p ON w.period_id = p.period_id
|
|
|
- WHERE w.company_id = c.company_id
|
|
|
- AND p.training_camp_id = #{trainingCampId}
|
|
|
- <if test="sTime != null and eTime != null">
|
|
|
- AND w.create_time BETWEEN #{sTime} AND #{eTime}
|
|
|
- </if>
|
|
|
- )
|
|
|
- </if>
|
|
|
- <if test="periodId != null">
|
|
|
- AND EXISTS (
|
|
|
- SELECT 1 FROM fs_course_watch_log w
|
|
|
- WHERE w.company_id = c.company_id
|
|
|
- AND w.period_id = #{periodId}
|
|
|
- <if test="sTime != null and eTime != null">
|
|
|
- AND w.create_time BETWEEN #{sTime} AND #{eTime}
|
|
|
- </if>
|
|
|
- )
|
|
|
- </if>
|
|
|
- <if test="(trainingCampId == null and periodId == null) and (sTime != null and eTime != null)">
|
|
|
- AND EXISTS (
|
|
|
- SELECT 1 FROM fs_course_watch_log w
|
|
|
- WHERE w.company_id = c.company_id
|
|
|
- AND w.create_time BETWEEN #{sTime} AND #{eTime}
|
|
|
- )
|
|
|
- </if>
|
|
|
- </where>
|
|
|
+ <choose>
|
|
|
+ <!-- 当传了 trainingCampId 时 -->
|
|
|
+ <when test="trainingCampId != null">
|
|
|
+ INNER JOIN fs_course_watch_log w ON c.company_id = w.company_id
|
|
|
+ INNER JOIN fs_user_course_period p ON w.period_id = p.period_id AND p.training_camp_id = #{trainingCampId}
|
|
|
+ </when>
|
|
|
+ <!-- 当传了 periodId 时 -->
|
|
|
+ <when test="periodId != null">
|
|
|
+ INNER JOIN fs_course_watch_log w ON c.company_id = w.company_id AND w.period_id = #{periodId}
|
|
|
+ </when>
|
|
|
+ <!-- 当只传了时间范围时 -->
|
|
|
+ <when test="(trainingCampId == null and periodId == null) and (sTime != null and eTime != null)">
|
|
|
+ INNER JOIN fs_course_watch_log w ON c.company_id = w.company_id
|
|
|
+ </when>
|
|
|
+<!-- <!– 默认情况:必须有关联记录 –>-->
|
|
|
+<!-- <otherwise>-->
|
|
|
+<!-- INNER JOIN fs_course_watch_log w ON c.company_id = w.company_id-->
|
|
|
+<!-- </otherwise>-->
|
|
|
+ </choose>
|
|
|
+ <where>
|
|
|
+ <if test="companyId != null and companyId != ''">
|
|
|
+ AND c.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ <if test="(trainingCampId == null and periodId == null) and (sTime != null and eTime != null)">
|
|
|
+ AND Date(w.create_time) BETWEEN #{sTime} AND #{eTime}
|
|
|
+ </if>
|
|
|
+ <if test="trainingCampId != null and (sTime != null and eTime != null)">
|
|
|
+ AND Date(w.create_time) BETWEEN #{sTime} AND #{eTime}
|
|
|
+ </if>
|
|
|
+ <if test="periodId != null and (sTime != null and eTime != null)">
|
|
|
+ AND Date(w.create_time) BETWEEN #{sTime} AND #{eTime}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY c.company_id, c.company_name
|
|
|
</select>
|
|
|
<select id="selectWatchStatistics" resultType="com.fs.his.vo.FsCourseReportVO">
|
|
|
SELECT
|
|
|
@@ -1466,11 +1467,11 @@ FROM
|
|
|
COUNT(DISTINCT CASE WHEN log_type = 1 THEN user_id END) AS watchingCount,
|
|
|
COUNT(DISTINCT CASE WHEN log_type = 2 THEN user_id END) AS finishedCount,
|
|
|
COUNT(DISTINCT CASE WHEN log_type = 4 THEN user_id END) AS interruptedCount,
|
|
|
- COUNT(DISTINCT CASE WHEN DATE(create_time) = CURDATE() THEN user_id END) AS accessCount
|
|
|
+ COUNT(DISTINCT user_id) AS accessCount
|
|
|
FROM fs_course_watch_log
|
|
|
<where>
|
|
|
<if test="sTime != null and eTime != null">
|
|
|
- AND create_time BETWEEN #{sTime} AND #{eTime}
|
|
|
+ AND Date(create_time) BETWEEN #{sTime} AND #{eTime}
|
|
|
</if>
|
|
|
<if test="trainingCampId != null">
|
|
|
AND period_id IN (SELECT period_id FROM fs_user_course_period WHERE training_camp_id = #{trainingCampId})
|
|
|
@@ -1496,7 +1497,7 @@ FROM
|
|
|
INNER JOIN fs_course_watch_log w ON a.watch_log_id = w.log_id
|
|
|
<where>
|
|
|
<if test="sTime != null and eTime != null">
|
|
|
- AND w.create_time BETWEEN #{sTime} AND #{eTime}
|
|
|
+ AND Date(w.create_time) BETWEEN #{sTime} AND #{eTime}
|
|
|
</if>
|
|
|
<if test="trainingCampId != null">
|
|
|
AND w.period_id IN (SELECT period_id FROM fs_user_course_period WHERE training_camp_id = #{trainingCampId})
|
|
|
@@ -1522,7 +1523,7 @@ FROM
|
|
|
INNER JOIN fs_course_watch_log w ON rpl.watch_log_id = w.log_id
|
|
|
<where>
|
|
|
<if test="sTime != null and eTime != null">
|
|
|
- AND w.create_time BETWEEN #{sTime} AND #{eTime}
|
|
|
+ AND DATE(w.create_time) BETWEEN #{sTime} AND #{eTime}
|
|
|
</if>
|
|
|
<if test="companyIds != null and companyIds.size() > 0">
|
|
|
AND w.company_id IN
|
|
|
@@ -1623,7 +1624,7 @@ FROM
|
|
|
</if>
|
|
|
<!-- 时间范围 -->
|
|
|
<if test="sTime != null and eTime != null">
|
|
|
- AND log.create_time BETWEEN #{sTime} AND #{eTime}
|
|
|
+ AND DATE(log.create_time) BETWEEN #{sTime} AND #{eTime}
|
|
|
</if>
|
|
|
<!-- 训练营 -->
|
|
|
<if test="trainingCampId != null and trainingCampId != ''">
|