@pisell/pisellos 2.2.263 → 2.2.264
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/index.d.ts +0 -4
- package/dist/model/strategy/adapter/index.js +1 -5
- package/dist/model/strategy/adapter/promotion/adapter.d.ts +4 -0
- package/dist/model/strategy/adapter/promotion/adapter.js +23 -0
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
- package/dist/model/strategy/adapter/promotion/evaluator.js +279 -6
- package/dist/model/strategy/adapter/promotion/examples.d.ts +86 -0
- package/dist/model/strategy/adapter/promotion/examples.js +99 -0
- package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/model/strategy/adapter/promotion/type.d.ts +90 -2
- package/dist/model/strategy/adapter/promotion/type.js +45 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +10 -16
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -2
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +1 -32
- package/dist/modules/Discount/index.d.ts +2 -5
- package/dist/modules/Discount/index.js +7 -30
- package/dist/modules/Discount/types.d.ts +0 -4
- package/dist/modules/Order/index.d.ts +2 -14
- package/dist/modules/Order/index.js +736 -1035
- package/dist/modules/Order/types.d.ts +0 -16
- package/dist/modules/Order/utils.d.ts +3 -4
- package/dist/modules/Order/utils.js +61 -54
- package/dist/modules/Product/types.d.ts +0 -22
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +2 -4
- package/dist/modules/ProductList/types.d.ts +0 -2
- package/dist/modules/Rules/index.d.ts +9 -2
- package/dist/modules/Rules/index.js +43 -69
- package/dist/modules/Rules/types.d.ts +1 -10
- package/dist/server/index.d.ts +0 -55
- package/dist/server/index.js +753 -1173
- package/dist/server/modules/order/index.d.ts +4 -10
- package/dist/server/modules/order/index.js +399 -404
- package/dist/server/modules/order/types.d.ts +0 -4
- package/dist/server/modules/products/index.d.ts +8 -31
- package/dist/server/modules/products/index.js +390 -549
- package/dist/server/modules/products/types.d.ts +0 -18
- package/dist/solution/BaseSales/index.d.ts +1 -21
- package/dist/solution/BaseSales/index.js +789 -1136
- package/dist/solution/BaseSales/types.d.ts +1 -6
- package/dist/solution/BaseSales/types.js +1 -1
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/dist/solution/BaseSales/utils/cartPromotion.js +97 -50
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +8 -6
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -14
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +25 -59
- package/dist/solution/BookingTicket/types.d.ts +0 -2
- package/dist/solution/ScanOrder/index.js +31 -20
- package/dist/solution/ShopDiscount/index.js +14 -15
- package/dist/solution/VenueBooking/index.js +30 -19
- package/lib/model/strategy/adapter/index.d.ts +0 -4
- package/lib/model/strategy/adapter/index.js +2 -13
- package/lib/model/strategy/adapter/promotion/adapter.d.ts +4 -0
- package/lib/model/strategy/adapter/promotion/adapter.js +20 -0
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
- package/lib/model/strategy/adapter/promotion/evaluator.js +235 -0
- package/lib/model/strategy/adapter/promotion/examples.d.ts +86 -0
- package/lib/model/strategy/adapter/promotion/examples.js +91 -0
- package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +51 -0
- package/lib/model/strategy/adapter/promotion/type.d.ts +90 -2
- package/lib/model/strategy/adapter/promotion/type.js +2 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -5
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -1
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +2 -23
- package/lib/modules/Discount/index.d.ts +2 -5
- package/lib/modules/Discount/index.js +3 -23
- package/lib/modules/Discount/types.d.ts +0 -4
- package/lib/modules/Order/index.d.ts +2 -14
- package/lib/modules/Order/index.js +60 -326
- package/lib/modules/Order/types.d.ts +0 -16
- package/lib/modules/Order/utils.d.ts +3 -4
- package/lib/modules/Order/utils.js +23 -22
- package/lib/modules/Product/types.d.ts +0 -22
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +2 -4
- package/lib/modules/ProductList/types.d.ts +0 -2
- package/lib/modules/Rules/index.d.ts +9 -2
- package/lib/modules/Rules/index.js +29 -61
- package/lib/modules/Rules/types.d.ts +1 -10
- package/lib/server/index.d.ts +0 -55
- package/lib/server/index.js +34 -332
- package/lib/server/modules/order/index.d.ts +4 -10
- package/lib/server/modules/order/index.js +139 -198
- package/lib/server/modules/order/types.d.ts +0 -4
- package/lib/server/modules/products/index.d.ts +8 -31
- package/lib/server/modules/products/index.js +35 -134
- package/lib/server/modules/products/types.d.ts +0 -18
- package/lib/solution/BaseSales/index.d.ts +1 -21
- package/lib/solution/BaseSales/index.js +72 -313
- package/lib/solution/BaseSales/types.d.ts +1 -6
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/lib/solution/BaseSales/utils/cartPromotion.js +64 -25
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +5 -4
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +0 -8
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +8 -33
- package/lib/solution/BookingTicket/types.d.ts +0 -2
- package/lib/solution/ScanOrder/index.js +8 -0
- package/lib/solution/ShopDiscount/index.js +1 -2
- package/lib/solution/VenueBooking/index.js +8 -0
- package/package.json +1 -1
- package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
- package/dist/model/strategy/adapter/dataVariant/adapter.js +0 -167
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +0 -780
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
- package/dist/model/strategy/adapter/dataVariant/examples.js +0 -277
- package/dist/model/strategy/adapter/dataVariant/index.d.ts +0 -4
- package/dist/model/strategy/adapter/dataVariant/index.js +0 -4
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +0 -148
- package/dist/model/strategy/adapter/dataVariant/type.js +0 -54
- package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +0 -53
- package/dist/modules/Order/utils/orderCollectionIdentity.js +0 -405
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
- package/lib/model/strategy/adapter/dataVariant/adapter.js +0 -149
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +0 -583
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
- package/lib/model/strategy/adapter/dataVariant/examples.js +0 -293
- package/lib/model/strategy/adapter/dataVariant/index.d.ts +0 -4
- package/lib/model/strategy/adapter/dataVariant/index.js +0 -38
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +0 -148
- package/lib/model/strategy/adapter/dataVariant/type.js +0 -31
- package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +0 -53
- package/lib/modules/Order/utils/orderCollectionIdentity.js +0 -415
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var _excluded = ["id"],
|
|
2
2
|
_excluded2 = ["product_id"],
|
|
3
3
|
_excluded3 = ["product_id"];
|
|
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
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
|
+
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); }
|
|
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;
|
|
553
553
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
554
554
|
while (1) switch (_context7.prev = _context7.next) {
|
|
555
555
|
case 0:
|
|
@@ -563,42 +563,26 @@ 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
|
-
scannedList = raw.scannedDiscountList || [];
|
|
567
|
-
extractedCustomerId = this.getDiscountCustomerId(scannedList);
|
|
568
|
-
hasOrderCustomer = Boolean(this.store.order.getOrderCustomer()); // 缺 Holder 等场景 isAvailable=false,但仍需把 Pass 归属客户带入订单,供 Holder 弹窗使用。
|
|
569
|
-
if (!(!hasOrderCustomer && extractedCustomerId)) {
|
|
570
|
-
_context7.next = 11;
|
|
571
|
-
break;
|
|
572
|
-
}
|
|
573
|
-
_context7.next = 11;
|
|
574
|
-
return this.hydrateOrderCustomerFromScanDiscounts(scannedList);
|
|
575
|
-
case 11:
|
|
576
566
|
if (!raw.isAvailable) {
|
|
577
|
-
_context7.next =
|
|
567
|
+
_context7.next = 11;
|
|
578
568
|
break;
|
|
579
569
|
}
|
|
580
|
-
_context7.next =
|
|
570
|
+
_context7.next = 8;
|
|
571
|
+
return this.hydrateOrderCustomerFromScanDiscounts(raw.scannedDiscountList || []);
|
|
572
|
+
case 8:
|
|
573
|
+
_context7.next = 10;
|
|
581
574
|
return this.store.order.recalculateSummary({
|
|
582
575
|
createIfMissing: true
|
|
583
576
|
});
|
|
584
|
-
case
|
|
577
|
+
case 10:
|
|
585
578
|
this.store.order.persistTempOrder();
|
|
586
|
-
|
|
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:
|
|
579
|
+
case 11:
|
|
595
580
|
return _context7.abrupt("return", {
|
|
596
581
|
isAvailable: raw.isAvailable,
|
|
597
582
|
type: raw.type,
|
|
598
|
-
unavailableReason: raw.unavailableReason
|
|
599
|
-
scannedDiscountList: raw.scannedDiscountList
|
|
583
|
+
unavailableReason: raw.unavailableReason
|
|
600
584
|
});
|
|
601
|
-
case
|
|
585
|
+
case 12:
|
|
602
586
|
case "end":
|
|
603
587
|
return _context7.stop();
|
|
604
588
|
}
|
|
@@ -657,22 +641,12 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
657
641
|
}, {
|
|
658
642
|
key: "getDiscountCustomerId",
|
|
659
643
|
value: function getDiscountCustomerId(discounts) {
|
|
660
|
-
var
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
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;
|
|
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;
|
|
676
650
|
}
|
|
677
651
|
}, {
|
|
678
652
|
key: "resolveCustomerByDiscountCustomerId",
|
|
@@ -1527,15 +1501,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1527
1501
|
void this.store.order.recalculateSummary({
|
|
1528
1502
|
createIfMissing: true
|
|
1529
1503
|
}).then(function () {
|
|
1530
|
-
|
|
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
|
-
});
|
|
1504
|
+
return _this3.store.order.persistTempOrder();
|
|
1539
1505
|
}).catch(function (error) {
|
|
1540
1506
|
console.error('Failed to recalculate summary after clearing customer:', error);
|
|
1541
1507
|
});
|
|
@@ -2502,7 +2468,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2502
2468
|
var _addAddTimeProductsToBooking = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(input) {
|
|
2503
2469
|
var _this7 = this,
|
|
2504
2470
|
_input$bookingPatch;
|
|
2505
|
-
var bookingUid, orderLines, coveredMinutes, bookingTimePatch, result,
|
|
2471
|
+
var bookingUid, orderLines, coveredMinutes, bookingTimePatch, result, _iterator, _step, line;
|
|
2506
2472
|
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2507
2473
|
while (1) switch (_context30.prev = _context30.next) {
|
|
2508
2474
|
case 0:
|
|
@@ -2542,15 +2508,15 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2542
2508
|
}));
|
|
2543
2509
|
case 11:
|
|
2544
2510
|
result = [];
|
|
2545
|
-
|
|
2511
|
+
_iterator = _createForOfIteratorHelper(orderLines);
|
|
2546
2512
|
_context30.prev = 13;
|
|
2547
|
-
|
|
2513
|
+
_iterator.s();
|
|
2548
2514
|
case 15:
|
|
2549
|
-
if ((
|
|
2515
|
+
if ((_step = _iterator.n()).done) {
|
|
2550
2516
|
_context30.next = 29;
|
|
2551
2517
|
break;
|
|
2552
2518
|
}
|
|
2553
|
-
line =
|
|
2519
|
+
line = _step.value;
|
|
2554
2520
|
_context30.t0 = result.splice;
|
|
2555
2521
|
_context30.t1 = result;
|
|
2556
2522
|
_context30.t2 = [0, result.length];
|
|
@@ -2571,10 +2537,10 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2571
2537
|
case 31:
|
|
2572
2538
|
_context30.prev = 31;
|
|
2573
2539
|
_context30.t7 = _context30["catch"](13);
|
|
2574
|
-
|
|
2540
|
+
_iterator.e(_context30.t7);
|
|
2575
2541
|
case 34:
|
|
2576
2542
|
_context30.prev = 34;
|
|
2577
|
-
|
|
2543
|
+
_iterator.f();
|
|
2578
2544
|
return _context30.finish(34);
|
|
2579
2545
|
case 37:
|
|
2580
2546
|
return _context30.abrupt("return", result);
|
|
@@ -41,6 +41,10 @@ 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
|
+
}
|
|
44
48
|
export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
45
49
|
_inherits(ScanOrderImpl, _BaseModule);
|
|
46
50
|
var _super = _createSuper(ScanOrderImpl);
|
|
@@ -1177,7 +1181,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1177
1181
|
_iterator3.s();
|
|
1178
1182
|
case 19:
|
|
1179
1183
|
if ((_step3 = _iterator3.n()).done) {
|
|
1180
|
-
_context15.next =
|
|
1184
|
+
_context15.next = 36;
|
|
1181
1185
|
break;
|
|
1182
1186
|
}
|
|
1183
1187
|
product = _step3.value;
|
|
@@ -1185,8 +1189,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1185
1189
|
_context15.next = 23;
|
|
1186
1190
|
break;
|
|
1187
1191
|
}
|
|
1188
|
-
return _context15.abrupt("continue",
|
|
1192
|
+
return _context15.abrupt("continue", 34);
|
|
1189
1193
|
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:
|
|
1190
1201
|
product.discount_list = (product.discount_list || []).filter(function (pd) {
|
|
1191
1202
|
var _pd$discount$resource, _pd$discount;
|
|
1192
1203
|
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;
|
|
@@ -1210,47 +1221,47 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1210
1221
|
mainPrice: newMainSellingPrice,
|
|
1211
1222
|
bundle: product.product_bundle
|
|
1212
1223
|
});
|
|
1213
|
-
case
|
|
1224
|
+
case 34:
|
|
1214
1225
|
_context15.next = 19;
|
|
1215
1226
|
break;
|
|
1216
|
-
case
|
|
1217
|
-
_context15.next =
|
|
1227
|
+
case 36:
|
|
1228
|
+
_context15.next = 41;
|
|
1218
1229
|
break;
|
|
1219
|
-
case 35:
|
|
1220
|
-
_context15.prev = 35;
|
|
1221
|
-
_context15.t0 = _context15["catch"](17);
|
|
1222
|
-
_iterator3.e(_context15.t0);
|
|
1223
1230
|
case 38:
|
|
1224
1231
|
_context15.prev = 38;
|
|
1225
|
-
|
|
1226
|
-
|
|
1232
|
+
_context15.t0 = _context15["catch"](17);
|
|
1233
|
+
_iterator3.e(_context15.t0);
|
|
1227
1234
|
case 41:
|
|
1235
|
+
_context15.prev = 41;
|
|
1236
|
+
_iterator3.f();
|
|
1237
|
+
return _context15.finish(41);
|
|
1238
|
+
case 44:
|
|
1228
1239
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
1229
|
-
_context15.next =
|
|
1240
|
+
_context15.next = 47;
|
|
1230
1241
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1231
|
-
case
|
|
1242
|
+
case 47:
|
|
1232
1243
|
tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
|
|
1233
1244
|
return d.isSelected;
|
|
1234
1245
|
});
|
|
1235
|
-
_context15.next =
|
|
1246
|
+
_context15.next = 50;
|
|
1236
1247
|
return this.store.order.recalculateSummary({
|
|
1237
1248
|
createIfMissing: true
|
|
1238
1249
|
});
|
|
1239
|
-
case
|
|
1250
|
+
case 50:
|
|
1240
1251
|
this.store.order.persistTempOrder();
|
|
1241
1252
|
this.logMethodSuccess('setDiscountSelected', params);
|
|
1242
|
-
_context15.next =
|
|
1253
|
+
_context15.next = 58;
|
|
1243
1254
|
break;
|
|
1244
|
-
case
|
|
1245
|
-
_context15.prev =
|
|
1255
|
+
case 54:
|
|
1256
|
+
_context15.prev = 54;
|
|
1246
1257
|
_context15.t1 = _context15["catch"](1);
|
|
1247
1258
|
this.logMethodError('setDiscountSelected', _context15.t1);
|
|
1248
1259
|
throw _context15.t1;
|
|
1249
|
-
case
|
|
1260
|
+
case 58:
|
|
1250
1261
|
case "end":
|
|
1251
1262
|
return _context15.stop();
|
|
1252
1263
|
}
|
|
1253
|
-
}, _callee15, this, [[1,
|
|
1264
|
+
}, _callee15, this, [[1, 54], [17, 38, 41, 44]]);
|
|
1254
1265
|
}));
|
|
1255
1266
|
function setDiscountSelected(_x8) {
|
|
1256
1267
|
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,
|
|
759
|
+
var _this$getCustomer2, _this$store$discount7, _this$getDiscountList, _this$store$discount8, _this$store$productLi2, orderId, customerId, 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,8 +777,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
777
777
|
order_id: orderId
|
|
778
778
|
} : {}));
|
|
779
779
|
case 5:
|
|
780
|
-
|
|
781
|
-
goodPassList = (prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.discountList) || [];
|
|
780
|
+
goodPassList = _context9.sent;
|
|
782
781
|
scanDiscount = (_this$getDiscountList = this.getDiscountList()) === null || _this$getDiscountList === void 0 ? void 0 : _this$getDiscountList.filter(function (item) {
|
|
783
782
|
return item.isScan;
|
|
784
783
|
}); // goodPassList 里可能有 scanDiscount 重合的部分,goodPassList 需要剔除
|
|
@@ -790,35 +789,35 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
790
789
|
});
|
|
791
790
|
newDiscountList = [].concat(_toConsumableArray(scanDiscount), _toConsumableArray(newGoodPassList || [])); // 存储原始优惠券列表
|
|
792
791
|
this.store.originalDiscountList = newDiscountList;
|
|
793
|
-
_context9.next =
|
|
792
|
+
_context9.next = 13;
|
|
794
793
|
return (_this$store$discount8 = this.store.discount) === null || _this$store$discount8 === void 0 ? void 0 : _this$store$discount8.setOriginalDiscountList(newDiscountList);
|
|
795
|
-
case
|
|
794
|
+
case 13:
|
|
796
795
|
// 根据当前预约时间过滤优惠券列表
|
|
797
796
|
filteredDiscountList = this.filterDiscountListByBookingTime(newDiscountList, this.store.currentBookingTime);
|
|
798
797
|
this.store.filteredDiscountList = filteredDiscountList;
|
|
799
798
|
this.setDiscountList(filteredDiscountList || []);
|
|
800
799
|
if (!((_this$store$productLi2 = this.store.productList) !== null && _this$store$productLi2 !== void 0 && _this$store$productLi2.length)) {
|
|
801
|
-
_context9.next =
|
|
800
|
+
_context9.next = 20;
|
|
802
801
|
break;
|
|
803
802
|
}
|
|
804
803
|
_result3 = this.calcDiscount(this.store.productList);
|
|
805
|
-
_context9.next =
|
|
804
|
+
_context9.next = 20;
|
|
806
805
|
return this.core.effects.emit("".concat(this.name, ":onLoadPrepareCalcResult"), _result3);
|
|
807
|
-
case
|
|
808
|
-
_context9.next =
|
|
806
|
+
case 20:
|
|
807
|
+
_context9.next = 22;
|
|
809
808
|
return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"), filteredDiscountList);
|
|
810
|
-
case
|
|
811
|
-
_context9.next =
|
|
809
|
+
case 22:
|
|
810
|
+
_context9.next = 27;
|
|
812
811
|
break;
|
|
813
|
-
case
|
|
814
|
-
_context9.prev =
|
|
812
|
+
case 24:
|
|
813
|
+
_context9.prev = 24;
|
|
815
814
|
_context9.t0 = _context9["catch"](0);
|
|
816
815
|
console.error('[ShopDiscount] 加载准备配置出错:', _context9.t0);
|
|
817
|
-
case
|
|
816
|
+
case 27:
|
|
818
817
|
case "end":
|
|
819
818
|
return _context9.stop();
|
|
820
819
|
}
|
|
821
|
-
}, _callee9, this, [[0,
|
|
820
|
+
}, _callee9, this, [[0, 24]]);
|
|
822
821
|
}));
|
|
823
822
|
function loadPrepareConfig(_x9) {
|
|
824
823
|
return _loadPrepareConfig.apply(this, arguments);
|
|
@@ -51,6 +51,10 @@ 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
|
+
}
|
|
54
58
|
function cloneCustomDepositData(customDepositData) {
|
|
55
59
|
if (!customDepositData || _typeof(customDepositData) !== 'object') return undefined;
|
|
56
60
|
return _objectSpread(_objectSpread({}, customDepositData), {}, {
|
|
@@ -2163,7 +2167,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2163
2167
|
_iterator14.s();
|
|
2164
2168
|
case 21:
|
|
2165
2169
|
if ((_step14 = _iterator14.n()).done) {
|
|
2166
|
-
_context21.next =
|
|
2170
|
+
_context21.next = 38;
|
|
2167
2171
|
break;
|
|
2168
2172
|
}
|
|
2169
2173
|
product = _step14.value;
|
|
@@ -2171,8 +2175,15 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2171
2175
|
_context21.next = 25;
|
|
2172
2176
|
break;
|
|
2173
2177
|
}
|
|
2174
|
-
return _context21.abrupt("continue",
|
|
2178
|
+
return _context21.abrupt("continue", 36);
|
|
2175
2179
|
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:
|
|
2176
2187
|
// 1. 把 product.discount_list 和当前选中的 discount 对齐(剔除已取消的券)
|
|
2177
2188
|
product.discount_list = (product.discount_list || []).filter(function (pd) {
|
|
2178
2189
|
var _pd$discount$resource, _pd$discount;
|
|
@@ -2197,36 +2208,36 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2197
2208
|
mainPrice: newMainSellingPrice,
|
|
2198
2209
|
bundle: product.product_bundle
|
|
2199
2210
|
});
|
|
2200
|
-
case
|
|
2211
|
+
case 36:
|
|
2201
2212
|
_context21.next = 21;
|
|
2202
2213
|
break;
|
|
2203
|
-
case
|
|
2204
|
-
_context21.next =
|
|
2214
|
+
case 38:
|
|
2215
|
+
_context21.next = 43;
|
|
2205
2216
|
break;
|
|
2206
|
-
case 37:
|
|
2207
|
-
_context21.prev = 37;
|
|
2208
|
-
_context21.t0 = _context21["catch"](19);
|
|
2209
|
-
_iterator14.e(_context21.t0);
|
|
2210
2217
|
case 40:
|
|
2211
2218
|
_context21.prev = 40;
|
|
2212
|
-
|
|
2213
|
-
|
|
2219
|
+
_context21.t0 = _context21["catch"](19);
|
|
2220
|
+
_iterator14.e(_context21.t0);
|
|
2214
2221
|
case 43:
|
|
2222
|
+
_context21.prev = 43;
|
|
2223
|
+
_iterator14.f();
|
|
2224
|
+
return _context21.finish(43);
|
|
2225
|
+
case 46:
|
|
2215
2226
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
2216
|
-
_context21.next =
|
|
2227
|
+
_context21.next = 49;
|
|
2217
2228
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
2218
|
-
case
|
|
2229
|
+
case 49:
|
|
2219
2230
|
tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
|
|
2220
2231
|
return d.isSelected;
|
|
2221
2232
|
});
|
|
2222
2233
|
afterApplyTarget = this.store.order.getDiscountList().find(function (d) {
|
|
2223
2234
|
return d.id === params.discountId;
|
|
2224
2235
|
}) || null;
|
|
2225
|
-
_context21.next =
|
|
2236
|
+
_context21.next = 53;
|
|
2226
2237
|
return this.store.order.recalculateSummary({
|
|
2227
2238
|
createIfMissing: true
|
|
2228
2239
|
});
|
|
2229
|
-
case
|
|
2240
|
+
case 53:
|
|
2230
2241
|
this.store.order.persistTempOrder();
|
|
2231
2242
|
finalSummary = ((_this$store$order$get = this.store.order.getTempOrder()) === null || _this$store$order$get === void 0 ? void 0 : _this$store$order$get.summary) || null;
|
|
2232
2243
|
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;
|
|
@@ -2235,16 +2246,16 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2235
2246
|
return d.id === params.discountId;
|
|
2236
2247
|
}) || null;
|
|
2237
2248
|
return _context21.abrupt("return", this.store.order.getDiscountList());
|
|
2238
|
-
case
|
|
2239
|
-
_context21.prev =
|
|
2249
|
+
case 61:
|
|
2250
|
+
_context21.prev = 61;
|
|
2240
2251
|
_context21.t1 = _context21["catch"](1);
|
|
2241
2252
|
this.logMethodError('setDiscountSelected', _context21.t1);
|
|
2242
2253
|
throw _context21.t1;
|
|
2243
|
-
case
|
|
2254
|
+
case 65:
|
|
2244
2255
|
case "end":
|
|
2245
2256
|
return _context21.stop();
|
|
2246
2257
|
}
|
|
2247
|
-
}, _callee21, this, [[1,
|
|
2258
|
+
}, _callee21, this, [[1, 61], [19, 40, 43, 46]]);
|
|
2248
2259
|
}));
|
|
2249
2260
|
function setDiscountSelected(_x15) {
|
|
2250
2261
|
return _setDiscountSelected.apply(this, arguments);
|
|
@@ -5,7 +5,3 @@ export { PromotionEvaluator } from './promotion/evaluator';
|
|
|
5
5
|
export { PromotionAdapter } from './promotion/adapter';
|
|
6
6
|
export { ItemRuleEvaluator } from './itemRule/evaluator';
|
|
7
7
|
export { ItemRuleAdapter } from './itemRule/adapter';
|
|
8
|
-
export { DataVariantEvaluator } from './dataVariant/evaluator';
|
|
9
|
-
export { DataVariantAdapter } from './dataVariant/adapter';
|
|
10
|
-
export { runDataVariantDemo } from './dataVariant/examples';
|
|
11
|
-
export * from './dataVariant/type';
|
|
@@ -30,15 +30,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/model/strategy/adapter/index.ts
|
|
31
31
|
var adapter_exports = {};
|
|
32
32
|
__export(adapter_exports, {
|
|
33
|
-
DataVariantAdapter: () => import_adapter3.DataVariantAdapter,
|
|
34
|
-
DataVariantEvaluator: () => import_evaluator4.DataVariantEvaluator,
|
|
35
33
|
ItemRuleAdapter: () => import_adapter2.ItemRuleAdapter,
|
|
36
34
|
ItemRuleEvaluator: () => import_evaluator3.ItemRuleEvaluator,
|
|
37
35
|
PromotionAdapter: () => import_adapter.PromotionAdapter,
|
|
38
36
|
PromotionEvaluator: () => import_evaluator2.PromotionEvaluator,
|
|
39
37
|
WalletPassAdapter: () => import_walletPass.default,
|
|
40
|
-
WalletPassEvaluator: () => import_evaluator.WalletPassEvaluator
|
|
41
|
-
runDataVariantDemo: () => import_examples.runDataVariantDemo
|
|
38
|
+
WalletPassEvaluator: () => import_evaluator.WalletPassEvaluator
|
|
42
39
|
});
|
|
43
40
|
module.exports = __toCommonJS(adapter_exports);
|
|
44
41
|
__reExport(adapter_exports, require("./type"), module.exports);
|
|
@@ -48,21 +45,13 @@ var import_evaluator2 = require("./promotion/evaluator");
|
|
|
48
45
|
var import_adapter = require("./promotion/adapter");
|
|
49
46
|
var import_evaluator3 = require("./itemRule/evaluator");
|
|
50
47
|
var import_adapter2 = require("./itemRule/adapter");
|
|
51
|
-
var import_evaluator4 = require("./dataVariant/evaluator");
|
|
52
|
-
var import_adapter3 = require("./dataVariant/adapter");
|
|
53
|
-
var import_examples = require("./dataVariant/examples");
|
|
54
|
-
__reExport(adapter_exports, require("./dataVariant/type"), module.exports);
|
|
55
48
|
// Annotate the CommonJS export names for ESM import in node:
|
|
56
49
|
0 && (module.exports = {
|
|
57
|
-
DataVariantAdapter,
|
|
58
|
-
DataVariantEvaluator,
|
|
59
50
|
ItemRuleAdapter,
|
|
60
51
|
ItemRuleEvaluator,
|
|
61
52
|
PromotionAdapter,
|
|
62
53
|
PromotionEvaluator,
|
|
63
54
|
WalletPassAdapter,
|
|
64
55
|
WalletPassEvaluator,
|
|
65
|
-
|
|
66
|
-
...require("./type"),
|
|
67
|
-
...require("./dataVariant/type")
|
|
56
|
+
...require("./type")
|
|
68
57
|
});
|
|
@@ -134,6 +134,8 @@ var PromotionAdapter = class {
|
|
|
134
134
|
return this.parseXItemsForYPriceAction(action);
|
|
135
135
|
case import_type.PROMOTION_ACTION_TYPES.BUY_X_GET_Y_FREE:
|
|
136
136
|
return this.parseBuyXGetYFreeAction(action);
|
|
137
|
+
case import_type.PROMOTION_ACTION_TYPES.ITEM_REWARD:
|
|
138
|
+
return this.parseItemRewardAction(action);
|
|
137
139
|
default:
|
|
138
140
|
return void 0;
|
|
139
141
|
}
|
|
@@ -167,6 +169,24 @@ var PromotionAdapter = class {
|
|
|
167
169
|
giftProducts: config.giftProducts || []
|
|
168
170
|
};
|
|
169
171
|
}
|
|
172
|
+
/**
|
|
173
|
+
* 解析 商品奖励 Action
|
|
174
|
+
*/
|
|
175
|
+
parseItemRewardAction(action) {
|
|
176
|
+
const value = action.value || {};
|
|
177
|
+
const config = action.config || {};
|
|
178
|
+
return {
|
|
179
|
+
type: import_type.PROMOTION_ACTION_TYPES.ITEM_REWARD,
|
|
180
|
+
rewardMethod: value.rewardMethod || "free",
|
|
181
|
+
rewardValue: Number(value.rewardValue || 0),
|
|
182
|
+
quantityRule: value.quantityRule || "per_condition_quantity",
|
|
183
|
+
triggerQuantity: Number(value.triggerQuantity || 1),
|
|
184
|
+
rewardQuantity: Number(value.rewardQuantity || 1),
|
|
185
|
+
maxRewardQuantity: value.maxRewardQuantity === void 0 || value.maxRewardQuantity === null ? void 0 : Number(value.maxRewardQuantity),
|
|
186
|
+
rewardTargets: Array.isArray(config.rewardTargets) ? config.rewardTargets : [],
|
|
187
|
+
targetSelection: config.targetSelection || "consumer_best"
|
|
188
|
+
};
|
|
189
|
+
}
|
|
170
190
|
/**
|
|
171
191
|
* 获取适用的商品列表
|
|
172
192
|
*
|
|
@@ -169,6 +169,21 @@ export declare class PromotionEvaluator {
|
|
|
169
169
|
* 支持 bundle 子商品的数量计算(主商品数量 × 子商品数量)
|
|
170
170
|
*/
|
|
171
171
|
private processBuyXGetYFree;
|
|
172
|
+
/**
|
|
173
|
+
* 处理 商品奖励 促销
|
|
174
|
+
*
|
|
175
|
+
* 1. 使用 group.products 统计触发条件商品数量
|
|
176
|
+
* 2. 按 quantityRule 计算最多奖励的目标商品数量
|
|
177
|
+
* 3. 在全购物车商品中筛选 rewardTargets
|
|
178
|
+
* 4. 按消费者最优(可节省金额从高到低)选择目标单位
|
|
179
|
+
* 5. 对目标商品拆分并写入 finalPrice,触发商品本身不改价
|
|
180
|
+
*/
|
|
181
|
+
private processItemReward;
|
|
182
|
+
private normalizePositiveInteger;
|
|
183
|
+
private getAvailablePromotionQuantity;
|
|
184
|
+
private buildItemRewardTargetUnits;
|
|
185
|
+
private resolveItemRewardFinalPrice;
|
|
186
|
+
private resolveItemRewardLimit;
|
|
172
187
|
/**
|
|
173
188
|
* 获取未参与任何促销的商品
|
|
174
189
|
*/
|
|
@@ -194,6 +209,8 @@ export declare class PromotionEvaluator {
|
|
|
194
209
|
* 检查商品是否在策略的适用范围内
|
|
195
210
|
*/
|
|
196
211
|
private isProductInStrategy;
|
|
212
|
+
private shouldSkipStrategyForProduct;
|
|
213
|
+
private hasActionType;
|
|
197
214
|
/**
|
|
198
215
|
* 查找商品匹配规则
|
|
199
216
|
*/
|