@pisell/pisellos 2.1.172 → 2.1.174
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/apis/picoding.d.ts +0 -0
- package/dist/apis/picoding.js +1 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/model/strategy/adapter/promotion/evaluator.js +26 -99
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +2 -2
- package/dist/model/strategy/adapter/walletPass/evaluator.js +12 -63
- package/dist/model/strategy/adapter/walletPass/locales.js +3 -12
- package/dist/model/strategy/engine.d.ts +5 -18
- package/dist/model/strategy/engine.js +45 -145
- package/dist/model/strategy/type.d.ts +0 -17
- package/dist/model/strategy/type.js +0 -4
- package/dist/modules/Cart/types.d.ts +0 -2
- package/dist/modules/Cart/utils/cartProduct.js +25 -56
- package/dist/modules/Cart/utils/changePrice.js +16 -9
- package/dist/modules/Discount/availability.d.ts +7 -0
- package/dist/modules/Discount/availability.js +52 -0
- package/dist/modules/Discount/entitlementPass.d.ts +34 -0
- package/dist/modules/Discount/entitlementPass.js +147 -0
- package/dist/modules/Discount/entitlementState.d.ts +8 -0
- package/dist/modules/Discount/entitlementState.js +205 -0
- package/dist/modules/Discount/index.d.ts +12 -3
- package/dist/modules/Discount/index.js +211 -17
- package/dist/modules/Discount/types.d.ts +42 -22
- package/dist/modules/Holder/index.d.ts +48 -0
- package/dist/modules/Holder/index.js +640 -0
- package/dist/modules/Holder/types.d.ts +123 -0
- package/dist/modules/Holder/types.js +1 -0
- package/dist/modules/Holder/utils.d.ts +13 -0
- package/dist/modules/Holder/utils.js +34 -0
- package/dist/modules/OpenData/index.d.ts +24 -0
- package/dist/modules/OpenData/index.js +173 -0
- package/dist/modules/OpenData/types.d.ts +73 -0
- package/dist/modules/OpenData/types.js +1 -0
- package/dist/modules/OpenData/utils.d.ts +2 -0
- package/dist/modules/OpenData/utils.js +75 -0
- package/dist/modules/Order/index.d.ts +67 -1
- package/dist/modules/Order/index.js +923 -30
- package/dist/modules/Order/types.d.ts +176 -12
- package/dist/modules/Order/types.js +2 -0
- package/dist/modules/Order/utils.d.ts +128 -0
- package/dist/modules/Order/utils.js +621 -5
- package/dist/modules/Payment/index.d.ts +1 -2
- package/dist/modules/Payment/index.js +7 -10
- package/dist/modules/Payment/utils.js +0 -3
- package/dist/modules/Payment/walletpass.d.ts +0 -23
- package/dist/modules/Payment/walletpass.js +95 -191
- package/dist/modules/Product/types.d.ts +7 -0
- package/dist/modules/Product/utils.js +2 -2
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +4 -3
- package/dist/modules/Quotation/index.d.ts +48 -0
- package/dist/modules/Quotation/index.js +248 -0
- package/dist/modules/Quotation/types.d.ts +42 -0
- package/dist/modules/Quotation/types.js +1 -0
- package/dist/modules/Rules/entitlementLines.d.ts +8 -0
- package/dist/modules/Rules/entitlementLines.js +157 -0
- package/dist/modules/Rules/index.d.ts +17 -11
- package/dist/modules/Rules/index.js +495 -726
- package/dist/modules/Rules/types.d.ts +2 -4
- package/dist/modules/SalesSummary/index.d.ts +63 -0
- package/dist/modules/SalesSummary/index.js +174 -0
- package/dist/modules/SalesSummary/types.d.ts +60 -0
- package/dist/modules/SalesSummary/types.js +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +30 -0
- package/dist/modules/SalesSummary/utils.js +480 -0
- package/dist/modules/ScanOrderLogger/index.d.ts +23 -0
- package/dist/modules/ScanOrderLogger/index.js +174 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.js +221 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.js +50 -0
- package/dist/modules/ScanOrderLogger/types.d.ts +53 -0
- package/dist/modules/ScanOrderLogger/types.js +1 -0
- package/dist/modules/Schedule/getDateIsInSchedule.js +11 -18
- package/dist/modules/Schedule/utils.d.ts +1 -1
- package/dist/modules/Summary/types.d.ts +0 -2
- package/dist/modules/Summary/utils.d.ts +3 -9
- package/dist/modules/Summary/utils.js +67 -57
- package/dist/modules/index.d.ts +5 -0
- package/dist/modules/index.js +6 -1
- package/dist/plugins/window.d.ts +3 -2
- package/dist/solution/BookingByStep/index.d.ts +17 -3
- package/dist/solution/BookingByStep/index.js +322 -247
- package/dist/solution/BookingByStep/types.d.ts +4 -1
- package/dist/solution/BookingByStep/types.js +7 -1
- package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
- package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
- package/dist/solution/Checkout/index.js +0 -2
- package/dist/solution/ScanOrder/index.d.ts +158 -0
- package/dist/solution/ScanOrder/index.js +3474 -0
- package/dist/solution/ScanOrder/types.d.ts +307 -0
- package/dist/solution/ScanOrder/types.js +35 -0
- package/dist/solution/ScanOrder/utils.d.ts +172 -0
- package/dist/solution/ScanOrder/utils.js +796 -0
- package/dist/solution/ShopDiscount/index.d.ts +6 -2
- package/dist/solution/ShopDiscount/index.js +194 -110
- package/dist/solution/ShopDiscount/types.d.ts +1 -1
- package/dist/solution/ShopDiscount/types.js +1 -2
- package/dist/solution/ShopDiscount/utils.d.ts +1 -0
- package/dist/solution/ShopDiscount/utils.js +52 -27
- package/dist/solution/VenueBooking/index.d.ts +225 -0
- package/dist/solution/VenueBooking/index.js +3749 -0
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/dist/solution/VenueBooking/types.d.ts +156 -0
- package/dist/solution/VenueBooking/types.js +21 -0
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +104 -0
- package/dist/solution/VenueBooking/utils/resource.d.ts +14 -0
- package/dist/solution/VenueBooking/utils/resource.js +131 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +38 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +239 -0
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/dist/solution/VenueBooking/utils/timeSlot.js +453 -0
- package/dist/solution/VenueBooking/utils.d.ts +1 -0
- package/dist/solution/VenueBooking/utils.js +1 -0
- package/dist/solution/index.d.ts +2 -0
- package/dist/solution/index.js +3 -1
- package/dist/types/index.d.ts +1 -0
- package/lib/apis/picoding.d.ts +0 -0
- package/lib/apis/picoding.js +0 -0
- package/lib/index.d.ts +0 -1
- package/lib/index.js +1 -3
- package/lib/model/strategy/adapter/promotion/evaluator.js +8 -57
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +2 -2
- package/lib/model/strategy/adapter/walletPass/evaluator.js +7 -36
- package/lib/model/strategy/adapter/walletPass/locales.js +3 -12
- package/lib/model/strategy/engine.d.ts +5 -18
- package/lib/model/strategy/engine.js +21 -85
- package/lib/model/strategy/type.d.ts +0 -17
- package/lib/modules/Cart/types.d.ts +0 -2
- package/lib/modules/Cart/utils/cartProduct.js +12 -39
- package/lib/modules/Cart/utils/changePrice.js +13 -9
- package/lib/modules/Discount/availability.d.ts +7 -0
- package/lib/modules/Discount/availability.js +91 -0
- package/lib/modules/Discount/entitlementPass.d.ts +34 -0
- package/lib/modules/Discount/entitlementPass.js +184 -0
- package/lib/modules/Discount/entitlementState.d.ts +8 -0
- package/lib/modules/Discount/entitlementState.js +206 -0
- package/lib/modules/Discount/index.d.ts +12 -3
- package/lib/modules/Discount/index.js +123 -12
- package/lib/modules/Discount/types.d.ts +42 -22
- package/lib/modules/Holder/index.d.ts +48 -0
- package/lib/modules/Holder/index.js +402 -0
- package/lib/modules/Holder/types.d.ts +123 -0
- package/lib/modules/Holder/types.js +17 -0
- package/lib/modules/Holder/utils.d.ts +13 -0
- package/lib/modules/Holder/utils.js +71 -0
- package/lib/modules/OpenData/index.d.ts +24 -0
- package/lib/modules/OpenData/index.js +119 -0
- package/lib/modules/OpenData/types.d.ts +73 -0
- package/lib/modules/OpenData/types.js +17 -0
- package/lib/modules/OpenData/utils.d.ts +2 -0
- package/lib/modules/OpenData/utils.js +111 -0
- package/lib/modules/Order/index.d.ts +67 -1
- package/lib/modules/Order/index.js +529 -1
- package/lib/modules/Order/types.d.ts +176 -12
- package/lib/modules/Order/utils.d.ts +128 -0
- package/lib/modules/Order/utils.js +514 -2
- package/lib/modules/Payment/index.d.ts +1 -2
- package/lib/modules/Payment/index.js +0 -1
- package/lib/modules/Payment/utils.js +0 -3
- package/lib/modules/Payment/walletpass.d.ts +0 -23
- package/lib/modules/Payment/walletpass.js +17 -94
- package/lib/modules/Product/types.d.ts +7 -0
- package/lib/modules/Product/utils.js +2 -2
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +5 -4
- package/lib/modules/Quotation/index.d.ts +48 -0
- package/lib/modules/Quotation/index.js +152 -0
- package/lib/modules/Quotation/types.d.ts +42 -0
- package/lib/modules/Quotation/types.js +17 -0
- package/lib/modules/Rules/entitlementLines.d.ts +8 -0
- package/lib/modules/Rules/entitlementLines.js +158 -0
- package/lib/modules/Rules/index.d.ts +17 -11
- package/lib/modules/Rules/index.js +548 -798
- package/lib/modules/Rules/types.d.ts +2 -4
- package/lib/modules/SalesSummary/index.d.ts +63 -0
- package/lib/modules/SalesSummary/index.js +105 -0
- package/lib/modules/SalesSummary/types.d.ts +60 -0
- package/lib/modules/SalesSummary/types.js +17 -0
- package/lib/modules/SalesSummary/utils.d.ts +30 -0
- package/lib/modules/SalesSummary/utils.js +420 -0
- package/lib/modules/ScanOrderLogger/index.d.ts +23 -0
- package/lib/modules/ScanOrderLogger/index.js +147 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.js +157 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.js +52 -0
- package/lib/modules/ScanOrderLogger/types.d.ts +53 -0
- package/lib/modules/ScanOrderLogger/types.js +17 -0
- package/lib/modules/Schedule/getDateIsInSchedule.js +9 -11
- package/lib/modules/Schedule/utils.d.ts +1 -1
- package/lib/modules/Summary/types.d.ts +0 -2
- package/lib/modules/Summary/utils.d.ts +3 -9
- package/lib/modules/Summary/utils.js +45 -34
- package/lib/modules/index.d.ts +5 -0
- package/lib/modules/index.js +11 -1
- package/lib/plugins/window.d.ts +3 -2
- package/lib/solution/BookingByStep/index.d.ts +17 -3
- package/lib/solution/BookingByStep/index.js +45 -4
- package/lib/solution/BookingByStep/types.d.ts +4 -1
- package/lib/solution/BookingByStep/types.js +15 -0
- package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
- package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
- package/lib/solution/Checkout/index.js +0 -2
- package/lib/solution/ScanOrder/index.d.ts +158 -0
- package/lib/solution/ScanOrder/index.js +2135 -0
- package/lib/solution/ScanOrder/types.d.ts +307 -0
- package/lib/solution/ScanOrder/types.js +36 -0
- package/lib/solution/ScanOrder/utils.d.ts +172 -0
- package/lib/solution/ScanOrder/utils.js +658 -0
- package/lib/solution/ShopDiscount/index.d.ts +6 -2
- package/lib/solution/ShopDiscount/index.js +94 -50
- package/lib/solution/ShopDiscount/types.d.ts +1 -1
- package/lib/solution/ShopDiscount/utils.d.ts +1 -0
- package/lib/solution/ShopDiscount/utils.js +48 -11
- package/lib/solution/VenueBooking/index.d.ts +225 -0
- package/lib/solution/VenueBooking/index.js +2073 -0
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/lib/solution/VenueBooking/types.d.ts +156 -0
- package/lib/solution/VenueBooking/types.js +44 -0
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +110 -0
- package/lib/solution/VenueBooking/utils/resource.d.ts +14 -0
- package/lib/solution/VenueBooking/utils/resource.js +92 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +38 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +237 -0
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/lib/solution/VenueBooking/utils/timeSlot.js +339 -0
- package/lib/solution/VenueBooking/utils.d.ts +1 -0
- package/lib/solution/VenueBooking/utils.js +69 -0
- package/lib/solution/index.d.ts +2 -0
- package/lib/solution/index.js +5 -1
- package/lib/types/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
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."); }
|
|
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 _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; }
|
|
5
|
+
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; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
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); }
|
|
8
|
+
import dayjs from 'dayjs';
|
|
9
|
+
export var ENTITLEMENT_PASS_TYPE = 'entitlement_pass';
|
|
10
|
+
export var GOOD_PASS_TYPE = 'good_pass';
|
|
11
|
+
function getDiscountType(discount) {
|
|
12
|
+
var nestedDiscount = discount === null || discount === void 0 ? void 0 : discount.discount;
|
|
13
|
+
return String((discount === null || discount === void 0 ? void 0 : discount.tag) || (discount === null || discount === void 0 ? void 0 : discount.type) || (nestedDiscount === null || nestedDiscount === void 0 ? void 0 : nestedDiscount.tag) || (nestedDiscount === null || nestedDiscount === void 0 ? void 0 : nestedDiscount.type) || '');
|
|
14
|
+
}
|
|
15
|
+
export function isEntitlementPass(discount) {
|
|
16
|
+
return getDiscountType(discount) === ENTITLEMENT_PASS_TYPE;
|
|
17
|
+
}
|
|
18
|
+
export function isFullCoveragePass(discount) {
|
|
19
|
+
var type = getDiscountType(discount);
|
|
20
|
+
return type === GOOD_PASS_TYPE || type === ENTITLEMENT_PASS_TYPE;
|
|
21
|
+
}
|
|
22
|
+
function resolveIncludedUses(discount) {
|
|
23
|
+
var _discount$extension_d;
|
|
24
|
+
var metadata = discount.metadata;
|
|
25
|
+
var hasMetadataIncludedUses = !!metadata && _typeof(metadata) === 'object' && Object.prototype.hasOwnProperty.call(metadata, 'included_uses');
|
|
26
|
+
var rawValue = hasMetadataIncludedUses ? metadata === null || metadata === void 0 ? void 0 : metadata.included_uses : Array.isArray(discount.extension_data) ? (_discount$extension_d = discount.extension_data.find(function (item) {
|
|
27
|
+
return (item === null || item === void 0 ? void 0 : item.field_key) === 'included_uses';
|
|
28
|
+
})) === null || _discount$extension_d === void 0 ? void 0 : _discount$extension_d.value : undefined;
|
|
29
|
+
if (!rawValue || _typeof(rawValue) !== 'object' || Array.isArray(rawValue)) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
var includedUses = rawValue;
|
|
33
|
+
if (includedUses.type === 'unlimited' && includedUses.value === null) {
|
|
34
|
+
return {
|
|
35
|
+
type: 'unlimited',
|
|
36
|
+
value: null
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
if (includedUses.type === 'limited' && typeof includedUses.value === 'number' && Number.isInteger(includedUses.value) && includedUses.value >= 1 && includedUses.value <= 9999) {
|
|
40
|
+
return {
|
|
41
|
+
type: 'limited',
|
|
42
|
+
value: includedUses.value
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
function resolveNonNegativeInteger(value) {
|
|
48
|
+
if (typeof value !== 'number' && typeof value !== 'string' || typeof value === 'string' && value.trim() === '') {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
var normalizedValue = Number(value);
|
|
52
|
+
if (!Number.isInteger(normalizedValue) || normalizedValue < 0) return null;
|
|
53
|
+
return normalizedValue;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Resolve the authoritative total-use contract for an Entitlement Pass.
|
|
58
|
+
* Invalid or missing configuration fails closed. Legacy mode/total_uses fields
|
|
59
|
+
* are intentionally unsupported.
|
|
60
|
+
*/
|
|
61
|
+
export function resolveEntitlementQuota(discount) {
|
|
62
|
+
if (!isEntitlementPass(discount)) return null;
|
|
63
|
+
var includedUses = resolveIncludedUses(discount);
|
|
64
|
+
if (!includedUses) return null;
|
|
65
|
+
if (includedUses.type === 'unlimited') {
|
|
66
|
+
return {
|
|
67
|
+
type: 'unlimited',
|
|
68
|
+
value: null,
|
|
69
|
+
balance: null
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
var balance = resolveNonNegativeInteger(discount === null || discount === void 0 ? void 0 : discount.balance);
|
|
73
|
+
if (balance === null) return null;
|
|
74
|
+
return {
|
|
75
|
+
type: 'limited',
|
|
76
|
+
value: includedUses.value,
|
|
77
|
+
balance: balance
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
export function getRemainingEntitlementUses(discount, usedCount, requestedCount) {
|
|
81
|
+
var quota = resolveEntitlementQuota(discount);
|
|
82
|
+
var normalizedRequestedCount = Math.max(Math.floor(Number(requestedCount) || 0), 0);
|
|
83
|
+
if (!quota || normalizedRequestedCount <= 0) return 0;
|
|
84
|
+
if (quota.type === 'unlimited') return normalizedRequestedCount;
|
|
85
|
+
var normalizedUsedCount = Math.max(Math.floor(Number(usedCount) || 0), 0);
|
|
86
|
+
return Math.min(Math.max(quota.balance - normalizedUsedCount, 0), normalizedRequestedCount);
|
|
87
|
+
}
|
|
88
|
+
export function hasAvailableEntitlementUses(discount) {
|
|
89
|
+
var quota = resolveEntitlementQuota(discount);
|
|
90
|
+
return !!quota && (quota.type === 'unlimited' || quota.balance > 0);
|
|
91
|
+
}
|
|
92
|
+
function resolveExpireTimestamp(value) {
|
|
93
|
+
if (typeof value !== 'string' || !value.trim()) return Number.POSITIVE_INFINITY;
|
|
94
|
+
var normalizedValue = value.trim();
|
|
95
|
+
var calendarParts = normalizedValue.match(/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?)?/);
|
|
96
|
+
if (calendarParts) {
|
|
97
|
+
var _calendarParts = _slicedToArray(calendarParts, 7),
|
|
98
|
+
year = _calendarParts[1],
|
|
99
|
+
month = _calendarParts[2],
|
|
100
|
+
day = _calendarParts[3],
|
|
101
|
+
_calendarParts$ = _calendarParts[4],
|
|
102
|
+
hour = _calendarParts$ === void 0 ? '0' : _calendarParts$,
|
|
103
|
+
_calendarParts$2 = _calendarParts[5],
|
|
104
|
+
minute = _calendarParts$2 === void 0 ? '0' : _calendarParts$2,
|
|
105
|
+
_calendarParts$3 = _calendarParts[6],
|
|
106
|
+
second = _calendarParts$3 === void 0 ? '0' : _calendarParts$3;
|
|
107
|
+
var yearNumber = Number(year);
|
|
108
|
+
var monthNumber = Number(month);
|
|
109
|
+
var dayNumber = Number(day);
|
|
110
|
+
var hourNumber = Number(hour);
|
|
111
|
+
var minuteNumber = Number(minute);
|
|
112
|
+
var secondNumber = Number(second);
|
|
113
|
+
var daysInMonth = new Date(Date.UTC(yearNumber, monthNumber, 0)).getUTCDate();
|
|
114
|
+
if (yearNumber <= 0 || monthNumber < 1 || monthNumber > 12 || dayNumber < 1 || dayNumber > daysInMonth || hourNumber < 0 || hourNumber > 23 || minuteNumber < 0 || minuteNumber > 59 || secondNumber < 0 || secondNumber > 59) {
|
|
115
|
+
return Number.POSITIVE_INFINITY;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
var date = dayjs(normalizedValue);
|
|
119
|
+
return date.isValid() ? date.valueOf() : Number.POSITIVE_INFINITY;
|
|
120
|
+
}
|
|
121
|
+
function compareIds(left, right) {
|
|
122
|
+
var leftNumber = Number(left);
|
|
123
|
+
var rightNumber = Number(right);
|
|
124
|
+
if (Number.isFinite(leftNumber) && Number.isFinite(rightNumber)) {
|
|
125
|
+
return leftNumber - rightNumber;
|
|
126
|
+
}
|
|
127
|
+
return String(left !== null && left !== void 0 ? left : '').localeCompare(String(right !== null && right !== void 0 ? right : ''), undefined, {
|
|
128
|
+
numeric: true
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** Sort Entitlement Passes by expiry, finite balance, then card instance id. */
|
|
133
|
+
export function compareEntitlementPassPriority(left, right) {
|
|
134
|
+
var expireDifference = resolveExpireTimestamp(left.expire_time) - resolveExpireTimestamp(right.expire_time);
|
|
135
|
+
if (!Number.isNaN(expireDifference) && expireDifference !== 0) {
|
|
136
|
+
return expireDifference;
|
|
137
|
+
}
|
|
138
|
+
var leftQuota = resolveEntitlementQuota(left);
|
|
139
|
+
var rightQuota = resolveEntitlementQuota(right);
|
|
140
|
+
var leftBalance = (leftQuota === null || leftQuota === void 0 ? void 0 : leftQuota.type) === 'limited' ? leftQuota.balance : Number.POSITIVE_INFINITY;
|
|
141
|
+
var rightBalance = (rightQuota === null || rightQuota === void 0 ? void 0 : rightQuota.type) === 'limited' ? rightQuota.balance : Number.POSITIVE_INFINITY;
|
|
142
|
+
var balanceDifference = leftBalance - rightBalance;
|
|
143
|
+
if (!Number.isNaN(balanceDifference) && balanceDifference !== 0) {
|
|
144
|
+
return balanceDifference;
|
|
145
|
+
}
|
|
146
|
+
return compareIds(left.id, right.id);
|
|
147
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Discount } from './types';
|
|
2
|
+
export declare function hasEntitlementDiscount(product: any): boolean;
|
|
3
|
+
export declare function isPersistedEntitlementLine(product: any, mappedProduct?: any): boolean;
|
|
4
|
+
/** Refresh authoritative balances while retaining the user's scan/selection state. */
|
|
5
|
+
export declare function mergeEntitlementDiscountLists(current: Discount[], incoming: Discount[], observed?: Discount[]): Discount[];
|
|
6
|
+
export declare function retainScannedEntitlements(current: Discount[], scanned: Discount[]): Discount[];
|
|
7
|
+
/** Historical uses are display records; backend balance already excludes them. */
|
|
8
|
+
export declare function withCommittedEntitlementDetails(discounts: Discount[], products: any[], getProduct: (item: any) => any): Discount[];
|
|
@@ -0,0 +1,205 @@
|
|
|
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 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; }
|
|
4
|
+
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; }
|
|
5
|
+
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; }
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
|
+
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); }
|
|
8
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
9
|
+
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."); }
|
|
10
|
+
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); }
|
|
11
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
12
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
13
|
+
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
|
+
import { cloneDeep } from 'lodash-es';
|
|
15
|
+
import Decimal from 'decimal.js';
|
|
16
|
+
import { getDiscountLifecycleReason } from "./availability";
|
|
17
|
+
import { isEntitlementPass, resolveEntitlementQuota } from "./entitlementPass";
|
|
18
|
+
function getEntitlementDiscountLines(product) {
|
|
19
|
+
var _product$_origin$prod, _product$_origin, _product$_originData, _ref, _product$discount_lis, _ref2, _ref3, _ref4, _product$product_bund, _product$_extend;
|
|
20
|
+
var nested = (_product$_origin$prod = product === null || product === void 0 || (_product$_origin = product._origin) === null || _product$_origin === void 0 ? void 0 : _product$_origin.product) !== null && _product$_origin$prod !== void 0 ? _product$_origin$prod : product === null || product === void 0 || (_product$_originData = product._originData) === null || _product$_originData === void 0 ? void 0 : _product$_originData.product;
|
|
21
|
+
return [{
|
|
22
|
+
discount_list: (_ref = (_product$discount_lis = product === null || product === void 0 ? void 0 : product.discount_list) !== null && _product$discount_lis !== void 0 ? _product$discount_lis : nested === null || nested === void 0 ? void 0 : nested.discount_list) !== null && _ref !== void 0 ? _ref : []
|
|
23
|
+
}].concat(_toConsumableArray((_ref2 = (_ref3 = (_ref4 = (_product$product_bund = product === null || product === void 0 ? void 0 : product.product_bundle) !== null && _product$product_bund !== void 0 ? _product$product_bund : product === null || product === void 0 ? void 0 : product.bundle) !== null && _ref4 !== void 0 ? _ref4 : product === null || product === void 0 || (_product$_extend = product._extend) === null || _product$_extend === void 0 || (_product$_extend = _product$_extend.other) === null || _product$_extend === void 0 ? void 0 : _product$_extend.bundle) !== null && _ref3 !== void 0 ? _ref3 : nested === null || nested === void 0 ? void 0 : nested.product_bundle) !== null && _ref2 !== void 0 ? _ref2 : []));
|
|
24
|
+
}
|
|
25
|
+
export function hasEntitlementDiscount(product) {
|
|
26
|
+
return getEntitlementDiscountLines(product).some(function (line) {
|
|
27
|
+
return (line.discount_list || []).some(isEntitlementPass);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export function isPersistedEntitlementLine(product, mappedProduct) {
|
|
31
|
+
var _product$_origin$prod2, _product$_origin2, _product$_originData2, _product$_origin3, _product$_originData3, _product$_extend2, _product$metadata;
|
|
32
|
+
var nested = (_product$_origin$prod2 = product === null || product === void 0 || (_product$_origin2 = product._origin) === null || _product$_origin2 === void 0 ? void 0 : _product$_origin2.product) !== null && _product$_origin$prod2 !== void 0 ? _product$_origin$prod2 : product === null || product === void 0 || (_product$_originData2 = product._originData) === null || _product$_originData2 === void 0 ? void 0 : _product$_originData2.product;
|
|
33
|
+
var persisted = [product === null || product === void 0 ? void 0 : product.order_detail_id, product === null || product === void 0 ? void 0 : product.booking_id, product === null || product === void 0 || (_product$_origin3 = product._origin) === null || _product$_origin3 === void 0 ? void 0 : _product$_origin3.booking_id, product === null || product === void 0 || (_product$_originData3 = product._originData) === null || _product$_originData3 === void 0 ? void 0 : _product$_originData3.booking_id, product === null || product === void 0 || (_product$_extend2 = product._extend) === null || _product$_extend2 === void 0 ? void 0 : _product$_extend2.order_detail_id, nested === null || nested === void 0 ? void 0 : nested.order_detail_id, nested === null || nested === void 0 ? void 0 : nested.booking_id, mappedProduct === null || mappedProduct === void 0 ? void 0 : mappedProduct.order_detail_id, mappedProduct === null || mappedProduct === void 0 ? void 0 : mappedProduct.booking_id].some(function (value) {
|
|
34
|
+
return value !== undefined && value !== null && value !== '' && value !== 0 && value !== '0';
|
|
35
|
+
});
|
|
36
|
+
var lines = getEntitlementDiscountLines(mappedProduct !== null && mappedProduct !== void 0 ? mappedProduct : product);
|
|
37
|
+
// 已有预约上刚选的卡仍属本次使用,只有接口回传的明细才计入历史。
|
|
38
|
+
return lines.some(function (line) {
|
|
39
|
+
return (line.discount_list || []).some(isEntitlementPass);
|
|
40
|
+
}) && (persisted && (product === null || product === void 0 || (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.entitlement_source_identity) == null || lines.some(function (line) {
|
|
41
|
+
return (line.discount_list || []).some(function (item) {
|
|
42
|
+
return isEntitlementPass(item) && item.id;
|
|
43
|
+
});
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Refresh authoritative balances while retaining the user's scan/selection state. */
|
|
48
|
+
export function mergeEntitlementDiscountLists(current, incoming) {
|
|
49
|
+
var observed = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : incoming;
|
|
50
|
+
var previous = new Map(current.map(function (item) {
|
|
51
|
+
return [String(item.id), item];
|
|
52
|
+
}));
|
|
53
|
+
var observedById = new Map(observed.map(function (item) {
|
|
54
|
+
return [String(item.id), item];
|
|
55
|
+
}));
|
|
56
|
+
var next = new Map();
|
|
57
|
+
current.filter(function (item) {
|
|
58
|
+
return item.isScan;
|
|
59
|
+
}).forEach(function (item) {
|
|
60
|
+
var fresh = observedById.get(String(item.id));
|
|
61
|
+
if (isEntitlementPass(item) && getDiscountLifecycleReason(fresh || item)) return;
|
|
62
|
+
next.set(String(item.id), item);
|
|
63
|
+
});
|
|
64
|
+
incoming.forEach(function (item) {
|
|
65
|
+
var old = previous.get(String(item.id));
|
|
66
|
+
if (old !== null && old !== void 0 && old.isScan && !isEntitlementPass(item)) return;
|
|
67
|
+
next.set(String(item.id), old && isEntitlementPass(item) ? _objectSpread(_objectSpread({}, item), {}, {
|
|
68
|
+
isScan: old.isScan,
|
|
69
|
+
isSelected: old.isSelected,
|
|
70
|
+
isManualSelect: old.isManualSelect
|
|
71
|
+
}) : item);
|
|
72
|
+
});
|
|
73
|
+
return _toConsumableArray(next.values());
|
|
74
|
+
}
|
|
75
|
+
export function retainScannedEntitlements(current, scanned) {
|
|
76
|
+
var result = new Map(current.map(function (item) {
|
|
77
|
+
return [String(item.id), item];
|
|
78
|
+
}));
|
|
79
|
+
scanned.filter(function (item) {
|
|
80
|
+
return isEntitlementPass(item) && !getDiscountLifecycleReason(item);
|
|
81
|
+
}).forEach(function (item) {
|
|
82
|
+
var previous = result.get(String(item.id));
|
|
83
|
+
var committed = item.committedAppliedProductDetails || (previous === null || previous === void 0 ? void 0 : previous.committedAppliedProductDetails) || [];
|
|
84
|
+
var isAvailable = !!item.isAvailable;
|
|
85
|
+
result.set(String(item.id), _objectSpread(_objectSpread({}, item), {}, {
|
|
86
|
+
isScan: true,
|
|
87
|
+
isAvailable: isAvailable,
|
|
88
|
+
isSelected: committed.length > 0,
|
|
89
|
+
reasonCode: isAvailable ? undefined : item.reasonCode || 'product_not_applicable',
|
|
90
|
+
committedAppliedProductDetails: committed,
|
|
91
|
+
appliedProductDetails: committed,
|
|
92
|
+
savedAmount: committed.length ? previous === null || previous === void 0 ? void 0 : previous.savedAmount : 0
|
|
93
|
+
}));
|
|
94
|
+
});
|
|
95
|
+
return _toConsumableArray(result.values());
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Historical uses are display records; backend balance already excludes them. */
|
|
99
|
+
export function withCommittedEntitlementDetails(discounts, products, getProduct) {
|
|
100
|
+
var savedAmount = function savedAmount(details) {
|
|
101
|
+
return details.reduce(function (sum, detail) {
|
|
102
|
+
var _detail$discount;
|
|
103
|
+
return sum.plus(new Decimal(((_detail$discount = detail.discount) === null || _detail$discount === void 0 ? void 0 : _detail$discount.fixed_amount) || 0).times(detail._num));
|
|
104
|
+
}, new Decimal(0)).toNumber();
|
|
105
|
+
};
|
|
106
|
+
var committed = new Map();
|
|
107
|
+
var _iterator = _createForOfIteratorHelper(products),
|
|
108
|
+
_step;
|
|
109
|
+
try {
|
|
110
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
111
|
+
var origin = _step.value;
|
|
112
|
+
var product = getProduct(origin);
|
|
113
|
+
var persisted = isPersistedEntitlementLine(origin, product);
|
|
114
|
+
var lines = [product].concat(_toConsumableArray(product.bundle || []));
|
|
115
|
+
var bundleKeys = new Set((product.bundle || []).flatMap(function (line) {
|
|
116
|
+
return (line.discount_list || []).map(function (detail) {
|
|
117
|
+
var _detail$discount$reso, _detail$discount2, _detail$metadata;
|
|
118
|
+
return "".concat((_detail$discount$reso = (_detail$discount2 = detail.discount) === null || _detail$discount2 === void 0 ? void 0 : _detail$discount2.resource_id) !== null && _detail$discount$reso !== void 0 ? _detail$discount$reso : detail.id, ":").concat((_detail$metadata = detail.metadata) === null || _detail$metadata === void 0 ? void 0 : _detail$metadata.custom_product_bundle_map_id);
|
|
119
|
+
});
|
|
120
|
+
}));
|
|
121
|
+
var _iterator2 = _createForOfIteratorHelper(lines),
|
|
122
|
+
_step2;
|
|
123
|
+
try {
|
|
124
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
125
|
+
var line = _step2.value;
|
|
126
|
+
var _iterator3 = _createForOfIteratorHelper(line.discount_list || []),
|
|
127
|
+
_step3;
|
|
128
|
+
try {
|
|
129
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
130
|
+
var _detail$metadata2, _detail$discount$reso2, _detail$discount3, _ref5, _detail$discount$reso3, _detail$discount4, _ref6, _ref7, _detail$metadata$num, _detail$metadata3, _ref8, _product$quantity, _detail$discount$fixe, _detail$discount5;
|
|
131
|
+
var detail = _step3.value;
|
|
132
|
+
var bundleId = (_detail$metadata2 = detail.metadata) === null || _detail$metadata2 === void 0 ? void 0 : _detail$metadata2.custom_product_bundle_map_id;
|
|
133
|
+
if (!isEntitlementPass(detail) || !persisted && !detail.id || line === product && bundleId && bundleKeys.has("".concat((_detail$discount$reso2 = (_detail$discount3 = detail.discount) === null || _detail$discount3 === void 0 ? void 0 : _detail$discount3.resource_id) !== null && _detail$discount$reso2 !== void 0 ? _detail$discount$reso2 : detail.id, ":").concat(bundleId))) continue;
|
|
134
|
+
var id = (_ref5 = (_detail$discount$reso3 = (_detail$discount4 = detail.discount) === null || _detail$discount4 === void 0 ? void 0 : _detail$discount4.resource_id) !== null && _detail$discount$reso3 !== void 0 ? _detail$discount$reso3 : detail.resource_id) !== null && _ref5 !== void 0 ? _ref5 : detail.id;
|
|
135
|
+
if (id == null) continue;
|
|
136
|
+
var lineUses = Number((_ref6 = (_ref7 = (_detail$metadata$num = (_detail$metadata3 = detail.metadata) === null || _detail$metadata3 === void 0 ? void 0 : _detail$metadata3.num) !== null && _detail$metadata$num !== void 0 ? _detail$metadata$num : line.num) !== null && _ref7 !== void 0 ? _ref7 : line.quantity) !== null && _ref6 !== void 0 ? _ref6 : 1);
|
|
137
|
+
if (!Number.isFinite(lineUses) || lineUses <= 0) continue;
|
|
138
|
+
var count = lineUses * (line === product && !bundleId ? 1 : Number((_ref8 = (_product$quantity = product.quantity) !== null && _product$quantity !== void 0 ? _product$quantity : product.num) !== null && _ref8 !== void 0 ? _ref8 : 1));
|
|
139
|
+
var list = committed.get(String(id)) || [];
|
|
140
|
+
list.push(_objectSpread(_objectSpread({}, cloneDeep(detail)), {}, {
|
|
141
|
+
_num: count,
|
|
142
|
+
metadata: _objectSpread(_objectSpread({}, detail.metadata), {}, {
|
|
143
|
+
num: count
|
|
144
|
+
}),
|
|
145
|
+
discount: _objectSpread(_objectSpread({}, detail.discount), {}, {
|
|
146
|
+
fixed_amount: (_detail$discount$fixe = (_detail$discount5 = detail.discount) === null || _detail$discount5 === void 0 ? void 0 : _detail$discount5.fixed_amount) !== null && _detail$discount$fixe !== void 0 ? _detail$discount$fixe : new Decimal(detail.amount || 0).div(bundleId ? lineUses : 1).toNumber()
|
|
147
|
+
})
|
|
148
|
+
}));
|
|
149
|
+
committed.set(String(id), list);
|
|
150
|
+
}
|
|
151
|
+
} catch (err) {
|
|
152
|
+
_iterator3.e(err);
|
|
153
|
+
} finally {
|
|
154
|
+
_iterator3.f();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
} catch (err) {
|
|
158
|
+
_iterator2.e(err);
|
|
159
|
+
} finally {
|
|
160
|
+
_iterator2.f();
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
} catch (err) {
|
|
164
|
+
_iterator.e(err);
|
|
165
|
+
} finally {
|
|
166
|
+
_iterator.f();
|
|
167
|
+
}
|
|
168
|
+
var next = discounts.map(function (item) {
|
|
169
|
+
if (!isEntitlementPass(item)) return item;
|
|
170
|
+
var details = committed.get(String(item.id)) || [];
|
|
171
|
+
committed.delete(String(item.id));
|
|
172
|
+
return _objectSpread(_objectSpread(_objectSpread({}, item), {}, {
|
|
173
|
+
committedAppliedProductDetails: details,
|
|
174
|
+
isEditMode: details.length > 0 && !resolveEntitlementQuota(item)
|
|
175
|
+
}, item.isEditMode && resolveEntitlementQuota(item) ? {
|
|
176
|
+
isDisabled: false
|
|
177
|
+
} : {}), details.length && !resolveEntitlementQuota(item) ? {
|
|
178
|
+
isSelected: true,
|
|
179
|
+
isDisabled: true,
|
|
180
|
+
isUsed: true,
|
|
181
|
+
appliedProductDetails: details,
|
|
182
|
+
savedAmount: savedAmount(details)
|
|
183
|
+
} : {});
|
|
184
|
+
});
|
|
185
|
+
committed.forEach(function (details, id) {
|
|
186
|
+
var _first$discount;
|
|
187
|
+
var first = details[0];
|
|
188
|
+
next.push(_objectSpread(_objectSpread({}, first), {}, {
|
|
189
|
+
id: Number(id),
|
|
190
|
+
tag: 'entitlement_pass',
|
|
191
|
+
type: 'entitlement_pass',
|
|
192
|
+
format_title: (_first$discount = first.discount) === null || _first$discount === void 0 ? void 0 : _first$discount.title,
|
|
193
|
+
isEditMode: true,
|
|
194
|
+
isSelected: true,
|
|
195
|
+
isDisabled: true,
|
|
196
|
+
isUsed: true,
|
|
197
|
+
isAvailable: true,
|
|
198
|
+
committedAppliedProductDetails: details,
|
|
199
|
+
appliedProductDetails: details,
|
|
200
|
+
applicableProductDetails: [],
|
|
201
|
+
savedAmount: savedAmount(details)
|
|
202
|
+
}));
|
|
203
|
+
});
|
|
204
|
+
return next;
|
|
205
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import { Discount, DiscountModuleAPI } from './types';
|
|
3
|
+
import { Discount, DiscountModuleAPI, DiscountWithReason } from './types';
|
|
4
4
|
export declare class DiscountModule extends BaseModule implements Module, DiscountModuleAPI {
|
|
5
5
|
protected defaultName: string;
|
|
6
6
|
protected defaultVersion: string;
|
|
@@ -17,17 +17,26 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
|
|
|
17
17
|
setOriginalDiscountList(originalDiscountList: Discount[]): Promise<void>;
|
|
18
18
|
getOriginalDiscountList(): Discount[];
|
|
19
19
|
loadPrepareConfig(params: {
|
|
20
|
-
action?: 'create';
|
|
20
|
+
action?: 'create' | 'edit';
|
|
21
21
|
with_good_pass: 0 | 1;
|
|
22
22
|
with_discount_card: 0 | 1;
|
|
23
23
|
customer_id: number;
|
|
24
24
|
with_wallet_pass_holder: 0 | 1;
|
|
25
25
|
request_timezone: string;
|
|
26
|
+
order_id?: number | string;
|
|
27
|
+
with_entitlement_pass?: 0 | 1;
|
|
28
|
+
filter_order_wallet_pass_usage?: 0 | 1;
|
|
26
29
|
}): Promise<Discount[]>;
|
|
27
|
-
batchSearch(code: string,
|
|
30
|
+
batchSearch(code: string, customerIdOrOptions?: number | {
|
|
31
|
+
customerId?: number;
|
|
32
|
+
orderId?: number | string;
|
|
33
|
+
withEntitlementPass?: boolean;
|
|
34
|
+
}): Promise<DiscountWithReason>;
|
|
28
35
|
batchSearchByProductIds(productIds: number[]): Promise<any>;
|
|
29
36
|
filterEnabledDiscountList(discountList: Discount[]): Discount[];
|
|
30
37
|
private checkUsageCreditsLimit;
|
|
38
|
+
filterEnabledDiscountListWithReason(discountList: Discount[]): DiscountWithReason;
|
|
39
|
+
private checkUsageCreditsLimitWithFailKey;
|
|
31
40
|
uniqueByProductId(discountList: Discount[]): Discount[];
|
|
32
41
|
filterDiscountListByProductIds(discountList: Discount[], productIds: number[]): Discount[];
|
|
33
42
|
calcDiscountApplicableProductTotalPrice(discount: Discount): number | undefined;
|