feat(customs): show broker submission state in admin

This commit is contained in:
2026-09-28 13:21:59 +08:00
parent fad49a07a8
commit 730defabca
4 changed files with 111 additions and 13 deletions
@@ -19,6 +19,29 @@ export interface ContainerCustomsReceiptVersion {
createdAt: string
}
export type ContainerCustomsConfirmationAction = 'CONFIRM' | 'REJECT'
export interface ContainerCustomsConfirmationHistory {
id: string
receiptVersion: number
action: ContainerCustomsConfirmationAction
reason: string | null
operatorName: string
createdAt: string
}
export interface ContainerCustomsBrokerSubmission {
id: string
customsContainerId: string
loadingPlanId: string
batchNo: string
status: 'SENT'
sourceVersion: number
sentByName: string
sentAt: string
version: number
}
export interface ContainerCustomsInbound {
inboundId: string
orderId: string
@@ -42,6 +65,7 @@ export interface ContainerCustomsDocument {
receiptRejectReason?: string | null
finalDocument: ContainerCustomsFile | null
receiptHistory?: ContainerCustomsReceiptVersion[]
confirmationHistory: ContainerCustomsConfirmationHistory[]
}
export interface ContainerCustomsView {
@@ -59,6 +83,7 @@ export interface ContainerCustomsView {
actualBoxCount: number
inbounds: ContainerCustomsInbound[]
documents: ContainerCustomsDocument[]
brokerSubmission: ContainerCustomsBrokerSubmission | null
startedAt: string | null
completedAt: string | null
brokerSubmittedAt?: string | null
@@ -119,7 +144,24 @@ function normalize(value: RawContainerCustomsView): ContainerCustomsView {
...value,
aggregateId: String(value.aggregateId), loadingPlanId: String(value.loadingPlanId), containerBookingId: String(value.containerBookingId), version: Number(value.version),
inbounds: value.inbounds.map((item) => ({ ...item, inboundId: String(item.inboundId), orderId: String(item.orderId), tenantId: String(item.tenantId) })),
documents: value.documents.map((item) => ({ ...item, documentId: String(item.documentId), tenantId: String(item.tenantId), source: file(item.source)!, receipt: file(item.receipt), finalDocument: file(item.finalDocument), receiptHistory: (item.receiptHistory || []).map((version) => ({ ...version, version: Number(version.version), file: file(version.file)! })) })),
brokerSubmission: value.brokerSubmission ? {
...value.brokerSubmission,
id: String(value.brokerSubmission.id),
customsContainerId: String(value.brokerSubmission.customsContainerId),
loadingPlanId: String(value.brokerSubmission.loadingPlanId),
sourceVersion: Number(value.brokerSubmission.sourceVersion),
version: Number(value.brokerSubmission.version),
} : null,
documents: value.documents.map((item) => ({
...item,
documentId: String(item.documentId),
tenantId: String(item.tenantId),
source: file(item.source)!,
receipt: file(item.receipt),
finalDocument: file(item.finalDocument),
receiptHistory: (item.receiptHistory || []).map((version) => ({ ...version, version: Number(version.version), file: file(version.file)! })),
confirmationHistory: (item.confirmationHistory || []).map((history) => ({ ...history, id: String(history.id), receiptVersion: Number(history.receiptVersion), reason: history.reason ?? null })),
})),
}
}
@@ -174,7 +216,7 @@ export function downloadContainerCustomsFinal(documentId: string) {
return http.get<Blob, Blob>(`${basePath}/documents/${encodeURIComponent(documentId)}/final/download`, { responseType: 'blob' })
}
async function action(loadingPlanId: string, name: 'start' | 'submit-to-broker' | 'complete-all-buy', expectedVersion: number, remark?: string) {
async function action(loadingPlanId: string, name: 'start' | 'send-to-broker' | 'submit-to-broker' | 'complete-all-buy', expectedVersion: number, remark?: string) {
const response = await http.post<ApiEnvelope<RawContainerCustomsView>, ApiEnvelope<RawContainerCustomsView>>(
`${basePath}/${encodeURIComponent(loadingPlanId)}/${name}`,
{ expectedVersion, confirm: true, remark: remark?.trim() || null },
@@ -187,6 +229,10 @@ export function startContainerCustoms(loadingPlanId: string, expectedVersion: nu
return action(loadingPlanId, 'start', expectedVersion)
}
export function sendContainerCustomsToBroker(loadingPlanId: string, expectedVersion: number) {
return action(loadingPlanId, 'send-to-broker', expectedVersion, '已将冻结退税报关资料首次发送给报关行')
}
export function completeAllBuyContainerCustoms(loadingPlanId: string, expectedVersion: number) {
return action(loadingPlanId, 'complete-all-buy', expectedVersion)
}