
-- 推广员后台首页快捷菜单 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='流水月份聚合表';