
-- 推广员后台首页快捷菜单 ZCL

DROP TABLE IF EXISTS `tab_quick_menu`;
CREATE TABLE `tab_quick_menu` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '文档ID',
  `name` varchar(50) NOT NULL DEFAULT '' COMMENT '菜单名称',
  `url` varchar(255) NOT NULL DEFAULT '' COMMENT '链接地址',
  `icon` varchar(50) DEFAULT '0' COMMENT '菜单ICON',
  `status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '状态',
  PRIMARY KEY (`id`),
  KEY `status` (`status`)
) ENGINE=MyISAM AUTO_INCREMENT=17 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of tab_quick_menu
-- ----------------------------
INSERT INTO `tab_quick_menu` VALUES ('1', '账户信息', '/index.php?s=/Home/Promote/base_info.html', '11', '0');
INSERT INTO `tab_quick_menu` VALUES ('2', '组长管理', '/index.php?s=/Home/Promote/mychlid.html', '12', '0');
INSERT INTO `tab_quick_menu` VALUES ('3', '推广员管理', '/index.php?s=/Home/Promote/mygrand.html', '0', '0');
INSERT INTO `tab_quick_menu` VALUES ('4', '数据汇总', '/index.php?s=/Home/Query/summary.html', '0', '0');
INSERT INTO `tab_quick_menu` VALUES ('5', '充值明细', '/index.php?s=/Home/Query/recharge.html', '0', '0');
INSERT INTO `tab_quick_menu` VALUES ('6', '注册明细', '/index.php?s=/Home/Query/register.html', '0', '0');
INSERT INTO `tab_quick_menu` VALUES ('7', 'ARPU统计', '/index.php?s=/Home/Query/arpu_analysis.html', '0', '0');
INSERT INTO `tab_quick_menu` VALUES ('8', '留存统计', '/index.php?s=/Home/Query/retention_analysis.html', '0', '0');
INSERT INTO `tab_quick_menu` VALUES ('9', '角色查询', '/index.php?s=/Home/Query/userPlayers.html', '0', '0');
INSERT INTO `tab_quick_menu` VALUES ('10', '专服管理', '/index.php?s=/Home/Apply/index.html', '0', '0');
INSERT INTO `tab_quick_menu` VALUES ('11', '扶持申请', '/index.php?s=/Home/Support/index.html', '0', '0');
INSERT INTO `tab_quick_menu` VALUES ('12', '扶持记录', '/index.php?s=/Home/Support/lists.html', '0', '0');
INSERT INTO `tab_quick_menu` VALUES ('13', '扶持额度', '/index.php?s=/Home/Support/quota.html', '0', '0');
INSERT INTO `tab_quick_menu` VALUES ('14', '我的平台币', '/index.php?s=/Home/PromoteCoin/myCoin.html', '0', '0');
INSERT INTO `tab_quick_menu` VALUES ('15', '平台币转移', '/index.php?s=/Home/PromoteCoin/record.html', '0', '0');
INSERT INTO `tab_quick_menu` VALUES ('16', '平台币充值', '/index.php?s=/Home/CoinOrder/order_list.html', '0', '0');

-- 推广员后台首页快捷菜单关联表 ZCL

DROP TABLE IF EXISTS `tab_promote_quick_menu`;
CREATE TABLE `tab_promote_quick_menu` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `promote_id` int(11) DEFAULT NULL COMMENT '推广员ID',
  `quick_menu_id` int(11) DEFAULT NULL COMMENT '快捷菜单ID',
  `create_time` int(11) DEFAULT NULL COMMENT '创建时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=latin1;

-- ----------------------------
-- Records of tab_promote_quick_menu
-- ----------------------------
INSERT INTO `tab_promote_quick_menu` VALUES ('4', '1', '3', '1569719823');
INSERT INTO `tab_promote_quick_menu` VALUES ('6', '1', '5', '1569719828');
INSERT INTO `tab_promote_quick_menu` VALUES ('7', '1', '6', '1569719830');
INSERT INTO `tab_promote_quick_menu` VALUES ('8', '1', '7', '1569719832');
INSERT INTO `tab_promote_quick_menu` VALUES ('9', '1', '14', '1569719835');
INSERT INTO `tab_promote_quick_menu` VALUES ('10', '1', '15', '1569719839');
INSERT INTO `tab_promote_quick_menu` VALUES ('11', '1', '12', '1569719849');
INSERT INTO `tab_promote_quick_menu` VALUES ('12', '1', '13', '1569719852');
INSERT INTO `tab_promote_quick_menu` VALUES ('14', '1', '8', '1569719866');
INSERT INTO `tab_promote_quick_menu` VALUES ('15', '1', '9', '1569719870');
INSERT INTO `tab_promote_quick_menu` VALUES ('16', '1', '10', '1569719877');
INSERT INTO `tab_promote_quick_menu` VALUES ('18', '1', '1', '1569720739');

-- 2019-10-01 by elf 
alter table tab_game_source add column `original_url` varchar(255) NOT NULL default '' COMMENT '原包路径';
alter table tab_game_source add column `org_plist_url` varchar(255) NOT NULL default '' COMMENT '原包Plist路径';

-- ----------------------------
-- 2019-10-08 cxj
-- ----------------------------
ALTER TABLE `tab_game` ADD COLUMN `server_type`  tinyint(2) NOT NULL DEFAULT 1 COMMENT '1-专服 2-混服' AFTER `support_ratio`;
ALTER TABLE `tab_game` ADD COLUMN `detail_content` MEDIUMTEXT NULL DEFAULT NULL COMMENT '游戏资料介绍' AFTER `features`;

-- ----------------------------
-- 2019-10-10 cxj
-- ----------------------------
ALTER TABLE `tab_promote` ADD COLUMN `child_game_permission`  tinyint(2) NOT NULL DEFAULT 0 COMMENT '下级游戏添加权限 0-本账号已添加游戏 1-所有游戏' AFTER `idcard`;

-- 2019-10-11 cxj
ALTER TABLE `tab_apply` ADD COLUMN `bale_sort`  int(5) NOT NULL DEFAULT 0 COMMENT '打包顺序' AFTER `offline_status`;

-- ----------------------------
-- 2019-10-11 zyx
-- ----------------------------
ALTER TABLE `tab_user` ADD COLUMN `last_device_number`  varchar(50) DEFAULT '' COMMENT '上一次登录设备号' AFTER `device_tab_protect_log_readnumber`;
ALTER TABLE `tab_user` ADD COLUMN `last_login_ip`  varchar(16) DEFAULT '' COMMENT '上一次登录id' AFTER `login_ip`;

CREATE TABLE `tab_protect_log` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `game_id` int(11) NOT NULL DEFAULT '0' COMMENT '游戏id',
  `game_name` varchar(30) NOT NULL DEFAULT '' COMMENT '游戏名称',
  `server_id` int(11) NOT NULL DEFAULT '0' COMMENT '服务器id',
  `server_name` varchar(30) NOT NULL DEFAULT '' COMMENT '游戏服务区',
  `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '用户id',
  `user_account` varchar(30) NOT NULL DEFAULT '' COMMENT '测试账号',
  `nickname` varchar(30) NOT NULL DEFAULT '' COMMENT '角色名称',
  `promote_id` int(11) NOT NULL DEFAULT '0' COMMENT '推广员id',
  `promote_account` varchar(30) NOT NULL DEFAULT '' COMMENT '推广员',
  `type` tinyint(2) DEFAULT '1' COMMENT '异常类型',
  `detail` varchar(200) DEFAULT '' COMMENT '异常内容',
  `create_time` int(11) DEFAULT '0' COMMENT '创建时间',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;

-----------------
--测试资源申请表--
-----------------
CREATE TABLE `tab_test_resource` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键自增',
  `user_id` int(11) DEFAULT '0' COMMENT '对应角色的id',
  `user_account` varchar(50) DEFAULT NULL COMMENT '用户帐号',
  `user_password` varchar(248) DEFAULT NULL COMMENT '用户密码',
  `phone` varchar(15) DEFAULT '' COMMENT '手机号码',
  `role_name` varchar(50) DEFAULT NULL COMMENT '角色名',
  `game_id` int(11) NOT NULL COMMENT '游戏id',
  `game_name` varchar(30) NOT NULL COMMENT '游戏名称',
  `server_name` varchar(30) NOT NULL COMMENT '区服名称',
  `server_id` int(11) DEFAULT NULL COMMENT '对接区服id',
  `promote_id` int(11) DEFAULT '0' COMMENT '所属推广员id',
  `promote_account` varchar(30) DEFAULT '' COMMENT '所属推广员账号',
  `apply_name` varchar(30) DEFAULT '' COMMENT '申请人名称',
  `apply_id` int(11) DEFAULT '0' COMMENT '申请人id',
  `apply_remark` varchar(200) DEFAULT '' COMMENT '申请备注',
  `apply_resource` int(11) DEFAULT '0' COMMENT '申请资源数量',
  `apply_status` tinyint(2) DEFAULT '0' COMMENT '审核状态 0未审核 1未通过 2通过/发放',
  `apply_type` int(2) DEFAULT '0' COMMENT '扶持类型 0：新增 1：后续',
  `verify_resource` int(11) DEFAULT '0' COMMENT '实际发放',
  `verify_remark` varchar(200) DEFAULT '' COMMENT '审核意见',
  `create_time` int(11) DEFAULT '0' COMMENT '申请时间',
  `verify_time` int(11) DEFAULT '0' COMMENT '审核时间',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `user_id` (`user_id`) USING BTREE,
  KEY `game_id` (`game_id`) USING BTREE,
  KEY `promote_id` (`promote_id`) USING BTREE,
  KEY `create_time` (`create_time`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='测试资源申请';

-- 2019-10-09 by elf
alter table tab_user_play_info add column `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '角色创建时间';
alter table tab_user_play_info add column `create_ip` varchar(16) NOT NULL DEFAULT '' COMMENT '角色创建IP';
alter table tab_user_play_info add column `create_device_number` varchar(50) NOT NULL DEFAULT '' COMMENT '角色创建设备号';
alter table tab_server add column `server_id` varchar(50) not NULL default '' COMMENT '对接区服id';

-- ----------------------------
-- 2019-10-11 zyx
-- ----------------------------
CREATE TABLE `sys_document_read` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `document_id` int(11) NOT NULL DEFAULT '0' COMMENT '文档模型基础表id',
  `category_id` int(10) NOT NULL DEFAULT '0' COMMENT '所属分类',
  `promote_id` int(11) NOT NULL DEFAULT '0' COMMENT '推广员id',
  `create_time` int(11) DEFAULT '0' COMMENT '创建时间',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=9 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;

CREATE TABLE `tab_protect_log_read` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `log_id` int(11) NOT NULL DEFAULT '0' COMMENT '日志id',
  `promote_id` int(11) NOT NULL DEFAULT '0' COMMENT '推广员id',
  `create_time` int(11) DEFAULT '0' COMMENT '创建时间',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=25 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;

-- 增加用户Token 验证用户
ALTER TABLE `tab_user`
ADD COLUMN `user_token`  char(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '用户token 登入时下发' AFTER `token`;

-- ----------------------------
-- 2019-10-17 zyx
-- ----------------------------
alter table `tab_giftbag` modify COLUMN `giftbag_version` tinyint(2) COMMENT '运营平台 0双平台 1and 2ios 3超级签'

-- 2019-10-22 cxj
UPDATE `sys_model` SET list_grid = "id:编号\r\nsort:排序\r\ngame_name:游戏名称\r\ngame_type_name:游戏类型\r\ngame_type_id:游戏类型\r\ngame_appid:游戏appid\r\ngame_status|get_info_status:显示状态\r\npay_status|get_info_status:支付状态\r\nicon:图片id\r\napply_status:审核状态\r\ncategory:开放类型\r\nrecommend_status|get_info_status*1:推荐状态\r\nrelation_game_id:关联游戏id\r\nrelation_game_name:关联游戏名称\r\nsdk_version:运营平台\r\ndevelopers:开发商\r\ndow_num:下载\r\nonline_status:上线状态\r\ncreate_time:创建时间\r\nserver_type:混服管理\r\npartner_id:合作方\r\nid:操作:[EDIT]&id=[id]|编辑,Game/del?ids=[id]|删除" where id = 15;

-- 2019-10-23 zcl
ALTER TABLE `tab_coin_pay_order` CHANGE COLUMN `currency_num` `coin_num`  int(11) NULL DEFAULT 0 COMMENT '代币数量' AFTER `auditor_time`;

-- 2019-10-23 zcl
update tab_quick_menu set name='订单查询' where name='充值明细'

-- 2019-10-28 cxj
CREATE TABLE `tab_partner` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `partner` varchar(30) NOT NULL COMMENT '合作方名称',
  `uid` int(11) NOT NULL DEFAULT '0' COMMENT '添加人ID',
  `status` tinyint(3) NOT NULL DEFAULT '1' COMMENT '状态 0-禁用 1-启用',
  `create_time` int(10) NOT NULL DEFAULT '0' COMMENT '添加时间',
  `last_up_time` int(10) NOT NULL DEFAULT '0' COMMENT '最后更新时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `tab_game` ADD COLUMN `partner_id` int(11) NOT NULL DEFAULT 0 COMMENT '合作方ID' AFTER `supersign_url`;
ALTER TABLE `tab_partner` MODIFY COLUMN `partner` varchar(60) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '合作方名称' AFTER `id`;

-- 2019-10-28 chenzhi
CREATE TABLE `tab_spend_count` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增主键',
  `promote_id` int(11) NOT NULL DEFAULT '0' COMMENT '推广员id',
  `promote_account` varchar(30) DEFAULT '' COMMENT '推广员账号',
  `parent_id` int(11) DEFAULT '0' COMMENT '父类ID',
  `parent_name` varchar(30) DEFAULT NULL COMMENT '父类名称',
  `root_id` int(11) DEFAULT 0 COMMENT '根ID',
  `root_name` varchar(30) DEFAULT NULL COMMENT '根名称',
  `game_id` int(11) NOT NULL DEFAULT '0' COMMENT '游戏id',
  `game_name` varchar(30) DEFAULT '' COMMENT '游戏名称',
  `partner_id` int(11) DEFAULT '0' COMMENT '合作方id',
  `partner_name` varchar(50) DEFAULT NULL COMMENT '合作方名称',
  `cash_count` decimal(10,2) DEFAULT '0.00' COMMENT '现金流水',
  `balance_coin_count` decimal(10,2) DEFAULT '0.00' COMMENT '平台币流水',
  `inside_cash_count` decimal(10,2) DEFAULT '0.00' COMMENT '内充流水/绑定币流水',
  `count_date` varchar(30) DEFAULT '' COMMENT '统计月份',
  `create_time` int(11) DEFAULT NULL COMMENT '添加时间',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `game_id` (`game_id`) USING BTREE,
  KEY `promote_id` (`promote_id`) USING BTREE,
  KEY `partner_id` (`partner_id`) USING BTREE,
  KEY `count_date` (`count_date`) USING BTREE
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='游戏流水聚合表';

CREATE TABLE `tab_spend_user_count` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增主键',
  `promote_id` int(11) NOT NULL DEFAULT '0' COMMENT '推广员id',
  `promote_account` varchar(30) DEFAULT '' COMMENT '推广员账号',
  `parent_id` int(11) DEFAULT '0' COMMENT '父类ID',
  `parent_name` varchar(30) DEFAULT NULL COMMENT '父类名称',
  `root_id` int(11) DEFAULT 0 COMMENT '根ID',
  `root_name` varchar(30) DEFAULT NULL COMMENT '根名称',
  `cash_count` decimal(10,2) DEFAULT '0.00' COMMENT '现金流水',
  `balance_coin_count` decimal(10,2) DEFAULT '0.00' COMMENT '平台币流水',
  `inside_cash_count` decimal(10,2) DEFAULT '0.00' COMMENT '内充流水',
  `all_count` decimal(10,2) DEFAULT '0.00' COMMENT '流水和',
  `count_date` varchar(30) DEFAULT '' COMMENT '统计月份',
  `create_time` int(11) DEFAULT NULL COMMENT '添加时间',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `promote_id` (`promote_id`) USING BTREE,
  KEY `parent_id` (`parent_id`) USING BTREE,
  KEY `count_date` (`count_date`) USING BTREE
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='流水角色聚合表';

CREATE TABLE `tab_spend_month_count` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增主键',
  `cash_count` decimal(10,2) DEFAULT '0.00' COMMENT '现金流水',
  `balance_coin_count` decimal(10,2) DEFAULT '0.00' COMMENT '平台币流水',
  `inside_cash_count` decimal(10,2) DEFAULT '0.00' COMMENT '内充流水',
  `all_count` decimal(10,2) DEFAULT '0.00' COMMENT '流水和',
  `count_date` varchar(30) DEFAULT '' COMMENT '统计月份',
  `create_time` int(11) DEFAULT NULL COMMENT '添加时间',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `count_date` (`count_date`) USING BTREE
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='流水月份聚合表';
-----头像---
ALTER TABLE `sys_file`
MODIFY COLUMN `name`  char(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '原始文件名' AFTER `id`;

--downloadlog下载日志数据表
DROP TABLE IF EXISTS `tab_downloadlog`;
CREATE TABLE IF NOT EXISTS `tab_downloadlog` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `logid` varchar(254) NOT NULL DEFAULT '0' COMMENT '日志id',
  `admin_id` int(11) NOT NULL DEFAULT '0' COMMENT '推广者|管理员id',
  `type` varchar(254) NOT NULL DEFAULT '0' COMMENT '下载控制器地址',
  `dataname` varchar(254) NOT NULL DEFAULT '0' COMMENT '导出数据名称',
  `status` int(11) NOT NULL DEFAULT '0' COMMENT '下载状态 0未下载 1已下载',
  `addtime` int(11) NOT NULL DEFAULT '0' COMMENT '添加下载时间戳',
  `begintime` int(11) NOT NULL DEFAULT '0' COMMENT '开始下载时间戳',
  `content` mediumtext COMMENT '备注内容',
  `conditions` varchar(1024) DEFAULT '[]' COMMENT '下载筛选条件',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=220 DEFAULT CHARSET=utf8 COMMENT='下载管理日志';

ALTER TABLE `tab_promote`
	ADD COLUMN `ver_status` TINYINT(2) NULL DEFAULT NULL COMMENT '资质认证审核状态(1是审核成功，2审核失败，3未审核)' AFTER `child_game_permission`,
	ADD COLUMN `idcarpic` CHAR(253) NULL DEFAULT NULL COMMENT '身份证证件照' AFTER `ver_status`,
	ADD COLUMN `businesspic` CHAR(253) NULL DEFAULT NULL COMMENT '营业执照' AFTER `idcarpic`,
	ADD COLUMN `agreementpic` CHAR(253) NULL DEFAULT NULL COMMENT '合同' AFTER `businesspic`,
	ADD COLUMN `address` VARCHAR(520) NULL DEFAULT NULL COMMENT '住址' AFTER `agreementpic`,
	ADD COLUMN `account_type` INT(11) NULL DEFAULT NULL COMMENT '(1为公司，2为个人)' AFTER `address`;

-- 2019-11-06 chenzhi
DROP TABLE IF EXISTS `tab_spend_count`;
CREATE TABLE `tab_spend_count` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增主键',
  `promote_id` int(11) NOT NULL DEFAULT '0' COMMENT '推广员id',
  `promote_account` varchar(30) DEFAULT '' COMMENT '推广员账号',
  `chain` varchar(255) NOT NULL DEFAULT '' COMMENT '推广员链路',
  `level` tinyint(1) NOT NULL DEFAULT '0' COMMENT '推广员级别',
  `game_id` int(11) NOT NULL DEFAULT '0' COMMENT '游戏id',
  `game_name` varchar(30) DEFAULT '' COMMENT '游戏名称',
  `partner_id` int(11) DEFAULT '0' COMMENT '合作方id',
  `partner_name` varchar(50) DEFAULT NULL COMMENT '合作方名称',
  `cash_count` decimal(10,2) DEFAULT '0.00' COMMENT '现金流水',
  `balance_coin_count` decimal(10,2) DEFAULT '0.00' COMMENT '平台币流水',
  `inside_cash_count` decimal(10,2) DEFAULT '0.00' COMMENT '内充流水/绑定币流水',
  `count_date` varchar(30) DEFAULT '' COMMENT '统计月份',
  `create_time` int(11) DEFAULT NULL COMMENT '添加时间',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `game_id` (`game_id`) USING BTREE,
  KEY `promote_id` (`promote_id`) USING BTREE,
  KEY `partner_id` (`partner_id`) USING BTREE,
  KEY `chain` (`chain`) USING BTREE,
  KEY `level` (`level`) USING BTREE,
  KEY `count_date` (`count_date`) USING BTREE
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='游戏流水聚合表';

DROP TABLE IF EXISTS `tab_spend_month_count`;
CREATE TABLE `tab_spend_month_count` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增主键',
  `cash_count` decimal(10,2) DEFAULT '0.00' COMMENT '现金流水',
  `balance_coin_count` decimal(10,2) DEFAULT '0.00' COMMENT '平台币游戏支付流水',
  `balance_coin_deposit` decimal(10,2) DEFAULT '0.00' COMMENT '平台币充值流水',
  `bind_coin_count` decimal(10,2) DEFAULT '0.00' COMMENT '绑币消耗',
  `inside_cash_count` decimal(10,2) DEFAULT '0.00' COMMENT '内充流水',
  `all_count` decimal(10,2) DEFAULT '0.00' COMMENT '流水和',
  `count_date` varchar(30) DEFAULT '' COMMENT '统计月份',
  `create_time` int(11) DEFAULT NULL COMMENT '添加时间',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `count_date` (`count_date`) USING BTREE
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='流水月份聚合表';

DROP TABLE IF EXISTS `tab_spend_user_count`;
CREATE TABLE `tab_spend_user_count` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增主键',
  `promote_id` int(11) NOT NULL DEFAULT '0' COMMENT '推广员id',
  `promote_account` varchar(30) DEFAULT '' COMMENT '推广员账号',
  `chain` varchar(255) NOT NULL DEFAULT '' COMMENT '推广员链路',
  `level` tinyint(1) NOT NULL DEFAULT '0' COMMENT '推广员级别',
  `cash_count` decimal(10,2) DEFAULT '0.00' COMMENT '现金流水',
  `balance_coin_count` decimal(10,2) DEFAULT '0.00' COMMENT '平台币流水',
  `bind_coin_count` decimal(10,2) DEFAULT '0.00' COMMENT '绑定币消耗',
  `inside_cash_count` decimal(10,2) DEFAULT '0.00' COMMENT '内充流水',
  `all_count` decimal(10,2) DEFAULT '0.00' COMMENT '流水和',
  `count_date` varchar(30) DEFAULT '' COMMENT '统计月份',
  `create_time` int(11) DEFAULT NULL COMMENT '添加时间',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `promote_id` (`promote_id`) USING BTREE,
  KEY `chain` (`chain`) USING BTREE,
  KEY `level` (`level`) USING BTREE,
  KEY `count_date` (`count_date`) USING BTREE
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='流水角色聚合表';

-- 2019-11-6 cxj
ALTER TABLE `tab_spend` ADD COLUMN `withdraw_id` int(11) NOT NULL DEFAULT 0 COMMENT '提现ID' AFTER `pay_url`;
ALTER TABLE `tab_withdraw` ADD COLUMN `settlement_end_time` int(10) NOT NULL DEFAULT 0 COMMENT '结算截止时间' AFTER `old_promote_account`;

-- 2019-11-07 chenzhi
INSERT INTO `sys_menu` (`title`, `pid`, `sort`, `url`, `hide`, `tip`, `group`, `is_dev`, `status`) VALUES ('补链详情', '192', '0', 'Mend/shiftInfo', '0', '', '推广补链', '0', '1');
ALTER TABLE `tab_spend_user_count`
ADD COLUMN `bind_coin_count`  decimal(10,2) NULL DEFAULT 0.00 COMMENT '绑定币消耗' AFTER `balance_coin_count`;

-- 2019-11-6 ylw 设备禁用信息表
CREATE TABLE `tab_device_bans` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '风控表ID',
  `tag` varchar(255) NOT NULL COMMENT '风控标识',
  `type` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '类型 0未知 1设备号 2IP',
  `operator_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '操作者ID',
  `create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;

-- 2019-11-07   elf   推广员三级变四级
ALTER TABLE `tab_promote` ADD COLUMN `level` tinyint(1) NOT NULL DEFAULT 0 COMMENT '推广员级别' after parent_name;
ALTER TABLE `tab_promote` ADD COLUMN `chain` varchar(30) NOT NULL DEFAULT '' COMMENT '推广员链路' after level;

-- 2019-11-07   elf   迁移任务
ALTER TABLE `sys_shift_task` ADD COLUMN `shift_ids` varchar(255) NOT NULL DEFAULT '' COMMENT '迁移ID';
ALTER TABLE `sys_shift_task` ADD COLUMN `remark` varchar(255) NOT NULL DEFAULT '' COMMENT '备注';


-- 2019-11-07 cxj
ALTER TABLE `tab_withdraw` ADD COLUMN `transfer_proof` int(11) NOT NULL DEFAULT 0 COMMENT '汇款证明' AFTER `settlement_end_time`;

-- 2019-11-08 cxj
ALTER TABLE `sys_document_download` MODIFY COLUMN `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '文档ID' FIRST;
ALTER TABLE `tab_promote`
	CHANGE COLUMN `ver_status` `ver_status` TINYINT(2) NULL DEFAULT '3' COMMENT '资质认证审核状态(1是审核成功，2审核失败，3未审核)' AFTER `child_game_permission`;

-- 2019-11-11 elf
ALTER TABLE `tab_promote_coin_record` ADD COLUMN `promote_id` int(11) NOT NULL DEFAULT 0 COMMENT '推广员ID' AFTER `ref_id`;
ALTER TABLE `tab_promote_coin_record` ADD COLUMN `target_level` tinyint(1) NOT NULL DEFAULT 0 COMMENT '目标对象等级' AFTER `target_type`;
ALTER TABLE `tab_promote_coin_record` ADD COLUMN `game_id` int(11) NOT NULL DEFAULT 0 COMMENT '游戏ID' AFTER `target_level`;

CREATE TABLE `tab_promote_coin_transfer_log` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `sn` varchar(30) NOT NULL DEFAULT '' COMMENT '订单号',
  `promote_id` int(11) NOT NULL COMMENT '推广员ID',
  `target_id` int(11) NOT NULL COMMENT '目标对象ID',
  `target_type` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '类型 1 推广员 2 玩家',
  `target_level` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '目标对象等级',
  `num` int(11) NOT NULL DEFAULT '0' COMMENT '转账数量',
  `game_id` int(1) NOT NULL DEFAULT '0' COMMENT '游戏ID',
  `status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '0 未处理 1 成功',
  `remark` varchar(255) NOT NULL DEFAULT '' COMMENT '备注',
  `description` varchar(255) NOT NULL DEFAULT '' COMMENT '描述说明',
  `create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE `tab_downloadlog`
	CHANGE COLUMN `conditions` `conditions` VARCHAR(20480) NULL DEFAULT '[]' COMMENT '下载筛选条件' AFTER `content`;

-- 2019-11-17 zhengyongxing
UPDATE `platform_new`.`tab_quick_menu` SET `url` = '/index.php?s=/Home/PromoteCoin/transferLogs.html' WHERE `id` = 15
UPDATE `platform_new`.`tab_quick_menu` SET `url` = 'index.php?s=/Home/Promote/children/promote_type/1.html' WHERE `id` = 2
UPDATE `platform_new`.`tab_quick_menu` SET `url` = '/index.php?s=/Home/Promote/children/promote_type/2.html' WHERE `id` = 3

-- 增加tab_spend extend 字段长度到255
ALTER TABLE `tab_spend`
MODIFY COLUMN `extend`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '通知游戏方扩展(一般是游戏方透传)' AFTER `pay_game_status`;


ALTER TABLE `tab_spend`
ADD COLUMN `exists`  int(11) NOT NULL DEFAULT 0 COMMENT '0 不存在  1存在' AFTER `withdraw_id`,
ADD COLUMN `pay_url`  text CHARACTER SET utf8 COLLATE utf8_general_ci NULL AFTER `exists`;
ALTER TABLE `tab_deposit`
ADD COLUMN `pay_url`  text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '支付信息' AFTER `check_sign`;

--创建消息未读记录
CREATE TABLE `tab_notice_read` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `notice_id` int(11) NOT NULL COMMENT '广告id',
  `game_id` int(11) DEFAULT NULL,
  `user_id` int(11) NOT NULL COMMENT '用户id',
  `is_read` tinyint(2) DEFAULT '0' COMMENT '0未读1已读',
  `create_time` int(11) DEFAULT NULL COMMENT '创建时间',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=9 DEFAULT CHARSET=utf8;

-- 2019-11-19 cxj
-- 添加索引
ALTER TABLE `tab_user_play_info` ADD INDEX `search`(`promote_id`, `game_id`, `server_id`, `create_time`);
ALTER TABLE `tab_user_login_record` ADD INDEX `search`(`promote_id`, `game_id`, `server_id`, `login_time`);
ALTER TABLE `tab_spend` ADD INDEX `search`(`promote_id`, `game_id`, `server_id`, `pay_way`, `pay_status`, `pay_time`);


-- 添加登录日统计表
CREATE TABLE `tab_login_daily_record` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `game_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '游戏ID',
  `user_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户ID',
  `promote_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '推广员id',
  `create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
  PRIMARY KEY (`id`),
  KEY `search` (`promote_id`,`game_id`,`create_time`) USING BTREE,
  KEY `user_id` (`user_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=284597 DEFAULT CHARSET=utf8;
--sdk 支付信息
ALTER TABLE `tab_pay_info`
MODIFY COLUMN `order_id`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '平台订单ID' AFTER `game_id`,
ADD COLUMN `extend`  varchar(255) NOT NULL DEFAULT '' COMMENT 'cp订单ID' AFTER `game_id`;


--推广员补充说明

ALTER TABLE `tab_promote`
	CHANGE COLUMN `ver_status` `ver_status` INT(11) NULL DEFAULT '0' COMMENT '资质认证审核状态(1是审核成功，2审核失败，3未审核,4修改认证)' AFTER `child_game_permission`,
	ADD COLUMN `anothpic` CHAR(254) NULL DEFAULT NULL AFTER `account_type`;


--2019-11-19 chenzhi
CREATE TABLE `tab_index_chart` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键自增',
  `date` int(11) NOT NULL DEFAULT '0' COMMENT '日期时间戳',
  `new_user_hours` varchar(500) NOT NULL DEFAULT '' COMMENT '新增用户聚合',
  `new_user_count` int(11) NOT NULL DEFAULT '0' COMMENT '单日新增总计',
  `active_user_hours` varchar(500) NOT NULL DEFAULT '' COMMENT '活跃用户聚合',
  `active_user_count` int(11) NOT NULL DEFAULT '0' COMMENT '单日活跃总计',
  `active_user_list` longtext COMMENT '单日活跃用户的id序列',
  `pay_user_hours` varchar(500) NOT NULL DEFAULT '' COMMENT '付费用户聚合',
  `pay_user_count` int(11) NOT NULL DEFAULT '0' COMMENT '单日付费用户总计',
  `pay_user_list` longtext  COMMENT '单日付费用户的id序列',
  `pay_money_hours` varchar(500) NOT NULL DEFAULT '' COMMENT '付费金额聚合',
  `pay_money_count` decimal(10,2) DEFAULT '0.00' COMMENT '单日付费金额总计',
  `promote_new_hours` varchar(500) NOT NULL DEFAULT '' COMMENT '小时新增渠道',
  `promote_new_count` int(11) NOT NULL DEFAULT '0' COMMENT '新增合作渠道总计',
  `all_count`  varchar(500) NOT NULL DEFAULT '' COMMENT '累计的统计数据',
  `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '统计日期',
  PRIMARY KEY (`id`),
  KEY `date` (`date`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='首页折线图静态数据';

-- 2019-11-20 zyx
DROP TABLE IF EXISTS `tab_device_statistics`;
CREATE TABLE `tab_device_statistics`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `time` int(11) NOT NULL DEFAULT 0 COMMENT '日期时间戳',
  `new_device` int(11) NOT NULL DEFAULT 0 COMMENT '当日新增设备',
  `active_device` int(11) NOT NULL DEFAULT 0 COMMENT '当日活跃设备',
  `today_new_device` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL COMMENT '当日新增设备按小时划分的json字符串',
  `today_active_device` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL COMMENT '当日活跃设备按小时划分的json字符串',
  `today_model_device` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL COMMENT '当日启动机型(机型，系统，数量)',
  `model` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL COMMENT '当日启动设备',
  `version` int(11) NOT NULL DEFAULT 1 COMMENT '机型',
  `duration7` int(255) NOT NULL DEFAULT 0 COMMENT '七天的平均使用时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `time`(`time`) USING BTREE
) ENGINE = MyISAM AUTO_INCREMENT = 163 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;

ALTER TABLE `platform`.`tab_device_record`
ADD INDEX `create_time`(`create_time`) USING BTREE,
ADD INDEX `unique_code`(`unique_code`) USING BTREE,
ADD INDEX `idx_unique_version`(`version`, `unique_code`) USING BTREE,
ADD INDEX `version`(`version`) USING BTREE;
UPDATE `platform_new`.`tab_quick_menu` SET `url` = '/index.php?s=/Home/TestResource/index.html' WHERE `id` = 11
UPDATE `platform_new`.`tab_quick_menu` SET `url` = '/index.php?s=/Home/TestResource/lists.html' WHERE `id` = 12


--提现订单 添加索引
ALTER TABLE `tab_withdraw`
ADD INDEX `widthdraw_number`(`widthdraw_number`);

--玩家角色数据统计表
CREATE TABLE `tab_user_play_data_count` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL DEFAULT 0 COMMENT '玩家ID',
  `promote_id` int(11) NOT NULL DEFAULT 0 COMMENT '推广员ID',
  `game_id` int(11) NOT NULL DEFAULT 0 COMMENT '游戏id',
  `server_id` varchar(255) NOT NULL COMMENT '区服id',
  `role_id` varchar(255) NOT NULL COMMENT '角色id',
  `recharge_cost` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '充值总额',
  `recharge_count` int(10) NOT NULL DEFAULT 0 COMMENT '充值次数',
  `create_time` int(10) NOT NULL DEFAULT 0 COMMENT '创建时间',
  PRIMARY KEY (`id`),
  KEY `recharge_cost` (`recharge_cost`) USING BTREE,
  KEY `recharge_count` (`recharge_count`) USING BTREE,
  KEY `create_time` (`create_time`) USING BTREE,
  KEY `search` (`user_id`,`promote_id`,`game_id`,`server_id`,`role_id`,`create_time`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;

-- 身份证认证信息
CREATE TABLE `tab_idcard_log` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(80) NOT NULL COMMENT '姓名',
  `id_card` varchar(20) NOT NULL COMMENT '身份证号码',
  `user_id` int(11) NOT NULL COMMENT '用户id',
  `ip` varchar(40) DEFAULT '0' COMMENT 'ip地址',
  `num` int(11) DEFAULT '1' COMMENT '认证次数',
  `status` tinyint(2) DEFAULT '0' COMMENT '0 认证失败 1 认证成功',
  `create_time` int(11) DEFAULT '0' COMMENT '创建时间',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=12 DEFAULT CHARSET=utf8 COMMENT='身份证认证信息';

-- 公告已读表
CREATE TABLE `tab_notice_read` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `notice_id` int(11) NOT NULL COMMENT '广告id',
  `game_id` int(11) DEFAULT NULL,
  `user_id` int(11) NOT NULL COMMENT '用户id',
  `is_read` tinyint(2) DEFAULT '0' COMMENT '0未读1已读',
  `create_time` int(11) DEFAULT NULL COMMENT '创建时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;

-- 短信日志
CREATE TABLE `tab_sms_log` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `code` int(11) DEFAULT NULL COMMENT '验证码',
  `phone` varchar(20) NOT NULL COMMENT '手机号',
  `content` text NOT NULL COMMENT '发送内容',
  `status` tinyint(2) NOT NULL COMMENT '发送状态',
  `msg` varchar(80) DEFAULT NULL COMMENT '发送返回的信息',
  `ip` varchar(20) DEFAULT NULL COMMENT 'ip地址',
  `create_time` int(11) DEFAULT NULL COMMENT '创建时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8 COMMENT='短信日志';

--提现表添加最后更新时间
ALTER TABLE `tab_withdraw`
ADD COLUMN `last_up_update_time` int(10) NOT NULL DEFAULT 0 COMMENT '最后更新时间',
ADD COLUMN `spend_ids` longtext NOT NULL COMMENT '充值订单id';

-- 推广员添加oa关联
ALTER TABLE `tab_promote`
ADD COLUMN`oa_associated` tinyint(1) DEFAULT '0' COMMENT 'oa是否关联',

--玩家角色表--添加索引
ALTER TABLE `tab_user_play_info`
ADD INDEX `game_id`(`game_id`, `server_id`, `role_id`);

-- SDK菜单配置

INSERT INTO `tab_tool` (`name`, `title`, `config`, `template`, `type`, `status`, `create_time` )
VALUES
  ('personal_menu', '个人中心列表', '[{\"name\":\"gift\",\"title\":\"\\u793c\\u5305\",\"menu_version\":\"0\",\"url\":\"\\/sdk.php\\/GameGiftPage\\/gift_list\",\"type\":\"0\",\"act\":\"gift\",\"ios_url\":\"?action=gift\",\"sort\":\"1\",\"id\":1,\"icon\":\"\\/Uploads\\/Picture\\/2019-11-20\\/5dd526395e339.png\",\"cover\":\"1986\"},{\"name\":\"balance\",\"title\":\"\\u4f59\\u989d\",\"menu_version\":\"0\",\"url\":\"\\/sdk.php\\/UserH\\/get_user_money\",\"type\":\"0\",\"act\":\"\\/sdk.php\\/UserH\\/get_user_money\",\"ios_url\":\"\\/sdk.php\\/UserH\\/get_user_money\",\"sort\":\"2\",\"id\":\"2\",\"icon\":\"\\/Uploads\\/Picture\\/2019-11-20\\/5dd5264d1e202.png\",\"cover\":\"1987\"},{\"name\":\"message\",\"title\":\"\\u6d88\\u606f\",\"menu_version\":\"0\",\"url\":\"\",\"type\":\"1\",\"act\":\"msg\",\"ios_url\":\"\",\"sort\":\"3\",\"id\":3,\"icon\":\"\\/Uploads\\/Picture\\/2019-11-20\\/5dd5265fb396d.png\",\"cover\":\"1988\"},{\"name\":\"support\",\"title\":\"\\u5ba2\\u670d\",\"menu_version\":\"0\",\"url\":\"\",\"type\":\"1\",\"act\":\"support\",\"ios_url\":\"\",\"sort\":\"4\",\"id\":4,\"icon\":\"\\/Uploads\\/Picture\\/2019-11-20\\/5dd52674492b7.png\",\"cover\":\"1989\"}]', '', 5, 1, 1571723212 );
INSERT INTO `tab_tool` (`name`, `title`, `config`, `template`, `type`, `status`, `create_time` )
VALUES
  ('contact_cs', '联系客服', '[{\"name\":\"support\",\"title\":\"\\u8054\\u7cfb\\u5ba2\\u670d\",\"menu_version\":\"0\",\"url\":\"\",\"type\":\"2\",\"act\":\"3007567814\",\"ios_url\":\"3007567814\",\"sort\":\"1\",\"id\":1,\"icon\":\"\",\"cover\":\"\"}]', '', 5, 1, 1571723212 );
INSERT INTO `tab_tool` (`name`, `title`, `config`, `template`, `type`, `status`, `create_time` )
VALUES
  ('sdk_menu', 'SDK用户菜单', '[{\"name\":\"mine\",\"title\":\"\\u6211\\u7684\",\"menu_version\":\"0\",\"url\":\"\",\"type\":\"1\",\"act\":\"my\",\"ios_url\":\"\",\"sort\":\"1\",\"id\":\"1\",\"icon\":\"\\/Uploads\\/Picture\\/2019-11-20\\/5dd524dfd76fa.png\",\"cover\":\"1980\"},{\"name\":\"gift\",\"title\":\"\\u793c\\u5305\",\"menu_version\":\"0\",\"url\":\"\\/sdk.php\\/GameGiftPage\\/gift_list\",\"type\":\"0\",\"act\":\"gift\",\"ios_url\":\"?action=gift\",\"sort\":\"2\",\"id\":2,\"icon\":\"\\/Uploads\\/Picture\\/2019-11-20\\/5dd52509f3767.png\",\"cover\":\"1981\"},{\"name\":\"support\",\"title\":\"\\u5ba2\\u670d\",\"menu_version\":\"0\",\"url\":\"\",\"type\":\"1\",\"act\":\"support\",\"ios_url\":\"\",\"sort\":\"3\",\"id\":3,\"icon\":\"\\/Uploads\\/Picture\\/2019-11-20\\/5dd5251e0aee3.png\",\"cover\":\"1982\"},{\"name\":\"message\",\"title\":\"\\u6d88\\u606f\",\"menu_version\":\"0\",\"url\":\"\",\"type\":\"1\",\"act\":\"msg\",\"ios_url\":\"\",\"sort\":\"4\",\"id\":4,\"icon\":\"\\/Uploads\\/Picture\\/2019-11-20\\/5dd525606ff53.png\",\"cover\":\"1983\"},{\"name\":\"logout\",\"title\":\"\\u9000\\u51fa\",\"menu_version\":\"0\",\"url\":\"\",\"type\":\"1\",\"act\":\"logout\",\"ios_url\":\"\",\"sort\":\"5\",\"id\":5,\"icon\":\"\\/Uploads\\/Picture\\/2019-11-20\\/5dd525d99ed99.png\",\"cover\":\"1984\"},{\"name\":\"suppersign\",\"title\":\"\\u8d85\\u7ea7\\u7b7e\",\"menu_version\":\"2\",\"url\":\"\\/mobile.php\\/ssg\\/home\",\"type\":\"2\",\"act\":\"suppersign\",\"ios_url\":\"http:\\/\\/m.wmtxkj.cn\\/mobile.php\\/ssg\\/home\",\"sort\":\"6\",\"id\":6,\"icon\":\"\\/Uploads\\/Picture\\/2019-11-20\\/5dd525f388843.png\",\"cover\":\"1985\"}]', '', 5, 1, 1571723212 );

-- 修改迁移
ALTER TABLE `tab_mend` 
ADD COLUMN `order_time` int(11) NOT NULL DEFAULT 0 COMMENT '订单时间' AFTER `remark`;
ALTER TABLE `sys_shift_task` 
CHANGE COLUMN `create_promote_id` `creator_id` int(11) NOT NULL DEFAULT 0 COMMENT '创建渠道ID' AFTER `status`;
ALTER TABLE `sys_shift_task` 
ADD COLUMN `creator_type` tinyint(1) NOT NULL DEFAULT 0 COMMENT '创建者类型 0 后台管理员 1 推广员' AFTER `creator_id`;
ALTER TABLE `tab_mend` 
ADD COLUMN `op_type` tinyint(0) NOT NULL DEFAULT 0 COMMENT '0 管理员 1 推广员' AFTER `op_account`;

--补链新增切分时间 chenzhi
UPDATE `sys_model` SET `list_grid` = 'id:编号
user_account:账号
user_nickname:昵称
promote_id:推广员编号
promote_account:推广员账号
promote_id_to:修改后编号
promote_account_to:修改后账号
remark:备注
create_time:时间
op_account:操作人账号
order_time:切分时间' WHERE `id` = 29;

--新增风控类型
ALTER TABLE `tab_device_bans`
MODIFY COLUMN `type`  tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '类型 0未知 1设备号 2IP 3落地页链接 4下载链接' AFTER `tag`;

-- user表注册类型添加7虚拟
ALTER TABLE `tab_user` MODIFY COLUMN `register_type` tinyint(2) DEFAULT '1' COMMENT '注册方式 0游客1账号 2 手机 3微信 4QQ 5百度 6微博 7虚拟';

--游戏评分字段改为保留小数1位  2019-12-03 郑昌隆---
ALTER TABLE tab_game MODIFY COLUMN `game_score` double(3,1) DEFAULT '0' COMMENT '游戏评分';

--新增区服预告表  chenzhi 2019-12-04
CREATE TABLE `tab_server_notice` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键自增',
  `game_id` int(11) NOT NULL COMMENT '游戏id',
  `game_name` varchar(30) NOT NULL COMMENT '游戏名称',
  `server_name` varchar(30) NOT NULL COMMENT '区服名称',
  `server_num` int(11) DEFAULT NULL COMMENT '对接区服id',
  `recommend_status` tinyint(2) DEFAULT '1' COMMENT '推荐状态(0:否,1:是)',
  `show_status` tinyint(2) DEFAULT '1' COMMENT '显示状态(0:否,1:是)',
  `stop_status` tinyint(2) DEFAULT '0' COMMENT '是否停服(0:否,1:是)',
  `server_status` tinyint(2) DEFAULT '0' COMMENT '区服状态(0:正常,1拥挤,2爆满)',
  `icon` int(11) DEFAULT NULL COMMENT '区服图标',
  `start_time` int(11) DEFAULT NULL COMMENT '开始时间',
  `desride` varchar(300) DEFAULT NULL COMMENT '描述',
  `prompt` varchar(300) DEFAULT NULL COMMENT '停服提示',
  `parent_id` int(11) DEFAULT NULL COMMENT '父类id',
  `create_time` int(11) DEFAULT NULL COMMENT '创建时间',
  `server_version` tinyint(2) DEFAULT NULL COMMENT '运营平台 1and 2ios 0双平台',
  `developers` int(11) DEFAULT '0' COMMENT '开发商',
  `server_id` varchar(50) NOT NULL DEFAULT '' COMMENT '对接区服id',
  PRIMARY KEY (`id`),
  KEY `game_id` (`game_id`),
  KEY `show_status` (`show_status`),
  KEY `start_time` (`start_time`),
  KEY `create_time` (`create_time`)
) ENGINE=InnoDB AUTO_INCREMENT=488 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='游戏区服预告表';

INSERT INTO `sys_model` ( `name`, `title`, `extend`, `relation`, `need_pk`, `field_sort`, `field_group`, `attribute_list`, `attribute_alias`, `template_list`, `template_add`, `template_edit`, `list_grid`, `list_row`, `search_key`, `search_list`, `create_time`, `update_time`, `status`, `engine_type`) 
VALUES ('ServerNotice', '游戏区服预告', '0', '', '1', '{\"1\":[\"289\",\"288\",\"290\",\"291\",\"293\",\"292\",\"287\",\"286\",\"282\",\"281\",\"283\",\"284\",\"285\",\"280\"]}', '1:基础', '', '', '', '', '', 'id:编号\r\ngame_name:游戏名称\r\nserver_name:区服名称\r\nshow_status|get_info_status:区服状态\r\nstart_time|set_show_time:开服时间\r\nserver_version:运营平台\r\ndevelopers:开发商\r\nid:操作:[EDIT]&id=[id]|编辑,ServerNotice/del?ids=[id]|删除', '10', '', '', '1480318911', '1493879217', '1', 'MyISAM');

--游戏表新增字段-落地页视频  liuweiwen 2019-12-09
ALTER TABLE tab_game ADD `flooring_page_video` varchar(150) NOT NULL DEFAULT '' COMMENT '落地页视频';
ALTER TABLE tab_game ADD `supersign_status` tinyint(1) DEFAULT '1' COMMENT '超级签开关：1-开启；0-关闭';
ALTER TABLE tab_game ADD `ios_video_top` tinyint(1) DEFAULT '1' COMMENT 'ios落地页视频是否置顶：1-置顶；0-不置顶';

-- 新旧IOS打包标识
ALTER TABLE `tab_game_source` add COLUMN `is_new_sdk` tinyint(2) DEFAULT '0' COMMENT '是否新SDK(IOS)';
ALTER TABLE `tab_mend` ADD COLUMN `pay_amount` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '换绑时归属前推广员的充值金额' AFTER `promote_account_to`;

-- 合服游戏区服表  tping
CREATE TABLE `tab_server_union` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键自增',
  `game_id` int(11) NOT NULL COMMENT '游戏id',
  `game_name` varchar(30) NOT NULL COMMENT '游戏名称',
  `server_name` varchar(30) NOT NULL COMMENT '区服名称',
  `server_num` int(11) DEFAULT NULL COMMENT '对接区服id',
  `recommend_status` tinyint(2) DEFAULT '1' COMMENT '推荐状态(0:否,1:是)',
  `show_status` tinyint(2) DEFAULT '1' COMMENT '显示状态(0:否,1:是)',
  `stop_status` tinyint(2) DEFAULT '0' COMMENT '是否停服(0:否,1:是)',
  `server_status` tinyint(2) DEFAULT '0' COMMENT '区服状态(0:正常,1拥挤,2爆满)',
  `icon` int(11) DEFAULT NULL COMMENT '区服图标',
  `start_time` int(11) DEFAULT NULL COMMENT '开始时间',
  `desride` varchar(300) DEFAULT NULL COMMENT '描述',
  `prompt` varchar(300) DEFAULT NULL COMMENT '停服提示',
  `parent_id` int(11) DEFAULT NULL COMMENT '父类id',
  `create_time` int(11) DEFAULT NULL COMMENT '创建时间',
  `server_version` tinyint(2) DEFAULT NULL COMMENT '运营平台 1and 2ios 0双平台',
  `developers` int(11) DEFAULT '0' COMMENT '开发商',
  `server_id` varchar(50) NOT NULL DEFAULT '' COMMENT '对接区服id',
  PRIMARY KEY (`id`),
  KEY `game_id` (`game_id`),
  KEY `show_status` (`show_status`),
  KEY `start_time` (`start_time`),
  KEY `create_time` (`create_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='合服游戏区服表';

-- 用户行为 tping
ALTER TABLE `tab_pay_info` ADD COLUMN `user_account` varchar(30) DEFAULT NULL COMMENT '用户账号';
ALTER TABLE `tab_pay_info` ADD COLUMN `game_player_name` varchar(30) DEFAULT '' COMMENT '游戏玩家昵称';
ALTER TABLE `tab_pay_info` ADD COLUMN `game_name` varchar(30) DEFAULT '' COMMENT '游戏名称';
ALTER TABLE `tab_pay_info` ADD COLUMN `server_id` int(11) DEFAULT '0' COMMENT '区服id';
ALTER TABLE `tab_pay_info` ADD COLUMN `server_name` varchar(30) DEFAULT '' COMMENT '区服名称';
ALTER TABLE `tab_pay_info` ADD COLUMN `promote_id` int(11) NOT NULL DEFAULT '0' COMMENT '推广员id';
ALTER TABLE `tab_pay_info` ADD COLUMN `game_player_id` varchar(30) DEFAULT '0' COMMENT '玩家游戏内id';
ALTER TABLE `tab_pay_info` ADD COLUMN `sdk_version` tinyint(2) DEFAULT '1' COMMENT '区别sdk版本1安卓 2苹果 ';
ALTER TABLE `tab_pay_info` ADD COLUMN `promote_account` varchar(30) DEFAULT '' COMMENT '推广员账号';

ALTER TABLE `tab_pay_info`
MODIFY COLUMN `game_player_id`  varchar(255) NULL DEFAULT '0' COMMENT '玩家游戏内id' AFTER `promote_id`;
ALTER TABLE `tab_pay_info`
ADD COLUMN `ip`  varchar(255) NOT NULL DEFAULT '0' AFTER `promote_account`,
ADD COLUMN `pay_way`  int NOT NULL DEFAULT 0 AFTER `ip`;
-- 默认值处理 tping
ALTER TABLE `tab_pay_info`
MODIFY COLUMN `user_account`  varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '用户账号' AFTER `txn_time`,
MODIFY COLUMN `game_player_name`  varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '游戏玩家昵称' AFTER `user_account`,
MODIFY COLUMN `game_name`  varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '游戏名称' AFTER `game_player_name`,
MODIFY COLUMN `server_id`  int(11) NOT NULL DEFAULT 0 COMMENT '区服id' AFTER `game_name`,
MODIFY COLUMN `server_name`  varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '区服名称' AFTER `server_id`,
MODIFY COLUMN `game_player_id`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '0' COMMENT '玩家游戏内id' AFTER `promote_id`,
MODIFY COLUMN `sdk_version`  tinyint(2) NOT NULL DEFAULT 1 COMMENT '区别sdk版本1安卓 2苹果 ' AFTER `game_player_id`,
MODIFY COLUMN `promote_account`  varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '推广员账号' AFTER `sdk_version`;

-- 苹果内购  tping
ALTER TABLE `tab_spend_distinction`
MODIFY COLUMN `extend`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '通知游戏方扩展(一般是游戏方透传)' AFTER `game_name`;


-- 菜单(游戏充值预下单)
INSERT INTO `sys_menu`(`title`, `pid`, `sort`, `url`, `hide`, `tip`, `group`, `is_dev`, `status`) VALUES ('游戏充值预下单', 16, 0, 'BehaviorLog/game', 0, '', '行为日志', 0, 1);

--平台币表增加字段，model变修改内容  zyx 2019-12-11
UPDATE `sys_model` SET `list_grid` = 'id:编号\r\npay_order_number:订单号\r\nuser_account:用户账号\r\npromote_account:所属推广员\r\npay_amount:支付金额\r\npay_way:充值方式\r\ncreate_time|set_show_time:支付时间\r\npay_status|get_info_status*12:支付状态\r\npay_ip:支付IP\r\nsdk_status:游戏SDK状态\r\n' WHERE `id` = 9

CREATE TABLE `tab_test_white_list`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL COMMENT '用户id',
  `account` varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '白名单账号',
  `show_status` tinyint(2) NULL DEFAULT 1 COMMENT '显示状态',
  `add_user` varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '后台添加账号',
  `create_ime` int(11) NULL DEFAULT NULL COMMENT '添加时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 12 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Dynamic;
--2019-12-13
--游戏添加落地页视频封面
ALTER TABLE `tab_game`
ADD COLUMN `flooring_page_video_cover` int(11) NOT NULL DEFAULT 0 COMMENT '落地页视频封面';

--2019-12-11 超级签新增充值方式 chenzhi
ALTER TABLE `tab_game_supersign` ADD COLUMN `pay_way` tinyint(2) DEFAULT '0' COMMENT '充值方式(0:未知,1:支付宝,2:微信)' AFTER `pay_time`;


--新增游戏聚合 2019-12-16 chenzhi
CREATE TABLE `tab_game_count` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键自增',
  `date` int(11) NOT NULL DEFAULT '0' COMMENT '日期时间戳',
  `game_id` int(11) NOT NULL DEFAULT '0' COMMENT '游戏id',
  `game_name` varchar(50) NOT NULL DEFAULT '' COMMENT '游戏名称',
  `new_user_count` int(11) NOT NULL DEFAULT '0' COMMENT '新增总计',
  `active_user_count` int(11) NOT NULL DEFAULT '0' COMMENT '活跃总计',
  `active_user_list` longtext COMMENT '活跃用户的id序列',
  `pay_money_count` decimal(10,2) DEFAULT '0.00' COMMENT '付费金额总计',
  `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '统计日期',
  PRIMARY KEY (`id`),
  KEY `date` (`date`) USING BTREE,
  KEY `new_user_count` (`new_user_count`) USING BTREE,
  KEY `active_user_count` (`active_user_count`) USING BTREE,
  KEY `pay_money_count` (`pay_money_count`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='总览游戏统计聚合';

CREATE TABLE `tab_promote_count` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键自增',
  `date` int(11) NOT NULL DEFAULT '0' COMMENT '日期时间戳',
  `promote_id` int(11) NOT NULL DEFAULT '0' COMMENT '推广账号',
  `promote_account` varchar(30) NOT NULL DEFAULT '' COMMENT '账号',
  `new_user_count` int(11) NOT NULL DEFAULT '0' COMMENT '新增总计',
  `active_user_count` int(11) NOT NULL DEFAULT '0' COMMENT '活跃总计',
  `active_user_list` longtext COMMENT '活跃用户的id序列',
  `pay_money_count` decimal(10,2) DEFAULT '0.00' COMMENT '付费金额总计',
  `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '统计日期',
  PRIMARY KEY (`id`),
  KEY `date` (`date`) USING BTREE,
  KEY `new_user_count` (`new_user_count`) USING BTREE,
  KEY `active_user_count` (`active_user_count`) USING BTREE,
  KEY `pay_money_count` (`pay_money_count`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='总览推广员统计聚合';

--2019-12-16
--公会分成比例管理
CREATE TABLE `tab_promote_game_ratio` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `promote_id` int(11) NOT NULL DEFAULT '0' COMMENT '推广员id',
  `game_id` int(11) NOT NULL DEFAULT '0' COMMENT '游戏id',
  `ratio` decimal(5,2) NOT NULL DEFAULT '0.00' COMMENT '分成比例',
  `last_ratio` decimal(5,2) NOT NULL DEFAULT '0.00' COMMENT '上次的分成比例',
  `last_ratio_status` tinyint(3) NOT NULL DEFAULT '0' COMMENT '上次的分成比例状态：0-未设置 1-已设置',
  `begin_time` int(10) NOT NULL DEFAULT '0' COMMENT '开始时间',
  `end_time` int(10) NOT NULL DEFAULT '0' COMMENT '过期时间',
  `remark` varchar(255) COLLATE utf8mb4_bin NOT NULL COMMENT '备注',
  `status` tinyint(3) NOT NULL DEFAULT '0' COMMENT '审核状态：-1-未通过 0-待审核 1-通过',
  `review_time` int(10) NOT NULL DEFAULT '0' COMMENT '审核时间',
  `applicant_id` int(11) NOT NULL DEFAULT '0' COMMENT '申请人',
  `reviewer_id` int(11) NOT NULL DEFAULT '0' COMMENT '审核人',
  `create_time` int(10) NOT NULL DEFAULT '0' COMMENT '创建时间',
  `update_time` int(10) NOT NULL DEFAULT '0' COMMENT '更新时间',
  PRIMARY KEY (`id`),
  KEY `promote_id` (`promote_id`,`game_id`,`status`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

-- 超级签统计菜单
INSERT INTO `sys_menu`( `title`, `pid`, `sort`, `url`, `hide`, `tip`, `group`, `is_dev`, `status`) VALUES ('游戏统计', 137, 0, 'SuperStatistical/index', 0, '', '财务管理', 0, 1);

-- pay_info 增加索引 tping
ALTER TABLE `tab_pay_info`
ADD INDEX `idx_game_id_server_id` (`game_id`, `server_id`) ,
ADD INDEX `idx_user_account` (`user_account`) ,
ADD INDEX `idx_promote_id` (`promote_id`) ,
ADD INDEX `idx_game_player_id` (`game_player_id`) ,
ADD INDEX `idx_game_player_name` (`game_player_name`) ,
ADD INDEX `idx_extend` (`extend`) ;


--新增游戏聚合 2019-12-19 zyx
ALTER TABLE `sys_auth_group`
ADD COLUMN `data_empower_type` tinyint(4) NOT NULL DEFAULT 1 COMMENT '数据权限 1 全部 2 部分数据 3 自己底下的会长' AFTER `rules`;
ALTER TABLE `platform`.`sys_auth_group`
ADD COLUMN `data_president` longtext NULL COMMENT '会长数据' AFTER `data_empower_type`;

-- user_play 增加create_time
ALTER TABLE `platform_pre1218`.`tab_user_play`
ADD COLUMN `create_time` int(11) NOT NULL COMMENT '创建时间' AFTER `check_money`;

-- 推广员表加入推广公司字段 liuweiwen 20191216
ALTER TABLE tab_promote ADD `company_id` int(11) NOT NULL DEFAULT '0' COMMENT '推广公司ID';
-- 新增推广公司表 liuweiwen 20191216
CREATE TABLE `tab_promote_company` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `company_name` varchar(60) NOT NULL COMMENT '推广公司名称',
  `uid` int(11) NOT NULL DEFAULT '0' COMMENT '添加人ID',
  `status` tinyint(3) NOT NULL DEFAULT '1' COMMENT '状态 0-禁用 1-启用',
  `create_time` int(10) NOT NULL DEFAULT '0' COMMENT '添加时间',
  `last_up_time` int(10) NOT NULL DEFAULT '0' COMMENT '最后更新时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='推广公司';
-- 推广员表新增推广公司id liuweiwen  2019-12-23
ALTER TABLE tab_promote ADD `company_id` int(11) NOT NULL DEFAULT '0' COMMENT '推广公司ID';
-- 新增推广公司表 liuweiwen  2019-12-23
CREATE TABLE `tab_promote_company` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `company_name` varchar(60) NOT NULL COMMENT '推广公司名称',
  `uid` int(11) NOT NULL DEFAULT '0' COMMENT '添加人ID',
  `status` tinyint(3) NOT NULL DEFAULT '1' COMMENT '状态 0-禁用 1-启用',
  `create_time` int(10) NOT NULL DEFAULT '0' COMMENT '添加时间',
  `last_up_time` int(10) NOT NULL DEFAULT '0' COMMENT '最后更新时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='推广公司';


-- 菜单(推广公司录入)有个变量，所以后面几句要一起执行 liuweiwen
INSERT INTO `sys_menu`(`title`, `pid`, `sort`, `url`, `hide`, `tip`, `group`, `is_dev`, `status`)
VALUES ('推广公司录入', 185, 56, 'PromoteCompany/lists', 0, '该功能用于录入工会所属的推广公司名称', '推广员管理', 0, 1);

set @company_id = (SELECT id FROM sys_menu WHERE title = '推广公司录入');
INSERT INTO `sys_menu`(`title`, `pid`, `sort`, `url`, `hide`, `tip`, `group`, `is_dev`, `status`)
VALUES ('新增', @company_id, 0, 'PromoteCompany/add', 0, '', '推广员管理', 0, 1);
INSERT INTO `sys_menu`(`title`, `pid`, `sort`, `url`, `hide`, `tip`, `group`, `is_dev`, `status`)
VALUES ('编辑', @company_id, 0, 'PromoteCompany/edit', 0, '', '推广员管理', 0, 1);
INSERT INTO `sys_menu`(`title`, `pid`, `sort`, `url`, `hide`, `tip`, `group`, `is_dev`, `status`)
VALUES ('删除', @company_id, 0, 'PromoteCompany/del', 0, '', '推广员管理', 0, 1);
-- 增加修改b_spend表索引 liuweiwen  2019-12-23
DROP INDEX o ON tab_spend;
ALTER TABLE tab_spend ADD INDEX o(pay_status, is_check, settle_check, promote_id);
ALTER TABLE tab_user_login_record ADD INDEX user_id_promote_idx(user_id, promote_id);

CREATE TABLE `tab_player_retention` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) not null COMMENT '用户ID',
  `game_id` int(11) NOT NULL COMMENT '游戏ID',
  `player_id` int(11) NOT NULL COMMENT '玩家ID',
  `day1` tinyint(1) NOT NULL default 0 COMMENT '是否1日留存',
  `day2` tinyint(1) NOT NULL default 0 COMMENT '是否2日留存',
  `day3` tinyint(1) NOT NULL default 0 COMMENT '是否3日留存',
  `day4` tinyint(1) NOT NULL default 0 COMMENT '是否4日留存',
  `day5` tinyint(1) NOT NULL default 0 COMMENT '是否5日留存',
  `day6` tinyint(1) NOT NULL default 0 COMMENT '是否6日留存',
  `day7` tinyint(1) NOT NULL default 0 COMMENT '是否7日留存',
  `day15` tinyint(1) NOT NULL default 0 COMMENT '是否15日留存',
  `day30` tinyint(1) NOT NULL default 0 COMMENT '是否30日留存',
  PRIMARY KEY (`id`),
  KEY `index_game_id` (`game_id`),
  KEY `index_user_id` (`user_id`),
  KEY `index_player_id` (`player_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户留存率';
-- 玩家注册时间
ALTER TABLE `tab_user_play`
ADD COLUMN `create_time` int(11) NOT NULL DEFAULT 0 COMMENT '玩家注册时间';

update tab_user_play a left join tab_user b on a.user_id= b.id set a.create_time = b.register_time where a.user_id=b.id;
ALTER TABLE `tab_spend`
ADD COLUMN `event_status` tinyint(1) NOT NULL DEFAULT 0 COMMENT '事件是否通知';

-- 菜单添加补单记录
INSERT INTO `sys_menu`(`title`, `pid`, `sort`, `url`, `hide`, `tip`, `group`, `is_dev`, `status`) VALUES ('补单记录管理', 137, 0, 'BehaviorLog/singleSupplement', 0, '', '游戏订单', 0, 1);


-- 增加通知到账 tping
CREATE TABLE `tab_repair_pay` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `admin_id` int(11) NOT NULL DEFAULT '0',
  `admin_name` varchar(255) NOT NULL DEFAULT '',
  `pay_order_number` varchar(255) NOT NULL DEFAULT '',
  `ip` varchar(255) NOT NULL DEFAULT '',
  `tab` varchar(255) NOT NULL DEFAULT '' COMMENT '订单表：spend,deposit',
  `create_time` int(11) NOT NULL DEFAULT '0',
  `type` int(11) DEFAULT '0' COMMENT '0通知到账 1补单记录',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8 COMMENT='通知到账补单';

ALTER TABLE `tab_game`
ADD COLUMN `beta_status` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Beta版状态';
ALTER TABLE `tab_game`
ADD COLUMN `beta_url` varchar(150) NOT NULL DEFAULT '' COMMENT 'Beta链接';

-- 游戏支付方式渠道配置
ALTER TABLE `tab_game`
ADD COLUMN `pay_config` varchar(255) NOT NULL COMMENT '支付渠道 wx 微信 zfb 支付宝 quick 快捷 (gf 官方 sq 双乾';

ALTER TABLE tab_promote add `company_belong` tinyint(1) NOT NULL DEFAULT '0' COMMENT '工会归属：0-内团；1-外团';
ALTER TABLE tab_promote add `company_relation` tinyint(1) NOT NULL DEFAULT '0' COMMENT '工会关系：0-自主开发及维护；1-只维护';
-- 游戏的合作方新增联系人，联系电话，邮寄地址,公司税号，收款方名称，银行账号，开户行 liuweiwen  2020-01-03
ALTER TABLE tab_partner ADD `link_man` varchar(64) DEFAULT '' COMMENT '联系人' AFTER `status`;
ALTER TABLE tab_partner ADD  `link_phone` varchar(24) DEFAULT NULL COMMENT '联系电话'  AFTER `link_man`;
ALTER TABLE tab_partner ADD  `address` varchar(255) DEFAULT NULL COMMENT '邮寄地址' AFTER `link_phone`;
ALTER TABLE tab_partner ADD  `company_tax_no` varchar(64) DEFAULT NULL COMMENT '公司税号' AFTER `address`;
ALTER TABLE tab_partner ADD  `payee_name` varchar(24) DEFAULT NULL COMMENT '收款方名称' AFTER `company_tax_no`;
ALTER TABLE tab_partner ADD  `bank_account` varchar(32) DEFAULT NULL COMMENT '银行账号' AFTER `payee_name`;
ALTER TABLE tab_partner ADD  `opening_bank` varchar(128) DEFAULT NULL COMMENT '开户行' AFTER `bank_account`;

-- 推广公会归属管理 2020-1-1 刘伟文
CREATE TABLE `tab_promote_belong` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `promote_id` int(11) NOT NULL DEFAULT '0' COMMENT '推广员id',
  `verify_status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '审核状态:0-待审核；1-审核通过；2-审核拒绝',
  `company_belong` tinyint(1) NOT NULL DEFAULT '0' COMMENT '工会归属：0-内团；1-外团',
  `company_relation` tinyint(1) NOT NULL DEFAULT '0' COMMENT '工会关系：0-自主开发及维护；1-只维护',
  `remark` varchar(255) DEFAULT NULL COMMENT '备注',
  `applicant_id` int(11) NOT NULL DEFAULT '0' COMMENT '申请人(后台管理员)id',
  `applicant_name` varchar(32) DEFAULT NULL,
  `approver_id` int(11) NOT NULL DEFAULT '0' COMMENT '确认人(后台管理员)id',
  `approver_name` varchar(30) DEFAULT NULL,
  `applicant_time` int(11) DEFAULT '0' COMMENT '申请时间',
  `update_time` int(11) DEFAULT '0' COMMENT '修改时间',
  `verify_time` int(11) DEFAULT '0' COMMENT '审批时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='推广公会归属管理';

-- 公司信息 2020-1-8 刘伟文
INSERT INTO `tab_tool` (`name`, `title`, `config`, `template`, `type`, `status`, `create_time`) VALUES ('company_info', '公司信息', NULL, NULL, '1', '1', NULL);


-- cp/公会对账单 2020-1-7 陈志
CREATE TABLE `tab_statement` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增主键',
  `statement_type` tinyint(2) DEFAULT '0' COMMENT '对账类型(0-上游对账单;1-下游对账单)',
  `company_id` int(11) DEFAULT '0' COMMENT '对账公司id',
  `company_name` varchar(60) NOT NULL COMMENT '对账公司名称',
  `link_phone` varchar(24) DEFAULT NULL COMMENT '对账公司联系人电话',
  `statement_begin_time` int(11) NOT NULL DEFAULT '0' COMMENT '对账开始时间',
  `statement_end_time` int(11) NOT NULL DEFAULT '0' COMMENT '对账截止时间',
  `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建对账单时间',
  `statement_money` decimal(10,2) DEFAULT '0.00' COMMENT '对账金额',
  `pay_amount` decimal(10,2) DEFAULT '0.00' COMMENT '平台金额合计(已减罚款)',
  `is_confirm` tinyint(2) DEFAULT '0' COMMENT '是否确认(0-未确认;1-确认)',
  `pay_type` tinyint(2) DEFAULT '0' COMMENT '收款方(0-甲方付给乙方,乙方收款;1-乙方付给甲方,甲方收款)',
  `ext_field` varchar(50) DEFAULT '' COMMENT '扩展字段，如果是下游为提现单号',
  `first_party_info` longtext NOT NULL COMMENT '甲方相关信息json',
  `second_party_info` longtext NOT NULL COMMENT '乙方相关信息json',
  `statement_info` longtext NOT NULL COMMENT '订单相关信息json',
  PRIMARY KEY (`id`),
  KEY `statement_type` (`statement_type`),
  KEY `company_id` (`company_id`),
  KEY `link_phone` (`link_phone`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='cp/公会对账单';



-- 新增CP游戏分成比例表 2020-01-09 郑昌隆
CREATE TABLE `tab_cp_game_ratio` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `game_id` int(11) DEFAULT '0' COMMENT '游戏ID',
  `ratio` decimal(5,2) DEFAULT '0.00' COMMENT '分成比率',
  `begin_total_amount` decimal(11,2) DEFAULT '0.00' COMMENT '分成开始档位总流水',
  `add_time` int(11) DEFAULT '0' COMMENT '添加时间',
  `update_time` int(11) DEFAULT '0' COMMENT '更新时间',
  `is_del` tinyint(2) DEFAULT '0' COMMENT '1-已删除',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

-- 玩家列表账户锁定添加备注  2020-01-09 郑昌隆
ALTER TABLE `tab_user` ADD COLUMN `lock_remark` varchar(512) NOT NULL DEFAULT '' COMMENT '账号锁定原因' after lock_status;

-- 2019-12-30
-- 会长管理后台提现 cxj
ALTER TABLE `tab_withdraw`
ADD COLUMN `settlement_begin_time` int(10) NOT NULL DEFAULT 0 COMMENT '结算开始时间' AFTER `old_promote_account`;
ALTER TABLE `tab_withdraw`
ADD COLUMN `op_id` int(11) NOT NULL DEFAULT 0 COMMENT '操作id';
ALTER TABLE `tab_withdraw`
ADD COLUMN `op_type` tinyint(3) NOT NULL DEFAULT 1 COMMENT '操作人：1-推广员 2-管理员 3-自动';
ALTER TABLE `tab_withdraw`
ADD COLUMN `last_op_id` int(11) NOT NULL DEFAULT 0 COMMENT '最后操作人id',
ADD COLUMN `last_op_type` tinyint(3) NOT NULL DEFAULT 1 COMMENT '最后操作人：1-推广员 2-管理员 3-自动';

-- 2019-12-31
-- 推广员结算类型 cxj
ALTER TABLE `tab_promote`
ADD COLUMN `settlement_type` tinyint(3) NOT NULL DEFAULT 1 COMMENT '结算类型：1-周结 2-月结';

ALTER TABLE tab_promote add `company_belong` tinyint(1) NOT NULL DEFAULT '0' COMMENT '工会归属：0-内团；1-外团';
ALTER TABLE tab_promote add `company_relation` tinyint(1) NOT NULL DEFAULT '0' COMMENT '工会关系：0-自主开发及维护；1-只维护';

-- 2020-01-02
-- 提现结算类型 cxj
ALTER TABLE `tab_withdraw`
ADD COLUMN `settlement_type` tinyint(3) NOT NULL DEFAULT 3 COMMENT '结算类型：1-周结 2-月结 3-管理员提现 4-推广员提现 5-其他';

-- 2020 01-03 cxj
ALTER TABLE `sys_file`
MODIFY COLUMN `mime` char(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '文件mime类型';

ALTER TABLE `tab_spend`
MODIFY COLUMN `selle_status` int(11) NOT NULL DEFAULT 0 COMMENT '渠道结算 0未结算1 结算',
MODIFY COLUMN `selle_ratio` double(5, 2) DEFAULT 0.00 COMMENT '渠道分成比例';

-- 2020 01-06 cxj
ALTER TABLE `tab_promote_game_ratio`
ADD COLUMN `turnover_ratio` varchar(2000) NOT NULL COMMENT '流水分成比例' AFTER `last_ratio_status`;
ALTER TABLE `tab_promote_game_ratio`
ADD COLUMN `last_turnover_ratio` varchar(2000) NOT NULL COMMENT '上次流水分成比例' AFTER `turnover_ratio`;

-- 2020 01-07 cxj
ALTER TABLE `tab_withdraw`
ADD COLUMN `game_ratio` varchar(5000) NOT NULL COMMENT '游戏提现实际分成比例';

ALTER TABLE `tab_withdraw`
MODIFY COLUMN `settlement_type` tinyint(3) NOT NULL DEFAULT 1 COMMENT '结算类型：1-周结 2-月结 9-其他';

-- 2020 01-13
-- 公会分成比例申请记录
CREATE TABLE `tab_promote_game_ratio_log` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `promote_id` int(11) NOT NULL DEFAULT '0' COMMENT '推广员id',
  `game_id` int(11) NOT NULL DEFAULT '0' COMMENT '游戏id',
  `ratio` decimal(5,2) NOT NULL DEFAULT '0.00' COMMENT '分成比例',
  `last_ratio` decimal(5,2) NOT NULL DEFAULT '0.00' COMMENT '上次的分成比例',
  `last_ratio_status` tinyint(3) NOT NULL DEFAULT '0' COMMENT '上次的分成比例状态：0-未设置 1-已设置',
  `turnover_ratio` varchar(2000) COLLATE utf8mb4_bin NOT NULL COMMENT '流水分成比例',
  `last_turnover_ratio` varchar(2000) COLLATE utf8mb4_bin NOT NULL COMMENT '上次流水分成比例',
  `begin_time` int(10) NOT NULL DEFAULT '0' COMMENT '开始时间',
  `end_time` int(10) NOT NULL DEFAULT '0' COMMENT '过期时间',
  `remark` varchar(255) COLLATE utf8mb4_bin NOT NULL COMMENT '备注',
  `status` tinyint(3) NOT NULL DEFAULT '0' COMMENT '审核状态：-1-未通过 0-待审核 1-通过',
  `review_time` int(10) NOT NULL DEFAULT '0' COMMENT '审核时间',
  `applicant_id` int(11) NOT NULL DEFAULT '0' COMMENT '申请人',
  `reviewer_id` int(11) NOT NULL DEFAULT '0' COMMENT '审核人',
  `create_time` int(10) NOT NULL DEFAULT '0' COMMENT '创建时间',
  PRIMARY KEY (`id`),
  KEY `promote_id` (`promote_id`,`game_id`,`status`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

-- 平台规则
CREATE TABLE `sys_document_pop_rules` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '平台规则表',
  `title` varchar(100) COLLATE utf8mb4_bin NOT NULL DEFAULT '',
  `desc` varchar(255) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '描述',
  `content` text COLLATE utf8mb4_bin,
  `sort` smallint(3) unsigned NOT NULL DEFAULT '0' COMMENT '权重',
  `type` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '类型  0不弹窗 1弹出单次  2循环弹出',
  `pop_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '弹窗时间',
  `operate_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '操作时间',
  `operater_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '操作者ID',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

-- 2020-01-14
-- cxj
ALTER TABLE `tab_promote_game_ratio`
MODIFY COLUMN `turnover_ratio` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '流水分成比例' AFTER `last_ratio_status`,
MODIFY COLUMN `last_turnover_ratio` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '上次流水分成比例';

UPDATE tab_spend SET selle_ratio = 0.00 where selle_ratio is null

ALTER TABLE `tab_promote_game_ratio`
ADD COLUMN `relation_game_id` int(11) NOT NULL DEFAULT 0 COMMENT '关联游戏id' AFTER `game_id`;
ALTER TABLE `tab_promote_game_ratio_log`
ADD COLUMN `relation_game_id` int(11) NOT NULL DEFAULT 0 COMMENT '关联游戏id' AFTER `game_id`;

ALTER TABLE `tab_spend`
MODIFY COLUMN `selle_status` int(11) NOT NULL DEFAULT 0 COMMENT '渠道结算 0未结算1 结算',
MODIFY COLUMN `selle_ratio` double(5, 2) DEFAULT 0.00 COMMENT '渠道分成比例';


ALTER TABLE `tab_game`
ADD COLUMN `download_ways` tinyint(3) NOT NULL DEFAULT 0 COMMENT '下载方式' AFTER `beta_url`;

-- 是否需要修复旧数据
ALTER TABLE `tab_promote`
ADD COLUMN `can_view_recharge` tinyint(1) NOT NULL default 0 COMMENT '是否显示充值数据 0否 1是';

ALTER TABLE `tab_promote_belong`
ADD COLUMN `can_view_recharge` tinyint(1) NOT NULL default 0 COMMENT '是否显示充值数据 0否 1是';

--CP分成比例添加运算符字段  2020-02-04 郑昌隆
ALTER TABLE `tab_cp_game_ratio`
ADD COLUMN `instanceof` tinyint(2) NOT NULL DEFAULT 1 COMMENT '运算符（1:>= ; 2:>）' AFTER `game_id`;

-- 2020-02-04
ALTER TABLE `tab_promote`
ADD COLUMN `auto_review_withdraw_status` tinyint(3) NOT NULL DEFAULT 0 COMMENT '提现自动审核状态：0-关闭 1-开启';
ALTER TABLE `tab_promote`
ADD COLUMN `auto_review_withdraw_updated_time` int(10) NOT NULL DEFAULT 0 COMMENT '提现自动审核状态更新时间';
ALTER TABLE `tab_promote`
ADD INDEX `auto_review_withdraw_status`(`auto_review_withdraw_status`) USING BTREE;

-- 奖罚记录
CREATE TABLE `tab_reward_record` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `reward_type` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '奖罚类型 1奖励 2惩罚',
  `company_type` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '公司类型 1上游公司 2下游公司',
  `company_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '公司ID 当公司类型为上游CP公司时，展示合作方管理下的公司，反之展示推广公司管理下的公司',
  `accounts` json NOT NULL,
  `relation_game_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '游戏id',
  `content` varchar(1000) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '事件内容',
  `money` double(11,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '金额',
  `remark` varchar(255) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '备注',
  `create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
  `creater_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建者ID',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

CREATE TABLE `tab_company_info` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `partner` varchar(60) NOT NULL COMMENT '合作方名称',
  `uid` int(11) NOT NULL DEFAULT '0' COMMENT '添加人ID',
  `status` tinyint(3) NOT NULL DEFAULT '1' COMMENT '状态 0-禁用 1-启用',
  `link_man` varchar(64) DEFAULT '' COMMENT '联系人',
  `link_phone` varchar(24) DEFAULT NULL COMMENT '联系电话',
  `address` varchar(255) DEFAULT NULL COMMENT '邮寄地址',
  `company_tax_no` varchar(64) DEFAULT NULL COMMENT '公司税号',
  `payee_name` varchar(24) DEFAULT NULL COMMENT '收款方名称',
  `bank_account` varchar(32) DEFAULT NULL COMMENT '银行账号',
  `opening_bank` varchar(128) DEFAULT NULL COMMENT '开户行',
  `create_time` int(10) NOT NULL DEFAULT '0' COMMENT '添加时间',
  `last_up_time` int(10) NOT NULL DEFAULT '0' COMMENT '最后更新时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8 COMMENT='内部公司信息';
