-- 结算管理 / 运输对账 CREATE TABLE IF NOT EXISTS `blade_transport_reconciliation` ( `id` bigint(20) NOT NULL, `tenant_id` varchar(12) NOT NULL DEFAULT '000000', `create_user` bigint(20) DEFAULT NULL, `create_dept` bigint(20) DEFAULT NULL, `create_time` datetime DEFAULT NULL, `update_user` bigint(20) DEFAULT NULL, `update_time` datetime DEFAULT NULL, `status` int(11) DEFAULT 1, `is_deleted` int(11) DEFAULT 0, `reconciliation_no` varchar(100) NOT NULL, `formal_settlement_id` bigint(20) NOT NULL, `formal_settlement_no` varchar(100) NOT NULL, `pre_settlement_nos` varchar(1000) DEFAULT NULL, `settlement_type` varchar(30) NOT NULL, `reconciliation_mode` varchar(30) NOT NULL, `project_id` bigint(20) DEFAULT NULL, `project_name` varchar(100) DEFAULT NULL, `dept_id` bigint(20) DEFAULT NULL, `dept_name` varchar(100) DEFAULT NULL, `contract_id` bigint(20) DEFAULT NULL, `contract_no` varchar(100) DEFAULT NULL, `contract_name` varchar(200) DEFAULT NULL, `customer_name` varchar(200) DEFAULT NULL COMMENT '客户/承运商', `payer_name` varchar(200) DEFAULT NULL, `payee_name` varchar(200) DEFAULT NULL, `currency` varchar(20) DEFAULT 'RMB', `settlement_amount` decimal(18,2) DEFAULT 0, `paid_amount` decimal(18,2) DEFAULT 0, `reconciler_id` bigint(20) DEFAULT NULL, `reconciler_name` varchar(100) DEFAULT NULL, `reconciliation_date` date DEFAULT NULL, `reconciliation_status` varchar(30) NOT NULL DEFAULT 'unfinished', `match_status` varchar(30) NOT NULL DEFAULT 'unmatched', `internal_bill_count` int(11) DEFAULT 0, `external_bill_count` int(11) DEFAULT 0, `difference_count` int(11) DEFAULT 0, `internal_quantity` decimal(18,6) DEFAULT 0, `external_quantity` decimal(18,6) DEFAULT 0, `difference_quantity` decimal(18,6) DEFAULT 0, `internal_amount` decimal(18,2) DEFAULT 0, `external_amount` decimal(18,2) DEFAULT 0, `difference_amount` decimal(18,2) DEFAULT 0, `matched_count` int(11) DEFAULT 0, `unmatched_count` int(11) DEFAULT 0, `bill_updated` tinyint(1) DEFAULT 0, `completed_time` datetime DEFAULT NULL, `remark` varchar(200) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `uk_transport_reconciliation_no` (`tenant_id`,`reconciliation_no`), KEY `idx_transport_reconciliation_formal` (`formal_settlement_id`), KEY `idx_transport_reconciliation_type` (`settlement_type`), KEY `idx_transport_reconciliation_status` (`reconciliation_status`,`match_status`), KEY `idx_transport_reconciliation_create` (`create_time`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='运输对账单'; CREATE TABLE IF NOT EXISTS `blade_transport_reconciliation_internal` ( `id` bigint(20) NOT NULL, `tenant_id` varchar(12) NOT NULL DEFAULT '000000', `create_user` bigint(20) DEFAULT NULL, `create_dept` bigint(20) DEFAULT NULL, `create_time` datetime DEFAULT NULL, `update_user` bigint(20) DEFAULT NULL, `update_time` datetime DEFAULT NULL, `status` int(11) DEFAULT 1, `is_deleted` int(11) DEFAULT 0, `reconciliation_id` bigint(20) NOT NULL, `formal_settlement_detail_id` bigint(20) NOT NULL, `formal_settlement_detail_fee_id` bigint(20) DEFAULT NULL, `source_detail_id` bigint(20) DEFAULT NULL, `source_cargo_fee_id` bigint(20) DEFAULT NULL, `line_no` int(11) NOT NULL, `document_no` varchar(100) DEFAULT NULL, `waybill_no` varchar(100) DEFAULT NULL, `vehicle_no` varchar(100) DEFAULT NULL, `departure_address` varchar(500) DEFAULT NULL, `arrival_address` varchar(500) DEFAULT NULL, `actual_departure_time` datetime DEFAULT NULL, `actual_completion_time` datetime DEFAULT NULL, `transport_type` varchar(100) DEFAULT NULL, `cargo_name` varchar(500) DEFAULT NULL, `cargo_type` varchar(500) DEFAULT NULL, `specification` varchar(200) DEFAULT NULL, `model` varchar(200) DEFAULT NULL, `transport_quantity` decimal(18,6) DEFAULT NULL, `quantity_unit` varchar(50) DEFAULT NULL, `mileage` decimal(18,2) DEFAULT NULL, `batch_no` varchar(100) DEFAULT NULL, `unit_price` decimal(18,2) DEFAULT NULL, `freight_amount` decimal(18,2) DEFAULT 0, `fee_items_json` longtext, `settlement_amount` decimal(18,2) DEFAULT 0, `matched_external_id` bigint(20) DEFAULT NULL, `matched_external_line_no` int(11) DEFAULT NULL, `match_result` varchar(30) DEFAULT 'unmatched', `update_result` varchar(30) DEFAULT 'not_updated', `update_message` varchar(500) DEFAULT NULL, PRIMARY KEY (`id`), KEY `idx_recon_internal_bill` (`reconciliation_id`), KEY `idx_recon_internal_source` (`source_detail_id`), KEY `idx_recon_internal_match` (`matched_external_id`), KEY `idx_recon_internal_vehicle` (`vehicle_no`,`cargo_name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='运输对账内部账单快照'; CREATE TABLE IF NOT EXISTS `blade_transport_reconciliation_external` ( `id` bigint(20) NOT NULL, `tenant_id` varchar(12) NOT NULL DEFAULT '000000', `create_user` bigint(20) DEFAULT NULL, `create_dept` bigint(20) DEFAULT NULL, `create_time` datetime DEFAULT NULL, `update_user` bigint(20) DEFAULT NULL, `update_time` datetime DEFAULT NULL, `status` int(11) DEFAULT 1, `is_deleted` int(11) DEFAULT 0, `reconciliation_id` bigint(20) NOT NULL, `external_line_no` int(11) NOT NULL, `vehicle_no` varchar(100) DEFAULT NULL, `departure_address` varchar(500) DEFAULT NULL, `arrival_address` varchar(500) DEFAULT NULL, `actual_departure_time` datetime DEFAULT NULL, `actual_completion_time` datetime DEFAULT NULL, `transport_type` varchar(100) DEFAULT NULL, `cargo_name` varchar(500) DEFAULT NULL, `cargo_type` varchar(500) DEFAULT NULL, `specification` varchar(200) DEFAULT NULL, `model` varchar(200) DEFAULT NULL, `transport_quantity` decimal(18,6) DEFAULT NULL, `quantity_unit` varchar(50) DEFAULT NULL, `mileage` decimal(18,2) DEFAULT NULL, `batch_no` varchar(100) DEFAULT NULL, `unit_price` decimal(18,2) DEFAULT NULL, `freight_amount` decimal(18,2) DEFAULT 0, `fee_items_json` longtext, `settlement_amount` decimal(18,2) DEFAULT 0, `suspected_duplicate` tinyint(1) DEFAULT 0, `match_status` varchar(30) DEFAULT 'unmatched', `matched_internal_id` bigint(20) DEFAULT NULL, `error_message` varchar(500) DEFAULT NULL, `raw_data_json` longtext, PRIMARY KEY (`id`), KEY `idx_recon_external_bill` (`reconciliation_id`), KEY `idx_recon_external_line` (`reconciliation_id`,`external_line_no`), KEY `idx_recon_external_match` (`matched_internal_id`), KEY `idx_recon_external_status` (`match_status`,`suspected_duplicate`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='运输对账外部账单'; CREATE TABLE IF NOT EXISTS `blade_transport_reconciliation_change_record` ( `id` bigint(20) NOT NULL, `tenant_id` varchar(12) NOT NULL DEFAULT '000000', `create_user` bigint(20) DEFAULT NULL, `create_dept` bigint(20) DEFAULT NULL, `create_time` datetime DEFAULT NULL, `update_user` bigint(20) DEFAULT NULL, `update_time` datetime DEFAULT NULL, `status` int(11) DEFAULT 1, `is_deleted` int(11) DEFAULT 0, `reconciliation_id` bigint(20) NOT NULL, `internal_detail_id` bigint(20) DEFAULT NULL, `formal_settlement_id` bigint(20) DEFAULT NULL, `formal_settlement_detail_id` bigint(20) DEFAULT NULL, `source_detail_id` bigint(20) DEFAULT NULL, `document_no` varchar(100) DEFAULT NULL, `cargo_name` varchar(500) DEFAULT NULL, `before_amount` decimal(18,2) DEFAULT 0, `after_amount` decimal(18,2) DEFAULT 0, `before_data_json` longtext, `after_data_json` longtext, `operator_id` bigint(20) DEFAULT NULL, `operator_name` varchar(100) DEFAULT NULL, `change_time` datetime DEFAULT NULL, `change_reason` varchar(200) DEFAULT NULL, PRIMARY KEY (`id`), KEY `idx_recon_change_bill` (`reconciliation_id`), KEY `idx_recon_change_source` (`source_detail_id`), KEY `idx_recon_change_time` (`change_time`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='运输对账账单变更记录'; INSERT INTO `blade_menu` (`id`,`parent_id`,`code`,`name`,`alias`,`path`,`source`,`sort`,`category`,`action`,`is_open`,`component`,`remark`,`is_deleted`) VALUES (2090000000000002060,2090000000000001000,'transport_reconciliation','运输对账','transport_reconciliation','/settlement/transport-reconciliation','iconfont icon-caidanguanli',5,1,0,1,NULL,'',0), (2090000000000002061,2090000000000002060,'transport_reconciliation_view','查看','transport_reconciliation_view','', '',1,2,0,1,NULL,'',0), (2090000000000002062,2090000000000002060,'transport_reconciliation_add','新增','transport_reconciliation_add','', '',2,2,0,1,NULL,'',0), (2090000000000002063,2090000000000002060,'transport_reconciliation_edit','编辑','transport_reconciliation_edit','', '',3,2,0,1,NULL,'',0), (2090000000000002064,2090000000000002060,'transport_reconciliation_delete','删除','transport_reconciliation_delete','', '',4,2,0,1,NULL,'',0), (2090000000000002065,2090000000000002060,'transport_reconciliation_import','导入外部账单','transport_reconciliation_import','', '',5,2,0,1,NULL,'',0), (2090000000000002066,2090000000000002060,'transport_reconciliation_match','开始匹配','transport_reconciliation_match','', '',6,2,0,1,NULL,'',0), (2090000000000002067,2090000000000002060,'transport_reconciliation_update','按匹配结果更新','transport_reconciliation_update','', '',7,2,0,1,NULL,'',0), (2090000000000002068,2090000000000002060,'transport_reconciliation_complete','完成对账','transport_reconciliation_complete','', '',8,2,0,1,NULL,'',0), (2090000000000002069,2090000000000002060,'transport_reconciliation_export','导出','transport_reconciliation_export','', '',9,2,0,1,NULL,'',0), (2090000000000002070,2090000000000002060,'transport_reconciliation_adjust','明细调整','transport_reconciliation_adjust','', '',10,2,0,1,NULL,'',0) ON DUPLICATE KEY UPDATE `name`=VALUES(`name`),`path`=VALUES(`path`),`is_deleted`=0;