@pisell/pisellos 2.2.261 → 2.2.263

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 (134) hide show
  1. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
  2. package/dist/model/strategy/adapter/dataVariant/adapter.js +167 -0
  3. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
  4. package/dist/model/strategy/adapter/dataVariant/evaluator.js +780 -0
  5. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  6. package/dist/model/strategy/adapter/dataVariant/examples.js +277 -0
  7. package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  8. package/dist/model/strategy/adapter/dataVariant/index.js +4 -0
  9. package/dist/model/strategy/adapter/dataVariant/type.d.ts +148 -0
  10. package/dist/model/strategy/adapter/dataVariant/type.js +54 -0
  11. package/dist/model/strategy/adapter/index.d.ts +4 -0
  12. package/dist/model/strategy/adapter/index.js +5 -1
  13. package/dist/model/strategy/adapter/promotion/adapter.d.ts +0 -4
  14. package/dist/model/strategy/adapter/promotion/adapter.js +0 -23
  15. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
  16. package/dist/model/strategy/adapter/promotion/evaluator.js +6 -279
  17. package/dist/model/strategy/adapter/promotion/examples.d.ts +0 -86
  18. package/dist/model/strategy/adapter/promotion/examples.js +0 -99
  19. package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
  20. package/dist/model/strategy/adapter/promotion/index.js +1 -1
  21. package/dist/model/strategy/adapter/promotion/type.d.ts +2 -90
  22. package/dist/model/strategy/adapter/promotion/type.js +0 -45
  23. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +16 -10
  24. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
  25. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
  26. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +32 -1
  27. package/dist/modules/Discount/index.d.ts +5 -2
  28. package/dist/modules/Discount/index.js +30 -7
  29. package/dist/modules/Discount/types.d.ts +4 -0
  30. package/dist/modules/Order/index.d.ts +14 -2
  31. package/dist/modules/Order/index.js +1035 -736
  32. package/dist/modules/Order/types.d.ts +16 -0
  33. package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
  34. package/dist/modules/Order/utils/orderCollectionIdentity.js +405 -0
  35. package/dist/modules/Order/utils.d.ts +4 -3
  36. package/dist/modules/Order/utils.js +54 -61
  37. package/dist/modules/Product/types.d.ts +22 -0
  38. package/dist/modules/ProductList/index.d.ts +1 -1
  39. package/dist/modules/ProductList/index.js +4 -2
  40. package/dist/modules/ProductList/types.d.ts +2 -0
  41. package/dist/modules/Rules/index.d.ts +2 -9
  42. package/dist/modules/Rules/index.js +69 -43
  43. package/dist/modules/Rules/types.d.ts +10 -1
  44. package/dist/server/index.d.ts +55 -0
  45. package/dist/server/index.js +1173 -753
  46. package/dist/server/modules/order/index.d.ts +10 -4
  47. package/dist/server/modules/order/index.js +404 -399
  48. package/dist/server/modules/order/types.d.ts +4 -0
  49. package/dist/server/modules/products/index.d.ts +31 -8
  50. package/dist/server/modules/products/index.js +549 -390
  51. package/dist/server/modules/products/types.d.ts +18 -0
  52. package/dist/solution/BaseSales/index.d.ts +21 -1
  53. package/dist/solution/BaseSales/index.js +1136 -789
  54. package/dist/solution/BaseSales/types.d.ts +6 -1
  55. package/dist/solution/BaseSales/types.js +1 -1
  56. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
  57. package/dist/solution/BaseSales/utils/cartPromotion.js +48 -81
  58. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
  59. package/dist/solution/BaseSales/utils/parseSalesResponse.js +6 -8
  60. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +14 -1
  61. package/dist/solution/BookingByStep/index.d.ts +1 -1
  62. package/dist/solution/BookingTicket/index.d.ts +1 -1
  63. package/dist/solution/BookingTicket/index.js +59 -25
  64. package/dist/solution/BookingTicket/types.d.ts +2 -0
  65. package/dist/solution/ScanOrder/index.js +20 -31
  66. package/dist/solution/ShopDiscount/index.js +15 -14
  67. package/dist/solution/VenueBooking/index.js +19 -30
  68. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
  69. package/lib/model/strategy/adapter/dataVariant/adapter.js +149 -0
  70. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
  71. package/lib/model/strategy/adapter/dataVariant/evaluator.js +583 -0
  72. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  73. package/lib/model/strategy/adapter/dataVariant/examples.js +293 -0
  74. package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  75. package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
  76. package/lib/model/strategy/adapter/dataVariant/type.d.ts +148 -0
  77. package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
  78. package/lib/model/strategy/adapter/index.d.ts +4 -0
  79. package/lib/model/strategy/adapter/index.js +13 -2
  80. package/lib/model/strategy/adapter/promotion/adapter.d.ts +0 -4
  81. package/lib/model/strategy/adapter/promotion/adapter.js +0 -20
  82. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
  83. package/lib/model/strategy/adapter/promotion/evaluator.js +0 -235
  84. package/lib/model/strategy/adapter/promotion/examples.d.ts +0 -86
  85. package/lib/model/strategy/adapter/promotion/examples.js +0 -91
  86. package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
  87. package/lib/model/strategy/adapter/promotion/index.js +0 -51
  88. package/lib/model/strategy/adapter/promotion/type.d.ts +2 -90
  89. package/lib/model/strategy/adapter/promotion/type.js +0 -2
  90. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -0
  91. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -0
  92. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
  93. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +23 -2
  94. package/lib/modules/Discount/index.d.ts +5 -2
  95. package/lib/modules/Discount/index.js +23 -3
  96. package/lib/modules/Discount/types.d.ts +4 -0
  97. package/lib/modules/Order/index.d.ts +14 -2
  98. package/lib/modules/Order/index.js +326 -60
  99. package/lib/modules/Order/types.d.ts +16 -0
  100. package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
  101. package/lib/modules/Order/utils/orderCollectionIdentity.js +415 -0
  102. package/lib/modules/Order/utils.d.ts +4 -3
  103. package/lib/modules/Order/utils.js +22 -23
  104. package/lib/modules/Product/types.d.ts +22 -0
  105. package/lib/modules/ProductList/index.d.ts +1 -1
  106. package/lib/modules/ProductList/index.js +4 -2
  107. package/lib/modules/ProductList/types.d.ts +2 -0
  108. package/lib/modules/Rules/index.d.ts +2 -9
  109. package/lib/modules/Rules/index.js +61 -29
  110. package/lib/modules/Rules/types.d.ts +10 -1
  111. package/lib/server/index.d.ts +55 -0
  112. package/lib/server/index.js +332 -34
  113. package/lib/server/modules/order/index.d.ts +10 -4
  114. package/lib/server/modules/order/index.js +198 -139
  115. package/lib/server/modules/order/types.d.ts +4 -0
  116. package/lib/server/modules/products/index.d.ts +31 -8
  117. package/lib/server/modules/products/index.js +134 -35
  118. package/lib/server/modules/products/types.d.ts +18 -0
  119. package/lib/solution/BaseSales/index.d.ts +21 -1
  120. package/lib/solution/BaseSales/index.js +313 -72
  121. package/lib/solution/BaseSales/types.d.ts +6 -1
  122. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
  123. package/lib/solution/BaseSales/utils/cartPromotion.js +29 -60
  124. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
  125. package/lib/solution/BaseSales/utils/parseSalesResponse.js +4 -5
  126. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +8 -0
  127. package/lib/solution/BookingByStep/index.d.ts +1 -1
  128. package/lib/solution/BookingTicket/index.d.ts +1 -1
  129. package/lib/solution/BookingTicket/index.js +33 -8
  130. package/lib/solution/BookingTicket/types.d.ts +2 -0
  131. package/lib/solution/ScanOrder/index.js +0 -8
  132. package/lib/solution/ShopDiscount/index.js +2 -1
  133. package/lib/solution/VenueBooking/index.js +0 -8
  134. package/package.json +1 -1
@@ -1,8 +1,8 @@
1
1
  var _excluded = ["id"],
2
2
  _excluded2 = ["product_id"],
3
3
  _excluded3 = ["product_id"];
4
- 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; } } }; }
5
4
  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); }
5
+ 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; } } }; }
6
6
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
7
7
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
8
8
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
@@ -549,7 +549,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
549
549
  key: "scanPromotionCode",
550
550
  value: function () {
551
551
  var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(code, customerId) {
552
- var raw;
552
+ var raw, scannedList, extractedCustomerId, hasOrderCustomer, tempOrder;
553
553
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
554
554
  while (1) switch (_context7.prev = _context7.next) {
555
555
  case 0:
@@ -563,26 +563,42 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
563
563
  return this.store.order.scanCode(code, customerId);
564
564
  case 4:
565
565
  raw = _context7.sent;
566
- if (!raw.isAvailable) {
566
+ scannedList = raw.scannedDiscountList || [];
567
+ extractedCustomerId = this.getDiscountCustomerId(scannedList);
568
+ hasOrderCustomer = Boolean(this.store.order.getOrderCustomer()); // 缺 Holder 等场景 isAvailable=false,但仍需把 Pass 归属客户带入订单,供 Holder 弹窗使用。
569
+ if (!(!hasOrderCustomer && extractedCustomerId)) {
567
570
  _context7.next = 11;
568
571
  break;
569
572
  }
570
- _context7.next = 8;
571
- return this.hydrateOrderCustomerFromScanDiscounts(raw.scannedDiscountList || []);
572
- case 8:
573
- _context7.next = 10;
573
+ _context7.next = 11;
574
+ return this.hydrateOrderCustomerFromScanDiscounts(scannedList);
575
+ case 11:
576
+ if (!raw.isAvailable) {
577
+ _context7.next = 18;
578
+ break;
579
+ }
580
+ _context7.next = 14;
574
581
  return this.store.order.recalculateSummary({
575
582
  createIfMissing: true
576
583
  });
577
- case 10:
584
+ case 14:
578
585
  this.store.order.persistTempOrder();
579
- case 11:
586
+ tempOrder = this.store.order.ensureTempOrder();
587
+ _context7.next = 18;
588
+ return this.effectsEmit('onDiscountApplied', {
589
+ productList: tempOrder.products || [],
590
+ discountList: this.store.order.getDiscountList(),
591
+ selectedDiscountList: tempOrder.discount_list || [],
592
+ tempOrder: tempOrder
593
+ });
594
+ case 18:
580
595
  return _context7.abrupt("return", {
581
596
  isAvailable: raw.isAvailable,
582
597
  type: raw.type,
583
- unavailableReason: raw.unavailableReason
598
+ unavailableReason: raw.unavailableReason,
599
+ scannedDiscountList: raw.scannedDiscountList
584
600
  });
585
- case 12:
601
+ case 19:
586
602
  case "end":
587
603
  return _context7.stop();
588
604
  }
@@ -641,12 +657,22 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
641
657
  }, {
642
658
  key: "getDiscountCustomerId",
643
659
  value: function getDiscountCustomerId(discounts) {
644
- var discount = discounts.find(function (item) {
645
- return item.customer_id != null;
646
- });
647
- var customerId = Number(discount === null || discount === void 0 ? void 0 : discount.customer_id);
648
- if (!Number.isFinite(customerId) || customerId <= 0) return null;
649
- return customerId;
660
+ var _iterator = _createForOfIteratorHelper(discounts),
661
+ _step;
662
+ try {
663
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
664
+ var item = _step.value;
665
+ var topLevelId = Number(item.customer_id);
666
+ if (Number.isFinite(topLevelId) && topLevelId > 0) {
667
+ return topLevelId;
668
+ }
669
+ }
670
+ } catch (err) {
671
+ _iterator.e(err);
672
+ } finally {
673
+ _iterator.f();
674
+ }
675
+ return null;
650
676
  }
651
677
  }, {
652
678
  key: "resolveCustomerByDiscountCustomerId",
@@ -1501,7 +1527,15 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1501
1527
  void this.store.order.recalculateSummary({
1502
1528
  createIfMissing: true
1503
1529
  }).then(function () {
1504
- return _this3.store.order.persistTempOrder();
1530
+ var _discountModule$getDi;
1531
+ var tempOrder = _this3.store.order.ensureTempOrder();
1532
+ _this3.store.order.persistTempOrder();
1533
+ return _this3.effectsEmit('onDiscountApplied', {
1534
+ productList: tempOrder.products || [],
1535
+ discountList: (discountModule === null || discountModule === void 0 || (_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [],
1536
+ selectedDiscountList: tempOrder.discount_list || [],
1537
+ tempOrder: tempOrder
1538
+ });
1505
1539
  }).catch(function (error) {
1506
1540
  console.error('Failed to recalculate summary after clearing customer:', error);
1507
1541
  });
@@ -2468,7 +2502,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2468
2502
  var _addAddTimeProductsToBooking = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(input) {
2469
2503
  var _this7 = this,
2470
2504
  _input$bookingPatch;
2471
- var bookingUid, orderLines, coveredMinutes, bookingTimePatch, result, _iterator, _step, line;
2505
+ var bookingUid, orderLines, coveredMinutes, bookingTimePatch, result, _iterator2, _step2, line;
2472
2506
  return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2473
2507
  while (1) switch (_context30.prev = _context30.next) {
2474
2508
  case 0:
@@ -2508,15 +2542,15 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2508
2542
  }));
2509
2543
  case 11:
2510
2544
  result = [];
2511
- _iterator = _createForOfIteratorHelper(orderLines);
2545
+ _iterator2 = _createForOfIteratorHelper(orderLines);
2512
2546
  _context30.prev = 13;
2513
- _iterator.s();
2547
+ _iterator2.s();
2514
2548
  case 15:
2515
- if ((_step = _iterator.n()).done) {
2549
+ if ((_step2 = _iterator2.n()).done) {
2516
2550
  _context30.next = 29;
2517
2551
  break;
2518
2552
  }
2519
- line = _step.value;
2553
+ line = _step2.value;
2520
2554
  _context30.t0 = result.splice;
2521
2555
  _context30.t1 = result;
2522
2556
  _context30.t2 = [0, result.length];
@@ -2537,10 +2571,10 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2537
2571
  case 31:
2538
2572
  _context30.prev = 31;
2539
2573
  _context30.t7 = _context30["catch"](13);
2540
- _iterator.e(_context30.t7);
2574
+ _iterator2.e(_context30.t7);
2541
2575
  case 34:
2542
2576
  _context30.prev = 34;
2543
- _iterator.f();
2577
+ _iterator2.f();
2544
2578
  return _context30.finish(34);
2545
2579
  case 37:
2546
2580
  return _context30.abrupt("return", result);
@@ -83,6 +83,8 @@ export interface ILoadProductsParams {
83
83
  extension_type?: string[];
84
84
  /** 商品发布状态 */
85
85
  status?: string;
86
+ /** 智能定价条件上下文,仅影响策略命中,不参与商品集合筛选 */
87
+ strategy_context?: Record<string, any>;
86
88
  }
87
89
  /**
88
90
  * 加载商品详情的参数
@@ -41,10 +41,6 @@ import { composeLinePrice, createUuidV4, getProductSkuOptions, normalizeSubmitCo
41
41
  import dayjs from 'dayjs';
42
42
  import { ItemRuleEvaluator } from "../../model/strategy/adapter/itemRule";
43
43
  export * from "./types";
44
- function isItemRewardProductDiscount(discount) {
45
- var _discount$metadata, _discount$metadata2;
46
- return (discount === null || discount === void 0 ? void 0 : discount.type) === 'product' && (discount === null || discount === void 0 || (_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.source) === 'promotion' && (discount === null || discount === void 0 || (_discount$metadata2 = discount.metadata) === null || _discount$metadata2 === void 0 ? void 0 : _discount$metadata2.actionType) === 'ITEM_REWARD';
47
- }
48
44
  export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
49
45
  _inherits(ScanOrderImpl, _BaseModule);
50
46
  var _super = _createSuper(ScanOrderImpl);
@@ -1181,7 +1177,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1181
1177
  _iterator3.s();
1182
1178
  case 19:
1183
1179
  if ((_step3 = _iterator3.n()).done) {
1184
- _context15.next = 36;
1180
+ _context15.next = 33;
1185
1181
  break;
1186
1182
  }
1187
1183
  product = _step3.value;
@@ -1189,15 +1185,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1189
1185
  _context15.next = 23;
1190
1186
  break;
1191
1187
  }
1192
- return _context15.abrupt("continue", 34);
1188
+ return _context15.abrupt("continue", 31);
1193
1189
  case 23:
1194
- if (!(product.discount_list || []).some(isItemRewardProductDiscount)) {
1195
- _context15.next = 26;
1196
- break;
1197
- }
1198
- product.discount_list = (product.discount_list || []).filter(isItemRewardProductDiscount);
1199
- return _context15.abrupt("continue", 34);
1200
- case 26:
1201
1190
  product.discount_list = (product.discount_list || []).filter(function (pd) {
1202
1191
  var _pd$discount$resource, _pd$discount;
1203
1192
  var rid = (_pd$discount$resource = (_pd$discount = pd.discount) === null || _pd$discount === void 0 ? void 0 : _pd$discount.resource_id) !== null && _pd$discount$resource !== void 0 ? _pd$discount$resource : pd.id;
@@ -1221,47 +1210,47 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1221
1210
  mainPrice: newMainSellingPrice,
1222
1211
  bundle: product.product_bundle
1223
1212
  });
1224
- case 34:
1213
+ case 31:
1225
1214
  _context15.next = 19;
1226
1215
  break;
1227
- case 36:
1228
- _context15.next = 41;
1216
+ case 33:
1217
+ _context15.next = 38;
1229
1218
  break;
1230
- case 38:
1231
- _context15.prev = 38;
1219
+ case 35:
1220
+ _context15.prev = 35;
1232
1221
  _context15.t0 = _context15["catch"](17);
1233
1222
  _iterator3.e(_context15.t0);
1234
- case 41:
1235
- _context15.prev = 41;
1223
+ case 38:
1224
+ _context15.prev = 38;
1236
1225
  _iterator3.f();
1237
- return _context15.finish(41);
1238
- case 44:
1226
+ return _context15.finish(38);
1227
+ case 41:
1239
1228
  OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
1240
- _context15.next = 47;
1229
+ _context15.next = 44;
1241
1230
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
1242
- case 47:
1231
+ case 44:
1243
1232
  tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
1244
1233
  return d.isSelected;
1245
1234
  });
1246
- _context15.next = 50;
1235
+ _context15.next = 47;
1247
1236
  return this.store.order.recalculateSummary({
1248
1237
  createIfMissing: true
1249
1238
  });
1250
- case 50:
1239
+ case 47:
1251
1240
  this.store.order.persistTempOrder();
1252
1241
  this.logMethodSuccess('setDiscountSelected', params);
1253
- _context15.next = 58;
1242
+ _context15.next = 55;
1254
1243
  break;
1255
- case 54:
1256
- _context15.prev = 54;
1244
+ case 51:
1245
+ _context15.prev = 51;
1257
1246
  _context15.t1 = _context15["catch"](1);
1258
1247
  this.logMethodError('setDiscountSelected', _context15.t1);
1259
1248
  throw _context15.t1;
1260
- case 58:
1249
+ case 55:
1261
1250
  case "end":
1262
1251
  return _context15.stop();
1263
1252
  }
1264
- }, _callee15, this, [[1, 54], [17, 38, 41, 44]]);
1253
+ }, _callee15, this, [[1, 51], [17, 35, 38, 41]]);
1265
1254
  }));
1266
1255
  function setDiscountSelected(_x8) {
1267
1256
  return _setDiscountSelected.apply(this, arguments);
@@ -756,7 +756,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
756
756
  key: "loadPrepareConfig",
757
757
  value: function () {
758
758
  var _loadPrepareConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
759
- var _this$getCustomer2, _this$store$discount7, _this$getDiscountList, _this$store$discount8, _this$store$productLi2, orderId, customerId, goodPassList, scanDiscount, scanDiscountIds, newGoodPassList, newDiscountList, filteredDiscountList, _result3;
759
+ var _this$getCustomer2, _this$store$discount7, _this$getDiscountList, _this$store$discount8, _this$store$productLi2, orderId, customerId, prepareConfigResult, goodPassList, scanDiscount, scanDiscountIds, newGoodPassList, newDiscountList, filteredDiscountList, _result3;
760
760
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
761
761
  while (1) switch (_context9.prev = _context9.next) {
762
762
  case 0:
@@ -777,7 +777,8 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
777
777
  order_id: orderId
778
778
  } : {}));
779
779
  case 5:
780
- goodPassList = _context9.sent;
780
+ prepareConfigResult = _context9.sent;
781
+ goodPassList = (prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.discountList) || [];
781
782
  scanDiscount = (_this$getDiscountList = this.getDiscountList()) === null || _this$getDiscountList === void 0 ? void 0 : _this$getDiscountList.filter(function (item) {
782
783
  return item.isScan;
783
784
  }); // goodPassList 里可能有 scanDiscount 重合的部分,goodPassList 需要剔除
@@ -789,35 +790,35 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
789
790
  });
790
791
  newDiscountList = [].concat(_toConsumableArray(scanDiscount), _toConsumableArray(newGoodPassList || [])); // 存储原始优惠券列表
791
792
  this.store.originalDiscountList = newDiscountList;
792
- _context9.next = 13;
793
+ _context9.next = 14;
793
794
  return (_this$store$discount8 = this.store.discount) === null || _this$store$discount8 === void 0 ? void 0 : _this$store$discount8.setOriginalDiscountList(newDiscountList);
794
- case 13:
795
+ case 14:
795
796
  // 根据当前预约时间过滤优惠券列表
796
797
  filteredDiscountList = this.filterDiscountListByBookingTime(newDiscountList, this.store.currentBookingTime);
797
798
  this.store.filteredDiscountList = filteredDiscountList;
798
799
  this.setDiscountList(filteredDiscountList || []);
799
800
  if (!((_this$store$productLi2 = this.store.productList) !== null && _this$store$productLi2 !== void 0 && _this$store$productLi2.length)) {
800
- _context9.next = 20;
801
+ _context9.next = 21;
801
802
  break;
802
803
  }
803
804
  _result3 = this.calcDiscount(this.store.productList);
804
- _context9.next = 20;
805
+ _context9.next = 21;
805
806
  return this.core.effects.emit("".concat(this.name, ":onLoadPrepareCalcResult"), _result3);
806
- case 20:
807
- _context9.next = 22;
807
+ case 21:
808
+ _context9.next = 23;
808
809
  return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"), filteredDiscountList);
809
- case 22:
810
- _context9.next = 27;
810
+ case 23:
811
+ _context9.next = 28;
811
812
  break;
812
- case 24:
813
- _context9.prev = 24;
813
+ case 25:
814
+ _context9.prev = 25;
814
815
  _context9.t0 = _context9["catch"](0);
815
816
  console.error('[ShopDiscount] 加载准备配置出错:', _context9.t0);
816
- case 27:
817
+ case 28:
817
818
  case "end":
818
819
  return _context9.stop();
819
820
  }
820
- }, _callee9, this, [[0, 24]]);
821
+ }, _callee9, this, [[0, 25]]);
821
822
  }));
822
823
  function loadPrepareConfig(_x9) {
823
824
  return _loadPrepareConfig.apply(this, arguments);
@@ -51,10 +51,6 @@ import { RegisterAndLoginHooks } from "../RegisterAndLogin/types";
51
51
  import Decimal from 'decimal.js';
52
52
  export * from "./types";
53
53
  var OPEN_DATA_SECTION_CODES = ['basic', 'fulfillment', 'reservation', 'sale', 'menu', 'availability', 'workflow', 'checkout'];
54
- function isItemRewardProductDiscount(discount) {
55
- var _discount$metadata, _discount$metadata2;
56
- return (discount === null || discount === void 0 ? void 0 : discount.type) === 'product' && (discount === null || discount === void 0 || (_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.source) === 'promotion' && (discount === null || discount === void 0 || (_discount$metadata2 = discount.metadata) === null || _discount$metadata2 === void 0 ? void 0 : _discount$metadata2.actionType) === 'ITEM_REWARD';
57
- }
58
54
  function cloneCustomDepositData(customDepositData) {
59
55
  if (!customDepositData || _typeof(customDepositData) !== 'object') return undefined;
60
56
  return _objectSpread(_objectSpread({}, customDepositData), {}, {
@@ -2167,7 +2163,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2167
2163
  _iterator14.s();
2168
2164
  case 21:
2169
2165
  if ((_step14 = _iterator14.n()).done) {
2170
- _context21.next = 38;
2166
+ _context21.next = 35;
2171
2167
  break;
2172
2168
  }
2173
2169
  product = _step14.value;
@@ -2175,15 +2171,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2175
2171
  _context21.next = 25;
2176
2172
  break;
2177
2173
  }
2178
- return _context21.abrupt("continue", 36);
2174
+ return _context21.abrupt("continue", 33);
2179
2175
  case 25:
2180
- if (!(product.discount_list || []).some(isItemRewardProductDiscount)) {
2181
- _context21.next = 28;
2182
- break;
2183
- }
2184
- product.discount_list = (product.discount_list || []).filter(isItemRewardProductDiscount);
2185
- return _context21.abrupt("continue", 36);
2186
- case 28:
2187
2176
  // 1. 把 product.discount_list 和当前选中的 discount 对齐(剔除已取消的券)
2188
2177
  product.discount_list = (product.discount_list || []).filter(function (pd) {
2189
2178
  var _pd$discount$resource, _pd$discount;
@@ -2208,36 +2197,36 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2208
2197
  mainPrice: newMainSellingPrice,
2209
2198
  bundle: product.product_bundle
2210
2199
  });
2211
- case 36:
2200
+ case 33:
2212
2201
  _context21.next = 21;
2213
2202
  break;
2214
- case 38:
2215
- _context21.next = 43;
2203
+ case 35:
2204
+ _context21.next = 40;
2216
2205
  break;
2217
- case 40:
2218
- _context21.prev = 40;
2206
+ case 37:
2207
+ _context21.prev = 37;
2219
2208
  _context21.t0 = _context21["catch"](19);
2220
2209
  _iterator14.e(_context21.t0);
2221
- case 43:
2222
- _context21.prev = 43;
2210
+ case 40:
2211
+ _context21.prev = 40;
2223
2212
  _iterator14.f();
2224
- return _context21.finish(43);
2225
- case 46:
2213
+ return _context21.finish(40);
2214
+ case 43:
2226
2215
  OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
2227
- _context21.next = 49;
2216
+ _context21.next = 46;
2228
2217
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
2229
- case 49:
2218
+ case 46:
2230
2219
  tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
2231
2220
  return d.isSelected;
2232
2221
  });
2233
2222
  afterApplyTarget = this.store.order.getDiscountList().find(function (d) {
2234
2223
  return d.id === params.discountId;
2235
2224
  }) || null;
2236
- _context21.next = 53;
2225
+ _context21.next = 50;
2237
2226
  return this.store.order.recalculateSummary({
2238
2227
  createIfMissing: true
2239
2228
  });
2240
- case 53:
2229
+ case 50:
2241
2230
  this.store.order.persistTempOrder();
2242
2231
  finalSummary = ((_this$store$order$get = this.store.order.getTempOrder()) === null || _this$store$order$get === void 0 ? void 0 : _this$store$order$get.summary) || null;
2243
2232
  finalProduct = ((_this$store$order$get2 = this.store.order.getTempOrder()) === null || _this$store$order$get2 === void 0 || (_this$store$order$get2 = _this$store$order$get2.products) === null || _this$store$order$get2 === void 0 ? void 0 : _this$store$order$get2[0]) || null;
@@ -2246,16 +2235,16 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2246
2235
  return d.id === params.discountId;
2247
2236
  }) || null;
2248
2237
  return _context21.abrupt("return", this.store.order.getDiscountList());
2249
- case 61:
2250
- _context21.prev = 61;
2238
+ case 58:
2239
+ _context21.prev = 58;
2251
2240
  _context21.t1 = _context21["catch"](1);
2252
2241
  this.logMethodError('setDiscountSelected', _context21.t1);
2253
2242
  throw _context21.t1;
2254
- case 65:
2243
+ case 62:
2255
2244
  case "end":
2256
2245
  return _context21.stop();
2257
2246
  }
2258
- }, _callee21, this, [[1, 61], [19, 40, 43, 46]]);
2247
+ }, _callee21, this, [[1, 58], [19, 37, 40, 43]]);
2259
2248
  }));
2260
2249
  function setDiscountSelected(_x15) {
2261
2250
  return _setDiscountSelected.apply(this, arguments);
@@ -0,0 +1,50 @@
1
+ import type { EvaluationResult, RuntimeContext } from '../../type';
2
+ import type { BusinessAdapter } from '../type';
3
+ import type { DataVariantBusinessData, DataVariantProduct } from './type';
4
+ /**
5
+ * Data Variant 适配器。
6
+ *
7
+ * 负责把智能定价运行态数据转换为 StrategyEngine 能识别的 attributes。
8
+ */
9
+ export declare class DataVariantAdapter implements BusinessAdapter {
10
+ name: string;
11
+ version: string;
12
+ /**
13
+ * 准备批量全局上下文。
14
+ *
15
+ * 这里只放不依赖单个商品的字段,用于预计算 schedule/channel/orderType 等条件。
16
+ */
17
+ prepareContext(businessData: DataVariantBusinessData): RuntimeContext;
18
+ /**
19
+ * 准备全局预计算上下文。
20
+ */
21
+ prepareGlobalContext(businessData: DataVariantBusinessData): RuntimeContext;
22
+ /**
23
+ * 准备单商品上下文。
24
+ *
25
+ * 商品级条件只在当前商品 data_variants 引用到对应规则后才评估。
26
+ */
27
+ prepareProductContext(businessData: DataVariantBusinessData, product: DataVariantProduct): RuntimeContext;
28
+ transformResult(result: EvaluationResult): EvaluationResult;
29
+ formatConfig(result: EvaluationResult, businessData?: DataVariantBusinessData): {
30
+ result: EvaluationResult;
31
+ businessData?: DataVariantBusinessData;
32
+ };
33
+ /**
34
+ * 构建 menu_match 使用的轻量商品对象。
35
+ *
36
+ * collection_ids 来自商品 collection 字段,避免 operator 读取复杂商品对象。
37
+ */
38
+ buildProductValue(product: DataVariantProduct): {
39
+ id: number;
40
+ product_variant_id: number;
41
+ collection_ids: number[];
42
+ };
43
+ private toNumber;
44
+ /**
45
+ * 归一化客户 id:无效值返回 undefined,有效值统一为 number。
46
+ */
47
+ private normalizeCustomerId;
48
+ private normalizeNumberArray;
49
+ }
50
+ export default DataVariantAdapter;