 alter table custody_tenant_email_authorization_info add column purpose varchar(255) after dir_file_path;

 update custody_tenant_email_authorization_info set purpose = 'all' where trust_no = '54' or trust_no = '14' or trust_no = '39' or trust_no = '97' or trust_no = '98';

 alter table custody_tenant_email_authorization_info drop index unique_key;

-- 海通currenty 字典表
delete from  `custody_data_dictionary_duration_currency_details` where trust_no = '21' and origin_value = '156';
delete from  `custody_data_dictionary_duration_currency_details` where trust_no = '21' and origin_value = 'CNY';
delete from  `custody_data_dictionary_duration_currency_details` where trust_no = '21' and origin_value = '250';
delete from  `custody_data_dictionary_duration_currency_details` where trust_no = '21' and origin_value = 'FRF';
delete from  `custody_data_dictionary_duration_currency_details` where trust_no = '21' and origin_value = '280';
delete from  `custody_data_dictionary_duration_currency_details` where trust_no = '21' and origin_value = 'DEM';
delete from  `custody_data_dictionary_duration_currency_details` where trust_no = '21' and origin_value = '344';
delete from  `custody_data_dictionary_duration_currency_details` where trust_no = '21' and origin_value = 'HKD';
delete from  `custody_data_dictionary_duration_currency_details` where trust_no = '21' and origin_value = '392';
delete from  `custody_data_dictionary_duration_currency_details` where trust_no = '21' and origin_value = 'JPY';
delete from  `custody_data_dictionary_duration_currency_details` where trust_no = '21' and origin_value = '826';
delete from  `custody_data_dictionary_duration_currency_details` where trust_no = '21' and origin_value = 'GBP';
delete from  `custody_data_dictionary_duration_currency_details` where trust_no = '21' and origin_value = '840';
delete from  `custody_data_dictionary_duration_currency_details` where trust_no = '21' and origin_value = 'USD';
delete from  `custody_data_dictionary_duration_currency_details` where trust_no = '21' and origin_value = '978';
delete from  `custody_data_dictionary_duration_currency_details` where trust_no = '21' and origin_value = 'EUR';

INSERT INTO `custody_data_dictionary_duration_currency_details` VALUES (null, 1, '21', '156', NULL, NULL, '2022-11-17 09:22:55', '2022-11-17 09:22:57', 0);
INSERT INTO `custody_data_dictionary_duration_currency_details` VALUES (null, 1, '21', 'CNY', NULL, NULL, '2022-11-17 09:23:32', '2022-11-17 09:23:34', 0);
INSERT INTO `custody_data_dictionary_duration_currency_details` VALUES (null, 2, '21', '250', NULL, NULL, '2022-11-17 09:32:04', '2022-11-17 09:32:06', 0);
INSERT INTO `custody_data_dictionary_duration_currency_details` VALUES (null, 2, '21', 'FRF', NULL, NULL, '2022-11-17 09:29:08', '2022-11-17 09:29:11', 0);
INSERT INTO `custody_data_dictionary_duration_currency_details` VALUES (null, 3, '21', '280', NULL, NULL, '2022-11-17 09:29:33', '2022-11-17 09:29:35', 0);
INSERT INTO `custody_data_dictionary_duration_currency_details` VALUES (null, 3, '21', 'DEM', NULL, NULL, '2022-11-17 09:29:51', '2022-11-17 09:29:53', 0);
INSERT INTO `custody_data_dictionary_duration_currency_details` VALUES (null, 4, '21', '344', NULL, NULL, '2022-11-17 09:30:15', '2022-11-17 09:30:18', 0);
INSERT INTO `custody_data_dictionary_duration_currency_details` VALUES (null, 4, '21', 'HKD', NULL, NULL, '2022-11-17 09:30:33', '2022-11-17 09:30:35', 0);
INSERT INTO `custody_data_dictionary_duration_currency_details` VALUES (null, 5, '21', '392', NULL, NULL, '2022-11-17 09:31:02', '2022-11-17 09:31:05', 0);
INSERT INTO `custody_data_dictionary_duration_currency_details` VALUES (null, 5, '21', 'JPY', NULL, NULL, '2022-11-17 09:31:26', '2022-11-17 09:31:28', 0);
INSERT INTO `custody_data_dictionary_duration_currency_details` VALUES (null, 6, '21', '826', NULL, NULL, '2022-11-17 09:32:00', '2022-11-17 09:32:02', 0);
INSERT INTO `custody_data_dictionary_duration_currency_details` VALUES (null, 6, '21', 'GBP', NULL, NULL, '2022-11-17 09:32:25', '2022-11-17 09:32:28', 0);
INSERT INTO `custody_data_dictionary_duration_currency_details` VALUES (null, 7, '21', '840', NULL, NULL, '2022-11-17 09:32:56', '2022-11-17 09:32:58', 0);
INSERT INTO `custody_data_dictionary_duration_currency_details` VALUES (null, 7, '21', 'USD', NULL, NULL, '2022-11-17 09:33:12', '2022-11-17 09:33:14', 0);
INSERT INTO `custody_data_dictionary_duration_currency_details` VALUES (null, 8, '21', '978', NULL, NULL, '2022-11-17 09:33:35', '2022-11-17 09:33:37', 0);
INSERT INTO `custody_data_dictionary_duration_currency_details` VALUES (null, 8, '21', 'EUR', NULL, NULL, '2022-11-17 09:33:50', '2022-11-17 09:33:52', 0);


-- 海通 字典表
delete from  `custody_data_dictionary_payment_direction_details` where trust_no = '21' and origin_value = '1';
delete from  `custody_data_dictionary_payment_direction_details` where trust_no = '21' and origin_value = '-1';
INSERT INTO `custody_data_dictionary_payment_direction_details` VALUES (null, 1, '21', '1', NULL, NULL, '2022-11-17 09:22:55', '2022-11-17 09:22:57', 0);
INSERT INTO `custody_data_dictionary_payment_direction_details` VALUES (null, 2, '21', '-1', NULL, NULL, '2022-11-17 09:22:55', '2022-11-17 09:22:57', 0);

-- 邮件解析估值表
INSERT INTO `custody_tenant_email_authorization_info` VALUES (null, 'P1000869', 'AUTO', 'pop3s', 'pop.qiye.aliyun.com', '995', 'daxindata@v-invest.cn', '2021Yctz', 'wbgz@htsc.com', '私募证券投资基金估值表', NULL, 'fund_value', '34', NULL, '一村_华泰', '2022-11-14 15:01:01', '2022-11-14 15:01:09', 0);
INSERT INTO `custody_tenant_email_authorization_info` VALUES (null, 'P1032800', 'AUTO', 'pop3s', 'pop.qiye.aliyun.com', '995', 'ipodata@tongyigroup.cn', 'Tongyi1234', 'yywbfa@cmschina.com.cn', '【估值表】', NULL, 'fund_value', '25', NULL, '招商-通怡', '2022-11-15 17:17:32', '2022-11-15 17:17:37', 0);

-- 第一创业邮件解析其它表
delete from  `custody_tenant_email_authorization_info` where tenant_name = 'P1002894' and trust_no = '97';
INSERT INTO `custody_tenant_email_authorization_info` VALUES (null, 'P1002894', 'AUTO', 'pop3s', 'pop.exmail.qq.com', '995', 'data@linyuan-invest.com', 'FsmTJgSe36v6rkeS', 'xyyybzxt@fcsc.com', '林园投资_第一创业TA客服文件', '', 'all', '97', NULL, '第一创业_林园', '2022-10-27 14:55:44', '2022-10-27 14:55:47', 0);


-- 删除海通林园的sql
delete from  custody_mj_account_seq_info  where trust_no = '21' and admin = 'P1002894';
delete from  custody_account_info  where trust_no = '21' and admin = 'P1002894';
delete from  custody_account_info  where trust_no = '21' and admin = 'P1002894';
delete from  custody_mj_account_balance_info  where trust_no = '21' and admin = 'P1002894';
delete from  custody_tg_account_seq_info  where trust_no = '21' and admin = 'P1002894';
delete from  custody_tg_account_balance_info  where trust_no = '21' and admin = 'P1002894';

DROP TABLE IF EXISTS `custody_fund_open_info`;
CREATE TABLE `custody_fund_open_info`  (
  `id` int(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `fund_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '基金备案编码',
  `inner_fund_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '基金内部代码',
  `fund_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '基金名称',
  `fund_open_date` varchar(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '开放日期',
  `open_type` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '数据字典：开放状态开放日类型-开放日类型',
  `open_status` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '数据字典：开放状态开放日类型-开放状态  如有多种则用英文逗号隔开',
  `if_fixed_time` int(1) NULL DEFAULT NULL COMMENT '是否固定时点计提报酬日',
  `trust_no` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '数据字典：托管人',
  `admin` varchar(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '租户名',
  `unique_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '唯一索引：用于插入',
  `remark` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `version` varchar(36) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '版本',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  `is_deleted` int(1) NULL DEFAULT 0 COMMENT '是否删除(有效|0,无效|1)',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `unique_key`(`unique_key`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '基金产品开放信息表（fund_open_info）' ROW_FORMAT = Dynamic;
--更新表权限
update custody_table_permission set service_name = 'fundOpenInfoService' , remark = '基金产品开放信息表' where id = '5' and tableName = 'fund_open_info';
--开放日类型数据字典
INSERT INTO `custody_data_dictionary_type_of_open_day`(`id`, `key_str`, `value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (4, '3', '基金分红', NULL, NULL, '2022-11-04 17:11:41', '2022-11-04 17:11:43', 0);


--银河 开放日类型
delete form `custody_data_dictionary_type_of_open_day_details` where trust_no = '45';
INSERT INTO `custody_data_dictionary_type_of_open_day_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (1, '33', '2', NULL, NULL, '2022-11-04 17:12:11', '2022-11-04 17:12:11', 0);
INSERT INTO `custody_data_dictionary_type_of_open_day_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (2, '33', '3', NULL, NULL, '2022-11-04 17:12:11', '2022-11-04 17:12:11', 0);
INSERT INTO `custody_data_dictionary_type_of_open_day_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (4, '33', '4', NULL, NULL, '2022-11-04 17:12:11', '2022-11-04 17:12:11', 0);

--申万 开放日类型
delete from `custody_data_dictionary_type_of_open_day_details` where trust_no = '45';
INSERT INTO `custody_data_dictionary_type_of_open_day_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (1, '45', '0', NULL, NULL, '2022-11-14 23:21:48', '2022-11-14 23:21:48', 0);
INSERT INTO `custody_data_dictionary_type_of_open_day_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (2, '45', '1', NULL, NULL, '2022-11-14 23:21:48', '2022-11-14 23:21:48', 0);

--申万开放状态
delete  from `custody_data_dictionary_open_state_details`where trust_no = '45';
INSERT INTO `custody_data_dictionary_open_state_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (1, '45', '1', NULL, NULL, '2022-11-14 23:26:11', '2022-11-14 23:26:11', 0);
INSERT INTO `custody_data_dictionary_open_state_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (6, '45', '4', NULL, NULL, '2022-11-14 23:26:11', '2022-11-14 23:26:11', 0);
INSERT INTO `custody_data_dictionary_open_state_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (7, '45', '3', NULL, NULL, '2022-11-14 23:26:11', '2022-11-14 23:26:11', 0);
INSERT INTO `custody_data_dictionary_open_state_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (16, '45', '1', NULL, NULL, '2022-11-14 23:26:11', '2022-11-14 23:26:11', 0);
INSERT INTO `custody_data_dictionary_open_state_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (20, '45', '4', NULL, NULL, '2022-11-14 23:26:11', '2022-11-14 23:26:11', 0);
INSERT INTO `custody_data_dictionary_open_state_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (21, '45', '3', NULL, NULL, '2022-11-14 23:26:11', '2022-11-14 23:26:11', 0);

--招商开放日类型
delete from custody_data_dictionary_type_of_open_day_details where trust_no = '25';
INSERT INTO `custody_data_dictionary_type_of_open_day_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (1, '25', '固开(固开申购固开赎回)', NULL, NULL, '2022-03-21 20:02:50', '2022-11-15 09:26:44', 0);
INSERT INTO `custody_data_dictionary_type_of_open_day_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (1, '25', '申购固开', NULL, NULL, '2022-11-15 09:24:39', '2022-11-15 09:24:44', 0);
INSERT INTO `custody_data_dictionary_type_of_open_day_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (1, '25', '赎回固开', NULL, NULL, '2022-11-15 09:26:44', '2022-11-15 09:26:44', 0);
INSERT INTO `custody_data_dictionary_type_of_open_day_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (1, '25', '申购固开赎回临开', NULL, NULL, '2022-11-15 09:26:44', '2022-11-15 09:26:44', 0);
INSERT INTO `custody_data_dictionary_type_of_open_day_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (1, '25', '申购临开赎回固开', NULL, NULL, '2022-11-15 09:26:44', '2022-11-15 09:26:44', 0);
INSERT INTO `custody_data_dictionary_type_of_open_day_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (2, '25', '临开(临开申购临开赎回)', NULL, NULL, '2022-11-15 09:26:44', '2022-11-15 09:26:44', 0);
INSERT INTO `custody_data_dictionary_type_of_open_day_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (2, '25', '申购临开', NULL, NULL, '2022-11-15 09:26:44', '2022-11-15 09:26:44', 0);
INSERT INTO `custody_data_dictionary_type_of_open_day_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (2, '25', '赎回临开', NULL, NULL, '2022-11-15 09:26:44', '2022-11-15 09:26:44', 0);
INSERT INTO `custody_data_dictionary_type_of_open_day_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (3, '25', '申购固开赎回临开', NULL, NULL, '2022-11-15 13:39:49', '2022-11-15 13:39:52', 0);
INSERT INTO `custody_data_dictionary_type_of_open_day_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (3, '25', '申购临开赎回固开', NULL, NULL, '2022-11-15 13:40:05', '2022-11-15 13:40:07', 0);

-- 清理invokeRecord数据
create table custody_invoke_record_new like custody_invoke_record;
insert into custody_invoke_record_new select * from custody_invoke_record where invoke_time > '2022-11-01';
select * from custody_invoke_record_new  order by invoke_time desc;
-- truncate table custody_invoke_record;
-- insert into custody_invoke_record select * from custody_invoke_record_new;
-- drop table custody_invoke_record_new;
