
CREATE DATABASE /*!32312 IF NOT EXISTS*/`${sqlDataBaseName}` /*!40100 DEFAULT CHARACTER SET utf8mb4 */;

USE `${sqlDataBaseName}`;

DROP TABLE IF EXISTS `${sqlTablePrefix}user`;

CREATE TABLE `${sqlTablePrefix}user` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `system` varchar(32) DEFAULT NULL COMMENT '系统',
  `nick_name` varchar(128) DEFAULT NULL COMMENT '昵称',
  `portrait` varchar(512) DEFAULT NULL COMMENT '头像',
  `phone` varchar(64) DEFAULT NULL COMMENT '手机号',
  `email` varchar(64) DEFAULT NULL COMMENT '邮箱',
  `pwd` varchar(32) DEFAULT NULL COMMENT '密码',
  `wx_id` bigint(20) DEFAULT NULL COMMENT '微信索引',
  `qq_id` bigint(20) DEFAULT NULL COMMENT 'QQ索引',
  `status` int(11) DEFAULT '0' COMMENT '状态',
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `UX_SYSTEM_PHONE` (`system`,`phone`),
  UNIQUE KEY `UX_SYSTEM_EMAIL` (`system`,`email`),
  KEY `INX_EMAIL` (`email`),
  KEY `INX_PHONE` (`phone`)
) ENGINE=InnoDB AUTO_INCREMENT=22380 DEFAULT CHARSET=utf8mb4 COMMENT='用户信息';

DROP TABLE IF EXISTS `${sqlTablePrefix}user_qq`;

CREATE TABLE `${sqlTablePrefix}user_qq` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `system` varchar(32) DEFAULT NULL,
  `nick_name` varchar(64) DEFAULT NULL COMMENT '昵称',
  `portrait` varchar(512) DEFAULT NULL COMMENT '头像',
  `open_id` varchar(64) DEFAULT NULL COMMENT 'openid',
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `UX_SYSTEM_OPEN_ID` (`system`,`open_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='QQ授权信息';


DROP TABLE IF EXISTS `${sqlTablePrefix}user_vip_info`;

CREATE TABLE `${sqlTablePrefix}user_vip_info` (
  `uid` bigint(20) NOT NULL,
  `expire_date` datetime DEFAULT NULL,
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  PRIMARY KEY (`uid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

DROP TABLE IF EXISTS `${sqlTablePrefix}user_wx`;

CREATE TABLE `${sqlTablePrefix}user_wx` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `system` varchar(32) DEFAULT NULL,
  `nick_name` varchar(64) DEFAULT NULL COMMENT '昵称',
  `sex` int(11) DEFAULT NULL COMMENT '性别',
  `province` varchar(64) DEFAULT NULL COMMENT '省',
  `city` varchar(64) DEFAULT NULL COMMENT '市',
  `country` varchar(64) DEFAULT NULL COMMENT '国家',
  `head_img_url` varchar(512) DEFAULT NULL COMMENT '头像',
  `open_id` varchar(64) DEFAULT NULL COMMENT 'openid',
  `union_id` varchar(64) DEFAULT NULL COMMENT 'unionid',
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `UX_SYSTEM_UNION_ID` (`system`,`union_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='微信授权信息';


DROP TABLE IF EXISTS `${sqlTablePrefix}vip_order_record`;

CREATE TABLE `${sqlTablePrefix}vip_order_record` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `order_type` varchar(64) DEFAULT NULL,
  `uid` bigint(20) DEFAULT NULL,
  `state` int(11) DEFAULT NULL,
  `money_pay` tinyint(4) DEFAULT NULL,
  `gold_corn_pay` tinyint(4) DEFAULT NULL,
  `gold_corn` int(11) DEFAULT NULL,
  `type` varchar(64) DEFAULT NULL,
  `money` decimal(8,2) DEFAULT NULL,
  `pay_way` int(11) DEFAULT NULL,
  `pay_money` decimal(8,2) DEFAULT NULL,
  `ip_info` varchar(64) DEFAULT NULL,
  `pay_time` datetime DEFAULT NULL,
  `vip_start_time` datetime DEFAULT NULL,
  `vip_end_time` datetime DEFAULT NULL,
  `remarks` varchar(256) DEFAULT NULL,
  `apple_transaction_id` varchar(64) DEFAULT NULL,
  `apple_original_transaction_id` varchar(64) DEFAULT NULL,
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=200010 DEFAULT CHARSET=utf8mb4;


