DROP TABLE IF EXISTS `c_bidding_basic_info`;
CREATE TABLE `c_bidding_basic_info`
(
    `id`                       bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `c_project_information_id` bigint(20)                   DEFAULT NULL COMMENT '项目Id',
    `business_number`          varchar(250)                 DEFAULT NULL COMMENT '业务编号',
    `trading_platform_id`      bigint(20)                   DEFAULT NULL COMMENT '贸易平台Id',
    `prequalification`         tinyint(3)                   DEFAULT NULL COMMENT '是否资格预审 0否  1是',
    `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 '修改时间',
    `stage`                    varchar(32)                  DEFAULT '' COMMENT '业务当前阶段',
    `status`                   varchar(32)                  DEFAULT '' COMMENT '业务状态',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB COMMENT ='招投标管理基本信息表';

DROP TABLE IF EXISTS `bidding_basic_info_his`;
CREATE TABLE `bidding_basic_info_his`
(
    `id`                       bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `c_bidding_basic_info_id`  bigint(20)                   DEFAULT NULL COMMENT '招投标管理基本信息表id',
    `business_number`          varchar(250)                 DEFAULT NULL COMMENT '业务编号',
    `c_project_information_id` bigint(20)                   DEFAULT NULL COMMENT '项目Id',
    `trading_platform_id`      bigint(20)                   DEFAULT NULL COMMENT '贸易平台Id',
    `prequalification`         tinyint(3)                   DEFAULT NULL COMMENT '是否资格预审 0否  1是',
    `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`) USING BTREE
) ENGINE = InnoDB COMMENT ='招投标管理基本信息历史表';

DROP TABLE IF EXISTS `bidding_template_review`;
CREATE TABLE `bidding_template_review`
(
    `id`                    bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `bidding_basic_info_id` bigint(20)          NOT NULL COMMENT '招投标管理基本信息表Id',
    `conclusion`            tinyint(3)                            DEFAULT NULL COMMENT '审批结论 0驳回 1通过 ',
    `comments`              varchar(1024) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '审批意见',
    `user_create`           varchar(32) COLLATE utf8_unicode_ci   DEFAULT '' COMMENT '创建人',
    `user_modified`         varchar(32) COLLATE utf8_unicode_ci   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 COMMENT ='招投标管理模板审核信息表';

DROP TABLE IF EXISTS `bidding_guarantee_method`;
CREATE TABLE `bidding_guarantee_method`
(
    `id`                    bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `bidding_basic_info_id` bigint(20)          NOT NULL COMMENT '招投标管理基本信息表Id',
    `tender_method`         tinyint(3)                          DEFAULT NULL COMMENT ' 投标方式 0线下装订 1线上上传',
    `bid_guarantee_method`  tinyint(3)                          DEFAULT NULL COMMENT ' 投标保证方式 0保证金 1保函 2其他',
    `deposit_amount`        bigint(20)                          DEFAULT NULL COMMENT '保证金金额',
    `user_create`           varchar(32) COLLATE utf8_unicode_ci 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`) USING BTREE
) ENGINE = InnoDB COMMENT ='招投标管理-保证方式确认表';

DROP TABLE IF EXISTS `bidding_bond_collection_confirmation`;
CREATE TABLE `bidding_bond_collection_confirmation`
(
    `id`                    bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `bidding_basic_info_id` bigint(20)          NOT NULL COMMENT '招投标管理基本信息表Id',
    `deposit_collection`    tinyint(3)                   DEFAULT NULL COMMENT ' 保证金收款  1确认',
    `comments`              varchar(1024)                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`) USING BTREE
) ENGINE = InnoDB COMMENT ='招投标管理-保证金收款确认表';

DROP TABLE IF EXISTS `bidding_award_confirm`;
CREATE TABLE `bidding_award_confirm`
(
    `id`                    bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `bidding_basic_info_id` bigint(20)          NOT NULL COMMENT '招投标管理基本信息表Id',
    `win_the_bidding`       tinyint(3)                   DEFAULT NULL COMMENT ' 是否中标 0未中标 1中标',
    `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`) USING BTREE
) ENGINE = InnoDB COMMENT ='业务管理-中标确认表';

DROP TABLE IF EXISTS `bidding_refund_deposit_confirmation`;
CREATE TABLE `bidding_refund_deposit_confirmation`
(
    `id`                    bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `bidding_basic_info_id` bigint(20)          NOT NULL COMMENT '招投标管理基本信息表Id',
    `refund_deposit`        tinyint(3)                   DEFAULT NULL COMMENT ' 保证金退还  1确认',
    `deposit_amount`        bigint(20)                   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`) USING BTREE
) ENGINE = InnoDB COMMENT ='招投标管理-保证金退款确认表';


DROP TABLE IF EXISTS `c_sales_contract_management`;
CREATE TABLE `c_sales_contract_management`
(
    `id`                       bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `c_project_information_id` bigint(20)                   DEFAULT NULL COMMENT '项目Id',
    `business_number`          varchar(50)         NOT NULL COMMENT '业务编号',
    `trading_platform_id`      bigint(20)                   DEFAULT NULL COMMENT '贸易平台Id',
    `contract_status`          varchar(32)                  DEFAULT '' COMMENT '合同状态（已创建，已录入，已驳回，已审核，已变更，已驳回（变更），已审核（变更））',
    `stage`                    varchar(32)                  DEFAULT '' COMMENT '当前阶段',
    `is_change`                tinyint(1)                   DEFAULT '0' COMMENT '是否发生变更标识、默认为否',
    `customer_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 COMMENT ='销售合同管理表';

DROP TABLE IF EXISTS `sales_contract_management_his`;
CREATE TABLE `sales_contract_management_his`
(
    `id`                             bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `c_sales_contract_management_id` bigint(20)                   DEFAULT NULL COMMENT '销售合同管理Id',
    `business_number`                varchar(50)         NOT NULL COMMENT '业务编号',
    `trading_platform_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 COMMENT ='销售合同管理历史表';

DROP TABLE IF EXISTS `sales_contract_approval_condition_dic`;
CREATE TABLE `sales_contract_approval_condition_dic`
(
    `id`             bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `approval_type`  tinyint(1)                   DEFAULT '0' COMMENT '审核类别 0 形式审查 1 内容审查',
    `approval_point` varchar(200)                 DEFAULT '' COMMENT '审核要点',
    `loan_condition` varchar(200)                 DEFAULT '' 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 COMMENT ='销售合同-模板初审(基础交易合同)-字典表';

DROP TABLE IF EXISTS `sales_contract_template_first_approval_info`;
CREATE TABLE `sales_contract_template_first_approval_info`
(
    `id`                             bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `c_sales_contract_management_id` bigint(20)                   DEFAULT NULL COMMENT '销售合同管理Id',
    `approval_conclusion`            varchar(50)         NOT 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 COMMENT ='销售合同-模板初审表';

DROP TABLE IF EXISTS `sales_contract_template_first_approval_comment_info`;
CREATE TABLE `sales_contract_template_first_approval_comment_info`
(
    `id`                                             bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `sales_contract_template_first_approval_info_id` bigint(20)                   DEFAULT NULL COMMENT '销售合同-模板初审Id',
    `approval_comment`                               varchar(50)         NOT 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 COMMENT ='销售合同-模板初审-审批意见表';

DROP TABLE IF EXISTS `sales_contract_template_again_approval_info`;
CREATE TABLE `sales_contract_template_again_approval_info`
(
    `id`                             bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `c_sales_contract_management_id` bigint(20)                   DEFAULT NULL COMMENT '销售合同管理Id',
    `approval_conclusion`            varchar(50)         NOT 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 COMMENT ='销售合同-模板复审表';

DROP TABLE IF EXISTS `sales_contract_template_again_approval_comment_info`;
CREATE TABLE `sales_contract_template_again_approval_comment_info`
(
    `id`                                             bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `sales_contract_template_again_approval_info_id` bigint(20)                   DEFAULT NULL COMMENT '销售合同-模板复审Id',
    `approval_comment`                               varchar(50)         NOT 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 COMMENT ='销售合同-模板复审-审批意见表';

DROP TABLE IF EXISTS `c_sales_contract_basic_info`;
CREATE TABLE `c_sales_contract_basic_info`
(
    `id`                             bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `c_sales_contract_management_id` bigint(20)                   DEFAULT NULL COMMENT '销售合同管理Id',
    `contract_number`                varchar(50)                  DEFAULT NULL COMMENT '合同编号',
    `contract_name`                  varchar(100)        NOT NULL COMMENT '合同名称',
    `contract_plan_amount_type`      tinyint(1)                   DEFAULT 0 COMMENT '合同约定金额类型（0固定金额、1适时网价）',
    `is_performance_bond`            tinyint(1)                   DEFAULT NULL COMMENT '是否有履约保证金，0:无 1:有',
    `is_retention`                   tinyint(1)                   DEFAULT NULL COMMENT '是否有质保金，0:无 1:有',
    `retention_percent`              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 COMMENT ='销售合同-基本信息表';

DROP TABLE IF EXISTS `sales_contract_approval`;
CREATE TABLE `sales_contract_approval`
(
    `id`                             bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `c_sales_contract_basic_info_id` bigint(20) unsigned          DEFAULT '0' COMMENT '销售合同基本信息表Id',
    `approval_comment`               varchar(3000)                DEFAULT '' COMMENT '审批意见',
    `approval_conclusion`            varchar(50)         NOT NULL COMMENT '审批结论',
    `auditor_id`                     bigint(20) unsigned          DEFAULT '0' COMMENT '审核人Id',
    `settle_cycle_method`            varchar(100)                   DEFAULT NULL COMMENT '结算周期方式（自然月、固定天数）',
    `settle_cycle`                   int(10)                      DEFAULT NULL COMMENT '结算周期',
    `performance_bond_limit`         varchar(100)                 DEFAULT NULL COMMENT '履约保证金上限',
    `sign_confirm`                   tinyint(3)                   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`) USING BTREE
) ENGINE = InnoDB COMMENT ='销售合同-审核表';

DROP TABLE IF EXISTS `sales_contract_retention_info`;
CREATE TABLE `sales_contract_retention_info`
(
    `id`                         bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `sales_contract_approval_id` bigint(20)          NOT NULL COMMENT '销售合同-审核表Id',
    `is_retention`               tinyint(1)                   DEFAULT NULL COMMENT '是否有质保金，0:无 1:有',
    `retention_percent`          decimal(17, 2)               DEFAULT NULL COMMENT '质保金比例',
    `is_limit`                   tinyint(1)                   DEFAULT NULL COMMENT '质保金是否有上限，0:无 1:有',
    `retention_limit`            decimal(17, 2)               DEFAULT NULL COMMENT '质保金上限',
    `release_method`             varchar(200)                 DEFAULT NULL COMMENT '质保金释放规则',
    `retention_period`           varchar(100)                 DEFAULT '' 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 COMMENT ='销售合同-质保金信息表';

DROP TABLE IF EXISTS `c_sales_sign_confirmation`;
CREATE TABLE `c_sales_sign_confirmation`
(
    `id`                             bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `c_sales_contract_management_id` bigint(20)                   DEFAULT NULL COMMENT '销售合同管理Id',
    `contract_link`                  varchar(2048)                DEFAULT NULL COMMENT '合同链接',
    `short_contract_link`            varchar(1024)                DEFAULT NULL COMMENT '客户合同链接短连接',
    `short_contract_link_create`     timestamp           NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '短链接创建时间',
    `sign_conclusion`                tinyint(1)                   DEFAULT NULL COMMENT '签署结论 1完成',
    `remark`                         varchar(1024)                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 COMMENT ='销售合同-签署确认表';

DROP TABLE IF EXISTS `c_sign_confirmation_electronic_info`;
CREATE TABLE `c_sign_confirmation_electronic_info`
(
    `id`                               bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `c_sales_sign_confirmation_id`     bigint(20)          NOT NULL COMMENT '销售合同-签署确认表Id',
    `contract_name`                    varchar(50)                  DEFAULT NULL COMMENT '合同名称',
    `contract_id`                      varchar(500)                 DEFAULT NULL COMMENT '合同id',
    `file_id`                          bigint(20)                   DEFAULT NULL COMMENT '电子签文件',
    `electronic_signature_personal_id` bigint(20)          NOT NULL COMMENT '电子签个人信息表Id',
    `transaction_id`                   varchar(255)                 DEFAULT NULL COMMENT '客户合同交易id',
    `sign_status`                      tinyint(1)                   DEFAULT NULL COMMENT '客户签署状态',
    `back_file_id`                     bigint(20)                   DEFAULT NULL COMMENT '电子签回调文件',
    `report_file_id`                   bigint(20)                   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 COMMENT ='销售合同-签署确认合同信息';

DROP TABLE IF EXISTS `sign_confirmation_approval`;
CREATE TABLE `sign_confirmation_approval`
(
    `id`                             bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `c_sales_contract_management_id` bigint(20)                   DEFAULT 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 COMMENT ='销售合同-签署确认审核表';

DROP TABLE IF EXISTS `sales_contract_template_first_approval_info`;
CREATE TABLE `sales_contract_template_first_approval_info`
(
    `id`                                       bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `c_sales_contract_management_id`           bigint(20)                   DEFAULT NULL COMMENT '销售合同管理Id',
    `sales_contract_approval_condition_dic_id` bigint(20)                   DEFAULT NULL COMMENT '模板初审(基础交易合同)-字典Id',
    `is_agree`                                 tinyint(1)                   DEFAULT '0' COMMENT '是否满足 1 是 0 否',
    `approval_conclusion`                      varchar(50)         NOT 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 COMMENT ='销售合同-模板初审表';

DROP TABLE IF EXISTS `sales_contract_basic_info_history`;
CREATE TABLE `sales_contract_basic_info_history`
(
    `id`                             bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `c_sales_contract_management_id` bigint(20)                   DEFAULT NULL COMMENT '销售合同管理Id',
    `contract_number`                varchar(50)                  DEFAULT NULL COMMENT '合同编号',
    `contract_name`                  varchar(100)        NOT NULL COMMENT '合同名称',
    `contract_plan_amount_type`      varchar(32)                  DEFAULT '' COMMENT '合同约定金额类型（固定金额、适时网价）',
    `is_performance_bond`            tinyint(1)                   DEFAULT NULL COMMENT '是否有履约保证金，0:无 1:有',
    `is_retention`                   tinyint(1)                   DEFAULT NULL COMMENT '是否有质保金，0:无 1:有',
    `retention_percent`              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 COMMENT ='销售合同-基本信息历史表';

DROP TABLE IF EXISTS `c_sales_contract_person_info`;
CREATE TABLE `c_sales_contract_person_info`
(
    `id`                             bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `c_sales_contract_basic_info_id` bigint(20)          NOT NULL COMMENT '销售合同管理Id',
    `name`                           varchar(50)                  DEFAULT NULL COMMENT '用户名',
    `type`                           varchar(50)                  DEFAULT '' COMMENT '人员类型',
    `mobile`                         varchar(50)                  DEFAULT NULL COMMENT '联系电话',
    `remark`                         varchar(1024)                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 COMMENT ='销售合同-人员信息';

DROP TABLE IF EXISTS `sales_contract_person_info_history`;
CREATE TABLE `sales_contract_person_info_history`
(
    `id`                                   bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `sales_contract_basic_info_history_id` bigint(20)          NOT NULL COMMENT '销售合同基础信息历史Id',
    `name`                                 varchar(50)                  DEFAULT NULL COMMENT '用户名',
    `type`                                 varchar(50)                  DEFAULT '' COMMENT '人员类型',
    `mobile`                               varchar(50)                  DEFAULT NULL COMMENT '联系电话',
    `remark`                               varchar(1024)                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 COMMENT ='销售合同-人员信息历史表';


DROP TABLE IF EXISTS `c_sales_contract_goods_info`;
CREATE TABLE `c_sales_contract_goods_info`
(
    `id`                             bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `c_sales_contract_basic_info_id` bigint(20)          NOT NULL COMMENT '销售合同基本信息表Id',
    `goods_name`                     varchar(500)        NOT NULL COMMENT '货物名称',
    `goods_factory`                  varchar(500)        NOT NULL COMMENT '厂家',
    `model_number`                   varchar(500)        NOT NULL COMMENT '型号',
    `units`                          varchar(10)         NOT NULL COMMENT '单位',
    `quantity`                       varchar(500)                 DEFAULT NULL COMMENT '数量',
    `is_clear_price`                 tinyint(1)                   DEFAULT NULL COMMENT '是否明确单价，0:否 1:是',
    `sales_price`                    varchar(50)                  DEFAULT NULL COMMENT '销售单价',
    `remark`                         varchar(500)                 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 COMMENT ='销售合同-货物信息表';

DROP TABLE IF EXISTS `sales_contract_goods_info_history`;
CREATE TABLE `sales_contract_goods_info_history`
(
    `id`                                   bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `sales_contract_basic_info_history_id` bigint(20)          NOT NULL COMMENT '销售合同基本信息历史表Id',
    `goods_name`                           varchar(500)        NOT NULL COMMENT '货物名称',
    `goods_factory`                        varchar(500)        NOT NULL COMMENT '厂家',
    `model_number`                         varchar(500)        NOT NULL COMMENT '型号',
    `units`                                varchar(10)         NOT NULL COMMENT '单位',
    `quantity`                             varchar(500)                 DEFAULT NULL COMMENT '数量',
    `is_clear_price`                       tinyint(1)                   DEFAULT NULL COMMENT '是否明确单价，0:否 1:是',
    `sales_price`                          varchar(50)                  DEFAULT NULL COMMENT '销售单价',
    `remark`                               varchar(500)                 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 COMMENT ='销售合同-货物信息历史表';

DROP TABLE IF EXISTS `sales_contract_retention_info`;
CREATE TABLE `sales_contract_retention_info`
(
    `id`                         bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `sales_contract_approval_id` bigint(20)          NOT NULL COMMENT '销售合同-审核表Id',
    `is_retention`               tinyint(1)                   DEFAULT NULL COMMENT '是否有质保金，0:无 1:有',
    `retention_percent`          decimal(17, 2)               DEFAULT NULL COMMENT '质保金比例',
    `is_limit`                   tinyint(1)                   DEFAULT NULL COMMENT '质保金是否有上限，0:无 1:有',
    `retention_limit`            decimal(17, 2)               DEFAULT NULL COMMENT '质保金上限',
    `release_method`             varchar(200)                 DEFAULT NULL COMMENT '质保金释放规则',
    `retention_period`           varchar(100)                 DEFAULT '' 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 COMMENT ='销售合同-质保金信息表';

DROP TABLE IF EXISTS `c_sales_sign_confirmation`;
CREATE TABLE `c_sales_sign_confirmation`
(
    `id`                             bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `c_sales_contract_management_id` bigint(20)                   DEFAULT NULL COMMENT '销售合同管理Id',
    `contract_link`                  varchar(2048)                DEFAULT NULL COMMENT '合同链接',
    `short_contract_link`            varchar(1024)                DEFAULT NULL COMMENT '客户合同链接短连接',
    `short_contract_link_create`     timestamp           NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '短链接创建时间',
    `sign_conclusion`                tinyint(1)                   DEFAULT NULL COMMENT '签署结论 1完成',
    `remark`                         varchar(1024)                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 COMMENT ='销售合同销售-签署确认表';

DROP TABLE IF EXISTS `c_sales_sign_confirmation_electronic_info`;
CREATE TABLE `c_sales_sign_confirmation_electronic_info`
(
    `id`                               bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `c_sales_sign_confirmation_id`     bigint(20)          NOT NULL COMMENT '销售合同-签署确认表Id',
    `contract_name`                    varchar(50)                  DEFAULT NULL COMMENT '合同名称',
    `contract_id`                      varchar(500)                 DEFAULT NULL COMMENT '合同id',
    `electronic_signature_personal_id` bigint(20)          NOT NULL COMMENT '电子签个人信息表Id',
    `transaction_id`                   varchar(255)                 DEFAULT NULL COMMENT '客户合同交易id',
    `back_file_id`                     bigint(20)                   DEFAULT NULL COMMENT '电子签回调文件',
    `report_file_id`                   bigint(20)                   DEFAULT NULL COMMENT '出证电子签文件',
    `file_id`                          bigint(20)                   DEFAULT NULL COMMENT '电子签文件',
    `sign_status`                      tinyint(1)                   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 COMMENT ='销售合同-签署确认合同信息';

DROP TABLE IF EXISTS `sales_sign_confirmation_approval`;
CREATE TABLE `sales_sign_confirmation_approval`
(
    `id`                             bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `c_sales_contract_management_id` bigint(20)                   DEFAULT 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 COMMENT ='销售合同-签署确认审核表';

DROP TABLE IF EXISTS `c_sales_contract_supplement_info`;
CREATE TABLE `c_sales_contract_supplement_info`
(
    `id`                             bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `c_sales_contract_management_id` bigint(20)                   DEFAULT NULL COMMENT '销售合同管理Id',
    `change_type`                    tinyint(1)                   DEFAULT NULL COMMENT '变更类型， 1:经办人变更,0:合同条款变更',
    `remark`                         varchar(100)                 DEFAULT '' 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 COMMENT ='销售合同变更信息表';

DROP TABLE IF EXISTS `sales_contract_supplement_his_info`;
CREATE TABLE `sales_contract_supplement_his_info`
(
    `id`                                  bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `c_sales_contract_management_id`      bigint(20)                   DEFAULT NULL COMMENT '销售合同管理Id',
    `c_sales_contract_supplement_info_id` bigint(20)                   DEFAULT NULL COMMENT '销售合同变更信息表Id',
    `change_type`                         tinyint(1)                   DEFAULT NULL COMMENT '变更类型， 1:经办人变更,0:合同条款变更',
    `remark`                              varchar(100)                 DEFAULT '' 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 COMMENT ='销售合同变更信息历史表';

DROP TABLE IF EXISTS `c_sales_contract_supplement_person_info`;
CREATE TABLE `c_sales_contract_supplement_person_info`
(
    `id`                                  bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `c_sales_contract_supplement_info_id` bigint(20)          NOT NULL COMMENT '销售合同变更Id',
    `name`                                varchar(50)                  DEFAULT NULL COMMENT '用户名',
    `type`                                varchar(50)                  DEFAULT '' COMMENT '人员类型',
    `mobile`                              varchar(50)                  DEFAULT NULL COMMENT '联系电话',
    `remark`                              varchar(1024)                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 COMMENT ='销售合同变更-人员信息表';

DROP TABLE IF EXISTS `sales_contract_supplement_person_info_history`;
CREATE TABLE `sales_contract_supplement_person_info_history`
(
    `id`                                    bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `sales_contract_supplement_his_info_id` bigint(20)          NOT NULL COMMENT '销售合同变更历史Id',
    `name`                                  varchar(50)                  DEFAULT NULL COMMENT '用户名',
    `type`                                  varchar(50)                  DEFAULT '' COMMENT '人员类型',
    `mobile`                                varchar(50)                  DEFAULT NULL COMMENT '联系电话',
    `remark`                                varchar(1024)                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 COMMENT ='销售合同变更-人员信息历史表';

DROP TABLE IF EXISTS `sales_contract_supplement_template_approval`;
CREATE TABLE `sales_contract_supplement_template_approval`
(
    `id`                                  bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `c_sales_contract_supplement_info_id` bigint(20)                   DEFAULT NULL COMMENT '销售合同变更信息表Id',
    `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 COMMENT ='销售合同变更-模板审核表';

DROP TABLE IF EXISTS `sales_contract_supplement_template_approval_comment_info`;
CREATE TABLE `sales_contract_supplement_template_approval_comment_info`
(
    `id`                                             bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `sales_contract_supplement_template_approval_id` bigint(20)                   DEFAULT NULL COMMENT '销售合同变更-模板复审Id',
    `approval_comment`                               varchar(50)         NOT 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 COMMENT ='销售合同变更-模板复审-审批意见表';

DROP TABLE IF EXISTS `c_sales_contract_supplement_basic_info`;
CREATE TABLE `c_sales_contract_supplement_basic_info`
(
    `id`                                  bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `supplement_contract_number`          varchar(50)                  DEFAULT NULL COMMENT '补充合同编号',
    `c_sales_contract_supplement_info_id` bigint(20)                   DEFAULT NULL COMMENT '销售合同变更信息表Id',
    `is_add_goods`                        tinyint(1)                   DEFAULT NULL COMMENT '是否新增货物， 1:是,0:否',
    `remark`                              varchar(100)                 DEFAULT '' 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 COMMENT ='销售合同变更基础信息表';

DROP TABLE IF EXISTS `c_sales_contract_supplement_basic_his_info`;
CREATE TABLE `c_sales_contract_supplement_basic_his_info`
(
    `id`                                  bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `supplement_contract_number`          varchar(50)                  DEFAULT NULL COMMENT '补充合同编号',
    `c_sales_contract_supplement_info_id` bigint(20)                   DEFAULT NULL COMMENT '销售合同变更信息表Id',
    `is_add_goods`                        tinyint(1)                   DEFAULT NULL COMMENT '是否新增货物， 1:是,0:否',
    `remark`                              varchar(100)                 DEFAULT '' 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 COMMENT ='销售合同变更基础信息历史表';

DROP TABLE IF EXISTS `c_sales_contract_supplement_goods_info`;
CREATE TABLE `c_sales_contract_supplement_goods_info`
(
    `id`                                        bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `c_sales_contract_supplement_basic_info_id` bigint(20)                   DEFAULT NULL COMMENT '销售合同变更基础信息表Id',
    `goods_name`                                varchar(500)        NOT NULL COMMENT '货物名称',
    `goods_factory`                             varchar(500)        NOT NULL COMMENT '厂家',
    `model_number`                              varchar(500)        NOT NULL COMMENT '型号',
    `units`                                     varchar(10)         NOT NULL COMMENT '单位',
    `quantity`                                  varchar(500)                 DEFAULT NULL COMMENT '数量',
    `is_clear_price`                            tinyint(1)                   DEFAULT NULL COMMENT '是否明确单价，0:否 1:是',
    `sales_price`                               varchar(50)                  DEFAULT NULL COMMENT '销售单价',
    `remark`                                    varchar(500)                 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 COMMENT ='销售合同变更-货物信息表';

DROP TABLE IF EXISTS `sales_contract_supplement_goods_his_info`;
CREATE TABLE `sales_contract_supplement_goods_his_info`
(
    `id`                                          bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `sales_contract_supplement_basic_his_info_id` bigint(20)                   DEFAULT NULL COMMENT '销售合同变更基础信息历史表Id',
    `goods_name`                                  varchar(500)        NOT NULL COMMENT '货物名称',
    `goods_factory`                               varchar(500)        NOT NULL COMMENT '厂家',
    `model_number`                                varchar(500)        NOT NULL COMMENT '型号',
    `units`                                       varchar(10)         NOT NULL COMMENT '单位',
    `quantity`                                    varchar(500)                 DEFAULT NULL COMMENT '数量',
    `is_clear_price`                              tinyint(1)                   DEFAULT NULL COMMENT '是否明确单价，0:否 1:是',
    `sales_price`                                 varchar(50)                  DEFAULT NULL COMMENT '销售单价',
    `remark`                                      varchar(500)                 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 COMMENT ='销售合同变更-货物信息历史表';

DROP TABLE IF EXISTS `sales_contract_supplement_approval`;
CREATE TABLE `sales_contract_supplement_approval`
(
    `id`                                  bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `c_sales_contract_supplement_info_id` bigint(20)                   DEFAULT NULL COMMENT '销售合同变更信息表Id',
    `approval_conclusion`                 varchar(50)         NOT NULL COMMENT '审批结论',
    `approval_comment`                    varchar(100)                 DEFAULT NULL COMMENT '审批意见',
    `sign_confirm`                        tinyint(3)                   DEFAULT '0' COMMENT '签署确认 0否 1是',
    `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 COMMENT ='销售合同变更-审核表';

DROP TABLE IF EXISTS `c_sales_supplement_sign_confirmation`;
CREATE TABLE `c_sales_supplement_sign_confirmation`
(
    `id`                                  bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `c_sales_contract_supplement_info_id` bigint(20)                   DEFAULT NULL COMMENT '销售合同变更信息表Id',
    `contract_link`                       varchar(2048)                DEFAULT NULL COMMENT '合同链接',
    `short_contract_link`                 varchar(1024)                DEFAULT NULL COMMENT '客户合同链接短连接',
    `short_contract_link_create`          timestamp           NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '短链接创建时间',
    `sign_conclusion`                     tinyint(1)                   DEFAULT NULL COMMENT '签署结论 1完成',
    `remark`                              varchar(1024)                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 COMMENT ='销售合同变更-签署确认表';

DROP TABLE IF EXISTS `c_sales_supplement_sign_confirmation_electronic_info`;
CREATE TABLE `c_sales_supplement_sign_confirmation_electronic_info`
(
    `id`                                      bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `c_sales_supplement_sign_confirmation_id` bigint(20)          NOT NULL COMMENT '销售合同变更-签署确认表Id',
    `contract_name`                           varchar(50)                  DEFAULT NULL COMMENT '合同名称',
    `contract_id`                             varchar(500)                 DEFAULT NULL COMMENT '合同id',
    `electronic_signature_personal_id`        bigint(20)          NOT NULL COMMENT '电子签个人信息表Id',
    `transaction_id`                          varchar(255)                 DEFAULT NULL COMMENT '客户合同交易id',
    `sign_status`                             tinyint(1)                   DEFAULT NULL COMMENT '客户签署状态',
    `back_file_id`                            bigint(20)                   DEFAULT NULL COMMENT '电子签回调文件',
    `report_file_id`                          bigint(20)                   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 COMMENT ='销售合同变更-签署确认合同信息';

DROP TABLE IF EXISTS `sales_supplement_sign_confirmation_approval`;
CREATE TABLE `sales_supplement_sign_confirmation_approval`
(
    `id`                                  bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `c_sales_contract_supplement_info_id` bigint(20)                   DEFAULT 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 COMMENT ='销售合同变更-签署确认审核表';

DROP TABLE IF EXISTS `sales_contract_template_first_approval_condition_rel`;
CREATE TABLE `sales_contract_template_first_approval_condition_rel`
(
    `id`                                             bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `sales_contract_template_first_approval_info_id` bigint(20) unsigned DEFAULT '0' COMMENT '销售合同-模板初审ID',
    `sales_contract_approval_condition_dic_id`       bigint(20) unsigned DEFAULT NULL COMMENT '销售合同-模板初审(基础交易合同)-字典表ID',
    `is_agree`                                       tinyint(1)          DEFAULT '0' COMMENT '是否满足 1 是 0 否',
    PRIMARY KEY (`id`)
) COMMENT ='销售合同-模板初审和审核条件关联关系表';

DROP TABLE IF EXISTS `sales_contract_approval_person_info_history_ref`;
CREATE TABLE `sales_contract_approval_person_info_history_ref`
(
    `id`                         bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `sales_contract_approval_id` bigint(20)          NOT NULL COMMENT '销售合同审核Id',
    `name`                       varchar(50)                  DEFAULT NULL COMMENT '用户名',
    `type`                       varchar(50)                  DEFAULT '' COMMENT '人员类型',
    `mobile`                     varchar(50)                  DEFAULT NULL COMMENT '联系电话',
    `remark`                     varchar(1024)                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 COMMENT ='--销售合同审核人员信息历史表';

DROP TABLE IF EXISTS `sales_contract_supplement_approval_person_info_history_ref`;
CREATE TABLE `sales_contract_supplement_approval_person_info_history_ref`
(
    `id`                                    bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `sales_contract_supplement_approval_id` bigint(20)          NOT NULL COMMENT '销售合同补充合同审核Id',
    `name`                                  varchar(50)                  DEFAULT NULL COMMENT '用户名',
    `type`                                  varchar(50)                  DEFAULT '' COMMENT '人员类型',
    `mobile`                                varchar(50)                  DEFAULT NULL COMMENT '联系电话',
    `remark`                                varchar(1024)                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 COMMENT ='--销售合同补充合同审核人员信息历史表';

-- 验收单管理-表结构


DROP TABLE IF EXISTS `c_acceptance_goods_info`;
CREATE TABLE `c_acceptance_goods_info`
(
    `id`                         bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `acceptance_goods_number`    varchar(250)                 DEFAULT NULL COMMENT '验收单编号',
    `goods_name`                 varchar(500)                 DEFAULT NULL COMMENT '货物名称',
    `goods_material`             varchar(500)                 DEFAULT NULL COMMENT '货物材质',
    `goods_type`                 varchar(500)                 DEFAULT NULL COMMENT '型号',
    `goods_factory`              varchar(500)                 DEFAULT NULL COMMENT '厂家',
    `goods_unit`                 varchar(50)                  DEFAULT NULL COMMENT '单位',
    `goods_quantity`             decimal(17, 4)               DEFAULT NULL COMMENT '数量',
    `acceptance_date`            datetime                     DEFAULT NULL COMMENT '验收日期',
    `c_acceptance_basic_info_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 '修改时间',
    `sales_price`                decimal(17, 4)               DEFAULT NULL COMMENT '销售单价',
    `reference_price`            decimal(17, 4)               DEFAULT NULL COMMENT '参考价格',
    `floating_price`             decimal(17, 4)               DEFAULT NULL COMMENT '浮动单价',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB COMMENT ='验收单-货物信息表';

DROP TABLE IF EXISTS `acceptance_his_goods_info`;
CREATE TABLE `acceptance_his_goods_info`
(
    `id`                      bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `acceptance_goods_number` varchar(250)                 DEFAULT NULL COMMENT '验收单编号',
    `goods_name`              varchar(500)                 DEFAULT NULL COMMENT '货物名称',
    `goods_material`          varchar(500)                 DEFAULT NULL COMMENT '货物材质',
    `goods_type`              varchar(500)                 DEFAULT NULL COMMENT '型号',
    `goods_factory`           varchar(500)                 DEFAULT NULL COMMENT '厂家',
    `goods_unit`              varchar(50)                  DEFAULT NULL COMMENT '单位',
    `goods_quantity`          decimal(17, 4)               DEFAULT NULL COMMENT '数量',
    `acceptance_date`         datetime            NOT NULL COMMENT '验收日期',
    `acceptance_his_info_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 '修改时间',
    `sales_price`             decimal(17, 4)               DEFAULT NULL COMMENT '销售单价',
    `reference_price`         decimal(17, 4)               DEFAULT NULL COMMENT '参考价格',
    `floating_price`          decimal(17, 4)               DEFAULT NULL COMMENT '浮动单价',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB COMMENT ='验收单-历史货物信息表';

DROP TABLE IF EXISTS `c_acceptance_sign_confirmation`;
CREATE TABLE `c_acceptance_sign_confirmation`
(
    `id`                         bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `c_acceptance_basic_info_id` bigint(20) unsigned          DEFAULT '0' COMMENT '验收单-基础信息表ID',
    `contract_link`              varchar(2048)                DEFAULT NULL COMMENT '合同链接',
    `short_contract_link`        varchar(1024)                DEFAULT NULL COMMENT '客户合同链接短连接',
    `short_contract_link_create` timestamp           NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '短链接创建时间',
    `sign_conclusion`            tinyint(1)                   DEFAULT NULL COMMENT '签署结论 1完成',
    `remark`                     varchar(1024)                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
  COLLATE = utf8_unicode_ci COMMENT ='验收单签署确认表';

DROP TABLE IF EXISTS `c_acceptance_sign_confirmation_electronic_info`;
CREATE TABLE `c_acceptance_sign_confirmation_electronic_info`
(
    `id`                                bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `c_acceptance_sign_confirmation_id` bigint(20)          NOT NULL COMMENT '验收单签署确认表Id',
    `contract_name`                     varchar(50)                  DEFAULT NULL COMMENT '合同名称',
    `contract_id`                       varchar(500)                 DEFAULT NULL COMMENT '合同id',
    `file_id`                           bigint(20)                   DEFAULT NULL COMMENT '电子签文件',
    `electronic_signature_personal_id`  bigint(20)          NOT NULL COMMENT '电子签个人信息表Id',
    `transaction_id`                    varchar(255)                 DEFAULT NULL COMMENT '客户合同交易id',
    `sign_status`                       tinyint(1)                   DEFAULT NULL COMMENT '客户签署状态',
    `back_file_id`                      bigint(20)                   DEFAULT NULL COMMENT '电子签回调文件',
    `report_file_id`                    bigint(20)                   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 COMMENT ='验收单签署确认合同信息表';

DROP TABLE IF EXISTS `c_acceptance_sign_confirmation_goods_info`;
CREATE TABLE `c_acceptance_sign_confirmation_goods_info`
(
    `id`                                bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `c_acceptance_sign_confirmation_id` bigint(20)                   DEFAULT NULL COMMENT '验收单信息表id',
    `goods_name`                        varchar(500)                 DEFAULT NULL COMMENT '货物名称',
    `goods_material`                    varchar(500)                 DEFAULT NULL COMMENT '货物材质',
    `goods_type`                        varchar(500)                 DEFAULT NULL COMMENT '型号',
    `goods_factory`                     varchar(500)                 DEFAULT NULL COMMENT '厂家',
    `goods_unit`                        varchar(50)                  DEFAULT NULL COMMENT '单位',
    `goods_quantity`                    decimal(17, 4)               DEFAULT NULL COMMENT '数量',
    `reference_price`                   decimal(17, 4)               DEFAULT NULL COMMENT '参考价格',
    `floating_price`                    decimal(17, 4)               DEFAULT NULL COMMENT '浮动单价',
    `sales_price`                       decimal(17, 4)               DEFAULT NULL COMMENT '销售单价',
    `acceptance_date`                   datetime            NOT 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 COMMENT ='下游验收单-签署确认货物信息表';

DROP TABLE IF EXISTS `c_acceptance_goods_info`;
CREATE TABLE `c_acceptance_goods_info`
(
    `id`                         bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `goods_name`                 varchar(500)                 DEFAULT NULL COMMENT '货物名称',
    `goods_material`             varchar(500)                 DEFAULT NULL COMMENT '货物材质',
    `goods_type`                 varchar(500)                 DEFAULT NULL COMMENT '型号',
    `goods_factory`              varchar(500)                 DEFAULT NULL COMMENT '厂家',
    `goods_unit`                 varchar(50)                  DEFAULT NULL COMMENT '单位',
    `goods_quantity`             decimal(17, 4)               DEFAULT NULL COMMENT '数量',
    `acceptance_date`            datetime                     DEFAULT NULL COMMENT '验收日期',
    `c_acceptance_basic_info_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 '修改时间',
    `sales_price`                decimal(17, 4)               DEFAULT NULL COMMENT '销售单价',
    `reference_price`            decimal(17, 4)               DEFAULT NULL COMMENT '参考价格',
    `floating_price`             decimal(17, 4)               DEFAULT NULL COMMENT '浮动单价',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB COMMENT ='验收单-货物信息表';

DROP TABLE IF EXISTS `acceptance_his_goods_info`;
CREATE TABLE `acceptance_his_goods_info`
(
    `id`                     bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `goods_name`             varchar(500)                 DEFAULT NULL COMMENT '货物名称',
    `goods_material`         varchar(500)                 DEFAULT NULL COMMENT '货物材质',
    `goods_type`             varchar(500)                 DEFAULT NULL COMMENT '型号',
    `goods_factory`          varchar(500)                 DEFAULT NULL COMMENT '厂家',
    `goods_unit`             varchar(50)                  DEFAULT NULL COMMENT '单位',
    `goods_quantity`         decimal(17, 4)               DEFAULT NULL COMMENT '数量',
    `acceptance_date`        datetime            NOT NULL COMMENT '验收日期',
    `acceptance_his_info_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 '修改时间',
    `sales_price`            decimal(17, 4)               DEFAULT NULL COMMENT '销售单价',
    `reference_price`        decimal(17, 4)               DEFAULT NULL COMMENT '参考价格',
    `floating_price`         decimal(17, 4)               DEFAULT NULL COMMENT '浮动单价',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB COMMENT ='验收单-历史货物信息表';

DROP TABLE IF EXISTS `c_acceptance_person_info`;
CREATE TABLE `c_acceptance_person_info`
(
    `id`                         bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `c_acceptance_basic_info_id` bigint(20)          NOT NULL COMMENT '验收单Id',
    `name`                       varchar(50)                  DEFAULT NULL COMMENT '用户名',
    `card_type`                  varchar(50)                  DEFAULT '' COMMENT '证件类型',
    `type`                       varchar(50)                  DEFAULT '' COMMENT '人员类型',
    `socialCreditCode`           varchar(18)                  DEFAULT NULL COMMENT '证件号码',
    `mobile`                     varchar(50)                  DEFAULT NULL COMMENT '联系电话',
    `remark`                     varchar(1024)                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 COMMENT ='验收单_人员信息表';

DROP TABLE IF EXISTS `acceptance_person_info_history`;
CREATE TABLE `acceptance_person_info_history`
(
    `id`                       bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `acceptance_basic_info_id` bigint(20)          NOT NULL COMMENT '验收单Id',
    `name`                     varchar(50)                  DEFAULT NULL COMMENT '用户名',
    `card_type`                varchar(50)                  DEFAULT '' COMMENT '证件类型',
    `type`                     varchar(50)                  DEFAULT '' COMMENT '人员类型',
    `socialCreditCode`         varchar(18)                  DEFAULT NULL COMMENT '证件号码',
    `mobile`                   varchar(50)                  DEFAULT NULL COMMENT '联系电话',
    `remark`                   varchar(1024)                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 COMMENT ='验收单_人员历史信息';

DROP TABLE IF EXISTS `c_acceptance_sell_bill_ref`;
CREATE TABLE `c_acceptance_sell_bill_ref`
(
    `id`                         bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `c_acceptance_basic_info_id` bigint(20)   DEFAULT NULL COMMENT '验收单-基础信息表ID',
    `sell_bill_id`               bigint(20)   DEFAULT NULL COMMENT '钢小二-销售单信息id',
    `sell_bill_number`           varchar(300) DEFAULT '' COMMENT '销售单号',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB COMMENT ='钢小二-销售单和验收单关联关系表';

DROP TABLE IF EXISTS `acceptance_sell_bill_ref_his`;
CREATE TABLE `acceptance_sell_bill_ref_his`
(
    `id`                     bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `acceptance_his_info_id` bigint(20)   DEFAULT NULL COMMENT '下游验收单-基础信息历史表ID',
    `sell_bill_id`           bigint(20)   DEFAULT NULL COMMENT '钢小二-销售单信息id',
    `sell_bill_number`       varchar(300) DEFAULT '' COMMENT '销售单号',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB COMMENT ='钢小二-销售单和验收单关联关系历史表';

DROP TABLE IF EXISTS `acceptance_approval`;
CREATE TABLE `acceptance_approval`
(
    `id`                         bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `c_acceptance_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 '修改时间',
    `sign_confirm`               tinyint(3)                   DEFAULT '0' COMMENT '签署确认 0否 1是',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB COMMENT ='验收单管理-审核表';

DROP TABLE IF EXISTS `acceptance_sign_confirmation_electronic_info_history`;
CREATE TABLE `acceptance_sign_confirmation_electronic_info_history`
(
    `id`                                bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `c_acceptance_sign_confirmation_id` bigint(20)          NOT NULL COMMENT '验收单签署确认表Id',
    `contract_name`                     varchar(50)                  DEFAULT NULL COMMENT '合同名称',
    `contract_id`                       varchar(500)                 DEFAULT NULL COMMENT '合同id',
    `file_id`                           bigint(20)                   DEFAULT NULL COMMENT '电子签文件',
    `electronic_signature_personal_id`  bigint(20)          NOT NULL COMMENT '电子签个人信息表Id',
    `transaction_id`                    varchar(255)                 DEFAULT NULL COMMENT '客户合同交易id',
    `sign_status`                       tinyint(1)                   DEFAULT NULL COMMENT '客户签署状态',
    `back_file_id`                      bigint(20)                   DEFAULT NULL COMMENT '电子签回调文件',
    `report_file_id`                    bigint(20)                   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 COMMENT ='验收单_签署确认合同信息历史表';

DROP TABLE IF EXISTS `acceptance_sign_confirmation_history`;
CREATE TABLE `acceptance_sign_confirmation_history`
(
    `id`                         bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `c_acceptance_basic_info_id` bigint(20) unsigned          DEFAULT '0' COMMENT '验收单-基础信息表ID',
    `contract_link`              varchar(2048)                DEFAULT NULL COMMENT '合同链接',
    `short_contract_link`        varchar(1024)                DEFAULT NULL COMMENT '客户合同链接短连接',
    `short_contract_link_create` timestamp           NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '短链接创建时间',
    `sign_conclusion`            tinyint(1)                   DEFAULT NULL COMMENT '签署结论 1完成',
    `remark`                     varchar(1024)                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 COMMENT ='验收单_签署确认历史表';


DROP TABLE IF EXISTS `c_acceptance_price_adjust_info`;
CREATE TABLE `c_acceptance_price_adjust_info`
(
    `id`                         bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `c_acceptance_basic_info_id` bigint(20)                   DEFAULT NULL COMMENT '验收单_基础信息表ID',
    `supplement_description`     varchar(50)                  DEFAULT '' COMMENT '补充说明',
    `check_operator_supplier`    varchar(32)                  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 COMMENT ='验收单单价调整表';

DROP TABLE IF EXISTS `c_acceptance_price_adjust_his_info`;
CREATE TABLE `c_acceptance_price_adjust_his_info`
(
    `id`                                bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `c_acceptance_price_adjust_info_id` bigint(20)                   DEFAULT NULL COMMENT '验收单-单价调整表ID',
    `supplement_description`            varchar(50)                  DEFAULT '' COMMENT '补充说明',
    `check_operator_supplier`           varchar(32)                  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 COMMENT ='验收单单价调整历史表';

DROP TABLE IF EXISTS `c_acceptance_price_goods_info`;
CREATE TABLE `c_acceptance_price_goods_info`
(
    `id`                                bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `goods_name`                        varchar(500)                 DEFAULT NULL COMMENT '货物名称',
    `acceptance_godds_number`           varchar(250)                 DEFAULT NULL COMMENT '验收单编号',
    `goods_material`                    varchar(500)                 DEFAULT NULL COMMENT '货物材质',
    `goods_type`                        varchar(500)                 DEFAULT NULL COMMENT '型号',
    `goods_factory`                     varchar(500)                 DEFAULT NULL COMMENT '厂家',
    `goods_unit`                        varchar(50)                  DEFAULT NULL COMMENT '单位',
    `goods_quantity`                    decimal(17, 4)               DEFAULT NULL COMMENT '数量',
    `acceptance_date`                   datetime                     DEFAULT NULL COMMENT '验收日期',
    `c_acceptance_price_adjust_info_id` bigint(20)                   DEFAULT NULL COMMENT '验收单-单价调整表ID',
    `sales_price`                       decimal(17, 4)               DEFAULT NULL COMMENT '销售单价',
    `reference_price`                   decimal(17, 4)               DEFAULT NULL COMMENT '参考价格',
    `floating_price`                    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 '修改时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB COMMENT ='验收单单价调整-货物信息表';

DROP TABLE IF EXISTS `acceptance_price_goods_his_info`;
CREATE TABLE `acceptance_price_goods_his_info`
(
    `id`                                    bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `goods_name`                            varchar(500)                 DEFAULT NULL COMMENT '货物名称',
    `acceptance_godds_number`               varchar(250)                 DEFAULT NULL COMMENT '验收单编号',
    `goods_material`                        varchar(500)                 DEFAULT NULL COMMENT '货物材质',
    `goods_type`                            varchar(500)                 DEFAULT NULL COMMENT '型号',
    `goods_factory`                         varchar(500)                 DEFAULT NULL COMMENT '厂家',
    `goods_unit`                            varchar(50)                  DEFAULT NULL COMMENT '单位',
    `goods_quantity`                        decimal(17, 4)               DEFAULT NULL COMMENT '数量',
    `acceptance_date`                       datetime                     DEFAULT NULL COMMENT '验收日期',
    `c_acceptance_price_adjust_his_info_id` bigint(20)                   DEFAULT NULL COMMENT '验收单-单价调整历史表ID',
    `sales_price`                           decimal(17, 4)               DEFAULT NULL COMMENT '销售单价',
    `reference_price`                       decimal(17, 4)               DEFAULT NULL COMMENT '参考价格',
    `floating_price`                        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 '修改时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB COMMENT ='验收单单价调整-货物信息历史表';

DROP TABLE IF EXISTS `acceptance_price_approval`;
CREATE TABLE `acceptance_price_approval`
(
    `id`                                bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `c_acceptance_price_adjust_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 COMMENT ='验收单单价调整-审核表';


-- 销售合同人员类型
INSERT INTO `t_dictionary`(`name`, `parentId`, `code`, `value`, `gradation`)
VALUES ('销售合同人员类型', NULL, 'salesContractPersonType', NULL, 0);
INSERT INTO `t_dictionary`(`name`, `parentId`, `code`, `value`, `gradation`)
VALUES ('合同签署人', (SELECT t.id FROM t_dictionary t WHERE CODE = 'salesContractPersonType'),
        'salesContractPersonType_sign', NULL, 0);
INSERT INTO `t_dictionary`(`name`, `parentId`, `code`, `value`, `gradation`)
VALUES ('验收经办人', (SELECT t.id FROM t_dictionary t WHERE CODE = 'salesContractPersonType'),
        'salesContractPersonType_acceptance', NULL, 1);
INSERT INTO `t_dictionary`(`name`, `parentId`, `code`, `value`, `gradation`)
VALUES ('结算经办人', (SELECT t.id FROM t_dictionary t WHERE CODE = 'salesContractPersonType'),
        'salesContractPersonType_settlement', NULL, 2);

DROP TABLE IF EXISTS `c_purch_contract_management`;
CREATE TABLE `c_purch_contract_management`
(
    `id`                  bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `business_number`     varchar(50)         NOT NULL COMMENT '业务编号',
    `contract_status`     varchar(32)                  DEFAULT '0' COMMENT '合同状态',
    `is_change`           tinyint(1)                   DEFAULT '0' COMMENT '是否发生变更标识、默认为否',
    `trading_platform_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 COMMENT ='采购合同管理表';

DROP TABLE IF EXISTS `c_purch_contract_basic_info`;
CREATE TABLE `c_purch_contract_basic_info`
(
    `id`                             bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `contract_number`                varchar(50)                  DEFAULT NULL COMMENT '合同编号',
    `contract_name`                  varchar(50)                  DEFAULT NULL COMMENT '合同名称',
    `project_name`                   varchar(32)                  DEFAULT NULL COMMENT '项目名称',
    `supplier_name`                  varchar(50)                  DEFAULT NULL COMMENT '供应商(主体)名称',
    `buyer_name`                     varchar(50)                  DEFAULT NULL COMMENT '需方公司名称',
    `trading_platform_id`            bigint(20)                   DEFAULT NULL COMMENT '贸易平台Id',
    `repurch_method`                 varchar(50)                  DEFAULT '' COMMENT '回购方式（先息后本，仅本金）',
    `contract_plan_amount_type`      bigint(20)                   DEFAULT NULL COMMENT '合同约定金额类型（固定金额、适时网价）',
    `contract_plan_amount`           decimal(17, 4)               DEFAULT NULL COMMENT '合同约定金额',
    `c_purch_contract_management_id` bigint(20)          NOT 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 '修改时间',
    `contract_id`                    varchar(1024)                DEFAULT NULL COMMENT '采购合同id',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB COMMENT ='采购合同-基本信息表';


-- 销售合同-模板初审-审核条件
INSERT INTO `sales_contract_approval_condition_dic`(`approval_type`, `approval_point`, `loan_condition`)
VALUES (0, '是否符合招标投标要求', '重点关注中标通知书');
INSERT INTO `sales_contract_approval_condition_dic`(`approval_type`, `approval_point`, `loan_condition`)
VALUES (0, '合同签章主体是否适格', '重点关注分公司、项目部签署合同文件');
INSERT INTO `sales_contract_approval_condition_dic`(`approval_type`, `approval_point`, `loan_condition`)
VALUES (0, '合同文本是否完备', '合同要素齐全，主体、标的、数量、质量等条款均完备-《民法典》470条');
INSERT INTO `sales_contract_approval_condition_dic`(`approval_type`, `approval_point`, `loan_condition`)
VALUES (0, '合同是否生效且在生效期内', '关注合同生效条件以及合同履行完毕之日');
INSERT INTO `sales_contract_approval_condition_dic`(`approval_type`, `approval_point`, `loan_condition`)
VALUES (0, '签订主体与盖章、签字方是否一致，签章是否完备且清晰', '合同约定');

INSERT INTO `sales_contract_approval_condition_dic`(`approval_type`, `approval_point`, `loan_condition`)
VALUES (1, '合同标的名称、数量以及质量标准条款是否完备', '');
INSERT INTO `sales_contract_approval_condition_dic`(`approval_type`, `approval_point`, `loan_condition`)
VALUES (1, '合同价款是否约定清晰，包含合同价款的计算方式、合同价款包含的具体项目等', '建筑类重点关注网价条款');
INSERT INTO `sales_contract_approval_condition_dic`(`approval_type`, `approval_point`, `loan_condition`)
VALUES (1, '合同约定送货地点、方式是否明确', '送货地点可不明确，具体是实际操作为准');
INSERT INTO `sales_contract_approval_condition_dic`(`approval_type`, `approval_point`, `loan_condition`)
VALUES (1, '合同标的验收标准、验收人员以及验收单据是否明确', '验收人员信息需明确');
INSERT INTO `sales_contract_approval_condition_dic`(`approval_type`, `approval_point`, `loan_condition`)
VALUES (1, '合同约定结算条件、结算人员或结算单要求是否明确', '');
INSERT INTO `sales_contract_approval_condition_dic`(`approval_type`, `approval_point`, `loan_condition`)
VALUES (1, '是否存在质保金、履约保证金条款', '重点关注质保金、履约保证金退还条件及时间');
INSERT INTO `sales_contract_approval_condition_dic`(`approval_type`, `approval_point`, `loan_condition`)
VALUES (1, '付款条件、方式以及节点是否明确', '重点关注付款节点以及付款周期');
INSERT INTO `sales_contract_approval_condition_dic`(`approval_type`, `approval_point`, `loan_condition`)
VALUES (1, '是否存在宽限期条款', '宽限期需加在下游账期中，并反馈至风控，评估上游账期');
INSERT INTO `sales_contract_approval_condition_dic`(`approval_type`, `approval_point`, `loan_condition`)
VALUES (1, '是否存在禁止转让条款、附条件条款等', '需关注禁止转让条款的违约责任，并通过上游合同/三方协议转嫁给供应商');
INSERT INTO `sales_contract_approval_condition_dic`(`approval_type`, `approval_point`, `loan_condition`)
VALUES (1, '违约金比例是否高于普通标准', '比例高需转嫁给供应商');
INSERT INTO `sales_contract_approval_condition_dic`(`approval_type`, `approval_point`, `loan_condition`)
VALUES (1, '争议解决条款是否清晰明确', '');
INSERT INTO `sales_contract_approval_condition_dic`(`approval_type`, `approval_point`, `loan_condition`)
VALUES (1, '通知送达条款是否明确', '关注我司贸易平台送达地址');
INSERT INTO `sales_contract_approval_condition_dic`(`approval_type`, `approval_point`, `loan_condition`)
VALUES (1, '不存在谅解条款，即买方付款无需以第三方的付款为前提', '红线否决项');

-- 采购合同c端建表语句
DROP TABLE IF EXISTS `c_purch_contract_retention_info`;
CREATE TABLE `c_purch_contract_retention_info`
(
    `id`                             bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `is_retention`                   tinyint(1)                   DEFAULT NULL COMMENT '是否有质保金，0:无 1:有',
    `retention_percent`              decimal(17, 2)               DEFAULT NULL COMMENT '质保金比例',
    `is_limit`                       tinyint(1)                   DEFAULT NULL COMMENT '质保金是否有上限，0:无 1:有',
    `retention_limit`                decimal(17, 2)               DEFAULT NULL COMMENT '质保金上限',
    `release_method`                 varchar(256)                 DEFAULT '' COMMENT '质保金释放规则',
    `release_date`                   datetime                     DEFAULT NULL COMMENT '释放日期',
    `release_days`                   int(10)                      DEFAULT NULL COMMENT '释放天数',
    `c_purch_contract_basic_info_id` bigint(20)          NOT 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 COMMENT ='采购合同-质保金信息表';

DROP TABLE IF EXISTS `c_purch_contract_price_rule`;
CREATE TABLE `c_purch_contract_price_rule`
(
    `id`                             bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `accrual_margin_calc_method`     tinyint(1)                   DEFAULT NULL COMMENT '利差计算方式（0固定利率、1固定金额）',
    `trade_platform_offer`           decimal(17, 4)               DEFAULT NULL COMMENT '贸易平台报价/年',
    `factoring_offer`                decimal(17, 2)               DEFAULT NULL COMMENT '保理报价/年',
    `factoring_finance_deadline`     int(10)                      DEFAULT NULL COMMENT '预估保理融资期限',
    `differ_amount`                  decimal(17, 2)               DEFAULT NULL COMMENT '差额',
    `monthly_interest_rate`          decimal(17, 4)               DEFAULT NULL COMMENT '月利率',
    `c_purch_contract_basic_info_id` bigint(20)          NOT 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 COMMENT ='采购合同-价格规则表';

DROP TABLE IF EXISTS `c_purch_contract_settle_payment`;
CREATE TABLE `c_purch_contract_settle_payment`
(
    `id`                             bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `c_purch_contract_basic_info_id` bigint(20)          NOT NULL COMMENT '采购合同基本信息表Id',
    `bank_name`                      varchar(256)        NOT NULL COMMENT '银行名称',
    `bank_account_name`              varchar(256)        NOT NULL COMMENT '供应商收款账户名',
    `bank_account`                   varchar(64)         NOT 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 COMMENT ='采购合同-结算与付款表';

DROP TABLE IF EXISTS `c_purch_contract_buyer_seller`;
CREATE TABLE `c_purch_contract_buyer_seller`
(
    `id`                             bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `serial_number`                  smallint(5) unsigned         DEFAULT '0' COMMENT '编号',
    `name`                           varchar(50)                  DEFAULT NULL COMMENT '姓名',
    `id_card`                        varchar(50)                  DEFAULT NULL COMMENT '身份证号',
    `contact`                        varchar(50)                  DEFAULT NULL COMMENT '联系方式',
    `c_purch_contract_basic_info_id` bigint(20)          NOT 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 COMMENT ='采购合同-需方收货人或供应商发货人表';

DROP TABLE IF EXISTS `c_purch_contract_goods_info`;
CREATE TABLE `c_purch_contract_goods_info`
(
    `id`                             bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `c_sales_contract_goods_info_id` bigint(20)          NOT NULL COMMENT '销售合同货物信息ID',
    `goods_name`                     varchar(500)        NOT NULL COMMENT '货物名称',
    `goods_factory`                  varchar(500)        NOT NULL COMMENT '厂家',
    `model_number`                   varchar(500)        NOT NULL COMMENT '型号',
    `units`                          varchar(10)         NOT NULL COMMENT '单位',
    `quantity`                       varchar(500)                 DEFAULT NULL COMMENT '数量',
    `remark`                         varchar(500)                 DEFAULT NULL COMMENT '备注',
    `c_purch_contract_basic_info_id` bigint(20)          NOT 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 '修改时间',
    `supplement`                     tinyint(3)                   DEFAULT NULL COMMENT '是否补充货物 0 不是 1 是',
    `price`                          varchar(50)                  DEFAULT NULL COMMENT '暂定单价',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARSET = utf8 COMMENT ='采购合同-货物信息表';

DROP TABLE IF EXISTS `c_purch_contract_sign_conclusion`;
CREATE TABLE `c_purch_contract_sign_conclusion`
(
    `id`                             bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `c_purch_contract_basic_info_id` bigint(20)          NOT NULL COMMENT '采购合同Id',
    `remark`                         varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '说明',
    `conclusion`                     varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '签署结论',
    `user_create`                    varchar(32) COLLATE utf8_unicode_ci  DEFAULT '' COMMENT '创建人',
    `user_modified`                  varchar(32) COLLATE utf8_unicode_ci  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 COMMENT ='采购合同 合同的签署结论';

DROP TABLE IF EXISTS `c_purch_contract_electronic_info`;
CREATE TABLE `c_purch_contract_electronic_info`
(
    `id`                             bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `certify_link`                   varchar(1024)                DEFAULT NULL COMMENT '认证链接',
    `certify_status`                 tinyint(1)                   DEFAULT NULL COMMENT '认证状态',
    `contract_link`                  varchar(2048)                DEFAULT NULL COMMENT '合同链接',
    `sign_status`                    tinyint(1)                   DEFAULT NULL COMMENT '签署状态',
    `fdd_customer_id`                varchar(50)                  DEFAULT NULL COMMENT '客户编号',
    `c_purch_contract_basic_info_id` bigint(20)          NOT 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 '修改时间',
    `short_contract_link`            varchar(1024)                DEFAULT NULL COMMENT '签署短链接',
    `short_contract_link_create`     timestamp           NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '签署短链接创建时间',
    `transaction_id`                 varchar(255)                 DEFAULT NULL COMMENT '客户合同交易id',
    `contract_name`                  varchar(500)                 DEFAULT NULL COMMENT '合同名称',
    `contract_id`                    varchar(500)                 DEFAULT NULL COMMENT '合同名称',
    `call_back`                      tinyint(3)                   DEFAULT '0' COMMENT '是否回调 0 未回调 1 回调',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB COMMENT ='采购合同-电子合同信息表';

DROP TABLE IF EXISTS `c_purch_contract_supplement_info`;
CREATE TABLE `c_purch_contract_supplement_info`
(
    `id`                             bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `c_purch_contract_management_id` bigint(20)          NOT NULL COMMENT '采购合同管理Id',
    `supplement_contract_number`     varchar(50)                  DEFAULT NULL COMMENT '补充合同编号',
    `price_rule_detail`              varchar(500)                 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 '修改时间',
    `contract_id`                    varchar(1024)                DEFAULT NULL COMMENT '采购合同id',
    `add_goods`                      tinyint(3)                   DEFAULT NULL COMMENT '是否新增货物 0 不新增 1 新增',
    `other_convention`               varchar(500)                 DEFAULT NULL COMMENT '其他约定',
    `remark`                         varchar(500)                 DEFAULT NULL COMMENT '说明',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARSET = utf8 COMMENT ='采购合同-补充信息表';

DROP TABLE IF EXISTS `c_purch_contract_supplement_goods_info`;
CREATE TABLE `c_purch_contract_supplement_goods_info`
(
    `id`                                  bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `c_purch_contract_supplement_info_id` bigint(20)          NOT NULL COMMENT '采购补充合同信息表Id',
    `goods_name`                          varchar(500)        NOT NULL COMMENT '货物名称',
    `goods_factory`                       varchar(500)        NOT NULL COMMENT '厂家',
    `model_number`                        varchar(500)        NOT NULL COMMENT '型号',
    `units`                               varchar(10)         NOT NULL COMMENT '单位',
    `quantity`                            varchar(500)                 DEFAULT NULL COMMENT '数量',
    `remark`                              varchar(500)                 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 '修改时间',
    `price`                               varchar(50)                  DEFAULT NULL COMMENT '暂定单价',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB COMMENT ='采购合同-补充货物信息表';

DROP TABLE IF EXISTS `c_purch_contract_supplement_electronic_info`;
CREATE TABLE `c_purch_contract_supplement_electronic_info`
(
    `id`                                  bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `c_purch_contract_supplement_info_id` bigint(20)          NOT NULL COMMENT '采购补充合同信息表Id',
    `certify_link`                        varchar(1024)                DEFAULT NULL COMMENT '认证链接',
    `certify_status`                      tinyint(1)                   DEFAULT NULL COMMENT '认证状态',
    `contract_link`                       varchar(2048)                DEFAULT NULL COMMENT '合同链接',
    `sign_status`                         tinyint(1)                   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 '修改时间',
    `short_contract_link`                 varchar(1024)                DEFAULT NULL COMMENT '签署短链接',
    `short_contract_link_create`          timestamp           NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '签署短链接创建时间',
    `transaction_id`                      varchar(255)                 DEFAULT NULL COMMENT '客户合同交易id',
    `contract_name`                       varchar(500)                 DEFAULT NULL COMMENT '合同名称',
    `contract_id`                         varchar(500)                 DEFAULT NULL COMMENT '合同名称',
    `call_back`                           tinyint(3)                   DEFAULT '0' COMMENT '是否回调 0 未回调 1 回调',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB COMMENT ='采购合同-补充电子合同信息表';

DROP TABLE IF EXISTS `purch_supplement_contract_sign_conclusion`;
CREATE TABLE `purch_supplement_contract_sign_conclusion`
(
    `id`                                bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `purch_contract_supplement_info_id` bigint(20)          NOT NULL COMMENT '采购合同变更合同Id',
    `remark`                            varchar(500)                 DEFAULT NULL COMMENT '说明',
    `conclusion`                        varchar(500)                 DEFAULT NULL COMMENT '签署结论',
    `visible`                           tinyint(3)                   DEFAULT NULL COMMENT '是否提交 0 不提交 1 提交',
    `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`) USING BTREE
) ENGINE = InnoDB COMMENT ='采购合同变更-合同的签署结论';

DROP TABLE IF EXISTS `purch_contract_approval`;
CREATE TABLE `purch_contract_approval`
(
    `id`                           bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `purch_contract_basic_info_id` bigint(20) unsigned          DEFAULT '0' COMMENT '采购合同基本信息表Id',
    `approval_comment`             varchar(3000)                DEFAULT '' COMMENT '审批意见',
    `approval_conclusion`          varchar(50)                  DEFAULT 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 '修改时间',
    `sign_mode`                    tinyint(3)                   DEFAULT NULL COMMENT '签署方式 0线下签署  1线上签署',
    `upload`                       tinyint(3)                   DEFAULT NULL COMMENT '是否上传合同  0不上传 1上传',
    `sign_file`                    bigint(20)                   DEFAULT NULL COMMENT '待线上签署合同附件id',
    `visible`                      tinyint(3)                   DEFAULT NULL COMMENT '是否提交 0 不提交 1 提交',
    `use_contract`                 tinyint(3)                   DEFAULT '1' COMMENT '是否使用系统生成的合同 0 不使用  1使用',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB COMMENT ='采购合同-审核表';

DROP TABLE IF EXISTS `purch_contract_supplement_approval`;
CREATE TABLE `purch_contract_supplement_approval`
(
    `id`                                bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `purch_contract_supplement_info_id` bigint(20)          NOT 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 '修改时间',
    `other_convention`                  varchar(2000)                DEFAULT NULL COMMENT '其他约定',
    `sign_mode`                         tinyint(3)                   DEFAULT NULL COMMENT '签署方式 0线下签署  1线上签署',
    `upload`                            tinyint(3)                   DEFAULT NULL COMMENT '是否上传合同  0不上传 1上传',
    `use_contract`                      tinyint(3)                   DEFAULT '0' COMMENT '是否使用系统生成的合同 0 不使用  1使用',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB COMMENT ='采购合同-变更审核表';

DROP TABLE IF EXISTS `purch_contract_basic_info_history`;
CREATE TABLE `purch_contract_basic_info_history`
(
    `id`                           bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `contract_number`              varchar(50)                  DEFAULT NULL COMMENT '合同编号',
    `contract_name`                varchar(50)                  DEFAULT NULL COMMENT '合同名称',
    `supplier_name`                varchar(50)                  DEFAULT NULL COMMENT '供应商名称',
    `buyer_name`                   varchar(50)                  DEFAULT NULL COMMENT '需方公司名称',
    `project_name`                 varchar(32)                  DEFAULT NULL COMMENT '项目名称',
    `trading_platform_id`          bigint(20)                   DEFAULT NULL COMMENT '贸易平台Id',
    `contract_period`              varchar(50)                  DEFAULT NULL COMMENT '采购合同期限',
    `repurch_method`               varchar(50)                  DEFAULT '' COMMENT '回购方式（先息后本，仅本金）',
    `contract_plan_amount_type`    bigint(20)                   DEFAULT NULL COMMENT '合同约定金额类型（固定金额、适时网价）',
    `contract_plan_amount`         decimal(17, 4)               DEFAULT NULL COMMENT '合同约定金额',
    `purch_contract_management_id` bigint(20)          NOT 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 '修改时间',
    `partner_entity_id`            bigint(20)                   DEFAULT NULL COMMENT '主表id',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB COMMENT ='采购合同-基本信息历史表';

DROP TABLE IF EXISTS `purch_contract_buyer_seller_history`;
CREATE TABLE `purch_contract_buyer_seller_history`
(
    `id`                                   bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `serial_number`                        smallint(5) unsigned         DEFAULT '0' COMMENT '编号',
    `name`                                 varchar(50)                  DEFAULT NULL COMMENT '姓名',
    `id_card`                              varchar(50)                  DEFAULT NULL COMMENT '身份证号',
    `contact`                              varchar(50)                  DEFAULT NULL COMMENT '联系方式',
    `purch_contract_basic_info_history_id` bigint(20)          NOT 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 COMMENT ='采购合同-需方收货人或供应商发货人历史表';

DROP TABLE IF EXISTS `purch_contract_goods_info_history`;
CREATE TABLE `purch_contract_goods_info_history`
(
    `id`                                   bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `sales_contract_goods_info_id`         bigint(20)          NOT NULL COMMENT '销售合同货物信息ID',
    `goods_name`                           varchar(500)        NOT NULL COMMENT '货物名称',
    `goods_factory`                        varchar(500)        NOT NULL COMMENT '厂家',
    `model_number`                         varchar(500)        NOT NULL COMMENT '型号',
    `units`                                varchar(10)         NOT NULL COMMENT '单位',
    `quantity`                             varchar(500)                 DEFAULT NULL COMMENT '数量',
    `remark`                               varchar(500)                 DEFAULT NULL COMMENT '备注',
    `purch_contract_basic_info_history_id` bigint(20)          NOT 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 '修改时间',
    `supplement`                           tinyint(3)                   DEFAULT NULL COMMENT '是否补充货物 0 不是 1 是',
    `price`                                varchar(50)                  DEFAULT NULL COMMENT '暂定单价',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB COMMENT ='采购合同-货物信息历史表';

DROP TABLE IF EXISTS `purch_contract_price_rule_history`;
CREATE TABLE `purch_contract_price_rule_history`
(
    `id`                                   bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `accrual_margin_calc_method`           tinyint(1)                   DEFAULT NULL COMMENT '利差计算方式（固定利率、固定金额）',
    `trade_platform_offer`                 decimal(17, 4)               DEFAULT NULL COMMENT '贸易平台报价/年',
    `factoring_offer`                      decimal(17, 2)               DEFAULT NULL COMMENT '保理报价/年',
    `factoring_finance_deadline`           int(10)                      DEFAULT NULL COMMENT '预估保理融资期限',
    `differ_amount`                        decimal(17, 2)               DEFAULT NULL COMMENT '差额',
    `monthly_interest_rate`                decimal(17, 4)               DEFAULT NULL COMMENT '月利率',
    `purch_contract_basic_info_history_id` bigint(20)          NOT 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 COMMENT ='采购合同-价格规则表';

DROP TABLE IF EXISTS `purch_contract_retention_info_history`;
CREATE TABLE `purch_contract_retention_info_history`
(
    `id`                                   bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `is_retention`                         tinyint(1)                   DEFAULT NULL COMMENT '是否有质保金，0:无 1:有',
    `retention_percent`                    decimal(17, 2)               DEFAULT NULL COMMENT '质保金比例',
    `is_limit`                             tinyint(1)                   DEFAULT NULL COMMENT '质保金是否有上限，0:无 1:有',
    `retention_limit`                      decimal(17, 2)               DEFAULT NULL COMMENT '质保金上限',
    `release_method`                       varchar(20)                  DEFAULT NULL COMMENT '质保金释放方式',
    `release_date`                         datetime                     DEFAULT NULL COMMENT '释放日期',
    `release_days`                         int(10)                      DEFAULT NULL COMMENT '释放天数',
    `purch_contract_basic_info_history_id` bigint(20)          NOT 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 COMMENT ='采购合同-质保金信息历史表';

DROP TABLE IF EXISTS `purch_contract_settle_payment_history`;
CREATE TABLE `purch_contract_settle_payment_history`
(
    `id`                                   bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `settle_method`                        bigint(20)                   DEFAULT NULL COMMENT '结算方式',
    `payment_method`                       varchar(1024)                DEFAULT NULL COMMENT '付款方式',
    `purch_contract_basic_info_history_id` bigint(20)          NOT 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 '修改时间',
    `bank_name`                            varchar(256)        NOT NULL COMMENT '银行名称',
    `bank_account_name`                    varchar(256)        NOT NULL COMMENT '供应商收款账户名',
    `bank_account`                         varchar(64)         NOT NULL COMMENT '银行卡号',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARSET = utf8 COMMENT ='采购合同-结算与付款历史表';

DROP TABLE IF EXISTS `purch_contract_sign_approval`;
CREATE TABLE `purch_contract_sign_approval`
(
    `id`                             bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `c_purch_contract_basic_info_id` bigint(20) unsigned          DEFAULT '0' 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
  DEFAULT CHARSET = utf8 COMMENT ='采购合同-签署审核表';

DROP TABLE IF EXISTS `purch_contract_supplement_info_history`;
CREATE TABLE `purch_contract_supplement_info_history`
(
    `id`                           bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `purch_contract_management_id` bigint(20)          NOT NULL COMMENT '采购合同管理Id',
    `supplement_contract_number`   varchar(50)                  DEFAULT NULL COMMENT '补充合同编号',
    `price_rule_detail`            varchar(500)                 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 '修改时间',
    `approval`                     tinyint(3)                   DEFAULT NULL COMMENT '是否审核 0 不审核 1 审核',
    `add_goods`                    tinyint(3)                   DEFAULT NULL COMMENT '是否新增货物 0 不新增 1 新增',
    `other_convention`             varchar(500)                 DEFAULT NULL COMMENT '其他约定',
    `remark`                       varchar(500)                 DEFAULT NULL COMMENT '说明',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB COMMENT ='采购合同-补充信息历史表';

DROP TABLE IF EXISTS `purch_contract_supplement_goods_info_history`;
CREATE TABLE `purch_contract_supplement_goods_info_history`
(
    `id`                                bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `purch_contract_supplement_info_id` bigint(20)          NOT NULL COMMENT '采购补充合同信息表Id',
    `goods_name`                        varchar(500)        NOT NULL COMMENT '货物名称',
    `goods_factory`                     varchar(500)        NOT NULL COMMENT '厂家',
    `model_number`                      varchar(500)        NOT NULL COMMENT '型号',
    `units`                             varchar(10)         NOT NULL COMMENT '单位',
    `quantity`                          varchar(500)                 DEFAULT NULL COMMENT '数量',
    `remark`                            varchar(500)                 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 '修改时间',
    `price`                             varchar(50)                  DEFAULT NULL COMMENT '暂定单价',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARSET = utf8 COMMENT ='采购合同-补充货物信息历史表';

-- 钢小二
DROP TABLE IF EXISTS `sell_bill`;
CREATE TABLE `sell_bill`
(
    `id`                         bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `c_acceptance_basic_info_id` bigint(20)               DEFAULT NULL COMMENT '下游验收单-基础信息表',
    `tenant_id`                  bigint(20)               DEFAULT NULL COMMENT '租户ID',
    `clear_version`              varchar(300)             DEFAULT '' COMMENT '清库版本号',
    `sell_bill_number`           varchar(300)             DEFAULT '' COMMENT '销售单号',
    `last_modify_time`           timestamp           NULL DEFAULT NULL COMMENT '最后更新日期 ',
    `company_id`                 bigint(20)               DEFAULT NULL COMMENT '销售单销售公司Id',
    `company_name`               varchar(300)             DEFAULT '' COMMENT '销售单销售公司',
    `customer_id`                bigint(20)               DEFAULT NULL COMMENT '销售单客户Id ',
    `customer_name`              varchar(300)             DEFAULT '' COMMENT '销售单客户',
    `project_id`                 bigint(20)               DEFAULT NULL COMMENT '工程Id',
    `project_name`               varchar(300)             DEFAULT '' COMMENT '销售单工程',
    `settlement_center_id`       bigint(20)               DEFAULT NULL COMMENT '代理结算单位Id',
    `settlement_center_name`     varchar(300)             DEFAULT '' COMMENT '代理结算（银科下面卡服保、长盈保贸易抬头）',
    `audit`                      tinyint(3)               DEFAULT NULL COMMENT '1是 0否',
    `state`                      tinyint(3)               DEFAULT NULL COMMENT '1未提交 2审批中 3已审批',
    `audit_date`                 timestamp           NULL DEFAULT NULL COMMENT '审单日期',
    `type`                       tinyint(3)               DEFAULT NULL COMMENT '1库存销售2先销后进',
    `receipt_date`               timestamp           NULL DEFAULT NULL COMMENT '签收日期',
    `attachment_url`             varchar(3000)            DEFAULT '' COMMENT '附件地址',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB COMMENT ='钢小二-销售单信息';

DROP TABLE IF EXISTS `sell_bill_item`;
CREATE TABLE `sell_bill_item`
(
    `id`                  bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `tenant_id`           bigint(20)               DEFAULT NULL COMMENT '租户ID',
    `clear_version`       varchar(300)             DEFAULT '' COMMENT '清库版本号',
    `sell_bill_id`        bigint(20)               DEFAULT NULL COMMENT '钢小二-销售单信息id',
    `last_modify_time`    timestamp           NULL DEFAULT NULL COMMENT '最后更新日期 ',
    `product_name_id`     bigint(20)               DEFAULT NULL COMMENT '品名id',
    `product_name`        varchar(300)             DEFAULT '' COMMENT '销售单明细品名',
    `material_id`         bigint(20)               DEFAULT NULL COMMENT '材质Id',
    `material_name`       varchar(300)             DEFAULT '' COMMENT '销售单明细材质',
    `specifications_id`   bigint(20)               DEFAULT NULL COMMENT '规格Id',
    `specification_name`  varchar(300)             DEFAULT '' COMMENT '销售单明细规格',
    `length`              varchar(300)             DEFAULT '',
    `origin`              bigint(20)               DEFAULT NULL COMMENT '产地Id',
    `originName`          varchar(300)             DEFAULT '' COMMENT '销售单明细产地',
    `unit`                bigint(20)               DEFAULT NULL COMMENT '单位id',
    `unit_text`           varchar(300)             DEFAULT '' COMMENT '销售单明细单位',
    `audit_quantity`      decimal(18, 6)           DEFAULT NULL COMMENT '销售单数量（取审单数量 ）',
    `audit_price`         decimal(18, 3)           DEFAULT NULL COMMENT '销售单单价（取审单单价 ）',
    `audit_amount`        decimal(18, 3)           DEFAULT NULL COMMENT '销售单金额（取审单金额 ）',
    `audit_proxy_price`   decimal(18, 3)           DEFAULT NULL COMMENT '销售单代理单价（取审单代理单价）',
    `stock_number`        varchar(300)             DEFAULT '' COMMENT '库存卡号',
    `transfered_quantity` decimal(18, 6)           DEFAULT NULL,
    `audit_proxy_amount`  decimal(18, 3)           DEFAULT NULL COMMENT '销售单代理金额（取审单代理金额 ）',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB COMMENT ='钢小二-销售单货物信息';

DROP TABLE IF EXISTS `sell_bill_file_ref`;
CREATE TABLE `sell_bill_file_ref`
(
    `id`               bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `file_id`          bigint(20)   DEFAULT NULL COMMENT '附件id',
    `sell_bill_id`     bigint(20)   DEFAULT NULL COMMENT '钢小二-销售单信息id',
    `sell_bill_number` varchar(300) DEFAULT '' COMMENT '销售单号',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB COMMENT ='钢小二-销售单和验收单关联关系表';

DROP TABLE IF EXISTS `sell_bill`;
CREATE TABLE `sell_bill`
(
    `id`                       bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `acceptance_basic_info_id` bigint(20)               DEFAULT NULL COMMENT '下游验收单-基础信息表',
    `tenant_id`                bigint(20)               DEFAULT NULL COMMENT '租户ID',
    `clear_version`            varchar(300)             DEFAULT '' COMMENT '清库版本号',
    `sell_bill_number`         varchar(300)             DEFAULT '' COMMENT '销售单号',
    `last_modify_time`         timestamp           NULL DEFAULT NULL COMMENT '最后更新日期 ',
    `company_id`               bigint(20)               DEFAULT NULL COMMENT '销售单销售公司Id',
    `company_name`             varchar(300)             DEFAULT '' COMMENT '销售单销售公司',
    `customer_id`              bigint(20)               DEFAULT NULL COMMENT '销售单客户Id ',
    `customer_name`            varchar(300)             DEFAULT '' COMMENT '销售单客户',
    `project_id`               bigint(20)               DEFAULT NULL COMMENT '工程Id',
    `project_name`             varchar(300)             DEFAULT '' COMMENT '销售单工程',
    `settlement_center_id`     bigint(20)               DEFAULT NULL COMMENT '代理结算单位Id',
    `settlement_center_name`   varchar(300)             DEFAULT '' COMMENT '代理结算（银科下面卡服保、长盈保贸易抬头）',
    `audit`                    tinyint(3)               DEFAULT NULL COMMENT '1是 0否',
    `state`                    tinyint(3)               DEFAULT NULL COMMENT '1未提交 2审批中 3已审批',
    `audit_date`               timestamp           NULL DEFAULT NULL COMMENT '审单日期',
    `type`                     tinyint(3)               DEFAULT NULL COMMENT '1库存销售2先销后进',
    `receipt_date`             timestamp           NULL DEFAULT NULL COMMENT '签收日期',
    `attachment_url`           varchar(3000)            DEFAULT '' COMMENT '附件地址',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB COMMENT ='钢小二-销售单信息';

DROP TABLE IF EXISTS `sell_bill_item`;
CREATE TABLE `sell_bill_item`
(
    `id`                  bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `tenant_id`           bigint(20)               DEFAULT NULL COMMENT '租户ID',
    `clear_version`       varchar(300)             DEFAULT '' COMMENT '清库版本号',
    `sell_bill_id`        bigint(20)               DEFAULT NULL COMMENT '钢小二-销售单信息id',
    `last_modify_time`    timestamp           NULL DEFAULT NULL COMMENT '最后更新日期 ',
    `product_name_id`     bigint(20)               DEFAULT NULL COMMENT '品名id',
    `product_name`        varchar(300)             DEFAULT '' COMMENT '销售单明细品名',
    `material_id`         bigint(20)               DEFAULT NULL COMMENT '材质Id',
    `material_name`       varchar(300)             DEFAULT '' COMMENT '销售单明细材质',
    `specifications_id`   bigint(20)               DEFAULT NULL COMMENT '规格Id',
    `specification_name`  varchar(300)             DEFAULT '' COMMENT '销售单明细规格',
    `length`              varchar(300)             DEFAULT '',
    `origin`              bigint(20)               DEFAULT NULL COMMENT '产地Id',
    `originName`          varchar(300)             DEFAULT '' COMMENT '销售单明细产地',
    `unit`                bigint(20)               DEFAULT NULL COMMENT '单位id',
    `unit_text`           varchar(300)             DEFAULT '' COMMENT '销售单明细单位',
    `audit_quantity`      decimal(18, 6)           DEFAULT NULL COMMENT '销售单数量（取审单数量 ）',
    `audit_price`         decimal(18, 3)           DEFAULT NULL COMMENT '销售单单价（取审单单价 ）',
    `audit_amount`        decimal(18, 3)           DEFAULT NULL COMMENT '销售单金额（取审单金额 ）',
    `audit_proxy_price`   decimal(18, 3)           DEFAULT NULL COMMENT '销售单代理单价（取审单代理单价）',
    `stock_number`        varchar(300)             DEFAULT '' COMMENT '库存卡号',
    `transfered_quantity` decimal(18, 6)           DEFAULT NULL,
    `audit_proxy_amount`  decimal(18, 3)           DEFAULT NULL COMMENT '销售单代理金额（取审单代理金额 ）',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB COMMENT ='钢小二-销售单货物信息';

DROP TABLE IF EXISTS `sell_bill_file_ref`;
CREATE TABLE `sell_bill_file_ref`
(
    `id`               bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `file_id`          bigint(20)   DEFAULT NULL COMMENT '附件id',
    `sell_bill_id`     bigint(20)   DEFAULT NULL COMMENT '钢小二-销售单信息id',
    `sell_bill_number` varchar(300) DEFAULT '' COMMENT '销售单号',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB COMMENT ='钢小二-销售单和验收单关联关系表';

DROP TABLE IF EXISTS `purch_contract_supplement_sign_approval`;
CREATE TABLE `purch_contract_supplement_sign_approval`
(
    `id`                                bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `purch_contract_supplement_info_id` bigint(20)          NOT 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 COMMENT ='采购合同-补充签署审核表';

DROP TABLE IF EXISTS `acceptance_price_adjust_approval_info`;
CREATE TABLE `acceptance_price_adjust_approval_info`
(
    `id`                                bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `c_acceptance_price_adjust_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 COMMENT ='验收单-单价调整审核表';

DROP TABLE IF EXISTS `purch_contract_replenish_info`;
CREATE TABLE `purch_contract_replenish_info`
(
    `id`                         bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `project_amount_category`    varchar(200)                 DEFAULT NULL COMMENT '工程量类别（概算量、固定量）',
    `goods_price_settle_method`  varchar(500)                 DEFAULT NULL COMMENT '货物单价结算方式',
    `purch_contract_approval_id` bigint(20)          NOT 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 COMMENT ='采购合同-补充信息表';

DROP TABLE IF EXISTS `purch_contract_deliver_clause`;
CREATE TABLE `purch_contract_deliver_clause`
(
    `id`                         bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `deliver_site`               varchar(50)                  DEFAULT NULL COMMENT '交货地点',
    `deliver_method`             varchar(50)                  DEFAULT NULL COMMENT '交货方式',
    `deliver_date`               varchar(500)                 DEFAULT NULL COMMENT '交货日期',
    `transport_premium`          varchar(50)                  DEFAULT NULL COMMENT '运输及保险费',
    `purch_contract_approval_id` bigint(20)          NOT 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 COMMENT ='采购合同-交货规定表';

DROP TABLE IF EXISTS `purch_contract_approval_settle_payment`;
CREATE TABLE `purch_contract_approval_settle_payment`
(
    `id`                         bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `settle_method`              varchar(200)                 DEFAULT NULL COMMENT '结算方式',
    `payment_method`             varchar(1024)                DEFAULT NULL COMMENT '付款时间及方式',
    `purch_contract_approval_id` bigint(20)          NOT 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 COMMENT ='采购合同审核-结算与付款表';

DROP TABLE IF EXISTS `purch_contract_other_clause`;
CREATE TABLE `purch_contract_other_clause`
(
    `id`                         bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `serial_number`              smallint(5) unsigned         DEFAULT '0' COMMENT '编号',
    `payment_condition`          varchar(2000)                DEFAULT NULL COMMENT '其他条件',
    `purch_contract_approval_id` bigint(20)          NOT 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 COMMENT ='采购合同-其他条款表';

DROP TABLE IF EXISTS `purch_contract_quality_accept`;
CREATE TABLE `purch_contract_quality_accept`
(
    `id`                         bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `accept_criteria`            varchar(2000)                DEFAULT NULL COMMENT '验收标准',
    `quality_criteria`           varchar(500)                 DEFAULT NULL COMMENT '质量标准',
    `purch_contract_approval_id` bigint(20)          NOT 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 COMMENT ='采购合同-质量与验收表';

DROP TABLE IF EXISTS `purch_contract_need_user_rel`;
CREATE TABLE `purch_contract_need_user_rel`
(
    `id`                         BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
    `purch_contract_approval_id` BIGINT(20)          NOT NULL COMMENT '采购合同审核表Id',
    `sys_user_id`                BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'b端用户表id',
    PRIMARY KEY (`id`)
) ENGINE = INNODB COMMENT = '采购合同需方收货人表';

DROP TABLE IF EXISTS `purch_contract_approval_settle_cycle`;
CREATE TABLE `purch_contract_approval_settle_cycle`
(
    `id`                         bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `settle_cycle_method`        varchar(100)                 DEFAULT NULL COMMENT '结算周期方式（固定天数、自然月）',
    `settle_cycle`               int(10)                      DEFAULT NULL COMMENT '结算周期',
    `plan_payback_days`          int(10)                      DEFAULT NULL COMMENT '约定回款时间',
    `settle_min_amount`          decimal(17, 2)               DEFAULT NULL COMMENT '结算最低差额',
    `purch_contract_approval_id` bigint(20)          NOT 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 COMMENT ='采购合同-结算周期表';

DROP TABLE IF EXISTS `purch_contract_approval_vat_info`;
CREATE TABLE `purch_contract_approval_vat_info`
(
    `id`                         bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `tax_rate`                   decimal(17, 2)               DEFAULT NULL COMMENT '税率',
    `receipt_type`               varchar(50)                  DEFAULT NULL COMMENT '发票类型',
    `open_cycle`                 varchar(50)                  DEFAULT NULL COMMENT '开票周期',
    `open_bank`                  varchar(50)                  DEFAULT NULL COMMENT '发票开户行',
    `receipt_account`            varchar(50)                  DEFAULT NULL COMMENT '发票账号',
    `receipt_remark`             varchar(500)                 DEFAULT NULL COMMENT '发票备注',
    `purch_contract_approval_id` bigint(20)          NOT 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 COMMENT ='采购合同审核-增值税要求表';

DROP TABLE IF EXISTS `sales_contract_supplement_template_first_approval_info`;
CREATE TABLE `sales_contract_supplement_template_first_approval_info`
(
    `id`                                  bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `c_sales_contract_supplement_info_id` bigint(20)                   DEFAULT NULL COMMENT '销售合同变更Id',
    `is_agree`                            tinyint(1)                   DEFAULT '0' COMMENT '是否满足 1 是 0 否',
    `approval_conclusion`                 varchar(50)         NOT 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 COMMENT ='销售合同变更-模板初审表';

DROP TABLE IF EXISTS `sales_contract_supplement_template_first_approval_condition_rel`;
CREATE TABLE `sales_contract_supplement_template_first_approval_condition_rel`
(
    `id`                                                        bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `sales_contract_supplement_template_first_approval_info_id` bigint(20) unsigned DEFAULT '0' COMMENT '销售合同-模板初审ID',
    `sales_contract_approval_condition_dic_id`                  bigint(20) unsigned DEFAULT NULL COMMENT '销售合同变更-模板初审(基础交易合同)-字典表ID',
    `is_agree`                                                  tinyint(1)          DEFAULT '0' COMMENT '是否满足 1 是 0 否',
    PRIMARY KEY (`id`)
) ENGINE = InnoDB COMMENT ='销售合同变更-模板初审和审核条件关联关系表';

DROP TABLE IF EXISTS `sales_contract_supplement_template_first_approval_comment_info`;
CREATE TABLE `sales_contract_supplement_template_first_approval_comment_info`
(
    `id`                                                        bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `sales_contract_supplement_template_first_approval_info_id` bigint(20)                   DEFAULT NULL COMMENT '销售合同-变更模板初审Id',
    `approval_comment`                                          varchar(50)         NOT 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 COMMENT ='销售合同变更-模板初审-审批意见表';

alter table c_purch_contract_management
    add `c_supplier_info_id` bigint(20) DEFAULT NULL COMMENT '供应商id';

DROP TABLE IF EXISTS `c_acceptance_basic_info`;
CREATE TABLE `c_acceptance_basic_info`
(
    `id`                           bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `business_number`              varchar(250)                 DEFAULT NULL COMMENT '业务编号',
    `trading_platform_id`          bigint(20)                   DEFAULT NULL COMMENT '贸易平台Id',
    `c_project_core_enterprise_id` bigint(20)                   DEFAULT NULL COMMENT '核心企业Id',
    `c_supplier_info_id`           bigint(20)                   DEFAULT NULL COMMENT '供应商企业信息Id',
    `acceptance_number`            varchar(250)                 DEFAULT NULL COMMENT '验收单号',
    `expected_settlement_date`     datetime                     DEFAULT NULL COMMENT '预计结算日期 ',
    `sign_confirm`                 tinyint(3)                   DEFAULT NULL COMMENT '是否签署确认 0否 1是',
    `specification`                varchar(50)                  DEFAULT '' COMMENT '特别说明',
    `steel_waiter`                 tinyint(3)                   DEFAULT NULL COMMENT '1是 0否  是否为刚小二',
    `acceptance_status`            varchar(50)                  DEFAULT '' COMMENT '状态',
    `additional_remarks`           varchar(500)                 DEFAULT NULL COMMENT '补充说明信息',
    `is_settlement`                tinyint(1)                   DEFAULT NULL COMMENT '是否已结算，0:未结算 1:已结算  （注：结算未审核完成统一视为未结算）',
    `is_receivables`               tinyint(1)                   DEFAULT NULL COMMENT '是否做底层，0:未做底层 1:已做底层',
    `is_approval`                  tinyint(1)                   DEFAULT NULL COMMENT '申请审核，0:不申请 1:申请',
    `stage`                        varchar(32)                  DEFAULT '' COMMENT '业务当前阶段',
    `sys_user_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 '修改时间',
    `signer`                       bigint(20)                   DEFAULT NULL COMMENT '验收单签署人Id',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB COMMENT ='下游验收单-基础信息表';

DROP TABLE IF EXISTS `acceptance_basic_info_his`;
CREATE TABLE `acceptance_basic_info_his`
(
    `id`                           bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `business_number`              varchar(250)       DEFAULT NULL COMMENT '业务编号',
    `trading_platform_id`          bigint(20)         DEFAULT NULL COMMENT '贸易平台Id',
    `c_project_core_enterprise_id` bigint(20)         DEFAULT NULL COMMENT '核心企业Id',
    `c_supplier_info_id`           bigint(20)         DEFAULT NULL COMMENT '供应商企业信息Id',
    `acceptance_number`            varchar(250)       DEFAULT NULL COMMENT '验收单号',
    `expected_settlement_date`     datetime           DEFAULT NULL COMMENT '预计结算日期 ',
    `sign_confirm`                 tinyint(3)         DEFAULT NULL COMMENT '是否签署确认 0否 1是',
    `specification`                varchar(50)        DEFAULT '' COMMENT '特别说明',
    `steel_waiter`                 tinyint(3)         DEFAULT NULL COMMENT '1是 0否  是否为刚小二',
    `acceptance_status`            varchar(50)        DEFAULT '' COMMENT '状态',
    `additional_remarks`           varchar(500)       DEFAULT NULL COMMENT '补充说明信息',
    `is_settlement`                tinyint(1)         DEFAULT NULL COMMENT '是否已结算，0:未结算 1:已结算  （注：结算未审核完成统一视为未结算）',
    `is_receivables`               tinyint(1)         DEFAULT NULL COMMENT '是否做底层，0:未做底层 1:已做底层',
    `is_approval`                  tinyint(1)         DEFAULT NULL COMMENT '申请审核，0:不申请 1:申请',
    `stage`                        varchar(32)        DEFAULT '' COMMENT '业务当前阶段',
    `sys_user_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 '修改时间',
    `signer`                       bigint(20)         DEFAULT NULL COMMENT '验收单签署人Id',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB COMMENT ='下游验收单-基础信息表';


ALTER TABLE c_purch_contract_retention_info
    ADD `release_time` varchar(50) DEFAULT NULL COMMENT '质保金释放时间';
ALTER TABLE purch_contract_retention_info_history
    ADD `release_time` varchar(50) DEFAULT NULL COMMENT '质保金释放时间';

ALTER TABLE purch_contract_approval_settle_cycle
    ADD `settle_rule` varchar(50) DEFAULT NULL COMMENT '结算规则';


alter table purch_contract_need_user_rel
    add `name` varchar(200) DEFAULT NULL COMMENT '用户名';
alter table purch_contract_need_user_rel
    add `mobile` varchar(20) DEFAULT NULL COMMENT '手机号';
alter table purch_contract_need_user_rel
    add `id_card` varchar(255) DEFAULT NULL COMMENT '身份证号';
ALTER TABLE purch_contract_supplement_approval
    ADD `visible` tinyint(3) DEFAULT NULL COMMENT '是否提交 0 不提交 1 提交';

DROP TABLE IF EXISTS `purch_contract_supplement_approval_comment_info`;
CREATE TABLE `purch_contract_supplement_approval_comment_info`
(
    `id`                                    bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `purch_contract_supplement_approval_id` bigint(20)                   DEFAULT NULL COMMENT '采购合同变更-审核Id',
    `other_comment`                         varchar(50)         NOT 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 COMMENT ='采购合同变更-其他约定表';


DROP TABLE IF EXISTS `upload_purch_supplement_contract`;
CREATE TABLE `upload_purch_supplement_contract`
(
    `id`                                    bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `purch_contract_supplement_approval_id` bigint(20)          NOT NULL COMMENT '采购合同变更-审核表Id',
    `contract_name`                         varchar(500)                 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`) USING BTREE
) ENGINE = InnoDB COMMENT ='采购合同 上传变更合同的信息';

DROP TABLE IF EXISTS `upload_purch_contract_supplement_signer`;
CREATE TABLE `upload_purch_contract_supplement_signer`
(
    `id`                                  bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `upload_purch_supplement_contract_id` bigint(20)          NOT NULL COMMENT '采购合同变更-上传合同的信息Id',
    `signer_name`                         varchar(500)                 DEFAULT NULL COMMENT '签署人名称',
    `signer_social_credit_code`           varchar(500)                 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`) USING BTREE
) ENGINE = InnoDB COMMENT ='采购合同 上传变更合同的签署人信息';

ALTER table purch_contract_supplement_approval
    ADD `price_rule_detail` varchar(500) DEFAULT NULL COMMENT '价格规则计算';
ALTER table purch_contract_supplement_approval
    ADD `contract_effect_date` varchar(500) DEFAULT NULL COMMENT '合同生效日';

ALTER TABLE c_purch_contract_supplement_electronic_info
    ADD `fdd_customer_id` varchar(50) DEFAULT NULL COMMENT '客户编号';

ALTER table c_sales_supplement_sign_confirmation_electronic_info
    add `file_id` bigint(20) DEFAULT NULL COMMENT '电子签文件';

ALTER TABLE c_sales_contract_goods_info
    ADD `occupy` tinyint(1) DEFAULT 0 COMMENT '是否被占用，0:否 1:是';
ALTER TABLE c_sales_contract_supplement_goods_info
    ADD `occupy` tinyint(1) DEFAULT 0 COMMENT '是否被占用，0:否 1:是';

ALTER table c_purch_contract_supplement_goods_info
    ADD `supplement` tinyint(3) DEFAULT 0 COMMENT '是否补充货物 0 不是 1 是';
ALTER TABLE c_purch_contract_supplement_goods_info
    ADD `c_sales_contract_goods_info_id` bigint(20) NOT NULL COMMENT '销售合同货物信息ID';

CREATE TABLE `upload_purch_contract`
(
    `id`                         bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `purch_contract_approval_id` bigint(20)          NOT NULL COMMENT '采购合同-审核表Id',
    `contract_name`              varchar(500)                 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`) USING BTREE
) ENGINE = InnoDB COMMENT ='采购合同 上传合同的信息';

CREATE TABLE `upload_purch_contract_signer`
(
    `id`                        bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `upload_purch_contract_id`  bigint(20)          NOT NULL COMMENT '采购合同-上传合同的信息Id',
    `signer_name`               varchar(500)                 DEFAULT NULL COMMENT '签署人名称',
    `signer_social_credit_code` varchar(500)                 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`) USING BTREE
) ENGINE = InnoDB COMMENT ='采购合同 上传合同的签署人信息';

INSERT INTO `t_permission`(`parentId`, `cname`, `ename`, `gradation`, `moduleName`, `url`, `icon`, `user_create`,
                           `user_modified`, `gmt_create`, `gmt_modified`)
VALUES (NULL, '招投标管理', 'BiddingBasicInfo', 0, NULL, '', NULL, NULL, NULL, now(), now());
INSERT INTO `t_permission`(`parentId`, `cname`, `ename`, `gradation`, `moduleName`, `url`, `icon`, `user_create`,
                           `user_modified`, `gmt_create`, `gmt_modified`)
VALUES ((select t.id from t_permission t where t.ename = 'BiddingBasicInfo'), '数据全员可见', 'viewAllBiddingBasicInfo', 0,
        '招投标管理', null, NULL, NULL, NULL, now(), now());

ALTER TABLE c_sales_supplement_sign_confirmation_electronic_info
    add `call_back` tinyint(3) DEFAULT '0' COMMENT '是否回调 0 未回调 1 回调';
ALTER TABLE c_sales_sign_confirmation_electronic_info
    add `call_back` tinyint(3) DEFAULT '0' COMMENT '是否回调 0 未回调 1 回调';

ALTER TABLE c_project_information ADD `already_bidding` tinyint(1) DEFAULT 0 COMMENT '是否已做招投标，0:否 1:是';
ALTER TABLE c_sales_contract_management ADD `purch` tinyint(1) DEFAULT 0 COMMENT '是否已做采购合同，0:否 1:是';

ALTER TABLE sales_contract_approval add   `settle_rule` varchar(200) COLLATE utf8_bin DEFAULT '' COMMENT '结算规则';
ALTER TABLE c_purch_contract_buyer_seller add `buyer_or_seller` tinyint(1) NOT NULL DEFAULT '2' COMMENT '收货人/发货人标识 （1:需方收货人,2:供应商发货人）';

UPDATE t_dictionary set code = 'purchContractSettleMethod1' WHERE id = 1033;
UPDATE t_dictionary set code = 'purchContractSettleMethod2' WHERE id = 1034;
UPDATE t_dictionary set code = 'purchContractSettleMethod3' WHERE id = 1035;

ALTER table c_purch_contract_supplement_info
    ADD `contract_effect_date` varchar(500) DEFAULT NULL COMMENT '合同生效日';

ALTER table purch_contract_supplement_info_history
    ADD `contract_effect_date` varchar(500) DEFAULT NULL COMMENT '合同生效日';

ALTER TABLE c_sales_contract_supplement_goods_info ADD `supplement`  tinyint(1)  DEFAULT NULL COMMENT '是否补充货物 1:是,0:否';
