<?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.smartor.mapper.MchFollowupPlanItemMapper">
|
|
<resultMap id="MchFollowupPlanItemResult" type="com.smartor.domain.MchFollowupPlanItem">
|
<id property="id" column="id"/>
|
<result property="planId" column="plan_id"/>
|
<result property="seq" column="seq"/>
|
<result property="sendType" column="send_type"/>
|
<result property="sendTime" column="send_time"/>
|
<result property="titleName" column="title_name"/>
|
<result property="content" column="content"/>
|
<result property="templateId" column="template_id"/>
|
<result property="url" column="url"/>
|
<result property="sendStatus" column="send_status"/>
|
<result property="retryCount" column="retry_count"/>
|
<result property="nextRetryTime" column="next_retry_time"/>
|
<result property="sendTimeActual" column="send_time_actual"/>
|
<result property="resultMsg" column="result_msg"/>
|
<result property="providerMsgId" column="provider_msg_id"/>
|
<result property="createTime" column="create_time"/>
|
<result property="updateTime" column="update_time"/>
|
</resultMap>
|
|
<sql id="selectItemVo">
|
select id, plan_id, seq, send_type, send_time, title_name, content, template_id, url,
|
send_status, retry_count, next_retry_time, send_time_actual,
|
result_msg, provider_msg_id, create_time, update_time
|
from mch_followup_plan_item
|
</sql>
|
|
<insert id="insertMchFollowupPlanItem" parameterType="com.smartor.domain.MchFollowupPlanItem"
|
useGeneratedKeys="true" keyProperty="id">
|
insert into mch_followup_plan_item
|
(plan_id, seq, send_type, send_time, title_name, content, template_id, url,
|
send_status, retry_count, next_retry_time, send_time_actual,
|
result_msg, provider_msg_id, create_time, update_time)
|
values
|
(#{planId}, #{seq}, #{sendType}, #{sendTime}, #{titleName}, #{content}, #{templateId}, #{url},
|
#{sendStatus}, #{retryCount}, #{nextRetryTime}, #{sendTimeActual},
|
#{resultMsg}, #{providerMsgId}, #{createTime}, #{updateTime})
|
</insert>
|
|
<update id="updateMchFollowupPlanItem" parameterType="com.smartor.domain.MchFollowupPlanItem">
|
update mch_followup_plan_item
|
<set>
|
<if test="sendType != null">send_type = #{sendType},</if>
|
<if test="sendTime != null">send_time = #{sendTime},</if>
|
<if test="titleName != null">title_name = #{titleName},</if>
|
<if test="content != null">content = #{content},</if>
|
<if test="templateId != null">template_id = #{templateId},</if>
|
<if test="url != null">url = #{url},</if>
|
<if test="sendStatus != null">send_status = #{sendStatus},</if>
|
<if test="retryCount != null">retry_count = #{retryCount},</if>
|
<if test="nextRetryTime != null">next_retry_time = #{nextRetryTime},</if>
|
<if test="sendTimeActual != null">send_time_actual = #{sendTimeActual},</if>
|
<if test="resultMsg != null">result_msg = #{resultMsg},</if>
|
<if test="providerMsgId != null">provider_msg_id = #{providerMsgId},</if>
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
</set>
|
where id = #{id}
|
</update>
|
|
<update id="updateSendResult" parameterType="com.smartor.domain.MchFollowupPlanItem">
|
update mch_followup_plan_item
|
set send_status = #{sendStatus,jdbcType=CHAR},
|
retry_count = #{retryCount,jdbcType=INTEGER},
|
next_retry_time = #{nextRetryTime,jdbcType=TIMESTAMP},
|
send_time_actual = #{sendTimeActual,jdbcType=TIMESTAMP},
|
result_msg = #{resultMsg,jdbcType=VARCHAR},
|
provider_msg_id = #{providerMsgId,jdbcType=VARCHAR},
|
update_time = #{updateTime,jdbcType=TIMESTAMP}
|
where id = #{id}
|
</update>
|
|
<select id="selectMchFollowupPlanItemById" resultMap="MchFollowupPlanItemResult">
|
<include refid="selectItemVo"/>
|
where id = #{id}
|
</select>
|
|
<select id="selectByPlanId" resultMap="MchFollowupPlanItemResult">
|
<include refid="selectItemVo"/>
|
where plan_id = #{planId}
|
order by seq asc, id asc
|
</select>
|
|
<select id="selectDueItems" resultMap="MchFollowupPlanItemResult">
|
select i.id, i.plan_id, i.seq, i.send_type, i.send_time, i.title_name, i.content,
|
i.template_id, i.url, i.send_status, i.retry_count, i.next_retry_time,
|
i.send_time_actual, i.result_msg, i.provider_msg_id, i.create_time, i.update_time
|
from mch_followup_plan_item i
|
inner join mch_followup_plan p on p.id = i.plan_id
|
where p.orgid = #{orgid}
|
and p.plan_status = '0'
|
and i.send_status = '0'
|
and i.send_time <= #{now}
|
and (i.next_retry_time is null or i.next_retry_time <= #{now})
|
order by i.send_time asc, i.seq asc, i.id asc
|
limit #{limit}
|
</select>
|
|
<update id="claimItem">
|
update mch_followup_plan_item
|
set send_status = '1',
|
update_time = #{now}
|
where id = #{id}
|
and send_status = '0'
|
</update>
|
|
<update id="cancelPendingByPlanId">
|
update mch_followup_plan_item
|
set send_status = '5',
|
result_msg = '计划重建,取消未发送节点',
|
update_time = #{now}
|
where plan_id = #{planId}
|
and send_status = '0'
|
</update>
|
|
<select id="countPendingByPlanId" resultType="int">
|
select count(1)
|
from mch_followup_plan_item
|
where plan_id = #{planId}
|
and send_status in ('0', '1')
|
</select>
|
|
</mapper>
|