-- 额度支用基础信息
DROP TABLE IF EXISTS `review_quota_disburse`;
CREATE TABLE `review_quota_disburse` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `c_financing_basic_info_id` bigint(20) unsigned DEFAULT '0' COMMENT 'C端融资信息基础Id',
        `approval_conclusion` varchar(50) DEFAULT '' COMMENT '通过pass/否决veto',
        `approval_comments` varchar(3000) DEFAULT '' COMMENT '审批意见',
        `business_number` varchar(50) DEFAULT NULL COMMENT '业务编号',
        `quota_disburse_batch` int(11) DEFAULT NULL COMMENT '额度支用批次',
        `business_credit_balance` decimal(17,2) DEFAULT '0.00' COMMENT '业务综合授信余额',
        `supplier_credit_balance` decimal(17,2) DEFAULT '0.00' COMMENT '供应商授信余额',
        `start_date` datetime DEFAULT NULL COMMENT '应收账款起始日',
        `term` int(4) DEFAULT '0' COMMENT '应收账款期限',
        `end_date` datetime DEFAULT NULL COMMENT '应收账款到期日',
        `accounts_receivable_net_amount_total` decimal(17,2) DEFAULT '0.00' COMMENT '应收账款净额总和',
        `report_method` tinyint(1) DEFAULT NULL COMMENT '账户上报方式 1:A类，0:B类',
        `is_resp_repay` tinyint(1) unsigned DEFAULT '0' COMMENT '有无相关还款责任人：0无、1有',
        `is_mortgage_info` tinyint(1) unsigned DEFAULT '0' COMMENT '有无抵质押：0无、1有',
        `visible` tinyint(1) unsigned DEFAULT '0' COMMENT '是否显示，默认0表示否',
        `plan_irr` float(11,4) DEFAULT '0.0000' COMMENT '预期IRR',
        `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='额度支用';

-- 额度支用基础信息-历史表
DROP TABLE IF EXISTS `review_quota_disburse_his`;
CREATE TABLE `review_quota_disburse_his` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_quota_disburse_id` bigint(20) unsigned DEFAULT '0' COMMENT '额度支用信息Id',
        `approval_conclusion` varchar(50) DEFAULT '' COMMENT '通过pass/否决veto',
        `approval_comments` varchar(3000) DEFAULT '' COMMENT '审批意见',
        `business_number` varchar(50) DEFAULT NULL COMMENT '业务编号',
        `quota_disburse_batch` int(11) DEFAULT NULL COMMENT '额度支用批次',
        `business_credit_balance` decimal(17,2) DEFAULT '0.00' COMMENT '业务综合授信余额',
        `supplier_credit_balance` decimal(17,2) DEFAULT '0.00' COMMENT '供应商授信余额',
        `start_date` datetime DEFAULT NULL COMMENT '应收账款起始日',
        `term` int(4) DEFAULT '0' COMMENT '应收账款期限',
        `end_date` datetime DEFAULT NULL COMMENT '应收账款到期日',
        `accounts_receivable_net_amount_total` decimal(17,2) DEFAULT '0.00' COMMENT '应收账款净额总和',
        `report_method` tinyint(1) DEFAULT NULL COMMENT '账户上报方式 1:A类，0:B类',
        `is_resp_repay` tinyint(1) unsigned DEFAULT '0' COMMENT '有无相关还款责任人：0无、1有',
        `is_mortgage_info` tinyint(1) unsigned DEFAULT '0' COMMENT '有无抵质押：0无、1有',
        `plan_irr` float(11,4) DEFAULT '0.0000' COMMENT '预期IRR',
        `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
         PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='额度支用';

-- 额度支用-融资信息
DROP TABLE IF EXISTS `review_financing_info`;
CREATE TABLE `review_financing_info` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_quota_disburse_id` bigint(20) unsigned DEFAULT '0' COMMENT '额度支用的ID',
        `financing_amount` decimal(17,2) DEFAULT '0.00' COMMENT '融资金额',
        `financing_rate` float(5,4) DEFAULT '0.0000' COMMENT '融资利率(年化)',
        `financing_ratio` float(5,4) DEFAULT '0.0000' COMMENT '融资比例',
        `financing_period` int(11) DEFAULT '0' COMMENT '融资期限',
        `starting_date_type` varchar(50) DEFAULT '' COMMENT '起算日类别:自保理融资款实际投放之日(plan_day)、明确日期(clear_day)',
        `starting_date` datetime DEFAULT NULL COMMENT '起算日：包含预计投放日、明确日期',
        `comprehensive_quotation` float(5,4) DEFAULT '0.0000' COMMENT '对外综合报价',
        `overdue_interest_rate` float(5,4) DEFAULT '0.0000' COMMENT '逾期利率',
        `management_fee_ratio` float(5,4) DEFAULT '0.0000' COMMENT '管理费率(年化)',
        `margin_ratio` float(5,4) DEFAULT '0.0000' COMMENT '保证金比例',
        `repayment_method` varchar(200) DEFAULT '' COMMENT '回款方式',
        `financing_interest` decimal(30,2) DEFAULT '0.00' COMMENT '融资利息',
        `management_fee_amount` decimal(30,2) DEFAULT '0.00' COMMENT '管理费金额',
        `margin_amount` decimal(30,2) DEFAULT '0.00' COMMENT '保证金金额',
        `other_fee_amount` decimal(30,2) DEFAULT '0.00' COMMENT '其他费用金额',
        `transfer_notice_method` varchar(200) DEFAULT '' COMMENT '转让通知方式,多选用“_”隔开',
        `service_scope` varchar(200) DEFAULT '' COMMENT '服务范围,多选用“_”隔开',
        `is_occupation` tinyint(3) DEFAULT NULL COMMENT '是否占用公司金额 1:是，0:否',
        `is_risk` tinyint(3) DEFAULT NULL COMMENT '是否公司承险 1:是，0:否',
        `repayment_adjustment` varchar(200) DEFAULT '' COMMENT '还款期限调整方式',
        `pay_back_method` varchar(200) DEFAULT '' COMMENT '还款方式',
        `institution_name` varchar(200) DEFAULT '' COMMENT '出资方名称',
        `prepayment_interest_calculate` varchar(200) DEFAULT '' COMMENT '提前回款利息计算方式',
        `is_interest_calculate` tinyint(1) DEFAULT NULL COMMENT '利息是否计算投放日，1:是,0:否',
        `currency_code` varchar(200) DEFAULT '' COMMENT '币种',
        `exchange_rate` decimal(17,2) DEFAULT '0.00' COMMENT '汇率',
        `bad_debt_guarantee_rate` float(5,4) DEFAULT '0.0000' COMMENT '坏账担保比例',
        `business_type` bigint(20) DEFAULT NULL COMMENT '业务类型',
        `account_name` varchar(200) DEFAULT NULL COMMENT '账号名称',
        `disburse_expiry_date` datetime DEFAULT NULL COMMENT '支用到期日',
        `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='额度支用-融资信息';

-- 额度支用-融资信息历史信息
DROP TABLE IF EXISTS `review_financing_info_his`;
CREATE TABLE `review_financing_info_his` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_quota_disburse_his_id` bigint(20) unsigned DEFAULT '0' COMMENT '额度支用历史信息Id',
        `financing_amount` decimal(17,2) DEFAULT '0.00' COMMENT '融资金额',
        `financing_rate` float(5,4) DEFAULT '0.0000' COMMENT '融资利率(年化)',
        `financing_ratio` float(5,4) DEFAULT '0.0000' COMMENT '融资比例',
        `financing_period` int(11) DEFAULT '0' COMMENT '融资期限',
        `starting_date_type` varchar(50) DEFAULT '' COMMENT '起算日类别:自保理融资款实际投放之日(plan_day)、明确日期(clear_day)',
        `starting_date` datetime DEFAULT NULL COMMENT '起算日：包含预计投放日、明确日期',
        `comprehensive_quotation` float(5,4) DEFAULT '0.0000' COMMENT '对外综合报价',
        `overdue_interest_rate` float(5,4) DEFAULT '0.0000' COMMENT '逾期利率',
        `management_fee_ratio` float(5,4) DEFAULT '0.0000' COMMENT '管理费率(年化)',
        `margin_ratio` float(5,4) DEFAULT '0.0000' COMMENT '保证金比例',
        `repayment_method` varchar(200) DEFAULT '' COMMENT '回款方式',
        `financing_interest` decimal(30,2) DEFAULT '0.00' COMMENT '融资利息',
        `management_fee_amount` decimal(30,2) DEFAULT '0.00' COMMENT '管理费金额',
        `margin_amount` decimal(30,2) DEFAULT '0.00' COMMENT '保证金金额',
        `other_fee_amount` decimal(30,2) DEFAULT '0.00' COMMENT '其他费用金额',
        `transfer_notice_method` varchar(200) DEFAULT '' COMMENT '转让通知方式,多选用“_”隔开',
        `service_scope` varchar(200) DEFAULT '' COMMENT '服务范围,多选用“_”隔开',
        `is_occupation` tinyint(3) DEFAULT NULL COMMENT '是否占用公司金额 1:是，0:否',
        `is_risk` tinyint(3) DEFAULT NULL COMMENT '是否公司承险 1:是，0:否',
        `repayment_adjustment` varchar(200) DEFAULT '' COMMENT '还款期限调整方式',
        `pay_back_method` varchar(200) DEFAULT '' COMMENT '还款方式',
        `institution_name` varchar(200) DEFAULT '' COMMENT '出资方名称',
        `prepayment_interest_calculate` varchar(200) DEFAULT '' COMMENT '提前回款利息计算方式',
        `is_interest_calculate` tinyint(1) DEFAULT NULL COMMENT '利息是否计算投放日，1:是,0:否',
        `currency_code` varchar(200) DEFAULT '' COMMENT '币种',
        `exchange_rate` decimal(17,2) DEFAULT '0.00' COMMENT '汇率',
        `bad_debt_guarantee_rate` float(5,4) DEFAULT '0.0000' COMMENT '坏账担保比例',
        `business_type` bigint(20) DEFAULT NULL COMMENT '业务类型',
        `account_name` varchar(200) DEFAULT NULL COMMENT '账号名称',
        `disburse_expiry_date` datetime DEFAULT NULL COMMENT '支用到期日',
        `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='额度支用-融资信息-历史表';

-- 额度支用-收支计划
DROP TABLE IF EXISTS `review_income_expenditure_plan`;
CREATE TABLE `review_income_expenditure_plan` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_quota_disburse_id` bigint(20) unsigned DEFAULT '0' COMMENT '额度支用的ID',
        `income_expenditure_date` datetime DEFAULT NULL COMMENT '收支日期',
        `income_expenditure_type` varchar(50) DEFAULT '' COMMENT '收支类型',
        `receivables` decimal(17,2) DEFAULT NULL COMMENT '收款',
        `loan` decimal(17,2) DEFAULT NULL COMMENT '放款',
        `final_cash_flow` decimal(17,2) DEFAULT '0.00' COMMENT '最终现金流',
        `receiving_subject` varchar(50) DEFAULT '' COMMENT '收款主体:债权人creditor、债务人debtor',
        `record_no` tinyint(3) unsigned DEFAULT '0' COMMENT '序号',
        `currency_code` varchar(50) DEFAULT '' COMMENT '币种',
        `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='额度支用-收支计划';

-- 额度支用-收支计划-历史表
DROP TABLE IF EXISTS `review_income_expenditure_plan_his`;
CREATE TABLE `review_income_expenditure_plan_his` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_quota_disburse_his_id` bigint(20) unsigned DEFAULT '0' COMMENT '额度支用历史信息Id',
        `income_expenditure_date` datetime DEFAULT NULL COMMENT '收支日期',
        `income_expenditure_type` varchar(50) DEFAULT '' COMMENT '收支类型',
        `receivables` decimal(17,2) DEFAULT NULL COMMENT '收款',
        `loan` decimal(17,2) DEFAULT NULL COMMENT '放款',
        `final_cash_flow` decimal(17,2) DEFAULT '0.00' COMMENT '最终现金流',
        `receiving_subject` varchar(50) DEFAULT '' COMMENT '收款主体:债权人creditor、债务人debtor',
        `record_no` tinyint(3) unsigned DEFAULT '0' COMMENT '序号',
        `currency_code` varchar(50) DEFAULT '' COMMENT '币种',
        `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='额度支用-收支计划-历史表';

-- 额度支用-主合同信息
DROP TABLE IF EXISTS `review_master_contract`;
CREATE TABLE `review_master_contract` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_quota_disburse_id` bigint(20) unsigned DEFAULT '0' COMMENT '额度支用的ID',
        `contract_name` varchar(50) DEFAULT '' COMMENT '合同名称',
        `contract_no` varchar(50) DEFAULT '' COMMENT '合同编号',
        `factoring_name` varchar(50) DEFAULT '' COMMENT '保理商名称',
        `factoring_social_credit_code` varchar(18) DEFAULT '' COMMENT '保理商统一社会信用码',
        `factoring_address` varchar(50) DEFAULT '' COMMENT '保理商注册地址',
        `factoring_legal_person` varchar(50) DEFAULT '' COMMENT '保理商法人',
        `applicant_social_credit_code` varchar(20) DEFAULT '' COMMENT '保理申请人统一社会信用码',
        `applicant_contact` varchar(50) DEFAULT '' COMMENT '保理申请人联系人',
        `applicant_contact_number` varchar(50) DEFAULT '' COMMENT '保理申请人联系电话',
        `applicant_company_name` varchar(100) DEFAULT '' COMMENT '保理申请人公司名称',
        `applicant_company_address` varchar(500) DEFAULT '' COMMENT '保理申请人公司注册地址',
        `applicant_company_legal_person` varchar(500) DEFAULT '' COMMENT '保理申请人公司法人',
        `factoring_account_name` varchar(500) DEFAULT '' COMMENT '保理专户户名',
        `factoring_account` varchar(500) DEFAULT '' COMMENT '保理专户账户',
        `factoring_account_bank` varchar(500) DEFAULT '' COMMENT '保理专户开户行',
        `our_account_name` varchar(500) DEFAULT '' COMMENT '我司指定账户户名',
        `our_account` varchar(500) DEFAULT '' COMMENT '我司指定账户',
        `our_account_bank` varchar(500) DEFAULT '' COMMENT '我司指定账户开户行',
        `applicant_designated_account_name` varchar(500) DEFAULT '' COMMENT '保理申请人指定账户户名',
        `applicant_designated_account` varchar(500) DEFAULT '' COMMENT '保理申请人指定账户',
        `applicant_designated_bank` varchar(500) DEFAULT '' COMMENT '保理申请人指定账户开户行',
        `pool_factoring_financing_confirm_no` varchar(100) DEFAULT '' COMMENT '池保理融资确认书编号',
        `factoring_id` bigint(20) unsigned DEFAULT '0' COMMENT '保理商id',
        `applicant_company_id` bigint(20) unsigned DEFAULT '0' COMMENT '保理申请人公司id',
        `factoring_account_name2` varchar(500) DEFAULT '' COMMENT '保理专户户名2',
        `factoring_account2` varchar(500) DEFAULT '' COMMENT '保理专户账户2',
        `factoring_account_bank2` varchar(500) DEFAULT '' COMMENT '保理专户开户行2',
        `applicant_email` varchar(50) DEFAULT '' COMMENT '保理申请人邮箱',
        `factoring_agent_name` varchar(100) DEFAULT NULL COMMENT '保理商联系人',
        `factoring_agent_phone` varchar(100) DEFAULT NULL COMMENT '保理商联系人电话',
        `factoring_agent_email` varchar(100) DEFAULT NULL COMMENT '保理商联系人邮箱',
        `double_factoring_type` bigint(20) unsigned DEFAULT '0' COMMENT '是否双保理： 0：否 1：是',
        `platform_name` varchar(100) DEFAULT NULL COMMENT '贸易平台名称',
        `platform_id` bigint(20) unsigned DEFAULT '0' COMMENT '贸易平台id',
        `platform_legal` varchar(100) DEFAULT NULL COMMENT '贸易平台法定代表人',
        `platform_address` varchar(100) DEFAULT NULL COMMENT '贸易平台注册地址',
        `platform_contact` varchar(100) DEFAULT NULL COMMENT '贸易平台联系人',
        `platform_contact_phone` varchar(100) DEFAULT NULL COMMENT '贸易平台联系人电话',
        `platform_contact_email` varchar(100) DEFAULT NULL COMMENT '贸易平台联系人邮箱',
        `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='额度支用-主合同信息';

-- 额度支用-主合同信息-历史表
DROP TABLE IF EXISTS `review_master_contract_his`;
CREATE TABLE `review_master_contract_his` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_quota_disburse_his_id` bigint(20) unsigned DEFAULT '0' COMMENT '额度支用历史信息Id',
        `contract_name` varchar(50) DEFAULT '' COMMENT '合同名称',
        `contract_no` varchar(50) DEFAULT '' COMMENT '合同编号',
        `factoring_name` varchar(50) DEFAULT '' COMMENT '保理商名称',
        `factoring_social_credit_code` varchar(18) DEFAULT '' COMMENT '保理商统一社会信用码',
        `factoring_address` varchar(50) DEFAULT '' COMMENT '保理商注册地址',
        `factoring_legal_person` varchar(50) DEFAULT '' COMMENT '保理商法人',
        `applicant_social_credit_code` varchar(20) DEFAULT '' COMMENT '保理申请人统一社会信用码',
        `applicant_contact` varchar(50) DEFAULT '' COMMENT '保理申请人联系人',
        `applicant_contact_number` varchar(50) DEFAULT '' COMMENT '保理申请人联系电话',
        `applicant_company_name` varchar(100) DEFAULT '' COMMENT '保理申请人公司名称',
        `applicant_company_address` varchar(500) DEFAULT '' COMMENT '保理申请人公司注册地址',
        `applicant_company_legal_person` varchar(500) DEFAULT '' COMMENT '保理申请人公司法人',
        `factoring_account_name` varchar(500) DEFAULT '' COMMENT '保理专户户名',
        `factoring_account` varchar(500) DEFAULT '' COMMENT '保理专户账户',
        `factoring_account_bank` varchar(500) DEFAULT '' COMMENT '保理专户开户行',
        `our_account_name` varchar(500) DEFAULT '' COMMENT '我司指定账户户名',
        `our_account` varchar(500) DEFAULT '' COMMENT '我司指定账户',
        `our_account_bank` varchar(500) DEFAULT '' COMMENT '我司指定账户开户行',
        `applicant_designated_account_name` varchar(500) DEFAULT '' COMMENT '保理申请人指定账户户名',
        `applicant_designated_account` varchar(500) DEFAULT '' COMMENT '保理申请人指定账户',
        `applicant_designated_bank` varchar(500) DEFAULT '' COMMENT '保理申请人指定账户开户行',
        `pool_factoring_financing_confirm_no` varchar(100) DEFAULT '' COMMENT '池保理融资确认书编号',
        `factoring_id` bigint(20) unsigned DEFAULT '0' COMMENT '保理商id',
        `applicant_company_id` bigint(20) unsigned DEFAULT '0' COMMENT '保理申请人公司id',
        `factoring_account_name2` varchar(500) DEFAULT '' COMMENT '保理专户户名2',
        `factoring_account2` varchar(500) DEFAULT '' COMMENT '保理专户账户2',
        `factoring_account_bank2` varchar(500) DEFAULT '' COMMENT '保理专户开户行2',
        `applicant_email` varchar(50) DEFAULT '' COMMENT '保理申请人邮箱',
        `factoring_agent_name` varchar(100) DEFAULT NULL COMMENT '保理商联系人',
        `factoring_agent_phone` varchar(100) DEFAULT NULL COMMENT '保理商联系人电话',
        `factoring_agent_email` varchar(100) DEFAULT NULL COMMENT '保理商联系人邮箱',
        `double_factoring_type` bigint(20) unsigned DEFAULT '0' COMMENT '是否双保理： 0：否 1：是',
        `platform_name` varchar(100) DEFAULT NULL COMMENT '贸易平台名称',
        `platform_id` bigint(20) unsigned DEFAULT '0' COMMENT '贸易平台id',
        `platform_legal` varchar(100) DEFAULT NULL COMMENT '贸易平台法定代表人',
        `platform_address` varchar(100) DEFAULT NULL COMMENT '贸易平台注册地址',
        `platform_contact` varchar(100) DEFAULT NULL COMMENT '贸易平台联系人',
        `platform_contact_phone` varchar(100) DEFAULT NULL COMMENT '贸易平台联系人电话',
        `platform_contact_email` varchar(100) DEFAULT NULL COMMENT '贸易平台联系人邮箱',
        `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='额度支用-主合同信息';

-- 额度支用-主合同信息债务人信息
DROP TABLE IF EXISTS `review_master_contract_debtor`;
CREATE TABLE `review_master_contract_debtor` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_master_contract_id` bigint(20) unsigned DEFAULT '0' COMMENT '主合同的ID',
        `company_id` bigint(20) unsigned DEFAULT '0' COMMENT '债务人公司ID',
        `contact` varchar(50) DEFAULT '' COMMENT '债务人联系人',
        `contact_number` varchar(50) DEFAULT '' COMMENT '债务人联系电话',
        `company_name` varchar(100) DEFAULT '' COMMENT '债务人公司名称',
        `address` varchar(500) DEFAULT '' COMMENT '债务人公司注册地址',
        `email` varchar(50) DEFAULT '' COMMENT '债务人邮箱',
        `legal_person` varchar(100) DEFAULT '' COMMENT '债务人公司法人',
        `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='额度支用-主合同信息债务人信息';

-- 额度支用-主合同信息债务人信息-历史表
DROP TABLE IF EXISTS `review_master_contract_debtor_his`;
CREATE TABLE `review_master_contract_debtor_his` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_master_contract_his_id` bigint(20) unsigned DEFAULT '0' COMMENT '主合同信息历史表ID',
        `company_id` bigint(20) unsigned DEFAULT '0' COMMENT '债务人公司ID',
        `contact` varchar(50) DEFAULT '' COMMENT '债务人联系人',
        `contact_number` varchar(50) DEFAULT '' COMMENT '债务人联系电话',
        `company_name` varchar(100) DEFAULT '' COMMENT '债务人公司名称',
        `address` varchar(500) DEFAULT '' COMMENT '债务人公司注册地址',
        `email` varchar(50) DEFAULT '' COMMENT '债务人邮箱',
        `legal_person` varchar(100) DEFAULT '' COMMENT '债务人公司法人',
        `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='额度支用-主合同信息债务人信息';

-- 额度支用-相关还款责任人
DROP TABLE IF EXISTS `review_rlt_repay`;
CREATE TABLE `review_rlt_repay` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_quota_disburse_id` bigint(20) unsigned DEFAULT '0' COMMENT '额度支用的ID',
        `arlp_id_type` varchar(50) DEFAULT '' COMMENT '身份类别',
        `arlp_name` varchar(80) DEFAULT '' COMMENT '责任人名称',
        `arlp_cert_type` varchar(50) DEFAULT '' COMMENT '责任人身份标识类型',
        `nationality` varchar(50) DEFAULT '' COMMENT '国别代码',
        `arlp_cert_num` varchar(40) DEFAULT '' COMMENT '责任人身份标识号码',
        `responsible_phone` varchar(25) DEFAULT '' COMMENT '联系方式',
        `responsible_email` varchar(50) DEFAULT '' COMMENT '邮箱',
        `responsible_report_method` tinyint(1) DEFAULT NULL COMMENT '上报方式 1:A类，0:B类',
        `arlp_type` varchar(50) DEFAULT '' COMMENT '还款责任人类型',
        `arlp_amt` varchar(15) DEFAULT NULL COMMENT '还款责任金额',
        `warty_sign` tinyint(1) DEFAULT NULL COMMENT '联保标志 0:单人保证/多人分保,1:联保',
        `max_guar_mcc` varchar(46) DEFAULT '' COMMENT '保证合同标识码',
        `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        `guarantee_object` varchar(50) DEFAULT NULL COMMENT '担保对象,01 债权人 02债务人',
        `guarantee_object_id` bigint(20) DEFAULT NULL COMMENT '债权人id/债务人id',
        `guarantee_object_name` varchar(50) DEFAULT NULL COMMENT '债权人name/债务人name',
        `address` varchar(500) DEFAULT NULL COMMENT '住所地（身份证地址）',
        `actual_address` varchar(500) DEFAULT NULL COMMENT '实际地址（实际地址）',
        `guarantee_card_front_file_storage_id` bigint(20) unsigned DEFAULT NULL COMMENT '担保人证照正面',
        `guarantee_card_reverse_file_storage_id` bigint(20) unsigned DEFAULT NULL COMMENT '担保人证照反面',
        `spouse_name` varchar(50) DEFAULT '' COMMENT '担保人配偶',
        `spouse_card_type` varchar(50) DEFAULT '' COMMENT '配偶证件类型',
        `spouse_id_card` varchar(18) DEFAULT '' COMMENT '配偶身份证号码',
        `spouse_contact_number` varchar(50) DEFAULT '' COMMENT '配偶联系方式',
        `spouse_card_front_file_storage_id` bigint(20) unsigned DEFAULT NULL COMMENT '配偶证照正面',
        `spouse_card_reverse_file_storage_id` bigint(20) unsigned DEFAULT NULL COMMENT '配偶证照反面',
        `legal_representative` varchar(50) DEFAULT '' COMMENT '法定代表人',
        `is_property_list` tinyint(3) unsigned DEFAULT '0' COMMENT '是否有资产清单 0否，1有',
        `guarantee_classify` tinyint(1) DEFAULT NULL COMMENT '担保函类型： 1：最高额保证合同 0：常规担保函',
        `guarantee_contract_no` varchar(50) DEFAULT '' COMMENT '原保证合同编号',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='额度支用-相关还款责任人表';

-- 额度支用-相关还款责任人-历史表
DROP TABLE IF EXISTS `review_rlt_repay_his`;
CREATE TABLE `review_rlt_repay_his` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_quota_disburse_his_id` bigint(20) unsigned DEFAULT '0' COMMENT '额度支用历史信息Id',
        `arlp_id_type` varchar(50) DEFAULT '' COMMENT '身份类别',
        `arlp_name` varchar(80) DEFAULT '' COMMENT '责任人名称',
        `arlp_cert_type` varchar(50) DEFAULT '' COMMENT '责任人身份标识类型',
        `nationality` varchar(50) DEFAULT '' COMMENT '国别代码',
        `arlp_cert_num` varchar(40) DEFAULT '' COMMENT '责任人身份标识号码',
        `responsible_phone` varchar(25) DEFAULT '' COMMENT '联系方式',
        `responsible_email` varchar(50) DEFAULT '' COMMENT '邮箱',
        `responsible_report_method` tinyint(1) DEFAULT NULL COMMENT '上报方式 1:A类，0:B类',
        `arlp_type` varchar(50) DEFAULT '' COMMENT '还款责任人类型',
        `arlp_amt` varchar(15) DEFAULT NULL COMMENT '还款责任金额',
        `warty_sign` tinyint(1) DEFAULT NULL COMMENT '联保标志 0:单人保证/多人分保,1:联保',
        `max_guar_mcc` varchar(46) DEFAULT '' COMMENT '保证合同标识码',
        `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        `guarantee_object` varchar(50) DEFAULT NULL COMMENT '担保对象,01 债权人 02债务人',
        `guarantee_object_id` bigint(20) DEFAULT NULL COMMENT '债权人id/债务人id',
        `guarantee_object_name` varchar(50) DEFAULT NULL COMMENT '债权人name/债务人name',
        `address` varchar(500) DEFAULT NULL COMMENT '住所地（身份证地址）',
        `actual_address` varchar(500) DEFAULT NULL COMMENT '实际地址（实际地址）',
        `guarantee_card_front_file_storage_id` bigint(20) unsigned DEFAULT NULL COMMENT '担保人证照正面',
        `guarantee_card_reverse_file_storage_id` bigint(20) unsigned DEFAULT NULL COMMENT '担保人证照反面',
        `spouse_name` varchar(50) DEFAULT '' COMMENT '担保人配偶',
        `spouse_card_type` varchar(50) DEFAULT '' COMMENT '配偶证件类型',
        `spouse_id_card` varchar(18) DEFAULT '' COMMENT '配偶身份证号码',
        `spouse_contact_number` varchar(50) DEFAULT '' COMMENT '配偶联系方式',
        `spouse_card_front_file_storage_id` bigint(20) unsigned DEFAULT NULL COMMENT '配偶证照正面',
        `spouse_card_reverse_file_storage_id` bigint(20) unsigned DEFAULT NULL COMMENT '配偶证照反面',
        `legal_representative` varchar(50) DEFAULT '' COMMENT '法定代表人',
        `is_property_list` tinyint(3) unsigned DEFAULT '0' COMMENT '是否有资产清单 0否，1有',
        `guarantee_classify` tinyint(1) DEFAULT NULL COMMENT '担保函类型： 1：最高额保证合同 0：常规担保函',
        `guarantee_contract_no` varchar(50) DEFAULT '' COMMENT '原保证合同编号',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='额度支用-相关还款责任人-历史表';

-- 额度支用-担保类信息附件关联表
DROP TABLE IF EXISTS `review_guarantee_file`;
CREATE TABLE `review_guarantee_file` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `guarantee_id` bigint(20) unsigned DEFAULT '0' COMMENT '担保类信息ID：保证信息的ID、动产抵押信息的ID、股权质押信息的ID',
        `file_id` bigint(20) unsigned DEFAULT '0' COMMENT '附件的ID',
        `guarantee_file_type` varchar(50) DEFAULT '' COMMENT '担保类附件类型：保证信息guaranteeInfo、动产抵押信息chattelMortgage、股权质押信息pledgeInformation',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='额度支用-担保类信息附件关联表';

-- 额度支用-担保类信息附件关联历史表
DROP TABLE IF EXISTS `review_guarantee_file_his`;
CREATE TABLE `review_guarantee_file_his` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `guarantee_id` bigint(20) unsigned DEFAULT '0' COMMENT '担保类信息ID：保证信息的ID、动产抵押信息的ID、股权质押信息的ID',
        `file_id` bigint(20) unsigned DEFAULT '0' COMMENT '附件的ID',
        `guarantee_file_type` varchar(50) DEFAULT '' COMMENT '担保类附件类型：保证信息guaranteeInfo、动产抵押信息chattelMortgage、股权质押信息pledgeInformation',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT ='额度支用-担保类信息附件关联历史表';


-- 额度支用-相关还款责任人:股权资产表
DROP TABLE IF EXISTS `review_rlt_repay_equity_assets`;
CREATE TABLE `review_rlt_repay_equity_assets` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_rlt_repay_id` bigint(20) unsigned DEFAULT '0' COMMENT '相关还款责任人的ID',
        `company_name` varchar(50)  DEFAULT '' COMMENT '被投资企业名称',
        `registered_capital` decimal(17,2) DEFAULT '0.00' COMMENT '注册资金',
        `investment_date` datetime DEFAULT NULL COMMENT '投资日期',
        `ratio` decimal(5,4) DEFAULT '0.0000' COMMENT '出资比例',
        `investment_amount` decimal(17,2) DEFAULT '0.00' COMMENT '实物/现金出资',
        `position` varchar(50)  DEFAULT '0' COMMENT '所任职务',
        `is_report` varchar(50)  DEFAULT '0' COMMENT '有无验收报告 0否，1有',
        `user_create` varchar(50)  DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(50)  DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT ='相关还款责任人:股权资产';

-- 额度支用-相关还款责任人:股权资产历史表
DROP TABLE IF EXISTS `review_rlt_repay_equity_assets_history`;
CREATE TABLE `review_rlt_repay_equity_assets_history` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_rlt_repay_id` bigint(20) unsigned DEFAULT '0' COMMENT '相关还款责任人的ID',
        `company_name` varchar(50)  DEFAULT '' COMMENT '被投资企业名称',
        `registered_capital` decimal(17,2) DEFAULT '0.00' COMMENT '注册资金',
        `investment_date` datetime DEFAULT NULL COMMENT '投资日期',
        `ratio` decimal(5,4) DEFAULT '0.0000' COMMENT '出资比例',
        `investment_amount` decimal(17,2) DEFAULT '0.00' COMMENT '实物/现金出资',
        `position` varchar(50)  DEFAULT '0' COMMENT '所任职务',
        `is_report` varchar(50)  DEFAULT '0' COMMENT '有无验收报告 0否，1有',
        `user_create` varchar(50)  DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(50)  DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT ='相关还款责任人:股权资产历史表';

-- 额度支用-相关还款责任人:不动产(房产)
DROP TABLE IF EXISTS `review_rlt_repay_estate`;
CREATE TABLE `review_rlt_repay_estate` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_rlt_repay_id` bigint(20) unsigned DEFAULT '0' COMMENT '相关还款责任人的ID',
        `house_address_door_number` varchar(500)  DEFAULT '' COMMENT '房产地址及门号',
        `purchase_contract` varchar(50)  DEFAULT '' COMMENT '购买合同',
        `house_property_no` varchar(50)  DEFAULT '' COMMENT '房产证号',
        `is_loan` tinyint(3) unsigned DEFAULT '0' COMMENT '是否有贷款 0否，1有',
        `loan_balance` decimal(17,2) DEFAULT '0.00' COMMENT '贷款余额',
        `is_rent` tinyint(3) unsigned DEFAULT '0' COMMENT '是否出租，0否，1是',
        `user_create` varchar(50)  DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(50)  DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT ='相关还款责任人:不动产(房产)';

-- 额度支用-相关还款责任人:不动产(房产)历史
DROP TABLE IF EXISTS `review_rlt_repay_estate_history`;
CREATE TABLE `review_rlt_repay_estate_history` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_rlt_repay_id` bigint(20) unsigned DEFAULT '0' COMMENT '相关还款责任人的ID',
        `house_address_door_number` varchar(500)  DEFAULT '' COMMENT '房产地址及门号',
        `purchase_contract` varchar(50)  DEFAULT '' COMMENT '购买合同',
        `house_property_no` varchar(50)  DEFAULT '' COMMENT '房产证号',
        `is_loan` tinyint(3) unsigned DEFAULT '0' COMMENT '是否有贷款 0否，1有',
        `loan_balance` decimal(17,2) DEFAULT '0.00' COMMENT '贷款余额',
        `is_rent` tinyint(3) unsigned DEFAULT '0' COMMENT '是否出租，0否，1是',
        `user_create` varchar(50)  DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(50)  DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT ='相关还款责任人:不动产(房产)历史表';

-- 额度支用-相关还款责任人:不动产(土地)
DROP TABLE IF EXISTS `review_rlt_repay_land`;
CREATE TABLE `review_rlt_repay_land` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_rlt_repay_id` bigint(20) unsigned DEFAULT '0' COMMENT '相关还款责任人的ID',
        `location` varchar(50)  DEFAULT '' COMMENT '具体位置',
        `land_no` varchar(50)  DEFAULT '' COMMENT '土地证号或土地租地合同',
        `original_book_value` varchar(50)  DEFAULT '' COMMENT '账面原值',
        `area` varchar(50)  DEFAULT '' COMMENT '面积',
        `land_nature` varchar(50)  DEFAULT '' COMMENT '土地性质',
        `mortgage_installment` varchar(50)  DEFAULT '' COMMENT '抵押/按揭:抵押mortgage，按揭installment',
        `reamrk` varchar(50)  DEFAULT '' COMMENT '状况描述',
        `user_create` varchar(50)  DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(50)  DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT ='相关还款责任人:不动产(土地)';

-- 额度支用-相关还款责任人:不动产(土地)历史
DROP TABLE IF EXISTS `review_rlt_repay_land_history`;
CREATE TABLE `review_rlt_repay_land_history` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_rlt_repay_id` bigint(20) unsigned DEFAULT '0' COMMENT '相关还款责任人的ID',
        `location` varchar(50)  DEFAULT '' COMMENT '具体位置',
        `land_no` varchar(50)  DEFAULT '' COMMENT '土地证号或土地租地合同',
        `original_book_value` varchar(50)  DEFAULT '' COMMENT '账面原值',
        `area` varchar(50)  DEFAULT '' COMMENT '面积',
        `land_nature` varchar(50)  DEFAULT '' COMMENT '土地性质',
        `mortgage_installment` varchar(50)  DEFAULT '' COMMENT '抵押/按揭:抵押mortgage，按揭installment',
        `reamrk` varchar(50)  DEFAULT '' COMMENT '状况描述',
        `user_create` varchar(50)  DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(50)  DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT ='相关还款责任人:不动产(土地)历史表';

-- 额度支用-相关还款责任人:其他资产
DROP TABLE IF EXISTS `review_rlt_repay_other_assets`;
CREATE TABLE `review_rlt_repay_other_assets` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_rlt_repay_id` bigint(20) unsigned DEFAULT '0' COMMENT '相关还款责任人的ID',
        `other_assets` varchar(100)  DEFAULT '' COMMENT '被投资企业名称',
        `user_create` varchar(50)  DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(50)  DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT = '相关还款责任人:其他资产';

-- 额度支用-相关还款责任人:其他资产历史
DROP TABLE IF EXISTS `review_rlt_repay_other_assets_history`;
CREATE TABLE `review_rlt_repay_other_assets_history` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_rlt_repay_id` bigint(20) unsigned DEFAULT '0' COMMENT '相关还款责任人的ID',
        `other_assets` varchar(100)  DEFAULT '' COMMENT '被投资企业名称',
        `user_create` varchar(50)  DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(50)  DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT = '相关还款责任人:其他资产历史表';

-- 额度支用-相关还款责任人:动产(车辆信息)
DROP TABLE IF EXISTS `review_rlt_repay_vehicle`;
CREATE TABLE `review_rlt_repay_vehicle` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_rlt_repay_id` bigint(20) unsigned DEFAULT '0' COMMENT '相关还款责任人的ID',
        `vehicle_name_license_no` varchar(50)  DEFAULT '' COMMENT '名称型号及牌照号',
        `purchase_date` datetime DEFAULT NULL COMMENT '购买日期',
        `engine_no` varchar(50)  DEFAULT '' COMMENT '发动机号',
        `driving_license_no` varchar(50)  DEFAULT '' COMMENT '行驶证号',
        `is_loan` tinyint(3) unsigned DEFAULT '0' COMMENT '是否有贷款 0否，1有',
        `loan_balance` decimal(17,2) DEFAULT '0.00' COMMENT '贷款余额',
        `user_create` varchar(50)  DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(50)  DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT ='相关还款责任人:动产(车辆信息)';

-- 额度支用-相关还款责任人:动产(车辆信息)历史表
DROP TABLE IF EXISTS `review_rlt_repay_vehicle_history`;
CREATE TABLE `review_rlt_repay_vehicle_history` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_rlt_repay_id` bigint(20) unsigned DEFAULT '0' COMMENT '相关还款责任人的ID',
        `vehicle_name_license_no` varchar(50)  DEFAULT '' COMMENT '名称型号及牌照号',
        `purchase_date` datetime DEFAULT NULL COMMENT '购买日期',
        `engine_no` varchar(50)  DEFAULT '' COMMENT '发动机号',
        `driving_license_no` varchar(50)  DEFAULT '' COMMENT '行驶证号',
        `is_loan` tinyint(3) unsigned DEFAULT '0' COMMENT '是否有贷款 0否，1有',
        `loan_balance` decimal(17,2) DEFAULT '0.00' COMMENT '贷款余额',
        `user_create` varchar(50)  DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(50)  DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='相关还款责任人:动产(车辆信息)历史表';

-- 额度支用-抵质押信息
DROP TABLE IF EXISTS `review_mortgage_basic_info`;
CREATE TABLE `review_mortgage_basic_info` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `mortgage_no` varchar(46) DEFAULT '' COMMENT '抵(质)押合同标识码',
        `guar_type` tinyint(1) DEFAULT NULL COMMENT '合同类型 1:抵押合同，2:质押合同',
        `debtor_id_type` varchar(50) DEFAULT '' COMMENT '债务人身份类别',
        `debtor_name` varchar(46) DEFAULT '' COMMENT '债务人名称',
        `debtor_phone` varchar(46) DEFAULT '' COMMENT '债务人联系方式',
        `debtor_id_address` varchar(80) DEFAULT '' COMMENT '债务人住址地（身份证地址）',
        `debtor_actual_address` varchar(80) DEFAULT '' COMMENT '债务人实际住址（实际地址）',
        `guar_amount` varchar(15) DEFAULT '' COMMENT '担保金额',
        `currency` varchar(50) DEFAULT '' COMMENT '币种',
        `mort_contr_value_date` datetime DEFAULT NULL COMMENT '抵质押合同生效日期',
        `mort_contr_finish_date` datetime DEFAULT NULL COMMENT '抵质押合同失效日期',
        `mort_contr_expire_date` datetime DEFAULT NULL COMMENT '抵质押合同到期日期',
        `max_guar` tinyint(1) DEFAULT NULL COMMENT '最高额担保标识 1:是，0:否',
        `mort_contr_status` tinyint(1) DEFAULT NULL COMMENT '抵质押合同状态 1:有效（指合同生后处于履约状态），2:到期/失效（指合同履行完毕或解除）',
        `contract_no` varchar(50) DEFAULT '' COMMENT '原动产抵押合同编号,原股权质押合同编号',
        `mortgagor_id_type` varchar(50) DEFAULT '' COMMENT '抵押人身份类别',
        `mortgagor_name` varchar(80) DEFAULT '' COMMENT '抵押人名称',
        `mortgagor_cert_type` varchar(100) DEFAULT '' COMMENT '抵押人身份标识类型',
        `mortgagor_cert_num` varchar(80) DEFAULT '' COMMENT '抵押人身份标识号码',
        `contact_number` varchar(50) DEFAULT '' COMMENT '联系方式',
        `address` varchar(500) DEFAULT '' COMMENT '住所地(身份证地址)、住所地(营业执照地址)',
        `actual_address` varchar(500) DEFAULT '' COMMENT '实际地址(实际住址)、实际地址(实际办公地)',
        `card_front_file_storage_id` bigint(20) unsigned DEFAULT NULL COMMENT '证照正面',
        `card_reverse_file_storage_id` bigint(20) unsigned DEFAULT NULL COMMENT '证照反面',
        `legal_representative` varchar(50) DEFAULT '' COMMENT '法定代表人',
        `start_date` datetime DEFAULT NULL COMMENT '债务履行开始日',
        `end_date` datetime DEFAULT NULL COMMENT '债务履行到期日',
        `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='额度支用-抵质押基础信息表';

-- 额度支用-抵质押信息-历史表
DROP TABLE IF EXISTS `review_mortgage_basic_info_his`;
CREATE TABLE `review_mortgage_basic_info_his` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `mortgage_no` varchar(46) DEFAULT '' COMMENT '抵(质)押合同标识码',
        `guar_type` tinyint(1) DEFAULT NULL COMMENT '合同类型 1:抵押合同，2:质押合同',
        `debtor_id_type` varchar(50) DEFAULT '' COMMENT '债务人身份类别',
        `debtor_name` varchar(46) DEFAULT '' COMMENT '债务人名称',
        `debtor_phone` varchar(46) DEFAULT '' COMMENT '债务人联系方式',
        `debtor_id_address` varchar(80) DEFAULT '' COMMENT '债务人住址地（身份证地址）',
        `debtor_actual_address` varchar(80) DEFAULT '' COMMENT '债务人实际住址（实际地址）',
        `guar_amount` varchar(15) DEFAULT '' COMMENT '担保金额',
        `currency` varchar(50) DEFAULT '' COMMENT '币种',
        `mort_contr_value_date` datetime DEFAULT NULL COMMENT '抵质押合同生效日期',
        `mort_contr_finish_date` datetime DEFAULT NULL COMMENT '抵质押合同失效日期',
        `mort_contr_expire_date` datetime DEFAULT NULL COMMENT '抵质押合同到期日期',
        `max_guar` tinyint(1) DEFAULT NULL COMMENT '最高额担保标识 1:是，0:否',
        `mort_contr_status` tinyint(1) DEFAULT NULL COMMENT '抵质押合同状态 1:有效（指合同生后处于履约状态），2:到期/失效（指合同履行完毕或解除）',
        `contract_no` varchar(50) DEFAULT '' COMMENT '原动产抵押合同编号,原股权质押合同编号',
        `mortgagor_id_type` varchar(50) DEFAULT '' COMMENT '抵押人身份类别',
        `mortgagor_name` varchar(80) DEFAULT '' COMMENT '抵押人名称',
        `mortgagor_cert_type` varchar(100) DEFAULT '' COMMENT '抵押人身份标识类型',
        `mortgagor_cert_num` varchar(80) DEFAULT '' COMMENT '抵押人身份标识号码',
        `contact_number` varchar(50) DEFAULT '' COMMENT '联系方式',
        `address` varchar(500) DEFAULT '' COMMENT '住所地(身份证地址)、住所地(营业执照地址)',
        `actual_address` varchar(500) DEFAULT '' COMMENT '实际地址(实际住址)、实际地址(实际办公地)',
        `card_front_file_storage_id` bigint(20) unsigned DEFAULT NULL COMMENT '证照正面',
        `card_reverse_file_storage_id` bigint(20) unsigned DEFAULT NULL COMMENT '证照反面',
        `legal_representative` varchar(50) DEFAULT '' COMMENT '法定代表人',
        `start_date` datetime DEFAULT NULL COMMENT '债务履行开始日',
        `end_date` datetime DEFAULT NULL COMMENT '债务履行到期日',
        `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='额度支用-抵质押基础信息-历史表';

-- 额度支用-抵质押基础信息中间表
DROP TABLE IF EXISTS `review_quota_mortgage_rel`;
CREATE TABLE `review_quota_mortgage_rel` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_quota_disburse_id` bigint(20) unsigned DEFAULT '0' COMMENT '额度支用的ID',
        `review_mortgage_basic_id` bigint(20) unsigned DEFAULT NULL COMMENT '抵质押基础信息的ID',
        `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='额度支用-抵质押基础信息中间表';

-- 额度支用-抵质押基础信息中间历史表
DROP TABLE IF EXISTS `review_quota_mortgage_rel_his`;
CREATE TABLE `review_quota_mortgage_rel_his` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_quota_disburse_his_id` bigint(20) unsigned DEFAULT '0' COMMENT '额度支用历史信息Id',
        `review_mortgage_basic_his_id` bigint(20) unsigned DEFAULT NULL COMMENT '抵质押基础历史信息的ID',
        `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='额度支用-抵质押基础信息中间表';

-- 额度支用-抵押物说明信息表
DROP TABLE IF EXISTS `review_mortgage_collateral_info`;
CREATE TABLE `review_mortgage_collateral_info` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_mortgage_basic_id` bigint(20) unsigned DEFAULT NULL COMMENT '抵质押基础信息的ID',
        `ser_no` varchar(40) DEFAULT '' COMMENT '抵押物序号',
        `coll_type` varchar(50) DEFAULT '' COMMENT '抵押物种类',
        `coll_id_type` varchar(50) DEFAULT '' COMMENT '抵押物识别号类型',
        `coll_cert_id` varchar(40) DEFAULT '' COMMENT '抵押物唯一标识号',
        `coll_district` varchar(50) DEFAULT '' COMMENT '抵押物位置所在行政区划',
        `coll_value` varchar(15) DEFAULT '' COMMENT '抵押物评估价值',
        `coll_currency` varchar(50) DEFAULT '' COMMENT '抵押物币种',
        `evaluate_org_type` tinyint(1) DEFAULT NULL COMMENT '评估机构类型 1-自评估，2-第三方评估机构',
        `coll_evaluate_date` datetime DEFAULT NULL COMMENT '抵押物评估日期',
        `coll_desc` varchar(200) DEFAULT '' COMMENT '抵押物说明',
        `collateral_name` varchar(50) DEFAULT '' COMMENT '抵押物名称',
        `number` varchar(50) DEFAULT '' COMMENT '抵押数量',
        `collateral_type` varchar(50) DEFAULT '' COMMENT '型号',
        `engine_number` varchar(100) DEFAULT NULL COMMENT '发动机号',
        `track_number` varchar(100) DEFAULT NULL COMMENT '履带号',
        `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='额度支用-抵押物说明信息表';

-- 额度支用-抵押物说明信息-历史表
DROP TABLE IF EXISTS `review_mortgage_collateral_info_his`;
CREATE TABLE `review_mortgage_collateral_info_his` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_mortgage_basic_his_id` bigint(20) unsigned DEFAULT NULL COMMENT '抵质押基础历史信息的ID',
        `ser_no` varchar(40) DEFAULT '' COMMENT '抵押物序号',
        `coll_type` varchar(50) DEFAULT '' COMMENT '抵押物种类',
        `coll_id_type` varchar(50) DEFAULT '' COMMENT '抵押物识别号类型',
        `coll_cert_id` varchar(40) DEFAULT '' COMMENT '抵押物唯一标识号',
        `coll_district` varchar(50) DEFAULT '' COMMENT '抵押物位置所在行政区划',
        `coll_value` varchar(15) DEFAULT '' COMMENT '抵押物评估价值',
        `coll_currency` varchar(50) DEFAULT '' COMMENT '抵押物币种',
        `evaluate_org_type` tinyint(1) DEFAULT NULL COMMENT '评估机构类型 1-自评估，2-第三方评估机构',
        `coll_evaluate_date` datetime DEFAULT NULL COMMENT '抵押物评估日期',
        `coll_desc` varchar(200) DEFAULT '' COMMENT '抵押物说明',
        `collateral_name` varchar(50) DEFAULT '' COMMENT '抵押物名称',
        `number` varchar(50) DEFAULT '' COMMENT '抵押数量',
        `collateral_type` varchar(50) DEFAULT '' COMMENT '型号',
        `engine_number` varchar(100) DEFAULT NULL COMMENT '发动机号',
        `track_number` varchar(100) DEFAULT NULL COMMENT '履带号',
        `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='额度支用-抵押物说明信息表';

-- 额度支用-质押物说明信息表
DROP TABLE IF EXISTS `review_mortgage_pledge_info`;
CREATE TABLE `review_mortgage_pledge_info` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_mortgage_basic_id` bigint(20) unsigned DEFAULT NULL COMMENT '抵质押基础信息的ID',
        `ser_no` varchar(40) DEFAULT '' COMMENT '质押物序号',
        `ple_type` varchar(50) DEFAULT '' COMMENT '质押物种类',
        `ple_currency` varchar(50) DEFAULT '' COMMENT '质押物币种',
        `ple_value` varchar(15) DEFAULT '' COMMENT '质押物价值',
        `pledger_id_type` varchar(50) DEFAULT '' COMMENT '出质人身份类别',
        `pledger_name` varchar(80) DEFAULT '' COMMENT '出质人名称',
        `pledger_cert_type` varchar(50) DEFAULT '' COMMENT '出质人身份标识类型',
        `pledger_cert_num` varchar(80) DEFAULT '' COMMENT '出质人身份标识号码',
        `company` varchar(50) DEFAULT '' COMMENT '标的公司',
        `equity_ratio` float(5,4) DEFAULT '0.0000' COMMENT '股权比例',
        `share_number` decimal(17,2) DEFAULT '0.00' COMMENT '股数（万股）',
        `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='额度支用-质押物说明信息表';

-- 额度支用-质押物说明信息表
DROP TABLE IF EXISTS `review_mortgage_pledge_info_his`;
CREATE TABLE `review_mortgage_pledge_info_his` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_mortgage_basic_his_id` bigint(20) unsigned DEFAULT NULL COMMENT '抵质押基础历史信息的ID',
        `ser_no` varchar(40) DEFAULT '' COMMENT '质押物序号',
        `ple_type` varchar(50) DEFAULT '' COMMENT '质押物种类',
        `ple_currency` varchar(50) DEFAULT '' COMMENT '质押物币种',
        `ple_value` varchar(15) DEFAULT '' COMMENT '质押物价值',
        `pledger_id_type` varchar(50) DEFAULT '' COMMENT '出质人身份类别',
        `pledger_name` varchar(80) DEFAULT '' COMMENT '出质人名称',
        `pledger_cert_type` varchar(50) DEFAULT '' COMMENT '出质人身份标识类型',
        `pledger_cert_num` varchar(80) DEFAULT '' COMMENT '出质人身份标识号码',
        `company` varchar(50) DEFAULT '' COMMENT '标的公司',
        `equity_ratio` float(5,4) DEFAULT '0.0000' COMMENT '股权比例',
        `share_number` decimal(17,2) DEFAULT '0.00' COMMENT '股数（万股）',
        `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='额度支用-质押物说明信息表';

-- 额度支用-应收账款转让信息
DROP TABLE IF EXISTS `review_transfer_receivable`;
CREATE TABLE `review_transfer_receivable` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_quota_disburse_id` bigint(20) unsigned DEFAULT '0' COMMENT '额度支用ID',
        `confirmation_no` varchar(50) DEFAULT '' COMMENT '确认书编号',
        `notice_no` varchar(50) DEFAULT '' COMMENT '通知书编号',
        `transferor` varchar(50) DEFAULT '' COMMENT '转让方',
        `transferee` varchar(50) DEFAULT '' COMMENT '受让方',
        `is_confirm` tinyint(3) unsigned DEFAULT '0' COMMENT '是否确认:0否，1是',
        `confirm_method` varchar(200) DEFAULT '' COMMENT '确权方式(回执确认-receiptConfirm、三方协议确认-tripartiteAgreementConfirm、其他-otherConfirm)',
        `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='额度支用-应收账款转让信息';

-- 额度支用-应收账款转让-历史信息
DROP TABLE IF EXISTS `review_transfer_receivable_his`;
CREATE TABLE `review_transfer_receivable_his` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_quota_disburse_his_id` bigint(20) unsigned DEFAULT '0' COMMENT '额度支用历史信息Id',
        `confirmation_no` varchar(50) DEFAULT '' COMMENT '确认书编号',
        `notice_no` varchar(50) DEFAULT '' COMMENT '通知书编号',
        `transferor` varchar(50) DEFAULT '' COMMENT '转让方',
        `transferee` varchar(50) DEFAULT '' COMMENT '受让方',
        `is_confirm` tinyint(3) unsigned DEFAULT '0' COMMENT '是否确认:0否，1是',
        `confirm_method` varchar(200) DEFAULT '' COMMENT '确权方式(回执确认-receiptConfirm、三方协议确认-tripartiteAgreementConfirm、其他-otherConfirm)',
        `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='额度支用-应收账款转让信息';

-- 额度支用-基础交易合同信息（三方协议）
DROP TABLE IF EXISTS `review_basic_contract`;
CREATE TABLE `review_basic_contract` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_quota_disburse_id` bigint(20) unsigned DEFAULT '0' COMMENT '额度支用ID',
        `tripartite_agreement_no` varchar(50) DEFAULT '' COMMENT '三方协议编号:按规则生成',
        `debtor_company_id` bigint(20) unsigned DEFAULT '0' COMMENT '债务人公司ID',
        `debtor_company_name` varchar(50) DEFAULT '' COMMENT '债务人公司名称',
        `debtor_social_credit_code` varchar(50) DEFAULT '' COMMENT '债务人统一社会信用码',
        `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        `special_agreement` varchar(5000) DEFAULT '' COMMENT '特殊约定',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='额度支用-基础交易合同信息（三方协议）';

-- 额度支用-基础交易合同信息（三方协议）
DROP TABLE IF EXISTS `review_basic_contract_his`;
CREATE TABLE `review_basic_contract_his` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_quota_disburse_his_id` bigint(20) unsigned DEFAULT '0' COMMENT '额度支用历史信息Id',
        `tripartite_agreement_no` varchar(50) DEFAULT '' COMMENT '三方协议编号:按规则生成',
        `debtor_company_id` bigint(20) unsigned DEFAULT '0' COMMENT '债务人公司ID',
        `debtor_company_name` varchar(50) DEFAULT '' COMMENT '债务人公司名称',
        `debtor_social_credit_code` varchar(50) DEFAULT '' COMMENT '债务人统一社会信用码',
        `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        `special_agreement` varchar(5000) DEFAULT '' COMMENT '特殊约定',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='额度支用-基础交易合同信息（三方协议）';

-- 额度支用-基础交易合同信息（三方协议）变更内容
DROP TABLE IF EXISTS `review_basic_contract_change_content`;
CREATE TABLE `review_basic_contract_change_content` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_basic_contract_id` bigint(20) unsigned DEFAULT '0' COMMENT '基础交易合同信息（三方协议）的ID',
        `contract_no` varchar(50) DEFAULT '' COMMENT '基础交易合同编号:获取的是所选应收账款中的合同编号',
        `contract_name` varchar(50) DEFAULT '' COMMENT '基础交易合同名称:获取的是所选应收账款中的合同名称',
        `original_contract_content` varchar(500) DEFAULT '' COMMENT '原合同内容',
        `post_change_content` varchar(500) DEFAULT '' COMMENT '变更后内容',
        `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        `special_agreement_basic` varchar(100) DEFAULT NULL COMMENT '其他特殊约定-固定内容',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='额度支用-基础交易合同信息（三方协议）变更内容';

-- 额度支用-基础交易合同信息（三方协议）变更内容-历史表
DROP TABLE IF EXISTS `review_basic_contract_change_content_his`;
CREATE TABLE `review_basic_contract_change_content_his` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_basic_contract_his_id` bigint(20) unsigned DEFAULT '0' COMMENT '基础交易合同信息（三方协议）的历史Id',
        `contract_no` varchar(50) DEFAULT '' COMMENT '基础交易合同编号:获取的是所选应收账款中的合同编号',
        `contract_name` varchar(50) DEFAULT '' COMMENT '基础交易合同名称:获取的是所选应收账款中的合同名称',
        `original_contract_content` varchar(500) DEFAULT '' COMMENT '原合同内容',
        `post_change_content` varchar(500) DEFAULT '' COMMENT '变更后内容',
        `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        `special_agreement_basic` varchar(100) DEFAULT NULL COMMENT '其他特殊约定-固定内容',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='额度支用-基础交易合同信息（三方协议）变更内容';

-- 额度支用审批
DROP TABLE IF EXISTS `review_quota_disburse_approval`;
CREATE TABLE `review_quota_disburse_approval` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_quota_disburse_id` bigint(20) unsigned DEFAULT '0' COMMENT '额度支用ID',
        `currency_code` varchar(50) DEFAULT '' COMMENT '币种',
        `approval_conclusion` varchar(50) DEFAULT '' COMMENT '通过pass/否决veto',
        `approval_comments` varchar(3000) DEFAULT '' COMMENT '审批意见',
        `assignee_id` bigint(20) unsigned DEFAULT '0' COMMENT '处理人(风险经理)',
        `visible` tinyint(3) unsigned DEFAULT '0' COMMENT '是否显示，默认0表示否',
        `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='额度支用审批';

-- 额度支用审批-放款条件
DROP TABLE IF EXISTS `review_loan_condition`;
CREATE TABLE `review_loan_condition` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_quota_disburse_approval_id` bigint(20) unsigned DEFAULT '0' COMMENT '额度支用审批的ID',
        `income_expenditure_plan_id` bigint(20) unsigned DEFAULT '0' COMMENT '额度支用节点中，对应收支计划的ID',
        `loan_date` datetime DEFAULT NULL COMMENT '放款日期',
        `amount` decimal(17,2) DEFAULT '0.00' COMMENT '金额',
        `loan_condition` varchar(2000) DEFAULT '0' COMMENT '放款条件',
        `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='额度支用审批-放款条件';


-- 合同基础表
DROP TABLE IF EXISTS `contract_info`;
CREATE TABLE `contract_info` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_quota_disburse_id` bigint(20) unsigned DEFAULT '0' COMMENT '额度支用ID',
        `review_quota_disburse_approval_id` bigint(20) unsigned DEFAULT '0' COMMENT '额度支用审批ID',
        `business_no` varchar(20)  DEFAULT '' COMMENT '业务编号',
        `contract_no` varchar(20)  DEFAULT '' COMMENT '合同编号',
        `quota_disburse_batch` int(11) DEFAULT '0' COMMENT '额度支用批次',
        `assignee_id` bigint(20) unsigned DEFAULT '0' COMMENT '处理人(法务专员)',
        `conclusion` varchar(50) DEFAULT '' COMMENT '结论',
        `suggestion` varchar(3000) DEFAULT '' COMMENT '意见',
        `contract_sign_method` bigint(20) unsigned DEFAULT '0' COMMENT '合同签署方式 0.线下签 1.电子签',
        `do_upload` tinyint(3) DEFAULT '0' COMMENT '是否上传合同  TRUE  上传   FALSE   不上传',
        `visible` tinyint(3) unsigned DEFAULT '0' COMMENT '是否显示，默认0表示否',
        `electronic_sign_file_code` varchar(1000) DEFAULT NULL COMMENT '电子签模板文件code',
        `user_create` varchar(50)  DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(50)  DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='合同基础表';

-- 合同融资信息
DROP TABLE IF EXISTS `contract_financing_info`;
CREATE TABLE `contract_financing_info` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `contract_info_id` bigint(20) unsigned DEFAULT '0' COMMENT '合同基础信息ID',
        `principal_collection_method` varchar(500) DEFAULT '' COMMENT '本金支付方式',
        `interest_collection_method` varchar(500) DEFAULT '' COMMENT '利息支付方式',
        `management_fee_collection_method` varchar(500) DEFAULT '' COMMENT '管理费支付方式',
        `margin_collection_method` varchar(500) DEFAULT '' COMMENT '保证金支付方式',
        `margin_return_method` varchar(500) DEFAULT '' COMMENT '保证金退还方式',
        `margin_return_condition` varchar(500) DEFAULT '' COMMENT '保证金退还条件',
        `other_fee_collection_method` varchar(500) DEFAULT '' COMMENT '其他费用支付方式',
        `user_create` varchar(50)  DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(50)  DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='合同融资信息';

-- 合同放款条件设定
DROP TABLE IF EXISTS `contract_loan_condition_setting`;
CREATE TABLE `contract_loan_condition_setting` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `contract_info_id` bigint(20) unsigned DEFAULT '0' COMMENT '合同基础信息ID',
        `order_number` int(11) DEFAULT '0' COMMENT '序号',
        `is_fixed_condition` tinyint(1) unsigned DEFAULT '0' COMMENT '是否是固定条件， 0否，1是',
        `condition_type` varchar(50) DEFAULT '' COMMENT '条件类型',
        `loan_condition` varchar(3000) DEFAULT '0' COMMENT '放款条件',
        `is_checked` tinyint(1) DEFAULT NULL COMMENT '是否选中',
        `user_create` varchar(50)  DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(50)  DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='合同放款条件设定';

-- 合同放款条件与放款条件设定中间表
DROP TABLE IF EXISTS `contract_loan_condition_setting_rel`;
CREATE TABLE `contract_loan_condition_setting_rel` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `review_loan_condition_id` bigint(20) DEFAULT NULL COMMENT '额度支用-放款条件ID',
        `contract_loan_condition_setting_id` bigint(20) DEFAULT NULL COMMENT '合同-放款条件设定ID',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='合同-放款条件与放款条件设定中间表';

-- 合同管理-主合同信息
DROP TABLE IF EXISTS `contract_master_contract`;
CREATE TABLE `contract_master_contract` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `contract_info_id` bigint(20) unsigned DEFAULT '0' COMMENT '合同基础信息ID',
        `contract_num` int(11) DEFAULT '0' COMMENT '合同份数',
        `special_agreement` varchar(3000) DEFAULT '' COMMENT '保理主合同特殊约定',
        `factoring_contract_agreement` varchar(3000) DEFAULT '' COMMENT '保理信息表特殊约定',
        `financing_confirm_agreement` varchar(3000) DEFAULT '' COMMENT '融资确认书特殊约定',
        `user_create` varchar(50)  DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(50)  DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='合同:主合同信息';

-- 合同管理-基础交易合同信息（三方协议）
DROP TABLE IF EXISTS `contract_basic_contract`;
CREATE TABLE `contract_basic_contract` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `contract_info_id` bigint(20) unsigned DEFAULT '0' COMMENT '合同基础信息ID',
        `tripartite_agreement_no` varchar(50) DEFAULT '' COMMENT '三方协议编号:按规则生成',
        `debtor_company_id` bigint(20) unsigned DEFAULT '0' COMMENT '债务人公司ID',
        `debtor_company_name` varchar(50) DEFAULT '' COMMENT '债务人公司名称',
        `debtor_social_credit_code` varchar(50) DEFAULT '' COMMENT '债务人统一社会信用码',
        `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        `special_agreement` varchar(5000) DEFAULT '' COMMENT '特殊约定',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='合同:基础交易合同信息（三方协议）';

-- 合同管理-基础交易合同信息（三方协议）
DROP TABLE IF EXISTS `contract_basic_contract_change_content`;
CREATE TABLE `contract_basic_contract_change_content` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `contract_info_id` bigint(20) unsigned DEFAULT '0' COMMENT '合同基础信息ID',
        `contract_basic_contract_id` bigint(20) unsigned DEFAULT '0' COMMENT '合同基础交易合同信息（三方协议）的ID',
        `underlying_assets_id` bigint(20) unsigned DEFAULT '0' COMMENT '所选的底层资产的ID：国内或者出口',
        `contract_no` varchar(50) DEFAULT '' COMMENT '基础交易合同编号:获取的是所选应收账款中的合同编号',
        `contract_name` varchar(50) DEFAULT '' COMMENT '基础交易合同名称:获取的是所选应收账款中的合同名称',
        `original_contract_content` varchar(500) DEFAULT '' COMMENT '原合同内容',
        `post_change_content` varchar(500) DEFAULT '' COMMENT '变更后内容',
        `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        `special_agreement_basic` varchar(100) DEFAULT NULL COMMENT '其他特殊约定-固定内容',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='合同:基础交易合同信息（三方协议）变更内容';

-- 合同管理-上传合同的信息
DROP TABLE IF EXISTS `upload_contract_info`;
CREATE TABLE `upload_contract_info` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `contract_info_id` bigint(20) unsigned DEFAULT '0' COMMENT '合同基础信息ID',
        `contract_name` varchar(200) DEFAULT '' COMMENT '合同名称',
        `contract_type` varchar(32) DEFAULT '' COMMENT '合同类型  主合同-master、附件-annex',
        `file_id` bigint(20) DEFAULT NULL COMMENT '附件id',
        `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='上传合同的信息';


-- 合同管理-上传合同的签署人信息
DROP TABLE IF EXISTS `upload_contract_signatory`;
CREATE TABLE `upload_contract_signatory` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `upload_contract_info_Id` bigint(20) unsigned DEFAULT NULL COMMENT '上传合同id',
        `name` varchar(20) DEFAULT '' COMMENT '签署方姓名',
        `social_credit_code` varchar(50) DEFAULT '' COMMENT '统一信用代码或者身份证号',
        `type` tinyint(3) DEFAULT NULL COMMENT '签署方类别  TRUE：公司  false 个人',
        `contact_number` varchar(20) DEFAULT '' COMMENT '联系方式',
        `contract_type` varchar(32) DEFAULT '' COMMENT '合同类型  主合同-master、附件-annex',
        `card_type` varchar(50) DEFAULT '' COMMENT '证件类型',
        `card_front_file_storage_id` bigint(20) unsigned DEFAULT NULL COMMENT '证照正面',
        `card_reverse_file_storage_id` bigint(20) unsigned DEFAULT NULL COMMENT '证照反面',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='上传合同的签署人信息';

-- 合同管理-合同电子签信息
DROP TABLE IF EXISTS `contract_electronic_info`;
CREATE TABLE `contract_electronic_info` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
        `contract_name` varchar(500) DEFAULT NULL COMMENT '合同名称',
        `contract_info_id` bigint(20) unsigned DEFAULT '0' COMMENT '合同基础信息ID',
        `contract_id` varchar(1024) DEFAULT NULL COMMENT '合同编号',
        `auto_sign_transaction_id` varchar(255) DEFAULT NULL COMMENT '自动签署合同交易id',
        `file_id` bigint(20) DEFAULT NULL COMMENT '电子签文件',
        `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
        `user_modified` varchar(50) DEFAULT NULL COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='合同电子签信息';

-- 合同管理-合同电子签信息客户信息
DROP TABLE IF EXISTS `contract_electronic_customer_info`;
CREATE TABLE `contract_electronic_customer_info` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
        `contract_electronic_info_id` bigint(20) DEFAULT NULL COMMENT '合同电子签信息ID',
        `sys_customer_id` bigint(20) DEFAULT NULL COMMENT '合同电子签企业信息管理表ID',
        `customer_name` varchar(500) DEFAULT NULL,
        `transaction_id` varchar(255) DEFAULT NULL COMMENT '客户合同交易id',
        `contract_link` varchar(2048) DEFAULT NULL,
        `keyword` varchar(255) DEFAULT NULL COMMENT '关键字',
        `short_contract_link` varchar(1024) DEFAULT NULL COMMENT '客户合同链接短连接',
        `short_contract_link_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '短链接创建时间',
        `sign_status` tinyint(1) DEFAULT NULL COMMENT '客户签署状态',
        `file_id` bigint(20) DEFAULT NULL COMMENT '电子签文件',
        `report_file_id` bigint(20) DEFAULT NULL COMMENT '出证电子签文件',
        `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
        `user_modified` varchar(50) DEFAULT NULL COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='合同电子签信息客户信息';

-- 合同管理-合同电子签企业信息管理表
DROP TABLE IF EXISTS `sys_customer`;
CREATE TABLE `sys_customer` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
        `ent_business_id` bigint(20) DEFAULT NULL COMMENT '企业工商信息表id',
        `platform_id` bigint(20) DEFAULT NULL COMMENT '贸易平台id',
        `auth_status` tinyint(1) DEFAULT '0' COMMENT '企业认证状态 0：未认证 1：已认证',
        `auto_sign_status` tinyint(1) DEFAULT '0' COMMENT '企业授权自动签署状态 0：未认证 1：已认证',
        `auth_url` varchar(1024) DEFAULT NULL COMMENT '认证链接',
        `short_auth_url` varchar(1024) DEFAULT NULL COMMENT '认证短链接',
        `short_auth_url_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '认证短链接创建时间',
        `auto_sign_url` varchar(1024) DEFAULT NULL COMMENT '自动签署链接',
        `short_auto_sign_url` varchar(1024) DEFAULT NULL COMMENT '自动签署短链接',
        `short_auto_sign_url_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '自动签署创建时间',
        `fdd_customer_id` varchar(50) DEFAULT NULL COMMENT '企业在法大大上的客户编号',
        `transaction_id` varchar(255) DEFAULT NULL COMMENT '企业在法大大上自动签署合同的交易号',
        `file_id` bigint(20) unsigned DEFAULT NULL COMMENT '开启自动签附件的ID',
        `account_type` tinyint(1) DEFAULT NULL COMMENT '客户类型 1个人 2公司',
        `user_create` varchar(50) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(50) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        `certificate_sign_url` varchar(1024) DEFAULT NULL COMMENT '授权书签署链接',
        `certificate_short_sign_url` varchar(1024) DEFAULT NULL COMMENT '授权书签署短链接',
        `certificate_short_sign_url_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '授权书签署短链接创建时间',
        `certificate_transaction_id` varchar(255) DEFAULT NULL COMMENT '企业在法大大上签署授权书的交易号',
        `certificate_sign_status` tinyint(1) DEFAULT '0' COMMENT '企业授权授权书签署状态 0：未签署 1：已签署',
        `certificate_file_id` bigint(20) unsigned DEFAULT NULL COMMENT '已经签署的授权书的附件的ID',
        `certificate_supplement_report_file` bigint(20) unsigned DEFAULT NULL COMMENT '授权书的出征文件附件的ID',
        `certificate_contract_id` varchar(1024) DEFAULT NULL COMMENT '授权书合同编号',
        PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='合同电子签企业信息管理表';

-- 合同管理-合同电子签企业信息管理表
DROP TABLE IF EXISTS `sys_customer_file_ref`;
CREATE TABLE `sys_customer_file_ref` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `contract_electronic_info_id` bigint(20) unsigned DEFAULT '0' COMMENT '合同电子签信息ID',
        `file_id` bigint(20) unsigned DEFAULT '0' COMMENT '附件的ID',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='电子签客户附件信息中间表';

-- 合同管理-个人电子签信息表
DROP TABLE IF EXISTS `electronic_person_info`;
CREATE TABLE `electronic_person_info` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `name` varchar(50) DEFAULT NULL COMMENT '用户名',
        `socialCreditCode` varchar(18) DEFAULT NULL COMMENT '证件号码',
        `mobile` varchar(50) DEFAULT NULL COMMENT '联系电话',
        `email` varchar(128) DEFAULT NULL COMMENT '电子邮箱',
        `user_create` varchar(30) DEFAULT NULL COMMENT '创建人',
        `user_modified` varchar(30) DEFAULT NULL COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        `card_type` varchar(50) DEFAULT '' COMMENT '证件类型',
        `card_front_file_storage_id` bigint(20) unsigned DEFAULT NULL COMMENT '证照正面',
        `card_reverse_file_storage_id` bigint(20) unsigned DEFAULT NULL COMMENT '证照反面',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='个人电子签信息表';

-- 合同管理-合同签署确认表
DROP TABLE IF EXISTS `contract_sign_confirm`;
CREATE TABLE `contract_sign_confirm` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `contract_info_id` bigint(20) unsigned DEFAULT '0' COMMENT '合同基础ID',
        `assignee_id` bigint(20) unsigned DEFAULT '0' COMMENT '处理人ID',
        `visible` tinyint(3) unsigned DEFAULT '0' COMMENT '是否显示，默认0表示否',
        `conclusion` varchar(50) DEFAULT '' COMMENT '结论',
        `remark` varchar(3000) DEFAULT '' COMMENT '备注',
        `user_create` varchar(50) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(50) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='合同签署确认表';

-- 合同管理-法务终审表
DROP TABLE IF EXISTS `contract_legal_final_approval`;
CREATE TABLE `contract_legal_final_approval` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `contract_info_id` bigint(20) unsigned DEFAULT '0' COMMENT '合同基础ID',
        `assignee_id` bigint(20) unsigned DEFAULT '0' COMMENT '处理人ID',
        `visible` tinyint(3) unsigned DEFAULT '0' COMMENT '是否显示，默认0表示否',
        `conclusion` varchar(50) DEFAULT '' COMMENT '审批结论',
        `suggestion` varchar(3000) DEFAULT '' COMMENT '审批意见',
        `user_create` varchar(50) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(50) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='法务终审';

-- 付款管理-付款信息表
DROP TABLE IF EXISTS `payment_info`;
CREATE TABLE `payment_info` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `c_financing_basic_info_id` bigint(20) unsigned DEFAULT '0' COMMENT 'C端融资信息基础Id',
        `business_no` varchar(50) DEFAULT '' COMMENT '业务编号',
        `contract_info_id` bigint(20) unsigned DEFAULT '0' COMMENT '合同ID',
        `quota_disburse_id` bigint(20) unsigned DEFAULT '0' COMMENT '额度支用ID',
        `quota_disburse_batch` int(11) DEFAULT '0' COMMENT '额度支用批次',
        `contract_no` varchar(50) DEFAULT '' COMMENT '合同编号',
        `total_loan_amount` decimal(17,2) DEFAULT '0.00' COMMENT '放款总额',
        `user_create` varchar(50) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(50) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='付款信息表';

-- 付款管理-付款申请表
DROP TABLE IF EXISTS `payment_apply`;
CREATE TABLE `payment_apply` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `payment_info_id` bigint(20) unsigned DEFAULT '0' COMMENT '付款信息ID',
        `payment_no` varchar(50) DEFAULT '' COMMENT '付款编号',
        `payment_type` varchar(50) DEFAULT '' COMMENT '付款类型',
        `plan_no` varchar(30) DEFAULT '' COMMENT '付款笔数',
        `payment_amount` decimal(17,2) DEFAULT '0.00' COMMENT '付款金额',
        `currency_code` varchar(50) DEFAULT '' COMMENT '币种code',
        `plan_payment_date` datetime DEFAULT NULL COMMENT '计划付款日期',
        `status_code` varchar(50) DEFAULT '' COMMENT '状态code',
        `visible` tinyint(3) unsigned DEFAULT '0' COMMENT '放款申请：是否显示，默认0表示暂存',
        `user_create` varchar(50) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(50) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='付款申请表';

-- 付款管理-付款条件表
DROP TABLE IF EXISTS `payment_condition`;
CREATE TABLE `payment_condition` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `payment_apply_id` bigint(20) unsigned DEFAULT '0' COMMENT '付款申请ID',
        `condition_content` varchar(350) DEFAULT '' COMMENT '付款条件',
        `exempt` tinyint(1) DEFAULT NULL COMMENT '是否豁免 0 不豁免 1 豁免',
        `follow` tinyint(1) DEFAULT NULL COMMENT '是否跟进 0 不跟进 1 跟进',
        `exempt_reason` varchar(350) DEFAULT '' COMMENT '豁免原因',
        `supplement` varchar(1024) DEFAULT NULL COMMENT '补充说明',
        `meet` tinyint(1) DEFAULT NULL COMMENT '是否满足 0 不满足 1 满足',
        `user_create` varchar(50) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(50) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='付款条件表';

-- 付款管理-付款条件与附件关联表
DROP TABLE IF EXISTS `payment_condition_file_ref`;
CREATE TABLE `payment_condition_file_ref` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `payment_condition_id` bigint(20) unsigned DEFAULT '0' COMMENT '付款条件ID',
        `file_id` bigint(20) unsigned DEFAULT '0' COMMENT '附件ID',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='付款条件与附件关联表';

-- 付款管理-付款申请历史表
DROP TABLE IF EXISTS `payment_apply_his`;
CREATE TABLE `payment_apply_his` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `payment_info_id` bigint(20) unsigned DEFAULT '0' COMMENT '付款信息ID',
        `payment_apply_id` bigint(20) unsigned DEFAULT '0' COMMENT '付款申请ID',
        `payment_no` varchar(50) DEFAULT '' COMMENT '付款编号',
        `payment_type` varchar(50) DEFAULT '' COMMENT '付款类型',
        `plan_no` varchar(30) DEFAULT '' COMMENT '付款笔数',
        `payment_amount` decimal(17,2) DEFAULT '0.00' COMMENT '付款金额',
        `currency_code` varchar(50) DEFAULT '' COMMENT '币种code',
        `plan_payment_date` datetime DEFAULT NULL COMMENT '计划付款日期',
        `user_create` varchar(50) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(50) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='付款申请表';

-- 付款管理-付款条件历史表
DROP TABLE IF EXISTS `payment_condition_his`;
CREATE TABLE `payment_condition_his` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `payment_apply_his_id` bigint(20) unsigned DEFAULT '0' COMMENT '付款申请历史ID',
        `condition_content` varchar(350) DEFAULT '' COMMENT '付款条件',
        `exempt` tinyint(1) DEFAULT NULL COMMENT '是否豁免 0 不豁免 1 豁免',
        `follow` tinyint(1) DEFAULT NULL COMMENT '是否跟进 0 不跟进 1 跟进',
        `exempt_reason` varchar(350) DEFAULT '' COMMENT '豁免原因',
        `supplement` varchar(1024) DEFAULT NULL COMMENT '补充说明 ',
        `user_create` varchar(50) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(50) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='付款条件表';

-- 付款管理-付款条件与附件关联历史表
DROP TABLE IF EXISTS `payment_condition_file_ref_his`;
CREATE TABLE `payment_condition_file_ref_his` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `payment_condition_his_id` bigint(20) unsigned DEFAULT '0' COMMENT '付款条件历史ID',
        `file_id` bigint(20) unsigned DEFAULT '0' COMMENT '附件ID',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='付款条件与附件关联历史表';


-- 付款管理-豁免审批表（业务）
DROP TABLE IF EXISTS `exemption_approval_business`;
CREATE TABLE `exemption_approval_business` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `payment_apply_id` bigint(20) NOT NULL COMMENT '付款申请表id',
        `approval_conclusion` varchar(50) DEFAULT '' COMMENT '通过pass/退回back',
        `approval_comments` varchar(3000) DEFAULT '' COMMENT '审批意见',
        `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='付款申请-豁免审批表（业务）';

-- 付款管理-豁免审批表（风控）
DROP TABLE IF EXISTS `exemption_approval_risk`;
CREATE TABLE `exemption_approval_risk` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `payment_apply_id` bigint(20) NOT NULL COMMENT '付款申请表id',
        `approval_conclusion` varchar(50) DEFAULT '' COMMENT '通过pass/退回back',
        `approval_comments` varchar(3000) DEFAULT '' COMMENT '审批意见',
        `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='付款申请-豁免审批表（风控）';

-- 付款管理-付款审批表（风控）
DROP TABLE IF EXISTS `payment_approval`;
CREATE TABLE `payment_approval` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `payment_apply_id` bigint(20) NOT NULL COMMENT '付款申请表id',
        `approval_conclusion` varchar(50) DEFAULT '' COMMENT '审批结论',
        `approval_comment` varchar(3000) DEFAULT '' COMMENT '审批意见',
        `visible` tinyint(1) DEFAULT '0' COMMENT '是否显示，默认0表示暂存',
        `user_create` varchar(50) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(50) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='付款审批表';

-- 付款管理-应收账款登记表
DROP TABLE IF EXISTS `receivables_register_info`;
CREATE TABLE `receivables_register_info` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `payment_apply_id` bigint(20) NOT NULL COMMENT '付款申请表id',
        `payment_approval_id` bigint(20) DEFAULT NULL COMMENT '付款审批Id',
        `receivables_register_number` varchar(100) DEFAULT NULL COMMENT '应收账款登记-登记证明编号',
        `receivables_expiry_date` datetime DEFAULT NULL COMMENT '应收账款登记-登记到期日',
        `mortgage_register_number` varchar(100) DEFAULT NULL COMMENT '动产抵押登记-登记证明编号',
        `mortgage_expiry_date` datetime DEFAULT NULL COMMENT '动产抵押登记-登记到期日',
        `ownership_register_number` varchar(100) DEFAULT NULL COMMENT '所有权保留登记-登记证明编号',
        `ownership_date` datetime DEFAULT NULL COMMENT '所有权保留登记-登记到期日',
        `file_id` bigint(20) DEFAULT NULL COMMENT '中登网登记模板文件ID',
        `user_create` varchar(50) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(50) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='应收账款登记表';

-- 付款管理-应收账款登记文件表
DROP TABLE IF EXISTS `receivables_register_file`;
CREATE TABLE `receivables_register_file` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `file_id` bigint(20) DEFAULT NULL COMMENT '文件Id',
        `receivables_register_id` bigint(20) DEFAULT NULL COMMENT '应收账款登记Id',
        `register_type` varchar(100) DEFAULT NULL COMMENT '登记类型，receivables-应收账款登记、mortgage-动产抵押登记、ownership-所有权保留登记',
        `user_create` varchar(50) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(50) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='应收账款登记文件表';

-- 分账管理-基本信息表
DROP TABLE IF EXISTS `ledger_account_basic_info`;
CREATE TABLE `ledger_account_basic_info` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
        `cash_flow_manage_basic_info_id` bigint(20) DEFAULT NULL COMMENT '对应现金流基础信息表(入账)Id',
        `enterprise_id` bigint(20) DEFAULT NULL COMMENT '企业Id',
        `label` tinyint(1) DEFAULT NULL COMMENT '标签 0:下游回款、1:上游回购',
        `ledger_number` varchar(50) NOT NULL COMMENT '分账单号',
        `ledger_status` varchar(100) DEFAULT '' COMMENT '分账状态 待处理、已完成',
        `currency` varchar(100) DEFAULT '' COMMENT '币种',
        `ledger_type` varchar(100) DEFAULT '' COMMENT '入账类型 （现金、票据贴现）',
        `ledger_amount` decimal(17,2) DEFAULT '0.00' COMMENT '入账金额',
        `ledger_date` datetime DEFAULT NULL COMMENT '入账日期',
        `discount_charge` decimal(17,2) DEFAULT NULL COMMENT '贴现费用(当入账类型为票据贴现时填写)',
        `remark` varchar(500) DEFAULT NULL COMMENT '说明(当入账类型为票据贴现时填写)',
        `goods_amount` decimal(17,2) DEFAULT NULL COMMENT '货款金额',
        `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
        `user_modified` varchar(50) DEFAULT NULL COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='分账管理-基本信息表';

-- 分账管理-货款分配表
DROP TABLE IF EXISTS `ledger_fund_goods_assign`;
CREATE TABLE `ledger_fund_goods_assign` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
        `ledger_account_basic_info_id` bigint(20) DEFAULT NULL COMMENT '对应分账管理基本信息表Id',
        `business_number` varchar(50) NOT NULL COMMENT '业务编号',
        `underlying_assets_no` varchar(50) DEFAULT NULL COMMENT 'SOP底层资产编号',
        `acceptance_goods_number` varchar(50) DEFAULT NULL COMMENT '验收单号',
        `settlement_number` varchar(50) DEFAULT NULL COMMENT '结算单号',
        `billing_factoring_business_loan_record_id` bigint(20) DEFAULT NULL COMMENT '对应SOP放款记录Id',
        `sop_accounts_receivable_id` bigint(20) DEFAULT NULL COMMENT '对应SOP应收账款Id',
        `supplier_id` bigint(20) DEFAULT NULL COMMENT '供应商Id',
        `supplier_name` varchar(50) DEFAULT NULL COMMENT '供应商名称',
        `contract_no` varchar(50) DEFAULT NULL COMMENT '对应SOP合同编号',
        `quota_disburse_batch` int(11) DEFAULT NULL COMMENT '对应SOP额度支用批次',
        `sales_total_price` decimal(17,2) DEFAULT NULL COMMENT '销售总价',
        `purchase_total_price` decimal(17,2) DEFAULT NULL COMMENT '采购总价',
        `loan_date` datetime DEFAULT NULL COMMENT '放款日期/结算日期',
        `loan_amount` decimal(17,2) DEFAULT NULL COMMENT '放款金额',
        `current_assign_amount` decimal(17,2) DEFAULT '0.00' COMMENT '本次分配金额',
        `is_accrual` tinyint(1) DEFAULT NULL COMMENT '是否计提 0：否，1：是',
        `accrual_amount` decimal(17,2) DEFAULT '0.00' COMMENT '计提金额',
        `financing_overdue_interest` decimal(17,2) DEFAULT '0.00' COMMENT '逾期利息',
        `financing_interest` decimal(17,2) DEFAULT '0.00' COMMENT '融资利息',
        `financing_management_fee` decimal(17,2) DEFAULT '0.00' COMMENT '融资管理费',
        `has_assign_interest` tinyint(1) DEFAULT '1' COMMENT '是否分配利息',
        `has_assign_management_fee` tinyint(1) DEFAULT '1' COMMENT '是否分配管理费',
        `has_assign_overdue_interest` tinyint(1) DEFAULT '1' COMMENT '是否分配逾期利息',
        `financing_principal` decimal(17,2) DEFAULT '0.00' COMMENT '融资本金',
        `platform_profit` decimal(17,2) DEFAULT '0.00' COMMENT '平台利润',
        `guarantee` decimal(17,2) DEFAULT '0.00' COMMENT '质保金',
        `discount_amount` decimal(17,2) DEFAULT '0.00' COMMENT '实退金额',
        `refund_interest` decimal(17,2) DEFAULT NULL COMMENT '应退利息',
        `refund_management_fee` decimal(17,2) DEFAULT NULL COMMENT '应退管理费',
        `to_assigned_amount` decimal(17,2) DEFAULT '0.00' COMMENT '待分配金额',
        `goods_assign_id` bigint(20) DEFAULT NULL COMMENT '货物分配Id',
        `latest_coll_date` datetime DEFAULT NULL COMMENT '最近一期本金回款日期（如果没有回款取放款日期）',
        `last_plan_date` datetime DEFAULT NULL COMMENT '最后一期计划本金收款日期',
        `pay_coll_basic_id` bigint(20) DEFAULT NULL COMMENT '账后基础表Id',
        `returned_amount` decimal(17,2) DEFAULT '0.00' COMMENT '待回款金额（本金）',
        `is_submit` tinyint(1) DEFAULT '1' COMMENT '是否提交',
        `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
        `user_modified` varchar(50) DEFAULT NULL COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='分账管理-货款分配表';

-- 分账管理-账后收放款计划分配表
DROP TABLE IF EXISTS `ledger_plan_factoring_assign`;
CREATE TABLE `ledger_plan_factoring_assign` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `ledger_account_basic_info_id` bigint(20) DEFAULT NULL COMMENT '对应分账管理基本信息表Id',
        `ledger_fund_goods_assign_id` bigint(20) DEFAULT NULL COMMENT '对应分账管理货款分配表Id',
        `billing_factoring_business_loan_record_id` bigint(20) DEFAULT NULL COMMENT '对应SOP放款记录Id',
        `sop_accounts_receivable_id` bigint(20) DEFAULT NULL COMMENT '对应SOP应收账款Id',
        `pay_coll_basic_id` bigint(20) DEFAULT NULL COMMENT '账后基础信息Id',
        `plan_factoring_id` bigint(20) DEFAULT NULL COMMENT '账后收放款计划Id(对应sop中的账后收放款计划)',
        `amount_type` varchar(50) DEFAULT '' COMMENT '金额类型',
        `plan_date` datetime DEFAULT NULL COMMENT '实际分配日期，精确到年月日',
        `actual_date` datetime DEFAULT NULL COMMENT '实际分配日期，精确到年月日',
        `plan_amount` decimal(17,2) DEFAULT '0.00' COMMENT '应分金额',
        `actual_amount` decimal(17,2) DEFAULT '0.00' COMMENT '实分配金额',
        `is_principal` tinyint(1) DEFAULT NULL COMMENT '还款金额类型是否为本金 0:否 1:是',
        `delete_flag` tinyint(1) DEFAULT NULL COMMENT '删除标识,对应收放款计划需删除',
        `user_create` varchar(50) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(50) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='分账管理-账后收放款计划分配表';

-- 分账管理-供应商与银行账户关联关系表
DROP TABLE IF EXISTS `ledger_supplier_bank_ref`;
CREATE TABLE `ledger_supplier_bank_ref` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
        `ledger_account_basic_info_id` bigint(20) DEFAULT NULL COMMENT '对应分账管理基本信息表Id',
        `supplier_bank_card_info_id` bigint(20) DEFAULT NULL COMMENT '对应供应商银行卡账户表Id',
        `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
        `user_modified` varchar(50) DEFAULT NULL COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='分账管理-供应商与银行账户关联关系表';

INSERT INTO `t_dictionary`( `name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ( '融资管理', (SELECT t.id from t_dictionary t where t.code = 'systemBusinessModel'), 'financingManagement', NULL, 20, now(), now());

-- 服务范围字典项
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('服务范围', NULL, 'serviceScope', NULL, 1, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('应收账款融资', (select t.id from t_dictionary t where t.code = 'serviceScope'), 'accountReceivableFinancing', NULL, 0, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('应收账款管理', (select t.id from t_dictionary t where t.code = 'serviceScope'), 'accountReceivableManagement', NULL, 1, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('应收账款催收', (select t.id from t_dictionary t where t.code = 'serviceScope'), 'collectionReceivables', NULL, 2, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('信用风险担保', (select t.id from t_dictionary t where t.code = 'serviceScope'), 'creditRiskGuarantee', NULL, 3, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('坏账担保', (select t.id from t_dictionary t where t.code = 'serviceScope'), 'accountReceivableOther', NULL, 4, now(), now());

-- 还款期限调整方式字典项
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('还款期限调整方式', NULL, 'repaymentAdjustment', NULL, 1, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('固定融资期限', (select t.id from t_dictionary t where t.code = 'repaymentAdjustment'), 'fixed_financing_period', NULL, 0, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('固定还款日', (select t.id from t_dictionary t where t.code = 'repaymentAdjustment'), 'fixed_repayment_date', NULL, 1, now(), now());

-- 身份类型字典项
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('身份类别', NULL, 'idType', NULL, 1, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('自然人', (select t.id from t_dictionary t where t.code = 'idType'), 'idType_1', '1', 0, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('组织机构', (select t.id from t_dictionary t where t.code = 'idType'), 'idType_2', '2', 1, now(), now());

-- 关联人证件类型字典项
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('关联人证件类型', NULL, 'certType', NULL, 1, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('户口簿', (select t.id from t_dictionary t where t.code = 'certType'), 'certType_ZYZCRY_ZYCZR_SJKZR_1_idType_1', '1', 0, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('护照', (select t.id from t_dictionary t where t.code = 'certType'), 'certType_ZYZCRY_ZYCZR_SJKZR_2_idType_1', '2', 1, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('港澳居民来往内地通行证', (select t.id from t_dictionary t where t.code = 'certType'), 'certType_ZYZCRY_ZYCZR_SJKZR_5_idType_1', '5', 2, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('台湾同胞来往内地通行证', (select t.id from t_dictionary t where t.code = 'certType'), 'certType_ZYZCRY_ZYCZR_SJKZR_6_idType_1', '6', 3, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('外国人居留证', (select t.id from t_dictionary t where t.code = 'certType'), 'certType_ZYZCRY_ZYCZR_SJKZR_8_idType_1', '8', 4, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('警官证', (select t.id from t_dictionary t where t.code = 'certType'), 'certType_ZYZCRY_ZYCZR_SJKZR_9_idType_1', '9', 5, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('香港身份证', (select t.id from t_dictionary t where t.code = 'certType'), 'certType_ZYZCRY_ZYCZR_SJKZR_A_idType_1', 'A', 6, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('澳门身份证', (select t.id from t_dictionary t where t.code = 'certType'), 'certType_ZYZCRY_ZYCZR_SJKZR_B_idType_1', 'B', 7, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('台湾身份证', (select t.id from t_dictionary t where t.code = 'certType'), 'certType_ZYZCRY_ZYCZR_SJKZR_C_idType_1', 'C', 8, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('其他证件', (select t.id from t_dictionary t where t.code = 'certType'), 'certType_ZYZCRY_ZYCZR_SJKZR_X_idType_1', 'X', 9, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('居民身份证及其他以公民身份证号为标识的证件', (select t.id from t_dictionary t where t.code = 'certType'), 'certType_ZYZCRY_ZYCZR_SJKZR_10_idType_1', '10', -1, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('军人身份证件', (select t.id from t_dictionary t where t.code = 'certType'), 'certType_ZYZCRY_ZYCZR_SJKZR_20_idType_1', '20', 11, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('中征码（原贷款卡编码）', (select t.id from t_dictionary t where t.code = 'certType'), 'certType_ZYCZR_SJKZR_SJJG_QYGLGX_QTBS_10_idType_2', '10', 12, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('统一社会信用代码', (select t.id from t_dictionary t where t.code = 'certType'), 'certType_ZYCZR_SJKZR_SJJG_QYGLGX_QTBS_20_idType_2', '20', 13, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('组织机构代码', (select t.id from t_dictionary t where t.code = 'certType'), 'certType_ZYCZR_SJKZR_SJJG_QYGLGX_QTBS_30_idType_2', '30', 14, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('工商注册号', (select t.id from t_dictionary t where t.code = 'certType'), 'QTBS_01', '01', 15, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('事业单位证书号', (select t.id from t_dictionary t where t.code = 'certType'), 'QTBS_02', '02', 16, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('社会团体登记号', (select t.id from t_dictionary t where t.code = 'certType'), 'QTBS_03', '03', 17, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('民办非企业登记号', (select t.id from t_dictionary t where t.code = 'certType'), 'QTBS_04', '04', 18, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('基金会登记号', (select t.id from t_dictionary t where t.code = 'certType'), 'QTBS_05', '05', 19, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('宗教证书登记号', (select t.id from t_dictionary t where t.code = 'certType'), 'QTBS_06', '06', 20, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('纳税人识别号（国税）', (select t.id from t_dictionary t where t.code = 'certType'), 'QTBS_41', '41', 21, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('纳税人识别号（地税）', (select t.id from t_dictionary t where t.code = 'certType'), 'QTBS_42', '42', 22, now(), now());

-- 还款责任人类型字典项
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('额度支用-还款责任人类型', NULL, 'quotaDisburseArlpType', NULL, 1, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('共同借款人', (select t.id from t_dictionary t where t.code = 'quotaDisburseArlpType'), 'arlpType_GTJKR', '1', 0, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('保证人', (select t.id from t_dictionary t where t.code = 'quotaDisburseArlpType'), 'arlpType_BZR', '2', 1, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('票据承兑人', (select t.id from t_dictionary t where t.code = 'quotaDisburseArlpType'), 'arlpType_PJCDR', '3', 2, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('应收账款债务人', (select t.id from t_dictionary t where t.code = 'quotaDisburseArlpType'), 'arlpType_YSZKZWR', '4', 3, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('供应链中核心企业', (select t.id from t_dictionary t where t.code = 'quotaDisburseArlpType'), 'arlpType_GYLZHXQY', '5', 4, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('其他', (select t.id from t_dictionary t where t.code = 'quotaDisburseArlpType'), 'arlpType_QT', '6', 5, now(), now());

-- 抵押物种类字典项
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('额度支用-抵押物种类', NULL, 'collateralType', NULL, 1, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('房产', (select t.id from t_dictionary t where t.code = 'collateralType'), 'collateralType_FC', '11', 0, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('土地使用权（包括土地附着物）', (select t.id from t_dictionary t where t.code = 'collateralType'), 'collateralType_TDSYQ', '12', 1, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('交通运输设备', (select t.id from t_dictionary t where t.code = 'collateralType'), 'collateralType_JTYSSB', '13', 2, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('机器设备', (select t.id from t_dictionary t where t.code = 'collateralType'), 'collateralType_JQSB', '14', 3, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('其他', (select t.id from t_dictionary t where t.code = 'collateralType'), 'collateralType_QT', '99', 4, now(), now());

-- 抵押物识别号类型字典项
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('额度支用-抵押物识别号类型', NULL, 'collateralIdType', NULL, 1, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('房产权证号', (select t.id from t_dictionary t where t.code = 'collateralIdType'), 'collateralIdType_FCQZH', '1', 0, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('土地使用权证号', (select t.id from t_dictionary t where t.code = 'collateralIdType'), 'collateralIdType_TDSYQZH', '2', 1, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('建设用地规划许可证号', (select t.id from t_dictionary t where t.code = 'collateralIdType'), 'collateralIdType_JSYDGHXKZH', '3', 2, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('交通工具发动机号', (select t.id from t_dictionary t where t.code = 'collateralIdType'), 'collateralIdType_JTGJFDJH', '4', 3, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('交通工具运营执照号', (select t.id from t_dictionary t where t.code = 'collateralIdType'), 'collateralIdType_JTGJYYZZH', '5', 4, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('机器设备规划型号', (select t.id from t_dictionary t where t.code = 'collateralIdType'), 'collateralIdType_JQSBGHXH', '6', 5, now(), now());

-- 质押物种类字典项
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('额度支用-质押物种类', NULL, 'pledgeType', NULL, 1, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('现金及其等价物', (select t.id from t_dictionary t where t.code = 'pledgeType'), 'pledgeType_cash', '11', 0, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('票据', (select t.id from t_dictionary t where t.code = 'pledgeType'), 'pledgeType_bill', '12', 1, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('保单', (select t.id from t_dictionary t where t.code = 'pledgeType'), 'pledgeType_guar_slip', '13', 2, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('债券', (select t.id from t_dictionary t where t.code = 'pledgeType'), 'pledgeType_bond', '14', 3, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('股权', (select t.id from t_dictionary t where t.code = 'pledgeType'), 'pledgeType_equity', '15', 4, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('基金', (select t.id from t_dictionary t where t.code = 'pledgeType'), 'pledgeType_fund', '21', 5, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('贵金属', (select t.id from t_dictionary t where t.code = 'pledgeType'), 'pledgeType_prec_meta', '22', 6, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('应收账款', (select t.id from t_dictionary t where t.code = 'pledgeType'), 'pledgeType_acco_rec', '23', 7, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('流动资产', (select t.id from t_dictionary t where t.code = 'pledgeType'), 'pledgeType_cur_assets', '24', 8, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('无形资产', (select t.id from t_dictionary t where t.code = 'pledgeType'), 'pledgeType_inta_assets', '25', 9, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('涉农质物', (select t.id from t_dictionary t where t.code = 'pledgeType'), 'pledgeType_agri_matter', '26', 10, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('其他', (select t.id from t_dictionary t where t.code = 'pledgeType'), 'pledgeType_other', '90', 11, now(), now());

-- 合同类型字典项
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('合同类型', NULL, 'contractType', NULL, 1, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('主合同', (select t.id from t_dictionary t where t.code = 'contractType'), 'firstContract', NULL, 1, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('担保函', (select t.id from t_dictionary t where t.code = 'contractType'), 'guarantee', NULL, 2, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('财产清单', (select t.id from t_dictionary t where t.code = 'contractType'), 'inventory', NULL, 3, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('动产抵押', (select t.id from t_dictionary t where t.code = 'contractType'), 'movable', NULL, 4, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('股权质押', (select t.id from t_dictionary t where t.code = 'contractType'), 'stockRight', NULL, 5, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('主合同-公司', (select t.id from t_dictionary t where t.code = 'firstContract'), 'firstContractCompany', NULL, 1, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('池保理业务合同 ', (select t.id from t_dictionary t where t.code = 'firstContractCompany'), 'poolFactoringBusinessContract', NULL, 1, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('池保理保理信息表—国内适用', (select t.id from t_dictionary t where t.code = 'firstContractCompany'), 'poolFactoringInformationDomestic', NULL, 2, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('池保理应收账款入池确认书', (select t.id from t_dictionary t where t.code = 'firstContractCompany'), 'poolFactoringAccountReceivableIntoPoolConfirm', NULL, 3, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('池保理保理融资确认书', (select t.id from t_dictionary t where t.code = 'firstContractCompany'), 'poolFactoringFinancingConfirm', NULL, 4, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('池保理应收账款转让通知书—国内适用-明保理适用', (select t.id from t_dictionary t where t.code = 'firstContractCompany'), 'accountReceivableTransferNoticeDomesticBright', NULL, 5, now(), now());
INSERT INTO `t_dictionary` (`name`, `parentId`, `code`, `value`, `gradation`, `gmt_create`, `gmt_modified`)
VALUES ('三方协议（贸理通）', (select t.id from t_dictionary t where t.code = 'firstContractCompany'), 'tripartiteAgreementFactoring', NULL, 6, now(), now());

-- 融资管理权限配置
INSERT INTO `t_permission`( `type`, `cname`, `ename`, `gradation`, `moduleName`,`url`, `icon`)
VALUES ( 'menu', '融资管理', 'FinancingManage', 8, NULL, NULL, 1);
INSERT INTO `t_permission`(`parentId`, `type`, `cname`, `ename`, `gradation`, `moduleName`, `url`, `icon`)
VALUES ((SELECT t.id FROM t_permission t WHERE t.ename = 'FinancingManage'), 'button', '数据可见-查看全员', 'viewAllFinancingManage', 0, '融资管理', NULL, NULL);
INSERT INTO `t_permission`( `parentId`, `type`, `cname`, `ename`, `gradation`, `moduleName`, `url`, `icon`)
VALUES ( (SELECT t.id FROM t_permission t WHERE t.ename = 'FinancingManage'), 'button', '查看', 'viewFinancingManage', 1, '融资管理', NULL, NULL);
INSERT INTO `t_permission`( `parentId`, `type`, `cname`, `ename`, `gradation`, `moduleName`, `url`, `icon`)
VALUES ( (SELECT t.id FROM t_permission t WHERE t.ename = 'FinancingManage'), 'button', '资金置换', 'fundExchange', 2, '融资管理', NULL, NULL);
INSERT INTO `t_permission`( `parentId`, `type`, `cname`, `ename`, `gradation`, `moduleName`, `url`, `icon`)
VALUES ( (SELECT t.id FROM t_permission t WHERE t.ename = 'FinancingManage'), 'button', '终止', 'terminateFinancing', 3, '融资管理', NULL, NULL);
INSERT INTO `t_permission`( `parentId`, `type`, `cname`, `ename`, `gradation`, `moduleName`, `url`, `icon`)
VALUES ( (SELECT t.id FROM t_permission t WHERE t.ename = 'FinancingManage'), 'button', '支用文件下载', 'quotaDisburseFileDownload', 1, '融资管理', NULL, NULL);
INSERT INTO `t_permission`( `parentId`, `type`, `cname`, `ename`, `gradation`, `moduleName`, `url`, `icon`)
VALUES ( (SELECT t.id FROM t_permission t WHERE t.ename = 'FinancingManage'), 'button', '合同文件下载', 'contractFileDownload', 2, '融资管理', NULL, NULL);
INSERT INTO `t_permission`( `parentId`, `type`, `cname`, `ename`, `gradation`, `moduleName`, `url`, `icon`)
VALUES ( (SELECT t.id FROM t_permission t WHERE t.ename = 'FinancingManage'), 'button', '合同出证文件下载', 'contractCertificateFileDownload', 3, '融资管理', NULL, NULL);
INSERT INTO `t_permission`( `parentId`, `type`, `cname`, `ename`, `gradation`, `moduleName`, `url`, `icon`)
VALUES ( (SELECT t.id FROM t_permission t WHERE t.ename = 'FinancingManage'), 'button', '付款文件下载', 'paymentFileDownload', 3, '融资管理', NULL, NULL);
INSERT INTO `t_permission`( `parentId`, `type`, `cname`, `ename`, `gradation`, `moduleName`, `url`, `icon`)
VALUES ( (SELECT t.id FROM t_permission t WHERE t.ename = 'FinancingManage'), 'button', '生成新的合同签署链接', 'generateContractSignLink', 3, '融资管理', NULL, NULL);
INSERT INTO `t_permission`( `parentId`, `type`, `cname`, `ename`, `gradation`, `moduleName`, `url`, `icon`)
VALUES ( (SELECT t.id FROM t_permission t WHERE t.ename = 'FinancingManage'), 'button', '重新下载合同签署文件', 'reDownloadContractSignFile', 3, '融资管理', NULL, NULL);

-------------------------------------- 2024.3.2已执行 ---------------------------------------------------------
INSERT INTO `t_permission`( `type`, `cname`, `ename`, `gradation`, `moduleName`,`url`, `icon`)
VALUES ( 'menu', '分账管理', 'DivideAccountsManage', 9, NULL, NULL, 1);
INSERT INTO `t_permission`(`parentId`, `type`, `cname`, `ename`, `gradation`, `moduleName`, `url`, `icon`)
VALUES ((SELECT t.id FROM t_permission t WHERE t.ename = 'DivideAccountsManage'), 'button', '查看', 'viewLedger', 0, '分账管理', NULL, NULL);
INSERT INTO `t_permission`(`parentId`, `type`, `cname`, `ename`, `gradation`, `moduleName`, `url`, `icon`)
VALUES ((SELECT t.id FROM t_permission t WHERE t.ename = 'DivideAccountsManage'), 'button', '编辑', 'editLedger', 1, '分账管理', NULL, NULL);
INSERT INTO `t_permission`(`parentId`, `type`, `cname`, `ename`, `gradation`, `moduleName`, `url`, `icon`)
VALUES ((SELECT t.id FROM t_permission t WHERE t.ename = 'DivideAccountsManage'), 'button', '数据可见-查看全员', 'viewAllLedger', 2, '分账管理', NULL, NULL);

-- 现金流管理-基础信息表增加字段
ALTER TABLE `cash_flow_manage_basic_info` ADD `ledger_fund_goods_assign_id` bigint(20) DEFAULT NULL COMMENT '对应分账管理货物分配表Id';

-- 现金流管理-出账信息表
DROP TABLE IF EXISTS `cash_flow_manage_out_info`;
CREATE TABLE `cash_flow_manage_out_info` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
        `cash_flow_manage_basic_info_id` bigint(20) NOT NULL COMMENT '现金流管理基础信息表Id',
        `loan_date` datetime DEFAULT NULL COMMENT '此次放款日期',
        `loan_amount` decimal(17,2) DEFAULT '0.00' COMMENT '此次放款金额',
        `from_company_belong` bigint(20) DEFAULT NULL COMMENT '打款账户--归属公司',
        `from_bank_name` varchar(256) NOT NULL COMMENT '打款账户--银行名称',
        `from_bank_account` varchar(64) NOT NULL COMMENT '打款账户--银行卡号',
        `to_company_belong` bigint(20) DEFAULT NULL COMMENT '收款账户--归属公司',
        `to_bank_name` varchar(256) DEFAULT NULL COMMENT '收款账户--银行名称',
        `to_bank_account` varchar(64) DEFAULT NULL COMMENT '收款账户--银行卡号',
        `curr_executor` varchar(50) DEFAULT NULL COMMENT '当前执行人',
        `file_text` mediumtext COMMENT '附件富文本',
        `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
        `user_modified` varchar(50) DEFAULT NULL COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='现金流管理-出账信息表';

-- 合同管理-基础交易合同信息（三方协议）-历史
DROP TABLE IF EXISTS `contract_basic_contract_his`;
CREATE TABLE `contract_basic_contract_his` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `contract_info_id` bigint(20) unsigned DEFAULT '0' COMMENT '合同基础信息ID',
        `tripartite_agreement_no` varchar(50) DEFAULT '' COMMENT '三方协议编号:按规则生成',
        `debtor_company_id` bigint(20) unsigned DEFAULT '0' COMMENT '债务人公司ID',
        `debtor_company_name` varchar(50) DEFAULT '' COMMENT '债务人公司名称',
        `debtor_social_credit_code` varchar(50) DEFAULT '' COMMENT '债务人统一社会信用码',
        `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        `special_agreement` varchar(5000) DEFAULT '' COMMENT '特殊约定',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='合同:基础交易合同信息（三方协议）-历史';

-- 合同管理-基础交易合同信息（三方协议）-历史
DROP TABLE IF EXISTS `contract_basic_contract_change_content_his`;
CREATE TABLE `contract_basic_contract_change_content_his` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        `contract_info_id` bigint(20) unsigned DEFAULT '0' COMMENT '合同基础信息ID',
        `contract_basic_contract_his_id` bigint(20) unsigned DEFAULT '0' COMMENT '合同基础交易合同信息（三方协议）的历史ID',
        `underlying_assets_id` bigint(20) unsigned DEFAULT '0' COMMENT '所选的底层资产的ID：国内或者出口',
        `contract_no` varchar(50) DEFAULT '' COMMENT '基础交易合同编号:获取的是所选应收账款中的合同编号',
        `contract_name` varchar(50) DEFAULT '' COMMENT '基础交易合同名称:获取的是所选应收账款中的合同名称',
        `original_contract_content` varchar(500) DEFAULT '' COMMENT '原合同内容',
        `post_change_content` varchar(500) DEFAULT '' COMMENT '变更后内容',
        `user_create` varchar(32) DEFAULT '' COMMENT '创建人',
        `user_modified` varchar(32) DEFAULT '' COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        `special_agreement_basic` varchar(100) DEFAULT NULL COMMENT '其他特殊约定-固定内容',
        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='合同:基础交易合同信息（三方协议）变更内容-历史';


-- 分账管理-供应商银行卡账户信息表
DROP TABLE IF EXISTS `supplier_bank_card_info`;
CREATE TABLE `supplier_bank_card_info` (
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
        `ledger_account_basic_info_id` bigint(20) DEFAULT NULL COMMENT '对应分账管理基本信息表Id',
        `supplier_id` bigint(20) DEFAULT NULL COMMENT '供应商Id',
        `supplier_name` varchar(100) DEFAULT NULL COMMENT '供应商Id',
        `bank_name` varchar(50) NOT NULL COMMENT '所属银行',
        `account_name` varchar(50) NOT NULL COMMENT '账户名称',
        `account_number` varchar(50) DEFAULT NULL COMMENT '账号',
        `user_create` varchar(50) DEFAULT NULL COMMENT '创建人',
        `user_modified` varchar(50) DEFAULT NULL COMMENT '修改人',
        `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
        PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='供应商银行卡账户信息表';


-- 修改公司归属字典项
UPDATE `t_dictionary` SET name = '长安银科资产管理有限公司' where code = 'zi_guan';
UPDATE `t_dictionary` SET name = '长安银科商业保理有限公司' where code = 'factoring';
UPDATE `t_dictionary` SET name = '西安银叶科技服务有限公司' where code = 'investment';
UPDATE `t_dictionary` SET name = '西安长银保国际贸易有限公司' where code = 'xi_an_ao_hong';
UPDATE `t_dictionary` SET name = '上海敖洪商贸有限公司' where code = 'shang_hai_ao_hong';

