CREATE TABLE `settlement_approval` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `settlement_basic_info_id` bigint(20) DEFAULT NULL COMMENT '结算单基础信息表id',
  `approval_comment` varchar(3000) DEFAULT '' COMMENT '审批意见',
  `approval_conclusion` varchar(50) NOT NULL COMMENT '审批结论',
  `auditor_id` bigint(20) unsigned DEFAULT '0' 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 AUTO_INCREMENT=311 DEFAULT CHARSET=utf8 COMMENT='结算单-审核表';

CREATE TABLE `settlement_his_goods_info` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `settlement_his_info_id` bigint(20) NOT NULL COMMENT '结算单历史信息表ID',
  `acceptance_basic_info_id` bigint(20) NOT NULL COMMENT '验收单基础信息表ID',
  `acceptance_goods_info_id` bigint(20) NOT NULL COMMENT '验收单货物信息表ID',
  `sales_price` decimal(17,4) DEFAULT NULL COMMENT '销售单价',
  `sales_total_price` decimal(17,4) DEFAULT NULL COMMENT '销售总价',
  `sales_guarantee_money` decimal(17,4) DEFAULT NULL COMMENT '销售质保金',
  `purchase_price` decimal(17,4) DEFAULT NULL COMMENT '采购单价',
  `purchase_total_price` decimal(17,4) DEFAULT NULL COMMENT '采购总价',
  `purchase_guarantee_money` decimal(17,4) 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 '修改时间',
  `reference_price` decimal(17,2) DEFAULT NULL COMMENT '参考价格',
  `floating_price` decimal(17,2) DEFAULT NULL COMMENT '浮动价格',
  `acceptance_goods_number` varchar(30) DEFAULT NULL COMMENT '验收单编号',
  `goods_quantity` decimal(17,4) DEFAULT NULL COMMENT '数量',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=5807 DEFAULT CHARSET=utf8 COMMENT='结算单-下游历史结算货物信息表';


CREATE TABLE `settlement_his_info` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `settlement_basic_info_id` bigint(20) NOT NULL COMMENT '结算单基础信息表ID',
  `settlement_number` varchar(50) DEFAULT NULL COMMENT '结算单号',
  `business_number` varchar(50) DEFAULT NULL COMMENT '业务编号',
  `supplier_id` bigint(20) DEFAULT NULL COMMENT '供应商Id',
  `enterprise_customer_info_id` bigint(20) DEFAULT NULL COMMENT '核心企业Id',
  `trading_platform_id` bigint(20) DEFAULT NULL COMMENT '贸易平台Id',
  `settlement_date` datetime DEFAULT NULL COMMENT '结算日期',
  `settlement_amount` decimal(17,2) DEFAULT NULL COMMENT '结算金额',
  `settlement_start_date` datetime DEFAULT NULL COMMENT '对账开始日期',
  `settlement_end_date` datetime DEFAULT NULL COMMENT '对账结束日期',
  `operator_supplier` varchar(200) DEFAULT NULL COMMENT '经办人（供应商）',
  `operator_enterprise` varchar(200) DEFAULT NULL COMMENT '经办人（核心企业）',
  `additional_remarks` varchar(500) 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 '修改时间',
  `business_name` varchar(50) DEFAULT '' COMMENT '业务名称',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=586 DEFAULT CHARSET=utf8 COMMENT='结算单-历史信息表';


CREATE TABLE `settlement_his_repayment_plan` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `settlement_his_info_id` bigint(20) NOT NULL COMMENT '结算单历史信息表ID',
  `repayment_amount` decimal(17,2) DEFAULT NULL COMMENT '回款金额',
  `repayment_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`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=344 DEFAULT CHARSET=utf8 COMMENT='结算单-历史回款计划表';


CREATE TABLE `invoice_approval` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `invoice_basic_info_id` bigint(20) DEFAULT NULL COMMENT '发票基础信息表ID',
  `approval_comment` varchar(3000) DEFAULT '' COMMENT '审批意见',
  `approval_conclusion` varchar(50) NOT NULL COMMENT '审批结论',
  `auditor_id` bigint(20) unsigned DEFAULT '0' 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 AUTO_INCREMENT=215 DEFAULT CHARSET=utf8 COMMENT='发票管理-审核表';

CREATE TABLE `invoice_his_goods_info` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `invoice_his_info_id` bigint(20) DEFAULT NULL COMMENT '发票历史信息表ID',
  `settlement_basic_info_id` bigint(20) DEFAULT NULL COMMENT '结算单基础信息表ID',
  `settlement_goods_info_id` bigint(20) DEFAULT NULL COMMENT '结算单货物信息表ID',
  `settlement_number` varchar(50) DEFAULT NULL COMMENT '验收单编号',
  `goods_name` varchar(500) DEFAULT NULL COMMENT '货物名称',
  `goods_factory` varchar(500) DEFAULT NULL COMMENT '厂家',
  `goods_type` varchar(500) DEFAULT NULL COMMENT '型号',
  `goods_unit` varchar(500) DEFAULT NULL COMMENT '单位',
  `goods_quantity` decimal(17,4) DEFAULT NULL COMMENT '数量',
  `sales_price` decimal(17,2) DEFAULT NULL COMMENT '销售单价',
  `sales_total_price` decimal(17,2) DEFAULT NULL COMMENT '销售总价',
  `open_quantity` decimal(17,4) DEFAULT NULL COMMENT '开票数量',
  `open_amount` decimal(17,2) 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 AUTO_INCREMENT=4993 DEFAULT CHARSET=utf8 COMMENT='发票管理-货物历史信息表';

CREATE TABLE `invoice_his_info` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `invoice_basic_info_id` bigint(20) DEFAULT NULL COMMENT '发票基础信息表ID',
  `business_number` varchar(50) DEFAULT NULL COMMENT '业务编号',
  `enterprise_customer_info_id` bigint(20) DEFAULT NULL COMMENT '核心企业Id',
  `trading_platform_id` bigint(20) DEFAULT NULL COMMENT '贸易平台Id',
  `tax_identify_number` varchar(64) DEFAULT NULL COMMENT '纳税识别号',
  `address` varchar(500) DEFAULT NULL COMMENT '地址',
  `phone` varchar(50) DEFAULT NULL COMMENT '电话',
  `account_bank_name` varchar(500) DEFAULT NULL COMMENT '开户行名称',
  `account_number` varchar(50) DEFAULT NULL COMMENT '开户账号',
  `invoice_type` varchar(50) DEFAULT NULL COMMENT '发票类型',
  `amount_kind` varbinary(50) DEFAULT NULL COMMENT '金额种类',
  `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  `open_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 '修改时间',
  `product_broad_info` varchar(255) DEFAULT NULL COMMENT '商品大类信息',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=230 DEFAULT CHARSET=utf8 COMMENT='发票管理-历史信息表';


CREATE TABLE `invoice_his_possession_cost_info` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `invoice_his_info_id` bigint(20) DEFAULT NULL COMMENT '发票历史信息表ID',
  `possession_cost_type` bigint(20) DEFAULT NULL COMMENT '资金占用费类型',
  `possession_cost` decimal(17,2) 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 AUTO_INCREMENT=188 DEFAULT CHARSET=utf8 COMMENT='发票管理-资金占用费历史信息表';

CREATE TABLE `invoice_his_supplier_info` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `invoice_his_info_id` bigint(20) DEFAULT NULL COMMENT '发票历史信息表ID',
  `supplier_id` bigint(20) DEFAULT NULL COMMENT '供应商Id',
  `supplier_name` varchar(50) DEFAULT NULL COMMENT '供应商名称',
  `open_amount` decimal(17,2) 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='发票管理-供应商历史信息表';

CREATE TABLE `invoice_possession_cost_info` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `invoice_basic_info_id` bigint(20) DEFAULT NULL COMMENT '发票基础信息表ID',
  `possession_cost_type` bigint(20) DEFAULT NULL COMMENT '资金占用费类型',
  `possession_cost` decimal(17,2) 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 AUTO_INCREMENT=202 DEFAULT CHARSET=utf8 COMMENT='发票管理-资金占用费信息表';

CREATE TABLE `invoice_supplier_info` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `invoice_basic_info_id` bigint(20) DEFAULT NULL COMMENT '发票基础信息表ID',
  `supplier_id` bigint(20) DEFAULT NULL COMMENT '供应商Id',
  `supplier_name` varchar(50) DEFAULT NULL COMMENT '供应商名称',
  `open_amount` decimal(17,2) 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='发票管理-供应商信息表';