@pisell/pisellos 0.10.21 → 0.10.23

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.
Files changed (73) hide show
  1. package/dist/modules/BookingContext/index.d.ts +3 -0
  2. package/dist/modules/BookingContext/index.js +42 -13
  3. package/dist/modules/BookingContext/types.d.ts +4 -4
  4. package/dist/modules/BookingContext/types.js +3 -3
  5. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +10 -7
  6. package/dist/modules/OpenData/index.d.ts +1 -0
  7. package/dist/modules/OpenData/index.js +28 -9
  8. package/dist/modules/Order/index.d.ts +5 -0
  9. package/dist/modules/Order/index.js +148 -84
  10. package/dist/modules/ProductList/clientDataVariants.d.ts +50 -0
  11. package/dist/modules/ProductList/clientDataVariants.js +216 -0
  12. package/dist/modules/ProductList/index.d.ts +14 -13
  13. package/dist/modules/ProductList/index.js +105 -77
  14. package/dist/modules/Quotation/index.d.ts +16 -0
  15. package/dist/modules/Quotation/index.js +240 -27
  16. package/dist/modules/ResourcePlanner/planner.d.ts +2 -2
  17. package/dist/modules/ResourcePlanner/planner.js +88 -21
  18. package/dist/modules/ResourcePlanner/types.d.ts +12 -0
  19. package/dist/modules/Rules/index.d.ts +5 -0
  20. package/dist/modules/Rules/index.js +27 -12
  21. package/dist/solution/BaseSales/index.d.ts +16 -1
  22. package/dist/solution/BaseSales/index.js +667 -349
  23. package/dist/solution/BookingByStep/index.d.ts +1 -1
  24. package/dist/solution/BookingTicket/index.d.ts +1 -1
  25. package/dist/solution/Sales/index.js +5 -3
  26. package/dist/solution/UnifiedBookingSales/index.d.ts +1 -1
  27. package/dist/solution/UnifiedBookingSales/index.js +290 -81
  28. package/dist/solution/UnifiedBookingSales/types.d.ts +4 -0
  29. package/dist/solution/VenueBooking/index.d.ts +2 -0
  30. package/dist/solution/VenueBooking/index.js +542 -494
  31. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
  32. package/dist/solution/VenueBooking/utils/dateSummary.js +3 -1
  33. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +2 -0
  34. package/dist/solution/VenueBooking/utils/slotMerge.js +3 -1
  35. package/dist/utils/platform.d.ts +8 -0
  36. package/dist/utils/platform.js +15 -0
  37. package/lib/modules/BookingContext/index.d.ts +3 -0
  38. package/lib/modules/BookingContext/index.js +35 -8
  39. package/lib/modules/BookingContext/types.d.ts +4 -4
  40. package/lib/modules/BookingContext/types.js +3 -3
  41. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +4 -0
  42. package/lib/modules/OpenData/index.d.ts +1 -0
  43. package/lib/modules/OpenData/index.js +13 -0
  44. package/lib/modules/Order/index.d.ts +5 -0
  45. package/lib/modules/Order/index.js +65 -8
  46. package/lib/modules/ProductList/clientDataVariants.d.ts +50 -0
  47. package/lib/modules/ProductList/clientDataVariants.js +204 -0
  48. package/lib/modules/ProductList/index.d.ts +14 -13
  49. package/lib/modules/ProductList/index.js +77 -58
  50. package/lib/modules/Quotation/index.d.ts +16 -0
  51. package/lib/modules/Quotation/index.js +112 -9
  52. package/lib/modules/ResourcePlanner/planner.d.ts +2 -2
  53. package/lib/modules/ResourcePlanner/planner.js +80 -20
  54. package/lib/modules/ResourcePlanner/types.d.ts +12 -0
  55. package/lib/modules/Rules/index.d.ts +5 -0
  56. package/lib/modules/Rules/index.js +20 -11
  57. package/lib/solution/BaseSales/index.d.ts +16 -1
  58. package/lib/solution/BaseSales/index.js +293 -66
  59. package/lib/solution/BookingByStep/index.d.ts +1 -1
  60. package/lib/solution/BookingTicket/index.d.ts +1 -1
  61. package/lib/solution/Sales/index.js +2 -1
  62. package/lib/solution/UnifiedBookingSales/index.d.ts +1 -1
  63. package/lib/solution/UnifiedBookingSales/index.js +225 -20
  64. package/lib/solution/UnifiedBookingSales/types.d.ts +4 -0
  65. package/lib/solution/VenueBooking/index.d.ts +2 -0
  66. package/lib/solution/VenueBooking/index.js +28 -8
  67. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
  68. package/lib/solution/VenueBooking/utils/dateSummary.js +3 -1
  69. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +2 -0
  70. package/lib/solution/VenueBooking/utils/slotMerge.js +3 -1
  71. package/lib/utils/platform.d.ts +8 -0
  72. package/lib/utils/platform.js +22 -0
  73. package/package.json +1 -1
@@ -36,6 +36,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
36
36
  import dayjs from 'dayjs';
37
37
  import { cloneDeep } from 'lodash-es';
38
38
  import { OpenDataModule } from "../../modules";
39
+ import { isProductFlexibleDuration } from "../../modules/BookingContext/utils";
39
40
  import { getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings } from "../../modules/OpenData";
40
41
  import { getScheduleStartEndTimePoints } from "../../modules/Schedule/getDateIsInSchedule";
41
42
  import { AvailabilityError, createAvailabilityProjection, getProductTimeRanges as getProjectionProductTimeRanges, queryAvailabilityProjection, validateAvailabilitySelection } from "../../modules/ResourcePlanner";
@@ -43,6 +44,7 @@ import { UnifiedBookingSalesHooks } from "./types";
43
44
  import { AvailabilityRemoteOccupancyCache } from "./remoteOccupancyCache";
44
45
  import { BookingTicket } from "../BookingTicket";
45
46
  import { addLocalCalendarDays, captureRuntimeOffsetMinutes, formatLocalDate, formatLocalDateTime, formatLocalTime, localDateTimeToScalar, localDateToScalar, localDateToScalarStart, parseLocalDate, parseLocalDateTime } from "../../modules/ResourcePlanner/localClock";
47
+ import { isCustomerUserPlatform } from "../../utils/platform";
46
48
  export * from "./types";
47
49
  export { AvailabilityError } from "../../modules/ResourcePlanner";
48
50
  var OPEN_DATA_SECTION_CODES = ['sale', 'reservation', 'fulfillment', 'menu', 'workflow', 'basic', 'checkout', 'availability', 'documents'];
@@ -52,6 +54,30 @@ function normalizePositiveInteger(value) {
52
54
  if (!Number.isInteger(normalized) || normalized <= 0) return undefined;
53
55
  return normalized;
54
56
  }
57
+ function getCandidateDurationMinutes(candidate) {
58
+ var startAt = candidate.bookingStartAt || candidate.startAt;
59
+ var endAt = candidate.bookingEndAt || candidate.endAt;
60
+ try {
61
+ var start = localDateTimeToScalar(parseLocalDateTime(startAt));
62
+ var end = localDateTimeToScalar(parseLocalDateTime(endAt));
63
+ var minutes = Math.round((end - start) / 60000);
64
+ return Number.isInteger(minutes) && minutes > 0 ? minutes : undefined;
65
+ } catch (_error) {
66
+ return undefined;
67
+ }
68
+ }
69
+ function getCandidateStartTime(candidate) {
70
+ if (/^([01]\d|2[0-3]):[0-5]\d$/.test(candidate.startTime || '')) {
71
+ return candidate.startTime;
72
+ }
73
+ var startAt = candidate.bookingStartAt || candidate.startAt;
74
+ try {
75
+ var start = parseLocalDateTime(startAt);
76
+ return "".concat(String(start.hour).padStart(2, '0'), ":").concat(String(start.minute).padStart(2, '0'));
77
+ } catch (_error) {
78
+ return undefined;
79
+ }
80
+ }
55
81
  function isRecord(value) {
56
82
  return !!value && _typeof(value) === 'object' && !Array.isArray(value);
57
83
  }
@@ -178,8 +204,9 @@ function filterCustomerBoundDiscounts(discountList) {
178
204
  }
179
205
  var DEFAULT_AVAILABILITY_SLOT_STEP_MINUTES = 30;
180
206
  var DEFAULT_AVAILABILITY_BUSINESS_HOURS = {
181
- startTime: '09:00',
182
- endTime: '18:00'
207
+ // Same start/end is interpreted as an overnight range, i.e. 24 hours.
208
+ startTime: '00:00',
209
+ endTime: '00:00'
183
210
  };
184
211
  var MAX_AVAILABILITY_RANGE_DAYS = 90;
185
212
  var MAX_AVAILABILITY_CONTEXT_REGISTRY = 128;
@@ -495,6 +522,7 @@ export function normalizeProductForAvailability(product) {
495
522
  var fixedOffsetMinutes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : captureRuntimeOffsetMinutes();
496
523
  var raw = product;
497
524
  var kind = resolveProductKind(raw);
525
+ var isFlexibleDuration = kind === 'duration' && isProductFlexibleDuration(raw.duration);
498
526
  var sessionRules = [];
499
527
  var sessionRanges = [];
500
528
  var explicitSession = ((_raw$cartDetailValue = raw.cartDetailValue) === null || _raw$cartDetailValue === void 0 ? void 0 : _raw$cartDetailValue.session) || ((_raw$_extend = raw._extend) === null || _raw$_extend === void 0 || (_raw$_extend = _raw$_extend.other) === null || _raw$_extend === void 0 ? void 0 : _raw$_extend.session) || raw.session;
@@ -516,7 +544,8 @@ export function normalizeProductForAvailability(product) {
516
544
  id: (_raw$id = raw.id) !== null && _raw$id !== void 0 ? _raw$id : raw.product_id,
517
545
  title: pickLocalizedText(raw.title || raw.name || raw.product_title),
518
546
  kind: kind,
519
- durationMinutes: kind === 'duration' ? Math.max(1, Number(((_raw$duration = raw.duration) === null || _raw$duration === void 0 ? void 0 : _raw$duration.value) || raw.duration || raw.service_duration || 30) || 30) : undefined,
547
+ isFlexibleDuration: isFlexibleDuration || undefined,
548
+ durationMinutes: kind === 'duration' && !isFlexibleDuration ? Math.max(1, Number(((_raw$duration = raw.duration) === null || _raw$duration === void 0 ? void 0 : _raw$duration.value) || raw.duration || raw.service_duration || 30) || 30) : undefined,
520
549
  requirementGroups: normalizeRequirementGroups(raw),
521
550
  sessionRules: sessionRules,
522
551
  sessionRanges: sessionRanges,
@@ -1063,6 +1092,137 @@ function buildBookingFromAvailabilitySelection(params) {
1063
1092
  } : {})
1064
1093
  });
1065
1094
  }
1095
+ var POS_OVERRIDABLE_AVAILABILITY_CONFLICT_CODES = new Set(['past', 'booking_cutoff', 'resource_full', 'resource_unavailable', 'resource_capacity_exceeded',
1096
+ // A required group whose selected resource is outside its window is surfaced
1097
+ // as missing_resource at group level. Structural validation below still
1098
+ // rejects a genuinely missing selection.
1099
+ 'missing_resource']);
1100
+ function matchesForcedSelectionGroup(selection, group) {
1101
+ var hasGroupId = typeof selection.requirementGroupId === 'string' && selection.requirementGroupId.trim().length > 0;
1102
+ var hasFormId = selection.formId !== undefined && selection.formId !== null;
1103
+ if (!hasGroupId && !hasFormId) return false;
1104
+ if (hasGroupId && selection.requirementGroupId !== group.id) return false;
1105
+ if (hasFormId && !sameAvailabilityId(selection.formId, group.formId)) return false;
1106
+ return true;
1107
+ }
1108
+
1109
+ /**
1110
+ * POS may intentionally overbook a configured time/resource. Rebuild the
1111
+ * assignments from the submitted, structurally valid resource identities so
1112
+ * a full/unavailable option is not silently dropped by normal availability
1113
+ * evaluation. This deliberately ignores capacity, occupancy and resource
1114
+ * windows, while retaining product/group/resource identity and selection
1115
+ * cardinality checks.
1116
+ */
1117
+ function buildPosForcedAvailabilityAssignments(params) {
1118
+ var product = params.product,
1119
+ resources = params.resources,
1120
+ candidate = params.candidate,
1121
+ requirementSelections = params.requirementSelections,
1122
+ partySize = params.partySize;
1123
+ var groups = product.requirementGroups || [];
1124
+ var conflicts = [];
1125
+ var assignments = [];
1126
+ var selectionsByGroup = new Map();
1127
+ var addConflict = function addConflict(code, message) {
1128
+ var details = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1129
+ return conflicts.push(_objectSpread({
1130
+ code: code,
1131
+ message: message,
1132
+ productId: candidate.productId,
1133
+ candidateKey: candidate.key
1134
+ }, details));
1135
+ };
1136
+ requirementSelections.forEach(function (selection) {
1137
+ var _group$min, _group$max;
1138
+ var matchedGroups = groups.filter(function (group) {
1139
+ return matchesForcedSelectionGroup(selection, group);
1140
+ });
1141
+ if (matchedGroups.length !== 1) {
1142
+ addConflict('invalid_requirement_group', '选择的资源组不属于当前商品', {
1143
+ requirementGroupId: selection.requirementGroupId,
1144
+ formId: selection.formId
1145
+ });
1146
+ return;
1147
+ }
1148
+ var group = matchedGroups[0];
1149
+ if (selectionsByGroup.has(group.id)) {
1150
+ addConflict('invalid_selection_count', "\u8D44\u6E90\u7EC4 ".concat(group.id, " \u88AB\u91CD\u590D\u63D0\u4EA4"), {
1151
+ requirementGroupId: group.id,
1152
+ formId: group.formId
1153
+ });
1154
+ return;
1155
+ }
1156
+ selectionsByGroup.set(group.id, selection);
1157
+ if (!Array.isArray(selection.resourceIds)) {
1158
+ addConflict('invalid_selection_count', "\u8D44\u6E90\u7EC4 ".concat(group.id, " \u7684\u8D44\u6E90\u9009\u62E9\u5FC5\u987B\u662F\u6570\u7EC4"), {
1159
+ requirementGroupId: group.id,
1160
+ formId: group.formId
1161
+ });
1162
+ return;
1163
+ }
1164
+ var selectedResourceIds = Array.from(new Map(selection.resourceIds.map(function (resourceId) {
1165
+ return [String(resourceId), resourceId];
1166
+ })).values());
1167
+ var required = group.required !== false;
1168
+ var min = Math.max(required ? 1 : 0, Number((_group$min = group.min) !== null && _group$min !== void 0 ? _group$min : required ? 1 : 0) || 0);
1169
+ var max = Math.max(min, Number((_group$max = group.max) !== null && _group$max !== void 0 ? _group$max : Math.max(min, 1)) || Math.max(min, 1));
1170
+ if (selectedResourceIds.length < min) {
1171
+ addConflict('missing_resource', "\u8D44\u6E90\u7EC4 ".concat(group.id, " \u7F3A\u5C11\u5DF2\u9009\u8D44\u6E90"), {
1172
+ requirementGroupId: group.id,
1173
+ formId: group.formId
1174
+ });
1175
+ return;
1176
+ }
1177
+ if (selectedResourceIds.length > max) {
1178
+ addConflict('invalid_selection_count', "\u8D44\u6E90\u7EC4 ".concat(group.id, " \u5DF2\u9009\u8D44\u6E90\u6570\u91CF\u8D85\u51FA\u4E0A\u9650"), {
1179
+ requirementGroupId: group.id,
1180
+ formId: group.formId
1181
+ });
1182
+ return;
1183
+ }
1184
+ selectedResourceIds.forEach(function (resourceId) {
1185
+ var _group$resourceIds2, _group$formId, _candidate$primarySch5, _candidate$primarySch6;
1186
+ var resource = resources.find(function (item) {
1187
+ return sameAvailabilityId(item.id, resourceId);
1188
+ });
1189
+ var belongsToGroup = Boolean(resource && !(group.formId !== undefined && resource.formId !== undefined && !sameAvailabilityId(group.formId, resource.formId)) && !((_group$resourceIds2 = group.resourceIds) !== null && _group$resourceIds2 !== void 0 && _group$resourceIds2.length && !group.resourceIds.some(function (id) {
1190
+ return sameAvailabilityId(id, resourceId);
1191
+ })));
1192
+ if (!resource || !belongsToGroup) {
1193
+ addConflict('resource_unavailable', "\u8D44\u6E90 ".concat(String(resourceId), " \u4E0D\u5C5E\u4E8E\u5F53\u524D\u5546\u54C1\u8D44\u6E90\u7EC4"), {
1194
+ requirementGroupId: group.id,
1195
+ formId: group.formId,
1196
+ resourceId: resourceId
1197
+ });
1198
+ return;
1199
+ }
1200
+ assignments.push({
1201
+ productId: product.id,
1202
+ resourceId: resourceId,
1203
+ formId: (_group$formId = group.formId) !== null && _group$formId !== void 0 ? _group$formId : resource.formId,
1204
+ startAt: candidate.bookingStartAt || candidate.startAt,
1205
+ endAt: candidate.bookingEndAt || candidate.endAt,
1206
+ capacityRequired: Math.max(1, partySize),
1207
+ scheduleId: (_candidate$primarySch5 = candidate.primaryScheduleRef) === null || _candidate$primarySch5 === void 0 ? void 0 : _candidate$primarySch5.scheduleId,
1208
+ timeSlotId: (_candidate$primarySch6 = candidate.primaryScheduleRef) === null || _candidate$primarySch6 === void 0 ? void 0 : _candidate$primarySch6.timeSlotId
1209
+ });
1210
+ });
1211
+ });
1212
+ groups.filter(function (group) {
1213
+ return group.required !== false;
1214
+ }).forEach(function (group) {
1215
+ if (selectionsByGroup.has(group.id)) return;
1216
+ addConflict('missing_resource', "\u8D44\u6E90\u7EC4 ".concat(group.id, " \u7F3A\u5C11\u5DF2\u9009\u8D44\u6E90"), {
1217
+ requirementGroupId: group.id,
1218
+ formId: group.formId
1219
+ });
1220
+ });
1221
+ return {
1222
+ assignments: assignments,
1223
+ conflicts: conflicts
1224
+ };
1225
+ }
1066
1226
  export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1067
1227
  _inherits(UnifiedBookingSalesImpl, _BookingTicket);
1068
1228
  var _super = _createSuper(UnifiedBookingSalesImpl);
@@ -1817,8 +1977,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1817
1977
  key: "isAuthenticatedCustomerUserPlatform",
1818
1978
  value: function isAuthenticatedCustomerUserPlatform() {
1819
1979
  var _this$otherParams14;
1820
- var platform = String(((_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.platform) || '').toLowerCase();
1821
- return platform === 'pc' || platform === 'h5';
1980
+ return isCustomerUserPlatform((_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.platform);
1822
1981
  }
1823
1982
  }, {
1824
1983
  key: "resolveDiscountOrderIdentity",
@@ -2121,7 +2280,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2121
2280
  key: "getProtocol",
2122
2281
  value: (function () {
2123
2282
  var _getProtocol = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(policyId) {
2124
- var normalizedPolicyId;
2283
+ var normalizedPolicyId, policyUrl;
2125
2284
  return _regeneratorRuntime().wrap(function _callee15$(_context15) {
2126
2285
  while (1) switch (_context15.prev = _context15.next) {
2127
2286
  case 0:
@@ -2132,8 +2291,12 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2132
2291
  }
2133
2292
  throw new Error('[UnifiedBookingSales] getProtocol 需要 policyId');
2134
2293
  case 3:
2135
- return _context15.abrupt("return", this.request.get("/shop-policy/".concat(encodeURIComponent(normalizedPolicyId))));
2136
- case 4:
2294
+ policyUrl = 'shop-policy';
2295
+ if (this.otherParams.platform === 'kiosk' || this.otherParams.platform === 'pos' || this.otherParams.platform === 'shop') {
2296
+ policyUrl = 'policy';
2297
+ }
2298
+ return _context15.abrupt("return", this.request.get("/".concat(policyUrl, "/").concat(encodeURIComponent(normalizedPolicyId))));
2299
+ case 6:
2137
2300
  case "end":
2138
2301
  return _context15.stop();
2139
2302
  }
@@ -2571,23 +2734,26 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2571
2734
  }, {
2572
2735
  key: "buildUnifiedOrderProduct",
2573
2736
  value: function buildUnifiedOrderProduct(sourceProduct, ownershipKey, product) {
2574
- var _sourceProduct$id, _ref33, _sourceProduct$produc, _ref34, _ref35, _sourceProduct$quanti, _sourceProduct$price, _ref36, _ref37, _sourceProduct$sellin;
2737
+ var _ref33, _sourceProduct$_exten, _sourceProduct$_exten2, _sourceProduct$metada, _sourceProduct$id, _ref34, _sourceProduct$produc, _ref35, _ref36, _sourceProduct$quanti, _sourceProduct$price, _ref37, _ref38, _sourceProduct$sellin;
2575
2738
  var normalizedProductRaw = (product === null || product === void 0 ? void 0 : product.raw) || {};
2739
+ var quotationShelfId = (_ref33 = (_sourceProduct$_exten = (_sourceProduct$_exten2 = sourceProduct._extend) === null || _sourceProduct$_exten2 === void 0 ? void 0 : _sourceProduct$_exten2.quotation_shelf_id) !== null && _sourceProduct$_exten !== void 0 ? _sourceProduct$_exten : sourceProduct.quotation_shelf_id) !== null && _ref33 !== void 0 ? _ref33 : (_sourceProduct$metada = sourceProduct.metadata) === null || _sourceProduct$metada === void 0 ? void 0 : _sourceProduct$metada.quotation_shelf_id;
2576
2740
  var orderProduct = this.transformBaseProductToOrderProduct({
2577
2741
  payload: _objectSpread(_objectSpread({}, sourceProduct), {}, {
2578
2742
  id: (_sourceProduct$id = sourceProduct.id) !== null && _sourceProduct$id !== void 0 ? _sourceProduct$id : product === null || product === void 0 ? void 0 : product.id,
2579
- product_id: (_ref33 = (_sourceProduct$produc = sourceProduct.product_id) !== null && _sourceProduct$produc !== void 0 ? _sourceProduct$produc : sourceProduct.id) !== null && _ref33 !== void 0 ? _ref33 : product === null || product === void 0 ? void 0 : product.id,
2580
- quantity: (_ref34 = (_ref35 = (_sourceProduct$quanti = sourceProduct.quantity) !== null && _sourceProduct$quanti !== void 0 ? _sourceProduct$quanti : sourceProduct.num) !== null && _ref35 !== void 0 ? _ref35 : product === null || product === void 0 ? void 0 : product.quantity) !== null && _ref34 !== void 0 ? _ref34 : 1,
2743
+ product_id: (_ref34 = (_sourceProduct$produc = sourceProduct.product_id) !== null && _sourceProduct$produc !== void 0 ? _sourceProduct$produc : sourceProduct.id) !== null && _ref34 !== void 0 ? _ref34 : product === null || product === void 0 ? void 0 : product.id,
2744
+ quantity: (_ref35 = (_ref36 = (_sourceProduct$quanti = sourceProduct.quantity) !== null && _sourceProduct$quanti !== void 0 ? _sourceProduct$quanti : sourceProduct.num) !== null && _ref36 !== void 0 ? _ref36 : product === null || product === void 0 ? void 0 : product.quantity) !== null && _ref35 !== void 0 ? _ref35 : 1,
2581
2745
  price: (_sourceProduct$price = sourceProduct.price) !== null && _sourceProduct$price !== void 0 ? _sourceProduct$price : normalizedProductRaw.price,
2582
- selling_price: (_ref36 = (_ref37 = (_sourceProduct$sellin = sourceProduct.selling_price) !== null && _sourceProduct$sellin !== void 0 ? _sourceProduct$sellin : sourceProduct.price) !== null && _ref37 !== void 0 ? _ref37 : normalizedProductRaw.selling_price) !== null && _ref36 !== void 0 ? _ref36 : normalizedProductRaw.price,
2746
+ selling_price: (_ref37 = (_ref38 = (_sourceProduct$sellin = sourceProduct.selling_price) !== null && _sourceProduct$sellin !== void 0 ? _sourceProduct$sellin : sourceProduct.price) !== null && _ref38 !== void 0 ? _ref38 : normalizedProductRaw.selling_price) !== null && _ref37 !== void 0 ? _ref37 : normalizedProductRaw.price,
2583
2747
  metadata: _objectSpread(_objectSpread({}, sourceProduct.metadata || {}), {}, _defineProperty({}, ownershipKey, true))
2584
2748
  }),
2585
2749
  sourceProduct: sourceProduct
2586
2750
  });
2587
2751
  if (orderProduct && _typeof(orderProduct) === 'object') {
2588
- // BaseSales may rebuild metadata from its price source. Stamp ownership after that transform
2589
- // so each UnifiedBookingSales entry point can replace only its own temporary lines.
2590
- orderProduct.metadata = _objectSpread(_objectSpread({}, orderProduct.metadata || {}), {}, _defineProperty({}, ownershipKey, true));
2752
+ // BaseSales may rebuild metadata from its price source. Stamp ownership and the selected
2753
+ // quotation shelf after that transform so neither booking adds nor edits lose quote identity.
2754
+ orderProduct.metadata = _objectSpread(_objectSpread({}, orderProduct.metadata || {}), {}, _defineProperty({}, ownershipKey, true), quotationShelfId !== undefined ? {
2755
+ quotation_shelf_id: quotationShelfId
2756
+ } : {});
2591
2757
  }
2592
2758
  return orderProduct;
2593
2759
  }
@@ -2737,7 +2903,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2737
2903
  key: "addRetailProduct",
2738
2904
  value: (function () {
2739
2905
  var _addRetailProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
2740
- var _params$quantity, _ref38, _params$productId, _params$product, _params$product2;
2906
+ var _params$quantity, _ref39, _params$productId, _params$product, _params$product2;
2741
2907
  var quantity, productId, sourceProduct, products, orderProduct;
2742
2908
  return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2743
2909
  while (1) switch (_context23.prev = _context23.next) {
@@ -2749,7 +2915,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2749
2915
  }
2750
2916
  throw new Error('[UnifiedBookingSales] retail 商品数量必须大于 0');
2751
2917
  case 3:
2752
- productId = (_ref38 = (_params$productId = params.productId) !== null && _params$productId !== void 0 ? _params$productId : (_params$product = params.product) === null || _params$product === void 0 ? void 0 : _params$product.id) !== null && _ref38 !== void 0 ? _ref38 : (_params$product2 = params.product) === null || _params$product2 === void 0 ? void 0 : _params$product2.product_id;
2918
+ productId = (_ref39 = (_params$productId = params.productId) !== null && _params$productId !== void 0 ? _params$productId : (_params$product = params.product) === null || _params$product === void 0 ? void 0 : _params$product.id) !== null && _ref39 !== void 0 ? _ref39 : (_params$product2 = params.product) === null || _params$product2 === void 0 ? void 0 : _params$product2.product_id;
2753
2919
  sourceProduct = params.product;
2754
2920
  if (!sourceProduct && productId !== undefined && productId !== null) {
2755
2921
  sourceProduct = this.unifiedProductCatalog.find(function (product) {
@@ -3054,8 +3220,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3054
3220
  return _context24.abrupt("return", normalized.filter(function (product) {
3055
3221
  var _product$requirementG2;
3056
3222
  return (_product$requirementG2 = product.requirementGroups) === null || _product$requirementG2 === void 0 ? void 0 : _product$requirementG2.some(function (group) {
3057
- var _group$resourceIds2;
3058
- return (_group$resourceIds2 = group.resourceIds) === null || _group$resourceIds2 === void 0 ? void 0 : _group$resourceIds2.some(function (resourceId) {
3223
+ var _group$resourceIds3;
3224
+ return (_group$resourceIds3 = group.resourceIds) === null || _group$resourceIds3 === void 0 ? void 0 : _group$resourceIds3.some(function (resourceId) {
3059
3225
  return prepare.resourceIds.some(function (id) {
3060
3226
  return sameAvailabilityId(id, resourceId);
3061
3227
  });
@@ -3353,7 +3519,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3353
3519
  var products = Array.isArray(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) ? tempOrder.products : [];
3354
3520
  var bookings = Array.isArray(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.bookings) ? tempOrder.bookings : [];
3355
3521
  productLineUids.forEach(function (requestedUid) {
3356
- var _ref39, _product$booking_uid2, _product$metadata5;
3522
+ var _ref40, _product$booking_uid2, _product$metadata5;
3357
3523
  var product = products.find(function (line) {
3358
3524
  return getProductLineUid(line) === String(requestedUid);
3359
3525
  });
@@ -3363,7 +3529,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3363
3529
  });
3364
3530
  }
3365
3531
  var productUid = getProductLineUid(product);
3366
- var linkedBookingUid = String((_ref39 = (_product$booking_uid2 = product.booking_uid) !== null && _product$booking_uid2 !== void 0 ? _product$booking_uid2 : (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.booking_uid) !== null && _ref39 !== void 0 ? _ref39 : '');
3532
+ var linkedBookingUid = String((_ref40 = (_product$booking_uid2 = product.booking_uid) !== null && _product$booking_uid2 !== void 0 ? _product$booking_uid2 : (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.booking_uid) !== null && _ref40 !== void 0 ? _ref40 : '');
3367
3533
  var linkedBookings = bookings.filter(function (booking) {
3368
3534
  var _booking$product_uid;
3369
3535
  return linkedBookingUid && getBookingUid(booking) === linkedBookingUid || productUid && String((_booking$product_uid = booking.product_uid) !== null && _booking$product_uid !== void 0 ? _booking$product_uid : '') === productUid;
@@ -3409,16 +3575,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3409
3575
  var _this5 = this;
3410
3576
  var bookings = Array.isArray(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.bookings) ? tempOrder.bookings : [];
3411
3577
  return bookings.flatMap(function (booking) {
3412
- var _ref40, _booking$product_uid2, _booking$metadata2;
3578
+ var _ref41, _booking$product_uid2, _booking$metadata2;
3413
3579
  var bookingUid = getBookingUid(booking);
3414
- var productUid = String((_ref40 = (_booking$product_uid2 = booking.product_uid) !== null && _booking$product_uid2 !== void 0 ? _booking$product_uid2 : (_booking$metadata2 = booking.metadata) === null || _booking$metadata2 === void 0 ? void 0 : _booking$metadata2.product_uid) !== null && _ref40 !== void 0 ? _ref40 : '');
3580
+ var productUid = String((_ref41 = (_booking$product_uid2 = booking.product_uid) !== null && _booking$product_uid2 !== void 0 ? _booking$product_uid2 : (_booking$metadata2 = booking.metadata) === null || _booking$metadata2 === void 0 ? void 0 : _booking$metadata2.product_uid) !== null && _ref41 !== void 0 ? _ref41 : '');
3415
3581
  var scheduleEventId = toNumberId(booking.schedule_event_id);
3416
3582
  var startAt = booking.start_at || "".concat(booking.start_date || '', " ").concat(booking.start_time || '').trim();
3417
3583
  var endAt = booking.end_at || "".concat(booking.end_date || booking.start_date || '', " ").concat(booking.end_time || '').trim();
3418
3584
  var resources = Array.isArray(booking.resources) ? booking.resources : [];
3419
3585
  return resources.flatMap(function (resource) {
3420
- var _ref41, _resource$resource_id, _ref42, _resource$capacity;
3421
- var resourceId = (_ref41 = (_resource$resource_id = resource.resource_id) !== null && _resource$resource_id !== void 0 ? _resource$resource_id : resource.relation_id) !== null && _ref41 !== void 0 ? _ref41 : resource.id;
3586
+ var _ref42, _resource$resource_id, _ref43, _resource$capacity;
3587
+ var resourceId = (_ref42 = (_resource$resource_id = resource.resource_id) !== null && _resource$resource_id !== void 0 ? _resource$resource_id : resource.relation_id) !== null && _ref42 !== void 0 ? _ref42 : resource.id;
3422
3588
  if (resourceId == null || !startAt || !endAt) return [];
3423
3589
  var range = normalizeAvailabilityLocalDateTimeRange({
3424
3590
  startAt: startAt,
@@ -3431,7 +3597,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3431
3597
  resourceId: resourceId,
3432
3598
  startAt: range.startAt,
3433
3599
  endAt: range.endAt,
3434
- pax: Math.max(1, Number((_ref42 = (_resource$capacity = resource.capacity) !== null && _resource$capacity !== void 0 ? _resource$capacity : booking.capacity) !== null && _ref42 !== void 0 ? _ref42 : 1) || 1),
3600
+ pax: Math.max(1, Number((_ref43 = (_resource$capacity = resource.capacity) !== null && _resource$capacity !== void 0 ? _resource$capacity : booking.capacity) !== null && _ref43 !== void 0 ? _ref43 : 1) || 1),
3435
3601
  source: 'cart',
3436
3602
  scheduleEventId: scheduleEventId,
3437
3603
  bookingUid: bookingUid || undefined,
@@ -4093,17 +4259,20 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4093
4259
  return _prepareAvailabilityProjection.apply(this, arguments);
4094
4260
  }
4095
4261
  return prepareAvailabilityProjection;
4096
- }() /** Pure configuration calculation over the current context projection. */)
4262
+ }() /** Candidate calculation over the current context projection and runtime minute. */)
4097
4263
  }, {
4098
4264
  key: "getProductTimeRanges",
4099
4265
  value: (function () {
4100
4266
  var _getProductTimeRanges = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(contextId) {
4101
- var _this9 = this;
4267
+ var _this$otherParams$pla,
4268
+ _this$otherParams19,
4269
+ _this9 = this;
4102
4270
  var request,
4103
4271
  _yield$this$ensureAva,
4104
4272
  context,
4105
4273
  projectionEntry,
4106
4274
  contextVersion,
4275
+ allowOutsideOperatingHoursForRequestedStartTimes,
4107
4276
  _args37 = arguments;
4108
4277
  return _regeneratorRuntime().wrap(function _callee37$(_context37) {
4109
4278
  while (1) switch (_context37.prev = _context37.next) {
@@ -4116,14 +4285,21 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4116
4285
  context = _yield$this$ensureAva.context;
4117
4286
  projectionEntry = _yield$this$ensureAva.projectionEntry;
4118
4287
  contextVersion = context.activeVersion;
4119
- return _context37.abrupt("return", getProjectionProductTimeRanges(projectionEntry.projection, request).map(function (group) {
4288
+ allowOutsideOperatingHoursForRequestedStartTimes = String((_this$otherParams$pla = (_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.platform) !== null && _this$otherParams$pla !== void 0 ? _this$otherParams$pla : '').trim().toLowerCase() === 'pos' && Object.values(request.durationStartTimesByProductId || {}).some(function (startTimes) {
4289
+ return Array.isArray(startTimes) && startTimes.length > 0;
4290
+ });
4291
+ return _context37.abrupt("return", getProjectionProductTimeRanges(projectionEntry.projection, _objectSpread(_objectSpread({}, request), allowOutsideOperatingHoursForRequestedStartTimes ? {
4292
+ allowOutsideOperatingHoursForRequestedStartTimes: true
4293
+ } : {}), {
4294
+ evaluatedAt: this.getAvailabilityRuntimeDateTime()
4295
+ }).map(function (group) {
4120
4296
  return _objectSpread(_objectSpread({}, group), {}, {
4121
4297
  ranges: group.ranges.map(function (candidate) {
4122
4298
  return _this9.decorateAvailabilityCandidate(context.contextId, contextVersion, candidate);
4123
4299
  })
4124
4300
  });
4125
4301
  }));
4126
- case 8:
4302
+ case 9:
4127
4303
  case "end":
4128
4304
  return _context37.stop();
4129
4305
  }
@@ -4245,9 +4421,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4245
4421
  }, {
4246
4422
  key: "findLinkedBooking",
4247
4423
  value: function findLinkedBooking(product) {
4248
- var _ref44, _product$booking_uid3, _product$metadata6, _this$getTempOrder3;
4424
+ var _ref45, _product$booking_uid3, _product$metadata6, _this$getTempOrder3;
4249
4425
  var productUid = getProductLineUid(product);
4250
- var bookingUid = String((_ref44 = (_product$booking_uid3 = product.booking_uid) !== null && _product$booking_uid3 !== void 0 ? _product$booking_uid3 : (_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.booking_uid) !== null && _ref44 !== void 0 ? _ref44 : '');
4426
+ var bookingUid = String((_ref45 = (_product$booking_uid3 = product.booking_uid) !== null && _product$booking_uid3 !== void 0 ? _product$booking_uid3 : (_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.booking_uid) !== null && _ref45 !== void 0 ? _ref45 : '');
4251
4427
  return (((_this$getTempOrder3 = this.getTempOrder()) === null || _this$getTempOrder3 === void 0 ? void 0 : _this$getTempOrder3.bookings) || []).find(function (booking) {
4252
4428
  var _booking$product_uid3;
4253
4429
  return bookingUid && getBookingUid(booking) === bookingUid || productUid && String((_booking$product_uid3 = booking.product_uid) !== null && _booking$product_uid3 !== void 0 ? _booking$product_uid3 : '') === productUid;
@@ -4259,7 +4435,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4259
4435
  key: "commitAvailabilitySelection",
4260
4436
  value: (function () {
4261
4437
  var _commitAvailabilitySelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(contextId, params) {
4262
- var normalizedContextId, _params$bookingCount, _ref45, _params$orderProduct$, _params$orderProduct, _params$orderProduct2, _params$orderProduct3, _params$orderProduct$2, _params$orderProduct4, _params$orderProduct5, _editingLine$product_, _baseProjection$meta$, _refreshedProjection$, _baseProjection$meta$2, _ref46, _params$orderProduct$3, _params$orderProduct6, _existingBooking$meta, _ref47, _ref48, _params$orderProduct$4, _params$orderProduct7, _params$orderProduct8, _existingBooking$meta2, _existingBooking$hold, bookingCount, orderProductQuantity, partySize, _yield$this$ensureAva3, context, projectionEntry, refreshed, boundEditingUids, orderProductId, editingLine, _editingLine$product_2, baseProjection, commitWriteGuard, prepareParams, fallbackResources, commitSnapshot, refreshedProjection, _baseProjection$meta$3, latestContext, refreshedRanges, refreshedCandidateBase, validation, capacityConflict, revalidationEntry, revalidatedContext, refreshedCandidate, product, existingBooking, existingBookingUid, booking, transformed, productLineUid, bookingUid, productLineUids, bookingUids, _transformed$product_, _transformed$product_2, _transformed$product_3, _ref49, _transformed$product_4, _this$getTempOrder4, _this$getTempOrder5, _this$getTempOrder6, beforeProductLineUids, beforeBookingUids, products, addedLines, addedBookings, nextContext, result;
4438
+ var normalizedContextId, _params$bookingCount, _ref46, _params$orderProduct$, _params$orderProduct, _params$orderProduct2, _params$orderProduct3, _params$orderProduct$2, _params$orderProduct4, _params$orderProduct5, _editingLine$product_, _baseProjection$meta$, _refreshedProjection$, _baseProjection$meta$2, _this$otherParams$pla2, _this$otherParams20, _ref47, _params$orderProduct$3, _params$orderProduct6, _existingBooking$meta, _ref48, _ref49, _params$orderProduct$4, _params$orderProduct7, _params$orderProduct8, _existingBooking$meta2, _existingBooking$hold, bookingCount, orderProductQuantity, partySize, _yield$this$ensureAva3, context, projectionEntry, refreshed, boundEditingUids, orderProductId, editingLine, _editingLine$product_2, baseProjection, commitWriteGuard, prepareParams, fallbackResources, commitSnapshot, refreshedProjection, _baseProjection$meta$3, latestContext, candidateDurationMinutes, candidateStartTime, allowPosAvailabilityOverride, refreshedRanges, refreshedCandidateBase, product, validation, forced, capacityConflict, revalidationEntry, revalidatedContext, refreshedCandidate, existingBooking, existingBookingUid, booking, transformed, productLineUid, bookingUid, productLineUids, bookingUids, _transformed$product_, _transformed$product_2, _transformed$product_3, _ref50, _transformed$product_4, _this$getTempOrder4, _this$getTempOrder5, _this$getTempOrder6, beforeProductLineUids, beforeBookingUids, products, addedLines, addedBookings, nextContext, result;
4263
4439
  return _regeneratorRuntime().wrap(function _callee39$(_context39) {
4264
4440
  while (1) switch (_context39.prev = _context39.next) {
4265
4441
  case 0:
@@ -4293,7 +4469,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4293
4469
  bookingCount: bookingCount
4294
4470
  });
4295
4471
  case 11:
4296
- orderProductQuantity = (_ref45 = (_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 && _ref45 !== void 0 ? _ref45 : (_params$orderProduct3 = params.orderProduct) === null || _params$orderProduct3 === void 0 || (_params$orderProduct3 = _params$orderProduct3._extend) === null || _params$orderProduct3 === void 0 ? void 0 : _params$orderProduct3.quantity;
4472
+ orderProductQuantity = (_ref46 = (_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 && _ref46 !== void 0 ? _ref46 : (_params$orderProduct3 = params.orderProduct) === null || _params$orderProduct3 === void 0 || (_params$orderProduct3 = _params$orderProduct3._extend) === null || _params$orderProduct3 === void 0 ? void 0 : _params$orderProduct3.quantity;
4297
4473
  if (!(orderProductQuantity !== undefined && orderProductQuantity !== null && Number(orderProductQuantity) !== bookingCount)) {
4298
4474
  _context39.next = 14;
4299
4475
  break;
@@ -4487,20 +4663,29 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4487
4663
  });
4488
4664
  case 67:
4489
4665
  this.assertAvailabilityCommitWriteCAS(commitWriteGuard);
4490
- refreshedRanges = getProjectionProductTimeRanges(refreshedProjection, {
4666
+ candidateDurationMinutes = getCandidateDurationMinutes(params.candidate);
4667
+ candidateStartTime = getCandidateStartTime(params.candidate);
4668
+ allowPosAvailabilityOverride = String((_this$otherParams$pla2 = (_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.platform) !== null && _this$otherParams$pla2 !== void 0 ? _this$otherParams$pla2 : '').trim().toLowerCase() === 'pos';
4669
+ refreshedRanges = getProjectionProductTimeRanges(refreshedProjection, _objectSpread({
4491
4670
  productIds: [params.candidate.productId],
4492
4671
  dateRange: {
4493
4672
  startDate: params.candidate.startAt.slice(0, 10),
4494
4673
  endDate: params.candidate.startAt.slice(0, 10)
4495
4674
  }
4496
- }).flatMap(function (group) {
4675
+ }, candidateDurationMinutes ? _objectSpread({
4676
+ durationMinutesByProductId: _defineProperty({}, String(params.candidate.productId), candidateDurationMinutes)
4677
+ }, candidateStartTime ? _objectSpread({
4678
+ durationStartTimesByProductId: _defineProperty({}, String(params.candidate.productId), [candidateStartTime])
4679
+ }, allowPosAvailabilityOverride ? {
4680
+ allowOutsideOperatingHoursForRequestedStartTimes: true
4681
+ } : {}) : {}) : {})).flatMap(function (group) {
4497
4682
  return group.ranges;
4498
4683
  });
4499
4684
  refreshedCandidateBase = refreshedRanges.find(function (candidate) {
4500
4685
  return candidate.startAt === params.candidate.startAt && candidate.endAt === params.candidate.endAt && candidate.bookingStartAt === params.candidate.bookingStartAt && candidate.bookingEndAt === params.candidate.bookingEndAt;
4501
4686
  });
4502
4687
  if (refreshedCandidateBase) {
4503
- _context39.next = 72;
4688
+ _context39.next = 75;
4504
4689
  break;
4505
4690
  }
4506
4691
  throw new AvailabilityError('REVALIDATION_FAILED', '缓存重校验后候选时间已不在商品配置中', {
@@ -4508,15 +4693,46 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4508
4693
  candidate: params.candidate,
4509
4694
  refreshedSnapshotId: refreshedProjection.meta.snapshotId
4510
4695
  });
4511
- case 72:
4696
+ case 75:
4697
+ product = refreshedProjection.products.find(function (item) {
4698
+ return sameAvailabilityId(item.id, refreshedCandidateBase.productId);
4699
+ });
4700
+ if (product) {
4701
+ _context39.next = 78;
4702
+ break;
4703
+ }
4704
+ throw new AvailabilityError('REVALIDATION_FAILED', '缓存重校验后商品不在 projection 中', {
4705
+ productId: refreshedCandidateBase.productId
4706
+ });
4707
+ case 78:
4512
4708
  validation = validateAvailabilitySelection(refreshedProjection, {
4513
4709
  candidate: refreshedCandidateBase,
4514
4710
  requirementSelections: params.requirementSelections,
4515
4711
  partySize: partySize,
4516
4712
  bookingCount: bookingCount
4517
4713
  });
4714
+ if (allowPosAvailabilityOverride && !validation.ok && validation.conflicts.every(function (conflict) {
4715
+ return POS_OVERRIDABLE_AVAILABILITY_CONFLICT_CODES.has(conflict.code);
4716
+ })) {
4717
+ forced = buildPosForcedAvailabilityAssignments({
4718
+ product: product,
4719
+ resources: refreshedProjection.resources,
4720
+ candidate: refreshedCandidateBase,
4721
+ requirementSelections: params.requirementSelections,
4722
+ partySize: partySize
4723
+ });
4724
+ validation = forced.conflicts.length > 0 ? _objectSpread(_objectSpread({}, validation), {}, {
4725
+ assignments: [],
4726
+ conflicts: forced.conflicts
4727
+ }) : _objectSpread(_objectSpread({}, validation), {}, {
4728
+ ok: true,
4729
+ status: validation.availability.status,
4730
+ assignments: forced.assignments,
4731
+ conflicts: []
4732
+ });
4733
+ }
4518
4734
  if (validation.ok) {
4519
- _context39.next = 76;
4735
+ _context39.next = 83;
4520
4736
  break;
4521
4737
  }
4522
4738
  capacityConflict = validation.conflicts.find(function (conflict) {
@@ -4526,7 +4742,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4526
4742
  validation: validation,
4527
4743
  refreshedSnapshotId: refreshedProjection.meta.snapshotId
4528
4744
  });
4529
- case 76:
4745
+ case 83:
4530
4746
  // Revalidation failure must leave the caller's candidate reusable. Only publish the
4531
4747
  // refreshed projection/version after candidate and resource validation has passed;
4532
4748
  // otherwise a second Confirm from the still-open modal would incorrectly become stale.
@@ -4539,7 +4755,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4539
4755
  incrementVersion: true
4540
4756
  });
4541
4757
  revalidatedContext = this.getAvailabilityContextEntry(normalizedContextId);
4542
- _context39.next = 80;
4758
+ _context39.next = 87;
4543
4759
  return this.emitAvailabilityDiagnostic({
4544
4760
  action: 'refresh',
4545
4761
  contextId: normalizedContextId,
@@ -4550,7 +4766,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4550
4766
  previousOrderRevision: baseProjection.meta.orderRevision,
4551
4767
  reason: 'commit_cached_occupancy_revalidation'
4552
4768
  });
4553
- case 80:
4769
+ case 87:
4554
4770
  commitWriteGuard = {
4555
4771
  contextId: normalizedContextId,
4556
4772
  expectedVersion: revalidatedContext.activeVersion,
@@ -4559,27 +4775,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4559
4775
  expectedOrderRevision: revalidationEntry.orderRevision
4560
4776
  };
4561
4777
  refreshedCandidate = this.decorateAvailabilityCandidate(normalizedContextId, revalidatedContext.activeVersion, refreshedCandidateBase);
4562
- product = refreshedProjection.products.find(function (item) {
4563
- return sameAvailabilityId(item.id, refreshedCandidate.productId);
4564
- });
4565
- if (product) {
4566
- _context39.next = 85;
4567
- break;
4568
- }
4569
- throw new AvailabilityError('REVALIDATION_FAILED', '缓存重校验后商品不在 projection 中', {
4570
- productId: refreshedCandidate.productId
4571
- });
4572
- case 85:
4573
4778
  existingBooking = editingLine ? this.findLinkedBooking(editingLine) : undefined;
4574
4779
  existingBookingUid = existingBooking ? getBookingUid(existingBooking) : '';
4575
4780
  if (!(params.mode === 'edit' && !existingBookingUid)) {
4576
- _context39.next = 89;
4781
+ _context39.next = 93;
4577
4782
  break;
4578
4783
  }
4579
4784
  throw new AvailabilityError('PRODUCT_LINE_NOT_FOUND', '编辑商品行缺少关联 booking', {
4580
4785
  productLineUid: params.productLineUid
4581
4786
  });
4582
- case 89:
4787
+ case 93:
4583
4788
  this.assertAvailabilityCommitWriteCAS(commitWriteGuard);
4584
4789
  booking = buildBookingFromAvailabilitySelection({
4585
4790
  assignments: validation.assignments,
@@ -4587,21 +4792,21 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4587
4792
  product: product,
4588
4793
  resources: refreshedProjection.resources,
4589
4794
  bookingUid: existingBookingUid || undefined,
4590
- holder: (_ref46 = (_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 : existingBooking === null || existingBooking === void 0 ? void 0 : existingBooking.holder) !== null && _ref46 !== void 0 ? _ref46 : existingBooking === null || existingBooking === void 0 || (_existingBooking$meta = existingBooking.metadata) === null || _existingBooking$meta === void 0 ? void 0 : _existingBooking$meta.holder,
4591
- holderIds: (_ref47 = (_ref48 = (_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 && _ref48 !== void 0 ? _ref48 : existingBooking === null || existingBooking === void 0 || (_existingBooking$meta2 = existingBooking.metadata) === null || _existingBooking$meta2 === void 0 ? void 0 : _existingBooking$meta2.holder_id) !== null && _ref47 !== void 0 ? _ref47 : existingBooking === null || existingBooking === void 0 || (_existingBooking$hold = existingBooking.holder) === null || _existingBooking$hold === void 0 ? void 0 : _existingBooking$hold.form_record
4795
+ holder: (_ref47 = (_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 : existingBooking === null || existingBooking === void 0 ? void 0 : existingBooking.holder) !== null && _ref47 !== void 0 ? _ref47 : existingBooking === null || existingBooking === void 0 || (_existingBooking$meta = existingBooking.metadata) === null || _existingBooking$meta === void 0 ? void 0 : _existingBooking$meta.holder,
4796
+ holderIds: (_ref48 = (_ref49 = (_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 && _ref49 !== void 0 ? _ref49 : existingBooking === null || existingBooking === void 0 || (_existingBooking$meta2 = existingBooking.metadata) === null || _existingBooking$meta2 === void 0 ? void 0 : _existingBooking$meta2.holder_id) !== null && _ref48 !== void 0 ? _ref48 : existingBooking === null || existingBooking === void 0 || (_existingBooking$hold = existingBooking.holder) === null || _existingBooking$hold === void 0 ? void 0 : _existingBooking$hold.form_record
4592
4797
  });
4593
4798
  transformed = this.buildUnifiedOrderProduct(_objectSpread(_objectSpread({}, params.orderProduct), {}, {
4594
4799
  num: bookingCount,
4595
4800
  quantity: bookingCount
4596
4801
  }), 'unified_booking_sales', product);
4597
4802
  if (transformed) {
4598
- _context39.next = 94;
4803
+ _context39.next = 98;
4599
4804
  break;
4600
4805
  }
4601
4806
  throw new AvailabilityError('INVALID_TARGET_FILTER', 'orderProduct 无法转换为订单行', {
4602
4807
  orderProduct: params.orderProduct
4603
4808
  });
4604
- case 94:
4809
+ case 98:
4605
4810
  transformed.num = bookingCount;
4606
4811
  transformed.metadata = _objectSpread(_objectSpread({}, transformed.metadata || {}), {}, {
4607
4812
  unified_booking_sales: true,
@@ -4614,7 +4819,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4614
4819
  productLineUids = [];
4615
4820
  bookingUids = [];
4616
4821
  if (!(params.mode === 'edit' && editingLine && params.productLineUid)) {
4617
- _context39.next = 113;
4822
+ _context39.next = 117;
4618
4823
  break;
4619
4824
  }
4620
4825
  transformed.product_sku = (_transformed$product_ = transformed.product_sku) !== null && _transformed$product_ !== void 0 ? _transformed$product_ : editingLine.product_sku;
@@ -4624,31 +4829,35 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4624
4829
  unique_identification_number: params.productLineUid,
4625
4830
  booking_uid: existingBookingUid
4626
4831
  });
4627
- _context39.next = 107;
4628
- return this.updateOrderProduct({
4832
+ _context39.next = 111;
4833
+ return this.updateOrderProduct(_objectSpread(_objectSpread({
4629
4834
  product_id: (_transformed$product_3 = transformed.product_id) !== null && _transformed$product_3 !== void 0 ? _transformed$product_3 : editingLine.product_id,
4630
- product_variant_id: (_ref49 = (_transformed$product_4 = transformed.product_variant_id) !== null && _transformed$product_4 !== void 0 ? _transformed$product_4 : editingLine.product_variant_id) !== null && _ref49 !== void 0 ? _ref49 : 0,
4835
+ product_variant_id: (_ref50 = (_transformed$product_4 = transformed.product_variant_id) !== null && _transformed$product_4 !== void 0 ? _transformed$product_4 : editingLine.product_variant_id) !== null && _ref50 !== void 0 ? _ref50 : 0,
4631
4836
  unique_identification_number: params.productLineUid,
4632
4837
  updates: transformed,
4633
4838
  booking: booking
4634
- });
4635
- case 107:
4839
+ }, params.allowBookingReprice !== undefined ? {
4840
+ allow_booking_reprice: params.allowBookingReprice
4841
+ } : {}), params.allowBookingDiscountReapply !== undefined ? {
4842
+ allow_booking_discount_reapply: params.allowBookingDiscountReapply
4843
+ } : {}));
4844
+ case 111:
4636
4845
  productLineUid = params.productLineUid;
4637
4846
  bookingUid = existingBookingUid;
4638
4847
  productLineUids = [productLineUid];
4639
4848
  bookingUids = [bookingUid];
4640
- _context39.next = 125;
4849
+ _context39.next = 129;
4641
4850
  break;
4642
- case 113:
4851
+ case 117:
4643
4852
  beforeProductLineUids = new Set((((_this$getTempOrder4 = this.getTempOrder()) === null || _this$getTempOrder4 === void 0 ? void 0 : _this$getTempOrder4.products) || []).map(function (line) {
4644
4853
  return getProductLineUid(line);
4645
4854
  }).filter(Boolean));
4646
4855
  beforeBookingUids = new Set((((_this$getTempOrder5 = this.getTempOrder()) === null || _this$getTempOrder5 === void 0 ? void 0 : _this$getTempOrder5.bookings) || []).map(function (item) {
4647
4856
  return getBookingUid(item);
4648
4857
  }).filter(Boolean));
4649
- _context39.next = 117;
4858
+ _context39.next = 121;
4650
4859
  return this.addProductToOrder(transformed, booking);
4651
- case 117:
4860
+ case 121:
4652
4861
  products = _context39.sent;
4653
4862
  addedLines = products.filter(function (line) {
4654
4863
  var _line$product_id, _line$metadata;
@@ -4666,13 +4875,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4666
4875
  }).filter(Boolean);
4667
4876
  if (bookingUids.length === 0) {
4668
4877
  bookingUids = addedLines.map(function (line) {
4669
- var _ref50, _line$booking_uid, _line$metadata2;
4670
- return String((_ref50 = (_line$booking_uid = line.booking_uid) !== null && _line$booking_uid !== void 0 ? _line$booking_uid : (_line$metadata2 = line.metadata) === null || _line$metadata2 === void 0 ? void 0 : _line$metadata2.booking_uid) !== null && _ref50 !== void 0 ? _ref50 : '');
4878
+ var _ref51, _line$booking_uid, _line$metadata2;
4879
+ return String((_ref51 = (_line$booking_uid = line.booking_uid) !== null && _line$booking_uid !== void 0 ? _line$booking_uid : (_line$metadata2 = line.metadata) === null || _line$metadata2 === void 0 ? void 0 : _line$metadata2.booking_uid) !== null && _ref51 !== void 0 ? _ref51 : '');
4671
4880
  }).filter(Boolean);
4672
4881
  }
4673
4882
  productLineUid = productLineUids[productLineUids.length - 1] || '';
4674
4883
  bookingUid = bookingUids[bookingUids.length - 1] || '';
4675
- case 125:
4884
+ case 129:
4676
4885
  this.invalidateAvailabilityContextsAfterCommit();
4677
4886
  nextContext = this.getAvailabilityContextEntry(normalizedContextId);
4678
4887
  result = {
@@ -4686,21 +4895,21 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4686
4895
  productLineUids: productLineUids,
4687
4896
  bookingUids: bookingUids
4688
4897
  };
4689
- _context39.next = 130;
4690
- return this.core.effects.emit("".concat(this.name, ":").concat(UnifiedBookingSalesHooks.onAvailabilitySelectionCommitted), result);
4691
- case 130:
4692
- return _context39.abrupt("return", result);
4693
- case 131:
4694
- _context39.prev = 131;
4695
4898
  _context39.next = 134;
4696
- return this.releaseAvailabilityCommitLock(normalizedContextId);
4899
+ return this.core.effects.emit("".concat(this.name, ":").concat(UnifiedBookingSalesHooks.onAvailabilitySelectionCommitted), result);
4697
4900
  case 134:
4698
- return _context39.finish(131);
4901
+ return _context39.abrupt("return", result);
4699
4902
  case 135:
4903
+ _context39.prev = 135;
4904
+ _context39.next = 138;
4905
+ return this.releaseAvailabilityCommitLock(normalizedContextId);
4906
+ case 138:
4907
+ return _context39.finish(135);
4908
+ case 139:
4700
4909
  case "end":
4701
4910
  return _context39.stop();
4702
4911
  }
4703
- }, _callee39, this, [[5,, 131, 135]]);
4912
+ }, _callee39, this, [[5,, 135, 139]]);
4704
4913
  }));
4705
4914
  function commitAvailabilitySelection(_x32, _x33) {
4706
4915
  return _commitAvailabilitySelection.apply(this, arguments);