
/*
 Navicat MySQL Data Transfer

 Source Server         : localhost
 Source Server Type    : MySQL
 Source Server Version : 80032 (8.0.32)
 Source Host           : localhost:3306
 Source Schema         : java_financial

 Target Server Type    : MySQL
 Target Server Version : 80032 (8.0.32)
 File Encoding         : 65001

 Date: 22/09/2023 12:01:49
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for assure
-- ----------------------------
DROP TABLE IF EXISTS `assure`;
CREATE TABLE `assure`  (
                           `id` int NOT NULL AUTO_INCREMENT COMMENT 'ID',
                           `created_at` timestamp NULL DEFAULT NULL COMMENT '创建时间',
                           `updated_at` timestamp NULL DEFAULT NULL COMMENT '修改时间',
                           `examination_id` int NOT NULL COMMENT '考核ID',
                           `flow_id` int NOT NULL COMMENT '流程ID',
                           `instance_id` int NULL DEFAULT 0 COMMENT '流程实例ID',
                           `financing_id` int NULL DEFAULT NULL COMMENT '融资ID',
                           `assure_no` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '承兑担保编号',
                           `assure_end_time` timestamp NULL DEFAULT NULL COMMENT '签约日期',
                           `assure_amount` decimal(10, 2) UNSIGNED NULL DEFAULT 0.00 COMMENT '担保金额',
                           `express_id` int NULL DEFAULT NULL COMMENT '担保企业ID',
                           `express_name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '担保企业名称',
                           `product_assure_status` tinyint NULL DEFAULT NULL COMMENT '货物反担保状态 0未确认，1已确认',
                           `buyer_id` int NULL DEFAULT NULL COMMENT '被担保企业ID',
                           `buyer_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '被担保企业名称',
                           PRIMARY KEY (`id`) USING BTREE,
                           INDEX `examination_idx`(`examination_id` ASC) USING BTREE,
                           INDEX `instance_idx`(`instance_id` ASC) USING BTREE,
                           INDEX `flow_idx`(`flow_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '担保' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for attachments
-- ----------------------------
DROP TABLE IF EXISTS `attachments`;
CREATE TABLE `attachments`  (
                                `id` int NOT NULL AUTO_INCREMENT,
                                `created_at` timestamp NULL DEFAULT NULL,
                                `updated_at` timestamp NULL DEFAULT NULL,
                                `data` json NULL,
                                `type` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
                                `path` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
                                `name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
                                PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for bank_acceptance_bill
-- ----------------------------
DROP TABLE IF EXISTS `bank_acceptance_bill`;
CREATE TABLE `bank_acceptance_bill`  (
                                         `id` int NOT NULL AUTO_INCREMENT COMMENT 'ID',
                                         `created_at` timestamp NULL DEFAULT NULL COMMENT '创建时间',
                                         `updated_at` timestamp NULL DEFAULT NULL COMMENT '修改时间',
                                         `examination_id` int NOT NULL COMMENT '考核ID',
                                         `flow_id` int NOT NULL COMMENT '流程ID',
                                         `instance_id` int NOT NULL DEFAULT 0 COMMENT '流程实例ID',
                                         `invoice_no` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '汇票编号',
                                         `invoice_time` timestamp NULL DEFAULT NULL COMMENT '出票日期',
                                         `invoice_status` tinyint UNSIGNED NULL DEFAULT 0 COMMENT '出票状态',
                                         `invoice_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '出票金额',
                                         `invoice_fee` decimal(10, 2) NULL DEFAULT NULL COMMENT '手续费',
                                         `seller_id` int NULL DEFAULT NULL COMMENT '收款人ID',
                                         `seller_name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '收款人',
                                         `bank_id` int NULL DEFAULT NULL COMMENT '承兑银行ID',
                                         `bank_name` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '承兑银行',
                                         `buyer_id` int NULL DEFAULT NULL COMMENT '出票人ID',
                                         `buyer_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '出票人',
                                         `financing_id` int NULL DEFAULT NULL COMMENT '融资ID',
                                         `contract_id` int NULL DEFAULT NULL COMMENT '购销合同ID',
                                         PRIMARY KEY (`id`) USING BTREE,
                                         INDEX `examination_idx`(`examination_id` ASC) USING BTREE,
                                         INDEX `instance_idx`(`instance_id` ASC) USING BTREE,
                                         INDEX `flow_idx`(`flow_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '银行承兑汇票' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for classes
-- ----------------------------
DROP TABLE IF EXISTS `classes`;
CREATE TABLE `classes`  (
                            `id` bigint NOT NULL AUTO_INCREMENT,
                            `name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
                            `created_at` timestamp NULL DEFAULT NULL,
                            `updated_at` timestamp NULL DEFAULT NULL,
                            `data` json NULL,
                            `school_id` int NOT NULL,
                            `teacher_id` int NOT NULL COMMENT '教师id',
                            `classes_id` bigint NULL DEFAULT NULL COMMENT 'classes_id',
                            PRIMARY KEY (`id`) USING BTREE,
                            INDEX `fk_classes_schools1_idx`(`school_id` ASC) USING BTREE,
                            INDEX `fk_classes_users1_idx`(`teacher_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 999 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '班级表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for configs
-- ----------------------------
DROP TABLE IF EXISTS `configs`;
CREATE TABLE `configs`  (
                            `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
                            `created_at` timestamp NULL DEFAULT NULL,
                            `updated_at` timestamp NULL DEFAULT NULL,
                            `user_id` int NOT NULL COMMENT '用户ID',
                            `name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '配置名',
                            `value` json NULL COMMENT '配置值',
                            `flow_rate` decimal(10, 2) NULL DEFAULT NULL COMMENT '业务流程评分%',
                            `raise_rate` decimal(10, 2) NULL DEFAULT NULL COMMENT '资产增长率评分%',
                            `report_rate` decimal(10, 2) NULL DEFAULT NULL COMMENT '实训报告评分%',
                            `duration_rate` decimal(10, 2) NULL DEFAULT NULL COMMENT '实训时长评分%',
                            `operator_rate` decimal(10, 2) NULL DEFAULT NULL COMMENT '流程准确性维度%',
                            `raise_set_data` json NULL COMMENT '增长率评分设置',
                            `duration_set_data` json NULL COMMENT '实训时长打分设置',
                            PRIMARY KEY (`id`) USING BTREE,
                            INDEX `fk_configs_users1_idx`(`user_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for contracts_factoring
-- ----------------------------
DROP TABLE IF EXISTS `contracts_factoring`;
CREATE TABLE `contracts_factoring`  (
                                        `id` int NOT NULL AUTO_INCREMENT COMMENT 'ID',
                                        `created_at` timestamp NULL DEFAULT NULL COMMENT '创建时间',
                                        `updated_at` timestamp NULL DEFAULT NULL COMMENT '修改时间',
                                        `examination_id` int NOT NULL COMMENT '考核ID',
                                        `flow_id` int NOT NULL COMMENT '流程ID',
                                        `instance_id` int NOT NULL DEFAULT 0 COMMENT '流程实例ID',
                                        `bl_contract_no` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '保理合同编号',
                                        `bl_contract_time` timestamp NULL DEFAULT NULL COMMENT '合同签订日期',
                                        `bl_contract_status` tinyint UNSIGNED NULL DEFAULT 0 COMMENT '合同状态',
                                        `buyer_id` int NULL DEFAULT NULL COMMENT '买方ID',
                                        `buyer_name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '买方',
                                        `seller_id` int NULL DEFAULT NULL COMMENT '卖方ID',
                                        `seller_name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '卖方',
                                        `bank_id` int NULL DEFAULT NULL COMMENT '银行ID',
                                        `bank_name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '银行',
                                        `accept_no` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '受理单号',
                                        `buyer_confirm` tinyint(1) NULL DEFAULT NULL COMMENT '买方是否确认',
                                        `seller_confirm` tinyint(1) NULL DEFAULT NULL COMMENT '卖方是否确认',
                                        `bank_confirm` tinyint(1) NULL DEFAULT NULL COMMENT '银行是否确认',
                                        `apply_rate` decimal(10, 2) NULL DEFAULT NULL,
                                        `supply_rate` decimal(10, 2) NULL DEFAULT NULL COMMENT '反向保理利率',
                                        `contract_account` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '合同账户',
                                        `apply_poundage_rate` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '手续费率',
                                        `bl_contract_file` json NULL COMMENT '合同文件',
                                        `contract_id` int NULL DEFAULT NULL COMMENT '购销合同ID',
                                        `accept_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '核定保理额度',
                                        `bl_contract_end_time` timestamp NULL DEFAULT NULL COMMENT '到期日',
                                        PRIMARY KEY (`id`) USING BTREE,
                                        INDEX `examination_idx`(`examination_id` ASC) USING BTREE,
                                        INDEX `instance_idx`(`instance_id` ASC) USING BTREE,
                                        INDEX `flow_idx`(`flow_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '保理合同' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for contracts_pledge
-- ----------------------------
DROP TABLE IF EXISTS `contracts_pledge`;
CREATE TABLE `contracts_pledge`  (
                                     `id` int NOT NULL AUTO_INCREMENT COMMENT 'ID',
                                     `created_at` timestamp NULL DEFAULT NULL COMMENT '创建时间',
                                     `updated_at` timestamp NULL DEFAULT NULL COMMENT '修改时间',
                                     `examination_id` int NOT NULL COMMENT '考核ID',
                                     `flow_id` int NOT NULL COMMENT '流程ID',
                                     `instance_id` int NOT NULL DEFAULT 0 COMMENT '流程实例ID',
                                     `zy_contract_no` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '质押合同编号',
                                     `zy_contract_time` timestamp NULL DEFAULT NULL COMMENT '到期日',
                                     `zy_contract_status` tinyint UNSIGNED NULL DEFAULT 0 COMMENT '合同状态 ',
                                     `buyer_id` int NULL DEFAULT NULL COMMENT '次债务人ID',
                                     `buyer_name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '次债务人',
                                     `seller_id` int NULL DEFAULT NULL COMMENT '出质人ID',
                                     `seller_name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '出质人',
                                     `bank_id` int NULL DEFAULT NULL COMMENT '质权人ID',
                                     `bank_name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '质权人',
                                     `buyer_confirm` tinyint(1) NULL DEFAULT NULL COMMENT '买方是否确认',
                                     `seller_confirm` tinyint(1) NULL DEFAULT NULL COMMENT '卖方是否确认',
                                     `bank_confirm` tinyint(1) NULL DEFAULT NULL COMMENT '银行是否确认',
                                     `yszk_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '应收账款金额',
                                     `financing_id` int NULL DEFAULT NULL COMMENT '贷款ID',
                                     `contract_id` int NULL DEFAULT NULL COMMENT '购销合同ID',
                                     `seller_zy_contract_file` json NULL COMMENT '质押合同文件',
                                     PRIMARY KEY (`id`) USING BTREE,
                                     INDEX `examination_idx`(`examination_id` ASC) USING BTREE,
                                     INDEX `instance_idx`(`instance_id` ASC) USING BTREE,
                                     INDEX `flow_idx`(`flow_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '质押合同' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for contracts_products
-- ----------------------------
DROP TABLE IF EXISTS `contracts_products`;
CREATE TABLE `contracts_products`  (
                                       `id` int NOT NULL AUTO_INCREMENT COMMENT 'ID',
                                       `contract_id` int NULL DEFAULT NULL COMMENT '购销合同ID',
                                       `protocol_id` int NULL DEFAULT NULL COMMENT '协议ID',
                                       `product_no` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '产品编号',
                                       `product_id` int NULL DEFAULT NULL COMMENT '产品ID',
                                       `nums` int NULL DEFAULT NULL COMMENT '数量',
                                       `price` decimal(10, 2) NULL DEFAULT NULL COMMENT '签订合同时总价格',
                                       `pickup_status` tinyint NULL DEFAULT NULL COMMENT '提货状态 1已提货',
                                       `pickup_product_id` int NULL DEFAULT NULL COMMENT '提货ID',
                                       `created_at` timestamp NULL DEFAULT NULL COMMENT '创建时间',
                                       `updated_at` timestamp NULL DEFAULT NULL COMMENT '修改时间',
                                       PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 76 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '合同产品' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for contracts_purchase_sales
-- ----------------------------
DROP TABLE IF EXISTS `contracts_purchase_sales`;
CREATE TABLE `contracts_purchase_sales`  (
                                             `id` int NOT NULL AUTO_INCREMENT COMMENT 'ID',
                                             `created_at` timestamp NULL DEFAULT NULL COMMENT '创建时间',
                                             `updated_at` timestamp NULL DEFAULT NULL COMMENT '修改时间',
                                             `examination_id` int NOT NULL COMMENT '考核ID',
                                             `flow_id` int NOT NULL COMMENT '流程ID',
                                             `instance_id` int NULL DEFAULT 0 COMMENT 'examination_instances id',
                                             `contract_no` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '合同编号',
                                             `contract_time` timestamp NULL DEFAULT NULL COMMENT '签约日期',
                                             `contract_status` tinyint UNSIGNED NULL DEFAULT 0 COMMENT '合同状态 0未确认 1买方确认 2卖方确认',
                                             `buyer_id` int NULL DEFAULT NULL COMMENT '买方ID',
                                             `buyer_name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '买方',
                                             `seller_id` int NULL DEFAULT NULL COMMENT '卖方ID',
                                             `seller_name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '卖方',
                                             `bank_id` int NULL DEFAULT NULL COMMENT '银行ID',
                                             `bank_name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '银行',
                                             `express_id` int NULL DEFAULT NULL COMMENT '物流ID',
                                             `express_name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '物流',
                                             `buyer_confirm` tinyint(1) NULL DEFAULT NULL COMMENT '买方是否确认',
                                             `seller_confirm` tinyint(1) NULL DEFAULT NULL COMMENT '卖方是否确认',
                                             `bank_confirm` tinyint(1) NULL DEFAULT NULL COMMENT '银行是否确认',
                                             `express_confirm` tinyint(1) NULL DEFAULT NULL COMMENT '物流是否确认',
                                             `contract_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '合同金额',
                                             `pay_time` timestamp NULL DEFAULT NULL COMMENT '付款日期',
                                             `total_cost_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '货物成本总价',
                                             `total_sell_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '货物总售价',
                                             `examination_inst_id` int NULL DEFAULT NULL COMMENT 'user_examination id',
                                             PRIMARY KEY (`id`) USING BTREE,
                                             INDEX `examination_idx`(`examination_id` ASC) USING BTREE,
                                             INDEX `instance_idx`(`instance_id` ASC) USING BTREE,
                                             INDEX `flow_idx`(`flow_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 14 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '卖方、买方签订购销合同' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for examination_classes
-- ----------------------------
DROP TABLE IF EXISTS `examination_classes`;
CREATE TABLE `examination_classes`  (
                                        `examination_id` bigint NOT NULL,
                                        `class_id` bigint NOT NULL,
                                        `status` tinyint UNSIGNED NOT NULL DEFAULT 0,
                                        `data` json NULL,
                                        PRIMARY KEY (`examination_id`, `class_id`) USING BTREE,
                                        INDEX `fk_classes_has_examinations_examinations1_idx`(`examination_id` ASC) USING BTREE,
                                        INDEX `fk_classes_has_examinations_classes1_idx`(`class_id` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for examination_financials
-- ----------------------------
DROP TABLE IF EXISTS `examination_financials`;
CREATE TABLE `examination_financials`  (
                                           `id` int NOT NULL AUTO_INCREMENT,
                                           `created_at` timestamp NULL DEFAULT NULL,
                                           `updated_at` timestamp NULL DEFAULT NULL,
                                           `data` json NULL,
                                           `init_balance` decimal(65, 2) NULL DEFAULT 1000000.00 COMMENT '初始资金',
                                           `balance` decimal(65, 2) NOT NULL DEFAULT 1000000.00 COMMENT '可用资金',
                                           `product_assets` decimal(65, 2) NOT NULL COMMENT '存货价值',
                                           `raise_rate` decimal(11, 2) NULL DEFAULT NULL COMMENT '资产增长率',
                                           `raise_orders` int NULL DEFAULT 0 COMMENT '资产增长率排名',
                                           PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 488 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '融资申请方的资金概况' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for examination_instances
-- ----------------------------
DROP TABLE IF EXISTS `examination_instances`;
CREATE TABLE `examination_instances`  (
                                          `id` int NOT NULL AUTO_INCREMENT,
                                          `created_at` timestamp NULL DEFAULT NULL,
                                          `updated_at` timestamp NULL DEFAULT NULL,
                                          `data` json NULL,
                                          `examination_id` int NOT NULL,
                                          `flow_id` int NOT NULL,
                                          `finish_step` int UNSIGNED NULL DEFAULT 0,
                                          `status` tinyint UNSIGNED NOT NULL DEFAULT 0 COMMENT '1:已提交实训；',
                                          `team_id` int NULL DEFAULT 0,
                                          `init_balance` decimal(65, 2) NULL DEFAULT NULL COMMENT '初始资金',
                                          `balance` decimal(65, 2) NULL DEFAULT NULL COMMENT '可用资金',
                                          `product_assets` decimal(65, 2) NULL DEFAULT NULL COMMENT '存货价值',
                                          `raise_rate` decimal(65, 2) NULL DEFAULT NULL COMMENT '资产增长率',
                                          `raise_orders` int NULL DEFAULT NULL COMMENT '资产增长率排名',
                                          PRIMARY KEY (`id`) USING BTREE,
                                          INDEX `examination_idx`(`examination_id` ASC) USING BTREE,
                                          INDEX `flow_idx`(`flow_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1991 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for examinations
-- ----------------------------
DROP TABLE IF EXISTS `examinations`;
CREATE TABLE `examinations`  (
                                 `id` bigint NOT NULL AUTO_INCREMENT,
                                 `created_at` timestamp NULL DEFAULT NULL,
                                 `updated_at` timestamp NULL DEFAULT NULL,
                                 `deleted_at` timestamp NULL DEFAULT NULL,
                                 `data` json NULL,
                                 `name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
                                 `flow_id` bigint NOT NULL COMMENT '流程id',
                                 `mode` tinyint UNSIGNED NOT NULL DEFAULT 0 COMMENT '实训模式：0：个人；1：班级；',
                                 `start_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
                                 `end_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
                                 `teacher_id` bigint NOT NULL COMMENT '教师id',
                                 `status` tinyint UNSIGNED NOT NULL DEFAULT 0,
                                 `user_num` int UNSIGNED NOT NULL DEFAULT 0,
                                 `type` tinyint UNSIGNED NOT NULL DEFAULT 0 COMMENT '0:练习模式；1: 实训模式；',
                                 `scores_status` tinyint UNSIGNED NOT NULL DEFAULT 0 COMMENT '0: 待评分；1：已评分；',
                                 `is_delete` tinyint(1) NULL DEFAULT NULL,
                                 PRIMARY KEY (`id`) USING BTREE,
                                 UNIQUE INDEX `name_UNIQUE`(`name` ASC, `deleted_at` ASC) USING BTREE,
                                 INDEX `flow_idx`(`flow_id` ASC) USING BTREE,
                                 INDEX `users_idx`(`teacher_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 94 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for financings
-- ----------------------------
DROP TABLE IF EXISTS `financings`;
CREATE TABLE `financings`  (
                               `id` int NOT NULL AUTO_INCREMENT COMMENT 'ID',
                               `created_at` timestamp NULL DEFAULT NULL COMMENT '创建时间',
                               `updated_at` timestamp NULL DEFAULT NULL COMMENT '修改时间',
                               `examination_id` int NOT NULL COMMENT '考核ID',
                               `flow_id` int NOT NULL COMMENT '流程ID',
                               `instance_id` int NOT NULL DEFAULT 0 COMMENT '流程实例ID',
                               `apply_no` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '融资申请编号',
                               `apply_status` tinyint NULL DEFAULT 0 COMMENT '0:已申请融资；1：银行已受理；2：银行审核通过；-5：银行已驳回；',
                               `role_id` int NULL DEFAULT NULL COMMENT '角色ID',
                               `role_type` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '角色类型',
                               `financing_no` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '贷款编号',
                               `financing_status` tinyint NULL DEFAULT 0 COMMENT '1: 贷款发放; 5：还款中； 9：已结清贷款；',
                               `financing_end_time` timestamp NULL DEFAULT NULL COMMENT '贷款到期时间',
                               `levy_status` tinyint NULL DEFAULT NULL COMMENT '1: 催收成功',
                               `seller_id` int NULL DEFAULT NULL COMMENT '申请企业ID',
                               `seller_name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '申请企业名称',
                               `bank_id` int NULL DEFAULT NULL COMMENT '贷款银行ID',
                               `bank_name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '贷款银行名称',
                               `apply_rate` decimal(10, 2) NULL DEFAULT NULL COMMENT '利率(%)',
                               `apply_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '贷款申请金额',
                               `yfzk_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '应付（应收）账款金额',
                               `interest_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '利息总额',
                               `repayment_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '已还金额',
                               `financing_months` int NULL DEFAULT NULL COMMENT '融资期限（月）',
                               `financing_start_time` timestamp NULL DEFAULT NULL COMMENT '贷款开始时间',
                               `max_apply_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '最大融资金额',
                               `protocol_no` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '协议编号',
                               `accept_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '受理编号',
                               `bail_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '需缴纳保证金',
                               `bail_status` tinyint NULL DEFAULT NULL COMMENT '保证金缴纳状态 0未缴纳 1已缴纳',
                               `bail_rate` decimal(10, 2) NULL DEFAULT NULL COMMENT '保证金比例',
                               `accept_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '核定保理额度',
                               `contract_id` int NULL DEFAULT NULL COMMENT '合同ID',
                               `contract_no` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '合同编号',
                               `contract_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '合同金额',
                               `fk_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '融资放款金额',
                               `apply_poundage` decimal(10, 2) NULL DEFAULT NULL COMMENT '手续费(至少10元)',
                               `commit_status` tinyint NULL DEFAULT NULL COMMENT '余款入账状态 0未入账 1已入账',
                               `financing_type` tinyint NULL DEFAULT NULL COMMENT '融资类型 1存货质押；2保兑仓；3应收账款质押；4正向保理；5反向保理；',
                               `buyer_id` int NULL DEFAULT NULL COMMENT '买方ID',
                               `buyer_name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '买方名称',
                               `audit_desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '审核意见',
                               `financing_audit_time` timestamp NULL DEFAULT NULL COMMENT '审核时间',
                               `financing_audit_user` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '审核人',
                               `protocol_id` int NULL DEFAULT NULL COMMENT '协议ID',
                               PRIMARY KEY (`id`) USING BTREE,
                               INDEX `examination_idx`(`examination_id` ASC) USING BTREE,
                               INDEX `instance_idx`(`instance_id` ASC) USING BTREE,
                               INDEX `flow_idx`(`flow_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 22 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for flows
-- ----------------------------
DROP TABLE IF EXISTS `flows`;
CREATE TABLE `flows`  (
                          `id` bigint NOT NULL AUTO_INCREMENT,
                          `created_at` timestamp NULL DEFAULT NULL COMMENT '创建时间',
                          `updated_at` timestamp NULL DEFAULT NULL COMMENT '更新时间',
                          `data` json NULL,
                          `name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '业务名称',
                          `abbr` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '流程简称',
                          `step` int NULL DEFAULT NULL COMMENT '流程总步骤',
                          `roles` json NULL COMMENT '流程相关角色',
                          `flow_scores` decimal(10, 2) NULL DEFAULT NULL COMMENT '流程分数',
                          `apply_role_id` int NULL DEFAULT NULL COMMENT '申请角色Id',
                          PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 56 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '实训业务流程' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for instance_datas
-- ----------------------------
DROP TABLE IF EXISTS `instance_datas`;
CREATE TABLE `instance_datas`  (
                                   `id` int NOT NULL AUTO_INCREMENT,
                                   `examination_id` int NOT NULL,
                                   `flow_id` int NOT NULL,
                                   `instance_id` int NOT NULL DEFAULT 0,
                                   `parent_id` int NOT NULL DEFAULT 0,
                                   `prefix` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
                                   `no` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '编号',
                                   `status` tinyint NULL DEFAULT 0,
                                   `time` timestamp NULL DEFAULT NULL COMMENT '日期',
                                   `created_at` timestamp NULL DEFAULT NULL,
                                   `updated_at` timestamp NULL DEFAULT NULL,
                                   `data` json NULL,
                                   `instance_role_id` int NOT NULL DEFAULT 0,
                                   PRIMARY KEY (`id`) USING BTREE,
                                   INDEX `examination_idx`(`examination_id` ASC) USING BTREE,
                                   INDEX `instance_idx`(`instance_id` ASC) USING BTREE,
                                   INDEX `flow_idx`(`flow_id` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for instance_roles
-- ----------------------------
DROP TABLE IF EXISTS `instance_roles`;
CREATE TABLE `instance_roles`  (
                                   `id` int NOT NULL AUTO_INCREMENT,
                                   `instance_data_id` int NULL DEFAULT NULL,
                                   `buyer_id` int NULL DEFAULT NULL,
                                   `buyer_name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
                                   `seller_id` int NULL DEFAULT NULL,
                                   `seller_name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
                                   `bank_id` int NULL DEFAULT NULL,
                                   `bank_name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
                                   `express_id` int NULL DEFAULT NULL,
                                   `express_name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
                                   `created_at` timestamp NULL DEFAULT NULL,
                                   `updated_at` timestamp NULL DEFAULT NULL,
                                   `data` json NULL,
                                   PRIMARY KEY (`id`) USING BTREE,
                                   INDEX `instance_data_idx`(`instance_data_id` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for invoice
-- ----------------------------
DROP TABLE IF EXISTS `invoice`;
CREATE TABLE `invoice`  (
                            `id` int NOT NULL AUTO_INCREMENT COMMENT 'ID',
                            `created_at` timestamp NULL DEFAULT NULL COMMENT '创建时间',
                            `updated_at` timestamp NULL DEFAULT NULL COMMENT '修改时间',
                            `examination_id` int NOT NULL COMMENT '考核ID',
                            `flow_id` int NOT NULL COMMENT '流程ID',
                            `instance_id` int NOT NULL DEFAULT 0 COMMENT '流程实例ID',
                            `contract_no` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '购销合同编号',
                            `invoice_end_time` timestamp NULL DEFAULT NULL COMMENT '付款到期日',
                            `invoice_status` tinyint UNSIGNED NULL DEFAULT 0 COMMENT '发票传递 0未传递，1已传递，2已接收',
                            `invoice_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '发票金额',
                            `yfzk_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '应收账款金额',
                            `invoice_no` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '发票号码',
                            `contract_id` int NULL DEFAULT NULL COMMENT '购销合同ID',
                            `vat` decimal(10, 2) NULL DEFAULT NULL COMMENT '增值税率',
                            `line_file_data` json NULL COMMENT '发票文件',
                            PRIMARY KEY (`id`) USING BTREE,
                            INDEX `examination_idx`(`examination_id` ASC) USING BTREE,
                            INDEX `instance_idx`(`instance_id` ASC) USING BTREE,
                            INDEX `flow_idx`(`flow_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '发票' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for materials
-- ----------------------------
DROP TABLE IF EXISTS `materials`;
CREATE TABLE `materials`  (
                              `id` int NOT NULL AUTO_INCREMENT,
                              `created_at` timestamp NULL DEFAULT NULL,
                              `updated_at` timestamp NULL DEFAULT NULL,
                              `data` json NULL,
                              `name` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
                              `corporation` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '法人/负责人',
                              `industry` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
                              `account` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '账号',
                              `telephone` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
                              `address` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
                              `balance` decimal(11, 2) UNSIGNED NOT NULL COMMENT '启动资金',
                              `current_assets_ratio` decimal(4, 2) UNSIGNED NOT NULL COMMENT '流动资产比率',
                              `fixed_assets_ratio` decimal(4, 2) UNSIGNED NOT NULL COMMENT '固定资产比率',
                              `liabilities_ratio` decimal(4, 2) UNSIGNED NOT NULL COMMENT '资产负债率',
                              `type` tinyint UNSIGNED NOT NULL DEFAULT 0 COMMENT '1:卖方企业；2：买方企业；3：物流仓储业；4：银行；',
                              `credit_level` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '信用评级',
                              `user_id` int UNSIGNED NOT NULL DEFAULT 0,
                              PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 111 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for migrations
-- ----------------------------
DROP TABLE IF EXISTS `migrations`;
CREATE TABLE `migrations`  (
                               `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
                               `migration` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
                               `batch` int NOT NULL,
                               PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for notices
-- ----------------------------
DROP TABLE IF EXISTS `notices`;
CREATE TABLE `notices`  (
                            `id` bigint NOT NULL AUTO_INCREMENT,
                            `created_at` timestamp NULL DEFAULT NULL COMMENT '创建时间',
                            `updated_at` timestamp NULL DEFAULT NULL COMMENT '更新时间',
                            `data` json NULL,
                            `content` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '公告内容',
                            `teacher_id` bigint NULL DEFAULT NULL COMMENT '教师id',
                            PRIMARY KEY (`id`) USING BTREE,
                            INDEX `fk_notices_users1_idx`(`teacher_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '公告表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for operate_scores
-- ----------------------------
DROP TABLE IF EXISTS `operate_scores`;
CREATE TABLE `operate_scores`  (
                                   `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
                                   `user_examination_id` int NOT NULL DEFAULT 0,
                                   `instance_id` int NOT NULL DEFAULT 0,
                                   `flow_id` int NOT NULL DEFAULT 0,
                                   `type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
                                   `times` int NOT NULL DEFAULT 0,
                                   `score` int NOT NULL DEFAULT 0,
                                   `data` json NULL,
                                   `created_at` timestamp NULL DEFAULT NULL,
                                   `updated_at` timestamp NULL DEFAULT NULL,
                                   PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 179 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for pickup_products
-- ----------------------------
DROP TABLE IF EXISTS `pickup_products`;
CREATE TABLE `pickup_products`  (
                                    `id` int NOT NULL AUTO_INCREMENT,
                                    `created_at` timestamp NULL DEFAULT NULL,
                                    `updated_at` timestamp NULL DEFAULT NULL,
                                    `examination_id` int NOT NULL,
                                    `flow_id` int NOT NULL,
                                    `instance_id` int NOT NULL DEFAULT 0,
                                    `pickup_apply_no` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '提货申请单号',
                                    `pickup_apply_file` json NULL COMMENT '提货申请单',
                                    `pickup_apply_status` tinyint NULL DEFAULT 0 COMMENT '1:已上传提货申请单；2： 申请方已提交；',
                                    `pickup_no` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '提货单号',
                                    `pickup_status` tinyint NULL DEFAULT 0 COMMENT '1: 待确认；2： 银行出具提货通知书；3: 银行确认签发, 待物流银行确认；5: 物流出具提货通知书回执；9: 提货完成；',
                                    `apply_user_id` int NULL DEFAULT NULL COMMENT '提货申请人',
                                    `apply_user_name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '提货申请人姓名',
                                    `pickup_time` timestamp NULL DEFAULT NULL COMMENT '提货日期',
                                    `pickup_apply_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '提货货物总价值',
                                    `financing_id` int NULL DEFAULT NULL COMMENT '融资ID',
                                    `protocol_id` int NULL DEFAULT NULL COMMENT '存货质押协议ID',
                                    `pickup_bank_file` json NULL COMMENT '提货通知书',
                                    `pickup_express_file` json NULL COMMENT '提货通知书回执',
                                    `shouxin_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '授信敞口',
                                    `had_pickup_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '已提货物金额',
                                    `bail_repayment_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '已缴纳保证金及还款总额',
                                    PRIMARY KEY (`id`) USING BTREE,
                                    INDEX `instance_idx`(`instance_id` ASC) USING BTREE,
                                    INDEX `examination_idx`(`examination_id` ASC) USING BTREE,
                                    INDEX `flow_idx`(`flow_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '提货申请' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for products
-- ----------------------------
DROP TABLE IF EXISTS `products`;
CREATE TABLE `products`  (
                             `id` int NOT NULL AUTO_INCREMENT,
                             `created_at` timestamp NULL DEFAULT NULL,
                             `updated_at` timestamp NULL DEFAULT NULL,
                             `data` json NULL,
                             `product_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
                             `title` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
                             `unit` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
                             `sku` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
                             `cost_price` decimal(11, 2) UNSIGNED NOT NULL COMMENT '成本价格',
                             `sell_price` decimal(11, 2) UNSIGNED NOT NULL COMMENT '售价',
                             `user_id` int UNSIGNED NOT NULL DEFAULT 0,
                             PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 43 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for protocols
-- ----------------------------
DROP TABLE IF EXISTS `protocols`;
CREATE TABLE `protocols`  (
                              `id` int(11) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT COMMENT 'ID',
                              `created_at` timestamp NULL DEFAULT NULL COMMENT '创建时间',
                              `updated_at` timestamp NULL DEFAULT NULL COMMENT '修改时间',
                              `examination_id` int NOT NULL COMMENT '考核ID',
                              `flow_id` int NOT NULL COMMENT '流程ID',
                              `instance_id` int NOT NULL DEFAULT 0 COMMENT '流程实例ID',
                              `protocol_no` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '协议编号',
                              `protocol_time` timestamp NULL DEFAULT NULL COMMENT '签约日期',
                              `protocol_status` tinyint UNSIGNED NULL DEFAULT 0 COMMENT '协议状态 0未确认，1、2、3、4四方分别确认',
                              `product_data` json NULL COMMENT '协议文件',
                              `buyer_id` int NULL DEFAULT NULL COMMENT '买方ID',
                              `buyer_name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '买方',
                              `seller_id` int NULL DEFAULT NULL COMMENT '卖方ID',
                              `seller_name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '卖方',
                              `bank_id` int NULL DEFAULT NULL COMMENT '银行ID',
                              `bank_name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '银行',
                              `express_id` int NULL DEFAULT NULL COMMENT '物流ID',
                              `express_name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '物流',
                              `type` tinyint(1) NULL DEFAULT 0 COMMENT '类型',
                              `protocol_data` json NULL COMMENT '此字段待删除',
                              `buyer_confirm` tinyint(1) NULL DEFAULT NULL COMMENT '买方是否确认',
                              `seller_confirm` tinyint(1) NULL DEFAULT NULL COMMENT '卖方是否确认',
                              `bank_confirm` tinyint(1) NULL DEFAULT NULL COMMENT '银行是否确认',
                              `express_confirm` tinyint(1) NULL DEFAULT NULL COMMENT '物流是否确认',
                              `contract_no` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '购销合同编号',
                              `protocol_start_time` timestamp NULL DEFAULT NULL COMMENT '协议开始时间',
                              `protocol_end_time` timestamp NULL DEFAULT NULL COMMENT '协议到期时间',
                              `protocol_fxbl_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '反向保理授信额度',
                              `contract_id` int NULL DEFAULT NULL COMMENT '购销合同ID',
                              PRIMARY KEY (`id`) USING BTREE,
                              INDEX `examination_idx`(`examination_id` ASC) USING BTREE,
                              INDEX `instance_idx`(`instance_id` ASC) USING BTREE,
                              INDEX `flow_idx`(`flow_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 17 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '卖方、买方、银行、物流签订协议' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for recommend_supplier
-- ----------------------------
DROP TABLE IF EXISTS `recommend_supplier`;
CREATE TABLE `recommend_supplier`  (
                                       `id` int NOT NULL AUTO_INCREMENT COMMENT 'ID',
                                       `created_at` timestamp NULL DEFAULT NULL COMMENT '创建时间',
                                       `updated_at` timestamp NULL DEFAULT NULL COMMENT '修改时间',
                                       `examination_id` int NOT NULL COMMENT '考核ID',
                                       `flow_id` int NOT NULL COMMENT '流程ID',
                                       `instance_id` int NOT NULL DEFAULT 0 COMMENT '流程实例ID',
                                       `contract_no` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '购销合同编号',
                                       `seller_id` int NULL DEFAULT NULL COMMENT '供应商ID',
                                       `seller_name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '供应商名称',
                                       `supply_level` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '供应商评级',
                                       `supply_status` tinyint(1) NULL DEFAULT NULL COMMENT '是否推荐 0否，1是',
                                       `supply_year` tinyint(1) NULL DEFAULT NULL COMMENT '合作年限',
                                       `yfzk_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '应收账款均值',
                                       `supply_rate` decimal(10, 2) NULL DEFAULT NULL COMMENT '供应商利率: 一级供应商利率为8%，二级供应商利率8.5%，三级供应商利率为9%',
                                       `contract_id` int NULL DEFAULT NULL COMMENT '购销合同ID',
                                       PRIMARY KEY (`id`) USING BTREE,
                                       INDEX `examination_idx`(`examination_id` ASC) USING BTREE,
                                       INDEX `instance_idx`(`instance_id` ASC) USING BTREE,
                                       INDEX `flow_idx`(`flow_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '推荐供应商' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for repayments
-- ----------------------------
DROP TABLE IF EXISTS `repayments`;
CREATE TABLE `repayments`  (
                               `id` int NOT NULL AUTO_INCREMENT COMMENT 'ID',
                               `created_at` timestamp NULL DEFAULT NULL COMMENT '创建时间',
                               `updated_at` timestamp NULL DEFAULT NULL COMMENT '修改时间',
                               `examination_id` int NOT NULL COMMENT '考核ID',
                               `flow_id` int NOT NULL COMMENT '流程ID',
                               `instance_id` int NOT NULL DEFAULT 0 COMMENT '流程实例ID',
                               `repayment_no` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '还款编号',
                               `repayment_status` tinyint NULL DEFAULT NULL COMMENT '0：催收；1：还款中；9: 已结清贷款；',
                               `financing_no` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '贷款编号',
                               `repayment_time` datetime NULL DEFAULT NULL COMMENT '还款时间',
                               `repayment_amount` decimal(10, 2) NOT NULL COMMENT '还款金额',
                               `repayment_count` int NULL DEFAULT NULL COMMENT '还款次数',
                               `financing_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '应付账款金额',
                               `repayment_type` tinyint NULL DEFAULT NULL COMMENT '还款类型：1买方还款 2卖方还款',
                               `repayment_user_id` int NULL DEFAULT NULL COMMENT '还款人ID',
                               `repayment_user` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '还款人',
                               `financing_id` int NULL DEFAULT NULL COMMENT '贷款ID',
                               PRIMARY KEY (`id`) USING BTREE,
                               INDEX `instance_idx`(`instance_id` ASC) USING BTREE,
                               INDEX `examination_idx`(`examination_id` ASC) USING BTREE,
                               INDEX `flow_idx`(`flow_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 16 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '还贷管理' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for roles
-- ----------------------------
DROP TABLE IF EXISTS `roles`;
CREATE TABLE `roles`  (
                          `id` int NOT NULL AUTO_INCREMENT,
                          `name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
                          `description` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
                          PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for schools
-- ----------------------------
DROP TABLE IF EXISTS `schools`;
CREATE TABLE `schools`  (
                            `id` int NOT NULL AUTO_INCREMENT,
                            `created_at` timestamp NULL DEFAULT NULL,
                            `updated_at` timestamp NULL DEFAULT NULL,
                            `data` json NULL,
                            `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
                            `status` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
                            `description` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
                            `code` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
                            `college` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
                            `major` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
                            `core_org_id` int NOT NULL,
                            PRIMARY KEY (`id`) USING BTREE,
                            UNIQUE INDEX `name_UNIQUE`(`name` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for send_products
-- ----------------------------
DROP TABLE IF EXISTS `send_products`;
CREATE TABLE `send_products`  (
                                  `id` int NOT NULL AUTO_INCREMENT,
                                  `created_at` timestamp NULL DEFAULT NULL,
                                  `updated_at` timestamp NULL DEFAULT NULL,
                                  `data` json NULL,
                                  `examination_id` int NOT NULL,
                                  `flow_id` int NOT NULL,
                                  `instance_id` int NOT NULL DEFAULT 0,
                                  `send_no` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '发货单号',
                                  `send_data` json NULL,
                                  `send_status` tinyint NULL DEFAULT NULL COMMENT '0:待发货；1：待接收；2: 已接收；',
                                  `product_data` json NULL,
                                  `accept_data` json NULL COMMENT '收货信息',
                                  `in_warehouse_no` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '入库编号',
                                  `in_warehouse_data` json NULL,
                                  `in_warehouse_status` tinyint NULL DEFAULT NULL COMMENT '0:已入库;1: 待核定；2：已核定；',
                                  `entity_id` int NULL DEFAULT NULL,
                                  `entity_type` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
                                  `seller_id` int NULL DEFAULT NULL COMMENT '发货人ID',
                                  `seller_name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '发货人姓名',
                                  `buyer_id` int NULL DEFAULT NULL COMMENT '买方ID',
                                  `buyer_name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '买方名称',
                                  `send_time` timestamp NULL DEFAULT NULL COMMENT '发货时间',
                                  `send_address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '发货地点',
                                  `accept_time` timestamp NULL DEFAULT NULL COMMENT '收货时间',
                                  `accept_address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '收货地点',
                                  `contract_no` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '合同编号',
                                  `contract_id` int NULL DEFAULT NULL COMMENT '合同ID',
                                  `examination_inst_id` int NULL DEFAULT NULL COMMENT 'user_examination id',
                                  `express_id` int NULL DEFAULT NULL COMMENT '物流ID',
                                  `express_name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '物流名称',
                                  `protocol_id` int NULL DEFAULT NULL COMMENT '协议ID',
                                  `protocol_no` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '协议编号',
                                  `total_cost_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '货物成本总价',
                                  `total_sell_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '货物总售价',
                                  `send_invoice_file` json NULL COMMENT '银行承兑汇票收悉确认函',
                                  PRIMARY KEY (`id`) USING BTREE,
                                  INDEX `instance_idx`(`instance_id` ASC) USING BTREE,
                                  INDEX `examination_idx`(`examination_id` ASC) USING BTREE,
                                  INDEX `flow_idx`(`flow_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 22 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '发货管理' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for student
-- ----------------------------
DROP TABLE IF EXISTS `student`;
CREATE TABLE `student`  (
                            `student_id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '学生ID',
                            `student_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '学号',
                            `student_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '姓名',
                            `student_phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '电话号码',
                            `student_account` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '学生账号',
                            `student_password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '密码',
                            `student_sex` int NULL DEFAULT NULL COMMENT '性别(1男 2女)',
                            `student_id_cart_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '证件类型',
                            `student_id_card` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '证件号',
                            `max_education` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '最高学历',
                            `student_political_outlook` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '政治面貌',
                            `student_address` varchar(3000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '联系地址',
                            `student_source` varchar(3000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '来源',
                            `student_nation` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '民族',
                            `student_birthday` date NULL DEFAULT NULL COMMENT '出生年月',
                            `student_test_no` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '考生号',
                            `postal_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '邮政编码',
                            `student_email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '邮箱',
                            `student_job_address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '工作单位',
                            `target_university_id` bigint NULL DEFAULT NULL COMMENT '报考学校ID',
                            `student_remark` varchar(3000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
                            `student_status` int NULL DEFAULT NULL COMMENT '状态（1正常 2删除）',
                            `student_add_time` datetime NULL DEFAULT NULL COMMENT '添加时间',
                            `org_id` bigint NULL DEFAULT NULL COMMENT '组织机构ID',
                            `user_id` bigint NULL DEFAULT NULL COMMENT '后台用户ID',
                            PRIMARY KEY (`student_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '学生' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for sys_log
-- ----------------------------
DROP TABLE IF EXISTS `sys_log`;
CREATE TABLE `sys_log`  (
                            `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
                            `method` varchar(500) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '请求方法',
                            `request_url` varchar(200) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '请求URI',
                            `params` varchar(5000) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '请求参数',
                            `result` varchar(10000) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '结果',
                            `ip` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT 'ip地址',
                            `create_time` datetime(6) NULL DEFAULT NULL COMMENT '操作时间',
                            `result_time` datetime(6) NULL DEFAULT NULL COMMENT '响应时间',
                            `token` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL,
                            `session` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT 'session',
                            `user_id` bigint NULL DEFAULT NULL COMMENT '管理员或教师ID',
                            `open_id` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '微信ID',
                            PRIMARY KEY (`id`) USING BTREE,
                            INDEX `token`(`token` ASC) USING BTREE,
                            INDEX `create_time`(`create_time` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 15892 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci COMMENT = '行为日志' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for sys_log_text
-- ----------------------------
DROP TABLE IF EXISTS `sys_log_text`;
CREATE TABLE `sys_log_text`  (
                                 `id` bigint NOT NULL AUTO_INCREMENT,
                                 `sys_id` bigint NULL DEFAULT NULL,
                                 `params` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '请求参数',
                                 `result` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '结果',
                                 PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 597 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for teams
-- ----------------------------
DROP TABLE IF EXISTS `teams`;
CREATE TABLE `teams`  (
                          `id` int NOT NULL AUTO_INCREMENT,
                          `created_at` timestamp NULL DEFAULT NULL,
                          `updated_at` timestamp NULL DEFAULT NULL,
                          `deleted_at` timestamp NULL DEFAULT NULL,
                          `data` json NULL,
                          `name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
                          `creator_id` int NOT NULL COMMENT '创建团队的用户id',
                          `leader_id` int NOT NULL COMMENT '队长id',
                          `end_time` timestamp NULL DEFAULT NULL COMMENT '实训结束时间',
                          `class_id` int NOT NULL,
                          `flow_id` int NOT NULL,
                          `status` tinyint NOT NULL DEFAULT 0,
                          `examination_id` int UNSIGNED NOT NULL DEFAULT 0,
                          PRIMARY KEY (`id`) USING BTREE,
                          INDEX `fk_teams_users1_idx`(`creator_id` ASC) USING BTREE,
                          INDEX `fk_teams_users2_idx`(`leader_id` ASC) USING BTREE,
                          INDEX `fk_teams_classes1_idx`(`class_id` ASC) USING BTREE,
                          INDEX `fk_teams_flows1_idx`(`flow_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 59 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for user_examinations
-- ----------------------------
DROP TABLE IF EXISTS `user_examinations`;
CREATE TABLE `user_examinations`  (
                                      `id` int NOT NULL AUTO_INCREMENT,
                                      `flow_id` int NOT NULL,
                                      `examination_id` int NOT NULL,
                                      `user_id` int NOT NULL,
                                      `team_id` int NOT NULL,
                                      `financial_id` int NULL DEFAULT NULL,
                                      `instance_id` int NOT NULL,
                                      `status` tinyint UNSIGNED NOT NULL DEFAULT 0 COMMENT '1：已提交实训；2：已评分；',
                                      `finish_time` timestamp NULL DEFAULT NULL,
                                      `report_file` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
                                      `report_name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
                                      `flow_scores` decimal(11, 2) NULL DEFAULT NULL,
                                      `report_scores` decimal(11, 2) NULL DEFAULT NULL,
                                      `raise_scores` decimal(11, 2) NULL DEFAULT NULL,
                                      `duration_scores` decimal(11, 2) NULL DEFAULT NULL,
                                      `total_scores` decimal(11, 2) NULL DEFAULT NULL,
                                      `class_id` int NOT NULL,
                                      `class_orders` int UNSIGNED NOT NULL DEFAULT 0 COMMENT '个人排名',
                                      `team_orders` int UNSIGNED NOT NULL DEFAULT 0 COMMENT '团队排名',
                                      `data` json NULL,
                                      `created_at` timestamp NULL DEFAULT NULL,
                                      `updated_at` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
                                      `operator_scores` tinyint NULL DEFAULT NULL,
                                      PRIMARY KEY (`id`) USING BTREE,
                                      INDEX `user_idx`(`user_id` ASC) USING BTREE,
                                      INDEX `examination_idx`(`examination_id` ASC) USING BTREE,
                                      INDEX `class_idx`(`class_id` ASC) USING BTREE,
                                      INDEX `financial_idx`(`financial_id` ASC) USING BTREE,
                                      INDEX `team_idx`(`team_id` ASC) USING BTREE,
                                      INDEX `instance_idx`(`instance_id` ASC) USING BTREE,
                                      INDEX `flow_idx`(`flow_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1645 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户考试表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for user_teams
-- ----------------------------
DROP TABLE IF EXISTS `user_teams`;
CREATE TABLE `user_teams`  (
                               `id` int NOT NULL AUTO_INCREMENT,
                               `user_id` int NOT NULL,
                               `team_id` int NOT NULL,
                               `roles` json NULL,
                               PRIMARY KEY (`id`) USING BTREE,
                               INDEX `fk_user_team_users1_idx`(`user_id` ASC) USING BTREE,
                               INDEX `fk_user_team_teams1_idx`(`team_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 163 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for users
-- ----------------------------
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users`  (
                          `id` bigint NOT NULL AUTO_INCREMENT,
                          `created_at` timestamp NULL DEFAULT NULL,
                          `deleted_at` timestamp NULL DEFAULT NULL,
                          `updated_at` timestamp NULL DEFAULT NULL,
                          `data` json NULL,
                          `ex_user_id` bigint NOT NULL,
                          `class_id` bigint NOT NULL,
                          `type` tinyint NOT NULL DEFAULT 0 COMMENT '用户类型，4是学生 ; 3是教师',
                          `sex` tinyint NULL DEFAULT NULL,
                          `username` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
                          `password` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
                          `student_no` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
                          `nickname` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
                          `init_balance` decimal(65, 2) NULL DEFAULT NULL COMMENT '初始资金',
                          `balance` decimal(65, 2) NULL DEFAULT NULL COMMENT '可用资金',
                          `product_assets` decimal(65, 2) NULL DEFAULT NULL COMMENT '存货价值',
                          `total_assets` decimal(65, 2) NULL DEFAULT NULL COMMENT '总资产',
                          `core_user_id` int NOT NULL COMMENT '关联core_user表的id',
                          `core_org_id` int NOT NULL,
                          `flow_integral` json NULL COMMENT '完成业务流程积分',
                          `school_id` bigint NULL DEFAULT NULL,
                          `college_id` bigint NULL DEFAULT NULL,
                          `student_id` bigint NULL DEFAULT NULL,
                          `teacher_id` bigint NULL DEFAULT NULL,
                          PRIMARY KEY (`id`) USING BTREE,
                          INDEX `fk_users_classes_idx`(`class_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 38953 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for warehouse_receipt
-- ----------------------------
DROP TABLE IF EXISTS `warehouse_receipt`;
CREATE TABLE `warehouse_receipt`  (
                                      `id` int NOT NULL AUTO_INCREMENT,
                                      `created_at` timestamp NULL DEFAULT NULL,
                                      `updated_at` timestamp NULL DEFAULT NULL,
                                      `examination_id` int NOT NULL,
                                      `flow_id` int NOT NULL,
                                      `instance_id` int NOT NULL DEFAULT 0,
                                      `send_no` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '发货单号',
                                      `in_warehouse_status` tinyint NULL DEFAULT NULL COMMENT '0:已入库;1: 出具清单；2：已核定；',
                                      `in_warehouse_no` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '入库编号',
                                      `in_warehouse_start_time` timestamp NULL DEFAULT NULL COMMENT '存货开始时间',
                                      `in_warehouse_end_time` timestamp NULL DEFAULT NULL COMMENT '存货结束时间',
                                      `seller_id` int NULL DEFAULT NULL COMMENT '存货人ID',
                                      `seller_name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '存货人姓名',
                                      `yfzk_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '货物总价值',
                                      `in_warehouse_time` timestamp NULL DEFAULT NULL COMMENT '入库时间',
                                      `protocol_id` int NULL DEFAULT NULL COMMENT '协议ID',
                                      `in_warehouse_file_data` json NULL COMMENT '质物清单',
                                      PRIMARY KEY (`id`) USING BTREE,
                                      INDEX `instance_idx`(`instance_id` ASC) USING BTREE,
                                      INDEX `examination_idx`(`examination_id` ASC) USING BTREE,
                                      INDEX `flow_idx`(`flow_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '入库管理' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for warehouse_shipment
-- ----------------------------
DROP TABLE IF EXISTS `warehouse_shipment`;
CREATE TABLE `warehouse_shipment`  (
                                       `id` int NOT NULL AUTO_INCREMENT,
                                       `created_at` timestamp NULL DEFAULT NULL,
                                       `updated_at` timestamp NULL DEFAULT NULL,
                                       `examination_id` int NOT NULL,
                                       `flow_id` int NOT NULL,
                                       `instance_id` int NOT NULL DEFAULT 0,
                                       `express_no` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '送货单号',
                                       `in_warehouse_status` tinyint NULL DEFAULT NULL COMMENT '0:已入库;1: 待核定；2：已核定；',
                                       `pickup_no` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '提货单号',
                                       `out_warehouse_no` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '出库单号',
                                       `out_warehouse_user` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '出库确认人',
                                       `out_warehouse_time` timestamp NULL DEFAULT NULL COMMENT '出库日期',
                                       `out_warehouse_status` tinyint(1) NULL DEFAULT NULL COMMENT '出库状态 2已配送',
                                       `receipt_no` int NULL DEFAULT NULL COMMENT '入库单号',
                                       `receipt_status` tinyint(1) NULL DEFAULT NULL COMMENT '入库状态 1待收货，2待入库，3已入库',
                                       `receipt_time` timestamp NULL DEFAULT NULL COMMENT '入库数据',
                                       `receipt_user` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '入库确认人',
                                       `receipt_user_id` int NULL DEFAULT NULL COMMENT '入库确认人ID',
                                       `out_warehouse_user_id` int NULL DEFAULT NULL COMMENT '出库确认人ID',
                                       `protocol_id` int NULL DEFAULT NULL COMMENT '协议ID',
                                       `pickup_product_id` int NULL DEFAULT NULL COMMENT '提货ID',
                                       PRIMARY KEY (`id`) USING BTREE,
                                       INDEX `instance_idx`(`instance_id` ASC) USING BTREE,
                                       INDEX `examination_idx`(`examination_id` ASC) USING BTREE,
                                       INDEX `flow_idx`(`flow_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '出库及配送' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for yszk_transfer
-- ----------------------------
DROP TABLE IF EXISTS `yszk_transfer`;
CREATE TABLE `yszk_transfer`  (
                                  `id` int NOT NULL AUTO_INCREMENT COMMENT 'ID',
                                  `created_at` timestamp NULL DEFAULT NULL COMMENT '创建时间',
                                  `updated_at` timestamp NULL DEFAULT NULL COMMENT '修改时间',
                                  `examination_id` int NOT NULL COMMENT '考核ID',
                                  `flow_id` int NOT NULL COMMENT '流程ID',
                                  `instance_id` int NOT NULL DEFAULT 0 COMMENT '流程实例ID',
                                  `bl_contract_no` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '保理合同编号',
                                  `buyer_confirm` tinyint(1) NULL DEFAULT NULL COMMENT '买方是否确认',
                                  `seller_confirm` tinyint(1) NULL DEFAULT NULL COMMENT '卖方是否确认',
                                  `bank_confirm` tinyint(1) NULL DEFAULT NULL COMMENT '银行是否确认',
                                  `yszk_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '应收账款净额',
                                  `yszk_no` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '应收账款编号',
                                  `seller_transfer_file` json NULL COMMENT '应收账款转让申请书',
                                  `seller_invoice_file` json NULL COMMENT '增值税发票',
                                  `seller_transfer_notice_file` json NULL COMMENT '应收账款债权转让通知书',
                                  `transfer_status` tinyint(1) NULL DEFAULT NULL COMMENT '转移状态 0新增数据 1卖方确认 2银行确认 3买方确认',
                                  `buyer_transfer_file` json NULL COMMENT '应收账款转让通知书回执',
                                  PRIMARY KEY (`id`) USING BTREE,
                                  INDEX `examination_idx`(`examination_id` ASC) USING BTREE,
                                  INDEX `instance_idx`(`instance_id` ASC) USING BTREE,
                                  INDEX `flow_idx`(`flow_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '应收账款转让' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- View structure for user_integral
-- ----------------------------
DROP VIEW IF EXISTS `user_integral`;
CREATE ALGORITHM = UNDEFINED SQL SECURITY DEFINER VIEW `user_integral` AS select `t10`.`user_id` AS `user_id`,`t10`.`class_id` AS `class_id`,`t10`.`total_integral` AS `integral`,row_number() OVER (ORDER BY `t10`.`total_integral` desc )  AS `integral_order` from (select `t9`.`user_id` AS `user_id`,sum((`t9`.`integral` + `t9`.`ext_integral`)) AS `total_integral`,max(`t9`.`class_id`) AS `class_id` from (select `t2`.`user_id` AS `user_id`,`t3`.`mode` AS `MODE`,max(`t2`.`class_id`) AS `class_id`,sum((50 - (30 * (1 - `t3`.`mode`)))) AS `integral`,sum(distinct `t1`.`flow_id`) AS `flow_id_sum`,(case when (sum(distinct `t1`.`flow_id`) > 14) then (100 * (`t3`.`mode` + 1)) else 0 end) AS `ext_integral` from ((`financings` `t1` join `user_examinations` `t2` on((`t1`.`instance_id` = `t2`.`instance_id`))) join `examinations` `t3` on((`t2`.`examination_id` = `t3`.`id`))) where ((`t1`.`financing_status` = 9) and (`t3`.`mode` is not null) and (`t3`.`type` = 0)) group by `t2`.`user_id`,`t3`.`mode`) `t9` group by `t9`.`user_id`) `t10`;

SET FOREIGN_KEY_CHECKS = 1;
