
-- 财务费用分类表
DROP TABLE IF EXISTS `t_plu_finance_type`;
CREATE TABLE `t_plu_finance_type` (
  `id` bigint(20) NOT NULL,
  `name` varchar(64) DEFAULT '' COMMENT '分类名',
  `parent_id` bigint(20) DEFAULT 0 COMMENT '上级id',
  `level` tinyint(1) unsigned DEFAULT 0 COMMENT '分类登记 0类型 1类目 2名目',

  `operator` bigint(20) DEFAULT 0 COMMENT '操作人id',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '创建日期',
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT '修改日期',
  `rec_status` tinyint(1) unsigned DEFAULT 0 COMMENT '状态，0正常 1禁用 2删除',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='财务费用分类表';

-- 财务信息
DROP TABLE IF EXISTS `t_plu_finance`;
CREATE TABLE `t_plu_finance` (
  `id` bigint(20) NOT NULL,
  `type` tinyint(1) unsigned DEFAULT 0 COMMENT '财务类型 0项目财务条 1任务财务条',
  `budget` bigint(20) DEFAULT 0 COMMENT '预算',
  `bonus` bigint(20) DEFAULT 0 COMMENT '奖金',
  `task_id` bigint(20) DEFAULT 0 COMMENT '关联的任务或项目id',

  `operator` bigint(20) DEFAULT 0 COMMENT '操作人id',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '创建日期',
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT '修改日期',
  `rec_status` tinyint(1) unsigned DEFAULT 0 COMMENT '状态，0正常 1禁用 2删除',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='财务信息';


-- 财务预算追加信息
DROP TABLE IF EXISTS `t_plu_finance_append_budget`;
CREATE TABLE `t_plu_finance_append_budget` (
  `id` bigint(20) NOT NULL,
  `finance_id` bigint(20) DEFAULT 0 COMMENT '财务id',
  `add_budget` bigint(20) DEFAULT 0 COMMENT '追加的预算',
  `member_id` bigint(20) DEFAULT 0 COMMENT '操作人id',

  `operator` bigint(20) DEFAULT 0 COMMENT '操作人id',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '创建日期',
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT '修改日期',
  `rec_status` tinyint(1) unsigned DEFAULT 0 COMMENT '状态，0正常 1禁用 2删除',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `budget_finance_index`(`finance_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='财务预算追加信息';

-- 财务费用申请表
DROP TABLE IF EXISTS `t_plu_finance_apply`;
CREATE TABLE `t_plu_finance_apply` (
  `id` bigint(20) NOT NULL,
  `finance_id` bigint(20) DEFAULT 0 COMMENT '财务id',
  `member_id` bigint(20) DEFAULT 0 COMMENT '申请人id',
  `type_id` bigint(20) DEFAULT 0 COMMENT '类型id',
  `category_id` bigint(20) DEFAULT 0 COMMENT '类目id',
  `row_id` bigint(20) DEFAULT 0 COMMENT '名目id',
  `remark` varchar(128) DEFAULT '' COMMENT '备注',
  `project_id` bigint(20) DEFAULT 0 COMMENT '项目id',
  `task_id` bigint(20) DEFAULT 0 COMMENT '任务id',
  `submit_name` varchar(64) DEFAULT '' COMMENT '提交人姓名',
  `department` varchar(64) DEFAULT '' COMMENT '所属部门 暂时存储汉字，不关联',
  `money` bigint(20) DEFAULT 0 COMMENT '申请总金额',
  `apply_time` bigint(20) DEFAULT 0 COMMENT '申请时间',
  `apply_type` tinyint(1) unsigned DEFAULT 0 COMMENT '当前放款状态 0待审批 1已驳回 2已放款 3已领取',
  `invoice` tinyint(1) unsigned DEFAULT 0 COMMENT '是否上传了发票 0未上传 1已上传',

  `operator` bigint(20) DEFAULT 0 COMMENT '操作人id',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '创建日期',
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT '修改日期',
  `rec_status` tinyint(1) unsigned DEFAULT 0 COMMENT '状态，0正常 1禁用 2删除',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `apply_finance_index`(`finance_id`) USING BTREE,
  INDEX `apply_type_index`(`type_id`) USING BTREE,
  INDEX `apply_category_index`(`category_id`) USING BTREE,
  INDEX `apply_row_index`(`row_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='财务费用申请表';


-- 费用申请发票表
DROP TABLE IF EXISTS `t_plu_finance_invoice`;
CREATE TABLE `t_plu_finance_invoice` (
  `id` bigint(20) NOT NULL,
  `finance_apply_id` bigint(20) DEFAULT 0 COMMENT '财务支出申请表id',
  `url` varchar(256) DEFAULT '' COMMENT '发票浏览地址',
  `invoice_code` varchar(64) DEFAULT '' COMMENT '发票代码',
  `invoice_number` varchar(64) DEFAULT '' COMMENT '发票号码',
  `money` bigint(20) DEFAULT 0 COMMENT '金额',
  `tax_money` bigint(20) DEFAULT 0 COMMENT '税额',
  `invoice_time` bigint(20) DEFAULT 0 COMMENT '开票时间',
  `remark` varchar(128) DEFAULT '' COMMENT '备注',

  `operator` bigint(20) DEFAULT 0 COMMENT '操作人id',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '创建日期',
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT '修改日期',
  `rec_status` tinyint(1) unsigned DEFAULT 0 COMMENT '状态，0正常 1禁用 2删除',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `invoice_finance_apply_index`(`finance_apply_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='费用申请发票表';


-- 费用申请审核表
DROP TABLE IF EXISTS `t_plu_finance_check`;
CREATE TABLE `t_plu_finance_check` (
  `id` bigint(20) NOT NULL,
  `finance_apply_id` bigint(20) DEFAULT 0 COMMENT '财务费用申请表id',
  `checker_id` bigint(20) DEFAULT 0 COMMENT '审核人id',

  `operator` bigint(20) DEFAULT 0 COMMENT '操作人id',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '创建日期',
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT '修改日期',
  `rec_status` tinyint(1) unsigned DEFAULT 0 COMMENT '状态，0正常 1禁用 2删除',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `check_finance_apply_index`(`finance_apply_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='费用申请审核表';


-- 审核记录表
DROP TABLE IF EXISTS `t_plu_finance_check_log`;
CREATE TABLE `t_plu_finance_check_log` (
  `id` bigint(20) NOT NULL,
  `check_id` bigint(20) DEFAULT 0 COMMENT '审核表id',
  `check_status` tinyint(1) unsigned DEFAULT 0 COMMENT '审核状态 0未审核 1已通过 2驳回',
  `check_time` bigint(20) DEFAULT 0 COMMENT '审核时间',
  `remark` varchar(64) DEFAULT '' COMMENT '备注信息',

  `operator` bigint(20) DEFAULT 0 COMMENT '操作人id',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '创建日期',
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT '修改日期',
  `rec_status` tinyint(1) unsigned DEFAULT 0 COMMENT '状态，0正常 1禁用 2删除',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='审核记录表';




ALTER TABLE t_pro_task_plugin ADD COLUMN `code` VARCHAR(20) DEFAULT '' COMMENT '插件code' AFTER rowspan;
