123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498 |
- <?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.QwSopMapper">
- <resultMap type="com.fs.sop.domain.QwSop" id="QwSopResult">
- <result property="id" column="id" />
- <result property="name" column="name" />
- <result property="status" column="status" />
- <result property="type" column="type" />
- <result property="qwUserIds" column="qw_user_ids" />
- <result property="createBy" column="create_by" />
- <result property="createTime" column="create_time" />
- <result property="companyId" column="company_id" />
- <result property="sendType" column="send_type" />
- <result property="tags" column="tags" />
- <result property="excludeTags" column="exclude_tags" />
- <result property="startTime" column="start_time" />
- <result property="filterType" column="filter_type" />
- <result property="tempId" column="temp_id" />
- <result property="corpId" column="corp_id" />
- <result property="expiryTime" column="expiry_time" />
- <result property="isAutoSop" column="is_auto_sop" />
- <result property="autoSopTime" column="auto_sop_time" />
- <result property="minConversionDay" column="min_conversion_day" />
- <result property="maxConversionDay" column="max_conversion_day" />
- <result property="minSend" column="min_send" />
- <result property="maxSend" column="max_send" />
- <result property="stopTime" column="stop_time" />
- <result property="isRating" column="is_rating" />
- <result property="courseDay" column="course_day" />
- <result property="filterMode" column="filter_mode" />
- </resultMap>
- <sql id="selectQwSopVo">
- select * from qw_sop
- </sql>
- <select id="selectQwSopAutoByTagsByForeach" resultType="com.fs.qw.vo.QwSopRuleTimeVO">
- SELECT
- qs.*,
- qst.name AS temp_name,
- qst.setting AS temp_setting,
- qst.status AS temp_status,
- qst.gap AS temp_gap,
- qst.sort AS temp_sort,
- qst.create_time AS temp_create_time,
- qst.create_by AS temp_create_by,
- qst.corp_id AS temp_company_id
- FROM
- qw_sop qs
- LEFT JOIN
- qw_sop_temp qst ON qs.temp_id = qst.id
- WHERE
- FIND_IN_SET(#{map.qwUserId}, COALESCE(qs.qw_user_ids, '')) > 0
- AND qs.corp_id = #{map.corpId}
- AND qst.status = '1'
- AND qs.status IN (2, 3, 4)
- AND qs.is_auto_sop = 1
- AND qs.send_type = #{map.sendType}
- AND (
- <foreach collection='map.tagsIdsSelectList' item='item' index='index' separator=' or '>
- find_in_set( #{item}, TRIM(REGEXP_REPLACE(qs.tags, '[\"\\\\[\\\\]]', '')))
- </foreach>
- )
- </select>
- <select id="selectQwSopAutoByTagsByForeachNotAuto" resultType="com.fs.qw.vo.QwSopRuleTimeVO">
- SELECT
- qs.*,
- qst.name AS temp_name,
- qst.setting AS temp_setting,
- qst.status AS temp_status,
- qst.gap AS temp_gap,
- qst.sort AS temp_sort,
- qst.create_time AS temp_create_time,
- qst.create_by AS temp_create_by,
- qst.corp_id AS temp_company_id
- FROM
- qw_sop qs
- LEFT JOIN
- qw_sop_temp qst ON qs.temp_id = qst.id
- WHERE
- FIND_IN_SET(#{map.qwUserId}, COALESCE(qs.qw_user_ids, '')) > 0
- AND qs.corp_id = #{map.corpId}
- AND qst.status = '1'
- AND qs.status IN (2, 3, 4)
- AND qs.send_type = #{map.sendType}
- AND (
- <foreach collection='map.tagsIdsSelectList' item='item' index='index' separator=' or '>
- find_in_set( #{item}, TRIM(REGEXP_REPLACE(qs.tags, '[\"\\\\[\\\\]]', '')) )
- </foreach>
- )
- </select>
- <select id="selectQwSopAutoByTagsByForeachRemoveNotAuto" resultType="com.fs.qw.vo.QwSopRuleTimeVO">
- SELECT
- qs.*,
- qst.name AS temp_name,
- qst.setting AS temp_setting,
- qst.status AS temp_status,
- qst.gap AS temp_gap,
- qst.sort AS temp_sort,
- qst.create_time AS temp_create_time,
- qst.create_by AS temp_create_by,
- qst.corp_id AS temp_company_id
- FROM
- qw_sop qs
- LEFT JOIN
- qw_sop_temp qst ON qs.temp_id = qst.id
- WHERE
- FIND_IN_SET(#{map.qwUserId}, COALESCE(qs.qw_user_ids, '')) > 0
- AND qs.corp_id = #{map.corpId}
- AND qst.status = '1'
- AND qs.status IN (2, 3, 4)
- AND qs.send_type = #{map.sendType}
- AND (
- <foreach collection='map.tagsIdsSelectList' item='item' index='index' separator=' and '>
- NOT find_in_set( #{item}, TRIM(REGEXP_REPLACE(qs.tags, '[\"\\\\[\\\\]]', '')) )
- </foreach>
- )
- </select>
- <select id="selectQwAiSopAutoByTagsByForeach" resultType="com.fs.qw.vo.QwSopRuleTimeVO">
- SELECT
- qs.*,
- qst.name AS temp_name,
- qst.setting AS temp_setting,
- qst.status AS temp_status,
- qst.gap AS temp_gap,
- qst.sort AS temp_sort,
- qst.create_time AS temp_create_time,
- qst.create_by AS temp_create_by,
- qst.corp_id AS temp_company_id
- FROM
- qw_sop qs
- LEFT JOIN
- qw_sop_temp qst ON qs.temp_id = qst.id
- WHERE
- FIND_IN_SET(#{map.qwUserId}, COALESCE(qs.qw_user_ids, '')) > 0
- AND qs.corp_id = #{map.corpId}
- AND qst.status = '1'
- AND qs.status IN (2, 3, 4)
- AND qs.send_type = 4
- AND (
- <foreach collection='map.tagsIdsSelectList' item='item' index='index' separator=' or '>
- find_in_set( #{item}, TRIM(REGEXP_REPLACE(qs.tags, '[\"\\\\[\\\\]]', '')) )
- </foreach>
- )
- </select>
- <select id="selectQwSopByQwUserId" resultType="com.fs.qw.vo.QwSopRuleTimeVO">
- SELECT
- qs.*
- FROM
- qw_sop qs
- LEFT JOIN
- qw_sop_temp qst ON qs.temp_id = qst.id
- WHERE
- FIND_IN_SET(#{map.qwUserId}, COALESCE(qs.qw_user_ids, '')) > 0
- AND qs.corp_id = #{map.corpId}
- AND qst.status = '1'
- AND qs.status IN (2, 3, 4)
- AND qs.send_type = #{map.sendType}
- </select>
- <select id="checkSopRuleTime" resultType="com.fs.qw.vo.QwSopRuleTimeVO">
- <![CDATA[
- SELECT
- qs.*,
- qst.name AS temp_name,
- qst.setting AS temp_setting,
- qst.status AS temp_status,
- qst.gap AS temp_gap,
- qst.sort AS temp_sort,
- qst.create_time AS temp_create_time,
- qst.create_by AS temp_create_by,
- qst.corp_id AS temp_company_id
- FROM
- qw_sop qs
- LEFT JOIN qw_sop_temp qst ON qs.temp_id = qst.id
- WHERE
- qs.status = 1
- AND qs.start_time <= NOW()
- ]]>
- </select>
- <select id="selectQwSopByClickHouseId" parameterType="String" resultType="com.fs.qw.vo.QwSopRuleTimeVO">
- <![CDATA[
- SELECT
- qs.*,
- qst.name AS temp_name,
- qst.setting AS temp_setting,
- qst.status AS temp_status,
- qst.gap AS temp_gap,
- qst.sort AS temp_sort,
- qst.create_time AS temp_create_time,
- qst.create_by AS temp_create_by,
- qst.corp_id AS temp_company_id
- FROM
- qw_sop qs
- LEFT JOIN
- qw_sop_temp qst
- ON
- qs.temp_id = qst.id
- WHERE
- qs.id = #{id}
- ]]>
- </select>
- <select id="selectQwSopList" parameterType="QwSop" resultMap="QwSopResult">
- <include refid="selectQwSopVo"/>
- <where>
- <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
- <if test="status != null "> and status = #{status}</if>
- <if test="type != null "> and type = #{type}</if>
- <if test="id != null and id!='' "> and id = #{id}</if>
- <if test="companyId != null "> and company_id = #{companyId}</if>
- <if test="qwUserIds != null and qwUserIds != ''"> and FIND_IN_SET(#{qwUserIds}, qw_user_ids) > 0</if>
- <if test="createBy != null and createBy != ''"> and create_by = #{createBy}</if>
- <if test="corpId != null and corpId != ''"> and corp_id = #{corpId}</if>
- <if test="createTime != null "> and DATE(create_time) = #{createTime}</if>
- <if test="sendType != null "> and send_type = #{sendType}</if>
- <if test="expiryTime != null "> and expiry_time = #{expiryTime}</if>
- <if test="isAutoSop != null "> and is_auto_sop = #{isAutoSop}</if>
- <if test="autoSopTime != null "> and auto_sop_time = #{autoSopTime}</if>
- <if test="minSend != null "> and min_send = #{minSend}</if>
- <if test="maxSend != null "> and max_send = #{maxSend}</if>
- <if test="stopTime != null "> and stop_time = #{stopTime}</if>
- <!-- 加入固定条件 -->
- and status != 6
- </where>
- order by create_time desc
- </select>
- <select id="selectChatQwSopList" parameterType="QwSop" resultMap="QwSopResult">
- <include refid="selectQwSopVo"/>
- where send_type = 4
- and status != 6
- order by create_time desc
- </select>
- <select id="selectQwSopByIsRating" parameterType="QwSop" resultMap="QwSopResult">
- <include refid="selectQwSopVo"/>
- where is_rating = 1
- and send_type in(2,3)
- order by create_time desc
- </select>
- <select id="selectQwSopById" parameterType="String" resultMap="QwSopResult">
- <include refid="selectQwSopVo"/>
- where id = #{id}
- </select>
- <insert id="insertQwSop" parameterType="com.fs.sop.domain.QwSop" useGeneratedKeys="false" keyProperty="id">
- insert into qw_sop
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="data.name != null">name,</if>
- <if test="data.status != null">status,</if>
- <if test="data.type != null">type,</if>
- <if test="data.qwUserIds != null">qw_user_ids,</if>
- <if test="data.createBy != null">create_by,</if>
- <if test="data.createTime != null">create_time,</if>
- <if test="data.companyId != null">company_id,</if>
- <if test="data.sendType != null">send_type,</if>
- <if test="data.tags != null">tags,</if>
- <if test="data.excludeTags != null">exclude_tags,</if>
- <if test="data.startTime != null">start_time,</if>
- <if test="data.filterType != null">filter_type,</if>
- <if test="data.tempId != null">temp_id,</if>
- <if test="data.corpId != null">corp_id,</if>
- <if test="data.expiryTime != null">expiry_time,</if>
- <if test="data.isAutoSop != null">is_auto_sop,</if>
- <if test="data.autoSopTime != null">auto_sop_time,</if>
- <if test="data.minConversionDay != null">min_conversion_day,</if>
- <if test="data.maxConversionDay != null">max_conversion_day,</if>
- <if test="data.minSend != null">min_send,</if>
- <if test="data.maxSend != null">max_send,</if>
- <if test="data.isRating != null">is_rating,</if>
- <if test="data.courseDay != null">course_day,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="data.name != null">#{data.name},</if>
- <if test="data.status != null">#{data.status},</if>
- <if test="data.type != null">#{data.type},</if>
- <if test="data.qwUserIds != null">#{data.qwUserIds},</if>
- <if test="data.createBy != null">#{data.createBy},</if>
- <if test="data.createTime != null">#{data.createTime},</if>
- <if test="data.companyId != null">#{data.companyId},</if>
- <if test="data.sendType != null">#{data.sendType},</if>
- <if test="data.tags != null">#{data.tags},</if>
- <if test="data.excludeTags != null">#{data.excludeTags},</if>
- <if test="data.startTime != null">#{data.startTime},</if>
- <if test="data.filterType != null">#{data.filterType},</if>
- <if test="data.tempId != null">#{data.tempId},</if>
- <if test="data.corpId != null">#{data.corpId},</if>
- <if test="data.expiryTime != null">#{data.expiryTime},</if>
- <if test="data.isAutoSop != null">#{data.isAutoSop},</if>
- <if test="data.autoSopTime != null">#{data.autoSopTime},</if>
- <if test="data.minConversionDay != null">#{data.minConversionDay},</if>
- <if test="data.maxConversionDay != null">#{data.maxConversionDay},</if>
- <if test="data.minSend != null">#{data.minSend},</if>
- <if test="data.maxSend != null">#{data.maxSend},</if>
- <if test="data.isRating != null">#{data.isRating},</if>
- <if test="data.courseDay != null">#{data.courseDay},</if>
- </trim>
- </insert>
- <update id="updateAutoSopTime" useGeneratedKeys="false" keyProperty="id" >
- UPDATE qw_sop
- SET
- is_auto_sop = #{map.isAutoSop}
- <if test="map.autoSopTime != null and map.autoSopTime != ''">
- ,auto_sop_time = #{map.autoSopTime}
- </if>
- WHERE id = #{map.id}
- </update>
- <update id="updateSopStatus" useGeneratedKeys="false" keyProperty="id" >
- UPDATE qw_sop
- SET status = #{map.status},stop_time = NOW()
- WHERE id = #{map.id}
- </update>
- <select id="selectStatusQwSopById" resultType="QwSop">
- select * from qw_sop where id in
- <foreach item="id" collection="ids" open="(" separator="," close=")">
- #{id}
- </foreach>
- </select>
- <select id="executeSopByIds" resultType="com.fs.qw.vo.QwSopRuleTimeVO">
- SELECT qs.*,
- qst.name AS temp_name,
- qst.setting AS temp_setting,
- qst.status AS temp_status,
- qst.gap AS temp_gap,
- qst.sort AS temp_sort,
- qst.create_time AS temp_create_time,
- qst.create_by AS temp_create_by,
- qst.corp_id AS temp_company_id
- FROM qw_sop qs
- LEFT JOIN qw_sop_temp qst ON qs.temp_id = qst.id
- WHERE qs.id IN
- <foreach item="id" collection="ids" open="(" separator="," close=")">
- #{id}
- </foreach>
- </select>
- <select id="executeSopWxByIds" resultType="com.fs.qw.vo.WxSopRuleTimeVO">
- SELECT qs.*,
- qst.name AS temp_name,
- qst.setting AS temp_setting,
- qst.status AS temp_status,
- qst.gap AS temp_gap,
- qst.sort AS temp_sort,
- qst.create_time AS temp_create_time,
- qst.create_by AS temp_create_by,
- qst.corp_id AS temp_company_id
- FROM qw_sop qs
- LEFT JOIN qw_sop_temp qst ON qs.temp_id = qst.id
- WHERE qs.id IN
- <foreach item="id" collection="ids" open="(" separator="," close=")">
- #{id}
- </foreach>
- </select>
- <select id="selectAiChatQwSopList" resultType="com.fs.sop.domain.QwSop">
- <include refid="selectQwSopVo"/>
- <where>
- send_type = 4
- <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
- <if test="status != null "> and status = #{status}</if>
- <if test="type != null "> and type = #{type}</if>
- <if test="companyId != null "> and company_id = #{companyId}</if>
- <if test="qwUserIds != null and qwUserIds != ''"> and qw_user_ids = #{qwUserIds}</if>
- <if test="createBy != null and createBy != ''"> and create_by = #{createBy}</if>
- <if test="corpId != null and corpId != ''"> and corp_id = #{corpId}</if>
- <if test="createTime != null "> and DATE(create_time) = #{createTime}</if>
- <if test="expiryTime != null "> and expiry_time = #{expiryTime}</if>
- <if test="isAutoSop != null "> and is_auto_sop = #{isAutoSop}</if>
- <if test="autoSopTime != null "> and auto_sop_time = #{autoSopTime}</if>
- <if test="minSend != null "> and min_send = #{minSend}</if>
- <if test="maxSend != null "> and max_send = #{maxSend}</if>
- <if test="stopTime != null "> and stop_time = #{stopTime}</if>
- <!-- 加入固定条件 -->
- and status != 6
- </where>
- order by create_time desc
- </select>
- <select id="selectByTemplateId" resultType="com.fs.sop.domain.QwSop">
- select * from qw_sop where temp_id = #{tempId}
- </select>
- <select id="selectWxSop" resultType="com.fs.sop.domain.QwSop">
- select a.* from qw_sop a
- where a.send_type != 4 and a.status in (2,3) and a.type = 1
- </select>
- <select id="executeSopChatByIds" resultType="com.fs.qw.vo.ChatSopRuleTimeVO">
- SELECT qs.*,
- qst.name AS temp_name,
- qst.setting AS temp_setting,
- qst.status AS temp_status,
- qst.gap AS temp_gap,
- qst.sort AS temp_sort,
- qst.create_time AS temp_create_time,
- qst.create_by AS temp_create_by,
- qst.corp_id AS temp_company_id
- FROM qw_sop qs
- LEFT JOIN qw_sop_temp qst ON qs.temp_id = qst.id
- WHERE qs.id IN
- <foreach item="id" collection="ids" open="(" separator="," close=")">
- #{id}
- </foreach>
- </select>
- <update id="updateQwSop" parameterType="QwSop" useGeneratedKeys="false" keyProperty="id" >
- UPDATE qw_sop
- <trim prefix="SET" suffixOverrides=",">
- <if test="data.name != null">name = #{data.name},</if>
- <if test="data.status != null">status = #{data.status},</if>
- <if test="data.type != null">type = #{data.type},</if>
- <if test="data.qwUserIds != null">qw_user_ids = #{data.qwUserIds},</if>
- <if test="data.createBy != null">create_by = #{data.createBy},</if>
- <if test="data.createTime != null">create_time = #{data.createTime},</if>
- <if test="data.companyId != null">company_id = #{data.companyId},</if>
- <if test="data.sendType != null">send_type = #{data.sendType},</if>
- <if test="data.tags != null">tags = #{data.tags},</if>
- <if test="data.excludeTags != null">exclude_tags = #{data.excludeTags},</if>
- <if test="data.startTime != null">start_time = #{data.startTime},</if>
- <if test="data.filterType != null">filter_type = #{data.filterType},</if>
- <if test="data.tempId != null">temp_id = #{data.tempId},</if>
- <if test="data.corpId != null">corp_id = #{data.corpId},</if>
- <if test="data.expiryTime != null">expiry_time = #{data.expiryTime},</if>
- <if test="data.isAutoSop != null">is_auto_sop = #{data.isAutoSop},</if>
- <if test="data.autoSopTime != null">auto_sop_time = #{data.autoSopTime},</if>
- <if test="data.minConversionDay != null">min_conversion_day = #{data.minConversionDay},</if>
- <if test="data.maxConversionDay != null">max_conversion_day = #{data.maxConversionDay},</if>
- <if test="data.minSend != null">min_send = #{data.minSend},</if>
- <if test="data.maxSend != null">max_send = #{data.maxSend},</if>
- <if test="data.voice != null">voice = #{data.voice},</if>
- <if test="data.isRating != null">is_rating = #{data.isRating},</if>
- <if test="data.courseDay != null">course_day = #{data.courseDay},</if>
- </trim>
- where id = #{data.id}
- </update>
- <delete id="deleteQwSopById" parameterType="String">
- DELETE FROM qw_sop
- where id = #{id}
- </delete>
- <delete id="deleteQwSopByIds" parameterType="String">
- DELETE FROM qw_sop
- where id in
- <foreach item="id" collection="array" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- <update id="deleteQwSopByIdsUpdate" useGeneratedKeys="false" keyProperty="id">
- UPDATE qw_sop
- SET status = 6
- WHERE id IN
- <foreach item="id" collection="ids" open="(" separator="," close=")">
- #{id}
- </foreach>
- </update>
- <update id="updateStatusQwSopById" useGeneratedKeys="false" keyProperty="id" >
- UPDATE qw_sop
- SET status = 4
- WHERE id IN
- <foreach item="id" collection="ids" open="(" separator="," close=")">
- #{id}
- </foreach>
- </update>
- <update id="updateStatusQwSopById2" useGeneratedKeys="false" keyProperty="id" >
- UPDATE qw_sop
- SET status = 3
- WHERE id IN
- <foreach item="id" collection="ids" open="(" separator="," close=")">
- #{id}
- </foreach>
- </update>
- <update id="updateMinSendStatus">
- UPDATE qw_sop
- SET min_send = 1
- WHERE id = #{id}
- </update>
- <update id="updateMaxSendStatus">
- UPDATE qw_sop
- SET max_send = 1
- WHERE id = #{id}
- </update>
- </mapper>
|