@pisell/pisellos 0.10.20 → 0.10.22

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 (88) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  2. package/dist/modules/BookingContext/index.d.ts +3 -0
  3. package/dist/modules/BookingContext/index.js +42 -13
  4. package/dist/modules/BookingContext/types.d.ts +4 -4
  5. package/dist/modules/BookingContext/types.js +3 -3
  6. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +10 -7
  7. package/dist/modules/OpenData/index.d.ts +10 -1
  8. package/dist/modules/OpenData/index.js +268 -14
  9. package/dist/modules/OpenData/types.d.ts +14 -1
  10. package/dist/modules/OpenData/utils.d.ts +1 -0
  11. package/dist/modules/OpenData/utils.js +8 -5
  12. package/dist/modules/Order/index.d.ts +6 -1
  13. package/dist/modules/Order/index.js +148 -84
  14. package/dist/modules/ProductList/clientDataVariants.d.ts +50 -0
  15. package/dist/modules/ProductList/clientDataVariants.js +216 -0
  16. package/dist/modules/ProductList/index.d.ts +14 -13
  17. package/dist/modules/ProductList/index.js +105 -77
  18. package/dist/modules/Quotation/index.d.ts +16 -0
  19. package/dist/modules/Quotation/index.js +240 -27
  20. package/dist/modules/ResourcePlanner/planner.d.ts +2 -2
  21. package/dist/modules/ResourcePlanner/planner.js +88 -21
  22. package/dist/modules/ResourcePlanner/types.d.ts +12 -0
  23. package/dist/modules/Rules/index.d.ts +5 -0
  24. package/dist/modules/Rules/index.js +27 -12
  25. package/dist/plugins/request.d.ts +2 -1
  26. package/dist/plugins/request.js +4 -2
  27. package/dist/server/index.js +33 -16
  28. package/dist/solution/BaseSales/index.d.ts +16 -1
  29. package/dist/solution/BaseSales/index.js +690 -349
  30. package/dist/solution/BookingByStep/index.d.ts +1 -1
  31. package/dist/solution/BookingTicket/index.d.ts +14 -2
  32. package/dist/solution/BookingTicket/index.js +25 -18
  33. package/dist/solution/Sales/index.js +29 -22
  34. package/dist/solution/UnifiedBookingSales/index.d.ts +1 -1
  35. package/dist/solution/UnifiedBookingSales/index.js +315 -99
  36. package/dist/solution/UnifiedBookingSales/types.d.ts +4 -0
  37. package/dist/solution/VenueBooking/index.d.ts +2 -0
  38. package/dist/solution/VenueBooking/index.js +542 -494
  39. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
  40. package/dist/solution/VenueBooking/utils/dateSummary.js +3 -1
  41. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +2 -0
  42. package/dist/solution/VenueBooking/utils/slotMerge.js +3 -1
  43. package/dist/utils/platform.d.ts +8 -0
  44. package/dist/utils/platform.js +15 -0
  45. package/lib/modules/BookingContext/index.d.ts +3 -0
  46. package/lib/modules/BookingContext/index.js +35 -8
  47. package/lib/modules/BookingContext/types.d.ts +4 -4
  48. package/lib/modules/BookingContext/types.js +3 -3
  49. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +4 -0
  50. package/lib/modules/OpenData/index.d.ts +10 -1
  51. package/lib/modules/OpenData/index.js +162 -2
  52. package/lib/modules/OpenData/types.d.ts +14 -1
  53. package/lib/modules/OpenData/utils.d.ts +1 -0
  54. package/lib/modules/OpenData/utils.js +9 -5
  55. package/lib/modules/Order/index.d.ts +6 -1
  56. package/lib/modules/Order/index.js +65 -8
  57. package/lib/modules/ProductList/clientDataVariants.d.ts +50 -0
  58. package/lib/modules/ProductList/clientDataVariants.js +204 -0
  59. package/lib/modules/ProductList/index.d.ts +14 -13
  60. package/lib/modules/ProductList/index.js +77 -58
  61. package/lib/modules/Quotation/index.d.ts +16 -0
  62. package/lib/modules/Quotation/index.js +112 -9
  63. package/lib/modules/ResourcePlanner/planner.d.ts +2 -2
  64. package/lib/modules/ResourcePlanner/planner.js +80 -20
  65. package/lib/modules/ResourcePlanner/types.d.ts +12 -0
  66. package/lib/modules/Rules/index.d.ts +5 -0
  67. package/lib/modules/Rules/index.js +20 -11
  68. package/lib/plugins/request.d.ts +2 -1
  69. package/lib/plugins/request.js +3 -2
  70. package/lib/server/index.js +16 -1
  71. package/lib/solution/BaseSales/index.d.ts +16 -1
  72. package/lib/solution/BaseSales/index.js +314 -66
  73. package/lib/solution/BookingByStep/index.d.ts +1 -1
  74. package/lib/solution/BookingTicket/index.d.ts +14 -2
  75. package/lib/solution/BookingTicket/index.js +3 -0
  76. package/lib/solution/Sales/index.js +3 -0
  77. package/lib/solution/UnifiedBookingSales/index.d.ts +1 -1
  78. package/lib/solution/UnifiedBookingSales/index.js +228 -20
  79. package/lib/solution/UnifiedBookingSales/types.d.ts +4 -0
  80. package/lib/solution/VenueBooking/index.d.ts +2 -0
  81. package/lib/solution/VenueBooking/index.js +28 -8
  82. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
  83. package/lib/solution/VenueBooking/utils/dateSummary.js +3 -1
  84. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +2 -0
  85. package/lib/solution/VenueBooking/utils/slotMerge.js +3 -1
  86. package/lib/utils/platform.d.ts +8 -0
  87. package/lib/utils/platform.js +22 -0
  88. 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",
@@ -1937,29 +2096,36 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1937
2096
  cachedData = this.store.openData.getOpenData();
1938
2097
  lastFetchedAt = this.store.openData.getLastFetchedAt();
1939
2098
  if (!(!params.force && this.openDataTarget === target && cachedData && lastFetchedAt && Date.now() - lastFetchedAt < OPEN_DATA_CACHE_TTL)) {
1940
- _context11.next = 11;
2099
+ _context11.next = 14;
2100
+ break;
2101
+ }
2102
+ if (!(typeof this.store.openData.ensureInvoiceTemplateSettings === 'function')) {
2103
+ _context11.next = 13;
1941
2104
  break;
1942
2105
  }
2106
+ _context11.next = 13;
2107
+ return this.store.openData.ensureInvoiceTemplateSettings(target);
2108
+ case 13:
1943
2109
  return _context11.abrupt("return", cachedData);
1944
- case 11:
2110
+ case 14:
1945
2111
  if (!this.loadOpenDataInFlight) {
1946
- _context11.next = 19;
2112
+ _context11.next = 22;
1947
2113
  break;
1948
2114
  }
1949
2115
  if (!(this.loadOpenDataInFlightTarget === target)) {
1950
- _context11.next = 16;
2116
+ _context11.next = 19;
1951
2117
  break;
1952
2118
  }
1953
- _context11.next = 15;
1954
- return this.loadOpenDataInFlight;
1955
- case 15:
1956
- return _context11.abrupt("return", _context11.sent);
1957
- case 16:
1958
2119
  _context11.next = 18;
1959
2120
  return this.loadOpenDataInFlight;
1960
2121
  case 18:
1961
- return _context11.abrupt("return", this.loadOpenData(params));
2122
+ return _context11.abrupt("return", _context11.sent);
1962
2123
  case 19:
2124
+ _context11.next = 21;
2125
+ return this.loadOpenDataInFlight;
2126
+ case 21:
2127
+ return _context11.abrupt("return", this.loadOpenData(params));
2128
+ case 22:
1963
2129
  this.loadOpenDataInFlightTarget = target;
1964
2130
  request = this.store.openData.fetchOpenData({
1965
2131
  scope: 'board',
@@ -1967,10 +2133,10 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1967
2133
  section_code: [].concat(OPEN_DATA_SECTION_CODES)
1968
2134
  });
1969
2135
  this.loadOpenDataInFlight = request;
1970
- _context11.prev = 22;
1971
- _context11.next = 25;
2136
+ _context11.prev = 25;
2137
+ _context11.next = 28;
1972
2138
  return request;
1973
- case 25:
2139
+ case 28:
1974
2140
  openData = _context11.sent;
1975
2141
  if (this.loadOpenDataInFlight === request) {
1976
2142
  this.openDataTarget = target;
@@ -1979,18 +2145,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1979
2145
  this.otherParams.channel = channel;
1980
2146
  }
1981
2147
  return _context11.abrupt("return", openData);
1982
- case 28:
1983
- _context11.prev = 28;
2148
+ case 31:
2149
+ _context11.prev = 31;
1984
2150
  if (this.loadOpenDataInFlight === request) {
1985
2151
  this.loadOpenDataInFlight = null;
1986
2152
  this.loadOpenDataInFlightTarget = null;
1987
2153
  }
1988
- return _context11.finish(28);
1989
- case 31:
2154
+ return _context11.finish(31);
2155
+ case 34:
1990
2156
  case "end":
1991
2157
  return _context11.stop();
1992
2158
  }
1993
- }, _callee11, this, [[22,, 28, 31]]);
2159
+ }, _callee11, this, [[25,, 31, 34]]);
1994
2160
  }));
1995
2161
  function loadOpenData(_x7) {
1996
2162
  return _loadOpenData.apply(this, arguments);
@@ -2114,7 +2280,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2114
2280
  key: "getProtocol",
2115
2281
  value: (function () {
2116
2282
  var _getProtocol = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(policyId) {
2117
- var normalizedPolicyId;
2283
+ var normalizedPolicyId, policyUrl;
2118
2284
  return _regeneratorRuntime().wrap(function _callee15$(_context15) {
2119
2285
  while (1) switch (_context15.prev = _context15.next) {
2120
2286
  case 0:
@@ -2125,8 +2291,12 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2125
2291
  }
2126
2292
  throw new Error('[UnifiedBookingSales] getProtocol 需要 policyId');
2127
2293
  case 3:
2128
- return _context15.abrupt("return", this.request.get("/shop-policy/".concat(encodeURIComponent(normalizedPolicyId))));
2129
- 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:
2130
2300
  case "end":
2131
2301
  return _context15.stop();
2132
2302
  }
@@ -2564,23 +2734,26 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2564
2734
  }, {
2565
2735
  key: "buildUnifiedOrderProduct",
2566
2736
  value: function buildUnifiedOrderProduct(sourceProduct, ownershipKey, product) {
2567
- 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;
2568
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;
2569
2740
  var orderProduct = this.transformBaseProductToOrderProduct({
2570
2741
  payload: _objectSpread(_objectSpread({}, sourceProduct), {}, {
2571
2742
  id: (_sourceProduct$id = sourceProduct.id) !== null && _sourceProduct$id !== void 0 ? _sourceProduct$id : product === null || product === void 0 ? void 0 : product.id,
2572
- 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,
2573
- 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,
2574
2745
  price: (_sourceProduct$price = sourceProduct.price) !== null && _sourceProduct$price !== void 0 ? _sourceProduct$price : normalizedProductRaw.price,
2575
- 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,
2576
2747
  metadata: _objectSpread(_objectSpread({}, sourceProduct.metadata || {}), {}, _defineProperty({}, ownershipKey, true))
2577
2748
  }),
2578
2749
  sourceProduct: sourceProduct
2579
2750
  });
2580
2751
  if (orderProduct && _typeof(orderProduct) === 'object') {
2581
- // BaseSales may rebuild metadata from its price source. Stamp ownership after that transform
2582
- // so each UnifiedBookingSales entry point can replace only its own temporary lines.
2583
- 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
+ } : {});
2584
2757
  }
2585
2758
  return orderProduct;
2586
2759
  }
@@ -2730,7 +2903,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2730
2903
  key: "addRetailProduct",
2731
2904
  value: (function () {
2732
2905
  var _addRetailProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
2733
- var _params$quantity, _ref38, _params$productId, _params$product, _params$product2;
2906
+ var _params$quantity, _ref39, _params$productId, _params$product, _params$product2;
2734
2907
  var quantity, productId, sourceProduct, products, orderProduct;
2735
2908
  return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2736
2909
  while (1) switch (_context23.prev = _context23.next) {
@@ -2742,7 +2915,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2742
2915
  }
2743
2916
  throw new Error('[UnifiedBookingSales] retail 商品数量必须大于 0');
2744
2917
  case 3:
2745
- 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;
2746
2919
  sourceProduct = params.product;
2747
2920
  if (!sourceProduct && productId !== undefined && productId !== null) {
2748
2921
  sourceProduct = this.unifiedProductCatalog.find(function (product) {
@@ -3047,8 +3220,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3047
3220
  return _context24.abrupt("return", normalized.filter(function (product) {
3048
3221
  var _product$requirementG2;
3049
3222
  return (_product$requirementG2 = product.requirementGroups) === null || _product$requirementG2 === void 0 ? void 0 : _product$requirementG2.some(function (group) {
3050
- var _group$resourceIds2;
3051
- 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) {
3052
3225
  return prepare.resourceIds.some(function (id) {
3053
3226
  return sameAvailabilityId(id, resourceId);
3054
3227
  });
@@ -3346,7 +3519,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3346
3519
  var products = Array.isArray(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) ? tempOrder.products : [];
3347
3520
  var bookings = Array.isArray(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.bookings) ? tempOrder.bookings : [];
3348
3521
  productLineUids.forEach(function (requestedUid) {
3349
- var _ref39, _product$booking_uid2, _product$metadata5;
3522
+ var _ref40, _product$booking_uid2, _product$metadata5;
3350
3523
  var product = products.find(function (line) {
3351
3524
  return getProductLineUid(line) === String(requestedUid);
3352
3525
  });
@@ -3356,7 +3529,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3356
3529
  });
3357
3530
  }
3358
3531
  var productUid = getProductLineUid(product);
3359
- 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 : '');
3360
3533
  var linkedBookings = bookings.filter(function (booking) {
3361
3534
  var _booking$product_uid;
3362
3535
  return linkedBookingUid && getBookingUid(booking) === linkedBookingUid || productUid && String((_booking$product_uid = booking.product_uid) !== null && _booking$product_uid !== void 0 ? _booking$product_uid : '') === productUid;
@@ -3402,16 +3575,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3402
3575
  var _this5 = this;
3403
3576
  var bookings = Array.isArray(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.bookings) ? tempOrder.bookings : [];
3404
3577
  return bookings.flatMap(function (booking) {
3405
- var _ref40, _booking$product_uid2, _booking$metadata2;
3578
+ var _ref41, _booking$product_uid2, _booking$metadata2;
3406
3579
  var bookingUid = getBookingUid(booking);
3407
- 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 : '');
3408
3581
  var scheduleEventId = toNumberId(booking.schedule_event_id);
3409
3582
  var startAt = booking.start_at || "".concat(booking.start_date || '', " ").concat(booking.start_time || '').trim();
3410
3583
  var endAt = booking.end_at || "".concat(booking.end_date || booking.start_date || '', " ").concat(booking.end_time || '').trim();
3411
3584
  var resources = Array.isArray(booking.resources) ? booking.resources : [];
3412
3585
  return resources.flatMap(function (resource) {
3413
- var _ref41, _resource$resource_id, _ref42, _resource$capacity;
3414
- 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;
3415
3588
  if (resourceId == null || !startAt || !endAt) return [];
3416
3589
  var range = normalizeAvailabilityLocalDateTimeRange({
3417
3590
  startAt: startAt,
@@ -3424,7 +3597,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3424
3597
  resourceId: resourceId,
3425
3598
  startAt: range.startAt,
3426
3599
  endAt: range.endAt,
3427
- 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),
3428
3601
  source: 'cart',
3429
3602
  scheduleEventId: scheduleEventId,
3430
3603
  bookingUid: bookingUid || undefined,
@@ -4086,17 +4259,20 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4086
4259
  return _prepareAvailabilityProjection.apply(this, arguments);
4087
4260
  }
4088
4261
  return prepareAvailabilityProjection;
4089
- }() /** Pure configuration calculation over the current context projection. */)
4262
+ }() /** Candidate calculation over the current context projection and runtime minute. */)
4090
4263
  }, {
4091
4264
  key: "getProductTimeRanges",
4092
4265
  value: (function () {
4093
4266
  var _getProductTimeRanges = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(contextId) {
4094
- var _this9 = this;
4267
+ var _this$otherParams$pla,
4268
+ _this$otherParams19,
4269
+ _this9 = this;
4095
4270
  var request,
4096
4271
  _yield$this$ensureAva,
4097
4272
  context,
4098
4273
  projectionEntry,
4099
4274
  contextVersion,
4275
+ allowOutsideOperatingHoursForRequestedStartTimes,
4100
4276
  _args37 = arguments;
4101
4277
  return _regeneratorRuntime().wrap(function _callee37$(_context37) {
4102
4278
  while (1) switch (_context37.prev = _context37.next) {
@@ -4109,14 +4285,21 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4109
4285
  context = _yield$this$ensureAva.context;
4110
4286
  projectionEntry = _yield$this$ensureAva.projectionEntry;
4111
4287
  contextVersion = context.activeVersion;
4112
- 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) {
4113
4296
  return _objectSpread(_objectSpread({}, group), {}, {
4114
4297
  ranges: group.ranges.map(function (candidate) {
4115
4298
  return _this9.decorateAvailabilityCandidate(context.contextId, contextVersion, candidate);
4116
4299
  })
4117
4300
  });
4118
4301
  }));
4119
- case 8:
4302
+ case 9:
4120
4303
  case "end":
4121
4304
  return _context37.stop();
4122
4305
  }
@@ -4238,9 +4421,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4238
4421
  }, {
4239
4422
  key: "findLinkedBooking",
4240
4423
  value: function findLinkedBooking(product) {
4241
- var _ref44, _product$booking_uid3, _product$metadata6, _this$getTempOrder3;
4424
+ var _ref45, _product$booking_uid3, _product$metadata6, _this$getTempOrder3;
4242
4425
  var productUid = getProductLineUid(product);
4243
- 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 : '');
4244
4427
  return (((_this$getTempOrder3 = this.getTempOrder()) === null || _this$getTempOrder3 === void 0 ? void 0 : _this$getTempOrder3.bookings) || []).find(function (booking) {
4245
4428
  var _booking$product_uid3;
4246
4429
  return bookingUid && getBookingUid(booking) === bookingUid || productUid && String((_booking$product_uid3 = booking.product_uid) !== null && _booking$product_uid3 !== void 0 ? _booking$product_uid3 : '') === productUid;
@@ -4252,7 +4435,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4252
4435
  key: "commitAvailabilitySelection",
4253
4436
  value: (function () {
4254
4437
  var _commitAvailabilitySelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(contextId, params) {
4255
- 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;
4256
4439
  return _regeneratorRuntime().wrap(function _callee39$(_context39) {
4257
4440
  while (1) switch (_context39.prev = _context39.next) {
4258
4441
  case 0:
@@ -4286,7 +4469,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4286
4469
  bookingCount: bookingCount
4287
4470
  });
4288
4471
  case 11:
4289
- 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;
4290
4473
  if (!(orderProductQuantity !== undefined && orderProductQuantity !== null && Number(orderProductQuantity) !== bookingCount)) {
4291
4474
  _context39.next = 14;
4292
4475
  break;
@@ -4480,20 +4663,29 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4480
4663
  });
4481
4664
  case 67:
4482
4665
  this.assertAvailabilityCommitWriteCAS(commitWriteGuard);
4483
- 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({
4484
4670
  productIds: [params.candidate.productId],
4485
4671
  dateRange: {
4486
4672
  startDate: params.candidate.startAt.slice(0, 10),
4487
4673
  endDate: params.candidate.startAt.slice(0, 10)
4488
4674
  }
4489
- }).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) {
4490
4682
  return group.ranges;
4491
4683
  });
4492
4684
  refreshedCandidateBase = refreshedRanges.find(function (candidate) {
4493
4685
  return candidate.startAt === params.candidate.startAt && candidate.endAt === params.candidate.endAt && candidate.bookingStartAt === params.candidate.bookingStartAt && candidate.bookingEndAt === params.candidate.bookingEndAt;
4494
4686
  });
4495
4687
  if (refreshedCandidateBase) {
4496
- _context39.next = 72;
4688
+ _context39.next = 75;
4497
4689
  break;
4498
4690
  }
4499
4691
  throw new AvailabilityError('REVALIDATION_FAILED', '缓存重校验后候选时间已不在商品配置中', {
@@ -4501,15 +4693,46 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4501
4693
  candidate: params.candidate,
4502
4694
  refreshedSnapshotId: refreshedProjection.meta.snapshotId
4503
4695
  });
4504
- 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:
4505
4708
  validation = validateAvailabilitySelection(refreshedProjection, {
4506
4709
  candidate: refreshedCandidateBase,
4507
4710
  requirementSelections: params.requirementSelections,
4508
4711
  partySize: partySize,
4509
4712
  bookingCount: bookingCount
4510
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
+ }
4511
4734
  if (validation.ok) {
4512
- _context39.next = 76;
4735
+ _context39.next = 83;
4513
4736
  break;
4514
4737
  }
4515
4738
  capacityConflict = validation.conflicts.find(function (conflict) {
@@ -4519,7 +4742,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4519
4742
  validation: validation,
4520
4743
  refreshedSnapshotId: refreshedProjection.meta.snapshotId
4521
4744
  });
4522
- case 76:
4745
+ case 83:
4523
4746
  // Revalidation failure must leave the caller's candidate reusable. Only publish the
4524
4747
  // refreshed projection/version after candidate and resource validation has passed;
4525
4748
  // otherwise a second Confirm from the still-open modal would incorrectly become stale.
@@ -4532,7 +4755,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4532
4755
  incrementVersion: true
4533
4756
  });
4534
4757
  revalidatedContext = this.getAvailabilityContextEntry(normalizedContextId);
4535
- _context39.next = 80;
4758
+ _context39.next = 87;
4536
4759
  return this.emitAvailabilityDiagnostic({
4537
4760
  action: 'refresh',
4538
4761
  contextId: normalizedContextId,
@@ -4543,7 +4766,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4543
4766
  previousOrderRevision: baseProjection.meta.orderRevision,
4544
4767
  reason: 'commit_cached_occupancy_revalidation'
4545
4768
  });
4546
- case 80:
4769
+ case 87:
4547
4770
  commitWriteGuard = {
4548
4771
  contextId: normalizedContextId,
4549
4772
  expectedVersion: revalidatedContext.activeVersion,
@@ -4552,27 +4775,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4552
4775
  expectedOrderRevision: revalidationEntry.orderRevision
4553
4776
  };
4554
4777
  refreshedCandidate = this.decorateAvailabilityCandidate(normalizedContextId, revalidatedContext.activeVersion, refreshedCandidateBase);
4555
- product = refreshedProjection.products.find(function (item) {
4556
- return sameAvailabilityId(item.id, refreshedCandidate.productId);
4557
- });
4558
- if (product) {
4559
- _context39.next = 85;
4560
- break;
4561
- }
4562
- throw new AvailabilityError('REVALIDATION_FAILED', '缓存重校验后商品不在 projection 中', {
4563
- productId: refreshedCandidate.productId
4564
- });
4565
- case 85:
4566
4778
  existingBooking = editingLine ? this.findLinkedBooking(editingLine) : undefined;
4567
4779
  existingBookingUid = existingBooking ? getBookingUid(existingBooking) : '';
4568
4780
  if (!(params.mode === 'edit' && !existingBookingUid)) {
4569
- _context39.next = 89;
4781
+ _context39.next = 93;
4570
4782
  break;
4571
4783
  }
4572
4784
  throw new AvailabilityError('PRODUCT_LINE_NOT_FOUND', '编辑商品行缺少关联 booking', {
4573
4785
  productLineUid: params.productLineUid
4574
4786
  });
4575
- case 89:
4787
+ case 93:
4576
4788
  this.assertAvailabilityCommitWriteCAS(commitWriteGuard);
4577
4789
  booking = buildBookingFromAvailabilitySelection({
4578
4790
  assignments: validation.assignments,
@@ -4580,21 +4792,21 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4580
4792
  product: product,
4581
4793
  resources: refreshedProjection.resources,
4582
4794
  bookingUid: existingBookingUid || undefined,
4583
- 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,
4584
- 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
4585
4797
  });
4586
4798
  transformed = this.buildUnifiedOrderProduct(_objectSpread(_objectSpread({}, params.orderProduct), {}, {
4587
4799
  num: bookingCount,
4588
4800
  quantity: bookingCount
4589
4801
  }), 'unified_booking_sales', product);
4590
4802
  if (transformed) {
4591
- _context39.next = 94;
4803
+ _context39.next = 98;
4592
4804
  break;
4593
4805
  }
4594
4806
  throw new AvailabilityError('INVALID_TARGET_FILTER', 'orderProduct 无法转换为订单行', {
4595
4807
  orderProduct: params.orderProduct
4596
4808
  });
4597
- case 94:
4809
+ case 98:
4598
4810
  transformed.num = bookingCount;
4599
4811
  transformed.metadata = _objectSpread(_objectSpread({}, transformed.metadata || {}), {}, {
4600
4812
  unified_booking_sales: true,
@@ -4607,7 +4819,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4607
4819
  productLineUids = [];
4608
4820
  bookingUids = [];
4609
4821
  if (!(params.mode === 'edit' && editingLine && params.productLineUid)) {
4610
- _context39.next = 113;
4822
+ _context39.next = 117;
4611
4823
  break;
4612
4824
  }
4613
4825
  transformed.product_sku = (_transformed$product_ = transformed.product_sku) !== null && _transformed$product_ !== void 0 ? _transformed$product_ : editingLine.product_sku;
@@ -4617,31 +4829,35 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4617
4829
  unique_identification_number: params.productLineUid,
4618
4830
  booking_uid: existingBookingUid
4619
4831
  });
4620
- _context39.next = 107;
4621
- return this.updateOrderProduct({
4832
+ _context39.next = 111;
4833
+ return this.updateOrderProduct(_objectSpread(_objectSpread({
4622
4834
  product_id: (_transformed$product_3 = transformed.product_id) !== null && _transformed$product_3 !== void 0 ? _transformed$product_3 : editingLine.product_id,
4623
- 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,
4624
4836
  unique_identification_number: params.productLineUid,
4625
4837
  updates: transformed,
4626
4838
  booking: booking
4627
- });
4628
- 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:
4629
4845
  productLineUid = params.productLineUid;
4630
4846
  bookingUid = existingBookingUid;
4631
4847
  productLineUids = [productLineUid];
4632
4848
  bookingUids = [bookingUid];
4633
- _context39.next = 125;
4849
+ _context39.next = 129;
4634
4850
  break;
4635
- case 113:
4851
+ case 117:
4636
4852
  beforeProductLineUids = new Set((((_this$getTempOrder4 = this.getTempOrder()) === null || _this$getTempOrder4 === void 0 ? void 0 : _this$getTempOrder4.products) || []).map(function (line) {
4637
4853
  return getProductLineUid(line);
4638
4854
  }).filter(Boolean));
4639
4855
  beforeBookingUids = new Set((((_this$getTempOrder5 = this.getTempOrder()) === null || _this$getTempOrder5 === void 0 ? void 0 : _this$getTempOrder5.bookings) || []).map(function (item) {
4640
4856
  return getBookingUid(item);
4641
4857
  }).filter(Boolean));
4642
- _context39.next = 117;
4858
+ _context39.next = 121;
4643
4859
  return this.addProductToOrder(transformed, booking);
4644
- case 117:
4860
+ case 121:
4645
4861
  products = _context39.sent;
4646
4862
  addedLines = products.filter(function (line) {
4647
4863
  var _line$product_id, _line$metadata;
@@ -4659,13 +4875,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4659
4875
  }).filter(Boolean);
4660
4876
  if (bookingUids.length === 0) {
4661
4877
  bookingUids = addedLines.map(function (line) {
4662
- var _ref50, _line$booking_uid, _line$metadata2;
4663
- 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 : '');
4664
4880
  }).filter(Boolean);
4665
4881
  }
4666
4882
  productLineUid = productLineUids[productLineUids.length - 1] || '';
4667
4883
  bookingUid = bookingUids[bookingUids.length - 1] || '';
4668
- case 125:
4884
+ case 129:
4669
4885
  this.invalidateAvailabilityContextsAfterCommit();
4670
4886
  nextContext = this.getAvailabilityContextEntry(normalizedContextId);
4671
4887
  result = {
@@ -4679,21 +4895,21 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4679
4895
  productLineUids: productLineUids,
4680
4896
  bookingUids: bookingUids
4681
4897
  };
4682
- _context39.next = 130;
4683
- return this.core.effects.emit("".concat(this.name, ":").concat(UnifiedBookingSalesHooks.onAvailabilitySelectionCommitted), result);
4684
- case 130:
4685
- return _context39.abrupt("return", result);
4686
- case 131:
4687
- _context39.prev = 131;
4688
4898
  _context39.next = 134;
4689
- return this.releaseAvailabilityCommitLock(normalizedContextId);
4899
+ return this.core.effects.emit("".concat(this.name, ":").concat(UnifiedBookingSalesHooks.onAvailabilitySelectionCommitted), result);
4690
4900
  case 134:
4691
- return _context39.finish(131);
4901
+ return _context39.abrupt("return", result);
4692
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:
4693
4909
  case "end":
4694
4910
  return _context39.stop();
4695
4911
  }
4696
- }, _callee39, this, [[5,, 131, 135]]);
4912
+ }, _callee39, this, [[5,, 135, 139]]);
4697
4913
  }));
4698
4914
  function commitAvailabilitySelection(_x32, _x33) {
4699
4915
  return _commitAvailabilitySelection.apply(this, arguments);