fix(customs): add broker submission and receipt action history

This commit is contained in:
2026-09-28 13:21:37 +08:00
parent ab64699245
commit e63cb2b29e
15 changed files with 365 additions and 8 deletions
@@ -1769,6 +1769,28 @@ CREATE TABLE fl_customs_container (
CONSTRAINT chk_customs_container_status CHECK ((status in (_utf8mb4'WAITING_CUSTOMER_DOCUMENTS',_utf8mb4'READY_TO_START',_utf8mb4'DECLARING',_utf8mb4'COMPLETED')))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='装柜完成后的整柜出口报关聚合';
CREATE TABLE fl_customs_broker_submission (
id bigint unsigned NOT NULL COMMENT '首次发送报关行批次ID',
customs_container_id bigint unsigned NOT NULL COMMENT '所属整柜报关聚合ID',
loading_plan_id bigint unsigned NOT NULL COMMENT '装柜计划ID快照',
batch_no varchar(64) NOT NULL COMMENT '首次发送报关行批次号',
status varchar(16) NOT NULL COMMENT '发送状态:SENT已发送',
source_version int unsigned NOT NULL COMMENT '发送时整柜报关聚合版本',
source_snapshot_json json NOT NULL COMMENT '发送时冻结资料版本与覆盖范围快照',
sent_by bigint unsigned NOT NULL COMMENT '首次发送操作人ID',
sent_by_name varchar(64) DEFAULT NULL COMMENT '首次发送操作人名称快照',
sent_at datetime(3) NOT NULL COMMENT '首次发送时间',
version int unsigned NOT NULL DEFAULT '1' COMMENT '乐观锁版本号',
created_at datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '批次创建时间',
updated_at datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '批次更新时间',
PRIMARY KEY (id),
UNIQUE KEY uk_customs_broker_submission_container (customs_container_id),
UNIQUE KEY uk_customs_broker_submission_batch (batch_no),
KEY idx_customs_broker_submission_plan (loading_plan_id,sent_at),
CONSTRAINT fk_customs_broker_submission_container FOREIGN KEY (customs_container_id) REFERENCES fl_customs_container (id),
CONSTRAINT chk_customs_broker_submission_status CHECK ((status in (_utf8mb4'SENT')))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='冻结退税报关资料首次发送报关行批次事实';
CREATE TABLE fl_customs_container_history (
id bigint unsigned NOT NULL COMMENT '报关历史记录ID',
customs_container_id bigint unsigned NOT NULL COMMENT '所属整柜报关聚合ID',
@@ -1865,6 +1887,21 @@ CREATE TABLE fl_customs_completion_document_version (
CONSTRAINT fk_customs_completion_version FOREIGN KEY (completion_document_id) REFERENCES fl_customs_completion_document (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='报关完成文件不可变覆盖版本';
CREATE TABLE fl_customs_completion_action_history (
id bigint unsigned NOT NULL COMMENT '客户回执动作历史ID',
completion_document_id bigint unsigned NOT NULL COMMENT '报关行回执当前版本逻辑根ID',
receipt_version int unsigned NOT NULL COMMENT '动作对应的回执文件版本',
action varchar(16) NOT NULL COMMENT '客户动作:CONFIRM确认、REJECT打回',
reason varchar(500) DEFAULT NULL COMMENT '客户打回原因;确认动作为空',
operator_id bigint unsigned NOT NULL COMMENT '客户操作人ID',
operator_name varchar(64) DEFAULT NULL COMMENT '客户操作人名称快照',
created_at datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '客户动作时间',
PRIMARY KEY (id),
KEY idx_customs_completion_action_history (completion_document_id,receipt_version,created_at,id),
CONSTRAINT fk_customs_completion_action_history_document FOREIGN KEY (completion_document_id) REFERENCES fl_customs_completion_document (id),
CONSTRAINT chk_customs_completion_action_history_action CHECK ((action in (_utf8mb4'CONFIRM',_utf8mb4'REJECT')))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='客户报关行回执确认与打回不可变历史';
CREATE TABLE fl_customs_customer_document_inbound (
document_id bigint unsigned NOT NULL COMMENT '客户报送资料ID',
inbound_id bigint unsigned NOT NULL COMMENT '覆盖入仓单ID',