修改提交
This commit is contained in:
+40
@@ -17,6 +17,7 @@ import com.baiyue.lastleg.relabel.mapper.RelabelStatusHistoryMapper;
|
||||
import com.baiyue.lastleg.service.LastlegOrderNoGenerator;
|
||||
import com.baiyue.lastleg.wallet.WalletCommandOutboxService;
|
||||
import com.baiyue.lastleg.inventory.command.service.InventoryCommandService;
|
||||
import com.baiyue.lastleg.inventory.command.dto.InventoryCommandRequests;
|
||||
import com.baiyue.lastleg.inventory.entity.InventoryBalance;
|
||||
import com.baiyue.lastleg.inventory.entity.InventoryPosition;
|
||||
import com.baiyue.lastleg.inventory.mapper.InventoryBalanceMapper;
|
||||
@@ -129,6 +130,25 @@ class RelabelApplicationServiceTest {
|
||||
assertEquals("FBR-1", result.application().relabelNo());
|
||||
}
|
||||
|
||||
@Test
|
||||
void partialRelabelFreezesOnlyNotifiedPackages() {
|
||||
RelabelRequests.Create request = request("key-partial", 10, 2);
|
||||
RelabelApplication persisted = application(11L, "FBR-PARTIAL", "10001", "key-partial", null,
|
||||
RelabelApplicationService.PENDING_PROCESSING);
|
||||
persisted.setLastlegOrderId(21L);
|
||||
when(applications.findNo(eq("10001"), any())).thenReturn(persisted);
|
||||
when(items.selectList(any())).thenReturn(List.of(item(31L, 11L, "SKU-A", 10, 2)));
|
||||
when(histories.selectList(any())).thenReturn(List.of());
|
||||
when(orders.selectById(21L)).thenReturn(order(21L, "10001", "LMO-RELABEL-PARTIAL",
|
||||
RelabelApplicationService.PENDING_PROCESSING));
|
||||
|
||||
service.create("10001", "operator-1", request);
|
||||
|
||||
ArgumentCaptor<InventoryCommandRequests.Move> move = ArgumentCaptor.forClass(InventoryCommandRequests.Move.class);
|
||||
verify(inventoryCommands).hold(eq("10001"), eq("operator-1"), move.capture());
|
||||
assertEquals(2L, move.getValue().packages());
|
||||
}
|
||||
|
||||
@Test
|
||||
void createRejectsNotifiedBoxesAboveTotalBeforeAnyWrite() {
|
||||
ResponseStatusException exception = assertThrows(ResponseStatusException.class, () ->
|
||||
@@ -315,6 +335,26 @@ class RelabelApplicationServiceTest {
|
||||
assertEquals("COMPLETED", order.getRelabelStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
void completingPartialRelabelReleasesOnlyNotifiedPackages() {
|
||||
RelabelApplication application = application(11L, "FBR-PARTIAL", "10001", "key-partial", "hash", "PROCESSING");
|
||||
application.setLastlegOrderId(21L);
|
||||
LastlegOrder order = order(21L, "10001", "LMO-RELABEL-PARTIAL", "PROCESSING");
|
||||
when(applications.lockNo("10001", "FBR-PARTIAL")).thenReturn(application);
|
||||
stubDetail(application);
|
||||
RelabelItem relabelItem = item(31L, application.getId(), "SKU-A", 10, 6);
|
||||
relabelItem.setSourceInventoryPositionId(201L);
|
||||
when(items.selectList(any())).thenReturn(List.of(relabelItem));
|
||||
when(orders.selectById(21L)).thenReturn(order);
|
||||
|
||||
service.changeStatus("10001", "FBR-PARTIAL", "operator-2",
|
||||
new RelabelRequests.ChangeStatus("COMPLETED", "finished"));
|
||||
|
||||
ArgumentCaptor<InventoryCommandRequests.Move> move = ArgumentCaptor.forClass(InventoryCommandRequests.Move.class);
|
||||
verify(inventoryCommands).release(eq("10001"), eq("operator-2"), move.capture());
|
||||
assertEquals(6L, move.getValue().packages());
|
||||
}
|
||||
|
||||
private void stubDetail(RelabelApplication application) {
|
||||
when(applications.findNo(application.getCustomerId(), application.getRelabelNo())).thenReturn(application);
|
||||
when(items.selectList(any())).thenReturn(List.of(item(31L, application.getId(), "SKU-A", 10, 6)));
|
||||
|
||||
Reference in New Issue
Block a user