ai_scheduler/sql/10_ai_advice_deal_lead.sql

26 lines
1.8 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_deal_lead` (
`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',
`lead_type` varchar(20) NOT NULL DEFAULT '' COMMENT '线索类型:visit 约定到访 / deal 约定成交 / payment 约定付款',
`title` varchar(255) NOT NULL DEFAULT '' COMMENT '线索标题',
`detail` text COMMENT '线索详情/原文摘录',
`expect_at` datetime NOT NULL COMMENT '期望/约定时间(绝对时间)',
`status` varchar(20) NOT NULL DEFAULT 'pending' COMMENT '状态:pending 待跟进 / done 已完成 / cancelled 已取消',
`source` varchar(20) NOT NULL DEFAULT 'ai' COMMENT '来源:ai 复盘抽取 / manual 手动补录',
`source_msg_ids` text COMMENT '来源消息ID列表(逗号分隔,便于追溯)',
`result` text 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_expect` (`status`,`expect_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='成交线索(约定到访/成交/付款,供销售跟进并注入后续对话)';