|
|
@@ -0,0 +1,237 @@
|
|
|
+<?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.wx.sop.mapper.WxSopLogsMapper">
|
|
|
+
|
|
|
+ <resultMap type="WxSopLogs" id="WxSopLogsResult">
|
|
|
+ <result property="id" column="id" />
|
|
|
+ <result property="type" column="type" />
|
|
|
+ <result property="sopId" column="sop_id" />
|
|
|
+ <result property="sopUserId" column="sop_user_id" />
|
|
|
+ <result property="sendType" column="send_type" />
|
|
|
+ <result property="generateType" column="generate_type" />
|
|
|
+ <result property="accountId" column="account_id" />
|
|
|
+ <result property="wxContactId" column="wx_contact_id" />
|
|
|
+ <result property="wxContactName" column="wx_contact_name" />
|
|
|
+ <result property="wxRoomId" column="wx_room_id" />
|
|
|
+ <result property="wxRoomName" column="wx_room_name" />
|
|
|
+ <result property="fsUserId" column="fs_user_id" />
|
|
|
+ <result property="sendStatus" column="send_status" />
|
|
|
+ <result property="sendRemark" column="send_remark" />
|
|
|
+ <result property="sendSort" column="send_sort" />
|
|
|
+ <result property="expirationTime" column="expiration_time" />
|
|
|
+ <result property="createTime" column="create_time" />
|
|
|
+ <result property="createBy" column="create_by" />
|
|
|
+ <result property="updateTime" column="update_time" />
|
|
|
+ <result property="updateBy" column="update_by" />
|
|
|
+ <result property="remark" column="remark" />
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <sql id="selectWxSopLogsVo">
|
|
|
+ select id, type, sop_id, sop_user_id, send_type, generate_type, account_id, wx_contact_id, wx_contact_name, wx_room_id, wx_room_name, fs_user_id, send_status, send_remark, send_sort, expiration_time, create_time, create_by, update_time, update_by, remark from wx_sop_logs
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <select id="selectWxSopLogsList" parameterType="WxSopLogs" resultMap="WxSopLogsResult">
|
|
|
+ <include refid="selectWxSopLogsVo"/>
|
|
|
+ <where>
|
|
|
+ <if test="type != null "> and type = #{type}</if>
|
|
|
+ <if test="sopId != null "> and sop_id = #{sopId}</if>
|
|
|
+ <if test="sopUserId != null "> and sop_user_id = #{sopUserId}</if>
|
|
|
+ <if test="sendType != null "> and send_type = #{sendType}</if>
|
|
|
+ <if test="generateType != null "> and generate_type = #{generateType}</if>
|
|
|
+ <if test="accountId != null "> and account_id = #{accountId}</if>
|
|
|
+ <if test="wxContactId != null "> and wx_contact_id = #{wxContactId}</if>
|
|
|
+ <if test="wxContactName != null and wxContactName != ''"> and wx_contact_name like concat('%', #{wxContactName}, '%')</if>
|
|
|
+ <if test="wxRoomId != null "> and wx_room_id = #{wxRoomId}</if>
|
|
|
+ <if test="wxRoomName != null and wxRoomName != ''"> and wx_room_name like concat('%', #{wxRoomName}, '%')</if>
|
|
|
+ <if test="fsUserId != null "> and fs_user_id = #{fsUserId}</if>
|
|
|
+ <if test="sendStatus != null "> and send_status = #{sendStatus}</if>
|
|
|
+ <if test="sendRemark != null and sendRemark != ''"> and send_remark = #{sendRemark}</if>
|
|
|
+ <if test="sendSort != null "> and send_sort = #{sendSort}</if>
|
|
|
+ <if test="expirationTime != null "> and expiration_time = #{expirationTime}</if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectWxSopLogsById" parameterType="Long" resultMap="WxSopLogsResult">
|
|
|
+ <include refid="selectWxSopLogsVo"/>
|
|
|
+ where id = #{id}
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <insert id="insertWxSopLogs" parameterType="WxSopLogs" useGeneratedKeys="true" keyProperty="id">
|
|
|
+ insert into wx_sop_logs
|
|
|
+ <trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
+ <if test="type != null">type,</if>
|
|
|
+ <if test="sopId != null">sop_id,</if>
|
|
|
+ <if test="sopUserId != null">sop_user_id,</if>
|
|
|
+ <if test="sendType != null">send_type,</if>
|
|
|
+ <if test="generateType != null">generate_type,</if>
|
|
|
+ <if test="accountId != null">account_id,</if>
|
|
|
+ <if test="wxContactId != null">wx_contact_id,</if>
|
|
|
+ <if test="wxContactName != null">wx_contact_name,</if>
|
|
|
+ <if test="wxRoomId != null">wx_room_id,</if>
|
|
|
+ <if test="wxRoomName != null">wx_room_name,</if>
|
|
|
+ <if test="fsUserId != null">fs_user_id,</if>
|
|
|
+ <if test="sendStatus != null">send_status,</if>
|
|
|
+ <if test="sendRemark != null">send_remark,</if>
|
|
|
+ <if test="sendSort != null">send_sort,</if>
|
|
|
+ <if test="expirationTime != null">expiration_time,</if>
|
|
|
+ <if test="createTime != null">create_time,</if>
|
|
|
+ <if test="createBy != null">create_by,</if>
|
|
|
+ <if test="updateTime != null">update_time,</if>
|
|
|
+ <if test="updateBy != null">update_by,</if>
|
|
|
+ <if test="remark != null">remark,</if>
|
|
|
+ </trim>
|
|
|
+ <trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
+ <if test="type != null">#{type},</if>
|
|
|
+ <if test="sopId != null">#{sopId},</if>
|
|
|
+ <if test="sopUserId != null">#{sopUserId},</if>
|
|
|
+ <if test="sendType != null">#{sendType},</if>
|
|
|
+ <if test="generateType != null">#{generateType},</if>
|
|
|
+ <if test="accountId != null">#{accountId},</if>
|
|
|
+ <if test="wxContactId != null">#{wxContactId},</if>
|
|
|
+ <if test="wxContactName != null">#{wxContactName},</if>
|
|
|
+ <if test="wxRoomId != null">#{wxRoomId},</if>
|
|
|
+ <if test="wxRoomName != null">#{wxRoomName},</if>
|
|
|
+ <if test="fsUserId != null">#{fsUserId},</if>
|
|
|
+ <if test="sendStatus != null">#{sendStatus},</if>
|
|
|
+ <if test="sendRemark != null">#{sendRemark},</if>
|
|
|
+ <if test="sendSort != null">#{sendSort},</if>
|
|
|
+ <if test="expirationTime != null">#{expirationTime},</if>
|
|
|
+ <if test="createTime != null">#{createTime},</if>
|
|
|
+ <if test="createBy != null">#{createBy},</if>
|
|
|
+ <if test="updateTime != null">#{updateTime},</if>
|
|
|
+ <if test="updateBy != null">#{updateBy},</if>
|
|
|
+ <if test="remark != null">#{remark},</if>
|
|
|
+ </trim>
|
|
|
+ </insert>
|
|
|
+ <insert id="batchInsertWxSopLogs" parameterType="java.util.List">
|
|
|
+ INSERT INTO wx_sop_logs
|
|
|
+ (
|
|
|
+ type, sop_id, sop_user_id, send_type, generate_type, account_id,
|
|
|
+ wx_contact_id, wx_contact_name, wx_room_id, wx_room_name, fs_user_id,
|
|
|
+ send_status, send_remark, send_sort, expiration_time, create_time,
|
|
|
+ create_by, update_time, update_by, remark, content_json, send_time
|
|
|
+ )
|
|
|
+ VALUES
|
|
|
+ <foreach collection="list" item="log" separator=",">
|
|
|
+ (
|
|
|
+ #{log.type}, #{log.sopId}, #{log.sopUserId}, #{log.sendType}, #{log.generateType},
|
|
|
+ #{log.accountId}, #{log.wxContactId}, #{log.wxContactName}, #{log.wxRoomId},
|
|
|
+ #{log.wxRoomName}, #{log.fsUserId}, #{log.sendStatus}, #{log.sendRemark},
|
|
|
+ #{log.sendSort}, #{log.expirationTime}, #{log.createTime}, #{log.createBy},
|
|
|
+ #{log.updateTime}, #{log.updateBy}, #{log.remark}, #{log.contentJson}, #{log.sendTime}
|
|
|
+ )
|
|
|
+ </foreach>
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <update id="updateWxSopLogs" parameterType="WxSopLogs">
|
|
|
+ update wx_sop_logs
|
|
|
+ <trim prefix="SET" suffixOverrides=",">
|
|
|
+ <if test="type != null">type = #{type},</if>
|
|
|
+ <if test="sopId != null">sop_id = #{sopId},</if>
|
|
|
+ <if test="sopUserId != null">sop_user_id = #{sopUserId},</if>
|
|
|
+ <if test="sendType != null">send_type = #{sendType},</if>
|
|
|
+ <if test="generateType != null">generate_type = #{generateType},</if>
|
|
|
+ <if test="accountId != null">account_id = #{accountId},</if>
|
|
|
+ <if test="wxContactId != null">wx_contact_id = #{wxContactId},</if>
|
|
|
+ <if test="wxContactName != null">wx_contact_name = #{wxContactName},</if>
|
|
|
+ <if test="wxRoomId != null">wx_room_id = #{wxRoomId},</if>
|
|
|
+ <if test="wxRoomName != null">wx_room_name = #{wxRoomName},</if>
|
|
|
+ <if test="fsUserId != null">fs_user_id = #{fsUserId},</if>
|
|
|
+ <if test="sendStatus != null">send_status = #{sendStatus},</if>
|
|
|
+ <if test="sendRemark != null">send_remark = #{sendRemark},</if>
|
|
|
+ <if test="sendSort != null">send_sort = #{sendSort},</if>
|
|
|
+ <if test="expirationTime != null">expiration_time = #{expirationTime},</if>
|
|
|
+ <if test="createTime != null">create_time = #{createTime},</if>
|
|
|
+ <if test="createBy != null">create_by = #{createBy},</if>
|
|
|
+ <if test="updateTime != null">update_time = #{updateTime},</if>
|
|
|
+ <if test="updateBy != null">update_by = #{updateBy},</if>
|
|
|
+ <if test="remark != null">remark = #{remark},</if>
|
|
|
+ </trim>
|
|
|
+ where id = #{id}
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <delete id="deleteWxSopLogsById" parameterType="Long">
|
|
|
+ delete from wx_sop_logs where id = #{id}
|
|
|
+ </delete>
|
|
|
+
|
|
|
+ <delete id="deleteWxSopLogsByIds" parameterType="String">
|
|
|
+ delete from wx_sop_logs where id in
|
|
|
+ <foreach item="id" collection="array" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </delete>
|
|
|
+
|
|
|
+ <resultMap type="com.fs.wx.sop.vo.WxSopLogsListVO" id="WxSopLogsListVOResult">
|
|
|
+ <result property="id" column="id" />
|
|
|
+ <result property="sopId" column="sop_id" />
|
|
|
+ <result property="sopUserId" column="sop_user_id" />
|
|
|
+ <result property="accountId" column="account_id" />
|
|
|
+ <result property="accountName" column="account_name" />
|
|
|
+ <result property="wxContactId" column="wx_contact_id" />
|
|
|
+ <result property="wxContactName" column="wx_contact_name" />
|
|
|
+ <result property="tagNames" column="tag_names" />
|
|
|
+ <result property="wxRoomId" column="wx_room_id" />
|
|
|
+ <result property="wxRoomName" column="wx_room_name" />
|
|
|
+ <result property="type" column="type" />
|
|
|
+ <result property="sendType" column="send_type" />
|
|
|
+ <result property="generateType" column="generate_type" />
|
|
|
+ <result property="sendStatus" column="send_status" />
|
|
|
+ <result property="sendRemark" column="send_remark" />
|
|
|
+ <result property="sendSort" column="send_sort" />
|
|
|
+ <result property="expirationTime" column="expiration_time" />
|
|
|
+ <result property="createTime" column="create_time" />
|
|
|
+ <result property="realSendTime" column="real_send_time" />
|
|
|
+ <result property="remark" column="remark" />
|
|
|
+ <result property="fsUserId" column="fs_user_id" />
|
|
|
+ <result property="companyId" column="company_id" />
|
|
|
+ <result property="sendTime" column="send_time" />
|
|
|
+ <result property="contentJson" column="content_json" />
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <select id="selectWxSopLogsListBySopId" parameterType="com.fs.wx.sop.params.WxSopLogsParam" resultMap="WxSopLogsListVOResult">
|
|
|
+ SELECT
|
|
|
+ wsl.id, wsl.sop_id, wsl.sop_user_id, wsl.account_id,
|
|
|
+ wsl.wx_contact_id, wsl.wx_contact_name, wsui.tag_names,
|
|
|
+ wsl.wx_room_id, wsl.wx_room_name, wsl.type, wsl.send_type,
|
|
|
+ wsl.generate_type, wsl.send_status, wsl.send_remark, wsl.send_sort,
|
|
|
+ wsl.expiration_time, wsl.create_time, wsl.update_time as real_send_time,
|
|
|
+ wsl.remark, wsl.fs_user_id, wsl.send_time, wsl.content_json
|
|
|
+ FROM wx_sop_logs wsl
|
|
|
+ LEFT JOIN wx_sop_user_info wsui ON wsl.sop_id = wsui.sop_id AND wsl.wx_contact_id = wsui.wx_contact_id
|
|
|
+ <where>
|
|
|
+ <if test="sopId != null">AND wsl.sop_id = #{sopId}</if>
|
|
|
+ <if test="sopUserId != null">AND wsl.sop_user_id = #{sopUserId}</if>
|
|
|
+ <if test="accountId != null">AND wsl.account_id = #{accountId}</if>
|
|
|
+ <if test="accountIdList != null and accountIdList.size() > 0">
|
|
|
+ AND wsl.account_id IN
|
|
|
+ <foreach collection="accountIdList" item="accId" open="(" separator="," close=")">
|
|
|
+ #{accId}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="wxContactName != null and wxContactName != ''">AND wsl.wx_contact_name LIKE CONCAT('%', #{wxContactName}, '%')</if>
|
|
|
+ <if test="wxContactId != null">AND wsl.wx_contact_id = #{wxContactId}</if>
|
|
|
+ <if test="sendStatus != null">AND wsl.send_status = #{sendStatus}</if>
|
|
|
+ <if test="sendType != null">AND wsl.send_type = #{sendType}</if>
|
|
|
+ <if test="type != null">AND wsl.type = #{type}</if>
|
|
|
+ <if test="scheduleStartTime != null and scheduleStartTime != ''">AND wsl.create_time >= #{scheduleStartTime}</if>
|
|
|
+ <if test="scheduleEndTime != null and scheduleEndTime != ''">AND wsl.create_time <= #{scheduleEndTime}</if>
|
|
|
+ </where>
|
|
|
+ ORDER BY wsl.create_time DESC
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectByWxId" resultType="com.fs.wx.sop.domain.WxSopLogs">
|
|
|
+ select ql.*,
|
|
|
+ qs.name,
|
|
|
+ qs.expiry_time as expiryTime
|
|
|
+ from wx_sop_logs ql
|
|
|
+ left join wx_sop qs on qs.id = ql.sop_id
|
|
|
+ where ql.account_id = #{id}
|
|
|
+ and ql.send_status = 0
|
|
|
+ <![CDATA[
|
|
|
+ and ql.send_time <= now()
|
|
|
+ ]]>
|
|
|
+ order by ql.send_time limit 30
|
|
|
+ </select>
|
|
|
+</mapper>
|