|
@@ -48,10 +48,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<result property="courseMaOpenId" column="course_ma_open_id" />
|
|
<result property="courseMaOpenId" column="course_ma_open_id" />
|
|
|
<result property="qwExtId" column="qw_ext_id" />
|
|
<result property="qwExtId" column="qw_ext_id" />
|
|
|
<result property="qwUserId" column="qw_user_id" />
|
|
<result property="qwUserId" column="qw_user_id" />
|
|
|
|
|
+ <result property="level" column="level"/>
|
|
|
</resultMap>
|
|
</resultMap>
|
|
|
|
|
|
|
|
<sql id="selectFsUserVo">
|
|
<sql id="selectFsUserVo">
|
|
|
- select user_id,qw_ext_id,sex,is_buy,course_ma_open_id,is_push,is_add_qw,source,login_device,is_individuation_push,store_open_id,password,jpush_id, is_vip,vip_start_date,vip_end_date,vip_level,vip_status,nick_name,integral_status, avatar, phone, integral,sign_num, status, tui_user_id, tui_time, tui_user_count, ma_open_id, mp_open_id, union_id, is_del, user_code, remark, create_time, update_time, last_ip, balance,is_weixin_auth,parent_id,qw_user_id,company_id,company_user_id from fs_user
|
|
|
|
|
|
|
+ select user_id,qw_ext_id,sex,is_buy,`level`,course_ma_open_id,is_push,is_add_qw,source,login_device,is_individuation_push,store_open_id,password,jpush_id, is_vip,vip_start_date,vip_end_date,vip_level,vip_status,nick_name,integral_status, avatar, phone, integral,sign_num, status, tui_user_id, tui_time, tui_user_count, ma_open_id, mp_open_id, union_id, is_del, user_code, remark, create_time, update_time, last_ip, balance,is_weixin_auth,parent_id,qw_user_id,company_id,company_user_id from fs_user
|
|
|
</sql>
|
|
</sql>
|
|
|
|
|
|
|
|
<select id="selectFsUserList" parameterType="FsUser" resultMap="FsUserResult">
|
|
<select id="selectFsUserList" parameterType="FsUser" resultMap="FsUserResult">
|
|
@@ -557,6 +558,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="orderCount != null">order_count,</if>
|
|
<if test="orderCount != null">order_count,</if>
|
|
|
<if test="companyId != null">company_id,</if>
|
|
<if test="companyId != null">company_id,</if>
|
|
|
<if test="companyUserId != null">company_user_id,</if>
|
|
<if test="companyUserId != null">company_user_id,</if>
|
|
|
|
|
+ <if test="level != null">`level`,</if>
|
|
|
</trim>
|
|
</trim>
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
<if test="nickName != null">#{nickName},</if>
|
|
<if test="nickName != null">#{nickName},</if>
|
|
@@ -600,6 +602,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="orderCount != null">#{orderCount},</if>
|
|
<if test="orderCount != null">#{orderCount},</if>
|
|
|
<if test="companyId != null">#{companyId},</if>
|
|
<if test="companyId != null">#{companyId},</if>
|
|
|
<if test="companyUserId != null">#{companyUserId},</if>
|
|
<if test="companyUserId != null">#{companyUserId},</if>
|
|
|
|
|
+ <if test="level != null">#{level},</if>
|
|
|
</trim>
|
|
</trim>
|
|
|
</insert>
|
|
</insert>
|
|
|
|
|
|
|
@@ -891,6 +894,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
fs_user.user_id
|
|
fs_user.user_id
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
|
|
+ <select id="getUserTotal" resultType="java.lang.Integer">
|
|
|
|
|
+ SELECT count(fs_user.user_id) as userTotal
|
|
|
|
|
+ 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 fs_user.is_del = 0
|
|
|
|
|
+ <if test="userId != null and userId != 0 ">
|
|
|
|
|
+ and (ucu.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="companyId != null ">
|
|
|
|
|
+ and ucu.company_id = #{companyId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+ <select id="getTodayNewUser" resultType="java.lang.Integer">
|
|
|
|
|
+ SELECT count(fs_user.user_id) as todayNewUser
|
|
|
|
|
+ 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 fs_user.is_del = 0
|
|
|
|
|
+ <if test="userId != null and userId != 0 ">
|
|
|
|
|
+ and (ucu.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="companyId != null ">
|
|
|
|
|
+ and ucu.company_id = #{companyId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ AND to_days(ucu.create_time) = to_days(now())
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
<select id="countUserSummary" resultType="com.fs.store.vo.h5.FsUserSummaryCountVO">
|
|
<select id="countUserSummary" resultType="com.fs.store.vo.h5.FsUserSummaryCountVO">
|
|
|
SELECT (SELECT count(fs_user.user_id)
|
|
SELECT (SELECT count(fs_user.user_id)
|
|
|
FROM fs_user
|
|
FROM fs_user
|
|
@@ -1206,6 +1238,106 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ <!-- 查询观看和完成人数 -->
|
|
|
|
|
+ <select id="countUserWatchStats" resultType="Map">
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ COUNT(DISTINCT CASE WHEN l.log_type != 3 AND l.send_type = 1 THEN l.user_id END) AS courseWatchNum,
|
|
|
|
|
+ COUNT(DISTINCT CASE WHEN l.log_type = 2 AND l.send_type = 1 THEN l.user_id END) AS courseCompleteNum
|
|
|
|
|
+ FROM fs_course_watch_log l
|
|
|
|
|
+ LEFT JOIN fs_user u ON u.user_id = l.user_id
|
|
|
|
|
+ LEFT JOIN company_user cu_l ON l.company_user_id = cu_l.user_id
|
|
|
|
|
+ <where>
|
|
|
|
|
+ <if test="userId != null and userId != 0">
|
|
|
|
|
+ AND (cu_l.user_id = #{userId} OR cu_l.parent_id = #{userId})
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="userId != null and userId == 0">
|
|
|
|
|
+ AND l.company_id = #{companyId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="periodId != null and periodId != ''">
|
|
|
|
|
+ AND l.period_id = #{periodId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="videoId != null and videoId != ''">
|
|
|
|
|
+ AND l.video_id = #{videoId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="startTime != null and startTime != ''">
|
|
|
|
|
+ AND l.create_time >= #{startTime}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
|
|
+ AND l.create_time <= #{endTime}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="companyUserId != null and companyUserId != ''">
|
|
|
|
|
+ AND l.company_user_id = #{companyUserId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </where>
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 查询答题人数和答对人数 -->
|
|
|
|
|
+ <select id="countUserAnswerStats" resultType="Map">
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ COUNT(DISTINCT CASE WHEN a.user_id THEN a.user_id END) AS answerNum,
|
|
|
|
|
+ COUNT(DISTINCT CASE WHEN a.is_right = 1 THEN a.user_id END) AS answerRightNum
|
|
|
|
|
+ FROM fs_course_answer_logs a
|
|
|
|
|
+ LEFT JOIN fs_user u ON u.user_id = a.user_id
|
|
|
|
|
+ LEFT JOIN company_user cu_a ON a.company_user_id = cu_a.user_id
|
|
|
|
|
+ <where>
|
|
|
|
|
+ <if test="userId != null and userId != 0">
|
|
|
|
|
+ AND (cu_a.user_id = #{userId} OR cu_a.parent_id = #{userId})
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="userId != null and userId == 0">
|
|
|
|
|
+ AND a.company_id = #{companyId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="periodId != null and periodId != ''">
|
|
|
|
|
+ AND a.period_id = #{periodId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="videoId != null and videoId != ''">
|
|
|
|
|
+ AND a.video_id = #{videoId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="startTime != null and startTime != ''">
|
|
|
|
|
+ AND a.create_time >= #{startTime}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
|
|
+ AND a.create_time <= #{endTime}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="companyUserId != null and companyUserId != ''">
|
|
|
|
|
+ AND a.company_user_id = #{companyUserId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </where>
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 查询红包数量和红包金额 -->
|
|
|
|
|
+ <select id="countUserRedPacketStats" resultType="Map">
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ COUNT(CASE WHEN flog.status = 1 THEN flog.log_id END) AS redPacketNum,
|
|
|
|
|
+ IFNULL(SUM(CASE WHEN flog.status = 1 THEN flog.amount END), 0) AS redPacketAmount
|
|
|
|
|
+ FROM fs_course_red_packet_log flog
|
|
|
|
|
+ LEFT JOIN fs_user u ON u.user_id = flog.user_id
|
|
|
|
|
+ LEFT JOIN company_user cu_flog ON flog.company_user_id = cu_flog.user_id
|
|
|
|
|
+ <where>
|
|
|
|
|
+ <if test="userId != null and userId != 0">
|
|
|
|
|
+ AND (cu_flog.user_id = #{userId} OR cu_flog.parent_id = #{userId})
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="userId != null and userId == 0">
|
|
|
|
|
+ AND flog.company_id = #{companyId}
|
|
|
|
|
+ </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>
|
|
|
|
|
+ <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="companyUserId != null and companyUserId != ''">
|
|
|
|
|
+ AND flog.company_user_id = #{companyUserId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </where>
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
<select id="countUserAnswer" resultType="Map">
|
|
<select id="countUserAnswer" resultType="Map">
|
|
|
SELECT
|
|
SELECT
|
|
|
(
|
|
(
|