| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- <?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.qw.mapper.QwSopSmsLogsMapper">
- <resultMap type="QwSopSmsLogs" id="QwSopSmsLogsResult">
- <result property="id" column="id" />
- <result property="sopId" column="sop_id" />
- <result property="sopLogId" column="sop_log_id" />
- <result property="qwUserId" column="qw_user_id" />
- <result property="companyId" column="company_id" />
- <result property="companyUserId" column="company_user_id" />
- <result property="contactId" column="contact_id" />
- <result property="fsUserId" column="fs_user_id" />
- <result property="phoneNumber" column="phone_number" />
- <result property="remark" column="remark" />
- <result property="content" column="content" />
- <result property="serverId" column="server_id" />
- <result property="status" column="status" />
- <result property="sendTime" column="send_time" />
- <result property="smsTemplateCode" column="sms_template_code" />
- <result property="createTime" column="create_time" />
- <result property="updateTime" column="update_time" />
- <result property="smsIndex" column="sms_index"></result>
- </resultMap>
- <sql id="selectQwSopSmsLogsVo">
- select id, sop_id, sop_log_id, qw_user_id, company_id, company_user_id, contact_id, fs_user_id, phone_number, remark, content, server_id, status, send_time, sms_template_code, create_time, update_time,sms_index from qw_sop_sms_logs
- </sql>
- <select id="selectQwSopSmsLogsList" parameterType="QwSopSmsLogs" resultMap="QwSopSmsLogsResult">
- <include refid="selectQwSopSmsLogsVo"/>
- <where>
- <if test="sopId != null and sopId != ''"> and sop_id = #{sopId}</if>
- <if test="sopLogId != null "> and sop_log_id = #{sopLogId}</if>
- <if test="qwUserId != null "> and qw_user_id = #{qwUserId}</if>
- <if test="companyId != null "> and company_id = #{companyId}</if>
- <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
- <if test="contactId != null "> and contact_id = #{contactId}</if>
- <if test="fsUserId != null and fsUserId != ''"> and fs_user_id = #{fsUserId}</if>
- <if test="phoneNumber != null and phoneNumber != ''"> and phone_number = #{phoneNumber}</if>
- <if test="content != null and content != ''"> and content = #{content}</if>
- <if test="serverId != null "> and server_id = #{serverId}</if>
- <if test="status != null and status != ''"> and status = #{status}</if>
- <if test="sendTime != null "> and send_time = #{sendTime}</if>
- <if test="smsTemplateCode != null and smsTemplateCode != ''"> and sms_template_code = #{smsTemplateCode}</if>
- </where>
- </select>
- <select id="selectQwSopSmsLogsById" parameterType="Long" resultMap="QwSopSmsLogsResult">
- <include refid="selectQwSopSmsLogsVo"/>
- where id = #{id}
- </select>
- <insert id="insertQwSopSmsLogs" parameterType="QwSopSmsLogs" useGeneratedKeys="true" keyProperty="id">
- insert into qw_sop_sms_logs
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="sopId != null">sop_id,</if>
- <if test="sopLogId != null">sop_log_id,</if>
- <if test="qwUserId != null">qw_user_id,</if>
- <if test="companyId != null">company_id,</if>
- <if test="companyUserId != null">company_user_id,</if>
- <if test="contactId != null">contact_id,</if>
- <if test="fsUserId != null">fs_user_id,</if>
- <if test="phoneNumber != null">phone_number,</if>
- <if test="remark != null">remark,</if>
- <if test="content != null">content,</if>
- <if test="serverId != null">server_id,</if>
- <if test="status != null">status,</if>
- <if test="sendTime != null">send_time,</if>
- <if test="smsTemplateCode != null">sms_template_code,</if>
- <if test="createTime != null">create_time,</if>
- <if test="updateTime != null">update_time,</if>
- <if test="smsIndex != null">sms_index,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="sopId != null">#{sopId},</if>
- <if test="sopLogId != null">#{sopLogId},</if>
- <if test="qwUserId != null">#{qwUserId},</if>
- <if test="companyId != null">#{companyId},</if>
- <if test="companyUserId != null">#{companyUserId},</if>
- <if test="contactId != null">#{contactId},</if>
- <if test="fsUserId != null">#{fsUserId},</if>
- <if test="phoneNumber != null">#{phoneNumber},</if>
- <if test="remark != null">#{remark},</if>
- <if test="content != null">#{content},</if>
- <if test="serverId != null">#{serverId},</if>
- <if test="status != null">#{status},</if>
- <if test="sendTime != null">#{sendTime},</if>
- <if test="smsTemplateCode != null">#{smsTemplateCode},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="updateTime != null">#{updateTime},</if>
- <if test="smsIndex != null">#{smsIndex},</if>
- </trim>
- </insert>
- <update id="updateQwSopSmsLogs" parameterType="QwSopSmsLogs">
- update qw_sop_sms_logs
- <trim prefix="SET" suffixOverrides=",">
- <if test="sopId != null">sop_id = #{sopId},</if>
- <if test="sopLogId != null">sop_log_id = #{sopLogId},</if>
- <if test="qwUserId != null">qw_user_id = #{qwUserId},</if>
- <if test="companyId != null">company_id = #{companyId},</if>
- <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
- <if test="contactId != null">contact_id = #{contactId},</if>
- <if test="fsUserId != null">fs_user_id = #{fsUserId},</if>
- <if test="phoneNumber != null">phone_number = #{phoneNumber},</if>
- <if test="remark != null">remark = #{remark},</if>
- <if test="content != null">content = #{content},</if>
- <if test="serverId != null">server_id = #{serverId},</if>
- <if test="status != null">status = #{status},</if>
- <if test="sendTime != null">send_time = #{sendTime},</if>
- <if test="smsTemplateCode != null">sms_template_code = #{smsTemplateCode},</if>
- <if test="createTime != null">create_time = #{createTime},</if>
- <if test="updateTime != null">update_time = #{updateTime},</if>
- <if test="smsIndex != null">sms_index = #{smsIndex},</if>
- </trim>
- where id = #{id}
- </update>
- <delete id="deleteQwSopSmsLogsById" parameterType="Long">
- delete from qw_sop_sms_logs where id = #{id}
- </delete>
- <delete id="deleteQwSopSmsLogsByIds" parameterType="String">
- delete from qw_sop_sms_logs where id in
- <foreach item="id" collection="array" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- <!-- 查询待发送:例如 10点执行则查 当天 0 点 ~ 11 点之前。serverIds 为空时返回空结果。建议索引:(server_id, status, create_time) -->
- <select id="selectPendingSmsByServerAndTime" resultType="com.fs.qw.domain.QwSopSmsLogs">
- SELECT
- id,
- fs_user_id,
- content,
- sms_template_code
- FROM
- qw_sop_sms_logs
- <where>
- <choose>
- <when test="serverIds != null and serverIds.size() > 0">
- server_id IN
- <foreach collection="serverIds" item="serverId" open="(" separator="," close=")">
- #{serverId}
- </foreach>
- AND status = #{status}
- AND create_time >= #{startTime}
- AND create_time < #{endTime}
- </when>
- <otherwise>
- 1 = 0
- </otherwise>
- </choose>
- </where>
- </select>
- <!-- 分页查询待发送 OOM -->
- <select id="selectPendingSmsByServerAndTimePage" resultType="com.fs.qw.domain.QwSopSmsLogs">
- SELECT
- id,
- fs_user_id,
- content,
- sms_template_code,
- sop_log_id,
- server_id,
- sms_index
- FROM
- qw_sop_sms_logs
- <where>
- <choose>
- <when test="serverIds != null and serverIds.size() > 0">
- server_id IN
- <foreach collection="serverIds" item="serverId" open="(" separator="," close=")">
- #{serverId}
- </foreach>
- AND status = #{status}
- AND create_time < #{endTime}
- </when>
- <otherwise>
- 1 = 0
- </otherwise>
- </choose>
- </where>
- LIMIT #{pageSize}
- </select>
- <update id="updateStatusByIds">
- UPDATE qw_sop_sms_logs SET status = #{status}, update_time = NOW() WHERE id IN
- <foreach collection="ids" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- </update>
- <select id="selectQwSopSmsLogsByIdAndIndex" resultType="com.fs.qw.domain.QwSopSmsLogs">
- SELECT
- id,
- status,
- sms_index
- FROM
- qw_sop_sms_logs
- where id = #{id} and `index` = #{index}
- </select>
- <update id="updateSmsNotifyInfo" parameterType="QwSopSmsLogs">
- update qw_sop_sms_logs
- <trim prefix="SET" suffixOverrides=",">
- <if test="qwSopSmsLogs.remark != null">remark = #{qwSopSmsLogs.remark},</if>
- <if test="qwSopSmsLogs.status != null">status = #{qwSopSmsLogs.status},</if>
- <if test="qwSopSmsLogs.sendTime != null">send_time = #{qwSopSmsLogs.sendTime},</if>
- </trim>
- where sop_log_id = #{qwSopSmsLogs.sopLogId} AND sms_index = #{qwSopSmsLogs.smsIndex}
- </update>
- <insert id="batchInsertQwSopSmsLogsOneTouch" parameterType="java.util.List" useGeneratedKeys="false">
- INSERT INTO qw_sop_sms_logs
- (
- sop_id, sop_log_id, qw_user_id, company_id, company_user_id, contact_id, fs_user_id,
- content, server_id, status, send_time, sms_template_code, create_time,sms_index
- )
- VALUES
- <foreach collection="qwSopSmsLogs" item="log" separator=",">
- (
- #{log.sopId},
- #{log.sopLogId},
- #{log.qwUserId},
- #{log.companyId},
- #{log.companyUserId},
- #{log.contactId},
- #{log.fsUserId},
- #{log.content},
- #{log.serverId},
- #{log.status},
- #{log.sendTime},
- #{log.smsTemplateCode},
- #{log.createTime},
- #{log.smsIndex}
- )
- </foreach>
- </insert>
- </mapper>
|