|
@@ -57,6 +57,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<select id="selectFsUserList" parameterType="FsUser" resultMap="FsUserResult">
|
|
|
<include refid="selectFsUserVo"/>
|
|
|
<where>
|
|
|
+ <if test="userId != null">and user_id = #{userId}</if>
|
|
|
<if test="nickName != null and nickName != ''"> and nick_name like concat( #{nickName}, '%')</if>
|
|
|
<if test="avatar != null and avatar != ''"> and avatar = #{avatar}</if>
|
|
|
<if test="phone != null and phone != ''"> and phone = #{phone}</if>
|
|
@@ -110,6 +111,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
#{videoId}
|
|
|
</foreach>
|
|
|
</if>
|
|
|
+ <if test="companyId != null">
|
|
|
+ AND fwl.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
</where>
|
|
|
GROUP BY
|
|
|
fwl.video_id
|
|
@@ -125,10 +129,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
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}
|
|
@@ -142,6 +146,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
#{videoId}
|
|
|
</foreach>
|
|
|
</if>
|
|
|
+ <if test="companyId != null">
|
|
|
+ AND flog.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
</where>
|
|
|
GROUP BY
|
|
|
flog.video_id
|
|
@@ -167,10 +174,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
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}
|
|
@@ -184,7 +191,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
#{videoId}
|
|
|
</foreach>
|
|
|
</if>
|
|
|
-
|
|
|
+ <if test="companyId != null">
|
|
|
+ AND fs_course_answer_logs.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
</where>
|
|
|
GROUP BY
|
|
|
fs_course_answer_logs.video_id
|
|
@@ -196,7 +205,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
|
<select id="selectFsUserPageList" resultType="com.fs.store.vo.h5.FsUserPageListVO">
|
|
|
SELECT
|
|
|
- fs_user.*,
|
|
|
+ fs_user.user_id,
|
|
|
+ fs_user.avatar,
|
|
|
+ fs_user.nickname,
|
|
|
+ fs_user.phone,
|
|
|
fs_user_course_count.id,
|
|
|
fs_user_course_count.watch_course_count,
|
|
|
fs_user_course_count.miss_course_count,
|
|
@@ -210,53 +222,64 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
GROUP_CONCAT(DISTINCT company_tag.tag) AS tag,
|
|
|
GROUP_CONCAT(DISTINCT company_tag.tag_id) AS tagIds,
|
|
|
company_user.nick_name as companyUserNickName,
|
|
|
- fs_user_company_user.is_repeat_fans
|
|
|
+ fs_user_company_user.is_repeat_fans,
|
|
|
+ fs_user_company_user.project_id,
|
|
|
+ fs_user_company_user.`status`,
|
|
|
+ fs_user_company_user.remark,
|
|
|
+ fs_user_company_user.id as userCompanyUserId,
|
|
|
+ fs_user_company_user.create_time
|
|
|
FROM
|
|
|
fs_user
|
|
|
- LEFT JOIN fs_user_course_count ON fs_user.user_id = fs_user_course_count.user_id
|
|
|
- LEFT JOIN company_tag_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 fs_user_company_user ON fs_user_company_user.user_id = fs_user.user_id
|
|
|
+ INNER JOIN fs_user_company_user ON fs_user_company_user.user_id = fs_user.user_id
|
|
|
+ LEFT JOIN fs_user_course_count ON fs_user_company_user.user_id = fs_user_course_count.user_id and fs_user_company_user.project_id = fs_user_course_count.project_id
|
|
|
+ left join fs_user_project_tag upt ON upt.user_company_user_id = fs_user_company_user.id
|
|
|
+ LEFT JOIN company_tag ON company_tag.tag_id = upt.tag_id
|
|
|
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>
|
|
|
- <if test="companyUserId != null and companyUserId!= '' ">
|
|
|
- and fs_user.company_user_id = #{companyUserId}
|
|
|
+ <if test="status != null">
|
|
|
+ AND fs_user_company_user.status = #{status}
|
|
|
+ </if>
|
|
|
+ <if test="projectId != null">
|
|
|
+ AND fs_user_company_user.project_id = #{projectId}
|
|
|
</if>
|
|
|
- <choose>
|
|
|
- <when test = "isBlack">
|
|
|
- AND (fs_user.status = 0 or fs_user_company_user.is_repeat_fans = 1)
|
|
|
- </when>
|
|
|
- <otherwise>
|
|
|
- AND (fs_user.status = 1 and fs_user_company_user.is_repeat_fans = 0)
|
|
|
- </otherwise>
|
|
|
- </choose>
|
|
|
<if test="keyword != null and keyword !='' ">
|
|
|
- AND (fs_user.nick_name LIKE concat('%',#{keyword},'%')
|
|
|
+ AND (fs_user.nickname LIKE concat('%',#{keyword},'%')
|
|
|
or fs_user.phone LIKE concat('%',#{keyword},'%')
|
|
|
)
|
|
|
</if>
|
|
|
<if test="registerStartTime != null and registerStartTime !='' ">
|
|
|
- AND fs_user.create_time >= #{registerStartTime}
|
|
|
+ AND fs_user_company_user.create_time >= #{registerStartTime}
|
|
|
</if>
|
|
|
<if test="registerEndTime != null and registerEndTime !='' ">
|
|
|
- AND fs_user.create_time <= #{registerEndTime}
|
|
|
+ AND fs_user_company_user.create_time <= #{registerEndTime}
|
|
|
+ </if>
|
|
|
+ <if test="isNullTag">
|
|
|
+ and (upt.tag_id is null
|
|
|
+ <if test="tagIds != null and tagIds.length > 0">
|
|
|
+ or upt.tag_id in
|
|
|
+ <foreach collection="tagIds" item="item" index="index" open="(" separator="," close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ )
|
|
|
</if>
|
|
|
- <if test="tagIds != null and tagIds.length > 0">
|
|
|
- AND
|
|
|
- <foreach collection="tagIds" item="item" index="index" open="(" separator="or" close=")">
|
|
|
- CONCAT(',', company_tag_user.tag_ids, ',') LIKE CONCAT('%,', #{item}, ',%')
|
|
|
+
|
|
|
+ <if test="!isNullTag and tagIds != null and tagIds.length > 0">
|
|
|
+ AND upt.tag_id in
|
|
|
+ <foreach collection="tagIds" item="item" index="index" open="(" separator="," close=")">
|
|
|
+ #{item}
|
|
|
</foreach>
|
|
|
</if>
|
|
|
<if test="tabValue != null and tabValue !='' ">
|
|
|
<choose>
|
|
|
<when test = "tabValue == 1">
|
|
|
- AND DAY(fs_user.create_time) = DAY(NOW())
|
|
|
+ AND DAY(fs_user_company_user.create_time) = DAY(NOW())
|
|
|
</when>
|
|
|
<when test = "tabValue == 2">
|
|
|
AND DAY(fs_user_course_count.complete_watch_date) = DAY(NOW())
|
|
@@ -290,16 +313,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</choose>
|
|
|
</if>
|
|
|
|
|
|
- group by fs_user.user_id
|
|
|
+ group by fs_user.user_id, fs_user_company_user.project_id
|
|
|
|
|
|
<if test="continueMissCourseSort != null and continueMissCourseSort !='' ">
|
|
|
order by
|
|
|
<choose>
|
|
|
<when test = "continueMissCourseSort == 0">
|
|
|
- fs_user.create_time desc
|
|
|
+ fs_user_company_user.create_time desc
|
|
|
</when>
|
|
|
<when test = "continueMissCourseSort == 1">
|
|
|
- fs_user.nick_name asc
|
|
|
+ fs_user.nickname asc
|
|
|
</when>
|
|
|
</choose>
|
|
|
</if>
|
|
@@ -314,17 +337,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
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,
|
|
|
+ ucu.project_id
|
|
|
FROM
|
|
|
fs_user
|
|
|
<where>
|
|
|
fs_user.is_del = 0
|
|
|
+ <if test="userId != null">
|
|
|
+ AND fs_user.user_id = #{userId}
|
|
|
+ </if>
|
|
|
<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}
|
|
@@ -333,7 +360,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
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>
|
|
@@ -344,6 +371,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="phone != null and phone != ''">
|
|
|
AND fs_user.phone like concat('%', #{phone},'%')
|
|
|
</if>
|
|
|
+ <if test="projectId != null">
|
|
|
+ AND ucu.project_id = #{projectId}
|
|
|
+ </if>
|
|
|
</where>
|
|
|
limit ${(pageNum-1)*pageSize},${pageSize}
|
|
|
</select>
|
|
@@ -353,8 +383,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
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 ucu.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ <if test="companyUserId != null and companyUserId != '' ">
|
|
|
+ AND ucu.company_user_id = #{companyUserId}
|
|
|
+ </if>
|
|
|
<if test="registerStartTime != null and registerStartTime !='' ">
|
|
|
AND fs_user.create_time >= #{registerStartTime}
|
|
|
</if>
|
|
@@ -362,7 +399,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
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>
|
|
@@ -373,8 +410,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="phone != null and phone!=''">
|
|
|
AND fs_user.phone = #{phone}
|
|
|
</if>
|
|
|
- <if test="companyId != null">
|
|
|
- AND fs_user.company_id = #{companyId}
|
|
|
+ <if test="projectId != null">
|
|
|
+ AND ucu.project_id = #{projectId}
|
|
|
</if>
|
|
|
</where>
|
|
|
</select>
|
|
@@ -596,10 +633,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
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`
|
|
@@ -632,7 +669,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
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
|
|
|
+ inner JOIN fs_user_company_user cu ON cu.user_id = fs_user.user_id and cu.project_id = fs_user_course_count.project_id
|
|
|
<where>
|
|
|
<if test="dateTag != null and dateTag !='' ">
|
|
|
<choose>
|
|
@@ -650,6 +687,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</when>
|
|
|
</choose>
|
|
|
</if>
|
|
|
+ <if test="userCompanyId!=null">
|
|
|
+ and cu.id = #{userCompanyId}
|
|
|
+ </if>
|
|
|
and fs_user.user_id = #{fsUserId}
|
|
|
</where>
|
|
|
GROUP BY
|
|
@@ -664,7 +704,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
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 fs_course_watch_log fcwl on fs_course_answer_logs.watch_log_id =fcwl.log_id
|
|
|
+ left join fs_user_company_user fucu on fucu.user_id =fs_user.user_id and fcwl.project = fucu.project_id
|
|
|
<where>
|
|
|
|
|
|
<if test="dateTag != null and dateTag !='' ">
|
|
@@ -683,18 +724,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</when>
|
|
|
</choose>
|
|
|
</if>
|
|
|
- and fs_user.user_id = #{fsUserId}
|
|
|
+ and fs_user.user_id = #{fsUserId} and fucu.company_user_id =#{userId}
|
|
|
</where>
|
|
|
GROUP BY
|
|
|
fs_user.user_id
|
|
|
) AS answerTime,
|
|
|
(
|
|
|
SELECT
|
|
|
- ifnull(count( DISTINCT log_id ), 0) AS answerRightTime
|
|
|
+ ifnull(count( DISTINCT fs_course_answer_logs.log_id ), 0) AS answerRightTime
|
|
|
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 fs_course_watch_log fcwl on fs_course_answer_logs.watch_log_id =fcwl.log_id
|
|
|
+ left join fs_user_company_user fucu on fucu.user_id =fs_user.user_id and fcwl.project = fucu.project_id
|
|
|
<where>
|
|
|
fs_course_answer_logs.is_right = 1
|
|
|
<if test="dateTag != null and dateTag !='' ">
|
|
@@ -713,7 +755,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</when>
|
|
|
</choose>
|
|
|
</if>
|
|
|
- and fs_user.user_id = #{fsUserId}
|
|
|
+ and fs_user.user_id = #{fsUserId} and fucu.company_user_id =#{userId}
|
|
|
</where>
|
|
|
GROUP BY
|
|
|
fs_user.user_id
|
|
@@ -722,13 +764,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
|
<select id="getCountRedPacket" resultType="com.fs.store.vo.h5.UserDetailsVO">
|
|
|
SELECT
|
|
|
- ifnull( count( DISTINCT log_id ), 0 ) AS answerRedPacketTime,
|
|
|
+ ifnull( count( DISTINCT fs_course_red_packet_log.log_id ), 0 ) AS answerRedPacketTime,
|
|
|
ifnull( sum( amount ), 0 ) AS answerRedPacketAmount,
|
|
|
fs_user.user_id
|
|
|
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
|
|
|
+ left join fs_course_watch_log fcwl on fs_course_red_packet_log.watch_log_id =fcwl.log_id
|
|
|
+ left join fs_user_company_user fucu on fucu.user_id =fs_user.user_id and fcwl.project = fucu.project_id
|
|
|
<where>
|
|
|
fs_course_red_packet_log.status = 1
|
|
|
<if test="dateTag != null and dateTag !='' ">
|
|
@@ -747,7 +790,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</when>
|
|
|
</choose>
|
|
|
</if>
|
|
|
- and fs_user.user_id = #{fsUserId}
|
|
|
+ and fs_user.user_id = #{fsUserId} and fucu.company_user_id =#{userId}
|
|
|
</where>
|
|
|
GROUP BY
|
|
|
fs_user.user_id
|
|
@@ -756,45 +799,46 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<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
|
|
|
+ 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
|
|
|
+ AND to_days(ucu.create_time) = to_days(now())) as todayNewUser
|
|
|
</select>
|
|
|
|
|
|
<select id="countTag" resultType="com.fs.store.vo.h5.FsUserSummaryCountTagVO">
|
|
|
SELECT
|
|
|
company_tag.tag AS tagName,
|
|
|
- count( fs_user.user_id ) AS number
|
|
|
+ count( ucu.user_id ) AS number
|
|
|
FROM
|
|
|
- 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
|
|
|
+ fs_user_project_tag upt
|
|
|
+ inner join fs_user_company_user ucu on ucu.id = upt.user_company_user_id
|
|
|
+ inner join company_tag ON upt.tag_id = company_tag.tag_id
|
|
|
+ left join company_user on company_user.user_id = ucu.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 (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>
|
|
|
GROUP BY
|
|
|
company_tag.tag_id
|
|
@@ -802,20 +846,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
|
<select id="countUserCourse" resultType="Map">
|
|
|
SELECT
|
|
|
- (
|
|
|
- SELECT
|
|
|
- count(distinct fcc.user_id )
|
|
|
- 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
|
|
|
+ (SELECT COUNT(*) FROM (
|
|
|
+ SELECT 1
|
|
|
+ FROM fs_user_course_count fcc
|
|
|
+ JOIN fs_user ON fs_user.user_id = fcc.user_id
|
|
|
+ JOIN fs_user_company_user ucu ON ucu.user_id = fs_user.user_id
|
|
|
+ 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>
|
|
|
+ fcc.project_id = ucu.project_id
|
|
|
<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}
|
|
@@ -835,20 +879,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</if>
|
|
|
</where>
|
|
|
) as courseWatchNum,
|
|
|
- (
|
|
|
- SELECT
|
|
|
- count(distinct fcc.user_id )
|
|
|
- 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
|
|
|
+ (SELECT COUNT(*) FROM (
|
|
|
+ SELECT 1
|
|
|
+ FROM fs_user_course_count fcc
|
|
|
+ JOIN fs_user ON fs_user.user_id = fcc.user_id
|
|
|
+ JOIN fs_user_company_user ucu ON ucu.user_id = fs_user.user_id
|
|
|
+ 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>
|
|
|
+ fcc.project_id = ucu.project_id
|
|
|
<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 !='' ">
|
|
@@ -868,24 +912,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
AND company_user.user_id = #{companyUserId}
|
|
|
</if>
|
|
|
</where>
|
|
|
- ) as courseCompleteNum
|
|
|
+ GROUP BY fcc.user_id, ucu.project_id
|
|
|
+ ) AS complete_counts ) as courseCompleteNum
|
|
|
</select>
|
|
|
|
|
|
<select id="countUserAnswer" resultType="Map">
|
|
|
SELECT
|
|
|
(
|
|
|
SELECT
|
|
|
- count(distinct fs_user.user_id )
|
|
|
+ count(fs_user.user_id )
|
|
|
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_course_watch_log fcwl on fs_course_answer_logs.watch_log_id=fcwl.log_id
|
|
|
+ left join fs_user_company_user fucu on fucu.user_id =fs_user.user_id and fcwl.project = fucu.project_id
|
|
|
<where>
|
|
|
<if test="userId != null and userId != 0 ">
|
|
|
- and (fs_user.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
+ and (fucu.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}
|
|
@@ -907,17 +954,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
) AS answerNum,
|
|
|
(
|
|
|
SELECT
|
|
|
- count(distinct fs_user.user_id )
|
|
|
+ count(fs_user.user_id )
|
|
|
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_course_watch_log fcwl on fs_course_answer_logs.watch_log_id=fcwl.log_id
|
|
|
+ left join fs_user_company_user fucu on fucu.user_id =fs_user.user_id and fcwl.project = fucu.project_id
|
|
|
<where>
|
|
|
<if test="userId != null and userId != 0 ">
|
|
|
- and (fs_user.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
+ and (fucu.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 !='' ">
|
|
@@ -948,20 +997,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
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
|
|
|
- WHERE 1=1
|
|
|
+ left join fs_user_company_user ucu on ucu.user_id = fs_user.user_id
|
|
|
+ WHERE 1=1 and fcpd.del_flag =0 and fpd.del_flag =0
|
|
|
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,
|
|
|
|
|
@@ -970,13 +1020,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
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
|
|
|
- WHERE 1=1
|
|
|
+ left join fs_user_company_user ucu on ucu.user_id = fs_user.user_id
|
|
|
+ WHERE 1=1 and fcpd.del_flag =0 and fpd.del_flag =0
|
|
|
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}
|
|
@@ -986,13 +1037,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</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>
|
|
@@ -1001,14 +1053,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</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
|
|
@@ -1023,14 +1075,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
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}
|
|
@@ -1070,13 +1123,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
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}
|
|
@@ -1127,10 +1180,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
LEFT JOIN fs_user_course_video fcv ON fcv.video_id = fwl.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_user_company_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}
|
|
|
+ and fs_user_company_user.company_id = #{companyId}
|
|
|
</if>
|
|
|
<if test="startTime != null and startTime !='' ">
|
|
|
AND fwl.create_time >= #{startTime}
|
|
@@ -1176,14 +1229,14 @@ 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 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
|
|
|
+ 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}
|
|
@@ -1222,13 +1275,15 @@ 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
|
|
|
- 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
|
|
|
+ left join fs_course_watch_log fcwl on flog.watch_log_id =fcwl.log_id
|
|
|
+ left join fs_user_company_user fucu on fucu.user_id =fs_user.user_id and fcwl.project = fucu.project_id
|
|
|
where flog.status = 1
|
|
|
<if test="userId != null and userId != 0 ">
|
|
|
- and (fs_user.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
+ and (fucu.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}
|
|
@@ -1253,13 +1308,15 @@ 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
|
|
|
- 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
|
|
|
+ left join fs_course_watch_log fcwl on flog.watch_log_id =fcwl.log_id
|
|
|
+ left join fs_user_company_user fucu on fucu.user_id =fs_user.user_id and fcwl.project = fucu.project_id
|
|
|
where flog.status = 1
|
|
|
<if test="userId != null and userId != 0 ">
|
|
|
- and (fs_user.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
+ and (fucu.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}
|
|
@@ -1296,14 +1353,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
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}
|
|
@@ -1319,13 +1377,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<select id="companyUserCount" resultType="com.fs.store.vo.h5.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,
|
|
@@ -1334,13 +1392,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
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(
|
|
@@ -1358,10 +1417,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
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>
|
|
@@ -1375,10 +1434,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
fs_course_watch_log l
|
|
|
LEFT JOIN fs_user on fs_user.user_id = l.user_id
|
|
|
LEFT JOIN company_user ON l.company_user_id = company_user.user_id
|
|
|
+ LEFT JOIN fs_user_company_user ON fs_user_company_user.user_id = fs_user.user_id and l.project =fs_user_company_user.project_id
|
|
|
where
|
|
|
l.log_type != 3 and send_type = 1
|
|
|
<if test="userId != null and userId != 0 ">
|
|
|
- and (l.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="userId != null and userId == 0 ">
|
|
|
and l.company_id = #{companyId}
|
|
@@ -1394,7 +1454,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</if>
|
|
|
<if test="endTime != null and endTime != ''">
|
|
|
and l.create_time <= #{endTime}
|
|
|
- </if>
|
|
|
+ </if> <if test="companyUserId != null and companyUserId != ''">
|
|
|
+ AND l.user_id = #{companyUserId}
|
|
|
+ </if>
|
|
|
-- 单独通过销售id查询
|
|
|
<if test="companyUserId != null and companyUserId != ''">
|
|
|
AND l.company_user_id = #{companyUserId}
|
|
@@ -1405,12 +1467,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
count(DISTINCT l.user_id)
|
|
|
FROM
|
|
|
fs_course_watch_log l
|
|
|
- LEFT JOIN fs_user on fs_user.user_id = l.user_id
|
|
|
LEFT JOIN company_user ON l.company_user_id = company_user.user_id
|
|
|
+ LEFT JOIN fs_user ON fs_user.user_id = l.user_id
|
|
|
+ LEFT JOIN fs_user_company_user ON fs_user_company_user.user_id = fs_user.user_id and l.project =fs_user_company_user.project_id
|
|
|
where
|
|
|
l.log_type = 2 and send_type = 1
|
|
|
<if test="userId != null and userId != 0 ">
|
|
|
- and (l.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="userId != null and userId == 0 ">
|
|
|
and l.company_id = #{companyId}
|
|
@@ -1463,4 +1526,84 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
AND l.company_user_id = #{companyUserId}
|
|
|
</if>
|
|
|
</select>
|
|
|
+
|
|
|
+ <select id="selectFsUserVOListByProject" resultType="com.fs.his.vo.FsUserVO">
|
|
|
+ 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
|
|
|
+ ,company.company_name,
|
|
|
+ ucu.project_id,
|
|
|
+ ucu.id as companyUserId
|
|
|
+ FROM
|
|
|
+ fs_user u
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT max( payment_id ) AS payment_id, max( pay_time ) AS last_buy_time, SUM( pay_money ) AS total_amount,
|
|
|
+ user_id
|
|
|
+ FROM
|
|
|
+ fs_store_payment
|
|
|
+ WHERE
|
|
|
+ STATUS = 1
|
|
|
+ AND user_id IS NOT NULL
|
|
|
+ GROUP BY
|
|
|
+ user_id
|
|
|
+ ) b ON u.user_id = b.user_id
|
|
|
+ LEFT JOIN fs_store_payment p ON u.user_id = p.user_id
|
|
|
+ AND b.last_buy_time = p.pay_time
|
|
|
+ AND b.payment_id = p.payment_id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ fs_user_course_count.user_id,Max( fs_user_course_count.last_watch_date ) AS last_watch_date,fs_user_course_count.watch_course_count,
|
|
|
+ fs_user_course_count.part_course_count
|
|
|
+ FROM
|
|
|
+ fs_user_course_count
|
|
|
+ GROUP BY fs_user_course_count.user_id
|
|
|
+ ) fcc ON fcc.user_id = u.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 and u.nickname is not null
|
|
|
+ <if test = "maps.nickname != null and maps.nickname !='' " >
|
|
|
+ AND u.nickname LIKE CONCAT("%",#{maps.nickname},"%")
|
|
|
+ </if >
|
|
|
+ <if test = "maps.userId != null and maps.userId !='' " >
|
|
|
+ AND u.user_id = #{maps.userId}
|
|
|
+ </if >
|
|
|
+ <if test = "maps.phone != null and maps.phone !='' " >
|
|
|
+ AND u.phone LIKE CONCAT("%",#{maps.phone},"%")
|
|
|
+ </if >
|
|
|
+ <if test = "maps.startCreateTime != null and maps.endCreateTime != null" >
|
|
|
+ AND (DATE_FORMAT( u.create_time, "%Y-%m-%d" ) >= DATE_FORMAT(#{maps.startCreateTime}, "%Y-%m-%d")
|
|
|
+ and DATE_FORMAT( u.create_time, "%Y-%m-%d" ) <= DATE_FORMAT(#{maps.endCreateTime}, "%Y-%m-%d")
|
|
|
+ )
|
|
|
+ </if >
|
|
|
+ <if test = "maps.registerCode != null and maps.registerCode !='' " >
|
|
|
+ AND u.register_code = #{maps.registerCode}
|
|
|
+ </if >
|
|
|
+ <if test = "maps.status != null" >
|
|
|
+ AND u.STATUS = #{maps.status}
|
|
|
+ </if >
|
|
|
+ <if test = "maps.companyUserNickName != null and maps.companyUserNickName != '' " >
|
|
|
+ AND company_user.nick_name like CONCAT ("%",#{maps.companyUserNickName},"%")
|
|
|
+ </if >
|
|
|
+ <if test = "maps.companyName != null and maps.companyName != '' " >
|
|
|
+ AND company.company_name like CONCAT ("%",#{maps.companyName},"%")
|
|
|
+ </if >
|
|
|
+ <if test = "maps.companyId != null and maps.companyId != '' " >
|
|
|
+ AND company.company_id = #{maps.companyId}
|
|
|
+ </if >
|
|
|
+ <if test = "maps.level != null and maps.level !=''" >
|
|
|
+ AND u.LEVEL = #{maps.level}
|
|
|
+ </if >
|
|
|
+ <if test = "maps.isPromoter != null and maps.isPromoter !=''" >
|
|
|
+ AND u.is_promoter = #{maps.isPromoter}
|
|
|
+ </if >
|
|
|
+ <if test = "maps.projectId != null" >
|
|
|
+ AND ucu.project_id = #{maps.projectId}
|
|
|
+ </if >
|
|
|
+ </where>
|
|
|
+ ORDER BY
|
|
|
+ user_id DESC
|
|
|
+ </select>
|
|
|
</mapper>
|