Files
zyt/server/sql/1.9.20260709/create_qywx_external_contact_follow.sql
T
2026-07-15 09:07:29 +08:00

18 lines
1.5 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.
-- 企微客户「现存跟进关系」表:external_userid × follow_user_id 一行,带企微 createtime
-- 用途:客户列表「任意添加(企微口径)」时间筛选——企微后台的时间筛选按"现存跟进关系的添加时间"
-- 匹配(关系被删后该客户不再出现在对应日期下),follow_users JSON 无法做 SQL 范围筛选,故落关系表。
-- 维护:CustomerLogic 在每次 UPSERT 客户时同步;软删客户时清空该客户的关系行。
-- 回填:执行 php think 版本回填脚本或 server/backfill_follow_relations.php(从 follow_users JSON 解析)。
CREATE TABLE IF NOT EXISTS `zyt_qywx_external_contact_follow` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`external_userid` varchar(64) NOT NULL DEFAULT '' COMMENT '外部联系人 external_userid',
`follow_user_id` varchar(64) NOT NULL DEFAULT '' COMMENT '跟进员工企微 userid',
`createtime` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '该员工添加此客户的时间(企微 follow_user.createtime,秒)',
`create_time` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '本行创建时间',
`update_time` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '本行更新时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_ext_user` (`external_userid`, `follow_user_id`),
KEY `idx_createtime` (`createtime`),
KEY `idx_user` (`follow_user_id`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT = '企微客户现存跟进关系(企微口径时间筛选用)';