@pisell/pisellos 2.3.94 → 2.3.95

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.
Files changed (72) hide show
  1. package/dist/model/strategy/adapter/itemRule/adapter.d.ts +4 -1
  2. package/dist/model/strategy/adapter/itemRule/adapter.js +135 -35
  3. package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +8 -1
  4. package/dist/model/strategy/adapter/itemRule/evaluator.js +25 -1
  5. package/dist/model/strategy/adapter/itemRule/type.d.ts +44 -0
  6. package/dist/model/strategy/adapter/itemRule/type.js +19 -1
  7. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  8. package/dist/modules/Order/index.d.ts +18 -3
  9. package/dist/modules/Order/index.js +885 -485
  10. package/dist/modules/Order/salesNotes.d.ts +31 -0
  11. package/dist/modules/Order/salesNotes.js +492 -0
  12. package/dist/modules/Order/types.d.ts +91 -5
  13. package/dist/modules/Order/types.js +5 -0
  14. package/dist/modules/Order/utils.d.ts +12 -0
  15. package/dist/modules/Order/utils.js +75 -26
  16. package/dist/modules/ProductList/index.d.ts +2 -1
  17. package/dist/modules/ProductList/index.js +100 -20
  18. package/dist/modules/ProductList/types.d.ts +10 -0
  19. package/dist/server/index.d.ts +6 -0
  20. package/dist/server/index.js +43 -3
  21. package/dist/solution/BaseSales/index.d.ts +9 -1
  22. package/dist/solution/BaseSales/index.js +894 -706
  23. package/dist/solution/BookingByStep/index.d.ts +2 -2
  24. package/dist/solution/BookingTicket/utils/orderCustomer.js +3 -2
  25. package/dist/solution/RegisterAndLogin/config.d.ts +9 -3
  26. package/dist/solution/RegisterAndLogin/config.js +95 -40
  27. package/dist/solution/RegisterAndLogin/index.js +4 -1
  28. package/dist/solution/ScanOrder/index.d.ts +1 -0
  29. package/dist/solution/ScanOrder/index.js +31 -27
  30. package/dist/solution/ScanOrder/utils.d.ts +1 -0
  31. package/dist/solution/ScanOrder/utils.js +2 -0
  32. package/dist/solution/UnifiedBookingSales/index.d.ts +15 -2
  33. package/dist/solution/UnifiedBookingSales/index.js +751 -483
  34. package/dist/solution/UnifiedBookingSales/types.d.ts +14 -1
  35. package/dist/solution/VenueBooking/index.d.ts +1 -0
  36. package/dist/solution/VenueBooking/index.js +8 -4
  37. package/lib/model/strategy/adapter/itemRule/adapter.d.ts +4 -1
  38. package/lib/model/strategy/adapter/itemRule/adapter.js +73 -4
  39. package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +8 -1
  40. package/lib/model/strategy/adapter/itemRule/evaluator.js +23 -1
  41. package/lib/model/strategy/adapter/itemRule/type.d.ts +44 -0
  42. package/lib/model/strategy/adapter/itemRule/type.js +19 -1
  43. package/lib/modules/Order/index.d.ts +18 -3
  44. package/lib/modules/Order/index.js +325 -28
  45. package/lib/modules/Order/salesNotes.d.ts +31 -0
  46. package/lib/modules/Order/salesNotes.js +382 -0
  47. package/lib/modules/Order/types.d.ts +91 -5
  48. package/lib/modules/Order/types.js +4 -0
  49. package/lib/modules/Order/utils.d.ts +12 -0
  50. package/lib/modules/Order/utils.js +68 -16
  51. package/lib/modules/ProductList/index.d.ts +2 -1
  52. package/lib/modules/ProductList/index.js +47 -2
  53. package/lib/modules/ProductList/types.d.ts +10 -0
  54. package/lib/server/index.d.ts +6 -0
  55. package/lib/server/index.js +37 -3
  56. package/lib/solution/BaseSales/index.d.ts +9 -1
  57. package/lib/solution/BaseSales/index.js +105 -1
  58. package/lib/solution/BookingByStep/index.d.ts +2 -2
  59. package/lib/solution/BookingTicket/utils/orderCustomer.js +2 -1
  60. package/lib/solution/RegisterAndLogin/config.d.ts +9 -3
  61. package/lib/solution/RegisterAndLogin/config.js +49 -8
  62. package/lib/solution/RegisterAndLogin/index.js +4 -1
  63. package/lib/solution/ScanOrder/index.d.ts +1 -0
  64. package/lib/solution/ScanOrder/index.js +5 -1
  65. package/lib/solution/ScanOrder/utils.d.ts +1 -0
  66. package/lib/solution/ScanOrder/utils.js +1 -0
  67. package/lib/solution/UnifiedBookingSales/index.d.ts +15 -2
  68. package/lib/solution/UnifiedBookingSales/index.js +125 -1
  69. package/lib/solution/UnifiedBookingSales/types.d.ts +14 -1
  70. package/lib/solution/VenueBooking/index.d.ts +1 -0
  71. package/lib/solution/VenueBooking/index.js +5 -1
  72. package/package.json +1 -1
@@ -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 } from './type';
3
+ import { type ItemRuleBusinessData, type QuantityCheckResult, type PrefillItemResult, type QuantityLimitResult, type AllergyRequirement } from './type';
4
4
  /**
5
5
  * ItemRule 适配器
6
6
  *
@@ -14,7 +14,10 @@ export declare class ItemRuleAdapter implements BusinessAdapter {
14
14
  transformResult(result: EvaluationResult, businessData?: ItemRuleBusinessData): {
15
15
  quantityChecks: QuantityCheckResult[];
16
16
  prefillItems: PrefillItemResult[];
17
+ allergyRequirements: AllergyRequirement[];
17
18
  };
19
+ private processAllergyCheck;
20
+ private normalizeAllergyDataSourceItems;
18
21
  formatConfig(result: EvaluationResult, businessData?: ItemRuleBusinessData): {
19
22
  result: EvaluationResult;
20
23
  businessData?: ItemRuleBusinessData;
@@ -1,4 +1,8 @@
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; }
2
6
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
7
  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."); }
4
8
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
@@ -31,18 +35,22 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
31
35
  _createClass(ItemRuleAdapter, [{
32
36
  key: "prepareContext",
33
37
  value: function prepareContext(businessData) {
38
+ var _ref;
34
39
  var pax = businessData.pax,
35
40
  cartItems = businessData.cartItems,
36
41
  serviceType = businessData.serviceType,
42
+ channel = businessData.channel,
37
43
  submissionIndex = businessData.submissionIndex,
38
44
  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();
39
46
  return {
40
47
  entities: {
41
48
  cartItems: cartItems,
42
49
  historicalItems: businessData.historicalItems || [],
43
- pax: pax
50
+ pax: pax,
51
+ currentProduct: businessData.currentProduct
44
52
  },
45
- attributes: _objectSpread({
53
+ attributes: _objectSpread(_objectSpread({
46
54
  serviceType: serviceType || '',
47
55
  totalPax: pax.total,
48
56
  adultPax: pax.adult,
@@ -52,7 +60,9 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
52
60
  cartTotalQuantity: cartItems.reduce(function (sum, item) {
53
61
  return sum + item.quantity;
54
62
  }, 0)
55
- }, custom),
63
+ }, custom), {}, {
64
+ channel: resolvedChannel
65
+ }),
56
66
  metadata: {
57
67
  timestamp: Date.now()
58
68
  }
@@ -63,10 +73,12 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
63
73
  value: function transformResult(result, businessData) {
64
74
  var quantityChecks = [];
65
75
  var prefillItems = [];
76
+ var allergyRequirements = [];
66
77
  if (!result.applicable || !businessData) {
67
78
  return {
68
79
  quantityChecks: quantityChecks,
69
- prefillItems: prefillItems
80
+ prefillItems: prefillItems,
81
+ allergyRequirements: allergyRequirements
70
82
  };
71
83
  }
72
84
  var _iterator = _createForOfIteratorHelper(result.matchedActions),
@@ -82,6 +94,9 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
82
94
  } else if (action.type === ITEM_RULE_ACTION_TYPES.PREFILL_CART) {
83
95
  var items = this.processPrefillCart(action, businessData);
84
96
  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);
85
100
  }
86
101
  }
87
102
  } catch (err) {
@@ -91,9 +106,94 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
91
106
  }
92
107
  return {
93
108
  quantityChecks: quantityChecks,
94
- prefillItems: prefillItems
109
+ prefillItems: prefillItems,
110
+ allergyRequirements: allergyRequirements
95
111
  };
96
112
  }
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
+ }
97
197
  }, {
98
198
  key: "formatConfig",
99
199
  value: function formatConfig(result, businessData) {
@@ -178,19 +278,19 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
178
278
  }));
179
279
  var quantity = 0;
180
280
  var countFromItems = function countFromItems(items) {
181
- var _iterator2 = _createForOfIteratorHelper(items),
182
- _step2;
281
+ var _iterator3 = _createForOfIteratorHelper(items),
282
+ _step3;
183
283
  try {
184
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
185
- var item = _step2.value;
284
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
285
+ var item = _step3.value;
186
286
  if (targetIds.has(item.product_id)) {
187
287
  quantity += item.quantity;
188
288
  }
189
289
  }
190
290
  } catch (err) {
191
- _iterator2.e(err);
291
+ _iterator3.e(err);
192
292
  } finally {
193
- _iterator2.f();
293
+ _iterator3.f();
194
294
  }
195
295
  };
196
296
  if (scope === 'cumulative') {
@@ -214,11 +314,11 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
214
314
  var requiredMax;
215
315
  var requiredExact;
216
316
  var mustInclude;
217
- var _iterator3 = _createForOfIteratorHelper(rules),
218
- _step3;
317
+ var _iterator4 = _createForOfIteratorHelper(rules),
318
+ _step4;
219
319
  try {
220
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
221
- var rule = _step3.value;
320
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
321
+ var rule = _step4.value;
222
322
  var resolvedValue = this.resolveQuantityValue(rule, businessData);
223
323
  switch (rule.comparison) {
224
324
  case 'minimum':
@@ -260,9 +360,9 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
260
360
  }
261
361
  }
262
362
  } catch (err) {
263
- _iterator3.e(err);
363
+ _iterator4.e(err);
264
364
  } finally {
265
- _iterator3.f();
365
+ _iterator4.f();
266
366
  }
267
367
  return {
268
368
  passed: failedRules.length === 0,
@@ -336,11 +436,11 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
336
436
  var requiredMax;
337
437
  var requiredExact;
338
438
  var mustInclude;
339
- var _iterator4 = _createForOfIteratorHelper(quantityRules),
340
- _step4;
439
+ var _iterator5 = _createForOfIteratorHelper(quantityRules),
440
+ _step5;
341
441
  try {
342
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
343
- var rule = _step4.value;
442
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
443
+ var rule = _step5.value;
344
444
  var resolvedValue = this.resolveQuantityValue(rule, businessData);
345
445
  switch (rule.comparison) {
346
446
  case 'minimum':
@@ -370,9 +470,9 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
370
470
  }
371
471
  }
372
472
  } catch (err) {
373
- _iterator4.e(err);
473
+ _iterator5.e(err);
374
474
  } finally {
375
- _iterator4.f();
475
+ _iterator5.f();
376
476
  }
377
477
  var remainingMax = this.calculateRemainingMax(scope, requiredMax, targets, businessData);
378
478
  var formattedValidationMessage = this.formatValidationMessage(validationMessage, requiredMin, requiredMax, requiredExact);
@@ -412,19 +512,19 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
412
512
  return t.product_id;
413
513
  }));
414
514
  var historicalQty = 0;
415
- var _iterator5 = _createForOfIteratorHelper(historicalItems),
416
- _step5;
515
+ var _iterator6 = _createForOfIteratorHelper(historicalItems),
516
+ _step6;
417
517
  try {
418
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
419
- var item = _step5.value;
518
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
519
+ var item = _step6.value;
420
520
  if (targetIds.has(item.product_id)) {
421
521
  historicalQty += item.quantity;
422
522
  }
423
523
  }
424
524
  } catch (err) {
425
- _iterator5.e(err);
525
+ _iterator6.e(err);
426
526
  } finally {
427
- _iterator5.f();
527
+ _iterator6.f();
428
528
  }
429
529
  return Math.max(0, requiredMax - historicalQty);
430
530
  }
@@ -438,11 +538,11 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
438
538
  var config = action.config;
439
539
  if (!(config !== null && config !== void 0 && config.products)) return [];
440
540
  var results = [];
441
- var _iterator6 = _createForOfIteratorHelper(config.products),
442
- _step6;
541
+ var _iterator7 = _createForOfIteratorHelper(config.products),
542
+ _step7;
443
543
  try {
444
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
445
- var prefillProduct = _step6.value;
544
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
545
+ var prefillProduct = _step7.value;
446
546
  var quantity = this.resolvePrefillQuantity(prefillProduct.quantityFrom, prefillProduct.quantity, businessData);
447
547
  if (quantity <= 0) continue;
448
548
  results.push({
@@ -453,9 +553,9 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
453
553
  });
454
554
  }
455
555
  } catch (err) {
456
- _iterator6.e(err);
556
+ _iterator7.e(err);
457
557
  } finally {
458
- _iterator6.f();
558
+ _iterator7.f();
459
559
  }
460
560
  return results;
461
561
  }
@@ -1,5 +1,5 @@
1
1
  import type { StrategyConfig } from '../../type';
2
- import { type ItemRuleBusinessData, type ItemRuleEvaluationResult, type QuantityCheckResult, type QuantityLimitResult, type PrefillItemResult } from './type';
2
+ import { type ItemRuleBusinessData, type ItemRuleEvaluationResult, type QuantityCheckResult, type QuantityLimitResult, type PrefillItemResult, type AllergyRequirement } from './type';
3
3
  /**
4
4
  * ItemRule 评估器
5
5
  *
@@ -21,6 +21,13 @@ 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;
24
31
  /**
25
32
  * 获取当前配置中各商品的数量限制
26
33
  *
@@ -63,6 +63,7 @@ export var ItemRuleEvaluator = /*#__PURE__*/function () {
63
63
  }) : this.strategyConfigs;
64
64
  var allQuantityChecks = [];
65
65
  var allPrefillItems = [];
66
+ var allAllergyRequirements = [];
66
67
  var rawResults = [];
67
68
  var context = this.adapter.prepareContext(businessData);
68
69
  var _iterator = _createForOfIteratorHelper(configs),
@@ -74,9 +75,11 @@ export var ItemRuleEvaluator = /*#__PURE__*/function () {
74
75
  rawResults.push(evalResult);
75
76
  var _this$adapter$transfo = this.adapter.transformResult(evalResult, businessData),
76
77
  quantityChecks = _this$adapter$transfo.quantityChecks,
77
- prefillItems = _this$adapter$transfo.prefillItems;
78
+ prefillItems = _this$adapter$transfo.prefillItems,
79
+ allergyRequirements = _this$adapter$transfo.allergyRequirements;
78
80
  allQuantityChecks.push.apply(allQuantityChecks, _toConsumableArray(quantityChecks));
79
81
  allPrefillItems.push.apply(allPrefillItems, _toConsumableArray(prefillItems));
82
+ allAllergyRequirements.push.apply(allAllergyRequirements, _toConsumableArray(allergyRequirements));
80
83
  }
81
84
  } catch (err) {
82
85
  _iterator.e(err);
@@ -89,12 +92,33 @@ export var ItemRuleEvaluator = /*#__PURE__*/function () {
89
92
  return {
90
93
  quantityChecks: allQuantityChecks,
91
94
  prefillItems: allPrefillItems,
95
+ allergyRequirements: allAllergyRequirements,
92
96
  allPassed: failedChecks.length === 0,
93
97
  failedChecks: failedChecks,
94
98
  rawResults: rawResults
95
99
  };
96
100
  }
97
101
 
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
+
98
122
  /**
99
123
  * 获取当前配置中各商品的数量限制
100
124
  *
@@ -4,6 +4,8 @@ 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";
7
9
  };
8
10
  export type ItemRuleActionType = (typeof ITEM_RULE_ACTION_TYPES)[keyof typeof ITEM_RULE_ACTION_TYPES];
9
11
  export declare const ITEM_RULE_TEMPLATES: {
@@ -63,6 +65,42 @@ export interface TargetItem {
63
65
  /** 变体 ID */
64
66
  product_variant_id?: number;
65
67
  }
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
+ }
66
104
  /**
67
105
  * 预填商品项
68
106
  */
@@ -119,6 +157,10 @@ export interface ItemRuleBusinessData {
119
157
  historicalItems?: CartItemSummary[];
120
158
  /** 服务类型(如 'dine-in', 'takeaway') */
121
159
  serviceType?: string;
160
+ /** 当前业务渠道(如 'kiosk', 'pos', 'online_store') */
161
+ channel?: string;
162
+ /** 当前正在加入购物车的商品;ALLERGY_CHECK 只读取该商品的 Target。 */
163
+ currentProduct?: Pick<TargetItem, 'product_id' | 'product_variant_id'>;
122
164
  /** 当前提交次数(0=首次提交, >0=追加提交) */
123
165
  submissionIndex?: number;
124
166
  /** 策略配置列表(可选,如果不传则使用 setStrategyConfigs 设置的) */
@@ -216,6 +258,8 @@ export interface ItemRuleEvaluationResult {
216
258
  quantityChecks: QuantityCheckResult[];
217
259
  /** 需要预填的商品列表 */
218
260
  prefillItems: PrefillItemResult[];
261
+ /** 当前商品命中的过敏门禁要求;不同 Action/商品不会合并。 */
262
+ allergyRequirements: AllergyRequirement[];
219
263
  /** 所有校验是否全部通过 */
220
264
  allPassed: boolean;
221
265
  /** 未通过的校验列表 */
@@ -6,7 +6,9 @@ export var ITEM_RULE_ACTION_TYPES = {
6
6
  /** 数量校验 */
7
7
  QUANTITY_CHECK: 'QUANTITY_CHECK',
8
8
  /** 预填购物车 */
9
- PREFILL_CART: 'PREFILL_CART'
9
+ PREFILL_CART: 'PREFILL_CART',
10
+ /** 加购前过敏信息确认 */
11
+ ALLERGY_CHECK: 'ALLERGY_CHECK'
10
12
  };
11
13
  // ============================================
12
14
  // Rule Template 类型(创建规则时的起始模板)
@@ -50,6 +52,22 @@ export var ITEM_RULE_TEMPLATES = {
50
52
 
51
53
  /** 目标项 */
52
54
 
55
+ // ============================================
56
+ // Allergy Check 相关类型
57
+ // ============================================
58
+
59
+ /** 策略展示文案,可由调用方按当前 locale 解析。 */
60
+
61
+ /** 内联过敏源选项。稳定 id 用于保存选择,label 只负责展示。 */
62
+
63
+ /** 当前仅支持随策略下发的内联过敏源。 */
64
+
65
+ /** 每个目标商品独立持有自己的过敏源,禁止跨商品合并。 */
66
+
67
+ /** ALLERGY_CHECK Action 的商品级配置。 */
68
+
69
+ /** 当前商品命中的单条过敏门禁要求。 */
70
+
53
71
  // ============================================
54
72
  // Prefill Cart 相关类型
55
73
  // ============================================
@@ -0,0 +1,9 @@
1
+ // 导出评估器
2
+ export { PromotionEvaluator } from "./evaluator";
3
+
4
+ // 导出适配器
5
+ export { PromotionAdapter } from "./adapter";
6
+ export { default } from "./adapter";
7
+
8
+ // 导出策略配置示例常量
9
+ export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY, ITEM_REWARD_STRATEGY } from "./examples";
@@ -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 } from './types';
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, SalesNote, SalesNotesMutationSnapshot, SetSalesNoteInput, PickupReferenceMode, ShopServiceData, ShopServiceType } 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';
@@ -299,9 +299,24 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
299
299
  updateTempOrderNote(note: string, sync: boolean): string | Promise<string>;
300
300
  syncTempOrderNoteToRemote(orderId: number | string, note: string): Promise<string>;
301
301
  getTempOrderNote(): string;
302
+ private ensureSalesNotesRuntimeState;
303
+ private ensureSalesNotesLoadedForMutation;
304
+ private normalizeSalesNoteUuid;
305
+ private getSalesNotePrimaryRelation;
306
+ private removeSalesNotesForMissingProductLines;
307
+ private setSalesNoteOnTempOrder;
308
+ getSalesNotes(): SalesNote[];
309
+ createSalesNotesMutationSnapshot(): SalesNotesMutationSnapshot;
310
+ restoreSalesNotesMutationSnapshot(snapshot: SalesNotesMutationSnapshot): void;
311
+ setSalesNote(input: SetSalesNoteInput): Promise<SalesNote>;
312
+ removeSalesNote(uuid: string): Promise<void>;
313
+ clearSalesNotes(): Promise<void>;
302
314
  updateTempOrderShopDiscount(amount: string | number): string;
303
315
  updateTempOrderDepositAmount(amount: string | number): OrderSummary;
304
316
  updateTempOrderBuzzer(buzzer: string): string;
317
+ private updateTempOrderShopServiceData;
318
+ updateTempOrderPickupReferenceMode(mode: PickupReferenceMode): ShopServiceData;
319
+ updateTempOrderServiceType(serviceType: ShopServiceType): ShopServiceData;
305
320
  updateTempOrderContactsInfo(contactsInfo: Record<string, any> | null): Record<string, any> | null;
306
321
  private buildTempOrderCustomer;
307
322
  private isCustomerBoundDiscount;
@@ -452,7 +467,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
452
467
  removeProductFromOrder(identity: OrderProductIdentity, options?: RemoveProductsFromOrderOptions): Promise<OrderProduct[]>;
453
468
  /**
454
469
  * 仅清空购物车行(products / bookings),不重置整单。
455
- * 用于「仅清空商品」;客户、备注、支付等协议字段保持不变。
470
+ * 普通整单 note 保持不变;以商品行为主体的 Sales Notes 同步删除。
456
471
  */
457
472
  clearOrderCartLines(): Promise<OrderTempOrder>;
458
473
  buildCurrentSubmitPayloadForLocalPrint(params?: {
@@ -589,4 +604,4 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
589
604
  getOrderInfo(order_id: number): Promise<any>;
590
605
  getVouchers(): any[];
591
606
  }
592
- export type { AddProductToOrderOptions, RemoveProductsFromOrderOptions, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, } from './types';
607
+ export type { AddProductToOrderOptions, RemoveProductsFromOrderOptions, SalesNote, SalesNoteDraftInput, SalesNoteLocalizedSelection, SalesNoteLocalizedText, SalesNoteRelation, SalesNoteTextInput, SetSalesNoteInput, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, } from './types';