@pisell/pisellos 2.1.174 → 2.1.176
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 +0 -9
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +0 -2
- package/dist/model/strategy/adapter/walletPass/evaluator.js +2 -4
- package/dist/modules/Discount/index.d.ts +3 -6
- package/dist/modules/Discount/index.js +23 -125
- package/dist/modules/Discount/types.d.ts +5 -34
- package/dist/modules/OpenData/types.d.ts +1 -0
- package/dist/modules/ProductList/index.js +13 -6
- package/dist/modules/Rules/index.d.ts +2 -12
- package/dist/modules/Rules/index.js +113 -377
- package/dist/modules/Rules/types.d.ts +2 -2
- package/dist/plugins/window.d.ts +0 -2
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/ScanOrder/index.d.ts +7 -5
- package/dist/solution/ScanOrder/index.js +123 -31
- package/dist/solution/ScanOrder/resourceSchedule.d.ts +12 -0
- package/dist/solution/ScanOrder/resourceSchedule.js +300 -0
- package/dist/solution/ScanOrder/types.d.ts +9 -1
- package/dist/solution/ShopDiscount/index.d.ts +0 -3
- package/dist/solution/ShopDiscount/index.js +78 -161
- package/dist/solution/ShopDiscount/utils.d.ts +0 -1
- package/dist/solution/ShopDiscount/utils.js +1 -40
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +0 -2
- package/lib/model/strategy/adapter/walletPass/evaluator.js +2 -4
- package/lib/modules/Discount/index.d.ts +3 -6
- package/lib/modules/Discount/index.js +16 -66
- package/lib/modules/Discount/types.d.ts +5 -34
- package/lib/modules/OpenData/types.d.ts +1 -0
- package/lib/modules/ProductList/index.js +8 -1
- package/lib/modules/Rules/index.d.ts +2 -12
- package/lib/modules/Rules/index.js +69 -303
- package/lib/modules/Rules/types.d.ts +2 -2
- package/lib/plugins/window.d.ts +0 -2
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/ScanOrder/index.d.ts +7 -5
- package/lib/solution/ScanOrder/index.js +90 -12
- package/lib/solution/ScanOrder/resourceSchedule.d.ts +12 -0
- package/lib/solution/ScanOrder/resourceSchedule.js +272 -0
- package/lib/solution/ScanOrder/types.d.ts +9 -1
- package/lib/solution/ShopDiscount/index.d.ts +0 -3
- package/lib/solution/ShopDiscount/index.js +28 -78
- package/lib/solution/ShopDiscount/utils.d.ts +0 -1
- package/lib/solution/ShopDiscount/utils.js +1 -42
- package/package.json +1 -1
- package/dist/modules/Discount/availability.d.ts +0 -7
- package/dist/modules/Discount/availability.js +0 -52
- package/dist/modules/Discount/entitlementPass.d.ts +0 -34
- package/dist/modules/Discount/entitlementPass.js +0 -147
- package/dist/modules/Discount/entitlementState.d.ts +0 -8
- package/dist/modules/Discount/entitlementState.js +0 -205
- package/dist/modules/Rules/entitlementLines.d.ts +0 -8
- package/dist/modules/Rules/entitlementLines.js +0 -157
- package/lib/modules/Discount/availability.d.ts +0 -7
- package/lib/modules/Discount/availability.js +0 -91
- package/lib/modules/Discount/entitlementPass.d.ts +0 -34
- package/lib/modules/Discount/entitlementPass.js +0 -184
- package/lib/modules/Discount/entitlementState.d.ts +0 -8
- package/lib/modules/Discount/entitlementState.js +0 -206
- package/lib/modules/Rules/entitlementLines.d.ts +0 -8
- package/lib/modules/Rules/entitlementLines.js +0 -158
|
@@ -1,205 +0,0 @@
|
|
|
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,8 +0,0 @@
|
|
|
1
|
-
import type { RulesParamsHooks } from './types';
|
|
2
|
-
export declare function isEntitlementRuntimeLine(product: any, mappedProduct?: any): boolean;
|
|
3
|
-
/** 仅同步本次多次卡行的数量与价格,沿用 Rules 的主商品、套餐计算结果。 */
|
|
4
|
-
export declare function rebuildEntitlementLine(origin: any, bundle: any[], hooks: RulesParamsHooks, count?: number): any;
|
|
5
|
-
/** 重算只还原本次多次卡;套餐和多 Holder 按父商品份数计算,不再合并商品行。 */
|
|
6
|
-
export declare function prepareEntitlementLines(products: any[], hooks: RulesParamsHooks, canUseEntitlement: (product: any) => boolean): any[];
|
|
7
|
-
/** 客户端钩子可能保留原 _id,只给新增的重复行补标识,保留拆分结果。 */
|
|
8
|
-
export declare function finalizeEntitlementLines(products: any[], hooks: RulesParamsHooks): any[];
|
|
@@ -1,157 +0,0 @@
|
|
|
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 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; }
|
|
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; }
|
|
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; }
|
|
5
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
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
|
-
import { cloneDeep } from 'lodash-es';
|
|
8
|
-
import Decimal from 'decimal.js';
|
|
9
|
-
import { isEntitlementPass } from "../Discount/entitlementPass";
|
|
10
|
-
import { hasEntitlementDiscount, isPersistedEntitlementLine } from "../Discount/entitlementState";
|
|
11
|
-
var SOURCE = 'entitlement_source_identity';
|
|
12
|
-
function isManualDiscount(data) {
|
|
13
|
-
var _data$isManualDiscoun, _data$discount_list;
|
|
14
|
-
return (_data$isManualDiscoun = data.isManualDiscount) !== null && _data$isManualDiscoun !== void 0 ? _data$isManualDiscoun : data.total != data.origin_total && (data.bundle || []).every(function (item) {
|
|
15
|
-
var _item$discount_list;
|
|
16
|
-
return !((_item$discount_list = item.discount_list) !== null && _item$discount_list !== void 0 && _item$discount_list.length);
|
|
17
|
-
}) && (!((_data$discount_list = data.discount_list) !== null && _data$discount_list !== void 0 && _data$discount_list.length) || data.discount_list.every(function (item) {
|
|
18
|
-
return item.type === 'product';
|
|
19
|
-
}));
|
|
20
|
-
}
|
|
21
|
-
export function isEntitlementRuntimeLine(product, mappedProduct) {
|
|
22
|
-
var _product$metadata;
|
|
23
|
-
return ((_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata[SOURCE]) != null && !isPersistedEntitlementLine(product, mappedProduct) && !isManualDiscount(mappedProduct !== null && mappedProduct !== void 0 ? mappedProduct : product);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/** 仅同步本次多次卡行的数量与价格,沿用 Rules 的主商品、套餐计算结果。 */
|
|
27
|
-
export function rebuildEntitlementLine(origin, bundle, hooks, count) {
|
|
28
|
-
var _ref, _ref2, _ref3, _data$original_price;
|
|
29
|
-
var data = hooks.getProduct(origin);
|
|
30
|
-
var quantity = (_ref = (_ref2 = count !== null && count !== void 0 ? count : data.quantity) !== null && _ref2 !== void 0 ? _ref2 : data.num) !== null && _ref !== void 0 ? _ref : 1;
|
|
31
|
-
var discounts = (data.discount_list || []).map(function (item) {
|
|
32
|
-
var _item$metadata;
|
|
33
|
-
return isEntitlementPass(item) && !((_item$metadata = item.metadata) !== null && _item$metadata !== void 0 && _item$metadata.custom_product_bundle_map_id) ? _objectSpread(_objectSpread({}, item), {}, {
|
|
34
|
-
_num: quantity,
|
|
35
|
-
metadata: _objectSpread(_objectSpread({}, item.metadata), {}, {
|
|
36
|
-
num: quantity
|
|
37
|
-
})
|
|
38
|
-
}) : item;
|
|
39
|
-
});
|
|
40
|
-
var mainDiscount = discounts.filter(function (item) {
|
|
41
|
-
var _item$metadata2;
|
|
42
|
-
return !((_item$metadata2 = item.metadata) !== null && _item$metadata2 !== void 0 && _item$metadata2.custom_product_bundle_map_id);
|
|
43
|
-
}).reduce(function (sum, item) {
|
|
44
|
-
return sum.plus(item.amount || 0);
|
|
45
|
-
}, new Decimal(0));
|
|
46
|
-
var originalPrice = new Decimal((_ref3 = (_data$original_price = data.original_price) !== null && _data$original_price !== void 0 ? _data$original_price : data.price) !== null && _ref3 !== void 0 ? _ref3 : 0);
|
|
47
|
-
var sourceSellingPrice = originalPrice.minus(mainDiscount).toNumber();
|
|
48
|
-
var optionPrice = (data.options || []).reduce(function (sum, item) {
|
|
49
|
-
return sum.plus(new Decimal(item.price || 0).times(item.num || 0));
|
|
50
|
-
}, new Decimal(0));
|
|
51
|
-
var bundleTotal = bundle.reduce(function (sum, item) {
|
|
52
|
-
return sum.plus(new Decimal(item.price || 0).times(item.num || 1));
|
|
53
|
-
}, new Decimal(0));
|
|
54
|
-
var bundleOriginalTotal = bundle.reduce(function (sum, item) {
|
|
55
|
-
var _ref4, _item$original_price;
|
|
56
|
-
return sum.plus(new Decimal((_ref4 = (_item$original_price = item.original_price) !== null && _item$original_price !== void 0 ? _item$original_price : item.price) !== null && _ref4 !== void 0 ? _ref4 : 0).times(item.num || 1));
|
|
57
|
-
}, new Decimal(0));
|
|
58
|
-
return hooks.setProduct(origin, {
|
|
59
|
-
quantity: quantity,
|
|
60
|
-
discount_list: discounts,
|
|
61
|
-
bundle: bundle,
|
|
62
|
-
price: sourceSellingPrice,
|
|
63
|
-
main_product_selling_price: sourceSellingPrice,
|
|
64
|
-
total: new Decimal(sourceSellingPrice).plus(optionPrice).plus(bundleTotal).toNumber(),
|
|
65
|
-
origin_total: originalPrice.plus(optionPrice).plus(bundleOriginalTotal).toNumber()
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
function setLineIdentity(row, id) {
|
|
69
|
-
row._id = id;
|
|
70
|
-
row.metadata = _objectSpread(_objectSpread({}, row.metadata), {}, {
|
|
71
|
-
unique_identification_number: id
|
|
72
|
-
});
|
|
73
|
-
if (row._extend) row._extend.unique_identification_number = id;
|
|
74
|
-
return row;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/** 重算只还原本次多次卡;套餐和多 Holder 按父商品份数计算,不再合并商品行。 */
|
|
78
|
-
export function prepareEntitlementLines(products, hooks, canUseEntitlement) {
|
|
79
|
-
return products.flatMap(function (original) {
|
|
80
|
-
var _original$metadata, _origin$metadata$SOUR, _origin$metadata, _data$discount_list2, _ref8, _data$original_price2, _mainEntitlement$disc;
|
|
81
|
-
var data = hooks.getProduct(original);
|
|
82
|
-
if (isPersistedEntitlementLine(original, data) || isManualDiscount(data)) return [original];
|
|
83
|
-
var applicable = canUseEntitlement(original);
|
|
84
|
-
if (!((_original$metadata = original.metadata) !== null && _original$metadata !== void 0 && _original$metadata[SOURCE]) && !hasEntitlementDiscount(data) && !applicable) return [original];
|
|
85
|
-
var origin = cloneDeep(original);
|
|
86
|
-
origin.metadata = _objectSpread(_objectSpread({}, origin.metadata), {}, _defineProperty({}, SOURCE, (_origin$metadata$SOUR = (_origin$metadata = origin.metadata) === null || _origin$metadata === void 0 ? void 0 : _origin$metadata[SOURCE]) !== null && _origin$metadata$SOUR !== void 0 ? _origin$metadata$SOUR : data._id));
|
|
87
|
-
var bundle = (data.bundle || []).map(function (item) {
|
|
88
|
-
var _ref5, _ref6, _ref7, _item$original_price2, _entitlement$discount;
|
|
89
|
-
var entitlement = (item.discount_list || []).find(isEntitlementPass);
|
|
90
|
-
if (!entitlement) return item;
|
|
91
|
-
var discounts = (item.discount_list || []).filter(function (discount) {
|
|
92
|
-
return !isEntitlementPass(discount);
|
|
93
|
-
});
|
|
94
|
-
var originalPrice = (_ref5 = (_ref6 = (_ref7 = (_item$original_price2 = item.original_price) !== null && _item$original_price2 !== void 0 ? _item$original_price2 : (_entitlement$discount = entitlement.discount) === null || _entitlement$discount === void 0 ? void 0 : _entitlement$discount.original_amount) !== null && _ref7 !== void 0 ? _ref7 : item.product_price) !== null && _ref6 !== void 0 ? _ref6 : item.price) !== null && _ref5 !== void 0 ? _ref5 : 0;
|
|
95
|
-
var amount = discounts.reduce(function (sum, discount) {
|
|
96
|
-
return sum.plus(discount.amount || 0);
|
|
97
|
-
}, new Decimal(0));
|
|
98
|
-
var price = new Decimal(originalPrice).minus(amount.div(item.num || 1)).toNumber();
|
|
99
|
-
return _objectSpread(_objectSpread({}, item), {}, {
|
|
100
|
-
original_price: originalPrice,
|
|
101
|
-
price: price,
|
|
102
|
-
bundle_selling_price: price,
|
|
103
|
-
discount_list: discounts
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
var mainEntitlement = (_data$discount_list2 = data.discount_list) === null || _data$discount_list2 === void 0 ? void 0 : _data$discount_list2.find(isEntitlementPass);
|
|
107
|
-
var restored = hooks.setProduct(origin, {
|
|
108
|
-
original_price: (_ref8 = (_data$original_price2 = data.original_price) !== null && _data$original_price2 !== void 0 ? _data$original_price2 : mainEntitlement === null || mainEntitlement === void 0 || (_mainEntitlement$disc = mainEntitlement.discount) === null || _mainEntitlement$disc === void 0 ? void 0 : _mainEntitlement$disc.original_amount) !== null && _ref8 !== void 0 ? _ref8 : data.price,
|
|
109
|
-
discount_list: (data.discount_list || []).filter(function (item) {
|
|
110
|
-
return !isEntitlementPass(item);
|
|
111
|
-
}),
|
|
112
|
-
bundle: bundle
|
|
113
|
-
});
|
|
114
|
-
var row = rebuildEntitlementLine(restored, bundle, hooks);
|
|
115
|
-
var count = Math.max(1, Math.floor(Number(data.quantity || data.num || 1)));
|
|
116
|
-
if (!applicable || count <= 1 || !bundle.length && !Array.isArray(data.holder_id)) return [row];
|
|
117
|
-
return Array.from({
|
|
118
|
-
length: count
|
|
119
|
-
}, function (_, index) {
|
|
120
|
-
var _unit$_origin;
|
|
121
|
-
var unit = cloneDeep(row);
|
|
122
|
-
// booking 使用 _extend.holder_id,appointmentBooking 使用购物车 Holder。
|
|
123
|
-
for (var _i = 0, _arr = [unit, unit._extend]; _i < _arr.length; _i++) {
|
|
124
|
-
var source = _arr[_i];
|
|
125
|
-
if (Array.isArray(source === null || source === void 0 ? void 0 : source.holder_id)) source.holder_id = source.holder_id.slice(index, index + 1);
|
|
126
|
-
}
|
|
127
|
-
if (Array.isArray((_unit$_origin = unit._origin) === null || _unit$_origin === void 0 || (_unit$_origin = _unit$_origin.holder) === null || _unit$_origin === void 0 ? void 0 : _unit$_origin.form_record)) {
|
|
128
|
-
var records = unit._origin.holder.form_record;
|
|
129
|
-
// 单 Holder 的多份商品仍归属同一人;多个 Holder 才按份对应。
|
|
130
|
-
if (records.length > 1) unit._origin.holder.form_record = records.slice(index, index + 1);
|
|
131
|
-
}
|
|
132
|
-
return setLineIdentity(rebuildEntitlementLine(unit, hooks.getProduct(unit).bundle || [], hooks, 1), "".concat(data._id, ":entitlement-unit:").concat(index));
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/** 客户端钩子可能保留原 _id,只给新增的重复行补标识,保留拆分结果。 */
|
|
138
|
-
export function finalizeEntitlementLines(products, hooks) {
|
|
139
|
-
var runtime = function runtime(item) {
|
|
140
|
-
return isEntitlementRuntimeLine(item, hooks.getProduct(item));
|
|
141
|
-
};
|
|
142
|
-
var seen = new Set(products.filter(function (item) {
|
|
143
|
-
return !runtime(item);
|
|
144
|
-
}).map(function (item) {
|
|
145
|
-
return String(item._id);
|
|
146
|
-
}));
|
|
147
|
-
return products.map(function (origin, index) {
|
|
148
|
-
var _origin$_id;
|
|
149
|
-
if (!runtime(origin)) return origin;
|
|
150
|
-
var base = String((_origin$_id = origin._id) !== null && _origin$_id !== void 0 ? _origin$_id : hooks.getProduct(origin)._id);
|
|
151
|
-
var id = base;
|
|
152
|
-
var ordinal = index;
|
|
153
|
-
while (seen.has(id)) id = "".concat(base, ":entitlement-split:").concat(ordinal++);
|
|
154
|
-
seen.add(id);
|
|
155
|
-
return id === String(origin._id) ? origin : setLineIdentity(cloneDeep(origin), id);
|
|
156
|
-
});
|
|
157
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { Discount, DiscountFilterRejectKey } from './types';
|
|
2
|
-
/** 周期限制只影响当前使用;total_credits 才代表整张卡的次数耗尽。 */
|
|
3
|
-
export declare function getDiscountUsageLimitFailKey(discount: Discount): DiscountFilterRejectKey | null;
|
|
4
|
-
export declare function hasAvailableDiscountBalance(discount: Discount): boolean;
|
|
5
|
-
/** 按卡本身当前生命周期判断;预约时间或一次日程不匹配不代表已失效。 */
|
|
6
|
-
export declare function getDiscountLifecycleReason(discount: Discount): 'disabled' | 'exhausted' | 'expired' | 'not_shared_at_store' | undefined;
|
|
7
|
-
export declare function getDiscountUsageBlockReason(discount: Discount): string | undefined;
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
|
|
29
|
-
// src/modules/Discount/availability.ts
|
|
30
|
-
var availability_exports = {};
|
|
31
|
-
__export(availability_exports, {
|
|
32
|
-
getDiscountLifecycleReason: () => getDiscountLifecycleReason,
|
|
33
|
-
getDiscountUsageBlockReason: () => getDiscountUsageBlockReason,
|
|
34
|
-
getDiscountUsageLimitFailKey: () => getDiscountUsageLimitFailKey,
|
|
35
|
-
hasAvailableDiscountBalance: () => hasAvailableDiscountBalance
|
|
36
|
-
});
|
|
37
|
-
module.exports = __toCommonJS(availability_exports);
|
|
38
|
-
var import_dayjs = __toESM(require("dayjs"));
|
|
39
|
-
var import_decimal = __toESM(require("decimal.js"));
|
|
40
|
-
var import_entitlementPass = require("./entitlementPass");
|
|
41
|
-
function getDiscountUsageLimitFailKey(discount) {
|
|
42
|
-
var _a, _b, _c;
|
|
43
|
-
const value = (_b = (_a = discount.extension_data) == null ? void 0 : _a.find(
|
|
44
|
-
(field) => field.field_key === "usage_credits"
|
|
45
|
-
)) == null ? void 0 : _b.value;
|
|
46
|
-
if (!value)
|
|
47
|
-
return null;
|
|
48
|
-
const limits = [
|
|
49
|
-
["total_credits", discount.total_order_behavior_count],
|
|
50
|
-
["per_user_limit", discount.customer_order_behavior_count],
|
|
51
|
-
["max_per_day", discount.today_order_behavior_count],
|
|
52
|
-
["max_per_week", discount.week_order_behavior_count],
|
|
53
|
-
["max_per_month", discount.month_order_behavior_count]
|
|
54
|
-
];
|
|
55
|
-
return ((_c = limits.find(
|
|
56
|
-
([key, count]) => Number(value[key]) > 0 && Number(count || 0) >= Number(value[key])
|
|
57
|
-
)) == null ? void 0 : _c[0]) || null;
|
|
58
|
-
}
|
|
59
|
-
function hasAvailableDiscountBalance(discount) {
|
|
60
|
-
if ((0, import_entitlementPass.isEntitlementPass)(discount))
|
|
61
|
-
return (0, import_entitlementPass.hasAvailableEntitlementUses)(discount);
|
|
62
|
-
return new import_decimal.default(discount.par_value || 0).minus(discount.used_par_value || 0).greaterThan(0);
|
|
63
|
-
}
|
|
64
|
-
function getDiscountLifecycleReason(discount) {
|
|
65
|
-
var _a, _b;
|
|
66
|
-
if (discount.is_franchisor_pass === 1 && ((_a = discount.franchisee_wallet_pass) == null ? void 0 : _a.use) !== "enabled") {
|
|
67
|
-
return "not_shared_at_store";
|
|
68
|
-
}
|
|
69
|
-
if (discount.limit_status && discount.limit_status !== "enable") {
|
|
70
|
-
return "disabled";
|
|
71
|
-
}
|
|
72
|
-
if (((0, import_entitlementPass.isEntitlementPass)(discount) || discount.par_value != null) && !hasAvailableDiscountBalance(discount) || getDiscountUsageLimitFailKey(discount) === "total_credits") {
|
|
73
|
-
return "exhausted";
|
|
74
|
-
}
|
|
75
|
-
if (((_b = discount.metadata) == null ? void 0 : _b.validity_type) !== "custom_schedule_validity" && discount.expire_time) {
|
|
76
|
-
const expiry = (0, import_dayjs.default)(discount.expire_time);
|
|
77
|
-
if (expiry.isValid() && !(0, import_dayjs.default)().isBefore(expiry))
|
|
78
|
-
return "expired";
|
|
79
|
-
}
|
|
80
|
-
return void 0;
|
|
81
|
-
}
|
|
82
|
-
function getDiscountUsageBlockReason(discount) {
|
|
83
|
-
return getDiscountLifecycleReason(discount) || getDiscountUsageLimitFailKey(discount) || (discount.unified_available_status != null && String(discount.unified_available_status) !== "" && Number(discount.unified_available_status) === 0 ? "server_unavailable" : void 0);
|
|
84
|
-
}
|
|
85
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
86
|
-
0 && (module.exports = {
|
|
87
|
-
getDiscountLifecycleReason,
|
|
88
|
-
getDiscountUsageBlockReason,
|
|
89
|
-
getDiscountUsageLimitFailKey,
|
|
90
|
-
hasAvailableDiscountBalance
|
|
91
|
-
});
|
|
@@ -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 {};
|