####################################################################################
###  玩家表新增绑定支付宝
####################################################################################
ALTER TABLE `h_member`
    ADD COLUMN `alipay_account`  varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '绑定支付宝账号' AFTER `switch_money`;

####################################################################################
###  游戏折扣表新增 渠道分成模式 新增 渠道 cpa单价
####################################################################################
ALTER TABLE `h_game_rate`
    MODIFY COLUMN `benefit_type`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '优惠类型，0 无优惠 1 折扣 2 返利' AFTER `sub_agent_rate`,
    MODIFY COLUMN `mem_agent_reward`  decimal(20,2) NOT NULL DEFAULT 0.00 COMMENT '玩家渠道奖励' AFTER `first_mem_rebate`,
    MODIFY COLUMN `mem_reward`  decimal(20,2) NOT NULL DEFAULT 0.00 COMMENT '玩家奖励' AFTER `mem_agent_reward`,
    MODIFY COLUMN `agent_reward`  decimal(20,2) UNSIGNED NOT NULL DEFAULT 0.00 COMMENT '渠道cpa单价' AFTER `mem_reward`,
    ADD COLUMN `agent_benefit_type`  tinyint(4) UNSIGNED NOT NULL DEFAULT 2 COMMENT '渠道分成模式 1 cpa 2 cps' AFTER `mem_reward`,
    ADD COLUMN `sub_agent_reward`  decimal(20,2) UNSIGNED NOT NULL DEFAULT 0 COMMENT '二级渠道cpa单价' AFTER `agent_reward`;
####################################################################################
###  渠道游戏折扣表新增 渠道分成模式 新增 渠道 cpa单价
####################################################################################
ALTER TABLE `h_agent_game_rate`
    MODIFY COLUMN `benefit_type`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '优惠类型，0 无优惠 1 折扣 2 返利' AFTER `sub_agent_rate`,
    MODIFY COLUMN `mem_agent_reward`  decimal(20,2) NOT NULL DEFAULT 0.00 COMMENT '渠道奖励' AFTER `first_mem_rebate`,
    MODIFY COLUMN `mem_reward`  decimal(20,2) NOT NULL DEFAULT 0.00 COMMENT '玩家奖励' AFTER `mem_agent_reward`,
    ADD COLUMN `agent_benefit_type`  tinyint(4) UNSIGNED NOT NULL DEFAULT 2 COMMENT '渠道分成模式 1 cpa 2 cps' AFTER `mem_reward`,
    ADD COLUMN `agent_reward`  decimal(20,2) UNSIGNED NOT NULL DEFAULT 0 COMMENT '渠道cpa单价' AFTER `agent_benefit_type`,
    ADD COLUMN `sub_agent_reward`  decimal(20,2) UNSIGNED NOT NULL DEFAULT 0 COMMENT '二级渠道cpa单价' AFTER `agent_reward`;

##################################################################################
##### 渠道CPA记录表
##################################################################################
DROP TABLE IF EXISTS `h_agent_cpa_log`;
DROP TABLE IF EXISTS `h_agent_cpa_log`;
CREATE TABLE `h_agent_cpa_log` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `order_id` varchar(64) NOT NULL DEFAULT '' COMMENT '订单号',
    `parent_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '渠道ID',
    `agent_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '渠道ID',
    `app_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '游戏ID',
    `mem_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '玩家ID',
    `ip` char(16) NOT NULL DEFAULT '' COMMENT '注册IP',
    `agent_cpa` decimal(20,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '渠道cpa',
    `parent_cpa` decimal(20,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '渠道cpa',
    `create_time` bigint(20) NOT NULL DEFAULT '0' COMMENT '创建时间',
    `update_time` bigint(20) NOT NULL DEFAULT '0' COMMENT '更新时间',
    PRIMARY KEY (`id`) USING BTREE,
    KEY `acl_mem_index` (`mem_id`) USING BTREE,
    KEY `acl_ip_index` (`ip`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='渠道cpa量记录表';

####################################################################################
#### 新增每日cpa
####################################################################################
ALTER TABLE `dw_day`
    ADD COLUMN `cpa_cnt` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '计算cpa玩家数量' AFTER `reg_real_sum_money`,
    ADD COLUMN `openid_cnt`  int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '第三方注册数量';
ALTER TABLE `dw_day_agent`
    ADD COLUMN `cpa_cnt` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '计算cpa玩家数量' AFTER `reg_real_sum_money`,
    ADD COLUMN `openid_cnt`  int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '第三方注册数量';
ALTER TABLE `dw_day_game`
    ADD COLUMN `cpa_cnt` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '计算cpa玩家数量' AFTER `reg_real_sum_money`,
    ADD COLUMN `openid_cnt`  int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '第三方注册数量';
ALTER TABLE `dw_day_game_agent`
    ADD COLUMN `cpa_cnt` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '计算cpa玩家数量' AFTER `reg_real_sum_money`,
    ADD COLUMN `openid_cnt`  int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '第三方注册数量';
#########################################################################################
##### 支付方式表修改
#########################################################################################
ALTER TABLE `h_payway`
    MODIFY COLUMN `desc`  varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '描述' AFTER `payname`,
    MODIFY COLUMN `rate`  double(7,4) UNSIGNED NOT NULL DEFAULT 0.0100 COMMENT '通道费率' AFTER `desc`,
    MODIFY COLUMN `realname`  varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '实际名称' AFTER `rate`,
    MODIFY COLUMN `status`  tinyint(4) UNSIGNED NOT NULL DEFAULT 2 COMMENT '状态 1 禁用 2 可用 ' AFTER `realname`,
    MODIFY COLUMN `parent_id`  int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '父ID' AFTER `status`,
    ADD COLUMN `is_config`  tinyint(4) UNSIGNED NOT NULL DEFAULT 1 COMMENT '是否后台配置' AFTER `parent_id`,
    ADD COLUMN `config`  varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '支付配置' AFTER `is_config`;
