-- 项目资金计划表结构
CREATE TABLE `PROJECT_FUND_PLAN` (
  `ID` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `PROJECT_ID` int DEFAULT NULL COMMENT '项目ID',
  `PAY_DATE` date DEFAULT NULL COMMENT '付款日期',
  `PAY_WAY` int DEFAULT NULL COMMENT '付款方式',
  `PAY_RATIO` float DEFAULT NULL COMMENT '付款比例',
  `PAY_CURRENCY` double DEFAULT NULL COMMENT '付款金额',
  `PAY_TERM` varchar(255) DEFAULT NULL COMMENT '付款条件',
  `CONTRACT_PAY_PLAN_ID` int DEFAULT NULL COMMENT '合同付款计划ID',
  `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新日期',
  PRIMARY KEY (`ID`),
  KEY `FK_PROJECT_FUND_PLAN_PROJECT` (`PROJECT_ID`),
  KEY `FK_PROJECT_FUND_PLAN_CONTRACT_PAY_PLAN` (`CONTRACT_PAY_PLAN_ID`),
  CONSTRAINT `FK_PROJECT_FUND_PLAN_PROJECT` FOREIGN KEY (`PROJECT_ID`) REFERENCES `PROJECT` (`ID`),
  CONSTRAINT `FK_PROJECT_FUND_PLAN_CONTRACT_PAY_PLAN` FOREIGN KEY (`CONTRACT_PAY_PLAN_ID`) REFERENCES `CONTRACT_PAY_PLAN` (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='项目资金计划';

/** Alert 增加 PAY_WAY **/
ALTER TABLE `PROJECT_FUND_PLAN`
ADD COLUMN `PAY_WAY` int DEFAULT NULL COMMENT '付款方式';

-- 项目投标表结构 (参考)
CREATE TABLE `PROJECT_BID` (
  `ID` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `PROJECT_ID` int DEFAULT NULL COMMENT '项目ID',
  `LEVEL` int NOT NULL COMMENT '客户资信等级',
  `AMOUNT` double DEFAULT NULL COMMENT '报价金额',
  `CUS_EVAL_FILE_ID` int DEFAULT NULL COMMENT '评价表单文件ID',
  `COST_ID` int DEFAULT NULL COMMENT '成本ID',
  `STANDARD_PAY_WAY` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否标准付款方式',
  `NO_STANDARD_PAY_WAY_TEXT` varchar(255) DEFAULT NULL COMMENT '非标准付款方式文本',
  `STANDARD_CONTRACT_TEXT` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否标准合同文本',
  `NO_STANDARD_CONTRACT_TEXT` varchar(255) DEFAULT NULL COMMENT '非标准合同文本',
  `AUTHORIZER_FILE` varchar(255) DEFAULT NULL COMMENT '审核文件',
  `BID_ACCEPTANCE_LETTER_FILE` varchar(255) DEFAULT NULL COMMENT '中标通知书文件',
  `APPLICANT_ID` int DEFAULT NULL COMMENT '申请人ID',
  `APPLY_DATE` datetime DEFAULT NULL COMMENT '申请日期',
  `AUTHORIZER_ID` int DEFAULT NULL COMMENT '审核人ID',
  `AUTHORIZER_DATE` datetime DEFAULT NULL COMMENT '审核时间',
  `DESCRIPTION` text COMMENT '说明',
  PRIMARY KEY (`ID`),
  KEY `FK_PROJECT_BID_PROJECT` (`PROJECT_ID`),
  KEY `FK_PROJECT_BID_CUS_EVAL_FILE` (`CUS_EVAL_FILE_ID`),
  KEY `FK_PROJECT_BID_COST` (`COST_ID`),
  KEY `FK_PROJECT_BID_APPLICANT` (`APPLICANT_ID`),
  KEY `FK_PROJECT_BID_AUTHORIZER` (`AUTHORIZER_ID`),
  CONSTRAINT `FK_PROJECT_BID_PROJECT` FOREIGN KEY (`PROJECT_ID`) REFERENCES `PROJECT` (`ID`),
  CONSTRAINT `FK_PROJECT_BID_CUS_EVAL_FILE` FOREIGN KEY (`CUS_EVAL_FILE_ID`) REFERENCES `COMPANY_CUSTOMER_EVALUATION_FORM_FILE` (`ID`),
  CONSTRAINT `FK_PROJECT_BID_COST` FOREIGN KEY (`COST_ID`) REFERENCES `PROJECT_COST` (`ID`),
  CONSTRAINT `FK_PROJECT_BID_APPLICANT` FOREIGN KEY (`APPLICANT_ID`) REFERENCES `EMPLOYEE` (`ID`),
  CONSTRAINT `FK_PROJECT_BID_AUTHORIZER` FOREIGN KEY (`AUTHORIZER_ID`) REFERENCES `EMPLOYEE` (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='项目投标';