CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_user` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `user_headimg` VARCHAR(500) NOT NULL DEFAULT '' COMMENT '会员头像',
    `nick_name` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '用户昵称',
    `name` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '姓名',
    `password` CHAR(60) NOT NULL DEFAULT '' COMMENT '密码（哈希存储）',
    `sex` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '性别：0未知 1男 2女',
    `openid` VARCHAR(64) NOT NULL DEFAULT '' COMMENT '用户openid',
    `unionid` VARCHAR(64) NOT NULL DEFAULT '' COMMENT '用户unionid',
    `district` varchar(100) DEFAULT NULL COMMENT '区',
    `address` varchar(255) NOT NULL DEFAULT '' COMMENT '详细地址',
    `birthday` varchar(30) NOT NULL DEFAULT '' COMMENT '生日',
    `phone` VARCHAR(20) NOT NULL DEFAULT '' COMMENT '手机号',
    `qq` VARCHAR(20) NOT NULL DEFAULT '' COMMENT 'qq号',
    `wechat` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '微信号',
    `idcard` CHAR(18) NOT NULL DEFAULT '' COMMENT '身份证号',
    `platform` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '所属平台: 0微信|1百度|2支付宝|3字节跳动|4公众号|5手机站|6QQ|7企业微信|8Android|9IOS|10PC|15企微客户',
    `level_id` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '级别ID',
    `groupid` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '组别ID',
    `growth_value` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '成长值',
    `integral` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '积分',
    `is_main` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否主账号 0否 1是',
    `status` TINYINT UNSIGNED NOT NULL DEFAULT 1 COMMENT '状态 0禁用 1启用',
    `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '应用ID',
    `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
    `create_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    `delete_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_openid` (`mch_id`, `shop_id`, `openid`),
    KEY `idx_phone` (`phone`),
    KEY `idx_shop` (`mch_id`, `shop_id`),
    KEY `idx_status` (`status`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_user_visit_logs` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `user_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '用户id',
    `admin_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '商家用户id',
    `op_type` TINYINT UNSIGNED NOT NULL DEFAULT 1 COMMENT '操作类型：1查看 2转发 3复制 4保存 5拨打 6浏览（商品）',
    `op_name` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '操作名字',
    `page_flag` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '页面标识',
    `page_param` TEXT NOT NULL COMMENT '页面参数',
    `stay_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '停留时间（秒）',
    `ip` VARCHAR(45) NOT NULL DEFAULT '' COMMENT '用户IP',
    `action_type` TINYINT UNSIGNED NOT NULL DEFAULT 1 COMMENT '动作类型：0新增用户 1启动小程序 2进入页面 3退出 4页面内操作',
    `platform` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '平台: 0微信 1百度 2支付宝 3字节跳动 4公众号 5手机站 6QQ',
    `share_log_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '分享记录id',
    `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '应用ID',
    `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
    `create_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    `delete_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间',
    PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户访问日志表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_config` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `config_key` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '配置项key',
    `config_value` TEXT NOT NULL COMMENT '配置项value',
    `description` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '配置描述',
    `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '应用ID',
    `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
    `create_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    `delete_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_shop_config` (`mch_id`, `shop_id`, `config_key`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='商城配置表';

INSERT INTO `YB_TABLE_PREFIX_sys_config` VALUES (1, 'site_config', '{\"site_name\":\"站点名称\",\"copyright\":\"后台版权信息\",\"site_record\":\"icp备案号\",\"site_link\":\"icp备案链接\",\"ploice_site_record\":\"公安备案号\",\"ploice_site_link\":\"公安备案链接\",\"icon\":\"https://moban-1256746889.cos.ap-chengdu.myqcloud.com/app/image/system_logo_8.0.png\",\"site_fav_icon\":\"https://moban-1256746889.cos.ap-chengdu.myqcloud.com/app/image/system_logo_8.0.png\",\"login_image\":\"https://moban-1256746889.cos.ap-chengdu.myqcloud.com/app/image/admin_login_banner_system_8.0.png\",\"index_icon\":\"https://moban-1256746889.cos.ap-chengdu.myqcloud.com/app/image/index_icon_system_8.0.png\",\"copyright_logo\":\"\",\"copyright_type\":0,\"is_open_register\":0,\"login_type\":{\"password\":true,\"phone\":false,\"scan\":false},\"copyright_miniapp\":\"\"}', '站点设置', 0, 0, 1759058276, 1759060706, 0);
INSERT INTO `YB_TABLE_PREFIX_sys_config` (`id`, `config_key`, `config_value`, `description`, `mch_id`, `shop_id`, `create_time`, `update_time`, `delete_time`) VALUES (2, 'site_copyright_backend', '{\"type\":1,\"copyright_logo\":\"\",\"copyright_type\":2,\"copyright_miniapp\":\"壹佰云8.0\\n© 2026 壹佰网络 版权所有\",\"is_jump\":0,\"content\":\"\",\"is_alone\":1}', '后台版权', 0, 0, 1780308426, 1780308486, 0);

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_file_group` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `name` VARCHAR(100) NOT NULL COMMENT '相册名称',
    `cover` VARCHAR(500) NOT NULL DEFAULT '' COMMENT '相册封面URL',
    `is_default` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否为默认相册 0否 1是',
    `status` TINYINT UNSIGNED NOT NULL DEFAULT 1 COMMENT '状态 0隐藏 1显示',
    `sort` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '排序值',
    `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '应用ID',
    `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
    `create_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    `delete_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_mch_shop_name` (`mch_id`, `shop_id`, `name`),
    KEY `idx_shop` (`mch_id`, `shop_id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='附件分类表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_file` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '文件ID',
    `group_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '分类ID',
    `filename` VARCHAR(255) NOT NULL COMMENT '文件名',
    `type` TINYINT UNSIGNED NOT NULL DEFAULT 1 COMMENT '文件类型 0其它 1图片 2音频 3视频',
    `url` VARCHAR(500) NOT NULL COMMENT '文件访问路径',
    `filesize` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '文件大小(字节)',
    `mimetype` VARCHAR(100) NOT NULL DEFAULT '' COMMENT 'MIME类型',
    `storage` TINYINT UNSIGNED NOT NULL DEFAULT 1 COMMENT '存储位置 1本地 2远程',
    `uid` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '上传用户ID',
    `user_type` TINYINT UNSIGNED NOT NULL DEFAULT 1 COMMENT '1后台用户 2小程序用户 3商家助手后台 4商家助手小程序',
    `user_name` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '上传者用户名',
    `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '应用ID',
    `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
    `create_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    `delete_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间',
    PRIMARY KEY (`id`),
    KEY `idx_group` (`group_id`),
    KEY `idx_shop` (`mch_id`, `shop_id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='上传附件表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_admin` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'ID',
    `account` VARCHAR(100) NOT NULL COMMENT '登录账号',
    `password` VARCHAR(255) NOT NULL COMMENT '登录密码（建议加密存储）',
    `user_name` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '用户名称',
    `avatar` VARCHAR(500) NOT NULL DEFAULT '' COMMENT '用户头像',
    `phone` CHAR(11) NOT NULL DEFAULT '' COMMENT '手机号',
    `wx_num` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '微信号',
    `qq_num` VARCHAR(20) NOT NULL DEFAULT '' COMMENT 'QQ号',
    `position` VARCHAR(200) NOT NULL DEFAULT '' COMMENT '职位',
    `email` VARCHAR(200) NOT NULL DEFAULT '' COMMENT '邮箱',
    `token` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '登录token',
    `status` TINYINT UNSIGNED NOT NULL DEFAULT 1 COMMENT '账号状态 1开启 0关闭',
    `admin_type` VARCHAR(50) NOT NULL DEFAULT 'admin' COMMENT '账号归属 super 超管 admin 管理员 staff 员工',
    `is_default` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否默认 0否 1是',
    `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '应用ID',
    `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
    `create_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    `delete_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_account` (`mch_id`, `shop_id`,`account`),
    KEY `idx_mch_shop` (`mch_id`, `shop_id`),
    KEY `idx_admin_type` (`admin_type`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='管理员表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_admin_group` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
    `pid` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '上级ID',
    `name` VARCHAR(100) NOT NULL COMMENT '权限组名称',
    `status` TINYINT UNSIGNED NOT NULL DEFAULT 1 COMMENT '用户组状态 1正常 0隐藏',
    `menu_ids` TEXT NOT NULL COMMENT '系统模块ID组',
    `group_type` VARCHAR(50) NOT NULL DEFAULT 'admin' COMMENT '角色归属 admin/系统等',
    `remark` VARCHAR(500) DEFAULT '' COMMENT '权限描述',
    `is_default` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否默认权限组 0否 1是',
    `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '应用ID',
    `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
    `create_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    `delete_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间',
    PRIMARY KEY (`id`) USING BTREE,
    KEY `idx_pid` (`pid`),
    KEY `idx_shop` (`mch_id`, `shop_id`),
    KEY `idx_group_type` (`group_type`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='系统管理员角色表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_admin_group_relation` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
    `admin_id` BIGINT UNSIGNED NOT NULL COMMENT '管理员ID',
    `group_id` BIGINT UNSIGNED NOT NULL COMMENT '权限组ID',
    `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '应用ID',
    `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
    `create_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_admin_group` (`admin_id`,`group_id`),
    KEY `idx_admin` (`admin_id`),
    KEY `idx_group` (`group_id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='管理员与角色关系表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_department` (
    `id` INT(11) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
    `name` VARCHAR(100) NOT NULL COMMENT '部门名称',
    `pid` INT(11) NOT NULL DEFAULT 0 COMMENT '上级ID',
    `level` INT(11) NOT NULL DEFAULT 1 COMMENT '级别',
    `sort` INT(11) NOT NULL DEFAULT 0 COMMENT '排序',
    `status` TINYINT(1) NOT NULL DEFAULT 1 COMMENT '是否启用：0-否，1-是',
    `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '应用ID',
    `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
    `create_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    `delete_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间',
    PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='商家员工部门表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_department_admin_relate` (
    `id` INT(11) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
    `admin_id` INT(11) NOT NULL COMMENT '员工ID',
    `department_id` INT(11) NOT NULL COMMENT '部门ID',
    `sort` INT(11) NOT NULL DEFAULT 0 COMMENT '部门内排序值，数值越大排序越前面',
    `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '应用ID',
    `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
    `create_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    `delete_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间',
    PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='员工-部门关联表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_department_leader` (
    `id` INT(11) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
    `department_id` INT(11) NOT NULL COMMENT '部门ID',
    `leader_id` INT(11) NOT NULL COMMENT '负责人ID',
    `leader_type` TINYINT(2) NOT NULL DEFAULT 1 COMMENT '负责人类型：1-主负责人，2-副负责人',
    `status` TINYINT(1) NOT NULL DEFAULT 1 COMMENT '是否启用：0-否，1-是',
    `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '应用ID',
    `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
    `create_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    `delete_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间',
    PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='部门负责人关联表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_admin_log` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `admin_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '管理员ID',
    `admin_name` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '管理员名称（冗余字段，便于查询）',
    `url` VARCHAR(1000) NOT NULL DEFAULT '' COMMENT '操作页面URL',
    `title` VARCHAR(200) NOT NULL DEFAULT '' COMMENT '日志标题',
    `content` TEXT NOT NULL COMMENT '操作内容',
    `ip` VARCHAR(45) NOT NULL DEFAULT '' COMMENT 'IP地址（兼容IPv6）',
    `user_agent` VARCHAR(1000) NOT NULL DEFAULT '' COMMENT 'User-Agent',
    `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '应用ID',
    `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
    `create_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    PRIMARY KEY (`id`),
    KEY `idx_admin` (`admin_id`),
    KEY `idx_mch_shop_time` (`mch_id`, `shop_id`, `create_time`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='管理员操作日志表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_addons` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '插件ID',
    `name` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '插件名称',
    `icon` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '插件图标URL',
    `plugin_flag` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '插件标识（唯一）',
    `plugin_file` varchar(100) NOT NULL DEFAULT '' COMMENT '插件文件名',
    `plugin_type` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '插件类型，如payment、marketing',
    `excludes` varchar(255) NOT NULL DEFAULT '' COMMENT '互斥插件',
    `description` TEXT NOT NULL COMMENT '插件描述',
    `version` VARCHAR(50) NOT NULL DEFAULT '1.0.0' COMMENT '版本号，遵循SemVer',
    `status` TINYINT UNSIGNED NOT NULL DEFAULT 1 COMMENT '启用状态 0禁用 1启用',
    `is_default` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否默认安装 0否 1是',
    `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '应用ID',
    `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
    `create_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_plugin_flag` (`plugin_flag`, `mch_id`, `shop_id`),
    KEY `idx_mch_shop` (`mch_id`, `shop_id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='已安装插件表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_addons_switch` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `module_key` varchar(100) NOT NULL DEFAULT '' COMMENT '模块标识',
    `is_open` tinyint(1) DEFAULT '0' COMMENT '模块是否可用 0关闭不可用，1打开可用',
    `remark` varchar(300) DEFAULT NULL COMMENT '备注信息',
    `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '商户ID',
    `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
    `create_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_module_mch_shop` (`module_key`, `mch_id`, `shop_id`),
    KEY `idx_mch_shop` (`mch_id`, `shop_id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='安装插件开关配置表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_addons_operation_log` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'ID',
    `operation_no` CHAR(32) NOT NULL DEFAULT '' COMMENT '操作流水号',
    `plugin_file` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '插件目录',
    `plugin_flag` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '插件标识',
    `plugin_version` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '插件版本',
    `operation` VARCHAR(30) NOT NULL DEFAULT '' COMMENT '操作类型 install/update/uninstall',
    `status` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '状态 0执行中 1成功 2失败 3已回滚',
    `operator_type` VARCHAR(30) NOT NULL DEFAULT '' COMMENT '操作者类型',
    `operator_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '操作者ID',
    `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '商户ID',
    `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
    `backup_path` VARCHAR(500) NOT NULL DEFAULT '' COMMENT '备份目录',
    `detail_json` MEDIUMTEXT NULL COMMENT '执行详情',
    `error_message` TEXT NULL COMMENT '错误信息',
    `create_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_operation_no` (`operation_no`),
    KEY `idx_plugin_operation` (`plugin_flag`, `operation`, `status`),
    KEY `idx_create_time` (`create_time`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='插件操作日志表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_addons_locks` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'ID',
    `lock_key` VARCHAR(191) NOT NULL DEFAULT '' COMMENT '锁key',
    `owner_token` CHAR(64) NOT NULL DEFAULT '' COMMENT '锁持有令牌',
    `driver` VARCHAR(20) NOT NULL DEFAULT 'db' COMMENT '锁驱动',
    `expire_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '过期时间',
    `create_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_lock_key` (`lock_key`),
    KEY `idx_expire_time` (`expire_time`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='插件互斥锁表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_addons_migrations` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'ID',
    `operation_no` CHAR(32) NOT NULL DEFAULT '' COMMENT '操作流水号',
    `plugin_file` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '插件目录',
    `plugin_flag` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '插件标识',
    `plugin_version` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '插件版本',
    `operation` VARCHAR(30) NOT NULL DEFAULT '' COMMENT '迁移操作 install/update/uninstall',
    `migration_file` VARCHAR(191) NOT NULL DEFAULT '' COMMENT 'SQL文件',
    `migration_hash` CHAR(40) NOT NULL DEFAULT '' COMMENT 'SQL文件hash',
    `status` TINYINT UNSIGNED NOT NULL DEFAULT 1 COMMENT '状态 1成功 2失败',
    `error_message` TEXT NULL COMMENT '错误信息',
    `executed_at` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '执行时间',
    `create_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_addon_migration` (`plugin_flag`, `operation`, `migration_file`, `migration_hash`),
    KEY `idx_operation_no` (`operation_no`),
    KEY `idx_plugin_file` (`plugin_file`, `operation`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='插件SQL迁移记录表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_task` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '自增ID',
    `task_type` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '事件类型:hook,sql,url,shell',
    `task_key` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '任务标识',
    `title` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '任务名称',
    `content` TEXT NOT NULL COMMENT '事件内容',
    `instruction` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '说明',
    `time_type` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '周期状态 1秒 2分 3时 4天 5每天定时 6每周定时 7每月定时',
    `week` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '周',
    `day` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '日',
    `hour` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '时',
    `minute` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '分',
    `second` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '秒',
    `schedule` VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'Crontab表达式',
    `sleep` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '延迟秒数执行',
    `maximums` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '最大执行次数 0不限',
    `executes` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '已执行次数',
    `start_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '开始时间',
    `end_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '结束时间',
    `execute_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '最后执行时间',
    `sort` INT NOT NULL DEFAULT 0 COMMENT '排序',
    `status` ENUM('normal','completed','expired','hidden') NOT NULL DEFAULT 'normal' COMMENT '状态',
    `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '应用ID',
    `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
    `create_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    `delete_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_task_key` (`mch_id`, `shop_id`, `task_key`),
    KEY `idx_status_time` (`status`, `execute_time`),
    KEY `idx_mch_shop` (`mch_id`, `shop_id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='定时任务表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_task_log` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '自增ID',
    `task_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '任务ID',
    `execute_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '执行时间',
    `complete_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '完成时间',
    `content` TEXT COMMENT '执行结果',
    `process_id` INT NOT NULL DEFAULT 0 COMMENT '进程ID',
    `status` ENUM('success','failure','inprogress') NOT NULL DEFAULT 'failure' COMMENT '状态',
    `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '应用ID',
    `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
    `create_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    PRIMARY KEY (`id`),
    KEY `idx_task` (`task_id`),
    KEY `idx_mch_shop` (`mch_id`, `shop_id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='定时任务日志表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_api_account` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '自增ID',
    `secret_key` VARCHAR(100) NOT NULL COMMENT '接口秘钥',
    `description` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '描述',
    `permission` text COMMENT '接口权限',
    `interface_name` text COMMENT '选择接口名称',
    `status` TINYINT UNSIGNED NOT NULL DEFAULT 1 COMMENT '状态 0禁用 1启用',
    `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '应用ID',
    `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
    `create_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    `delete_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_secret_key` (`secret_key`),
    KEY `idx_mch_shop_status` (`mch_id`, `shop_id`, `status`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='接口账号表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_menus` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '模块ID',
    `name` VARCHAR(100) NOT NULL COMMENT '模块名称',
    `application_flag` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '应用标识',
    `plugin_flag` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '插件标识',
    `path` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '前端路径',
    `component` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '前端组件',
    `mid` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '菜单ID：同一解决方案时唯一标识',
    `pid` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '上级ID 0为顶级：对应mid',
    `level` TINYINT UNSIGNED NOT NULL DEFAULT 1 COMMENT '等级',
    `url` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '链接地址',
    `is_menu` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否菜单栏 0否 1是',
    `is_page` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否组件菜单 0否 1是',
    `menu_type` VARCHAR(50) NOT NULL DEFAULT 'admin' COMMENT '账号归属 super 超管 admin 管理员',
    `collapse` TINYINT UNSIGNED NOT NULL DEFAULT 1 COMMENT '展开状态: 0收起 1展开',
    `sort` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '排序',
    `info` VARCHAR(500) NOT NULL DEFAULT '' COMMENT '模块描述',
    `logo` text COMMENT '模块小图标',
    `is_show` TINYINT UNSIGNED NOT NULL DEFAULT 1 COMMENT '是否显示 0否 1是',
    `status` TINYINT UNSIGNED NOT NULL DEFAULT 1 COMMENT '状态 0禁用 1启用',
    `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '商户ID',
    `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
    `create_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '修改时间',
    PRIMARY KEY (`id`) USING BTREE,
    KEY `idx_mch_shop` (`mch_id`, `shop_id`),
    KEY `idx_plugin` (`plugin_flag`),
    KEY `idx_menu_type` (`menu_type`),
    KEY `idx_pid_level` (`pid`, `level`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='系统菜单表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_lang` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '语言ID',
    `name` VARCHAR(100) NOT NULL COMMENT '语言名称，如 English, 中文',
    `lang_code` VARCHAR(20) NOT NULL COMMENT '语言代码，如 en, zh',
    `country_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '地区ID，关联 YB_TABLE_PREFIX_sys_lang_country',
    `sort` INT NOT NULL DEFAULT 0 COMMENT '排序',
    `is_default` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否默认 1是 0否',
    `status` TINYINT(1) NOT NULL DEFAULT 1 COMMENT '状态 1启用 0禁用',
    `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '商户ID',
    `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
    `create_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    `delete_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间',
    PRIMARY KEY (`id`),
    KEY `idx_lang_code` (`lang_code`),
    KEY `idx_status` (`status`, `is_default`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='语言表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_lang_detail` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键id',
    `lang_id` BIGINT UNSIGNED NOT NULL COMMENT '语言ID，关联 YB_TABLE_PREFIX_sys_lang',
    `lang_key` VARCHAR(191) NOT NULL COMMENT '词条key',
    `lang_value` VARCHAR(500) NOT NULL COMMENT '词条翻译值',
    `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '商户ID',
    `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
    `create_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    `delete_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间',
    PRIMARY KEY (`id`),
    KEY `idx_lang_key` (`lang_id`, `lang_key`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='语言词条表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_lang_country` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键id',
    `name` VARCHAR(100) NOT NULL COMMENT '地区名称，如 美国，中国',
    `region_code` VARCHAR(20) NOT NULL COMMENT '地区代码，如 US, CN, TW',
    `sort` INT NOT NULL DEFAULT 0 COMMENT '排序值',
    `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '商户ID',
    `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
    `create_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    `delete_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间',
    PRIMARY KEY (`id`),
    KEY `idx_region_code` (`region_code`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='语言地区表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_warning_word` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `sensitive_word` VARCHAR(255) NOT NULL COMMENT '敏感词',
    `status` TINYINT(1) NOT NULL DEFAULT 1 COMMENT '是否启用 0否 1是',
    `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '商户ID',
    `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
    `create_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    `delete_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间',
    PRIMARY KEY (`id`),
    KEY `idx_status` (`status`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='敏感词表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_warning_log` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `word_list` TEXT COMMENT '命中的敏感词数组',
    `title` VARCHAR(200) NOT NULL DEFAULT '' COMMENT '日志标题',
    `url` VARCHAR(1000) NOT NULL DEFAULT '' COMMENT '操作页面',
    `user_id` BIGINT UNSIGNED NOT NULL COMMENT '管理员ID',
    `user_name` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '管理员姓名',
    `content` TEXT NOT NULL COMMENT '内容',
    `ip` VARBINARY(16) NOT NULL COMMENT 'IP地址（支持IPv4/IPv6）',
    `type` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '来源：0后台提交 1小程序提交',
    `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '商户ID',
    `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
    `create_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    `delete_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间',
    PRIMARY KEY (`id`),
    KEY `idx_mch_shop_time` (`mch_id`, `shop_id`, `create_time`),
    KEY `idx_user` (`user_id`, `type`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='违规词过滤与预警日志表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_message` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '消息ID',
    `source` VARCHAR(2000) NOT NULL DEFAULT '' COMMENT '消息来源(模块/页面标识)',
    `title` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '消息标题',
    `type` VARCHAR(50) NOT NULL DEFAULT 'system' COMMENT '消息类型: system公告, remind提醒, warning预警等',
    `content` MEDIUMTEXT COMMENT '消息内容',
    `status` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '状态: 0未读 1已读 2已删除',
    `receiver_type` VARCHAR(20) NOT NULL DEFAULT 'admin' COMMENT '接收对象类型: admin/管理员 user/用户',
    `receiver_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '接收对象ID',
    `is_remind` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否提醒 0否 1是',
    `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '商户ID',
    `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
    `create_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    `delete_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间',
    PRIMARY KEY (`id`),
    KEY `idx_receiver_status` (`receiver_type`, `receiver_id`, `status`),
    KEY `idx_mch_shop_time` (`mch_id`, `shop_id`, `create_time`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='系统通知表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_dict` (
    `id` INT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '自增ID',
    `key` VARCHAR(100) NOT NULL COMMENT '字典Key',
    `name` VARCHAR(50) NOT NULL COMMENT '字典名称',
    `value` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '字典值',
    `pid` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '父级ID',
    `status` TINYINT(1) UNSIGNED NOT NULL DEFAULT 1 COMMENT '状态：0-禁用，1-正常',
    `sort` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '排序',
    `mark` TEXT COMMENT '说明',
    `is_value` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否最终使用值，0-否，1-是（多级字典中用于标识最终层）',
    `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '应用ID',
    `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
    `create_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    `delete_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间',
    PRIMARY KEY (`id`),
    KEY `idx_key` (`key`),
    KEY `idx_pid` (`pid`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='系统字典表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_area` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '自增ID',
    `code` VARCHAR(100) NOT NULL COMMENT '地区编码',
    `name` VARCHAR(100) NOT NULL COMMENT '地区名称',
    `pid` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '上级地区ID',
    `level` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '地区层级：1省/直辖市，2市，3区县等',
    PRIMARY KEY (`id`),
    KEY `idx_pid` (`pid`),
    KEY `idx_code` (`code`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='系统地区表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_share_param` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '自增ID',
    `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '应用ID',
    `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
    `user_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '用户ID',
    `param_key` VARCHAR(191) NOT NULL DEFAULT '' COMMENT '参数Key',
    `param` VARCHAR(500) NOT NULL DEFAULT '' COMMENT '参数内容',
    `create_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    `delete_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间',
    PRIMARY KEY (`id`),
    KEY `idx_user_key` (`user_id`, `param_key`),
    KEY `idx_mch_shop` (`mch_id`, `shop_id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='系统分享参数表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_goods` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '商品ID',
    `goods_name` VARCHAR(255) NOT NULL COMMENT '商品名称',
    `pic` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '商品主图',
    `price` DECIMAL(10,2) NOT NULL DEFAULT 0.00 COMMENT '销售价',
    `market_price` DECIMAL(10,2) NOT NULL DEFAULT 0.00 COMMENT '市场价',
    `cost_price` DECIMAL(10,2) NOT NULL DEFAULT 0.00 COMMENT '成本价',
    `stock` INT NOT NULL DEFAULT 0 COMMENT '库存数量',
    `goods_type` VARCHAR(50) NOT NULL DEFAULT 'normal' COMMENT '商品类型: normal实物, inquiry询价, product产品, recharge会员储值, warehouse仓储商品, member_card会员卡',
    `sales_volume` INT NOT NULL DEFAULT 0 COMMENT '基础销量',
    `real_sales_volume` INT NOT NULL DEFAULT 0 COMMENT '实际销量',
    `promote_word` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '促销语',
    `click` INT NOT NULL DEFAULT 0 COMMENT '浏览量',
    `share_times` INT NOT NULL DEFAULT 0 COMMENT '分享次数',
    `sort` INT NOT NULL DEFAULT 0 COMMENT '商品排序',
    `extend` TEXT COMMENT '扩展信息(JSON)',
    `status` TINYINT NOT NULL DEFAULT 1 COMMENT '状态: 0下架 1上架',
    `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '商户ID',
    `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
    `create_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    `delete_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间',
    PRIMARY KEY (`id`),
    KEY `idx_shop_status` (`shop_id`, `status`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='系统商品表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_goods_sku` (
    `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
    `sys_goods_id` int(11) NOT NULL COMMENT '商品id',
    `sku_id` int(11) NOT NULL DEFAULT 0 COMMENT '子表skuid',
    `spec_id_group` varchar(255) NOT NULL COMMENT '规格组合，格式为规格1id:规格值1id；规格2id:规格值2id；...',
    `sku_name` varchar(500) NOT NULL COMMENT '',
    `market_price` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '市场价',
    `price` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '销售价',
    `stock` int(11) NOT NULL DEFAULT 0 COMMENT '库存',
    `sku_img` varchar(255) DEFAULT '' COMMENT 'sku图片',
    `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '商户ID',
    `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
    `create_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    `delete_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间',
    PRIMARY KEY (`id`)
    ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8 COMMENT='系统商品sku信息表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_goods_activity` (
    `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',
    `sys_goods_id` int(11) NOT NULL COMMENT '系统商品表id',
    `sys_sku_id` int(11) NOT NULL DEFAULT 0 COMMENT '系统商品sku id',
    `activity_type` varchar(100) NOT NULL DEFAULT '' COMMENT '活动类型：1-赠送积分，2-赠送成长值，3-会员价，4-达人佣金,5-员工佣金，6-分销佣金，7-区域限购',
    `content` text COMMENT '活动内容',
    `status` tinyint(1) NOT NULL DEFAULT 0 COMMENT '状态:0-关闭；1-开启；',
    `mch_id` int(11) NOT NULL COMMENT '应用id',
    `shop_id` int(11) NOT NULL DEFAULT 0 COMMENT '店铺id',
    `create_time` int(11) NOT NULL COMMENT '创建时间',
    `update_time` int(11) NOT NULL DEFAULT 0 COMMENT '更新时间',
    PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8 COMMENT='商品活动表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_order_activity` (
    `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',
    `sys_order_id` int(11) NOT NULL COMMENT '系统订单id',
    `type` varchar(100) NOT NULL DEFAULT '' COMMENT '优惠活动类型，1-优惠券；2-满减；3-会员折扣，4：砍价；5：秒杀；6：拼团；7：积分；10：拼团返利，11：商品卡,12:优惠活动',
    `act_id` int(11) NOT NULL COMMENT '优惠活动id',
    `act_detail` varchar(5000) NOT NULL COMMENT '优惠活动详情',
    `money` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '最终优惠金额',
    `mch_id` int(11) NOT NULL COMMENT '应用id',
    `shop_id` int(11) NOT NULL DEFAULT 0 COMMENT '店铺id',
    `create_time` int(11) NOT NULL COMMENT '创建时间',
    `update_time` int(11) NOT NULL DEFAULT 0 COMMENT '更新时间',
    PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8 COMMENT='订单-优惠活动关联表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_goods_view_log` (
    `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',
    `user_id` int(11) NOT NULL COMMENT '用户id',
    `sys_goods_id` int(11) NOT NULL COMMENT '系统商品id',
    `goods_type`  varchar(100) NOT NULL DEFAULT '' COMMENT '商品类型: normal实物, inquiry询价, product产品, recharge会员储值, warehouse仓储商品, member_card会员卡',
    `times` int(11) NOT NULL DEFAULT 0 COMMENT '商品被访问次数',
    `mch_id` int(11) NOT NULL COMMENT '应用id',
    `shop_id` int(11) NOT NULL DEFAULT 0 COMMENT '店铺id',
    `create_time` int(11) NOT NULL COMMENT '创建时间',
    `update_time` int(11) NOT NULL DEFAULT 0 COMMENT '更新时间',
    PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8 COMMENT='系统商品浏览记录表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_order` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '订单ID',
    `order_no` VARCHAR(50) NOT NULL COMMENT '系统订单编号(唯一)',
    `out_trade_no` VARCHAR(50) NOT NULL COMMENT '商户内部交易号',
    `transaction_id` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '第三方支付流水号',
    `buyer_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '买家ID',
    `sub_buyer_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '子买家id',
    `order_money` DECIMAL(10,2) NOT NULL COMMENT '订单总金额',
    `pay_money` DECIMAL(10,2) NOT NULL COMMENT '实付金额',
    `balance_money` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '余额抵扣金额',
    `integral` int(11) NOT NULL DEFAULT 0 COMMENT '使用积分',
    `refund_money` DECIMAL(10,2) NOT NULL DEFAULT 0.00 COMMENT '已退款金额',
    `refund_status` TINYINT NOT NULL DEFAULT 0 COMMENT '退款状态: 0无退款 1部分退款 2全额退款',
    `order_type` VARCHAR(50) NOT NULL DEFAULT 'normal' COMMENT '订单类型 normal：普通订单；activity_bargain：砍价订单；activity_seckill：秒杀订单；activity_group：拼团订单；activity_integral：积分订单；',
    `order_status` TINYINT NOT NULL DEFAULT 0 COMMENT '订单状态: 0待支付 1已支付 2已发货 3已完成 4退款中 5已退款 6已取消 7已关闭',
    `order_goods_type` VARCHAR(50) NOT NULL DEFAULT 'normal' COMMENT '商品类型: normal-普通, member_charge-储值, electron_coupon-电子卡券, reservation_service-预约服务, micro_pay-当面付, member_card-会员卡',
    `pay_status` TINYINT NOT NULL DEFAULT 0 COMMENT '付款状态: 0未付款 1已付款',
    `pay_type` VARCHAR(50) NOT NULL DEFAULT '0' COMMENT '支付类型，0-微信，1-百度，2-支付宝，3-字节跳动，4-QQ，7-货到付款，8-银行卡支付，11-储值余额，12-激励视频，13-兑换码，15-现金支付，16-积分兑换',
    `pay_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '支付时间',
    `notify_url` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '异步通知URL',
    `return_url` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '支付完成回跳URL',
    `finish_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '完成时间',
    `is_comment` tinyint(1) NOT NULL DEFAULT 1 COMMENT '是否已评价，1:未评价；2:已评价',
    `buyer_remarks` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '买家备注',
    `platform` TINYINT NOT NULL DEFAULT 0 COMMENT '所属平台: 0微信|1百度|2支付宝|3字节跳动|4公众号|5手机站|6QQ',
    `is_help_pay` TINYINT NOT NULL DEFAULT 0 COMMENT '是否代付',
    `extend` TEXT COMMENT '扩展信息(JSON)',
    `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '商户ID',
    `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
    `create_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    `delete_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uniq_order_no` (`order_no`),
    KEY `idx_buyer_status` (`buyer_id`, `order_status`),
    KEY `idx_shop_time` (`shop_id`, `create_time`),
    KEY `idx_pay_status` (`pay_status`, `pay_type`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='系统订单表（含支付信息）';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_order_goods` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '自增ID',
    `sys_order_id` BIGINT UNSIGNED NOT NULL COMMENT '订单ID',
    `sys_goods_id` BIGINT UNSIGNED NOT NULL COMMENT '商品ID',
    `goods_name` VARCHAR(255) NOT NULL COMMENT '商品名称(下单快照)',
    `goods_price` DECIMAL(10,2) NOT NULL COMMENT '商品单价(快照)',
    `num` INT NOT NULL DEFAULT 1 COMMENT '购买数量',
    `pic_url` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '商品图片(快照)',
    `pay_money` DECIMAL(10,2) NOT NULL DEFAULT 0.00 COMMENT '实际支付金额',
    `modify_money` DECIMAL(10,2) NOT NULL DEFAULT 0.00 COMMENT '后台改价金额',
    `freight` DECIMAL(10,2) NOT NULL DEFAULT 0.00 COMMENT '运费',
    `discount_info` TEXT COMMENT '折扣信息(JSON)',
    `goods_info` TEXT COMMENT '商品扩展信息(JSON，如规格属性)',
    `order_goods_type` VARCHAR(50) NOT NULL DEFAULT 'normal' COMMENT '商品类型: normal普通, inquiry询价, product产品, recharge储值, member_card会员卡',
    `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '商户ID',
    `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
    `create_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    `delete_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间',
    PRIMARY KEY (`id`),
    KEY `idx_order_goods` (`sys_order_id`, `sys_goods_id`),
    KEY `idx_shop_goods` (`shop_id`, `sys_goods_id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='系统订单商品表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_order_refund` (
    `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',
    `sys_order_id` int(11) NOT NULL COMMENT '系统订单id',
    `user_id` int(11) NOT NULL COMMENT '用户id',
    `refund_id` varchar(50) NOT NULL DEFAULT '' COMMENT '第三方退款单号',
    `out_refund_no` varchar(50) NOT NULL DEFAULT '' COMMENT '系统退款单号',
    `order_type` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '订单类型 normal：普通订单；activity_bargain：砍价订单；activity_seckill：秒杀订单；activity_group：拼团订单；activity_integralmall：积分订单；',
    `refund_reason` varchar(500) NOT NULL DEFAULT '' COMMENT '退款原因',
    `reject_reason` varchar(500) NOT NULL DEFAULT '' COMMENT '拒绝退款原因',
    `remark` varchar(500) NOT NULL DEFAULT '' COMMENT '备注',
    `status` tinyint(1) NOT NULL DEFAULT 0 COMMENT '退款状态，0：待退款；1：同意；2：拒绝；3：取消退款',
    `mch_id` int(11) NOT NULL COMMENT '应用id',
    `shop_id` int(11) NOT NULL DEFAULT 0 COMMENT '店铺id',
    `platform` tinyint(3) NOT NULL DEFAULT 0 COMMENT '所属平台: 0微信|1百度|2支付宝|3字节跳动|4公众号|5手机站|6QQ',
    `create_time` int(11) NOT NULL COMMENT '申请时间',
    `update_time` int(11) NOT NULL DEFAULT 0 COMMENT '更新时间',
    PRIMARY KEY (`id`)
    ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8 COMMENT='订单退款表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_order_express` (
    `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',
    `sys_order_id` int(11) NOT NULL COMMENT '系统订单id',
    `express_type` tinyint(2) NOT NULL DEFAULT 1 COMMENT '发货方式，1-常用物流；2-无需物流；3-达达配送；4-微信物流；7-蜂鸟；8-裹小递',
    `express_name` varchar(100) NOT NULL DEFAULT '' COMMENT '快递公司名称',
    `express_code` varchar(50) NOT NULL DEFAULT '' COMMENT '快递公司编码',
    `express_no` varchar(50) NOT NULL DEFAULT '' COMMENT '运单编号',
    `delivery_type` tinyint(1) NOT NULL DEFAULT 0 COMMENT '物流类型，0-默认，1-快递鸟 2-快递100 3-阿里云物流',
    `remarks` varchar(100) NOT NULL DEFAULT '' COMMENT '备注信息',
    `mch_id` int(11) NOT NULL COMMENT '应用id',
    `shop_id` int(11) NOT NULL DEFAULT 0 COMMENT '店铺id',
    `create_time` int(11) NOT NULL COMMENT '发货时间',
    `update_time` int(11) NOT NULL DEFAULT 0 COMMENT '更新时间',
    PRIMARY KEY (`id`)
    ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8 COMMENT='订单物流表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_order_price_modify_log` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `sys_order_id` int(11) NOT NULL COMMENT '系统订单id',
    `admin_id` int(11) NOT NULL COMMENT '操作人id',
    `admin_name` varchar(50) NOT NULL DEFAULT '' COMMENT '操作人名称',
    `admin_type` tinyint(1) NOT NULL DEFAULT 1 COMMENT '操作人类型：1 后台,2 商家端',
    `old_price` decimal(10,2) NOT NULL COMMENT '修改前的金额',
    `new_price` decimal(10,2) NOT NULL COMMENT '修改后的金额',
    `mch_id` int(11) NOT NULL COMMENT '应用id',
    `shop_id` int(11) NOT NULL DEFAULT 0 COMMENT '店铺id',
    `create_time` int(11) NOT NULL COMMENT '修改时间',
    `update_time` int(11) NOT NULL DEFAULT 0 COMMENT '更新时间',
    PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8 COMMENT='订单价格修改日志表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_builder` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '自增ID',
    `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '商户ID',
    `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
    `admin_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '管理员ID',
    `group_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '分组ID',
    `builder_type` VARCHAR(50) NOT NULL DEFAULT 'builder' COMMENT '类型：system/系统 builder/自建',
    `name` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '应用名称',
    `relation_table` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '关联表名',
    `icon` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '应用图标',
    `image` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '应用图片',
    `is_approval` TINYINT NOT NULL DEFAULT 0 COMMENT '是否审批: 0否 1是',
    `is_edit` TINYINT NOT NULL DEFAULT 1 COMMENT '是否可修改: 0否 1是',
    `sys_menu_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '菜单ID',
    `desc` VARCHAR(2000) NOT NULL DEFAULT '' COMMENT '应用描述',
    `data` LONGTEXT NOT NULL COMMENT '表单配置信息(JSON)',
    `extend` TEXT COMMENT '扩展信息(JSON)',
    `create_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    `delete_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间',
    PRIMARY KEY (`id`),
    KEY `idx_shop_admin` (`shop_id`, `admin_id`),
    KEY `idx_menu` (`sys_menu_id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='界面构建模块表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_builder_group` (
  `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '商户ID',
  `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
  `admin_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '管理员ID',
  `builder_type` VARCHAR(50) NOT NULL DEFAULT 'builder' COMMENT '类型：system/系统 builder/自建',
    `name` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '应用名称',
    `is_edit` TINYINT NOT NULL DEFAULT 1 COMMENT '是否可修改: 0否 1是',
    `sys_menu_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '菜单ID',
    `desc` VARCHAR(2000) NOT NULL DEFAULT '' COMMENT '应用描述',
    `create_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    `delete_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间',
    PRIMARY KEY (`id`),
    KEY `idx_shop_admin` (`shop_id`, `admin_id`),
    KEY `idx_menu` (`sys_menu_id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='界面构建分组表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_builder_scenes` (
   `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '自增ID',
   `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '商户ID',
   `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
   `admin_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '管理员ID',
   `sys_builder_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '关联应用ID',
   `relation_table` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '关联表名',
   `scene_flag` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '场景值标识',
    `name` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '场景名称',
    `data` LONGTEXT NOT NULL COMMENT '场景数据(JSON)',
    `default_sort` VARCHAR(2000) NOT NULL DEFAULT '' COMMENT '默认排序规则',
    `is_default` TINYINT NOT NULL DEFAULT 0 COMMENT '是否默认: 0否 1是',
    `is_edit` TINYINT NOT NULL DEFAULT 0 COMMENT '是否可修改: 0否 1是',
    `status` TINYINT NOT NULL DEFAULT 1 COMMENT '状态: 0隐藏 1显示',
    `sort` INT NOT NULL DEFAULT 0 COMMENT '显示排序',
    `extend` TEXT COMMENT '扩展信息(JSON)',
    `create_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    `delete_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间',
    PRIMARY KEY (`id`),
    KEY `idx_builder_scene` (`sys_builder_id`, `sort`),
    KEY `idx_shop_admin` (`shop_id`, `admin_id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='界面构建模块场景表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_builder_searchs` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '自增ID',
    `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '商户ID',
    `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
    `admin_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '管理员ID',
    `sys_builder_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '关联应用ID',
    `relation_table` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '关联表名',
    `data` LONGTEXT NOT NULL COMMENT '搜索条件配置(JSON)',
    `extend` TEXT COMMENT '扩展信息(JSON)',
    `create_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    `delete_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间',
    PRIMARY KEY (`id`),
    KEY `idx_builder_search` (`sys_builder_id`),
    KEY `idx_shop_admin` (`shop_id`, `admin_id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='界面构建模块搜索表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_builder_columns` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '自增ID',
    `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '商户ID',
    `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
    `admin_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '管理员ID',
    `sys_builder_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '关联应用ID',
    `relation_table` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '关联表名',
    `data` LONGTEXT NOT NULL COMMENT '字段配置(JSON)',
    `extend` TEXT COMMENT '扩展信息(JSON)',
    `create_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    `delete_time` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间',
    PRIMARY KEY (`id`),
    KEY `idx_builder_column` (`sys_builder_id`),
    KEY `idx_shop_admin` (`shop_id`, `admin_id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='界面构建模块字段配置表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_approval_setting` (
     `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '自增ID',
     `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '应用ID',
     `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
     `name` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '审批项名称',
    `flag` VARCHAR(191) NOT NULL DEFAULT '' COMMENT '审批项标识',
    `mark` TEXT COMMENT '备注',
    `relation_table` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '关联表名',
    `setting` LONGTEXT COMMENT '服务配置',
    `type` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '类型: 0固定审批 | 1授权审批人 | 2无需审批',
    `create_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    `delete_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间',
    PRIMARY KEY (`id`),
    KEY `idx_flag` (`flag`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='审批设置表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_approval_log` (
     `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '自增ID',
     `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '应用ID',
     `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
     `admin_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建管理员ID',
     `approval_setting_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '审批设置ID',
     `relation_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '关联ID',
     `relation_table` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '关联表名',
    `type` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '类型: 0固定审批 | 1授权审批人 | 2无需审批',
    `status` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '状态: 0未审批 | 1通过 | 2不通过',
    `flag` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '审批项标识',
    `create_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    `delete_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间',
    PRIMARY KEY (`id`),
    KEY `idx_setting_relation` (`approval_setting_id`, `relation_id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='审批记录表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_approval_admin_log` (
   `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '自增ID',
   `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '应用ID',
   `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
   `approval_setting_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '审批设置ID',
   `admin_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '管理员ID',
   `relation_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '关联ID',
   `relation_table` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '关联表名',
    `type` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '类型: 0固定审批 | 1授权审批人 | 2无需审批',
    `level` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '层级',
    `approval_type` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '审批类型: 0任意一人 | 1多人会签 | 2直属上级',
    `status` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '状态: 0未审批 | 1通过 | 2不通过 | 3等待上级审批',
    `is_chaosong` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否抄送: 0否 | 1是',
    `mark` TEXT COMMENT '备注',
    `flag` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '审批项标识',
    `approval_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '审核时间',
    `create_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    `delete_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间',
    PRIMARY KEY (`id`),
    KEY `idx_admin_relation` (`admin_id`, `relation_id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='审批人员日志表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_approval_admin_action_log` (
  `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `mch_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '应用ID',
  `shop_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '店铺ID',
  `approval_setting_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '审批设置ID',
  `admin_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '管理员ID',
  `relation_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '关联ID',
  `relation_table` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '关联表名',
    `type` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '类型: 0固定审批 | 1授权审批人 | 2无需审批',
    `level` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '层级',
    `approval_type` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '审批类型: 0任意一人 | 1多人会签 | 2直属上级',
    `status` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '状态: 0未审批 | 1通过 | 2不通过 | 3等待上级审批',
    `is_chaosong` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否抄送: 0否 | 1是',
    `mark` TEXT COMMENT '备注',
    `flag` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '审批项标识',
    `approval_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '审核时间',
    `create_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    `delete_time` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '删除时间',
    PRIMARY KEY (`id`),
    KEY `idx_admin_action` (`admin_id`, `relation_id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='审批人员操作记录表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_access_token` (
    `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',
    `appid` varchar(255) NOT NULL COMMENT 'appid',
    `access_token` varchar(255) NOT NULL COMMENT 'access_token',
    `refresh_token` varchar(255) DEFAULT '' COMMENT 'refresh_token',
    `expire_time` int(11) NOT NULL DEFAULT '0' COMMENT '过期时间',
    `token_type` varchar(255) DEFAULT 'default' COMMENT 'default/默认 customer_contact_token/企业微信客户  address_book_token/企业通讯录',
    `platform` tinyint(3) NOT NULL DEFAULT 0 COMMENT '所属平台: 0微信|1百度|2支付宝|3字节跳动|4公众号|5手机站|6QQ',
    `mch_id` int(11) NOT NULL COMMENT '应用id',
    `shop_id` int(11) NOT NULL DEFAULT 0 COMMENT '店铺ID',
    `create_time` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
    `update_time` int(11) NOT NULL DEFAULT 0 COMMENT '修改时间',
    PRIMARY KEY (`id`)
    ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8 COMMENT='access_token表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_pay_notify` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `mch_id` int(11) NOT NULL COMMENT '应用ID',
    `shop_id` int(11) NOT NULL DEFAULT 0 COMMENT '店铺id',
    `order_number` varchar(50) DEFAULT NULL COMMENT '订单号',
    `notify_message` varchar(2000) NOT NULL COMMENT '回调内容',
    `create_time` int(11) NOT NULL,
    PRIMARY KEY (`id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='支付通知表';

CREATE TABLE IF NOT EXISTS `YB_TABLE_PREFIX_sys_transfer_log` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `mch_id` int(11) NOT NULL COMMENT '应用ID',
    `shop_id` int(11) NOT NULL DEFAULT 0 COMMENT '店铺ID',
    `relate_type` tinyint(2) NOT NULL DEFAULT 1 COMMENT '关联类型 1/分销 2/股东分红 3/区域代理 4/团队分红 5/门店佣金 6/积分提现 7/社区团购 8/代理股东',
    `relate_ids` varchar(1000) NOT NULL DEFAULT '' COMMENT '关联id组',
    `out_batch_no` varchar(50) NOT NULL DEFAULT '' COMMENT '商家批次单号',
    `request_message` varchar(2000) NOT NULL COMMENT '请求信息',
    `return_message` varchar(2000) NOT NULL DEFAULT '' COMMENT '返回信息',
    `create_time` int(11) NOT NULL COMMENT '记录创建时间',
    `update_time` int(11) NOT NULL DEFAULT 0 COMMENT '记录修改时间',
    PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='提现记录表';
