|
@@ -189,7 +189,7 @@
|
|
|
limit 10
|
|
|
</select>
|
|
|
<select id="selectCusListPage" resultType="com.fs.store.domain.FsUser">
|
|
|
- select user.user_id,
|
|
|
+ select distinct user.user_id,
|
|
|
user.username,
|
|
|
user.real_name,
|
|
|
user.id_card,
|
|
@@ -199,43 +199,48 @@
|
|
|
user.status,
|
|
|
user.company_id,
|
|
|
user.company_user_id,
|
|
|
- user.create_time
|
|
|
+ user.create_time,
|
|
|
+ t.companyUserId,
|
|
|
+ concat(cu.user_name, '_', cu.user_id) companyUserName
|
|
|
from
|
|
|
fs_user `user` join (
|
|
|
- select user_id from fs_user
|
|
|
+ select u.user_id, ucu.user_id as companyUserId from fs_user u
|
|
|
+ left join fs_user_company_user ucu on cu.user_id = u.user_id
|
|
|
<where>
|
|
|
<if test="companyId != null and companyId != ''">
|
|
|
- AND company_id = #{companyId}
|
|
|
+ AND ucu.company_id = #{companyId}
|
|
|
</if>
|
|
|
<if test="companyUserId != null and companyUserId != ''">
|
|
|
- AND company_user_id = #{companyUserId}
|
|
|
+ AND ucu.company_user_id = #{companyUserId}
|
|
|
</if>
|
|
|
<if test="phone != null and phone != ''">
|
|
|
- AND phone = #{phone}
|
|
|
+ AND u.phone = #{phone}
|
|
|
</if>
|
|
|
</where>
|
|
|
- order by user_id desc
|
|
|
+ order by u.user_id desc
|
|
|
limit ${(pageNum-1)*pageSize},${pageSize}
|
|
|
) t on t.user_id = `user`.user_id
|
|
|
+ left join company_user cu on cu.user_id = t.companyUserId
|
|
|
</select>
|
|
|
<select id="selectCusListPageCount" resultType="java.lang.Long">
|
|
|
- SELECT COUNT(user_id)
|
|
|
- FROM fs_user
|
|
|
+ SELECT COUNT(u.user_id)
|
|
|
+ FROM fs_user u
|
|
|
+ left join fs_user_company_user cu on cu.user_id = u.user_id
|
|
|
<where>
|
|
|
<if test="companyId != null and companyId != ''">
|
|
|
- AND company_id = #{companyId}
|
|
|
+ AND cu.company_id = #{companyId}
|
|
|
</if>
|
|
|
<if test="companyUserId != null and companyUserId != ''">
|
|
|
- AND company_user_id = #{companyUserId}
|
|
|
+ AND cu.company_user_id = #{companyUserId}
|
|
|
</if>
|
|
|
<if test="phone != null and phone != ''">
|
|
|
- AND phone = #{phone}
|
|
|
+ AND u.phone = #{phone}
|
|
|
</if>
|
|
|
</where>
|
|
|
</select>
|
|
|
|
|
|
<select id="selectFsUserVOList" resultType="com.fs.store.vo.FSUserVO">
|
|
|
- SELECT
|
|
|
+ SELECT distinct
|
|
|
b.total_amount,b.last_buy_time,p.pay_money as number,p.payment_id,p.pay_time,
|
|
|
u.*,
|
|
|
fcc.watch_course_count, fcc.part_course_count, company_user.nick_name AS companyUserNickName, fcc.last_watch_date
|
|
@@ -264,7 +269,8 @@
|
|
|
fs_user_course_count
|
|
|
GROUP BY fs_user_course_count.user_id
|
|
|
) fcc ON fcc.user_id = u.user_id
|
|
|
- LEFT JOIN company_user ON company_user.user_id = u.company_user_id
|
|
|
+ left join fs_user_company_user ucu on ucu.user_id = u.user_id
|
|
|
+ LEFT JOIN company_user ON company_user.user_id = ucu.company_user_id
|
|
|
LEFT JOIN company on company.company_id = company_user.company_id
|
|
|
<where>
|
|
|
1 = 1
|
|
@@ -474,17 +480,18 @@
|
|
|
fs_user.status,
|
|
|
fs_user.create_time,
|
|
|
fs_user.remark,
|
|
|
- fs_user.company_user_id,
|
|
|
- fs_user.company_id
|
|
|
+ ucu.company_user_id,
|
|
|
+ ucu.company_id
|
|
|
FROM
|
|
|
fs_user
|
|
|
+ left join fs_user_company_user ucu on ucu.user_id = fs_user.user_id
|
|
|
<where>
|
|
|
fs_user.is_del = 0
|
|
|
<if test="companyId != null">
|
|
|
- AND fs_user.company_id = #{companyId}
|
|
|
+ AND ucu.company_id = #{companyId}
|
|
|
</if>
|
|
|
<if test="companyUserId != null and companyUserId != '' ">
|
|
|
- AND fs_user.company_user_id = #{companyUserId}
|
|
|
+ AND ucu.company_user_id = #{companyUserId}
|
|
|
</if>
|
|
|
<if test="registerStartTime != null and registerStartTime !='' ">
|
|
|
AND fs_user.create_time >= #{registerStartTime}
|
|
@@ -493,7 +500,7 @@
|
|
|
AND fs_user.create_time <= #{registerEndTime}
|
|
|
</if>
|
|
|
<if test="companyUserIds != null and companyUserIds.size > 0">
|
|
|
- AND fs_user.company_user_id in
|
|
|
+ AND ucu.company_user_id in
|
|
|
<foreach collection="companyUserIds" item="item" index="index" open="(" separator="," close=")">
|
|
|
${item}
|
|
|
</foreach>
|
|
@@ -534,10 +541,10 @@
|
|
|
LEFT JOIN company_user ON company_user.user_id = fs_user_company_user.company_user_id
|
|
|
where fs_user.is_del = 0
|
|
|
<if test="userId != null and userId!= 0 ">
|
|
|
- and fs_user.company_user_id = #{userId}
|
|
|
+ and fs_user_company_user.company_user_id = #{userId}
|
|
|
</if>
|
|
|
<if test="companyId != null ">
|
|
|
- and fs_user.company_id = #{companyId}
|
|
|
+ and fs_user_company_user.company_id = #{companyId}
|
|
|
</if>
|
|
|
<choose>
|
|
|
<when test = "isBlack">
|
|
@@ -626,10 +633,10 @@
|
|
|
LEFT JOIN company_user ON company_user.user_id = fs_user_company_user.company_user_id
|
|
|
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} )
|
|
|
+ and (fs_user_company_user.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
</if>
|
|
|
<if test="companyId != null ">
|
|
|
- and fs_user.company_id = #{companyId}
|
|
|
+ and fs_user_company_user.company_id = #{companyId}
|
|
|
</if>
|
|
|
GROUP BY
|
|
|
fs_user.`status`
|
|
@@ -662,7 +669,6 @@
|
|
|
FROM
|
|
|
fs_user_course_count
|
|
|
LEFT JOIN fs_user ON fs_user.user_id = fs_user_course_count.user_id
|
|
|
- LEFT JOIN company_user ON company_user.user_id = fs_user.company_user_id
|
|
|
<where>
|
|
|
<if test="dateTag != null and dateTag !='' ">
|
|
|
<choose>
|
|
@@ -694,7 +700,6 @@
|
|
|
FROM
|
|
|
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>
|
|
|
|
|
|
<if test="dateTag != null and dateTag !='' ">
|
|
@@ -724,7 +729,6 @@
|
|
|
FROM
|
|
|
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>
|
|
|
fs_course_answer_logs.is_right = 1
|
|
|
<if test="dateTag != null and dateTag !='' ">
|
|
@@ -758,7 +762,6 @@
|
|
|
FROM
|
|
|
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>
|
|
|
fs_course_red_packet_log.status = 1
|
|
|
<if test="dateTag != null and dateTag !='' ">
|
|
@@ -788,7 +791,9 @@
|
|
|
count(if(date(u.create_time) = curdate(),u.user_id, null)) newVipCount,
|
|
|
count(u.user_id) vipCount
|
|
|
from fs_user u
|
|
|
- where u.company_user_id = #{companyUserId}
|
|
|
+ left join fs_user_company_user ucu on ucu.user_id = u.user_id
|
|
|
+ left join company_user cu on cu.user_id = ucu.company_user_id
|
|
|
+ where cu.user_id = #{companyUserId}
|
|
|
</select>
|
|
|
|
|
|
<update id="batchUpdateFsUserByIds" parameterType="Long">
|
|
@@ -802,24 +807,26 @@
|
|
|
<select id="countUserSummary" resultType="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
|
|
|
+ left join fs_user_company_user ucu on ucu.user_id = fs_user.user_id
|
|
|
+ LEFT JOIN company_user ON ucu.company_user_id = company_user.user_id
|
|
|
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} )
|
|
|
+ and (ucu.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
</if>
|
|
|
<if test="companyId != null ">
|
|
|
- and fs_user.company_id = #{companyId}
|
|
|
+ and ucu.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
|
|
|
+ left join fs_user_company_user ucu on ucu.user_id = fs_user.user_id
|
|
|
+ LEFT JOIN company_user ON ucu.company_user_id = company_user.user_id
|
|
|
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} )
|
|
|
+ and (ucu.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
</if>
|
|
|
<if test="companyId != null ">
|
|
|
- and fs_user.company_id = #{companyId}
|
|
|
+ and ucu.company_id = #{companyId}
|
|
|
</if>
|
|
|
AND to_days(fs_user.create_time) = to_days(now())) as todayNewUser
|
|
|
</select>
|
|
@@ -832,13 +839,14 @@
|
|
|
company_tag_user
|
|
|
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
|
|
|
+ left join fs_user_company_user ucu on ucu.user_id = fs_user.user_id
|
|
|
+ LEFT JOIN company_user ON ucu.company_user_id = company_user.user_id
|
|
|
<where>
|
|
|
<if test="userId != null and userId != 0 ">
|
|
|
- and (fs_user.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
+ and (ucu.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
</if>
|
|
|
<if test="companyId != null ">
|
|
|
- and fs_user.company_id = #{companyId}
|
|
|
+ and ucu.company_id = #{companyId}
|
|
|
</if>
|
|
|
and company_tag.tag_id is not null
|
|
|
</where>
|
|
@@ -854,14 +862,15 @@
|
|
|
FROM
|
|
|
fs_user_course_count fcc
|
|
|
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_company_user ucu on ucu.user_id = fs_user.user_id
|
|
|
+ LEFT JOIN company_user ON ucu.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>
|
|
|
<if test="userId != null and userId != 0 ">
|
|
|
- and (fs_user.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
+ and (ucu.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
</if>
|
|
|
<if test="userId != null and userId == 0 ">
|
|
|
- and fs_user.company_id = #{companyId}
|
|
|
+ and ucu.company_id = #{companyId}
|
|
|
</if>
|
|
|
<if test="startTime != null and startTime !='' ">
|
|
|
and fcc.create_time >= #{startTime}
|
|
@@ -887,14 +896,15 @@
|
|
|
FROM
|
|
|
fs_user_course_count fcc
|
|
|
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_company_user ucu on ucu.user_id = fs_user.user_id
|
|
|
+ LEFT JOIN company_user ON ucu.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>
|
|
|
<if test="userId != null and userId != 0 ">
|
|
|
- and (fs_user.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
+ and (ucu.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
</if>
|
|
|
<if test="userId != null and userId == 0 ">
|
|
|
- and fs_user.company_id = #{companyId}
|
|
|
+ and ucu.company_id = #{companyId}
|
|
|
</if>
|
|
|
AND fcc.complete_watch_count > 0
|
|
|
<if test="startTime != null and startTime !='' ">
|
|
@@ -925,13 +935,13 @@
|
|
|
FROM
|
|
|
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
|
|
|
+ LEFT JOIN company_user ON company_user.user_id = fs_course_answer_logs.company_user_id
|
|
|
<where>
|
|
|
<if test="userId != null and userId != 0 ">
|
|
|
- and (fs_user.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
+ and (fs_course_answer_logs.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
</if>
|
|
|
<if test="userId != null and userId == 0 ">
|
|
|
- and fs_user.company_id = #{companyId}
|
|
|
+ and fs_course_answer_logs.company_id = #{companyId}
|
|
|
</if>
|
|
|
<if test="startTime != null and startTime !='' ">
|
|
|
AND fs_course_answer_logs.create_time >= #{startTime}
|
|
@@ -957,13 +967,13 @@
|
|
|
FROM
|
|
|
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
|
|
|
+ LEFT JOIN company_user ON company_user.user_id = fs_course_answer_logs.company_user_id
|
|
|
<where>
|
|
|
<if test="userId != null and userId != 0 ">
|
|
|
- and (fs_user.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
+ and (fs_course_answer_logs.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
</if>
|
|
|
<if test="userId != null and userId == 0 ">
|
|
|
- and fs_user.company_id = #{companyId}
|
|
|
+ and fs_course_answer_logs.company_id = #{companyId}
|
|
|
</if>
|
|
|
AND fs_course_answer_logs.is_right = 1
|
|
|
<if test="startTime != null and startTime !='' ">
|
|
@@ -994,13 +1004,13 @@
|
|
|
FROM
|
|
|
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
|
|
|
+ LEFT JOIN company_user ON company_user.user_id = flog.company_user_id
|
|
|
<where>
|
|
|
<if test="userId != null and userId != 0 ">
|
|
|
- and (fs_user.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
+ and (flog.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
</if>
|
|
|
<if test="userId != null and userId == 0 ">
|
|
|
- and fs_user.company_id = #{companyId}
|
|
|
+ and flog.company_id = #{companyId}
|
|
|
</if>
|
|
|
<if test="startTime != null and startTime !='' ">
|
|
|
AND flog.create_time >= #{startTime}
|
|
@@ -1026,13 +1036,13 @@
|
|
|
FROM
|
|
|
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
|
|
|
+ LEFT JOIN company_user ON company_user.user_id = flog.company_user_id
|
|
|
<where>
|
|
|
<if test="userId != null and userId != 0 ">
|
|
|
- and (fs_user.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
+ and (flog.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
</if>
|
|
|
<if test="userId != null and userId == 0 ">
|
|
|
- and fs_user.company_id = #{companyId}
|
|
|
+ and flog.company_id = #{companyId}
|
|
|
</if>
|
|
|
<if test="startTime != null and startTime !='' ">
|
|
|
AND flog.create_time >= #{startTime}
|
|
@@ -1062,20 +1072,21 @@
|
|
|
LEFT JOIN fs_user_course_period fpd on fpd.period_id = fcpd.period_id
|
|
|
LEFT JOIN fs_user_course_count fcc ON FIND_IN_SET( fcpd.period_id, fcc.course_ids ) > 0
|
|
|
LEFT JOIN fs_user ON fs_user.user_id = fcc.user_id
|
|
|
+ left join fs_user_company_user ucu on ucu.user_id = fs_user.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}
|
|
|
+ AND ucu.company_user_id = #{userId}
|
|
|
</if>
|
|
|
<if test="userId != null and userId == 0 ">
|
|
|
- and fs_user.company_id = #{companyId}
|
|
|
+ and ucu.company_id = #{companyId}
|
|
|
</if>
|
|
|
<if test="periodId != null and periodId != ''">
|
|
|
AND fcpd.period_id = #{periodId}
|
|
|
</if>
|
|
|
-- 单独通过销售id查询
|
|
|
<if test="companyUserId != null and companyUserId != ''">
|
|
|
- AND fs_user.company_user_id = #{companyUserId}
|
|
|
+ AND ucu.company_user_id = #{companyUserId}
|
|
|
</if>
|
|
|
) as courseNum,
|
|
|
|
|
@@ -1084,13 +1095,14 @@
|
|
|
LEFT JOIN fs_user_course_period fpd on fpd.period_id = fcpd.period_id
|
|
|
LEFT JOIN fs_user_course_count fcc ON FIND_IN_SET( fcpd.period_id, fcc.course_ids ) > 0
|
|
|
LEFT JOIN fs_user ON fs_user.user_id = fcc.user_id
|
|
|
+ left join fs_user_company_user ucu on ucu.user_id = fs_user.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}
|
|
|
+ AND ucu.company_user_id = #{userId}
|
|
|
</if>
|
|
|
<if test="userId != null and userId == 0 ">
|
|
|
- and fs_user.company_id = #{companyId}
|
|
|
+ and ucu.company_id = #{companyId}
|
|
|
</if>
|
|
|
<if test="periodId != null and periodId != ''">
|
|
|
AND fcpd.period_id = #{periodId}
|
|
@@ -1100,13 +1112,14 @@
|
|
|
</if>
|
|
|
-- 单独通过销售id查询
|
|
|
<if test="companyUserId != null and companyUserId != ''">
|
|
|
- AND fs_user.company_user_id = #{companyUserId}
|
|
|
+ AND ucu.company_user_id = #{companyUserId}
|
|
|
</if>
|
|
|
) as videoNum,
|
|
|
|
|
|
( SELECT count(DISTINCT fs_user.user_id ) FROM fs_user_course_count fcc
|
|
|
LEFT JOIN fs_user_course_period_days fcpd ON FIND_IN_SET( fcpd.period_id, fcc.course_ids ) > 0
|
|
|
LEFT JOIN fs_user ON fs_user.user_id = fcc.user_id
|
|
|
+ left join fs_user_company_user ucu on ucu.user_id = fs_user.user_id
|
|
|
<if test="periodId != null and periodId != ''">
|
|
|
AND fcpd.period_id = #{periodId}
|
|
|
</if>
|
|
@@ -1115,14 +1128,14 @@
|
|
|
</if>
|
|
|
-- 单独通过销售id查询
|
|
|
<if test="companyUserId != null and companyUserId != ''">
|
|
|
- AND fs_user.company_user_id = #{companyUserId}
|
|
|
+ AND ucu.company_user_id = #{companyUserId}
|
|
|
</if>
|
|
|
<where>
|
|
|
<if test="userId != null and userId != 0 ">
|
|
|
- AND fs_user.company_user_id = #{userId}
|
|
|
+ AND ucu.company_user_id = #{userId}
|
|
|
</if>
|
|
|
<if test="userId != null and userId == 0 ">
|
|
|
- and fs_user.company_id = #{companyId}
|
|
|
+ and ucu.company_id = #{companyId}
|
|
|
</if>
|
|
|
</where>
|
|
|
) as courseUserNum
|
|
@@ -1137,14 +1150,15 @@
|
|
|
FROM
|
|
|
fs_user_course_count fcc
|
|
|
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_company_user ucu on ucu.user_id = fs_user.user_id
|
|
|
+ LEFT JOIN company_user ON ucu.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>
|
|
|
<if test="userId != null and userId != 0 ">
|
|
|
- AND ( fs_user.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
+ AND ( ucu.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
</if>
|
|
|
<if test="userId != null and userId == 0 ">
|
|
|
- and fs_user.company_id = #{companyId}
|
|
|
+ and ucu.company_id = #{companyId}
|
|
|
</if>
|
|
|
<if test="startTime != null and startTime !='' ">
|
|
|
AND fcc.create_time >= #{startTime}
|
|
@@ -1184,13 +1198,13 @@
|
|
|
FROM
|
|
|
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
|
|
|
+ LEFT JOIN company_user ON company_user.user_id = fs_course_answer_logs.company_user_id
|
|
|
<where>
|
|
|
<if test="userId != null and userId != 0 ">
|
|
|
- AND ( fs_user.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
+ AND ( fs_course_answer_logs.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
</if>
|
|
|
<if test="userId != null and userId == 0 ">
|
|
|
- and fs_user.company_id = #{companyId}
|
|
|
+ and fs_course_answer_logs.company_id = #{companyId}
|
|
|
</if>
|
|
|
<if test="startTime != null and startTime !='' ">
|
|
|
AND fs_course_answer_logs.create_time >= #{startTime}
|
|
@@ -1233,15 +1247,16 @@
|
|
|
FROM
|
|
|
fs_user_course_count fcc
|
|
|
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_company_user ucu on ucu.user_id = fs_user.user_id
|
|
|
+ LEFT JOIN company_user ON ucu.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>
|
|
|
<if test="userId != null and userId != 0 ">
|
|
|
- AND ( fs_user.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
+ AND ( ucu.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
</if>
|
|
|
<if test="userId != null and userId == 0 ">
|
|
|
- and fs_user.company_id = #{companyId}
|
|
|
+ and ucu.company_id = #{companyId}
|
|
|
</if>
|
|
|
<if test="startTime != null and startTime !='' ">
|
|
|
AND fcc.create_time >= #{startTime}
|
|
@@ -1286,14 +1301,14 @@
|
|
|
FROM
|
|
|
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
|
|
|
+ LEFT JOIN company_user ON company_user.user_id = fs_course_answer_logs.company_user_id
|
|
|
LEFT JOIN fs_user_course_video fcv ON fcv.video_id = fs_course_answer_logs.video_id
|
|
|
<where>
|
|
|
<if test="userId != null and userId != 0 ">
|
|
|
- AND ( fs_user.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
+ AND ( fs_course_answer_logs.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
</if>
|
|
|
<if test="userId != null and userId == 0 ">
|
|
|
- and fs_user.company_id = #{companyId}
|
|
|
+ and fs_course_answer_logs.company_id = #{companyId}
|
|
|
</if>
|
|
|
<if test="startTime != null and startTime !='' ">
|
|
|
AND fs_course_answer_logs.create_time >= #{startTime}
|
|
@@ -1341,14 +1356,15 @@
|
|
|
FROM
|
|
|
fs_user_course_count fcc
|
|
|
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_company_user ucu on ucu.user_id = fs_user.user_id
|
|
|
+ LEFT JOIN company_user ON ucu.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>
|
|
|
<if test="companyUserId != null and companyUserId != 0 ">
|
|
|
- AND fs_user.company_user_id = #{companyUserId}
|
|
|
+ AND ucu.company_user_id = #{companyUserId}
|
|
|
</if>
|
|
|
<if test="companyUserId != null and companyUserId == 0 ">
|
|
|
- and fs_user.company_id = #{companyId}
|
|
|
+ and ucu.company_id = #{companyId}
|
|
|
</if>
|
|
|
<if test="periodId != null and periodId != ''">
|
|
|
AND fcpd.period_id = #{periodId}
|
|
@@ -1369,14 +1385,12 @@
|
|
|
flog.video_id
|
|
|
FROM
|
|
|
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>
|
|
|
<if test="companyUserId != null and companyUserId != 0 ">
|
|
|
- AND fs_user.company_user_id = #{companyUserId}
|
|
|
+ AND flog.company_user_id = #{companyUserId}
|
|
|
</if>
|
|
|
<if test="companyUserId != null and companyUserId == 0 ">
|
|
|
- and fs_user.company_id = #{companyId}
|
|
|
+ and flog.company_id = #{companyId}
|
|
|
</if>
|
|
|
<if test="periodId != null and periodId != ''">
|
|
|
AND flog.period_id = #{periodId}
|
|
@@ -1414,13 +1428,12 @@
|
|
|
FROM
|
|
|
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>
|
|
|
<if test="companyUserId != null and companyUserId != 0 ">
|
|
|
- AND fs_user.company_user_id = #{companyUserId}
|
|
|
+ AND fs_course_answer_logs.company_user_id = #{companyUserId}
|
|
|
</if>
|
|
|
<if test="companyUserId != null and companyUserId == 0 ">
|
|
|
- and fs_user.company_id = #{companyId}
|
|
|
+ and fs_course_answer_logs.company_id = #{companyId}
|
|
|
</if>
|
|
|
<if test="periodId != null and periodId != ''">
|
|
|
AND fs_course_answer_logs.period_id = #{periodId}
|
|
@@ -1443,13 +1456,13 @@
|
|
|
<select id="companyUserCount" resultType="CompanyUserSummaryCountVO">
|
|
|
SELECT
|
|
|
(
|
|
|
- SELECT count( fs_user.user_id ) FROM fs_user LEFT JOIN company_user ON fs_user.company_user_id = company_user.user_id
|
|
|
+ SELECT count( fs_user.user_id ) FROM fs_user left join fs_user_company_user ucu on ucu.user_id = fs_user.user_id LEFT JOIN company_user ON ucu.company_user_id = company_user.user_id
|
|
|
<where>
|
|
|
<if test="companyUserId != null and companyUserId != '' and companyUserId != '0' ">
|
|
|
- AND fs_user.company_user_id = #{companyUserId}
|
|
|
+ AND ucu.company_user_id = #{companyUserId}
|
|
|
</if>
|
|
|
<if test="companyUserId != null and companyUserId != '' and companyUserId == '0' ">
|
|
|
- and fs_user.company_id = #{companyId}
|
|
|
+ and ucu.company_id = #{companyId}
|
|
|
</if>
|
|
|
</where>
|
|
|
) AS userTotal,
|
|
@@ -1458,13 +1471,14 @@
|
|
|
count( fs_user.user_id )
|
|
|
FROM
|
|
|
fs_user
|
|
|
- LEFT JOIN company_user ON fs_user.company_user_id = company_user.user_id
|
|
|
+ left join fs_user_company_user ucu on ucu.user_id = fs_user.user_id
|
|
|
+ LEFT JOIN company_user ON ucu.company_user_id = company_user.user_id
|
|
|
<where>
|
|
|
<if test="companyUserId != null and companyUserId != '' and companyUserId != '0' ">
|
|
|
- AND fs_user.company_user_id = #{companyUserId}
|
|
|
+ AND ucu.company_user_id = #{companyUserId}
|
|
|
</if>
|
|
|
<if test="companyUserId != null and companyUserId != '' and companyUserId == '0' ">
|
|
|
- and fs_user.company_id = #{companyId}
|
|
|
+ and ucu.company_id = #{companyId}
|
|
|
</if>
|
|
|
and fs_user.is_del = 0
|
|
|
AND to_days( fs_user.create_time ) = to_days(
|
|
@@ -1482,10 +1496,10 @@
|
|
|
LEFT JOIN fs_user ON fs_user.user_id = flog.user_id
|
|
|
<where>
|
|
|
<if test="companyUserId != null and companyUserId != '' and companyUserId != '0' ">
|
|
|
- AND fs_user.company_user_id = #{companyUserId}
|
|
|
+ AND flog.company_user_id = #{companyUserId}
|
|
|
</if>
|
|
|
<if test="companyUserId != null and companyUserId != '' and companyUserId == '0' ">
|
|
|
- and fs_user.company_id = #{companyId}
|
|
|
+ and flog.company_id = #{companyId}
|
|
|
</if>
|
|
|
</where>
|
|
|
</select>
|
|
@@ -1495,13 +1509,14 @@
|
|
|
count(1)
|
|
|
FROM
|
|
|
fs_user
|
|
|
+ left join fs_user_company_user ucu on ucu.user_id = fs_user.user_id
|
|
|
<where>
|
|
|
fs_user.is_del = 0
|
|
|
<if test="companyId != null">
|
|
|
- AND fs_user.company_id = #{companyId}
|
|
|
+ AND ucu.company_id = #{companyId}
|
|
|
</if>
|
|
|
<if test="companyUserId != null and companyUserId != '' ">
|
|
|
- AND fs_user.company_user_id = #{companyUserId}
|
|
|
+ AND ucu.company_user_id = #{companyUserId}
|
|
|
</if>
|
|
|
<if test="registerStartTime != null and registerStartTime !='' ">
|
|
|
AND fs_user.create_time >= #{registerStartTime}
|
|
@@ -1510,7 +1525,7 @@
|
|
|
AND fs_user.create_time <= #{registerEndTime}
|
|
|
</if>
|
|
|
<if test="companyUserIds != null and companyUserIds.size > 0">
|
|
|
- AND fs_user.company_user_id in
|
|
|
+ AND ucu.company_user_id in
|
|
|
<foreach collection="companyUserIds" item="item" index="index" open="(" separator="," close=")">
|
|
|
${item}
|
|
|
</foreach>
|
|
@@ -1609,16 +1624,17 @@
|
|
|
SELECT
|
|
|
count( fs_user.user_id ) as userNum,
|
|
|
count( DISTINCT CASE WHEN to_days( fs_user.create_time ) = to_days( now()) THEN fs_user.user_id END ) as newUserNum,
|
|
|
- fs_user.company_id
|
|
|
+ ucu.company_id
|
|
|
FROM
|
|
|
fs_user
|
|
|
- LEFT JOIN company_user ON company_user.user_id = fs_user.company_user_id
|
|
|
+ left join fs_user_company_user ucu on ucu.user_id = fs_user.user_id
|
|
|
+ LEFT JOIN company_user ON company_user.user_id = ucu.company_user_id
|
|
|
WHERE
|
|
|
fs_user.is_del = 0
|
|
|
AND fs_user.`status` = 1
|
|
|
AND company_user.user_id is not null
|
|
|
GROUP BY
|
|
|
- fs_user.company_id
|
|
|
+ ucu.company_id
|
|
|
</select>
|
|
|
|
|
|
|
|
@@ -1655,8 +1671,6 @@
|
|
|
flog.company_id
|
|
|
FROM
|
|
|
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
|
|
|
GROUP BY
|
|
|
flog.period_id,
|
|
|
flog.video_id,
|
|
@@ -1682,7 +1696,6 @@
|
|
|
FROM
|
|
|
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
|
|
|
GROUP BY
|
|
|
fs_course_answer_logs.period_id,
|
|
|
fs_course_answer_logs.video_id,
|
|
@@ -1701,14 +1714,33 @@
|
|
|
|
|
|
FROM
|
|
|
fs_user
|
|
|
- LEFT JOIN company_user ON company_user.user_id = fs_user.company_user_id
|
|
|
- LEFT JOIN company ON company.company_id = fs_user.company_id
|
|
|
+ left join fs_user_company_user ucu on ucu.user_id = fs_user.user_id
|
|
|
+ LEFT JOIN company_user ON company_user.user_id = ucu.company_user_id
|
|
|
+ LEFT JOIN company ON company.company_id = ucu.company_id
|
|
|
WHERE
|
|
|
fs_user.is_del = 0
|
|
|
AND fs_user.`status` = 1
|
|
|
AND company_user.user_id is not null
|
|
|
GROUP BY
|
|
|
- fs_user.company_user_id, date(fs_user.create_time)
|
|
|
+ ucu.company_user_id, date(fs_user.create_time)
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectByCompanyUserAndProjectId" resultType="com.fs.store.domain.FsUser">
|
|
|
+ select
|
|
|
+ u.*
|
|
|
+ from fs_user u
|
|
|
+ inner join fs_user_company_user ucu on ucu.user_id = u.user_id
|
|
|
+ inner join company_user cu on cu.user_id = ucu.company_user_id
|
|
|
+ where cu.user_id = #{companyUserId} and ucu.project_id = #{projectId}
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectByUserIdAndProjectId" resultType="com.fs.store.domain.FsUser">
|
|
|
+ select
|
|
|
+ u.*
|
|
|
+ from fs_user u
|
|
|
+ inner join fs_user_company_user ucu on ucu.user_id = u.user_id
|
|
|
+ inner join company_user cu on cu.user_id = ucu.company_user_id
|
|
|
+ where u.user_id = #{userId} and ucu.project_id = #{projectId}
|
|
|
</select>
|
|
|
|
|
|
|