fix(firstleg): retry chained remainder settlement

This commit is contained in:
2026-08-11 11:12:29 +08:00
parent fe0f1665e5
commit 7aa2b507f6
2 changed files with 95 additions and 5 deletions
@@ -169,6 +169,13 @@ public class PdaPickSettlementService {
int sequence = splits.nextSplitSequence(parent.tenantId(), rootInboundId);
String remainderChildCode = childPackageCount > 0
? childInboundCode(root.inboundCode(), sequence) : null;
// Consume the current slice before inserting its successor so the single-active-remainder
// constraint is released. A local failure rolls this back; the Order split is idempotent on retry.
requireAffected(splits.markSourceLoaded(parent.tenantId(), parentInboundId, pickedPackageCount,
operatorId, sourceVersion), "来源分片状态");
if (parentInboundId != rootInboundId) {
requireAffected(splits.touchRootSplit(parent.tenantId(), rootInboundId, operatorId, rootVersion), "根单拆分状态");
}
if (remainderChildId != 0L) {
requireAffected(splits.cloneChildWithPurpose(parent.tenantId(), parentInboundId, rootInboundId, remainderChildId,
orderSplit.remainderChild().orderId(), orderSplit.remainderChild().orderNo(),
@@ -198,11 +205,6 @@ public class PdaPickSettlementService {
line.remainingPackageCount()), "子入库测量明细");
lineNo++;
}
requireAffected(splits.markSourceLoaded(parent.tenantId(), parentInboundId, pickedPackageCount,
operatorId, sourceVersion), "来源分片状态");
if (parentInboundId != rootInboundId) {
requireAffected(splits.touchRootSplit(parent.tenantId(), rootInboundId, operatorId, rootVersion), "根单拆分状态");
}
requireAffected(splits.applyBatch(parent.tenantId(), batchId), "拆分批次生效");
for (MeasurementSplitLine line : measurementLines) {
requireAffected(splits.updateMeasurementItemForLoaded(parent.tenantId(),