@pisell/pisellos 2.2.293 → 2.2.295
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/itemRule/adapter.d.ts +1 -4
- package/dist/model/strategy/adapter/itemRule/adapter.js +35 -135
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +1 -8
- package/dist/model/strategy/adapter/itemRule/evaluator.js +1 -25
- package/dist/model/strategy/adapter/itemRule/type.d.ts +0 -44
- package/dist/model/strategy/adapter/itemRule/type.js +1 -19
- package/dist/modules/Order/index.d.ts +3 -18
- package/dist/modules/Order/index.js +485 -885
- package/dist/modules/Order/types.d.ts +5 -91
- package/dist/modules/Order/types.js +0 -5
- package/dist/modules/Order/utils.js +10 -22
- package/dist/modules/ProductList/index.d.ts +1 -2
- package/dist/modules/ProductList/index.js +20 -100
- package/dist/modules/ProductList/types.d.ts +0 -10
- package/dist/server/index.d.ts +0 -6
- package/dist/server/index.js +3 -43
- package/dist/solution/BaseSales/index.d.ts +1 -9
- package/dist/solution/BaseSales/index.js +706 -894
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingTicket/utils/orderCustomer.js +2 -3
- package/dist/solution/RegisterAndLogin/config.d.ts +3 -9
- package/dist/solution/RegisterAndLogin/config.js +40 -95
- package/dist/solution/RegisterAndLogin/index.js +1 -4
- package/dist/solution/ScanOrder/index.d.ts +0 -1
- package/dist/solution/ScanOrder/index.js +27 -31
- package/dist/solution/ScanOrder/utils.d.ts +0 -1
- package/dist/solution/ScanOrder/utils.js +0 -2
- package/dist/solution/UnifiedBookingSales/index.d.ts +4 -17
- package/dist/solution/UnifiedBookingSales/index.js +489 -755
- package/dist/solution/UnifiedBookingSales/types.d.ts +1 -14
- package/dist/solution/VenueBooking/index.d.ts +0 -1
- package/dist/solution/VenueBooking/index.js +4 -8
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +1 -4
- package/lib/model/strategy/adapter/itemRule/adapter.js +4 -73
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +1 -8
- package/lib/model/strategy/adapter/itemRule/evaluator.js +1 -23
- package/lib/model/strategy/adapter/itemRule/type.d.ts +0 -44
- package/lib/model/strategy/adapter/itemRule/type.js +1 -19
- package/lib/model/strategy/adapter/promotion/index.js +46 -1
- package/lib/modules/Order/index.d.ts +3 -18
- package/lib/modules/Order/index.js +28 -325
- package/lib/modules/Order/types.d.ts +5 -91
- package/lib/modules/Order/types.js +0 -4
- package/lib/modules/Order/utils.js +1 -13
- package/lib/modules/ProductList/index.d.ts +1 -2
- package/lib/modules/ProductList/index.js +2 -47
- package/lib/modules/ProductList/types.d.ts +0 -10
- package/lib/server/index.d.ts +0 -6
- package/lib/server/index.js +3 -37
- package/lib/solution/BaseSales/index.d.ts +1 -9
- package/lib/solution/BaseSales/index.js +1 -105
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingTicket/utils/orderCustomer.js +1 -2
- package/lib/solution/RegisterAndLogin/config.d.ts +3 -9
- package/lib/solution/RegisterAndLogin/config.js +8 -49
- package/lib/solution/RegisterAndLogin/index.js +1 -4
- package/lib/solution/ScanOrder/index.d.ts +0 -1
- package/lib/solution/ScanOrder/index.js +1 -5
- package/lib/solution/ScanOrder/utils.d.ts +0 -1
- package/lib/solution/ScanOrder/utils.js +0 -1
- package/lib/solution/UnifiedBookingSales/index.d.ts +4 -17
- package/lib/solution/UnifiedBookingSales/index.js +6 -128
- package/lib/solution/UnifiedBookingSales/types.d.ts +1 -14
- package/lib/solution/VenueBooking/index.d.ts +0 -1
- package/lib/solution/VenueBooking/index.js +1 -5
- package/package.json +1 -1
- package/dist/modules/Order/salesNotes.d.ts +0 -31
- package/dist/modules/Order/salesNotes.js +0 -492
- package/lib/modules/Order/salesNotes.d.ts +0 -31
- package/lib/modules/Order/salesNotes.js +0 -382
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { EvaluationResult, RuntimeContext, ActionEffect } from '../../type';
|
|
2
2
|
import type { BusinessAdapter } from '../type';
|
|
3
|
-
import { type ItemRuleBusinessData, type QuantityCheckResult, type PrefillItemResult, type QuantityLimitResult
|
|
3
|
+
import { type ItemRuleBusinessData, type QuantityCheckResult, type PrefillItemResult, type QuantityLimitResult } from './type';
|
|
4
4
|
/**
|
|
5
5
|
* ItemRule 适配器
|
|
6
6
|
*
|
|
@@ -14,10 +14,7 @@ export declare class ItemRuleAdapter implements BusinessAdapter {
|
|
|
14
14
|
transformResult(result: EvaluationResult, businessData?: ItemRuleBusinessData): {
|
|
15
15
|
quantityChecks: QuantityCheckResult[];
|
|
16
16
|
prefillItems: PrefillItemResult[];
|
|
17
|
-
allergyRequirements: AllergyRequirement[];
|
|
18
17
|
};
|
|
19
|
-
private processAllergyCheck;
|
|
20
|
-
private normalizeAllergyDataSourceItems;
|
|
21
18
|
formatConfig(result: EvaluationResult, businessData?: ItemRuleBusinessData): {
|
|
22
19
|
result: EvaluationResult;
|
|
23
20
|
businessData?: ItemRuleBusinessData;
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
3
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
5
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
6
2
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
7
3
|
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
4
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
@@ -35,22 +31,18 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
|
|
|
35
31
|
_createClass(ItemRuleAdapter, [{
|
|
36
32
|
key: "prepareContext",
|
|
37
33
|
value: function prepareContext(businessData) {
|
|
38
|
-
var _ref;
|
|
39
34
|
var pax = businessData.pax,
|
|
40
35
|
cartItems = businessData.cartItems,
|
|
41
36
|
serviceType = businessData.serviceType,
|
|
42
|
-
channel = businessData.channel,
|
|
43
37
|
submissionIndex = businessData.submissionIndex,
|
|
44
38
|
custom = businessData.custom;
|
|
45
|
-
var resolvedChannel = String((_ref = channel !== null && channel !== void 0 ? channel : custom === null || custom === void 0 ? void 0 : custom.channel) !== null && _ref !== void 0 ? _ref : '').trim();
|
|
46
39
|
return {
|
|
47
40
|
entities: {
|
|
48
41
|
cartItems: cartItems,
|
|
49
42
|
historicalItems: businessData.historicalItems || [],
|
|
50
|
-
pax: pax
|
|
51
|
-
currentProduct: businessData.currentProduct
|
|
43
|
+
pax: pax
|
|
52
44
|
},
|
|
53
|
-
attributes: _objectSpread(
|
|
45
|
+
attributes: _objectSpread({
|
|
54
46
|
serviceType: serviceType || '',
|
|
55
47
|
totalPax: pax.total,
|
|
56
48
|
adultPax: pax.adult,
|
|
@@ -60,9 +52,7 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
|
|
|
60
52
|
cartTotalQuantity: cartItems.reduce(function (sum, item) {
|
|
61
53
|
return sum + item.quantity;
|
|
62
54
|
}, 0)
|
|
63
|
-
}, custom),
|
|
64
|
-
channel: resolvedChannel
|
|
65
|
-
}),
|
|
55
|
+
}, custom),
|
|
66
56
|
metadata: {
|
|
67
57
|
timestamp: Date.now()
|
|
68
58
|
}
|
|
@@ -73,12 +63,10 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
|
|
|
73
63
|
value: function transformResult(result, businessData) {
|
|
74
64
|
var quantityChecks = [];
|
|
75
65
|
var prefillItems = [];
|
|
76
|
-
var allergyRequirements = [];
|
|
77
66
|
if (!result.applicable || !businessData) {
|
|
78
67
|
return {
|
|
79
68
|
quantityChecks: quantityChecks,
|
|
80
|
-
prefillItems: prefillItems
|
|
81
|
-
allergyRequirements: allergyRequirements
|
|
69
|
+
prefillItems: prefillItems
|
|
82
70
|
};
|
|
83
71
|
}
|
|
84
72
|
var _iterator = _createForOfIteratorHelper(result.matchedActions),
|
|
@@ -94,9 +82,6 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
|
|
|
94
82
|
} else if (action.type === ITEM_RULE_ACTION_TYPES.PREFILL_CART) {
|
|
95
83
|
var items = this.processPrefillCart(action, businessData);
|
|
96
84
|
prefillItems.push.apply(prefillItems, _toConsumableArray(items));
|
|
97
|
-
} else if (action.type === ITEM_RULE_ACTION_TYPES.ALLERGY_CHECK) {
|
|
98
|
-
var requirement = this.processAllergyCheck(action, result, businessData);
|
|
99
|
-
if (requirement) allergyRequirements.push(requirement);
|
|
100
85
|
}
|
|
101
86
|
}
|
|
102
87
|
} catch (err) {
|
|
@@ -106,94 +91,9 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
|
|
|
106
91
|
}
|
|
107
92
|
return {
|
|
108
93
|
quantityChecks: quantityChecks,
|
|
109
|
-
prefillItems: prefillItems
|
|
110
|
-
allergyRequirements: allergyRequirements
|
|
94
|
+
prefillItems: prefillItems
|
|
111
95
|
};
|
|
112
96
|
}
|
|
113
|
-
|
|
114
|
-
// ============================================
|
|
115
|
-
// Allergy Check 处理
|
|
116
|
-
// ============================================
|
|
117
|
-
}, {
|
|
118
|
-
key: "processAllergyCheck",
|
|
119
|
-
value: function processAllergyCheck(action, result, businessData) {
|
|
120
|
-
var _currentProduct$produ, _productTargets$find, _target$dataSource, _action$priority, _target$product_varia;
|
|
121
|
-
var config = action.config;
|
|
122
|
-
var currentProduct = businessData.currentProduct;
|
|
123
|
-
if (!config || config.targetType !== 'product' || config.promptScope !== 'once_per_order_product' || !Array.isArray(config.targets) || !currentProduct) {
|
|
124
|
-
return null;
|
|
125
|
-
}
|
|
126
|
-
var currentProductId = Number(currentProduct.product_id);
|
|
127
|
-
var currentVariantId = Number((_currentProduct$produ = currentProduct.product_variant_id) !== null && _currentProduct$produ !== void 0 ? _currentProduct$produ : 0);
|
|
128
|
-
if (!Number.isFinite(currentProductId) || currentProductId <= 0) return null;
|
|
129
|
-
var productTargets = config.targets.filter(function (item) {
|
|
130
|
-
return Number(item.product_id) === currentProductId;
|
|
131
|
-
});
|
|
132
|
-
var target = (_productTargets$find = productTargets.find(function (item) {
|
|
133
|
-
var _item$product_variant;
|
|
134
|
-
return currentVariantId > 0 && Number((_item$product_variant = item.product_variant_id) !== null && _item$product_variant !== void 0 ? _item$product_variant : 0) === currentVariantId;
|
|
135
|
-
})) !== null && _productTargets$find !== void 0 ? _productTargets$find : productTargets.find(function (item) {
|
|
136
|
-
var _item$product_variant2;
|
|
137
|
-
return Number((_item$product_variant2 = item.product_variant_id) !== null && _item$product_variant2 !== void 0 ? _item$product_variant2 : 0) <= 0;
|
|
138
|
-
});
|
|
139
|
-
if (!target || ((_target$dataSource = target.dataSource) === null || _target$dataSource === void 0 ? void 0 : _target$dataSource.type) !== 'inline') return null;
|
|
140
|
-
var items = this.normalizeAllergyDataSourceItems(target.dataSource.items);
|
|
141
|
-
if (!items.length) return null;
|
|
142
|
-
return _objectSpread(_objectSpread({
|
|
143
|
-
strategyId: result.config.metadata.id,
|
|
144
|
-
ruleId: action.id,
|
|
145
|
-
priority: (_action$priority = action.priority) !== null && _action$priority !== void 0 ? _action$priority : 0,
|
|
146
|
-
targetType: 'product',
|
|
147
|
-
product_id: currentProductId
|
|
148
|
-
}, Number((_target$product_varia = target.product_variant_id) !== null && _target$product_varia !== void 0 ? _target$product_varia : 0) > 0 ? {
|
|
149
|
-
product_variant_id: Number(target.product_variant_id)
|
|
150
|
-
} : {}), {}, {
|
|
151
|
-
dataSource: {
|
|
152
|
-
type: 'inline',
|
|
153
|
-
items: items
|
|
154
|
-
},
|
|
155
|
-
promptScope: config.promptScope,
|
|
156
|
-
allowNote: config.allowNote === true
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
}, {
|
|
160
|
-
key: "normalizeAllergyDataSourceItems",
|
|
161
|
-
value: function normalizeAllergyDataSourceItems(items) {
|
|
162
|
-
if (!Array.isArray(items)) return [];
|
|
163
|
-
var uniqueIds = new Set();
|
|
164
|
-
var normalized = [];
|
|
165
|
-
var _iterator2 = _createForOfIteratorHelper(items),
|
|
166
|
-
_step2;
|
|
167
|
-
try {
|
|
168
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
169
|
-
var _item$id;
|
|
170
|
-
var item = _step2.value;
|
|
171
|
-
var id = String((_item$id = item === null || item === void 0 ? void 0 : item.id) !== null && _item$id !== void 0 ? _item$id : '').trim();
|
|
172
|
-
var rawLabel = item === null || item === void 0 ? void 0 : item.label;
|
|
173
|
-
var label = typeof rawLabel === 'string' ? rawLabel.trim() : Object.entries(rawLabel || {}).reduce(function (labels, _ref2) {
|
|
174
|
-
var _ref3 = _slicedToArray(_ref2, 2),
|
|
175
|
-
locale = _ref3[0],
|
|
176
|
-
value = _ref3[1];
|
|
177
|
-
if (typeof value === 'string' && value.trim().length > 0) {
|
|
178
|
-
labels[locale] = value.trim();
|
|
179
|
-
}
|
|
180
|
-
return labels;
|
|
181
|
-
}, {});
|
|
182
|
-
var hasLabel = typeof label === 'string' ? label.length > 0 : Object.keys(label).length > 0;
|
|
183
|
-
if (!id || !hasLabel || uniqueIds.has(id)) continue;
|
|
184
|
-
uniqueIds.add(id);
|
|
185
|
-
normalized.push({
|
|
186
|
-
id: id,
|
|
187
|
-
label: label
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
} catch (err) {
|
|
191
|
-
_iterator2.e(err);
|
|
192
|
-
} finally {
|
|
193
|
-
_iterator2.f();
|
|
194
|
-
}
|
|
195
|
-
return normalized;
|
|
196
|
-
}
|
|
197
97
|
}, {
|
|
198
98
|
key: "formatConfig",
|
|
199
99
|
value: function formatConfig(result, businessData) {
|
|
@@ -278,19 +178,19 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
|
|
|
278
178
|
}));
|
|
279
179
|
var quantity = 0;
|
|
280
180
|
var countFromItems = function countFromItems(items) {
|
|
281
|
-
var
|
|
282
|
-
|
|
181
|
+
var _iterator2 = _createForOfIteratorHelper(items),
|
|
182
|
+
_step2;
|
|
283
183
|
try {
|
|
284
|
-
for (
|
|
285
|
-
var item =
|
|
184
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
185
|
+
var item = _step2.value;
|
|
286
186
|
if (targetIds.has(item.product_id)) {
|
|
287
187
|
quantity += item.quantity;
|
|
288
188
|
}
|
|
289
189
|
}
|
|
290
190
|
} catch (err) {
|
|
291
|
-
|
|
191
|
+
_iterator2.e(err);
|
|
292
192
|
} finally {
|
|
293
|
-
|
|
193
|
+
_iterator2.f();
|
|
294
194
|
}
|
|
295
195
|
};
|
|
296
196
|
if (scope === 'cumulative') {
|
|
@@ -314,11 +214,11 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
|
|
|
314
214
|
var requiredMax;
|
|
315
215
|
var requiredExact;
|
|
316
216
|
var mustInclude;
|
|
317
|
-
var
|
|
318
|
-
|
|
217
|
+
var _iterator3 = _createForOfIteratorHelper(rules),
|
|
218
|
+
_step3;
|
|
319
219
|
try {
|
|
320
|
-
for (
|
|
321
|
-
var rule =
|
|
220
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
221
|
+
var rule = _step3.value;
|
|
322
222
|
var resolvedValue = this.resolveQuantityValue(rule, businessData);
|
|
323
223
|
switch (rule.comparison) {
|
|
324
224
|
case 'minimum':
|
|
@@ -360,9 +260,9 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
|
|
|
360
260
|
}
|
|
361
261
|
}
|
|
362
262
|
} catch (err) {
|
|
363
|
-
|
|
263
|
+
_iterator3.e(err);
|
|
364
264
|
} finally {
|
|
365
|
-
|
|
265
|
+
_iterator3.f();
|
|
366
266
|
}
|
|
367
267
|
return {
|
|
368
268
|
passed: failedRules.length === 0,
|
|
@@ -436,11 +336,11 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
|
|
|
436
336
|
var requiredMax;
|
|
437
337
|
var requiredExact;
|
|
438
338
|
var mustInclude;
|
|
439
|
-
var
|
|
440
|
-
|
|
339
|
+
var _iterator4 = _createForOfIteratorHelper(quantityRules),
|
|
340
|
+
_step4;
|
|
441
341
|
try {
|
|
442
|
-
for (
|
|
443
|
-
var rule =
|
|
342
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
343
|
+
var rule = _step4.value;
|
|
444
344
|
var resolvedValue = this.resolveQuantityValue(rule, businessData);
|
|
445
345
|
switch (rule.comparison) {
|
|
446
346
|
case 'minimum':
|
|
@@ -470,9 +370,9 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
|
|
|
470
370
|
}
|
|
471
371
|
}
|
|
472
372
|
} catch (err) {
|
|
473
|
-
|
|
373
|
+
_iterator4.e(err);
|
|
474
374
|
} finally {
|
|
475
|
-
|
|
375
|
+
_iterator4.f();
|
|
476
376
|
}
|
|
477
377
|
var remainingMax = this.calculateRemainingMax(scope, requiredMax, targets, businessData);
|
|
478
378
|
var formattedValidationMessage = this.formatValidationMessage(validationMessage, requiredMin, requiredMax, requiredExact);
|
|
@@ -512,19 +412,19 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
|
|
|
512
412
|
return t.product_id;
|
|
513
413
|
}));
|
|
514
414
|
var historicalQty = 0;
|
|
515
|
-
var
|
|
516
|
-
|
|
415
|
+
var _iterator5 = _createForOfIteratorHelper(historicalItems),
|
|
416
|
+
_step5;
|
|
517
417
|
try {
|
|
518
|
-
for (
|
|
519
|
-
var item =
|
|
418
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
419
|
+
var item = _step5.value;
|
|
520
420
|
if (targetIds.has(item.product_id)) {
|
|
521
421
|
historicalQty += item.quantity;
|
|
522
422
|
}
|
|
523
423
|
}
|
|
524
424
|
} catch (err) {
|
|
525
|
-
|
|
425
|
+
_iterator5.e(err);
|
|
526
426
|
} finally {
|
|
527
|
-
|
|
427
|
+
_iterator5.f();
|
|
528
428
|
}
|
|
529
429
|
return Math.max(0, requiredMax - historicalQty);
|
|
530
430
|
}
|
|
@@ -538,11 +438,11 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
|
|
|
538
438
|
var config = action.config;
|
|
539
439
|
if (!(config !== null && config !== void 0 && config.products)) return [];
|
|
540
440
|
var results = [];
|
|
541
|
-
var
|
|
542
|
-
|
|
441
|
+
var _iterator6 = _createForOfIteratorHelper(config.products),
|
|
442
|
+
_step6;
|
|
543
443
|
try {
|
|
544
|
-
for (
|
|
545
|
-
var prefillProduct =
|
|
444
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
445
|
+
var prefillProduct = _step6.value;
|
|
546
446
|
var quantity = this.resolvePrefillQuantity(prefillProduct.quantityFrom, prefillProduct.quantity, businessData);
|
|
547
447
|
if (quantity <= 0) continue;
|
|
548
448
|
results.push({
|
|
@@ -553,9 +453,9 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
|
|
|
553
453
|
});
|
|
554
454
|
}
|
|
555
455
|
} catch (err) {
|
|
556
|
-
|
|
456
|
+
_iterator6.e(err);
|
|
557
457
|
} finally {
|
|
558
|
-
|
|
458
|
+
_iterator6.f();
|
|
559
459
|
}
|
|
560
460
|
return results;
|
|
561
461
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StrategyConfig } from '../../type';
|
|
2
|
-
import { type ItemRuleBusinessData, type ItemRuleEvaluationResult, type QuantityCheckResult, type QuantityLimitResult, type PrefillItemResult
|
|
2
|
+
import { type ItemRuleBusinessData, type ItemRuleEvaluationResult, type QuantityCheckResult, type QuantityLimitResult, type PrefillItemResult } from './type';
|
|
3
3
|
/**
|
|
4
4
|
* ItemRule 评估器
|
|
5
5
|
*
|
|
@@ -21,13 +21,6 @@ export declare class ItemRuleEvaluator {
|
|
|
21
21
|
* 完整评估:数量校验 + 预填购物车
|
|
22
22
|
*/
|
|
23
23
|
evaluate(businessData: ItemRuleBusinessData): ItemRuleEvaluationResult;
|
|
24
|
-
/**
|
|
25
|
-
* 获取当前商品优先级最高的过敏门禁要求。
|
|
26
|
-
*
|
|
27
|
-
* 不同商品或不同 Action 的数据源不会合并;相同优先级按
|
|
28
|
-
* strategyId + ruleId 稳定排序,保证多次评估结果一致。
|
|
29
|
-
*/
|
|
30
|
-
getAllergyRequirement(businessData: ItemRuleBusinessData): AllergyRequirement | null;
|
|
31
24
|
/**
|
|
32
25
|
* 获取当前配置中各商品的数量限制
|
|
33
26
|
*
|
|
@@ -63,7 +63,6 @@ export var ItemRuleEvaluator = /*#__PURE__*/function () {
|
|
|
63
63
|
}) : this.strategyConfigs;
|
|
64
64
|
var allQuantityChecks = [];
|
|
65
65
|
var allPrefillItems = [];
|
|
66
|
-
var allAllergyRequirements = [];
|
|
67
66
|
var rawResults = [];
|
|
68
67
|
var context = this.adapter.prepareContext(businessData);
|
|
69
68
|
var _iterator = _createForOfIteratorHelper(configs),
|
|
@@ -75,11 +74,9 @@ export var ItemRuleEvaluator = /*#__PURE__*/function () {
|
|
|
75
74
|
rawResults.push(evalResult);
|
|
76
75
|
var _this$adapter$transfo = this.adapter.transformResult(evalResult, businessData),
|
|
77
76
|
quantityChecks = _this$adapter$transfo.quantityChecks,
|
|
78
|
-
prefillItems = _this$adapter$transfo.prefillItems
|
|
79
|
-
allergyRequirements = _this$adapter$transfo.allergyRequirements;
|
|
77
|
+
prefillItems = _this$adapter$transfo.prefillItems;
|
|
80
78
|
allQuantityChecks.push.apply(allQuantityChecks, _toConsumableArray(quantityChecks));
|
|
81
79
|
allPrefillItems.push.apply(allPrefillItems, _toConsumableArray(prefillItems));
|
|
82
|
-
allAllergyRequirements.push.apply(allAllergyRequirements, _toConsumableArray(allergyRequirements));
|
|
83
80
|
}
|
|
84
81
|
} catch (err) {
|
|
85
82
|
_iterator.e(err);
|
|
@@ -92,33 +89,12 @@ export var ItemRuleEvaluator = /*#__PURE__*/function () {
|
|
|
92
89
|
return {
|
|
93
90
|
quantityChecks: allQuantityChecks,
|
|
94
91
|
prefillItems: allPrefillItems,
|
|
95
|
-
allergyRequirements: allAllergyRequirements,
|
|
96
92
|
allPassed: failedChecks.length === 0,
|
|
97
93
|
failedChecks: failedChecks,
|
|
98
94
|
rawResults: rawResults
|
|
99
95
|
};
|
|
100
96
|
}
|
|
101
97
|
|
|
102
|
-
/**
|
|
103
|
-
* 获取当前商品优先级最高的过敏门禁要求。
|
|
104
|
-
*
|
|
105
|
-
* 不同商品或不同 Action 的数据源不会合并;相同优先级按
|
|
106
|
-
* strategyId + ruleId 稳定排序,保证多次评估结果一致。
|
|
107
|
-
*/
|
|
108
|
-
}, {
|
|
109
|
-
key: "getAllergyRequirement",
|
|
110
|
-
value: function getAllergyRequirement(businessData) {
|
|
111
|
-
var requirements = this.evaluate(businessData).allergyRequirements;
|
|
112
|
-
if (!requirements.length) return null;
|
|
113
|
-
return _toConsumableArray(requirements).sort(function (left, right) {
|
|
114
|
-
var priorityDiff = right.priority - left.priority;
|
|
115
|
-
if (priorityDiff !== 0) return priorityDiff;
|
|
116
|
-
var strategyDiff = left.strategyId.localeCompare(right.strategyId);
|
|
117
|
-
if (strategyDiff !== 0) return strategyDiff;
|
|
118
|
-
return left.ruleId.localeCompare(right.ruleId);
|
|
119
|
-
})[0];
|
|
120
|
-
}
|
|
121
|
-
|
|
122
98
|
/**
|
|
123
99
|
* 获取当前配置中各商品的数量限制
|
|
124
100
|
*
|
|
@@ -4,8 +4,6 @@ export declare const ITEM_RULE_ACTION_TYPES: {
|
|
|
4
4
|
readonly QUANTITY_CHECK: "QUANTITY_CHECK";
|
|
5
5
|
/** 预填购物车 */
|
|
6
6
|
readonly PREFILL_CART: "PREFILL_CART";
|
|
7
|
-
/** 加购前过敏信息确认 */
|
|
8
|
-
readonly ALLERGY_CHECK: "ALLERGY_CHECK";
|
|
9
7
|
};
|
|
10
8
|
export type ItemRuleActionType = (typeof ITEM_RULE_ACTION_TYPES)[keyof typeof ITEM_RULE_ACTION_TYPES];
|
|
11
9
|
export declare const ITEM_RULE_TEMPLATES: {
|
|
@@ -65,42 +63,6 @@ export interface TargetItem {
|
|
|
65
63
|
/** 变体 ID */
|
|
66
64
|
product_variant_id?: number;
|
|
67
65
|
}
|
|
68
|
-
/** 策略展示文案,可由调用方按当前 locale 解析。 */
|
|
69
|
-
export type ItemRuleLocalizedText = string | Record<string, string>;
|
|
70
|
-
/** 内联过敏源选项。稳定 id 用于保存选择,label 只负责展示。 */
|
|
71
|
-
export interface AllergyDataSourceItem {
|
|
72
|
-
id: string;
|
|
73
|
-
label: ItemRuleLocalizedText;
|
|
74
|
-
}
|
|
75
|
-
/** 当前仅支持随策略下发的内联过敏源。 */
|
|
76
|
-
export interface AllergyDataSource {
|
|
77
|
-
type: 'inline';
|
|
78
|
-
items: AllergyDataSourceItem[];
|
|
79
|
-
}
|
|
80
|
-
/** 每个目标商品独立持有自己的过敏源,禁止跨商品合并。 */
|
|
81
|
-
export interface AllergyTargetItem extends TargetItem {
|
|
82
|
-
dataSource: AllergyDataSource;
|
|
83
|
-
}
|
|
84
|
-
export type AllergyPromptScope = 'once_per_order_product';
|
|
85
|
-
/** ALLERGY_CHECK Action 的商品级配置。 */
|
|
86
|
-
export interface AllergyCheckConfig {
|
|
87
|
-
targetType: 'product';
|
|
88
|
-
targets: AllergyTargetItem[];
|
|
89
|
-
promptScope: AllergyPromptScope;
|
|
90
|
-
allowNote?: boolean;
|
|
91
|
-
}
|
|
92
|
-
/** 当前商品命中的单条过敏门禁要求。 */
|
|
93
|
-
export interface AllergyRequirement {
|
|
94
|
-
strategyId: string;
|
|
95
|
-
ruleId: string;
|
|
96
|
-
priority: number;
|
|
97
|
-
targetType: 'product';
|
|
98
|
-
product_id: number;
|
|
99
|
-
product_variant_id?: number;
|
|
100
|
-
dataSource: AllergyDataSource;
|
|
101
|
-
promptScope: AllergyPromptScope;
|
|
102
|
-
allowNote: boolean;
|
|
103
|
-
}
|
|
104
66
|
/**
|
|
105
67
|
* 预填商品项
|
|
106
68
|
*/
|
|
@@ -157,10 +119,6 @@ export interface ItemRuleBusinessData {
|
|
|
157
119
|
historicalItems?: CartItemSummary[];
|
|
158
120
|
/** 服务类型(如 'dine-in', 'takeaway') */
|
|
159
121
|
serviceType?: string;
|
|
160
|
-
/** 当前业务渠道(如 'kiosk', 'pos', 'online_store') */
|
|
161
|
-
channel?: string;
|
|
162
|
-
/** 当前正在加入购物车的商品;ALLERGY_CHECK 只读取该商品的 Target。 */
|
|
163
|
-
currentProduct?: Pick<TargetItem, 'product_id' | 'product_variant_id'>;
|
|
164
122
|
/** 当前提交次数(0=首次提交, >0=追加提交) */
|
|
165
123
|
submissionIndex?: number;
|
|
166
124
|
/** 策略配置列表(可选,如果不传则使用 setStrategyConfigs 设置的) */
|
|
@@ -258,8 +216,6 @@ export interface ItemRuleEvaluationResult {
|
|
|
258
216
|
quantityChecks: QuantityCheckResult[];
|
|
259
217
|
/** 需要预填的商品列表 */
|
|
260
218
|
prefillItems: PrefillItemResult[];
|
|
261
|
-
/** 当前商品命中的过敏门禁要求;不同 Action/商品不会合并。 */
|
|
262
|
-
allergyRequirements: AllergyRequirement[];
|
|
263
219
|
/** 所有校验是否全部通过 */
|
|
264
220
|
allPassed: boolean;
|
|
265
221
|
/** 未通过的校验列表 */
|
|
@@ -6,9 +6,7 @@ export var ITEM_RULE_ACTION_TYPES = {
|
|
|
6
6
|
/** 数量校验 */
|
|
7
7
|
QUANTITY_CHECK: 'QUANTITY_CHECK',
|
|
8
8
|
/** 预填购物车 */
|
|
9
|
-
PREFILL_CART: 'PREFILL_CART'
|
|
10
|
-
/** 加购前过敏信息确认 */
|
|
11
|
-
ALLERGY_CHECK: 'ALLERGY_CHECK'
|
|
9
|
+
PREFILL_CART: 'PREFILL_CART'
|
|
12
10
|
};
|
|
13
11
|
// ============================================
|
|
14
12
|
// Rule Template 类型(创建规则时的起始模板)
|
|
@@ -52,22 +50,6 @@ export var ITEM_RULE_TEMPLATES = {
|
|
|
52
50
|
|
|
53
51
|
/** 目标项 */
|
|
54
52
|
|
|
55
|
-
// ============================================
|
|
56
|
-
// Allergy Check 相关类型
|
|
57
|
-
// ============================================
|
|
58
|
-
|
|
59
|
-
/** 策略展示文案,可由调用方按当前 locale 解析。 */
|
|
60
|
-
|
|
61
|
-
/** 内联过敏源选项。稳定 id 用于保存选择,label 只负责展示。 */
|
|
62
|
-
|
|
63
|
-
/** 当前仅支持随策略下发的内联过敏源。 */
|
|
64
|
-
|
|
65
|
-
/** 每个目标商品独立持有自己的过敏源,禁止跨商品合并。 */
|
|
66
|
-
|
|
67
|
-
/** ALLERGY_CHECK Action 的商品级配置。 */
|
|
68
|
-
|
|
69
|
-
/** 当前商品命中的单条过敏门禁要求。 */
|
|
70
|
-
|
|
71
53
|
// ============================================
|
|
72
54
|
// Prefill Cart 相关类型
|
|
73
55
|
// ============================================
|
|
@@ -3,7 +3,7 @@ import { BaseModule } from '../BaseModule';
|
|
|
3
3
|
import { OrderModuleAPI, CommitOrderParams, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, CancelOrderParams, ChangeBookingStatusParams, CheckoutOrderParams } from './types';
|
|
4
4
|
import { CartItem } from '../Cart/types';
|
|
5
5
|
import { type SubmitPayloadEnhancer } from './utils';
|
|
6
|
-
import type { OrderAmountSnapshot, AddProductBookingInput, AddProductToOrderOptions, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, ReplaceTempOrderOptions, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions, RemoveProductsFromOrderOptions
|
|
6
|
+
import type { OrderAmountSnapshot, AddProductBookingInput, AddProductToOrderOptions, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, ReplaceTempOrderOptions, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions, RemoveProductsFromOrderOptions } from './types';
|
|
7
7
|
import type { ICustomer } from '../AccountList/types';
|
|
8
8
|
import type { Discount } from '../Discount/types';
|
|
9
9
|
import { UnavailableReason } from '../Rules/types';
|
|
@@ -301,24 +301,9 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
301
301
|
updateTempOrderNote(note: string, sync: boolean): string | Promise<string>;
|
|
302
302
|
syncTempOrderNoteToRemote(orderId: number | string, note: string): Promise<string>;
|
|
303
303
|
getTempOrderNote(): string;
|
|
304
|
-
private ensureSalesNotesRuntimeState;
|
|
305
|
-
private ensureSalesNotesLoadedForMutation;
|
|
306
|
-
private normalizeSalesNoteUuid;
|
|
307
|
-
private getSalesNotePrimaryRelation;
|
|
308
|
-
private removeSalesNotesForMissingProductLines;
|
|
309
|
-
private setSalesNoteOnTempOrder;
|
|
310
|
-
getSalesNotes(): SalesNote[];
|
|
311
|
-
createSalesNotesMutationSnapshot(): SalesNotesMutationSnapshot;
|
|
312
|
-
restoreSalesNotesMutationSnapshot(snapshot: SalesNotesMutationSnapshot): void;
|
|
313
|
-
setSalesNote(input: SetSalesNoteInput): Promise<SalesNote>;
|
|
314
|
-
removeSalesNote(uuid: string): Promise<void>;
|
|
315
|
-
clearSalesNotes(): Promise<void>;
|
|
316
304
|
updateTempOrderShopDiscount(amount: string | number): string;
|
|
317
305
|
updateTempOrderDepositAmount(amount: string | number): OrderSummary;
|
|
318
306
|
updateTempOrderBuzzer(buzzer: string): string;
|
|
319
|
-
private updateTempOrderShopServiceData;
|
|
320
|
-
updateTempOrderPickupReferenceMode(mode: PickupReferenceMode): ShopServiceData;
|
|
321
|
-
updateTempOrderServiceType(serviceType: ShopServiceType): ShopServiceData;
|
|
322
307
|
updateTempOrderContactsInfo(contactsInfo: Record<string, any> | null): Record<string, any> | null;
|
|
323
308
|
private buildTempOrderCustomer;
|
|
324
309
|
private isCustomerBoundDiscount;
|
|
@@ -469,7 +454,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
469
454
|
removeProductFromOrder(identity: OrderProductIdentity, options?: RemoveProductsFromOrderOptions): Promise<OrderProduct[]>;
|
|
470
455
|
/**
|
|
471
456
|
* 仅清空购物车行(products / bookings),不重置整单。
|
|
472
|
-
*
|
|
457
|
+
* 用于「仅清空商品」;客户、备注、支付等协议字段保持不变。
|
|
473
458
|
*/
|
|
474
459
|
clearOrderCartLines(): Promise<OrderTempOrder>;
|
|
475
460
|
buildCurrentSubmitPayloadForLocalPrint(params?: {
|
|
@@ -606,4 +591,4 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
606
591
|
getOrderInfo(order_id: number): Promise<any>;
|
|
607
592
|
getVouchers(): any[];
|
|
608
593
|
}
|
|
609
|
-
export type { AddProductToOrderOptions, RemoveProductsFromOrderOptions,
|
|
594
|
+
export type { AddProductToOrderOptions, RemoveProductsFromOrderOptions, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, } from './types';
|