/*
 Navicat Premium Data Transfer

 Source Server         : 测试
 Source Server Type    : MariaDB
 Source Server Version : 100318
 Source Host           : test.tall.wiki:3306
 Source Schema         : game

 Target Server Type    : MariaDB
 Target Server Version : 100318
 File Encoding         : 65001

 Date: 13/05/2021 15:10:59
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for t_game_activity_prize
-- ----------------------------
DROP TABLE IF EXISTS `t_game_activity_prize`;
CREATE TABLE `t_game_activity_prize`  (
  `id` bigint(20) NOT NULL,
  `game_id` bigint(20) NULL DEFAULT 0 COMMENT '游戏类型id',
  `sequence` int(11) NULL DEFAULT 0 COMMENT '顺序',
  `description` varchar(225) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '奖品详情',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp,
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp ON UPDATE CURRENT_TIMESTAMP,
  `rec_status` tinyint(1) UNSIGNED NULL DEFAULT 0,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `game_index`(`game_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '活动奖品表' ROW_FORMAT = Compact;

-- ----------------------------
-- Table structure for t_game_activity_rule
-- ----------------------------
DROP TABLE IF EXISTS `t_game_activity_rule`;
CREATE TABLE `t_game_activity_rule`  (
  `id` bigint(20) NOT NULL,
  `game_id` bigint(20) NULL DEFAULT 0 COMMENT '游戏类型id',
  `sequence` int(11) NULL DEFAULT 0 COMMENT '规则顺序',
  `description` varchar(225) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '活动规则',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp,
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp ON UPDATE CURRENT_TIMESTAMP,
  `rec_status` tinyint(1) UNSIGNED NULL DEFAULT 0,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `game_index`(`game_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '活动规则表' ROW_FORMAT = Compact;

-- ----------------------------
-- Table structure for t_game_group
-- ----------------------------
DROP TABLE IF EXISTS `t_game_group`;
CREATE TABLE `t_game_group`  (
  `id` bigint(20) NOT NULL,
  `record_id` bigint(20) NULL DEFAULT 0 COMMENT '购买记录id',
  `code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '队伍code',
  `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '队伍名',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp,
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp ON UPDATE CURRENT_TIMESTAMP,
  `rec_status` tinyint(1) UNSIGNED NULL DEFAULT 0,
  `head_portrait_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '头像',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `record_index`(`record_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '游戏分组信息表' ROW_FORMAT = Compact;

-- ----------------------------
-- Table structure for t_game_prize_instructions
-- ----------------------------
DROP TABLE IF EXISTS `t_game_prize_instructions`;
CREATE TABLE `t_game_prize_instructions`  (
  `id` bigint(20) NOT NULL,
  `game_id` bigint(20) NULL DEFAULT 0 COMMENT '游戏类型id',
  `sequence` int(11) NULL DEFAULT 0 COMMENT '顺序',
  `description` varchar(225) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '奖券使用说明',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp,
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp ON UPDATE CURRENT_TIMESTAMP,
  `rec_status` tinyint(1) UNSIGNED NULL DEFAULT 0,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `game_index`(`game_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '奖券使用说明表' ROW_FORMAT = Compact;

-- ----------------------------
-- Table structure for t_game_record
-- ----------------------------
DROP TABLE IF EXISTS `t_game_record`;
CREATE TABLE `t_game_record`  (
  `id` bigint(20) NOT NULL,
  `user_pay_id` bigint(20) NULL DEFAULT 0 COMMENT '创建的游戏id',
  `task_id` bigint(20) NULL DEFAULT 0 COMMENT '关联的任务id',
  `url` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '大屏路径',
  `QR_code_url` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '二维码路径',
  `time_difference` int(11) NULL DEFAULT 0 COMMENT '大屏与服务器的时间差',
  `start_time` bigint(20) NULL DEFAULT 0 COMMENT '游戏实际开始时间',
  `end_time` bigint(20) NULL DEFAULT 0 COMMENT '游戏实际结束时间',
  `game_status` tinyint(2) UNSIGNED NULL DEFAULT 0 COMMENT '游戏状态 0未开始 1准备中 2进行中 3已结束',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp,
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp ON UPDATE CURRENT_TIMESTAMP,
  `rec_status` tinyint(1) UNSIGNED NULL DEFAULT 0,
  `game_group` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '游戏分组状态 0不分组 1分组',
  `duration` int(11) UNSIGNED NULL DEFAULT 1 COMMENT '游戏时长 单位：分钟',
  `member_limit` int(11) UNSIGNED NULL DEFAULT 500 COMMENT '人数限制，团队游戏里每个团队的限制',
  `rank_rule` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '排名规则 0总分 1平均分',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `type_member_index`(`user_pay_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '创建的游戏记录表' ROW_FORMAT = Compact;

-- ----------------------------
-- Table structure for t_game_score_log
-- ----------------------------
DROP TABLE IF EXISTS `t_game_score_log`;
CREATE TABLE `t_game_score_log`  (
  `id` bigint(20) NOT NULL,
  `user_id` bigint(20) NULL DEFAULT 0 COMMENT '参与者的id',
  `record_id` bigint(20) NULL DEFAULT 0 COMMENT '游戏记录id',
  `operation_type` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '操作类型 0数钱 ',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp,
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp ON UPDATE CURRENT_TIMESTAMP,
  `rec_status` tinyint(1) UNSIGNED NULL DEFAULT 0,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `member_index`(`user_id`) USING BTREE,
  INDEX `record_index`(`record_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户参与游戏信息表' ROW_FORMAT = Compact;

-- ----------------------------
-- Table structure for t_game_type
-- ----------------------------
DROP TABLE IF EXISTS `t_game_type`;
CREATE TABLE `t_game_type`  (
  `id` bigint(20) NOT NULL,
  `code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '编号',
  `name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '游戏名',
  `description` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '详情',
  `pay_type` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '付费类型 0免费 1付费 暂时默认免费',
  `screen_url` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '大屏前端路径',
  `client_url` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '客户端前端路径',
  `is_group` tinyint(1) NULL DEFAULT 0 COMMENT '是否是分组游戏 0不分组 1分组',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp,
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp ON UPDATE CURRENT_TIMESTAMP,
  `rec_status` tinyint(1) UNSIGNED NULL DEFAULT 0,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '游戏信息表' ROW_FORMAT = Compact;

-- ----------------------------
-- Table structure for t_game_user_join
-- ----------------------------
DROP TABLE IF EXISTS `t_game_user_join`;
CREATE TABLE `t_game_user_join`  (
  `id` bigint(20) NOT NULL,
  `user_id` bigint(20) NULL DEFAULT 0 COMMENT '参与者的id',
  `nickname` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '用户昵称',
  `avatar_url` varchar(225) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '头像',
  `phone` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '手机号',
  `record_id` bigint(20) NULL DEFAULT 0 COMMENT '游戏记录id',
  `times` int(11) NULL DEFAULT 0 COMMENT '滑动次数',
  `score` int(11) NULL DEFAULT 0 COMMENT '分数',
  `time_difference` int(11) NULL DEFAULT 0 COMMENT '客户端与服务器的时间差',
  `local_start_time` bigint(20) NULL DEFAULT 0 COMMENT '客户端本地开始时间',
  `local_end_time` bigint(20) NULL DEFAULT 0 COMMENT '客户端本地结束时间',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp,
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp ON UPDATE CURRENT_TIMESTAMP,
  `rec_status` tinyint(1) UNSIGNED NULL DEFAULT 0,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `user_index`(`user_id`) USING BTREE,
  INDEX `record_index`(`record_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户参与游戏信息表' ROW_FORMAT = Compact;

-- ----------------------------
-- Table structure for t_game_user_join_group
-- ----------------------------
DROP TABLE IF EXISTS `t_game_user_join_group`;
CREATE TABLE `t_game_user_join_group`  (
  `id` bigint(20) NOT NULL,
  `user_join_id` bigint(20) NULL DEFAULT 0 COMMENT '参加游戏的用户的id',
  `game_group_id` bigint(20) NULL DEFAULT 0 COMMENT '分组信息的id',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp,
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp ON UPDATE CURRENT_TIMESTAMP,
  `rec_status` tinyint(1) UNSIGNED NULL DEFAULT 0,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `user_join_index`(`user_join_id`) USING BTREE,
  INDEX `game_group_index`(`game_group_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户分组表' ROW_FORMAT = Compact;

-- ----------------------------
-- Table structure for t_game_user_pay
-- ----------------------------
DROP TABLE IF EXISTS `t_game_user_pay`;
CREATE TABLE `t_game_user_pay`  (
  `id` bigint(20) NOT NULL,
  `user_id` bigint(20) NULL DEFAULT 0 COMMENT '创建者的id',
  `game_type_id` bigint(20) NULL DEFAULT 0 COMMENT '游戏类型id',
  `total_count` int(11) NULL DEFAULT 0 COMMENT '游戏可用次数',
  `used_count` int(11) NULL DEFAULT 0 COMMENT '已经使用的次数',
  `created_time` bigint(20) NULL DEFAULT 0 COMMENT '创建时间',
  `due_time` bigint(20) NULL DEFAULT 0 COMMENT '过期时间',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp,
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp ON UPDATE CURRENT_TIMESTAMP,
  `rec_status` tinyint(1) UNSIGNED NULL DEFAULT 0,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `member_index`(`user_id`) USING BTREE,
  INDEX `game_type_index`(`game_type_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '创建的游戏记录表' ROW_FORMAT = Compact;

SET FOREIGN_KEY_CHECKS = 1;
