| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944 |
- <?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.course.mapper.FsCourseWatchLogMapper">
- <resultMap type="FsCourseWatchLog" id="FsCourseWatchLogResult">
- <result property="logId" column="log_id" />
- <result property="userId" column="user_id" />
- <result property="videoId" column="video_id" />
- <result property="logType" column="log_type" />
- <result property="createTime" column="create_time" />
- <result property="updateTime" column="update_time" />
- <result property="qwExternalContactId" column="qw_external_contact_id" />
- <result property="duration" column="duration" />
- <result property="qwUserId" column="qw_user_id" />
- <result property="companyUserId" column="company_user_id" />
- <result property="companyId" column="company_id" />
- <result property="courseId" column="course_id" />
- <result property="sendType" column="send_type" />
- <result property="rewardType" column="reward_type" />
- <result property="sopId" column="sop_id" />
- <result property="finishTime" column="finish_time" />
- <result property="sendFinishMsg" column="send_finish_msg" />
- <result property="campPeriodTime" column="camp_period_time" />
- <result property="lastHeartbeatTime" column="last_heartbeat_time" />
- <result property="project" column="project" />
- <result property="periodId" column="period_id" />
- </resultMap>
- <sql id="selectFsCourseWatchLogVo">
- select log_id, user_id,finish_time,send_finish_msg,sop_id,video_id,reward_type, log_type, create_time, update_time, qw_external_contact_id, duration, qw_user_id, company_user_id, company_id, course_id,camp_period_time,project,period_id from fs_course_watch_log
- </sql>
- <select id="selectFsCourseWatchLogList" parameterType="FsCourseWatchLog" resultMap="FsCourseWatchLogResult">
- <include refid="selectFsCourseWatchLogVo"/>
- <where>
- <if test="userId != null "> and user_id = #{userId}</if>
- <if test="videoId != null "> and video_id = #{videoId}</if>
- <if test="logType != null "> and log_type = #{logType}</if>
- <if test="qwExternalContactId != null "> and qw_external_contact_id = #{qwExternalContactId}</if>
- <if test="duration != null "> and duration = #{duration}</if>
- <if test="qwUserId != null and qwUserId != ''"> and qw_user_id = #{qwUserId}</if>
- <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
- <if test="companyId != null "> and company_id = #{companyId}</if>
- <if test="courseId != null "> and course_id = #{courseId}</if>
- <if test="sendType != null "> and send_type = #{sendType}</if>
- <if test="campPeriodTime != null "> and camp_period_time = #{campPeriodTime}</if>
- <if test="project != null "> and project = #{project}</if>
- </where>
- </select>
- <select id="selectFsCourseWatchLogByLogId" parameterType="Long" resultMap="FsCourseWatchLogResult">
- <include refid="selectFsCourseWatchLogVo"/>
- where log_id = #{logId}
- </select>
- <select id="selectFsCourseWatchLogListVO" resultType="com.fs.course.vo.FsCourseWatchLogListVO">
- select l.log_id,l.project,l.period_id,l.user_id,uc.course_name,v.title as video_name,qec.avatar as external_user_avatar,
- l.log_type,SEC_TO_TIME(l.duration) as duration,c.company_name,l.camp_period_time,l.finish_time,
- cu.nick_name as company_user_name ,l.send_type,l.create_time,l.update_time,l.last_heartbeat_time,
- qu.qw_user_name,qec.name as external_user_name,c.company_id,u.avatar as fsAvatar,u.nick_name as fsNickName,qec.create_time as qec_create_time,
- u.is_vip isVip,l.reward_type
- from fs_course_watch_log l
- left join fs_user_course_video v on v.video_id = l.video_id
- left join fs_user_course uc on uc.course_id = l.course_id
- left join fs_user u on u.user_id = l.user_id
- left join company_user cu on cu.user_id = l.company_user_id
- left join company c on c.company_id = l.company_id
- LEFT JOIN qw_user qu on qu.id= l.qw_user_id
- LEFT JOIN qw_external_contact qec on l.qw_external_contact_id = qec.id
- <where>
- <if test ='maps.isVip != null and maps.isVip == 0'>
- and (l.user_id = 0 or l.user_id is null)
- </if>
- <if test ='maps.isVip != null and maps.isVip == 1'>
- and l.user_id != 0 and l.user_id is not null
- </if>
- <if test ='maps.sendType !=null'>
- and l.send_type = #{maps.sendType}
- </if>
- <if test ='maps.userId !=null'>
- and l.user_id = #{maps.userId}
- </if>
- <if test ='maps.project !=null'>
- and l.project = #{maps.project}
- </if>
- <if test ='maps.qwExternalContactId !=null'>
- and l.qw_external_contact_id = #{maps.qwExternalContactId}
- </if>
- <if test ='maps.qwUserId !=null'>
- and l.qw_user_id = #{maps.qwUserId}
- </if>
- <if test ='maps.courseId !=null'>
- and l.course_id = #{maps.courseId}
- </if>
- <if test ='maps.videoId !=null'>
- and l.video_id = #{maps.videoId}
- </if>
- <if test ='maps.logType !=null'>
- and l.log_type = #{maps.logType}
- </if>
- <if test ='maps.companyId !=null'>
- and l.company_id = #{maps.companyId}
- </if>
- <if test ='maps.companyUserId !=null'>
- and l.company_user_id = #{maps.companyUserId}
- </if>
- <if test ='maps.companyUserName !=null and maps.companyUserName!=""'>
- and cu.nick_name like concat('%', #{maps.companyUserName}, '%')
- </if>
- <if test ='maps.nickName !=null and maps.nickName!=""'>
- and u.nick_name like concat('%', #{maps.nickName}, '%')
- </if>
- <if test ='maps.externalUserName !=null and maps.externalUserName!=""'>
- and qec.name like concat('%', #{maps.externalUserName}, '%')
- </if>
- <if test= 'maps.qecSTime != null '>
- and DATE(qec.create_time) >= DATE(#{maps.qecSTime})
- </if>
- <if test='maps.qecETime != null '>
- and DATE(qec.create_time) <= DATE(#{maps.qecETime})
- </if>
- <if test= 'maps.sTime != null '>
- and l.create_time >= #{maps.sTime}
- </if>
- <if test='maps.eTime != null '>
- and l.create_time <= #{maps.eTime}
- </if>
- <if test= 'maps.scheduleStartTime != null '>
- and l.camp_period_time >= #{maps.scheduleStartTime}
- </if>
- <if test='maps.scheduleEndTime != null '>
- and l.camp_period_time <= #{maps.scheduleEndTime}
- </if>
- <if test= 'maps.upSTime != null '>
- and l.update_time >= #{maps.upSTime}
- </if>
- <if test='maps.upETime != null '>
- and l.update_time <= #{maps.upETime}
- </if>
- <if test="maps.sopIds != null and maps.sopIds.size() > 0">
- and l.sop_id in
- <foreach item="sopId" index="index" collection="maps.sopIds" open="(" separator="," close=")">
- #{sopId}
- </foreach>
- </if>
- <if test ='maps.project !=null'>
- and l.project = #{maps.project}
- </if>
- <if test="maps.sopId != null and maps.sopId != '' ">
- and l.sop_id = #{maps.sopId}
- </if>
- <if test="maps.periodIds != null and maps.periodIds.size() > 0">
- and l.period_id in
- <foreach item="periodId" index="index" collection="maps.periodIds" open="(" separator="," close=")">
- #{periodId}
- </foreach>
- </if>
- <if test="maps.qwUserName != null and maps.qwUserName != '' ">
- and qu.qw_user_name = #{maps.qwUserName}
- </if>
- <if test='maps.cuDeptIdList != null and !maps.cuDeptIdList.isEmpty() and maps.userType != "00" '>
- AND cu.dept_id IN
- <foreach collection='maps.cuDeptIdList' item='item' open='(' separator=',' close=')'>
- #{item}
- </foreach>
- </if>
- </where>
- order by l.finish_time desc,l.update_time desc,l.create_time desc
- </select>
- <select id="selectFsCourseWatchLogListByParam" resultType="com.fs.course.vo.FsCourseWatchLogListVO">
- select l.log_id,l.user_id,uc.course_name,v.title as video_name,u.nick_name as fsNickName, u.avatar as fsAvatar,
- l.log_type,SEC_TO_TIME(l.duration) as duration,c.company_name,l.camp_period_time,l.finish_time,
- cu.nick_name as company_user_name ,l.send_type,l.create_time, qu.qw_user_name,qec.name as external_user_name
- from fs_course_watch_log l
- left join fs_user_course_video v on v.video_id = l.video_id
- left join fs_user_course uc on uc.course_id = l.course_id
- left join fs_user u on u.user_id = l.user_id
- left join company_user cu on cu.user_id = l.company_user_id
- left join company c on c.company_id = l.company_id
- LEFT JOIN qw_user qu on qu.id= l.qw_user_id
- LEFT JOIN qw_external_contact qec on l.qw_external_contact_id = qec.id
- <where>
- <if test ='userId !=null'>
- and l.user_id = #{userId}
- </if>
- <if test ='qwUserId !=null'>
- and l.qw_user_id = #{qwUserId}
- </if>
- <if test ='courseId !=null'>
- and l.course_id = #{courseId}
- </if>
- <if test ='videoId !=null'>
- and l.video_id = #{videoId}
- </if>
- <if test ='logType !=null'>
- and l.log_type = #{logType}
- </if>
- <if test ='companyId !=null'>
- and l.company_id = #{companyId}
- </if>
- <if test ='companyUserId !=null'>
- and l.company_user_id = #{companyUserId}
- </if>
- <if test ='companyUserName !=null and maps.companyUserName!=""'>
- and cu.nick_name like concat('%', #{companyUserName}, '%')
- </if>
- <if test ='nickName !=null and maps.nickName!=""'>
- and u.nick_name like concat('%', #{nickName}, '%')
- </if>
- <if test= 'sTime != null '>
- and DATE(l.create_time) >= DATE(#{sTime})
- </if>
- <if test='eTime != null '>
- and DATE(l.create_time) <= DATE(#{eTime})
- </if>
- <if test= 'maps.scheduleStartTime != null '>
- and DATE(l.camp_period_time) >= DATE(#{maps.scheduleStartTime})
- </if>
- <if test='maps.scheduleEndTime != null '>
- and DATE(l.camp_period_time) <= DATE(#{maps.scheduleEndTime})
- </if>
- <if test="sopIds != null and sopIds.size() > 0">
- and l.sop_id in
- <foreach item="sopId" index="index" collection="sopIds" open="(" separator="," close=")">
- #{sopId}
- </foreach>
- </if>
- </where>
- order by l.log_id desc
- </select>
- <insert id="insertFsCourseWatchLog" parameterType="FsCourseWatchLog" useGeneratedKeys="true" keyProperty="logId">
- insert into fs_course_watch_log
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="userId != null">user_id,</if>
- <if test="videoId != null">video_id,</if>
- <if test="logType != null">log_type,</if>
- <if test="createTime != null">create_time,</if>
- <if test="updateTime != null">update_time,</if>
- <if test="qwExternalContactId != null">qw_external_contact_id,</if>
- <if test="duration != null">duration,</if>
- <if test="qwUserId != null">qw_user_id,</if>
- <if test="companyUserId != null">company_user_id,</if>
- <if test="companyId != null">company_id,</if>
- <if test="courseId != null">course_id,</if>
- <if test="sendType != null">send_type,</if>
- <if test="rewardType != null">reward_type,</if>
- <if test="sopId != null">sop_id,</if>
- <if test="finishTime != null">finish_time,</if>
- <if test="sendFinishMsg != null">send_finish_msg,</if>
- <if test="campPeriodTime != null">camp_period_time,</if>
- <if test="periodId != null">period_id,</if>
- <if test="project != null">project,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="userId != null">#{userId},</if>
- <if test="videoId != null">#{videoId},</if>
- <if test="logType != null">#{logType},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="updateTime != null">#{updateTime},</if>
- <if test="qwExternalContactId != null">#{qwExternalContactId},</if>
- <if test="duration != null">#{duration},</if>
- <if test="qwUserId != null">#{qwUserId},</if>
- <if test="companyUserId != null">#{companyUserId},</if>
- <if test="companyId != null">#{companyId},</if>
- <if test="courseId != null">#{courseId},</if>
- <if test="sendType != null">#{sendType},</if>
- <if test="rewardType != null">#{rewardType},</if>
- <if test="sopId != null">#{sopId},</if>
- <if test="finishTime != null">#{finishTime},</if>
- <if test="sendFinishMsg != null">#{sendFinishMsg},</if>
- <if test="campPeriodTime != null">#{campPeriodTime},</if>
- <if test="periodId != null">#{periodId},</if>
- <if test="project != null">#{project},</if>
- </trim>
- </insert>
- <insert id="insertOrUpdateFsCourseWatchLog" parameterType="FsCourseWatchLog">
- insert into fs_course_watch_log
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="userId != null">user_id,</if>
- <if test="videoId != null">video_id,</if>
- <if test="logType != null">log_type,</if>
- <if test="createTime != null">create_time,</if>
- <if test="updateTime != null">update_time,</if>
- <if test="qwExternalContactId != null">qw_external_contact_id,</if>
- <if test="duration != null">duration,</if>
- <if test="qwUserId != null">qw_user_id,</if>
- <if test="companyUserId != null">company_user_id,</if>
- <if test="companyId != null">company_id,</if>
- <if test="courseId != null">course_id,</if>
- <if test="sendType != null">send_type,</if>
- <if test="rewardType != null">reward_type,</if>
- <if test="sopId != null">sop_id,</if>
- <if test="finishTime != null">finish_time,</if>
- <if test="sendFinishMsg != null">send_finish_msg,</if>
- <if test="campPeriodTime != null">camp_period_time,</if>
- <if test="project != null">project,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="userId != null">#{userId},</if>
- <if test="videoId != null">#{videoId},</if>
- <if test="logType != null">#{logType},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="updateTime != null">#{updateTime},</if>
- <if test="qwExternalContactId != null">#{qwExternalContactId},</if>
- <if test="duration != null">#{duration},</if>
- <if test="qwUserId != null">#{qwUserId},</if>
- <if test="companyUserId != null">#{companyUserId},</if>
- <if test="companyId != null">#{companyId},</if>
- <if test="courseId != null">#{courseId},</if>
- <if test="sendType != null">#{sendType},</if>
- <if test="rewardType != null">#{rewardType},</if>
- <if test="sopId != null">#{sopId},</if>
- <if test="finishTime != null">#{finishTime},</if>
- <if test="sendFinishMsg != null">#{sendFinishMsg},</if>
- <if test="campPeriodTime != null">#{campPeriodTime},</if>
- <if test="project != null">#{project},</if>
- </trim>
- on duplicate key update
- <trim suffixOverrides=",">
- <if test="updateTime != null">update_time = #{updateTime},</if>
- </trim>
- </insert>
- <insert id="insertFsCourseWatchLogBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="logId">
- INSERT INTO fs_course_watch_log (
- user_id,
- video_id,
- log_type,
- create_time,
- update_time,
- qw_external_contact_id,
- duration,
- qw_user_id,
- company_user_id,
- company_id,
- course_id,
- send_type,
- reward_type,
- sop_id,
- camp_period_time,
- project,
- period_id,
- im_msg_send_detail_id
- )
- VALUES
- <foreach collection="watchLogs" item="log" separator=",">
- (
- #{log.userId},
- #{log.videoId},
- #{log.logType},
- #{log.createTime},
- #{log.updateTime},
- #{log.qwExternalContactId},
- #{log.duration},
- #{log.qwUserId},
- #{log.companyUserId},
- #{log.companyId},
- #{log.courseId},
- #{log.sendType},
- #{log.rewardType},
- #{log.sopId},
- #{log.campPeriodTime},
- #{log.project},
- #{log.periodId},
- #{log.imMsgSendDetailId}
- )
- </foreach>
- ON DUPLICATE KEY UPDATE
- update_time = NOW(),
- im_msg_send_detail_id = VALUES(im_msg_send_detail_id)
- </insert>
- <update id="updateFsCourseWatchLog" parameterType="FsCourseWatchLog">
- update fs_course_watch_log
- <trim prefix="SET" suffixOverrides=",">
- <if test="userId != null">user_id = #{userId},</if>
- <if test="videoId != null">video_id = #{videoId},</if>
- <if test="logType != null">log_type = #{logType},</if>
- <if test="createTime != null">create_time = #{createTime},</if>
- <if test="updateTime != null">update_time = #{updateTime},</if>
- <if test="qwExternalContactId != null">qw_external_contact_id = #{qwExternalContactId},</if>
- <if test="duration != null">duration = #{duration},</if>
- <if test="qwUserId != null">qw_user_id = #{qwUserId},</if>
- <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
- <if test="companyId != null">company_id = #{companyId},</if>
- <if test="courseId != null">course_id = #{courseId},</if>
- <if test="sendType != null">send_type = #{sendType},</if>
- <if test="rewardType != null">reward_type = #{rewardType},</if>
- <if test="sopId != null">sop_id = #{sopId},</if>
- <if test="finishTime != null">finish_time = #{finishTime},</if>
- <if test="sendFinishMsg != null">send_finish_msg = #{sendFinishMsg},</if>
- <if test="lastHeartbeatTime != null">last_heartbeat_time = #{lastHeartbeatTime},</if>
- <if test="periodId != null">period_id = #{periodId},</if>
- <if test="project != null">project = #{project},</if>
- </trim>
- where log_id = #{logId}
- </update>
- <delete id="deleteFsCourseWatchLogByLogId" parameterType="Long">
- delete from fs_course_watch_log where log_id = #{logId}
- </delete>
- <delete id="deleteFsCourseWatchLogByLogIds" parameterType="String">
- delete from fs_course_watch_log where log_id in
- <foreach item="logId" collection="array" open="(" separator="," close=")">
- #{logId}
- </foreach>
- </delete>
- <select id="selectFsCourseWatchLogByFinishTime" resultType="com.fs.course.param.FsCourseWatchLogByFinishTimeParam">
- <![CDATA[
- SELECT
- fcwl.log_id,
- fcwl.create_time,
- fcwl.qw_external_contact_id,
- fcwl.qw_user_id,
- fcwl.user_id,
- fcwl.company_user_id,
- fcwl.company_id,
- fcwl.sop_id,
- fcwl.finish_time,
- fcwl.camp_period_time,
- qec.corp_id,
- qec.external_user_id,
- qec.tag_ids,
- qec.user_id AS qw_user,
- qec.name AS external_contact_name
- FROM
- fs_course_watch_log fcwl
- LEFT JOIN qw_external_contact qec ON fcwl.qw_external_contact_id = qec.id
- WHERE
- DATE(fcwl.finish_time)= '2025-02-09'
- and fcwl.camp_period_time is not NULL
- ]]>
- </select>
- <select id="getWatchLogByFsUser" resultType="com.fs.course.domain.FsCourseWatchLog">
- SELECT
- log_id,
- user_id,
- video_id,
- log_type,
- create_time,
- update_time,
- duration,
- company_user_id,
- company_id,
- course_id,
- send_type,
- reward_type,
- last_heartbeat_time,
- sop_id,
- finish_time,
- send_finish_msg,
- camp_period_time
- FROM
- fs_course_watch_log
- WHERE
- send_type = 1
- AND video_id = #{videoId}
- AND user_id = #{fsUserId}
- AND company_user_id = #{companyUserId} order by log_id desc limit 1
- </select>
- <select id="selectFsCourseWatchLogStatisticsListVONew"
- resultType="com.fs.course.vo.FsCourseWatchLogStatisticsListVO">
- SELECT
- o.company_user_id,o.user_id,DATE(o.create_time) create_time,
- SUM(CASE WHEN o.log_type = '1' THEN 1 ELSE 0 END) AS type1,
- SUM(CASE WHEN o.log_type = '2' THEN 1 ELSE 0 END) AS type2,
- SUM(CASE WHEN o.log_type = '3' THEN 1 ELSE 0 END) AS type3,
- SUM(CASE WHEN o.log_type = '4' THEN 1 ELSE 0 END) AS type4,
- o.project as project,
- o.course_id as course_id,
- o.video_id as video_id
- FROM fs_course_watch_log o
- <where>
- send_type=1
- <if test="companyId != null">
- and o.company_id=#{companyId}
- </if>
- <if test= 'sTime != null '>
- and DATE(o.create_time) >= #{sTime}
- </if>
- <if test='eTime != null '>
- and DATE(o.create_time) <= #{eTime}
- </if>
- <if test ='courseId !=null'>
- and o.course_id = #{courseId}
- </if>
- <if test ='videoId !=null'>
- and o.video_id = #{videoId}
- </if>
- <if test="companyUserId != null">
- and o.company_user_id = #{companyUserId}
- </if>
- <if test="project != null">
- and o.project = #{project}
- </if>
- <if test="userId != null">
- and o.user_id = #{userId}
- </if>
- </where>
- GROUP BY o.video_id,o.user_id,DATE(o.create_time),o.project,o.course_id
- ORDER BY o.video_id ,DATE(o.create_time)
- <!-- limit ${(pageNum-1)*pageSize},${pageSize}-->
- </select>
- <select id="selectFsCourseWatchLogStatisticsListVONewCount" resultType="java.lang.Long">
- SELECT COUNT(*)
- FROM (
- SELECT 1
- FROM fs_course_watch_log o
- <where>
- send_type=2
- <if test="companyId != null">
- and o.company_id=#{companyId}
- </if>
- <if test= 'sTime != null '>
- and o.create_time >= #{startDate}
- </if>
- <if test='eTime != null '>
- and o.create_time <= #{endDate}
- </if>
- <if test ='courseId !=null'>
- and o.course_id = #{courseId}
- </if>
- <if test ='videoId !=null'>
- and o.video_id = #{videoId}
- </if>
- <if test="companyUserId != null">
- and o.company_user_id = #{companyUserId}
- </if>
- <if test="project != null">
- and o.project = #{project}
- </if>
- <if test="userId != null">
- and o.user_id = #{userId}
- </if>
- </where>
- GROUP BY o.video_id, o.user_id, DATE(o.create_time), o.project, o.course_id
- ) AS grouped_results_count
- </select>
- <!-- 根据条件查询条数 -->
- <select id="countByMap" resultType="java.lang.Integer">
- select count(fcwl.log_id) from fs_course_watch_log fcwl
- <where>
- <if test="params.logTypes != null and params.logTypes.size() > 0">
- and fcwl.log_type in
- <foreach collection="params.logTypes" open="(" close=")" separator="," item="logType">
- #{logType}
- </foreach>
- </if>
- <if test="params.companyUserId != null">
- and fcwl.company_user_id = #{params.companyUserId}
- </if>
- <if test="params.date != null">
- and date(fcwl.create_time) = #{params.date}
- </if>
- </where>
- </select>
- <update id="batchUpdateWatchLog" parameterType="java.util.List">
- UPDATE fs_course_watch_log
- SET
- duration = CASE
- <foreach collection="list" item="item" index="index">
- WHEN video_id = #{item.videoId} AND qw_external_contact_id = #{item.qwExternalContactId} AND qw_user_id = #{item.qwUserId} THEN
- CASE
- <!-- 仅当传入的duration > 当前值时才更新 -->
- WHEN #{item.duration} IS NOT NULL AND #{item.duration} > duration THEN #{item.duration}
- ELSE duration <!-- 如果 duration 为 null,保持原值 -->
- END
- </foreach>
- END,
- last_heartbeat_time = CASE
- <foreach collection="list" item="item" index="index">
- WHEN video_id = #{item.videoId} AND qw_external_contact_id = #{item.qwExternalContactId} AND qw_user_id = #{item.qwUserId} THEN
- CASE
- WHEN #{item.lastHeartbeatTime} IS NOT NULL THEN #{item.lastHeartbeatTime}
- ELSE last_heartbeat_time <!-- 如果 last_heartbeat_time 为 null,保持原值 -->
- END
- </foreach>
- END,
- finish_time = CASE
- <foreach collection="list" item="item" index="index">
- WHEN video_id = #{item.videoId} AND qw_external_contact_id = #{item.qwExternalContactId} AND qw_user_id = #{item.qwUserId} THEN
- CASE
- WHEN finish_time IS NULL THEN #{item.finishTime} <!-- 如果表中 finish_time 为 null,更新为传入的值 -->
- ELSE finish_time <!-- 如果表中 finish_time 不为 null,保持原值 -->
- END
- </foreach>
- END,
- log_type = CASE
- <foreach collection="list" item="item" index="index">
- WHEN video_id = #{item.videoId} AND qw_external_contact_id = #{item.qwExternalContactId} AND qw_user_id = #{item.qwUserId} THEN
- CASE
- WHEN log_type = 2 THEN log_type <!-- 如果 log_type 已经是 2,保持原值 -->
- WHEN #{item.logType} IS NOT NULL AND log_type != 2 THEN #{item.logType} <!-- 如果 log_type 不是 2,更新为传入的值 -->
- ELSE log_type <!-- 其他情况保持原值 -->
- END
- </foreach>
- END
- WHERE
- (video_id, qw_external_contact_id, qw_user_id) IN
- <foreach collection="list" item="item" index="index" open="(" separator="," close=")">
- (#{item.videoId}, #{item.qwExternalContactId}, #{item.qwUserId})
- </foreach>
- </update>
- <update id="batchUpdateWatchLogSendMsg" parameterType="java.util.List">
- UPDATE fs_course_watch_log
- SET send_finish_msg = CASE
- <foreach collection="list" item="item">
- WHEN log_id = #{item.logId} THEN #{item.sendFinishMsg}
- </foreach>
- ELSE send_finish_msg
- END
- WHERE log_id IN
- <foreach collection="list" item="item" open="(" separator="," close=")">
- #{item.logId}
- </foreach>
- </update>
- <update id="batchUpdateFsUserWatchLog" parameterType="java.util.List">
- UPDATE fs_course_watch_log
- SET
- duration = CASE
- <foreach collection="list" item="item" index="index">
- WHEN video_id = #{item.videoId} AND user_id = #{item.userId} AND company_user_id = #{item.companyUserId} THEN
- CASE
- <!-- 仅当传入的duration > 当前值时才更新 -->
- WHEN #{item.duration} IS NOT NULL AND #{item.duration} > duration THEN #{item.duration}
- ELSE duration <!-- 如果 duration 为 null,保持原值 -->
- END
- </foreach>
- END,
- last_heartbeat_time = CASE
- <foreach collection="list" item="item" index="index">
- WHEN video_id = #{item.videoId} AND user_id = #{item.userId} AND company_user_id = #{item.companyUserId} THEN
- CASE
- WHEN #{item.lastHeartbeatTime} IS NOT NULL THEN #{item.lastHeartbeatTime}
- ELSE last_heartbeat_time <!-- 如果 last_heartbeat_time 为 null,保持原值 -->
- END
- </foreach>
- END,
- finish_time = CASE
- <foreach collection="list" item="item" index="index">
- WHEN video_id = #{item.videoId} AND user_id = #{item.userId} AND company_user_id = #{item.companyUserId} THEN
- CASE
- WHEN finish_time IS NULL THEN #{item.finishTime} <!-- 如果表中 finish_time 为 null,更新为传入的值 -->
- ELSE finish_time <!-- 如果表中 finish_time 不为 null,保持原值 -->
- END
- </foreach>
- END,
- log_type = CASE
- <foreach collection="list" item="item" index="index">
- WHEN video_id = #{item.videoId} AND user_id = #{item.userId} AND company_user_id = #{item.companyUserId} THEN
- CASE
- WHEN log_type = 2 THEN log_type <!-- 如果 log_type 已经是 2,保持原值 -->
- WHEN #{item.logType} IS NOT NULL AND log_type != 2 THEN #{item.logType} <!-- 如果 log_type 不是 2,更新为传入的值 -->
- ELSE log_type <!-- 其他情况保持原值 -->
- END
- </foreach>
- END
- WHERE
- (video_id, user_id, company_user_id) IN
- <foreach collection="list" item="item" index="index" open="(" separator="," close=")">
- (#{item.videoId}, #{item.userId}, #{item.companyUserId})
- </foreach>
- </update>
- <update id="batchUpdateWatchLogIsOpen">
- UPDATE fs_course_watch_log
- SET
- duration = CASE
- <foreach collection="list" item="item" index="index">
- WHEN video_id = #{item.videoId} AND user_id = #{item.userId} THEN
- CASE
- <!-- 仅当传入的duration > 当前值时才更新 -->
- WHEN #{item.duration} IS NOT NULL AND #{item.duration} > duration THEN #{item.duration}
- ELSE duration <!-- 如果 duration 为 null,保持原值 -->
- END
- </foreach>
- END,
- last_heartbeat_time = CASE
- <foreach collection="list" item="item" index="index">
- WHEN video_id = #{item.videoId} AND user_id = #{item.userId} THEN
- CASE
- WHEN #{item.lastHeartbeatTime} IS NOT NULL THEN #{item.lastHeartbeatTime}
- ELSE last_heartbeat_time <!-- 如果 last_heartbeat_time 为 null,保持原值 -->
- END
- </foreach>
- END,
- finish_time = CASE
- <foreach collection="list" item="item" index="index">
- WHEN video_id = #{item.videoId} AND user_id = #{item.userId} THEN
- CASE
- WHEN finish_time IS NULL THEN #{item.finishTime} <!-- 如果表中 finish_time 为 null,更新为传入的值 -->
- ELSE finish_time <!-- 如果表中 finish_time 不为 null,保持原值 -->
- END
- </foreach>
- END,
- log_type = CASE
- <foreach collection="list" item="item" index="index">
- WHEN video_id = #{item.videoId} AND user_id = #{item.userId} THEN
- CASE
- WHEN log_type = 2 THEN log_type <!-- 如果 log_type 已经是 2,保持原值 -->
- WHEN #{item.logType} IS NOT NULL AND log_type != 2 THEN #{item.logType} <!-- 如果 log_type 不是 2,更新为传入的值 -->
- ELSE log_type <!-- 其他情况保持原值 -->
- END
- </foreach>
- END
- WHERE
- (video_id, user_id) IN
- <foreach collection="list" item="item" index="index" open="(" separator="," close=")">
- (#{item.videoId}, #{item.userId})
- </foreach>
- </update>
- <select id="selectListBytrainingCampId" resultType="com.fs.course.vo.FsCourseWatchLogVO">
- select
- uc.course_name,v.title as video_name,
- watch.log_id,
- watch.user_id,
- watch.finish_time,
- watch.send_finish_msg,
- watch.sop_id,
- watch.video_id,
- watch.reward_type,
- watch.log_type,
- watch.create_time,
- watch.update_time,
- watch.qw_external_contact_id,
- watch.duration,
- watch.qw_user_id,
- watch.company_user_id,
- watch.company_id,
- watch.course_id,
- watch.camp_period_time
- from
- fs_user_course_training_camp camp
- left join fs_user_course_period period on
- camp.training_camp_id = period.training_camp_id
- left join fs_course_watch_log watch on
- period.period_id = watch.period_id
- left join fs_user_course uc on uc.course_id = watch.course_id
- left join fs_user_course_video v on v.video_id = watch.video_id
- <where>
- `period`.del_flag = '0' and watch.log_type <> 3
- <if test="trainingCampId != null">and camp.training_camp_id = #{trainingCampId}</if>
- <if test="userId != null">and watch.user_id = #{userId}</if>
- <if test="periodId != null">and `period`.period_id = #{periodId}</if>
- </where>
- </select>
- <select id="selectFsCourseWatchLogListVOexport" resultType="com.fs.course.vo.FsCourseWatchLogListVO">
- SELECT
- l.log_id,
- l.project AS project,
- l.period_id,
- l.user_id,
- l.log_type,
- SEC_TO_TIME(l.duration) AS duration,
- l.camp_period_time,
- l.finish_time,
- l.send_type,
- l.create_time,
- l.update_time,
- l.last_heartbeat_time,
- l.company_id,
- l.company_user_id,
- l.course_id,
- l.video_id,
- l.qw_user_id,
- l.qw_external_contact_id,
- l.sop_id,
- qec.create_time as qec_create_time
- FROM
- fs_course_watch_log l LEFT JOIN qw_external_contact qec on l.qw_external_contact_id = qec.id
- left join fs_user u on u.user_id = l.user_id
- left join company_user cu on cu.user_id = l.company_user_id
- <where>
- <if test ='maps.sendType !=null'>
- and l.send_type = #{maps.sendType}
- </if>
- <if test ='maps.userId !=null'>
- and l.user_id = #{maps.userId}
- </if>
- <if test ='maps.qwExternalContactId !=null'>
- and l.qw_external_contact_id = #{maps.qwExternalContactId}
- </if>
- <if test ='maps.qwUserId !=null'>
- and l.qw_user_id = #{maps.qwUserId}
- </if>
- <if test ='maps.courseId !=null'>
- and l.course_id = #{maps.courseId}
- </if>
- <if test ='maps.videoId !=null'>
- and l.video_id = #{maps.videoId}
- </if>
- <if test ='maps.logType !=null'>
- and l.log_type = #{maps.logType}
- </if>
- <if test ='maps.companyId !=null'>
- and l.company_id = #{maps.companyId}
- </if>
- <if test ='maps.companyUserId !=null'>
- and l.company_user_id = #{maps.companyUserId}
- </if>
- <if test ='maps.companyUserName !=null and maps.companyUserName!=""'>
- and cu.nick_name like concat('%', #{maps.companyUserName}, '%')
- </if>
- <if test ='maps.nickName !=null and maps.nickName!=""'>
- and u.nick_name like concat('%', #{maps.nickName}, '%')
- </if>
- <if test ='maps.externalUserName !=null and maps.externalUserName!=""'>
- and qec.name like concat('%', #{maps.externalUserName}, '%')
- </if>
- <if test= 'maps.qecSTime != null '>
- and DATE(qec.create_time) >= DATE(#{maps.qecSTime})
- </if>
- <if test='maps.qecETime != null '>
- and DATE(qec.create_time) <= DATE(#{maps.qecETime})
- </if>
- <if test= 'maps.sTime != null '>
- and DATE(l.create_time) >= DATE(#{maps.sTime})
- </if>
- <if test='maps.eTime != null '>
- and DATE(l.create_time) <= DATE(#{maps.eTime})
- </if>
- <if test= 'maps.scheduleStartTime != null '>
- and DATE(l.camp_period_time) >= DATE(#{maps.scheduleStartTime})
- </if>
- <if test='maps.scheduleEndTime != null '>
- and DATE(l.camp_period_time) <= DATE(#{maps.scheduleEndTime})
- </if>
- <if test= 'maps.upSTime != null '>
- and DATE(l.update_time) >= DATE(#{maps.upSTime})
- </if>
- <if test='maps.upETime != null '>
- and DATE(l.update_time) <= DATE(#{maps.upETime})
- </if>
- <if test="maps.sopIds != null and maps.sopIds.size() > 0">
- and l.sop_id in
- <foreach item="sopId" index="index" collection="maps.sopIds" open="(" separator="," close=")">
- #{sopId}
- </foreach>
- </if>
- <if test="maps.periodIds != null and maps.periodIds.size() > 0">
- and l.period_id in
- <foreach item="periodId" index="index" collection="maps.periodIds" open="(" separator="," close=")">
- #{periodId}
- </foreach>
- </if>
- </where>
- order by l.finish_time desc,l.update_time desc,l.create_time desc
- </select>
- <select id="getWatchCourseByVideoId" resultType="com.fs.course.domain.FsCourseWatchLog">
- SELECT
- *
- FROM
- fs_course_watch_log
- WHERE
- send_type = 1
- AND video_id = #{videoId}
- AND user_id in
- <foreach item="userId" index="index" collection="userIds" open="(" separator="," close=")">
- #{userId}
- </foreach>
- ORDER BY
- log_id DESC
- </select>
- <select id="getUserCountByCampId" resultType="java.lang.Integer">
- select count(distinct cwl.user_id)
- from fs_user_course_period ucp
- inner join fs_course_watch_log cwl on ucp.period_id = cwl.period_id
- where ucp.training_camp_id = #{trainingCampId}
- </select>
- <select id="selectFsCourseWatchLogStatisticsListByCompanyVO"
- resultType="com.fs.course.vo.FsCourseWatchLogStatisticsListByCompanyVO">
- SELECT
- o.video_id,
- o.company_id,
- comp.company_name,
- o.qw_user_id,
- DATE(o.create_time) create_time,
- v.title videoName,
- uc.course_name,
- SUM(CASE WHEN o.log_type = '1' THEN 1 ELSE 0 END) AS type1,
- SUM(CASE WHEN o.log_type = '2' THEN 1 ELSE 0 END) AS type2,
- SUM(CASE WHEN o.log_type = '3' THEN 1 ELSE 0 END) AS type3,
- SUM(CASE WHEN o.log_type = '4' THEN 1 ELSE 0 END) AS type4
- FROM
- fs_course_watch_log o
- LEFT JOIN fs_user_course_video v ON v.video_id = o.video_id
- LEFT JOIN company comp ON comp.company_id = o.company_id
- LEFT JOIN qw_user qu ON qu.id = o.qw_user_id
- LEFT JOIN fs_user_course uc ON uc.course_id = v.course_id
- <where>
- <if test="sendType != null">
- and send_type = #{sendType}
- </if>
- <if test="companyId != null">
- and o.company_id = #{companyId}
- </if>
- <if test="sTime != null">
- AND DATE (o.create_time) >= DATE (#{sTime})
- </if>
- <if test="eTime != null">
- AND DATE (o.create_time) <= DATE (#{eTime})
- </if>
- <if test="courseId != null">
- and o.course_id = #{courseId}
- </if>
- <if test="videoId != null">
- and o.video_id = #{videoId}
- </if>
- </where>
- GROUP BY
- DATE (o.create_time),
- o.company_id
- ORDER BY
- comp.company_id,
- DATE (o.create_time)
- </select>
- <select id="selectQwFsCourseWatchLogStatisticsListVO"
- resultType="com.fs.course.vo.FsCourseWatchLogStatisticsListVO" parameterType="com.fs.qw.param.QwSidebarStatsParam">
- SELECT
- o.project,
- o.course_id AS courseId,
- uc.course_name AS courseName,
- o.video_id AS videoId,
- v.title AS videoName,
- CASE WHEN o.log_type = 1 THEN 1 END AS type1,
- CASE WHEN o.log_type = 2 THEN 1 END AS type2,
- CASE WHEN o.log_type = 3 THEN 1 END AS type3,
- CASE WHEN o.log_type = 4 THEN 1 END AS type4,
- o.qw_user_id,
- o.user_id AS userId,
- o.company_user_id AS companyUserId,
- o.company_id AS companyId,
- o.create_time AS createTime
- FROM
- fs_course_watch_log o
- LEFT JOIN fs_user_course_video v ON v.video_id = o.video_id
- LEFT JOIN fs_user_course uc ON uc.course_id = v.course_id
- WHERE o.qw_external_contact_id=#{qwExternalContactId}
- <if test="sendType != null">
- AND send_type = #{sendType}
- </if>
- <if test="startTime != null">
- AND DATE(o.create_time) >= DATE(#{startTime})
- </if>
- <if test="endTime != null">
- AND DATE(o.create_time) <= DATE(#{endTime})
- </if>
- o.create_time DESC
- </select>
- <!-- 统计当天各公司的观看人数和完播人数, 存到redis中,定时任务每 ? 分钟执行一次 -->
- <select id="watchCourseStatisticsGroupByCompany" resultType="com.fs.statis.dto.WatchCourseStatisticsResultDTO">
- SELECT
- o.company_id AS companyId,
- c.company_name AS companyName,
- o.send_type,
- COUNT(DISTINCT o.user_id) AS watchUserCount,
- COUNT(o.log_id) AS watchCount,
- sum(case when o.log_type = 2 then 1 else 0 end) AS finishCount,
- COUNT(DISTINCT CASE WHEN o.log_type = 2 THEN o.user_id END) AS finishUserCount
- FROM
- fs_course_watch_log o
- LEFT JOIN company c ON c.company_id = o.company_id
- WHERE
- o.create_time >= #{params.startTime}
- AND o.create_time <= #{params.endTime}
- GROUP BY
- o.company_id,
- o.send_type
- </select>
- <select id="selectUserBaseInfo" resultType="com.fs.his.vo.FsUserReportVO">
- SELECT distinct u.user_id AS userId,
- u.nick_name AS nickName,
- u.integral AS integral,
- CASE
- WHEN u.`status` = '1' THEN '正常'
- WHEN u.`status` = '2' THEN '禁止'
- ELSE '无'
- END AS status,
- u.register_date AS registerDate,
- u.phone,
- cu.nick_name AS companyUserName,
- cuu.company_user_id as companyUserId,
- c.company_name AS companyName
- <if test='dimension == "dept"'>
- ,cd.dept_name AS deptName
- </if>
- FROM fs_user u
- inner JOIN fs_user_company_user cuu ON u.user_id = cuu.user_id
- <if test="sTime != null and eTime != null">
- left join fs_package_order po on po.user_id=u.user_id
- </if>
- LEFT JOIN company_user cu ON cuu.company_user_id = cu.user_id
- LEFT JOIN company c ON cuu.company_id = c.company_id
- <if test='dimension == "dept"'>
- LEFT JOIN company_dept cd ON cu.dept_id = cd.dept_id
- </if>
- <if test="trainingCampId != null or periodId != null ">
- Left Join fs_course_watch_log watch on watch.user_id= cuu.user_id and watch.project=cuu.project_id
- left join fs_user_course_period period on watch.period_id=period.period_id and period.del_flag=0
- left join fs_user_course_training_camp camp on period.training_camp_id= camp.training_camp_id and camp.del_flag=0
- </if>
- WHERE u.user_id IS NOT NULL
- <if test="userId != null">
- AND u.user_id = #{userId}
- </if>
- <if test="userPhone != null and userPhone != ''">
- AND u.phone LIKE CONCAT('%', #{userPhone}, '%')
- </if>
- <if test="nickName != null and nickName != ''">
- AND u.nick_name LIKE CONCAT('%', #{nickName}, '%')
- </if>
- <!-- 部门条件 -->
- <if test="deptId != null">
- AND cd.dept_id = #{deptId}
- </if>
- <!-- 销售公司条件 -->
- <if test="companyId != null and companyId != ''">
- AND c.company_id = #{companyId}
- </if>
- <if test="project != null">
- AND cuu.project_id = #{project}
- </if>
- <!-- 训练营条件 -->
- <if test="trainingCampId != null">
- AND camp.training_camp_id = #{trainingCampId}
- </if>
- <!-- 营期条件 -->
- <if test="periodId != null">
- AND period.period_id = #{periodId}
- </if>
- <!-- 时间范围 - 使用BETWEEN -->
- <if test="sTime != null and eTime != null">
- AND DATE(po.create_time) BETWEEN #{sTime} AND #{eTime}
- </if>
- order by u.create_time
- </select>
- <select id="selectWatchStatsByUserIds" resultType="com.fs.his.vo.FsUserReportVO">
- SELECT
- user_id AS userId,
- company_user_id AS companyUserId,
- MAX(
- COALESCE ( update_time, create_time )) AS lastWatchTime,
- COUNT( log_id ) AS watchCount,
- COUNT( DISTINCT period_id ) AS periodCount,
- CASE
- ( SELECT log_type FROM fs_course_watch_log w2 WHERE w2.user_id = w1.user_id ORDER BY create_time DESC LIMIT 1 )
- WHEN '1' THEN
- '看课中'
- WHEN '2' THEN
- '完课'
- WHEN '3' THEN
- '待看课'
- WHEN '4' THEN
- '看课中断' ELSE '无'
- END AS watchStatus
- FROM
- fs_course_watch_log w1
- WHERE (user_id, company_user_id) IN
- <foreach collection="userConditions" item="condition" open="(" close=")" separator=",">
- (#{condition.userId}, #{condition.companyUserId})
- </foreach>
- <if test="watchParam.project != null">
- AND w1.project = #{watchParam.project}
- </if>
- <if test="watchParam.periodId != null">
- AND w1.period_id = #{watchParam.periodId}
- </if>
- GROUP BY user_id,company_user_id
- </select>
- <select id="selectIntegralStatsByUserIds" resultType="com.fs.his.vo.FsUserReportVO">
- SELECT
- user_id AS userId,
- ABS(SUM(CASE WHEN integral < 0 THEN integral ELSE 0 END)) AS consumedIntegral
- from fs_user_integral_logs
- WHERE user_id IN
- <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
- #{userId}
- </foreach>
- GROUP BY user_id
- </select>
- <select id="selectRedPacketStatsByUserIds" resultType="com.fs.his.vo.FsUserReportVO">
- SELECT
- user_id AS userId,
- company_user_id AS companyUserId,
- SUM(amount) AS receivedAmount
- FROM fs_course_red_packet_log
- WHERE status = 1
- and (user_id, company_user_id) IN
- <foreach collection="userConditions" item="condition" open="(" close=")" separator=",">
- (#{condition.userId}, #{condition.companyUserId})
- </foreach>
- <if test="watchParam.periodId != null">
- AND period_id = #{watchParam.periodId}
- </if>
- GROUP BY user_id,company_user_id
- </select>
- <select id="selectOrderStatsByUserIds" resultType="com.fs.his.vo.FsUserReportVO">
- SELECT
- user_id AS userId,
- SUM(pay_money) AS orderAmount
- FROM fs_package_order
- WHERE status = 3
- AND user_id IN
- <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
- #{userId}
- </foreach>
- <if test="watchParam.sTime != null and watchParam.eTime != null">
- AND create_time BETWEEN #{watchParam.sTime} AND #{watchParam.eTime}
- </if>
- GROUP BY user_id
- </select>
- <select id="selectUserBaseData" resultType="com.fs.his.vo.WatchLogReportVO">
- SELECT
- log.user_id userId,
- u.nick_name AS nickName,
- cu.nick_name AS salesName,
- c.company_name AS salesCompany,
- cd.dept_name AS salesDept,
- log.period_id periodId,
- log.video_id videoId,
- log.log_id logId,
- log.create_time courseTime,
- log.finish_time finishTime,
- log.duration ,
- CASE
- WHEN log.log_type = '1' THEN '看课中'
- WHEN log.log_type = '2' THEN '完课'
- WHEN log.log_type = '3' THEN '待看课'
- WHEN log.log_type = '4' THEN '看课中断'
- ELSE '无'
- END AS watchStatus,
- cv.title AS videoTitle
- FROM
- fs_course_watch_log log
- <if test="orderSTime != null and orderETime != null">
- left join fs_package_order po ON po.user_id = log.user_id
- </if>
- LEFT JOIN fs_user u ON u.user_id = log.user_id
- LEFT JOIN fs_user_company_user cuu ON cuu.user_id = u.user_id
- LEFT JOIN company_user cu ON cuu.company_user_id = cu.user_id
- LEFT JOIN company c ON log.company_id = c.company_id
- LEFT JOIN company_dept cd ON cu.dept_id = cd.dept_id
- LEFT JOIN fs_user_course_video cv ON log.video_id = cv.video_id
- WHERE log.send_type =1
- <include refid="commonConditions"/>
- <if test="orderSTime != null and orderETime != null">
- AND DATE(po.create_time) BETWEEN #{orderSTime} AND #{orderETime}
- </if>
- group by log.user_id
- ORDER BY u.register_date DESC
- </select>
- <select id="selectSalesBaseData" resultType="com.fs.his.vo.WatchLogReportVO">
- SELECT
- log.user_id userId,
- log.company_user_id companyUserId,
- log.period_id periodId,
- log.log_id logId,
- log.create_time courseTime,
- cu.nick_name as salesName,
- d.dept_name AS salesDept,
- c.company_name AS salesCompany,
- COUNT( DISTINCT u.user_id ) AS userCount,
- COUNT( DISTINCT CASE WHEN u.STATUS = 1 THEN u.user_id END ) AS onlineUserCount,
- cv.title videoTitle,
- COUNT(DISTINCT log.log_id) AS totalLogCount,
- COUNT(DISTINCT CASE WHEN log.log_type = '2' THEN log.log_id END) AS finishedCount,
- COUNT(DISTINCT CASE WHEN log.log_type IN ('1', '3', '4') THEN log.log_id END) AS unfinishedCount,
- COUNT(DISTINCT log.log_id)-COUNT(DISTINCT log.user_id) AS notWatchedCount
- FROM
- fs_course_watch_log log
- <if test="orderSTime != null and orderETime != null">
- LEFT JOIN fs_package_order po ON po.user_id = log.user_id
- </if>
- LEFT JOIN company_user cu ON log.company_user_id = cu.user_id
- LEFT JOIN fs_user u on log.user_id= u.user_id
- LEFT JOIN company_dept d ON cu.dept_id = d.dept_id
- LEFT JOIN company c ON d.company_id = c.company_id
- LEFT JOIN fs_user_course_video cv ON log.video_id = cv.video_id
- WHERE log.send_type =1
- <if test="sTime != null and eTime != null">
- AND DATE(log.create_time) BETWEEN #{sTime} AND #{eTime}
- </if>
- <if test="orderSTime != null and orderETime != null">
- AND DATE(po.create_time) BETWEEN #{orderSTime} AND #{orderETime}
- </if>
- <!-- 销售公司 -->
- <if test="companyId != null and companyId != ''">
- AND log.company_id = #{companyId}
- </if>
- <if test="deptId != null and deptId != ''">
- AND d.dept_id = #{deptId}
- </if>
- <!-- 训练营 -->
- <if test="trainingCampId != null and trainingCampId != ''">
- AND log.period_id IN (SELECT period_id FROM fs_user_course_period WHERE training_camp_id =
- #{trainingCampId})
- </if>
- <!-- 营期 -->
- <if test="periodId != null and periodId != ''">
- AND log.period_id = #{periodId}
- </if>
- <!-- 会员id -->
- <if test="userId != null and userId != ''">
- AND log.user_id = #{userId}
- </if>
- <!-- 会员手机号 -->
- <if test="userPhone != null and userPhone != ''">
- AND u.phone LIKE CONCAT('%', #{userPhone}, '%')
- </if>
- <if test="project != null and project != ''">
- AND log.project = #{project}
- </if>
- <!-- 会员昵称 -->
- <if test="nickName != null and nickName != ''">
- AND u.nick_name LIKE CONCAT('%', #{nickName}, '%')
- </if>
- GROUP BY cu.user_id
- </select>
- <select id="selectCompanyBaseData" resultType="com.fs.his.vo.WatchLogReportVO">
- SELECT
- log.user_id userId,
- log.period_id periodId,
- log.log_id logId,
- log.create_time courseTime,
- d.dept_id AS deptId,
- d.dept_name AS salesDept,
- c.company_name AS salesCompany,
- COUNT(DISTINCT cu.user_id) AS salesCount,
- COUNT(DISTINCT u.user_id) AS userCount,
- COUNT(DISTINCT CASE WHEN u.STATUS = 1 THEN u.user_id END) AS onlineUserCount,
- cv.title videoTitle,
- COUNT(DISTINCT log.log_id) AS totalLogCount,
- COUNT(DISTINCT CASE WHEN log.log_type = '2' THEN log.log_id END) AS finishedCount,
- COUNT(DISTINCT CASE WHEN log.log_type IN ('1', '3', '4') THEN log.log_id END) AS unfinishedCount,
- COUNT(DISTINCT log.user_id) - COUNT(DISTINCT CASE WHEN log.log_type = '2' THEN log.user_id END) AS notWatchedCount
- FROM fs_course_watch_log log
- <if test="orderSTime != null and orderETime != null">
- LEFT JOIN fs_package_order po ON po.user_id = log.user_id
- </if>
- LEFT JOIN company_user cu ON log.company_user_id = cu.user_id
- LEFT JOIN fs_user u on log.user_id= u.user_id
- LEFT JOIN company_dept d ON cu.dept_id = d.dept_id
- LEFT JOIN company c ON d.company_id = c.company_id
- LEFT JOIN fs_user_course_video cv ON log.video_id = cv.video_id
- WHERE log.send_type =1
- <if test="sTime != null and eTime != null">
- AND DATE(log.create_time) BETWEEN #{sTime} AND #{eTime}
- </if>
- <if test="orderSTime != null and orderETime != null">
- AND DATE(po.create_time) BETWEEN #{orderSTime} AND #{orderETime}
- </if>
- <!-- 销售公司 -->
- <if test="companyId != null and companyId != ''">
- AND c.company_id = #{companyId}
- </if>
- <!--部门 -->
- <if test="deptId != null and deptId != ''">
- AND d.dept_id = #{deptId}
- </if>
- <!-- 训练营 -->
- <if test="trainingCampId != null and trainingCampId != ''">
- AND log.period_id IN (SELECT period_id FROM fs_user_course_period WHERE training_camp_id = #{trainingCampId})
- </if>
- <!-- 营期 -->
- <if test="periodId != null and periodId != ''">
- AND log.period_id = #{periodId}
- </if>
- <!-- 会员id -->
- <if test="userId != null and userId != ''">
- AND log.user_id = #{userId}
- </if>
- <!-- 会员手机号 -->
- <if test="userPhone != null and userPhone != ''">
- AND u.phone LIKE CONCAT('%', #{userPhone}, '%')
- </if>
- <if test="project != null and project != ''">
- AND log.project = #{project}
- </if>
- <!-- 会员昵称 -->
- <if test="nickName != null and nickName != ''">
- AND u.nick_name LIKE CONCAT('%', #{nickName}, '%')
- </if>
- GROUP BY d.dept_id
- </select>
- <select id="selectUserWatchDetails" resultType="com.fs.his.vo.WatchLogReportVO">
- SELECT
- wl.user_id AS userId,
- wl.company_user_id as companyUserId,
- camp.training_camp_name trainingCampName,
- cp.period_name periodName ,
- cv.title videoTitle ,
- CASE
- WHEN wl.log_type = '1' THEN '看课中'
- WHEN wl.log_type = '2' THEN '完课'
- WHEN wl.log_type = '3' THEN '待看课'
- WHEN wl.log_type = '4' THEN '看课中断'
- ELSE '无'
- END AS watchStatus,
- wl.duration,
- wl.create_time courseTime,
- wl.finish_time finishTime,
- COUNT(DISTINCT log_id) AS totalLogCount,
- COUNT(DISTINCT CASE WHEN wl.log_type = '2' THEN wl.log_id END) AS finishedCount,
- COUNT(DISTINCT CASE WHEN wl.log_type IN ('1', '3', '4') THEN wl.log_id END) AS unfinishedCount,
- (SELECT COUNT(DISTINCT concat(uc.userId, '_', uc.companyUserId))
- FROM (
- <foreach collection="userConditions" item="condition" separator="UNION ALL">
- SELECT #{condition.userId} AS userId, #{condition.companyUserId} AS companyUserId
- </foreach>
- ) uc
- ) - COUNT(DISTINCT concat(wl.user_id, '_', wl.company_user_id)) AS notWatchedCount
- FROM fs_course_watch_log wl
- LEFT JOIN fs_user_course_video cv ON wl.video_id = cv.video_id
- LEFT JOIN fs_user_course_period cp ON wl.period_id = cp.period_id AND cp.del_flag = 0
- LEFT JOIN fs_user_course_training_camp camp ON cp.training_camp_id = camp.training_camp_id and camp.del_flag=0
- WHERE wl.send_type = 1
- and (wl.user_id, wl.company_user_id) IN
- <foreach collection="userConditions" item="condition" open="(" close=")" separator=",">
- (#{condition.userId}, #{condition.companyUserId})
- </foreach>
- <if test="watchParam.trainingCampId != null">
- AND camp.training_camp_id = #{watchParam.trainingCampId}
- </if>
- <if test="watchParam.periodId != null">
- AND cp.period_id = #{watchParam.periodId}
- </if>
- <if test="watchParam.sTime != null and watchParam.eTime != null">
- AND wl.create_time BETWEEN #{watchParam.sTime} AND #{watchParam.eTime}
- </if>
- GROUP BY
- wl.user_id,
- wl.company_user_id,
- camp.training_camp_name,
- cp.period_name,
- cv.title,
- wl.log_type,
- wl.duration,
- wl.create_time,
- wl.finish_time
- </select>
- <select id="selectRedPacketStats" resultType="com.fs.his.vo.WatchLogReportVO">
- SELECT
- rp.watch_log_id as logId,
- SUM(rp.amount) AS redPacketAmount
- FROM fs_course_red_packet_log rp
- WHERE rp.watch_log_id IN
- <foreach collection="logIds" item="logId" open="(" separator="," close=")">
- #{logId}
- </foreach>
- GROUP BY rp.watch_log_id
- </select>
- <select id="selectOrderStats" resultType="com.fs.his.vo.WatchLogReportVO">
- SELECT
- user_id AS userId,
- COUNT(DISTINCT CASE WHEN status = 3 THEN order_id END) AS historyOrderCount
- FROM fs_package_order
- WHERE user_id IN
- <foreach collection="userIds" item="userId" open="(" separator="," close=")">
- #{userId}
- </foreach>
- <!--下单时间-->
- <if test="watchParam.orderSTime != null and watchParam.orderETime != null">
- AND DATE(create_time) BETWEEN #{watchParam.orderSTime} AND #{watchParam.orderETime}
- </if>
- GROUP BY user_id
- </select>
- <select id="selectAnswerStats" resultType="com.fs.his.vo.WatchLogReportVO">
- SELECT
- l.watch_log_id AS logId,
- CASE WHEN l.log_id IS NOT NULL THEN '已答题' ELSE '未答题' END AS answerStatus,
- (
- SELECT COUNT(1)
- FROM fs_course_watch_log wl
- WHERE wl.log_id IN
- <foreach collection="logIds" item="logId" open="(" separator="," close=")">
- #{logId}
- </foreach>
- AND wl.log_id NOT IN (
- SELECT watch_log_id
- FROM fs_course_answer_logs
- WHERE watch_log_id IS NOT NULL
- )) AS notAnsweredCount
- FROM fs_course_answer_logs l
- WHERE l.watch_log_id IN
- <foreach collection="logIds" item="logId" open="(" separator="," close=")">
- #{logId}
- </foreach>
- GROUP BY l.watch_log_id
- </select>
- <select id="selectCompanyBaseInfo" resultType="com.fs.his.vo.FsCourseReportVO">
- SELECT
- c.company_id AS companyId,
- c.company_name AS companyName
- FROM company c
- <where>
- <if test="companyId != null and companyId != ''">
- AND c.company_id = #{companyId}
- </if>
- </where>
- GROUP BY c.company_id, c.company_name
- ORDER BY c.create_time DESC
- </select>
- <select id="selectWatchStatistics" resultType="com.fs.his.vo.FsCourseReportVO">
- SELECT
- <choose>
- <!-- 公司维度查询 -->
- <when test="dimension == 'company'">
- company_id AS companyId,
- </when>
- <!-- 营期维度查询 -->
- <when test="dimension == 'camp'">
- period_id AS periodId,
- company_id AS companyId,
- </when>
- </choose>
- COUNT(DISTINCT CASE WHEN log_type = 3 THEN user_id END) AS pendingCount,
- COUNT(DISTINCT CASE WHEN log_type != 3 THEN user_id END) AS watchingCount,
- COUNT(DISTINCT CASE WHEN log_type = 2 THEN user_id END) AS finishedCount,
- COUNT(DISTINCT CASE WHEN log_type = 4 THEN user_id END) AS interruptedCount,
- COUNT(DISTINCT user_id) AS accessCount
- FROM fs_course_watch_log
- <where>
- <if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
- AND create_time >= #{startDate} AND create_time < DATE_ADD(#{endDate}, INTERVAL 1 DAY)
- </if>
- <choose>
- <!-- 公司维度筛选 -->
- <when test="dimension == 'company'">
- <if test="companyIds != null and companyIds.size() > 0">
- AND company_id IN
- <foreach collection="companyIds" item="companyId" open="(" separator="," close=")">
- #{companyId}
- </foreach>
- </if>
- </when>
- <!-- 营期维度筛选 -->
- <when test="dimension == 'camp'">
- <if test="periodIds != null and periodIds.size() > 0">
- AND period_id IN
- <foreach collection="periodIds" item="periodId" open="(" separator="," close=")">
- #{periodId}
- </foreach>
- </if>
- <if test="companyIds != null and companyIds.size() > 0">
- AND company_id IN
- <foreach collection="companyIds" item="companyId" open="(" separator="," close=")">
- #{companyId}
- </foreach>
- </if>
- </when>
- </choose>
- </where>
- <choose>
- <when test="dimension == 'company'">
- GROUP BY company_id
- </when>
- <when test="dimension == 'camp'">
- GROUP BY period_id,company_id
- </when>
- </choose>
- </select>
- <select id="selectAnswerStatistics" resultType="com.fs.his.vo.FsCourseReportVO">
- SELECT
- <choose>
- <!-- 公司维度查询 -->
- <when test="dimension == 'company'">
- w.company_id AS companyId,
- </when>
- <!-- 营期维度查询 -->
- <when test="dimension == 'camp'">
- w.period_id AS periodId,
- w.company_id AS companyId,
- </when>
- </choose>
- COUNT(DISTINCT a.user_id) AS answerUserCount
- FROM fs_course_answer_logs a
- INNER JOIN fs_course_watch_log w ON a.watch_log_id = w.log_id
- <where>
- <if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
- AND w.create_time >= #{startDate} AND w.create_time < DATE_ADD(#{endDate}, INTERVAL 1 DAY)
- </if>
- <choose>
- <!-- 公司维度筛选 -->
- <when test="dimension == 'company'">
- <if test="companyIds != null and companyIds.size() > 0">
- AND w.company_id IN
- <foreach collection="companyIds" item="companyId" open="(" separator="," close=")">
- #{companyId}
- </foreach>
- </if>
- </when>
- <!-- 营期维度筛选 -->
- <when test="dimension == 'camp'">
- <if test="periodIds != null and periodIds.size() > 0">
- AND w.period_id IN
- <foreach collection="periodIds" item="periodId" open="(" separator="," close=")">
- #{periodId}
- </foreach>
- </if>
- <if test="companyIds != null and companyIds.size() > 0">
- AND w.company_id IN
- <foreach collection="companyIds" item="companyId" open="(" separator="," close=")">
- #{companyId}
- </foreach>
- </if>
- </when>
- </choose>
- </where>
- <choose>
- <when test="dimension == 'company'">
- GROUP BY w.company_id
- </when>
- <when test="dimension == 'camp'">
- GROUP BY w.period_id,w.company_id
- </when>
- </choose>
- </select>
- <select id="selectRedPacketStatistics" resultType="com.fs.his.vo.FsCourseReportVO">
- SELECT
- <choose>
- <!-- 公司维度查询 -->
- <when test="dimension == 'company'">
- w.company_id AS companyId,
- </when>
- <!-- 营期维度查询 -->
- <when test="dimension == 'camp'">
- w.period_id AS periodId,
- w.company_id AS companyId,
- </when>
- </choose>
- COUNT(DISTINCT rpl.user_id) AS packetUserCount,
- COALESCE(SUM(rpl.amount), 0) AS packetAmount
- FROM fs_course_red_packet_log rpl
- INNER JOIN fs_course_watch_log w ON rpl.watch_log_id = w.log_id
- <where>
- rpl.status=1
- <if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
- AND w.create_time >= #{startDate} AND w.create_time < DATE_ADD(#{endDate}, INTERVAL 1 DAY)
- </if>
- <choose>
- <!-- 公司维度筛选 -->
- <when test="dimension == 'company'">
- <if test="companyIds != null and companyIds.size() > 0">
- AND w.company_id IN
- <foreach collection="companyIds" item="companyId" open="(" separator="," close=")">
- #{companyId}
- </foreach>
- </if>
- </when>
- <!-- 营期维度筛选 -->
- <when test="dimension == 'camp'">
- <if test="periodIds != null and periodIds.size() > 0">
- AND w.period_id IN
- <foreach collection="periodIds" item="periodId" open="(" separator="," close=")">
- #{periodId}
- </foreach>
- </if>
- <if test="companyIds != null and companyIds.size() > 0">
- AND w.company_id IN
- <foreach collection="companyIds" item="companyId" open="(" separator="," close=")">
- #{companyId}
- </foreach>
- </if>
- </when>
- </choose>
- </where>
- <choose>
- <when test="dimension == 'company'">
- GROUP BY w.company_id
- </when>
- <when test="dimension == 'camp'">
- GROUP BY w.period_id,w.company_id
- </when>
- </choose>
- </select>
- <select id="selectCampPeriodInfo" resultType="com.fs.his.vo.FsCourseReportVO">
- SELECT
- p.period_id AS periodId,
- p.period_name AS periodName,
- c.training_camp_name AS trainingCampName
- FROM fs_user_course_period p
- LEFT JOIN fs_user_course_training_camp c ON p.training_camp_id = c.training_camp_id
- WHERE p.period_id IN
- <foreach collection="periodIds" item="periodId" open="(" separator="," close=")">
- #{periodId}
- </foreach>
- </select>
- <select id="selectCampPeriodByPeriod" resultType="com.fs.his.vo.WatchLogReportVO">
- SELECT
- cp.period_id periodId,
- cp.period_name periodName,
- camp.training_camp_name
- FROM
- fs_user_course_period cp
- LEFT JOIN fs_user_course_training_camp camp ON camp.training_camp_id = cp.training_camp_id
- WHERE cp.period_id in
- <foreach collection="periodIds" item="periodId" open="(" separator="," close=")">
- #{periodId}
- </foreach>
- </select>
- <select id="getSalesMemberStats" resultType="com.fs.his.vo.WatchLogReportVO">
- SELECT
- cu.user_id companyUserId,
- cu.nick_name salesName,
- COUNT(DISTINCT u.user_id) AS userCount,
- COUNT(DISTINCT CASE WHEN u.status = 1 THEN u.user_id END) AS onlineUserCount
- FROM fs_user u
- LEFT JOIN fs_user_company_user cuu ON u.user_id = cuu.user_id
- LEFT JOIN company_user cu ON cuu.company_user_id = cu.user_id
- <where>
- (u.status = 1 OR cu.status = 1)
- <if test="salesIds != null and salesIds.size() > 0">
- AND cu.user_id IN
- <foreach collection="salesIds" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- </where>
- GROUP BY cu.user_id
- </select>
- <select id="getSalesDeptCompanyInfo" resultType="com.fs.his.vo.WatchLogReportVO">
- SELECT
- cu.user_id AS companyUserId,
- d.dept_name AS salesDept,
- c.company_name AS salesCompany,
- (SELECT COUNT(*)
- FROM company_user cu2
- WHERE cu2.dept_id = cu.dept_id
- AND cu2.del_flag = '0'
- AND cu2.status = '0') AS salesCount
- FROM company_user cu
- LEFT JOIN company_dept d ON cu.dept_id = d.dept_id
- LEFT JOIN company c ON d.company_id = c.company_id
- WHERE cu.user_id IN
- <foreach collection="salesIds" item="salesId" open="(" separator="," close=")">
- #{salesId}
- </foreach>
- <!--部门-->
- <if test="watchParam.deptId != null and watchParam.deptId != ''">
- AND d.dept_id = #{watchParam.deptId}
- </if>
- AND cu.del_flag = '0'
- </select>
- <select id="selectCompanyBaseDataOptimized" resultType="com.fs.his.vo.WatchLogReportVO">
- SELECT
- d.dept_id AS deptId,
- d.dept_name AS salesDept,
- c.company_name AS salesCompany,
- COUNT(DISTINCT cu.user_id) AS salesCount,
- COUNT(DISTINCT u.user_id) AS userCount,
- COUNT( DISTINCT CASE WHEN u.STATUS = 1 THEN u.user_id END ) AS onlineUserCount
- FROM fs_course_watch_log log
- LEFT JOIN company_user cu ON log.company_user_id = cu.user_id
- LEFT JOIN fs_user u ON log.user_id = u.user_id
- LEFT JOIN company_dept d ON cu.dept_id = d.dept_id
- LEFT JOIN company c ON d.company_id = c.company_id
- WHERE log.send_type = 1
- <if test="sTime != null and eTime != null">
- AND DATE(log.create_time) BETWEEN #{sTime} AND #{eTime}
- </if>
- <!-- 销售公司 -->
- <if test="companyId != null and companyId != ''">
- AND c.company_id = #{companyId}
- </if>
- <!--部门 -->
- <if test="deptId != null and deptId != ''">
- AND d.dept_id = #{deptId}
- </if>
- <!-- 训练营 -->
- <if test="trainingCampId != null and trainingCampId != ''">
- AND log.period_id IN (SELECT period_id FROM fs_user_course_period WHERE training_camp_id = #{trainingCampId})
- </if>
- <!-- 营期 -->
- <if test="periodId != null and periodId != ''">
- AND log.period_id = #{periodId}
- </if>
- <!-- 会员id -->
- <if test="userId != null and userId != ''">
- AND log.user_id = #{userId}
- </if>
- <!-- 会员手机号 -->
- <if test="userPhone != null and userPhone != ''">
- AND u.phone LIKE CONCAT('%', #{userPhone}, '%')
- </if>
- <if test="project != null and project != ''">
- AND log.project = #{project}
- </if>
- <!-- 会员昵称 -->
- <if test="nickName != null and nickName != ''">
- AND u.nick_name LIKE CONCAT('%', #{nickName}, '%')
- </if>
- GROUP BY d.dept_id, d.dept_name, c.company_name
- </select>
- <select id="selectAllDeptIds" resultType="java.lang.Long">
- SELECT DISTINCT d.dept_id
- FROM fs_course_watch_log log
- LEFT JOIN company_user cu ON log.company_user_id = cu.user_id
- LEFT JOIN company_dept d ON cu.dept_id = d.dept_id
- LEFT JOIN company c ON d.company_id = c.company_id
- LEFT JOIN fs_user u ON log.user_id = u.user_id
- WHERE log.send_type = 1
- <if test="sTime != null and eTime != null">
- AND DATE(log.create_time) BETWEEN #{sTime} AND #{eTime}
- </if>
- <!-- 销售公司 -->
- <if test="companyId != null and companyId != ''">
- AND c.company_id = #{companyId}
- </if>
- <!--部门 -->
- <if test="deptId != null and deptId != ''">
- AND d.dept_id = #{deptId}
- </if>
- <!-- 训练营 -->
- <if test="trainingCampId != null and trainingCampId != ''">
- AND log.period_id IN (SELECT period_id FROM fs_user_course_period WHERE training_camp_id = #{trainingCampId})
- </if>
- <!-- 营期 -->
- <if test="periodId != null and periodId != ''">
- AND log.period_id = #{periodId}
- </if>
- <!-- 会员id -->
- <if test="userId != null and userId != ''">
- AND log.user_id = #{userId}
- </if>
- <!-- 会员手机号 -->
- <if test="userPhone != null and userPhone != ''">
- AND u.phone LIKE CONCAT('%', #{userPhone}, '%')
- </if>
- <if test="project != null and project != ''">
- AND log.project = #{project}
- </if>
- <!-- 会员昵称 -->
- <if test="nickName != null and nickName != ''">
- AND u.nick_name LIKE CONCAT('%', #{nickName}, '%')
- </if>
- </select>
- <select id="selectWatchStatsByDeptBatch" resultType="com.fs.his.vo.WatchLogReportVO">
- SELECT
- d.dept_id AS deptId,
- log.user_id AS userId,
- log.period_id AS periodId,
- log.log_id AS logId,
- cv.title videoTitle,
- COUNT(DISTINCT log.log_id) AS totalLogCount,
- COUNT(DISTINCT CASE WHEN log.log_type = '2' THEN log.log_id END) AS finishedCount,
- COUNT(DISTINCT CASE WHEN log.log_type IN ('1', '3', '4') THEN log.log_id END) AS unfinishedCount,
- COUNT(DISTINCT log.user_id) - COUNT(DISTINCT CASE WHEN log.log_type = '2' THEN log.user_id END) AS notWatchedCount
- FROM fs_course_watch_log log
- LEFT JOIN fs_user_course_video cv ON log.video_id = cv.video_id
- <if test="orderSTime != null and orderETime != null">
- LEFT JOIN fs_package_order po ON po.user_id = log.user_id
- </if>
- LEFT JOIN company_user cu ON log.company_user_id = cu.user_id
- LEFT JOIN company_dept d ON cu.dept_id = d.dept_id
- WHERE log.send_type = 1
- AND d.dept_id IN
- <foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
- #{deptId}
- </foreach>
- <if test="sTime != null and eTime != null">
- AND DATE(log.create_time) BETWEEN #{sTime} AND #{eTime}
- </if>
- <if test="orderSTime != null and orderETime != null">
- AND DATE(po.create_time) BETWEEN #{orderSTime} AND #{orderETime}
- </if>
- <!-- 销售公司 -->
- <if test="companyId != null and companyId != ''">
- AND cu.company_id = #{companyId}
- </if>
- <!-- 训练营 -->
- <if test="trainingCampId != null and trainingCampId != ''">
- AND log.period_id IN (SELECT period_id FROM fs_user_course_period WHERE training_camp_id = #{trainingCampId})
- </if>
- <!-- 营期 -->
- <if test="periodId != null and periodId != ''">
- AND log.period_id = #{periodId}
- </if>
- <!-- 会员id -->
- <if test="userId != null and userId != ''">
- AND log.user_id = #{userId}
- </if>
- GROUP BY d.dept_id
- </select>
- <select id="selectCompanyBaseDataWithIds" resultType="com.fs.his.vo.WatchLogReportVO">
- SELECT
- log.user_id userId,
- log.period_id periodId,
- log.log_id logId,
- d.dept_id AS deptId,
- d.dept_name AS salesDept,
- c.company_name AS salesCompany
- FROM fs_course_watch_log log
- LEFT JOIN company_user cu ON log.company_user_id = cu.user_id
- LEFT JOIN company_dept d ON cu.dept_id = d.dept_id
- LEFT JOIN company c ON d.company_id = c.company_id
- WHERE log.send_type = 1
- <if test="sTime != null and eTime != null">
- AND DATE(log.create_time) BETWEEN #{sTime} AND #{eTime}
- </if>
- <!-- 销售公司 -->
- <if test="companyId != null and companyId != ''">
- AND c.company_id = #{companyId}
- </if>
- <!--部门 -->
- <if test="deptId != null and deptId != ''">
- AND d.dept_id = #{deptId}
- </if>
- <!-- 训练营 -->
- <if test="trainingCampId != null and trainingCampId != ''">
- AND log.period_id IN (SELECT period_id FROM fs_user_course_period WHERE training_camp_id = #{trainingCampId})
- </if>
- <!-- 营期 -->
- <if test="periodId != null and periodId != ''">
- AND log.period_id = #{periodId}
- </if>
- <!-- 会员id -->
- <if test="userId != null and userId != ''">
- AND log.user_id = #{userId}
- </if>
- <!-- 会员手机号 -->
- <if test="userPhone != null and userPhone != ''">
- AND u.phone LIKE CONCAT('%', #{userPhone}, '%')
- </if>
- <if test="project != null and project != ''">
- AND log.project = #{project}
- </if>
- <!-- 会员昵称 -->
- <if test="nickName != null and nickName != ''">
- AND u.nick_name LIKE CONCAT('%', #{nickName}, '%')
- </if>
- GROUP BY
- d.dept_id,
- d.dept_name,
- c.company_name
- </select>
- <select id="selectPeriodInfo" resultType="com.fs.his.vo.FsCourseReportVO">
- SELECT
- period.period_id periodId,
- period.period_name periodName,
- camp.training_camp_name trainingCampName,
- c.company_name companyName,
- c.company_id companyId
- FROM
- fs_user_course_period period
- LEFT JOIN fs_user_course_training_camp camp
- ON camp.training_camp_id = period.training_camp_id
- LEFT JOIN company c
- ON FIND_IN_SET(c.company_id, period.company_id) > 0
- <where>
- <!-- 只有当传入公司ID参数时才筛选公司 -->
- <if test="companyId != null">
- period.company_id = #{companyId}
- </if>
- <!-- 训练营 -->
- <if test="trainingCampId != null and trainingCampId != ''">
- AND period.training_camp_id= #{trainingCampId}
- </if>
- <!-- 营期 -->
- <if test="periodId != null and periodId != ''">
- AND period.period_id = #{periodId}
- </if>
- </where>
- ORDER BY period.create_time DESC
- </select>
- <sql id="commonConditions">
- <!-- 销售公司 -->
- <if test="companyId != null and companyId != ''">
- AND c.company_id = #{companyId}
- </if>
- <!-- 销售部门 -->
- <if test="deptId != null and deptId != ''">
- AND cd.dept_id = #{deptId}
- </if>
- <!-- 所属销售 -->
- <if test="salesId != null and salesId != ''">
- AND cu.user_id = #{salesId}
- </if>
- <!-- 项目 -->
- <if test="project != null and project != ''">
- AND cuu.project_id = #{project}
- </if>
- <!-- 时间范围 -->
- <if test="sTime != null and eTime != null">
- AND DATE(log.create_time) BETWEEN #{sTime} AND #{eTime}
- </if>
- <!-- 训练营 -->
- <if test="trainingCampId != null and trainingCampId != ''">
- AND log.period_id IN (SELECT period_id FROM fs_user_course_period WHERE training_camp_id = #{trainingCampId})
- </if>
- <!-- 营期 -->
- <if test="periodId != null and periodId != ''">
- AND log.period_id = #{periodId}
- </if>
- <!-- 会员ID -->
- <if test="userId != null and userId != ''">
- AND u.user_id = #{userId}
- </if>
- <!-- 会员手机号 -->
- <if test="userPhone != null and userPhone != ''">
- AND u.phone LIKE CONCAT('%', #{userPhone}, '%')
- </if>
- <!-- 会员昵称 -->
- <if test="nickName != null and nickName != ''">
- AND u.nick_name LIKE CONCAT('%', #{nickName}, '%')
- </if>
- </sql>
- </mapper>
|