|
@@ -124,8 +124,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
LEFT JOIN fs_user ON fs_user.user_id = flog.user_id
|
|
|
LEFT JOIN company_user ON company_user.user_id = fs_user.company_user_id
|
|
|
<where>
|
|
|
- <if test="companyUserId != null and companyUserId !='' ">
|
|
|
- AND company_user.user_id = #{companyUserId}
|
|
|
+ <if test="companyUserId != null and companyUserId != 0 ">
|
|
|
+ AND fs_user.company_user_id = #{companyUserId}
|
|
|
+ </if>
|
|
|
+ <if test="companyUserId != null and companyUserId == 0 ">
|
|
|
+ and fs_user.company_id = #{companyId}
|
|
|
</if>
|
|
|
<if test="periodId != null and periodId != ''">
|
|
|
AND flog.period_id = #{periodId}
|
|
@@ -163,8 +166,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
LEFT JOIN fs_user ON fs_user.user_id = fs_course_answer_logs.user_id
|
|
|
LEFT JOIN company_user ON company_user.user_id = fs_user.company_user_id
|
|
|
<where>
|
|
|
- <if test="companyUserId != null and companyUserId !='' ">
|
|
|
- AND company_user.user_id = #{companyUserId}
|
|
|
+ <if test="companyUserId != null and companyUserId != 0 ">
|
|
|
+ AND fs_user.company_user_id = #{companyUserId}
|
|
|
+ </if>
|
|
|
+ <if test="companyUserId != null and companyUserId == 0 ">
|
|
|
+ and fs_user.company_id = #{companyId}
|
|
|
</if>
|
|
|
<if test="periodId != null and periodId != ''">
|
|
|
AND fs_course_answer_logs.period_id = #{periodId}
|
|
@@ -579,9 +585,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
fs_user
|
|
|
LEFT JOIN fs_user_company_user ON fs_user_company_user.user_id = fs_user.user_id
|
|
|
LEFT JOIN company_user ON company_user.user_id = fs_user_company_user.company_user_id
|
|
|
- WHERE
|
|
|
- (company_user.user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
- and fs_user.is_del = 0
|
|
|
+ WHERE fs_user.is_del = 0
|
|
|
+ <if test="userId != null and userId != 0 ">
|
|
|
+ and (fs_user.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
+ </if>
|
|
|
+ <if test="companyId != null ">
|
|
|
+ and fs_user.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
GROUP BY
|
|
|
fs_user.`status`
|
|
|
</select>
|
|
@@ -601,8 +611,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
|
<select id="getCountWatchCourse" resultType="com.fs.store.vo.h5.UserDetailsVO">
|
|
|
SELECT
|
|
|
- ifnull( complete_watch_count, 0 ) AS completeWatchCount ,
|
|
|
- ifnull( watch_times, 0 ) AS watchTimes,
|
|
|
+ <if test="dateTag == null or dateTag =='' ">
|
|
|
+ ifnull( sum(complete_watch_count), 0 ) AS completeWatchCount ,
|
|
|
+ ifnull( sum(watch_times), 0 ) AS watchTimes,
|
|
|
+ </if>
|
|
|
+ <if test="dateTag != null and dateTag !='' ">
|
|
|
+ ifnull( complete_watch_count, 0 ) AS completeWatchCount ,
|
|
|
+ ifnull( watch_times, 0 ) AS watchTimes,
|
|
|
+ </if>
|
|
|
fs_user.user_id
|
|
|
FROM
|
|
|
fs_user_course_count
|
|
@@ -625,11 +641,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</when>
|
|
|
</choose>
|
|
|
</if>
|
|
|
+ and fs_user.user_id = #{fsUserId}
|
|
|
</where>
|
|
|
GROUP BY
|
|
|
fs_user.user_id
|
|
|
- HAVING
|
|
|
- fs_user.user_id = #{fsUserId}
|
|
|
</select>
|
|
|
|
|
|
<select id="getCountAnswer" resultType="com.fs.store.vo.h5.UserDetailsVO">
|
|
@@ -641,28 +656,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
fs_course_answer_logs
|
|
|
LEFT JOIN fs_user ON fs_user.user_id = fs_course_answer_logs.user_id
|
|
|
LEFT JOIN company_user ON company_user.user_id = fs_user.company_user_id
|
|
|
- WHERE
|
|
|
- (company_user.user_id = #{userId} or company_user.parent_id = #{userId} )
|
|
|
- <if test="dateTag != null and dateTag !='' ">
|
|
|
- <choose>
|
|
|
- <when test = "dateTag == '今天'">
|
|
|
- and to_days(fs_course_answer_logs.create_time) = to_days(now())
|
|
|
- </when>
|
|
|
- <when test = "dateTag == '昨天'">
|
|
|
- and fs_course_answer_logs.create_time >= CURDATE() - INTERVAL 1 DAY AND fs_course_answer_logs.create_time < CURDATE()
|
|
|
- </when>
|
|
|
- <when test = "dateTag == '前天'">
|
|
|
- and fs_course_answer_logs.create_time >= CURDATE() - INTERVAL 2 DAY AND fs_course_answer_logs.create_time < CURDATE() - INTERVAL 1 DAY
|
|
|
- </when>
|
|
|
- <when test = "dateTag == '近七天'">
|
|
|
- and fs_course_answer_logs.create_time >= CURDATE() - INTERVAL 7 DAY
|
|
|
- </when>
|
|
|
- </choose>
|
|
|
- </if>
|
|
|
+ <where>
|
|
|
+
|
|
|
+ <if test="dateTag != null and dateTag !='' ">
|
|
|
+ <choose>
|
|
|
+ <when test = "dateTag == '今天'">
|
|
|
+ and to_days(fs_course_answer_logs.create_time) = to_days(now())
|
|
|
+ </when>
|
|
|
+ <when test = "dateTag == '昨天'">
|
|
|
+ and fs_course_answer_logs.create_time >= CURDATE() - INTERVAL 1 DAY AND fs_course_answer_logs.create_time < CURDATE()
|
|
|
+ </when>
|
|
|
+ <when test = "dateTag == '前天'">
|
|
|
+ and fs_course_answer_logs.create_time >= CURDATE() - INTERVAL 2 DAY AND fs_course_answer_logs.create_time < CURDATE() - INTERVAL 1 DAY
|
|
|
+ </when>
|
|
|
+ <when test = "dateTag == '近七天'">
|
|
|
+ and fs_course_answer_logs.create_time >= CURDATE() - INTERVAL 7 DAY
|
|
|
+ </when>
|
|
|
+ </choose>
|
|
|
+ </if>
|
|
|
+ and fs_user.user_id = #{fsUserId}
|
|
|
+ </where>
|
|
|
GROUP BY
|
|
|
fs_user.user_id
|
|
|
- HAVING
|
|
|
- fs_user.user_id = #{fsUserId}
|
|
|
) AS answerTime,
|
|
|
(
|
|
|
SELECT
|
|
@@ -671,29 +686,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
fs_course_answer_logs
|
|
|
LEFT JOIN fs_user ON fs_user.user_id = fs_course_answer_logs.user_id
|
|
|
LEFT JOIN company_user ON company_user.user_id = fs_user.company_user_id
|
|
|
- WHERE
|
|
|
- (company_user.user_id = #{userId} or company_user.parent_id = #{userId} )
|
|
|
- AND fs_course_answer_logs.is_right = 1
|
|
|
- <if test="dateTag != null and dateTag !='' ">
|
|
|
- <choose>
|
|
|
- <when test = "dateTag == '今天'">
|
|
|
- and to_days(fs_course_answer_logs.create_time) = to_days(now())
|
|
|
- </when>
|
|
|
- <when test = "dateTag == '昨天'">
|
|
|
- and fs_course_answer_logs.create_time >= CURDATE() - INTERVAL 1 DAY AND fs_course_answer_logs.create_time < CURDATE()
|
|
|
- </when>
|
|
|
- <when test = "dateTag == '前天'">
|
|
|
- and fs_course_answer_logs.create_time >= CURDATE() - INTERVAL 2 DAY AND fs_course_answer_logs.create_time < CURDATE() - INTERVAL 1 DAY
|
|
|
- </when>
|
|
|
- <when test = "dateTag == '近七天'">
|
|
|
- and fs_course_answer_logs.create_time >= CURDATE() - INTERVAL 7 DAY
|
|
|
- </when>
|
|
|
- </choose>
|
|
|
- </if>
|
|
|
+ <where>
|
|
|
+ fs_course_answer_logs.is_right = 1
|
|
|
+ <if test="dateTag != null and dateTag !='' ">
|
|
|
+ <choose>
|
|
|
+ <when test = "dateTag == '今天'">
|
|
|
+ and to_days(fs_course_answer_logs.create_time) = to_days(now())
|
|
|
+ </when>
|
|
|
+ <when test = "dateTag == '昨天'">
|
|
|
+ and fs_course_answer_logs.create_time >= CURDATE() - INTERVAL 1 DAY AND fs_course_answer_logs.create_time < CURDATE()
|
|
|
+ </when>
|
|
|
+ <when test = "dateTag == '前天'">
|
|
|
+ and fs_course_answer_logs.create_time >= CURDATE() - INTERVAL 2 DAY AND fs_course_answer_logs.create_time < CURDATE() - INTERVAL 1 DAY
|
|
|
+ </when>
|
|
|
+ <when test = "dateTag == '近七天'">
|
|
|
+ and fs_course_answer_logs.create_time >= CURDATE() - INTERVAL 7 DAY
|
|
|
+ </when>
|
|
|
+ </choose>
|
|
|
+ </if>
|
|
|
+ and fs_user.user_id = #{fsUserId}
|
|
|
+ </where>
|
|
|
GROUP BY
|
|
|
fs_user.user_id
|
|
|
- HAVING
|
|
|
- fs_user.user_id = #{fsUserId}
|
|
|
) AS answerRightTime;
|
|
|
</select>
|
|
|
|
|
@@ -706,44 +720,52 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
fs_course_red_packet_log
|
|
|
LEFT JOIN fs_user ON fs_user.user_id = fs_course_red_packet_log.user_id
|
|
|
LEFT JOIN company_user ON company_user.user_id = fs_user.company_user_id
|
|
|
- WHERE
|
|
|
- (company_user.user_id = #{userId} or company_user.parent_id = #{userId} )
|
|
|
- and fs_course_red_packet_log.status = 1
|
|
|
- <if test="dateTag != null and dateTag !='' ">
|
|
|
- <choose>
|
|
|
- <when test = "dateTag == '今天'">
|
|
|
- and to_days(fs_course_red_packet_log.create_time) = to_days(now())
|
|
|
- </when>
|
|
|
- <when test = "dateTag == '昨天'">
|
|
|
- and fs_course_red_packet_log.create_time >= CURDATE() - INTERVAL 1 DAY AND fs_course_red_packet_log.create_time < CURDATE()
|
|
|
- </when>
|
|
|
- <when test = "dateTag == '前天'">
|
|
|
- and fs_course_red_packet_log.create_time >= CURDATE() - INTERVAL 2 DAY AND fs_course_red_packet_log.create_time < CURDATE() - INTERVAL 1 DAY
|
|
|
- </when>
|
|
|
- <when test = "dateTag == '近七天'">
|
|
|
- and fs_course_red_packet_log.create_time >= CURDATE() - INTERVAL 7 DAY
|
|
|
- </when>
|
|
|
- </choose>
|
|
|
- </if>
|
|
|
+ <where>
|
|
|
+ fs_course_red_packet_log.status = 1
|
|
|
+ <if test="dateTag != null and dateTag !='' ">
|
|
|
+ <choose>
|
|
|
+ <when test = "dateTag == '今天'">
|
|
|
+ and to_days(fs_course_red_packet_log.create_time) = to_days(now())
|
|
|
+ </when>
|
|
|
+ <when test = "dateTag == '昨天'">
|
|
|
+ and fs_course_red_packet_log.create_time >= CURDATE() - INTERVAL 1 DAY AND fs_course_red_packet_log.create_time < CURDATE()
|
|
|
+ </when>
|
|
|
+ <when test = "dateTag == '前天'">
|
|
|
+ and fs_course_red_packet_log.create_time >= CURDATE() - INTERVAL 2 DAY AND fs_course_red_packet_log.create_time < CURDATE() - INTERVAL 1 DAY
|
|
|
+ </when>
|
|
|
+ <when test = "dateTag == '近七天'">
|
|
|
+ and fs_course_red_packet_log.create_time >= CURDATE() - INTERVAL 7 DAY
|
|
|
+ </when>
|
|
|
+ </choose>
|
|
|
+ </if>
|
|
|
+ and fs_user.user_id = #{fsUserId}
|
|
|
+ </where>
|
|
|
GROUP BY
|
|
|
fs_user.user_id
|
|
|
- HAVING
|
|
|
- fs_user.user_id = #{fsUserId}
|
|
|
</select>
|
|
|
|
|
|
<select id="countUserSummary" resultType="com.fs.store.vo.h5.FsUserSummaryCountVO">
|
|
|
SELECT (SELECT count(fs_user.user_id)
|
|
|
FROM fs_user
|
|
|
LEFT JOIN company_user ON fs_user.company_user_id = company_user.user_id
|
|
|
- WHERE (
|
|
|
- company_user.user_id = #{userId}
|
|
|
- OR company_user.parent_id = #{userId}
|
|
|
- ) and fs_user.is_del = 0) as userTotal,
|
|
|
+ WHERE fs_user.is_del = 0
|
|
|
+ <if test="userId != null and userId != 0 ">
|
|
|
+ and (fs_user.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
+ </if>
|
|
|
+ <if test="companyId != null ">
|
|
|
+ and fs_user.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ ) as userTotal,
|
|
|
(SELECT count(fs_user.user_id)
|
|
|
FROM fs_user
|
|
|
LEFT JOIN company_user ON fs_user.company_user_id = company_user.user_id
|
|
|
- WHERE (company_user.user_id = #{userId} OR company_user.parent_id = #{userId})
|
|
|
- and fs_user.is_del = 0
|
|
|
+ WHERE fs_user.is_del = 0
|
|
|
+ <if test="userId != null and userId != 0 ">
|
|
|
+ and (fs_user.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
+ </if>
|
|
|
+ <if test="companyId != null ">
|
|
|
+ and fs_user.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
AND to_days(fs_user.create_time) = to_days(now())) as todayNewUser
|
|
|
</select>
|
|
|
|
|
@@ -756,7 +778,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
LEFT JOIN fs_user ON fs_user.user_id = company_tag_user.user_id
|
|
|
LEFT JOIN company_tag ON FIND_IN_SET( company_tag.tag_id, company_tag_user.tag_ids ) > 0
|
|
|
LEFT JOIN company_user ON fs_user.company_user_id = company_user.user_id
|
|
|
- where (company_user.user_id = #{userId} or company_user.parent_id = #{userId} ) and company_tag.tag_id is not null
|
|
|
+ <where>
|
|
|
+ <if test="userId != null and userId != 0 ">
|
|
|
+ and (fs_user.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
+ </if>
|
|
|
+ <if test="companyId != null ">
|
|
|
+ and fs_user.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ and company_tag.tag_id is not null
|
|
|
+ </where>
|
|
|
GROUP BY
|
|
|
company_tag.tag_id
|
|
|
</select>
|
|
@@ -771,25 +801,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
LEFT JOIN fs_user ON fs_user.user_id = fcc.user_id
|
|
|
LEFT JOIN company_user ON fs_user.company_user_id = company_user.user_id
|
|
|
LEFT JOIN fs_user_course_period_days fcpd ON FIND_IN_SET(fcpd.period_id, fcc.course_ids) > 0
|
|
|
- WHERE
|
|
|
- ( company_user.user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
- <if test="startTime != null and startTime !='' ">
|
|
|
- and fcc.create_time >= #{startTime}
|
|
|
- </if>
|
|
|
- <if test="endTime != null and endTime != ''">
|
|
|
- and fcc.create_time <= #{endTime}
|
|
|
- </if>
|
|
|
- <if test="periodId != null and periodId != ''">
|
|
|
- AND fcpd.period_id = #{periodId}
|
|
|
- </if>
|
|
|
- <if test="videoId != null and videoId != ''">
|
|
|
- AND fcpd.video_id = #{videoId}
|
|
|
- </if>
|
|
|
- -- 单独通过销售id查询
|
|
|
- <if test="companyUserId != null and companyUserId != ''">
|
|
|
- AND company_user.user_id = #{companyUserId}
|
|
|
- </if>
|
|
|
-
|
|
|
+ <where>
|
|
|
+ <if test="userId != null and userId != 0 ">
|
|
|
+ and (fs_user.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
+ </if>
|
|
|
+ <if test="userId != null and userId == 0 ">
|
|
|
+ and fs_user.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ <if test="startTime != null and startTime !='' ">
|
|
|
+ and fcc.create_time >= #{startTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
+ and fcc.create_time <= #{endTime}
|
|
|
+ </if>
|
|
|
+ <if test="periodId != null and periodId != ''">
|
|
|
+ AND fcpd.period_id = #{periodId}
|
|
|
+ </if>
|
|
|
+ <if test="videoId != null and videoId != ''">
|
|
|
+ AND fcpd.video_id = #{videoId}
|
|
|
+ </if>
|
|
|
+ -- 单独通过销售id查询
|
|
|
+ <if test="companyUserId != null and companyUserId != ''">
|
|
|
+ AND company_user.user_id = #{companyUserId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
) as courseWatchNum,
|
|
|
(
|
|
|
SELECT
|
|
@@ -799,25 +834,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
LEFT JOIN fs_user ON fs_user.user_id = fcc.user_id
|
|
|
LEFT JOIN company_user ON fs_user.company_user_id = company_user.user_id
|
|
|
LEFT JOIN fs_user_course_period_days fcpd ON FIND_IN_SET(fcpd.period_id, fcc.course_ids) > 0
|
|
|
- WHERE
|
|
|
- ( company_user.user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
- AND fcc.complete_watch_count > 0
|
|
|
- <if test="startTime != null and startTime !='' ">
|
|
|
- and fcc.create_time >= #{startTime}
|
|
|
- </if>
|
|
|
- <if test="endTime != null and endTime != ''">
|
|
|
- and fcc.create_time <= #{endTime}
|
|
|
- </if>
|
|
|
- <if test="periodId != null and periodId != ''">
|
|
|
- AND fcpd.period_id = #{periodId}
|
|
|
- </if>
|
|
|
- <if test="videoId != null and videoId != ''">
|
|
|
- AND fcpd.video_id = #{videoId}
|
|
|
- </if>
|
|
|
- -- 单独通过销售id查询
|
|
|
- <if test="companyUserId != null and companyUserId != ''">
|
|
|
- AND company_user.user_id = #{companyUserId}
|
|
|
- </if>
|
|
|
+ <where>
|
|
|
+ <if test="userId != null and userId != 0 ">
|
|
|
+ and (fs_user.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
+ </if>
|
|
|
+ <if test="userId != null and userId == 0 ">
|
|
|
+ and fs_user.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ AND fcc.complete_watch_count > 0
|
|
|
+ <if test="startTime != null and startTime !='' ">
|
|
|
+ and fcc.create_time >= #{startTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
+ and fcc.create_time <= #{endTime}
|
|
|
+ </if>
|
|
|
+ <if test="periodId != null and periodId != ''">
|
|
|
+ AND fcpd.period_id = #{periodId}
|
|
|
+ </if>
|
|
|
+ <if test="videoId != null and videoId != ''">
|
|
|
+ AND fcpd.video_id = #{videoId}
|
|
|
+ </if>
|
|
|
+ -- 单独通过销售id查询
|
|
|
+ <if test="companyUserId != null and companyUserId != ''">
|
|
|
+ AND company_user.user_id = #{companyUserId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
) as courseCompleteNum
|
|
|
</select>
|
|
|
|
|
@@ -830,24 +871,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
fs_course_answer_logs
|
|
|
LEFT JOIN fs_user ON fs_user.user_id = fs_course_answer_logs.user_id
|
|
|
LEFT JOIN company_user ON company_user.user_id = fs_user.company_user_id
|
|
|
- WHERE
|
|
|
- ( company_user.user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
- <if test="startTime != null and startTime !='' ">
|
|
|
- AND fs_course_answer_logs.create_time >= #{startTime}
|
|
|
- </if>
|
|
|
- <if test="endTime != null and endTime != ''">
|
|
|
- AND fs_course_answer_logs.create_time <= #{endTime}
|
|
|
- </if>
|
|
|
- <if test="periodId != null and periodId != ''">
|
|
|
- AND fs_course_answer_logs.period_id = #{periodId}
|
|
|
- </if>
|
|
|
- <if test="videoId != null and videoId != ''">
|
|
|
- AND fs_course_answer_logs.video_id = #{videoId}
|
|
|
- </if>
|
|
|
- -- 单独通过销售id查询
|
|
|
- <if test="companyUserId != null and companyUserId != ''">
|
|
|
- AND company_user.user_id = #{companyUserId}
|
|
|
- </if>
|
|
|
+ <where>
|
|
|
+ <if test="userId != null and userId != 0 ">
|
|
|
+ and (fs_user.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
+ </if>
|
|
|
+ <if test="userId != null and userId == 0 ">
|
|
|
+ and fs_user.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ <if test="startTime != null and startTime !='' ">
|
|
|
+ AND fs_course_answer_logs.create_time >= #{startTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
+ AND fs_course_answer_logs.create_time <= #{endTime}
|
|
|
+ </if>
|
|
|
+ <if test="periodId != null and periodId != ''">
|
|
|
+ AND fs_course_answer_logs.period_id = #{periodId}
|
|
|
+ </if>
|
|
|
+ <if test="videoId != null and videoId != ''">
|
|
|
+ AND fs_course_answer_logs.video_id = #{videoId}
|
|
|
+ </if>
|
|
|
+ -- 单独通过销售id查询
|
|
|
+ <if test="companyUserId != null and companyUserId != ''">
|
|
|
+ AND company_user.user_id = #{companyUserId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
) AS answerNum,
|
|
|
(
|
|
|
SELECT
|
|
@@ -856,25 +903,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
fs_course_answer_logs
|
|
|
LEFT JOIN fs_user ON fs_user.user_id = fs_course_answer_logs.user_id
|
|
|
LEFT JOIN company_user ON company_user.user_id = fs_user.company_user_id
|
|
|
- WHERE
|
|
|
- ( company_user.user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
- AND fs_course_answer_logs.is_right = 1
|
|
|
- <if test="startTime != null and startTime !='' ">
|
|
|
- AND fs_course_answer_logs.create_time >= #{startTime}
|
|
|
- </if>
|
|
|
- <if test="endTime != null and endTime != ''">
|
|
|
- AND fs_course_answer_logs.create_time <= #{endTime}
|
|
|
- </if>
|
|
|
- <if test="periodId != null and periodId != ''">
|
|
|
- AND fs_course_answer_logs.period_id = #{periodId}
|
|
|
- </if>
|
|
|
- <if test="videoId != null and videoId != ''">
|
|
|
- AND fs_course_answer_logs.video_id = #{videoId}
|
|
|
- </if>
|
|
|
- -- 单独通过销售id查询
|
|
|
- <if test="companyUserId != null and companyUserId != ''">
|
|
|
- AND company_user.user_id = #{companyUserId}
|
|
|
- </if>
|
|
|
+ <where>
|
|
|
+ <if test="userId != null and userId != 0 ">
|
|
|
+ and (fs_user.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
+ </if>
|
|
|
+ <if test="userId != null and userId == 0 ">
|
|
|
+ and fs_user.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ AND fs_course_answer_logs.is_right = 1
|
|
|
+ <if test="startTime != null and startTime !='' ">
|
|
|
+ AND fs_course_answer_logs.create_time >= #{startTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
+ AND fs_course_answer_logs.create_time <= #{endTime}
|
|
|
+ </if>
|
|
|
+ <if test="periodId != null and periodId != ''">
|
|
|
+ AND fs_course_answer_logs.period_id = #{periodId}
|
|
|
+ </if>
|
|
|
+ <if test="videoId != null and videoId != ''">
|
|
|
+ AND fs_course_answer_logs.video_id = #{videoId}
|
|
|
+ </if>
|
|
|
+ -- 单独通过销售id查询
|
|
|
+ <if test="companyUserId != null and companyUserId != ''">
|
|
|
+ AND company_user.user_id = #{companyUserId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
) AS answerRightNum
|
|
|
</select>
|
|
|
|
|
@@ -888,6 +941,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
LEFT JOIN fs_user ON fs_user.user_id = fcc.user_id
|
|
|
WHERE 1=1
|
|
|
AND FIND_IN_SET(#{companyId}, fpd.company_id)
|
|
|
+ <if test="userId != null and userId != 0 ">
|
|
|
+ AND fs_user.company_user_id = #{userId}
|
|
|
+ </if>
|
|
|
+ <if test="userId != null and userId == 0 ">
|
|
|
+ and fs_user.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
<if test="periodId != null and periodId != ''">
|
|
|
AND fcpd.period_id = #{periodId}
|
|
|
</if>
|
|
@@ -904,6 +963,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
LEFT JOIN fs_user ON fs_user.user_id = fcc.user_id
|
|
|
WHERE 1=1
|
|
|
AND FIND_IN_SET(#{companyId}, fpd.company_id)
|
|
|
+ <if test="userId != null and userId != 0 ">
|
|
|
+ AND fs_user.company_user_id = #{userId}
|
|
|
+ </if>
|
|
|
+ <if test="userId != null and userId == 0 ">
|
|
|
+ and fs_user.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
<if test="periodId != null and periodId != ''">
|
|
|
AND fcpd.period_id = #{periodId}
|
|
|
</if>
|
|
@@ -929,6 +994,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="companyUserId != null and companyUserId != ''">
|
|
|
AND fs_user.company_user_id = #{companyUserId}
|
|
|
</if>
|
|
|
+ <where>
|
|
|
+ <if test="userId != null and userId != 0 ">
|
|
|
+ AND fs_user.company_user_id = #{userId}
|
|
|
+ </if>
|
|
|
+ <if test="userId != null and userId == 0 ">
|
|
|
+ and fs_user.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
) as courseUserNum
|
|
|
</select>
|
|
|
|
|
@@ -943,20 +1016,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
LEFT JOIN fs_user ON fs_user.user_id = fcc.user_id
|
|
|
LEFT JOIN company_user ON fs_user.company_user_id = company_user.user_id
|
|
|
LEFT JOIN fs_user_course_period_days fcpd ON FIND_IN_SET( fcpd.period_id, fcc.course_ids ) > 0
|
|
|
- WHERE
|
|
|
- ( company_user.user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
- <if test="startTime != null and startTime !='' ">
|
|
|
- AND fcc.create_time >= #{startTime}
|
|
|
- </if>
|
|
|
- <if test="endTime != null and endTime != ''">
|
|
|
- AND fcc.create_time <= #{endTime}
|
|
|
- </if>
|
|
|
- <if test="periodId != null and periodId != ''">
|
|
|
- AND fcpd.period_id = #{periodId}
|
|
|
- </if>
|
|
|
- <if test="videoId != null and videoId != ''">
|
|
|
- AND fcpd.video_id = #{videoId}
|
|
|
- </if>
|
|
|
+ <where>
|
|
|
+ <if test="userId != null and userId != 0 ">
|
|
|
+ AND ( fs_user.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
+ </if>
|
|
|
+ <if test="userId != null and userId == 0 ">
|
|
|
+ and fs_user.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ <if test="startTime != null and startTime !='' ">
|
|
|
+ AND fcc.create_time >= #{startTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
+ AND fcc.create_time <= #{endTime}
|
|
|
+ </if>
|
|
|
+ <if test="periodId != null and periodId != ''">
|
|
|
+ AND fcpd.period_id = #{periodId}
|
|
|
+ </if>
|
|
|
+ <if test="videoId != null and videoId != ''">
|
|
|
+ AND fcpd.video_id = #{videoId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
group by fcc.user_id
|
|
|
<choose>
|
|
|
<when test="order != null and order == 'asc'">
|
|
@@ -983,20 +1062,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
fs_course_answer_logs
|
|
|
LEFT JOIN fs_user ON fs_user.user_id = fs_course_answer_logs.user_id
|
|
|
LEFT JOIN company_user ON company_user.user_id = fs_user.company_user_id
|
|
|
- WHERE
|
|
|
- ( company_user.user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
- <if test="startTime != null and startTime !='' ">
|
|
|
- AND fs_course_answer_logs.create_time >= #{startTime}
|
|
|
- </if>
|
|
|
- <if test="endTime != null and endTime != ''">
|
|
|
- AND fs_course_answer_logs.create_time <= #{endTime}
|
|
|
- </if>
|
|
|
- <if test="periodId != null and periodId != ''">
|
|
|
- AND fs_course_answer_logs.period_id = #{periodId}
|
|
|
- </if>
|
|
|
- <if test="videoId != null and videoId != ''">
|
|
|
- AND fs_course_answer_logs.video_id = #{videoId}
|
|
|
- </if>
|
|
|
+ <where>
|
|
|
+ <if test="userId != null and userId != 0 ">
|
|
|
+ AND ( fs_user.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
+ </if>
|
|
|
+ <if test="userId != null and userId == 0 ">
|
|
|
+ and fs_user.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ <if test="startTime != null and startTime !='' ">
|
|
|
+ AND fs_course_answer_logs.create_time >= #{startTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
+ AND fs_course_answer_logs.create_time <= #{endTime}
|
|
|
+ </if>
|
|
|
+ <if test="periodId != null and periodId != ''">
|
|
|
+ AND fs_course_answer_logs.period_id = #{periodId}
|
|
|
+ </if>
|
|
|
+ <if test="videoId != null and videoId != ''">
|
|
|
+ AND fs_course_answer_logs.video_id = #{videoId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
group by fs_user.user_id
|
|
|
<choose>
|
|
|
<when test="order != null and order == 'asc'">
|
|
@@ -1028,20 +1113,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
LEFT JOIN company_user ON fs_user.company_user_id = company_user.user_id
|
|
|
LEFT JOIN fs_user_course_period_days fcpd ON FIND_IN_SET( fcpd.period_id, fcc.course_ids ) > 0
|
|
|
LEFT JOIN fs_user_course_video fcv ON fcv.video_id = fcpd.video_id
|
|
|
- WHERE
|
|
|
- ( company_user.user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
- <if test="startTime != null and startTime !='' ">
|
|
|
- AND fcc.create_time >= #{startTime}
|
|
|
- </if>
|
|
|
- <if test="endTime != null and endTime != ''">
|
|
|
- AND fcc.create_time <= #{endTime}
|
|
|
- </if>
|
|
|
- <if test="periodId != null and periodId != ''">
|
|
|
- AND fcpd.period_id = #{periodId}
|
|
|
- </if>
|
|
|
- <if test="videoId != null and videoId != ''">
|
|
|
- AND fcpd.video_id = #{videoId}
|
|
|
- </if>
|
|
|
+ <where>
|
|
|
+ <if test="userId != null and userId != 0 ">
|
|
|
+ AND ( fs_user.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
+ </if>
|
|
|
+ <if test="userId != null and userId == 0 ">
|
|
|
+ and fs_user.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ <if test="startTime != null and startTime !='' ">
|
|
|
+ AND fcc.create_time >= #{startTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
+ AND fcc.create_time <= #{endTime}
|
|
|
+ </if>
|
|
|
+ <if test="periodId != null and periodId != ''">
|
|
|
+ AND fcpd.period_id = #{periodId}
|
|
|
+ </if>
|
|
|
+ <if test="videoId != null and videoId != ''">
|
|
|
+ AND fcpd.video_id = #{videoId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
GROUP BY
|
|
|
fcpd.video_id
|
|
|
<choose>
|
|
@@ -1074,20 +1165,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
LEFT JOIN fs_user ON fs_user.user_id = fs_course_answer_logs.user_id
|
|
|
LEFT JOIN company_user ON company_user.user_id = fs_user.company_user_id
|
|
|
LEFT JOIN fs_user_course_video fcv ON fcv.video_id = fs_course_answer_logs.video_id
|
|
|
- WHERE
|
|
|
- ( company_user.user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
- <if test="startTime != null and startTime !='' ">
|
|
|
- AND fs_course_answer_logs.create_time >= #{startTime}
|
|
|
- </if>
|
|
|
- <if test="endTime != null and endTime != ''">
|
|
|
- AND fs_course_answer_logs.create_time <= #{endTime}
|
|
|
- </if>
|
|
|
- <if test="periodId != null and periodId != ''">
|
|
|
- AND fs_course_answer_logs.period_id = #{periodId}
|
|
|
- </if>
|
|
|
- <if test="videoId != null and videoId != ''">
|
|
|
- AND fs_course_answer_logs.video_id = #{videoId}
|
|
|
- </if>
|
|
|
+ <where>
|
|
|
+ <if test="userId != null and userId != 0 ">
|
|
|
+ AND ( fs_user.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
+ </if>
|
|
|
+ <if test="userId != null and userId == 0 ">
|
|
|
+ and fs_user.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ <if test="startTime != null and startTime !='' ">
|
|
|
+ AND fs_course_answer_logs.create_time >= #{startTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
+ AND fs_course_answer_logs.create_time <= #{endTime}
|
|
|
+ </if>
|
|
|
+ <if test="periodId != null and periodId != ''">
|
|
|
+ AND fs_course_answer_logs.period_id = #{periodId}
|
|
|
+ </if>
|
|
|
+ <if test="videoId != null and videoId != ''">
|
|
|
+ AND fs_course_answer_logs.video_id = #{videoId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
GROUP BY
|
|
|
fs_course_answer_logs.video_id
|
|
|
<choose>
|
|
@@ -1113,24 +1210,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
fs_course_red_packet_log flog
|
|
|
LEFT JOIN fs_user ON fs_user.user_id = flog.user_id
|
|
|
LEFT JOIN company_user ON company_user.user_id = fs_user.company_user_id
|
|
|
- WHERE
|
|
|
- ( company_user.user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
- <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="periodId != null and periodId != ''">
|
|
|
- AND flog.period_id = #{periodId}
|
|
|
- </if>
|
|
|
- <if test="videoId != null and videoId != ''">
|
|
|
- AND flog.video_id = #{videoId}
|
|
|
- </if>
|
|
|
- -- 单独通过销售id查询
|
|
|
- <if test="companyUserId != null and companyUserId != ''">
|
|
|
- AND company_user.user_id = #{companyUserId}
|
|
|
- </if>
|
|
|
+ <where>
|
|
|
+ <if test="userId != null and userId != 0 ">
|
|
|
+ and (fs_user.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
+ </if>
|
|
|
+ <if test="userId != null and userId == 0 ">
|
|
|
+ and fs_user.company_id = #{companyId}
|
|
|
+ </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="periodId != null and periodId != ''">
|
|
|
+ AND flog.period_id = #{periodId}
|
|
|
+ </if>
|
|
|
+ <if test="videoId != null and videoId != ''">
|
|
|
+ AND flog.video_id = #{videoId}
|
|
|
+ </if>
|
|
|
+ -- 单独通过销售id查询
|
|
|
+ <if test="companyUserId != null and companyUserId != ''">
|
|
|
+ AND company_user.user_id = #{companyUserId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
) AS redPacketNum,
|
|
|
(
|
|
|
SELECT
|
|
@@ -1139,24 +1242,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
fs_course_red_packet_log flog
|
|
|
LEFT JOIN fs_user ON fs_user.user_id = flog.user_id
|
|
|
LEFT JOIN company_user ON company_user.user_id = fs_user.company_user_id
|
|
|
- WHERE
|
|
|
- ( company_user.user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
- <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="periodId != null and periodId != ''">
|
|
|
- AND flog.period_id = #{periodId}
|
|
|
- </if>
|
|
|
- <if test="videoId != null and videoId != ''">
|
|
|
- AND flog.video_id = #{videoId}
|
|
|
- </if>
|
|
|
- -- 单独通过销售id查询
|
|
|
- <if test="companyUserId != null and companyUserId != ''">
|
|
|
- AND company_user.user_id = #{companyUserId}
|
|
|
- </if>
|
|
|
+ <where>
|
|
|
+ <if test="userId != null and userId != 0 ">
|
|
|
+ and (fs_user.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
+ </if>
|
|
|
+ <if test="userId != null and userId == 0 ">
|
|
|
+ and fs_user.company_id = #{companyId}
|
|
|
+ </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="periodId != null and periodId != ''">
|
|
|
+ AND flog.period_id = #{periodId}
|
|
|
+ </if>
|
|
|
+ <if test="videoId != null and videoId != ''">
|
|
|
+ AND flog.video_id = #{videoId}
|
|
|
+ </if>
|
|
|
+ -- 单独通过销售id查询
|
|
|
+ <if test="companyUserId != null and companyUserId != ''">
|
|
|
+ AND company_user.user_id = #{companyUserId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
) AS redPacketAmount
|
|
|
</select>
|
|
|
|
|
@@ -1178,14 +1287,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
LEFT JOIN fs_user ON fs_user.user_id = fcc.user_id
|
|
|
LEFT JOIN company_user ON fs_user.company_user_id = company_user.user_id
|
|
|
LEFT JOIN fs_user_course_period_days fcpd ON FIND_IN_SET( fcpd.period_id, fcc.course_ids ) > 0
|
|
|
- WHERE
|
|
|
- company_user.user_id = #{companyUserId}
|
|
|
- <if test="periodId != null and periodId != ''">
|
|
|
- AND fcpd.period_id = #{periodId}
|
|
|
- </if>
|
|
|
- <if test="videoId != null and videoId != ''">
|
|
|
- AND fcpd.video_id = #{videoId}
|
|
|
- </if>
|
|
|
+ <where>
|
|
|
+ <if test="companyUserId != null and companyUserId != 0 ">
|
|
|
+ AND fs_user.company_user_id = #{companyUserId}
|
|
|
+ </if>
|
|
|
+ <if test="companyUserId != null and companyUserId == 0 ">
|
|
|
+ and fs_user.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ <if test="periodId != null and periodId != ''">
|
|
|
+ AND fcpd.period_id = #{periodId}
|
|
|
+ </if>
|
|
|
+ <if test="videoId != null and videoId != ''">
|
|
|
+ AND fcpd.video_id = #{videoId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
GROUP BY
|
|
|
fcpd.video_id
|
|
|
</select>
|
|
@@ -1194,7 +1309,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
SELECT
|
|
|
(
|
|
|
SELECT count( fs_user.user_id ) FROM fs_user LEFT JOIN company_user ON fs_user.company_user_id = company_user.user_id
|
|
|
- WHERE company_user.user_id = #{companyUserId}
|
|
|
+ <where>
|
|
|
+ <if test="companyUserId != null and companyUserId != '' and companyUserId != '0' ">
|
|
|
+ AND fs_user.company_user_id = #{companyUserId}
|
|
|
+ </if>
|
|
|
+ <if test="companyUserId != null and companyUserId != '' and companyUserId == '0' ">
|
|
|
+ and fs_user.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
) AS userTotal,
|
|
|
(
|
|
|
SELECT
|
|
@@ -1202,11 +1324,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
FROM
|
|
|
fs_user
|
|
|
LEFT JOIN company_user ON fs_user.company_user_id = company_user.user_id
|
|
|
- WHERE
|
|
|
- company_user.user_id = #{companyUserId}
|
|
|
- and fs_user.is_del = 0
|
|
|
- AND to_days( fs_user.create_time ) = to_days(
|
|
|
- now())
|
|
|
+ <where>
|
|
|
+ <if test="companyUserId != null and companyUserId != '' and companyUserId != '0' ">
|
|
|
+ AND fs_user.company_user_id = #{companyUserId}
|
|
|
+ </if>
|
|
|
+ <if test="companyUserId != null and companyUserId != '' and companyUserId == '0' ">
|
|
|
+ and fs_user.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ and fs_user.is_del = 0
|
|
|
+ AND to_days( fs_user.create_time ) = to_days(
|
|
|
+ now())
|
|
|
+ </where>
|
|
|
) AS todayNewUser
|
|
|
</select>
|
|
|
|
|
@@ -1217,7 +1345,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
FROM
|
|
|
fs_course_red_packet_log flog
|
|
|
LEFT JOIN fs_user ON fs_user.user_id = flog.user_id
|
|
|
- WHERE
|
|
|
- fs_user.company_user_id = #{companyUserId}
|
|
|
+ <where>
|
|
|
+ <if test="companyUserId != null and companyUserId != '' and companyUserId != '0' ">
|
|
|
+ AND fs_user.company_user_id = #{companyUserId}
|
|
|
+ </if>
|
|
|
+ <if test="companyUserId != null and companyUserId != '' and companyUserId == '0' ">
|
|
|
+ and fs_user.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
</select>
|
|
|
</mapper>
|