DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `pid` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '父级ID',
 `name` varchar(125) NOT NULL DEFAULT '' COMMENT '账户',
 `password` varchar(50) NOT NULL DEFAULT '' COMMENT '密码，md5加密',
 `nickname` varchar(50) NOT NULL DEFAULT '' COMMENT '显示名称',
 `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
 `expired_at` timestamp NULL DEFAULT NULL COMMENT '过期时间',
 `updated_at` timestamp NULL DEFAULT NULL COMMENT '更新时间',
 `deleted_at` timestamp NULL DEFAULT NULL COMMENT '删除时间',
 `avator` varchar(500) NOT NULL DEFAULT '' COMMENT '客服头像',
 `rec_num` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '正在接待数量',
 `online_status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '在线状态，1在线，2离线',
 `status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '开启状态，0正常，1关闭',
 `agent_num` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '子账号个数',
 `email` varchar(125) NOT NULL DEFAULT '' COMMENT '绑定邮箱',
 `company_pic` varchar(500) NOT NULL DEFAULT '' COMMENT '宣传图',
 `tel` varchar(125) NOT NULL DEFAULT '' COMMENT '绑定手机',
 `uuid` varchar(125) NOT NULL DEFAULT '' COMMENT '企业uuid',
 PRIMARY KEY (`id`) COMMENT '自增主键索引',
 UNIQUE KEY `idx_name` (`name`) COMMENT '账户唯一索引',
 KEY `idx_tel` (`tel`) COMMENT '手机号索引',
 KEY `idx_email` (`email`) COMMENT '邮箱索引',
 KEY `idx_rec_num` (`rec_num`) COMMENT '接待数索引',
 KEY `idx_pid` (`pid`) COMMENT '父级ID索引',
 KEY `idx_uuid` (`uuid`) COMMENT 'uuid索引',
 KEY `idx_updated_at` (`updated_at`) COMMENT '更新时间索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '客服用户表';
DROP TABLE IF EXISTS `user_douyin`;
CREATE TABLE `user_douyin` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `kefu_name` varchar(100) NOT NULL DEFAULT ''  COMMENT '客服账户',
 `nickname` varchar(500) NOT NULL DEFAULT ''  COMMENT '抖音昵称',
 `avatar` varchar(500) NOT NULL DEFAULT ''  COMMENT '抖音头像',
 `open_id` varchar(500) NOT NULL DEFAULT ''  COMMENT '抖音OpenId',
 `union_id` varchar(500) NOT NULL DEFAULT ''  COMMENT '抖音union_id',
 `access_token` varchar(500) NOT NULL DEFAULT ''  COMMENT '抖音AccessToken',
 `expires_in` datetime   COMMENT '抖音AccessToken过期时间',
 `refresh_token` varchar(500) NOT NULL DEFAULT ''  COMMENT '抖音refresh_token',
 `refresh_expires_in` datetime  COMMENT '抖音refresh_token过期时间',
 `client_token` varchar(500) NOT NULL DEFAULT ''  COMMENT '抖音client_token',
 `client_token_expires` datetime   COMMENT '抖音client_token过期时间',
 `ent_id` varchar(100) NOT NULL DEFAULT ''  COMMENT '企业ID',
 `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP  COMMENT '创建时间',
 PRIMARY KEY (`id`) COMMENT '自增主键索引',
 KEY `kefu_name` (`kefu_name`)  COMMENT '客服账户索引',
 KEY `ent_id` (`ent_id`)  COMMENT '企业ID索引',
 KEY `open_id` (`open_id`)  COMMENT '抖音OpenId索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT '客服抖音绑定表';
DROP TABLE IF EXISTS `user_attr`;
CREATE TABLE `user_attr` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `kefu_name` varchar(100) NOT NULL DEFAULT ''  COMMENT '客服账户',
 `auth_key` varchar(100) NOT NULL DEFAULT ''  COMMENT 'authKey',
 `id_card` varchar(100) NOT NULL DEFAULT ''  COMMENT '身份证号码',
 `ent_id` varchar(100) NOT NULL DEFAULT ''  COMMENT '企业ID',
 `good_num` int(11) unsigned NOT NULL DEFAULT 0  COMMENT '评价好评数量',
 `normal_num` int(11) unsigned NOT NULL DEFAULT 0  COMMENT '评价中评数量',
 `bad_num` int(11) unsigned NOT NULL DEFAULT 0  COMMENT '评价差评数量',
 `aigc_session_score` int(11) unsigned NOT NULL DEFAULT 0  COMMENT 'aigc积分',
 `money` int(11) unsigned NOT NULL DEFAULT 0  COMMENT '总金额',
 `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP  COMMENT '创建时间',
 PRIMARY KEY (`id`) COMMENT '自增主键索引',
 KEY `kefu_name` (`kefu_name`)  COMMENT '客服账户索引',
 KEY `ent_id` (`ent_id`)  COMMENT '企业ID索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT '客服属性表';
DROP TABLE IF EXISTS `rate`;
CREATE TABLE `rate` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `kefu_name` varchar(100) NOT NULL DEFAULT ''  COMMENT '客服账户',
 `kefu_nickname` varchar(100) NOT NULL DEFAULT ''  COMMENT '客服昵称',
 `visitor_id` varchar(100) NOT NULL DEFAULT ''  COMMENT '访客id',
 `content` varchar(1000) NOT NULL DEFAULT ''  COMMENT '评价内容',
 `ent_id` varchar(100) NOT NULL DEFAULT ''  COMMENT '企业ID',
 `score` int(11) unsigned NOT NULL DEFAULT 0  COMMENT '评价分数',
 `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP  COMMENT '创建时间',
 PRIMARY KEY (`id`) COMMENT '自增主键索引',
 KEY `kefu_name` (`kefu_name`)  COMMENT '客服账户索引',
 KEY `ent_id` (`ent_id`)  COMMENT '企业ID索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT '评价表';
DROP TABLE IF EXISTS `up_down_line`;
CREATE TABLE `up_down_line` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `kefu_name` varchar(100) NOT NULL DEFAULT ''  COMMENT '客服账户',
 `ent_id` varchar(100) NOT NULL DEFAULT ''  COMMENT '企业ID',
 `online_status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '在线状态，1在线，2离线',
 `client_ip` varchar(100) NOT NULL DEFAULT ''  COMMENT 'ip地址',
 `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP  COMMENT '创建时间',
 PRIMARY KEY (`id`) COMMENT '自增主键索引',
 KEY `kefu_name` (`kefu_name`)  COMMENT '客服账户索引',
 KEY `ent_id` (`ent_id`)  COMMENT '企业ID索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT '上下线统计表';
DROP TABLE IF EXISTS `fly_log`;
CREATE TABLE `fly_log` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `ent_id` varchar(100) NOT NULL DEFAULT ''  COMMENT '企业ID',
 `log_type` varchar(100) NOT NULL DEFAULT ''  COMMENT '日志类型',
 `log_content` varchar(2048) NOT NULL DEFAULT ''  COMMENT '日志内容',
 `ip_address` varchar(100) NOT NULL DEFAULT ''  COMMENT '用户IP地址',
 `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP  COMMENT '创建时间',
 PRIMARY KEY (`id`) COMMENT '自增主键索引',
  KEY `ent_id` (`ent_id`)  COMMENT '企业ID索引',
  KEY `idx_created_at` (`created_at`)  COMMENT '创建时间索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8  COMMENT '操作日志表';
DROP TABLE IF EXISTS `visitor`;
CREATE TABLE `visitor` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `name` varchar(550) NOT NULL DEFAULT ''  COMMENT '访客显示名称',
 `real_name` varchar(550) NOT NULL DEFAULT ''  COMMENT '访客真实姓名',
 `avator` varchar(500) NOT NULL DEFAULT ''  COMMENT '访客头像',
 `source_ip` varchar(50) NOT NULL DEFAULT ''  COMMENT '访客来源IP',
 `to_id` varchar(50) NOT NULL DEFAULT ''  COMMENT '对接客服账户',
 `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP  COMMENT '创建时间',
 `updated_at` timestamp NULL DEFAULT NULL  COMMENT '更新时间',
 `deleted_at` timestamp NULL DEFAULT NULL  COMMENT '删除时间',
 `visitor_id` varchar(100) NOT NULL DEFAULT ''  COMMENT '访客唯一ID',
 `status` tinyint(4) NOT NULL DEFAULT '0'  COMMENT '访客状态',
 `state` varchar(100) NOT NULL DEFAULT ''  COMMENT '访客状态位',
 `refer` varchar(500) NOT NULL DEFAULT ''  COMMENT '访客来源',
 `city` varchar(100) NOT NULL DEFAULT ''  COMMENT '访客城市',
 `client_ip` varchar(100) NOT NULL DEFAULT ''  COMMENT '访客IP',
 `extra` varchar(2048) NOT NULL DEFAULT '' COMMENT '访客扩展信息',
 `ent_id` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '对接的企业ID',
 `visit_num` int(11) unsigned NOT NULL DEFAULT 1 COMMENT '访客访问次数',
 PRIMARY KEY (`id`) COMMENT '自增主键索引',
 UNIQUE KEY `visitor_id` (`visitor_id`) COMMENT '访客唯一ID索引',
 KEY `to_id` (`to_id`) COMMENT '访客对接客服账户索引',
 KEY `idx_update` (`updated_at`) COMMENT '更新时间索引',
 KEY `idx_ent_id` (`ent_id`) COMMENT '企业ID索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4  COMMENT '访客表';
DROP TABLE IF EXISTS `visitor_ext`;
CREATE TABLE `visitor_ext` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `visitor_id` varchar(100) NOT NULL DEFAULT ''  COMMENT '访客ID',
 `ent_id` int(11) unsigned NOT NULL DEFAULT 0  COMMENT '对接的企业ID',
 `ua` varchar(500) NOT NULL DEFAULT '' COMMENT '访客浏览器UserAgent',
 `title` varchar(256) NOT NULL DEFAULT '' COMMENT '页面标题',
 `url` varchar(1500) NOT NULL DEFAULT '' COMMENT '页面地址',
 `refer` varchar(128) NOT NULL DEFAULT '' COMMENT '页面来源',
 `refer_url` varchar(500) NOT NULL DEFAULT '' COMMENT '页面来源地址',
 `client_ip` varchar(128) NOT NULL DEFAULT '' COMMENT '访客IP',
 `city` varchar(500) NOT NULL DEFAULT '' COMMENT '访客城市',
 `language` varchar(100) NOT NULL DEFAULT ''  COMMENT '浏览器语言',
 `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
 PRIMARY KEY (`id`) COMMENT '自增主键索引',
 KEY `visitor_id` (`visitor_id`) COMMENT '访客ID索引',
 KEY `ent_id` (`ent_id`) COMMENT '企业ID索引',
 KEY `title` (`title`) COMMENT '页面标题索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8  COMMENT '访客扩展表';
DROP TABLE IF EXISTS `visitor_attr`;
CREATE TABLE `visitor_attr` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `visitor_id` varchar(100) NOT NULL DEFAULT '' COMMENT '访客ID',
 `real_name` varchar(100) NOT NULL DEFAULT '' COMMENT '访客真实姓名',
 `tel` varchar(50) NOT NULL DEFAULT '' COMMENT '访客手机号',
 `email` varchar(50) NOT NULL DEFAULT '' COMMENT '访客邮箱',
 `qq` varchar(100) NOT NULL DEFAULT '' COMMENT '访客QQ',
 `wechat` varchar(100) NOT NULL DEFAULT '' COMMENT '访客微信',
 `comment` varchar(500) NOT NULL DEFAULT '' COMMENT '访客备注',
 `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
 `ent_id` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '对接企业ID',
 `max_message_num` varchar(100) NOT NULL DEFAULT '10'  COMMENT '访客最大消息数',
 PRIMARY KEY (`id`) COMMENT '自增主键索引',
 KEY `visitor_id` (`visitor_id`) COMMENT '访客ID索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8  COMMENT '访客属性表';
DROP TABLE IF EXISTS `message`;
CREATE TABLE `message` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `kefu_id` varchar(100) NOT NULL DEFAULT '' COMMENT '客服账户',
 `visitor_id` varchar(100) NOT NULL DEFAULT '' COMMENT '访客ID',
 `content` varchar(2048) NOT NULL DEFAULT '' COMMENT '消息内容',
 `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
 `updated_at` timestamp NULL DEFAULT NULL COMMENT '更新时间',
 `deleted_at` timestamp NULL DEFAULT NULL COMMENT '删除时间',
 `mes_type` enum('kefu','visitor') NOT NULL DEFAULT 'visitor' COMMENT '消息类型：kefu为客服发送，visitor为访客发送',
 `status` enum('read','unread') NOT NULL DEFAULT 'unread' COMMENT '已读状态：read为已读，unread为未读',
 `ent_id` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '客服企业ID',
 PRIMARY KEY (`id`) COMMENT '自增主键索引',
 KEY `kefu_id` (`kefu_id`) COMMENT '客服账户索引',
 KEY `visitor_id` (`visitor_id`) COMMENT '访客ID索引',
 KEY `created_at` (`created_at`) COMMENT '时间索引',
 KEY `idx_kefuid_mestype_status` (`kefu_id`,`mes_type`,`status`) COMMENT '联合索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '消息记录表';

DROP TABLE IF EXISTS `user_role`;
CREATE TABLE `user_role` (
 `id` int(11) NOT  NULL AUTO_INCREMENT,
 `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '客服ID',
 `role_id` int(11) NOT NULL DEFAULT '0' COMMENT '角色ID',
 PRIMARY KEY (`id`) COMMENT '自增主键索引',
 KEY `user_id` (`user_id`) COMMENT '客服ID索引'
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COMMENT '客户角色表';


DROP TABLE IF EXISTS `role`;
CREATE TABLE `role` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(100) NOT NULL DEFAULT '' COMMENT '角色名称',
  `method` varchar(100) NOT NULL DEFAULT '' COMMENT '允许的HTTP方法，*代表全部',
  `path` varchar(2048) NOT NULL DEFAULT '' COMMENT '允许的访客路径，*代表全部',
  `is_super` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '是否为超管，未启用',
   PRIMARY KEY (`id`) COMMENT '自增主键索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT '角色表';
INSERT INTO `role` (`id`, `name`, `method`, `path`, `is_super`) VALUES
(3, '子账号', 'GET', 'GET:/kefuinfo', '0'),
(2, '商家号', '*', '*', '0'),
(1, '管理员', '*', '*', '1');

DROP TABLE IF EXISTS `welcome`;
CREATE TABLE `welcome` (
 `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
 `user_id` varchar(100) NOT NULL DEFAULT '' COMMENT '客服账户',
 `keyword` varchar(100) NOT NULL DEFAULT '' COMMENT '关键词，welcome为默认欢迎；wechat为公众号欢迎语',
 `content` varchar(5000)  COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '欢迎消息内容',
 `is_default` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '是否默认，未启用',
 `delay_second` int(10) unsigned NOT NULL DEFAULT '3' COMMENT '延迟秒数',
 `ctime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
 PRIMARY KEY (`id`) COMMENT '自增主键索引',
 KEY `user_id` (`user_id`) COMMENT '客服账户索引',
 KEY `keyword` (`keyword`) COMMENT '关键词索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT '欢迎消息表';
INSERT INTO `welcome` (`id`, `user_id`, `content`, `is_default`, `ctime`, `keyword`) VALUES
(NULL, 'kefu2', '<p>您好，有什么可以帮您？</p>', 0, '2020-08-24 02:57:49','welcome');

DROP TABLE IF EXISTS `ipblack`;
CREATE TABLE `ipblack` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `ip` varchar(100) NOT NULL DEFAULT '' COMMENT 'IP地址',
 `name` varchar(500) NOT NULL DEFAULT '' COMMENT '名称',
 `create_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
 `kefu_id` varchar(100) NOT NULL DEFAULT '' COMMENT '操作的客服账户',
 `ent_id` varchar(100) NOT NULL DEFAULT '' COMMENT '客服企业ID',
 PRIMARY KEY (`id`) COMMENT '自增主键索引',
 UNIQUE KEY `ip` (`ip`) COMMENT 'IP索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT 'IP黑名单表';
DROP TABLE IF EXISTS `config`;
CREATE TABLE `config` (
 `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
 `conf_name` varchar(255) NOT NULL DEFAULT '' COMMENT '配置项描述',
 `conf_key` varchar(255) NOT NULL DEFAULT '' COMMENT '配置项key',
 `conf_value` text  COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '配置项值',
 PRIMARY KEY (`id`) COMMENT '自增主键索引',
 UNIQUE KEY `conf_key` (`conf_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT '系统配置表';

DROP TABLE IF EXISTS `ent_config`;
CREATE TABLE `ent_config` (
 `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
 `conf_name` varchar(255) NOT NULL DEFAULT '' COMMENT '配置描述',
 `conf_key` varchar(255) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '配置key',
 `conf_value` text COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '配置值',
 `ent_id` varchar(125) NOT NULL DEFAULT '' COMMENT '客服企业ID',
 PRIMARY KEY (`id`) COMMENT '自增主键索引',
 KEY `ent_id` (`ent_id`) COMMENT '客服企业ID索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '客服企业配置表';
DROP TABLE IF EXISTS `reply_group`;
CREATE TABLE `reply_group` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `group_name` varchar(255) NOT NULL DEFAULT '' COMMENT '组名',
 `user_id` varchar(255) NOT NULL DEFAULT '' COMMENT '客服账户',
 `ent_id` varchar(255) NOT NULL DEFAULT '' COMMENT '客服企业ID',
 `is_team` tinyint NOT NULL DEFAULT '1' COMMENT '1个人,2团队',
 PRIMARY KEY (`id`) COMMENT '自增主键索引',
 KEY `user_id` (`user_id`),
 KEY `ent_id` (`ent_id`) COMMENT '企业id索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '快捷回复分组表';
DROP TABLE IF EXISTS `reply_item`;
CREATE TABLE `reply_item` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `content` varchar(1024) NOT NULL DEFAULT '' COMMENT '快捷回复内容',
 `group_id` int(11) NOT NULL DEFAULT '0' COMMENT '快捷回复分组ID',
 `user_id` varchar(255) NOT NULL DEFAULT '' COMMENT '客服账户',
 `item_name` varchar(255) NOT NULL DEFAULT '' COMMENT '快捷回复标题',
 `ent_id` varchar(255) NOT NULL DEFAULT '' COMMENT '客服企业ID',
 `is_team` tinyint NOT NULL DEFAULT '1' COMMENT '1个人,2团队',
 PRIMARY KEY (`id`) COMMENT '自增主键索引',
 KEY `user_id` (`user_id`) COMMENT '客服账户索引',
 KEY `group_id` (`group_id`) COMMENT '快捷回复分组ID索引',
 KEY `ent_id` (`ent_id`) COMMENT '企业id索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '快捷回复表';
DROP TABLE IF EXISTS `article_cate`;
CREATE TABLE `article_cate` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `cat_name` varchar(50) NOT NULL DEFAULT '' COMMENT '自动回复分类名称',
 `user_id` varchar(50) NOT NULL DEFAULT '' COMMENT '客服账户',
 `ent_id` varchar(50) NOT NULL DEFAULT '' COMMENT '客服企业ID',
 `is_top` tinyint NOT NULL DEFAULT '0' COMMENT '是否置顶展示，1置顶',
 PRIMARY KEY (`id`) COMMENT '自增主键索引',
 KEY `ent_id` (`ent_id`) COMMENT '客服企业ID索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '自动回复分类表';
DROP TABLE IF EXISTS `article`;
CREATE TABLE `article` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `title` varchar(500) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '自动回复关键词',
 `content` text COLLATE utf8mb4_general_ci COMMENT '自动回复内容',
 `cat_id` int(11) NOT NULL DEFAULT '0' COMMENT '自动回复分类ID',
 `user_id` varchar(50) NOT NULL DEFAULT '' COMMENT '客服账户',
 `ent_id` varchar(50) NOT NULL DEFAULT '' COMMENT '客服企业ID',
 `api_url` varchar(500) NOT NULL DEFAULT '' COMMENT '第三方接口地址',
 `search_type` tinyint NOT NULL DEFAULT '1' COMMENT '1包含匹配,2精准匹配',
 `score` int(11) NOT NULL DEFAULT '0' COMMENT '命中次数',
 PRIMARY KEY (`id`) COMMENT '自增主键索引',
 KEY `ent_id` (`ent_id`) COMMENT '客服企业ID索引',
 KEY `cat_id` (`cat_id`) COMMENT '自动回复分类ID索引',
 KEY `score` (`score`) COMMENT '命中次数索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '自动回复表';
DROP TABLE IF EXISTS `user_client`;
CREATE TABLE `user_client` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `kefu` varchar(100) NOT NULL DEFAULT '' COMMENT '客服账户',
 `client_id` varchar(100) NOT NULL DEFAULT '' COMMENT '设备ID',
 `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
 UNIQUE KEY `idx_user` (`kefu`,`client_id`) COMMENT '客服设备唯一索引',
 PRIMARY KEY (`id`) COMMENT '自增主键索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT 'APP推送用手机设备ID表';
DROP TABLE IF EXISTS `tag`;
CREATE TABLE `tag` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `name` varchar(100) NOT NULL DEFAULT '' COMMENT '标签名称',
 `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
 `kefu` varchar(100) NOT NULL DEFAULT '' COMMENT '客服账户',
 `ent_id` int(11) NOT NULL DEFAULT 0 COMMENT '客服企业ID',
 PRIMARY KEY (`id`) COMMENT '自增主键索引',
 KEY `name` (`name`) COMMENT '标签名索引',
 KEY `kefu` (`kefu`) COMMENT '客服账户索引',
 KEY `ent_id` (`ent_id`) COMMENT '企业ID索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '标签表';
DROP TABLE IF EXISTS `visitor_tag`;
CREATE TABLE `visitor_tag` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `visitor_id` varchar(100) NOT NULL DEFAULT '' COMMENT '访客ID',
 `tag_id` int(11) NOT NULL DEFAULT 0 COMMENT '标签ID',
 `ent_id` int(11) NOT NULL DEFAULT 0 COMMENT '客服企业ID',
 `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
 `kefu` varchar(100) NOT NULL DEFAULT '' COMMENT '客服账户',
 PRIMARY KEY (`id`) COMMENT '自增主键索引',
 KEY `visitor_id` (`visitor_id`) COMMENT '访客ID索引',
 KEY `tag_id` (`tag_id`) COMMENT '标签ID索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '访客标签表';
DROP TABLE IF EXISTS `ip_auth`;
CREATE TABLE `ip_auth` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `content` varchar(100) NOT NULL DEFAULT '' COMMENT '备注',
 `ip_address` varchar(100) NOT NULL DEFAULT '' COMMENT 'IP地址',
 `expire_time` varchar(50) NOT NULL DEFAULT '' COMMENT '过期时间，未启用',
 `phone` varchar(100) NOT NULL DEFAULT '' COMMENT '客服账户手机号',
 `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
 `status` tinyint NOT NULL DEFAULT '1' COMMENT '开启状态，1正常，2关闭',
 `code` text DEFAULT NULL COMMENT '授权码',
 PRIMARY KEY (`id`) COMMENT '自增主键索引',
 UNIQUE KEY `ip_address` (`ip_address`) COMMENT 'IP地址索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT 'IP绑定表';
DROP TABLE IF EXISTS `oauth`;
CREATE TABLE `oauth` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `user_id` varchar(100) NOT NULL DEFAULT '' COMMENT '访客/客服账户',
 `oauth_id` varchar(100) NOT NULL DEFAULT '' COMMENT '公众号OPENID',
 `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
 `status` tinyint NOT NULL DEFAULT '1' COMMENT '状态，未启用',
 PRIMARY KEY (`id`) COMMENT '自增主键索引',
 KEY `user_id` (`user_id`) COMMENT '访客/客服账户索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT '微信公众号绑定表';
DROP TABLE IF EXISTS `new`;
CREATE TABLE `new` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `tag` varchar(100) NOT NULL DEFAULT '' COMMENT '公告标签',
 `title` varchar(100) NOT NULL DEFAULT '' COMMENT '公告标题',
 `content` text COMMENT '公告内容',
 `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
 `status` tinyint NOT NULL DEFAULT '1' COMMENT '状态，未启用',
 PRIMARY KEY (`id`) COMMENT '自增主键索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '公告表';
DROP TABLE IF EXISTS `visitor_black`;
CREATE TABLE `visitor_black` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `visitor_id` varchar(100) NOT NULL DEFAULT '' COMMENT '访客ID',
 `name` varchar(500) NOT NULL DEFAULT '' COMMENT '访客名称',
 `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
 `ent_id` varchar(100) NOT NULL DEFAULT '' COMMENT '客服企业ID',
 `kefu_name` varchar(100) NOT NULL DEFAULT '' COMMENT '客服账户',
 PRIMARY KEY (`id`) COMMENT '自增主键索引',
 UNIQUE KEY `visitor_id` (`visitor_id`) COMMENT '访客ID索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '访客黑名单表';
DROP TABLE IF EXISTS `qrcode`;
CREATE TABLE `qrcode` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `ent_id` varchar(100) NOT NULL DEFAULT '' COMMENT '客服企业ID',
 `kefu_name` varchar(500) NOT NULL DEFAULT '' COMMENT '客服账户',
 `uuid` varchar(125) NOT NULL DEFAULT '' COMMENT '唯一ID',
 `url` varchar(2048) NOT NULL DEFAULT '' COMMENT '跳转的URL',
 `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
 PRIMARY KEY (`id`) COMMENT '自增主键索引',
 KEY `ent_id` (`ent_id`) COMMENT '客服企业ID索引',
 KEY `uuid` (`uuid`) COMMENT '唯一ID索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT '二维码存储url映射表';
DROP TABLE IF EXISTS `user_order`;
CREATE TABLE `user_order` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `order_sn` varchar(100) NOT NULL DEFAULT '' COMMENT '订单号',
 `money` int unsigned NOT NULL DEFAULT '0' COMMENT '金额',
 `new_expire_time` varchar(100) NOT NULL DEFAULT '' COMMENT '新的到期时间',
 `payment` varchar(100) NOT NULL DEFAULT '' COMMENT 'alipay支付宝，wechat微信，bank网银',
 `type` tinyint NOT NULL DEFAULT 1  COMMENT '1未支付，2已支付，3已取消',
 `comment` varchar(100) NOT NULL DEFAULT '' COMMENT '备注',
 `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
 `operator` varchar(100) NOT NULL DEFAULT '' COMMENT '操作人',
 `kefu_name` varchar(100) NOT NULL DEFAULT '' COMMENT '客服账户',
 `ent_id` varchar(100) NOT NULL DEFAULT '' COMMENT '客服企业ID',
 PRIMARY KEY (`id`) COMMENT '自增主键索引',
 KEY `ent_id` (`ent_id`) COMMENT '客服企业ID索引',
 UNIQUE KEY `order_sn` (`order_sn`) COMMENT '订单号唯一索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT '客服订单表';
DROP TABLE IF EXISTS `customer`;
CREATE TABLE `customer` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `name` varchar(550) NOT NULL DEFAULT ''  COMMENT '会员名称',
 `avatar` varchar(500) NOT NULL DEFAULT ''  COMMENT '会员头像',
 `kefu_name` varchar(100) NOT NULL DEFAULT ''  COMMENT '客服账户',
 `tel` varchar(100) NOT NULL DEFAULT ''  COMMENT '会员手机号',
 `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP  COMMENT '创建时间',
 `updated_at` timestamp NULL DEFAULT NULL  COMMENT '更新时间',
 `openid` varchar(100) NOT NULL DEFAULT ''  COMMENT '会员ID',
 `acount_openid` varchar(100) NOT NULL DEFAULT ''  COMMENT '公众号会员ID',
 `extra` varchar(2048) NOT NULL DEFAULT '' COMMENT '会员扩展信息',
 `ent_id` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '对接的企业ID',
 `score` int(11) unsigned NOT NULL DEFAULT 1 COMMENT '会员积分',
 PRIMARY KEY (`id`) COMMENT '自增主键索引',
 KEY `openid` (`openid`) COMMENT '会员ID索引',
 KEY `acount_openid` (`acount_openid`) COMMENT '会员ID索引',
 KEY `kefu_name` (`kefu_name`) COMMENT '访客对接客服账户索引',
 KEY `ent_id` (`ent_id`) COMMENT '企业ID索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4  COMMENT '营销会员表';
DROP TABLE IF EXISTS `cms_cate`;
CREATE TABLE `cms_cate` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `cat_name` varchar(50) NOT NULL DEFAULT '' COMMENT '分类名称',
 `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP  COMMENT '创建时间',
 PRIMARY KEY (`id`) COMMENT '自增主键索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT 'CMS分类表';
DROP TABLE IF EXISTS `cms_news`;
CREATE TABLE `cms_news` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `title` varchar(500) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '标题',
 `content` text COLLATE utf8mb4_general_ci COMMENT '内容',
 `cat_id` int(11) NOT NULL DEFAULT '0' COMMENT '分类ID',
 `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP  COMMENT '创建时间',
 PRIMARY KEY (`id`) COMMENT '自增主键索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT 'CMS内容表';

DROP TABLE IF EXISTS `consumer`;
CREATE TABLE `consumer` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `company` varchar(500) NOT NULL DEFAULT ''  COMMENT '公司名',
 `realname` varchar(500) NOT NULL DEFAULT ''  COMMENT '姓名',
 `score` varchar(100) NOT NULL DEFAULT ''  COMMENT '级别',
 `consumer_sn` varchar(500) NOT NULL DEFAULT ''  COMMENT '客户编号',
 `ent_id` varchar(100) NOT NULL DEFAULT ''  COMMENT '企业ID',
 `kefu_name` varchar(100) NOT NULL DEFAULT ''  COMMENT 'kefu名称',
 `tel` varchar(100) NOT NULL DEFAULT ''  COMMENT '手机',
 `wechat` varchar(100) NOT NULL DEFAULT ''  COMMENT '微信',
 `qq` varchar(100) NOT NULL DEFAULT ''  COMMENT 'qq',
 `email` varchar(100) NOT NULL DEFAULT ''  COMMENT '邮箱',
 `remark` varchar(1000) NOT NULL DEFAULT ''  COMMENT '备注',
 `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP  COMMENT '创建时间',
 PRIMARY KEY (`id`) COMMENT '自增主键索引',
 KEY `ent_id` (`ent_id`)  COMMENT '企业ID索引',
 KEY `consumer_sn` (`consumer_sn`)  COMMENT '客户索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT '客户表';

DROP TABLE IF EXISTS `learn`;
CREATE TABLE `learn` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `content` varchar(500) NOT NULL DEFAULT ''  COMMENT '问题内容',
 `score` int(11) NOT NULL DEFAULT '1'  COMMENT '次数',
 `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP  COMMENT '创建时间',
 `ent_id` varchar(100) NOT NULL DEFAULT ''  COMMENT '企业ID',
 `kefu_name` varchar(100) NOT NULL DEFAULT ''  COMMENT 'kefu名称',
 `finshed` tinyint(4) NOT NULL DEFAULT 1 COMMENT '是否解决，1未解决，2已解决',
 PRIMARY KEY (`id`) COMMENT '自增主键索引',
 KEY `ent_id` (`ent_id`)  COMMENT '企业ID索引',
 KEY `content` (`content`)  COMMENT '问题内容索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '机器人学习库';
DROP TABLE IF EXISTS `wework_sync_msg`;
CREATE TABLE `wework_sync_msg` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `sync_cursor` varchar(255) NOT NULL DEFAULT '',
  `json_txt` text NOT NULL,
  `visitor_id` varchar(100) NOT NULL DEFAULT '',
  `kefu_id` varchar(100) NOT NULL DEFAULT '',
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `ent_id` int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  KEY `visitor_id` (`visitor_id`),
  KEY `kefu_id` (`kefu_id`),
  KEY `ent_id` (`ent_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
DROP TABLE IF EXISTS `ai_file`;
CREATE TABLE `ai_file` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `file_name` varchar(1000) NOT NULL DEFAULT ''  COMMENT '文件名',
 `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP  COMMENT '创建时间',
 `file_size` varchar(500) NOT NULL DEFAULT ''  COMMENT '字符数',
 `collect_name` varchar(500) NOT NULL DEFAULT ''  COMMENT '集合名称',
 PRIMARY KEY (`id`) COMMENT '自增主键索引',
 KEY `collect_name` (`collect_name`)  COMMENT 'AI集合文件列表'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT 'AI集合文件向量映射表';
DROP TABLE IF EXISTS `ai_file_points`;
CREATE TABLE `ai_file_points` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `file_id` varchar(500) NOT NULL DEFAULT ''  COMMENT '文件表自增ID',
 `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP  COMMENT '创建时间',
 `collect_name` varchar(500) NOT NULL DEFAULT ''  COMMENT '集合名称',
 `points_id` varchar(500) NOT NULL DEFAULT ''  COMMENT '向量ID',
 PRIMARY KEY (`id`) COMMENT '自增主键索引',
 KEY `collect_name` (`collect_name`)  COMMENT '集合名索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT 'AI集合文件向量映射表';
DROP TABLE IF EXISTS `aigc_session_collect`;
CREATE TABLE `aigc_session_collect` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `title` varchar(1000) NOT NULL DEFAULT ''  COMMENT '集合标题',
 `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP  COMMENT '创建时间',
 `kefu_name` varchar(500) NOT NULL DEFAULT ''  COMMENT '客服名称',
 `ent_id` varchar(500) NOT NULL DEFAULT ''  COMMENT '企业ID',
 PRIMARY KEY (`id`) COMMENT '自增主键索引',
 KEY `kefu_name` (`kefu_name`)  COMMENT '客服名称'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT 'AIGC会话集合';
DROP TABLE IF EXISTS `aigc_session_message`;
CREATE TABLE `aigc_session_message` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `collect_id` int(11) NOT NULL DEFAULT '0'  COMMENT '集合ID',
 `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP  COMMENT '创建时间',
 `kefu_avatar` varchar(500) NOT NULL DEFAULT ''  COMMENT '客服头像',
 `ai_avatar` varchar(500) NOT NULL DEFAULT ''  COMMENT 'AI头像',
 `content` text   COMMENT '内容',
 `kefu_name` varchar(500) NOT NULL DEFAULT ''  COMMENT '客服名称',
 `ent_id` varchar(500) NOT NULL DEFAULT ''  COMMENT '企业ID',
 `msg_type` varchar(500) NOT NULL DEFAULT ''  COMMENT '消息类型',
 PRIMARY KEY (`id`) COMMENT '自增主键索引',
 KEY `kefu_name` (`kefu_name`)  COMMENT '客服名称'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT 'AIGC会话消息';
DROP TABLE IF EXISTS `douyin_webhook`;
CREATE TABLE `douyin_webhook` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `kefu_name` varchar(100) NOT NULL DEFAULT ''  COMMENT '客服账户',
 `event` varchar(500) NOT NULL DEFAULT ''  COMMENT 'event',
 `from_user_id` varchar(500) NOT NULL DEFAULT ''  COMMENT 'from_user_id',
 `to_user_id` varchar(500) NOT NULL DEFAULT ''  COMMENT 'to_user_id',
 `client_key` varchar(500) NOT NULL DEFAULT ''  COMMENT 'client_key',
 `content` TEXT DEFAULT NULL  COMMENT 'content',
 `ent_id` varchar(100) NOT NULL DEFAULT ''  COMMENT '企业ID',
 `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP  COMMENT '创建时间',
 PRIMARY KEY (`id`) COMMENT '自增主键索引',
 KEY `kefu_name` (`kefu_name`)  COMMENT '客服账户索引',
 KEY `ent_id` (`ent_id`)  COMMENT '企业ID索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT '抖音webhooks日志表';
DROP TABLE IF EXISTS `wechat_login`;
CREATE TABLE `wechat_login` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `kefu_name` varchar(500) NOT NULL DEFAULT ''  COMMENT '客服账户',
 `open_id` varchar(500) NOT NULL DEFAULT ''  COMMENT '微信公众号openid',
 `temp_kefu_id` varchar(500) NOT NULL DEFAULT ''  COMMENT '临时客服ID',
 `status` varchar(500) NOT NULL DEFAULT ''  COMMENT '当前状态',
 `ent_id` varchar(100) NOT NULL DEFAULT ''  COMMENT '企业ID',
 `login_ip` varchar(100) NOT NULL DEFAULT ''  COMMENT '登录IP',
 `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP  COMMENT '创建时间',
 PRIMARY KEY (`id`) COMMENT '自增主键索引',
 KEY `temp_kefu_id` (`kefu_name`)  COMMENT '临时客服ID索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT '微信扫码登录表';
DROP TABLE IF EXISTS `product_order`;
CREATE TABLE `product_order` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `ent_id` varchar(100) NOT NULL DEFAULT ''  COMMENT '企业ID',
  `kefu_name` varchar(500) NOT NULL DEFAULT ''  COMMENT '客服账户',
  `user_id` varchar(500) NOT NULL DEFAULT ''  COMMENT '用户ID',
  `order_sn` varchar(500) NOT NULL DEFAULT ''  COMMENT '订单编号',
  `order_desc` varchar(500) NOT NULL DEFAULT ''  COMMENT '订单描述',
  `order_status` varchar(100) NOT NULL DEFAULT ''  COMMENT '订单状态：pending,processing,completed,cancelled',
  `total_amount` int(11) NOT NULL DEFAULT '0' COMMENT '订单金额',
  `payment_method` varchar(100) NOT NULL DEFAULT ''  COMMENT '支付方式：wechat,alipay,bank,other',
  `payment_status` varchar(100) NOT NULL DEFAULT ''  COMMENT '支付状态：paid,unpaid,refunded',
  `shipping_address` TEXT COMMENT '收货地址',
  `email` varchar(100) NOT NULL DEFAULT ''  COMMENT '邮箱',
  `contact` varchar(100) NOT NULL DEFAULT ''  COMMENT '联系人',
  `tel` varchar(100) NOT NULL DEFAULT ''  COMMENT '手机号',
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  `updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `kefu_name` (`kefu_name`)  COMMENT '客服账户索引',
  KEY `ent_id` (`ent_id`)  COMMENT '企业ID索引',
  KEY `order_sn` (`order_sn`)  COMMENT '订单号索引',
  KEY `user_id` (`user_id`)  COMMENT '用户ID'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '产品订单表';
DROP TABLE IF EXISTS `virtual_product`;
CREATE TABLE virtual_product (
    `id` INT NOT NULL AUTO_INCREMENT,
    `ent_id` varchar(100) NOT NULL DEFAULT ''  COMMENT '企业ID',
    `kefu_name` varchar(500) NOT NULL DEFAULT ''  COMMENT '客服账户',
    `product_name` VARCHAR(500) NOT NULL DEFAULT '',
    `product_category` VARCHAR(100) NOT NULL DEFAULT '',
    `payment` VARCHAR(500) NOT NULL DEFAULT ''  COMMENT '支付方式，wechat 微信支付；nan66 南星码支付',
    `description` TEXT,
    `price` int(11) NOT NULL DEFAULT '0' COMMENT '金额',
    `product_img` VARCHAR(1000) NOT NULL DEFAULT '',
    `resource_link` VARCHAR(1000) NOT NULL DEFAULT '',
    `is_active` tinyint(4) NOT NULL DEFAULT 1 COMMENT '在线状态，1在售，2下架',
    `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    `updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`),
    KEY `kefu_name` (`kefu_name`)  COMMENT '客服账户索引',
    KEY `ent_id` (`ent_id`)  COMMENT '企业ID索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '虚拟产品表';
DROP TABLE IF EXISTS `llm_log`;
CREATE TABLE llm_log (
    `id` INT NOT NULL AUTO_INCREMENT,
    `ent_id` varchar(100) NOT NULL DEFAULT ''  COMMENT '企业ID',
    `kefu_name` varchar(500) NOT NULL DEFAULT ''  COMMENT '客服账户',
    `model_name` VARCHAR(500) NOT NULL DEFAULT '' COMMENT '大模型名称',
    `question` TEXT DEFAULT NULL COMMENT '提问',
    `answer` TEXT DEFAULT NULL COMMENT '回复',
    `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`),
    KEY `kefu_name` (`kefu_name`)  COMMENT '客服账户索引',
    KEY `ent_id` (`ent_id`)  COMMENT '企业ID索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '大模型提问日志';
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '系统授权码', 'SystemAuthCode', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '百度翻译AppID', 'BaiduFanyiAppId', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '百度翻译密钥', 'BaiduFanyiAppSec', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '是否允许上传附件', 'SendAttachment', 'true');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '上传文件大小限制(单位M)', 'UploadMaxSize', '20');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '是否关闭系统频率限制', 'SystemFreqLimt', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '发送通知邮件(SMTP地址)', 'NoticeEmailSmtp', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '发送通知邮件(邮箱)', 'NoticeEmailAddress', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '发送通知邮件(密码)', 'NoticeEmailPassword', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, 'App个推(Token)', 'GetuiToken', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, 'App个推(AppID)', 'GetuiAppID', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, 'App个推(AppKey)', 'GetuiAppKey', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, 'App个推(AppSecret)', 'GetuiAppSecret', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, 'App个推(AppMasterSecret)', 'GetuiMasterSecret', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '落地域名跳转( 例: 留空不跳转 )', 'LandHost', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '客服系统公告', 'SystemNotice', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '客服系统标题', 'SystemTitle', '在线客服系统');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '客服系统登录页标题', 'SystemLoginTitle', '客服系统登录');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '客服系统关键字', 'SystemKeywords', '在线客服系统');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '客服系统描述', 'SystemDesc', '在线客服系统');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '客服首页跳转地址( 例:跳登录页 /login )', 'IndexJumpUrl', '/404');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '版权信息文案', 'CopyrightTxt', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '版权链接地址', 'CopyrightUrl', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '官方客服JS配置', 'SystemKefu', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '是否允许注册(1是允许，2是不允许，默认允许)', 'SystemRegister', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '系统版本号', 'SystemVersion', '0.7.9');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '系统版本名称', 'SystemVersionName', '开源在线客服系统');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '是否显示客服名称（off是不显示）', 'ShowKefuName', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '微信模板消息备注字段(remark)', 'WechatTemplateRemark', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '是否验证客服过期时间（on是验证）', 'KefuExpired', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '访客ID生成规则（ip:是通过客户ip生成，留空是uuid）', 'VisitorIdRule', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '平台官方客服商户ID', 'SystemBussinesId', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '平台官方热点问题商户ID', 'SystemHotQaBussinesId', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '支付宝收款码图片地址', 'AlipayImageUrl', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '微信收款码图片地址', 'WechatImageUrl', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '网银账号信息', 'BankInfo', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '访客端公众号带参二维码URL', 'VisitorWechatQrcodeUrl', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '访客消息回调URL', 'VisitorMessageCallUrl', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '客服消息回调URL', 'KefuMessageCallUrl', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '阿里云OSS(EndPoint,以http/https开头)', 'OSS_ENDPOINT', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '阿里云OSS(AccessKeyId)', 'OSS_ACCESS_KEY_ID', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '阿里云OSS(AccessKeySecret)', 'OSS_ACCESS_KEY_SECRET', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '阿里云OSS(OssBucket)', 'OSS_BUCKET', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '阿里云OSS(Bucket域名,以http/https开头)', 'OSS_BUCKET_DOMAIN', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '阿里云短信内容签名头(例如：【百度】xxxxx)', 'ALI_SMS_SIGN', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '阿里云短信模板CODE', 'ALI_SMS_CODE', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '敏感词库（以回车换行分割）', 'BlackWords', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '访客端是否展示默认头像（默认不展示）', 'VisitorShowAvator', 'false');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '访客端是否隐藏语音按钮（默认展示）', 'VisitorVoiceBtn', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '访客端是否隐藏发送位置按钮（默认展示）', 'VisitorMapBtn', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '访客端是否隐藏表情按钮（默认展示）', 'VisitorFaceBtn', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '访客端是否隐藏评价弹窗（默认展示）', 'VisitorCommentBtn', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '访客端是否隐藏已读未读（默认展示）', 'VisitorReadStatus', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '访客端是否隐藏+按钮（默认展示）', 'VisitorPlusBtn', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '访客端是否隐藏上传图片按钮（默认展示）', 'VisitorUploadImgBtn', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '访客端是否隐藏上传文件按钮（默认展示）', 'VisitorUploadFileBtn', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '访客端输入框长度限制（默认100）', 'VisitorMaxLength', '100');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '客服账号是否需要验证绑定手机', 'KefuBindTel', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '客服端是否隐藏发送语音按钮（默认展示）', 'KefuAudioBtn', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '客服端是否隐藏上传图片按钮（默认展示）', 'KefuUploadImgBtn', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '客服端是否隐藏上传文件按钮（默认展示）', 'KefuUploadFileBtn', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '客服端是否隐藏清除聊天按钮（默认展示）', 'KefuCleanBtn', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '客服端撤回消息时间限制，单位/秒（默认不限）', 'KefuDeleteMessageLimitTime', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, 'IP地址或者refer来源黑名单', 'SystemBlackList', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, 'IP白名单', 'SystemWhiteList', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, 'IP登录限制(1全公开,2禁止海外,3只能内网)', 'IpLoginForbidden', '1');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, 'OpenAI API最大消息数量', 'OpenAiApiMaxNum', '100');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '基于GPT的向量知识库服务接口', 'BaseGPTKnowledge', 'http://127.0.0.1:8083');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, 'QDRANT向量数据库地址', 'QdrantBase', '127.0.0.1');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, 'QDRANT向量数据库端口', 'QdrantPort', '6333');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '微信公众号网页授权地址', 'WechatOfficialAuthUrl', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '微信支付AppID', 'WechatPayAppId', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '微信支付商户号', 'WechatPayMchID', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '微信支付商户证书序列号', 'WechatPayMchCertificateSerialNumber', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '微信支付商户API V3密钥', 'WechatPayMchAPIv3Key', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '微信支付商户私钥', 'WechatPayMchPrivateKey', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '微信支付回调URL', 'WechatPayNotifyUrl', 'https://【域名】/api/v2/wechat_pay/notify');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '微信支付JSAPI支付回调URL', 'WechatJsApiNotifyUrl', 'https://test.com/2/jsApiPayNotifyUrl');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '是否验证强密码', 'CheckStrongPass', 'false');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '抖音client_key', 'DouyinClientKey', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '抖音client_secret', 'DouyinClientSecret', '');
INSERT INTO `user` (`id`, `name`, `password`, `nickname`, `created_at`, `updated_at`, `expired_at`, `avator`, `pid`,`agent_num`,`uuid`) VALUES
(3, 'admin', '202cb962ac59075b964b07152d234b70', '客服系统管理员', '2020-07-02 14:36:46', '2020-07-05 08:46:57', '2030-07-04 09:32:20', '/static/images/user/2.jpg', 1,100000,'49701881248f32017922d9c12fb2aed2'),
(2, 'kefu2', '202cb962ac59075b964b07152d234b70', '智能客服系统', '2020-07-02 14:36:46', '2020-07-05 08:46:57', '2030-07-04 09:32:20', '/static/images/user/2.jpg', 1,0,'aa3950f5a12be30c5729bac939baecee');
INSERT INTO `user_role` (`id`, `user_id`, `role_id`) VALUES
(1, 1, 1),
(2, 2, 2),
(3, 3, 1);
