1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.fs.store.mapper.FsUserMapper">
- <resultMap type="FsUser" id="FsUserResult">
- <result property="userId" column="user_id"/>
- <result property="username" column="username"/>
- <result property="password" column="password"/>
- <result property="realName" column="real_name"/>
- <result property="birthday" column="birthday"/>
- <result property="idCard" column="id_card"/>
- <result property="remark" column="remark"/>
- <result property="nickname" column="nickname"/>
- <result property="avatar" column="avatar"/>
- <result property="phone" column="phone"/>
- <result property="createTime" column="create_time"/>
- <result property="updateTime" column="update_time"/>
- <result property="lastIp" column="last_ip"/>
- <result property="nowMoney" column="now_money"/>
- <result property="brokeragePrice" column="brokerage_price"/>
- <result property="integral" column="integral"/>
- <result property="signNum" column="sign_num"/>
- <result property="status" column="status"/>
- <result property="level" column="level"/>
- <result property="spreadUserId" column="spread_user_id"/>
- <result property="spreadTime" column="spread_time"/>
- <result property="userType" column="user_type"/>
- <result property="isPromoter" column="is_promoter"/>
- <result property="payCount" column="pay_count"/>
- <result property="spreadCount" column="spread_count"/>
- <result property="addres" column="addres"/>
- <result property="maOpenId" column="ma_open_id"/>
- <result property="mpOpenId" column="mp_open_id"/>
- <result property="unionId" column="union_id"/>
- <result property="isDel" column="is_del"/>
- <result property="isWeixinAuth" column="is_weixin_auth"/>
- <result property="companyId" column="company_id"/>
- <result property="companyUserId" column="company_user_id"/>
- <result property="registerDate" column="register_date"/>
- <result property="registerCode" column="register_code"/>
- <result property="source" column="source"/>
- <result property="userCode" column="user_code"/>
- <result property="isShow" column="is_show"/>
- <result property="qwExtId" column="qw_ext_id" />
- <result property="isAddQw" column="is_add_qw" />
- </resultMap>
- <sql id="selectFsUserVo">
- select user_id,
- qw_ext_id,
- is_show,
- username,
- password,
- real_name,
- birthday,
- id_card,
- remark,
- nickname,
- avatar,
- phone,
- create_time,
- update_time,
- last_ip,
- now_money,
- brokerage_price,
- integral,
- sign_num,
- status,
- level,
- spread_user_id,
- spread_time,
- user_type,
- is_promoter,
- pay_count,
- spread_count,
- addres,
- ma_open_id,
- mp_open_id,
- union_id,
- is_del,
- is_weixin_auth,
- company_id,
- is_add_qw,
- company_user_id,
- register_date,
- register_code,
- source,
- user_code
- from fs_user
- </sql>
- <select id="selectFsUserList" parameterType="FsUser" resultMap="FsUserResult">
- <include refid="selectFsUserVo"/>
- <where>
- <if test="username != null and username != ''">and username like concat('%', #{username}, '%')</if>
- <if test="password != null and password != ''">and password = #{password}</if>
- <if test="realName != null and realName != ''">and real_name like concat('%', #{realName}, '%')</if>
- <if test="birthday != null ">and birthday = #{birthday}</if>
- <if test="idCard != null and idCard != ''">and id_card = #{idCard}</if>
- <if test="remark != null and remark != ''">and remark = #{remark}</if>
- <if test="nickname != null and nickname != ''">and nickname like concat('%', #{nickname}, '%')</if>
- <if test="avatar != null and avatar != ''">and avatar = #{avatar}</if>
- <if test="phone != null and phone != ''">and phone = #{phone}</if>
- <if test="lastIp != null and lastIp != ''">and last_ip = #{lastIp}</if>
- <if test="nowMoney != null ">and now_money = #{nowMoney}</if>
- <if test="brokeragePrice != null ">and brokerage_price = #{brokeragePrice}</if>
- <if test="integral != null ">and integral = #{integral}</if>
- <if test="signNum != null ">and sign_num = #{signNum}</if>
- <if test="status != null ">and status = #{status}</if>
- <if test="level != null ">and level = #{level}</if>
- <if test="spreadUserId != null ">and spread_user_id = #{spreadUserId}</if>
- <if test="spreadTime != null ">and spread_time = #{spreadTime}</if>
- <if test="userType != null and userType != ''">and user_type = #{userType}</if>
- <if test="isPromoter != null ">and is_promoter = #{isPromoter}</if>
- <if test="payCount != null ">and pay_count = #{payCount}</if>
- <if test="spreadCount != null ">and spread_count = #{spreadCount}</if>
- <if test="addres != null and addres != ''">and addres = #{addres}</if>
- <if test="isDel != null ">and is_del = #{isDel}</if>
- <if test="companyId != null ">and company_id = #{companyId}</if>
- <if test="companyUserId != null ">and company_user_id = #{companyUserId}</if>
- <if test="registerDate != null ">and DATE_FORMAT(register_date,'%Y-%m-%d') =
- DATE_FORMAT(#{registerDate},'%Y-%m-%d')
- </if>
- <if test="registerCode != null and registerCode != '' ">and register_code = #{registerCode}</if>
- <if test="source != null and source != '' ">and source = #{source}</if>
- <if test="isShow != null ">and is_show = #{isShow}</if>
- </where>
- order by user_id desc
- </select>
- <select id="selectFsUserById" parameterType="Long" resultMap="FsUserResult">
- <include refid="selectFsUserVo"/>
- where user_id = #{userId}
- </select>
- <select id="selectFsUserListLimit" resultType="com.fs.store.domain.FsUser">
- <include refid="selectFsUserVo"/>
- <where>
- <if test="password != null and password != ''">and password = #{password}</if>
- <if test="realName != null and realName != ''">and real_name like concat('%', #{realName}, '%')</if>
- <if test="birthday != null ">and birthday = #{birthday}</if>
- <if test="idCard != null and idCard != ''">and id_card = #{idCard}</if>
- <if test="remark != null and remark != ''">and remark = #{remark}</if>
- <if test="avatar != null and avatar != ''">and avatar = #{avatar}</if>
- <if test="lastIp != null and lastIp != ''">and last_ip = #{lastIp}</if>
- <if test="nowMoney != null ">and now_money = #{nowMoney}</if>
- <if test="brokeragePrice != null ">and brokerage_price = #{brokeragePrice}</if>
- <if test="integral != null ">and integral = #{integral}</if>
- <if test="signNum != null ">and sign_num = #{signNum}</if>
- <if test="status != null ">and status = #{status}</if>
- <if test="level != null ">and level = #{level}</if>
- <if test="spreadUserId != null ">and spread_user_id = #{spreadUserId}</if>
- <if test="spreadTime != null ">and spread_time = #{spreadTime}</if>
- <if test="userType != null and userType != ''">and user_type = #{userType}</if>
- <if test="isPromoter != null ">and is_promoter = #{isPromoter}</if>
- <if test="payCount != null ">and pay_count = #{payCount}</if>
- <if test="spreadCount != null ">and spread_count = #{spreadCount}</if>
- <if test="addres != null and addres != ''">and addres = #{addres}</if>
- <if test="isDel != null ">and is_del = #{isDel}</if>
- <if test="companyId != null ">and company_id = #{companyId}</if>
- <if test="companyUserId != null ">and company_user_id = #{companyUserId}</if>
- <if test="registerDate != null ">and DATE_FORMAT(register_date,'%Y-%m-%d') =
- DATE_FORMAT(#{registerDate},'%Y-%m-%d')
- </if>
- <if test="registerCode != null and registerCode != '' ">and register_code = #{registerCode}</if>
- <if test="source != null and source != '' ">and source = #{source}</if>
- <if test="isShow != null ">and is_show = #{isShow}</if>
- <if test="(username != null and username != '') or (nickname != null and nickname != '') or (phone != null and phone != '')">
- and (
- <if test="username != null and username != ''">username like concat('%', #{username}, '%')</if>
- <if test="nickname != null and nickname != ''">or nickname like concat('%', #{nickname}, '%')</if>
- <if test="phone != null and phone != ''">or phone like concat('%',#{phone},'%')</if>
- )
- </if>
- </where>
- order by user_id desc
- limit 10
- </select>
- <select id="selectCusListPage" resultType="com.fs.store.domain.FsUser">
- select user.user_id,
- user.username,
- user.real_name,
- user.id_card,
- user.phone,
- user.addres,
- user.nickname,
- user.status,
- user.company_id,
- user.company_user_id,
- user.create_time
- from
- fs_user `user` join (
- select user_id from fs_user
- <where>
- <if test="companyId != null and companyId != ''">
- AND company_id = #{companyId}
- </if>
- <if test="companyUserId != null and companyUserId != ''">
- AND company_user_id = #{companyUserId}
- </if>
- <if test="phone != null and phone != ''">
- AND phone = #{phone}
- </if>
- </where>
- order by user_id desc
- limit ${(pageNum-1)*pageSize},${pageSize}
- ) t on t.user_id = `user`.user_id
- </select>
- <select id="selectCusListPageCount" resultType="java.lang.Long">
- SELECT COUNT(user_id)
- FROM fs_user
- <where>
- <if test="companyId != null and companyId != ''">
- AND company_id = #{companyId}
- </if>
- <if test="companyUserId != null and companyUserId != ''">
- AND company_user_id = #{companyUserId}
- </if>
- <if test="phone != null and phone != ''">
- AND phone = #{phone}
- </if>
- </where>
- </select>
- <insert id="insertFsUser" parameterType="FsUser" useGeneratedKeys="true" keyProperty="userId">
- insert into fs_user
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="username != null">username,</if>
- <if test="password != null">password,</if>
- <if test="realName != null">real_name,</if>
- <if test="birthday != null">birthday,</if>
- <if test="idCard != null">id_card,</if>
- <if test="remark != null">remark,</if>
- <if test="nickname != null">nickname,</if>
- <if test="avatar != null">avatar,</if>
- <if test="phone != null">phone,</if>
- <if test="createTime != null">create_time,</if>
- <if test="updateTime != null">update_time,</if>
- <if test="lastIp != null">last_ip,</if>
- <if test="nowMoney != null">now_money,</if>
- <if test="brokeragePrice != null">brokerage_price,</if>
- <if test="integral != null">integral,</if>
- <if test="signNum != null">sign_num,</if>
- <if test="status != null">status,</if>
- <if test="level != null">level,</if>
- <if test="spreadUserId != null">spread_user_id,</if>
- <if test="spreadTime != null">spread_time,</if>
- <if test="userType != null and userType != ''">user_type,</if>
- <if test="isPromoter != null">is_promoter,</if>
- <if test="payCount != null">pay_count,</if>
- <if test="spreadCount != null">spread_count,</if>
- <if test="addres != null and addres != ''">addres,</if>
- <if test="maOpenId != null">ma_open_id,</if>
- <if test="mpOpenId != null">mp_open_id,</if>
- <if test="unionId != null">union_id,</if>
- <if test="isDel != null">is_del,</if>
- <if test="isWeixinAuth != null">is_weixin_auth,</if>
- <if test="companyId != null">company_id,</if>
- <if test="companyUserId != null">company_user_id,</if>
- <if test="registerDate != null">register_date,</if>
- <if test="registerCode != null">register_code,</if>
- <if test="source != null">source,</if>
- <if test="userCode != null">user_code,</if>
- <if test="isShow != null">is_show,</if>
- <if test="qwExtId != null">qw_ext_id,</if>
- <if test="isAddQw != null">is_add_qw,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="username != null">#{username},</if>
- <if test="password != null">#{password},</if>
- <if test="realName != null">#{realName},</if>
- <if test="birthday != null">#{birthday},</if>
- <if test="idCard != null">#{idCard},</if>
- <if test="remark != null">#{remark},</if>
- <if test="nickname != null">#{nickname},</if>
- <if test="avatar != null">#{avatar},</if>
- <if test="phone != null">#{phone},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="updateTime != null">#{updateTime},</if>
- <if test="lastIp != null">#{lastIp},</if>
- <if test="nowMoney != null">#{nowMoney},</if>
- <if test="brokeragePrice != null">#{brokeragePrice},</if>
- <if test="integral != null">#{integral},</if>
- <if test="signNum != null">#{signNum},</if>
- <if test="status != null">#{status},</if>
- <if test="level != null">#{level},</if>
- <if test="spreadUserId != null">#{spreadUserId},</if>
- <if test="spreadTime != null">#{spreadTime},</if>
- <if test="userType != null and userType != ''">#{userType},</if>
- <if test="isPromoter != null">#{isPromoter},</if>
- <if test="payCount != null">#{payCount},</if>
- <if test="spreadCount != null">#{spreadCount},</if>
- <if test="addres != null and addres != ''">#{addres},</if>
- <if test="maOpenId != null">#{maOpenId},</if>
- <if test="mpOpenId != null">#{mpOpenId},</if>
- <if test="unionId != null">#{unionId},</if>
- <if test="isDel != null">#{isDel},</if>
- <if test="isWeixinAuth != null">#{isWeixinAuth},</if>
- <if test="companyId != null">#{companyId},</if>
- <if test="companyUserId != null">#{companyUserId},</if>
- <if test="registerDate != null">#{registerDate},</if>
- <if test="registerCode != null">#{registerCode},</if>
- <if test="source != null">#{source},</if>
- <if test="userCode != null">#{userCode},</if>
- <if test="isShow != null">#{isShow},</if>
- <if test="qwExtId != null">#{qwExtId},</if>
- <if test="isAddQw != null">#{isAddQw},</if>
- </trim>
- </insert>
- <update id="updateFsUser" parameterType="FsUser">
- update fs_user
- <trim prefix="SET" suffixOverrides=",">
- <if test="username != null">username = #{username},</if>
- <if test="password != null">password = #{password},</if>
- <if test="realName != null">real_name = #{realName},</if>
- <if test="birthday != null">birthday = #{birthday},</if>
- <if test="idCard != null">id_card = #{idCard},</if>
- <if test="remark != null">remark = #{remark},</if>
- <if test="nickname != null">nickname = #{nickname},</if>
- <if test="avatar != null">avatar = #{avatar},</if>
- <if test="phone != null">phone = #{phone},</if>
- <if test="createTime != null">create_time = #{createTime},</if>
- <if test="updateTime != null">update_time = #{updateTime},</if>
- <if test="lastIp != null">last_ip = #{lastIp},</if>
- <if test="nowMoney != null">now_money = #{nowMoney},</if>
- <if test="brokeragePrice != null">brokerage_price = #{brokeragePrice},</if>
- <if test="integral != null">integral = #{integral},</if>
- <if test="signNum != null">sign_num = #{signNum},</if>
- <if test="status != null">status = #{status},</if>
- <if test="level != null">level = #{level},</if>
- <if test="spreadUserId != null">spread_user_id = #{spreadUserId},</if>
- <if test="spreadTime != null">spread_time = #{spreadTime},</if>
- <if test="userType != null and userType != ''">user_type = #{userType},</if>
- <if test="isPromoter != null">is_promoter = #{isPromoter},</if>
- <if test="payCount != null">pay_count = #{payCount},</if>
- <if test="spreadCount != null">spread_count = #{spreadCount},</if>
- <if test="addres != null and addres != ''">addres = #{addres},</if>
- <if test="maOpenId != null">ma_open_id = #{maOpenId},</if>
- <if test="mpOpenId != null">mp_open_id = #{mpOpenId},</if>
- <if test="unionId != null">union_id = #{unionId},</if>
- <if test="isDel != null">is_del = #{isDel},</if>
- <if test="isWeixinAuth != null">is_weixin_auth = #{isWeixinAuth},</if>
- <if test="companyId != null">company_id = #{companyId},</if>
- <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
- <if test="registerDate != null">register_date = #{registerDate},</if>
- <if test="registerCode != null">register_code = #{registerCode},</if>
- <if test="source != null">source = #{source},</if>
- <if test="userCode != null">user_code = #{userCode},</if>
- <if test="isShow != null">is_show = #{isShow},</if>
- <if test="qwExtId != null">qw_ext_id = #{qwExtId},</if>
- <if test="isAddQw != null">is_add_qw = #{isAddQw},</if>
- </trim>
- where user_id = #{userId}
- </update>
- <update id="transferCompanyUser">
- update fs_user
- set company_user_id=#{targetCompanyUserId}
- where
- user_id in
- <foreach collection="userIds" open="(" close=")" separator="," item="item">
- ${item}
- </foreach>
- </update>
- <delete id="deleteFsUserById" parameterType="Long">
- delete
- from fs_user
- where user_id = #{userId}
- </delete>
- <delete id="deleteFsUserByIds" parameterType="String">
- delete from fs_user where user_id in
- <foreach item="userId" collection="array" open="(" separator="," close=")">
- #{userId}
- </foreach>
- </delete>
- <select id="selectFsUserPageListNew" resultType="FsUserPageListVO">
- SELECT
- fs_user.*,
- fs_user_course_count.id,
- fs_user_course_count.watch_course_count,
- fs_user_course_count.miss_course_count,
- fs_user_course_count.miss_course_status,
- fs_user_course_count.course_ids,
- fs_user_course_count.part_course_count,
- fs_user_course_count.last_watch_date,
- fs_user_course_count.STATUS AS courseCountStatus,
- fs_user_course_count.stop_watch_days,
- fs_user_course_count.complete_watch_date,
- GROUP_CONCAT(DISTINCT company_tag.tag) AS tag,
- GROUP_CONCAT(DISTINCT company_tag.tag_id) AS tagIds,
- company_user.nick_name as companyUserNickName,
- if(fs_user.company_user_id = #{pcLoginUserId} or company_user.parent_id = #{pcLoginUserId}, 1, 0) as isCurrentCompanyUser
- FROM
- (SELECT
- fu.user_id
- FROM
- fs_user fu
- LEFT JOIN company_user cu ON fu.company_user_id = cu.user_id
- LEFT JOIN fs_user_course_count fucc ON fu.user_id = fucc.user_id
- LEFT JOIN company_tag_user ctu ON fu.user_id = ctu.user_id
- <where>
- <if test="userId != null and userId !='' ">
- AND (cu.user_id = #{userId} OR cu.parent_id = #{userId})
- </if>
- <if test="companyUserId != null and companyUserId !='' ">
- AND cu.user_id = #{companyUserId}
- </if>
- <!-- <choose>-->
- <!-- <when test = "isBlack">-->
- <!-- AND fu.status = 0-->
- <!-- </when>-->
- <!-- <otherwise>-->
- <!-- AND fu.status = 1-->
- <!-- </otherwise>-->
- <!-- </choose>-->
- <if test="keyword != null and keyword !='' ">
- AND (fu.nickname LIKE concat('%',#{keyword},'%')
- OR fu.phone LIKE concat('%',#{keyword},'%')
- )
- </if>
- <if test="registerStartTime != null and registerStartTime !='' ">
- AND fu.create_time >= #{registerStartTime}
- </if>
- <if test="registerEndTime != null and registerEndTime !='' ">
- AND fu.create_time <= #{registerEndTime}
- </if>
- <if test="tagIds != null and tagIds.length > 0">
- AND
- <foreach collection="tagIds" item="item" index="index" open="(" separator="or" close=")">
- ctu.tag_ids LIKE concat('%"',#{item},'"%')
- </foreach>
- </if>
- <if test="tabValue != null and tabValue !='' ">
- <choose>
- <when test = "tabValue == 1">
- AND DAY(fu.create_time) = DAY(NOW())
- </when>
- <when test = "tabValue == 2">
- AND DAY(fucc.complete_watch_date) = DAY(NOW())
- </when>
- <when test = "tabValue == 3">
- AND fucc.status = 3
- </when>
- </choose>
- </if>
- <if test="watchCourseType != null and watchCourseType !='' ">
- <choose>
- <when test = "watchCourseType == 1">
- AND fucc.status = 3
- </when>
- <when test = "watchCourseType == 2">
- AND fucc.status = 1
- </when>
- <when test = "watchCourseType == 3">
- AND fucc.status = 2
- </when>
- </choose>
- </if>
- <if test="missCourseStatus != null and missCourseStatus !='' ">
- <choose>
- <when test = "missCourseStatus == 1">
- AND fucc.miss_course_status = 1
- </when>
- <when test = "missCourseStatus == 2">
- AND fucc.miss_course_status = 2
- </when>
- </choose>
- </if>
- <if test="nickname !=null and nickname != ''">
- AND fu.nickname like concat(#{nickname},'%')
- </if>
- <if test="phone != null and phone !=''">
- AND fu.phone like concat(#{phone},'%')
- </if>
- <if test="companyId != null">
- AND fu.company_id = ${companyId}
- </if>
- </where>
- GROUP BY fu.user_id
- <if test="continueMissCourseSort != null and continueMissCourseSort !='' ">
- ORDER BY
- <choose>
- <when test = "continueMissCourseSort == 0">
- fucc.miss_course_days DESC
- </when>
- <when test = "continueMissCourseSort == 1">
- fucc.miss_course_days ASC
- </when>
- <when test = "continueMissCourseSort == 2">
- fu.create_time DESC
- </when>
- <when test = "continueMissCourseSort == 3">
- fu.nickname ASC
- </when>
- </choose>
- </if>
- LIMIT ${(pageNum-1)*pageSize},${pageSize}
- ) temp_user_ids
- JOIN fs_user ON temp_user_ids.user_id = fs_user.user_id
- LEFT JOIN company_user ON fs_user.company_user_id = company_user.user_id
- 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
- GROUP BY fs_user.user_id
- </select>
- <select id="selectFsUserPageList" resultType="FsUserPageListVO">
- SELECT
- fs_user.*,
- fs_user_course_count.id,
- fs_user_course_count.watch_course_count,
- fs_user_course_count.miss_course_count,
- fs_user_course_count.miss_course_status,
- fs_user_course_count.course_ids,
- fs_user_course_count.part_course_count,
- fs_user_course_count.last_watch_date,
- fs_user_course_count.STATUS AS courseCountStatus,
- fs_user_course_count.stop_watch_days,
- fs_user_course_count.complete_watch_date,
- GROUP_CONCAT(DISTINCT company_tag.tag) AS tag,
- GROUP_CONCAT(DISTINCT company_tag.tag_id) AS tagIds,
- company_user.nick_name as companyUserNickName
- FROM
- fs_user
- left join company_user on fs_user.company_user_id = company_user.user_id
- 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
- where fs_user.is_del = 0
- <if test="userId != null and userId !='' ">
- and (company_user.user_id = #{userId} OR company_user.parent_id = #{userId} )
- </if>
- <if test="companyUserId != null and companyUserId !='' ">
- and company_user.user_id = #{companyUserId}
- </if>
- <choose>
- <when test = "isBlack">
- AND fs_user.status = 0
- </when>
- <otherwise>
- AND fs_user.status = 1
- </otherwise>
- </choose>
- <if test="keyword != null and 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}
- </if>
- <if test="registerEndTime != null and registerEndTime !='' ">
- AND fs_user.create_time <= #{registerEndTime}
- </if>
- <if test="tagIds != null and tagIds.length > 0">
- AND
- <foreach collection="tagIds" item="item" index="index" open="(" separator="or" close=")">
- company_tag_user.tag_ids LIKE concat('%"',#{item},'"%')
- </foreach>
- </if>
- <if test="tabValue != null and tabValue !='' ">
- <choose>
- <when test = "tabValue == 1">
- AND DAY(fs_user.create_time) = DAY(NOW())
- </when>
- <when test = "tabValue == 2">
- AND DAY(fs_user_course_count.complete_watch_date) = DAY(NOW())
- </when>
- <when test = "tabValue == 3">
- AND (fs_user_course_count.status = 3 or fs_user_course_count.status is null)
- </when>
- </choose>
- </if>
- <if test="watchCourseType != null and watchCourseType !='' ">
- <choose>
- <when test = "watchCourseType == 1">
- AND (fs_user_course_count.status = 3 or fs_user_course_count.status is null)
- </when>
- <when test = "watchCourseType == 2">
- AND fs_user_course_count.status = 1
- </when>
- <when test = "watchCourseType == 3">
- AND fs_user_course_count.status = 2
- </when>
- </choose>
- </if>
- <if test="missCourseStatus != null and missCourseStatus !='' ">
- <choose>
- <when test = "missCourseStatus == 1">
- AND fs_user_course_count.miss_course_status = 1
- </when>
- <when test = "missCourseStatus == 2">
- AND (fs_user_course_count.miss_course_status = 2 or fs_user_course_count.miss_course_status is null )
- </when>
- </choose>
- </if>
- group by fs_user.user_id
- <if test="continueMissCourseSort != null and continueMissCourseSort !='' ">
- order by
- <choose>
- <when test = "continueMissCourseSort == 0">
- fs_user_course_count.miss_course_days desc
- </when>
- <when test = "continueMissCourseSort == 1">
- fs_user_course_count.miss_course_days asc
- </when>
- <when test = "continueMissCourseSort == 2">
- fs_user.create_time desc
- </when>
- <when test = "continueMissCourseSort == 3">
- fs_user.nickname asc
- </when>
- </choose>
- </if>
- </select>
- <select id="getUserNumber" resultType="UserListCountVO">
- SELECT
- fs_user.`status` as status,
- count( fs_user.user_id ) as num
- 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
- GROUP BY
- fs_user.`status`
- </select>
- <select id="getCountAnswer" resultType="UserDetailsVO">
- SELECT
- (
- SELECT
- ifnull(count( DISTINCT log_id ), 0) AS answerTime
- 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
- 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 to_days(now()) - to_days(fs_course_answer_logs.create_time) <= 1
- </when>
- <when test = "dateTag == '前天'">
- and to_days(now()) - to_days(fs_course_answer_logs.create_time) <= 2
- </when>
- <when test = "dateTag == '近七天'">
- and DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(fs_course_answer_logs.create_time)
- </when>
- </choose>
- </if>
- GROUP BY
- fs_user.user_id
- HAVING
- fs_user.user_id = #{fsUserId}
- ) AS answerTime,
- (
- SELECT
- ifnull(count( DISTINCT 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
- WHERE
- 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 to_days(now()) - to_days(fs_course_answer_logs.create_time) <= 1
- </when>
- <when test = "dateTag == '前天'">
- and to_days(now()) - to_days(fs_course_answer_logs.create_time) <= 2
- </when>
- <when test = "dateTag == '近七天'">
- and DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(fs_course_answer_logs.create_time)
- </when>
- </choose>
- </if>
- GROUP BY
- fs_user.user_id
- HAVING
- fs_user.user_id = #{fsUserId}
- ) AS answerRightTime;
- </select>
- <select id="getCountRedPacket" resultType="com.fs.store.vo.h5.UserDetailsVO">
- SELECT
- ifnull( count( DISTINCT log_id ), 0 ) AS answerRedPacketTime,
- ifnull( sum( amount ), 0 ) AS answerRedPacketAmount,
- ifnull( complete_watch_count, 0 ) AS completeWatchCount ,
- ifnull( watch_times, 0 ) AS watchTimes,
- 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_user_course_count ON fs_user_course_count.user_id = fs_user.user_id
- WHERE
- company_user.parent_id = #{userId}
- <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 to_days(now()) - to_days(fs_course_red_packet_log.create_time) <= 1
- </when>
- <when test = "dateTag == '前天'">
- and to_days(now()) - to_days(fs_course_red_packet_log.create_time) <= 2
- </when>
- <when test = "dateTag == '近七天'">
- and DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(fs_course_red_packet_log.create_time)
- </when>
- </choose>
- </if>
- GROUP BY
- fs_user.user_id
- HAVING
- fs_user.user_id = #{fsUserId}
- </select>
- <select id="getUserVipCountByCompanyUserId" resultType="java.util.Map">
- select
- 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}
- </select>
- <update id="batchUpdateFsUserByIds" parameterType="Long">
- update fs_user
- set status = #{status} where user_id in
- <foreach item="id" collection="ids" open="(" separator="," close=")">
- #{id}
- </foreach>
- </update>
- <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
- WHERE (
- company_user.user_id = #{userId}
- OR company_user.parent_id = #{userId}
- ) and fs_user.is_del = 0) 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
- AND to_days(fs_user.create_time) = to_days(now())) as todayNewUser
- </select>
- <select id="countTag" resultType="FsUserSummaryCountTagVO">
- SELECT
- company_tag.tag AS tagName,
- count( fs_user.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
- where (company_user.user_id = #{userId} or company_user.parent_id = #{userId} ) and company_tag.tag_id is not null
- GROUP BY
- company_tag.tag_id
- </select>
- <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
- 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>
- ) 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
- 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>
- ) as courseCompleteNum
- </select>
- <select id="countUserAnswer" resultType="Map">
- SELECT
- (
- SELECT
- count(distinct 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
- 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>
- ) AS answerNum,
- (
- SELECT
- count(distinct 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
- 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>
- ) AS answerRightNum
- </select>
- <select id="countUserRedPacket" resultType="Map">
- SELECT
- (
- SELECT
- count( flog.log_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
- ( 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>
- ) AS redPacketNum,
- (
- SELECT
- ifnull (sum( flog.amount ), 0)
- 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
- ( 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>
- ) AS redPacketAmount
- </select>
- <select id="countCourseDetails" resultType="Map">
- select (SELECT
- count( DISTINCT fcpd.period_id )
- FROM
- fs_user_course_period_days fcpd
- 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
- AND FIND_IN_SET(#{companyId}, fpd.company_id)
- <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}
- </if>
- ) as courseNum,
- (SELECT count(DISTINCT fcpd.video_id)
- FROM fs_user_course_period_days fcpd
- 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
- AND FIND_IN_SET(#{companyId}, fpd.company_id)
- <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 fs_user.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
- <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 fs_user.company_user_id = #{companyUserId}
- </if>
- ) as courseUserNum
- </select>
- <select id="countUserRankingByComplete" resultType="FsUserRankingVO">
- SELECT
- company_user.nick_name as userName,
- ifnull(
- ROUND((COUNT(DISTINCT CASE WHEN fcc.complete_watch_count > 0 THEN 1 END ) / count(1))*100,2),0
- ) as completeRate
- 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_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>
- group by fcc.user_id
- <choose>
- <when test="order != null and order == 'asc'">
- order by completeRate asc
- </when>
- <when test="order != null and order == 'desc'">
- order by completeRate desc
- </when>
- <otherwise>
- order by completeRate desc
- </otherwise>
- </choose>
- limit 20
- </select>
- <select id="countUserRankingByRight" resultType="FsUserRankingVO">
- SELECT
- company_user.nick_name as userName,
- ifnull(ROUND(
- (COUNT(DISTINCT CASE WHEN fs_course_answer_logs.is_right = 1 THEN 1 END ) / count(1))
- *100,2),0
- ) as answerRightRate
- 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
- ( 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>
- group by fs_user.user_id
- <choose>
- <when test="order != null and order == 'asc'">
- order by answerRightRate asc
- </when>
- <when test="order != null and order == 'desc'">
- order by answerRightRate desc
- </when>
- <otherwise>
- order by answerRightRate desc
- </otherwise>
- </choose>
- limit 20
- </select>
- <select id="countCourseRankingByComplete" resultType="FsCourseRankingVO">
- SELECT
- fcv.title AS videoName,
- ifnull(
- ROUND((
- COUNT( DISTINCT CASE WHEN fcc.complete_watch_count > 0 THEN 1 END ) / count(1))* 100,
- 2
- ),
- 0
- ) AS completeRate
- 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_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>
- GROUP BY
- fcpd.video_id
- <choose>
- <when test="order != null and order == 'asc'">
- ORDER BY completeRate asc
- </when>
- <when test="order != null and order == 'desc'">
- ORDER BY completeRate desc
- </when>
- <otherwise>
- ORDER BY completeRate desc
- </otherwise>
- </choose>
- LIMIT 20
- </select>
- <select id="countCourseRankingByRight" resultType="FsCourseRankingVO">
- SELECT
- fcv.title AS videoName,
- ifnull(
- ROUND(
- (
- COUNT( DISTINCT CASE WHEN fs_course_answer_logs.is_right = 1 THEN 1 END ) / count(1)) * 100,
- 2
- ),
- 0
- ) AS answerRightRate
- 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_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>
- GROUP BY
- fs_course_answer_logs.video_id
- <choose>
- <when test="order != null and order == 'asc'">
- ORDER BY answerRightRate asc
- </when>
- <when test="order != null and order == 'desc'">
- ORDER BY answerRightRate desc
- </when>
- <otherwise>
- ORDER BY answerRightRate desc
- </otherwise>
- </choose>
- LIMIT 20
- </select>
- <!-- 查询某用户的课程视频,看课统计 -->
- <select id="courseAnalysisCourseCount" resultType="FsCourseAnalysisCountVO">
- SELECT
- count( DISTINCT fcc.user_id ) as courseWatchNum,
- COUNT( DISTINCT CASE WHEN fcc.complete_watch_count > 0 THEN fcc.user_id END ) as courseCompleteNum,
- ifnull(
- ROUND(
- (
- COUNT( DISTINCT CASE WHEN fcc.complete_watch_count > 0 THEN fcc.user_id END ) / count( DISTINCT fcc.user_id )) * 100,
- 2
- ),
- 0
- ) as completeRate,
- fcpd.video_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
- 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>
- GROUP BY
- fcpd.video_id
- </select>
- <!-- 查询某用户的课程视频,红包统计 -->
- <select id="courseAnalysisRedPacketCount" resultType="FsCourseAnalysisCountVO">
- SELECT
- count( flog.log_id ) as redPacketNum,
- ifnull ( sum( flog.amount ), 0 ) as redPacketAmount,
- 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 !='' ">
- AND company_user.user_id = #{companyUserId}
- </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="videoIdList != null and videoIdList.size > 0 ">
- AND flog.video_id in
- <foreach collection="videoIdList" open="(" close=")" separator="," item="videoId">
- #{videoId}
- </foreach>
- </if>
- </where>
- GROUP BY
- flog.video_id
- </select>
- <!-- 查询某用户的课程视频,答题统计 -->
- <select id="courseAnalysisAnswerCount" resultType="FsCourseAnalysisCountVO">
- SELECT
- count( DISTINCT fs_user.user_id ) as answerNum,
- count(fs_course_answer_logs.log_id) answerTimes,
- COUNT( DISTINCT CASE WHEN fs_course_answer_logs.is_right = 1 THEN fs_user.user_id END ) as answerRightNum,
- COUNT( CASE WHEN fs_course_answer_logs.is_right = 1 THEN fs_course_answer_logs.log_id END ) as answerRightTimes,
- ifnull(
- ROUND(
- (
- COUNT( DISTINCT CASE WHEN fs_course_answer_logs.is_right = 1 THEN fs_user.user_id END ) / count( DISTINCT fs_user.user_id )) * 100,
- 2
- ),
- 0
- ) as answerRightRate,
- fs_course_answer_logs.video_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
- <where>
- <if test="companyUserId != null and companyUserId !='' ">
- AND company_user.user_id = #{companyUserId}
- </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>
- <if test="videoIdList != null and videoIdList.size > 0 ">
- AND fs_course_answer_logs.video_id in
- <foreach collection="videoIdList" open="(" close=")" separator="," item="videoId">
- #{videoId}
- </foreach>
- </if>
- </where>
- GROUP BY
- fs_course_answer_logs.video_id
- </select>
- <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
- WHERE company_user.user_id = #{companyUserId}
- ) 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 = #{companyUserId}
- and fs_user.is_del = 0
- AND to_days( fs_user.create_time ) = to_days(
- now())
- ) AS todayNewUser
- </select>
- <select id="newUserRedPacketCount" resultType="CompanyUserSummaryCountVO">
- SELECT
- count(flog.log_id) as userRedPacketNum,
- ifnull ( sum(case when to_days( fs_user.create_time ) = to_days(now()) THEN IFNULL(flog.amount,0) END), 0) as todayUserRedPacketAmount
- 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}
- </select>
- <select id="selectFsUserPageListCount" resultType="java.lang.Long">
- SELECT
- COUNT(DISTINCT fu.user_id) as total_count
- FROM
- fs_user fu
- LEFT JOIN fs_user_course_count fucc ON fu.user_id = fucc.user_id
- <where>
- <if test="companyId != null">
- AND fu.company_id = ${companyId}
- </if>
- <if test="phone != null and phone !=''">
- AND fu.phone like concat(#{phone},'%')
- </if>
- <if test="nickname !=null and nickname != ''">
- AND fu.nickname like concat(#{nickname},'%')
- </if>
- <if test="userId != null and userId !='' ">
- AND (cu.user_id = #{userId} OR cu.parent_id = #{userId})
- </if>
- <if test="companyUserId != null and companyUserId !='' ">
- AND cu.user_id = #{companyUserId}
- </if>
- <choose>
- <when test = "isBlack">
- AND fu.status = 0
- </when>
- <otherwise>
- AND fu.status = 1
- </otherwise>
- </choose>
- <if test="keyword != null and keyword !='' ">
- AND (fu.nickname LIKE concat(#{keyword},'%')
- OR fu.phone LIKE concat(#{keyword},'%')
- )
- </if>
- <if test="registerStartTime != null and registerStartTime !='' ">
- AND fu.create_time >= #{registerStartTime}
- </if>
- <if test="registerEndTime != null and registerEndTime !='' ">
- AND fu.create_time <= #{registerEndTime}
- </if>
- <if test="tagIds != null and tagIds.length > 0">
- AND EXISTS (
- SELECT 1 FROM company_tag_user ctu2
- WHERE fu.user_id = ctu2.user_id
- AND (
- <foreach collection="tagIds" item="item" index="index" separator="OR">
- ctu2.tag_ids LIKE concat(#{item},'"%')
- </foreach>
- )
- )
- </if>
- <if test="tabValue != null and tabValue !='' ">
- <choose>
- <when test = "tabValue == 1">
- AND DAY(fu.create_time) = DAY(NOW())
- </when>
- <when test = "tabValue == 2">
- AND DAY(fucc.complete_watch_date) = DAY(NOW())
- </when>
- <when test = "tabValue == 3">
- AND fucc.status = 3
- </when>
- </choose>
- </if>
- <if test="watchCourseType != null and watchCourseType !='' ">
- <choose>
- <when test = "watchCourseType == 1">
- AND fucc.status = 3
- </when>
- <when test = "watchCourseType == 2">
- AND fucc.status = 1
- </when>
- <when test = "watchCourseType == 3">
- AND fucc.status = 2
- </when>
- </choose>
- </if>
- <if test="missCourseStatus != null and missCourseStatus !='' ">
- <choose>
- <when test = "missCourseStatus == 1">
- AND fucc.miss_course_status = 1
- </when>
- <when test = "missCourseStatus == 2">
- AND fucc.miss_course_status = 2
- </when>
- </choose>
- </if>
- </where>
- </select>
- <select id="courseAnalysisWatchLog" resultType="FsCourseAnalysisCountVO">
- SELECT
- count( DISTINCT CASE WHEN fwl.log_type != 3 THEN fwl.user_id END ) AS courseWatchNum,
- count( CASE WHEN fwl.log_type != 3 THEN fwl.log_id END ) AS courseWatchTimes,
- count( DISTINCT CASE WHEN fwl.log_type = 2 THEN fwl.user_id END ) AS courseCompleteNum,
- count( CASE WHEN fwl.log_type = 2 THEN fwl.log_id END ) AS courseCompleteTimes,
- ifnull(
- ROUND(
- (
- COUNT( DISTINCT CASE WHEN fwl.log_type = 2 THEN fwl.user_id END ) / count( DISTINCT CASE WHEN fwl.log_type != 3 THEN fwl.user_id END )) * 100,
- 2
- ),
- 0
- ) AS completeRate,
- fwl.video_id
- FROM
- fs_course_watch_log fwl
- <where>
- <if test="periodId != null and periodId != ''">
- AND fwl.period_id = #{periodId}
- </if>
- <if test="videoId != null and videoId != ''">
- AND fwl.video_id = #{videoId}
- </if>
- <if test="videoIdList != null and videoIdList.size > 0 ">
- AND fwl.video_id in
- <foreach collection="videoIdList" open="(" close=")" separator="," item="videoId">
- #{videoId}
- </foreach>
- </if>
- </where>
- GROUP BY
- fwl.video_id
- </select>
- <update id="batchUpdateUserCompanyUser">
- update fs_user
- set company_id = #{companyId},
- company_user_id = #{companyUserId}
- where
- <foreach collection="userIds" separator="or" item="userId" index="index">
- user_id = #{userId}
- </foreach>
- </update>
- <select id="selectUserListByMap" resultType="com.fs.his.vo.OptionsVO">
- select
- u.user_id dictValue,
- u.nickname dictLabel
- from fs_user u
- <where>
- <if test="params.nickName != null and params.nickName != ''">
- u.nickname like concat('%', #{params.nickName}, '%')
- </if>
- </where>
- </select>
- </mapper>
|