ai_scheduler/sql/09_ai_advice_remind_task.sql

26 lines
1.7 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

CREATE TABLE `ai_advice_remind_task` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '自增主键',
`project_id` int NOT NULL DEFAULT '0' COMMENT '项目ID',
`advicer_id` int NOT NULL DEFAULT '0' COMMENT '所属销售ID',
`client_id` varchar(64) NOT NULL DEFAULT '' COMMENT '客户画像ID(Mongo advicer_client _id hex)',
`wxid` varchar(64) NOT NULL DEFAULT '' COMMENT '客户微信ID',
`self_wxid` varchar(64) NOT NULL DEFAULT '' COMMENT '销售本人微信ID',
`app_id` varchar(64) NOT NULL DEFAULT '' COMMENT '销售登录设备 appid(发消息用)',
`title` varchar(255) NOT NULL DEFAULT '' COMMENT '提醒标题',
`detail` text COMMENT '提醒详情/原文摘录',
`due_at` datetime NOT NULL COMMENT '到点时间(绝对时间)',
`status` varchar(20) NOT NULL DEFAULT 'pending' COMMENT '状态:pending 待执行 / done 已发送 / cancelled 已取消 / failed 执行失败',
`source` varchar(20) NOT NULL DEFAULT 'ai' COMMENT '来源:ai 复盘抽取 / manual 手动补录',
`source_msg_ids` text COMMENT '来源消息ID列表(逗号分隔,便于追溯)',
`result` text COMMENT '实际发送给客户的内容',
`err_msg` varchar(500) NOT NULL DEFAULT '' COMMENT '失败原因',
`done_at` datetime DEFAULT NULL COMMENT '完成/取消时间',
`create_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`),
KEY `idx_status_due` (`status`,`due_at`),
KEY `idx_wxid` (`wxid`),
KEY `idx_client` (`client_id`),
KEY `idx_project` (`project_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='定时提醒(到点由 AI 主动发消息提醒客户)';