79 lines
2.6 KiB
XML
79 lines
2.6 KiB
XML
<?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.imyeyu.api.modules.gao.mapper.GaoCustomerFollowUpReminderMapper">
|
|
<sql id="queryWhere">
|
|
`r`.`deleted_at` IS NULL
|
|
<if test="page.storeId != null and page.storeId != ''">
|
|
AND `r`.`store_id` = #{page.storeId}
|
|
</if>
|
|
<if test="page.customerId != null and page.customerId != ''">
|
|
AND `r`.`customer_id` = #{page.customerId}
|
|
</if>
|
|
<if test="page.responsibleUserId != null and page.responsibleUserId != ''">
|
|
AND `r`.`responsible_user_id` = #{page.responsibleUserId}
|
|
</if>
|
|
<if test="page.status != null">
|
|
AND `r`.`status` = #{page.status}
|
|
</if>
|
|
<if test="page.beginRemindAt != null">
|
|
AND `r`.`remind_at` >= #{page.beginRemindAt}
|
|
</if>
|
|
<if test="page.endRemindAt != null">
|
|
AND `r`.`remind_at` <= #{page.endRemindAt}
|
|
</if>
|
|
</sql>
|
|
|
|
<select id="countByQuery" resultType="long">
|
|
SELECT COUNT(1)
|
|
FROM `gao_customer_follow_up_reminder` `r`
|
|
WHERE <include refid="queryWhere"/>
|
|
</select>
|
|
|
|
<select id="selectByQuery" resultType="com.imyeyu.api.modules.gao.entity.GaoCustomerFollowUpReminder">
|
|
SELECT `r`.*
|
|
FROM `gao_customer_follow_up_reminder` `r`
|
|
WHERE <include refid="queryWhere"/>
|
|
ORDER BY `r`.`remind_at` ASC, `r`.`created_at` ASC, `r`.`id` ASC
|
|
LIMIT #{page.offset}, #{page.limit}
|
|
</select>
|
|
|
|
<select id="selectPendingSmsByRange" resultType="com.imyeyu.api.modules.gao.entity.GaoCustomerFollowUpReminder">
|
|
SELECT *
|
|
FROM `gao_customer_follow_up_reminder`
|
|
WHERE `status` = 'PENDING'
|
|
AND `deleted_at` IS NULL
|
|
AND `sms_notify_enabled` = 1
|
|
AND `sms_notify_detail_id` IS NULL
|
|
AND `remind_at` >= #{beginAt}
|
|
AND `remind_at` < #{endAt}
|
|
ORDER BY `store_id`, `responsible_user_id`, `remind_at`, `created_at`, `id`
|
|
FOR UPDATE
|
|
</select>
|
|
|
|
<update id="complete">
|
|
UPDATE `gao_customer_follow_up_reminder`
|
|
SET `status` = 'COMPLETED',
|
|
`updated_by` = #{updatedBy},
|
|
`completed_by` = #{completedBy},
|
|
`completed_at` = #{completedAt},
|
|
`updated_at` = #{completedAt}
|
|
WHERE `id` = #{id}
|
|
AND `status` = 'PENDING'
|
|
AND `deleted_at` IS NULL
|
|
</update>
|
|
|
|
<update id="bindSmsNotifyDetailId">
|
|
UPDATE `gao_customer_follow_up_reminder`
|
|
SET `sms_notify_detail_id` = #{smsNotifyDetailId},
|
|
`updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
|
|
WHERE `id` IN
|
|
<foreach collection="idList" item="id" separator="," open="(" close=")">
|
|
#{id}
|
|
</foreach>
|
|
AND `status` = 'PENDING'
|
|
AND `deleted_at` IS NULL
|
|
AND `sms_notify_enabled` = 1
|
|
AND `sms_notify_detail_id` IS NULL
|
|
</update>
|
|
</mapper>
|