Merge remote-tracking branch 'origin/test' into dev

This commit is contained in:
2026-09-08 21:29:21 +08:00
24 changed files with 154 additions and 75 deletions
@@ -75,6 +75,7 @@ class ContainerFeeDetailServiceTest {
approved.setId(51L);
approved.setTenantId(10001L);
approved.setLoadingPlanId(41L);
approved.setContainerBookingId(61L);
approved.setFeeItemId(11L);
approved.setDirection("RECEIVABLE");
approved.setSourceVersion(1);
@@ -87,7 +88,7 @@ class ContainerFeeDetailServiceTest {
service.approve(10001L, 41L, 51L, 9L, "admin");
verify(outbox).publishContainer(eq(FinanceFeeSourceOutboxService.PUBLISHED),
eq(10001L), eq(41L), eq(51L), eq(1), any(LocalDateTime.class));
eq(10001L), eq(61L), eq(51L), eq(1), any(LocalDateTime.class));
}
@Test
@@ -284,6 +285,7 @@ class ContainerFeeDetailServiceTest {
private void ownedPlan() {
LoadingPlanEntity plan = new LoadingPlanEntity();
plan.setId(41L);
plan.setContainerBookingId(61L);
when(loading.plan(41L)).thenReturn(plan);
LoadingPlanItemEntity item = new LoadingPlanItemEntity();
item.setAccountId(10001L);
@@ -316,6 +318,7 @@ class ContainerFeeDetailServiceTest {
value.setId(51L);
value.setTenantId(10001L);
value.setLoadingPlanId(41L);
value.setContainerBookingId(61L);
value.setFeeItemId(11L);
value.setFeeItemCodeSnapshot("TRUCKING");
value.setFeeItemNameSnapshot("拖车费");
@@ -96,11 +96,12 @@ class FinanceFeeSourceCommandServiceTest {
@Test
void routesContainerVoidThroughExistingBusinessService() throws Exception {
VoidRequest request = new VoidRequest("CONTAINER_FEE", 800L, 4, 9L,
null, 200L, 71L, "finance", "柜次费用作废");
null, 61L, 71L, "finance", "柜次费用作废");
ContainerFeeDetailEntity detail = new ContainerFeeDetailEntity();
detail.setId(800L); detail.setTenantId(9L); detail.setLoadingPlanId(200L);
detail.setContainerBookingId(61L);
detail.setSourceVersion(4); detail.setSourceStatus("ACTIVE");
when(containerFees.find(200L, 800L)).thenReturn(detail);
when(containerFees.findByContainerBookingId(61L, 800L)).thenReturn(detail);
service.voidSource("void-container", hash(request), request);
@@ -49,4 +49,18 @@ class FinanceFeeSourceOutboxServiceTest {
assertThatCode(() -> service.publishContainer(FinanceFeeSourceOutboxService.VOIDED,
10001L, 41L, 51L, 2, LocalDateTime.now())).doesNotThrowAnyException();
}
@Test
void containerEventUsesTheRealContainerBookingIdAsAggregateAndPayloadIdentity() {
service.publishContainer(FinanceFeeSourceOutboxService.PUBLISHED,
10001L, 61L, 51L, 2, LocalDateTime.of(2026, 8, 11, 12, 0));
ArgumentCaptor<InboundOutboxEntity> captor = ArgumentCaptor.forClass(InboundOutboxEntity.class);
verify(mapper).insert(captor.capture());
InboundOutboxEntity event = captor.getValue();
assertThat(event.getAggregateType()).isEqualTo("CONTAINER");
assertThat(event.getAggregateId()).isEqualTo(61L);
assertThat(event.getPayloadJson()).contains("\"containerId\":\"61\"")
.doesNotContain("\"containerId\":\"41\"");
}
}
@@ -90,10 +90,12 @@ class FinanceFeeSourceSnapshotServiceTest {
detail.setCurrency("CNY");
detail.setReviewStatus("APPROVED");
detail.setSourceVersion(2);
when(containerFees.find(41L, 51L, 2)).thenReturn(detail);
when(containerFees.findByContainerBookingId(61L, 51L, 2)).thenReturn(detail);
FinanceFeeSourceSnapshot snapshot = service.container(41L, 51L, 2);
FinanceFeeSourceSnapshot snapshot = service.container(61L, 51L, 2);
assertThat(snapshot.containerId()).isEqualTo(61L);
assertThat(snapshot.containerBookingId()).isEqualTo(61L);
assertThat(snapshot.supplierId()).isEqualTo(71L);
assertThat(snapshot.supplierName()).isEqualTo("现有供应商");
assertThat(snapshot.supplierCategory()).isEqualTo("TRUCKING");