fix: 按物理箱贯通一件代发履约箱数
This commit is contained in:
+6
-4
@@ -13,20 +13,22 @@ class DropshipOutboundCandidateMapperContractTest {
|
||||
String sql = select("listOutboundCandidates", String.class, String.class);
|
||||
for (String token : new String[] {"p.customer_id=#{customerId}", "p.status='ACTIVE'",
|
||||
"o.order_type='ONE_CLICK_DROPSHIP'", "COALESCE(o.detained,0)=0", "pos.status='OCCUPIED'",
|
||||
"pos.available_packages>0", "s.package_count>0", "c.status='AVAILABLE'",
|
||||
"pos.available_packages>0", "c.status='AVAILABLE'", "COUNT(*)=1", "ELSE 'MIXED'",
|
||||
"ll_dispatch_pallet_lock", "ll_warehouse_transfer_inventory_allocation",
|
||||
"ll_outbound_pallet_item", "pos.overseas_warehouse_id=#{warehouseId}", "LIMIT 500"}) {
|
||||
assertTrue(sql.contains(token), token);
|
||||
}
|
||||
assertTrue(sql.contains("LEAST(pos.available_packages,s.package_count"));
|
||||
assertTrue(sql.contains("LEAST(pos.available_packages,(SELECT COUNT(*) FROM ll_dropship_carton"));
|
||||
assertTrue(sql.contains("#{customerId} IS NULL OR #{customerId}='' OR p.customer_id=#{customerId}"));
|
||||
assertTrue(sql.contains("ORDER BY b.overseas_warehouse_name,p.pallet_no,sku_code"));
|
||||
assertTrue(!sql.contains("ORDER BY b.overseas_warehouse_name,p.pallet_no,s.sku_code"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void creationLockUsesTheSameEligibilityContractAndLocksOneSkuDimension() throws Exception {
|
||||
void creationLockUsesTheSameEligibilityContractAndLocksOnePhysicalPalletDimension() throws Exception {
|
||||
String sql = select("lockOutboundCandidate", String.class, Long.class, String.class);
|
||||
assertTrue(sql.contains("AND pos.id=#{positionId}"));
|
||||
assertTrue(sql.contains("AND s.sku_code=#{skuCode}"));
|
||||
assertTrue(sql.contains("AND #{skuCode}=(SELECT CASE WHEN COUNT(*)=1"));
|
||||
assertTrue(sql.contains("LIMIT 1 FOR UPDATE"));
|
||||
assertTrue(sql.contains("ll_dispatch_pallet_lock"));
|
||||
assertTrue(sql.contains("ll_outbound_pallet_item"));
|
||||
|
||||
+23
-5
@@ -34,8 +34,10 @@ import com.baiyue.lastleg.inventory.mapper.InventoryBalanceMapper;
|
||||
import com.baiyue.lastleg.transfer.mapper.WarehouseTransferPalletMapper;
|
||||
import com.baiyue.lastleg.dropship.entity.DropshipOrderProfile;
|
||||
import com.baiyue.lastleg.dropship.entity.DropshipCarton;
|
||||
import com.baiyue.lastleg.dropship.entity.DropshipCartonSku;
|
||||
import com.baiyue.lastleg.dropship.mapper.DropshipOrderProfileMapper;
|
||||
import com.baiyue.lastleg.dropship.mapper.DropshipCartonMapper;
|
||||
import com.baiyue.lastleg.dropship.mapper.DropshipCartonSkuMapper;
|
||||
import com.baiyue.lastleg.dropship.mapper.DropshipSkuInventoryMapper;
|
||||
import com.baiyue.lastleg.dropship.model.DropshipOutboundCandidate;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -83,6 +85,7 @@ class DeliveryTransferServiceTest {
|
||||
@Mock InventoryBalanceMapper inventoryBalances;
|
||||
@Mock DropshipOrderProfileMapper dropshipProfiles;
|
||||
@Mock DropshipCartonMapper dropshipCartons;
|
||||
@Mock DropshipCartonSkuMapper dropshipCartonSkus;
|
||||
@Mock DropshipSkuInventoryMapper dropshipSkuInventory;
|
||||
@Mock WarehouseTransferPalletMapper warehouseTransferPallets;
|
||||
|
||||
@@ -112,6 +115,7 @@ class DeliveryTransferServiceTest {
|
||||
ReflectionTestUtils.setField(service, "inventoryBalances", inventoryBalances);
|
||||
ReflectionTestUtils.setField(service, "dropshipProfiles", dropshipProfiles);
|
||||
ReflectionTestUtils.setField(service, "dropshipCartons", dropshipCartons);
|
||||
ReflectionTestUtils.setField(service, "dropshipCartonSkus", dropshipCartonSkus);
|
||||
ReflectionTestUtils.setField(service, "dropshipSkuInventory", dropshipSkuInventory);
|
||||
ReflectionTestUtils.setField(service, "warehouseTransferPallets", warehouseTransferPallets);
|
||||
}
|
||||
@@ -458,7 +462,7 @@ class DeliveryTransferServiceTest {
|
||||
for (long i = 1; i <= 2; i++) {
|
||||
when(dropshipProfiles.lockOutboundCandidate("TENANT-A", 900L + i, "SKU-1"))
|
||||
.thenReturn(dropshipCandidate(900L + i, 1000L + i, "WH-1", "DP-SHARED", "SKU-1", 1L));
|
||||
when(dropshipCartons.lockAvailable("TENANT-A", 1000L + i, "SKU-1", 1L))
|
||||
when(dropshipCartons.lockAvailablePhysical("TENANT-A", 1000L + i, 1L))
|
||||
.thenReturn(List.of(new DropshipCarton()));
|
||||
InventoryPosition position = new InventoryPosition();
|
||||
position.setId(900L + i); position.setCustomerId("TENANT-A"); position.setBalanceId(800L + i);
|
||||
@@ -489,7 +493,7 @@ class DeliveryTransferServiceTest {
|
||||
when(inventoryPositions.selectById(901L)).thenReturn(position);
|
||||
DropshipOutboundCandidate candidate = dropshipCandidate(901L, 1001L, "WH-1", "PLT-501", "MIXED", 1L);
|
||||
when(dropshipProfiles.lockOutboundCandidate("TENANT-A", 901L, "MIXED")).thenReturn(candidate);
|
||||
when(dropshipCartons.lockAvailable("TENANT-A", 1001L, "MIXED", 1L)).thenReturn(List.of());
|
||||
when(dropshipCartons.lockAvailablePhysical("TENANT-A", 1001L, 1L)).thenReturn(List.of());
|
||||
|
||||
ResponseStatusException exception = assertThrows(ResponseStatusException.class, () -> service.createOneClick(
|
||||
"TENANT-A", "U-1", new DeliveryRequests.OneClickOutbound("recipient", List.of(
|
||||
@@ -807,15 +811,15 @@ class DeliveryTransferServiceTest {
|
||||
OutboundPdaTask task = new OutboundPdaTask(); task.setId(701L); task.setCustomerId("TENANT-A");
|
||||
task.setOutboundOrderId(301L); task.setTaskNo("PDA-701"); task.setStatus("PENDING");
|
||||
OutboundPalletItem item = pallet(501L, "DP-1", "ONT8", "Ontario", "IN-A", 2);
|
||||
item.setSkuCode("SKU-1"); item.setCartonMarks("BOX-A,BOX-B");
|
||||
item.setSkuCode("MIXED"); item.setCartonMarks("BOX-A,BOX-B");
|
||||
InventoryPosition position = new InventoryPosition(); position.setId(901L); position.setCustomerId("TENANT-A");
|
||||
position.setBalanceId(801L); position.setPalletId(501L); position.setOverseasWarehouseId("WH-1");
|
||||
InventoryBalance balance = new InventoryBalance(); balance.setCustomerId("TENANT-A"); balance.setInboundCode("IN-A");
|
||||
DropshipOrderProfile profile = new DropshipOrderProfile(); profile.setId(1001L);
|
||||
DropshipCarton first = new DropshipCarton(); first.setId(1101L); first.setProductQuantity(7L);
|
||||
DropshipCarton second = new DropshipCarton(); second.setId(1102L); second.setProductQuantity(13L);
|
||||
first.setStatus("AVAILABLE"); first.setSkuCode("SKU-1"); first.setCartonMark("BOX-A");
|
||||
second.setStatus("AVAILABLE"); second.setSkuCode("SKU-1"); second.setCartonMark("BOX-B");
|
||||
first.setStatus("AVAILABLE"); first.setSkuCode("MIXED"); first.setCartonMark("BOX-A");
|
||||
second.setStatus("AVAILABLE"); second.setSkuCode("MIXED"); second.setCartonMark("BOX-B");
|
||||
when(pdaTasks.lockByNoAndWarehouse("PDA-701", "WH-1")).thenReturn(task);
|
||||
when(outboundOrders.selectById(301L)).thenReturn(outbound);
|
||||
when(outboundOrders.lockByNo("TENANT-A", "OUT-301")).thenReturn(outbound);
|
||||
@@ -825,8 +829,14 @@ class DeliveryTransferServiceTest {
|
||||
when(dropshipProfiles.findPosition("TENANT-A", 901L)).thenReturn(profile);
|
||||
when(dropshipCartons.findByProfileAndMark("TENANT-A", 1001L, "BOX-A")).thenReturn(first);
|
||||
when(dropshipCartons.findByProfileAndMark("TENANT-A", 1001L, "BOX-B")).thenReturn(second);
|
||||
when(dropshipCartonSkus.listCarton("TENANT-A", 1101L)).thenReturn(List.of(
|
||||
cartonSku("SKU-1", 7), cartonSku("SKU-2", 3)));
|
||||
when(dropshipCartonSkus.listCarton("TENANT-A", 1102L)).thenReturn(List.of(
|
||||
cartonSku("SKU-1", 13), cartonSku("SKU-2", 2)));
|
||||
when(dropshipSkuInventory.deduct("TENANT-A", 1001L, "SKU-1", 1L, 7L)).thenReturn(1);
|
||||
when(dropshipSkuInventory.deduct("TENANT-A", 1001L, "SKU-2", 1L, 3L)).thenReturn(1);
|
||||
when(dropshipSkuInventory.deduct("TENANT-A", 1001L, "SKU-1", 1L, 13L)).thenReturn(1);
|
||||
when(dropshipSkuInventory.deduct("TENANT-A", 1001L, "SKU-2", 1L, 2L)).thenReturn(1);
|
||||
when(outboundPallets.findByOutbound("TENANT-A", 301L)).thenReturn(List.of(item));
|
||||
assertThrows(ResponseStatusException.class, () -> service.pdaPick("WH-1", "U-1", "PDA-701",
|
||||
new DeliveryRequests.PdaPick(item.getId(), 901L, 1L, "wrong-mark", List.of("WRONG-BOX"))));
|
||||
@@ -837,7 +847,9 @@ class DeliveryTransferServiceTest {
|
||||
new DeliveryRequests.PdaPick(item.getId(), 901L, 1L, "repeat-box-new-key", List.of("BOX-A"))));
|
||||
service.pdaPick("WH-1", "U-1", "PDA-701", new DeliveryRequests.PdaPick(item.getId(), 901L, 1L, "pick-13", List.of("BOX-B")));
|
||||
verify(dropshipSkuInventory).deduct("TENANT-A", 1001L, "SKU-1", 1L, 7L);
|
||||
verify(dropshipSkuInventory).deduct("TENANT-A", 1001L, "SKU-2", 1L, 3L);
|
||||
verify(dropshipSkuInventory).deduct("TENANT-A", 1001L, "SKU-1", 1L, 13L);
|
||||
verify(dropshipSkuInventory).deduct("TENANT-A", 1001L, "SKU-2", 1L, 2L);
|
||||
assertEquals("SHIPPED", first.getStatus()); assertEquals("SHIPPED", second.getStatus());
|
||||
assertEquals(2, item.getPickedPackageCount());
|
||||
}
|
||||
@@ -962,4 +974,10 @@ class DeliveryTransferServiceTest {
|
||||
value.setOverseasWarehouseId(warehouseId); value.setPalletNo(palletNo); value.setSkuCode(sku);
|
||||
value.setAvailablePackages(packages); return value;
|
||||
}
|
||||
|
||||
private static DropshipCartonSku cartonSku(String sku, long quantity) {
|
||||
DropshipCartonSku value = new DropshipCartonSku();
|
||||
value.setSkuCode(sku); value.setProductQuantity(quantity);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user