fix: merge multi-pallet dropship handover fragments

This commit is contained in:
2026-09-14 15:44:51 +08:00
parent fe888f9278
commit 13d2fe8e3a
4 changed files with 141 additions and 16 deletions
@@ -376,6 +376,32 @@ class LoadingCompletedOutboxServiceTest {
.doesNotStartWith("sha256:");
}
@Test void mergesOneDropshipSourceDetailSplitAcrossTwoPalletsBeforePublishing() throws Exception {
Row first = row(11, 100, 101); first.setFulfillmentType("ONE_CLICK_DROPSHIP");
Row second = row(11, 100, 101); second.setFulfillmentType("ONE_CLICK_DROPSHIP");
second.setLoadingPlanItemId(102L);
when(snapshots.rows(90L)).thenReturn(List.of(first, second));
when(snapshots.workPalletCount(90L)).thenReturn(2);
when(snapshots.actualPalletRows(90L)).thenReturn(List.of(
actualPallet(11,100,"DP-260914-0021",101,"SKU101","BOX-001",10),
actualPallet(11,100,"DP-260914-0022",101,"SKU101","BOX-002",10)));
service.publish(90L);
ArgumentCaptor<InboundOutboxEntity> captor = ArgumentCaptor.forClass(InboundOutboxEntity.class);
verify(outbox).insert(captor.capture());
EventEnvelope event = mapper.readValue(captor.getValue().getPayloadJson(), EventEnvelope.class);
assertThat(event.payload().at("/orders/0/items")).hasSize(1);
assertThat(event.payload().at("/orders/0/items/0/sourceInboundDetailId").asText()).isEqualTo("101");
assertThat(event.payload().at("/orders/0/items/0/packageCount").asInt()).isEqualTo(2);
assertThat(event.payload().at("/orders/0/items/0/productQuantity").asInt()).isEqualTo(20);
assertThat(event.payload().at("/orders/0/pallets")).hasSize(2);
assertThat(event.payload().at("/orders/0/pallets/0/skuPackages/0/sourceInboundDetailId").asText())
.isEqualTo("101");
assertThat(event.payload().at("/orders/0/pallets/1/skuPackages/0/sourceInboundDetailId").asText())
.isEqualTo("101");
}
@Test
void pricingBusinessTypeCannotTurnAStandardOrderIntoDropship() throws Exception {
Row value = row(11, 100, 101);