-- v1.1版本新增sql

-- 2021/10/21新增
ALTER TABLE `eb_chat_service_record` ADD `delete_time` INT(10) NULL DEFAULT NULL COMMENT '删除字段' AFTER `update_time`;
-- 2021/11/16新增
ALTER TABLE `eb_chat_user_label` ADD `sort` INT(10) NOT NULL DEFAULT '0' COMMENT '排序' AFTER `cate_id`;
-- 2021/11/18新增
CREATE TABLE `eb_qrcode` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL DEFAULT '' COMMENT '二维码名称',
  `url` varchar(255) NOT NULL DEFAULT '' COMMENT '地址',
  `user_ids` varchar(255) NOT NULL DEFAULT '' COMMENT '用户ids',
  `appid` varchar(35) NOT NULL DEFAULT '' COMMENT 'APPID',
  `sort` int(10) NOT NULL DEFAULT '0' COMMENT '排序',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='二维码';
-- 新增配置
INSERT INTO `eb_system_config` (`id`, `menu_name`, `type`, `input_type`, `config_tab_id`, `parameter`, `upload_type`, `required`, `width`, `high`, `value`, `info`, `desc`, `sort`, `status`) VALUES
(null, 'qq_map_key', 'text', 'input', 1, '', 0, '', 100, 0, '""', '腾讯地图开放平台KEY', '腾讯地图开放平台KEY,申请地址:https://lbs.qq.com/dev/console/application/mine', 0, 1),
(null, 'kefu_icon_url3', 'upload', '', 69, '', 1, '', 0, 0, '""', '客服图标地址自定义', '客服图标地址自定义', 0, 2),
(null, 'kefu_icon_url2', 'upload', '', 69, '', 1, '', 0, 0, '"data:image/png;base64,[encoded data, 4284 characters]"', '客服图标地址圆形', '客服图标地址圆形', 0, 0),
(null, 'kefu_icon_url1', 'upload', '', 69, '', 1, '', 0, 0, '"data:image/png;base64,[encoded data, 4284 characters]"', '客服图标地址', '客服图标地址', 0, 0),
(null, 'kefu_icon_type', 'radio', '', 69, '0=>默认图标\n1=>悬浮球\n2=>自定义', 0, '', 0, 0, '"1"', '客服图标', '客服图标', 0, 2);
-- 新增菜单
INSERT INTO `eb_system_menus` (`id`, `pid`, `icon`, `menu_name`, `module`, `controller`, `action`, `api_url`, `methods`, `params`, `sort`, `is_show`, `is_show_path`, `access`, `menu_path`, `path`, `auth_type`, `header`, `is_header`, `unique_auth`, `is_del`) VALUES
(null, 12, '', 'APP在线升级', 'admin', '', '', '', '', '[]', 0, 1, 0, 1, '/admin/setting/app/version', '12', 1, '', 0, 'setting-app-version', 0),
(null, 165, '', '站点统计', 'admin', '', '', '', '', '[]', 0, 1, 0, 1, '/admin/kefu/statistics', '165', 1, '', 0, 'admin-kefu-statistics', 0),
(null, 165, '', '客服二维码', 'admin', '', '', '', '', '[]', 0, 1, 0, 1, '/admin/kefu/qrcode', '165', 1, '', 0, 'admin-kefu-qrcode', 0),
(null, 165, '', '聊天记录', 'admin', '', '', '', '', '[]', 0, 1, 0, 1, '/admin/kefu/record', '165', 1, '', 0, 'admin-kefu-record', 0),
(null, 1096, '', '设置客服图标', 'admin', '', '', '/api/admin/setting/config/kefu', 'GET', '[]', 0, 0, 1, 1, '', '12/656/1096', 2, '', 0, 'adminapi-setting-set_kf_icon', 0),
(null, 656, '', '客服图标', 'admin', '', '', '', '', '[]', 0, 1, 0, 1, '/admin/setting/system_group_data/kf_icon', '12/656', 1, '', 0, 'setting-system-group_data-kf_icon', 0),
(null, 1094, '', '客服图标', 'admin', '', '', '', '', '[]', 0, 1, 0, 1, '/admin/setting/system_group_data/kf_icon', '12/656/1094', 1, '', 0, 'setting-system-group_data-kf_icon', 0),
(null, 47, '', '系统日志管理员搜索条件', 'admin', '', '', 'api/admin/system/log/search_admin', 'GET', '[]', 0, 0, 0, 1, '', '25/65/47', 2, '', 0, '', 0),
(null, 585, '', '用户标签搜索列表', 'admin', '', '', 'api/admin/user/user_label', 'GET', '[]', 0, 0, 0, 1, '', '9/10/585', 2, '', 0, '', 0),
(null, 47, '', '系统日志', 'admin', '', '', 'api/admin/system/log', 'GET', '[]', 0, 0, 0, 1, '', '25/65/47', 2, '', 0, '', 0),
(null, 1103, '', '保存APP升级', 'admin', '', '', 'api/admin/setting/verison/save/<id>', 'POST', '[]', 0, 0, 0, 1, '', '12/1103', 2, '', 0, '', 0),
(null, 1103, '', '获取创建APP升级包表单', 'admin', '', '', 'api/admin/setting/verison/<id>', 'GET', '[]', 0, 0, 0, 1, '', '12/1103', 2, '', 0, '', 0),
(null, 1103, '', '删除APP升级包', 'admin', '', '', 'api/admin/setting/verison/<id>', 'DELETE', '[]', 0, 0, 0, 1, '', '12/1103', 2, '', 0, '', 0),
(null, 1103, '', '获取APP升级包列表', 'admin', '', '', 'api/admin/setting/verison', 'GET', '[]', 0, 0, 0, 1, '', '12/1103', 2, '', 0, '', 0),
(null, 1102, '', '站点统计', 'admin', '', '', 'api/admin/chat/statistics', 'GET', '[]', 0, 0, 0, 1, '', '165/1102', 2, '', 0, '', 0),
(null, 678, '', '删除自动回复', 'admin', '', '', 'api/admin/chat/reply/<id>', 'DELETE', '[]', 0, 0, 0, 1, '', '165/678', 2, '', 0, '', 0),
(null, 678, '', '保存自动回复', 'admin', '', '', 'api/admin/chat/reply/<id>', 'POST', '[]', 0, 0, 0, 1, '', '165/678', 2, '', 0, '', 0),
(null, 678, '', '获取自动回复表单', 'admin', '', '', 'api/admin/chat/reply/<id>', 'GET', '[]', 0, 0, 0, 1, '', '165/678', 2, '', 0, '', 0),
(null, 678, '', '自动回复列表', 'admin', '', '', 'api/admin/chat/reply', 'GET', '[]', 0, 0, 0, 1, '', '165/678', 2, '', 0, '', 0),
(null, 1101, '', '删除随机客服二维码', 'admin', '', '', 'api/admin/chat/qrcode/<id>', 'DELETE', '[]', 0, 0, 0, 1, '', '165/1101', 2, '', 0, '', 0),
(null, 1101, '', '保存随机客服二维码', 'admin', '', '', 'api/admin/chat/qrcode/<id>', 'POST', '[]', 0, 0, 0, 1, '', '165/1101', 2, '', 0, '', 0),
(null, 1101, '', '获取随机客服二维码表单', 'admin', '', '', 'api/admin/chat/qrcode/<id>', 'GET', '[]', 0, 0, 0, 1, '', '165/1101', 2, '', 0, '', 0),
(null, 1101, '', '获取随机客服二维码', 'admin', '', '', 'api/admin/chat/qrcode', 'GET', '[]', 0, 0, 0, 1, '', '165/1101', 2, '', 0, '', 0),
(null, 1100, '', '获取所有客服', 'admin', '', '', 'api/admin/chat/record_kefu', 'GET', '[]', 0, 0, 0, 1, '', '165/1100', 2, '', 0, '', 0),
(null, 1100, '', '查看所有聊天记录', 'admin', '', '', 'api/admin/chat/record', 'GET', '[]', 0, 0, 0, 1, '', '165/1100', 2, '', 0, '', 0),
(null, 1096, '', '保存客服图标上传配置', 'admin', '', '', 'api/admin/setting/config/kefu', 'POST', '[]', 0, 0, 0, 1, '', '12/656/1096', 2, '', 0, '', 0),
(null, 1008, '', '标签分类移动排序', 'admin', '', '', 'api/admin/user/label/move_cate', 'POST', '[]', 0, 0, 0, 1, '', '9/1008', 2, '', 0, '', 0),
(null, 1008, '', '标签移动排序', 'admin', '', '', 'api/admin/user/label/move', 'POST', '[]', 0, 1, 0, 1, '', '9/1008', 2, '', 0, '', 0);

-- 新增app在线升级表
CREATE TABLE `eb_app_version` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(100) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT '更新摘要',
  `version_num` varchar(20) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT '版本号',
  `url` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT '下载地址',
  `info` varchar(1000) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT '更新详细内容',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
  `delete_time` timestamp NULL DEFAULT NULL COMMENT '删除时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='app在线升级';

CREATE TABLE `eb_site_statistics` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `source` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '网站来源',
  `path` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT '来源网址',
  `ip` varchar(20) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT 'ip地址',
  `region` varchar(50) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT '地区',
  `province` varchar(50) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT '省份',
  `browser` varchar(100) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT '浏览器',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='站点统计';

-- 2021/12/17
CREATE TABLE `eb_chat_service_group` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `name` varchar(100) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT '组名',
 `sort` int(10) NOT NULL DEFAULT '0' COMMENT '排序',
 `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间',
 `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
 PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='客服分组';

ALTER TABLE `eb_chat_service` ADD `group_id` INT(10) NOT NULL DEFAULT '0' COMMENT '分组id' AFTER `user_id`;

-- 2022/1/18

ALTER TABLE `eb_system_config` CHANGE `value` `value` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '默认值';
UPDATE `eb_system_config` SET `value` = '"data:image/png;base64,[encoded data, 6768 characters]"' WHERE `menu_name` = 'kefu_icon_url1';
