fix(dropship): preserve carton quantities and shared pallet outbound ownership

This commit is contained in:
2026-09-14 20:55:09 +08:00
parent 6dbcb2128c
commit 4f13ee2ec3
24 changed files with 302 additions and 99 deletions
@@ -157,11 +157,20 @@ public record FirstLegLoadingPlanCompletedV2(
/** 托盘下来源入库明细、SKU、箱数、数量及箱号冻结快照;同 SKU 多明细按 sourceInboundDetailId 精确区分。 */
public record SkuPackageSnapshot(String sourceInboundDetailId, String skuCode, String productName,
int packageCount, int productQuantity,
List<String> cartonMarks) {
List<String> cartonMarks, java.util.Map<String, Integer> cartonQuantities) {
public SkuPackageSnapshot {
if (sourceInboundDetailId == null || sourceInboundDetailId.isBlank()) {
throw new IllegalArgumentException("sourceInboundDetailId is required for each pallet SKU snapshot");
}
if (cartonMarks == null || cartonQuantities == null || cartonMarks.size() != packageCount
|| new java.util.HashSet<>(cartonMarks).size() != packageCount
|| !cartonQuantities.keySet().equals(new java.util.HashSet<>(cartonMarks))
|| cartonQuantities.values().stream().anyMatch(quantity -> quantity == null || quantity <= 0)
|| cartonQuantities.values().stream().mapToLong(Integer::longValue).sum() != productQuantity) {
throw new IllegalArgumentException("cartonQuantities must exactly cover cartonMarks and productQuantity");
}
cartonMarks = List.copyOf(cartonMarks);
cartonQuantities = java.util.Map.copyOf(cartonQuantities);
}
}
}