ALTER TABLE `zh_rpt_tree_node_cust`
ADD COLUMN `tender_id` INT NULL DEFAULT -1 COMMENT '新需求，跟标段走，不跟客户走' AFTER `cust_acc_id`,
ADD INDEX `tender` (`tender_id` ASC);
;

CREATE TABLE `zh_stage_yjcl`  (
  `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uuid` varchar(36) NOT NULL DEFAULT '' COMMENT 'uuid',
  `add_sid` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '新增期id',
  `add_sorder` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '新增期序号',
  `add_uid` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建人id',
  `tid` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '标段id',
  `sid` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '期id',
  `sorder` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '期序号',
  `name` varchar(255) NOT NULL DEFAULT '' COMMENT '名称',
  `m_order` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '排序',
  `spec` varchar(255) NOT NULL DEFAULT '' COMMENT '规格型号',
  `unit` varchar(20) NOT NULL DEFAULT '' COMMENT '单位',
  `tax` tinyint(4) UNSIGNED NOT NULL DEFAULT 0 COMMENT '税率',
  `arrive_time` varchar(50) NOT NULL DEFAULT '' COMMENT '到场时间',
  `source` varchar(255) NOT NULL DEFAULT '' COMMENT '材料来源',
  `bills_code` varchar(255) NOT NULL DEFAULT '' COMMENT '单据号',
  `location` varchar(50) NOT NULL DEFAULT '' COMMENT '存放位置',
  `prepare_pos` varchar(255) NOT NULL DEFAULT '' COMMENT '拟用于部位',
  `memo` varchar(1000) NOT NULL DEFAULT '' COMMENT '备注',
  `arrive_qty` decimal(24, 8) NOT NULL DEFAULT 0 COMMENT '到场数量',
  `arrive_tp` decimal(24, 8) NOT NULL DEFAULT 0 COMMENT '到场金额',
  `unit_price` decimal(24, 8) NOT NULL DEFAULT 0 COMMENT '单价',
  `ex_tax_up` decimal(24, 8) NOT NULL DEFAULT 0 COMMENT '除税单价',
  `qty` decimal(24, 8) NOT NULL DEFAULT 0 COMMENT '本期数量',
  `tp` decimal(24, 8) NOT NULL DEFAULT 0 COMMENT '本期金额',
  `pre_qty` decimal(24, 8) NOT NULL DEFAULT 0 COMMENT '截止上期数量',
  `pre_tp` decimal(24, 8) NOT NULL DEFAULT 0 COMMENT '截止上期金额',
  `pre_used` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '上期是否使用',
  `shistory` text NULL COMMENT '审批历史',
  PRIMARY KEY (`id`)
);

ALTER TABLE `zh_budget_std`
ADD COLUMN `ht_project_template_id` varchar(255) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL DEFAULT '' COMMENT '合同-项目合同模版-id列表（‘,’分隔）' AFTER `zb_bills_id`,
ADD COLUMN `ht_tender_template_id` varchar(255) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL DEFAULT '' COMMENT '合同-标段合同模版-id列表（‘,’分隔）' AFTER `ht_project_template_id`;

ALTER TABLE `zh_shenpi_audit`
ADD COLUMN `audit_ledger_id` varchar(5000) NOT NULL DEFAULT '' COMMENT '审批台账id' AFTER `audit_order`;

ALTER TABLE `zh_stage_audit`
ADD COLUMN `audit_ledger_id` varchar(5000) NOT NULL DEFAULT '' COMMENT '审批台账id' AFTER `audit_order`,
ADD COLUMN `audit_locked` tinyint(1) NOT NULL DEFAULT 0  COMMENT '审批锁定（仅协审用）' AFTER `audit_ledger_id`;

ALTER TABLE `zh_ledger_audit`
ADD COLUMN `audit_type` tinyint(4) NOT NULL DEFAULT 1  COMMENT '审批类型' AFTER `audit_order`,
ADD COLUMN `audit_ledger_id` varchar(5000) NOT NULL DEFAULT '' COMMENT '审批台账id' AFTER `audit_id`;

ALTER TABLE `zh_revise_audit`
ADD COLUMN `audit_type` tinyint(4) NOT NULL DEFAULT 1 COMMENT '审批类型' AFTER `audit_order`,
ADD COLUMN `audit_ledger_id` varchar(5000) NOT NULL DEFAULT '' COMMENT '审批台账id' AFTER `audit_type`;

ALTER TABLE `zh_tender_cache`
MODIFY COLUMN `ledger_flow_cur_uid` varchar(1000) NOT NULL DEFAULT '0' COMMENT '台账-当前流程人id' AFTER `ledger_status`,
MODIFY COLUMN `ledger_flow_pre_uid` varchar(1000) NOT NULL DEFAULT '0' COMMENT '台账-上一流程人id' AFTER `ledger_flow_cur_info`;

CREATE TABLE `zh_contract_tree` (
  `id` varchar(100) CHARACTER SET utf8 NOT NULL COMMENT '自增id',
  `spid` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '项目id',
  `tid` int(11) DEFAULT NULL COMMENT '标段id',
  `contract_type` tinyint(1) NOT NULL COMMENT '合同类型(1是支出，2是收入)',
  `contract_id` int(11) NOT NULL COMMENT '节点id',
  `contract_pid` int(11) NOT NULL COMMENT '父节点id',
  `level` tinyint(4) NOT NULL COMMENT '层级',
  `order` mediumint(4) NOT NULL DEFAULT '0' COMMENT '同级排序',
  `full_path` varchar(255) CHARACTER SET utf8 DEFAULT '' COMMENT '层级定位辅助字段parent.full_path.contract_id',
  `is_leaf` tinyint(1) NOT NULL COMMENT '是否叶子节点，界面显示辅助字段',
  `code` varchar(50) CHARACTER SET utf8 DEFAULT '' COMMENT '节点编号',
  `name` varchar(255) CHARACTER SET utf8 DEFAULT '' COMMENT '名称',
  `unit` varchar(255) CHARACTER SET utf8 DEFAULT '' COMMENT '单位',
  `remark` varchar(1000) CHARACTER SET utf8 DEFAULT '' COMMENT '备注',
  PRIMARY KEY (`id`),
  KEY `sub_id` (`spid`),
  KEY `tid` (`tid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT = '合同管理树结构表';

CREATE TABLE `zh_contract` (
  `id` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
  `spid` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '项目id',
  `tid` int(11) DEFAULT NULL COMMENT '标段id',
  `contract_type` tinyint(1) DEFAULT NULL COMMENT '合同类型(1是支出，2是收入)',
  `uid` int(11) DEFAULT NULL COMMENT '创建人id',
  `contract_id` int(11) NOT NULL COMMENT '节点id',
  `contract_pid` int(11) NOT NULL COMMENT '父节点id',
  `level` tinyint(4) NOT NULL COMMENT '层级',
  `is_leaf` tinyint(1) DEFAULT '1' COMMENT '是否是子节点',
  `order` mediumint(4) NOT NULL DEFAULT '0' COMMENT '同级排序',
  `full_path` varchar(255) CHARACTER SET utf8 DEFAULT '' COMMENT '层级定位辅助字段parent.full_path.contract_id',
  `c_code` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '合同编号',
  `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '合同名称',
  `total_price` decimal(30,8) DEFAULT '0.00000000' COMMENT '合同金额',
  `pay_price` decimal(30,8) DEFAULT '0.00000000' COMMENT '累计支付（回款）金额',
  `debit_price` decimal(30,8) DEFAULT '0.00000000' COMMENT '累计扣款金额',
  `yf_price` decimal(30,8) DEFAULT '0.00000000' COMMENT '累计应付（应回）金额',
  `sf_price` decimal(30,8) DEFAULT '0.00000000' COMMENT '累计已付（已回）金额',
  `party_a` varchar(255) COLLATE utf8_unicode_ci DEFAULT '' COMMENT '甲方',
  `party_a_user` varchar(255) COLLATE utf8_unicode_ci DEFAULT '' COMMENT '甲方签约人',
  `party_b` varchar(255) COLLATE utf8_unicode_ci DEFAULT '' COMMENT '乙方',
  `party_b_user` varchar(255) COLLATE utf8_unicode_ci DEFAULT '' COMMENT '乙方签约人',
  `sign_date` datetime DEFAULT NULL COMMENT '签订日期',
  `address` varchar(255) COLLATE utf8_unicode_ci DEFAULT '' COMMENT '签约地点',
  `entity` varchar(255) COLLATE utf8_unicode_ci DEFAULT '' COMMENT '单位',
  `bank` varchar(255) COLLATE utf8_unicode_ci DEFAULT '' COMMENT '开户行',
  `bank_account` varchar(255) COLLATE utf8_unicode_ci DEFAULT '' COMMENT '收款账号',
  `settle_code` varchar(255) COLLATE utf8_unicode_ci DEFAULT '' COMMENT '结算书编号',
  `remark` varchar(1000) COLLATE utf8_unicode_ci DEFAULT '' COMMENT '备注',
  `exist_pay` tinyint(1) DEFAULT '0' COMMENT '是否存在合同支付（回款）',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='合同详情表';

CREATE TABLE `zh_contract_pay` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `spid` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '项目id',
  `tid` int(11) DEFAULT NULL COMMENT '标段id',
  `contract_type` tinyint(1) NOT NULL COMMENT '合同类型(1是支出，2是收入)',
  `cid` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '合同详情id',
  `uid` int(11) DEFAULT NULL COMMENT '创建人id',
  `pay_time` datetime DEFAULT NULL COMMENT '支付日期',
  `pay_price` decimal(30,8) DEFAULT '0.00000000' COMMENT '付款金额',
  `debit_price` decimal(30,8) DEFAULT '0.00000000' COMMENT '扣款金额',
  `yf_price` decimal(30,8) DEFAULT '0.00000000' COMMENT '应付（回）金额',
  `sf_price` decimal(30,8) DEFAULT '0.00000000' COMMENT '实付金额',
  `pay_type` varchar(50) COLLATE utf8_unicode_ci DEFAULT '' COMMENT '支付方式',
  `remark` varchar(1000) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '备注',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT = '合同支付表';

CREATE TABLE `zh_contract_pay_attachment` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `spid` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '项目id',
  `tid` int(11) DEFAULT NULL COMMENT '标段id',
  `contract_type` tinyint(1) NOT NULL COMMENT '合同类型(1是支出，2是收入)',
  `cid` varchar(100) COLLATE utf8_unicode_ci NOT NULL COMMENT '合同详情id',
  `cpid` int(11) NOT NULL COMMENT '合同支付id',
  `uid` int(11) NOT NULL COMMENT '上传者id',
  `filename` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '文件名称',
  `fileext` varchar(5) COLLATE utf8_unicode_ci NOT NULL COMMENT '文件后缀',
  `filesize` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '文件大小',
  `filepath` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '文件存储路径',
  `upload_time` datetime NOT NULL COMMENT '上传时间',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_cid` (`cpid`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_unicode_ci COMMENT = '合同支付附件表';

CREATE TABLE `zh_contract_attachment` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `spid` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '项目id',
  `tid` int(11) DEFAULT NULL COMMENT '标段id',
  `contract_type` tinyint(1) NOT NULL COMMENT '合同类型(1是支出，2是收入)',
  `cid` varchar(100) COLLATE utf8_unicode_ci NOT NULL COMMENT '合同详情id',
  `uid` int(11) NOT NULL COMMENT '上传者id',
  `filename` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '文件名称',
  `fileext` varchar(5) COLLATE utf8_unicode_ci NOT NULL COMMENT '文件后缀',
  `filesize` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '文件大小',
  `filepath` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '文件存储路径',
  `upload_time` datetime NOT NULL COMMENT '上传时间',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_cid` (`cid`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_unicode_ci COMMENT = '合同文件表';

CREATE TABLE `zh_contract_audit` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `spid` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '项目id',
  `tid` int(11) DEFAULT NULL COMMENT '标段id',
  `uid` int(11) NOT NULL COMMENT '用户id',
  `permission_add` tinyint(1) DEFAULT '0' COMMENT '添加合同权限',
  `permission_edit` tinyint(1) DEFAULT '0' COMMENT '编辑节点权限',
  `permission_show_unit` tinyint(1) DEFAULT '0' COMMENT '查看该节点下同单位下合同权限',
  `permission_show_node` tinyint(1) DEFAULT '0' COMMENT '查看该节点下所有合同权限',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  PRIMARY KEY (`id`)
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_unicode_ci COMMENT = '合同权限用户表';

CREATE TABLE `zh_contract_tree_audit` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `spid` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '项目id',
  `tid` int(11) DEFAULT NULL COMMENT '标段id',
  `contract_type` tinyint(1) DEFAULT NULL COMMENT '合同类型(1是支出，2是收入)',
  `contract_id` int(11) DEFAULT NULL COMMENT '节点id',
  `uid` int(11) DEFAULT NULL COMMENT '节点授权人id',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  PRIMARY KEY (`id`)
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_unicode_ci COMMENT = '合同节点授权用户表';

CREATE TABLE `zh_financial_audit` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `spid` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '项目id',
  `uid` int(11) NOT NULL COMMENT '用户id',
  `permission_transfer_show` tinyint(1) DEFAULT '1' COMMENT '查看划拨权限',
  `permission_transfer_add` tinyint(1) DEFAULT '0' COMMENT '添加划拨权限',
  `permission_transfer_file` tinyint(1) DEFAULT '0' COMMENT '划拨文件权限',
  `permission_pay_show` tinyint(1) DEFAULT '1' COMMENT '查看支付权限',
  `permission_pay_file` tinyint(1) DEFAULT '0' COMMENT '支付文件权限',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='资金监管权限用户表';

CREATE TABLE `zh_financial_pay` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `spid` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '项目id',
  `tid` int(11) NOT NULL COMMENT '标段id',
  `code` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '支付编号',
  `create_time` datetime DEFAULT NULL COMMENT '申请时间',
  `uid` int(11) DEFAULT NULL COMMENT '申请人',
  `used` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '资金用途',
  `total_price` decimal(30,8) DEFAULT '0.00000000' COMMENT '支付金额',
  `small_expenses_tp` decimal(30,8) DEFAULT '0.00000000' COMMENT '小额支出支付金额',
  `times` tinyint(3) DEFAULT '1' COMMENT '次数',
  `status` tinyint(2) DEFAULT NULL COMMENT '审批状态',
  `entity` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '申请支付单位',
  `bank` varchar(255) COLLATE utf8_unicode_ci DEFAULT '' COMMENT '单位开户行',
  `bank_account` varchar(255) COLLATE utf8_unicode_ci DEFAULT '' COMMENT '支付账号',
  `remark` text COLLATE utf8_unicode_ci COMMENT '备注',
  `final_auditor_str` varchar(255) COLLATE utf8_unicode_ci DEFAULT '',
  `entities` varchar(5000) COLLATE utf8_unicode_ci DEFAULT '' COMMENT '收款单位',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='资金支付表';

CREATE TABLE `zh_financial_pay_attachment` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `spid` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '项目id',
  `fpid` int(11) NOT NULL COMMENT '申请支付id',
  `fpcid` int(11) DEFAULT NULL COMMENT '支付明细id',
  `uid` int(11) NOT NULL COMMENT '上传者id',
  `filename` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '文件名称',
  `fileext` varchar(5) COLLATE utf8_unicode_ci NOT NULL COMMENT '文件后缀',
  `filesize` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '文件大小',
  `filepath` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '文件存储路径',
  `upload_time` datetime NOT NULL COMMENT '上传时间',
  `type` tinyint(1) DEFAULT '0' COMMENT '文件类型（0为普通，1为发票）',
  `bill` varchar(255) COLLATE utf8_unicode_ci DEFAULT '' COMMENT '发票号',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_trid` (`fpid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='资金支付文件表';

CREATE TABLE `zh_financial_pay_audit` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `spid` varchar(100) COLLATE utf8_unicode_ci NOT NULL COMMENT '项目id',
  `tid` int(11) NOT NULL COMMENT '标段id',
  `fpid` int(11) NOT NULL COMMENT '资金支付id',
  `aid` int(11) NOT NULL COMMENT '审批人id',
  `order` int(11) NOT NULL COMMENT '审批顺序',
  `times` int(11) NOT NULL DEFAULT '1' COMMENT '审批次数',
  `status` int(1) NOT NULL COMMENT '审批状态',
  `begin_time` datetime DEFAULT NULL COMMENT '开始审批时间',
  `end_time` datetime DEFAULT NULL COMMENT '结束审批时间',
  `opinion` varchar(1000) CHARACTER SET utf8 DEFAULT NULL COMMENT '审批意见',
  `audit_type` tinyint(4) unsigned NOT NULL DEFAULT '1' COMMENT '审批类型(1个人，2会签，3或签)',
  `audit_order` tinyint(4) unsigned NOT NULL COMMENT '审批顺序',
  PRIMARY KEY (`id`),
  KEY `idx_sid_order_times` (`fpid`,`order`,`times`),
  KEY `idx_sid_status_aid_order_times` (`fpid`,`status`,`aid`,`order`,`times`),
  KEY `idx_sid_times_status` (`fpid`,`times`,`status`),
  KEY `idx_tid_aid` (`tid`,`aid`),
  KEY `idx_sid_times_aid` (`fpid`,`times`,`aid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='资金支付审批表';

CREATE TABLE `zh_financial_pay_contract` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `spid` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '项目id',
  `tid` int(11) DEFAULT NULL COMMENT '标段id',
  `fpid` int(11) DEFAULT NULL COMMENT '申请支付id',
  `cid` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '合同id',
  `c_code` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '合同编号',
  `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '合同名称',
  `total_price` decimal(30,8) DEFAULT NULL COMMENT '合同金额',
  `entity` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '收款单位',
  `bank` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '开户行',
  `bank_account` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '开户行账号',
  `small_expenses` tinyint(1) DEFAULT '0' COMMENT '是否小额支出',
  `pay_price` decimal(30,8) DEFAULT NULL COMMENT '支付金额',
  `settle_price` decimal(30,8) DEFAULT NULL COMMENT '结算金额',
  `pay_type` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '支付方式',
  `bill` tinyint(1) DEFAULT '0' COMMENT '是否需要发票',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='资金支付明细表';

CREATE TABLE `zh_financial_pay_tender` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `spid` varchar(100) COLLATE utf8_unicode_ci NOT NULL COMMENT '项目id',
  `tid` int(11) NOT NULL COMMENT '标段id',
  `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT '' COMMENT '开户名称',
  `bank` varchar(255) COLLATE utf8_unicode_ci DEFAULT '' COMMENT '开户银行',
  `bank_account` varchar(255) COLLATE utf8_unicode_ci DEFAULT '' COMMENT '开户账号',
  `contact` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '联系人',
  `phone` varchar(20) COLLATE utf8_unicode_ci DEFAULT '' COMMENT '联系电话',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='资金支付标段数据表';

CREATE TABLE `zh_financial_pay_tender_audit` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `spid` varchar(100) COLLATE utf8_unicode_ci NOT NULL COMMENT '项目id',
  `tid` int(11) NOT NULL COMMENT '标段id',
  `uid` int(11) NOT NULL COMMENT '用户id',
  `is_report` tinyint(1) DEFAULT '0' COMMENT '是否为填报人',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='资金支付标段人员权限表';

CREATE TABLE `zh_financial_transfer` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `spid` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '项目id',
  `t_time` varchar(20) COLLATE utf8_unicode_ci NOT NULL COMMENT '划拨年月',
  `total_price` decimal(30,8) DEFAULT '0.00000000' COMMENT '划拨金额',
  `uid` int(11) NOT NULL COMMENT '填报人',
  `is_lock` tinyint(1) DEFAULT '0' COMMENT '是否已锁定',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `remark` varchar(1000) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='资金划拨表';

CREATE TABLE `zh_financial_transfer_attachment` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `spid` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '项目id',
  `trid` int(11) NOT NULL COMMENT '划拨年月id',
  `uid` int(11) NOT NULL COMMENT '上传者id',
  `filename` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '文件名称',
  `fileext` varchar(5) COLLATE utf8_unicode_ci NOT NULL COMMENT '文件后缀',
  `filesize` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '文件大小',
  `filepath` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '文件存储路径',
  `upload_time` datetime NOT NULL COMMENT '上传时间',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_trid` (`trid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='资金划拨文件表';

CREATE TABLE `zh_financial_transfer_tender` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `spid` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '项目id',
  `trid` int(11) NOT NULL COMMENT '资金划拨id',
  `tid` int(11) NOT NULL COMMENT '标段id',
  `sorder` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '期数，以逗号分隔',
  `uid` int(11) NOT NULL COMMENT '创建人id',
  `is_lock` tinyint(1) DEFAULT '0' COMMENT '是否锁定',
  `total_price` decimal(30,8) DEFAULT '0.00000000' COMMENT '合同金额',
  `contract_tp` decimal(30,8) DEFAULT '0.00000000' COMMENT '本期合同计量',
  `qc_tp` decimal(30,8) DEFAULT '0.00000000' COMMENT '本期数量变更计量',
  `pc_tp` decimal(30,8) DEFAULT '0.00000000' COMMENT '本期补差',
  `yf_tp` decimal(30,8) DEFAULT '0.00000000' COMMENT '本期应付',
  `sf_tp` decimal(30,8) DEFAULT '0.00000000' COMMENT '本期实付',
  `hb_tp` decimal(30,8) DEFAULT '0.00000000' COMMENT '本期划拨',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='资金划拨标段表';

CREATE TABLE `zh_financial_transfer_tender_attachment` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `spid` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '项目id',
  `trid` int(11) NOT NULL COMMENT '划拨年月id',
  `ftid` int(11) NOT NULL COMMENT '划拨标段id',
  `uid` int(11) NOT NULL COMMENT '上传者id',
  `filename` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '文件名称',
  `fileext` varchar(5) COLLATE utf8_unicode_ci NOT NULL COMMENT '文件后缀',
  `filesize` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '文件大小',
  `filepath` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '文件存储路径',
  `upload_time` datetime NOT NULL COMMENT '上传时间',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_trid` (`trid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='资金划拨文件表';


ALTER TABLE `zh_account_cert`
ADD COLUMN `cert_type` varchar(255) NULL DEFAULT '' COMMENT '证书分类字符' AFTER `type`,
ADD COLUMN `cert_name` varchar(255) NULL DEFAULT '' COMMENT '证书名称字符' AFTER `name`;

-- update请放在最后

Update zh_filing_template SET is_fixed = 1 WHERE tree_level = 1;
