@pisell/pisellos 2.3.101 → 2.3.103
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/dataVariant/evaluator.d.ts +18 -2
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +287 -101
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +25 -0
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +10 -7
- package/dist/modules/Discount/index.d.ts +2 -0
- package/dist/modules/Discount/index.js +38 -5
- package/dist/modules/Discount/types.d.ts +11 -0
- package/dist/modules/Order/index.d.ts +29 -3
- package/dist/modules/Order/index.js +1105 -703
- package/dist/modules/Order/types.d.ts +14 -6
- package/dist/modules/Order/types.js +1 -1
- package/dist/modules/Order/utils/virtualSettlement.d.ts +63 -0
- package/dist/modules/Order/utils/virtualSettlement.js +284 -0
- package/dist/modules/Order/utils.d.ts +1 -0
- package/dist/modules/Order/utils.js +63 -24
- package/dist/modules/Product/types.d.ts +23 -0
- package/dist/modules/SalesSummary/index.d.ts +1 -0
- package/dist/modules/SalesSummary/index.js +4 -3
- package/dist/modules/SalesSummary/types.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.js +21 -1
- package/dist/solution/BaseSales/index.d.ts +10 -1
- package/dist/solution/BaseSales/index.js +1074 -746
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +72 -9
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingTicket/utils/addProductDecision.js +2 -1
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +137 -6
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +25 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +4 -0
- package/lib/modules/Discount/index.d.ts +2 -0
- package/lib/modules/Discount/index.js +31 -2
- package/lib/modules/Discount/types.d.ts +11 -0
- package/lib/modules/Order/index.d.ts +29 -3
- package/lib/modules/Order/index.js +326 -51
- package/lib/modules/Order/types.d.ts +14 -6
- package/lib/modules/Order/types.js +1 -1
- package/lib/modules/Order/utils/virtualSettlement.d.ts +63 -0
- package/lib/modules/Order/utils/virtualSettlement.js +262 -0
- package/lib/modules/Order/utils.d.ts +1 -0
- package/lib/modules/Order/utils.js +57 -20
- package/lib/modules/Product/types.d.ts +23 -0
- package/lib/modules/SalesSummary/index.d.ts +1 -0
- package/lib/modules/SalesSummary/index.js +4 -2
- package/lib/modules/SalesSummary/types.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.js +17 -1
- package/lib/solution/BaseSales/index.d.ts +10 -1
- package/lib/solution/BaseSales/index.js +228 -20
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +38 -0
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingTicket/utils/addProductDecision.js +1 -0
- package/package.json +1 -1
|
@@ -1,4 +1,3 @@
|
|
|
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
1
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
3
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."); }
|
|
4
3
|
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; } }
|
|
@@ -7,6 +6,7 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableTo
|
|
|
7
6
|
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."); }
|
|
8
7
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
9
8
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
9
|
+
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); }
|
|
10
10
|
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; }
|
|
11
11
|
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; }
|
|
12
12
|
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; } } }; }
|
|
@@ -24,7 +24,7 @@ import { DataVariantAdapter } from "./adapter";
|
|
|
24
24
|
/**
|
|
25
25
|
* Data Variant 评估器。
|
|
26
26
|
*
|
|
27
|
-
*
|
|
27
|
+
* OS Server 商品路由开启时由 ProductsModule 调用;路由关闭时由 ProductList 在远端响应后调用。
|
|
28
28
|
*/
|
|
29
29
|
export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
30
30
|
function DataVariantEvaluator() {
|
|
@@ -51,7 +51,7 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
51
51
|
/**
|
|
52
52
|
* 批量解析商品 Data Variant。
|
|
53
53
|
*
|
|
54
|
-
*
|
|
54
|
+
* 优先使用商品 metadata.data_variant_ids;缺少权威命中结果时才执行本地策略判断。
|
|
55
55
|
*/
|
|
56
56
|
}, {
|
|
57
57
|
key: "resolveProducts",
|
|
@@ -60,9 +60,17 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
60
60
|
var strategyConfigs = businessData.strategyConfigs ? this.normalizeStrategyConfigs(businessData.strategyConfigs) : this.strategyConfigs;
|
|
61
61
|
var menuScopeMap = this.buildMenuScopeMap(businessData.menuList || []);
|
|
62
62
|
var scheduleTimePoints = this.buildScheduleTimePoints(strategyConfigs, businessData.scheduleList || []);
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
// metadata.data_variant_ids 存在时,接口已经完成规则计算;只有仍有商品缺少
|
|
64
|
+
// 该权威结果时才初始化本地策略引擎,避免 OS/接口与客户端重复评估。
|
|
65
|
+
var shouldEvaluateStrategies = businessData.products.some(function (product) {
|
|
66
|
+
return _this.requiresLocalStrategyEvaluation(product);
|
|
67
|
+
});
|
|
68
|
+
var _ref = shouldEvaluateStrategies ? this.buildGlobalEffectiveRuleMap(strategyConfigs, businessData, menuScopeMap) : {
|
|
69
|
+
globalEffectiveRuleMap: new Map(),
|
|
70
|
+
rawResults: []
|
|
71
|
+
},
|
|
72
|
+
globalEffectiveRuleMap = _ref.globalEffectiveRuleMap,
|
|
73
|
+
rawResults = _ref.rawResults;
|
|
66
74
|
var products = businessData.products.map(function (product) {
|
|
67
75
|
var resolvedProduct = _this.resolveProduct(product, businessData, globalEffectiveRuleMap, menuScopeMap);
|
|
68
76
|
// 套餐子商品也可能携带 data_variants,需在同一策略上下文内继续评估并写回 bundle_item。
|
|
@@ -180,6 +188,69 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
180
188
|
});
|
|
181
189
|
return this.extractTimePointsFromSchedules(matchedSchedules);
|
|
182
190
|
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* 判断商品(含套餐子商品)是否仍需要本地执行策略条件。
|
|
194
|
+
* metadata.data_variant_ids 只要是数组,即使为空,也表示接口已经给出权威命中结果。
|
|
195
|
+
*/
|
|
196
|
+
}, {
|
|
197
|
+
key: "requiresLocalStrategyEvaluation",
|
|
198
|
+
value: function requiresLocalStrategyEvaluation(product) {
|
|
199
|
+
var _this2 = this;
|
|
200
|
+
var dataVariants = this.getProductDataVariants(product);
|
|
201
|
+
var hasConditionalVariant = dataVariants.some(function (variant) {
|
|
202
|
+
return Number(variant.data_variant_rule_id) !== 0;
|
|
203
|
+
});
|
|
204
|
+
if (hasConditionalVariant && this.getAuthoritativeVariantPriorities(product) === null) {
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
var bundleGroups = Array.isArray(product.bundle_group) ? product.bundle_group : [];
|
|
208
|
+
return bundleGroups.some(function (group) {
|
|
209
|
+
var bundleItems = Array.isArray(group === null || group === void 0 ? void 0 : group.bundle_item) ? group.bundle_item : [];
|
|
210
|
+
return bundleItems.some(function (item) {
|
|
211
|
+
return _this2.requiresLocalStrategyEvaluation(_this2.toBundleItemDataVariantProduct(item));
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* 将接口返回的高 -> 低优先级 Variant ID 转成数值优先级。
|
|
218
|
+
* 返回 null 表示接口没有提供该字段;空 Map 表示已计算但没有任何命中。
|
|
219
|
+
*/
|
|
220
|
+
}, {
|
|
221
|
+
key: "getAuthoritativeVariantPriorities",
|
|
222
|
+
value: function getAuthoritativeVariantPriorities(product) {
|
|
223
|
+
var _product$metadata;
|
|
224
|
+
var rawIds = product === null || product === void 0 || (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.data_variant_ids;
|
|
225
|
+
if (!Array.isArray(rawIds)) return null;
|
|
226
|
+
var orderedIds = [];
|
|
227
|
+
var seen = new Set();
|
|
228
|
+
var _iterator4 = _createForOfIteratorHelper(rawIds),
|
|
229
|
+
_step4;
|
|
230
|
+
try {
|
|
231
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
232
|
+
var rawId = _step4.value;
|
|
233
|
+
var id = this.normalizeDataVariantId(rawId);
|
|
234
|
+
if (id === null || seen.has(id)) continue;
|
|
235
|
+
seen.add(id);
|
|
236
|
+
orderedIds.push(id);
|
|
237
|
+
}
|
|
238
|
+
} catch (err) {
|
|
239
|
+
_iterator4.e(err);
|
|
240
|
+
} finally {
|
|
241
|
+
_iterator4.f();
|
|
242
|
+
}
|
|
243
|
+
return new Map(orderedIds.map(function (id, index) {
|
|
244
|
+
return [id, orderedIds.length - index];
|
|
245
|
+
}));
|
|
246
|
+
}
|
|
247
|
+
}, {
|
|
248
|
+
key: "normalizeDataVariantId",
|
|
249
|
+
value: function normalizeDataVariantId(value) {
|
|
250
|
+
if (value === undefined || value === null) return null;
|
|
251
|
+
var normalized = String(value).trim();
|
|
252
|
+
return normalized || null;
|
|
253
|
+
}
|
|
183
254
|
}, {
|
|
184
255
|
key: "buildGlobalEffectiveRuleMap",
|
|
185
256
|
value: function buildGlobalEffectiveRuleMap(strategyConfigs, businessData, menuScopeMap) {
|
|
@@ -187,11 +258,11 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
187
258
|
var rawResults = [];
|
|
188
259
|
var engine = this.createEngine(businessData, menuScopeMap);
|
|
189
260
|
var context = this.adapter.prepareGlobalContext(businessData);
|
|
190
|
-
var
|
|
191
|
-
|
|
261
|
+
var _iterator5 = _createForOfIteratorHelper(strategyConfigs),
|
|
262
|
+
_step5;
|
|
192
263
|
try {
|
|
193
|
-
for (
|
|
194
|
-
var config =
|
|
264
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
265
|
+
var config = _step5.value;
|
|
195
266
|
if (!this.isStrategyActive(config)) continue;
|
|
196
267
|
var _this$splitStrategyCo = this.splitStrategyConfig(config),
|
|
197
268
|
globalConfig = _this$splitStrategyCo.globalConfig,
|
|
@@ -208,9 +279,9 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
208
279
|
});
|
|
209
280
|
}
|
|
210
281
|
} catch (err) {
|
|
211
|
-
|
|
282
|
+
_iterator5.e(err);
|
|
212
283
|
} finally {
|
|
213
|
-
|
|
284
|
+
_iterator5.f();
|
|
214
285
|
}
|
|
215
286
|
return {
|
|
216
287
|
globalEffectiveRuleMap: globalEffectiveRuleMap,
|
|
@@ -223,11 +294,28 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
223
294
|
var dataVariants = this.getProductDataVariants(product);
|
|
224
295
|
if (!dataVariants.length) return product;
|
|
225
296
|
var matchedVariants = [];
|
|
226
|
-
var
|
|
227
|
-
|
|
297
|
+
var authoritativeVariantPriorities = this.getAuthoritativeVariantPriorities(product);
|
|
298
|
+
var settlementVariants = dataVariants.filter(function (variant) {
|
|
299
|
+
return variant.business_type === 'multi_currency_settlement' && variant.status === 'enable';
|
|
300
|
+
});
|
|
301
|
+
var _iterator6 = _createForOfIteratorHelper(dataVariants),
|
|
302
|
+
_step6;
|
|
228
303
|
try {
|
|
229
|
-
for (
|
|
230
|
-
var variant =
|
|
304
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
305
|
+
var variant = _step6.value;
|
|
306
|
+
if (variant.business_type === 'multi_currency_settlement') continue;
|
|
307
|
+
if (authoritativeVariantPriorities !== null) {
|
|
308
|
+
var variantId = this.normalizeDataVariantId(variant.id);
|
|
309
|
+
var priority = variantId === null ? undefined : authoritativeVariantPriorities.get(variantId);
|
|
310
|
+
if (priority === undefined) continue;
|
|
311
|
+
matchedVariants.push({
|
|
312
|
+
ruleId: String(variant.data_variant_rule_id),
|
|
313
|
+
priority: priority,
|
|
314
|
+
data: variant.data || {},
|
|
315
|
+
variant: variant
|
|
316
|
+
});
|
|
317
|
+
continue;
|
|
318
|
+
}
|
|
231
319
|
var rule = globalEffectiveRuleMap.get(String(variant.data_variant_rule_id));
|
|
232
320
|
if (!rule) continue;
|
|
233
321
|
if (!this.evaluateProductRules(rule, product, businessData, menuScopeMap)) {
|
|
@@ -241,12 +329,103 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
241
329
|
});
|
|
242
330
|
}
|
|
243
331
|
} catch (err) {
|
|
244
|
-
|
|
332
|
+
_iterator6.e(err);
|
|
245
333
|
} finally {
|
|
246
|
-
|
|
334
|
+
_iterator6.f();
|
|
247
335
|
}
|
|
248
|
-
|
|
249
|
-
|
|
336
|
+
var resolvedProduct = matchedVariants.length ? this.mergeMatchedVariants(product, matchedVariants) : product;
|
|
337
|
+
var availableSettlementOptions = this.resolveSettlementOptions(settlementVariants, product, businessData, globalEffectiveRuleMap, menuScopeMap, authoritativeVariantPriorities);
|
|
338
|
+
if (!settlementVariants.length) return resolvedProduct;
|
|
339
|
+
return _objectSpread(_objectSpread({}, resolvedProduct), {}, {
|
|
340
|
+
available_settlement_options: availableSettlementOptions
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* 多货币 Data Variant 只生成候选列表,不参与商品字段覆盖。
|
|
346
|
+
* rule_id=0 是无条件默认价;同币种命中的条件价优先于默认价。
|
|
347
|
+
*/
|
|
348
|
+
}, {
|
|
349
|
+
key: "resolveSettlementOptions",
|
|
350
|
+
value: function resolveSettlementOptions(variants, product, businessData, globalEffectiveRuleMap, menuScopeMap, authoritativeVariantPriorities) {
|
|
351
|
+
var _this3 = this;
|
|
352
|
+
if (!variants.length) return [];
|
|
353
|
+
var candidates = variants.flatMap(function (variant) {
|
|
354
|
+
var _variant$data, _variant$id, _variant$data$price, _variant$data2;
|
|
355
|
+
var settlement = (_variant$data = variant.data) === null || _variant$data === void 0 ? void 0 : _variant$data.multi_currency_settlement;
|
|
356
|
+
if (!settlement || _typeof(settlement) !== 'object') return [];
|
|
357
|
+
var ruleId = String(variant.data_variant_rule_id);
|
|
358
|
+
var isDefault = Number(variant.data_variant_rule_id) === 0;
|
|
359
|
+
var rule = isDefault ? undefined : globalEffectiveRuleMap.get(ruleId);
|
|
360
|
+
var variantId = _this3.normalizeDataVariantId(variant.id);
|
|
361
|
+
var authoritativePriority = variantId === null ? undefined : authoritativeVariantPriorities === null || authoritativeVariantPriorities === void 0 ? void 0 : authoritativeVariantPriorities.get(variantId);
|
|
362
|
+
var available;
|
|
363
|
+
var priority;
|
|
364
|
+
if (isDefault) {
|
|
365
|
+
// rule 0 是无条件默认候选,不依赖接口命中 ID 或本地策略引擎。
|
|
366
|
+
available = true;
|
|
367
|
+
priority = Number.NEGATIVE_INFINITY;
|
|
368
|
+
} else if (authoritativeVariantPriorities !== null) {
|
|
369
|
+
var _ref2;
|
|
370
|
+
// 数组存在(包括 [])即表示接口已经算过规则,不再在客户端二次判断。
|
|
371
|
+
available = authoritativePriority !== undefined;
|
|
372
|
+
priority = (_ref2 = authoritativePriority !== null && authoritativePriority !== void 0 ? authoritativePriority : rule === null || rule === void 0 ? void 0 : rule.priority) !== null && _ref2 !== void 0 ? _ref2 : Number.NEGATIVE_INFINITY;
|
|
373
|
+
} else {
|
|
374
|
+
var _rule$priority;
|
|
375
|
+
available = Boolean(rule && _this3.evaluateProductRules(rule, product, businessData, menuScopeMap));
|
|
376
|
+
priority = (_rule$priority = rule === null || rule === void 0 ? void 0 : rule.priority) !== null && _rule$priority !== void 0 ? _rule$priority : Number.NEGATIVE_INFINITY;
|
|
377
|
+
}
|
|
378
|
+
var settlementType = String(settlement.settlement_type || '');
|
|
379
|
+
var currencyProductId = _this3.toNumber(settlement.currency_product_id);
|
|
380
|
+
var settlementKey = settlementType === 'virtual_currency' ? "virtual_currency:".concat(currencyProductId || '') : settlementType || "variant:".concat((_variant$id = variant.id) !== null && _variant$id !== void 0 ? _variant$id : ruleId);
|
|
381
|
+
return [{
|
|
382
|
+
key: settlementKey,
|
|
383
|
+
priority: priority,
|
|
384
|
+
isDefault: isDefault,
|
|
385
|
+
option: _objectSpread(_objectSpread(_objectSpread({}, settlement), {}, {
|
|
386
|
+
settlement_type: settlementType
|
|
387
|
+
}, currencyProductId ? {
|
|
388
|
+
currency_product_id: currencyProductId
|
|
389
|
+
} : {}), {}, {
|
|
390
|
+
price: String((_variant$data$price = (_variant$data2 = variant.data) === null || _variant$data2 === void 0 ? void 0 : _variant$data2.price) !== null && _variant$data$price !== void 0 ? _variant$data$price : '0'),
|
|
391
|
+
data_variant_id: variant.id,
|
|
392
|
+
data_variant_rule_id: variant.data_variant_rule_id,
|
|
393
|
+
available: available,
|
|
394
|
+
disabled_reason: available ? '' : String(settlement.disabled_reason || 'Not available for this purchase.')
|
|
395
|
+
})
|
|
396
|
+
}];
|
|
397
|
+
});
|
|
398
|
+
var grouped = new Map();
|
|
399
|
+
var _iterator7 = _createForOfIteratorHelper(candidates),
|
|
400
|
+
_step7;
|
|
401
|
+
try {
|
|
402
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
403
|
+
var candidate = _step7.value;
|
|
404
|
+
var group = grouped.get(candidate.key) || [];
|
|
405
|
+
group.push(candidate);
|
|
406
|
+
grouped.set(candidate.key, group);
|
|
407
|
+
}
|
|
408
|
+
} catch (err) {
|
|
409
|
+
_iterator7.e(err);
|
|
410
|
+
} finally {
|
|
411
|
+
_iterator7.f();
|
|
412
|
+
}
|
|
413
|
+
return Array.from(grouped.values()).map(function (group) {
|
|
414
|
+
var matchedConditional = group.filter(function (candidate) {
|
|
415
|
+
return !candidate.isDefault && candidate.option.available;
|
|
416
|
+
}).sort(function (a, b) {
|
|
417
|
+
return b.priority - a.priority;
|
|
418
|
+
})[0];
|
|
419
|
+
var defaultCandidate = group.find(function (candidate) {
|
|
420
|
+
return candidate.isDefault;
|
|
421
|
+
});
|
|
422
|
+
var unavailableCandidate = _toConsumableArray(group).filter(function (candidate) {
|
|
423
|
+
return !candidate.option.available;
|
|
424
|
+
}).sort(function (a, b) {
|
|
425
|
+
return b.priority - a.priority;
|
|
426
|
+
})[0];
|
|
427
|
+
return (matchedConditional || defaultCandidate || unavailableCandidate).option;
|
|
428
|
+
});
|
|
250
429
|
}
|
|
251
430
|
|
|
252
431
|
/**
|
|
@@ -257,7 +436,7 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
257
436
|
}, {
|
|
258
437
|
key: "resolveProductBundleItems",
|
|
259
438
|
value: function resolveProductBundleItems(product, businessData, globalEffectiveRuleMap, menuScopeMap) {
|
|
260
|
-
var
|
|
439
|
+
var _this4 = this;
|
|
261
440
|
var bundleGroups = product.bundle_group;
|
|
262
441
|
if (!Array.isArray(bundleGroups) || bundleGroups.length === 0) {
|
|
263
442
|
return product;
|
|
@@ -269,7 +448,7 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
269
448
|
}
|
|
270
449
|
return _objectSpread(_objectSpread({}, group), {}, {
|
|
271
450
|
bundle_item: bundleItems.map(function (item) {
|
|
272
|
-
return
|
|
451
|
+
return _this4.resolveBundleItem(item, businessData, globalEffectiveRuleMap, menuScopeMap);
|
|
273
452
|
})
|
|
274
453
|
});
|
|
275
454
|
});
|
|
@@ -298,16 +477,17 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
298
477
|
}, {
|
|
299
478
|
key: "toBundleItemDataVariantProduct",
|
|
300
479
|
value: function toBundleItemDataVariantProduct(item) {
|
|
301
|
-
var _item$bundle_product_,
|
|
480
|
+
var _item$bundle_product_, _ref3, _ref4, _item$bundle_variant_;
|
|
302
481
|
var productId = (_item$bundle_product_ = item.bundle_product_id) !== null && _item$bundle_product_ !== void 0 ? _item$bundle_product_ : item.product_id;
|
|
303
|
-
var variantId = (
|
|
482
|
+
var variantId = (_ref3 = (_ref4 = (_item$bundle_variant_ = item.bundle_variant_id) !== null && _item$bundle_variant_ !== void 0 ? _item$bundle_variant_ : item.variant_id) !== null && _ref4 !== void 0 ? _ref4 : item.product_variant_id) !== null && _ref3 !== void 0 ? _ref3 : 0;
|
|
304
483
|
return {
|
|
305
484
|
id: productId,
|
|
306
485
|
product_id: productId,
|
|
307
486
|
product_variant_id: variantId,
|
|
308
487
|
variant_id: variantId,
|
|
309
488
|
collection: item.collection,
|
|
310
|
-
data_variants: item.data_variants
|
|
489
|
+
data_variants: item.data_variants,
|
|
490
|
+
metadata: item.metadata
|
|
311
491
|
};
|
|
312
492
|
}
|
|
313
493
|
|
|
@@ -332,19 +512,19 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
332
512
|
return originalItem;
|
|
333
513
|
}
|
|
334
514
|
var result = _objectSpread({}, originalItem);
|
|
335
|
-
var
|
|
336
|
-
|
|
515
|
+
var _iterator8 = _createForOfIteratorHelper(appliedFields),
|
|
516
|
+
_step8;
|
|
337
517
|
try {
|
|
338
|
-
for (
|
|
339
|
-
var field =
|
|
518
|
+
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
519
|
+
var field = _step8.value;
|
|
340
520
|
if (resolvedItem[field] !== undefined) {
|
|
341
521
|
result[field] = resolvedItem[field];
|
|
342
522
|
}
|
|
343
523
|
}
|
|
344
524
|
} catch (err) {
|
|
345
|
-
|
|
525
|
+
_iterator8.e(err);
|
|
346
526
|
} finally {
|
|
347
|
-
|
|
527
|
+
_iterator8.f();
|
|
348
528
|
}
|
|
349
529
|
result._dataVariant = _objectSpread(_objectSpread({}, appliedInfo), {}, {
|
|
350
530
|
appliedFields: appliedFields
|
|
@@ -386,11 +566,11 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
386
566
|
productRules: this.flattenConditionRules(conditions)
|
|
387
567
|
};
|
|
388
568
|
}
|
|
389
|
-
var
|
|
390
|
-
|
|
569
|
+
var _iterator9 = _createForOfIteratorHelper(conditions.rules),
|
|
570
|
+
_step9;
|
|
391
571
|
try {
|
|
392
|
-
for (
|
|
393
|
-
var rule =
|
|
572
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
573
|
+
var rule = _step9.value;
|
|
394
574
|
if (this.isConditionGroup(rule)) {
|
|
395
575
|
productRules.push.apply(productRules, _toConsumableArray(this.flattenConditionRules(rule)));
|
|
396
576
|
continue;
|
|
@@ -402,9 +582,9 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
402
582
|
}
|
|
403
583
|
}
|
|
404
584
|
} catch (err) {
|
|
405
|
-
|
|
585
|
+
_iterator9.e(err);
|
|
406
586
|
} finally {
|
|
407
|
-
|
|
587
|
+
_iterator9.f();
|
|
408
588
|
}
|
|
409
589
|
return {
|
|
410
590
|
globalConfig: _objectSpread(_objectSpread({}, config), {}, {
|
|
@@ -420,16 +600,16 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
420
600
|
}, {
|
|
421
601
|
key: "createEngine",
|
|
422
602
|
value: function createEngine(businessData, menuScopeMap) {
|
|
423
|
-
var
|
|
603
|
+
var _this5 = this;
|
|
424
604
|
var operatorHandlers = {
|
|
425
605
|
schedule_match: function schedule_match(fieldValue, compareValue) {
|
|
426
|
-
return
|
|
606
|
+
return _this5.evaluateScheduleMatch(fieldValue, compareValue, businessData.scheduleList || []);
|
|
427
607
|
},
|
|
428
608
|
menu_match: function menu_match(fieldValue, compareValue) {
|
|
429
|
-
return
|
|
609
|
+
return _this5.evaluateMenuMatch(fieldValue, compareValue, menuScopeMap);
|
|
430
610
|
},
|
|
431
611
|
array_intersects: function array_intersects(fieldValue, compareValue) {
|
|
432
|
-
return
|
|
612
|
+
return _this5.evaluateArrayIntersects(fieldValue, compareValue);
|
|
433
613
|
}
|
|
434
614
|
};
|
|
435
615
|
return new StrategyEngine({
|
|
@@ -455,19 +635,19 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
455
635
|
value: function evaluateMenuMatch(fieldValue, compareValue, menuScopeMap) {
|
|
456
636
|
var menuIds = this.normalizeNumberArray(compareValue);
|
|
457
637
|
if (!menuIds.length) return true;
|
|
458
|
-
var
|
|
459
|
-
|
|
638
|
+
var _iterator10 = _createForOfIteratorHelper(menuIds),
|
|
639
|
+
_step10;
|
|
460
640
|
try {
|
|
461
|
-
for (
|
|
462
|
-
var menuId =
|
|
641
|
+
for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
|
|
642
|
+
var menuId = _step10.value;
|
|
463
643
|
var scope = menuScopeMap.get(menuId);
|
|
464
644
|
if (!scope) continue;
|
|
465
645
|
if (this.isProductInMenuScope(fieldValue, scope)) return true;
|
|
466
646
|
}
|
|
467
647
|
} catch (err) {
|
|
468
|
-
|
|
648
|
+
_iterator10.e(err);
|
|
469
649
|
} finally {
|
|
470
|
-
|
|
650
|
+
_iterator10.f();
|
|
471
651
|
}
|
|
472
652
|
return false;
|
|
473
653
|
}
|
|
@@ -486,55 +666,55 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
486
666
|
key: "collectScheduleIdsFromStrategies",
|
|
487
667
|
value: function collectScheduleIdsFromStrategies(strategyConfigs) {
|
|
488
668
|
var scheduleIds = new Set();
|
|
489
|
-
var
|
|
490
|
-
|
|
669
|
+
var _iterator11 = _createForOfIteratorHelper(strategyConfigs),
|
|
670
|
+
_step11;
|
|
491
671
|
try {
|
|
492
|
-
for (
|
|
493
|
-
var config =
|
|
672
|
+
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
673
|
+
var config = _step11.value;
|
|
494
674
|
if (!this.isStrategyActive(config)) continue;
|
|
495
675
|
var rules = this.flattenConditionRules(config.conditions);
|
|
496
|
-
var
|
|
497
|
-
|
|
676
|
+
var _iterator12 = _createForOfIteratorHelper(rules),
|
|
677
|
+
_step12;
|
|
498
678
|
try {
|
|
499
|
-
for (
|
|
500
|
-
var rule =
|
|
679
|
+
for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
|
|
680
|
+
var rule = _step12.value;
|
|
501
681
|
if (rule.operator !== 'schedule_match') continue;
|
|
502
|
-
var
|
|
503
|
-
|
|
682
|
+
var _iterator13 = _createForOfIteratorHelper(this.normalizeNumberArray(rule.value)),
|
|
683
|
+
_step13;
|
|
504
684
|
try {
|
|
505
|
-
for (
|
|
506
|
-
var scheduleId =
|
|
685
|
+
for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
|
|
686
|
+
var scheduleId = _step13.value;
|
|
507
687
|
scheduleIds.add(scheduleId);
|
|
508
688
|
}
|
|
509
689
|
} catch (err) {
|
|
510
|
-
|
|
690
|
+
_iterator13.e(err);
|
|
511
691
|
} finally {
|
|
512
|
-
|
|
692
|
+
_iterator13.f();
|
|
513
693
|
}
|
|
514
694
|
}
|
|
515
695
|
} catch (err) {
|
|
516
|
-
|
|
696
|
+
_iterator12.e(err);
|
|
517
697
|
} finally {
|
|
518
|
-
|
|
698
|
+
_iterator12.f();
|
|
519
699
|
}
|
|
520
700
|
}
|
|
521
701
|
} catch (err) {
|
|
522
|
-
|
|
702
|
+
_iterator11.e(err);
|
|
523
703
|
} finally {
|
|
524
|
-
|
|
704
|
+
_iterator11.f();
|
|
525
705
|
}
|
|
526
706
|
return Array.from(scheduleIds);
|
|
527
707
|
}
|
|
528
708
|
}, {
|
|
529
709
|
key: "extractTimePointsFromSchedules",
|
|
530
710
|
value: function extractTimePointsFromSchedules(schedules) {
|
|
531
|
-
var
|
|
711
|
+
var _this6 = this;
|
|
532
712
|
var timePoints = new Set();
|
|
533
|
-
var
|
|
534
|
-
|
|
713
|
+
var _iterator14 = _createForOfIteratorHelper(schedules),
|
|
714
|
+
_step14;
|
|
535
715
|
try {
|
|
536
|
-
for (
|
|
537
|
-
var schedule =
|
|
716
|
+
for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
|
|
717
|
+
var schedule = _step14.value;
|
|
538
718
|
switch (schedule.type) {
|
|
539
719
|
case 'standard':
|
|
540
720
|
{
|
|
@@ -545,36 +725,36 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
545
725
|
case 'time-slots':
|
|
546
726
|
{
|
|
547
727
|
var slots = Array.isArray(schedule.time_slot) ? schedule.time_slot : [];
|
|
548
|
-
var
|
|
549
|
-
|
|
728
|
+
var _iterator15 = _createForOfIteratorHelper(slots),
|
|
729
|
+
_step15;
|
|
550
730
|
try {
|
|
551
|
-
for (
|
|
552
|
-
var slot =
|
|
731
|
+
for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
|
|
732
|
+
var slot = _step15.value;
|
|
553
733
|
this.addRawTimePoint(timePoints, slot.start_time);
|
|
554
734
|
this.addRawTimePoint(timePoints, slot.end_time);
|
|
555
735
|
}
|
|
556
736
|
} catch (err) {
|
|
557
|
-
|
|
737
|
+
_iterator15.e(err);
|
|
558
738
|
} finally {
|
|
559
|
-
|
|
739
|
+
_iterator15.f();
|
|
560
740
|
}
|
|
561
741
|
break;
|
|
562
742
|
}
|
|
563
743
|
case 'designation':
|
|
564
744
|
{
|
|
565
745
|
var designations = Array.isArray(schedule.designation) ? schedule.designation : schedule.designation ? [schedule.designation] : [];
|
|
566
|
-
var
|
|
567
|
-
|
|
746
|
+
var _iterator16 = _createForOfIteratorHelper(designations),
|
|
747
|
+
_step16;
|
|
568
748
|
try {
|
|
569
|
-
for (
|
|
570
|
-
var designation =
|
|
749
|
+
for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
|
|
750
|
+
var designation = _step16.value;
|
|
571
751
|
this.addRawTimePoint(timePoints, designation.start_time);
|
|
572
752
|
this.addRawTimePoint(timePoints, designation.end_time);
|
|
573
753
|
}
|
|
574
754
|
} catch (err) {
|
|
575
|
-
|
|
755
|
+
_iterator16.e(err);
|
|
576
756
|
} finally {
|
|
577
|
-
|
|
757
|
+
_iterator16.f();
|
|
578
758
|
}
|
|
579
759
|
break;
|
|
580
760
|
}
|
|
@@ -583,12 +763,12 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
583
763
|
}
|
|
584
764
|
}
|
|
585
765
|
} catch (err) {
|
|
586
|
-
|
|
766
|
+
_iterator14.e(err);
|
|
587
767
|
} finally {
|
|
588
|
-
|
|
768
|
+
_iterator14.f();
|
|
589
769
|
}
|
|
590
770
|
return Array.from(timePoints).sort(function (a, b) {
|
|
591
|
-
return
|
|
771
|
+
return _this6.timeToMinutes(a) - _this6.timeToMinutes(b);
|
|
592
772
|
});
|
|
593
773
|
}
|
|
594
774
|
}, {
|
|
@@ -635,14 +815,14 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
635
815
|
key: "isProductInMenuScope",
|
|
636
816
|
value: function isProductInMenuScope(product, scope) {
|
|
637
817
|
var _product$id,
|
|
638
|
-
|
|
818
|
+
_this7 = this;
|
|
639
819
|
if (scope.isAllProducts) return true;
|
|
640
820
|
if (!product || _typeof(product) !== 'object') return false;
|
|
641
821
|
var productId = this.toNumber((_product$id = product.id) !== null && _product$id !== void 0 ? _product$id : product.product_id);
|
|
642
822
|
var variantId = this.toNumber(product.product_variant_id);
|
|
643
823
|
var productKey = this.buildProductKey(productId, variantId);
|
|
644
824
|
var collectionIds = Array.isArray(product.collection_ids) ? product.collection_ids.map(function (id) {
|
|
645
|
-
return
|
|
825
|
+
return _this7.toNumber(id);
|
|
646
826
|
}) : [];
|
|
647
827
|
return collectionIds.some(function (id) {
|
|
648
828
|
return scope.collectionIds.has(id);
|
|
@@ -651,6 +831,7 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
651
831
|
}, {
|
|
652
832
|
key: "mergeMatchedVariants",
|
|
653
833
|
value: function mergeMatchedVariants(product, matchedVariants) {
|
|
834
|
+
var _this8 = this;
|
|
654
835
|
var original = _objectSpread({}, product);
|
|
655
836
|
var sortedVariants = _toConsumableArray(matchedVariants).sort(function (a, b) {
|
|
656
837
|
if (a.priority !== b.priority) return a.priority - b.priority;
|
|
@@ -659,11 +840,11 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
659
840
|
var result = _objectSpread({}, product);
|
|
660
841
|
var appliedRuleIds = [];
|
|
661
842
|
var appliedFields = new Set();
|
|
662
|
-
var
|
|
663
|
-
|
|
843
|
+
var _iterator17 = _createForOfIteratorHelper(sortedVariants),
|
|
844
|
+
_step17;
|
|
664
845
|
try {
|
|
665
|
-
for (
|
|
666
|
-
var matched =
|
|
846
|
+
for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
|
|
847
|
+
var matched = _step17.value;
|
|
667
848
|
for (var _i = 0, _Object$entries = Object.entries(matched.data); _i < _Object$entries.length; _i++) {
|
|
668
849
|
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
669
850
|
key = _Object$entries$_i[0],
|
|
@@ -675,12 +856,17 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
675
856
|
appliedRuleIds.push(matched.ruleId);
|
|
676
857
|
}
|
|
677
858
|
} catch (err) {
|
|
678
|
-
|
|
859
|
+
_iterator17.e(err);
|
|
679
860
|
} finally {
|
|
680
|
-
|
|
861
|
+
_iterator17.f();
|
|
681
862
|
}
|
|
682
863
|
result._dataVariant = {
|
|
683
864
|
appliedRuleIds: appliedRuleIds,
|
|
865
|
+
appliedVariantIds: Array.from(new Set(_toConsumableArray(sortedVariants).reverse().map(function (matched) {
|
|
866
|
+
return _this8.normalizeDataVariantId(matched.variant.id);
|
|
867
|
+
}).filter(function (id) {
|
|
868
|
+
return id !== null;
|
|
869
|
+
}))),
|
|
684
870
|
appliedFields: Array.from(appliedFields),
|
|
685
871
|
original: original
|
|
686
872
|
};
|
|
@@ -729,11 +915,11 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
729
915
|
key: "flattenConditionRules",
|
|
730
916
|
value: function flattenConditionRules(group) {
|
|
731
917
|
var rules = [];
|
|
732
|
-
var
|
|
733
|
-
|
|
918
|
+
var _iterator18 = _createForOfIteratorHelper(group.rules),
|
|
919
|
+
_step18;
|
|
734
920
|
try {
|
|
735
|
-
for (
|
|
736
|
-
var rule =
|
|
921
|
+
for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
|
|
922
|
+
var rule = _step18.value;
|
|
737
923
|
if (this.isConditionGroup(rule)) {
|
|
738
924
|
rules.push.apply(rules, _toConsumableArray(this.flattenConditionRules(rule)));
|
|
739
925
|
} else {
|
|
@@ -741,9 +927,9 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
741
927
|
}
|
|
742
928
|
}
|
|
743
929
|
} catch (err) {
|
|
744
|
-
|
|
930
|
+
_iterator18.e(err);
|
|
745
931
|
} finally {
|
|
746
|
-
|
|
932
|
+
_iterator18.f();
|
|
747
933
|
}
|
|
748
934
|
return rules;
|
|
749
935
|
}
|
|
@@ -755,10 +941,10 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
755
941
|
}, {
|
|
756
942
|
key: "normalizeNumberArray",
|
|
757
943
|
value: function normalizeNumberArray(value) {
|
|
758
|
-
var
|
|
944
|
+
var _this9 = this;
|
|
759
945
|
if (!Array.isArray(value)) return [];
|
|
760
946
|
return value.map(function (item) {
|
|
761
|
-
return
|
|
947
|
+
return _this9.toNumber(item);
|
|
762
948
|
}).filter(function (item) {
|
|
763
949
|
return item > 0;
|
|
764
950
|
});
|