/*==============================================================*/
/* Database name:  sg_gamedb                                    */
/* DBMS name:      MySQL 5.5.17                                 */
/* Created on:     2014-10-16 10:00:00                          */
/*==============================================================*/

create database if not exists % database % CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

use % database %;

-- ----------------------------
-- Table structure for db_version 版本号，每次更新数据库要改这个地方
-- ----------------------------
CREATE TABLE IF NOT EXISTS `db_version` (
    `version_2018_02_06_13` int unsigned NOT NULL COMMENT 'version'
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT = '数据库版本号';

/*==============================================================*/
/* Table: t_account    账号表                                   */
/*==============================================================*/
CREATE TABLE IF NOT EXISTS t_account (
    `user_name` varchar(50) NOT NULL,
    `user_password` varchar(128) NOT NULL,
    `login_time` int unsigned DEFAULT '0' COMMENT '上次登录时间',
    `logout_time` int unsigned DEFAULT '0' COMMENT '上次下线时间',
    `ip_address` char(24) DEFAULT '' COMMENT '上次登录的ip地址',
    `gm_level` int DEFAULT '0' COMMENT 'gm等级',
    `platform` varchar(50) DEFAULT '' COMMENT '平台',
    `is_online` int unsigned DEFAULT '0' COMMENT '角色是否在线',
    `channel` varchar(50) DEFAULT '' COMMENT '渠道号',
    `device_id` varchar(256) DEFAULT '' COMMENT '是否为刷榜账号',
    `auto_id` bigint NOT NULL auto_increment COMMENT '自增id',
    PRIMARY KEY (`auto_id`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE utf8mb4_general_ci COMMENT = '账号密码对照表';

/*==============================================================*/
/* Table: t_gameserver    GameServer表                          */
/*==============================================================*/
CREATE TABLE IF NOT EXISTS t_gameserver (
    `id` int unsigned COMMENT '服务器id',
    `start_time` int unsigned COMMENT '开服时间',
    `close_time` int unsigned COMMENT '关服时间',
    `is_close` int unsigned COMMENT '是否关服',
    primary key (`id`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE utf8mb4_general_ci COMMENT = '服务器设置';

-- ----------------------------
-- Table structure for t_player_baseinfo
-- ----------------------------
CREATE TABLE IF NOT EXISTS `t_player_baseinfo` (
    `dwUin` bigint unsigned NOT NULL COMMENT '对应玩家account表中的dwUin',
    `energy` int unsigned NOT NULL DEFAULT '0' COMMENT '能量',
    `star` int unsigned NOT NULL DEFAULT '0' COMMENT '星星',
    `recover_time` int unsigned NOT NULL DEFAULT '0' COMMENT '能量开始恢复时间',
    `diamond` int unsigned NOT NULL DEFAULT '1' COMMENT '钻石',
    `level` int unsigned NOT NULL DEFAULT '0' COMMENT '玩家等级',
    `exp` int unsigned zerofill NOT NULL DEFAULT '0' COMMENT '玩家经验',
    `start_order_id` varchar(50) DEFAULT NULL COMMENT '配置订单进度',
    `music_code` int unsigned NOT NULL DEFAULT '0' COMMENT '音效状态码改为GUID免费改名状态',
    `guild` int unsigned NOT NULL DEFAULT '0' COMMENT '引导进度 ',
    `pack_unlock_count` int unsigned NOT NULL DEFAULT '0' COMMENT '背包解锁数量',
    `last_play_time` int NOT NULL DEFAULT '0' COMMENT '广告能量购买时间',
    `EnergyBuyCount` int NOT NULL DEFAULT '0' COMMENT '能量购买次数',
    `user_name` varchar(50) NOT NULL DEFAULT '' COMMENT '玩家账号',
    `nick_name` varchar(50) NOT NULL DEFAULT '' COMMENT '玩家昵称',
    `login_time` int unsigned NOT NULL DEFAULT '0' COMMENT '上次登录时间',
    `logout_time` int unsigned NOT NULL DEFAULT '0' COMMENT '上次下线时间',
    `todayolinetime` int unsigned NOT NULL DEFAULT '0' COMMENT '当天的累计在线时间',
    `rolecreatetime` int unsigned NOT NULL DEFAULT '0' COMMENT '注册帐号时间',
    `EmitOrderCnt` int unsigned NOT NULL DEFAULT '0' COMMENT '注册帐号时间',
    `DailyRenewTime` int unsigned NOT NULL DEFAULT '0' COMMENT '注册帐号时间',
    `NoAd` int unsigned NOT NULL DEFAULT '0' COMMENT '注册帐号时间',
    `ChampshipsGroupID` int unsigned NOT NULL DEFAULT '0' COMMENT '注册帐号时间',
    `LastChampGroupID` int unsigned NOT NULL DEFAULT '0' COMMENT '注册帐号时间',
    `FaceBookId` varchar(128) DEFAULT '' COMMENT '玩家账号',
    PRIMARY KEY (`dwUin`),
    KEY `nick_name` (`nick_name`),
    KEY `user_name` (`user_name`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT = '存储玩家基本信息';

/*==============================================================*/
/* Table: t_player_data    玩家模块表                          */
/*==============================================================*/
CREATE TABLE IF NOT EXISTS t_player_mod (
    `dwUin` bigint unsigned COMMENT '玩家uid',
    `mData` blob DEFAULT NULL COMMENT '数据',
    `updateTime` int unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
    primary key (`dwUin`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE utf8mb4_general_ci COMMENT = '玩家模块表';

/*==============================================================*/
/* Table: t_player_data    玩家订单表                          */
/*==============================================================*/
CREATE TABLE IF NOT EXISTS t_player_charge (
    `id` bigint unsigned AUTO_INCREMENT COMMENT '订单id',
    `Uid` bigint unsigned NOT NULL COMMENT '玩家id',
    `OrderId` varchar(128) DEFAULT '' COMMENT '订单号',
    `ProductId` int unsigned NOT NULL DEFAULT '0' COMMENT '商品id',
    `ProductName` varchar(128) DEFAULT '' COMMENT '商品名称',
    `ProductDesc` varchar(128) DEFAULT '' COMMENT '商品描述',
    `Price` float NOT NULL DEFAULT '0' COMMENT '价格',
    `Currency` varchar(128) DEFAULT '' COMMENT '货币',
    `CreateTime` int unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
    `PayTime` int unsigned NOT NULL DEFAULT '0' COMMENT '支付时间',
    `PayStatus` int unsigned NOT NULL DEFAULT '0' COMMENT '支付状态 0 未支付 1 已支付 2 支付失败 3 已发货',
    `PayType` int unsigned NOT NULL DEFAULT '0' COMMENT '支付类型',
    `PayPlatform` varchar(128) DEFAULT '' COMMENT '支付平台',
    `PayChannel` varchar(128) DEFAULT '' COMMENT '支付渠道',
    `PayChannelOrderId` varchar(512) DEFAULT '' COMMENT '支付渠道订单号',
    `PayChannelUserId` varchar(128) DEFAULT '' COMMENT '支付渠道用户id',
    `PayChannelExtra` varchar(128) DEFAULT '' COMMENT '支付渠道额外信息',
    primary key (`id`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE utf8mb4_general_ci COMMENT = '玩家订单表';

-- ----------------------------
-- Table structure for system_mail_info
-- ----------------------------
CREATE TABLE IF NOT EXISTS `system_mail_info` (
    `mail_id` bigint NOT NULL AUTO_INCREMENT COMMENT '邮件ID',
    `title` varchar(128) DEFAULT "" COMMENT '邮件标题',
    `subTitle` varchar(128) DEFAULT "" COMMENT '邮件子标题',
    `content` varchar(2048) DEFAULT "" COMMENT '邮件内容',
    `title_en` varchar(128) DEFAULT "" COMMENT '英文邮件标题',
    `subTitlee_en` varchar(128) DEFAULT "" COMMENT '英文邮件子标题',
    `content_en` varchar(2048) DEFAULT "" COMMENT '英文邮件内容',
    `title_ptbr` varchar(128) DEFAULT "" COMMENT '葡萄牙邮件标题',
    `subTitle_ptbr` varchar(128) DEFAULT "" COMMENT '葡萄牙邮件子标题',
    `content_ptbr` varchar(2048) DEFAULT "" COMMENT '葡萄牙邮件内容',
    `items` varchar(2048) DEFAULT "{}" COMMENT '邮件附件',
    `start_time` int unsigned NOT NULL DEFAULT '0' COMMENT '开始时间',
    `register_time` int unsigned NOT NULL DEFAULT '0' COMMENT '注册时间',
    `end_time` int unsigned NOT NULL DEFAULT '0' COMMENT '结束时间',
    `mail_type` int unsigned NOT NULL DEFAULT '0' COMMENT '邮件类型',
    `send_type` int unsigned NOT NULL DEFAULT '0' COMMENT '发送类型',
    `to_uids` varchar(2048) DEFAULT "" COMMENT '发送者ID',
    `create_time` int unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
    PRIMARY KEY (`mail_id`)
) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COMMENT = '系统邮件';

/*==============================================================*/
/* Table: t_player_data    系统模块表                          */
/*==============================================================*/
CREATE TABLE IF NOT EXISTS t_server_mod (
    `id` int NOT NULL AUTO_INCREMENT primary key,
    `key` varchar(128) DEFAULT '' COMMENT '模块key',
    `mData` mediumblob DEFAULT NULL COMMENT '数据',
    `updateTime` int unsigned NOT NULL DEFAULT '0' COMMENT '更新时间'
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE utf8mb4_general_ci COMMENT = '系统模块表';