@pisell/pisellos 2.3.54 → 2.3.56

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.
@@ -1,6 +1,8 @@
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
2
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
3
  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."); }
4
+ 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); }
5
+ 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; }
4
6
  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; } }
5
7
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
6
8
  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; }
@@ -8,12 +10,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
8
10
  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; }
9
11
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
10
12
  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); }
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 _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); }
14
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
15
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
16
- 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; }
17
13
  import dayjs from 'dayjs';
18
14
  import { formatResources, getResourceByIds, getSumCapacity, getUsableTime, setDefaultCapacitys, setDefaultResource } from "./resources";
19
15
  import { hasActualResourceSelection, productNeedsResourceExtend } from "./resourceSelection";
@@ -81,9 +77,9 @@ export function getTimeObj(params) {
81
77
  useStartTime: useStartTime,
82
78
  ctx: ctx
83
79
  });
84
- var baseSlices = sliceDayIntoFiveMinutes(ctx === null || ctx === void 0 || (_ctx$bookingConfig2 = ctx.bookingConfig) === null || _ctx$bookingConfig2 === void 0 || (_ctx$bookingConfig2 = _ctx$bookingConfig2.config) === null || _ctx$bookingConfig2 === void 0 || (_ctx$bookingConfig2 = _ctx$bookingConfig2.basic) === null || _ctx$bookingConfig2 === void 0 ? void 0 : _ctx$bookingConfig2.service_time, isMultiDay);
85
- var timeSlices = _toConsumableArray(baseSlices.timeSlices);
86
- var durationSlicesBasedOnTime = _toConsumableArray(baseSlices.durationSlicesBasedOnTime);
80
+ var _sliceDayIntoFiveMinu = sliceDayIntoFiveMinutes(ctx === null || ctx === void 0 || (_ctx$bookingConfig2 = ctx.bookingConfig) === null || _ctx$bookingConfig2 === void 0 || (_ctx$bookingConfig2 = _ctx$bookingConfig2.config) === null || _ctx$bookingConfig2 === void 0 || (_ctx$bookingConfig2 = _ctx$bookingConfig2.basic) === null || _ctx$bookingConfig2 === void 0 ? void 0 : _ctx$bookingConfig2.service_time, isMultiDay),
81
+ timeSlices = _sliceDayIntoFiveMinu.timeSlices,
82
+ durationSlicesBasedOnTime = _sliceDayIntoFiveMinu.durationSlicesBasedOnTime;
87
83
  if (flexibleOption) {
88
84
  durationSlicesBasedOnTime.unshift(flexibleOption);
89
85
  }
@@ -1,5 +1,19 @@
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
+ 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."); }
3
+ 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); }
4
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
+ 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; }
1
7
  import dayjs from 'dayjs';
2
8
  import { getDurationValue } from "./flexible";
9
+ var timeSlicesCache = new Map();
10
+ function copyTimeSlices(result) {
11
+ return {
12
+ timeSlices: _toConsumableArray(result.timeSlices),
13
+ durationSlicesBasedOnTime: _toConsumableArray(result.durationSlicesBasedOnTime)
14
+ };
15
+ }
16
+
3
17
  /**
4
18
  * 把一天切成等长时间槽,输出 timeSlices(开始时间标签)与 durationSlicesBasedOnTime(基于切片的时长选项)。
5
19
  *
@@ -10,9 +24,12 @@ import { getDurationValue } from "./flexible";
10
24
  * @param isDay 是否跨日预约(true 时按 1~30 天切片)
11
25
  */
12
26
  export function sliceDayIntoFiveMinutes(config, isDay) {
27
+ var timeSlice = config && config.value || 5;
28
+ var cacheKey = isDay ? 'days' : "minutes:".concat(timeSlice);
29
+ var cached = timeSlicesCache.get(cacheKey);
30
+ if (cached) return copyTimeSlices(cached);
13
31
  var startTime = dayjs().startOf('day');
14
32
  var endTime = dayjs().endOf('day');
15
- var timeSlice = config && config.value || 5;
16
33
  var timeSlices = [];
17
34
  var durationSlicesBasedOnTime = [];
18
35
  var currentTime = startTime;
@@ -29,10 +46,12 @@ export function sliceDayIntoFiveMinutes(config, isDay) {
29
46
  });
30
47
  currentDay += 1;
31
48
  }
32
- return {
49
+ var _result = {
33
50
  timeSlices: timeSlices,
34
51
  durationSlicesBasedOnTime: durationSlicesBasedOnTime
35
52
  };
53
+ timeSlicesCache.set(cacheKey, _result);
54
+ return copyTimeSlices(_result);
36
55
  }
37
56
  while (currentTime.isBefore(endTime)) {
38
57
  timeSlices.push({
@@ -47,10 +66,12 @@ export function sliceDayIntoFiveMinutes(config, isDay) {
47
66
  });
48
67
  currentTime = nextTime;
49
68
  }
50
- return {
69
+ var result = {
51
70
  timeSlices: timeSlices,
52
71
  durationSlicesBasedOnTime: durationSlicesBasedOnTime
53
72
  };
73
+ timeSlicesCache.set(cacheKey, result);
74
+ return copyTimeSlices(result);
54
75
  }
55
76
 
56
77
  /**
@@ -354,6 +354,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
354
354
  updateVoucherOrderPaymentsAsync(payments: OrderPaymentSource[], options?: {
355
355
  status?: 'paid' | 'payment_pending';
356
356
  }): Promise<OrderPaymentData[]>;
357
+ private normalizeShouldMergeProductResult;
357
358
  private shouldMergeProductToOrder;
358
359
  private hasOrderProductLineNote;
359
360
  /**
@@ -375,7 +376,12 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
375
376
  * 带 booking 且 num>1 时由 `addProductToOrder` 拆成多次本方法调用(每次 num=1)。
376
377
  *
377
378
  * @example
378
- * await this.appendProductLineToTempOrder(tempOrder, { product_id: 1, num: 1 }, booking);
379
+ * const pending = this.appendProductLineToTempOrder(
380
+ * tempOrder,
381
+ * { product_id: 1, num: 1 },
382
+ * booking,
383
+ * );
384
+ * if (pending) await pending;
379
385
  */
380
386
  private appendProductLineToTempOrder;
381
387
  /**