add customer followup
This commit is contained in:
+26
@@ -0,0 +1,26 @@
|
||||
CREATE TABLE `gao_customer_follow_up_reminder` (
|
||||
`id` VARCHAR(36) NOT NULL,
|
||||
`store_id` VARCHAR(36) NOT NULL COMMENT '门店 ID',
|
||||
`customer_id` VARCHAR(36) NOT NULL COMMENT '客户 ID',
|
||||
`responsible_user_id` VARCHAR(36) NOT NULL COMMENT '负责人用户 ID',
|
||||
`content` TEXT NOT NULL COMMENT '跟进内容,纯文本',
|
||||
`remind_at` BIGINT NOT NULL COMMENT '提醒时间,Unix 毫秒时间戳',
|
||||
`status` VARCHAR(32) NOT NULL COMMENT 'PENDING 待完成,COMPLETED 已完成',
|
||||
`internal_notify_enabled` TINYINT(1) NOT NULL DEFAULT 0 COMMENT 'true 为发送站内通知',
|
||||
`sms_notify_enabled` TINYINT(1) NOT NULL DEFAULT 0 COMMENT 'true 为发送短信通知',
|
||||
`internal_notify_detail_id` VARCHAR(36) NULL COMMENT '站内通知详情 ID',
|
||||
`sms_notify_detail_id` VARCHAR(36) NULL COMMENT '短信聚合通知详情 ID,可被多条提醒共享',
|
||||
`completed_by` VARCHAR(36) NULL COMMENT '完成人用户 ID',
|
||||
`completed_at` BIGINT NULL COMMENT '完成时间',
|
||||
`created_by` VARCHAR(36) NOT NULL COMMENT '创建人用户 ID',
|
||||
`updated_by` VARCHAR(36) NULL COMMENT '最后修改人用户 ID',
|
||||
`created_at` BIGINT NOT NULL,
|
||||
`updated_at` BIGINT NULL,
|
||||
`deleted_at` BIGINT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_gao_customer_follow_up_reminder_customer_time` (`store_id`, `customer_id`, `deleted_at`, `remind_at`),
|
||||
KEY `idx_gao_customer_follow_up_reminder_responsible_time` (`store_id`, `responsible_user_id`, `status`, `deleted_at`, `remind_at`),
|
||||
KEY `idx_gao_customer_follow_up_reminder_sms_batch` (`store_id`, `sms_notify_enabled`, `status`, `deleted_at`, `remind_at`, `sms_notify_detail_id`),
|
||||
KEY `idx_gao_customer_follow_up_reminder_internal_detail` (`internal_notify_detail_id`),
|
||||
KEY `idx_gao_customer_follow_up_reminder_sms_detail` (`sms_notify_detail_id`)
|
||||
) COMMENT='GAO 客户跟进提醒';
|
||||
@@ -26,6 +26,17 @@
|
||||
ON DUPLICATE KEY UPDATE `id` = `id`
|
||||
</insert>
|
||||
|
||||
<select id="selectByBusinessKey" resultType="com.imyeyu.api.modules.common.entity.Notify">
|
||||
SELECT *
|
||||
FROM `notify`
|
||||
WHERE `biz_type` = #{bizType}
|
||||
AND `biz_reminded_type` = #{bizRemindedType}
|
||||
AND `biz_reminded_key` = #{bizRemindedKey}
|
||||
AND `deleted_at` IS NULL
|
||||
ORDER BY `created_at` DESC, `id` DESC
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="selectManagementPage" resultType="com.imyeyu.api.modules.common.vo.NotifyManagementItem">
|
||||
SELECT
|
||||
n.`id`,
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
<?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>
|
||||
Reference in New Issue
Block a user