|
@@ -240,12 +240,81 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="selectFsUserVOList" resultType="com.fs.store.vo.FSUserVO">
|
|
|
+ SELECT
|
|
|
+ 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
|
|
|
+ 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 company_user ON company_user.user_id = u.company_user_id
|
|
|
+ LEFT JOIN company on company.company_id = company_user.company_id
|
|
|
+ <where>
|
|
|
+ 1 = 1
|
|
|
+ <if test = "maps.nickname != null and maps.nickname !='' " >
|
|
|
+ AND u.nickname LIKE CONCAT("%",#{maps.nickname},"%")
|
|
|
+ </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.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 >
|
|
|
+ </where>
|
|
|
+ ORDER BY
|
|
|
+ user_id DESC
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+ <select id="selectFsUserVOListByProject" resultType="com.fs.store.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.project_id
|
|
|
FROM
|
|
|
fs_user u
|
|
|
LEFT JOIN (
|
|
@@ -650,7 +719,7 @@
|
|
|
and fs_user_company_user.company_id = #{companyId}
|
|
|
</if>
|
|
|
GROUP BY
|
|
|
- fs_user.`status`
|
|
|
+ fs_user.`status`,fs_user_company_user.project_id
|
|
|
</select>
|
|
|
|
|
|
<select id="getRepeatUserNumber" resultType="int">
|
|
@@ -867,16 +936,15 @@
|
|
|
|
|
|
<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 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
|
|
|
+ (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 (ucu.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
</if>
|
|
@@ -900,17 +968,17 @@
|
|
|
AND company_user.user_id = #{companyUserId}
|
|
|
</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 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
|
|
|
+ GROUP BY fcc.user_id, ucu.project_id
|
|
|
+ ) AS watch_counts) as courseWatchNum,
|
|
|
+ (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 (ucu.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
</if>
|
|
@@ -935,14 +1003,15 @@
|
|
|
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
|
|
@@ -974,7 +1043,7 @@
|
|
|
) 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
|