123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368 |
- <?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.sop.mapper.SopUserLogsMapper">
- <resultMap type="SopUserLogs" id="SopUserLogsResult">
- <result property="id" column="id" />
- <result property="sopId" column="sop_id" />
- <result property="sopTempId" column="sop_temp_id" />
- <result property="qwUserId" column="qw_user_id" />
- <result property="corpId" column="corp_id" />
- <result property="startTime" column="start_time" jdbcType="TIMESTAMP" />
- <result property="status" column="status" />
- <result property="userId" column="user_id" />
- <result property="countDays" column="count_days" />
- </resultMap>
- <sql id="selectSopUserLogsVo">
- SELECT
- id,
- sop_id,
- sop_temp_id,
- qw_user_id,
- corp_id,
- start_time,
- status,
- user_id,
- DATEDIFF(CURRENT_DATE, start_time) + 1 AS count_days
- FROM sop_user_logs
- </sql>
- <select id="selectSopUserLogsList" parameterType="com.fs.sop.domain.SopUserLogs" resultMap="SopUserLogsResult">
- <include refid="selectSopUserLogsVo"/>
- <where>
- <if test="id != null "> and id = #{id}</if>
- <if test="sopId != null "> and sop_id = #{sopId}</if>
- <if test="sopTempId != null "> and sop_temp_id = #{sopTempId}</if>
- <if test="qwUserId != null "> and qw_user_id = #{qwUserId}</if>
- <if test="corpId != null "> and corp_id = #{corpId}</if>
- <if test="startTime != null "> and start_time = #{startTime}</if>
- <if test="status != null "> and status = #{status}</if>
- <if test="userId != null "> and user_id = #{userId}</if>
- </where>
- order by start_time desc
- </select>
- <!-- 根据ID删除记录 -->
- <delete id="deleteSopUserLogsById" parameterType="String">
- DELETE FROM sop_user_logs WHERE id = #{id}
- </delete>
- <insert id="insertSopUserLogsByDate" parameterType="com.fs.sop.params.SopUserLogsParamByDate" useGeneratedKeys="false" >
- insert into sop_user_logs
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="data.id != null ">id,</if>
- <if test="data.sopId != null ">sop_id,</if>
- <if test="data.sopTempId != null ">sop_temp_id,</if>
- <if test="data.qwUserId != null ">qw_user_id,</if>
- <if test="data.corpId != null ">corp_id,</if>
- <if test="data.startTime != null ">start_time,</if>
- <if test="data.status != null ">status,</if>
- <if test="data.userId != null ">user_id,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="data.id != null ">#{data.id},</if>
- <if test="data.sopId != null ">#{data.sopId},</if>
- <if test="data.sopTempId != null ">#{data.sopTempId},</if>
- <if test="data.qwUserId != null ">#{data.qwUserId},</if>
- <if test="data.corpId != null ">#{data.corpId},</if>
- <if test="data.startTime != null ">#{data.startTime},</if>
- <if test="data.status != null ">#{data.status},</if>
- <if test="data.userId != null ">#{data.userId},</if>
- </trim>
- </insert>
- <select id="selectSopUserLogsById" parameterType="String" resultMap="SopUserLogsResult">
- <include refid="selectSopUserLogsVo"/>
- where id = #{id}
- </select>
- <select id="selectSopUserLogsBySopId" parameterType="String" resultMap="SopUserLogsResult">
- <include refid="selectSopUserLogsVo"/>
- where sop_id = #{sopId}
- </select>
- <insert id="insertSopUserLogsByList" parameterType="com.fs.sop.params.SopUserLogsList" useGeneratedKeys="false" >
- insert into sop_user_logs
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="data.id != null ">id,</if>
- <if test="data.sopId != null ">sop_id,</if>
- <if test="data.sopTempId != null ">sop_temp_id,</if>
- <if test="data.qwUserId != null ">qw_user_id,</if>
- <if test="data.corpId != null ">corp_id,</if>
- <if test="data.startTime != null ">start_time,</if>
- <if test="data.status != null ">status,</if>
- <if test="data.userId != null ">user_id,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="data.id != null ">#{data.id},</if>
- <if test="data.sopId != null ">#{data.sopId},</if>
- <if test="data.sopTempId != null ">#{data.sopTempId},</if>
- <if test="data.qwUserId != null ">#{data.qwUserId},</if>
- <if test="data.corpId != null ">#{data.corpId},</if>
- <if test="data.startTime != null ">#{data.startTime},</if>
- <if test="data.status != null ">#{data.status},</if>
- <if test="data.userId != null ">#{data.userId},</if>
- </trim>
- </insert>
- <insert id="batchInsertSopUserLogs">
- INSERT INTO sop_user_logs
- (
- sop_id, sop_temp_id, qw_user_id,chat_id,corp_id, start_time,
- status, user_id
- )
- VALUES
- <foreach collection="list" item="log" separator=",">
- (
- #{log.sopId},
- #{log.sopTempId},
- #{log.qwUserId},
- #{log.chatId},
- #{log.corpId},
- #{log.startTime},
- #{log.status},
- #{log.userId}
- )
- </foreach>
- </insert>
- <update id="updateSopUserLogsByTempId" parameterType="String">
- update sop_user_logs
- SET sop_temp_id = #{sopTempId} where sop_id = #{sopId}
- </update>
- <update id="deleteSopUserLogsBySopId" parameterType="String">
- update sop_user_logs
- SET status = 0 where sop_id = #{sopId}
- </update>
- <update id="deleteSopUserLogsByRemoveSop" parameterType="String">
- update sop_user_logs
- SET status = 0
- where sop_id = #{sopId} and qw_user_id=#{qwUserId} and corp_id=#{corpId}
- </update>
- <update id="deleteSopUserLogsBySopIds" parameterType="String">
- update sop_user_logs
- SET status = 0 where sop_id in
- <foreach item="id" collection="sopIds" open="(" separator="," close=")">
- #{id}
- </foreach>
- </update>
- <update id="updateSopUserLogsByStatus" parameterType="SopUserLogs" useGeneratedKeys="false" keyProperty="id" >
- UPDATE sop_user_logs
- SET status= #{data.status}
- WHERE sop_id = #{data.sopId}
- </update>
- <update id="updateSopUserLogsByStartTime" parameterType="SopUserLogs" useGeneratedKeys="false" keyProperty="id" >
- UPDATE sop_user_logs
- SET status= #{data.status},start_time = #{data.startTime}
- where id = #{data.id}
- </update>
- <update id="updateSopUserLogsByCompanyInfo" parameterType="SopUserLogs" useGeneratedKeys="false" keyProperty="id" >
- UPDATE sop_user_logs
- SET user_id= #{data.userId}
- where id = #{data.id}
- </update>
- <select id="repairSopUserLogsList" resultType="com.fs.sop.domain.SopUserLogs">
- select id,qw_user_id,corp_id,user_id from sop_user_logs where status=1 and user_id like '%null%'
- </select>
- <select id="selectSopUserLogsListByTime" resultType="com.fs.sop.vo.SopUserLogsVo">
- select a.*,
- b.min_conversion_day,
- b.max_conversion_day,
- b.min_send,
- b.max_send,
- b.is_fixed,
- b.is_register,
- b.chat_id,
- b.filter_mode
- from sop_user_logs a
- inner join qw_sop b on a.sop_id = b.id
- where a.start_time <= Now()
- and a.status = 1
- and b.send_type != 4 and b.status in (2,3)
- </select>
- <select id="meetsTheRatingByUserInfo" resultMap="SopUserLogsResult">
- SELECT
- ul.id,
- ul.sop_id,
- ul.sop_temp_id,
- ul.qw_user_id,
- ul.corp_id,
- ul.start_time,
- ul.`status`,
- ul.user_id,
- DATEDIFF( CURRENT_DATE, ul.start_time ) AS count_days
- FROM
- sop_user_logs ul LEFT JOIN qw_sop qs on ul.sop_id=qs.id
- WHERE
- ul.`status` = '1'
- and qs.is_rating=1
- and qs.`status` in (2,3)
- AND ( DATEDIFF( CURRENT_DATE, ul.start_time ) ) % 7 = 0
- AND ( DATEDIFF( CURRENT_DATE, ul.start_time ) ) > 0
- </select>
- <select id="meetsTheRatingByUserInfoWithPagination" resultType="Integer" resultMap="SopUserLogsResult">
- SELECT
- ul.id,
- ul.sop_id,
- ul.sop_temp_id,
- ul.qw_user_id,
- ul.corp_id,
- ul.start_time,
- ul.`status`,
- ul.user_id,
- DATEDIFF( CURRENT_DATE, ul.start_time ) AS count_days
- FROM
- sop_user_logs ul LEFT JOIN qw_sop qs on ul.sop_id=qs.id
- WHERE
- ul.`status` = '1'
- and qs.is_rating=1
- and qs.type=2
- and qs.send_type=2
- and qs.`status` in (2,3)
- AND ( DATEDIFF( CURRENT_DATE, ul.start_time ) ) >= 7
- ORDER BY id ASC
- LIMIT #{offset}, #{pageSize}
- </select>
- <select id="meetsTheRatingByUserInfoBySopId" resultType="String" resultMap="SopUserLogsResult">
- SELECT
- ul.id,
- ul.sop_id,
- ul.sop_temp_id,
- ul.qw_user_id,
- ul.corp_id,
- ul.start_time,
- ul.`status`,
- ul.user_id,
- DATEDIFF( CURRENT_DATE, ul.start_time ) AS count_days
- FROM
- sop_user_logs ul LEFT JOIN qw_sop qs on ul.sop_id=qs.id
- WHERE
- ul.`status` = '1'
- and qs.is_rating=1
- and qs.type=2
- and qs.send_type=2
- and qs.`status` in (2,3)
- and ul.sop_id= #{sopId}
- AND ( DATEDIFF( CURRENT_DATE, ul.start_time ) ) >= 7
- </select>
- <!-- <select id="selectSopUserLogsListByTime" resultType="com.fs.sop.vo.SopUserLogsVo">-->
- <!-- select a.*,b.min_conversion_day,b.max_conversion_day,b.min_send,b.max_send from sop_user_logs a-->
- <!-- inner join qw_sop b on a.sop_id = b.id-->
- <!-- where b.id="23d77d16-2967-4760-940c-bdce4ca78b59"-->
- <!-- </select>-->
- <!-- <select id="selectSopUserLogsListByTime" resultType="com.fs.sop.vo.SopUserLogsVo">-->
- <!-- select a.*,b.min_conversion_day,b.max_conversion_day,b.min_send,b.max_send from sop_user_logs a-->
- <!-- inner join qw_sop b on a.sop_id = b.id-->
- <!-- where a.id="2263eef1-f037-4db8-875a-b29d717929ef"-->
- <!-- </select>-->
- <select id="selectSopUserLogsListByTest" resultType="com.fs.sop.vo.SopUserLogsVo">
- select a.*,b.min_conversion_day,b.max_conversion_day,b.min_send,b.max_send from sop_user_logs a
- inner join qw_sop b on a.sop_id = b.id
- where a.sop_id = '343bbcae-07cf-11f0-b693-96e1ac939c1f' and a.start_time <= Now() and a.status = 1 and b.send_type != 4
- </select>
- <select id="selectSopUserLogsByUnionSopId" resultType="String" parameterType="SopUserLogs">
- SELECT id
- FROM sop_user_logs
- WHERE sop_id = #{data.sopId}
- AND sop_temp_id = #{data.sopTempId}
- AND qw_user_id = #{data.qwUserId}
- AND corp_id = #{data.corpId}
- AND start_time = STR_TO_DATE(#{data.startTime}, '%Y-%m-%d')
- AND status = #{data.status}
- limit 1
- </select>
- <select id="selectSopUserLogsByUpdate" resultType="String" parameterType="SopUserLogs">
- SELECT id
- FROM sop_user_logs
- WHERE sop_id = #{data.sopId}
- AND qw_user_id = #{data.qwUserId}
- AND corp_id = #{data.corpId}
- AND start_time = STR_TO_DATE(#{data.startTime}, '%Y-%m-%d')
- AND status = #{data.status}
- limit 1
- </select>
- <select id="selectSopUserLogsInfoListByTime" resultType="com.fs.sop.vo.SopUserLogsInfoVo">
- select
- c.id sopId,
- b.id sopLogsId,
- a.id sopLogsInfoId,
- a.external_id externalId,
- a.create_time createTime,a.qw_user_id qwUserId,a.corp_id corpId,a.fs_user_id fsUserId,a.external_user_name externalUserName,
- c.min_conversion_day minConversionDay,c.max_conversion_day maxConversionDay,c.min_send minSend,c.max_send maxSend
- from sop_user_logs_info a
- inner join sop_user_logs b on a.user_logs_id = b.id
- inner join qw_sop c on b.sop_id = c.id
- where a.create_time < CURDATE() and b.status = 1 and c.min_conversion_day is not null and c.max_conversion_day is not null and (c.min_send = 0 or c.max_send = 0)
- </select>
- <select id="selectSopUserLogsListBySopId" resultMap="SopUserLogsResult">
- select
- id,
- sop_id,
- sop_temp_id,
- qw_user_id,
- corp_id,
- start_time,
- status,
- user_id
- from sop_user_logs where sop_id = #{data.sopId} order by start_time desc
- </select>
- <select id="selectSopUserInfoLogsListByTime" resultType="com.fs.sop.vo.SopUserLogsInfoVo">
- select a.*,b.min_conversion_day,b.max_conversion_day,b.min_send,b.max_send from sop_user_logs_info_chat a
- inner join qw_sop b on a.sop_id = b.id
- where a.start_time <= Now() and a.status = 1
- </select>
- <select id="selectSopUserLogsByDate" resultType="String">
- SELECT id
- FROM sop_user_logs
- WHERE start_time BETWEEN STR_TO_DATE(#{scheduleStartTime}, '%Y-%m-%d') AND STR_TO_DATE(#{scheduleEndTime}, '%Y-%m-%d')
- </select>
- <select id="selectQwSopLogsMessSendList" resultType="com.fs.qw.param.SopUserLogsVO">
- <include refid="selectSopUserLogsVo"/>
- <where>
- count_days = 1
- <if test="sopIds != null and sopIds.size() > 0">
- and sop_id in
- <foreach item="sopId" index="index" collection="sopIds" open="(" separator="," close=")">
- #{sopId}
- </foreach>
- </if>
- </where>
- order by send_time desc
- </select>
- <select id="selectSopUserLogsByDateAndIds" resultType="com.fs.sop.domain.SopUserLogs" >
- select * from sop_user_logs where sop_id=#{sopId} and sop_temp_id=#{sopTempId} and qw_user_id=#{qwUserId} and corp_id=#{corpId} and start_time=#{startTime}
- </select>
- </mapper>
|