@pisell/pisellos 2.3.55 → 2.3.57
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.
- package/dist/core/index.js +0 -1
- package/dist/modules/BookingContext/utils/productExtend.js +5 -9
- package/dist/modules/BookingContext/utils/timeSlices.js +24 -3
- package/dist/modules/Order/index.d.ts +8 -2
- package/dist/modules/Order/index.js +636 -645
- package/dist/modules/Order/utils/discountProductLineIdentity.d.ts +45 -0
- package/dist/modules/Order/utils/discountProductLineIdentity.js +227 -0
- package/dist/modules/Rules/index.js +46 -5
- package/dist/solution/BaseSales/index.js +53 -34
- package/dist/solution/BaseSales/utils/cartPromotion.js +19 -1
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +1 -4
- package/lib/core/index.js +0 -1
- package/lib/model/strategy/adapter/promotion/index.js +0 -51
- package/lib/modules/BookingContext/utils/productExtend.js +4 -3
- package/lib/modules/BookingContext/utils/timeSlices.js +18 -3
- package/lib/modules/Order/index.d.ts +8 -2
- package/lib/modules/Order/index.js +161 -118
- package/lib/modules/Order/utils/discountProductLineIdentity.d.ts +45 -0
- package/lib/modules/Order/utils/discountProductLineIdentity.js +170 -0
- package/lib/modules/Rules/index.js +47 -3
- package/lib/solution/BaseSales/index.js +26 -6
- package/lib/solution/BaseSales/utils/cartPromotion.js +18 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +1 -4
- package/package.json +1 -1
package/dist/core/index.js
CHANGED
|
@@ -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
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
*
|
|
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
|
/**
|
|
@@ -487,7 +493,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
487
493
|
generateIdempotencyToken(): string;
|
|
488
494
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
489
495
|
createOrder(params: CommitOrderParams['query']): {
|
|
490
|
-
type: "
|
|
496
|
+
type: "appointment_booking" | "virtual";
|
|
491
497
|
platform: string;
|
|
492
498
|
sales_channel: string;
|
|
493
499
|
order_sales_channel: string;
|