#####    jeeppay-plus S3 代理商模块 版本升级SQL   #####

######   v3.0.0 ===> v3.1.0   ######   START   ######

-- 代理商系统 如意设备菜单
insert into t_sys_entitlement values('ENT_DEVICE_RUYI', '如意Lite', 'file', '/ruyi', 'RuyiPage', 'ML', 0, 1,  'ENT_DEVICE', '60', 'AGENT', null, now(), now());
insert into t_sys_entitlement values('ENT_DEVICE_RUYI_LIST', '页面：列表', 'no-icon', '', '', 'PB', 0, 1,  'ENT_DEVICE_RUYI', '0', 'AGENT', null, now(), now());
insert into t_sys_entitlement values('ENT_DEVICE_RUYI_VIEW', '按钮：详情', 'no-icon', '', '', 'PB', 0, 1,  'ENT_DEVICE_RUYI', '0', 'AGENT', null, now(), now());
insert into t_sys_entitlement values('ENT_DEVICE_RUYI_ADD', '按钮：新增', 'no-icon', '', '', 'PB', 0, 1,  'ENT_DEVICE_RUYI', '0', 'AGENT', null, now(), now());
insert into t_sys_entitlement values('ENT_DEVICE_RUYI_EDIT', '按钮：修改', 'no-icon', '', '', 'PB', 0, 1,  'ENT_DEVICE_RUYI', '0', 'AGENT', null, now(), now());
insert into t_sys_entitlement values('ENT_DEVICE_RUYI_ALLOT', '按钮：划拨/收回', 'no-icon', '', '', 'PB', 0, 1,  'ENT_DEVICE_RUYI', '0', 'AGENT', null, now(), now());

######   v3.1.0 ===> v3.2.0   ######   START   ######

-- 代理商配置表
DROP TABLE IF EXISTS `t_agent_config`;
CREATE TABLE `t_agent_config` (
                                  `agent_no` VARCHAR(64) NOT NULL COMMENT '代理商号',
                                  `config_key` VARCHAR(50) NOT NULL COMMENT '配置KEY',
                                  `config_val` TEXT NOT NULL COMMENT '配置内容项',
                                  `group_key` TEXT NOT NULL COMMENT '配置分组',
                                  `created_at` TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) COMMENT '创建时间',
                                  `updated_at` TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6) COMMENT '更新时间',
                                  PRIMARY KEY (`config_key`, `agent_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='代理商配置表';

-- 代理商进件初始配置项
INSERT INTO `t_sys_config` VALUES ('agentApplymentPreAudit', '代理商进件是否需要运营平台预审核', '代理商进件是否需要运营平台预审核', 'defaultConfig', '进件初始配置', '0', 'text', 0, '2023-3-29 10:53:30');
INSERT INTO `t_sys_config` VALUES ('agentApplyTimeLimit', '代理商发起进件默认时间限制', '代理商发起进件默认时间限制', 'defaultConfig', '进件初始配置', '', 'text', 0, '2023-3-29 10:53:30');
-- 代理商高级配置权限
insert into t_sys_entitlement values('ENT_AGENT_CONFIG_PAGE', '按钮：代理商配置信息', 'no-icon', '', '', 'PB', 0, 1,  'ENT_AGENT_INFO', '0', 'PLATFORM', null, now(), now());

######   v3.3.1 ===> v3.3.2   ######   START   ######

-- 代理商提现结算记录表 申请资料和打款凭证
ALTER TABLE `t_cashout_record` MODIFY COLUMN `sett_cert_img` VARCHAR(256) COMMENT '申请资料';
ALTER TABLE t_cashout_record ADD COLUMN `transfer_cert_img` VARCHAR(256) COMMENT '打款凭证（运营平台）' after `sett_cert_img`;

######   v3.3.2 ===> v3.3.3   ######   START   ######

insert into t_sys_entitlement values('ENT_PROFIT_CASHOUT_RECORD_COUNT', '页面：统计', 'no-icon', '', '', 'PB', 0, 1,  'ENT_PROFIT_CASHOUT_RECORD', '0', 'PLATFORM', null, now(), now());
insert into t_sys_entitlement values('ENT_CASHOUT_RECORD_COUNT', '页面：统计', 'no-icon', '', '', 'PB', 0, 1,  'ENT_AGENT_WALLET', '0', 'AGENT', null, now(), now());
-- 代理商列表
insert into t_sys_entitlement values('ENT_AGENT_INFO_COUNT', '页面：统计', 'no-icon', '', '', 'PB', 0, 1,  'ENT_AGENT_INFO', '0', 'PLATFORM', null, now(), now());

######   v3.3.5 ===> v3.3.6   ######   START   ######

-- 提现记录增加开户行支行名称
ALTER TABLE t_cashout_record ADD COLUMN `sett_account_sub_bank` VARCHAR(32) COMMENT '开户行支行名称' after `sett_account_bank`;

-- 代理商主表增加钱包冻结金额和冻结原因
ALTER TABLE t_agent_info ADD COLUMN `freeze_amount` BIGINT(20) NOT NULL DEFAULT 0 COMMENT '钱包冻结金额, 单位分' after `sipw`;
ALTER TABLE t_agent_info ADD COLUMN `freeze_desc` VARCHAR(256) DEFAULT NULL COMMENT '冻结原因' after `freeze_amount`;

######
v3.3.6 ===> v3.4.0    ######   START   ######

-- 代理商提现增加转账接口信息
alter table `t_cashout_record`
    add column `transfer_mch_app_id` VARCHAR(64) COMMENT '发起转账的自营应用ID' after `sett_type`;
alter table `t_cashout_record`
    add column `transfer_order_id` VARCHAR(64) COMMENT '转账系统订单号' after `transfer_mch_app_id`;
alter table `t_cashout_record`
    add column `transfer_if_code` VARCHAR(64) COMMENT '转账接口类型' after `transfer_order_id`;
alter table `t_cashout_record`
    add column `transfer_platform_mchfee_amount` BIGINT(20) COMMENT '自营商户费率费用' after `transfer_if_code`;
alter table `t_cashout_record`
    add column `transfer_platform_cost_amount` BIGINT(20) COMMENT '平台真实成本费用（ 来自转账订单数据 = 自营商户费率费用 - 平台利润 ）' after `transfer_platform_mchfee_amount`;
alter table `t_cashout_record`
    add column `contact_name` varchar(32) DEFAULT NULL COMMENT '联系人姓名' after `sett_account_telphone`;

######
v3.4.0 ===> v3.4.1  ######   START   ######
-- 订单退款统计权限
insert into t_sys_entitlement values('ENT_REFUND_ORDER_COUNT', '退款统计', 'no-icon', '', '', 'PB', 0, 1,  'ENT_REFUND_ORDER', '0', 'AGENT', null, now(), now());
-- 代理商解除码牌权限
insert into t_sys_entitlement
values ('ENT_DEVICE_QRC_RELIEVE', '按钮：解除', 'no-icon', '', '', 'PB', 0, 1, 'ENT_DEVICE_QRC', '0', 'AGENT', null,
        now(), now());
-- 代理商子商户配置权限
insert into t_sys_entitlement
values ('ENT_MCH_CONFIG_PAGE', '按钮：商户配置信息', 'no-icon', '', '', 'PB', 0, 1, 'ENT_MCH_INFO', '0', 'AGENT', null,
        now(), now());


######
v3.4.1 ===> next    ######   START   ######
