fix: 按物理箱贯通一件代发履约箱数

This commit is contained in:
2026-09-16 20:49:35 +08:00
parent 8797c0bef9
commit 545ad2083d
34 changed files with 779 additions and 132 deletions
@@ -5,8 +5,10 @@ import com.baiyue.lastleg.dropship.entity.DropshipOrderProfile;
import com.baiyue.lastleg.dropship.entity.DropshipSkuInventory;
import com.baiyue.lastleg.dropship.entity.DropshipCarton;
import com.baiyue.lastleg.dropship.entity.DropshipCartonLedger;
import com.baiyue.lastleg.dropship.entity.DropshipCartonSku;
import com.baiyue.lastleg.dropship.mapper.DropshipCartonLedgerMapper;
import com.baiyue.lastleg.dropship.mapper.DropshipCartonMapper;
import com.baiyue.lastleg.dropship.mapper.DropshipCartonSkuMapper;
import com.baiyue.lastleg.dropship.mapper.DropshipOrderProfileMapper;
import com.baiyue.lastleg.dropship.mapper.DropshipSkuInventoryMapper;
import com.baiyue.lastleg.entity.LastlegOrder;
@@ -32,6 +34,7 @@ class DropshipOrderServiceTest {
@Mock private DropshipOrderProfileMapper profiles;
@Mock private DropshipSkuInventoryMapper skuInventory;
@Mock private DropshipCartonMapper cartons;
@Mock private DropshipCartonSkuMapper cartonSkus;
@Mock private DropshipCartonLedgerMapper ledger;
@Mock private WarehouseResourceGateway warehouse;
@InjectMocks private DropshipOrderService service;
@@ -62,6 +65,7 @@ class DropshipOrderServiceTest {
verify(profiles, times(2)).insert(any(DropshipOrderProfile.class));
verify(skuInventory, times(2)).insert(any(DropshipSkuInventory.class));
verify(cartons, times(3)).insert(any(DropshipCarton.class));
verify(cartonSkus, times(3)).insert(any(DropshipCartonSku.class));
verify(ledger, times(3)).insert(any(DropshipCartonLedger.class));
ArgumentCaptor<DropshipOrderProfile> profilesCaptor = ArgumentCaptor.forClass(DropshipOrderProfile.class);
@@ -88,6 +92,33 @@ class DropshipOrderServiceTest {
.containsOnly(0L);
}
@Test
void multiSkuCartonsAreStoredOnceWithSeparateSkuFacts() {
LastlegOrder order = new LastlegOrder();
order.setId(10L); order.setCustomerId("C-1"); order.setOrderType("ONE_CLICK_DROPSHIP");
order.setOrderNo("LL-10"); order.setPackageCount(2); order.setProductQuantity(30);
when(orders.selectById(10L)).thenReturn(order);
when(profiles.listOrder("C-1", 10L)).thenReturn(List.of());
DropshipRequests.Receive request = new DropshipRequests.Receive("C-1", 10L, 20L, "EVENT-MIXED",
List.of(new DropshipRequests.Pallet("SOURCE-P-1", List.of(
new DropshipRequests.SkuPackages("SKU-A", "A", 2, 20,
List.of("BOX-1", "BOX-2"), java.util.Map.of("BOX-1", 10L, "BOX-2", 10L)),
new DropshipRequests.SkuPackages("SKU-B", "B", 2, 10,
List.of("BOX-1", "BOX-2"), java.util.Map.of("BOX-1", 5L, "BOX-2", 5L))),
1, 2, 1, "2".repeat(64))));
assertThat(service.receive(request)).isEqualTo(2);
ArgumentCaptor<DropshipCarton> physical = ArgumentCaptor.forClass(DropshipCarton.class);
verify(cartons, times(2)).insert(physical.capture());
assertThat(physical.getAllValues()).extracting(DropshipCarton::getCartonMark)
.containsExactly("BOX-1", "BOX-2");
assertThat(physical.getAllValues()).extracting(DropshipCarton::getSkuCode).containsOnly("MIXED");
assertThat(physical.getAllValues()).extracting(DropshipCarton::getProductQuantity).containsOnly(15L);
verify(cartonSkus, times(4)).insert(any(DropshipCartonSku.class));
verify(ledger, times(2)).insert(any(DropshipCartonLedger.class));
}
@Test
void activatesMultiplePalletsOnlyAfterPdaStockIn() {
DropshipOrderProfile first = profile(1L, "SOURCE-P-1");