

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for bot_address
-- ----------------------------
DROP TABLE IF EXISTS `bot_address`;
CREATE TABLE `bot_address`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `member_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'tg ID',
  `address` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '地址',
  `alias` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '别名',
  `updated_at` datetime(0) NULL DEFAULT NULL,
  `created_at` datetime(0) NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for bot_admin
-- ----------------------------
DROP TABLE IF EXISTS `bot_admin`;
CREATE TABLE `bot_admin`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `password` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `nickname` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `sex` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `cellphone` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `email` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `remarks` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `updated_at` datetime(0) NULL DEFAULT NULL,
  `created_at` datetime(0) NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '管理员' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of bot_admin
-- ----------------------------
INSERT INTO `bot_admin` VALUES (1, 'admin', '$2y$10$aRuvnclyyJyd7Nu8gDcqg.OBtAkWtZ0luS9Bzz8YD5eh3cJVpjHsy', '管理员', '女', '18888888888', 'admin@163.com', '', '2024-11-27 14:24:35', '2024-11-27 14:20:11');

-- ----------------------------
-- Table structure for bot_balance_logs
-- ----------------------------
DROP TABLE IF EXISTS `bot_balance_logs`;
CREATE TABLE `bot_balance_logs`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `room_id` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '房间号，如果是结算，或其它有房间号相关的，则记录此字段',
  `member_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'tg id',
  `amount` decimal(30, 10) NULL DEFAULT NULL COMMENT '变动金额',
  `before_balance` decimal(30, 10) NULL DEFAULT NULL COMMENT '变动前余额',
  `after_balance` decimal(30, 10) NULL DEFAULT NULL COMMENT '变动后余额',
  `change_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '变动类型，如 \"充值\"、\"提现\"、\"结算\" 等',
  `created_at` datetime(0) NULL DEFAULT NULL,
  `updated_at` datetime(0) NULL DEFAULT NULL,
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '变动的描述信息，可以存储一些简短的备注信息',
  `related_id` int(11) NULL DEFAULT NULL COMMENT '相关ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for bot_config
-- ----------------------------
DROP TABLE IF EXISTS `bot_config`;
CREATE TABLE `bot_config`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `field` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `val` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL,
  `updated_at` datetime(0) NULL DEFAULT NULL,
  `created_at` datetime(0) NULL DEFAULT NULL,
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `field`(`field`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of bot_config
-- ----------------------------
INSERT INTO `bot_config` VALUES (1, 'base_score', '[1,3,5,8,10,15]', '2025-07-07 17:48:06', '2025-07-07 17:48:06', '房间底分数组JSON');
INSERT INTO `bot_config` VALUES (2, 'brokerage', '0.05', '2025-07-07 17:48:06', '2025-07-07 17:48:06', '抽佣比例');
INSERT INTO `bot_config` VALUES (3, 'service_charge', '2', '2025-07-07 17:48:06', '2025-07-07 17:48:06', '提现手续费');
INSERT INTO `bot_config` VALUES (4, 'service_account', 'oooluckybot', '2025-07-07 17:48:06', '2025-07-07 17:48:06', '客服账号');
INSERT INTO `bot_config` VALUES (5, 'receiving_address', 'Trftghhnnbg6775tghy678ikuj9807ujht', '2025-07-07 17:48:06', '2025-07-07 17:48:06', '收款地址');
INSERT INTO `bot_config` VALUES (6, 'receiving_type', '2', '2025-07-07 17:48:06', '2025-07-07 17:48:06', '收款方式 1-自动 2-手动');
INSERT INTO `bot_config` VALUES (7, 'channel_message', '{\"chatId\":\"oooluckychannel\",\"image\":\"https://baidu.com/logo.jpg\",\"text\":\"这是文本内容\",\"button\":[[{\"text\":\"开云注册送138\",\"url\":\"https://baidu.com\"}],[{\"text\":\"世界杯招代理\",\"url\":\"https://baidu.com\"},{\"text\":\"米兰体育官网\",\"url\":\"https://baidu.com\"}]]}', '2025-07-07 17:48:06', '2025-07-07 17:48:06', '频道消息JSON');

INSERT INTO `bot_config` VALUES (8, 'betting_group', '+8jhXv9Eb-oRmZDY1', '2025-07-07 17:48:06', '2025-07-07 17:48:06', '投注群');
INSERT INTO `bot_config` VALUES (9, 'rebate', '0', '2025-07-07 17:48:06', '2025-07-07 17:48:06', '返佣比例');


-- ----------------------------
-- Table structure for bot_messages
-- ----------------------------
DROP TABLE IF EXISTS `bot_messages`;
CREATE TABLE `bot_messages`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `created_at` datetime(0) NULL DEFAULT NULL,
  `updated_at` datetime(0) NULL DEFAULT NULL,
  `json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for bot_room_users
-- ----------------------------
DROP TABLE IF EXISTS `bot_room_users`;
CREATE TABLE `bot_room_users`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `room_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '房间号',
  `member_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'tgID',
  `game_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '游戏ID',
  `status` tinyint(1) NULL DEFAULT 0 COMMENT '人员状态\r\n0 待准备\r\n1 已准备\r\n2 游戏中\r\n3 待结算\r\n4 已结算',
  `score` int(11) NULL DEFAULT NULL COMMENT '得分',
  `brokerage` decimal(30, 10) NULL DEFAULT 0.0000000000 COMMENT '抽佣金额',
  `real_score` decimal(30, 10) NULL DEFAULT 0.0000000000 COMMENT '真实金额',
  `screenshot` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '结算截图',
  `updated_at` datetime(0) NULL DEFAULT NULL,
  `created_at` datetime(0) NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
ALTER TABLE `bot_room_users` ADD COLUMN `first_name` varchar(255) NULL COMMENT '用户昵称' AFTER `created_at`;
-- ----------------------------
-- Table structure for bot_rooms
-- ----------------------------
DROP TABLE IF EXISTS `bot_rooms`;
CREATE TABLE `bot_rooms`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `room_id` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '房间号',
  `member_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '房主ID',
  `updated_at` datetime(0) NULL DEFAULT NULL,
  `created_at` datetime(0) NULL DEFAULT NULL,
  `status` tinyint(1) NULL DEFAULT 0 COMMENT '房间状态\r\n0 创建中\r\n1 创建完成\r\n2 游戏中\r\n3 已结算\r\n4 异常\r\n5 解散',
  `game_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '游戏名称',
  `base_score` int(11) NULL DEFAULT 0 COMMENT '底分',
  `participants` int(11) NULL DEFAULT 0 COMMENT '人数',
  `rounds` int(11) NULL DEFAULT 0 COMMENT '局数',
  `join_count` int(11) NULL DEFAULT 0 COMMENT '已加入人数',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

ALTER TABLE `bot_rooms` ADD COLUMN `introduction` varchar(255) NULL DEFAULT '' COMMENT '游戏介绍' AFTER `join_count`;

ALTER TABLE `bot_rooms`
ADD COLUMN `old_room_id`  varchar(16) NULL COMMENT '原房号' AFTER `join_count`;
ALTER TABLE `bot_rooms`
ADD COLUMN `midway`  tinyint(1) NULL DEFAULT 0 COMMENT '中途加入游戏 1-允许' AFTER `old_room_id`;

ALTER TABLE `bot_rooms`
ADD COLUMN `settle_status`  tinyint(1) NULL DEFAULT 0 COMMENT '结算通知:1=已通知' AFTER `midway`;

-- ----------------------------
-- Table structure for bot_users
-- ----------------------------
DROP TABLE IF EXISTS `bot_users`;
CREATE TABLE `bot_users`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `member_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户ID',
  `first_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户昵称',
  `created_at` datetime(0) NULL DEFAULT NULL,
  `updated_at` datetime(0) NULL DEFAULT NULL,
  `usdt` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT 'USDT地址',
  `game_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '游戏ID',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `member_id`(`member_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for bot_withdraws
-- ----------------------------
DROP TABLE IF EXISTS `bot_withdraws`;
CREATE TABLE `bot_withdraws`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `member_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'tg_id',
  `amount` decimal(30, 10) NULL DEFAULT NULL COMMENT '提现金额',
  `service_charge` decimal(30, 10) NULL DEFAULT NULL COMMENT '手续费',
  `to_account` decimal(30, 10) NULL DEFAULT NULL COMMENT '到账金额',
  `after_balance` decimal(30, 10) NULL DEFAULT NULL COMMENT '提现后余额',
  `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '提现地址',
  `updated_at` datetime(0) NULL DEFAULT NULL,
  `created_at` datetime(0) NULL DEFAULT NULL,
  `status` tinyint(1) NULL DEFAULT 0 COMMENT '状态\r\n0 申请中\r\n1 成功\r\n2 失败',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '失败备注',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;


-- ----------------------------
-- Table structure for bot_coins
-- ----------------------------
DROP TABLE IF EXISTS `bot_coins`;
CREATE TABLE `bot_coins` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `coin` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `net` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `address` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `min_exchange_amount` decimal(30,10) NOT NULL DEFAULT '10.0000000000' COMMENT '最低闪兑金额',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- ----------------------------
-- Records of bot_coins
-- ----------------------------
INSERT INTO `bot_coins` VALUES ('1', 'USDT', 'TRC20', 'TGQaMxtyWeGowy8xqwh98JNNLtc77nzZ8M', null, '2025-05-20 09:33:30', '1.0000000000');


-- ----------------------------
-- Table structure for bot_wallets
-- ----------------------------
DROP TABLE IF EXISTS `bot_wallets`;
CREATE TABLE `bot_wallets` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint(20) unsigned NOT NULL COMMENT '用户ID',
  `member_id` bigint(20) DEFAULT NULL COMMENT 'TGID',
  `coin` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '币种ID',
  `net` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '网络类型',
  `address` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '链上钱包地址',
  `private_key` text COLLATE utf8mb4_unicode_ci COMMENT '钱包私钥（加密后）',
  `available_balance` decimal(30,10) NOT NULL DEFAULT '0.0000000000' COMMENT '可用余额',
  `frozen_balance` decimal(30,10) NOT NULL DEFAULT '0.0000000000' COMMENT '冻结余额',
  `total_balance` decimal(30,10) NOT NULL DEFAULT '0.0000000000' COMMENT '总余额',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `wallets_user_id_index` (`user_id`),
  KEY `wallets_coin_id_index` (`coin`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

DROP TABLE IF EXISTS `bot_recharges`;
CREATE TABLE `bot_recharges` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `member_id` bigint(20) DEFAULT NULL COMMENT '会员ID',
  `net` varchar(50) DEFAULT NULL COMMENT '链接类型',
  `coin` varchar(50) DEFAULT NULL COMMENT '币种',
  `amount` decimal(30,10) DEFAULT NULL COMMENT '充值数量',
  `to_address` varchar(100) DEFAULT NULL COMMENT '充值地址（平台地址）',
  `from_address` varchar(100) DEFAULT NULL COMMENT '转出地址（用户发起地址）',
  `txid` varchar(100) DEFAULT NULL COMMENT '链上交易哈希',
  `block_time` int(11) DEFAULT NULL COMMENT '区块时间',
  `block_height` bigint(20) DEFAULT NULL,
  `confirmations` int(11) DEFAULT '0' COMMENT '确认数',
  `status` tinyint(2) DEFAULT '0' COMMENT '状态：0=待确认，1=已确认，2=失败，3=已忽略',
  `created_at` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_txid` (`txid`) USING BTREE,
  KEY `re_to_address` (`to_address`) USING BTREE,
  KEY `re_member_id` (`member_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
ALTER TABLE `bot_recharges`
ADD COLUMN `type`  tinyint(1) NULL DEFAULT 1 COMMENT '充值类型:1=自动,2=手动' AFTER `status`;
ALTER TABLE `bot_recharges`
ADD COLUMN `image`  varchar(255) NULL COMMENT '充值图片' AFTER `type`;

DROP TABLE IF EXISTS `bot_collects`;
CREATE TABLE `bot_collects` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `coin` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '币种',
  `net` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '网络',
  `from_address` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '归集来源地址',
  `to_address` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '归集目标地址（主钱包）',
  `amount` decimal(36,18) NOT NULL COMMENT '归集金额（USDT）',
  `fee` decimal(36,18) DEFAULT '0.000000000000000000' COMMENT '交易手续费（TRX）',
  `txid` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '链上交易哈希',
  `status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '状态：0待处理，1已发起，2已确认，3失败',
  `confirmations` int(11) DEFAULT '0' COMMENT '确认数',
  `block_number` bigint(20) DEFAULT NULL COMMENT '交易所在区块高度',
  `remark` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注信息',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`),
  KEY `idx_from_address` (`from_address`),
  KEY `idx_to_address` (`to_address`),
  KEY `idx_txid` (`txid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='归集记录表';

DROP TABLE IF EXISTS `bot_roles`;
CREATE TABLE `bot_roles` (
  `id` BIGINT UNSIGNED AUTO_INCREMENT COMMENT '角色ID',
  `name` VARCHAR(50) NOT NULL UNIQUE COMMENT '角色标识（英文唯一）',
  `display_name` VARCHAR(100) DEFAULT NULL COMMENT '角色名称（显示用）',
  `description` TEXT COMMENT '角色描述',
  `created_at` TIMESTAMP NULL DEFAULT NULL,
  `updated_at` TIMESTAMP NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) COMMENT='角色表';
ALTER TABLE `bot_roles`
MODIFY COLUMN `name`  varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '角色标识（英文唯一）' AFTER `id`;


DROP TABLE IF EXISTS `bot_permissions`;
CREATE TABLE `bot_permissions` (
  `id` BIGINT UNSIGNED AUTO_INCREMENT COMMENT '权限ID',
  `name` VARCHAR(100) NOT NULL UNIQUE COMMENT '权限标识（英文唯一）',
  `display_name` VARCHAR(100) DEFAULT NULL COMMENT '权限名称（显示用）',
  `description` TEXT COMMENT '权限描述',
  `created_at` TIMESTAMP NULL DEFAULT NULL,
  `updated_at` TIMESTAMP NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) COMMENT='权限表';

DROP TABLE IF EXISTS `bot_permission_role`;
CREATE TABLE `bot_permission_role` (
  `permission_id` BIGINT UNSIGNED NOT NULL COMMENT '权限ID',
  `role_id` BIGINT UNSIGNED NOT NULL COMMENT '角色ID',
  PRIMARY KEY (`permission_id`, `role_id`)
) COMMENT='权限与角色关联表';

DROP TABLE IF EXISTS `bot_role_menu`;
CREATE TABLE `bot_role_menu` (
  `menu_id` bigint(20) unsigned NOT NULL COMMENT '菜单ID',
  `role_id` bigint(20) unsigned NOT NULL COMMENT '角色ID',
  PRIMARY KEY (`menu_id`,`role_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='菜单与角色关联表';

DROP TABLE IF EXISTS `bot_role_user`;
CREATE TABLE `bot_role_user` (
  `user_id` BIGINT UNSIGNED NOT NULL COMMENT '用户ID',
  `role_id` BIGINT UNSIGNED NOT NULL COMMENT '角色ID',
  PRIMARY KEY (`user_id`, `role_id`)
) COMMENT='用户与角色关联表';


DROP TABLE IF EXISTS `bot_menus`;
CREATE TABLE `bot_menus` (
  `id` BIGINT UNSIGNED AUTO_INCREMENT COMMENT '菜单ID',
  `parent_id` BIGINT UNSIGNED DEFAULT 0 COMMENT '父级菜单ID',
  `title` VARCHAR(100) NOT NULL COMMENT '菜单名称',
  `icon` VARCHAR(50) DEFAULT NULL COMMENT '菜单图标',
  `uri` VARCHAR(255) DEFAULT NULL COMMENT '菜单链接地址/路由',
  `permission_name` VARCHAR(100) DEFAULT NULL COMMENT '绑定权限标识（name）',
  `sort` INT DEFAULT 0 COMMENT '排序值（越小越靠前）',
  `created_at` TIMESTAMP NULL DEFAULT NULL,
  `updated_at` TIMESTAMP NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) COMMENT='菜单表';
ALTER TABLE `bot_menus`
ADD COLUMN `status`  tinyint(1) NULL DEFAULT 1 COMMENT '是否可见：1=显示，2=隐藏' AFTER `sort`,
ADD COLUMN `type`  tinyint(1) NULL DEFAULT 1 COMMENT '类型:1=菜单,2=按钮' AFTER `status`;

INSERT INTO `bot_menus` VALUES ('1', '0', '会员列表', null, '/', null, '0', '1', '1', null, null);
INSERT INTO `bot_menus` VALUES ('2', '0', '充值列表', null, 'wallet/topUp', null, '0', '1', '1', null, null);
INSERT INTO `bot_menus` VALUES ('3', '40', '游戏房间', null, 'room', null, '0', '1', '1', null, null);
INSERT INTO `bot_menus` VALUES ('4', '0', '提现列表', null, 'withdraw/list', null, '0', '1', '1', null, null);
INSERT INTO `bot_menus` VALUES ('5', '0', '钱包记录', null, 'balance/log', null, '0', '1', '1', null, null);
INSERT INTO `bot_menus` VALUES ('6', '0', '所有配置', null, 'config', null, '0', '1', '1', null, null);
INSERT INTO `bot_menus` VALUES ('7', '6', '所有配置', null, 'getAll', null, '0', '1', '1', null, null);
INSERT INTO `bot_menus` VALUES ('8', '6', '频道管理', null, 'Message', null, '0', '1', '1', null, null);
INSERT INTO `bot_menus` VALUES ('9', '0', '权限管理', null, '/authority', null, '0', '1', '1', null, null);
INSERT INTO `bot_menus` VALUES ('10', '9', '账号管理', null, 'account', null, '0', '1', '1', null, null);
INSERT INTO `bot_menus` VALUES ('11', '9', '角色管理', null, 'role', null, '0', '1', '1', null, null);
INSERT INTO `bot_menus` VALUES ('12', '9', '菜单管理', null, 'menu', null, '0', '1', '1', null, null);

INSERT INTO `bot_menus` VALUES ('13', '10', '账号列表', null, 'admin/index', null, '0', '1', '2', '2025-07-30 15:46:37', '2025-07-30 15:46:37');
INSERT INTO `bot_menus` VALUES ('14', '10', '账号修改', null, 'admin/submit', null, '0', '1', '2', '2025-07-30 15:47:15', '2025-07-30 15:47:15');
INSERT INTO `bot_menus` VALUES ('15', '10', '账号删除', null, 'admin/delete', null, '0', '1', '2', '2025-07-30 15:47:50', '2025-07-30 15:47:50');
INSERT INTO `bot_menus` VALUES ('16', '4', '提现列表', null, 'admin/withdraw', null, '0', '1', '2', '2025-07-30 15:50:14', '2025-07-30 15:50:14');
INSERT INTO `bot_menus` VALUES ('17', '4', '提现审核', null, 'admin/withdraw/setStatus', null, '0', '1', '2', '2025-07-30 15:50:57', '2025-07-30 15:50:57');
INSERT INTO `bot_menus` VALUES ('18', '3', '游戏房间列表', null, 'admin/room', null, '0', '1', '2', '2025-07-30 15:52:28', '2025-07-30 15:52:28');
INSERT INTO `bot_menus` VALUES ('19', '3', '对局详情', null, 'admin/room/details', null, '0', '1', '2', '2025-07-30 15:53:10', '2025-07-30 15:53:10');
INSERT INTO `bot_menus` VALUES ('20', '3', '设置用户得分', null, 'admin/room/setScore', null, '0', '1', '2', '2025-07-30 15:53:40', '2025-07-30 15:53:40');
INSERT INTO `bot_menus` VALUES ('21', '3', '结算', null, 'admin/room/completed', null, '0', '1', '2', '2025-07-30 15:54:01', '2025-07-30 15:54:01');
INSERT INTO `bot_menus` VALUES ('22', '7', '获取所有配置', null, 'admin/config/getAll', null, '0', '1', '2', '2025-07-30 15:57:10', '2025-07-30 15:57:10');
INSERT INTO `bot_menus` VALUES ('23', '7', '修改配置', null, 'admin/config/set', null, '0', '1', '2', '2025-07-30 15:57:56', '2025-07-30 15:57:56');
INSERT INTO `bot_menus` VALUES ('24', '8', '获取指定配置', null, 'admin/config/get', null, '0', '1', '2', '2025-07-30 15:59:12', '2025-07-30 15:59:12');
INSERT INTO `bot_menus` VALUES ('25', '8', '发送频道消息', null, 'admin/config/sendChannelMessage', null, '0', '1', '2', '2025-07-30 15:59:57', '2025-07-30 15:59:57');
INSERT INTO `bot_menus` VALUES ('26', '5', '钱包记录', null, 'admin/balance/log', null, '0', '1', '2', '2025-07-30 16:01:43', '2025-07-30 16:01:43');
INSERT INTO `bot_menus` VALUES ('27', '2', '充值列表', null, 'admin/wallet', null, '0', '1', '2', '2025-07-30 16:05:07', '2025-07-30 16:05:07');
INSERT INTO `bot_menus` VALUES ('28', '1', '人工充值', null, 'admin/wallet/topUp', null, '0', '1', '2', '2025-07-30 16:07:01', '2025-07-30 16:07:01');
INSERT INTO `bot_menus` VALUES ('29', '2', '充值审核', null, 'admin/wallet/verifyRecharge', null, '0', '1', '2', '2025-07-30 16:08:07', '2025-07-30 16:08:07');
INSERT INTO `bot_menus` VALUES ('30', '1', '会员列表', null, 'admin/user', null, '0', '1', '2', '2025-07-30 16:09:09', '2025-07-30 16:09:09');
INSERT INTO `bot_menus` VALUES ('31', '12', '菜单列表', null, 'admin/menu', null, '0', '1', '2', '2025-07-30 16:09:45', '2025-07-30 16:09:45');
INSERT INTO `bot_menus` VALUES ('32', '12', '菜单修改', null, 'admin/menu/submit', null, '0', '1', '2', '2025-07-30 16:10:18', '2025-07-30 16:10:18');
INSERT INTO `bot_menus` VALUES ('33', '12', '菜单删除', null, 'admin/menu/delete', null, '0', '1', '2', '2025-07-30 16:10:43', '2025-07-30 16:10:43');
INSERT INTO `bot_menus` VALUES ('34', '12', '所有菜单', null, 'admin/menu/all', null, '0', '1', '2', '2025-07-30 16:11:20', '2025-07-30 16:11:20');
INSERT INTO `bot_menus` VALUES ('35', '11', '角色列表', null, 'admin/role', null, '0', '1', '2', '2025-07-30 16:13:21', '2025-07-30 16:13:21');
INSERT INTO `bot_menus` VALUES ('36', '11', '角色修改', null, 'admin/role/submit', null, '0', '1', '2', '2025-07-30 16:14:14', '2025-07-30 16:14:14');
INSERT INTO `bot_menus` VALUES ('37', '11', '角色删除', null, 'admin/role/delete', null, '0', '1', '2', '2025-07-30 16:14:26', '2025-07-30 16:14:26');
INSERT INTO `bot_menus` VALUES ('38', '11', '所有角色', null, 'admin/role/all', null, '0', '1', '2', '2025-07-30 16:14:38', '2025-07-30 16:14:38');

INSERT INTO `bot_menus` VALUES ('40', '0', '房间管理', null, '/chamber', null, '0', '1', '1', null, null);
INSERT INTO `bot_menus` VALUES ('41', '0', '游戏管理', null, 'game', null, '0', '1', '1', null, null);

-- ----------------------------
-- Table structure for bot_games
-- ----------------------------
DROP TABLE IF EXISTS `bot_games`;
CREATE TABLE `bot_games`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `game_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '游戏名称',
  `updated_at` datetime(0) NULL DEFAULT NULL,
  `created_at` datetime(0) NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `game_name`(`game_name`) USING BTREE COMMENT '游戏名称唯一'
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for bot_user_game
-- ----------------------------
DROP TABLE IF EXISTS `bot_user_game`;
CREATE TABLE `bot_user_game`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `game_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '游戏名称',
  `game_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '游戏ID',
  `member_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户ID',
  `updated_at` datetime(0) NULL DEFAULT NULL,
  `created_at` datetime(0) NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;


-- ----------------------------
-- Table structure for bot_gameplay_rules
-- ----------------------------
DROP TABLE IF EXISTS `bot_gameplay_rules`;
CREATE TABLE `bot_gameplay_rules` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `maxinum` bigint(20) DEFAULT '0' COMMENT '最高',
  `mininum` bigint(20) DEFAULT '0' COMMENT '最低',
  `odds` decimal(10,2) DEFAULT '1.00' COMMENT '赔率',
  `groups` varchar(50) DEFAULT NULL COMMENT '规则分组',
  `keywords` varchar(50) DEFAULT NULL COMMENT '玩法关键字',
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='玩法规则';

-- ----------------------------
-- Table structure for bot_bets
-- ----------------------------
DROP TABLE IF EXISTS `bot_bets`;
CREATE TABLE `bot_bets` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `issue_id` int(11) DEFAULT NULL COMMENT '投注ID',
  `issue_no` varchar(50) DEFAULT NULL COMMENT '投注期号',
  `member_id` varchar(40) DEFAULT NULL COMMENT '飞机ID',
  `user_id` int(11) DEFAULT NULL COMMENT '用户ID',
  `keywords` varchar(50) DEFAULT NULL COMMENT '玩法',
  `amount` decimal(20,2) DEFAULT '0.00' COMMENT '下分',
  `odds` decimal(10,2) DEFAULT '1.00' COMMENT '倍率',
  `status` tinyint(2) DEFAULT '1' COMMENT '状态:1-待结算,2-已结算',
  `profit` decimal(20,2) DEFAULT '0.00' COMMENT '利润',
  `created_at` datetime DEFAULT NULL COMMENT '创建时间',
  `updated_at` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Table structure for bot_issues
-- ----------------------------
DROP TABLE IF EXISTS `bot_issues`;
CREATE TABLE `bot_issues` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `issue_no` varchar(50) DEFAULT NULL COMMENT '期号',
  `start_time` datetime DEFAULT NULL COMMENT '开始时间',
  `end_time` datetime DEFAULT NULL COMMENT '截止时间',
  `winning_numbers` varchar(100) DEFAULT NULL COMMENT '中奖号码 按顺序 1,8,6',
  `status` tinyint(2) DEFAULT '1' COMMENT '状态：0-待发布,1-投注中,2-封盘,3-开奖',
  `created_at` datetime DEFAULT NULL COMMENT '创建时间',
  `updated_at` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;

ALTER TABLE `bot_issues`
ADD COLUMN `combo`  varchar(20) NULL AFTER `updated_at`,
ADD COLUMN `extreme`  varchar(20) NULL COMMENT '极值' AFTER `combo`;

SET FOREIGN_KEY_CHECKS = 1;

