fix(firstleg): freeze customs receipt after broker submission

This commit is contained in:
2026-09-26 17:45:41 +08:00
parent 5d365f9040
commit 5927034b1c
2 changed files with 15 additions and 0 deletions
@@ -205,6 +205,9 @@ public class ContainerCustomsService {
if (container == null || !DECLARING.equals(container.status()) || source.frozenAt() == null) {
throw conflict("当前客户资料不在报关中冻结版本");
}
if (mapper.brokerSubmittedAt(container.id()) != null) {
throw conflict("客户确认回执已发送给报关行,不可再修改回执");
}
CompletionRow completion = mapper.lockCompletion(documentId);
CustomsFileClient.Metadata metadata = upload(source.tenantId(), RECEIPT_FILE_TYPE, Long.toString(container.loadingPlanId()), operatorId, file);
long completionId;
@@ -274,6 +274,18 @@ class ContainerCustomsServiceTest {
verifyNoInteractions(files);
}
@Test void receiptCannotBeReplacedAfterBrokerSubmission(){
var source=document(1L);when(mapper.document(1L)).thenReturn(source);
when(mapper.claimCommand(anyLong(),eq(5L),eq("UPLOAD_COMPLETION_1"),eq("broker-sent-key"),anyString())).thenReturn(1);
when(mapper.lockContainerById(2L)).thenReturn(container(ContainerCustomsService.DECLARING,4));
when(mapper.lockDocument(1L)).thenReturn(source);
when(mapper.brokerSubmittedAt(2L)).thenReturn(java.time.LocalDateTime.now());
var file=new MockMultipartFile("file","result.bin","application/octet-stream",new byte[]{1});
assertThatThrownBy(()->service.uploadCompletion(1L,5L,"admin","broker-sent-key",0,file))
.isInstanceOf(BizException.class).hasMessageContaining("不可再修改回执");
verifyNoInteractions(files);
}
@Test void receiptReplaySucceedsAndDoesNotCompleteContainer(){
var source=document(1L);
var declaring=container(ContainerCustomsService.DECLARING,3);