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

# Conflicts:
#	firstleg/src/main/java/com/baiyue/firstleg/service/SmartLoadingService.java
This commit is contained in:
2026-09-08 18:37:23 +08:00
5 changed files with 316 additions and 7 deletions
@@ -64,6 +64,8 @@ class LoadingListServiceTest {
@MockBean
private LoadingCompletedOutboxService loadingCompletedOutboxService;
@MockBean
private FbaPricingService fbaPricingService;
@MockBean
private InboundHoldGuard inboundHoldGuard;
@Resource
private LoadingListService service;
@@ -778,6 +780,9 @@ class LoadingListServiceTest {
when(repository.history(anyString())).thenReturn(null);
when(repository.aggregate(10L)).thenReturn(before, after);
when(loadingPickService.requirePreloadConfirmationReady(10L)).thenReturn(links);
when(fbaPricingService.recalculateUnlockedContainerCustomerFees(eq(30L), anyLong(), anyString()))
.thenReturn(new FbaPricingService.ContainerFeeRecalculationResult(
FbaPricingService.ContainerFeeRecalculationStatus.RECALCULATED, 2));
when(repository.touchForPreloadConfirmation(10L, 3, 9L, "operator")).thenReturn(1);
when(repository.confirmLinkedPreload(301L, "PENDING", 2, 9L, "operator")).thenReturn(1);
when(repository.confirmLinkedPreload(302L, "CONFIRMING", 5, 9L, "operator")).thenReturn(1);
@@ -791,12 +796,35 @@ class LoadingListServiceTest {
assertThat(response.readiness().pdaTaskId()).isEqualTo(80L);
verify(repository).confirmLinkedPreload(301L, "PENDING", 2, 9L, "operator");
verify(repository).confirmLinkedPreload(302L, "CONFIRMING", 5, 9L, "operator");
verify(fbaPricingService).recalculateUnlockedContainerCustomerFees(eq(30L), eq(101L), anyString());
verify(fbaPricingService).recalculateUnlockedContainerCustomerFees(eq(30L), eq(102L), anyString());
verify(loadingPickService, times(1)).beginIfReady(30L, 9L, "operator");
verify(repository).appendHistory(eq(10L), anyString(), eq("CONFIRM_PRELOAD"),
eq("EDITING"), eq("EDITING"), anyString(), anyString(), eq(9L),
eq("operator"), org.mockito.ArgumentMatchers.isNull());
}
@Test
void refusesConfirmationWhenAContainerCustomerFeeIsNotReadyWithoutTouchingPlan() {
AggregateRow before = row("EDITING", 3);
List<Link> links = List.of(new Link(1L, 101L, 201L, 301L, "PENDING", 2, 10L, 30L,
"MSCU-001", "EDITING", 3, 4, null));
when(repository.history(anyString())).thenReturn(null);
when(repository.aggregate(10L)).thenReturn(before);
when(loadingPickService.requirePreloadConfirmationReady(10L)).thenReturn(links);
when(fbaPricingService.recalculateUnlockedContainerCustomerFees(eq(30L), eq(101L), anyString()))
.thenReturn(new FbaPricingService.ContainerFeeRecalculationResult(
FbaPricingService.ContainerFeeRecalculationStatus.NOT_READY, 0));
assertThatThrownBy(() -> service.confirmPreload(
10L, 9L, "operator", "confirm-key", new ConfirmPreloadRequest(3)))
.isInstanceOf(BizException.class).hasMessageContaining("初始费用");
verify(repository, never()).touchForPreloadConfirmation(anyLong(), anyInt(), anyLong(), anyString());
verify(repository, never()).confirmLinkedPreload(anyLong(), anyString(), anyInt(), anyLong(), anyString());
verify(loadingPickService, never()).beginIfReady(anyLong(), anyLong(), anyString());
}
@Test
void exactConfirmationReplayReturnsFrozenResponseWithoutTouchingPlan() throws Exception {
PreloadConfirmationResponse expected = new PreloadConfirmationResponse(
@@ -94,6 +94,7 @@ class SmartLoadingServiceTest {
@MockBean private LoadingModelBridgeService loadingModelBridge;
@MockBean private SplitPreloadService splitPreloadService;
@MockBean private ColoadGroupAssignmentPort coloadGroups;
@MockBean private FbaPricingService fbaPricingService;
@MockBean private PriceBookQueryUseCase priceBooks;
@MockBean private FirstlegDocumentNumberGenerator documentNumbers;
@MockBean private DropshipPalletizationMapper dropshipPallets;
@@ -114,6 +115,9 @@ class SmartLoadingServiceTest {
when(cargoClient.detail(anyString(), anyLong(), anyLong(), anyLong())).thenReturn(
ApiResponse.success(new OrderCargoClient.CargoBinding(20L, 30L, 1, "货物", 5,
new BigDecimal("10"), new BigDecimal("2"))));
when(fbaPricingService.recalculateUnlockedContainerCustomerFees(anyLong(), anyLong(), anyString()))
.thenReturn(new FbaPricingService.ContainerFeeRecalculationResult(
FbaPricingService.ContainerFeeRecalculationStatus.NOT_READY, 0));
}
@Test
@@ -392,6 +396,7 @@ class SmartLoadingServiceTest {
assertThat(item.getValue().getGrossWeightKg()).isEqualByComparingTo("50");
verify(splitPreloadService).ensurePendingForPreAllocation(customerId, 10L, 7L, "u");
verify(loadingModelBridge).bindIncrementalAllocation(1L, customerId, 10L, 7L, "u", "pending-1");
verify(fbaPricingService).recalculateUnlockedContainerCustomerFees(eq(99L), eq(customerId), anyString());
}
@Test
@@ -866,6 +871,8 @@ class SmartLoadingServiceTest {
verify(repository, times(2)).remove(eq(1L), anyLong(), eq(0), eq(7L), eq("u"));
verify(coloadGroups).unlockWholeGroupAfterRemoval(eq(700L), eq(1L),
org.mockito.ArgumentMatchers.startsWith("UNLOCK-"), eq(7L), eq("u"));
verify(fbaPricingService).recalculateUnlockedContainerCustomerFees(eq(99L), eq(9L), anyString());
verify(fbaPricingService).recalculateUnlockedContainerCustomerFees(eq(99L), eq(19L), anyString());
}
@Test