##创建费用计提明细表
DROP TABLE IF EXISTS `custody_charge_fee_detail_info`;
CREATE TABLE `custody_charge_fee_detail_info`  (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `fund_code` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '基金备案编码',
  `inner_fund_code` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '基金内部编码',
  `fund_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '基金名称',
  `fee_type` varchar(5) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '费用类型编码',
  `charge_fee` decimal(20, 2) NULL DEFAULT NULL COMMENT '计提金额',
  `fee_balance` decimal(20, 2) NULL DEFAULT NULL COMMENT '费用金额',
  `fee_date` varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '费用的计提时间（固定格式yyyyMMdd）',
  `summary` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '银行摘要',
  `currency` varchar(3) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '币种',
  `trust_no` varchar(2) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '数据字典：托管人',
  `admin` varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '租户名',
  `unique_key` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '唯一索引：用于插入',
  `version` varchar(36) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '版本',
  `remark` varchar(255) 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` varchar(1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '是否删除(有效|0,无效|1)',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `unique_key`(`unique_key`) USING BTREE,
  INDEX `query_key`(`admin`, `fee_type`, `fee_date`, `fee_balance`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 24041 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '费用计提明细表（charge_fee_detail_info）' ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `custody_pay_fee_detail_info`;
CREATE TABLE `custody_pay_fee_detail_info`  (
  `id` int(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `fund_code` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '基金备案编码',
  `inner_fund_code` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '基金内部编码',
  `fund_name` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '基金名称',
  `fee_type` varchar(5) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '费用类型编码',
  `charge_fee` decimal(20, 2) NULL DEFAULT NULL COMMENT '支付金额',
  `fee_balance` decimal(20, 2) NULL DEFAULT NULL COMMENT '费用余额',
  `fee_date` varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '支付日期',
  `summary` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '银行摘要',
  `currency` varchar(3) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '币种',
  `trust_no` varchar(2) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '数据字典：托管人',
  `admin` varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '租户名',
  `unique_key` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '唯一索引：用于插入',
  `version` varchar(36) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '版本',
  `remark` varchar(255) 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` varchar(1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '是否删除(有效|0,无效|1)',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `unique_key`(`unique_key`) USING BTREE,
  INDEX `query_key`(`admin`, `fee_type`, `fee_balance`, `fee_date`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1286 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '费用支付明细表（pay_fee_detail_info）' ROW_FORMAT = Dynamic;

##费用计提明细表权限
INSERT INTO `custody_table_permission`(`id`, `tableName`, `service_name`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (22, 'charge_fee_detail_info', 'chargeFeeDetailInfoService', NULL, '费用计提明细表', '2022-07-20 17:18:07', '2022-07-20 17:18:07', 0);
##费用支付明细表权限
INSERT INTO `custody_table_permission`(`id`, `tableName`, `service_name`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (23, 'pay_fee_detail_info', 'payFeeDetailInfoService', NULL, '费用支付明细表', '2022-07-20 17:18:07', '2022-07-20 17:18:07', 0);

##申万新增费用字典类型
INSERT INTO `custody_data_dictionary_types_of_fee_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (1, '45', '应付管理费', NULL, NULL, '2022-07-22 16:10:53', '2022-07-22 16:10:53', 0);
INSERT INTO `custody_data_dictionary_types_of_fee_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (2, '45', '应付投资顾问费', NULL, NULL, '2022-07-22 16:10:53', '2022-07-22 16:10:53', 0);
INSERT INTO `custody_data_dictionary_types_of_fee_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (3, '45', '应付销售服务费', NULL, NULL, '2022-07-22 16:10:53', '2022-07-22 16:10:53', 0);
INSERT INTO `custody_data_dictionary_types_of_fee_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (4, '45', '应付托管费', NULL, NULL, '2022-07-22 16:10:53', '2022-07-22 16:10:53', 0);
INSERT INTO `custody_data_dictionary_types_of_fee_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (6, '45', '应付业绩报酬', NULL, NULL, '2022-07-22 16:10:53', '2022-07-22 16:10:53', 0);
INSERT INTO `custody_data_dictionary_types_of_fee_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (10, '45', '应付附加税', NULL, NULL, '2022-07-22 16:10:53', '2022-07-22 16:10:53', 0);
INSERT INTO `custody_data_dictionary_types_of_fee_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (11, '45', '应付增值税', NULL, NULL, '2022-07-22 16:10:53', '2022-07-22 16:10:53', 0);
INSERT INTO `custody_data_dictionary_types_of_fee_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (14, '45', '应付运营服务费', NULL, NULL, '2022-07-22 16:10:53', '2022-07-22 16:10:53', 0);