@pisell/pisellos 2.3.128 → 2.3.130
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/index.d.ts +2 -0
- package/dist/index.js +3 -1
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.js +4 -2
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +58 -19
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +24 -12
- package/dist/modules/Customer/index.js +6 -3
- package/dist/modules/Customer/types.d.ts +2 -0
- package/dist/modules/Discount/availability.d.ts +7 -0
- package/dist/modules/Discount/availability.js +49 -0
- package/dist/modules/Discount/entitlementPass.d.ts +34 -0
- package/dist/modules/Discount/entitlementPass.js +147 -0
- package/dist/modules/Discount/index.d.ts +2 -2
- package/dist/modules/Discount/index.js +37 -151
- package/dist/modules/Discount/types.d.ts +36 -5
- package/dist/modules/FulfillmentTiming/index.d.ts +11 -0
- package/dist/modules/FulfillmentTiming/index.js +407 -0
- package/dist/modules/FulfillmentTiming/types.d.ts +67 -0
- package/dist/modules/FulfillmentTiming/types.js +1 -0
- package/dist/modules/OpenData/types.d.ts +6 -0
- package/dist/modules/Order/index.d.ts +12 -0
- package/dist/modules/Order/index.js +498 -247
- package/dist/modules/Order/pickupTiming.d.ts +46 -0
- package/dist/modules/Order/pickupTiming.js +53 -0
- package/dist/modules/Order/types.d.ts +5 -1
- package/dist/modules/Order/utils/orderCollectionIdentity.js +16 -12
- package/dist/modules/Order/utils.d.ts +1 -1
- package/dist/modules/Order/utils.js +117 -66
- package/dist/modules/Payment/index.js +9 -10
- package/dist/modules/Payment/types.d.ts +21 -1
- package/dist/modules/Payment/types.js +2 -0
- package/dist/modules/Payment/walletpass.d.ts +1 -1
- package/dist/modules/Payment/walletpass.js +80 -47
- package/dist/modules/Rules/index.d.ts +2 -2
- package/dist/modules/Rules/index.js +480 -186
- package/dist/modules/Rules/types.d.ts +4 -0
- package/dist/modules/Schedule/index.d.ts +8 -0
- package/dist/modules/Schedule/index.js +141 -39
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +1 -0
- package/dist/plugins/request.d.ts +7 -0
- package/dist/server/modules/order/types.d.ts +2 -0
- package/dist/server/utils/small-ticket.d.ts +1 -85
- package/dist/server/utils/small-ticket.js +2 -2542
- package/dist/shared/payment/loadPaymentMethods.d.ts +9 -0
- package/dist/shared/payment/loadPaymentMethods.js +66 -0
- package/dist/shared/receipt/loadCustomerInvoiceLayout.d.ts +22 -0
- package/dist/shared/receipt/loadCustomerInvoiceLayout.js +142 -0
- package/dist/shared/receipt/small-ticket.d.ts +85 -0
- package/dist/shared/receipt/small-ticket.js +2576 -0
- package/dist/shared/sales/loadSalesOrderSnapshot.d.ts +9 -0
- package/dist/shared/sales/loadSalesOrderSnapshot.js +21 -0
- package/dist/solution/BaseSales/index.d.ts +25 -0
- package/dist/solution/BaseSales/index.js +1226 -1040
- package/dist/solution/BaseSales/pickupTiming.d.ts +43 -0
- package/dist/solution/BaseSales/pickupTiming.js +589 -0
- package/dist/solution/BaseSales/types.d.ts +2 -2
- package/dist/solution/BaseSales/utils/cartPromotion.js +141 -126
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +3 -0
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +4 -5
- package/dist/solution/BookingTicket/index.js +60 -63
- package/dist/solution/BookingTicket/types.d.ts +5 -1
- package/dist/solution/BookingTicket/utils/cartView.js +3 -1
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +2 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +338 -147
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +8 -4
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +6 -0
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +19 -6
- package/dist/solution/OrderInvoicePreview/index.d.ts +56 -0
- package/dist/solution/OrderInvoicePreview/index.js +269 -0
- package/dist/solution/ShopDiscount/index.d.ts +2 -0
- package/dist/solution/ShopDiscount/index.js +99 -42
- package/dist/solution/ShopDiscount/utils.d.ts +4 -2
- package/dist/solution/ShopDiscount/utils.js +43 -23
- package/dist/solution/UnifiedBookingSales/index.d.ts +13 -4
- package/dist/solution/UnifiedBookingSales/index.js +874 -709
- package/dist/solution/index.d.ts +1 -0
- package/dist/solution/index.js +2 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +21 -1
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.js +2 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +35 -6
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +13 -6
- package/lib/modules/Customer/index.js +5 -1
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Discount/availability.d.ts +7 -0
- package/lib/modules/Discount/availability.js +43 -0
- package/lib/modules/Discount/entitlementPass.d.ts +34 -0
- package/lib/modules/Discount/entitlementPass.js +141 -0
- package/lib/modules/Discount/index.d.ts +2 -2
- package/lib/modules/Discount/index.js +23 -129
- package/lib/modules/Discount/types.d.ts +36 -5
- package/lib/modules/FulfillmentTiming/index.d.ts +11 -0
- package/lib/modules/FulfillmentTiming/index.js +359 -0
- package/lib/modules/FulfillmentTiming/types.d.ts +67 -0
- package/lib/modules/FulfillmentTiming/types.js +5 -0
- package/lib/modules/OpenData/types.d.ts +6 -0
- package/lib/modules/Order/index.d.ts +12 -0
- package/lib/modules/Order/index.js +252 -48
- package/lib/modules/Order/pickupTiming.d.ts +46 -0
- package/lib/modules/Order/pickupTiming.js +61 -0
- package/lib/modules/Order/types.d.ts +5 -1
- package/lib/modules/Order/utils/orderCollectionIdentity.js +14 -11
- package/lib/modules/Order/utils.d.ts +1 -1
- package/lib/modules/Order/utils.js +51 -7
- package/lib/modules/Payment/index.js +3 -4
- package/lib/modules/Payment/types.d.ts +21 -1
- package/lib/modules/Payment/types.js +1 -0
- package/lib/modules/Payment/walletpass.d.ts +1 -1
- package/lib/modules/Payment/walletpass.js +29 -9
- package/lib/modules/Rules/index.d.ts +2 -2
- package/lib/modules/Rules/index.js +357 -110
- package/lib/modules/Rules/types.d.ts +4 -0
- package/lib/modules/Schedule/index.d.ts +8 -0
- package/lib/modules/Schedule/index.js +68 -12
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +11 -0
- package/lib/plugins/request.d.ts +7 -0
- package/lib/server/modules/order/types.d.ts +2 -0
- package/lib/server/utils/small-ticket.d.ts +1 -85
- package/lib/server/utils/small-ticket.js +9 -2305
- package/lib/shared/payment/loadPaymentMethods.d.ts +9 -0
- package/lib/shared/payment/loadPaymentMethods.js +40 -0
- package/lib/shared/receipt/loadCustomerInvoiceLayout.d.ts +22 -0
- package/lib/shared/receipt/loadCustomerInvoiceLayout.js +86 -0
- package/lib/shared/receipt/small-ticket.d.ts +85 -0
- package/lib/shared/receipt/small-ticket.js +2342 -0
- package/lib/shared/sales/loadSalesOrderSnapshot.d.ts +9 -0
- package/lib/shared/sales/loadSalesOrderSnapshot.js +22 -0
- package/lib/solution/BaseSales/index.d.ts +25 -0
- package/lib/solution/BaseSales/index.js +102 -3
- package/lib/solution/BaseSales/pickupTiming.d.ts +43 -0
- package/lib/solution/BaseSales/pickupTiming.js +269 -0
- package/lib/solution/BaseSales/types.d.ts +2 -2
- package/lib/solution/BaseSales/utils/cartPromotion.js +12 -4
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +3 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +4 -5
- package/lib/solution/BookingTicket/index.js +36 -33
- package/lib/solution/BookingTicket/types.d.ts +5 -1
- package/lib/solution/BookingTicket/utils/cartView.js +3 -1
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +2 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +174 -42
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +8 -4
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +6 -0
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +11 -3
- package/lib/solution/OrderInvoicePreview/index.d.ts +56 -0
- package/lib/solution/OrderInvoicePreview/index.js +192 -0
- package/lib/solution/ShopDiscount/index.d.ts +2 -0
- package/lib/solution/ShopDiscount/index.js +55 -9
- package/lib/solution/ShopDiscount/utils.d.ts +4 -2
- package/lib/solution/ShopDiscount/utils.js +42 -25
- package/lib/solution/UnifiedBookingSales/index.d.ts +13 -4
- package/lib/solution/UnifiedBookingSales/index.js +132 -48
- package/lib/solution/index.d.ts +1 -0
- package/lib/solution/index.js +11 -0
- package/package.json +1 -1
|
@@ -6,13 +6,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
6
6
|
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; }
|
|
7
7
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
8
8
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
9
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
10
|
-
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."); }
|
|
11
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
12
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
13
9
|
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; } } }; }
|
|
14
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
15
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
16
10
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
17
11
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
18
12
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
@@ -25,17 +19,26 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
|
|
|
25
19
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
26
20
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
27
21
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
22
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
23
|
+
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."); }
|
|
24
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
25
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
26
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
27
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
28
28
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
29
29
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
30
30
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
31
31
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
32
32
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
33
|
+
import { loadSalesOrderSnapshot } from "../../shared/sales/loadSalesOrderSnapshot";
|
|
33
34
|
import { BaseModule } from "../BaseModule";
|
|
34
35
|
import { OrderHooks } from "./types";
|
|
35
36
|
import { composeLinePrice, generateDuration, getAllDiscountList, mergeRelationForms, ensureCartItemOriginHolder, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeOrderMetaList, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments, normalizeOrderProductDiscountList, resolveEffectivePerUnitDiscount, ensureProductSku, getProductSkuOptions, normalizeProductSkuOptions, sumOptionUnitPrice, clearTempOrderHolderAssignments, getOrderProductLineUid, indexOrderProductsByUid, calculateOrderProductsDeposit, collectPointCardSnapshotCodeCandidates, mergePointCardSnapshotCodes as _mergePointCardSnapshotCodes, buildVirtualCurrencySnapshotFromList, mergeOrderProductDisplayFields, resolveIsFormSubject, isMarkdownBundle } from "./utils";
|
|
36
37
|
import { isNormalProduct } from "../Product/utils";
|
|
37
38
|
import { getWeighedProductPriceFingerprint, resolveWeighedSourcePrice, withOriginalBundleOptionPrices } from "./utils/weighedProduct";
|
|
39
|
+
import { buildPickupTimingBooking, isFulfillmentTimingBooking } from "./pickupTiming";
|
|
38
40
|
import dayjs from 'dayjs';
|
|
41
|
+
import { getDiscountLifecycleReason } from "../Discount/availability";
|
|
39
42
|
import { stripOsPrivatePayloadFields } from "../../utils/os-private-payload";
|
|
40
43
|
import { buildSalesNoteText, decodeSalesNotesSnapshot, getSalesNotePolicy } from "./salesNotes";
|
|
41
44
|
import { ensureOrderPaymentNumber, mergeOrderPaymentRecord, resolveOrderPaymentIdentity } from "./payment-utils";
|
|
@@ -49,6 +52,7 @@ import { consolidateDiscountFreeProductLines, ensureUniqueProductLineUids } from
|
|
|
49
52
|
import { applyTempOrderSettlementState, getSelectedSettlementSnapshot, getSettlementKey, getTempOrderSettlementKey, getTempOrderSettlementSnapshot, isVirtualSettlementOrder, normalizeVirtualSettlementOrderProduct, normalizeVirtualSettlementProducts, OrderSettlementConflictError, releaseTempOrderSettlementState, VirtualCurrencyAssetNotFoundError, VirtualCurrencyBalanceError } from "./utils/virtualSettlement";
|
|
50
53
|
import { DiscountModule } from "../Discount";
|
|
51
54
|
import { RulesModule } from "../Rules";
|
|
55
|
+
import { isEntitlementPass, isFullCoveragePass } from "../Discount/entitlementPass";
|
|
52
56
|
import { UnavailableReason } from "../Rules/types";
|
|
53
57
|
import Decimal from 'decimal.js';
|
|
54
58
|
import { cloneDeep } from 'lodash-es';
|
|
@@ -72,9 +76,26 @@ function isManualProductDiscountProduct(product) {
|
|
|
72
76
|
return (item === null || item === void 0 ? void 0 : item.type) === 'product';
|
|
73
77
|
});
|
|
74
78
|
}
|
|
79
|
+
function syncReducedEntitlementPassUsageCount(discountList, previousQuantity, nextQuantity) {
|
|
80
|
+
if (!Array.isArray(discountList)) return discountList;
|
|
81
|
+
var previousCount = getSafeProductNum(previousQuantity);
|
|
82
|
+
var nextCount = getSafeProductNum(nextQuantity);
|
|
83
|
+
if (nextCount >= previousCount) return discountList;
|
|
84
|
+
return discountList.map(function (discount) {
|
|
85
|
+
var _discount$metadata$nu, _discount$metadata;
|
|
86
|
+
if (!isEntitlementPass(discount)) return discount;
|
|
87
|
+
var rawUsageCount = Number((_discount$metadata$nu = discount === null || discount === void 0 || (_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.num) !== null && _discount$metadata$nu !== void 0 ? _discount$metadata$nu : previousCount);
|
|
88
|
+
var usageCount = Number.isFinite(rawUsageCount) ? Math.max(Math.floor(rawUsageCount), 0) : previousCount;
|
|
89
|
+
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
90
|
+
metadata: _objectSpread(_objectSpread({}, (discount === null || discount === void 0 ? void 0 : discount.metadata) || {}), {}, {
|
|
91
|
+
num: Math.min(usageCount, nextCount)
|
|
92
|
+
})
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
}
|
|
75
96
|
var ORDER_PAYMENT_STATUS_PAID = 'paid';
|
|
76
97
|
var ORDER_PAYMENT_STATUS_PENDING = 'payment_pending';
|
|
77
|
-
var CUSTOMER_PROMOTION_DISCOUNT_TAGS = new Set(['good_pass', 'product_discount_card', 'discount_card']);
|
|
98
|
+
var CUSTOMER_PROMOTION_DISCOUNT_TAGS = new Set(['entitlement_pass', 'good_pass', 'product_discount_card', 'discount_card']);
|
|
78
99
|
function isCustomerPromotionDiscount(discount) {
|
|
79
100
|
return CUSTOMER_PROMOTION_DISCOUNT_TAGS.has(String((discount === null || discount === void 0 ? void 0 : discount.tag) || (discount === null || discount === void 0 ? void 0 : discount.type) || '').toLowerCase());
|
|
80
101
|
}
|
|
@@ -109,6 +130,27 @@ function getVoucherPaymentLifecycleKey(payment) {
|
|
|
109
130
|
if (!isVoucherPaymentRecord(payment)) return null;
|
|
110
131
|
return "".concat(String(payment.voucher_id), "::").concat(String(payment.status || ''));
|
|
111
132
|
}
|
|
133
|
+
function getDiscountIdentityKey(discount) {
|
|
134
|
+
var id = discount === null || discount === void 0 ? void 0 : discount.id;
|
|
135
|
+
if (id === undefined || id === null || id === '') return null;
|
|
136
|
+
return String(id);
|
|
137
|
+
}
|
|
138
|
+
function mergeCommittedEntitlementWithRuntime(committed, runtime) {
|
|
139
|
+
var _committed$committedA, _runtime$id, _runtime$isDisabled, _runtime$isSelected;
|
|
140
|
+
var committedAppliedProductDetails = (_committed$committedA = committed.committedAppliedProductDetails) !== null && _committed$committedA !== void 0 && _committed$committedA.length ? committed.committedAppliedProductDetails : committed.appliedProductDetails || [];
|
|
141
|
+
return _objectSpread(_objectSpread(_objectSpread({}, committed), runtime), {}, {
|
|
142
|
+
id: (_runtime$id = runtime.id) !== null && _runtime$id !== void 0 ? _runtime$id : committed.id,
|
|
143
|
+
tag: runtime.tag || committed.tag,
|
|
144
|
+
type: runtime.type || committed.type,
|
|
145
|
+
isEditMode: false,
|
|
146
|
+
isDisabled: (_runtime$isDisabled = runtime.isDisabled) !== null && _runtime$isDisabled !== void 0 ? _runtime$isDisabled : false,
|
|
147
|
+
isSelected: (_runtime$isSelected = runtime.isSelected) !== null && _runtime$isSelected !== void 0 ? _runtime$isSelected : committed.isSelected,
|
|
148
|
+
isUsed: committed.isUsed || runtime.isUsed,
|
|
149
|
+
committedAppliedProductDetails: _toConsumableArray(committedAppliedProductDetails),
|
|
150
|
+
applicableProductDetails: [].concat(_toConsumableArray(committed.applicableProductDetails || []), _toConsumableArray(runtime.applicableProductDetails || [])),
|
|
151
|
+
appliedProductDetails: [].concat(_toConsumableArray(committedAppliedProductDetails), _toConsumableArray(runtime.appliedProductDetails || []))
|
|
152
|
+
});
|
|
153
|
+
}
|
|
112
154
|
export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
113
155
|
_inherits(OrderModule, _BaseModule);
|
|
114
156
|
var _super = _createSuper(OrderModule);
|
|
@@ -173,7 +215,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
173
215
|
_step2;
|
|
174
216
|
try {
|
|
175
217
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
176
|
-
var _item$type2, _ref, _ref2, _item$discount$resour, _item$discount, _item$discount$title, _item$discount2, _item$discount3, _item$discount$fixed_, _item$
|
|
218
|
+
var _item$type2, _ref, _ref2, _item$discount$resour, _item$discount, _item$discount$title, _item$discount2, _item$metadata, _item$discount3, _item$discount4, _item$discount$fixed_, _item$discount5, _item$discount6, _item$amount, _ref3, _item$discount$origin, _item$discount7, _ref4, _ref5, _item$metadata$num, _item$metadata2, _item$discount$produc, _item$discount8, _ref6, _ref7, _item$metadata$num2, _item$metadata3, _item$discount9, _ref8, _item$discount$discou, _item$discount10, _item$amount2, _item$amount3, _product$product_id, _product$is_charge_ta, _ref9, _product$original_pri, _ref10, _item$discount$discou2, _item$discount11, _item$discount$discou3, _item$discount12;
|
|
177
219
|
var item = _step2.value;
|
|
178
220
|
var type = (_item$type2 = item === null || item === void 0 ? void 0 : item.type) !== null && _item$type2 !== void 0 ? _item$type2 : item === null || item === void 0 ? void 0 : item.tag;
|
|
179
221
|
if (!type || type === 'product') continue;
|
|
@@ -184,22 +226,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
184
226
|
var key = Number.isFinite(id) ? id : String(resourceId);
|
|
185
227
|
var title = (_item$discount$title = item === null || item === void 0 || (_item$discount2 = item.discount) === null || _item$discount2 === void 0 ? void 0 : _item$discount2.title) !== null && _item$discount$title !== void 0 ? _item$discount$title : {};
|
|
186
228
|
var amount = Number((item === null || item === void 0 ? void 0 : item.amount) || 0);
|
|
187
|
-
var
|
|
188
|
-
var
|
|
229
|
+
var encoded = (item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.encoded) || (item === null || item === void 0 ? void 0 : item.encoded) || (item === null || item === void 0 || (_item$discount3 = item.discount) === null || _item$discount3 === void 0 ? void 0 : _item$discount3.encoded) || '';
|
|
230
|
+
var discountCardType = item === null || item === void 0 || (_item$discount4 = item.discount) === null || _item$discount4 === void 0 ? void 0 : _item$discount4.discount_card_type;
|
|
231
|
+
var parValue = isDiscountCard ? discountCardType === 'fixed_amount' ? (_item$discount$fixed_ = item === null || item === void 0 || (_item$discount5 = item.discount) === null || _item$discount5 === void 0 ? void 0 : _item$discount5.fixed_amount) !== null && _item$discount$fixed_ !== void 0 ? _item$discount$fixed_ : item === null || item === void 0 ? void 0 : item.amount : item === null || item === void 0 || (_item$discount6 = item.discount) === null || _item$discount6 === void 0 ? void 0 : _item$discount6.percent : '0';
|
|
189
232
|
var detail = {
|
|
190
233
|
amount: String((_item$amount = item === null || item === void 0 ? void 0 : item.amount) !== null && _item$amount !== void 0 ? _item$amount : '0'),
|
|
191
234
|
type: type,
|
|
192
235
|
resource_id: key,
|
|
193
236
|
title: title,
|
|
194
|
-
original_amount: String((_ref3 = (_item$discount$origin = item === null || item === void 0 || (_item$
|
|
195
|
-
num: Number((_ref4 = (_ref5 = (_item$metadata$num = item === null || item === void 0 || (_item$
|
|
237
|
+
original_amount: String((_ref3 = (_item$discount$origin = item === null || item === void 0 || (_item$discount7 = item.discount) === null || _item$discount7 === void 0 ? void 0 : _item$discount7.original_amount) !== null && _item$discount$origin !== void 0 ? _item$discount$origin : item === null || item === void 0 ? void 0 : item.amount) !== null && _ref3 !== void 0 ? _ref3 : '0'),
|
|
238
|
+
num: Number((_ref4 = (_ref5 = (_item$metadata$num = item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.num) !== null && _item$metadata$num !== void 0 ? _item$metadata$num : product === null || product === void 0 ? void 0 : product.num) !== null && _ref5 !== void 0 ? _ref5 : product === null || product === void 0 ? void 0 : product.product_quantity) !== null && _ref4 !== void 0 ? _ref4 : 1) || 1,
|
|
196
239
|
metadata: item === null || item === void 0 ? void 0 : item.metadata,
|
|
197
|
-
discount: item === null || item === void 0 ? void 0 : item.discount,
|
|
198
|
-
|
|
240
|
+
discount: _objectSpread(_objectSpread({}, (item === null || item === void 0 ? void 0 : item.discount) || {}), {}, {
|
|
241
|
+
product_id: (_item$discount$produc = item === null || item === void 0 || (_item$discount8 = item.discount) === null || _item$discount8 === void 0 ? void 0 : _item$discount8.product_id) !== null && _item$discount$produc !== void 0 ? _item$discount$produc : product === null || product === void 0 ? void 0 : product.product_id
|
|
242
|
+
}),
|
|
243
|
+
_num: Number((_ref6 = (_ref7 = (_item$metadata$num2 = item === null || item === void 0 || (_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.num) !== null && _item$metadata$num2 !== void 0 ? _item$metadata$num2 : product === null || product === void 0 ? void 0 : product.num) !== null && _ref7 !== void 0 ? _ref7 : product === null || product === void 0 ? void 0 : product.product_quantity) !== null && _ref6 !== void 0 ? _ref6 : 1) || 1
|
|
199
244
|
};
|
|
200
245
|
var existed = discountMap.get(key);
|
|
201
246
|
if (existed) {
|
|
202
247
|
var _existed$limited_rela;
|
|
248
|
+
if (!existed.encoded && encoded) {
|
|
249
|
+
existed.encoded = encoded;
|
|
250
|
+
existed.metadata = _objectSpread(_objectSpread({}, existed.metadata), {}, {
|
|
251
|
+
encoded: encoded
|
|
252
|
+
});
|
|
253
|
+
}
|
|
203
254
|
existed.amount = Number(existed.amount || 0) + amount;
|
|
204
255
|
existed.used_par_value = String(Number(existed.used_par_value || 0) + amount);
|
|
205
256
|
if (!isDiscountCard) {
|
|
@@ -218,10 +269,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
218
269
|
discountMap.set(key, {
|
|
219
270
|
id: key,
|
|
220
271
|
product_name: '',
|
|
221
|
-
encoded:
|
|
222
|
-
code: '',
|
|
272
|
+
encoded: encoded,
|
|
273
|
+
code: (item === null || item === void 0 ? void 0 : item.code) || (item === null || item === void 0 || (_item$discount9 = item.discount) === null || _item$discount9 === void 0 ? void 0 : _item$discount9.code) || '',
|
|
274
|
+
metadata: {
|
|
275
|
+
encoded: encoded
|
|
276
|
+
},
|
|
223
277
|
tag: type,
|
|
224
|
-
product_id: (_ref8 = (_item$discount$discou = item === null || item === void 0 || (_item$
|
|
278
|
+
product_id: (_ref8 = (_item$discount$discou = item === null || item === void 0 || (_item$discount10 = item.discount) === null || _item$discount10 === void 0 ? void 0 : _item$discount10.discount_product_id) !== null && _item$discount$discou !== void 0 ? _item$discount$discou : product === null || product === void 0 ? void 0 : product.product_id) !== null && _ref8 !== void 0 ? _ref8 : 0,
|
|
225
279
|
relation_type: '',
|
|
226
280
|
par_value: String(parValue !== null && parValue !== void 0 ? parValue : '0'),
|
|
227
281
|
used_par_value: String((_item$amount2 = item === null || item === void 0 ? void 0 : item.amount) !== null && _item$amount2 !== void 0 ? _item$amount2 : '0'),
|
|
@@ -254,8 +308,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
254
308
|
amount: amount,
|
|
255
309
|
discount: _objectSpread(_objectSpread({}, (item === null || item === void 0 ? void 0 : item.discount) || {}), {}, {
|
|
256
310
|
resource_id: key,
|
|
257
|
-
discount_product_id: (_ref10 = (_item$discount$discou2 = item === null || item === void 0 || (_item$
|
|
258
|
-
discount_calculation_mode: (_item$discount$discou3 = item === null || item === void 0 || (_item$
|
|
311
|
+
discount_product_id: (_ref10 = (_item$discount$discou2 = item === null || item === void 0 || (_item$discount11 = item.discount) === null || _item$discount11 === void 0 ? void 0 : _item$discount11.discount_product_id) !== null && _item$discount$discou2 !== void 0 ? _item$discount$discou2 : product === null || product === void 0 ? void 0 : product.product_id) !== null && _ref10 !== void 0 ? _ref10 : 0,
|
|
312
|
+
discount_calculation_mode: (_item$discount$discou3 = item === null || item === void 0 || (_item$discount12 = item.discount) === null || _item$discount12 === void 0 ? void 0 : _item$discount12.discount_calculation_mode) !== null && _item$discount$discou3 !== void 0 ? _item$discount$discou3 : 'item_level'
|
|
259
313
|
}),
|
|
260
314
|
applicableProductDetails: [detail],
|
|
261
315
|
appliedProductDetails: [detail]
|
|
@@ -559,7 +613,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
559
613
|
}, {
|
|
560
614
|
key: "createDefaultRulesHooks",
|
|
561
615
|
value: function createDefaultRulesHooks() {
|
|
562
|
-
|
|
616
|
+
var _this2 = this;
|
|
617
|
+
return createDefaultOrderRulesHooks(function () {
|
|
618
|
+
var _this2$store$tempOrde;
|
|
619
|
+
return ((_this2$store$tempOrde = _this2.store.tempOrder) === null || _this2$store$tempOrde === void 0 ? void 0 : _this2$store$tempOrde.bookings) || [];
|
|
620
|
+
});
|
|
563
621
|
}
|
|
564
622
|
|
|
565
623
|
/**
|
|
@@ -581,9 +639,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
581
639
|
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
582
640
|
var _this$store$tempOrder,
|
|
583
641
|
_this$store$discount,
|
|
584
|
-
|
|
642
|
+
_this3 = this,
|
|
585
643
|
_this$store$tempOrder2;
|
|
586
|
-
var orderId, requestEpoch, requestOrderIdentityKey, prepareConfigResult, isCurrentRequest, discountList, _this$store$discount2, _this$store$discount3, _this$store$discount4, currentDiscountList,
|
|
644
|
+
var orderId, requestEpoch, requestOrderIdentityKey, prepareConfigResult, isCurrentRequest, discountList, _this$store$discount2, _this$store$discount3, _this$store$discount4, currentDiscountList, currentCommittedDiscounts, currentScanDiscounts, currentScanDiscountById, committedDiscountById, mergedCommittedDiscountIds, refreshedScanDiscountIds, runtimeDiscountIds, runtimeDiscounts, retainedCommittedDiscounts, retainedScanDiscounts, mergedDiscountList;
|
|
587
645
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
588
646
|
while (1) switch (_context3.prev = _context3.next) {
|
|
589
647
|
case 0:
|
|
@@ -599,6 +657,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
599
657
|
with_wallet_pass_holder: 1,
|
|
600
658
|
with_available_wallet_flag: 1,
|
|
601
659
|
with_available_wallet_pass_flag: 1,
|
|
660
|
+
with_entitlement_pass: 1,
|
|
661
|
+
filter_order_wallet_pass_usage: 0,
|
|
602
662
|
with_virtual_currency: 1,
|
|
603
663
|
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
604
664
|
}, orderId ? {
|
|
@@ -607,8 +667,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
607
667
|
case 5:
|
|
608
668
|
prepareConfigResult = _context3.sent;
|
|
609
669
|
isCurrentRequest = function isCurrentRequest() {
|
|
610
|
-
var
|
|
611
|
-
return requestEpoch ===
|
|
670
|
+
var _this3$store$tempOrde, _this3$store$tempOrde2;
|
|
671
|
+
return requestEpoch === _this3.customerWalletPrepareConfigEpoch && _this3.getDiscountConfigOrderIdentityKey(_this3.store.tempOrder) === requestOrderIdentityKey && String((_this3$store$tempOrde = (_this3$store$tempOrde2 = _this3.store.tempOrder) === null || _this3$store$tempOrde2 === void 0 ? void 0 : _this3$store$tempOrde2.customer_id) !== null && _this3$store$tempOrde !== void 0 ? _this3$store$tempOrde : '') === String(params.customerId);
|
|
612
672
|
};
|
|
613
673
|
if (isCurrentRequest()) {
|
|
614
674
|
_context3.next = 9;
|
|
@@ -626,56 +686,101 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
626
686
|
});
|
|
627
687
|
}
|
|
628
688
|
if (!discountList) {
|
|
629
|
-
_context3.next =
|
|
689
|
+
_context3.next = 32;
|
|
630
690
|
break;
|
|
631
691
|
}
|
|
632
692
|
currentDiscountList = ((_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 ? void 0 : _this$store$discount2.getDiscountList()) || [];
|
|
633
|
-
|
|
634
|
-
|
|
693
|
+
currentCommittedDiscounts = currentDiscountList.filter(function (discount) {
|
|
694
|
+
var _discount$committedAp;
|
|
695
|
+
return (discount === null || discount === void 0 ? void 0 : discount.isEditMode) || (discount === null || discount === void 0 || (_discount$committedAp = discount.committedAppliedProductDetails) === null || _discount$committedAp === void 0 ? void 0 : _discount$committedAp.length);
|
|
635
696
|
});
|
|
636
697
|
currentScanDiscounts = currentDiscountList.filter(function (discount) {
|
|
637
698
|
return discount === null || discount === void 0 ? void 0 : discount.isScan;
|
|
638
699
|
});
|
|
639
|
-
|
|
640
|
-
|
|
700
|
+
currentScanDiscountById = new Map(currentScanDiscounts.flatMap(function (discount) {
|
|
701
|
+
var id = getDiscountIdentityKey(discount);
|
|
702
|
+
return id === null ? [] : [[id, discount]];
|
|
641
703
|
}));
|
|
704
|
+
committedDiscountById = new Map(currentCommittedDiscounts.flatMap(function (discount) {
|
|
705
|
+
var id = getDiscountIdentityKey(discount);
|
|
706
|
+
return id === null ? [] : [[id, discount]];
|
|
707
|
+
}));
|
|
708
|
+
mergedCommittedDiscountIds = new Set();
|
|
709
|
+
refreshedScanDiscountIds = new Set();
|
|
642
710
|
runtimeDiscountIds = new Set();
|
|
643
|
-
runtimeDiscounts = discountList.
|
|
644
|
-
|
|
645
|
-
if (
|
|
646
|
-
runtimeDiscountIds.
|
|
647
|
-
|
|
711
|
+
runtimeDiscounts = discountList.flatMap(function (discount) {
|
|
712
|
+
var id = getDiscountIdentityKey(discount);
|
|
713
|
+
if (id === null) return [discount];
|
|
714
|
+
if (runtimeDiscountIds.has(id)) return [];
|
|
715
|
+
runtimeDiscountIds.add(id);
|
|
716
|
+
var currentScanDiscount = currentScanDiscountById.get(id);
|
|
717
|
+
if (currentScanDiscount && (!isEntitlementPass(currentScanDiscount) || !isEntitlementPass(discount))) {
|
|
718
|
+
return [];
|
|
719
|
+
}
|
|
720
|
+
var committedDiscount = committedDiscountById.get(id);
|
|
721
|
+
var nextDiscount = discount;
|
|
722
|
+
if (committedDiscount && isEntitlementPass(committedDiscount) && isEntitlementPass(discount)) {
|
|
723
|
+
mergedCommittedDiscountIds.add(id);
|
|
724
|
+
nextDiscount = mergeCommittedEntitlementWithRuntime(committedDiscount, discount);
|
|
725
|
+
}
|
|
726
|
+
if (currentScanDiscount) {
|
|
727
|
+
var _currentScanDiscount$, _currentScanDiscount$2;
|
|
728
|
+
refreshedScanDiscountIds.add(id);
|
|
729
|
+
nextDiscount = _objectSpread(_objectSpread({}, nextDiscount), {}, {
|
|
730
|
+
isScan: true,
|
|
731
|
+
isSelected: (_currentScanDiscount$ = currentScanDiscount.isSelected) !== null && _currentScanDiscount$ !== void 0 ? _currentScanDiscount$ : nextDiscount.isSelected,
|
|
732
|
+
isManualSelect: (_currentScanDiscount$2 = currentScanDiscount.isManualSelect) !== null && _currentScanDiscount$2 !== void 0 ? _currentScanDiscount$2 : nextDiscount.isManualSelect
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
return [nextDiscount];
|
|
736
|
+
});
|
|
737
|
+
retainedCommittedDiscounts = currentCommittedDiscounts.filter(function (discount) {
|
|
738
|
+
var id = getDiscountIdentityKey(discount);
|
|
739
|
+
return id === null || !mergedCommittedDiscountIds.has(id);
|
|
740
|
+
}).map(function (discount) {
|
|
741
|
+
var _discount$committedAp2;
|
|
742
|
+
return (_discount$committedAp2 = discount.committedAppliedProductDetails) !== null && _discount$committedAp2 !== void 0 && _discount$committedAp2.length ? _objectSpread(_objectSpread({}, discount), {}, {
|
|
743
|
+
isEditMode: true,
|
|
744
|
+
isDisabled: true,
|
|
745
|
+
isSelected: true,
|
|
746
|
+
isUsed: true,
|
|
747
|
+
appliedProductDetails: _toConsumableArray(discount.committedAppliedProductDetails)
|
|
748
|
+
}) : discount;
|
|
749
|
+
});
|
|
750
|
+
retainedScanDiscounts = currentScanDiscounts.filter(function (discount) {
|
|
751
|
+
var id = getDiscountIdentityKey(discount);
|
|
752
|
+
return id === null || !refreshedScanDiscountIds.has(id);
|
|
648
753
|
});
|
|
649
|
-
mergedDiscountList = [].concat(_toConsumableArray(
|
|
754
|
+
mergedDiscountList = [].concat(_toConsumableArray(retainedCommittedDiscounts), _toConsumableArray(retainedScanDiscounts), _toConsumableArray(runtimeDiscounts));
|
|
650
755
|
if (isCurrentRequest()) {
|
|
651
|
-
_context3.next =
|
|
756
|
+
_context3.next = 26;
|
|
652
757
|
break;
|
|
653
758
|
}
|
|
654
759
|
return _context3.abrupt("return", this.getDiscountList());
|
|
655
|
-
case
|
|
656
|
-
_context3.next =
|
|
760
|
+
case 26:
|
|
761
|
+
_context3.next = 28;
|
|
657
762
|
return (_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.setOriginalDiscountList(mergedDiscountList);
|
|
658
|
-
case
|
|
763
|
+
case 28:
|
|
659
764
|
if (isCurrentRequest()) {
|
|
660
|
-
_context3.next =
|
|
765
|
+
_context3.next = 30;
|
|
661
766
|
break;
|
|
662
767
|
}
|
|
663
768
|
return _context3.abrupt("return", this.getDiscountList());
|
|
664
|
-
case
|
|
665
|
-
_context3.next =
|
|
769
|
+
case 30:
|
|
770
|
+
_context3.next = 32;
|
|
666
771
|
return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.setDiscountList(mergedDiscountList);
|
|
667
|
-
case
|
|
772
|
+
case 32:
|
|
668
773
|
if (isCurrentRequest()) {
|
|
669
|
-
_context3.next =
|
|
774
|
+
_context3.next = 34;
|
|
670
775
|
break;
|
|
671
776
|
}
|
|
672
777
|
return _context3.abrupt("return", this.getDiscountList());
|
|
673
|
-
case
|
|
778
|
+
case 34:
|
|
674
779
|
if (params.apply !== false && (_this$store$tempOrder2 = this.store.tempOrder) !== null && _this$store$tempOrder2 !== void 0 && (_this$store$tempOrder2 = _this$store$tempOrder2.products) !== null && _this$store$tempOrder2 !== void 0 && _this$store$tempOrder2.length) {
|
|
675
780
|
this.applyDiscount();
|
|
676
781
|
}
|
|
677
782
|
return _context3.abrupt("return", this.getDiscountList());
|
|
678
|
-
case
|
|
783
|
+
case 36:
|
|
679
784
|
case "end":
|
|
680
785
|
return _context3.stop();
|
|
681
786
|
}
|
|
@@ -795,7 +900,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
795
900
|
value: function () {
|
|
796
901
|
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(code, customerId) {
|
|
797
902
|
var _this$store$discount11, _tempOrder$holder, _this$store$summary;
|
|
798
|
-
var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref16, isAvailable, newDiscountList, evaluatedDiscountList, unavailableReason, shouldRetainForLater, normalizedNewDiscountList,
|
|
903
|
+
var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref16, isAvailable, newDiscountList, evaluatedDiscountList, unavailableReason, scannedIds, evaluatedScannedDiscounts, shouldRetainForLater, normalizedNewDiscountList, resolvedDiscountList, _this$store$discount12, _this$store$discount13, retainedDiscounts;
|
|
799
904
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
800
905
|
while (1) switch (_context6.prev = _context6.next) {
|
|
801
906
|
case 0:
|
|
@@ -898,46 +1003,72 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
898
1003
|
isAvailable: false,
|
|
899
1004
|
discountList: this.getDiscountList()
|
|
900
1005
|
}, isAvailable = _ref16.isAvailable, newDiscountList = _ref16.discountList, evaluatedDiscountList = _ref16.evaluatedDiscountList, unavailableReason = _ref16.unavailableReason;
|
|
901
|
-
|
|
1006
|
+
scannedIds = new Set(withScanList.map(function (discount) {
|
|
1007
|
+
return String(discount.id);
|
|
1008
|
+
}));
|
|
1009
|
+
evaluatedScannedDiscounts = (evaluatedDiscountList || withScanList).filter(function (discount) {
|
|
1010
|
+
return scannedIds.has(String(discount.id)) && isCustomerPromotionDiscount(discount) && !getDiscountLifecycleReason(discount);
|
|
1011
|
+
});
|
|
1012
|
+
shouldRetainForLater = !isAvailable && evaluatedScannedDiscounts.length > 0;
|
|
902
1013
|
normalizedNewDiscountList = newDiscountList ? markScannedDiscounts(newDiscountList, withScanList) : undefined;
|
|
903
|
-
retainedDiscountList = evaluatedDiscountList ? markScannedDiscounts(evaluatedDiscountList, withScanList) : normalizedNewDiscountList;
|
|
904
1014
|
resolvedDiscountList = normalizedNewDiscountList || this.getDiscountList();
|
|
905
1015
|
if (!(isAvailable && normalizedNewDiscountList)) {
|
|
906
|
-
_context6.next =
|
|
1016
|
+
_context6.next = 37;
|
|
907
1017
|
break;
|
|
908
1018
|
}
|
|
909
|
-
_context6.next =
|
|
1019
|
+
_context6.next = 31;
|
|
910
1020
|
return (_this$store$discount12 = this.store.discount) === null || _this$store$discount12 === void 0 ? void 0 : _this$store$discount12.setDiscountList(normalizedNewDiscountList);
|
|
911
|
-
case
|
|
912
|
-
|
|
913
|
-
|
|
1021
|
+
case 31:
|
|
1022
|
+
// 实际写回商品时沿用扫码试算的优先级,避免旧商品行的选卡覆盖本次扫码。
|
|
1023
|
+
this.applyDiscount({
|
|
1024
|
+
preferredEntitlementPassIds: withScanList.filter(function (discount) {
|
|
1025
|
+
return isEntitlementPass(discount);
|
|
1026
|
+
}).map(function (discount) {
|
|
1027
|
+
return discount.id;
|
|
1028
|
+
})
|
|
1029
|
+
});
|
|
1030
|
+
_context6.next = 34;
|
|
914
1031
|
return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
915
|
-
case
|
|
1032
|
+
case 34:
|
|
916
1033
|
resolvedDiscountList = this.getDiscountList();
|
|
917
|
-
_context6.next =
|
|
1034
|
+
_context6.next = 45;
|
|
918
1035
|
break;
|
|
919
|
-
case
|
|
920
|
-
if (!
|
|
921
|
-
_context6.next =
|
|
1036
|
+
case 37:
|
|
1037
|
+
if (!shouldRetainForLater) {
|
|
1038
|
+
_context6.next = 45;
|
|
922
1039
|
break;
|
|
923
1040
|
}
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
1041
|
+
// 只合并本次识别的卡券;不把试算产生的其他选券状态写回订单。
|
|
1042
|
+
retainedDiscounts = new Map(this.getDiscountList().map(function (discount) {
|
|
1043
|
+
return [String(discount.id), discount];
|
|
1044
|
+
}));
|
|
1045
|
+
evaluatedScannedDiscounts.forEach(function (discount) {
|
|
1046
|
+
retainedDiscounts.set(String(discount.id), _objectSpread(_objectSpread({}, discount), {}, {
|
|
1047
|
+
isScan: true,
|
|
1048
|
+
isAvailable: false,
|
|
1049
|
+
isSelected: false,
|
|
1050
|
+
reasonCode: discount.reasonCode || 'product_not_applicable',
|
|
1051
|
+
appliedProductDetails: [],
|
|
1052
|
+
savedAmount: 0
|
|
1053
|
+
}));
|
|
1054
|
+
});
|
|
1055
|
+
_context6.next = 42;
|
|
1056
|
+
return (_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.setDiscountList(_toConsumableArray(retainedDiscounts.values()));
|
|
1057
|
+
case 42:
|
|
1058
|
+
_context6.next = 44;
|
|
928
1059
|
return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
929
|
-
case
|
|
1060
|
+
case 44:
|
|
930
1061
|
resolvedDiscountList = this.getDiscountList();
|
|
931
|
-
case
|
|
1062
|
+
case 45:
|
|
932
1063
|
return _context6.abrupt("return", {
|
|
933
1064
|
type: 'clientCalc',
|
|
934
1065
|
isAvailable: isAvailable || false,
|
|
935
1066
|
isAccepted: Boolean(isAvailable || shouldRetainForLater),
|
|
936
1067
|
discountList: resolvedDiscountList,
|
|
937
|
-
scannedDiscountList:
|
|
1068
|
+
scannedDiscountList: evaluatedScannedDiscounts,
|
|
938
1069
|
unavailableReason: unavailableReason
|
|
939
1070
|
});
|
|
940
|
-
case
|
|
1071
|
+
case 46:
|
|
941
1072
|
case "end":
|
|
942
1073
|
return _context6.stop();
|
|
943
1074
|
}
|
|
@@ -953,7 +1084,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
953
1084
|
value: function applyDiscount(options) {
|
|
954
1085
|
var _this$store$discount16,
|
|
955
1086
|
_this$store$summary2,
|
|
956
|
-
|
|
1087
|
+
_this4 = this;
|
|
957
1088
|
var tempOrder = this.store.tempOrder;
|
|
958
1089
|
// 任意 products CRUD 后都应当重算 discount 状态;即使 products 为空,
|
|
959
1090
|
// 也需要让 Rules.calcDiscount 把 DiscountModule 的 isSelected / isAvailable /
|
|
@@ -985,7 +1116,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
985
1116
|
orderTotalAmount: Number(((_this$store$summary2 = this.store.summary) === null || _this$store$summary2 === void 0 ? void 0 : _this$store$summary2.total_amount) || 0)
|
|
986
1117
|
}, {
|
|
987
1118
|
reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids,
|
|
988
|
-
reapplyWeighedDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyWeighedDiscountProductUids
|
|
1119
|
+
reapplyWeighedDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyWeighedDiscountProductUids,
|
|
1120
|
+
preferredEntitlementPassIds: options === null || options === void 0 ? void 0 : options.preferredEntitlementPassIds
|
|
989
1121
|
});
|
|
990
1122
|
if (result !== null && result !== void 0 && result.productList) {
|
|
991
1123
|
var previousProductsByUid = indexOrderProductsByUid(tempOrder.products);
|
|
@@ -1010,7 +1142,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1010
1142
|
(_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 || _this$store$discount17.setDiscountList(result.discountList);
|
|
1011
1143
|
}
|
|
1012
1144
|
this.hasActiveCustomerBoundDiscount = (tempOrder.products || []).some(function (product) {
|
|
1013
|
-
return
|
|
1145
|
+
return _this4.productHasCustomerBoundDiscount(product);
|
|
1014
1146
|
});
|
|
1015
1147
|
}
|
|
1016
1148
|
|
|
@@ -1073,7 +1205,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1073
1205
|
var _evaluatePromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
1074
1206
|
var _this$promotionEvalua,
|
|
1075
1207
|
_this$promotionEvalua2,
|
|
1076
|
-
|
|
1208
|
+
_this5 = this;
|
|
1077
1209
|
var tempOrder, strategyConfigs, result, removeSet, _iterator3, _step3, reduce, _iterator6, _step6, _loop2, _iterator4, _step4, _loop, payload;
|
|
1078
1210
|
return _regeneratorRuntime().wrap(function _callee7$(_context9) {
|
|
1079
1211
|
while (1) switch (_context9.prev = _context9.next) {
|
|
@@ -1232,7 +1364,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1232
1364
|
case 6:
|
|
1233
1365
|
_context7.prev = 6;
|
|
1234
1366
|
_context7.next = 9;
|
|
1235
|
-
return
|
|
1367
|
+
return _this5.giftSelectResolver({
|
|
1236
1368
|
strategyId: addAction.strategyId,
|
|
1237
1369
|
strategyName: addAction.strategyName,
|
|
1238
1370
|
giftCount: addAction.giftCount,
|
|
@@ -1267,7 +1399,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1267
1399
|
_context7.next = 26;
|
|
1268
1400
|
break;
|
|
1269
1401
|
}
|
|
1270
|
-
linked =
|
|
1402
|
+
linked = _this5.createLinkedProductAndBooking({
|
|
1271
1403
|
product: gp,
|
|
1272
1404
|
booking: booking
|
|
1273
1405
|
});
|
|
@@ -1597,12 +1729,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1597
1729
|
}, {
|
|
1598
1730
|
key: "rememberPointCardSnapshotCodeCandidates",
|
|
1599
1731
|
value: function rememberPointCardSnapshotCodeCandidates(value) {
|
|
1600
|
-
var
|
|
1732
|
+
var _this6 = this;
|
|
1601
1733
|
collectPointCardSnapshotCodeCandidates(value).forEach(function (_ref18) {
|
|
1602
1734
|
var id = _ref18.id,
|
|
1603
1735
|
code = _ref18.code;
|
|
1604
|
-
if (!
|
|
1605
|
-
|
|
1736
|
+
if (!_this6.pointCardSnapshotCodeCandidates.has(id)) {
|
|
1737
|
+
_this6.pointCardSnapshotCodeCandidates.set(id, code);
|
|
1606
1738
|
}
|
|
1607
1739
|
});
|
|
1608
1740
|
}
|
|
@@ -1809,23 +1941,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1809
1941
|
}, {
|
|
1810
1942
|
key: "calculatePaymentTotal",
|
|
1811
1943
|
value: function calculatePaymentTotal(payments) {
|
|
1812
|
-
var
|
|
1944
|
+
var _this7 = this;
|
|
1813
1945
|
return mapPaymentItemsToOrderPayments(payments, {
|
|
1814
1946
|
includeVoided: false
|
|
1815
1947
|
}).reduce(function (sum, payment) {
|
|
1816
1948
|
if (!isPaidPaymentRecord(payment)) return sum;
|
|
1817
|
-
return sum.plus(
|
|
1949
|
+
return sum.plus(_this7.calculatePaymentEffectiveAmount(payment));
|
|
1818
1950
|
}, new Decimal(0));
|
|
1819
1951
|
}
|
|
1820
1952
|
}, {
|
|
1821
1953
|
key: "calculateOrderPaidPaymentTotal",
|
|
1822
1954
|
value: function calculateOrderPaidPaymentTotal(payments) {
|
|
1823
|
-
var
|
|
1955
|
+
var _this8 = this;
|
|
1824
1956
|
return mapPaymentItemsToOrderPayments(payments, {
|
|
1825
1957
|
includeVoided: false
|
|
1826
1958
|
}).reduce(function (sum, payment) {
|
|
1827
1959
|
if (!isPaidPaymentRecord(payment)) return sum;
|
|
1828
|
-
return sum.plus(
|
|
1960
|
+
return sum.plus(_this8.calculatePaymentGapAmount(payment));
|
|
1829
1961
|
}, new Decimal(0));
|
|
1830
1962
|
}
|
|
1831
1963
|
}, {
|
|
@@ -1961,13 +2093,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1961
2093
|
}, {
|
|
1962
2094
|
key: "calculateDepositPaidAmount",
|
|
1963
2095
|
value: function calculateDepositPaidAmount(payments) {
|
|
1964
|
-
var
|
|
2096
|
+
var _this9 = this;
|
|
1965
2097
|
return (payments || []).reduce(function (sum, payment) {
|
|
1966
2098
|
var paymentRecord = payment;
|
|
1967
2099
|
if (!isPaidPaymentRecord(paymentRecord)) return sum;
|
|
1968
2100
|
var isDepositPayment = paymentRecord.type === 'deposit' || paymentRecord.order_payment_type === 'deposit';
|
|
1969
2101
|
if (!isDepositPayment) return sum;
|
|
1970
|
-
return sum.plus(
|
|
2102
|
+
return sum.plus(_this9.calculatePaymentGapAmount(paymentRecord));
|
|
1971
2103
|
}, new Decimal(0));
|
|
1972
2104
|
}
|
|
1973
2105
|
}, {
|
|
@@ -2004,17 +2136,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2004
2136
|
}, {
|
|
2005
2137
|
key: "getPaymentNumberDevicePrefixSync",
|
|
2006
2138
|
value: function getPaymentNumberDevicePrefixSync() {
|
|
2007
|
-
var
|
|
2139
|
+
var _this10 = this;
|
|
2008
2140
|
return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
|
|
2009
|
-
return
|
|
2141
|
+
return _this10.getPaymentNumberAppData(key);
|
|
2010
2142
|
});
|
|
2011
2143
|
}
|
|
2012
2144
|
}, {
|
|
2013
2145
|
key: "getPaymentNumberDevicePrefixAsync",
|
|
2014
2146
|
value: function getPaymentNumberDevicePrefixAsync() {
|
|
2015
|
-
var
|
|
2147
|
+
var _this11 = this;
|
|
2016
2148
|
return resolvePaymentNumberDevicePrefix(function (key) {
|
|
2017
|
-
return
|
|
2149
|
+
return _this11.getPaymentNumberAppData(key);
|
|
2018
2150
|
});
|
|
2019
2151
|
}
|
|
2020
2152
|
}, {
|
|
@@ -2144,16 +2276,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2144
2276
|
}, {
|
|
2145
2277
|
key: "calculatePaidPaymentSummary",
|
|
2146
2278
|
value: function calculatePaidPaymentSummary(payments) {
|
|
2147
|
-
var
|
|
2279
|
+
var _this12 = this;
|
|
2148
2280
|
return (payments || []).reduce(function (summary, payment) {
|
|
2149
2281
|
var paymentRecord = payment;
|
|
2150
2282
|
if (!isPaidPaymentRecord(paymentRecord)) return summary;
|
|
2151
2283
|
return {
|
|
2152
2284
|
customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
|
|
2153
|
-
orderPaidAmount: summary.orderPaidAmount.plus(
|
|
2154
|
-
gapPaidAmount: summary.gapPaidAmount.plus(
|
|
2155
|
-
payServiceChargeAmount: summary.payServiceChargeAmount.plus(
|
|
2156
|
-
roundingAmount: summary.roundingAmount.plus(
|
|
2285
|
+
orderPaidAmount: summary.orderPaidAmount.plus(_this12.calculatePaymentOrderAmount(paymentRecord)),
|
|
2286
|
+
gapPaidAmount: summary.gapPaidAmount.plus(_this12.calculatePaymentGapAmount(paymentRecord)),
|
|
2287
|
+
payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this12.calculatePaymentServiceFee(paymentRecord)),
|
|
2288
|
+
roundingAmount: summary.roundingAmount.plus(_this12.calculatePaymentRoundingAmount(paymentRecord))
|
|
2157
2289
|
};
|
|
2158
2290
|
}, {
|
|
2159
2291
|
customerPaidAmount: new Decimal(0),
|
|
@@ -2360,15 +2492,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2360
2492
|
}, {
|
|
2361
2493
|
key: "normalizeFingerprintValue",
|
|
2362
2494
|
value: function normalizeFingerprintValue(value) {
|
|
2363
|
-
var
|
|
2495
|
+
var _this13 = this;
|
|
2364
2496
|
if (Array.isArray(value)) {
|
|
2365
2497
|
return value.map(function (item) {
|
|
2366
|
-
return
|
|
2498
|
+
return _this13.normalizeFingerprintValue(item);
|
|
2367
2499
|
});
|
|
2368
2500
|
}
|
|
2369
2501
|
if (!value || _typeof(value) !== 'object') return value !== null && value !== void 0 ? value : '';
|
|
2370
2502
|
return Object.keys(value).sort().reduce(function (result, key) {
|
|
2371
|
-
result[key] =
|
|
2503
|
+
result[key] = _this13.normalizeFingerprintValue(value[key]);
|
|
2372
2504
|
return result;
|
|
2373
2505
|
}, {});
|
|
2374
2506
|
}
|
|
@@ -2383,14 +2515,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2383
2515
|
_sku$barcode,
|
|
2384
2516
|
_ref26,
|
|
2385
2517
|
_sku$variant_id,
|
|
2386
|
-
|
|
2518
|
+
_this14 = this;
|
|
2387
2519
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
2388
2520
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
2389
2521
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
2390
2522
|
var _discount$type;
|
|
2391
2523
|
return (_discount$type = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type !== void 0 ? _discount$type : discount === null || discount === void 0 ? void 0 : discount.tag;
|
|
2392
2524
|
});
|
|
2393
|
-
var
|
|
2525
|
+
var fullCoveragePassType = discountTypes.find(function (type) {
|
|
2526
|
+
return ['entitlement_pass', 'good_pass'].includes(type);
|
|
2527
|
+
});
|
|
2528
|
+
var extensionType = (product === null || product === void 0 ? void 0 : product.extension_type) || fullCoveragePassType || 'normal';
|
|
2394
2529
|
return {
|
|
2395
2530
|
product_id: (_product$product_id2 = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : null,
|
|
2396
2531
|
product_variant_id: (_product$product_vari = product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : null,
|
|
@@ -2417,7 +2552,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2417
2552
|
option_group_id: (_option$option_group_ = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_ !== void 0 ? _option$option_group_ : null,
|
|
2418
2553
|
option_group_item_id: (_ref28 = (_option$option_group_2 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_2 !== void 0 ? _option$option_group_2 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref28 !== void 0 ? _ref28 : null,
|
|
2419
2554
|
num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
|
|
2420
|
-
add_price:
|
|
2555
|
+
add_price: _this14.normalizeFingerprintMoney((_option$add_price = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price !== void 0 ? _option$add_price : option === null || option === void 0 ? void 0 : option.price)
|
|
2421
2556
|
};
|
|
2422
2557
|
})
|
|
2423
2558
|
}),
|
|
@@ -2427,8 +2562,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2427
2562
|
bundle_product_id: (_ref29 = (_ref30 = (_bundle$bundle_produc = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref30 !== void 0 ? _ref30 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref29 !== void 0 ? _ref29 : null,
|
|
2428
2563
|
bundle_variant_id: (_ref31 = (_bundle$bundle_varian = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle === null || bundle === void 0 ? void 0 : bundle.product_variant_id) !== null && _ref31 !== void 0 ? _ref31 : 0,
|
|
2429
2564
|
num: getSafeProductNum((_bundle$num = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num !== void 0 ? _bundle$num : bundle === null || bundle === void 0 ? void 0 : bundle.quantity),
|
|
2430
|
-
price:
|
|
2431
|
-
bundle_selling_price:
|
|
2565
|
+
price: _this14.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
|
|
2566
|
+
bundle_selling_price: _this14.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
|
|
2432
2567
|
price_type: (_bundle$price_type = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type !== void 0 ? _bundle$price_type : '',
|
|
2433
2568
|
price_type_ext: (_bundle$price_type_ex = bundle === null || bundle === void 0 ? void 0 : bundle.price_type_ext) !== null && _bundle$price_type_ex !== void 0 ? _bundle$price_type_ex : ''
|
|
2434
2569
|
};
|
|
@@ -2438,7 +2573,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2438
2573
|
return {
|
|
2439
2574
|
type: (_ref32 = (_discount$type2 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type2 !== void 0 ? _discount$type2 : discount === null || discount === void 0 ? void 0 : discount.tag) !== null && _ref32 !== void 0 ? _ref32 : '',
|
|
2440
2575
|
discount_id: (_ref33 = (_ref34 = (_discount$discount_id = discount === null || discount === void 0 ? void 0 : discount.discount_id) !== null && _discount$discount_id !== void 0 ? _discount$discount_id : discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null && _ref34 !== void 0 ? _ref34 : discount === null || discount === void 0 || (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) !== null && _ref33 !== void 0 ? _ref33 : null,
|
|
2441
|
-
amount:
|
|
2576
|
+
amount: _this14.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
2442
2577
|
};
|
|
2443
2578
|
}))
|
|
2444
2579
|
};
|
|
@@ -2446,9 +2581,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2446
2581
|
}, {
|
|
2447
2582
|
key: "buildOrderProductsFingerprint",
|
|
2448
2583
|
value: function buildOrderProductsFingerprint(products) {
|
|
2449
|
-
var
|
|
2584
|
+
var _this15 = this;
|
|
2450
2585
|
var items = (products || []).map(function (product) {
|
|
2451
|
-
return
|
|
2586
|
+
return _this15.buildProductFingerprintItem(product);
|
|
2452
2587
|
});
|
|
2453
2588
|
items.sort(function (left, right) {
|
|
2454
2589
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -2470,14 +2605,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2470
2605
|
_sku$barcode2,
|
|
2471
2606
|
_ref36,
|
|
2472
2607
|
_sku$variant_id2,
|
|
2473
|
-
|
|
2608
|
+
_this16 = this;
|
|
2474
2609
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
2475
2610
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
2476
2611
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
2477
2612
|
var _discount$type3;
|
|
2478
2613
|
return (_discount$type3 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type3 !== void 0 ? _discount$type3 : discount === null || discount === void 0 ? void 0 : discount.tag;
|
|
2479
2614
|
});
|
|
2480
|
-
var
|
|
2615
|
+
var fullCoveragePassType = discountTypes.find(function (type) {
|
|
2616
|
+
return ['entitlement_pass', 'good_pass'].includes(type);
|
|
2617
|
+
});
|
|
2618
|
+
var extensionType = (product === null || product === void 0 ? void 0 : product.extension_type) || fullCoveragePassType || 'normal';
|
|
2481
2619
|
return {
|
|
2482
2620
|
product_id: (_product$product_id3 = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id3 !== void 0 ? _product$product_id3 : null,
|
|
2483
2621
|
product_variant_id: (_product$product_vari2 = product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _product$product_vari2 !== void 0 ? _product$product_vari2 : null,
|
|
@@ -2501,7 +2639,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2501
2639
|
option_group_id: (_option$option_group_3 = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_3 !== void 0 ? _option$option_group_3 : null,
|
|
2502
2640
|
option_group_item_id: (_ref38 = (_option$option_group_4 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_4 !== void 0 ? _option$option_group_4 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref38 !== void 0 ? _ref38 : null,
|
|
2503
2641
|
num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
|
|
2504
|
-
add_price:
|
|
2642
|
+
add_price: _this16.normalizeFingerprintMoney((_option$add_price2 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price2 !== void 0 ? _option$add_price2 : option === null || option === void 0 ? void 0 : option.price)
|
|
2505
2643
|
};
|
|
2506
2644
|
})
|
|
2507
2645
|
}),
|
|
@@ -2515,14 +2653,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2515
2653
|
num: getSafeProductNum((_bundle$num2 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num2 !== void 0 ? _bundle$num2 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity),
|
|
2516
2654
|
price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
|
|
2517
2655
|
price_type_ext: (_bundle$price_type_ex2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type_ext) !== null && _bundle$price_type_ex2 !== void 0 ? _bundle$price_type_ex2 : '',
|
|
2518
|
-
option:
|
|
2656
|
+
option: _this16.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
|
|
2519
2657
|
var _ref44, _option$id3, _option$option_group_5, _ref45, _option$option_group_6, _option$num3, _option$add_price3;
|
|
2520
2658
|
return {
|
|
2521
2659
|
id: (_ref44 = (_option$id3 = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id3 !== void 0 ? _option$id3 : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref44 !== void 0 ? _ref44 : null,
|
|
2522
2660
|
option_group_id: (_option$option_group_5 = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_5 !== void 0 ? _option$option_group_5 : null,
|
|
2523
2661
|
option_group_item_id: (_ref45 = (_option$option_group_6 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_6 !== void 0 ? _option$option_group_6 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref45 !== void 0 ? _ref45 : null,
|
|
2524
2662
|
num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
|
|
2525
|
-
add_price:
|
|
2663
|
+
add_price: _this16.normalizeFingerprintMoney((_option$add_price3 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price3 !== void 0 ? _option$add_price3 : option === null || option === void 0 ? void 0 : option.price)
|
|
2526
2664
|
};
|
|
2527
2665
|
}))
|
|
2528
2666
|
};
|
|
@@ -2532,7 +2670,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2532
2670
|
return {
|
|
2533
2671
|
type: (_ref46 = (_discount$type4 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type4 !== void 0 ? _discount$type4 : discount === null || discount === void 0 ? void 0 : discount.tag) !== null && _ref46 !== void 0 ? _ref46 : '',
|
|
2534
2672
|
discount_id: (_ref47 = (_ref48 = (_discount$discount_id2 = discount === null || discount === void 0 ? void 0 : discount.discount_id) !== null && _discount$discount_id2 !== void 0 ? _discount$discount_id2 : discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null && _ref48 !== void 0 ? _ref48 : discount === null || discount === void 0 || (_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) !== null && _ref47 !== void 0 ? _ref47 : null,
|
|
2535
|
-
amount:
|
|
2673
|
+
amount: _this16.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
2536
2674
|
};
|
|
2537
2675
|
}))
|
|
2538
2676
|
};
|
|
@@ -2540,9 +2678,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2540
2678
|
}, {
|
|
2541
2679
|
key: "buildOrderProductsStructuralFingerprint",
|
|
2542
2680
|
value: function buildOrderProductsStructuralFingerprint(products) {
|
|
2543
|
-
var
|
|
2681
|
+
var _this17 = this;
|
|
2544
2682
|
var items = (products || []).map(function (product) {
|
|
2545
|
-
return
|
|
2683
|
+
return _this17.buildProductStructuralFingerprintItem(product);
|
|
2546
2684
|
});
|
|
2547
2685
|
items.sort(function (left, right) {
|
|
2548
2686
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -2994,9 +3132,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2994
3132
|
}, {
|
|
2995
3133
|
key: "sanitizeTempOrderProducts",
|
|
2996
3134
|
value: function sanitizeTempOrderProducts(tempOrder) {
|
|
2997
|
-
var
|
|
3135
|
+
var _this18 = this;
|
|
2998
3136
|
tempOrder.products = (tempOrder.products || []).map(function (product) {
|
|
2999
|
-
return
|
|
3137
|
+
return _this18.sanitizeOrderProductForTempOrder(_this18.normalizeVirtualSettlementProductIfEnabled(product));
|
|
3000
3138
|
});
|
|
3001
3139
|
this.syncTempOrderSettlementState(tempOrder);
|
|
3002
3140
|
ensureUniqueProductLineUids(tempOrder);
|
|
@@ -3116,7 +3254,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3116
3254
|
}, {
|
|
3117
3255
|
key: "syncLinkedBookingHoldersToProducts",
|
|
3118
3256
|
value: function syncLinkedBookingHoldersToProducts(tempOrder) {
|
|
3119
|
-
var
|
|
3257
|
+
var _this19 = this;
|
|
3120
3258
|
var bookings = tempOrder.bookings || [];
|
|
3121
3259
|
var products = tempOrder.products || [];
|
|
3122
3260
|
if (!bookings.length || !products.length) return;
|
|
@@ -3125,6 +3263,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3125
3263
|
bookings.forEach(function (booking) {
|
|
3126
3264
|
var _booking$metadata2, _booking$metadata3;
|
|
3127
3265
|
if (!booking || _typeof(booking) !== 'object') return;
|
|
3266
|
+
if (isFulfillmentTimingBooking(booking)) return;
|
|
3128
3267
|
var productUid = booking.product_uid || ((_booking$metadata2 = booking.metadata) === null || _booking$metadata2 === void 0 ? void 0 : _booking$metadata2.product_uid);
|
|
3129
3268
|
if (productUid !== undefined && productUid !== null && String(productUid) !== '') {
|
|
3130
3269
|
bookingByProductUid.set(String(productUid), booking);
|
|
@@ -3141,7 +3280,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3141
3280
|
var bookingUid = product.booking_uid || ((_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.booking_uid);
|
|
3142
3281
|
var linkedBooking = (productUid !== undefined && productUid !== null && String(productUid) !== '' ? bookingByProductUid.get(String(productUid)) : undefined) || (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '' ? bookingByBookingUid.get(String(bookingUid)) : undefined);
|
|
3143
3282
|
if (linkedBooking) {
|
|
3144
|
-
|
|
3283
|
+
_this19.setProductHolderFromBooking(product, linkedBooking);
|
|
3145
3284
|
}
|
|
3146
3285
|
});
|
|
3147
3286
|
}
|
|
@@ -3189,6 +3328,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3189
3328
|
try {
|
|
3190
3329
|
for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
|
|
3191
3330
|
var booking = _step18.value;
|
|
3331
|
+
if (isFulfillmentTimingBooking(booking)) continue;
|
|
3192
3332
|
var holder = booking !== null && booking !== void 0 && booking.holder && _typeof(booking.holder) === 'object' ? booking.holder : null;
|
|
3193
3333
|
if (!baseHolder && holder) {
|
|
3194
3334
|
baseHolder = holder;
|
|
@@ -3247,7 +3387,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3247
3387
|
}, {
|
|
3248
3388
|
key: "syncTempOrderHolderFromBookings",
|
|
3249
3389
|
value: function syncTempOrderHolderFromBookings(tempOrder) {
|
|
3250
|
-
var bookings = tempOrder.bookings || []
|
|
3390
|
+
var bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
3391
|
+
return !isFulfillmentTimingBooking(booking);
|
|
3392
|
+
});
|
|
3251
3393
|
var hasHolderSource = bookings.some(function (booking) {
|
|
3252
3394
|
var _booking$metadata4;
|
|
3253
3395
|
return (booking === null || booking === void 0 ? void 0 : booking.holder) !== undefined || (booking === null || booking === void 0 || (_booking$metadata4 = booking.metadata) === null || _booking$metadata4 === void 0 ? void 0 : _booking$metadata4.holder_id) !== undefined;
|
|
@@ -3269,9 +3411,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3269
3411
|
}, {
|
|
3270
3412
|
key: "findBookingIndexByUniqueIdentificationNumber",
|
|
3271
3413
|
value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
|
|
3272
|
-
var
|
|
3414
|
+
var _this20 = this;
|
|
3273
3415
|
return (tempOrder.bookings || []).findIndex(function (booking) {
|
|
3274
|
-
return
|
|
3416
|
+
return _this20.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
|
|
3275
3417
|
});
|
|
3276
3418
|
}
|
|
3277
3419
|
}, {
|
|
@@ -3279,12 +3421,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3279
3421
|
value: function removeLinkedBookingsForProduct(tempOrder, product) {
|
|
3280
3422
|
var _product$metadata5,
|
|
3281
3423
|
_product$metadata6,
|
|
3282
|
-
|
|
3424
|
+
_this21 = this;
|
|
3283
3425
|
var productUid = (product === null || product === void 0 || (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
3284
3426
|
var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.booking_uid);
|
|
3285
3427
|
if (!productUid && !bookingUid) return;
|
|
3286
3428
|
tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
3287
|
-
|
|
3429
|
+
if (isFulfillmentTimingBooking(booking)) return true;
|
|
3430
|
+
var currentBookingUid = _this21.getBookingUniqueIdentificationNumber(booking);
|
|
3288
3431
|
if (bookingUid && currentBookingUid === String(bookingUid)) return false;
|
|
3289
3432
|
if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
|
|
3290
3433
|
return true;
|
|
@@ -3586,7 +3729,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3586
3729
|
}, {
|
|
3587
3730
|
key: "removeSalesNotesForMissingProductLines",
|
|
3588
3731
|
value: function removeSalesNotesForMissingProductLines(tempOrder) {
|
|
3589
|
-
var
|
|
3732
|
+
var _this22 = this;
|
|
3590
3733
|
var state = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
3591
3734
|
if (!state.loaded || !Array.isArray(tempOrder.notes) || tempOrder.notes.length === 0) {
|
|
3592
3735
|
return;
|
|
@@ -3598,7 +3741,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3598
3741
|
return typeof uid === 'string' && uid.length > 0;
|
|
3599
3742
|
}));
|
|
3600
3743
|
var nextNotes = tempOrder.notes.filter(function (note) {
|
|
3601
|
-
var primary =
|
|
3744
|
+
var primary = _this22.getSalesNotePrimaryRelation(note);
|
|
3602
3745
|
if (!primary || primary.target_type !== 'order_detail') return true;
|
|
3603
3746
|
return remainingProductUids.has(primary.target_uuid);
|
|
3604
3747
|
});
|
|
@@ -3610,7 +3753,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3610
3753
|
key: "setSalesNoteOnTempOrder",
|
|
3611
3754
|
value: function setSalesNoteOnTempOrder(tempOrder, input) {
|
|
3612
3755
|
var _input$target,
|
|
3613
|
-
|
|
3756
|
+
_this23 = this,
|
|
3614
3757
|
_tempOrder$shop_order;
|
|
3615
3758
|
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
3616
3759
|
var note_type = String(input.note_type || '').trim();
|
|
@@ -3634,7 +3777,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3634
3777
|
var notes = tempOrder.notes || [];
|
|
3635
3778
|
// 当前 allergy policy 固定同一商品行只保留一条;业务调用方不参与去重规则。
|
|
3636
3779
|
var existingIndex = policy.uniquePerPrimaryTarget ? notes.findIndex(function (note) {
|
|
3637
|
-
var primary =
|
|
3780
|
+
var primary = _this23.getSalesNotePrimaryRelation(note);
|
|
3638
3781
|
return note.note_type === note_type && (primary === null || primary === void 0 ? void 0 : primary.target_type) === 'order_detail' && primary.target_uuid === target_uuid;
|
|
3639
3782
|
}) : -1;
|
|
3640
3783
|
var existing = existingIndex >= 0 ? notes[existingIndex] : null;
|
|
@@ -3871,10 +4014,47 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3871
4014
|
}, {
|
|
3872
4015
|
key: "updateTempOrderServiceType",
|
|
3873
4016
|
value: function updateTempOrderServiceType(serviceType) {
|
|
4017
|
+
if (serviceType !== 'pick_up') {
|
|
4018
|
+
var tempOrder = this.ensureTempOrder();
|
|
4019
|
+
tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
4020
|
+
return !isFulfillmentTimingBooking(booking);
|
|
4021
|
+
});
|
|
4022
|
+
}
|
|
3874
4023
|
return this.updateTempOrderShopServiceData({
|
|
3875
4024
|
service_type: serviceType
|
|
3876
4025
|
});
|
|
3877
4026
|
}
|
|
4027
|
+
}, {
|
|
4028
|
+
key: "getPickupTimingBooking",
|
|
4029
|
+
value: function getPickupTimingBooking() {
|
|
4030
|
+
var _this$store$tempOrder7;
|
|
4031
|
+
return (((_this$store$tempOrder7 = this.store.tempOrder) === null || _this$store$tempOrder7 === void 0 ? void 0 : _this$store$tempOrder7.bookings) || []).find(isFulfillmentTimingBooking) || null;
|
|
4032
|
+
}
|
|
4033
|
+
}, {
|
|
4034
|
+
key: "setPickupTimingBooking",
|
|
4035
|
+
value: function setPickupTimingBooking(input) {
|
|
4036
|
+
var tempOrder = this.ensureTempOrder();
|
|
4037
|
+
var bookings = tempOrder.bookings || [];
|
|
4038
|
+
var firstIndex = bookings.findIndex(isFulfillmentTimingBooking);
|
|
4039
|
+
var nextBooking = buildPickupTimingBooking(input, bookings[firstIndex]);
|
|
4040
|
+
// Keep the first row's identity and position; repair duplicate marked rows only.
|
|
4041
|
+
tempOrder.bookings = firstIndex === -1 ? [].concat(_toConsumableArray(bookings), [nextBooking]) : bookings.flatMap(function (booking, index) {
|
|
4042
|
+
return index === firstIndex ? [nextBooking] : isFulfillmentTimingBooking(booking) ? [] : [booking];
|
|
4043
|
+
});
|
|
4044
|
+
this.notifyTempOrderChanged();
|
|
4045
|
+
return nextBooking;
|
|
4046
|
+
}
|
|
4047
|
+
}, {
|
|
4048
|
+
key: "clearPickupTimingBooking",
|
|
4049
|
+
value: function clearPickupTimingBooking() {
|
|
4050
|
+
var _tempOrder$bookings;
|
|
4051
|
+
var tempOrder = this.store.tempOrder;
|
|
4052
|
+
if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$bookings = tempOrder.bookings) !== null && _tempOrder$bookings !== void 0 && _tempOrder$bookings.some(isFulfillmentTimingBooking))) return;
|
|
4053
|
+
tempOrder.bookings = tempOrder.bookings.filter(function (booking) {
|
|
4054
|
+
return !isFulfillmentTimingBooking(booking);
|
|
4055
|
+
});
|
|
4056
|
+
this.notifyTempOrderChanged();
|
|
4057
|
+
}
|
|
3878
4058
|
}, {
|
|
3879
4059
|
key: "updateTempOrderContactsInfo",
|
|
3880
4060
|
value: function updateTempOrderContactsInfo(contactsInfo) {
|
|
@@ -3906,7 +4086,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3906
4086
|
value: function isCustomerBoundDiscount(discount) {
|
|
3907
4087
|
var _discount$type5;
|
|
3908
4088
|
var type = (_discount$type5 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type5 !== void 0 ? _discount$type5 : discount === null || discount === void 0 ? void 0 : discount.tag;
|
|
3909
|
-
return type === 'good_pass' || type === 'discount_card' || type === 'product_discount_card';
|
|
4089
|
+
return type === 'entitlement_pass' || type === 'good_pass' || type === 'discount_card' || type === 'product_discount_card';
|
|
3910
4090
|
}
|
|
3911
4091
|
}, {
|
|
3912
4092
|
key: "shouldKeepCustomerBoundDiscountAfterCustomerChange",
|
|
@@ -3916,15 +4096,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3916
4096
|
}, {
|
|
3917
4097
|
key: "productHasCustomerBoundDiscount",
|
|
3918
4098
|
value: function productHasCustomerBoundDiscount(product) {
|
|
3919
|
-
var
|
|
4099
|
+
var _this24 = this;
|
|
3920
4100
|
if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
|
|
3921
|
-
return
|
|
4101
|
+
return _this24.isCustomerBoundDiscount(discount);
|
|
3922
4102
|
})) {
|
|
3923
4103
|
return true;
|
|
3924
4104
|
}
|
|
3925
4105
|
return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
|
|
3926
4106
|
return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
|
|
3927
|
-
return
|
|
4107
|
+
return _this24.isCustomerBoundDiscount(discount);
|
|
3928
4108
|
});
|
|
3929
4109
|
});
|
|
3930
4110
|
}
|
|
@@ -3933,18 +4113,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3933
4113
|
value: function shouldSkipDiscountCalculation(tempOrder) {
|
|
3934
4114
|
var _this$store$discount20,
|
|
3935
4115
|
_this$store$discount21,
|
|
3936
|
-
|
|
4116
|
+
_this25 = this;
|
|
3937
4117
|
if (this.hasActiveCustomerBoundDiscount) return false;
|
|
3938
4118
|
var discountList = ((_this$store$discount20 = this.store.discount) === null || _this$store$discount20 === void 0 || (_this$store$discount21 = _this$store$discount20.getDiscountList) === null || _this$store$discount21 === void 0 ? void 0 : _this$store$discount21.call(_this$store$discount20)) || [];
|
|
3939
4119
|
if (discountList.length > 0) return false;
|
|
3940
4120
|
return !(tempOrder.products || []).some(function (product) {
|
|
3941
|
-
return
|
|
4121
|
+
return _this25.productHasCustomerBoundDiscount(product);
|
|
3942
4122
|
});
|
|
3943
4123
|
}
|
|
3944
4124
|
}, {
|
|
3945
4125
|
key: "clearCustomerBoundDiscounts",
|
|
3946
4126
|
value: function clearCustomerBoundDiscounts(tempOrder) {
|
|
3947
|
-
var
|
|
4127
|
+
var _this26 = this,
|
|
3948
4128
|
_discountModule$getDi,
|
|
3949
4129
|
_discountModule$getOr,
|
|
3950
4130
|
_discountModule$setDi,
|
|
@@ -3953,7 +4133,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3953
4133
|
var filterDiscountList = function filterDiscountList(discountList) {
|
|
3954
4134
|
if (!Array.isArray(discountList)) return [];
|
|
3955
4135
|
return discountList.filter(function (discount) {
|
|
3956
|
-
var shouldRemove =
|
|
4136
|
+
var shouldRemove = _this26.isCustomerBoundDiscount(discount);
|
|
3957
4137
|
if (shouldRemove) didRemoveCustomerBoundDiscount = true;
|
|
3958
4138
|
return !shouldRemove;
|
|
3959
4139
|
});
|
|
@@ -3980,12 +4160,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3980
4160
|
var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
|
|
3981
4161
|
var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
|
|
3982
4162
|
var nextDiscounts = currentDiscounts.filter(function (discount) {
|
|
3983
|
-
if (
|
|
3984
|
-
return !
|
|
4163
|
+
if (_this26.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
4164
|
+
return !_this26.isCustomerBoundDiscount(discount);
|
|
3985
4165
|
});
|
|
3986
4166
|
var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
|
|
3987
|
-
if (
|
|
3988
|
-
return !
|
|
4167
|
+
if (_this26.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
4168
|
+
return !_this26.isCustomerBoundDiscount(discount);
|
|
3989
4169
|
});
|
|
3990
4170
|
void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
|
|
3991
4171
|
void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
|
|
@@ -4088,8 +4268,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4088
4268
|
}, {
|
|
4089
4269
|
key: "getOrderCustomerSnapshot",
|
|
4090
4270
|
value: function getOrderCustomerSnapshot() {
|
|
4091
|
-
var _this$store$
|
|
4092
|
-
var snapshot = (_this$store$
|
|
4271
|
+
var _this$store$tempOrder8;
|
|
4272
|
+
var snapshot = (_this$store$tempOrder8 = this.store.tempOrder) === null || _this$store$tempOrder8 === void 0 || (_this$store$tempOrder8 = _this$store$tempOrder8._extend) === null || _this$store$tempOrder8 === void 0 ? void 0 : _this$store$tempOrder8.customerSnapshot;
|
|
4093
4273
|
return snapshot ? cloneDeep(snapshot) : null;
|
|
4094
4274
|
}
|
|
4095
4275
|
}, {
|
|
@@ -4149,10 +4329,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4149
4329
|
}, {
|
|
4150
4330
|
key: "setOrderPayments",
|
|
4151
4331
|
value: function setOrderPayments(payments) {
|
|
4152
|
-
var
|
|
4332
|
+
var _this27 = this;
|
|
4153
4333
|
var tempOrder = this.ensureTempOrder();
|
|
4154
4334
|
tempOrder.payments = mapPaymentItemsToOrderPayments((payments || []).map(function (payment) {
|
|
4155
|
-
return
|
|
4335
|
+
return _this27.normalizePaymentSource(payment, {
|
|
4156
4336
|
defaultPaid: false
|
|
4157
4337
|
});
|
|
4158
4338
|
}));
|
|
@@ -4207,7 +4387,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4207
4387
|
}, {
|
|
4208
4388
|
key: "addOrderPaymentWithDevicePrefix",
|
|
4209
4389
|
value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
|
|
4210
|
-
var
|
|
4390
|
+
var _this28 = this;
|
|
4211
4391
|
this.logInfo('addOrderPayment', {
|
|
4212
4392
|
payment: payment
|
|
4213
4393
|
});
|
|
@@ -4225,7 +4405,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4225
4405
|
void this.recalculateSummary({
|
|
4226
4406
|
createIfMissing: true
|
|
4227
4407
|
}).catch(function (error) {
|
|
4228
|
-
|
|
4408
|
+
_this28.logError('recalculate summary after addOrderPayment failed', {
|
|
4229
4409
|
error: error instanceof Error ? error.message : String(error)
|
|
4230
4410
|
});
|
|
4231
4411
|
});
|
|
@@ -4338,7 +4518,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4338
4518
|
}, {
|
|
4339
4519
|
key: "applyPaymentLifecycleChange",
|
|
4340
4520
|
value: function applyPaymentLifecycleChange(tempOrder, options) {
|
|
4341
|
-
var
|
|
4521
|
+
var _this29 = this;
|
|
4342
4522
|
this.updateTempOrderPaymentStatus(tempOrder);
|
|
4343
4523
|
if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
|
|
4344
4524
|
this.persistTempOrder();
|
|
@@ -4348,7 +4528,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4348
4528
|
void this.recalculateSummary({
|
|
4349
4529
|
createIfMissing: true
|
|
4350
4530
|
}).catch(function (error) {
|
|
4351
|
-
|
|
4531
|
+
_this29.logError("recalculate summary after ".concat(logContext, " failed"), {
|
|
4352
4532
|
error: error instanceof Error ? error.message : String(error)
|
|
4353
4533
|
});
|
|
4354
4534
|
});
|
|
@@ -4392,7 +4572,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4392
4572
|
}, {
|
|
4393
4573
|
key: "updateVoucherOrderPayments",
|
|
4394
4574
|
value: function updateVoucherOrderPayments(payments, options) {
|
|
4395
|
-
var
|
|
4575
|
+
var _this30 = this;
|
|
4396
4576
|
var tempOrder = this.ensureTempOrder();
|
|
4397
4577
|
var isOrderPaymentType = function isOrderPaymentType(value) {
|
|
4398
4578
|
return value === 'normal' || value === 'deposit';
|
|
@@ -4427,7 +4607,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4427
4607
|
});
|
|
4428
4608
|
};
|
|
4429
4609
|
var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
|
|
4430
|
-
return
|
|
4610
|
+
return _this30.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
|
|
4431
4611
|
defaultPaid: false,
|
|
4432
4612
|
devicePrefix: options === null || options === void 0 ? void 0 : options.devicePrefix
|
|
4433
4613
|
});
|
|
@@ -4480,7 +4660,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4480
4660
|
void this.recalculateSummary({
|
|
4481
4661
|
createIfMissing: true
|
|
4482
4662
|
}).catch(function (error) {
|
|
4483
|
-
|
|
4663
|
+
_this30.logError('recalculate summary after updateVoucherOrderPayments failed', {
|
|
4484
4664
|
error: error instanceof Error ? error.message : String(error)
|
|
4485
4665
|
});
|
|
4486
4666
|
});
|
|
@@ -4538,7 +4718,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4538
4718
|
key: "shouldMergeProductToOrder",
|
|
4539
4719
|
value: function shouldMergeProductToOrder(params) {
|
|
4540
4720
|
var _this$orderHooks,
|
|
4541
|
-
|
|
4721
|
+
_this31 = this;
|
|
4542
4722
|
var onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
|
|
4543
4723
|
if (!onBeforeMergeProductToOrder) return true;
|
|
4544
4724
|
var result = onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
@@ -4546,7 +4726,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4546
4726
|
}));
|
|
4547
4727
|
if (result && _typeof(result) === 'object' && typeof result.then === 'function') {
|
|
4548
4728
|
return Promise.resolve(result).then(function (resolved) {
|
|
4549
|
-
return
|
|
4729
|
+
return _this31.normalizeShouldMergeProductResult(resolved);
|
|
4550
4730
|
});
|
|
4551
4731
|
}
|
|
4552
4732
|
return this.normalizeShouldMergeProductResult(result);
|
|
@@ -4747,7 +4927,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4747
4927
|
_metadata,
|
|
4748
4928
|
_productToAdd$metadat,
|
|
4749
4929
|
_origin,
|
|
4750
|
-
|
|
4930
|
+
_this32 = this;
|
|
4751
4931
|
var linked = booking ? this.createLinkedProductAndBooking({
|
|
4752
4932
|
product: product,
|
|
4753
4933
|
booking: booking
|
|
@@ -4774,18 +4954,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4774
4954
|
}
|
|
4775
4955
|
normalizedIncoming.discount_list = normalizeOrderProductDiscountList(normalizedIncoming.discount_list);
|
|
4776
4956
|
var hasIncomingGoodPass = this.hasGoodPassDiscount(normalizedIncoming);
|
|
4957
|
+
var hasIncomingEntitlementPass = this.hasEntitlementPassDiscount(normalizedIncoming);
|
|
4958
|
+
var isIncomingEntitlementAppend = this.isRuntimeEntitlementAppend(productToAdd, tempOrder);
|
|
4959
|
+
var isIncomingPersistedEntitlementPass = hasIncomingEntitlementPass && this.isPersistedProductLine(normalizedIncoming);
|
|
4777
4960
|
var hasIncomingProductNote = this.hasOrderProductLineNote(normalizedIncoming);
|
|
4778
4961
|
var hasIncomingManualProductDiscount = isManualProductDiscountProduct(normalizedIncoming);
|
|
4779
4962
|
var hasIncomingBookingUid = this.hasLinkedBookingUid(productToAdd) || this.hasLinkedBookingUid(normalizedIncoming);
|
|
4780
4963
|
var isIncomingCustomItem = ((_productToAdd$metadat = productToAdd.metadata) === null || _productToAdd$metadat === void 0 || (_productToAdd$metadat = _productToAdd$metadat.origin) === null || _productToAdd$metadat === void 0 ? void 0 : _productToAdd$metadat.isCustomItem) === true || ((_origin = productToAdd._origin) === null || _origin === void 0 ? void 0 : _origin.isCustomItem) === true;
|
|
4781
|
-
var shouldForceNewLine = disableMerge || !!booking ||
|
|
4782
|
-
var matchedIndex =
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
if (
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
if (
|
|
4964
|
+
var shouldForceNewLine = disableMerge || !!booking || hasIncomingGoodPass || isIncomingPersistedEntitlementPass || hasIncomingBookingUid || isIncomingCustomItem || isWeighingProduct;
|
|
4965
|
+
var matchedIndex = shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
4966
|
+
if (_this32.hasGoodPassDiscount(item)) return false;
|
|
4967
|
+
var isRuntimeEntitlementPass = _this32.isRuntimeEntitlementAppend(item, tempOrder);
|
|
4968
|
+
if (isIncomingEntitlementAppend !== isRuntimeEntitlementPass) {
|
|
4969
|
+
return false;
|
|
4970
|
+
}
|
|
4971
|
+
if (isIncomingEntitlementAppend && _this32.isPersistedProductLine(item)) {
|
|
4972
|
+
return false;
|
|
4973
|
+
}
|
|
4974
|
+
var hasExistingProductNote = _this32.hasOrderProductLineNote(item);
|
|
4975
|
+
if ((hasIncomingProductNote || hasExistingProductNote) && (!isRuntimeEntitlementPass || String(normalizedIncoming.note || '').trim() !== String(item.note || '').trim())) {
|
|
4976
|
+
return false;
|
|
4977
|
+
}
|
|
4978
|
+
var hasExistingManualProductDiscount = isManualProductDiscountProduct(item);
|
|
4979
|
+
if (isRuntimeEntitlementPass && !_this32.hasSameEntitlementMergePriceConfig(normalizedIncoming, item)) {
|
|
4980
|
+
return false;
|
|
4981
|
+
}
|
|
4982
|
+
if ((hasIncomingManualProductDiscount || hasExistingManualProductDiscount) && !isRuntimeEntitlementPass) {
|
|
4983
|
+
return false;
|
|
4984
|
+
}
|
|
4985
|
+
if (_this32.isPersistedProductLine(item)) return false;
|
|
4789
4986
|
if (item.product_id !== productToAdd.product_id) return false;
|
|
4790
4987
|
if (item.product_variant_id !== productToAdd.product_variant_id) return false;
|
|
4791
4988
|
var existedFingerprint = buildProductLineFingerprint(getProductSkuOptions(item), item.product_bundle);
|
|
@@ -4796,7 +4993,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4796
4993
|
var commitProductLine = function commitProductLine(shouldMerge) {
|
|
4797
4994
|
var committedProduct;
|
|
4798
4995
|
if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
|
|
4799
|
-
|
|
4996
|
+
_this32.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
|
|
4800
4997
|
if (linked) {
|
|
4801
4998
|
normalizedIncoming.booking_uid = linked.bookingUid;
|
|
4802
4999
|
normalizedIncoming.metadata = _objectSpread(_objectSpread({}, normalizedIncoming.metadata || {}), {}, {
|
|
@@ -4814,7 +5011,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4814
5011
|
var _targetProduct$metada;
|
|
4815
5012
|
var targetProduct = matchedProduct;
|
|
4816
5013
|
var targetUid = (_targetProduct$metada = targetProduct.metadata) === null || _targetProduct$metada === void 0 ? void 0 : _targetProduct$metada.unique_identification_number;
|
|
4817
|
-
var normalizedProduct =
|
|
5014
|
+
var normalizedProduct = _this32.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(targetProduct, normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
|
|
4818
5015
|
metadata: _objectSpread(_objectSpread({}, productToAdd.metadata || {}), {}, {
|
|
4819
5016
|
unique_identification_number: targetUid
|
|
4820
5017
|
})
|
|
@@ -4837,7 +5034,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4837
5034
|
order_detail_id: targetProduct.order_detail_id,
|
|
4838
5035
|
num: nextNum
|
|
4839
5036
|
});
|
|
4840
|
-
|
|
5037
|
+
_this32.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
|
|
4841
5038
|
committedProduct = tempOrder.products[matchedIndex];
|
|
4842
5039
|
if (matchedIndex !== tempOrder.products.length - 1) {
|
|
4843
5040
|
var mergedProduct = tempOrder.products[matchedIndex];
|
|
@@ -4947,7 +5144,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4947
5144
|
key: "addProductToOrder",
|
|
4948
5145
|
value: (function () {
|
|
4949
5146
|
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(product, booking, options) {
|
|
4950
|
-
var
|
|
5147
|
+
var _this33 = this;
|
|
4951
5148
|
var tempOrder, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex, _ref71, _productRecord$num, productRecord, splitCount, i, splitLine, committedProduct, _committedProduct, _committedProduct2;
|
|
4952
5149
|
return _regeneratorRuntime().wrap(function _callee23$(_context25) {
|
|
4953
5150
|
while (1) switch (_context25.prev = _context25.next) {
|
|
@@ -4976,7 +5173,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4976
5173
|
throw new Error('[Order Notes] 商品行缺少 unique_identification_number');
|
|
4977
5174
|
}
|
|
4978
5175
|
salesNoteDrafts.forEach(function (draft) {
|
|
4979
|
-
|
|
5176
|
+
_this33.setSalesNoteOnTempOrder(tempOrder, {
|
|
4980
5177
|
note_type: draft.note_type,
|
|
4981
5178
|
target: {
|
|
4982
5179
|
target_type: 'order_detail',
|
|
@@ -5210,45 +5407,99 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5210
5407
|
return addProductsToOrder;
|
|
5211
5408
|
}())
|
|
5212
5409
|
}, {
|
|
5213
|
-
key: "
|
|
5214
|
-
value: function
|
|
5410
|
+
key: "getFullCoveragePassDiscounts",
|
|
5411
|
+
value: function getFullCoveragePassDiscounts(product) {
|
|
5215
5412
|
var _product$_extend;
|
|
5216
|
-
var
|
|
5217
|
-
return (item === null || item === void 0 ? void 0 : item.type) === 'good_pass' || (item === null || item === void 0 ? void 0 : item.tag) === 'good_pass';
|
|
5218
|
-
});
|
|
5219
|
-
if (hasMainGoodPass) return true;
|
|
5220
|
-
var bundleDiscountList = [];
|
|
5413
|
+
var discountList = _toConsumableArray(product.discount_list || []);
|
|
5221
5414
|
(product.product_bundle || []).forEach(function (item) {
|
|
5222
|
-
|
|
5415
|
+
discountList.push.apply(discountList, _toConsumableArray((item === null || item === void 0 ? void 0 : item.discount_list) || []));
|
|
5223
5416
|
});
|
|
5224
5417
|
((product === null || product === void 0 || (_product$_extend = product._extend) === null || _product$_extend === void 0 || (_product$_extend = _product$_extend.other) === null || _product$_extend === void 0 ? void 0 : _product$_extend.bundle) || []).forEach(function (item) {
|
|
5225
|
-
|
|
5418
|
+
discountList.push.apply(discountList, _toConsumableArray((item === null || item === void 0 ? void 0 : item.discount_list) || []));
|
|
5419
|
+
});
|
|
5420
|
+
return discountList.filter(function (item) {
|
|
5421
|
+
return isFullCoveragePass(item);
|
|
5422
|
+
});
|
|
5423
|
+
}
|
|
5424
|
+
}, {
|
|
5425
|
+
key: "hasEntitlementPassDiscount",
|
|
5426
|
+
value: function hasEntitlementPassDiscount(product) {
|
|
5427
|
+
return this.getFullCoveragePassDiscounts(product).some(function (item) {
|
|
5428
|
+
return isEntitlementPass(item);
|
|
5226
5429
|
});
|
|
5227
|
-
|
|
5228
|
-
|
|
5430
|
+
}
|
|
5431
|
+
}, {
|
|
5432
|
+
key: "hasGoodPassDiscount",
|
|
5433
|
+
value: function hasGoodPassDiscount(product) {
|
|
5434
|
+
return this.getFullCoveragePassDiscounts(product).some(function (item) {
|
|
5435
|
+
return !isEntitlementPass(item);
|
|
5229
5436
|
});
|
|
5230
5437
|
}
|
|
5438
|
+
}, {
|
|
5439
|
+
key: "isPersistedProductLine",
|
|
5440
|
+
value: function isPersistedProductLine(product) {
|
|
5441
|
+
var _product$metadata11;
|
|
5442
|
+
return product.order_detail_id !== undefined && product.order_detail_id !== null && product.order_detail_id !== '' || ((_product$metadata11 = product.metadata) === null || _product$metadata11 === void 0 ? void 0 : _product$metadata11.is_edit_for_runtime) === true;
|
|
5443
|
+
}
|
|
5444
|
+
}, {
|
|
5445
|
+
key: "isRuntimeEntitlementAppend",
|
|
5446
|
+
value: function isRuntimeEntitlementAppend(product, tempOrder) {
|
|
5447
|
+
var _product$metadata$uni, _product$metadata12, _tempOrder$_extend10, _product$_origin;
|
|
5448
|
+
if (this.isPersistedProductLine(product)) return false;
|
|
5449
|
+
var uid = (_product$metadata$uni = (_product$metadata12 = product.metadata) === null || _product$metadata12 === void 0 ? void 0 : _product$metadata12.unique_identification_number) !== null && _product$metadata$uni !== void 0 ? _product$metadata$uni : product.unique_identification_number;
|
|
5450
|
+
var storedOrigin = uid !== undefined && uid !== null && uid !== '' ? (_tempOrder$_extend10 = tempOrder._extend) === null || _tempOrder$_extend10 === void 0 || (_tempOrder$_extend10 = _tempOrder$_extend10.productsByUid) === null || _tempOrder$_extend10 === void 0 || (_tempOrder$_extend10 = _tempOrder$_extend10[String(uid)]) === null || _tempOrder$_extend10 === void 0 ? void 0 : _tempOrder$_extend10.origin : undefined;
|
|
5451
|
+
return Boolean((product === null || product === void 0 || (_product$_origin = product._origin) === null || _product$_origin === void 0 ? void 0 : _product$_origin.__entitlementPassRuntimeAppend) === true || (storedOrigin === null || storedOrigin === void 0 ? void 0 : storedOrigin.__entitlementPassRuntimeAppend) === true);
|
|
5452
|
+
}
|
|
5453
|
+
}, {
|
|
5454
|
+
key: "hasSameEntitlementMergePriceConfig",
|
|
5455
|
+
value: function hasSameEntitlementMergePriceConfig(incoming, existing) {
|
|
5456
|
+
var _this34 = this;
|
|
5457
|
+
var buildPriceConfig = function buildPriceConfig(product) {
|
|
5458
|
+
var metadata = product.metadata || {};
|
|
5459
|
+
var bundle = (product.product_bundle || []).map(function (item) {
|
|
5460
|
+
var _ref73, _item$bundle_id, _ref74, _ref75, _item$bundle_product_, _ref76, _item$bundle_variant_, _ref77, _item$price_type, _ref78, _item$price_type_ext;
|
|
5461
|
+
return {
|
|
5462
|
+
bundle_id: (_ref73 = (_item$bundle_id = item.bundle_id) !== null && _item$bundle_id !== void 0 ? _item$bundle_id : item.id) !== null && _ref73 !== void 0 ? _ref73 : null,
|
|
5463
|
+
bundle_product_id: (_ref74 = (_ref75 = (_item$bundle_product_ = item.bundle_product_id) !== null && _item$bundle_product_ !== void 0 ? _item$bundle_product_ : item._bundle_product_id) !== null && _ref75 !== void 0 ? _ref75 : item.product_id) !== null && _ref74 !== void 0 ? _ref74 : null,
|
|
5464
|
+
bundle_variant_id: (_ref76 = (_item$bundle_variant_ = item.bundle_variant_id) !== null && _item$bundle_variant_ !== void 0 ? _item$bundle_variant_ : item.product_variant_id) !== null && _ref76 !== void 0 ? _ref76 : 0,
|
|
5465
|
+
price_type: (_ref77 = (_item$price_type = item.price_type) !== null && _item$price_type !== void 0 ? _item$price_type : item.custom_price_type) !== null && _ref77 !== void 0 ? _ref77 : '',
|
|
5466
|
+
price_type_ext: (_ref78 = (_item$price_type_ext = item.price_type_ext) !== null && _item$price_type_ext !== void 0 ? _item$price_type_ext : item.custom_price_type_ext) !== null && _ref78 !== void 0 ? _ref78 : ''
|
|
5467
|
+
};
|
|
5468
|
+
}).sort(function (left, right) {
|
|
5469
|
+
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
5470
|
+
});
|
|
5471
|
+
return JSON.stringify({
|
|
5472
|
+
original_price: _this34.normalizeFingerprintMoney(product.original_price),
|
|
5473
|
+
source_product_price: _this34.normalizeFingerprintMoney(metadata.source_product_price),
|
|
5474
|
+
main_product_original_price: _this34.normalizeFingerprintMoney(metadata.main_product_original_price),
|
|
5475
|
+
price_override: _this34.normalizeFingerprintMoney(metadata.price_override),
|
|
5476
|
+
is_manual_discount: Boolean(metadata.is_manual_discount),
|
|
5477
|
+
bundle: bundle
|
|
5478
|
+
});
|
|
5479
|
+
};
|
|
5480
|
+
return buildPriceConfig(incoming) === buildPriceConfig(existing);
|
|
5481
|
+
}
|
|
5231
5482
|
}, {
|
|
5232
5483
|
key: "getBundleRuntimeIdentity",
|
|
5233
5484
|
value: function getBundleRuntimeIdentity(bundle) {
|
|
5234
|
-
var
|
|
5485
|
+
var _ref79, _bundle$bundle_id2, _ref80, _bundle$bundle_group_2, _ref81, _ref82, _bundle$bundle_produc3, _ref83, _bundle$bundle_varian3;
|
|
5235
5486
|
if (!bundle || _typeof(bundle) !== 'object') return '';
|
|
5236
|
-
return [(
|
|
5487
|
+
return [(_ref79 = (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id) !== null && _ref79 !== void 0 ? _ref79 : '', (_ref80 = (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id) !== null && _ref80 !== void 0 ? _ref80 : '', (_ref81 = (_ref82 = (_bundle$bundle_produc3 = bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle._bundle_product_id) !== null && _ref82 !== void 0 ? _ref82 : bundle.product_id) !== null && _ref81 !== void 0 ? _ref81 : '', (_ref83 = (_bundle$bundle_varian3 = bundle.bundle_variant_id) !== null && _bundle$bundle_varian3 !== void 0 ? _bundle$bundle_varian3 : bundle.product_variant_id) !== null && _ref83 !== void 0 ? _ref83 : 0].join('|');
|
|
5237
5488
|
}
|
|
5238
5489
|
}, {
|
|
5239
5490
|
key: "preservePersistedBundlePriceFields",
|
|
5240
5491
|
value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
|
|
5241
|
-
var
|
|
5492
|
+
var _this35 = this;
|
|
5242
5493
|
if (!Array.isArray(nextBundles)) return nextBundles;
|
|
5243
5494
|
if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
|
|
5244
5495
|
var previousByIdentity = new Map();
|
|
5245
5496
|
previousBundles.forEach(function (bundle) {
|
|
5246
|
-
var identity =
|
|
5497
|
+
var identity = _this35.getBundleRuntimeIdentity(bundle);
|
|
5247
5498
|
if (identity) previousByIdentity.set(identity, bundle);
|
|
5248
5499
|
});
|
|
5249
5500
|
return nextBundles.map(function (bundle, index) {
|
|
5250
5501
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
5251
|
-
var previous = previousByIdentity.get(
|
|
5502
|
+
var previous = previousByIdentity.get(_this35.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
|
|
5252
5503
|
if (!previous || _typeof(previous) !== 'object') return bundle;
|
|
5253
5504
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
|
|
5254
5505
|
cover: previous.cover
|
|
@@ -5351,10 +5602,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5351
5602
|
var weighedSourcePrice = callerChangesWeighing ? resolveWeighedSourcePrice(nextProduct.product_sku) : undefined;
|
|
5352
5603
|
var hasResolvedWeighedPrice = weighedSourcePrice !== undefined;
|
|
5353
5604
|
if (hasResolvedWeighedPrice && !callerUpdatesSourcePrice) {
|
|
5354
|
-
var
|
|
5605
|
+
var _ref84, _targetProduct$metada3, _targetProduct$metada4, _ref85, _targetProduct$metada5, _targetProduct$metada6;
|
|
5355
5606
|
var nextMainOriginal = new Decimal(weighedSourcePrice).plus(sumOptionUnitPrice(getProductSkuOptions(nextProduct)));
|
|
5356
|
-
var previousMainOriginal = new Decimal((
|
|
5357
|
-
var previousMainSelling = new Decimal((
|
|
5607
|
+
var previousMainOriginal = new Decimal((_ref84 = (_targetProduct$metada3 = (_targetProduct$metada4 = targetProduct.metadata) === null || _targetProduct$metada4 === void 0 ? void 0 : _targetProduct$metada4.main_product_original_price) !== null && _targetProduct$metada3 !== void 0 ? _targetProduct$metada3 : targetProduct.original_price) !== null && _ref84 !== void 0 ? _ref84 : 0);
|
|
5608
|
+
var previousMainSelling = new Decimal((_ref85 = (_targetProduct$metada5 = (_targetProduct$metada6 = targetProduct.metadata) === null || _targetProduct$metada6 === void 0 ? void 0 : _targetProduct$metada6.main_product_selling_price) !== null && _targetProduct$metada5 !== void 0 ? _targetProduct$metada5 : targetProduct.selling_price) !== null && _ref85 !== void 0 ? _ref85 : 0);
|
|
5358
5609
|
// A manual final price remains fixed; other legacy discounts keep their amount
|
|
5359
5610
|
// until Rules reapplies the currently selected wallet discount below.
|
|
5360
5611
|
var nextMainSelling = isManualProductDiscountProduct(nextProduct) ? previousMainSelling : nextMainOriginal.minus(previousMainOriginal.minus(previousMainSelling));
|
|
@@ -5402,13 +5653,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5402
5653
|
delete nextProduct.metadata.main_product_original_price;
|
|
5403
5654
|
delete nextProduct.metadata.price_schema_version;
|
|
5404
5655
|
} else if (callerChangesLineConfiguration && !hasResolvedWeighedPrice && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
5405
|
-
var
|
|
5656
|
+
var _ref86, _targetProduct$metada15, _targetProduct$metada16, _ref87, _targetProduct$metada17, _targetProduct$metada18, _targetProduct$metada19;
|
|
5406
5657
|
// 仅 option / bundle 变化时,保留历史 source 和主商品折扣金额,
|
|
5407
5658
|
// 但必须让 original 与 selling 一起随新的 option 金额移动。
|
|
5408
5659
|
var previousOptionSum = sumOptionUnitPrice(getProductSkuOptions(targetProduct));
|
|
5409
5660
|
var nextOptionSum = sumOptionUnitPrice(getProductSkuOptions(nextProduct));
|
|
5410
|
-
var _previousMainOriginal2 = new Decimal(Number((
|
|
5411
|
-
var _previousMainSelling2 = new Decimal(Number((
|
|
5661
|
+
var _previousMainOriginal2 = new Decimal(Number((_ref86 = (_targetProduct$metada15 = (_targetProduct$metada16 = targetProduct.metadata) === null || _targetProduct$metada16 === void 0 ? void 0 : _targetProduct$metada16.main_product_original_price) !== null && _targetProduct$metada15 !== void 0 ? _targetProduct$metada15 : targetProduct.original_price) !== null && _ref86 !== void 0 ? _ref86 : 0) || 0);
|
|
5662
|
+
var _previousMainSelling2 = new Decimal(Number((_ref87 = (_targetProduct$metada17 = (_targetProduct$metada18 = targetProduct.metadata) === null || _targetProduct$metada18 === void 0 ? void 0 : _targetProduct$metada18.main_product_selling_price) !== null && _targetProduct$metada17 !== void 0 ? _targetProduct$metada17 : targetProduct.selling_price) !== null && _ref87 !== void 0 ? _ref87 : _previousMainOriginal2.toNumber()) || 0);
|
|
5412
5663
|
var _preservedDiscount = _previousMainOriginal2.minus(_previousMainSelling2);
|
|
5413
5664
|
var previousSource = ((_targetProduct$metada19 = targetProduct.metadata) === null || _targetProduct$metada19 === void 0 ? void 0 : _targetProduct$metada19.source_product_price) != null ? new Decimal(Number(targetProduct.metadata.source_product_price) || 0) : _previousMainOriginal2.minus(previousOptionSum);
|
|
5414
5665
|
var _nextMainOriginal2 = previousSource.plus(nextOptionSum);
|
|
@@ -5458,7 +5709,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5458
5709
|
// normalizeOrderProduct 幂等:v2 metadata 存在 → 保留 main_product_* 折扣重算 composite;
|
|
5459
5710
|
// 否则 → 把顶层 selling_price 视作 source,派生 main_product_* 并写 price_schema_version: 2。
|
|
5460
5711
|
var normalizedProduct = this.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(nextProduct, normalizeOrderProduct(nextProduct)));
|
|
5461
|
-
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
5712
|
+
normalizedProduct.discount_list = normalizeOrderProductDiscountList(isPersistedOrderLine ? syncReducedEntitlementPassUsageCount(normalizedProduct.discount_list, targetProduct.num, normalizedProduct.num) : normalizedProduct.discount_list);
|
|
5462
5713
|
var preservedBookingUid = nextProduct.booking_uid || ((_nextProduct$metadata2 = nextProduct.metadata) === null || _nextProduct$metadata2 === void 0 ? void 0 : _nextProduct$metadata2.booking_uid) || targetProduct.booking_uid || ((_targetProduct$metada20 = targetProduct.metadata) === null || _targetProduct$metada20 === void 0 ? void 0 : _targetProduct$metada20.booking_uid);
|
|
5463
5714
|
if (!booking && preservedBookingUid) {
|
|
5464
5715
|
normalizedProduct.booking_uid = preservedBookingUid;
|
|
@@ -5544,7 +5795,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5544
5795
|
key: "updateOrderProducts",
|
|
5545
5796
|
value: function () {
|
|
5546
5797
|
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(paramsList) {
|
|
5547
|
-
var
|
|
5798
|
+
var _this36 = this;
|
|
5548
5799
|
var tempOrder, reapplyWeighedDiscountProductUids, reapplyBookingDiscountProductUids;
|
|
5549
5800
|
return _regeneratorRuntime().wrap(function _callee26$(_context28) {
|
|
5550
5801
|
while (1) switch (_context28.prev = _context28.next) {
|
|
@@ -5558,7 +5809,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5558
5809
|
case 3:
|
|
5559
5810
|
reapplyWeighedDiscountProductUids = [];
|
|
5560
5811
|
reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
|
|
5561
|
-
var updatedProductUid =
|
|
5812
|
+
var updatedProductUid = _this36.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
|
|
5562
5813
|
// 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
|
|
5563
5814
|
if (params.allow_booking_discount_reapply && updatedProductUid) {
|
|
5564
5815
|
acc.push(String(updatedProductUid));
|
|
@@ -5591,7 +5842,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5591
5842
|
value: function () {
|
|
5592
5843
|
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
|
|
5593
5844
|
var _targetProduct$metada22;
|
|
5594
|
-
var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct, settlementSnapshot, currencyProductId, asset, requiredAmount, balance, isVirtualSettlement, promotionPayload;
|
|
5845
|
+
var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, isPersistedOrderLine, normalizedProduct, settlementSnapshot, currencyProductId, asset, requiredAmount, balance, isVirtualSettlement, promotionPayload;
|
|
5595
5846
|
return _regeneratorRuntime().wrap(function _callee27$(_context29) {
|
|
5596
5847
|
while (1) switch (_context29.prev = _context29.next) {
|
|
5597
5848
|
case 0:
|
|
@@ -5629,16 +5880,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5629
5880
|
throw new Error('[Order] 目标商品不存在,无法更新数量');
|
|
5630
5881
|
case 13:
|
|
5631
5882
|
targetProduct = tempOrder.products[productIndex];
|
|
5883
|
+
isPersistedOrderLine = targetProduct.order_detail_id !== undefined && targetProduct.order_detail_id !== null;
|
|
5632
5884
|
normalizedProduct = this.normalizeVirtualSettlementProductIfEnabled(normalizeOrderProduct(_objectSpread(_objectSpread({}, targetProduct), {}, {
|
|
5633
5885
|
num: getSafeProductNum(num),
|
|
5634
5886
|
metadata: _objectSpread(_objectSpread({}, targetProduct.metadata || {}), {}, {
|
|
5635
5887
|
unique_identification_number: ((_targetProduct$metada22 = targetProduct.metadata) === null || _targetProduct$metada22 === void 0 ? void 0 : _targetProduct$metada22.unique_identification_number) || unique_identification_number
|
|
5636
5888
|
})
|
|
5637
5889
|
})));
|
|
5638
|
-
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
5890
|
+
normalizedProduct.discount_list = normalizeOrderProductDiscountList(isPersistedOrderLine ? syncReducedEntitlementPassUsageCount(normalizedProduct.discount_list, targetProduct.num, normalizedProduct.num) : normalizedProduct.discount_list);
|
|
5639
5891
|
settlementSnapshot = getSelectedSettlementSnapshot(normalizedProduct);
|
|
5640
5892
|
if (!(this.isMultiCurrencySettlementEnabled() && (settlementSnapshot === null || settlementSnapshot === void 0 ? void 0 : settlementSnapshot.settlement_type) === 'virtual_currency' && tempOrder.customer_id && Number(tempOrder.customer_id) !== 1)) {
|
|
5641
|
-
_context29.next =
|
|
5893
|
+
_context29.next = 27;
|
|
5642
5894
|
break;
|
|
5643
5895
|
}
|
|
5644
5896
|
currencyProductId = Number(settlementSnapshot.currency_product_id);
|
|
@@ -5646,11 +5898,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5646
5898
|
return Number(item === null || item === void 0 ? void 0 : item.product_id) === currencyProductId;
|
|
5647
5899
|
});
|
|
5648
5900
|
if (asset) {
|
|
5649
|
-
_context29.next =
|
|
5901
|
+
_context29.next = 23;
|
|
5650
5902
|
break;
|
|
5651
5903
|
}
|
|
5652
5904
|
throw new VirtualCurrencyAssetNotFoundError(currencyProductId);
|
|
5653
|
-
case
|
|
5905
|
+
case 23:
|
|
5654
5906
|
requiredAmount = tempOrder.products.reduce(function (sum, item, index) {
|
|
5655
5907
|
var current = index === productIndex ? normalizedProduct : item;
|
|
5656
5908
|
var currentSnapshot = getSelectedSettlementSnapshot(current);
|
|
@@ -5658,44 +5910,44 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5658
5910
|
}, new Decimal(0));
|
|
5659
5911
|
balance = new Decimal(asset.balance || 0);
|
|
5660
5912
|
if (!balance.lt(requiredAmount)) {
|
|
5661
|
-
_context29.next =
|
|
5913
|
+
_context29.next = 27;
|
|
5662
5914
|
break;
|
|
5663
5915
|
}
|
|
5664
5916
|
throw new VirtualCurrencyBalanceError(balance.toFixed(2), requiredAmount.toFixed(2));
|
|
5665
|
-
case
|
|
5917
|
+
case 27:
|
|
5666
5918
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
5667
5919
|
this.prepareVirtualSettlementTempOrder(tempOrder);
|
|
5668
5920
|
isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder);
|
|
5669
5921
|
if (isVirtualSettlement) {
|
|
5670
|
-
_context29.next =
|
|
5922
|
+
_context29.next = 36;
|
|
5671
5923
|
break;
|
|
5672
5924
|
}
|
|
5673
|
-
_context29.next =
|
|
5925
|
+
_context29.next = 33;
|
|
5674
5926
|
return this.evaluatePromotion();
|
|
5675
|
-
case
|
|
5927
|
+
case 33:
|
|
5676
5928
|
_context29.t0 = _context29.sent;
|
|
5677
|
-
_context29.next =
|
|
5929
|
+
_context29.next = 37;
|
|
5678
5930
|
break;
|
|
5679
|
-
case 35:
|
|
5680
|
-
_context29.t0 = null;
|
|
5681
5931
|
case 36:
|
|
5932
|
+
_context29.t0 = null;
|
|
5933
|
+
case 37:
|
|
5682
5934
|
promotionPayload = _context29.t0;
|
|
5683
5935
|
if (!isVirtualSettlement) {
|
|
5684
5936
|
this.applyDiscount();
|
|
5685
5937
|
}
|
|
5686
5938
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
5687
|
-
_context29.next =
|
|
5939
|
+
_context29.next = 42;
|
|
5688
5940
|
return this.recalculateSummary({
|
|
5689
5941
|
createIfMissing: true
|
|
5690
5942
|
});
|
|
5691
|
-
case
|
|
5943
|
+
case 42:
|
|
5692
5944
|
this.persistTempOrder();
|
|
5693
5945
|
this.emitPromotionApplied(promotionPayload);
|
|
5694
5946
|
this.logInfo('updateOrderProductQuantity success', {
|
|
5695
5947
|
params: params
|
|
5696
5948
|
});
|
|
5697
5949
|
return _context29.abrupt("return", tempOrder.products);
|
|
5698
|
-
case
|
|
5950
|
+
case 46:
|
|
5699
5951
|
case "end":
|
|
5700
5952
|
return _context29.stop();
|
|
5701
5953
|
}
|
|
@@ -5786,7 +6038,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5786
6038
|
key: "removeProductsFromOrder",
|
|
5787
6039
|
value: (function () {
|
|
5788
6040
|
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(identities, options) {
|
|
5789
|
-
var
|
|
6041
|
+
var _this37 = this;
|
|
5790
6042
|
var tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
|
|
5791
6043
|
return _regeneratorRuntime().wrap(function _callee29$(_context32) {
|
|
5792
6044
|
while (1) switch (_context32.prev = _context32.next) {
|
|
@@ -5851,7 +6103,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5851
6103
|
}
|
|
5852
6104
|
if (productUid !== undefined && productUid !== null && productUid !== '') {
|
|
5853
6105
|
bookingsBeforeRemove.forEach(function (booking) {
|
|
5854
|
-
var bookingUid =
|
|
6106
|
+
var bookingUid = _this37.getBookingUniqueIdentificationNumber(booking);
|
|
5855
6107
|
if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
|
|
5856
6108
|
linkedBookingUidsToRemove.add(bookingUid);
|
|
5857
6109
|
}
|
|
@@ -6066,23 +6318,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6066
6318
|
}, {
|
|
6067
6319
|
key: "buildCurrentSubmitPayloadForLocalPrint",
|
|
6068
6320
|
value: function buildCurrentSubmitPayloadForLocalPrint(params) {
|
|
6069
|
-
var _params$cacheId, _this$otherParams5,
|
|
6321
|
+
var _params$cacheId, _this$otherParams5, _ref88, _params$businessCode, _this$otherParams6, _this$otherParams7;
|
|
6070
6322
|
var tempOrder = this.ensureTempOrder();
|
|
6071
6323
|
this.persistTempOrder();
|
|
6072
6324
|
var payload = buildSubmitPayload({
|
|
6073
6325
|
tempOrder: tempOrder,
|
|
6074
6326
|
cacheId: (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId,
|
|
6075
6327
|
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.platform),
|
|
6076
|
-
businessCode: (
|
|
6328
|
+
businessCode: (_ref88 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.businessCode) !== null && _ref88 !== void 0 ? _ref88 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.business_code,
|
|
6077
6329
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
6078
6330
|
type: params === null || params === void 0 ? void 0 : params.type,
|
|
6079
6331
|
summary: this.store.summary || createEmptySummary(),
|
|
6080
6332
|
enhance: function enhance(nextPayload) {
|
|
6081
|
-
var
|
|
6333
|
+
var _ref89, _tempOrder$order_numb, _ref90, _tempOrder$shop_order2, _ref91, _tempOrder$shop_full_;
|
|
6082
6334
|
return _objectSpread(_objectSpread({}, nextPayload), {}, {
|
|
6083
|
-
order_number: (
|
|
6084
|
-
shop_order_number: (
|
|
6085
|
-
shop_full_order_number: (
|
|
6335
|
+
order_number: (_ref89 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref89 !== void 0 ? _ref89 : null,
|
|
6336
|
+
shop_order_number: (_ref90 = (_tempOrder$shop_order2 = tempOrder.shop_order_number) !== null && _tempOrder$shop_order2 !== void 0 ? _tempOrder$shop_order2 : nextPayload.shop_order_number) !== null && _ref90 !== void 0 ? _ref90 : null,
|
|
6337
|
+
shop_full_order_number: (_ref91 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref91 !== void 0 ? _ref91 : null,
|
|
6086
6338
|
small_ticket_data_flag: 1
|
|
6087
6339
|
});
|
|
6088
6340
|
}
|
|
@@ -6246,7 +6498,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6246
6498
|
key: "runSubmitTempOrder",
|
|
6247
6499
|
value: function () {
|
|
6248
6500
|
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
|
|
6249
|
-
var _params$cacheId3, _this$otherParams12,
|
|
6501
|
+
var _params$cacheId3, _this$otherParams12, _ref92, _ref93, _submitSnapshot$busin, _this$otherParams13, _this$otherParams14, _submitSnapshot$type;
|
|
6250
6502
|
var tempOrder, isOnlineStorePlatform, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, shouldOverridePaymentStatus, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, isLocalPendingSubmit, salesNotesState, submittedOrderId, resultRecord;
|
|
6251
6503
|
return _regeneratorRuntime().wrap(function _callee37$(_context40) {
|
|
6252
6504
|
while (1) switch (_context40.prev = _context40.next) {
|
|
@@ -6313,7 +6565,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6313
6565
|
tempOrder: tempOrder,
|
|
6314
6566
|
cacheId: effectiveCacheId,
|
|
6315
6567
|
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.platform),
|
|
6316
|
-
businessCode: (
|
|
6568
|
+
businessCode: (_ref92 = (_ref93 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref93 !== void 0 ? _ref93 : (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.businessCode) !== null && _ref92 !== void 0 ? _ref92 : (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.business_code,
|
|
6317
6569
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
6318
6570
|
type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
|
|
6319
6571
|
summary: latestSummary,
|
|
@@ -6483,10 +6735,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6483
6735
|
value: function extractSubmitErrorResponse(error) {
|
|
6484
6736
|
var _error$response,
|
|
6485
6737
|
_error$response2,
|
|
6486
|
-
|
|
6738
|
+
_this38 = this;
|
|
6487
6739
|
var candidates = [error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data, error === null || error === void 0 ? void 0 : error.data, error === null || error === void 0 || (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.body, error === null || error === void 0 ? void 0 : error.body];
|
|
6488
6740
|
return candidates.find(function (candidate) {
|
|
6489
|
-
return
|
|
6741
|
+
return _this38.isSubmitErrorResponse(candidate);
|
|
6490
6742
|
}) || null;
|
|
6491
6743
|
}
|
|
6492
6744
|
}, {
|
|
@@ -6514,7 +6766,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6514
6766
|
key: "syncPaymentsToOrder",
|
|
6515
6767
|
value: function () {
|
|
6516
6768
|
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
|
|
6517
|
-
var
|
|
6769
|
+
var _this39 = this,
|
|
6518
6770
|
_params$confirmPendin;
|
|
6519
6771
|
var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, enhancePayload, submitParams, submitResult;
|
|
6520
6772
|
return _regeneratorRuntime().wrap(function _callee39$(_context42) {
|
|
@@ -6539,7 +6791,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6539
6791
|
case 9:
|
|
6540
6792
|
devicePrefix = _context42.t0;
|
|
6541
6793
|
mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
|
|
6542
|
-
return
|
|
6794
|
+
return _this39.normalizePaymentSource(payment, {
|
|
6543
6795
|
defaultPaid: false,
|
|
6544
6796
|
devicePrefix: devicePrefix
|
|
6545
6797
|
});
|
|
@@ -6618,7 +6870,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6618
6870
|
}, {
|
|
6619
6871
|
key: "createOrder",
|
|
6620
6872
|
value: function createOrder(params) {
|
|
6621
|
-
var
|
|
6873
|
+
var _this40 = this;
|
|
6622
6874
|
var order = _objectSpread({
|
|
6623
6875
|
type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
|
|
6624
6876
|
// 要从外面拿,virtual
|
|
@@ -6650,7 +6902,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6650
6902
|
|
|
6651
6903
|
// 为预约补齐 holder 信息
|
|
6652
6904
|
if (params !== null && params !== void 0 && (_params$extraData = params.extraData) !== null && _params$extraData !== void 0 && _params$extraData.is_add_holder_info) {
|
|
6653
|
-
ensureCartItemOriginHolder(item,
|
|
6905
|
+
ensureCartItemOriginHolder(item, _this40.window);
|
|
6654
6906
|
}
|
|
6655
6907
|
|
|
6656
6908
|
// 购物车是否为普通商品
|
|
@@ -7049,12 +7301,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7049
7301
|
params.forceRemote = false;
|
|
7050
7302
|
}
|
|
7051
7303
|
_context49.next = 6;
|
|
7052
|
-
return this.request
|
|
7053
|
-
|
|
7054
|
-
|
|
7055
|
-
forceRemote:
|
|
7056
|
-
} : {}), {
|
|
7057
|
-
osServer: true
|
|
7304
|
+
return loadSalesOrderSnapshot(this.request, {
|
|
7305
|
+
lookup: lookup,
|
|
7306
|
+
transport: 'os-server',
|
|
7307
|
+
forceRemote: params.forceRemote
|
|
7058
7308
|
});
|
|
7059
7309
|
case 6:
|
|
7060
7310
|
res = _context49.sent;
|
|
@@ -7292,10 +7542,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7292
7542
|
_step22;
|
|
7293
7543
|
try {
|
|
7294
7544
|
for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
|
|
7295
|
-
var _product$
|
|
7545
|
+
var _product$metadata13;
|
|
7296
7546
|
var product = _step22.value;
|
|
7297
7547
|
var productUid = getOrderCollectionUid('product', product);
|
|
7298
|
-
var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$
|
|
7548
|
+
var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata13 = product.metadata) === null || _product$metadata13 === void 0 ? void 0 : _product$metadata13.booking_uid);
|
|
7299
7549
|
if (!productUid || bookingUid === undefined || bookingUid === null || bookingUid === '') {
|
|
7300
7550
|
continue;
|
|
7301
7551
|
}
|
|
@@ -7353,7 +7603,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7353
7603
|
}, {
|
|
7354
7604
|
key: "normalizeTempOrderForRuntime",
|
|
7355
7605
|
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
7356
|
-
var
|
|
7606
|
+
var _this41 = this,
|
|
7357
7607
|
_raw$_extend;
|
|
7358
7608
|
var runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
|
|
7359
7609
|
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
|
|
@@ -7378,12 +7628,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7378
7628
|
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
7379
7629
|
var rawProducts = Array.isArray(raw.products) ? raw.products : [];
|
|
7380
7630
|
nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
|
|
7381
|
-
return
|
|
7631
|
+
return _this41.normalizeHydratedOrderProduct(p, {
|
|
7382
7632
|
makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
|
|
7383
7633
|
});
|
|
7384
7634
|
}) : [];
|
|
7385
7635
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
7386
|
-
var booking =
|
|
7636
|
+
var booking = _this41.normalizeHydratedBookingHolder(b || {});
|
|
7387
7637
|
return _objectSpread(_objectSpread({}, booking), {}, {
|
|
7388
7638
|
is_all: normalizeBookingIsAll(booking),
|
|
7389
7639
|
sub_type: normalizeBookingSubType(booking)
|
|
@@ -7433,15 +7683,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7433
7683
|
_step24;
|
|
7434
7684
|
try {
|
|
7435
7685
|
for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
|
|
7436
|
-
var _product$
|
|
7686
|
+
var _product$metadata14, _ref94, _ref95, _existed$origin, _rawProduct$metadata;
|
|
7437
7687
|
var _step24$value = _slicedToArray(_step24.value, 2),
|
|
7438
7688
|
index = _step24$value[0],
|
|
7439
7689
|
product = _step24$value[1];
|
|
7440
|
-
var uid = (_product$
|
|
7690
|
+
var uid = (_product$metadata14 = product.metadata) === null || _product$metadata14 === void 0 ? void 0 : _product$metadata14.unique_identification_number;
|
|
7441
7691
|
if (!uid) continue;
|
|
7442
7692
|
var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
|
|
7443
7693
|
var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
|
|
7444
|
-
var origin = (
|
|
7694
|
+
var origin = (_ref94 = (_ref95 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref95 !== void 0 ? _ref95 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref94 !== void 0 ? _ref94 : rawProduct;
|
|
7445
7695
|
var originSnapshot = cloneDeep(origin);
|
|
7446
7696
|
var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
|
|
7447
7697
|
if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
|
|
@@ -7492,8 +7742,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7492
7742
|
var bookingUidByProductUid = new Map();
|
|
7493
7743
|
var productByUid = new Map();
|
|
7494
7744
|
(tempOrder.products || []).forEach(function (product) {
|
|
7495
|
-
var _product$
|
|
7496
|
-
var productUid = (product === null || product === void 0 || (_product$
|
|
7745
|
+
var _product$metadata15;
|
|
7746
|
+
var productUid = (product === null || product === void 0 || (_product$metadata15 = product.metadata) === null || _product$metadata15 === void 0 ? void 0 : _product$metadata15.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
7497
7747
|
if (productUid !== undefined && productUid !== null && String(productUid) !== '') {
|
|
7498
7748
|
productByUid.set(String(productUid), product);
|
|
7499
7749
|
}
|
|
@@ -7514,8 +7764,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7514
7764
|
bookingUidByProductUid.set(String(productUid), bookingUid);
|
|
7515
7765
|
});
|
|
7516
7766
|
(tempOrder.products || []).forEach(function (product) {
|
|
7517
|
-
var _product$
|
|
7518
|
-
var productUid = (product === null || product === void 0 || (_product$
|
|
7767
|
+
var _product$metadata16;
|
|
7768
|
+
var productUid = (product === null || product === void 0 || (_product$metadata16 = product.metadata) === null || _product$metadata16 === void 0 ? void 0 : _product$metadata16.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
7519
7769
|
if (productUid === undefined || productUid === null || String(productUid) === '') return;
|
|
7520
7770
|
var bookingUid = bookingUidByProductUid.get(String(productUid));
|
|
7521
7771
|
if (!bookingUid) return;
|
|
@@ -7570,10 +7820,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7570
7820
|
}, {
|
|
7571
7821
|
key: "normalizeHydratedProductOptionItem",
|
|
7572
7822
|
value: function normalizeHydratedProductOptionItem(optionItem) {
|
|
7573
|
-
var
|
|
7574
|
-
var rawNum = (
|
|
7823
|
+
var _ref96, _optionItem$num, _ref97, _optionItem$add_price;
|
|
7824
|
+
var rawNum = (_ref96 = (_optionItem$num = optionItem === null || optionItem === void 0 ? void 0 : optionItem.num) !== null && _optionItem$num !== void 0 ? _optionItem$num : optionItem === null || optionItem === void 0 ? void 0 : optionItem.quantity) !== null && _ref96 !== void 0 ? _ref96 : 1;
|
|
7575
7825
|
var parsedNum = Number(rawNum);
|
|
7576
|
-
var rawPrice = (
|
|
7826
|
+
var rawPrice = (_ref97 = (_optionItem$add_price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _optionItem$add_price !== void 0 ? _optionItem$add_price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _ref97 !== void 0 ? _ref97 : 0;
|
|
7577
7827
|
var parsedPrice = Number(rawPrice);
|
|
7578
7828
|
var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
|
|
7579
7829
|
option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
|
|
@@ -7590,7 +7840,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7590
7840
|
}, {
|
|
7591
7841
|
key: "normalizeHydratedOrderProduct",
|
|
7592
7842
|
value: function normalizeHydratedOrderProduct(product, options) {
|
|
7593
|
-
var
|
|
7843
|
+
var _this42 = this;
|
|
7594
7844
|
var row = _objectSpread({}, product || {});
|
|
7595
7845
|
if (row.num === undefined && row.product_quantity !== undefined) {
|
|
7596
7846
|
row.num = row.product_quantity;
|
|
@@ -7598,7 +7848,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7598
7848
|
var productSku = ensureProductSku(row);
|
|
7599
7849
|
row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
|
|
7600
7850
|
option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
|
|
7601
|
-
return
|
|
7851
|
+
return _this42.normalizeHydratedProductOptionItem(optionItem || {});
|
|
7602
7852
|
}))
|
|
7603
7853
|
});
|
|
7604
7854
|
delete row["product_".concat('option', "_item")];
|
|
@@ -7686,8 +7936,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7686
7936
|
}, {
|
|
7687
7937
|
key: "getVouchers",
|
|
7688
7938
|
value: function getVouchers() {
|
|
7689
|
-
var _this$store$
|
|
7690
|
-
return ((_this$store$
|
|
7939
|
+
var _this$store$tempOrder9;
|
|
7940
|
+
return ((_this$store$tempOrder9 = this.store.tempOrder) === null || _this$store$tempOrder9 === void 0 ? void 0 : _this$store$tempOrder9.vouchers) || [];
|
|
7691
7941
|
}
|
|
7692
7942
|
}], [{
|
|
7693
7943
|
key: "populateSavedAmounts",
|
|
@@ -7706,11 +7956,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7706
7956
|
targetMap.set(discountKey, (targetMap.get(discountKey) || new Decimal(0)).plus(amount));
|
|
7707
7957
|
};
|
|
7708
7958
|
var addProductDiscountAmount = function addProductDiscountAmount(discount, quantity, isPersistedProduct) {
|
|
7709
|
-
var _discount$discount3, _discount$
|
|
7959
|
+
var _discount$discount3, _discount$metadata2;
|
|
7710
7960
|
var discountKey = ((_discount$discount3 = discount.discount) === null || _discount$discount3 === void 0 ? void 0 : _discount$discount3.resource_id) || discount.id;
|
|
7711
7961
|
if (discountKey == null) return;
|
|
7712
7962
|
var qty = Number(quantity) || 1;
|
|
7713
|
-
var amount = new Decimal(discount.amount || 0).times(qty).plus(((_discount$
|
|
7963
|
+
var amount = new Decimal(discount.amount || 0).times(qty).plus(((_discount$metadata2 = discount.metadata) === null || _discount$metadata2 === void 0 ? void 0 : _discount$metadata2.product_discount_difference) || 0);
|
|
7714
7964
|
addDiscountAmount(savedMap, discountKey, amount);
|
|
7715
7965
|
addDiscountAmount(isPersistedProduct || discount.order_discount_id != null ? editModeSavedMap : runtimeSavedMap, discountKey, amount);
|
|
7716
7966
|
};
|
|
@@ -7781,4 +8031,5 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7781
8031
|
}
|
|
7782
8032
|
}]);
|
|
7783
8033
|
return OrderModule;
|
|
7784
|
-
}(BaseModule);
|
|
8034
|
+
}(BaseModule);
|
|
8035
|
+
export { isFulfillmentTimingBooking } from "./pickupTiming";
|