@pisell/pisellos 2.3.204 → 2.3.206

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1281,6 +1281,12 @@ function buildPosForcedAvailabilityAssignments(params) {
1281
1281
  var _group$resourceIds2, _group$formId2, _candidate$primarySch7, _candidate$primarySch8;
1282
1282
  if (sameAvailabilityId(resourceId, POS_NO_RESOURCE_ID)) {
1283
1283
  var _group$formId, _candidate$primarySch5, _candidate$primarySch6;
1284
+ if (params.allowNoResource === false) {
1285
+ addConflict('resource_unavailable', '必须选择当前商品的有效资源', {
1286
+ resourceId: resourceId
1287
+ });
1288
+ return;
1289
+ }
1284
1290
  assignments.push({
1285
1291
  productId: product.id,
1286
1292
  resourceId: POS_NO_RESOURCE_ID,
@@ -1333,6 +1339,41 @@ function buildPosForcedAvailabilityAssignments(params) {
1333
1339
  conflicts: conflicts
1334
1340
  };
1335
1341
  }
1342
+
1343
+ /** Structural conversion only. The customer has already picked a time and resources in the UI. */
1344
+ function acceptCustomerSelectionSnapshot(params) {
1345
+ var _display$maxPartySize;
1346
+ var candidate = params.candidate;
1347
+ try {
1348
+ var start = localDateTimeToScalar(parseLocalDateTime(candidate.startAt));
1349
+ var end = localDateTimeToScalar(parseLocalDateTime(candidate.endAt));
1350
+ var bookingStart = localDateTimeToScalar(parseLocalDateTime(candidate.bookingStartAt));
1351
+ var bookingEnd = localDateTimeToScalar(parseLocalDateTime(candidate.bookingEndAt));
1352
+ if (end <= start || bookingEnd <= bookingStart) throw new Error('invalid interval');
1353
+ } catch (_unused5) {
1354
+ throw new AvailabilityError('INVALID_TARGET_FILTER', '所选时间必须是有效且递增的区间');
1355
+ }
1356
+ var _buildPosForcedAvaila = buildPosForcedAvailabilityAssignments(_objectSpread(_objectSpread({}, params), {}, {
1357
+ allowNoResource: false
1358
+ })),
1359
+ assignments = _buildPosForcedAvaila.assignments,
1360
+ conflicts = _buildPosForcedAvaila.conflicts;
1361
+ // Preserve the original time-card snapshot for callers; do not query current availability here.
1362
+ var display = candidate;
1363
+ var availability = _objectSpread(_objectSpread({}, candidate), {}, {
1364
+ status: display.status || 'available',
1365
+ maxPartySize: (_display$maxPartySize = display.maxPartySize) !== null && _display$maxPartySize !== void 0 ? _display$maxPartySize : params.partySize,
1366
+ reasonCodes: display.reasonCodes || [],
1367
+ requirementGroups: display.requirementGroups || []
1368
+ });
1369
+ return {
1370
+ ok: conflicts.length === 0,
1371
+ status: availability.status,
1372
+ assignments: assignments,
1373
+ conflicts: conflicts,
1374
+ availability: availability
1375
+ };
1376
+ }
1336
1377
  export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1337
1378
  _inherits(UnifiedBookingSalesImpl, _BookingTicket);
1338
1379
  var _super = _createSuper(UnifiedBookingSalesImpl);
@@ -2294,7 +2335,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2294
2335
  startAt: startAt,
2295
2336
  endAt: endAt
2296
2337
  }];
2297
- } catch (_unused5) {
2338
+ } catch (_unused6) {
2298
2339
  throw new AvailabilityError('INVALID_TARGET_FILTER', '记忆时间必须包含有效且递增的开始和结束时间');
2299
2340
  }
2300
2341
  }));
@@ -7001,7 +7042,19 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7001
7042
  return _refreshAvailabilityContextProjection.apply(this, arguments);
7002
7043
  }
7003
7044
  return refreshAvailabilityContextProjection;
7004
- }()
7045
+ }() /** Read an existing customer selection without refreshing its clock or occupancy snapshot. */
7046
+ }, {
7047
+ key: "getCustomerSelectionProjection",
7048
+ value: function getCustomerSelectionProjection(contextId) {
7049
+ var context = this.getAvailabilityContextEntry(contextId);
7050
+ var projectionEntry = this.getActiveAvailabilityProjectionEntry(context);
7051
+ if (!projectionEntry) throw this.createAvailabilityFacadeError('AVAILABILITY_CONTEXT_NOT_FOUND', '所选商品上下文已关闭,请重新打开商品');
7052
+ return {
7053
+ context: context,
7054
+ projectionEntry: projectionEntry,
7055
+ refreshed: false
7056
+ };
7057
+ }
7005
7058
  }, {
7006
7059
  key: "ensureAvailabilityContextProjection",
7007
7060
  value: function () {
@@ -7286,7 +7339,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7286
7339
  startAt: normalizeEndpoint(range.startAt),
7287
7340
  endAt: normalizeEndpoint(range.endAt)
7288
7341
  }];
7289
- } catch (_unused7) {
7342
+ } catch (_unused8) {
7290
7343
  throw new AvailabilityError('INVALID_TARGET_FILTER', '手工预约范围必须包含完整有效起止日期时间');
7291
7344
  }
7292
7345
  })) : undefined; // This new editing input represents an absolute instant. Normalize it once
@@ -7300,7 +7353,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7300
7353
  var scalar = localDateTimeToScalar(parseLocalDateTime(startAt));
7301
7354
  var inputOffset = (_extractFixedOffsetMi5 = extractFixedOffsetMinutes(startAt)) !== null && _extractFixedOffsetMi5 !== void 0 ? _extractFixedOffsetMi5 : editingOffset;
7302
7355
  return [productId, formatLocalDateTime(scalar + (editingOffset - inputOffset) * 60000, editingOffset)];
7303
- } catch (_unused8) {
7356
+ } catch (_unused9) {
7304
7357
  throw new AvailabilityError('INVALID_TARGET_FILTER', '编辑开始时间必须是完整有效日期时间');
7305
7358
  }
7306
7359
  })) : undefined;
@@ -7362,32 +7415,45 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7362
7415
  key: "queryBookingAvailability",
7363
7416
  value: (function () {
7364
7417
  var _queryBookingAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(contextId, request) {
7365
- var _this$otherParams$pla4, _this$otherParams49, _context$prepareParam3;
7366
- var _yield$this$ensureAva2, context, projectionEntry, refreshed, strictAvailability, isPosAvailabilityRequest, rememberedTimeByProductId, queryRequest, result, contextVersion, contextualResult;
7418
+ var _this$otherParams49, _this$otherParams$pla4, _this$otherParams50, _context$prepareParam3;
7419
+ var customerSelectionSnapshot, _ref67, context, projectionEntry, refreshed, strictAvailability, isPosAvailabilityRequest, rememberedTimeByProductId, queryRequest, result, contextVersion, contextualResult;
7367
7420
  return _regeneratorRuntime().wrap(function _callee67$(_context68) {
7368
7421
  while (1) switch (_context68.prev = _context68.next) {
7369
7422
  case 0:
7370
- _context68.next = 2;
7423
+ customerSelectionSnapshot = request.target === 'resource' && request.customerSelectionSnapshot === true && isCustomerUserPlatform((_this$otherParams49 = this.otherParams) === null || _this$otherParams49 === void 0 ? void 0 : _this$otherParams49.platform);
7424
+ if (!customerSelectionSnapshot) {
7425
+ _context68.next = 5;
7426
+ break;
7427
+ }
7428
+ _context68.t0 = this.getCustomerSelectionProjection(contextId);
7429
+ _context68.next = 8;
7430
+ break;
7431
+ case 5:
7432
+ _context68.next = 7;
7371
7433
  return this.ensureAvailabilityContextProjection(contextId, 'query_booking_availability');
7372
- case 2:
7373
- _yield$this$ensureAva2 = _context68.sent;
7374
- context = _yield$this$ensureAva2.context;
7375
- projectionEntry = _yield$this$ensureAva2.projectionEntry;
7376
- refreshed = _yield$this$ensureAva2.refreshed;
7434
+ case 7:
7435
+ _context68.t0 = _context68.sent;
7436
+ case 8:
7437
+ _ref67 = _context68.t0;
7438
+ context = _ref67.context;
7439
+ projectionEntry = _ref67.projectionEntry;
7440
+ refreshed = _ref67.refreshed;
7377
7441
  this.assertContextualQueryFreshness(context, request);
7378
7442
  strictAvailability = context.prepareParams.strictAvailability === true;
7379
- isPosAvailabilityRequest = String((_this$otherParams$pla4 = (_this$otherParams49 = this.otherParams) === null || _this$otherParams49 === void 0 ? void 0 : _this$otherParams49.platform) !== null && _this$otherParams$pla4 !== void 0 ? _this$otherParams$pla4 : '').trim().toLowerCase() === 'pos';
7443
+ isPosAvailabilityRequest = String((_this$otherParams$pla4 = (_this$otherParams50 = this.otherParams) === null || _this$otherParams50 === void 0 ? void 0 : _this$otherParams50.platform) !== null && _this$otherParams$pla4 !== void 0 ? _this$otherParams$pla4 : '').trim().toLowerCase() === 'pos';
7380
7444
  rememberedTimeByProductId = request.selectionIntent === 'remembered' ? this.resolveOrderRememberedTimes(context, projectionEntry.projection, request.rememberedTimeByProductId, request.orderSessionId) : undefined;
7381
7445
  queryRequest = request.target === 'date' || request.target === 'product' ? _objectSpread(_objectSpread({}, request), {}, {
7382
7446
  dateRange: request.dateRange || this.getAvailabilityBusinessDateRange(projectionEntry.projection)
7383
7447
  }) : request;
7384
- result = queryAvailabilityProjection(projectionEntry.projection, queryRequest, {
7448
+ result = queryAvailabilityProjection(projectionEntry.projection, queryRequest, _objectSpread(_objectSpread({}, customerSelectionSnapshot ? {
7449
+ evaluatedAt: projectionEntry.projection.meta.now
7450
+ } : {}), {}, {
7385
7451
  useDurationTimeGrid: this.usesDurationTimeGrid(projectionEntry.projection),
7386
7452
  enforceSaleCutoff: strictAvailability || isPosAvailabilityRequest && !((_context$prepareParam3 = context.prepareParams.editingProductLineUids) !== null && _context$prepareParam3 !== void 0 && _context$prepareParam3.length) && request.selectionIntent === 'remembered',
7387
7453
  rememberedTimeByProductId: rememberedTimeByProductId,
7388
7454
  useExactDurationCandidateMinute: isPosAvailabilityRequest && !strictAvailability,
7389
7455
  allowExcludedScheduleDateOverride: isPosAvailabilityRequest && !strictAvailability
7390
- });
7456
+ }));
7391
7457
  contextVersion = context.activeVersion;
7392
7458
  contextualResult = result.target === 'time' ? _objectSpread(_objectSpread({}, result), {}, {
7393
7459
  data: result.data.map(function (group) {
@@ -7419,7 +7485,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7419
7485
  contextVersion: contextVersion,
7420
7486
  refreshed: refreshed
7421
7487
  }));
7422
- case 15:
7488
+ case 21:
7423
7489
  case "end":
7424
7490
  return _context68.stop();
7425
7491
  }
@@ -7496,9 +7562,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7496
7562
  }, {
7497
7563
  key: "findLinkedBooking",
7498
7564
  value: function findLinkedBooking(product) {
7499
- var _ref67, _product$booking_uid3, _product$metadata7, _this$getTempOrder4;
7565
+ var _ref68, _product$booking_uid3, _product$metadata7, _this$getTempOrder4;
7500
7566
  var productUid = getProductLineUid(product);
7501
- var bookingUid = String((_ref67 = (_product$booking_uid3 = product.booking_uid) !== null && _product$booking_uid3 !== void 0 ? _product$booking_uid3 : (_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.booking_uid) !== null && _ref67 !== void 0 ? _ref67 : '');
7567
+ var bookingUid = String((_ref68 = (_product$booking_uid3 = product.booking_uid) !== null && _product$booking_uid3 !== void 0 ? _product$booking_uid3 : (_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.booking_uid) !== null && _ref68 !== void 0 ? _ref68 : '');
7502
7568
  return (((_this$getTempOrder4 = this.getTempOrder()) === null || _this$getTempOrder4 === void 0 ? void 0 : _this$getTempOrder4.bookings) || []).find(function (booking) {
7503
7569
  var _booking$product_uid3;
7504
7570
  return bookingUid && getBookingUid(booking) === bookingUid || productUid && String((_booking$product_uid3 = booking.product_uid) !== null && _booking$product_uid3 !== void 0 ? _booking$product_uid3 : '') === productUid;
@@ -7509,14 +7575,14 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7509
7575
  value: function () {
7510
7576
  var _removeBookingProductsOutsideStartDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(startDate) {
7511
7577
  var _this$getTempOrder5,
7512
- _this$otherParams50,
7578
+ _this$otherParams51,
7513
7579
  _this28 = this;
7514
7580
  var products, targetDate, identities;
7515
7581
  return _regeneratorRuntime().wrap(function _callee68$(_context69) {
7516
7582
  while (1) switch (_context69.prev = _context69.next) {
7517
7583
  case 0:
7518
7584
  products = ((_this$getTempOrder5 = this.getTempOrder()) === null || _this$getTempOrder5 === void 0 ? void 0 : _this$getTempOrder5.products) || [];
7519
- if (!(((_this$otherParams50 = this.otherParams) === null || _this$otherParams50 === void 0 ? void 0 : _this$otherParams50.enforceSingleBookingStartDate) !== true)) {
7585
+ if (!(((_this$otherParams51 = this.otherParams) === null || _this$otherParams51 === void 0 ? void 0 : _this$otherParams51.enforceSingleBookingStartDate) !== true)) {
7520
7586
  _context69.next = 3;
7521
7587
  break;
7522
7588
  }
@@ -7550,7 +7616,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7550
7616
  return _removeBookingProductsOutsideStartDate.apply(this, arguments);
7551
7617
  }
7552
7618
  return removeBookingProductsOutsideStartDate;
7553
- }() /** Revalidates against the latest landed occupancy cache, then mutates exactly one product line. */
7619
+ }() /** Customer snapshot writes defer availability to checkout; other callers retain cache revalidation. */
7554
7620
  }, {
7555
7621
  key: "commitAvailabilitySelection",
7556
7622
  value: (function () {
@@ -7558,13 +7624,14 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7558
7624
  var _this$availabilityCon,
7559
7625
  _this29 = this,
7560
7626
  _this$otherParams$pla5,
7561
- _this$otherParams51,
7627
+ _this$otherParams52,
7628
+ _this$otherParams53,
7562
7629
  _this$availabilityCon2,
7563
7630
  _params$availabilityC3,
7564
7631
  _params,
7565
7632
  _this$store$order11,
7566
7633
  _this$store$order11$e;
7567
- var normalizedContextId, calendarOrderSessionId, callerGuard, isEditingSelection, isPartyReplacement, isRememberedSelection, isOrderRememberedSelection, strictAvailability, hasCommitGuard, rememberedOrder, getRememberedCommitIdentity, rememberedCommitIdentity, availabilityCommitTargetGuard, guardedCommitPublished, _params$bookingCount, _ref68, _params$orderProduct$, _params$orderProduct, _params$orderProduct2, _params$orderProduct3, _params$orderProduct$2, _params$orderProduct4, _params$orderProduct5, _editingLine$product_, _this$otherParams$pla6, _this$otherParams52, _baseProjection$meta$, _refreshedProjection$, _baseProjection$meta$2, _this$otherParams$pla7, _this$otherParams53, _params$orderProduct$3, _params$orderProduct6, _existingBooking$hold, _existingBooking$meta, _ref69, _params$orderProduct$4, _params$orderProduct7, _params$orderProduct8, _existingBooking$meta2, _existingBooking$meta3, _existingBooking$hold2, _params$orderProduct9, _transformed$metadata, _nextContext$activeVe, bookingCount, orderProductQuantity, partySize, _yield$this$ensureAva3, context, projectionEntry, refreshed, boundEditingUids, orderProductId, editingLine, _editingLine$product_2, baseProjection, selectedProduct, commitWriteGuard, prepareParams, fallbackResources, commitSnapshot, refreshedProjection, _baseProjection$meta$3, latestContext, candidateDurationMinutes, candidateStartTime, allowPosAvailabilityOverride, candidateBusinessDate, rememberedTimeByProductId, refreshedRanges, refreshedCandidateBase, product, validation, forced, capacityConflict, revalidationEntry, revalidatedContext, refreshedCandidate, availabilityCommitGuard, existingBooking, existingBookingUid, booking, legacyBooking, legacyResources, selectedResources, resourceKeys, transformed, productLineUid, bookingUid, productLineUids, bookingUids, relatedRetailProducts, _transformed$product_, _transformed$product_2, _transformed$product_3, _ref70, _transformed$product_4, _this$getTempOrder6, _this$getTempOrder7, _params$salesNotes, _params$salesNotes2, _ref71, beforeProductLineUids, beforeBookingUids, products, addedLines, addedBookings, targetStillCurrent, nextContext, result, emit, release;
7634
+ var normalizedContextId, calendarOrderSessionId, callerGuard, isEditingSelection, isPartyReplacement, isRememberedSelection, isOrderRememberedSelection, customerSelectionSnapshot, strictAvailability, hasCommitGuard, rememberedOrder, getRememberedCommitIdentity, rememberedCommitIdentity, availabilityCommitTargetGuard, guardedCommitPublished, _params$bookingCount, _ref69, _params$orderProduct$, _params$orderProduct, _params$orderProduct2, _params$orderProduct3, _params$orderProduct$2, _params$orderProduct4, _params$orderProduct5, _editingLine$product_, _this$otherParams$pla6, _this$otherParams54, _baseProjection$meta$, _refreshedProjection$, _baseProjection$meta$2, _this$otherParams$pla7, _this$otherParams55, _params$orderProduct$3, _params$orderProduct6, _existingBooking$hold, _existingBooking$meta, _ref71, _params$orderProduct$4, _params$orderProduct7, _params$orderProduct8, _existingBooking$meta2, _existingBooking$meta3, _existingBooking$hold2, _params$orderProduct9, _transformed$metadata, _nextContext$activeVe, bookingCount, orderProductQuantity, partySize, _ref70, context, projectionEntry, refreshed, boundEditingUids, orderProductId, editingLine, _editingLine$product_2, baseProjection, selectedProduct, commitWriteGuard, prepareParams, fallbackResources, commitSnapshot, refreshedProjection, _baseProjection$meta$3, latestContext, candidateDurationMinutes, candidateStartTime, allowPosAvailabilityOverride, candidateBusinessDate, rememberedTimeByProductId, refreshedRanges, refreshedCandidateBase, product, validation, forced, capacityConflict, revalidationEntry, revalidatedContext, refreshedCandidate, availabilityCommitGuard, existingBooking, existingBookingUid, booking, legacyBooking, legacyResources, selectedResources, resourceKeys, transformed, productLineUid, bookingUid, productLineUids, bookingUids, relatedRetailProducts, _transformed$product_, _transformed$product_2, _transformed$product_3, _ref72, _transformed$product_4, editParams, _this$getTempOrder6, _this$getTempOrder7, _params$salesNotes, _params$salesNotes2, _ref73, beforeProductLineUids, beforeBookingUids, products, addedLines, addedBookings, targetStillCurrent, nextContext, result, emit, release;
7568
7635
  return _regeneratorRuntime().wrap(function _callee69$(_context70) {
7569
7636
  while (1) switch (_context70.prev = _context70.next) {
7570
7637
  case 0:
@@ -7599,14 +7666,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7599
7666
  case 9:
7600
7667
  isRememberedSelection = params.selectionIntent === 'remembered';
7601
7668
  isOrderRememberedSelection = isRememberedSelection && params.orderSessionId !== undefined;
7602
- if (!(isRememberedSelection && (String((_this$otherParams$pla5 = (_this$otherParams51 = this.otherParams) === null || _this$otherParams51 === void 0 ? void 0 : _this$otherParams51.platform) !== null && _this$otherParams$pla5 !== void 0 ? _this$otherParams$pla5 : '').trim().toLowerCase() !== 'pos' || params.mode !== 'add'))) {
7669
+ if (!(isRememberedSelection && (String((_this$otherParams$pla5 = (_this$otherParams52 = this.otherParams) === null || _this$otherParams52 === void 0 ? void 0 : _this$otherParams52.platform) !== null && _this$otherParams$pla5 !== void 0 ? _this$otherParams$pla5 : '').trim().toLowerCase() !== 'pos' || params.mode !== 'add'))) {
7603
7670
  _context70.next = 13;
7604
7671
  break;
7605
7672
  }
7606
7673
  throw new AvailabilityError('INVALID_TARGET_FILTER', '记忆时间自动提交仅支持 POS 新增 duration 商品');
7607
7674
  case 13:
7675
+ customerSelectionSnapshot = params.customerSelectionSnapshot === true && isCustomerUserPlatform((_this$otherParams53 = this.otherParams) === null || _this$otherParams53 === void 0 ? void 0 : _this$otherParams53.platform);
7608
7676
  strictAvailability = ((_this$availabilityCon2 = this.availabilityContextRegistry.get(normalizedContextId)) === null || _this$availabilityCon2 === void 0 ? void 0 : _this$availabilityCon2.prepareParams.strictAvailability) === true;
7609
- hasCommitGuard = strictAvailability || isRememberedSelection || isPartyReplacement || Boolean(params.availabilityCommitGuard);
7677
+ hasCommitGuard = customerSelectionSnapshot || strictAvailability || isRememberedSelection || isPartyReplacement || Boolean(params.availabilityCommitGuard);
7610
7678
  (_params$availabilityC3 = (_params = params).availabilityCommitGuard) === null || _params$availabilityC3 === void 0 || _params$availabilityC3.call(_params);
7611
7679
  // Stabilize the locally generated sale identity before taking the guard snapshot.
7612
7680
  if (hasCommitGuard) (_this$store$order11 = this.store.order) === null || _this$store$order11 === void 0 || (_this$store$order11$e = _this$store$order11.ensureTempOrder) === null || _this$store$order11$e === void 0 || _this$store$order11$e.call(_this$store$order11);
@@ -7630,55 +7698,65 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7630
7698
  return (isOrderRememberedSelection ? _this29.isOrderSessionCurrent(params.orderSessionId) : _this29.getTempOrder() === rememberedOrder) && getRememberedCommitIdentity() === rememberedCommitIdentity;
7631
7699
  };
7632
7700
  guardedCommitPublished = false;
7633
- _context70.next = 25;
7701
+ _context70.next = 26;
7634
7702
  return this.tryAcquireAvailabilityCommitLock(normalizedContextId);
7635
- case 25:
7636
- _context70.prev = 25;
7703
+ case 26:
7704
+ _context70.prev = 26;
7637
7705
  bookingCount = Number((_params$bookingCount = params.bookingCount) !== null && _params$bookingCount !== void 0 ? _params$bookingCount : 1);
7638
7706
  if (!(!Number.isInteger(bookingCount) || bookingCount <= 0)) {
7639
- _context70.next = 29;
7707
+ _context70.next = 30;
7640
7708
  break;
7641
7709
  }
7642
7710
  throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', 'bookingCount 必须是正整数', {
7643
7711
  bookingCount: params.bookingCount
7644
7712
  });
7645
- case 29:
7713
+ case 30:
7646
7714
  if (!(isEditingSelection && bookingCount !== 1)) {
7647
- _context70.next = 31;
7715
+ _context70.next = 32;
7648
7716
  break;
7649
7717
  }
7650
7718
  throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', '编辑预约商品时 bookingCount 必须为 1', {
7651
7719
  bookingCount: bookingCount
7652
7720
  });
7653
- case 31:
7654
- orderProductQuantity = (_ref68 = (_params$orderProduct$ = (_params$orderProduct = params.orderProduct) === null || _params$orderProduct === void 0 ? void 0 : _params$orderProduct.num) !== null && _params$orderProduct$ !== void 0 ? _params$orderProduct$ : (_params$orderProduct2 = params.orderProduct) === null || _params$orderProduct2 === void 0 ? void 0 : _params$orderProduct2.quantity) !== null && _ref68 !== void 0 ? _ref68 : (_params$orderProduct3 = params.orderProduct) === null || _params$orderProduct3 === void 0 || (_params$orderProduct3 = _params$orderProduct3._extend) === null || _params$orderProduct3 === void 0 ? void 0 : _params$orderProduct3.quantity;
7721
+ case 32:
7722
+ orderProductQuantity = (_ref69 = (_params$orderProduct$ = (_params$orderProduct = params.orderProduct) === null || _params$orderProduct === void 0 ? void 0 : _params$orderProduct.num) !== null && _params$orderProduct$ !== void 0 ? _params$orderProduct$ : (_params$orderProduct2 = params.orderProduct) === null || _params$orderProduct2 === void 0 ? void 0 : _params$orderProduct2.quantity) !== null && _ref69 !== void 0 ? _ref69 : (_params$orderProduct3 = params.orderProduct) === null || _params$orderProduct3 === void 0 || (_params$orderProduct3 = _params$orderProduct3._extend) === null || _params$orderProduct3 === void 0 ? void 0 : _params$orderProduct3.quantity;
7655
7723
  if (!(orderProductQuantity !== undefined && orderProductQuantity !== null && Number(orderProductQuantity) !== bookingCount)) {
7656
- _context70.next = 34;
7724
+ _context70.next = 35;
7657
7725
  break;
7658
7726
  }
7659
7727
  throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', 'orderProduct 数量与 bookingCount 不一致', {
7660
7728
  bookingCount: bookingCount,
7661
7729
  orderProductQuantity: orderProductQuantity
7662
7730
  });
7663
- case 34:
7731
+ case 35:
7664
7732
  partySize = Number(params.partySize);
7665
7733
  if (!(!Number.isInteger(partySize) || partySize <= 0)) {
7666
- _context70.next = 37;
7734
+ _context70.next = 38;
7667
7735
  break;
7668
7736
  }
7669
7737
  throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', 'partySize 必须是正整数', {
7670
7738
  partySize: params.partySize
7671
7739
  });
7672
- case 37:
7673
- _context70.next = 39;
7740
+ case 38:
7741
+ if (!customerSelectionSnapshot) {
7742
+ _context70.next = 42;
7743
+ break;
7744
+ }
7745
+ _context70.t0 = this.getCustomerSelectionProjection(normalizedContextId);
7746
+ _context70.next = 45;
7747
+ break;
7748
+ case 42:
7749
+ _context70.next = 44;
7674
7750
  return this.ensureAvailabilityContextProjection(normalizedContextId, 'commit_precheck');
7675
- case 39:
7676
- _yield$this$ensureAva3 = _context70.sent;
7677
- context = _yield$this$ensureAva3.context;
7678
- projectionEntry = _yield$this$ensureAva3.projectionEntry;
7679
- refreshed = _yield$this$ensureAva3.refreshed;
7751
+ case 44:
7752
+ _context70.t0 = _context70.sent;
7753
+ case 45:
7754
+ _ref70 = _context70.t0;
7755
+ context = _ref70.context;
7756
+ projectionEntry = _ref70.projectionEntry;
7757
+ refreshed = _ref70.refreshed;
7680
7758
  if (!refreshed) {
7681
- _context70.next = 45;
7759
+ _context70.next = 51;
7682
7760
  break;
7683
7761
  }
7684
7762
  throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'availability context 已刷新,请重新获取候选', {
@@ -7686,14 +7764,14 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7686
7764
  currentContextVersion: context.activeVersion,
7687
7765
  candidateContextVersion: params.candidate.availabilityContextVersion
7688
7766
  });
7689
- case 45:
7767
+ case 51:
7690
7768
  boundEditingUids = context.prepareParams.editingProductLineUids || [];
7691
7769
  if (!isEditingSelection) {
7692
- _context70.next = 51;
7770
+ _context70.next = 57;
7693
7771
  break;
7694
7772
  }
7695
7773
  if (!(!params.productLineUid || !boundEditingUids.includes(String(params.productLineUid)))) {
7696
- _context70.next = 49;
7774
+ _context70.next = 55;
7697
7775
  break;
7698
7776
  }
7699
7777
  throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'edit context 与当前商品行不匹配,请重新 prepare 编辑上下文', {
@@ -7701,21 +7779,21 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7701
7779
  productLineUid: params.productLineUid,
7702
7780
  editingProductLineUids: boundEditingUids
7703
7781
  });
7704
- case 49:
7705
- _context70.next = 53;
7782
+ case 55:
7783
+ _context70.next = 59;
7706
7784
  break;
7707
- case 51:
7785
+ case 57:
7708
7786
  if (!(boundEditingUids.length > 0)) {
7709
- _context70.next = 53;
7787
+ _context70.next = 59;
7710
7788
  break;
7711
7789
  }
7712
7790
  throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'edit context 不能用于 add,请重新 prepare 新增上下文', {
7713
7791
  contextId: normalizedContextId,
7714
7792
  editingProductLineUids: boundEditingUids
7715
7793
  });
7716
- case 53:
7794
+ case 59:
7717
7795
  if (!(projectionEntry.contextVersion !== context.activeVersion)) {
7718
- _context70.next = 55;
7796
+ _context70.next = 61;
7719
7797
  break;
7720
7798
  }
7721
7799
  throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'availability context 已刷新,请重新获取候选', {
@@ -7723,9 +7801,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7723
7801
  currentContextVersion: context.activeVersion,
7724
7802
  projectionContextVersion: projectionEntry.contextVersion
7725
7803
  });
7726
- case 55:
7727
- if (!(projectionEntry.orderRevision !== this.getCurrentOrderRevision())) {
7728
- _context70.next = 57;
7804
+ case 61:
7805
+ if (!(!customerSelectionSnapshot && projectionEntry.orderRevision !== this.getCurrentOrderRevision())) {
7806
+ _context70.next = 63;
7729
7807
  break;
7730
7808
  }
7731
7809
  throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', '购物车已变化,请重新获取候选', {
@@ -7734,9 +7812,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7734
7812
  projectionOrderRevision: projectionEntry.orderRevision,
7735
7813
  currentOrderRevision: this.getCurrentOrderRevision()
7736
7814
  });
7737
- case 57:
7815
+ case 63:
7738
7816
  if (!(projectionEntry.contextVersion !== params.candidate.availabilityContextVersion)) {
7739
- _context70.next = 59;
7817
+ _context70.next = 65;
7740
7818
  break;
7741
7819
  }
7742
7820
  throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', '候选已过期,请重新获取最新时间段', {
@@ -7744,35 +7822,35 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7744
7822
  candidateContextVersion: params.candidate.availabilityContextVersion,
7745
7823
  currentContextVersion: context.activeVersion
7746
7824
  });
7747
- case 59:
7825
+ case 65:
7748
7826
  this.assertAvailabilityCandidateFreshness(context, params.candidate);
7749
7827
  orderProductId = (_params$orderProduct$2 = (_params$orderProduct4 = params.orderProduct) === null || _params$orderProduct4 === void 0 ? void 0 : _params$orderProduct4.product_id) !== null && _params$orderProduct$2 !== void 0 ? _params$orderProduct$2 : (_params$orderProduct5 = params.orderProduct) === null || _params$orderProduct5 === void 0 ? void 0 : _params$orderProduct5.id;
7750
7828
  if (sameAvailabilityId(orderProductId, params.candidate.productId)) {
7751
- _context70.next = 63;
7829
+ _context70.next = 69;
7752
7830
  break;
7753
7831
  }
7754
7832
  throw new AvailabilityError('INVALID_TARGET_FILTER', 'orderProduct 与 candidate 商品不一致', {
7755
7833
  orderProductId: orderProductId,
7756
7834
  candidateProductId: params.candidate.productId
7757
7835
  });
7758
- case 63:
7836
+ case 69:
7759
7837
  if (!(isEditingSelection && !params.productLineUid)) {
7760
- _context70.next = 65;
7838
+ _context70.next = 71;
7761
7839
  break;
7762
7840
  }
7763
7841
  throw new AvailabilityError('PRODUCT_LINE_NOT_FOUND', 'edit 模式必须提供 productLineUid');
7764
- case 65:
7842
+ case 71:
7765
7843
  editingLine = isEditingSelection ? this.findProductLineByUid(String(params.productLineUid)) : undefined;
7766
7844
  if (!(isEditingSelection && !editingLine)) {
7767
- _context70.next = 68;
7845
+ _context70.next = 74;
7768
7846
  break;
7769
7847
  }
7770
7848
  throw new AvailabilityError('PRODUCT_LINE_NOT_FOUND', '找不到要编辑的预约商品行', {
7771
7849
  productLineUid: params.productLineUid
7772
7850
  });
7773
- case 68:
7851
+ case 74:
7774
7852
  if (!(editingLine && params.mode !== 'replace' && !sameAvailabilityId((_editingLine$product_ = editingLine.product_id) !== null && _editingLine$product_ !== void 0 ? _editingLine$product_ : editingLine.id, params.candidate.productId))) {
7775
- _context70.next = 70;
7853
+ _context70.next = 76;
7776
7854
  break;
7777
7855
  }
7778
7856
  throw new AvailabilityError('INVALID_TARGET_FILTER', '编辑商品行与 candidate 商品不一致', {
@@ -7780,47 +7858,59 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7780
7858
  productLineProductId: (_editingLine$product_2 = editingLine.product_id) !== null && _editingLine$product_2 !== void 0 ? _editingLine$product_2 : editingLine.id,
7781
7859
  candidateProductId: params.candidate.productId
7782
7860
  });
7783
- case 70:
7861
+ case 76:
7784
7862
  if (Array.isArray(params.requirementSelections)) {
7785
- _context70.next = 72;
7863
+ _context70.next = 78;
7786
7864
  break;
7787
7865
  }
7788
7866
  throw new AvailabilityError('INVALID_TARGET_FILTER', 'requirementSelections 必须是数组', {
7789
7867
  requirementSelections: params.requirementSelections
7790
7868
  });
7791
- case 72:
7869
+ case 78:
7792
7870
  baseProjection = projectionEntry.projection;
7793
7871
  selectedProduct = baseProjection.products.find(function (item) {
7794
7872
  return sameAvailabilityId(item.id, params.candidate.productId);
7795
7873
  });
7796
- if (!(isRememberedSelection && (String((_this$otherParams$pla6 = (_this$otherParams52 = this.otherParams) === null || _this$otherParams52 === void 0 ? void 0 : _this$otherParams52.platform) !== null && _this$otherParams$pla6 !== void 0 ? _this$otherParams$pla6 : '').trim().toLowerCase() !== 'pos' || params.mode !== 'add' || (selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.kind) !== 'duration'))) {
7797
- _context70.next = 76;
7874
+ if (!(isRememberedSelection && (String((_this$otherParams$pla6 = (_this$otherParams54 = this.otherParams) === null || _this$otherParams54 === void 0 ? void 0 : _this$otherParams54.platform) !== null && _this$otherParams$pla6 !== void 0 ? _this$otherParams$pla6 : '').trim().toLowerCase() !== 'pos' || params.mode !== 'add' || (selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.kind) !== 'duration'))) {
7875
+ _context70.next = 82;
7798
7876
  break;
7799
7877
  }
7800
7878
  throw new AvailabilityError('INVALID_TARGET_FILTER', '记忆时间自动提交仅支持 POS 新增 duration 商品');
7801
- case 76:
7879
+ case 82:
7802
7880
  commitWriteGuard = {
7803
7881
  contextId: normalizedContextId,
7804
7882
  expectedVersion: context.activeVersion,
7805
7883
  expectedRefreshNonce: context.refreshNonce,
7806
7884
  expectedLifecycleGeneration: this.availabilityLifecycleGeneration,
7807
- expectedOrderRevision: String((_baseProjection$meta$ = baseProjection.meta.orderRevision) !== null && _baseProjection$meta$ !== void 0 ? _baseProjection$meta$ : '')
7885
+ expectedOrderRevision: customerSelectionSnapshot ? this.getCurrentOrderRevision() : String((_baseProjection$meta$ = baseProjection.meta.orderRevision) !== null && _baseProjection$meta$ !== void 0 ? _baseProjection$meta$ : '')
7808
7886
  };
7809
7887
  prepareParams = baseProjection.meta.prepareParams;
7810
7888
  if (prepareParams) {
7811
- _context70.next = 80;
7889
+ _context70.next = 86;
7812
7890
  break;
7813
7891
  }
7814
7892
  throw new AvailabilityError('REVALIDATION_FAILED', 'projection 缺少 prepareParams,无法执行缓存重校验');
7815
- case 80:
7816
- fallbackResources = {
7893
+ case 86:
7894
+ fallbackResources = customerSelectionSnapshot ? undefined : {
7817
7895
  resources: cloneDeep(_toConsumableArray(baseProjection.resources || [])),
7818
7896
  resourceOccupancies: cloneDeep(_toConsumableArray(baseProjection.resourceOccupancies || []).filter(function (occupancy) {
7819
7897
  return occupancy.source !== 'cart';
7820
7898
  })),
7821
7899
  includesInjectedRawOccupancies: true
7822
7900
  };
7823
- _context70.next = 83;
7901
+ if (!customerSelectionSnapshot) {
7902
+ _context70.next = 91;
7903
+ break;
7904
+ }
7905
+ _context70.t1 = {
7906
+ projection: baseProjection,
7907
+ prepareParams: prepareParams,
7908
+ orderRevision: commitWriteGuard.expectedOrderRevision
7909
+ };
7910
+ _context70.next = 94;
7911
+ break;
7912
+ case 91:
7913
+ _context70.next = 93;
7824
7914
  return this.buildAvailabilityProjectionSnapshot(_objectSpread(_objectSpread({}, this.cloneAvailabilityPrepareParams(prepareParams)), {}, {
7825
7915
  editingProductLineUids: isEditingSelection && params.productLineUid ? [params.productLineUid] : []
7826
7916
  }), {
@@ -7828,20 +7918,22 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7828
7918
  fallbackResources: fallbackResources,
7829
7919
  durationCandidateAnchorAt: this.getAvailabilityDurationCandidateAnchorAt(baseProjection) || context.durationCandidateAnchorAt
7830
7920
  });
7831
- case 83:
7832
- commitSnapshot = _context70.sent;
7921
+ case 93:
7922
+ _context70.t1 = _context70.sent;
7923
+ case 94:
7924
+ commitSnapshot = _context70.t1;
7833
7925
  refreshedProjection = commitSnapshot.projection;
7834
- if (!(String((_refreshedProjection$ = refreshedProjection.meta.orderRevision) !== null && _refreshedProjection$ !== void 0 ? _refreshedProjection$ : '') !== String((_baseProjection$meta$2 = baseProjection.meta.orderRevision) !== null && _baseProjection$meta$2 !== void 0 ? _baseProjection$meta$2 : ''))) {
7835
- _context70.next = 90;
7926
+ if (!(!customerSelectionSnapshot && String((_refreshedProjection$ = refreshedProjection.meta.orderRevision) !== null && _refreshedProjection$ !== void 0 ? _refreshedProjection$ : '') !== String((_baseProjection$meta$2 = baseProjection.meta.orderRevision) !== null && _baseProjection$meta$2 !== void 0 ? _baseProjection$meta$2 : ''))) {
7927
+ _context70.next = 101;
7836
7928
  break;
7837
7929
  }
7838
- _context70.next = 88;
7930
+ _context70.next = 99;
7839
7931
  return this.refreshAvailabilityContextProjection({
7840
7932
  contextId: normalizedContextId,
7841
7933
  reason: 'commit_order_revision_changed',
7842
7934
  previousOrderRevision: String((_baseProjection$meta$3 = baseProjection.meta.orderRevision) !== null && _baseProjection$meta$3 !== void 0 ? _baseProjection$meta$3 : '')
7843
7935
  });
7844
- case 88:
7936
+ case 99:
7845
7937
  latestContext = this.getAvailabilityContextEntry(normalizedContextId);
7846
7938
  throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', '最终缓存重校验期间购物车已变化,请重新获取候选', {
7847
7939
  contextId: normalizedContextId,
@@ -7852,17 +7944,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7852
7944
  snapshotId: baseProjection.meta.snapshotId,
7853
7945
  refreshedSnapshotId: refreshedProjection.meta.snapshotId
7854
7946
  });
7855
- case 90:
7947
+ case 101:
7856
7948
  this.assertAvailabilityCommitWriteCAS(commitWriteGuard);
7857
7949
  candidateDurationMinutes = getCandidateDurationMinutes(params.candidate);
7858
7950
  candidateStartTime = getCandidateStartTime(params.candidate);
7859
- allowPosAvailabilityOverride = String((_this$otherParams$pla7 = (_this$otherParams53 = this.otherParams) === null || _this$otherParams53 === void 0 ? void 0 : _this$otherParams53.platform) !== null && _this$otherParams$pla7 !== void 0 ? _this$otherParams$pla7 : '').trim().toLowerCase() === 'pos' && !isRememberedSelection && !strictAvailability;
7951
+ allowPosAvailabilityOverride = String((_this$otherParams$pla7 = (_this$otherParams55 = this.otherParams) === null || _this$otherParams55 === void 0 ? void 0 : _this$otherParams55.platform) !== null && _this$otherParams$pla7 !== void 0 ? _this$otherParams$pla7 : '').trim().toLowerCase() === 'pos' && !isRememberedSelection && !strictAvailability;
7860
7952
  candidateBusinessDate = params.candidate.businessDate || ((selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.kind) === 'duration' && this.usesDurationTimeGrid(refreshedProjection) ? getDurationBusinessDate(refreshedProjection, params.candidate.startAt) : params.candidate.startAt.slice(0, 10));
7861
7953
  rememberedTimeByProductId = isOrderRememberedSelection ? this.resolveOrderRememberedTimes(context, refreshedProjection, _defineProperty({}, String(params.candidate.productId), {
7862
7954
  startAt: params.candidate.bookingStartAt,
7863
7955
  endAt: params.candidate.bookingEndAt
7864
7956
  }), params.orderSessionId) : undefined;
7865
- refreshedRanges = getProjectionProductTimeRanges(refreshedProjection, _objectSpread(_objectSpread({
7957
+ refreshedRanges = customerSelectionSnapshot ? [params.candidate] : getProjectionProductTimeRanges(refreshedProjection, _objectSpread(_objectSpread({
7866
7958
  productIds: [params.candidate.productId],
7867
7959
  dateRange: {
7868
7960
  startDate: candidateBusinessDate,
@@ -7903,7 +7995,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7903
7995
  return candidate.startAt === params.candidate.startAt && candidate.endAt === params.candidate.endAt && candidate.bookingStartAt === params.candidate.bookingStartAt && candidate.bookingEndAt === params.candidate.bookingEndAt;
7904
7996
  });
7905
7997
  if (refreshedCandidateBase) {
7906
- _context70.next = 100;
7998
+ _context70.next = 111;
7907
7999
  break;
7908
8000
  }
7909
8001
  throw new AvailabilityError('REVALIDATION_FAILED', '缓存重校验后候选时间已不在商品配置中', {
@@ -7911,19 +8003,25 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7911
8003
  candidate: params.candidate,
7912
8004
  refreshedSnapshotId: refreshedProjection.meta.snapshotId
7913
8005
  });
7914
- case 100:
8006
+ case 111:
7915
8007
  product = refreshedProjection.products.find(function (item) {
7916
8008
  return sameAvailabilityId(item.id, refreshedCandidateBase.productId);
7917
8009
  });
7918
8010
  if (product) {
7919
- _context70.next = 103;
8011
+ _context70.next = 114;
7920
8012
  break;
7921
8013
  }
7922
8014
  throw new AvailabilityError('REVALIDATION_FAILED', '缓存重校验后商品不在 projection 中', {
7923
8015
  productId: refreshedCandidateBase.productId
7924
8016
  });
7925
- case 103:
7926
- validation = validateAvailabilitySelection(refreshedProjection, {
8017
+ case 114:
8018
+ validation = customerSelectionSnapshot ? acceptCustomerSelectionSnapshot({
8019
+ candidate: params.candidate,
8020
+ product: product,
8021
+ resources: baseProjection.resources,
8022
+ requirementSelections: params.requirementSelections,
8023
+ partySize: partySize
8024
+ }) : validateAvailabilitySelection(refreshedProjection, {
7927
8025
  candidate: refreshedCandidateBase,
7928
8026
  requirementSelections: params.requirementSelections,
7929
8027
  partySize: partySize,
@@ -7956,7 +8054,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7956
8054
  });
7957
8055
  }
7958
8056
  if (validation.ok) {
7959
- _context70.next = 108;
8057
+ _context70.next = 119;
7960
8058
  break;
7961
8059
  }
7962
8060
  capacityConflict = validation.conflicts.find(function (conflict) {
@@ -7966,11 +8064,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7966
8064
  validation: validation,
7967
8065
  refreshedSnapshotId: refreshedProjection.meta.snapshotId
7968
8066
  });
7969
- case 108:
8067
+ case 119:
7970
8068
  // Revalidation failure must leave the caller's candidate reusable. Only publish the
7971
8069
  // refreshed projection/version after candidate and resource validation has passed;
7972
8070
  // otherwise a second Confirm from the still-open modal would incorrectly become stale.
7973
- revalidationEntry = this.storeAvailabilityProjectionEntry({
8071
+ revalidationEntry = customerSelectionSnapshot ? projectionEntry : this.storeAvailabilityProjectionEntry({
7974
8072
  contextId: normalizedContextId,
7975
8073
  prepareParams: commitSnapshot.prepareParams,
7976
8074
  prepareKey: context.prepareKey,
@@ -7979,7 +8077,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7979
8077
  incrementVersion: true
7980
8078
  });
7981
8079
  revalidatedContext = this.getAvailabilityContextEntry(normalizedContextId);
7982
- _context70.next = 112;
8080
+ if (customerSelectionSnapshot) {
8081
+ _context70.next = 124;
8082
+ break;
8083
+ }
8084
+ _context70.next = 124;
7983
8085
  return this.emitAvailabilityDiagnostic({
7984
8086
  action: 'refresh',
7985
8087
  contextId: normalizedContextId,
@@ -7990,13 +8092,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7990
8092
  previousOrderRevision: baseProjection.meta.orderRevision,
7991
8093
  reason: 'commit_cached_occupancy_revalidation'
7992
8094
  });
7993
- case 112:
8095
+ case 124:
7994
8096
  commitWriteGuard = {
7995
8097
  contextId: normalizedContextId,
7996
8098
  expectedVersion: revalidatedContext.activeVersion,
7997
8099
  expectedRefreshNonce: revalidatedContext.refreshNonce,
7998
8100
  expectedLifecycleGeneration: this.availabilityLifecycleGeneration,
7999
- expectedOrderRevision: revalidationEntry.orderRevision
8101
+ expectedOrderRevision: customerSelectionSnapshot ? commitWriteGuard.expectedOrderRevision : revalidationEntry.orderRevision
8000
8102
  };
8001
8103
  refreshedCandidate = this.decorateAvailabilityCandidate(normalizedContextId, revalidatedContext.activeVersion, refreshedCandidateBase); // Order may await line/runtime setup. Its guarded transaction invokes this
8002
8104
  // again immediately before publishing, while the live cart is unchanged.
@@ -8010,7 +8112,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
8010
8112
  // Same-order immutable snapshots and generated sale IDs preserve the session.
8011
8113
  // Capture the actual object Order is about to publish, not an earlier snapshot.
8012
8114
  if (isOrderRememberedSelection) rememberedOrder = _this29.getTempOrder();
8013
- if (!isRememberedSelection && !strictAvailability) return;
8115
+ if (customerSelectionSnapshot || !isRememberedSelection && !strictAvailability) return;
8014
8116
  var currentValidation = validateAvailabilitySelection(refreshedProjection, {
8015
8117
  candidate: refreshedCandidateBase,
8016
8118
  requirementSelections: params.requirementSelections,
@@ -8030,13 +8132,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
8030
8132
  existingBooking = editingLine ? this.findLinkedBooking(editingLine) : undefined;
8031
8133
  existingBookingUid = existingBooking ? getBookingUid(existingBooking) : '';
8032
8134
  if (!(isEditingSelection && !existingBookingUid)) {
8033
- _context70.next = 119;
8135
+ _context70.next = 131;
8034
8136
  break;
8035
8137
  }
8036
8138
  throw new AvailabilityError('PRODUCT_LINE_NOT_FOUND', '编辑商品行缺少关联 booking', {
8037
8139
  productLineUid: params.productLineUid
8038
8140
  });
8039
- case 119:
8141
+ case 131:
8040
8142
  this.assertAvailabilityCommitWriteCAS(commitWriteGuard);
8041
8143
  booking = buildBookingFromAvailabilitySelection({
8042
8144
  assignments: validation.assignments,
@@ -8045,7 +8147,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
8045
8147
  resources: refreshedProjection.resources,
8046
8148
  bookingUid: existingBookingUid || undefined,
8047
8149
  holder: (_params$orderProduct$3 = (_params$orderProduct6 = params.orderProduct) === null || _params$orderProduct6 === void 0 || (_params$orderProduct6 = _params$orderProduct6._extend) === null || _params$orderProduct6 === void 0 ? void 0 : _params$orderProduct6.holder) !== null && _params$orderProduct$3 !== void 0 ? _params$orderProduct$3 : params.mode === 'replace' ? undefined : (_existingBooking$hold = existingBooking === null || existingBooking === void 0 ? void 0 : existingBooking.holder) !== null && _existingBooking$hold !== void 0 ? _existingBooking$hold : existingBooking === null || existingBooking === void 0 || (_existingBooking$meta = existingBooking.metadata) === null || _existingBooking$meta === void 0 ? void 0 : _existingBooking$meta.holder,
8048
- holderIds: (_ref69 = (_params$orderProduct$4 = (_params$orderProduct7 = params.orderProduct) === null || _params$orderProduct7 === void 0 || (_params$orderProduct7 = _params$orderProduct7._extend) === null || _params$orderProduct7 === void 0 ? void 0 : _params$orderProduct7.holder_id) !== null && _params$orderProduct$4 !== void 0 ? _params$orderProduct$4 : (_params$orderProduct8 = params.orderProduct) === null || _params$orderProduct8 === void 0 || (_params$orderProduct8 = _params$orderProduct8._extend) === null || _params$orderProduct8 === void 0 || (_params$orderProduct8 = _params$orderProduct8.holder) === null || _params$orderProduct8 === void 0 ? void 0 : _params$orderProduct8.form_record) !== null && _ref69 !== void 0 ? _ref69 : params.mode === 'replace' ? undefined : (_existingBooking$meta2 = existingBooking === null || existingBooking === void 0 || (_existingBooking$meta3 = existingBooking.metadata) === null || _existingBooking$meta3 === void 0 ? void 0 : _existingBooking$meta3.holder_id) !== null && _existingBooking$meta2 !== void 0 ? _existingBooking$meta2 : existingBooking === null || existingBooking === void 0 || (_existingBooking$hold2 = existingBooking.holder) === null || _existingBooking$hold2 === void 0 ? void 0 : _existingBooking$hold2.form_record
8150
+ holderIds: (_ref71 = (_params$orderProduct$4 = (_params$orderProduct7 = params.orderProduct) === null || _params$orderProduct7 === void 0 || (_params$orderProduct7 = _params$orderProduct7._extend) === null || _params$orderProduct7 === void 0 ? void 0 : _params$orderProduct7.holder_id) !== null && _params$orderProduct$4 !== void 0 ? _params$orderProduct$4 : (_params$orderProduct8 = params.orderProduct) === null || _params$orderProduct8 === void 0 || (_params$orderProduct8 = _params$orderProduct8._extend) === null || _params$orderProduct8 === void 0 || (_params$orderProduct8 = _params$orderProduct8.holder) === null || _params$orderProduct8 === void 0 ? void 0 : _params$orderProduct8.form_record) !== null && _ref71 !== void 0 ? _ref71 : params.mode === 'replace' ? undefined : (_existingBooking$meta2 = existingBooking === null || existingBooking === void 0 || (_existingBooking$meta3 = existingBooking.metadata) === null || _existingBooking$meta3 === void 0 ? void 0 : _existingBooking$meta3.holder_id) !== null && _existingBooking$meta2 !== void 0 ? _existingBooking$meta2 : existingBooking === null || existingBooking === void 0 || (_existingBooking$hold2 = existingBooking.holder) === null || _existingBooking$hold2 === void 0 ? void 0 : _existingBooking$hold2.form_record
8049
8151
  });
8050
8152
  if (params.mode === 'replace') {
8051
8153
  // A different product must not inherit the previous product/resource's completed forms.
@@ -8053,7 +8155,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
8053
8155
  booking.relation_forms = [];
8054
8156
  }
8055
8157
  if (!(isRememberedSelection && (_params$orderProduct9 = params.orderProduct) !== null && _params$orderProduct9 !== void 0 && (_params$orderProduct9 = _params$orderProduct9._extend) !== null && _params$orderProduct9 !== void 0 && _params$orderProduct9.resource)) {
8056
- _context70.next = 130;
8158
+ _context70.next = 142;
8057
8159
  break;
8058
8160
  }
8059
8161
  // AutoClose 与编辑共用旧资源协议。仅复用其结构,实际资源及每份容量
@@ -8073,30 +8175,30 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
8073
8175
  return sameAvailabilityId(selected.form_id, resource.form_id);
8074
8176
  });
8075
8177
  }))) {
8076
- _context70.next = 129;
8178
+ _context70.next = 141;
8077
8179
  break;
8078
8180
  }
8079
8181
  throw new AvailabilityError('REVALIDATION_FAILED', '记忆时间的资源与本次校验结果不一致');
8080
- case 129:
8182
+ case 141:
8081
8183
  Object.assign(booking, {
8082
8184
  relation_id: legacyBooking.relation_id,
8083
8185
  form_id: legacyBooking.form_id,
8084
8186
  relation_type: legacyBooking.relation_type,
8085
8187
  resources: cloneDeep(legacyResources)
8086
8188
  });
8087
- case 130:
8189
+ case 142:
8088
8190
  transformed = this.buildUnifiedOrderProduct(_objectSpread(_objectSpread({}, params.orderProduct), {}, {
8089
8191
  num: bookingCount,
8090
8192
  quantity: bookingCount
8091
8193
  }), 'unified_booking_sales', product);
8092
8194
  if (transformed) {
8093
- _context70.next = 133;
8195
+ _context70.next = 145;
8094
8196
  break;
8095
8197
  }
8096
8198
  throw new AvailabilityError('INVALID_TARGET_FILTER', 'orderProduct 无法转换为订单行', {
8097
8199
  orderProduct: params.orderProduct
8098
8200
  });
8099
- case 133:
8201
+ case 145:
8100
8202
  transformed.num = bookingCount;
8101
8203
  transformed.metadata = _objectSpread(_objectSpread({}, transformed.metadata || {}), {}, {
8102
8204
  unified_booking_sales: true,
@@ -8111,7 +8213,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
8111
8213
  productLineUids = [];
8112
8214
  bookingUids = [];
8113
8215
  if (!(isPartyReplacement && editingLine && params.productLineUid)) {
8114
- _context70.next = 150;
8216
+ _context70.next = 162;
8115
8217
  break;
8116
8218
  }
8117
8219
  relatedRetailProducts = params.relatedRetailProducts.map(function (source) {
@@ -8126,7 +8228,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
8126
8228
  }
8127
8229
  return line;
8128
8230
  });
8129
- _context70.next = 143;
8231
+ _context70.next = 155;
8130
8232
  return this.store.order.replaceBookingProductWithRelatedRetail({
8131
8233
  productLineUid: params.productLineUid,
8132
8234
  product: transformed,
@@ -8135,17 +8237,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
8135
8237
  availabilityCommitGuard: availabilityCommitGuard,
8136
8238
  availabilityCommitTargetGuard: availabilityCommitTargetGuard
8137
8239
  });
8138
- case 143:
8240
+ case 155:
8139
8241
  guardedCommitPublished = true;
8140
8242
  productLineUid = params.productLineUid;
8141
8243
  bookingUid = existingBookingUid;
8142
8244
  productLineUids = [productLineUid];
8143
8245
  bookingUids = [bookingUid];
8144
- _context70.next = 183;
8246
+ _context70.next = 202;
8145
8247
  break;
8146
- case 150:
8248
+ case 162:
8147
8249
  if (!(params.mode === 'edit' && editingLine && params.productLineUid)) {
8148
- _context70.next = 165;
8250
+ _context70.next = 184;
8149
8251
  break;
8150
8252
  }
8151
8253
  transformed.product_sku = (_transformed$product_ = transformed.product_sku) !== null && _transformed$product_ !== void 0 ? _transformed$product_ : editingLine.product_sku;
@@ -8155,10 +8257,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
8155
8257
  unique_identification_number: params.productLineUid,
8156
8258
  booking_uid: existingBookingUid
8157
8259
  });
8158
- _context70.next = 157;
8159
- return this.updateOrderProduct(_objectSpread(_objectSpread({
8260
+ editParams = _objectSpread(_objectSpread({
8160
8261
  product_id: (_transformed$product_3 = transformed.product_id) !== null && _transformed$product_3 !== void 0 ? _transformed$product_3 : editingLine.product_id,
8161
- product_variant_id: (_ref70 = (_transformed$product_4 = transformed.product_variant_id) !== null && _transformed$product_4 !== void 0 ? _transformed$product_4 : editingLine.product_variant_id) !== null && _ref70 !== void 0 ? _ref70 : 0,
8262
+ product_variant_id: (_ref72 = (_transformed$product_4 = transformed.product_variant_id) !== null && _transformed$product_4 !== void 0 ? _transformed$product_4 : editingLine.product_variant_id) !== null && _ref72 !== void 0 ? _ref72 : 0,
8162
8263
  unique_identification_number: params.productLineUid,
8163
8264
  updates: transformed,
8164
8265
  booking: booking
@@ -8166,18 +8267,34 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
8166
8267
  allow_booking_reprice: params.allowBookingReprice
8167
8268
  } : {}), params.allowBookingDiscountReapply !== undefined ? {
8168
8269
  allow_booking_discount_reapply: params.allowBookingDiscountReapply
8169
- } : {}));
8170
- case 157:
8171
- _context70.next = 159;
8270
+ } : {});
8271
+ if (!customerSelectionSnapshot) {
8272
+ _context70.next = 174;
8273
+ break;
8274
+ }
8275
+ _context70.next = 171;
8276
+ return this.updateOrderProducts([editParams], {
8277
+ beforeApply: availabilityCommitGuard,
8278
+ isCurrentOrder: availabilityCommitTargetGuard
8279
+ });
8280
+ case 171:
8281
+ guardedCommitPublished = true;
8282
+ _context70.next = 176;
8283
+ break;
8284
+ case 174:
8285
+ _context70.next = 176;
8286
+ return this.updateOrderProduct(editParams);
8287
+ case 176:
8288
+ _context70.next = 178;
8172
8289
  return this.removeBookingProductsOutsideStartDate(booking.start_date);
8173
- case 159:
8290
+ case 178:
8174
8291
  productLineUid = params.productLineUid;
8175
8292
  bookingUid = existingBookingUid;
8176
8293
  productLineUids = [productLineUid];
8177
8294
  bookingUids = [bookingUid];
8178
- _context70.next = 183;
8295
+ _context70.next = 202;
8179
8296
  break;
8180
- case 165:
8297
+ case 184:
8181
8298
  beforeProductLineUids = new Set((((_this$getTempOrder6 = this.getTempOrder()) === null || _this$getTempOrder6 === void 0 ? void 0 : _this$getTempOrder6.products) || []).map(function (line) {
8182
8299
  return getProductLineUid(line);
8183
8300
  }).filter(Boolean));
@@ -8185,27 +8302,27 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
8185
8302
  return getBookingUid(item);
8186
8303
  }).filter(Boolean));
8187
8304
  availabilityCommitGuard === null || availabilityCommitGuard === void 0 || availabilityCommitGuard();
8188
- _context70.next = 170;
8305
+ _context70.next = 189;
8189
8306
  return this.addProductToOrder(transformed, booking, (_params$salesNotes = params.salesNotes) !== null && _params$salesNotes !== void 0 && _params$salesNotes.length || availabilityCommitGuard ? _objectSpread(_objectSpread({}, (_params$salesNotes2 = params.salesNotes) !== null && _params$salesNotes2 !== void 0 && _params$salesNotes2.length ? {
8190
8307
  salesNotes: params.salesNotes
8191
8308
  } : {}), availabilityCommitGuard ? {
8192
8309
  availabilityCommitGuard: availabilityCommitGuard,
8193
8310
  availabilityCommitTargetGuard: availabilityCommitTargetGuard
8194
8311
  } : {}) : undefined);
8195
- case 170:
8312
+ case 189:
8196
8313
  products = _context70.sent;
8197
8314
  guardedCommitPublished = hasCommitGuard;
8198
8315
  // A completed add can publish before a different order becomes current.
8199
8316
  // Keep its returned lines and never clean up products on that next order.
8200
8317
  if (!(!hasCommitGuard || availabilityCommitTargetGuard())) {
8201
- _context70.next = 176;
8318
+ _context70.next = 195;
8202
8319
  break;
8203
8320
  }
8204
- _context70.next = 175;
8321
+ _context70.next = 194;
8205
8322
  return this.removeBookingProductsOutsideStartDate(booking.start_date);
8206
- case 175:
8323
+ case 194:
8207
8324
  products = _context70.sent;
8208
- case 176:
8325
+ case 195:
8209
8326
  addedLines = products.filter(function (line) {
8210
8327
  var _line$product_id, _line$metadata3;
8211
8328
  return sameAvailabilityId((_line$product_id = line.product_id) !== null && _line$product_id !== void 0 ? _line$product_id : line.id, refreshedCandidate.productId) && ((_line$metadata3 = line.metadata) === null || _line$metadata3 === void 0 ? void 0 : _line$metadata3.availability_candidate_key) === refreshedCandidate.key && !beforeProductLineUids.has(getProductLineUid(line));
@@ -8213,7 +8330,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
8213
8330
  productLineUids = addedLines.map(function (line) {
8214
8331
  return getProductLineUid(line);
8215
8332
  }).filter(Boolean);
8216
- addedBookings = (((_ref71 = hasCommitGuard ? rememberedOrder : this.getTempOrder()) === null || _ref71 === void 0 ? void 0 : _ref71.bookings) || []).filter(function (item) {
8333
+ addedBookings = (((_ref73 = hasCommitGuard ? rememberedOrder : this.getTempOrder()) === null || _ref73 === void 0 ? void 0 : _ref73.bookings) || []).filter(function (item) {
8217
8334
  var _item$metadata;
8218
8335
  return ((_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.availability_candidate_key) === refreshedCandidate.key && !beforeBookingUids.has(getBookingUid(item));
8219
8336
  });
@@ -8222,13 +8339,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
8222
8339
  }).filter(Boolean);
8223
8340
  if (bookingUids.length === 0) {
8224
8341
  bookingUids = addedLines.map(function (line) {
8225
- var _ref72, _line$booking_uid, _line$metadata4;
8226
- return String((_ref72 = (_line$booking_uid = line.booking_uid) !== null && _line$booking_uid !== void 0 ? _line$booking_uid : (_line$metadata4 = line.metadata) === null || _line$metadata4 === void 0 ? void 0 : _line$metadata4.booking_uid) !== null && _ref72 !== void 0 ? _ref72 : '');
8342
+ var _ref74, _line$booking_uid, _line$metadata4;
8343
+ return String((_ref74 = (_line$booking_uid = line.booking_uid) !== null && _line$booking_uid !== void 0 ? _line$booking_uid : (_line$metadata4 = line.metadata) === null || _line$metadata4 === void 0 ? void 0 : _line$metadata4.booking_uid) !== null && _ref74 !== void 0 ? _ref74 : '');
8227
8344
  }).filter(Boolean);
8228
8345
  }
8229
8346
  productLineUid = productLineUids[productLineUids.length - 1] || '';
8230
8347
  bookingUid = bookingUids[bookingUids.length - 1] || '';
8231
- case 183:
8348
+ case 202:
8232
8349
  targetStillCurrent = !hasCommitGuard || availabilityCommitTargetGuard();
8233
8350
  if (targetStillCurrent) this.invalidateAvailabilityContextsAfterCommit();else this.removeAvailabilityContext(normalizedContextId);
8234
8351
  nextContext = hasCommitGuard ? this.availabilityContextRegistry.get(normalizedContextId) : this.getAvailabilityContextEntry(normalizedContextId);
@@ -8244,7 +8361,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
8244
8361
  bookingUids: bookingUids
8245
8362
  };
8246
8363
  if (!targetStillCurrent) {
8247
- _context70.next = 201;
8364
+ _context70.next = 220;
8248
8365
  break;
8249
8366
  }
8250
8367
  // A notification failure after publication must not invite a duplicate add.
@@ -8252,50 +8369,50 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
8252
8369
  return _this29.core.effects.emit("".concat(_this29.name, ":").concat(UnifiedBookingSalesHooks.onAvailabilitySelectionCommitted), result);
8253
8370
  };
8254
8371
  if (!guardedCommitPublished) {
8255
- _context70.next = 199;
8372
+ _context70.next = 218;
8256
8373
  break;
8257
8374
  }
8258
- _context70.prev = 190;
8259
- _context70.next = 193;
8375
+ _context70.prev = 209;
8376
+ _context70.next = 212;
8260
8377
  return emit();
8261
- case 193:
8262
- _context70.next = 197;
8378
+ case 212:
8379
+ _context70.next = 216;
8263
8380
  break;
8264
- case 195:
8265
- _context70.prev = 195;
8266
- _context70.t0 = _context70["catch"](190);
8267
- case 197:
8268
- _context70.next = 201;
8381
+ case 214:
8382
+ _context70.prev = 214;
8383
+ _context70.t2 = _context70["catch"](209);
8384
+ case 216:
8385
+ _context70.next = 220;
8269
8386
  break;
8270
- case 199:
8271
- _context70.next = 201;
8387
+ case 218:
8388
+ _context70.next = 220;
8272
8389
  return emit();
8273
- case 201:
8390
+ case 220:
8274
8391
  return _context70.abrupt("return", result);
8275
- case 202:
8276
- _context70.prev = 202;
8392
+ case 221:
8393
+ _context70.prev = 221;
8277
8394
  release = this.releaseAvailabilityCommitLock(normalizedContextId);
8278
8395
  if (!guardedCommitPublished) {
8279
- _context70.next = 209;
8396
+ _context70.next = 228;
8280
8397
  break;
8281
8398
  }
8282
- _context70.next = 207;
8399
+ _context70.next = 226;
8283
8400
  return release.catch(function () {
8284
8401
  return undefined;
8285
8402
  });
8286
- case 207:
8287
- _context70.next = 211;
8403
+ case 226:
8404
+ _context70.next = 230;
8288
8405
  break;
8289
- case 209:
8290
- _context70.next = 211;
8406
+ case 228:
8407
+ _context70.next = 230;
8291
8408
  return release;
8292
- case 211:
8293
- return _context70.finish(202);
8294
- case 212:
8409
+ case 230:
8410
+ return _context70.finish(221);
8411
+ case 231:
8295
8412
  case "end":
8296
8413
  return _context70.stop();
8297
8414
  }
8298
- }, _callee69, this, [[25,, 202, 212], [190, 195]]);
8415
+ }, _callee69, this, [[26,, 221, 231], [209, 214]]);
8299
8416
  }));
8300
8417
  function commitAvailabilitySelection(_x56, _x57) {
8301
8418
  return _commitAvailabilitySelection.apply(this, arguments);