fix(customs): add broker submission and receipt action history
This commit is contained in:
@@ -26,6 +26,28 @@ CREATE TABLE IF NOT EXISTS fl_customs_container (
|
||||
('WAITING_CUSTOMER_DOCUMENTS','READY_TO_START','DECLARING','COMPLETED'))
|
||||
) ENGINE=InnoDB COMMENT='装柜完成后的整柜出口报关聚合';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS 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) 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('SENT'))
|
||||
) ENGINE=InnoDB COMMENT='冻结退税报关资料首次发送报关行批次事实';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS fl_customs_customer_document (
|
||||
id BIGINT UNSIGNED NOT NULL COMMENT '客户报送资料ID',
|
||||
customs_container_id BIGINT UNSIGNED NOT NULL COMMENT '所属整柜报关聚合ID',
|
||||
@@ -136,6 +158,21 @@ CREATE TABLE IF NOT EXISTS fl_customs_completion_document_version (
|
||||
CONSTRAINT fk_customs_completion_version FOREIGN KEY(completion_document_id) REFERENCES fl_customs_completion_document(id)
|
||||
) ENGINE=InnoDB COMMENT='报关完成文件不可变覆盖版本';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS 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) NULL COMMENT '客户打回原因;确认动作为空',
|
||||
operator_id BIGINT UNSIGNED NOT NULL COMMENT '客户操作人ID',
|
||||
operator_name VARCHAR(64) 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('CONFIRM','REJECT'))
|
||||
) ENGINE=InnoDB COMMENT='客户报关行回执确认与打回不可变历史';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS fl_customs_final_document (
|
||||
id BIGINT UNSIGNED NOT NULL COMMENT '真实报关完税文件ID',
|
||||
source_document_id BIGINT UNSIGNED NOT NULL COMMENT '对应冻结客户资料ID',
|
||||
|
||||
Reference in New Issue
Block a user