@pisell/pisellos 2.3.124 → 2.3.126
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/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +0 -2
- package/dist/model/strategy/adapter/walletPass/evaluator.js +2 -4
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +19 -58
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +12 -24
- package/dist/modules/Customer/index.js +3 -6
- package/dist/modules/Customer/types.d.ts +0 -2
- package/dist/modules/Discount/index.d.ts +2 -2
- package/dist/modules/Discount/index.js +151 -37
- package/dist/modules/Discount/types.d.ts +5 -36
- package/dist/modules/Order/index.d.ts +12 -7
- package/dist/modules/Order/index.js +307 -432
- package/dist/modules/Order/types.d.ts +5 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.js +12 -16
- package/dist/modules/Order/utils.d.ts +11 -1
- package/dist/modules/Order/utils.js +127 -122
- package/dist/modules/Payment/types.d.ts +1 -21
- package/dist/modules/Payment/types.js +0 -2
- package/dist/modules/Payment/walletpass.d.ts +1 -1
- package/dist/modules/Payment/walletpass.js +47 -80
- package/dist/modules/Rules/index.d.ts +2 -2
- package/dist/modules/Rules/index.js +186 -480
- package/dist/modules/Rules/types.d.ts +0 -4
- package/dist/server/modules/order/types.d.ts +0 -2
- package/dist/solution/BaseSales/index.d.ts +0 -1
- package/dist/solution/BaseSales/index.js +59 -51
- package/dist/solution/BaseSales/types.d.ts +2 -2
- package/dist/solution/BaseSales/utils/cartPromotion.js +126 -141
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +2 -1
- package/dist/solution/BookingTicket/index.js +63 -60
- package/dist/solution/BookingTicket/types.d.ts +1 -5
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -2
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +147 -338
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +4 -8
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +0 -6
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +6 -19
- package/dist/solution/ShopDiscount/index.d.ts +0 -2
- package/dist/solution/ShopDiscount/index.js +42 -99
- package/dist/solution/ShopDiscount/utils.d.ts +2 -4
- package/dist/solution/ShopDiscount/utils.js +23 -43
- package/dist/solution/UnifiedBookingSales/index.js +2 -2
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +0 -2
- package/lib/model/strategy/adapter/walletPass/evaluator.js +0 -2
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +6 -35
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +6 -13
- package/lib/modules/Customer/index.js +1 -5
- package/lib/modules/Customer/types.d.ts +0 -2
- package/lib/modules/Discount/index.d.ts +2 -2
- package/lib/modules/Discount/index.js +129 -23
- package/lib/modules/Discount/types.d.ts +5 -36
- package/lib/modules/Order/index.d.ts +12 -7
- package/lib/modules/Order/index.js +107 -215
- package/lib/modules/Order/types.d.ts +5 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.js +11 -14
- package/lib/modules/Order/utils.d.ts +11 -1
- package/lib/modules/Order/utils.js +45 -39
- package/lib/modules/Payment/types.d.ts +1 -21
- package/lib/modules/Payment/types.js +0 -1
- package/lib/modules/Payment/walletpass.d.ts +1 -1
- package/lib/modules/Payment/walletpass.js +9 -29
- package/lib/modules/Rules/index.d.ts +2 -2
- package/lib/modules/Rules/index.js +110 -357
- package/lib/modules/Rules/types.d.ts +0 -4
- package/lib/server/modules/order/types.d.ts +0 -2
- package/lib/solution/BaseSales/index.d.ts +0 -1
- package/lib/solution/BaseSales/index.js +12 -5
- package/lib/solution/BaseSales/types.d.ts +2 -2
- package/lib/solution/BaseSales/utils/cartPromotion.js +4 -12
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +2 -1
- package/lib/solution/BookingTicket/index.js +33 -36
- package/lib/solution/BookingTicket/types.d.ts +1 -5
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -2
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +42 -174
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +4 -8
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +0 -6
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +3 -11
- package/lib/solution/ShopDiscount/index.d.ts +0 -2
- package/lib/solution/ShopDiscount/index.js +9 -55
- package/lib/solution/ShopDiscount/utils.d.ts +2 -4
- package/lib/solution/ShopDiscount/utils.js +25 -42
- package/lib/solution/UnifiedBookingSales/index.js +2 -2
- package/package.json +1 -1
- package/dist/modules/Discount/availability.d.ts +0 -7
- package/dist/modules/Discount/availability.js +0 -49
- package/dist/modules/Discount/entitlementPass.d.ts +0 -34
- package/dist/modules/Discount/entitlementPass.js +0 -147
- package/lib/modules/Discount/availability.d.ts +0 -7
- package/lib/modules/Discount/availability.js +0 -43
- package/lib/modules/Discount/entitlementPass.d.ts +0 -34
- package/lib/modules/Discount/entitlementPass.js +0 -141
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export declare const ENTITLEMENT_PASS_TYPE = "entitlement_pass";
|
|
2
|
-
export declare const GOOD_PASS_TYPE = "good_pass";
|
|
3
|
-
type DiscountLike = {
|
|
4
|
-
id?: number | string | null;
|
|
5
|
-
tag?: unknown;
|
|
6
|
-
type?: unknown;
|
|
7
|
-
discount?: object | null;
|
|
8
|
-
metadata?: object | null;
|
|
9
|
-
extension_data?: unknown;
|
|
10
|
-
balance?: unknown;
|
|
11
|
-
expire_time?: unknown;
|
|
12
|
-
};
|
|
13
|
-
export type EntitlementQuota = {
|
|
14
|
-
type: 'limited';
|
|
15
|
-
value: number;
|
|
16
|
-
balance: number;
|
|
17
|
-
} | {
|
|
18
|
-
type: 'unlimited';
|
|
19
|
-
value: null;
|
|
20
|
-
balance: null;
|
|
21
|
-
};
|
|
22
|
-
export declare function isEntitlementPass(discount: DiscountLike | null | undefined): boolean;
|
|
23
|
-
export declare function isFullCoveragePass(discount: DiscountLike | null | undefined): boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Resolve the authoritative total-use contract for an Entitlement Pass.
|
|
26
|
-
* Invalid or missing configuration fails closed. Legacy mode/total_uses fields
|
|
27
|
-
* are intentionally unsupported.
|
|
28
|
-
*/
|
|
29
|
-
export declare function resolveEntitlementQuota(discount: DiscountLike | null | undefined): EntitlementQuota | null;
|
|
30
|
-
export declare function getRemainingEntitlementUses(discount: DiscountLike | null | undefined, usedCount: number, requestedCount: number): number;
|
|
31
|
-
export declare function hasAvailableEntitlementUses(discount: DiscountLike | null | undefined): boolean;
|
|
32
|
-
/** Sort Entitlement Passes by expiry, finite balance, then card instance id. */
|
|
33
|
-
export declare function compareEntitlementPassPriority(left: DiscountLike, right: DiscountLike): number;
|
|
34
|
-
export {};
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.GOOD_PASS_TYPE = exports.ENTITLEMENT_PASS_TYPE = void 0;
|
|
7
|
-
exports.compareEntitlementPassPriority = compareEntitlementPassPriority;
|
|
8
|
-
exports.getRemainingEntitlementUses = getRemainingEntitlementUses;
|
|
9
|
-
exports.hasAvailableEntitlementUses = hasAvailableEntitlementUses;
|
|
10
|
-
exports.isEntitlementPass = isEntitlementPass;
|
|
11
|
-
exports.isFullCoveragePass = isFullCoveragePass;
|
|
12
|
-
exports.resolveEntitlementQuota = resolveEntitlementQuota;
|
|
13
|
-
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
const ENTITLEMENT_PASS_TYPE = exports.ENTITLEMENT_PASS_TYPE = 'entitlement_pass';
|
|
16
|
-
const GOOD_PASS_TYPE = exports.GOOD_PASS_TYPE = 'good_pass';
|
|
17
|
-
function getDiscountType(discount) {
|
|
18
|
-
const nestedDiscount = discount?.discount;
|
|
19
|
-
return String(discount?.tag || discount?.type || nestedDiscount?.tag || nestedDiscount?.type || '');
|
|
20
|
-
}
|
|
21
|
-
function isEntitlementPass(discount) {
|
|
22
|
-
return getDiscountType(discount) === ENTITLEMENT_PASS_TYPE;
|
|
23
|
-
}
|
|
24
|
-
function isFullCoveragePass(discount) {
|
|
25
|
-
const type = getDiscountType(discount);
|
|
26
|
-
return type === GOOD_PASS_TYPE || type === ENTITLEMENT_PASS_TYPE;
|
|
27
|
-
}
|
|
28
|
-
function resolveIncludedUses(discount) {
|
|
29
|
-
const metadata = discount.metadata;
|
|
30
|
-
const hasMetadataIncludedUses = !!metadata && typeof metadata === 'object' && Object.prototype.hasOwnProperty.call(metadata, 'included_uses');
|
|
31
|
-
const rawValue = hasMetadataIncludedUses ? metadata?.included_uses : Array.isArray(discount.extension_data) ? discount.extension_data.find(item => item?.field_key === 'included_uses')?.value : undefined;
|
|
32
|
-
if (!rawValue || typeof rawValue !== 'object' || Array.isArray(rawValue)) {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
const includedUses = rawValue;
|
|
36
|
-
if (includedUses.type === 'unlimited' && includedUses.value === null) {
|
|
37
|
-
return {
|
|
38
|
-
type: 'unlimited',
|
|
39
|
-
value: null
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
if (includedUses.type === 'limited' && typeof includedUses.value === 'number' && Number.isInteger(includedUses.value) && includedUses.value >= 1 && includedUses.value <= 9999) {
|
|
43
|
-
return {
|
|
44
|
-
type: 'limited',
|
|
45
|
-
value: includedUses.value
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
function resolveNonNegativeInteger(value) {
|
|
51
|
-
if (typeof value !== 'number' && typeof value !== 'string' || typeof value === 'string' && value.trim() === '') {
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
const normalizedValue = Number(value);
|
|
55
|
-
if (!Number.isInteger(normalizedValue) || normalizedValue < 0) return null;
|
|
56
|
-
return normalizedValue;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Resolve the authoritative total-use contract for an Entitlement Pass.
|
|
61
|
-
* Invalid or missing configuration fails closed. Legacy mode/total_uses fields
|
|
62
|
-
* are intentionally unsupported.
|
|
63
|
-
*/
|
|
64
|
-
function resolveEntitlementQuota(discount) {
|
|
65
|
-
if (!isEntitlementPass(discount)) return null;
|
|
66
|
-
const includedUses = resolveIncludedUses(discount);
|
|
67
|
-
if (!includedUses) return null;
|
|
68
|
-
if (includedUses.type === 'unlimited') {
|
|
69
|
-
return {
|
|
70
|
-
type: 'unlimited',
|
|
71
|
-
value: null,
|
|
72
|
-
balance: null
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
const balance = resolveNonNegativeInteger(discount?.balance);
|
|
76
|
-
if (balance === null) return null;
|
|
77
|
-
return {
|
|
78
|
-
type: 'limited',
|
|
79
|
-
value: includedUses.value,
|
|
80
|
-
balance
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
function getRemainingEntitlementUses(discount, usedCount, requestedCount) {
|
|
84
|
-
const quota = resolveEntitlementQuota(discount);
|
|
85
|
-
const normalizedRequestedCount = Math.max(Math.floor(Number(requestedCount) || 0), 0);
|
|
86
|
-
if (!quota || normalizedRequestedCount <= 0) return 0;
|
|
87
|
-
if (quota.type === 'unlimited') return normalizedRequestedCount;
|
|
88
|
-
const normalizedUsedCount = Math.max(Math.floor(Number(usedCount) || 0), 0);
|
|
89
|
-
return Math.min(Math.max(quota.balance - normalizedUsedCount, 0), normalizedRequestedCount);
|
|
90
|
-
}
|
|
91
|
-
function hasAvailableEntitlementUses(discount) {
|
|
92
|
-
const quota = resolveEntitlementQuota(discount);
|
|
93
|
-
return !!quota && (quota.type === 'unlimited' || quota.balance > 0);
|
|
94
|
-
}
|
|
95
|
-
function resolveExpireTimestamp(value) {
|
|
96
|
-
if (typeof value !== 'string' || !value.trim()) return Number.POSITIVE_INFINITY;
|
|
97
|
-
const normalizedValue = value.trim();
|
|
98
|
-
const calendarParts = normalizedValue.match(/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?)?/);
|
|
99
|
-
if (calendarParts) {
|
|
100
|
-
const [, year, month, day, hour = '0', minute = '0', second = '0'] = calendarParts;
|
|
101
|
-
const yearNumber = Number(year);
|
|
102
|
-
const monthNumber = Number(month);
|
|
103
|
-
const dayNumber = Number(day);
|
|
104
|
-
const hourNumber = Number(hour);
|
|
105
|
-
const minuteNumber = Number(minute);
|
|
106
|
-
const secondNumber = Number(second);
|
|
107
|
-
const daysInMonth = new Date(Date.UTC(yearNumber, monthNumber, 0)).getUTCDate();
|
|
108
|
-
if (yearNumber <= 0 || monthNumber < 1 || monthNumber > 12 || dayNumber < 1 || dayNumber > daysInMonth || hourNumber < 0 || hourNumber > 23 || minuteNumber < 0 || minuteNumber > 59 || secondNumber < 0 || secondNumber > 59) {
|
|
109
|
-
return Number.POSITIVE_INFINITY;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
const date = (0, _dayjs.default)(normalizedValue);
|
|
113
|
-
return date.isValid() ? date.valueOf() : Number.POSITIVE_INFINITY;
|
|
114
|
-
}
|
|
115
|
-
function compareIds(left, right) {
|
|
116
|
-
const leftNumber = Number(left);
|
|
117
|
-
const rightNumber = Number(right);
|
|
118
|
-
if (Number.isFinite(leftNumber) && Number.isFinite(rightNumber)) {
|
|
119
|
-
return leftNumber - rightNumber;
|
|
120
|
-
}
|
|
121
|
-
return String(left ?? '').localeCompare(String(right ?? ''), undefined, {
|
|
122
|
-
numeric: true
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/** Sort Entitlement Passes by expiry, finite balance, then card instance id. */
|
|
127
|
-
function compareEntitlementPassPriority(left, right) {
|
|
128
|
-
const expireDifference = resolveExpireTimestamp(left.expire_time) - resolveExpireTimestamp(right.expire_time);
|
|
129
|
-
if (!Number.isNaN(expireDifference) && expireDifference !== 0) {
|
|
130
|
-
return expireDifference;
|
|
131
|
-
}
|
|
132
|
-
const leftQuota = resolveEntitlementQuota(left);
|
|
133
|
-
const rightQuota = resolveEntitlementQuota(right);
|
|
134
|
-
const leftBalance = leftQuota?.type === 'limited' ? leftQuota.balance : Number.POSITIVE_INFINITY;
|
|
135
|
-
const rightBalance = rightQuota?.type === 'limited' ? rightQuota.balance : Number.POSITIVE_INFINITY;
|
|
136
|
-
const balanceDifference = leftBalance - rightBalance;
|
|
137
|
-
if (!Number.isNaN(balanceDifference) && balanceDifference !== 0) {
|
|
138
|
-
return balanceDifference;
|
|
139
|
-
}
|
|
140
|
-
return compareIds(left.id, right.id);
|
|
141
|
-
}
|