@pisell/pisellos 2.3.187 → 2.3.190

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 (47) hide show
  1. package/dist/modules/BookingContext/utils/productExtend.d.ts +9 -1
  2. package/dist/modules/BookingContext/utils/productExtend.js +47 -13
  3. package/dist/modules/Order/index.d.ts +15 -5
  4. package/dist/modules/Order/index.js +1161 -921
  5. package/dist/modules/Order/types.d.ts +16 -4
  6. package/dist/modules/Order/utils.d.ts +1 -3
  7. package/dist/modules/Order/utils.js +2 -5
  8. package/dist/modules/Product/index.d.ts +1 -1
  9. package/dist/modules/ResourcePlanner/planner.js +29 -2
  10. package/dist/modules/ResourcePlanner/types.d.ts +6 -0
  11. package/dist/modules/Rules/index.js +19 -30
  12. package/dist/solution/BaseSales/index.d.ts +4 -0
  13. package/dist/solution/BaseSales/index.js +204 -176
  14. package/dist/solution/BaseSales/types.d.ts +1 -0
  15. package/dist/solution/BaseSales/types.js +1 -0
  16. package/dist/solution/BookingByStep/index.d.ts +2 -2
  17. package/dist/solution/BookingByStep/index.js +8 -5
  18. package/dist/solution/BookingByStep/utils/resources.d.ts +10 -0
  19. package/dist/solution/BookingByStep/utils/resources.js +117 -76
  20. package/dist/solution/BookingTicket/index.js +52 -31
  21. package/dist/solution/UnifiedBookingSales/index.d.ts +3 -0
  22. package/dist/solution/UnifiedBookingSales/index.js +279 -204
  23. package/dist/solution/UnifiedBookingSales/types.d.ts +6 -1
  24. package/lib/modules/BookingContext/utils/productExtend.d.ts +9 -1
  25. package/lib/modules/BookingContext/utils/productExtend.js +38 -5
  26. package/lib/modules/Order/index.d.ts +15 -5
  27. package/lib/modules/Order/index.js +167 -21
  28. package/lib/modules/Order/types.d.ts +16 -4
  29. package/lib/modules/Order/utils.d.ts +1 -3
  30. package/lib/modules/Order/utils.js +2 -5
  31. package/lib/modules/Product/index.d.ts +1 -1
  32. package/lib/modules/ResourcePlanner/planner.js +25 -1
  33. package/lib/modules/ResourcePlanner/types.d.ts +6 -0
  34. package/lib/modules/Rules/index.js +9 -19
  35. package/lib/solution/BaseSales/index.d.ts +4 -0
  36. package/lib/solution/BaseSales/index.js +14 -0
  37. package/lib/solution/BaseSales/types.d.ts +1 -0
  38. package/lib/solution/BaseSales/types.js +1 -0
  39. package/lib/solution/BookingByStep/index.d.ts +2 -2
  40. package/lib/solution/BookingByStep/index.js +8 -2
  41. package/lib/solution/BookingByStep/utils/resources.d.ts +10 -0
  42. package/lib/solution/BookingByStep/utils/resources.js +25 -15
  43. package/lib/solution/BookingTicket/index.js +8 -2
  44. package/lib/solution/UnifiedBookingSales/index.d.ts +3 -0
  45. package/lib/solution/UnifiedBookingSales/index.js +80 -15
  46. package/lib/solution/UnifiedBookingSales/types.d.ts +6 -1
  47. package/package.json +1 -1
@@ -13,6 +13,7 @@ import type { SubmitPayloadEnhancer } from '../../modules/Order/utils';
13
13
  export declare const BaseSalesHookNames: {
14
14
  readonly onInited: "onInited";
15
15
  readonly onDestroy: "onDestroy";
16
+ readonly onOrderSessionChanged: "onOrderSessionChanged";
16
17
  readonly onRetryInit: "onRetryInit";
17
18
  readonly onRefresh: "onRefresh";
18
19
  readonly onCartValidationChanged: "onCartValidationChanged";
@@ -5,6 +5,7 @@
5
5
  export var BaseSalesHookNames = {
6
6
  onInited: 'onInited',
7
7
  onDestroy: 'onDestroy',
8
+ onOrderSessionChanged: 'onOrderSessionChanged',
8
9
  onRetryInit: 'onRetryInit',
9
10
  onRefresh: 'onRefresh',
10
11
  onCartValidationChanged: 'onCartValidationChanged',
@@ -328,7 +328,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
328
328
  date: string;
329
329
  status: string;
330
330
  week: string;
331
- weekNum: 0 | 1 | 2 | 3 | 5 | 4 | 6;
331
+ weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
332
332
  }[]>;
333
333
  submitTimeSlot(timeSlots: TimeSliceItem): void;
334
334
  private getScheduleDataByIds;
@@ -375,7 +375,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
375
375
  };
376
376
  setOtherData(key: string, value: any): void;
377
377
  getOtherData(key: string): any;
378
- getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
378
+ getProductTypeById(id: number): Promise<"duration" | "normal" | "session">;
379
379
  /**
380
380
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
381
381
  *
@@ -32,7 +32,7 @@ import { BaseModule } from "../../modules/BaseModule";
32
32
  import { createModule } from "./types";
33
33
  import { formatProductToCartItem, createCartItemOrigin, getUniqueId, handleVariantProduct, formatDateToCartItem, formatAccountToCartItem } from "../../modules/Cart/utils";
34
34
  import { getAvailableProductResources, isSessionProduct } from "./utils/products";
35
- import { getResourcesByProduct, getTimeSlicesByResource, getTimeSlicesByResources, getIsUsableByTimeItem, getOthersSelectedResources, getOthersCartSelectedResources, filterScheduleByDateRange, checkSessionProductLeadTime, sortCombinedResources, filterResourcesByFormItem, checkTwoResourcesIntersection, isConflict } from "./utils/resources";
35
+ import { getResourcesByProduct, getTimeSlicesByResource, getTimeSlicesByResources, getIsUsableByTimeItem, getPeakConcurrentPax, getOthersSelectedResources, getOthersCartSelectedResources, filterScheduleByDateRange, checkSessionProductLeadTime, sortCombinedResources, filterResourcesByFormItem, checkTwoResourcesIntersection, isConflict } from "./utils/resources";
36
36
  import dayjs from 'dayjs';
37
37
  import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
38
38
  import isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
@@ -3109,13 +3109,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3109
3109
  end_at: dayjs(item.end)
3110
3110
  })) {
3111
3111
  var _m$pax;
3112
- mSet.set(m.id, (_m$pax = m.pax) !== null && _m$pax !== void 0 ? _m$pax : 1);
3112
+ mSet.set(m.id, _objectSpread(_objectSpread({}, m), {}, {
3113
+ pax: (_m$pax = m.pax) !== null && _m$pax !== void 0 ? _m$pax : 1
3114
+ }));
3113
3115
  }
3114
3116
  });
3115
3117
  });
3116
- acc += Array.from(mSet.values()).reduce(function (acc, curr) {
3117
- return acc + curr;
3118
- }, 0);
3118
+ acc += getPeakConcurrentPax(Array.from(mSet.values()), {
3119
+ start_at: dayjs(item.start),
3120
+ end_at: dayjs(item.end)
3121
+ });
3119
3122
  return acc;
3120
3123
  }, 0);
3121
3124
  // 如果已使用容量超过了当前类型资源的容量,则不可用
@@ -7,6 +7,11 @@ import { CartItem, ProductData } from '../../../modules';
7
7
  *
8
8
  */
9
9
  type DateType = Dayjs;
10
+ interface EventItem {
11
+ pax: number;
12
+ start_at: DateType;
13
+ end_at: DateType;
14
+ }
10
15
  export interface TimeSliceItem {
11
16
  start_time: string;
12
17
  end_time: string;
@@ -20,6 +25,11 @@ export interface ResourceItem {
20
25
  interface BookingItem {
21
26
  [key: string]: any;
22
27
  }
28
+ /** 计算目标区间内的最大同时占用人数;事件去重由调用方负责。 */
29
+ export declare const getPeakConcurrentPax: (eventList: EventItem[], timeSlice: {
30
+ start_at: DateType;
31
+ end_at: DateType;
32
+ }) => number;
23
33
  /**
24
34
  * @title: 判断两个时间段是否有重叠
25
35
  * @description:
@@ -1,16 +1,20 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
3
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
5
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
7
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
8
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
9
2
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
10
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
11
4
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
12
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
13
6
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
10
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
12
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
14
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
15
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
16
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
17
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
14
18
  import dayjs from 'dayjs';
15
19
 
16
20
  /**
@@ -20,18 +24,53 @@ import dayjs from 'dayjs';
20
24
  *
21
25
  */
22
26
 
23
- /**
24
- * @title: 获取重叠剩余量
25
- * @description:
26
- * @param {any} eventList
27
- * @param {number} current
28
- * @return {*}
29
- * @Author: zhiwei.Wang
30
- */
31
- var getUseableEventCount = function getUseableEventCount(eventList, current) {
32
- return (eventList || []).reduce(function (pre, event) {
33
- return pre - event.pax;
34
- }, current || 0);
27
+ /** 计算目标区间内的最大同时占用人数;事件去重由调用方负责。 */
28
+ export var getPeakConcurrentPax = function getPeakConcurrentPax(eventList, timeSlice) {
29
+ var start = dayjs(timeSlice.start_at).valueOf();
30
+ var end = dayjs(timeSlice.end_at).valueOf();
31
+ var changes = new Map();
32
+ var _iterator = _createForOfIteratorHelper(eventList || []),
33
+ _step;
34
+ try {
35
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
36
+ var _changes$get, _changes$get2;
37
+ var event = _step.value;
38
+ var eventStart = Math.max(start, dayjs(event.start_at).valueOf());
39
+ var eventEnd = Math.min(end, dayjs(event.end_at).valueOf());
40
+ if (!(eventStart < eventEnd)) continue;
41
+ var pax = Number(event.pax);
42
+ changes.set(eventStart, ((_changes$get = changes.get(eventStart)) !== null && _changes$get !== void 0 ? _changes$get : 0) + pax);
43
+ changes.set(eventEnd, ((_changes$get2 = changes.get(eventEnd)) !== null && _changes$get2 !== void 0 ? _changes$get2 : 0) - pax);
44
+ }
45
+ } catch (err) {
46
+ _iterator.e(err);
47
+ } finally {
48
+ _iterator.f();
49
+ }
50
+ var current = 0;
51
+ var peak = 0;
52
+ // 同一时刻合并增减量,保持 [start, end) 语义,首尾相接不叠加。
53
+ var _iterator2 = _createForOfIteratorHelper(_toConsumableArray(changes).sort(function (_ref, _ref2) {
54
+ var _ref3 = _slicedToArray(_ref, 1),
55
+ a = _ref3[0];
56
+ var _ref4 = _slicedToArray(_ref2, 1),
57
+ b = _ref4[0];
58
+ return a - b;
59
+ })),
60
+ _step2;
61
+ try {
62
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
63
+ var _step2$value = _slicedToArray(_step2.value, 2),
64
+ change = _step2$value[1];
65
+ current += change;
66
+ peak = Math.max(peak, current);
67
+ }
68
+ } catch (err) {
69
+ _iterator2.e(err);
70
+ } finally {
71
+ _iterator2.f();
72
+ }
73
+ return peak;
35
74
  };
36
75
 
37
76
  /**
@@ -104,12 +143,12 @@ var formatResource = function formatResource(resourceItem, booking) {
104
143
  * @return {*}
105
144
  * @Author: zhiwei.Wang
106
145
  */
107
- var checkCapacity = function checkCapacity(_ref) {
108
- var event_list = _ref.event_list,
109
- timeSlice = _ref.timeSlice,
110
- resource = _ref.resource,
111
- _ref$currentCount = _ref.currentCount,
112
- currentCount = _ref$currentCount === void 0 ? 1 : _ref$currentCount;
146
+ var checkCapacity = function checkCapacity(_ref5) {
147
+ var event_list = _ref5.event_list,
148
+ timeSlice = _ref5.timeSlice,
149
+ resource = _ref5.resource,
150
+ _ref5$currentCount = _ref5.currentCount,
151
+ currentCount = _ref5$currentCount === void 0 ? 1 : _ref5$currentCount;
113
152
  // 单个预约:如果当前资源容量不足以满足需求的容量,且当前资源是没有被占用的,返回资源不可用标记,但在外部运算会通过 reason=capacityOnly 来处理组合资源可用
114
153
  // 多个预约:只需判断容量是否足够
115
154
  var isMultipleBooking = resource.resourceType === 'multiple';
@@ -130,8 +169,10 @@ var checkCapacity = function checkCapacity(_ref) {
130
169
  });
131
170
  });
132
171
 
133
- // 减去重叠的总量
134
- var conflictCount = getUseableEventCount(conflict, resource.capacity);
172
+ // 多人预约按同时占用峰值扣减,不能把先后到访的所有人数相加。
173
+ var conflictCount = resource.resourceType === 'single' ? conflict.reduce(function (remaining, event) {
174
+ return remaining - event.pax;
175
+ }, resource.capacity || 0) : (resource.capacity || 0) - getPeakConcurrentPax(conflict, timeSlice);
135
176
 
136
177
  // 同一时间段内只能进行一个预约,无论容量是否已满。
137
178
  if (resource.resourceType === 'single') {
@@ -170,16 +211,16 @@ var checkCapacity = function checkCapacity(_ref) {
170
211
  * @return {*}
171
212
  * @Author: zhiwei.Wang
172
213
  */
173
- export var getIsUsableByTimeItem = function getIsUsableByTimeItem(_ref2) {
214
+ export var getIsUsableByTimeItem = function getIsUsableByTimeItem(_ref6) {
174
215
  var _resource$combined_re;
175
- var timeSlice = _ref2.timeSlice,
176
- time = _ref2.time,
177
- resource = _ref2.resource,
178
- _ref2$currentCount = _ref2.currentCount,
179
- currentCount = _ref2$currentCount === void 0 ? 1 : _ref2$currentCount,
180
- _ref2$resourcesUseabl = _ref2.resourcesUseableMap,
181
- resourcesUseableMap = _ref2$resourcesUseabl === void 0 ? {} : _ref2$resourcesUseabl,
182
- cut_off_time = _ref2.cut_off_time;
216
+ var timeSlice = _ref6.timeSlice,
217
+ time = _ref6.time,
218
+ resource = _ref6.resource,
219
+ _ref6$currentCount = _ref6.currentCount,
220
+ currentCount = _ref6$currentCount === void 0 ? 1 : _ref6$currentCount,
221
+ _ref6$resourcesUseabl = _ref6.resourcesUseableMap,
222
+ resourcesUseableMap = _ref6$resourcesUseabl === void 0 ? {} : _ref6$resourcesUseabl,
223
+ cut_off_time = _ref6.cut_off_time;
183
224
  var status = {
184
225
  afterToDay: false,
185
226
  capacity: false,
@@ -191,11 +232,11 @@ export var getIsUsableByTimeItem = function getIsUsableByTimeItem(_ref2) {
191
232
  // 最早可预约时间为 当前日期之后并且提前量之后
192
233
  var earliest = dayjs();
193
234
  var canBookingForOngoing = false;
194
- var _ref3 = cut_off_time || {},
195
- unit = _ref3.unit,
196
- unit_type = _ref3.unit_type,
197
- type = _ref3.type,
198
- ongoing = _ref3.ongoing;
235
+ var _ref7 = cut_off_time || {},
236
+ unit = _ref7.unit,
237
+ unit_type = _ref7.unit_type,
238
+ type = _ref7.type,
239
+ ongoing = _ref7.ongoing;
199
240
  // 允许购买已开始的活动
200
241
  if (type === 'ongoing' && (ongoing === null || ongoing === void 0 ? void 0 : ongoing.type) === 'after_start') {
201
242
  // 如果timeSlice.start_at 小于当前时间,判断当前时间是否在如果timeSlice.start_at+ongoing.unit之间
@@ -366,17 +407,17 @@ export var getResourcesByProduct = function getResourcesByProduct(resourcesMap,
366
407
  * @Author: zhiwei.Wang
367
408
  * @Date: 2024-01-09 13:38
368
409
  */
369
- export var formatResources = function formatResources(_ref4) {
370
- var booking = _ref4.booking,
371
- resources = _ref4.resources;
410
+ export var formatResources = function formatResources(_ref8) {
411
+ var booking = _ref8.booking,
412
+ resources = _ref8.resources;
372
413
  try {
373
414
  var _list = _toConsumableArray(resources);
374
415
  var maps = {};
375
- var _iterator = _createForOfIteratorHelper(_list),
376
- _step;
416
+ var _iterator3 = _createForOfIteratorHelper(_list),
417
+ _step3;
377
418
  try {
378
419
  var _loop = function _loop() {
379
- var item = _step.value;
420
+ var item = _step3.value;
380
421
  var renderListMaps = {};
381
422
  item.renderList = item.renderList.map(function (d) {
382
423
  var res = formatResource(d, booking);
@@ -387,13 +428,13 @@ export var formatResources = function formatResources(_ref4) {
387
428
  renderListMaps: renderListMaps
388
429
  });
389
430
  };
390
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
431
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
391
432
  _loop();
392
433
  }
393
434
  } catch (err) {
394
- _iterator.e(err);
435
+ _iterator3.e(err);
395
436
  } finally {
396
- _iterator.f();
437
+ _iterator3.f();
397
438
  }
398
439
  return {
399
440
  list: _list,
@@ -412,20 +453,20 @@ export var formatResources = function formatResources(_ref4) {
412
453
  * @return {*}
413
454
  * @Author: zhiwei.Wang
414
455
  */
415
- export var getTimeSlicesByResource = function getTimeSlicesByResource(_ref5) {
416
- var resource = _ref5.resource,
417
- duration = _ref5.duration,
418
- _ref5$split = _ref5.split,
419
- split = _ref5$split === void 0 ? 10 : _ref5$split,
420
- _ref5$currentDate = _ref5.currentDate,
421
- currentDate = _ref5$currentDate === void 0 ? dayjs() : _ref5$currentDate,
422
- capacity = _ref5.capacity,
423
- _ref5$resourcesUseabl = _ref5.resourcesUseableMap,
424
- resourcesUseableMap = _ref5$resourcesUseabl === void 0 ? {} : _ref5$resourcesUseabl,
425
- cut_off_time = _ref5.cut_off_time,
426
- hasFlexibleDuration = _ref5.hasFlexibleDuration,
427
- operating_day_boundary = _ref5.operating_day_boundary,
428
- maxBlockThreshold = _ref5.maxBlockThreshold;
456
+ export var getTimeSlicesByResource = function getTimeSlicesByResource(_ref9) {
457
+ var resource = _ref9.resource,
458
+ duration = _ref9.duration,
459
+ _ref9$split = _ref9.split,
460
+ split = _ref9$split === void 0 ? 10 : _ref9$split,
461
+ _ref9$currentDate = _ref9.currentDate,
462
+ currentDate = _ref9$currentDate === void 0 ? dayjs() : _ref9$currentDate,
463
+ capacity = _ref9.capacity,
464
+ _ref9$resourcesUseabl = _ref9.resourcesUseableMap,
465
+ resourcesUseableMap = _ref9$resourcesUseabl === void 0 ? {} : _ref9$resourcesUseabl,
466
+ cut_off_time = _ref9.cut_off_time,
467
+ hasFlexibleDuration = _ref9.hasFlexibleDuration,
468
+ operating_day_boundary = _ref9.operating_day_boundary,
469
+ maxBlockThreshold = _ref9.maxBlockThreshold;
429
470
  var times = resource.times;
430
471
 
431
472
  // 存储所有时间切片
@@ -587,18 +628,18 @@ export var mergeSubResourcesTimeSlices = function mergeSubResourcesTimeSlices(re
587
628
  * @return {*}
588
629
  * @Author: zhiwei.Wang
589
630
  */
590
- export var getTimeSlicesByResources = function getTimeSlicesByResources(_ref6) {
591
- var resourceIds = _ref6.resourceIds,
592
- resourcesMap = _ref6.resourcesMap,
593
- duration = _ref6.duration,
594
- currentDate = _ref6.currentDate,
595
- split = _ref6.split,
596
- capacity = _ref6.capacity,
597
- resourcesUseableMap = _ref6.resourcesUseableMap,
598
- cut_off_time = _ref6.cut_off_time,
599
- hasFlexibleDuration = _ref6.hasFlexibleDuration,
600
- operating_day_boundary = _ref6.operating_day_boundary,
601
- maxBlockThreshold = _ref6.maxBlockThreshold;
631
+ export var getTimeSlicesByResources = function getTimeSlicesByResources(_ref10) {
632
+ var resourceIds = _ref10.resourceIds,
633
+ resourcesMap = _ref10.resourcesMap,
634
+ duration = _ref10.duration,
635
+ currentDate = _ref10.currentDate,
636
+ split = _ref10.split,
637
+ capacity = _ref10.capacity,
638
+ resourcesUseableMap = _ref10.resourcesUseableMap,
639
+ cut_off_time = _ref10.cut_off_time,
640
+ hasFlexibleDuration = _ref10.hasFlexibleDuration,
641
+ operating_day_boundary = _ref10.operating_day_boundary,
642
+ maxBlockThreshold = _ref10.maxBlockThreshold;
602
643
  // 获取资源列表
603
644
  var resources = getResourcesByIds(resourcesMap, resourceIds);
604
645
  mergeSubResourcesTimeSlices(resources, resourcesMap);
@@ -2737,16 +2737,24 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2737
2737
  }, {
2738
2738
  key: "buildBookingCalcContext",
2739
2739
  value: function buildBookingCalcContext(extra) {
2740
- var _extra$date, _extra$presetStartTim;
2740
+ var _extra$date,
2741
+ _extra$presetStartTim,
2742
+ _this$getOrderSession,
2743
+ _this8 = this;
2741
2744
  var state = this.store.bookingContext.getState();
2742
2745
  var date = (_extra$date = extra === null || extra === void 0 ? void 0 : extra.date) !== null && _extra$date !== void 0 ? _extra$date : state.date;
2743
- return _objectSpread({
2746
+ return _objectSpread(_objectSpread({
2744
2747
  bookingConfig: state.bookingConfig,
2745
2748
  resourcesOrigin: state.resourcesOrigin,
2746
2749
  resourcesOriginMap: state.resourcesOriginMap,
2747
2750
  date: date,
2748
2751
  presetStartTime: (_extra$presetStartTim = extra === null || extra === void 0 ? void 0 : extra.presetStartTime) !== null && _extra$presetStartTim !== void 0 ? _extra$presetStartTim : derivePresetStartTimeFromDate(date)
2749
- }, extra || {});
2752
+ }, extra || {}), {}, {
2753
+ orderSessionId: (_this$getOrderSession = this.getOrderSessionId()) !== null && _this$getOrderSession !== void 0 ? _this$getOrderSession : undefined,
2754
+ isOrderSessionCurrent: function isOrderSessionCurrent(sessionId) {
2755
+ return _this8.isOrderSessionCurrent(sessionId);
2756
+ }
2757
+ });
2750
2758
  }
2751
2759
 
2752
2760
  /**
@@ -2840,7 +2848,14 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2840
2848
  }, {
2841
2849
  key: "buildAddProductCtx",
2842
2850
  value: function buildAddProductCtx(extra) {
2843
- var _extra$date2, _ref14, _this$getOrderCustome4, _this$getOrderCustome5, _this$store$order$get5, _extra$presetStartTim2;
2851
+ var _extra$date2,
2852
+ _ref14,
2853
+ _this$getOrderCustome4,
2854
+ _this$getOrderCustome5,
2855
+ _this$store$order$get5,
2856
+ _extra$presetStartTim2,
2857
+ _this$getOrderSession2,
2858
+ _this9 = this;
2844
2859
  var bookingContextState = this.store.bookingContext.getState();
2845
2860
  var date = (_extra$date2 = extra === null || extra === void 0 ? void 0 : extra.date) !== null && _extra$date2 !== void 0 ? _extra$date2 : bookingContextState.date;
2846
2861
  var orderCustomerId = (_ref14 = (_this$getOrderCustome4 = (_this$getOrderCustome5 = this.getOrderCustomerSnapshot()) === null || _this$getOrderCustome5 === void 0 ? void 0 : _this$getOrderCustome5.id) !== null && _this$getOrderCustome4 !== void 0 ? _this$getOrderCustome4 : (_this$store$order$get5 = this.store.order.getTempOrder()) === null || _this$store$order$get5 === void 0 ? void 0 : _this$store$order$get5.customer_id) !== null && _ref14 !== void 0 ? _ref14 : undefined;
@@ -2852,7 +2867,11 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2852
2867
  presetStartTime: (_extra$presetStartTim2 = extra === null || extra === void 0 ? void 0 : extra.presetStartTime) !== null && _extra$presetStartTim2 !== void 0 ? _extra$presetStartTim2 : derivePresetStartTimeFromDate(date),
2853
2868
  customerId: orderCustomerId
2854
2869
  }, extra || {}), {}, {
2855
- channel: this.getSubmitOrderSalesChannel()
2870
+ channel: this.getSubmitOrderSalesChannel(),
2871
+ orderSessionId: (_this$getOrderSession2 = this.getOrderSessionId()) !== null && _this$getOrderSession2 !== void 0 ? _this$getOrderSession2 : undefined,
2872
+ isOrderSessionCurrent: function isOrderSessionCurrent(sessionId) {
2873
+ return _this9.isOrderSessionCurrent(sessionId);
2874
+ }
2856
2875
  });
2857
2876
  }
2858
2877
 
@@ -2988,7 +3007,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2988
3007
  key: "handleGlobalScanCode",
2989
3008
  value: (function () {
2990
3009
  var _handleGlobalScanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(code, bridge) {
2991
- var _this8 = this;
3010
+ var _this10 = this;
2992
3011
  var trimmed, _bridge$onNotify, _bridge$refresh, beforeScanCommit, beforeScanDialog, guardCallback, guardedBridge, _promotion$isAccepted, promotion, localSearch, scanCallback, raw, formatted, _bridge$onNotify2, host, _result8, _bridge$onNotify3, _bridge$isCurrent;
2993
3012
  return _regeneratorRuntime().wrap(function _callee40$(_context40) {
2994
3013
  while (1) switch (_context40.prev = _context40.next) {
@@ -3056,7 +3075,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3056
3075
  });
3057
3076
  case 16:
3058
3077
  localSearch = function localSearch(v) {
3059
- return _this8.store.products.findProductsByCodeOrBarcode(v);
3078
+ return _this10.store.products.findProductsByCodeOrBarcode(v);
3060
3079
  };
3061
3080
  scanCallback = handleGlobalScan(this.request, localSearch, this.getSubmitOrderSalesChannel());
3062
3081
  _context40.next = 20;
@@ -3080,40 +3099,40 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3080
3099
  host = {
3081
3100
  setOrderCustomer: function setOrderCustomer(customer) {
3082
3101
  beforeScanCommit();
3083
- _this8.setOrderCustomer(customer);
3102
+ _this10.setOrderCustomer(customer);
3084
3103
  },
3085
3104
  getOrderCustomerSnapshot: function getOrderCustomerSnapshot() {
3086
- return _this8.getOrderCustomerSnapshot();
3105
+ return _this10.getOrderCustomerSnapshot();
3087
3106
  },
3088
3107
  resolveCustomerById: function resolveCustomerById(customerId) {
3089
- return _this8.resolveCustomerById(customerId);
3108
+ return _this10.resolveCustomerById(customerId);
3090
3109
  },
3091
3110
  getBusinessCode: function getBusinessCode() {
3092
- var _this8$otherParams;
3093
- return (_this8$otherParams = _this8.otherParams) === null || _this8$otherParams === void 0 ? void 0 : _this8$otherParams.businessCode;
3111
+ var _this10$otherParams;
3112
+ return (_this10$otherParams = _this10.otherParams) === null || _this10$otherParams === void 0 ? void 0 : _this10$otherParams.businessCode;
3094
3113
  },
3095
3114
  buildAddProductCtx: function buildAddProductCtx(extra) {
3096
- return _this8.buildAddProductCtx(extra);
3115
+ return _this10.buildAddProductCtx(extra);
3097
3116
  },
3098
3117
  decideAddProduct: function decideAddProduct(item, options) {
3099
- return _this8.decideAddProduct(item, options);
3118
+ return _this10.decideAddProduct(item, options);
3100
3119
  },
3101
3120
  decideAfterDetail: function decideAfterDetail(cacheItem, options) {
3102
- return _this8.decideAfterDetail(cacheItem, options);
3121
+ return _this10.decideAfterDetail(cacheItem, options);
3103
3122
  },
3104
3123
  transformDetailToProductAndBooking: function transformDetailToProductAndBooking(input) {
3105
- return _this8.transformDetailToProductAndBooking(input);
3124
+ return _this10.transformDetailToProductAndBooking(input);
3106
3125
  },
3107
3126
  addProductToOrder: function addProductToOrder(product, booking) {
3108
3127
  beforeScanCommit();
3109
- return _this8.addProductToOrder(product, booking);
3128
+ return _this10.addProductToOrder(product, booking);
3110
3129
  },
3111
3130
  refreshWalletAssets: function refreshWalletAssets(params) {
3112
- return _this8.refreshWalletAssets(params);
3131
+ return _this10.refreshWalletAssets(params);
3113
3132
  },
3114
3133
  scanWalletAsset: function scanWalletAsset(scanCode) {
3115
3134
  beforeScanCommit();
3116
- return _this8.scanWalletAsset(scanCode);
3135
+ return _this10.scanWalletAsset(scanCode);
3117
3136
  }
3118
3137
  };
3119
3138
  if (!((guardedBridge === null || guardedBridge === void 0 ? void 0 : guardedBridge.scanScope) === 'product-voucher-collection')) {
@@ -3124,13 +3143,13 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3124
3143
  return applyProductVoucherCollectionScan(_objectSpread(_objectSpread({}, host), {}, {
3125
3144
  loadCustomerDiscounts: function () {
3126
3145
  var _loadCustomerDiscounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
3127
- var _this8$getOrderCustom;
3146
+ var _this10$getOrderCusto;
3128
3147
  var customerId;
3129
3148
  return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3130
3149
  while (1) switch (_context39.prev = _context39.next) {
3131
3150
  case 0:
3132
3151
  beforeScanCommit();
3133
- customerId = Number(((_this8$getOrderCustom = _this8.getOrderCustomer()) === null || _this8$getOrderCustom === void 0 ? void 0 : _this8$getOrderCustom.customer_id) || 0);
3152
+ customerId = Number(((_this10$getOrderCusto = _this10.getOrderCustomer()) === null || _this10$getOrderCusto === void 0 ? void 0 : _this10$getOrderCusto.customer_id) || 0);
3134
3153
  if (!(customerId <= 1)) {
3135
3154
  _context39.next = 4;
3136
3155
  break;
@@ -3138,10 +3157,10 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3138
3157
  return _context39.abrupt("return", []);
3139
3158
  case 4:
3140
3159
  _context39.next = 6;
3141
- return _this8.refreshDiscountConfigAfterOrderCustomerChange(customerId);
3160
+ return _this10.refreshDiscountConfigAfterOrderCustomerChange(customerId);
3142
3161
  case 6:
3143
3162
  beforeScanCommit();
3144
- return _context39.abrupt("return", _this8.getDiscountList());
3163
+ return _context39.abrupt("return", _this10.getDiscountList());
3145
3164
  case 8:
3146
3165
  case "end":
3147
3166
  return _context39.stop();
@@ -3208,7 +3227,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3208
3227
  key: "getGlobalScanCodeType",
3209
3228
  value: (function () {
3210
3229
  var _getGlobalScanCodeType = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(code) {
3211
- var _this9 = this,
3230
+ var _this11 = this,
3212
3231
  _formatGlobalScanResu,
3213
3232
  _formatGlobalScanResu2;
3214
3233
  var trimmed, scan, raw;
@@ -3223,7 +3242,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3223
3242
  return _context41.abrupt("return", null);
3224
3243
  case 3:
3225
3244
  scan = handleGlobalScan(this.request, function (value) {
3226
- return _this9.store.products.findProductsByCodeOrBarcode(value);
3245
+ return _this11.store.products.findProductsByCodeOrBarcode(value);
3227
3246
  }, this.getSubmitOrderSalesChannel());
3228
3247
  _context41.next = 6;
3229
3248
  return scan({
@@ -3356,7 +3375,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3356
3375
  key: "addAddTimeProductsToBooking",
3357
3376
  value: (function () {
3358
3377
  var _addAddTimeProductsToBooking = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(input) {
3359
- var _this10 = this,
3378
+ var _this12 = this,
3360
3379
  _input$bookingPatch;
3361
3380
  var bookingUid, orderLines, coveredMinutes, bookingTimePatch, result, _iterator2, _step2, line;
3362
3381
  return _regeneratorRuntime().wrap(function _callee43$(_context43) {
@@ -3371,7 +3390,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3371
3390
  case 3:
3372
3391
  orderLines = (input.products || []).map(function (line) {
3373
3392
  return {
3374
- product: _this10.buildAddTimeOrderLine(line, bookingUid)
3393
+ product: _this12.buildAddTimeOrderLine(line, bookingUid)
3375
3394
  };
3376
3395
  });
3377
3396
  if (this.store.order) {
@@ -3446,7 +3465,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3446
3465
  key: "setOtherParams",
3447
3466
  value: function () {
3448
3467
  var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(params) {
3449
- var _this11 = this;
3468
+ var _this13 = this;
3450
3469
  var _ref21,
3451
3470
  _ref21$cover,
3452
3471
  cover,
@@ -3459,8 +3478,8 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3459
3478
  _ref21 = _args44.length > 1 && _args44[1] !== undefined ? _args44[1] : {}, _ref21$cover = _ref21.cover, cover = _ref21$cover === void 0 ? false : _ref21$cover;
3460
3479
  nextParams = cover ? params : _objectSpread(_objectSpread({}, this.otherParams), params);
3461
3480
  if (['businessCode', 'business_code', 'channel', 'platform', 'shop_id', 'tenantId', 'cacheId'].some(function (key) {
3462
- var _this11$otherParams;
3463
- return (nextParams === null || nextParams === void 0 ? void 0 : nextParams[key]) !== ((_this11$otherParams = _this11.otherParams) === null || _this11$otherParams === void 0 ? void 0 : _this11$otherParams[key]);
3481
+ var _this13$otherParams;
3482
+ return (nextParams === null || nextParams === void 0 ? void 0 : nextParams[key]) !== ((_this13$otherParams = _this13.otherParams) === null || _this13$otherParams === void 0 ? void 0 : _this13$otherParams[key]);
3464
3483
  })) this.orderCustomerContactRequest = null;
3465
3484
  _context44.next = 5;
3466
3485
  return _get(_getPrototypeOf(BookingTicketImpl.prototype), "setOtherParams", this).call(this, params, {
@@ -3600,7 +3619,9 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3600
3619
  _context46.next = 11;
3601
3620
  return this.replaceTempOrder(_objectSpread(_objectSpread({}, tempOrder), {}, {
3602
3621
  vouchers: nextVouchers
3603
- }));
3622
+ }), {
3623
+ preserveOrderSessionId: this.getOrderSessionId() || undefined
3624
+ });
3604
3625
  case 11:
3605
3626
  this.core.effects.emit("".concat(this.name, ":onVouchersChange"), {});
3606
3627
  if (!(voucherIds.length === 0)) {
@@ -131,6 +131,9 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
131
131
  private cloneAvailabilityPrepareParams;
132
132
  private getAvailabilityDurationCandidateAnchorAt;
133
133
  private createAvailabilityContextRef;
134
+ /** Accept the v2 interval only within the POS order that recorded it. */
135
+ private resolveOrderRememberedTimes;
136
+ private assertRememberedOrderSession;
134
137
  private emitAvailabilityDiagnostic;
135
138
  private touchAvailabilityContext;
136
139
  private touchAvailabilityProjection;