@pisell/pisellos 2.2.260 → 2.2.262
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +1 -0
- package/dist/model/strategy/adapter/dataVariant/adapter.js +15 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +2 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +25 -0
- package/dist/model/strategy/adapter/dataVariant/examples.js +1 -6
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +2 -0
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +23 -13
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +32 -1
- package/dist/modules/Discount/index.d.ts +5 -2
- package/dist/modules/Discount/index.js +30 -7
- package/dist/modules/Discount/types.d.ts +4 -0
- package/dist/modules/Order/index.d.ts +45 -2
- package/dist/modules/Order/index.js +1552 -926
- package/dist/modules/Order/types.d.ts +36 -2
- package/dist/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
- package/dist/modules/Order/utils/bundleDiscountHydration.js +144 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.js +405 -0
- package/dist/modules/Order/utils.d.ts +8 -3
- package/dist/modules/Order/utils.js +136 -56
- package/dist/modules/Rules/index.d.ts +4 -10
- package/dist/modules/Rules/index.js +63 -12
- package/dist/modules/Rules/types.d.ts +12 -2
- package/dist/modules/SalesSummary/index.d.ts +7 -3
- package/dist/modules/SalesSummary/index.js +67 -39
- package/dist/modules/SalesSummary/types.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.js +2 -1
- package/dist/modules/SurchargeList/index.d.ts +6 -4
- package/dist/modules/SurchargeList/index.js +62 -39
- package/dist/modules/SurchargeList/types.d.ts +6 -2
- package/dist/server/index.d.ts +8 -0
- package/dist/server/index.js +1365 -911
- package/dist/server/modules/order/index.d.ts +32 -7
- package/dist/server/modules/order/index.js +551 -464
- package/dist/server/modules/order/types.d.ts +4 -0
- package/dist/server/modules/products/index.d.ts +5 -1
- package/dist/server/modules/products/index.js +384 -315
- package/dist/server/modules/products/types.d.ts +4 -0
- package/dist/solution/BaseSales/index.d.ts +42 -2
- package/dist/solution/BaseSales/index.js +1416 -775
- package/dist/solution/BaseSales/types.d.ts +7 -1
- package/dist/solution/BaseSales/types.js +3 -2
- package/dist/solution/BaseSales/utils/cartPromotion.js +19 -7
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +6 -8
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +20 -4
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +8 -0
- package/dist/solution/BookingTicket/index.js +212 -31
- package/dist/solution/ShopDiscount/index.js +15 -14
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +1 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.js +10 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +2 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +20 -1
- package/lib/model/strategy/adapter/dataVariant/examples.js +0 -2
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +2 -0
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +16 -1
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +23 -2
- package/lib/modules/Discount/index.d.ts +5 -2
- package/lib/modules/Discount/index.js +23 -3
- package/lib/modules/Discount/types.d.ts +4 -0
- package/lib/modules/Order/index.d.ts +45 -2
- package/lib/modules/Order/index.js +720 -116
- package/lib/modules/Order/types.d.ts +36 -2
- package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
- package/lib/modules/Order/utils/bundleDiscountHydration.js +139 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.js +415 -0
- package/lib/modules/Order/utils.d.ts +8 -3
- package/lib/modules/Order/utils.js +104 -18
- package/lib/modules/Rules/index.d.ts +4 -10
- package/lib/modules/Rules/index.js +61 -9
- package/lib/modules/Rules/types.d.ts +12 -2
- package/lib/modules/SalesSummary/index.d.ts +7 -3
- package/lib/modules/SalesSummary/index.js +28 -11
- package/lib/modules/SalesSummary/types.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.js +2 -0
- package/lib/modules/SurchargeList/index.d.ts +6 -4
- package/lib/modules/SurchargeList/index.js +41 -21
- package/lib/modules/SurchargeList/types.d.ts +6 -2
- package/lib/server/index.d.ts +8 -0
- package/lib/server/index.js +336 -11
- package/lib/server/modules/order/index.d.ts +32 -7
- package/lib/server/modules/order/index.js +298 -189
- package/lib/server/modules/order/types.d.ts +4 -0
- package/lib/server/modules/products/index.d.ts +5 -1
- package/lib/server/modules/products/index.js +21 -0
- package/lib/server/modules/products/types.d.ts +4 -0
- package/lib/solution/BaseSales/index.d.ts +42 -2
- package/lib/solution/BaseSales/index.js +535 -108
- package/lib/solution/BaseSales/types.d.ts +7 -1
- package/lib/solution/BaseSales/types.js +2 -1
- package/lib/solution/BaseSales/utils/cartPromotion.js +13 -1
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +4 -5
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +14 -6
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +8 -0
- package/lib/solution/BookingTicket/index.js +134 -8
- package/lib/solution/ShopDiscount/index.js +2 -1
- package/package.json +1 -1
|
@@ -3,13 +3,13 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArra
|
|
|
3
3
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
4
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
5
5
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
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
|
+
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
|
+
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); }); }; }
|
|
6
9
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
7
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."); }
|
|
8
11
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
9
12
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
10
|
-
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; }
|
|
11
|
-
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); } }
|
|
12
|
-
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); }); }; }
|
|
13
13
|
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; }
|
|
14
14
|
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; }
|
|
15
15
|
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; } } }; }
|
|
@@ -32,12 +32,14 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
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
33
|
import { BaseModule } from "../BaseModule";
|
|
34
34
|
import { OrderHooks } from "./types";
|
|
35
|
-
import { composeLinePrice, generateDuration, getAllDiscountList, mergeRelationForms, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments, normalizeOrderProductDiscountList, resolveEffectivePerUnitDiscount, ensureProductSku, getProductSkuOptions, normalizeProductSkuOptions, sumOptionUnitPrice, clearTempOrderHolderAssignments, getOrderProductLineUid, indexOrderProductsByUid, calculateOrderProductsDeposit, mergeOrderProductDisplayFields } from "./utils";
|
|
35
|
+
import { composeLinePrice, generateDuration, getAllDiscountList, mergeRelationForms, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments, normalizeOrderProductDiscountList, resolveEffectivePerUnitDiscount, ensureProductSku, getProductSkuOptions, normalizeProductSkuOptions, sumOptionUnitPrice, clearTempOrderHolderAssignments, getOrderProductLineUid, indexOrderProductsByUid, calculateOrderProductsDeposit, mergeOrderProductDisplayFields, resolveIsFormSubject } from "./utils";
|
|
36
36
|
import { isNormalProduct } from "../Product/utils";
|
|
37
37
|
import dayjs from 'dayjs';
|
|
38
38
|
import { processCartPromotion, appendPromotionTags as _appendPromotionTags, getOrderProductUid as getPromotionUid } from "../../solution/BaseSales/utils/cartPromotion";
|
|
39
39
|
import { buildProductLineFingerprint, getProductIdentityIndex, getSafeProductNum, isIdentityMatch, normalizeOrderProduct } from "../../solution/ScanOrder/utils";
|
|
40
40
|
import { syncManualProductDiscountProductNum } from "./utils/manualProductDiscount";
|
|
41
|
+
import { expandHydratedProductsForDiscountCollection, restoreHydratedBundleDiscounts } from "./utils/bundleDiscountHydration";
|
|
42
|
+
import { getOrderCollectionPersistentId, getOrderCollectionUid, normalizeOrderCollections, setOrderCollectionUid } from "./utils/orderCollectionIdentity";
|
|
41
43
|
import { DiscountModule } from "../Discount";
|
|
42
44
|
import { RulesModule } from "../Rules";
|
|
43
45
|
import { UnavailableReason } from "../Rules/types";
|
|
@@ -64,6 +66,23 @@ function isManualProductDiscountProduct(product) {
|
|
|
64
66
|
return (item === null || item === void 0 ? void 0 : item.type) === 'product';
|
|
65
67
|
});
|
|
66
68
|
}
|
|
69
|
+
var ORDER_PAYMENT_STATUS_PAID = 'paid';
|
|
70
|
+
var ORDER_PAYMENT_STATUS_PENDING = 'payment_pending';
|
|
71
|
+
function isVoucherPaymentRecord(payment) {
|
|
72
|
+
return (payment === null || payment === void 0 ? void 0 : payment.voucher_id) !== undefined && Number(payment.voucher_id) !== 0;
|
|
73
|
+
}
|
|
74
|
+
function hasSyncedOrderPaymentRecord(payment) {
|
|
75
|
+
return (payment === null || payment === void 0 ? void 0 : payment.order_payment_id) !== undefined && payment.order_payment_id !== null;
|
|
76
|
+
}
|
|
77
|
+
function isPendingVoucherPaymentRecord(payment) {
|
|
78
|
+
return isVoucherPaymentRecord(payment) && (payment === null || payment === void 0 ? void 0 : payment.status) === ORDER_PAYMENT_STATUS_PENDING;
|
|
79
|
+
}
|
|
80
|
+
function isPaidPaymentRecord(payment) {
|
|
81
|
+
return (payment === null || payment === void 0 ? void 0 : payment.status) === ORDER_PAYMENT_STATUS_PAID;
|
|
82
|
+
}
|
|
83
|
+
function isCommittedVoucherPaymentRecord(payment) {
|
|
84
|
+
return isVoucherPaymentRecord(payment) && (payment === null || payment === void 0 ? void 0 : payment.status) !== 'voided' && (hasSyncedOrderPaymentRecord(payment) || isPaidPaymentRecord(payment));
|
|
85
|
+
}
|
|
67
86
|
export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
68
87
|
_inherits(OrderModule, _BaseModule);
|
|
69
88
|
var _super = _createSuper(OrderModule);
|
|
@@ -108,7 +127,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
108
127
|
key: "collectHydratedEditDiscounts",
|
|
109
128
|
value: function collectHydratedEditDiscounts(products) {
|
|
110
129
|
var discountMap = new Map();
|
|
111
|
-
var _iterator = _createForOfIteratorHelper(products
|
|
130
|
+
var _iterator = _createForOfIteratorHelper(expandHydratedProductsForDiscountCollection(products)),
|
|
112
131
|
_step;
|
|
113
132
|
try {
|
|
114
133
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
@@ -138,6 +157,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
138
157
|
discount: item === null || item === void 0 ? void 0 : item.discount,
|
|
139
158
|
_num: Number((_ref6 = (_ref7 = (_item$metadata$num2 = item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.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
|
|
140
159
|
};
|
|
160
|
+
var existed = discountMap.get(key);
|
|
161
|
+
if (existed) {
|
|
162
|
+
var _existed$limited_rela;
|
|
163
|
+
existed.amount = Number(existed.amount || 0) + amount;
|
|
164
|
+
existed.used_par_value = String(Number(existed.used_par_value || 0) + amount);
|
|
165
|
+
existed.balance = String(Number(existed.balance || 0) + amount);
|
|
166
|
+
var productIds = Array.isArray((_existed$limited_rela = existed.limited_relation_product_data) === null || _existed$limited_rela === void 0 ? void 0 : _existed$limited_rela.product_ids) ? existed.limited_relation_product_data.product_ids : [];
|
|
167
|
+
if ((product === null || product === void 0 ? void 0 : product.product_id) !== undefined && (product === null || product === void 0 ? void 0 : product.product_id) !== null && !productIds.includes(product.product_id)) {
|
|
168
|
+
existed.limited_relation_product_data = _objectSpread(_objectSpread({}, existed.limited_relation_product_data || {}), {}, {
|
|
169
|
+
product_ids: [].concat(_toConsumableArray(productIds), [product.product_id])
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
existed.applicableProductDetails = [].concat(_toConsumableArray(existed.applicableProductDetails || []), [detail]);
|
|
173
|
+
existed.appliedProductDetails = [].concat(_toConsumableArray(existed.appliedProductDetails || []), [detail]);
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
141
176
|
discountMap.set(key, {
|
|
142
177
|
id: key,
|
|
143
178
|
product_name: '',
|
|
@@ -224,6 +259,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
224
259
|
product.metadata.main_product_selling_price = newMainSellingPrice;
|
|
225
260
|
product.metadata.price_schema_version = 2;
|
|
226
261
|
}
|
|
262
|
+
if (Array.isArray(product.product_bundle)) {
|
|
263
|
+
product.product_bundle = product.product_bundle.map(function (bundle) {
|
|
264
|
+
var _ref12, _bundle$original_pric;
|
|
265
|
+
var hasBundleDiscount = Array.isArray(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) && bundle.discount_list.length > 0;
|
|
266
|
+
if (hasBundleDiscount) return bundle;
|
|
267
|
+
var restoredPrice = (_ref12 = (_bundle$original_pric = bundle === null || bundle === void 0 ? void 0 : bundle.original_price) !== null && _bundle$original_pric !== void 0 ? _bundle$original_pric : bundle === null || bundle === void 0 ? void 0 : bundle.product_price) !== null && _ref12 !== void 0 ? _ref12 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
|
|
268
|
+
if (restoredPrice === undefined || restoredPrice === null || restoredPrice === '') return bundle;
|
|
269
|
+
return _objectSpread(_objectSpread({}, bundle), {}, {
|
|
270
|
+
price: restoredPrice,
|
|
271
|
+
bundle_selling_price: restoredPrice
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
}
|
|
227
275
|
product.selling_price = composeLinePrice({
|
|
228
276
|
mainPrice: newMainSellingPrice,
|
|
229
277
|
bundle: product.product_bundle
|
|
@@ -248,14 +296,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
248
296
|
if (!this.store.summary) {
|
|
249
297
|
this.store.summary = createEmptySummary();
|
|
250
298
|
}
|
|
299
|
+
if (!Array.isArray(this.store.availableWalletIds)) {
|
|
300
|
+
this.store.availableWalletIds = [];
|
|
301
|
+
}
|
|
251
302
|
this.request = this.core.getPlugin('request');
|
|
252
303
|
appPlugin = this.core.getPlugin('app');
|
|
253
304
|
if (appPlugin) {
|
|
254
|
-
_context.next =
|
|
305
|
+
_context.next = 9;
|
|
255
306
|
break;
|
|
256
307
|
}
|
|
257
308
|
throw new Error('Order 模块需要 app 插件支持');
|
|
258
|
-
case
|
|
309
|
+
case 9:
|
|
259
310
|
app = appPlugin.getApp();
|
|
260
311
|
this.logger = app.logger;
|
|
261
312
|
this.window = this.core.getPlugin('window');
|
|
@@ -268,7 +319,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
268
319
|
this.otherParams = otherParams;
|
|
269
320
|
this.registerDiscountModules(options);
|
|
270
321
|
this.logInfo('OrderModule initialized successfully');
|
|
271
|
-
case
|
|
322
|
+
case 21:
|
|
272
323
|
case "end":
|
|
273
324
|
return _context.stop();
|
|
274
325
|
}
|
|
@@ -445,7 +496,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
445
496
|
value: function () {
|
|
446
497
|
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
447
498
|
var _this$store$tempOrder, _this$store$discount, _this$store$tempOrder2;
|
|
448
|
-
var orderId, discountList, _this$store$discount2, _this$store$discount3, _this$store$discount4, currentEditDiscounts, runtimeDiscountIds, runtimeDiscounts, mergedDiscountList;
|
|
499
|
+
var orderId, prepareConfigResult, discountList, _this$store$discount2, _this$store$discount3, _this$store$discount4, currentDiscountList, currentEditDiscounts, currentScanDiscounts, currentScanDiscountIds, runtimeDiscountIds, runtimeDiscounts, mergedDiscountList;
|
|
449
500
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
450
501
|
while (1) switch (_context3.prev = _context3.next) {
|
|
451
502
|
case 0:
|
|
@@ -457,37 +508,49 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
457
508
|
with_good_pass: 1,
|
|
458
509
|
with_discount_card: 1,
|
|
459
510
|
with_wallet_pass_holder: 1,
|
|
511
|
+
with_available_wallet_flag: 1,
|
|
512
|
+
with_available_wallet_pass_flag: 1,
|
|
460
513
|
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
461
514
|
}, orderId ? {
|
|
462
515
|
order_id: orderId
|
|
463
516
|
} : {}));
|
|
464
517
|
case 3:
|
|
465
|
-
|
|
518
|
+
prepareConfigResult = _context3.sent;
|
|
519
|
+
discountList = prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.discountList;
|
|
520
|
+
this.store.availableWalletIds = (prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.availableWalletIds) || [];
|
|
466
521
|
if (!discountList) {
|
|
467
|
-
_context3.next =
|
|
522
|
+
_context3.next = 18;
|
|
468
523
|
break;
|
|
469
524
|
}
|
|
470
|
-
|
|
525
|
+
currentDiscountList = ((_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 ? void 0 : _this$store$discount2.getDiscountList()) || [];
|
|
526
|
+
currentEditDiscounts = currentDiscountList.filter(function (discount) {
|
|
471
527
|
return discount === null || discount === void 0 ? void 0 : discount.isEditMode;
|
|
472
528
|
});
|
|
529
|
+
currentScanDiscounts = currentDiscountList.filter(function (discount) {
|
|
530
|
+
return discount === null || discount === void 0 ? void 0 : discount.isScan;
|
|
531
|
+
});
|
|
532
|
+
currentScanDiscountIds = new Set(currentScanDiscounts.map(function (discount) {
|
|
533
|
+
return discount === null || discount === void 0 ? void 0 : discount.id;
|
|
534
|
+
}));
|
|
473
535
|
runtimeDiscountIds = new Set();
|
|
474
536
|
runtimeDiscounts = discountList.filter(function (discount) {
|
|
537
|
+
if (currentScanDiscountIds.has(discount === null || discount === void 0 ? void 0 : discount.id)) return false;
|
|
475
538
|
if (runtimeDiscountIds.has(discount === null || discount === void 0 ? void 0 : discount.id)) return false;
|
|
476
539
|
runtimeDiscountIds.add(discount === null || discount === void 0 ? void 0 : discount.id);
|
|
477
540
|
return true;
|
|
478
541
|
});
|
|
479
|
-
mergedDiscountList = [].concat(_toConsumableArray(currentEditDiscounts), _toConsumableArray(runtimeDiscounts));
|
|
480
|
-
_context3.next =
|
|
542
|
+
mergedDiscountList = [].concat(_toConsumableArray(currentEditDiscounts), _toConsumableArray(currentScanDiscounts), _toConsumableArray(runtimeDiscounts));
|
|
543
|
+
_context3.next = 16;
|
|
481
544
|
return (_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.setOriginalDiscountList(mergedDiscountList);
|
|
482
|
-
case
|
|
483
|
-
_context3.next =
|
|
545
|
+
case 16:
|
|
546
|
+
_context3.next = 18;
|
|
484
547
|
return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.setDiscountList(mergedDiscountList);
|
|
485
|
-
case
|
|
548
|
+
case 18:
|
|
486
549
|
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) {
|
|
487
550
|
this.applyDiscount();
|
|
488
551
|
}
|
|
489
552
|
return _context3.abrupt("return", this.getDiscountList());
|
|
490
|
-
case
|
|
553
|
+
case 20:
|
|
491
554
|
case "end":
|
|
492
555
|
return _context3.stop();
|
|
493
556
|
}
|
|
@@ -505,33 +568,76 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
505
568
|
return ((_this$store$discount5 = this.store.discount) === null || _this$store$discount5 === void 0 ? void 0 : _this$store$discount5.getDiscountList()) || [];
|
|
506
569
|
}
|
|
507
570
|
}, {
|
|
508
|
-
key: "
|
|
571
|
+
key: "getAvailableWalletIds",
|
|
572
|
+
value: function getAvailableWalletIds() {
|
|
573
|
+
return Array.isArray(this.store.availableWalletIds) ? _toConsumableArray(this.store.availableWalletIds) : [];
|
|
574
|
+
}
|
|
575
|
+
}, {
|
|
576
|
+
key: "syncScannedDiscountsToOriginalDiscountList",
|
|
509
577
|
value: function () {
|
|
510
|
-
var
|
|
511
|
-
var
|
|
512
|
-
var
|
|
578
|
+
var _syncScannedDiscountsToOriginalDiscountList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(discountList) {
|
|
579
|
+
var _this$store$discount6, _this$store$discount7, _this$store$discount8, _this$store$discount9;
|
|
580
|
+
var scanDiscounts, scanDiscountIds, originalDiscounts, nextOriginalDiscounts;
|
|
513
581
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
514
582
|
while (1) switch (_context4.prev = _context4.next) {
|
|
583
|
+
case 0:
|
|
584
|
+
scanDiscounts = (discountList || []).filter(function (discount) {
|
|
585
|
+
return discount === null || discount === void 0 ? void 0 : discount.isScan;
|
|
586
|
+
});
|
|
587
|
+
if (scanDiscounts.length) {
|
|
588
|
+
_context4.next = 3;
|
|
589
|
+
break;
|
|
590
|
+
}
|
|
591
|
+
return _context4.abrupt("return");
|
|
592
|
+
case 3:
|
|
593
|
+
scanDiscountIds = new Set(scanDiscounts.map(function (discount) {
|
|
594
|
+
return discount === null || discount === void 0 ? void 0 : discount.id;
|
|
595
|
+
}));
|
|
596
|
+
originalDiscounts = ((_this$store$discount6 = this.store.discount) === null || _this$store$discount6 === void 0 || (_this$store$discount7 = _this$store$discount6.getOriginalDiscountList) === null || _this$store$discount7 === void 0 ? void 0 : _this$store$discount7.call(_this$store$discount6)) || [];
|
|
597
|
+
nextOriginalDiscounts = [].concat(_toConsumableArray(scanDiscounts), _toConsumableArray(originalDiscounts.filter(function (discount) {
|
|
598
|
+
return !scanDiscountIds.has(discount === null || discount === void 0 ? void 0 : discount.id);
|
|
599
|
+
})));
|
|
600
|
+
_context4.next = 8;
|
|
601
|
+
return (_this$store$discount8 = this.store.discount) === null || _this$store$discount8 === void 0 || (_this$store$discount9 = _this$store$discount8.setOriginalDiscountList) === null || _this$store$discount9 === void 0 ? void 0 : _this$store$discount9.call(_this$store$discount8, nextOriginalDiscounts);
|
|
602
|
+
case 8:
|
|
603
|
+
case "end":
|
|
604
|
+
return _context4.stop();
|
|
605
|
+
}
|
|
606
|
+
}, _callee4, this);
|
|
607
|
+
}));
|
|
608
|
+
function syncScannedDiscountsToOriginalDiscountList(_x4) {
|
|
609
|
+
return _syncScannedDiscountsToOriginalDiscountList.apply(this, arguments);
|
|
610
|
+
}
|
|
611
|
+
return syncScannedDiscountsToOriginalDiscountList;
|
|
612
|
+
}()
|
|
613
|
+
}, {
|
|
614
|
+
key: "ensureEditDiscountConfigForProductChange",
|
|
615
|
+
value: function () {
|
|
616
|
+
var _ensureEditDiscountConfigForProductChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(tempOrder) {
|
|
617
|
+
var _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _this$store$discount10;
|
|
618
|
+
var orderId, customerId, currentDiscountList, hasRuntimeDiscounts;
|
|
619
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
620
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
515
621
|
case 0:
|
|
516
622
|
orderId = tempOrder.order_id;
|
|
517
623
|
customerId = Number(tempOrder.customer_id || ((_tempOrder$customer = tempOrder.customer) === null || _tempOrder$customer === void 0 ? void 0 : _tempOrder$customer.id) || ((_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 || (_tempOrder$_extend = _tempOrder$_extend.customerSnapshot) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend.id) || ((_tempOrder$_extend2 = tempOrder._extend) === null || _tempOrder$_extend2 === void 0 || (_tempOrder$_extend2 = _tempOrder$_extend2.customerSnapshot) === null || _tempOrder$_extend2 === void 0 ? void 0 : _tempOrder$_extend2.customer_id) || 0);
|
|
518
624
|
if (!(!orderId || !customerId || customerId === 1)) {
|
|
519
|
-
|
|
625
|
+
_context5.next = 4;
|
|
520
626
|
break;
|
|
521
627
|
}
|
|
522
|
-
return
|
|
628
|
+
return _context5.abrupt("return");
|
|
523
629
|
case 4:
|
|
524
|
-
currentDiscountList = ((_this$store$
|
|
630
|
+
currentDiscountList = ((_this$store$discount10 = this.store.discount) === null || _this$store$discount10 === void 0 ? void 0 : _this$store$discount10.getDiscountList()) || [];
|
|
525
631
|
hasRuntimeDiscounts = currentDiscountList.some(function (discount) {
|
|
526
632
|
return !(discount !== null && discount !== void 0 && discount.isEditMode);
|
|
527
633
|
});
|
|
528
634
|
if (!hasRuntimeDiscounts) {
|
|
529
|
-
|
|
635
|
+
_context5.next = 8;
|
|
530
636
|
break;
|
|
531
637
|
}
|
|
532
|
-
return
|
|
638
|
+
return _context5.abrupt("return");
|
|
533
639
|
case 8:
|
|
534
|
-
|
|
640
|
+
_context5.next = 10;
|
|
535
641
|
return this.loadDiscountConfig({
|
|
536
642
|
customerId: customerId,
|
|
537
643
|
action: 'edit',
|
|
@@ -540,11 +646,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
540
646
|
});
|
|
541
647
|
case 10:
|
|
542
648
|
case "end":
|
|
543
|
-
return
|
|
649
|
+
return _context5.stop();
|
|
544
650
|
}
|
|
545
|
-
},
|
|
651
|
+
}, _callee5, this);
|
|
546
652
|
}));
|
|
547
|
-
function ensureEditDiscountConfigForProductChange(
|
|
653
|
+
function ensureEditDiscountConfigForProductChange(_x5) {
|
|
548
654
|
return _ensureEditDiscountConfigForProductChange.apply(this, arguments);
|
|
549
655
|
}
|
|
550
656
|
return ensureEditDiscountConfigForProductChange;
|
|
@@ -552,35 +658,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
552
658
|
}, {
|
|
553
659
|
key: "scanCode",
|
|
554
660
|
value: function () {
|
|
555
|
-
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
556
|
-
var _this$store$
|
|
557
|
-
var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders,
|
|
558
|
-
return _regeneratorRuntime().wrap(function
|
|
559
|
-
while (1) switch (
|
|
661
|
+
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(code, customerId) {
|
|
662
|
+
var _this$store$discount11, _tempOrder$holder, _this$store$summary;
|
|
663
|
+
var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref13, isAvailable, newDiscountList, unavailableReason, _this$store$discount12;
|
|
664
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
665
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
560
666
|
case 0:
|
|
561
|
-
|
|
562
|
-
return (_this$store$
|
|
667
|
+
_context6.next = 2;
|
|
668
|
+
return (_this$store$discount11 = this.store.discount) === null || _this$store$discount11 === void 0 ? void 0 : _this$store$discount11.batchSearch(code, {
|
|
563
669
|
customerId: customerId
|
|
564
670
|
});
|
|
565
671
|
case 2:
|
|
566
|
-
|
|
567
|
-
if (
|
|
568
|
-
|
|
672
|
+
_context6.t0 = _context6.sent;
|
|
673
|
+
if (_context6.t0) {
|
|
674
|
+
_context6.next = 5;
|
|
569
675
|
break;
|
|
570
676
|
}
|
|
571
|
-
|
|
677
|
+
_context6.t0 = {
|
|
572
678
|
discountList: [],
|
|
573
679
|
unavailableReasonKey: null
|
|
574
680
|
};
|
|
575
681
|
case 5:
|
|
576
|
-
resultDiscountWithReason =
|
|
682
|
+
resultDiscountWithReason = _context6.t0;
|
|
577
683
|
resultDiscountList = resultDiscountWithReason.discountList, unavailableReasonKey = resultDiscountWithReason.unavailableReasonKey;
|
|
578
684
|
rulesModule = this.store.rules;
|
|
579
685
|
if (rulesModule) {
|
|
580
|
-
|
|
686
|
+
_context6.next = 10;
|
|
581
687
|
break;
|
|
582
688
|
}
|
|
583
|
-
return
|
|
689
|
+
return _context6.abrupt("return", {
|
|
584
690
|
type: 'clientCalc',
|
|
585
691
|
isAvailable: false,
|
|
586
692
|
discountList: this.getDiscountList(),
|
|
@@ -589,10 +695,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
589
695
|
});
|
|
590
696
|
case 10:
|
|
591
697
|
if (resultDiscountList.length) {
|
|
592
|
-
|
|
698
|
+
_context6.next = 12;
|
|
593
699
|
break;
|
|
594
700
|
}
|
|
595
|
-
return
|
|
701
|
+
return _context6.abrupt("return", {
|
|
596
702
|
type: 'server',
|
|
597
703
|
isAvailable: false,
|
|
598
704
|
discountList: this.getDiscountList(),
|
|
@@ -613,59 +719,65 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
613
719
|
return m.id === n.id;
|
|
614
720
|
});
|
|
615
721
|
}))) {
|
|
616
|
-
|
|
722
|
+
_context6.next = 18;
|
|
617
723
|
break;
|
|
618
724
|
}
|
|
619
|
-
|
|
725
|
+
_context6.next = 17;
|
|
726
|
+
return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
727
|
+
case 17:
|
|
728
|
+
return _context6.abrupt("return", {
|
|
620
729
|
type: 'clientCalc',
|
|
621
730
|
isAvailable: true,
|
|
622
731
|
discountList: this.getDiscountList(),
|
|
623
732
|
scannedDiscountList: resultDiscountList
|
|
624
733
|
});
|
|
625
|
-
case
|
|
734
|
+
case 18:
|
|
626
735
|
tempOrder = this.store.tempOrder;
|
|
627
|
-
holders = tempOrder
|
|
628
|
-
|
|
629
|
-
}] : [];
|
|
630
|
-
_ref12 = rulesModule.isDiscountListAvailable({
|
|
736
|
+
holders = (tempOrder === null || tempOrder === void 0 || (_tempOrder$holder = tempOrder.holder) === null || _tempOrder$holder === void 0 ? void 0 : _tempOrder$holder.form_record) || [];
|
|
737
|
+
_ref13 = rulesModule.isDiscountListAvailable({
|
|
631
738
|
productList: (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || [],
|
|
632
739
|
oldDiscountList: this.getDiscountList(),
|
|
633
740
|
newDiscountList: withScanList,
|
|
634
741
|
orderTotalAmount: Number(((_this$store$summary = this.store.summary) === null || _this$store$summary === void 0 ? void 0 : _this$store$summary.total_amount) || 0),
|
|
635
742
|
holders: holders,
|
|
636
|
-
isFormSubject:
|
|
743
|
+
isFormSubject: function isFormSubject(product) {
|
|
744
|
+
return resolveIsFormSubject(tempOrder, product);
|
|
745
|
+
}
|
|
637
746
|
}) || {
|
|
638
747
|
isAvailable: false,
|
|
639
748
|
discountList: this.getDiscountList()
|
|
640
|
-
}, isAvailable =
|
|
641
|
-
if (isAvailable && newDiscountList) {
|
|
642
|
-
|
|
643
|
-
|
|
749
|
+
}, isAvailable = _ref13.isAvailable, newDiscountList = _ref13.discountList, unavailableReason = _ref13.unavailableReason;
|
|
750
|
+
if (!(isAvailable && newDiscountList)) {
|
|
751
|
+
_context6.next = 26;
|
|
752
|
+
break;
|
|
644
753
|
}
|
|
645
|
-
|
|
754
|
+
(_this$store$discount12 = this.store.discount) === null || _this$store$discount12 === void 0 || _this$store$discount12.setDiscountList(newDiscountList);
|
|
755
|
+
this.applyDiscount();
|
|
756
|
+
_context6.next = 26;
|
|
757
|
+
return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
758
|
+
case 26:
|
|
759
|
+
return _context6.abrupt("return", {
|
|
646
760
|
type: 'clientCalc',
|
|
647
761
|
isAvailable: isAvailable || false,
|
|
648
762
|
discountList: newDiscountList || this.getDiscountList(),
|
|
649
763
|
scannedDiscountList: resultDiscountList,
|
|
650
764
|
unavailableReason: unavailableReason
|
|
651
765
|
});
|
|
652
|
-
case
|
|
766
|
+
case 27:
|
|
653
767
|
case "end":
|
|
654
|
-
return
|
|
768
|
+
return _context6.stop();
|
|
655
769
|
}
|
|
656
|
-
},
|
|
770
|
+
}, _callee6, this);
|
|
657
771
|
}));
|
|
658
|
-
function scanCode(
|
|
772
|
+
function scanCode(_x6, _x7) {
|
|
659
773
|
return _scanCode.apply(this, arguments);
|
|
660
774
|
}
|
|
661
775
|
return scanCode;
|
|
662
776
|
}()
|
|
663
777
|
}, {
|
|
664
778
|
key: "applyDiscount",
|
|
665
|
-
value: function applyDiscount() {
|
|
666
|
-
var _this$store$
|
|
667
|
-
_tempOrder$holder3,
|
|
668
|
-
_tempOrder$holder4,
|
|
779
|
+
value: function applyDiscount(options) {
|
|
780
|
+
var _this$store$discount13,
|
|
669
781
|
_this$store$summary2,
|
|
670
782
|
_this2 = this;
|
|
671
783
|
var tempOrder = this.store.tempOrder;
|
|
@@ -673,27 +785,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
673
785
|
// 也需要让 Rules.calcDiscount 把 DiscountModule 的 isSelected / isAvailable /
|
|
674
786
|
// appliedProductDetails / savedAmount 复位。
|
|
675
787
|
if (!tempOrder) return;
|
|
788
|
+
this.syncLinkedBookingHoldersToProducts(tempOrder);
|
|
676
789
|
delete tempOrder.discount_list;
|
|
677
|
-
|
|
790
|
+
var discountList = ((_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.getDiscountList()) || [];
|
|
791
|
+
var shouldSkipDiscountCalculation = this.shouldSkipDiscountCalculation(tempOrder);
|
|
792
|
+
if (shouldSkipDiscountCalculation) return;
|
|
678
793
|
var rulesModule = this.store.rules;
|
|
679
794
|
if (!rulesModule) return;
|
|
680
|
-
var discountList = ((_this$store$discount9 = this.store.discount) === null || _this$store$discount9 === void 0 ? void 0 : _this$store$discount9.getDiscountList()) || [];
|
|
681
|
-
var holders = (_tempOrder$holder3 = tempOrder.holder) !== null && _tempOrder$holder3 !== void 0 && _tempOrder$holder3.form_record_id ? [{
|
|
682
|
-
form_record_id: tempOrder.holder.form_record_id
|
|
683
|
-
}] : [];
|
|
684
795
|
var result = rulesModule.calcDiscount({
|
|
685
796
|
productList: tempOrder.products,
|
|
686
797
|
discountList: discountList,
|
|
687
|
-
holders:
|
|
688
|
-
isFormSubject:
|
|
798
|
+
holders: [],
|
|
799
|
+
isFormSubject: function isFormSubject(product) {
|
|
800
|
+
return resolveIsFormSubject(tempOrder, product);
|
|
801
|
+
},
|
|
689
802
|
orderTotalAmount: Number(((_this$store$summary2 = this.store.summary) === null || _this$store$summary2 === void 0 ? void 0 : _this$store$summary2.total_amount) || 0)
|
|
803
|
+
}, {
|
|
804
|
+
reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids
|
|
690
805
|
});
|
|
691
806
|
if (result !== null && result !== void 0 && result.productList) {
|
|
692
807
|
var previousProductsByUid = indexOrderProductsByUid(tempOrder.products);
|
|
693
808
|
tempOrder.products = this.applyProductDiscountPrices((result.productList || []).map(function (product, index) {
|
|
694
|
-
var
|
|
809
|
+
var _ref14;
|
|
695
810
|
var uid = getOrderProductLineUid(product);
|
|
696
|
-
var previous = (
|
|
811
|
+
var previous = (_ref14 = uid ? previousProductsByUid.get(uid) : undefined) !== null && _ref14 !== void 0 ? _ref14 : previousProductsByUid.get("__index__:".concat(index));
|
|
697
812
|
if (isManualProductDiscountProduct(previous)) {
|
|
698
813
|
return previous;
|
|
699
814
|
}
|
|
@@ -704,9 +819,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
704
819
|
}));
|
|
705
820
|
}
|
|
706
821
|
if (result !== null && result !== void 0 && result.discountList) {
|
|
707
|
-
var _this$store$
|
|
822
|
+
var _this$store$discount14;
|
|
708
823
|
OrderModule.populateSavedAmounts(result.productList || tempOrder.products, result.discountList);
|
|
709
|
-
(_this$store$
|
|
824
|
+
(_this$store$discount14 = this.store.discount) === null || _this$store$discount14 === void 0 || _this$store$discount14.setDiscountList(result.discountList);
|
|
710
825
|
}
|
|
711
826
|
this.hasActiveCustomerBoundDiscount = (tempOrder.products || []).some(function (product) {
|
|
712
827
|
return _this2.productHasCustomerBoundDiscount(product);
|
|
@@ -768,42 +883,42 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
768
883
|
}, {
|
|
769
884
|
key: "applyPromotion",
|
|
770
885
|
value: (function () {
|
|
771
|
-
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
886
|
+
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
772
887
|
var _this$promotionEvalua,
|
|
773
888
|
_this$promotionEvalua2,
|
|
774
889
|
_this3 = this;
|
|
775
890
|
var tempOrder, strategyConfigs, result, removeSet, _iterator3, _step3, reduce, _iterator6, _step6, _loop2, _iterator4, _step4, _loop, payload;
|
|
776
|
-
return _regeneratorRuntime().wrap(function
|
|
777
|
-
while (1) switch (
|
|
891
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context9) {
|
|
892
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
778
893
|
case 0:
|
|
779
894
|
if (!this.isApplyingPromotion) {
|
|
780
|
-
|
|
895
|
+
_context9.next = 2;
|
|
781
896
|
break;
|
|
782
897
|
}
|
|
783
|
-
return
|
|
898
|
+
return _context9.abrupt("return");
|
|
784
899
|
case 2:
|
|
785
900
|
if (this.promotionEvaluator) {
|
|
786
|
-
|
|
901
|
+
_context9.next = 4;
|
|
787
902
|
break;
|
|
788
903
|
}
|
|
789
|
-
return
|
|
904
|
+
return _context9.abrupt("return");
|
|
790
905
|
case 4:
|
|
791
906
|
tempOrder = this.store.tempOrder;
|
|
792
907
|
if (tempOrder) {
|
|
793
|
-
|
|
908
|
+
_context9.next = 7;
|
|
794
909
|
break;
|
|
795
910
|
}
|
|
796
|
-
return
|
|
911
|
+
return _context9.abrupt("return");
|
|
797
912
|
case 7:
|
|
798
913
|
strategyConfigs = (_this$promotionEvalua = (_this$promotionEvalua2 = this.promotionEvaluator).getStrategyConfigs) === null || _this$promotionEvalua === void 0 ? void 0 : _this$promotionEvalua.call(_this$promotionEvalua2);
|
|
799
914
|
if (!(Array.isArray(strategyConfigs) && strategyConfigs.length === 0)) {
|
|
800
|
-
|
|
915
|
+
_context9.next = 10;
|
|
801
916
|
break;
|
|
802
917
|
}
|
|
803
|
-
return
|
|
918
|
+
return _context9.abrupt("return");
|
|
804
919
|
case 10:
|
|
805
920
|
this.isApplyingPromotion = true;
|
|
806
|
-
|
|
921
|
+
_context9.prev = 11;
|
|
807
922
|
result = processCartPromotion(tempOrder.products, this.promotionEvaluator); // step 1: toRemove —— 直接过滤
|
|
808
923
|
if (result.giftActions.toRemove.length > 0) {
|
|
809
924
|
removeSet = new Set(result.giftActions.toRemove.map(String));
|
|
@@ -815,20 +930,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
815
930
|
|
|
816
931
|
// step 2: toReduce —— 调整数量
|
|
817
932
|
_iterator3 = _createForOfIteratorHelper(result.giftActions.toReduce);
|
|
818
|
-
|
|
933
|
+
_context9.prev = 15;
|
|
819
934
|
_iterator3.s();
|
|
820
935
|
case 17:
|
|
821
936
|
if ((_step3 = _iterator3.n()).done) {
|
|
822
|
-
|
|
937
|
+
_context9.next = 37;
|
|
823
938
|
break;
|
|
824
939
|
}
|
|
825
940
|
reduce = _step3.value;
|
|
826
941
|
_iterator6 = _createForOfIteratorHelper(reduce.items);
|
|
827
|
-
|
|
942
|
+
_context9.prev = 20;
|
|
828
943
|
_loop2 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop2() {
|
|
829
944
|
var item, product;
|
|
830
|
-
return _regeneratorRuntime().wrap(function _loop2$(
|
|
831
|
-
while (1) switch (
|
|
945
|
+
return _regeneratorRuntime().wrap(function _loop2$(_context8) {
|
|
946
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
832
947
|
case 0:
|
|
833
948
|
item = _step6.value;
|
|
834
949
|
product = result.products.find(function (p) {
|
|
@@ -839,52 +954,52 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
839
954
|
}
|
|
840
955
|
case 3:
|
|
841
956
|
case "end":
|
|
842
|
-
return
|
|
957
|
+
return _context8.stop();
|
|
843
958
|
}
|
|
844
959
|
}, _loop2);
|
|
845
960
|
});
|
|
846
961
|
_iterator6.s();
|
|
847
962
|
case 23:
|
|
848
963
|
if ((_step6 = _iterator6.n()).done) {
|
|
849
|
-
|
|
964
|
+
_context9.next = 27;
|
|
850
965
|
break;
|
|
851
966
|
}
|
|
852
|
-
return
|
|
967
|
+
return _context9.delegateYield(_loop2(), "t0", 25);
|
|
853
968
|
case 25:
|
|
854
|
-
|
|
969
|
+
_context9.next = 23;
|
|
855
970
|
break;
|
|
856
971
|
case 27:
|
|
857
|
-
|
|
972
|
+
_context9.next = 32;
|
|
858
973
|
break;
|
|
859
974
|
case 29:
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
_iterator6.e(
|
|
975
|
+
_context9.prev = 29;
|
|
976
|
+
_context9.t1 = _context9["catch"](20);
|
|
977
|
+
_iterator6.e(_context9.t1);
|
|
863
978
|
case 32:
|
|
864
|
-
|
|
979
|
+
_context9.prev = 32;
|
|
865
980
|
_iterator6.f();
|
|
866
|
-
return
|
|
981
|
+
return _context9.finish(32);
|
|
867
982
|
case 35:
|
|
868
|
-
|
|
983
|
+
_context9.next = 17;
|
|
869
984
|
break;
|
|
870
985
|
case 37:
|
|
871
|
-
|
|
986
|
+
_context9.next = 42;
|
|
872
987
|
break;
|
|
873
988
|
case 39:
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
_iterator3.e(
|
|
989
|
+
_context9.prev = 39;
|
|
990
|
+
_context9.t2 = _context9["catch"](15);
|
|
991
|
+
_iterator3.e(_context9.t2);
|
|
877
992
|
case 42:
|
|
878
|
-
|
|
993
|
+
_context9.prev = 42;
|
|
879
994
|
_iterator3.f();
|
|
880
|
-
return
|
|
995
|
+
return _context9.finish(42);
|
|
881
996
|
case 45:
|
|
882
997
|
if (!(result.giftActions.toAdd.length > 0)) {
|
|
883
|
-
|
|
998
|
+
_context9.next = 68;
|
|
884
999
|
break;
|
|
885
1000
|
}
|
|
886
1001
|
if (this.giftSelectResolver) {
|
|
887
|
-
|
|
1002
|
+
_context9.next = 50;
|
|
888
1003
|
break;
|
|
889
1004
|
}
|
|
890
1005
|
if (result.giftActions.toAdd.some(function (g) {
|
|
@@ -895,19 +1010,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
895
1010
|
} else {
|
|
896
1011
|
console.warn('[OrderModule] giftSelectResolver not set, skip applying single-option gifts', result.giftActions.toAdd);
|
|
897
1012
|
}
|
|
898
|
-
|
|
1013
|
+
_context9.next = 68;
|
|
899
1014
|
break;
|
|
900
1015
|
case 50:
|
|
901
1016
|
_iterator4 = _createForOfIteratorHelper(result.giftActions.toAdd);
|
|
902
|
-
|
|
1017
|
+
_context9.prev = 51;
|
|
903
1018
|
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
904
1019
|
var addAction, _sameStrategy$metadat, sameStrategy, giftResult, giftProducts, giftBookings, _iterator5, _step5, _step5$value, index, gp, booking, linked;
|
|
905
|
-
return _regeneratorRuntime().wrap(function _loop$(
|
|
906
|
-
while (1) switch (
|
|
1020
|
+
return _regeneratorRuntime().wrap(function _loop$(_context7) {
|
|
1021
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
907
1022
|
case 0:
|
|
908
1023
|
addAction = _step4.value;
|
|
909
1024
|
if (!(addAction.giftOptions.length === 1)) {
|
|
910
|
-
|
|
1025
|
+
_context7.next = 6;
|
|
911
1026
|
break;
|
|
912
1027
|
}
|
|
913
1028
|
sameStrategy = result.products.find(function (p) {
|
|
@@ -915,14 +1030,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
915
1030
|
return ((_p$metadata = p.metadata) === null || _p$metadata === void 0 || (_p$metadata = _p$metadata._giftInfo) === null || _p$metadata === void 0 ? void 0 : _p$metadata.strategyId) === addAction.strategyId;
|
|
916
1031
|
});
|
|
917
1032
|
if (!(sameStrategy && !sameStrategy.booking_uid && !((_sameStrategy$metadat = sameStrategy.metadata) !== null && _sameStrategy$metadat !== void 0 && _sameStrategy$metadat.booking_uid))) {
|
|
918
|
-
|
|
1033
|
+
_context7.next = 6;
|
|
919
1034
|
break;
|
|
920
1035
|
}
|
|
921
1036
|
sameStrategy.num = (Number(sameStrategy.num) || 0) + (addAction.giftCount || 1);
|
|
922
|
-
return
|
|
1037
|
+
return _context7.abrupt("return", 1);
|
|
923
1038
|
case 6:
|
|
924
|
-
|
|
925
|
-
|
|
1039
|
+
_context7.prev = 6;
|
|
1040
|
+
_context7.next = 9;
|
|
926
1041
|
return _this3.giftSelectResolver({
|
|
927
1042
|
strategyId: addAction.strategyId,
|
|
928
1043
|
strategyName: addAction.strategyName,
|
|
@@ -931,31 +1046,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
931
1046
|
sourceProductIds: addAction.sourceProductIds
|
|
932
1047
|
});
|
|
933
1048
|
case 9:
|
|
934
|
-
giftResult =
|
|
1049
|
+
giftResult = _context7.sent;
|
|
935
1050
|
giftProducts = Array.isArray(giftResult) ? giftResult : giftResult === null || giftResult === void 0 ? void 0 : giftResult.products;
|
|
936
1051
|
giftBookings = Array.isArray(giftResult) ? [] : (giftResult === null || giftResult === void 0 ? void 0 : giftResult.bookings) || [];
|
|
937
1052
|
if (!(Array.isArray(giftProducts) && giftProducts.length > 0)) {
|
|
938
|
-
|
|
1053
|
+
_context7.next = 37;
|
|
939
1054
|
break;
|
|
940
1055
|
}
|
|
941
1056
|
_iterator5 = _createForOfIteratorHelper(giftProducts.entries());
|
|
942
|
-
|
|
1057
|
+
_context7.prev = 14;
|
|
943
1058
|
_iterator5.s();
|
|
944
1059
|
case 16:
|
|
945
1060
|
if ((_step5 = _iterator5.n()).done) {
|
|
946
|
-
|
|
1061
|
+
_context7.next = 29;
|
|
947
1062
|
break;
|
|
948
1063
|
}
|
|
949
1064
|
_step5$value = _slicedToArray(_step5.value, 2), index = _step5$value[0], gp = _step5$value[1];
|
|
950
1065
|
if (gp) {
|
|
951
|
-
|
|
1066
|
+
_context7.next = 20;
|
|
952
1067
|
break;
|
|
953
1068
|
}
|
|
954
|
-
return
|
|
1069
|
+
return _context7.abrupt("continue", 27);
|
|
955
1070
|
case 20:
|
|
956
1071
|
booking = giftBookings[index];
|
|
957
1072
|
if (!booking) {
|
|
958
|
-
|
|
1073
|
+
_context7.next = 26;
|
|
959
1074
|
break;
|
|
960
1075
|
}
|
|
961
1076
|
linked = _this3.createLinkedProductAndBooking({
|
|
@@ -964,65 +1079,65 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
964
1079
|
});
|
|
965
1080
|
result.products.push(linked.product);
|
|
966
1081
|
tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
|
|
967
|
-
return
|
|
1082
|
+
return _context7.abrupt("continue", 27);
|
|
968
1083
|
case 26:
|
|
969
1084
|
// normalize 略过:调用方应保证返回完整 OrderProduct。
|
|
970
1085
|
result.products.push(gp);
|
|
971
1086
|
case 27:
|
|
972
|
-
|
|
1087
|
+
_context7.next = 16;
|
|
973
1088
|
break;
|
|
974
1089
|
case 29:
|
|
975
|
-
|
|
1090
|
+
_context7.next = 34;
|
|
976
1091
|
break;
|
|
977
1092
|
case 31:
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
_iterator5.e(
|
|
1093
|
+
_context7.prev = 31;
|
|
1094
|
+
_context7.t0 = _context7["catch"](14);
|
|
1095
|
+
_iterator5.e(_context7.t0);
|
|
981
1096
|
case 34:
|
|
982
|
-
|
|
1097
|
+
_context7.prev = 34;
|
|
983
1098
|
_iterator5.f();
|
|
984
|
-
return
|
|
1099
|
+
return _context7.finish(34);
|
|
985
1100
|
case 37:
|
|
986
|
-
|
|
1101
|
+
_context7.next = 42;
|
|
987
1102
|
break;
|
|
988
1103
|
case 39:
|
|
989
|
-
|
|
990
|
-
|
|
1104
|
+
_context7.prev = 39;
|
|
1105
|
+
_context7.t1 = _context7["catch"](6);
|
|
991
1106
|
// 用户取消 / 选择失败 → 视为放弃本次新增
|
|
992
|
-
console.warn('[OrderModule] giftSelectResolver rejected, skip add gift', addAction.strategyId,
|
|
1107
|
+
console.warn('[OrderModule] giftSelectResolver rejected, skip add gift', addAction.strategyId, _context7.t1);
|
|
993
1108
|
case 42:
|
|
994
1109
|
case "end":
|
|
995
|
-
return
|
|
1110
|
+
return _context7.stop();
|
|
996
1111
|
}
|
|
997
1112
|
}, _loop, null, [[6, 39], [14, 31, 34, 37]]);
|
|
998
1113
|
});
|
|
999
1114
|
_iterator4.s();
|
|
1000
1115
|
case 54:
|
|
1001
1116
|
if ((_step4 = _iterator4.n()).done) {
|
|
1002
|
-
|
|
1117
|
+
_context9.next = 60;
|
|
1003
1118
|
break;
|
|
1004
1119
|
}
|
|
1005
|
-
return
|
|
1120
|
+
return _context9.delegateYield(_loop(), "t3", 56);
|
|
1006
1121
|
case 56:
|
|
1007
|
-
if (!
|
|
1008
|
-
|
|
1122
|
+
if (!_context9.t3) {
|
|
1123
|
+
_context9.next = 58;
|
|
1009
1124
|
break;
|
|
1010
1125
|
}
|
|
1011
|
-
return
|
|
1126
|
+
return _context9.abrupt("continue", 58);
|
|
1012
1127
|
case 58:
|
|
1013
|
-
|
|
1128
|
+
_context9.next = 54;
|
|
1014
1129
|
break;
|
|
1015
1130
|
case 60:
|
|
1016
|
-
|
|
1131
|
+
_context9.next = 65;
|
|
1017
1132
|
break;
|
|
1018
1133
|
case 62:
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
_iterator4.e(
|
|
1134
|
+
_context9.prev = 62;
|
|
1135
|
+
_context9.t4 = _context9["catch"](51);
|
|
1136
|
+
_iterator4.e(_context9.t4);
|
|
1022
1137
|
case 65:
|
|
1023
|
-
|
|
1138
|
+
_context9.prev = 65;
|
|
1024
1139
|
_iterator4.f();
|
|
1025
|
-
return
|
|
1140
|
+
return _context9.finish(65);
|
|
1026
1141
|
case 68:
|
|
1027
1142
|
tempOrder.products = result.products;
|
|
1028
1143
|
this.lastUnfulfilledPromotions = result.unfulfilledPromotions;
|
|
@@ -1041,21 +1156,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1041
1156
|
products: tempOrder.products
|
|
1042
1157
|
};
|
|
1043
1158
|
this.effectsEmit('onPromotionApplied', payload);
|
|
1044
|
-
|
|
1159
|
+
_context9.next = 78;
|
|
1045
1160
|
break;
|
|
1046
1161
|
case 75:
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
console.error('[OrderModule] applyPromotion failed',
|
|
1162
|
+
_context9.prev = 75;
|
|
1163
|
+
_context9.t5 = _context9["catch"](11);
|
|
1164
|
+
console.error('[OrderModule] applyPromotion failed', _context9.t5);
|
|
1050
1165
|
case 78:
|
|
1051
|
-
|
|
1166
|
+
_context9.prev = 78;
|
|
1052
1167
|
this.isApplyingPromotion = false;
|
|
1053
|
-
return
|
|
1168
|
+
return _context9.finish(78);
|
|
1054
1169
|
case 81:
|
|
1055
1170
|
case "end":
|
|
1056
|
-
return
|
|
1171
|
+
return _context9.stop();
|
|
1057
1172
|
}
|
|
1058
|
-
},
|
|
1173
|
+
}, _callee7, this, [[11, 75, 78, 81], [15, 39, 42, 45], [20, 29, 32, 35], [51, 62, 65, 68]]);
|
|
1059
1174
|
}));
|
|
1060
1175
|
function applyPromotion() {
|
|
1061
1176
|
return _applyPromotion.apply(this, arguments);
|
|
@@ -1177,14 +1292,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1177
1292
|
}, {
|
|
1178
1293
|
key: "saveDraft",
|
|
1179
1294
|
value: function () {
|
|
1180
|
-
var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1181
|
-
return _regeneratorRuntime().wrap(function
|
|
1182
|
-
while (1) switch (
|
|
1295
|
+
var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
1296
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context10) {
|
|
1297
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
1183
1298
|
case 0:
|
|
1184
1299
|
case "end":
|
|
1185
|
-
return
|
|
1300
|
+
return _context10.stop();
|
|
1186
1301
|
}
|
|
1187
|
-
},
|
|
1302
|
+
}, _callee8);
|
|
1188
1303
|
}));
|
|
1189
1304
|
function saveDraft() {
|
|
1190
1305
|
return _saveDraft.apply(this, arguments);
|
|
@@ -1199,18 +1314,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1199
1314
|
}, {
|
|
1200
1315
|
key: "hydrateTempOrderFromLocalRecord",
|
|
1201
1316
|
value: function () {
|
|
1202
|
-
var _hydrateTempOrderFromLocalRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1203
|
-
return _regeneratorRuntime().wrap(function
|
|
1204
|
-
while (1) switch (
|
|
1317
|
+
var _hydrateTempOrderFromLocalRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(record) {
|
|
1318
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context11) {
|
|
1319
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1205
1320
|
case 0:
|
|
1206
|
-
return
|
|
1321
|
+
return _context11.abrupt("return", this.hydrateTempOrderFromRecord(record));
|
|
1207
1322
|
case 1:
|
|
1208
1323
|
case "end":
|
|
1209
|
-
return
|
|
1324
|
+
return _context11.stop();
|
|
1210
1325
|
}
|
|
1211
|
-
},
|
|
1326
|
+
}, _callee9, this);
|
|
1212
1327
|
}));
|
|
1213
|
-
function hydrateTempOrderFromLocalRecord(
|
|
1328
|
+
function hydrateTempOrderFromLocalRecord(_x8) {
|
|
1214
1329
|
return _hydrateTempOrderFromLocalRecord.apply(this, arguments);
|
|
1215
1330
|
}
|
|
1216
1331
|
return hydrateTempOrderFromLocalRecord;
|
|
@@ -1218,15 +1333,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1218
1333
|
}, {
|
|
1219
1334
|
key: "extractOrderIdFromSubmitResult",
|
|
1220
1335
|
value: function extractOrderIdFromSubmitResult(result) {
|
|
1221
|
-
var
|
|
1222
|
-
return (
|
|
1336
|
+
var _ref15, _ref16, _ref17, _result$data$order_id, _result$data, _result$data2;
|
|
1337
|
+
return (_ref15 = (_ref16 = (_ref17 = (_result$data$order_id = result === null || result === void 0 || (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.order_id) !== null && _result$data$order_id !== void 0 ? _result$data$order_id : result === null || result === void 0 ? void 0 : result.order_id) !== null && _ref17 !== void 0 ? _ref17 : result === null || result === void 0 || (_result$data2 = result.data) === null || _result$data2 === void 0 ? void 0 : _result$data2.id) !== null && _ref16 !== void 0 ? _ref16 : result === null || result === void 0 ? void 0 : result.id) !== null && _ref15 !== void 0 ? _ref15 : null;
|
|
1223
1338
|
}
|
|
1224
1339
|
}, {
|
|
1225
1340
|
key: "calculatePaymentEffectiveAmount",
|
|
1226
1341
|
value: function calculatePaymentEffectiveAmount(payment) {
|
|
1227
|
-
var
|
|
1342
|
+
var _ref18, _payment$origin_amoun;
|
|
1228
1343
|
var amount = new Decimal(payment.amount || 0);
|
|
1229
|
-
var originAmount = new Decimal((
|
|
1344
|
+
var originAmount = new Decimal((_ref18 = (_payment$origin_amoun = payment.origin_amount) !== null && _payment$origin_amoun !== void 0 ? _payment$origin_amoun : payment.amount) !== null && _ref18 !== void 0 ? _ref18 : 0);
|
|
1230
1345
|
var serviceFee = new Decimal(payment.service_fee || 0);
|
|
1231
1346
|
// TODO: 后端允许 amount 表示顾客实际支付总额后,移除这个兼容分支。
|
|
1232
1347
|
var effectiveAmount = serviceFee.gt(0) && amount.eq(originAmount) ? amount.plus(serviceFee) : amount;
|
|
@@ -1240,9 +1355,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1240
1355
|
return mapPaymentItemsToOrderPayments(payments, {
|
|
1241
1356
|
includeVoided: false
|
|
1242
1357
|
}).reduce(function (sum, payment) {
|
|
1358
|
+
if (!isPaidPaymentRecord(payment)) return sum;
|
|
1243
1359
|
return sum.plus(_this4.calculatePaymentEffectiveAmount(payment));
|
|
1244
1360
|
}, new Decimal(0));
|
|
1245
1361
|
}
|
|
1362
|
+
}, {
|
|
1363
|
+
key: "calculateOrderPaidPaymentTotal",
|
|
1364
|
+
value: function calculateOrderPaidPaymentTotal(payments) {
|
|
1365
|
+
var _this5 = this;
|
|
1366
|
+
return mapPaymentItemsToOrderPayments(payments, {
|
|
1367
|
+
includeVoided: false
|
|
1368
|
+
}).reduce(function (sum, payment) {
|
|
1369
|
+
if (!isPaidPaymentRecord(payment)) return sum;
|
|
1370
|
+
return sum.plus(_this5.calculatePaymentGapAmount(payment));
|
|
1371
|
+
}, new Decimal(0));
|
|
1372
|
+
}
|
|
1246
1373
|
}, {
|
|
1247
1374
|
key: "getDepositAmount",
|
|
1248
1375
|
value: function getDepositAmount(tempOrder, summary) {
|
|
@@ -1253,6 +1380,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1253
1380
|
value: function normalizeDepositAmount(amount) {
|
|
1254
1381
|
return Decimal.max(new Decimal(Number(amount) || 0), 0).toDecimalPlaces(2).toFixed(2);
|
|
1255
1382
|
}
|
|
1383
|
+
}, {
|
|
1384
|
+
key: "getLastOrderDepositSnapshot",
|
|
1385
|
+
value: function getLastOrderDepositSnapshot() {
|
|
1386
|
+
var _lastOrderInfo$deposi, _lastOrderInfo$summar;
|
|
1387
|
+
var lastOrderInfo = this.store.lastOrderInfo;
|
|
1388
|
+
if (!lastOrderInfo || _typeof(lastOrderInfo) !== 'object') return null;
|
|
1389
|
+
var rawDepositAmount = (_lastOrderInfo$deposi = lastOrderInfo.deposit_amount) !== null && _lastOrderInfo$deposi !== void 0 ? _lastOrderInfo$deposi : (_lastOrderInfo$summar = lastOrderInfo.summary) === null || _lastOrderInfo$summar === void 0 ? void 0 : _lastOrderInfo$summar.deposit_amount;
|
|
1390
|
+
var depositAmount = this.normalizeDepositAmount(rawDepositAmount !== null && rawDepositAmount !== void 0 ? rawDepositAmount : 0);
|
|
1391
|
+
var hasDepositAmount = new Decimal(depositAmount).gt(0);
|
|
1392
|
+
var isDeposit = Number(lastOrderInfo.is_deposit) === 1 || hasDepositAmount;
|
|
1393
|
+
if (!isDeposit || !hasDepositAmount) return null;
|
|
1394
|
+
return {
|
|
1395
|
+
isDeposit: 1,
|
|
1396
|
+
depositAmount: depositAmount
|
|
1397
|
+
};
|
|
1398
|
+
}
|
|
1399
|
+
}, {
|
|
1400
|
+
key: "getLastOrderSubmitSnapshot",
|
|
1401
|
+
value: function getLastOrderSubmitSnapshot() {
|
|
1402
|
+
var lastOrderInfo = this.store.lastOrderInfo;
|
|
1403
|
+
if (!lastOrderInfo || _typeof(lastOrderInfo) !== 'object') return {};
|
|
1404
|
+
var businessCode = lastOrderInfo.business_code;
|
|
1405
|
+
var type = lastOrderInfo.type;
|
|
1406
|
+
return _objectSpread(_objectSpread({}, typeof businessCode === 'string' && businessCode ? {
|
|
1407
|
+
businessCode: businessCode
|
|
1408
|
+
} : {}), typeof type === 'string' && type ? {
|
|
1409
|
+
type: type
|
|
1410
|
+
} : {});
|
|
1411
|
+
}
|
|
1256
1412
|
}, {
|
|
1257
1413
|
key: "applyDepositAmountToSummary",
|
|
1258
1414
|
value: function applyDepositAmountToSummary(tempOrder, summary, amount) {
|
|
@@ -1271,10 +1427,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1271
1427
|
tempOrder.is_deposit = hasDepositAmount ? 1 : 0;
|
|
1272
1428
|
return nextSummary;
|
|
1273
1429
|
}
|
|
1430
|
+
}, {
|
|
1431
|
+
key: "applyLastOrderDepositSnapshot",
|
|
1432
|
+
value: function applyLastOrderDepositSnapshot(tempOrder, summary) {
|
|
1433
|
+
var snapshot = this.getLastOrderDepositSnapshot();
|
|
1434
|
+
if (!snapshot) return summary;
|
|
1435
|
+
var existedDeposit = summary.deposit && _typeof(summary.deposit) === 'object' ? summary.deposit : undefined;
|
|
1436
|
+
var nextSummary = _objectSpread(_objectSpread({}, summary), {}, {
|
|
1437
|
+
deposit_amount: snapshot.depositAmount,
|
|
1438
|
+
deposit: _objectSpread(_objectSpread({}, existedDeposit || {}), {}, {
|
|
1439
|
+
total: snapshot.depositAmount,
|
|
1440
|
+
deposit_policy_ids: (existedDeposit === null || existedDeposit === void 0 ? void 0 : existedDeposit.deposit_policy_ids) || [],
|
|
1441
|
+
hasDeposit: true
|
|
1442
|
+
})
|
|
1443
|
+
});
|
|
1444
|
+
tempOrder.deposit_amount = snapshot.depositAmount;
|
|
1445
|
+
tempOrder.is_deposit = tempOrder.is_deposit === 0 && new Decimal(tempOrder.deposit_amount || 0).gt(0) ? 0 : snapshot.isDeposit;
|
|
1446
|
+
return nextSummary;
|
|
1447
|
+
}
|
|
1274
1448
|
}, {
|
|
1275
1449
|
key: "isDepositOrder",
|
|
1276
1450
|
value: function isDepositOrder(tempOrder, depositAmount) {
|
|
1277
|
-
return tempOrder.is_deposit === 1
|
|
1451
|
+
return tempOrder.is_deposit === 1 && depositAmount.gt(0);
|
|
1278
1452
|
}
|
|
1279
1453
|
}, {
|
|
1280
1454
|
key: "getOrderExpectedAmount",
|
|
@@ -1289,20 +1463,42 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1289
1463
|
if (depositAmount.lte(0)) return false;
|
|
1290
1464
|
return params.paidAmount.gte(depositAmount);
|
|
1291
1465
|
}
|
|
1466
|
+
}, {
|
|
1467
|
+
key: "getPaymentCompletion",
|
|
1468
|
+
value: function getPaymentCompletion(payments) {
|
|
1469
|
+
var tempOrder = this.ensureTempOrder();
|
|
1470
|
+
var summary = this.store.summary || createEmptySummary();
|
|
1471
|
+
var paymentList = payments || tempOrder.payments || [];
|
|
1472
|
+
var refundAmount = this.getSummaryRefundAmount(summary);
|
|
1473
|
+
var netPaidAmount = Decimal.max(this.calculateOrderPaidPaymentTotal(paymentList).minus(refundAmount), 0);
|
|
1474
|
+
var depositAmount = this.getDepositAmount(tempOrder, summary);
|
|
1475
|
+
var orderExpectedAmount = this.getOrderExpectedAmount(summary);
|
|
1476
|
+
var isDepositFullyPaid = this.isDepositCovered({
|
|
1477
|
+
tempOrder: tempOrder,
|
|
1478
|
+
summary: summary,
|
|
1479
|
+
paidAmount: netPaidAmount
|
|
1480
|
+
});
|
|
1481
|
+
var isOrderFullyPaid = orderExpectedAmount.lte(0) ? true : netPaidAmount.gte(orderExpectedAmount);
|
|
1482
|
+
var paymentStage = this.isDepositOrder(tempOrder, depositAmount) && !isDepositFullyPaid ? 'deposit' : 'normal';
|
|
1483
|
+
return {
|
|
1484
|
+
isFullyPaid: isOrderFullyPaid,
|
|
1485
|
+
isOrderFullyPaid: isOrderFullyPaid,
|
|
1486
|
+
isDepositFullyPaid: isDepositFullyPaid,
|
|
1487
|
+
paymentStage: paymentStage,
|
|
1488
|
+
depositAmount: depositAmount.toFixed(2),
|
|
1489
|
+
orderExpectedAmount: orderExpectedAmount.toFixed(2)
|
|
1490
|
+
};
|
|
1491
|
+
}
|
|
1292
1492
|
}, {
|
|
1293
1493
|
key: "calculateDepositPaidAmount",
|
|
1294
1494
|
value: function calculateDepositPaidAmount(payments) {
|
|
1295
|
-
var
|
|
1495
|
+
var _this6 = this;
|
|
1296
1496
|
return (payments || []).reduce(function (sum, payment) {
|
|
1297
1497
|
var paymentRecord = payment;
|
|
1298
|
-
if ((paymentRecord
|
|
1498
|
+
if (!isPaidPaymentRecord(paymentRecord)) return sum;
|
|
1299
1499
|
var isDepositPayment = paymentRecord.type === 'deposit' || paymentRecord.order_payment_type === 'deposit';
|
|
1300
1500
|
if (!isDepositPayment) return sum;
|
|
1301
|
-
|
|
1302
|
-
return sum.plus(_this5.calculatePaymentGapAmount(paymentRecord));
|
|
1303
|
-
}
|
|
1304
|
-
var rounding = new Decimal(paymentRecord.rounding_amount || 0);
|
|
1305
|
-
return sum.plus(new Decimal(paymentRecord.amount || 0).minus(rounding));
|
|
1501
|
+
return sum.plus(_this6.calculatePaymentGapAmount(paymentRecord));
|
|
1306
1502
|
}, new Decimal(0));
|
|
1307
1503
|
}
|
|
1308
1504
|
}, {
|
|
@@ -1317,7 +1513,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1317
1513
|
}, {
|
|
1318
1514
|
key: "normalizePaymentSource",
|
|
1319
1515
|
value: function normalizePaymentSource(payment, options) {
|
|
1320
|
-
var
|
|
1516
|
+
var _ref19, _paymentRecord$origin;
|
|
1321
1517
|
var paymentRecord = payment;
|
|
1322
1518
|
var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
|
|
1323
1519
|
if (!metadata.unique_payment_number) {
|
|
@@ -1325,7 +1521,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1325
1521
|
}
|
|
1326
1522
|
var normalized = _objectSpread(_objectSpread({}, paymentRecord), {}, {
|
|
1327
1523
|
metadata: metadata,
|
|
1328
|
-
origin_amount: (
|
|
1524
|
+
origin_amount: (_ref19 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref19 !== void 0 ? _ref19 : '0.00'
|
|
1329
1525
|
});
|
|
1330
1526
|
if (paymentRecord.status !== undefined) {
|
|
1331
1527
|
normalized.status = paymentRecord.status;
|
|
@@ -1339,8 +1535,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1339
1535
|
value: function updateTempOrderPaymentStatus(tempOrder, options) {
|
|
1340
1536
|
var summary = (options === null || options === void 0 ? void 0 : options.summary) || this.store.summary || createEmptySummary();
|
|
1341
1537
|
var paymentTotal = this.calculatePaymentTotal(tempOrder.payments || []);
|
|
1538
|
+
var orderPaymentTotal = this.calculateOrderPaidPaymentTotal(tempOrder.payments || []);
|
|
1342
1539
|
var refundAmount = this.getSummaryRefundAmount(summary);
|
|
1343
|
-
var netPaymentTotal = Decimal.max(
|
|
1540
|
+
var netPaymentTotal = Decimal.max(orderPaymentTotal.minus(refundAmount), 0);
|
|
1344
1541
|
var targetAmount = this.calculatePaymentTargetAmount(tempOrder, summary, netPaymentTotal);
|
|
1345
1542
|
if (this.shouldKeepPaymentStatusAfterAmountRecalc(tempOrder.payment_status, {
|
|
1346
1543
|
netPaymentTotal: netPaymentTotal,
|
|
@@ -1406,7 +1603,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1406
1603
|
key: "capVoucherPaymentsByRemainingAmount",
|
|
1407
1604
|
value: function capVoucherPaymentsByRemainingAmount(params) {
|
|
1408
1605
|
var targetAmount = this.getPaymentTargetAmount();
|
|
1409
|
-
var nonVoucherTotal = this.
|
|
1606
|
+
var nonVoucherTotal = this.calculateOrderPaidPaymentTotal(params.nonVoucherPayments);
|
|
1410
1607
|
if (targetAmount.lte(0)) return [];
|
|
1411
1608
|
var remainingAmount = Decimal.max(targetAmount.minus(nonVoucherTotal), 0);
|
|
1412
1609
|
var cappedVouchers = [];
|
|
@@ -1443,16 +1640,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1443
1640
|
}, {
|
|
1444
1641
|
key: "calculatePaidPaymentSummary",
|
|
1445
1642
|
value: function calculatePaidPaymentSummary(payments) {
|
|
1446
|
-
var
|
|
1643
|
+
var _this7 = this;
|
|
1447
1644
|
return (payments || []).reduce(function (summary, payment) {
|
|
1448
1645
|
var paymentRecord = payment;
|
|
1449
|
-
if ((paymentRecord
|
|
1646
|
+
if (!isPaidPaymentRecord(paymentRecord)) return summary;
|
|
1450
1647
|
return {
|
|
1451
1648
|
customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
|
|
1452
|
-
orderPaidAmount: summary.orderPaidAmount.plus(paymentRecord
|
|
1453
|
-
gapPaidAmount: summary.gapPaidAmount.plus(
|
|
1454
|
-
payServiceChargeAmount: summary.payServiceChargeAmount.plus(
|
|
1455
|
-
roundingAmount: summary.roundingAmount.plus(
|
|
1649
|
+
orderPaidAmount: summary.orderPaidAmount.plus(_this7.calculatePaymentOrderAmount(paymentRecord)),
|
|
1650
|
+
gapPaidAmount: summary.gapPaidAmount.plus(_this7.calculatePaymentGapAmount(paymentRecord)),
|
|
1651
|
+
payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this7.calculatePaymentServiceFee(paymentRecord)),
|
|
1652
|
+
roundingAmount: summary.roundingAmount.plus(_this7.calculatePaymentRoundingAmount(paymentRecord))
|
|
1456
1653
|
};
|
|
1457
1654
|
}, {
|
|
1458
1655
|
customerPaidAmount: new Decimal(0),
|
|
@@ -1476,11 +1673,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1476
1673
|
}, {
|
|
1477
1674
|
key: "calculatePaymentGapAmount",
|
|
1478
1675
|
value: function calculatePaymentGapAmount(payment) {
|
|
1479
|
-
if (payment.origin_amount
|
|
1480
|
-
|
|
1676
|
+
if (payment.origin_amount !== undefined && payment.origin_amount !== null && payment.origin_amount !== '') {
|
|
1677
|
+
var _rounding = new Decimal(payment.rounding_amount || 0);
|
|
1678
|
+
return new Decimal(payment.origin_amount || 0).minus(_rounding);
|
|
1481
1679
|
}
|
|
1482
1680
|
var rounding = new Decimal(payment.rounding_amount || 0);
|
|
1483
|
-
|
|
1681
|
+
var amount = new Decimal(payment.amount || 0);
|
|
1682
|
+
var serviceFee = this.calculatePaymentServiceFee(payment);
|
|
1683
|
+
if (serviceFee.lte(0)) return amount.minus(rounding);
|
|
1684
|
+
if (!hasSyncedOrderPaymentRecord(payment)) return new Decimal(0);
|
|
1685
|
+
return Decimal.max(amount.minus(serviceFee), 0).minus(rounding);
|
|
1686
|
+
}
|
|
1687
|
+
}, {
|
|
1688
|
+
key: "calculatePaymentOrderAmount",
|
|
1689
|
+
value: function calculatePaymentOrderAmount(payment) {
|
|
1690
|
+
if (payment.origin_amount !== undefined && payment.origin_amount !== null && payment.origin_amount !== '') {
|
|
1691
|
+
return new Decimal(payment.origin_amount || 0);
|
|
1692
|
+
}
|
|
1693
|
+
var amount = new Decimal(payment.amount || 0);
|
|
1694
|
+
var serviceFee = this.calculatePaymentServiceFee(payment);
|
|
1695
|
+
if (serviceFee.lte(0)) return amount;
|
|
1696
|
+
if (!hasSyncedOrderPaymentRecord(payment)) return new Decimal(0);
|
|
1697
|
+
return Decimal.max(amount.minus(serviceFee), 0);
|
|
1484
1698
|
}
|
|
1485
1699
|
}, {
|
|
1486
1700
|
key: "calculatePaymentRoundingAmount",
|
|
@@ -1637,15 +1851,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1637
1851
|
}, {
|
|
1638
1852
|
key: "normalizeFingerprintValue",
|
|
1639
1853
|
value: function normalizeFingerprintValue(value) {
|
|
1640
|
-
var
|
|
1854
|
+
var _this8 = this;
|
|
1641
1855
|
if (Array.isArray(value)) {
|
|
1642
1856
|
return value.map(function (item) {
|
|
1643
|
-
return
|
|
1857
|
+
return _this8.normalizeFingerprintValue(item);
|
|
1644
1858
|
});
|
|
1645
1859
|
}
|
|
1646
1860
|
if (!value || _typeof(value) !== 'object') return value !== null && value !== void 0 ? value : '';
|
|
1647
1861
|
return Object.keys(value).sort().reduce(function (result, key) {
|
|
1648
|
-
result[key] =
|
|
1862
|
+
result[key] = _this8.normalizeFingerprintValue(value[key]);
|
|
1649
1863
|
return result;
|
|
1650
1864
|
}, {});
|
|
1651
1865
|
}
|
|
@@ -1658,9 +1872,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1658
1872
|
_product$payment_pric,
|
|
1659
1873
|
_sku$code,
|
|
1660
1874
|
_sku$barcode,
|
|
1661
|
-
|
|
1875
|
+
_ref20,
|
|
1662
1876
|
_sku$variant_id,
|
|
1663
|
-
|
|
1877
|
+
_this9 = this;
|
|
1664
1878
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
1665
1879
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
1666
1880
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -1685,37 +1899,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1685
1899
|
product_sku: this.normalizeFingerprintValue({
|
|
1686
1900
|
code: (_sku$code = sku.code) !== null && _sku$code !== void 0 ? _sku$code : '',
|
|
1687
1901
|
barcode: (_sku$barcode = sku.barcode) !== null && _sku$barcode !== void 0 ? _sku$barcode : '',
|
|
1688
|
-
variant_id: (
|
|
1902
|
+
variant_id: (_ref20 = (_sku$variant_id = sku.variant_id) !== null && _sku$variant_id !== void 0 ? _sku$variant_id : product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _ref20 !== void 0 ? _ref20 : 0,
|
|
1689
1903
|
variant: sku.variant || [],
|
|
1690
1904
|
option: getProductSkuOptions(product || {}).map(function (option) {
|
|
1691
|
-
var
|
|
1905
|
+
var _ref21, _option$id, _option$option_group_, _ref22, _option$option_group_2, _option$num, _option$add_price;
|
|
1692
1906
|
return {
|
|
1693
|
-
id: (
|
|
1907
|
+
id: (_ref21 = (_option$id = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id !== void 0 ? _option$id : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref21 !== void 0 ? _ref21 : null,
|
|
1694
1908
|
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,
|
|
1695
|
-
option_group_item_id: (
|
|
1909
|
+
option_group_item_id: (_ref22 = (_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 && _ref22 !== void 0 ? _ref22 : null,
|
|
1696
1910
|
num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
|
|
1697
|
-
add_price:
|
|
1911
|
+
add_price: _this9.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)
|
|
1698
1912
|
};
|
|
1699
1913
|
})
|
|
1700
1914
|
}),
|
|
1701
1915
|
product_bundle: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.product_bundle) || []).map(function (bundle) {
|
|
1702
|
-
var
|
|
1916
|
+
var _ref23, _ref24, _bundle$bundle_produc, _ref25, _bundle$bundle_varian, _bundle$num, _bundle$price_type, _bundle$price_type_ex;
|
|
1703
1917
|
return {
|
|
1704
|
-
bundle_product_id: (
|
|
1705
|
-
bundle_variant_id: (
|
|
1918
|
+
bundle_product_id: (_ref23 = (_ref24 = (_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 && _ref24 !== void 0 ? _ref24 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref23 !== void 0 ? _ref23 : null,
|
|
1919
|
+
bundle_variant_id: (_ref25 = (_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 && _ref25 !== void 0 ? _ref25 : 0,
|
|
1706
1920
|
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),
|
|
1707
|
-
price:
|
|
1708
|
-
bundle_selling_price:
|
|
1921
|
+
price: _this9.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
|
|
1922
|
+
bundle_selling_price: _this9.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
|
|
1709
1923
|
price_type: (_bundle$price_type = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type !== void 0 ? _bundle$price_type : '',
|
|
1710
1924
|
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 : ''
|
|
1711
1925
|
};
|
|
1712
1926
|
})),
|
|
1713
1927
|
discount_list: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
1714
|
-
var
|
|
1928
|
+
var _ref26, _discount$type2, _ref27, _ref28, _discount$discount_id, _discount$discount;
|
|
1715
1929
|
return {
|
|
1716
|
-
type: (
|
|
1717
|
-
discount_id: (
|
|
1718
|
-
amount:
|
|
1930
|
+
type: (_ref26 = (_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 && _ref26 !== void 0 ? _ref26 : '',
|
|
1931
|
+
discount_id: (_ref27 = (_ref28 = (_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 && _ref28 !== void 0 ? _ref28 : discount === null || discount === void 0 || (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) !== null && _ref27 !== void 0 ? _ref27 : null,
|
|
1932
|
+
amount: _this9.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
1719
1933
|
};
|
|
1720
1934
|
}))
|
|
1721
1935
|
};
|
|
@@ -1723,9 +1937,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1723
1937
|
}, {
|
|
1724
1938
|
key: "buildOrderProductsFingerprint",
|
|
1725
1939
|
value: function buildOrderProductsFingerprint(products) {
|
|
1726
|
-
var
|
|
1940
|
+
var _this10 = this;
|
|
1727
1941
|
var items = (products || []).map(function (product) {
|
|
1728
|
-
return
|
|
1942
|
+
return _this10.buildProductFingerprintItem(product);
|
|
1729
1943
|
});
|
|
1730
1944
|
items.sort(function (left, right) {
|
|
1731
1945
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -1738,16 +1952,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1738
1952
|
var _product$product_id3,
|
|
1739
1953
|
_product$product_vari2,
|
|
1740
1954
|
_product$num2,
|
|
1741
|
-
|
|
1955
|
+
_ref29,
|
|
1742
1956
|
_metadata$unique_iden,
|
|
1743
1957
|
_metadata$price_overr,
|
|
1744
1958
|
_metadata$is_manual_d,
|
|
1745
1959
|
_metadata$product_dis,
|
|
1746
1960
|
_sku$code2,
|
|
1747
1961
|
_sku$barcode2,
|
|
1748
|
-
|
|
1962
|
+
_ref30,
|
|
1749
1963
|
_sku$variant_id2,
|
|
1750
|
-
|
|
1964
|
+
_this11 = this;
|
|
1751
1965
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
1752
1966
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
1753
1967
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -1761,7 +1975,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1761
1975
|
extension_type: extensionType,
|
|
1762
1976
|
num: getSafeProductNum((_product$num2 = product === null || product === void 0 ? void 0 : product.num) !== null && _product$num2 !== void 0 ? _product$num2 : product === null || product === void 0 ? void 0 : product.product_quantity),
|
|
1763
1977
|
metadata: {
|
|
1764
|
-
unique_identification_number: (
|
|
1978
|
+
unique_identification_number: (_ref29 = (_metadata$unique_iden = metadata.unique_identification_number) !== null && _metadata$unique_iden !== void 0 ? _metadata$unique_iden : product === null || product === void 0 ? void 0 : product.unique_identification_number) !== null && _ref29 !== void 0 ? _ref29 : '',
|
|
1765
1979
|
price_override: (_metadata$price_overr = metadata.price_override) !== null && _metadata$price_overr !== void 0 ? _metadata$price_overr : '',
|
|
1766
1980
|
is_manual_discount: (_metadata$is_manual_d = metadata.is_manual_discount) !== null && _metadata$is_manual_d !== void 0 ? _metadata$is_manual_d : '',
|
|
1767
1981
|
product_discount_reason: (_metadata$product_dis = metadata.product_discount_reason) !== null && _metadata$product_dis !== void 0 ? _metadata$product_dis : ''
|
|
@@ -1769,47 +1983,47 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1769
1983
|
product_sku: this.normalizeFingerprintValue({
|
|
1770
1984
|
code: (_sku$code2 = sku.code) !== null && _sku$code2 !== void 0 ? _sku$code2 : '',
|
|
1771
1985
|
barcode: (_sku$barcode2 = sku.barcode) !== null && _sku$barcode2 !== void 0 ? _sku$barcode2 : '',
|
|
1772
|
-
variant_id: (
|
|
1986
|
+
variant_id: (_ref30 = (_sku$variant_id2 = sku.variant_id) !== null && _sku$variant_id2 !== void 0 ? _sku$variant_id2 : product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _ref30 !== void 0 ? _ref30 : 0,
|
|
1773
1987
|
variant: sku.variant || [],
|
|
1774
1988
|
option: getProductSkuOptions(product || {}).map(function (option) {
|
|
1775
|
-
var
|
|
1989
|
+
var _ref31, _option$id2, _option$option_group_3, _ref32, _option$option_group_4, _option$num2, _option$add_price2;
|
|
1776
1990
|
return {
|
|
1777
|
-
id: (
|
|
1991
|
+
id: (_ref31 = (_option$id2 = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id2 !== void 0 ? _option$id2 : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref31 !== void 0 ? _ref31 : null,
|
|
1778
1992
|
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,
|
|
1779
|
-
option_group_item_id: (
|
|
1993
|
+
option_group_item_id: (_ref32 = (_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 && _ref32 !== void 0 ? _ref32 : null,
|
|
1780
1994
|
num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
|
|
1781
|
-
add_price:
|
|
1995
|
+
add_price: _this11.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)
|
|
1782
1996
|
};
|
|
1783
1997
|
})
|
|
1784
1998
|
}),
|
|
1785
1999
|
product_bundle: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.product_bundle) || []).map(function (bundle) {
|
|
1786
|
-
var
|
|
2000
|
+
var _ref33, _bundle$bundle_id, _ref34, _bundle$bundle_group_, _ref35, _ref36, _bundle$bundle_produc2, _ref37, _bundle$bundle_varian2, _bundle$num2, _bundle$price_type2, _bundle$price_type_ex2;
|
|
1787
2001
|
return {
|
|
1788
|
-
bundle_id: (
|
|
1789
|
-
bundle_group_id: (
|
|
1790
|
-
bundle_product_id: (
|
|
1791
|
-
bundle_variant_id: (
|
|
2002
|
+
bundle_id: (_ref33 = (_bundle$bundle_id = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_id) !== null && _bundle$bundle_id !== void 0 ? _bundle$bundle_id : bundle === null || bundle === void 0 ? void 0 : bundle.id) !== null && _ref33 !== void 0 ? _ref33 : null,
|
|
2003
|
+
bundle_group_id: (_ref34 = (_bundle$bundle_group_ = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle === null || bundle === void 0 ? void 0 : bundle.group_id) !== null && _ref34 !== void 0 ? _ref34 : null,
|
|
2004
|
+
bundle_product_id: (_ref35 = (_ref36 = (_bundle$bundle_produc2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref36 !== void 0 ? _ref36 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref35 !== void 0 ? _ref35 : null,
|
|
2005
|
+
bundle_variant_id: (_ref37 = (_bundle$bundle_varian2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_variant_id) !== null && _bundle$bundle_varian2 !== void 0 ? _bundle$bundle_varian2 : bundle === null || bundle === void 0 ? void 0 : bundle.product_variant_id) !== null && _ref37 !== void 0 ? _ref37 : 0,
|
|
1792
2006
|
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),
|
|
1793
2007
|
price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
|
|
1794
2008
|
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 : '',
|
|
1795
|
-
option:
|
|
1796
|
-
var
|
|
2009
|
+
option: _this11.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
|
|
2010
|
+
var _ref38, _option$id3, _option$option_group_5, _ref39, _option$option_group_6, _option$num3, _option$add_price3;
|
|
1797
2011
|
return {
|
|
1798
|
-
id: (
|
|
2012
|
+
id: (_ref38 = (_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 && _ref38 !== void 0 ? _ref38 : null,
|
|
1799
2013
|
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,
|
|
1800
|
-
option_group_item_id: (
|
|
2014
|
+
option_group_item_id: (_ref39 = (_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 && _ref39 !== void 0 ? _ref39 : null,
|
|
1801
2015
|
num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
|
|
1802
|
-
add_price:
|
|
2016
|
+
add_price: _this11.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)
|
|
1803
2017
|
};
|
|
1804
2018
|
}))
|
|
1805
2019
|
};
|
|
1806
2020
|
})),
|
|
1807
2021
|
discount_list: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
1808
|
-
var
|
|
2022
|
+
var _ref40, _discount$type4, _ref41, _ref42, _discount$discount_id2, _discount$discount2;
|
|
1809
2023
|
return {
|
|
1810
|
-
type: (
|
|
1811
|
-
discount_id: (
|
|
1812
|
-
amount:
|
|
2024
|
+
type: (_ref40 = (_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 && _ref40 !== void 0 ? _ref40 : '',
|
|
2025
|
+
discount_id: (_ref41 = (_ref42 = (_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 && _ref42 !== void 0 ? _ref42 : discount === null || discount === void 0 || (_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) !== null && _ref41 !== void 0 ? _ref41 : null,
|
|
2026
|
+
amount: _this11.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
1813
2027
|
};
|
|
1814
2028
|
}))
|
|
1815
2029
|
};
|
|
@@ -1817,9 +2031,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1817
2031
|
}, {
|
|
1818
2032
|
key: "buildOrderProductsStructuralFingerprint",
|
|
1819
2033
|
value: function buildOrderProductsStructuralFingerprint(products) {
|
|
1820
|
-
var
|
|
2034
|
+
var _this12 = this;
|
|
1821
2035
|
var items = (products || []).map(function (product) {
|
|
1822
|
-
return
|
|
2036
|
+
return _this12.buildProductStructuralFingerprintItem(product);
|
|
1823
2037
|
});
|
|
1824
2038
|
items.sort(function (left, right) {
|
|
1825
2039
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -1880,19 +2094,36 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1880
2094
|
});
|
|
1881
2095
|
return currentAmountGap === snapshotAmountGap;
|
|
1882
2096
|
}
|
|
2097
|
+
}, {
|
|
2098
|
+
key: "hasShopDiscountChangedFromSnapshot",
|
|
2099
|
+
value: function hasShopDiscountChangedFromSnapshot(tempOrder, snapshot) {
|
|
2100
|
+
var _snapshot$shop_discou;
|
|
2101
|
+
var snapshotSummary = snapshot.summary && _typeof(snapshot.summary) === 'object' ? snapshot.summary : {};
|
|
2102
|
+
var snapshotShopDiscount = (_snapshot$shop_discou = snapshot.shop_discount) !== null && _snapshot$shop_discou !== void 0 ? _snapshot$shop_discou : snapshotSummary.shop_discount;
|
|
2103
|
+
if (snapshotShopDiscount === undefined || snapshotShopDiscount === null || snapshotShopDiscount === '') {
|
|
2104
|
+
return !new Decimal(tempOrder.shop_discount || 0).equals(0);
|
|
2105
|
+
}
|
|
2106
|
+
return !new Decimal(tempOrder.shop_discount || 0).equals(snapshotShopDiscount || 0);
|
|
2107
|
+
}
|
|
1883
2108
|
}, {
|
|
1884
2109
|
key: "restoreOriginalSnapshotIfProductsUnchanged",
|
|
1885
|
-
value: function restoreOriginalSnapshotIfProductsUnchanged(tempOrder) {
|
|
1886
|
-
var snapshot = this.getOriginalSalesSnapshot(tempOrder);
|
|
1887
|
-
if (!snapshot) return null;
|
|
2110
|
+
value: function restoreOriginalSnapshotIfProductsUnchanged(tempOrder, snapshot) {
|
|
1888
2111
|
var currentFingerprint = this.buildOrderProductsFingerprint(tempOrder.products);
|
|
2112
|
+
var manualDepositOverride = this.getManualDepositOverride(tempOrder);
|
|
1889
2113
|
if (currentFingerprint !== snapshot.productFingerprint) {
|
|
1890
2114
|
var currentStructuralFingerprint = this.buildOrderProductsStructuralFingerprint(tempOrder.products);
|
|
1891
2115
|
var snapshotStructuralFingerprint = this.buildOrderProductsStructuralFingerprint(Array.isArray(snapshot.products) ? snapshot.products : []);
|
|
1892
2116
|
if (currentStructuralFingerprint !== snapshotStructuralFingerprint) return null;
|
|
1893
2117
|
}
|
|
1894
2118
|
var summary = _objectSpread(_objectSpread({}, createEmptySummary()), cloneDeep(snapshot.summary || {}));
|
|
1895
|
-
|
|
2119
|
+
var shouldUseManualDepositOverride = Boolean(manualDepositOverride && manualDepositOverride.productStructuralFingerprint === this.buildOrderProductsStructuralFingerprint(tempOrder.products));
|
|
2120
|
+
if (shouldUseManualDepositOverride) {
|
|
2121
|
+
summary = this.applyDepositAmountToSummary(tempOrder, summary, manualDepositOverride.amount);
|
|
2122
|
+
} else if (manualDepositOverride) {
|
|
2123
|
+
this.clearManualDepositOverride(tempOrder);
|
|
2124
|
+
}
|
|
2125
|
+
var isPayableAmountUnchanged = this.isSnapshotPayableAmountUnchanged(tempOrder, snapshot, summary);
|
|
2126
|
+
if (!isPayableAmountUnchanged) return null;
|
|
1896
2127
|
if (Array.isArray(snapshot.products)) {
|
|
1897
2128
|
tempOrder.products = cloneDeep(snapshot.products);
|
|
1898
2129
|
}
|
|
@@ -1902,7 +2133,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1902
2133
|
tempOrder.surcharge_fee = summary.surcharge_fee || tempOrder.surcharge_fee;
|
|
1903
2134
|
tempOrder.deposit_amount = summary.deposit_amount || '0.00';
|
|
1904
2135
|
tempOrder.is_deposit = summary.deposit_amount !== '0.00' ? 1 : 0;
|
|
2136
|
+
var previousSummary = this.store.summary;
|
|
1905
2137
|
this.store.summary = summary;
|
|
2138
|
+
this.updateTempOrderPaymentStatus(tempOrder, {
|
|
2139
|
+
previousSummary: previousSummary,
|
|
2140
|
+
summary: summary
|
|
2141
|
+
});
|
|
1906
2142
|
return summary;
|
|
1907
2143
|
}
|
|
1908
2144
|
}, {
|
|
@@ -2014,15 +2250,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2014
2250
|
}, {
|
|
2015
2251
|
key: "restoreOrder",
|
|
2016
2252
|
value: function restoreOrder() {
|
|
2017
|
-
var _this$store$
|
|
2253
|
+
var _this$store$discount15, _this$store$discount16;
|
|
2254
|
+
this.logInfo('restoreOrder start', {});
|
|
2018
2255
|
var freshTempOrder = this.createDefaultTempOrderInstance();
|
|
2019
2256
|
this.ensureExternalSaleNumber(freshTempOrder);
|
|
2020
2257
|
this.store.tempOrder = freshTempOrder;
|
|
2021
2258
|
this.store.summary = createEmptySummary();
|
|
2022
2259
|
this.store.lastOrderInfo = undefined;
|
|
2023
2260
|
this.store.syncState = undefined;
|
|
2024
|
-
void ((_this$store$
|
|
2025
|
-
void ((_this$store$
|
|
2261
|
+
void ((_this$store$discount15 = this.store.discount) === null || _this$store$discount15 === void 0 ? void 0 : _this$store$discount15.setOriginalDiscountList([]));
|
|
2262
|
+
void ((_this$store$discount16 = this.store.discount) === null || _this$store$discount16 === void 0 ? void 0 : _this$store$discount16.setDiscountList([]));
|
|
2026
2263
|
this.persistTempOrder();
|
|
2027
2264
|
return freshTempOrder;
|
|
2028
2265
|
}
|
|
@@ -2034,13 +2271,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2034
2271
|
}, {
|
|
2035
2272
|
key: "replaceTempOrder",
|
|
2036
2273
|
value: function () {
|
|
2037
|
-
var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2274
|
+
var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(tempOrder, options) {
|
|
2038
2275
|
var nextTempOrder;
|
|
2039
|
-
return _regeneratorRuntime().wrap(function
|
|
2040
|
-
while (1) switch (
|
|
2276
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context12) {
|
|
2277
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
2041
2278
|
case 0:
|
|
2042
2279
|
if (isTempOrder(tempOrder)) {
|
|
2043
|
-
|
|
2280
|
+
_context12.next = 2;
|
|
2044
2281
|
break;
|
|
2045
2282
|
}
|
|
2046
2283
|
throw new Error('无效的 tempOrder 数据');
|
|
@@ -2050,15 +2287,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2050
2287
|
});
|
|
2051
2288
|
this.store.tempOrder = nextTempOrder;
|
|
2052
2289
|
if (!((options === null || options === void 0 ? void 0 : options.recalculateSummary) !== false)) {
|
|
2053
|
-
|
|
2290
|
+
_context12.next = 9;
|
|
2054
2291
|
break;
|
|
2055
2292
|
}
|
|
2056
|
-
|
|
2293
|
+
_context12.next = 7;
|
|
2057
2294
|
return this.recalculateSummary({
|
|
2058
2295
|
createIfMissing: false
|
|
2059
2296
|
});
|
|
2060
2297
|
case 7:
|
|
2061
|
-
|
|
2298
|
+
_context12.next = 10;
|
|
2062
2299
|
break;
|
|
2063
2300
|
case 9:
|
|
2064
2301
|
this.store.summary = createEmptySummary();
|
|
@@ -2067,20 +2304,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2067
2304
|
this.persistTempOrder();
|
|
2068
2305
|
}
|
|
2069
2306
|
if (!(options !== null && options !== void 0 && options.saveDraft)) {
|
|
2070
|
-
|
|
2307
|
+
_context12.next = 14;
|
|
2071
2308
|
break;
|
|
2072
2309
|
}
|
|
2073
|
-
|
|
2310
|
+
_context12.next = 14;
|
|
2074
2311
|
return this.saveDraft();
|
|
2075
2312
|
case 14:
|
|
2076
|
-
return
|
|
2313
|
+
return _context12.abrupt("return", nextTempOrder);
|
|
2077
2314
|
case 15:
|
|
2078
2315
|
case "end":
|
|
2079
|
-
return
|
|
2316
|
+
return _context12.stop();
|
|
2080
2317
|
}
|
|
2081
|
-
},
|
|
2318
|
+
}, _callee10, this);
|
|
2082
2319
|
}));
|
|
2083
|
-
function replaceTempOrder(
|
|
2320
|
+
function replaceTempOrder(_x9, _x10) {
|
|
2084
2321
|
return _replaceTempOrder.apply(this, arguments);
|
|
2085
2322
|
}
|
|
2086
2323
|
return replaceTempOrder;
|
|
@@ -2088,11 +2325,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2088
2325
|
}, {
|
|
2089
2326
|
key: "getOrderIdentity",
|
|
2090
2327
|
value: function getOrderIdentity() {
|
|
2091
|
-
var
|
|
2328
|
+
var _ref43, _ref44, _tempOrder$order_id, _tempOrder$_extend6;
|
|
2092
2329
|
var tempOrder = this.store.tempOrder;
|
|
2093
2330
|
if (!tempOrder) return null;
|
|
2094
2331
|
var lastOrderInfo = this.store.lastOrderInfo || {};
|
|
2095
|
-
var orderId = (
|
|
2332
|
+
var orderId = (_ref43 = (_ref44 = (_tempOrder$order_id = tempOrder.order_id) !== null && _tempOrder$order_id !== void 0 ? _tempOrder$order_id : lastOrderInfo.order_id) !== null && _ref44 !== void 0 ? _ref44 : lastOrderInfo.id) !== null && _ref43 !== void 0 ? _ref43 : null;
|
|
2096
2333
|
return {
|
|
2097
2334
|
localId: this.cacheId || ((_tempOrder$_extend6 = tempOrder._extend) === null || _tempOrder$_extend6 === void 0 ? void 0 : _tempOrder$_extend6.localId),
|
|
2098
2335
|
orderId: orderId,
|
|
@@ -2127,7 +2364,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2127
2364
|
orderPaidAmount: paidPaymentSummary.gapPaidAmount
|
|
2128
2365
|
});
|
|
2129
2366
|
return {
|
|
2130
|
-
isDeposit: tempOrder.is_deposit === 1
|
|
2367
|
+
isDeposit: tempOrder.is_deposit === 1,
|
|
2131
2368
|
depositAmount: depositAmount,
|
|
2132
2369
|
expectAmount: summary.expect_amount || '0.00',
|
|
2133
2370
|
totalAmount: summary.total_amount || '0.00',
|
|
@@ -2166,32 +2403,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2166
2403
|
}, {
|
|
2167
2404
|
key: "addNewOrder",
|
|
2168
2405
|
value: function () {
|
|
2169
|
-
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2406
|
+
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
2170
2407
|
var tempOrder;
|
|
2171
|
-
return _regeneratorRuntime().wrap(function
|
|
2172
|
-
while (1) switch (
|
|
2408
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context13) {
|
|
2409
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
2173
2410
|
case 0:
|
|
2174
2411
|
tempOrder = this.ensureTempOrder();
|
|
2175
2412
|
this.ensureExternalSaleNumber(tempOrder);
|
|
2176
|
-
|
|
2413
|
+
_context13.next = 4;
|
|
2177
2414
|
return this.recalculateSummary({
|
|
2178
2415
|
createIfMissing: true
|
|
2179
2416
|
});
|
|
2180
2417
|
case 4:
|
|
2181
2418
|
this.persistTempOrder();
|
|
2182
2419
|
if (!this.draftPersistEnabled) {
|
|
2183
|
-
|
|
2420
|
+
_context13.next = 8;
|
|
2184
2421
|
break;
|
|
2185
2422
|
}
|
|
2186
|
-
|
|
2423
|
+
_context13.next = 8;
|
|
2187
2424
|
return this.saveDraft();
|
|
2188
2425
|
case 8:
|
|
2189
|
-
return
|
|
2426
|
+
return _context13.abrupt("return", tempOrder);
|
|
2190
2427
|
case 9:
|
|
2191
2428
|
case "end":
|
|
2192
|
-
return
|
|
2429
|
+
return _context13.stop();
|
|
2193
2430
|
}
|
|
2194
|
-
},
|
|
2431
|
+
}, _callee11, this);
|
|
2195
2432
|
}));
|
|
2196
2433
|
function addNewOrder() {
|
|
2197
2434
|
return _addNewOrder.apply(this, arguments);
|
|
@@ -2224,9 +2461,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2224
2461
|
}, {
|
|
2225
2462
|
key: "sanitizeTempOrderProducts",
|
|
2226
2463
|
value: function sanitizeTempOrderProducts(tempOrder) {
|
|
2227
|
-
var
|
|
2464
|
+
var _this13 = this;
|
|
2228
2465
|
tempOrder.products = (tempOrder.products || []).map(function (product) {
|
|
2229
|
-
return
|
|
2466
|
+
return _this13.sanitizeOrderProductForTempOrder(product);
|
|
2230
2467
|
});
|
|
2231
2468
|
}
|
|
2232
2469
|
}, {
|
|
@@ -2245,11 +2482,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2245
2482
|
}, {
|
|
2246
2483
|
key: "captureProductRuntime",
|
|
2247
2484
|
value: function captureProductRuntime(tempOrder, rawProduct, normalizedProduct, existedUid) {
|
|
2248
|
-
var _extend$productsByUid,
|
|
2485
|
+
var _extend$productsByUid, _ref45, _rawProduct$_origin;
|
|
2249
2486
|
var uid = existedUid || this.getProductUid(normalizedProduct);
|
|
2250
2487
|
var extend = this.ensureExtend(tempOrder);
|
|
2251
2488
|
var existed = ((_extend$productsByUid = extend.productsByUid) === null || _extend$productsByUid === void 0 ? void 0 : _extend$productsByUid[uid]) || {};
|
|
2252
|
-
var origin = (
|
|
2489
|
+
var origin = (_ref45 = (_rawProduct$_origin = rawProduct._origin) !== null && _rawProduct$_origin !== void 0 ? _rawProduct$_origin : normalizedProduct._origin) !== null && _ref45 !== void 0 ? _ref45 : existed.origin;
|
|
2253
2490
|
extend.productsByUid[uid] = _objectSpread(_objectSpread({}, existed), origin !== undefined ? {
|
|
2254
2491
|
origin: origin
|
|
2255
2492
|
} : {});
|
|
@@ -2316,6 +2553,48 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2316
2553
|
return record !== undefined && record !== null && record !== '';
|
|
2317
2554
|
});
|
|
2318
2555
|
}
|
|
2556
|
+
}, {
|
|
2557
|
+
key: "setProductHolderFromBooking",
|
|
2558
|
+
value: function setProductHolderFromBooking(product, booking) {
|
|
2559
|
+
if (!product || !booking) return;
|
|
2560
|
+
var holderRecords = this.collectBookingHolderRecords(booking);
|
|
2561
|
+
if (!product.metadata || _typeof(product.metadata) !== 'object') {
|
|
2562
|
+
product.metadata = {};
|
|
2563
|
+
}
|
|
2564
|
+
product.metadata.holder_id = holderRecords.length > 0 ? holderRecords : null;
|
|
2565
|
+
}
|
|
2566
|
+
}, {
|
|
2567
|
+
key: "syncLinkedBookingHoldersToProducts",
|
|
2568
|
+
value: function syncLinkedBookingHoldersToProducts(tempOrder) {
|
|
2569
|
+
var _this14 = this;
|
|
2570
|
+
var bookings = tempOrder.bookings || [];
|
|
2571
|
+
var products = tempOrder.products || [];
|
|
2572
|
+
if (!bookings.length || !products.length) return;
|
|
2573
|
+
var bookingByProductUid = new Map();
|
|
2574
|
+
var bookingByBookingUid = new Map();
|
|
2575
|
+
bookings.forEach(function (booking) {
|
|
2576
|
+
var _booking$metadata2, _booking$metadata3;
|
|
2577
|
+
if (!booking || _typeof(booking) !== 'object') return;
|
|
2578
|
+
var productUid = booking.product_uid || ((_booking$metadata2 = booking.metadata) === null || _booking$metadata2 === void 0 ? void 0 : _booking$metadata2.product_uid);
|
|
2579
|
+
if (productUid !== undefined && productUid !== null && String(productUid) !== '') {
|
|
2580
|
+
bookingByProductUid.set(String(productUid), booking);
|
|
2581
|
+
}
|
|
2582
|
+
var bookingUid = ((_booking$metadata3 = booking.metadata) === null || _booking$metadata3 === void 0 ? void 0 : _booking$metadata3.unique_identification_number) || booking.booking_uid;
|
|
2583
|
+
if (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '') {
|
|
2584
|
+
bookingByBookingUid.set(String(bookingUid), booking);
|
|
2585
|
+
}
|
|
2586
|
+
});
|
|
2587
|
+
products.forEach(function (product) {
|
|
2588
|
+
var _product$metadata5, _product$metadata6;
|
|
2589
|
+
if (!product || _typeof(product) !== 'object') return;
|
|
2590
|
+
var productUid = ((_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number) || product.unique_identification_number;
|
|
2591
|
+
var bookingUid = product.booking_uid || ((_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.booking_uid);
|
|
2592
|
+
var linkedBooking = (productUid !== undefined && productUid !== null && String(productUid) !== '' ? bookingByProductUid.get(String(productUid)) : undefined) || (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '' ? bookingByBookingUid.get(String(bookingUid)) : undefined);
|
|
2593
|
+
if (linkedBooking) {
|
|
2594
|
+
_this14.setProductHolderFromBooking(product, linkedBooking);
|
|
2595
|
+
}
|
|
2596
|
+
});
|
|
2597
|
+
}
|
|
2319
2598
|
|
|
2320
2599
|
/**
|
|
2321
2600
|
* 按 form_record 顺序读取 booking holder 的主字段名称。
|
|
@@ -2350,7 +2629,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2350
2629
|
}, {
|
|
2351
2630
|
key: "buildTempOrderHolderFromBookings",
|
|
2352
2631
|
value: function buildTempOrderHolderFromBookings(tempOrder) {
|
|
2353
|
-
var _baseHolder$customer_, _baseHolder,
|
|
2632
|
+
var _baseHolder$customer_, _baseHolder, _ref46, _baseHolder$form_id, _baseHolder2, _tempOrder$holder2, _baseHolder3, _this$otherParams;
|
|
2354
2633
|
var holderRecords = [];
|
|
2355
2634
|
var holderNames = [];
|
|
2356
2635
|
var baseHolder = null;
|
|
@@ -2397,7 +2676,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2397
2676
|
}
|
|
2398
2677
|
var nextHolder = {
|
|
2399
2678
|
customer_id: (_baseHolder$customer_ = (_baseHolder = baseHolder) === null || _baseHolder === void 0 ? void 0 : _baseHolder.customer_id) !== null && _baseHolder$customer_ !== void 0 ? _baseHolder$customer_ : tempOrder.customer_id,
|
|
2400
|
-
form_id: (
|
|
2679
|
+
form_id: (_ref46 = (_baseHolder$form_id = (_baseHolder2 = baseHolder) === null || _baseHolder2 === void 0 ? void 0 : _baseHolder2.form_id) !== null && _baseHolder$form_id !== void 0 ? _baseHolder$form_id : (_tempOrder$holder2 = tempOrder.holder) === null || _tempOrder$holder2 === void 0 ? void 0 : _tempOrder$holder2.form_id) !== null && _ref46 !== void 0 ? _ref46 : 0,
|
|
2401
2680
|
form_record: holderRecords
|
|
2402
2681
|
};
|
|
2403
2682
|
if (holderNames.length) {
|
|
@@ -2420,41 +2699,42 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2420
2699
|
value: function syncTempOrderHolderFromBookings(tempOrder) {
|
|
2421
2700
|
var bookings = tempOrder.bookings || [];
|
|
2422
2701
|
var hasHolderSource = bookings.some(function (booking) {
|
|
2423
|
-
var _booking$
|
|
2424
|
-
return (booking === null || booking === void 0 ? void 0 : booking.holder) !== undefined || (booking === null || booking === void 0 || (_booking$
|
|
2702
|
+
var _booking$metadata4;
|
|
2703
|
+
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;
|
|
2425
2704
|
});
|
|
2426
2705
|
var nextHolder = this.buildTempOrderHolderFromBookings(tempOrder);
|
|
2427
2706
|
if (nextHolder || hasHolderSource || bookings.length === 0) {
|
|
2428
2707
|
tempOrder.holder = nextHolder;
|
|
2429
2708
|
}
|
|
2709
|
+
this.syncLinkedBookingHoldersToProducts(tempOrder);
|
|
2430
2710
|
}
|
|
2431
2711
|
}, {
|
|
2432
2712
|
key: "getBookingUniqueIdentificationNumber",
|
|
2433
2713
|
value: function getBookingUniqueIdentificationNumber(booking) {
|
|
2434
|
-
var _booking$
|
|
2435
|
-
var uid = booking === null || booking === void 0 || (_booking$
|
|
2714
|
+
var _booking$metadata5;
|
|
2715
|
+
var uid = booking === null || booking === void 0 || (_booking$metadata5 = booking.metadata) === null || _booking$metadata5 === void 0 ? void 0 : _booking$metadata5.unique_identification_number;
|
|
2436
2716
|
if (uid === undefined || uid === null || uid === '') return null;
|
|
2437
2717
|
return String(uid);
|
|
2438
2718
|
}
|
|
2439
2719
|
}, {
|
|
2440
2720
|
key: "findBookingIndexByUniqueIdentificationNumber",
|
|
2441
2721
|
value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
|
|
2442
|
-
var
|
|
2722
|
+
var _this15 = this;
|
|
2443
2723
|
return (tempOrder.bookings || []).findIndex(function (booking) {
|
|
2444
|
-
return
|
|
2724
|
+
return _this15.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
|
|
2445
2725
|
});
|
|
2446
2726
|
}
|
|
2447
2727
|
}, {
|
|
2448
2728
|
key: "removeLinkedBookingsForProduct",
|
|
2449
2729
|
value: function removeLinkedBookingsForProduct(tempOrder, product) {
|
|
2450
|
-
var _product$
|
|
2451
|
-
_product$
|
|
2452
|
-
|
|
2453
|
-
var productUid = (product === null || product === void 0 || (_product$
|
|
2454
|
-
var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$
|
|
2730
|
+
var _product$metadata7,
|
|
2731
|
+
_product$metadata8,
|
|
2732
|
+
_this16 = this;
|
|
2733
|
+
var productUid = (product === null || product === void 0 || (_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
2734
|
+
var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.booking_uid);
|
|
2455
2735
|
if (!productUid && !bookingUid) return;
|
|
2456
2736
|
tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
2457
|
-
var currentBookingUid =
|
|
2737
|
+
var currentBookingUid = _this16.getBookingUniqueIdentificationNumber(booking);
|
|
2458
2738
|
if (bookingUid && currentBookingUid === String(bookingUid)) return false;
|
|
2459
2739
|
if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
|
|
2460
2740
|
return true;
|
|
@@ -2492,35 +2772,39 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2492
2772
|
hasDeposit: true
|
|
2493
2773
|
} : undefined
|
|
2494
2774
|
});
|
|
2775
|
+
var isExistingDepositDisabled = tempOrder.is_deposit === 0 && new Decimal(tempOrder.deposit_amount || 0).gt(0);
|
|
2495
2776
|
tempOrder.deposit_amount = depositAmount;
|
|
2496
|
-
tempOrder.is_deposit = hasDepositAmount ? 1 : 0;
|
|
2497
|
-
return nextSummary;
|
|
2777
|
+
tempOrder.is_deposit = hasDepositAmount && !isExistingDepositDisabled ? 1 : 0;
|
|
2778
|
+
return this.applyLastOrderDepositSnapshot(tempOrder, nextSummary);
|
|
2498
2779
|
}
|
|
2499
2780
|
}, {
|
|
2500
2781
|
key: "recalculateSummary",
|
|
2501
2782
|
value: function () {
|
|
2502
|
-
var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2503
|
-
var
|
|
2504
|
-
var tempOrder, snapshotSummary, shouldFullRecalculateFromSnapshot, summaryProducts, salesSummary, existedSummary, totalRefundAmount, paidPaymentSummary, emptyBaseSummary, emptySummaryBase, emptySummaryWithDeposit, emptySummary, salesSummaryResult, roundingAmount, payServiceChargeAmount, hasSalesSummaryAmount, expectAmount, amountPaymentPatch, normalizedExpectAmountPatch, summaryForGap, summary;
|
|
2505
|
-
return _regeneratorRuntime().wrap(function
|
|
2506
|
-
while (1) switch (
|
|
2783
|
+
var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(options) {
|
|
2784
|
+
var _this$otherParams2, _ref47, _salesSummaryResult$e;
|
|
2785
|
+
var tempOrder, originalSnapshot, hasShopDiscountChanged, shouldReuseOriginalSnapshot, snapshotSummary, shouldFullRecalculateFromSnapshot, summaryProducts, salesSummary, existedSummary, totalRefundAmount, paidPaymentSummary, emptyBaseSummary, emptySummaryBase, emptySummaryWithDeposit, emptySummary, salesSummaryResult, roundingAmount, payServiceChargeAmount, hasSalesSummaryAmount, expectAmount, amountPaymentPatch, normalizedExpectAmountPatch, summaryForGap, summary;
|
|
2786
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context14) {
|
|
2787
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
2507
2788
|
case 0:
|
|
2508
2789
|
tempOrder = options !== null && options !== void 0 && options.createIfMissing ? this.ensureTempOrder() : this.store.tempOrder;
|
|
2509
2790
|
if (tempOrder) {
|
|
2510
|
-
|
|
2791
|
+
_context14.next = 3;
|
|
2511
2792
|
break;
|
|
2512
2793
|
}
|
|
2513
|
-
return
|
|
2794
|
+
return _context14.abrupt("return", null);
|
|
2514
2795
|
case 3:
|
|
2515
2796
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
2516
|
-
|
|
2797
|
+
originalSnapshot = this.getOriginalSalesSnapshot(tempOrder);
|
|
2798
|
+
hasShopDiscountChanged = originalSnapshot ? this.hasShopDiscountChangedFromSnapshot(tempOrder, originalSnapshot) : false;
|
|
2799
|
+
shouldReuseOriginalSnapshot = originalSnapshot && !hasShopDiscountChanged;
|
|
2800
|
+
snapshotSummary = shouldReuseOriginalSnapshot ? this.restoreOriginalSnapshotIfProductsUnchanged(tempOrder, originalSnapshot) : null;
|
|
2517
2801
|
if (!snapshotSummary) {
|
|
2518
|
-
|
|
2802
|
+
_context14.next = 10;
|
|
2519
2803
|
break;
|
|
2520
2804
|
}
|
|
2521
|
-
return
|
|
2522
|
-
case
|
|
2523
|
-
shouldFullRecalculateFromSnapshot = Boolean(
|
|
2805
|
+
return _context14.abrupt("return", snapshotSummary);
|
|
2806
|
+
case 10:
|
|
2807
|
+
shouldFullRecalculateFromSnapshot = Boolean(originalSnapshot);
|
|
2524
2808
|
summaryProducts = shouldFullRecalculateFromSnapshot ? cloneDeep(tempOrder.products || []) : tempOrder.products;
|
|
2525
2809
|
if (shouldFullRecalculateFromSnapshot) {
|
|
2526
2810
|
this.clearPersistedAmountFieldsForFullRecalc(summaryProducts || []);
|
|
@@ -2530,7 +2814,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2530
2814
|
totalRefundAmount = existedSummary.total_refund_amount || '0.00';
|
|
2531
2815
|
paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
|
|
2532
2816
|
if (salesSummary) {
|
|
2533
|
-
|
|
2817
|
+
_context14.next = 26;
|
|
2534
2818
|
break;
|
|
2535
2819
|
}
|
|
2536
2820
|
emptyBaseSummary = _objectSpread(_objectSpread(_objectSpread({}, createEmptySummary()), existedSummary), {}, {
|
|
@@ -2556,16 +2840,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2556
2840
|
previousSummary: existedSummary,
|
|
2557
2841
|
summary: emptySummary
|
|
2558
2842
|
});
|
|
2559
|
-
return
|
|
2560
|
-
case
|
|
2561
|
-
|
|
2562
|
-
return salesSummary.getSummary({
|
|
2843
|
+
return _context14.abrupt("return", this.store.summary);
|
|
2844
|
+
case 26:
|
|
2845
|
+
_context14.next = 28;
|
|
2846
|
+
return salesSummary.getSummary(_objectSpread({
|
|
2563
2847
|
products: summaryProducts,
|
|
2564
2848
|
isPriceIncludeTax: tempOrder.is_price_include_tax,
|
|
2565
2849
|
shopDiscount: tempOrder.shop_discount
|
|
2566
|
-
})
|
|
2567
|
-
|
|
2568
|
-
|
|
2850
|
+
}, (_this$otherParams2 = this.otherParams) !== null && _this$otherParams2 !== void 0 && _this$otherParams2.channel ? {
|
|
2851
|
+
channel: this.otherParams.channel
|
|
2852
|
+
} : {}));
|
|
2853
|
+
case 28:
|
|
2854
|
+
salesSummaryResult = _context14.sent;
|
|
2569
2855
|
if (shouldFullRecalculateFromSnapshot) {
|
|
2570
2856
|
tempOrder.products = summaryProducts;
|
|
2571
2857
|
}
|
|
@@ -2573,7 +2859,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2573
2859
|
roundingAmount = paidPaymentSummary.roundingAmount;
|
|
2574
2860
|
payServiceChargeAmount = paidPaymentSummary.payServiceChargeAmount;
|
|
2575
2861
|
hasSalesSummaryAmount = salesSummaryResult.expect_amount !== undefined || salesSummaryResult.total_amount !== undefined;
|
|
2576
|
-
expectAmount = hasSalesSummaryAmount ? new Decimal((
|
|
2862
|
+
expectAmount = hasSalesSummaryAmount ? new Decimal((_ref47 = (_salesSummaryResult$e = salesSummaryResult.expect_amount) !== null && _salesSummaryResult$e !== void 0 ? _salesSummaryResult$e : salesSummaryResult.total_amount) !== null && _ref47 !== void 0 ? _ref47 : 0) : null;
|
|
2577
2863
|
amountPaymentPatch = hasSalesSummaryAmount || !roundingAmount.eq(0) || !payServiceChargeAmount.eq(0) ? _objectSpread({
|
|
2578
2864
|
rounding_amount: roundingAmount.toFixed(2)
|
|
2579
2865
|
}, expectAmount ? {
|
|
@@ -2610,14 +2896,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2610
2896
|
previousSummary: existedSummary,
|
|
2611
2897
|
summary: summary
|
|
2612
2898
|
});
|
|
2613
|
-
return
|
|
2614
|
-
case
|
|
2899
|
+
return _context14.abrupt("return", this.store.summary);
|
|
2900
|
+
case 46:
|
|
2615
2901
|
case "end":
|
|
2616
|
-
return
|
|
2902
|
+
return _context14.stop();
|
|
2617
2903
|
}
|
|
2618
|
-
},
|
|
2904
|
+
}, _callee12, this);
|
|
2619
2905
|
}));
|
|
2620
|
-
function recalculateSummary(
|
|
2906
|
+
function recalculateSummary(_x11) {
|
|
2621
2907
|
return _recalculateSummary.apply(this, arguments);
|
|
2622
2908
|
}
|
|
2623
2909
|
return recalculateSummary;
|
|
@@ -2625,30 +2911,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2625
2911
|
}, {
|
|
2626
2912
|
key: "getOrderSummary",
|
|
2627
2913
|
value: function () {
|
|
2628
|
-
var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2914
|
+
var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
2629
2915
|
var summary;
|
|
2630
|
-
return _regeneratorRuntime().wrap(function
|
|
2631
|
-
while (1) switch (
|
|
2916
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context15) {
|
|
2917
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
2632
2918
|
case 0:
|
|
2633
|
-
|
|
2919
|
+
_context15.next = 2;
|
|
2634
2920
|
return this.recalculateSummary({
|
|
2635
2921
|
createIfMissing: true
|
|
2636
2922
|
});
|
|
2637
2923
|
case 2:
|
|
2638
|
-
summary =
|
|
2924
|
+
summary = _context15.sent;
|
|
2639
2925
|
if (summary) {
|
|
2640
|
-
|
|
2926
|
+
_context15.next = 5;
|
|
2641
2927
|
break;
|
|
2642
2928
|
}
|
|
2643
|
-
return
|
|
2929
|
+
return _context15.abrupt("return", createEmptySummary());
|
|
2644
2930
|
case 5:
|
|
2645
2931
|
this.persistTempOrder();
|
|
2646
|
-
return
|
|
2932
|
+
return _context15.abrupt("return", summary);
|
|
2647
2933
|
case 7:
|
|
2648
2934
|
case "end":
|
|
2649
|
-
return
|
|
2935
|
+
return _context15.stop();
|
|
2650
2936
|
}
|
|
2651
|
-
},
|
|
2937
|
+
}, _callee13, this);
|
|
2652
2938
|
}));
|
|
2653
2939
|
function getOrderSummary() {
|
|
2654
2940
|
return _getOrderSummary.apply(this, arguments);
|
|
@@ -2672,23 +2958,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2672
2958
|
}, {
|
|
2673
2959
|
key: "syncTempOrderNoteToRemote",
|
|
2674
2960
|
value: function () {
|
|
2675
|
-
var _syncTempOrderNoteToRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2676
|
-
return _regeneratorRuntime().wrap(function
|
|
2677
|
-
while (1) switch (
|
|
2961
|
+
var _syncTempOrderNoteToRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(orderId, note) {
|
|
2962
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context16) {
|
|
2963
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
2678
2964
|
case 0:
|
|
2679
|
-
|
|
2965
|
+
_context16.next = 2;
|
|
2680
2966
|
return this.request.put("/order/order/".concat(orderId, "/note"), {
|
|
2681
2967
|
note: note
|
|
2682
2968
|
});
|
|
2683
2969
|
case 2:
|
|
2684
|
-
return
|
|
2970
|
+
return _context16.abrupt("return", note);
|
|
2685
2971
|
case 3:
|
|
2686
2972
|
case "end":
|
|
2687
|
-
return
|
|
2973
|
+
return _context16.stop();
|
|
2688
2974
|
}
|
|
2689
|
-
},
|
|
2975
|
+
}, _callee14, this);
|
|
2690
2976
|
}));
|
|
2691
|
-
function syncTempOrderNoteToRemote(
|
|
2977
|
+
function syncTempOrderNoteToRemote(_x12, _x13) {
|
|
2692
2978
|
return _syncTempOrderNoteToRemote.apply(this, arguments);
|
|
2693
2979
|
}
|
|
2694
2980
|
return syncTempOrderNoteToRemote;
|
|
@@ -2751,17 +3037,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2751
3037
|
}, {
|
|
2752
3038
|
key: "buildTempOrderCustomer",
|
|
2753
3039
|
value: function buildTempOrderCustomer(params) {
|
|
2754
|
-
var
|
|
3040
|
+
var _ref48, _ref49, _ref50, _source$name, _ref51, _ref52, _ref53, _source$customer_name, _source$id, _source$customer_id, _ref54, _source$country_calli, _source$phone, _source$email;
|
|
2755
3041
|
if (!params.customerId) return null;
|
|
2756
3042
|
var source = params.source ? cloneDeep(params.source) : {};
|
|
2757
|
-
var name = (
|
|
2758
|
-
var customerName = (
|
|
3043
|
+
var name = (_ref48 = (_ref49 = (_ref50 = (_source$name = source.name) !== null && _source$name !== void 0 ? _source$name : source.display_name) !== null && _ref50 !== void 0 ? _ref50 : source.customerName) !== null && _ref49 !== void 0 ? _ref49 : source.customer_name) !== null && _ref48 !== void 0 ? _ref48 : params.customerName;
|
|
3044
|
+
var customerName = (_ref51 = (_ref52 = (_ref53 = (_source$customer_name = source.customer_name) !== null && _source$customer_name !== void 0 ? _source$customer_name : source.customerName) !== null && _ref53 !== void 0 ? _ref53 : source.display_name) !== null && _ref52 !== void 0 ? _ref52 : source.name) !== null && _ref51 !== void 0 ? _ref51 : params.customerName;
|
|
2759
3045
|
return _objectSpread(_objectSpread({}, source), {}, {
|
|
2760
3046
|
id: (_source$id = source.id) !== null && _source$id !== void 0 ? _source$id : params.customerId,
|
|
2761
3047
|
customer_id: (_source$customer_id = source.customer_id) !== null && _source$customer_id !== void 0 ? _source$customer_id : params.customerId,
|
|
2762
3048
|
name: String(name || ''),
|
|
2763
3049
|
customer_name: String(customerName || ''),
|
|
2764
|
-
country_calling_code: String((
|
|
3050
|
+
country_calling_code: String((_ref54 = (_source$country_calli = source.country_calling_code) !== null && _source$country_calli !== void 0 ? _source$country_calli : source.countryCallingCode) !== null && _ref54 !== void 0 ? _ref54 : params.countryCallingCode),
|
|
2765
3051
|
phone: String((_source$phone = source.phone) !== null && _source$phone !== void 0 ? _source$phone : params.phone),
|
|
2766
3052
|
email: String((_source$email = source.email) !== null && _source$email !== void 0 ? _source$email : params.email)
|
|
2767
3053
|
});
|
|
@@ -2773,38 +3059,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2773
3059
|
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;
|
|
2774
3060
|
return type === 'good_pass' || type === 'discount_card' || type === 'product_discount_card';
|
|
2775
3061
|
}
|
|
3062
|
+
}, {
|
|
3063
|
+
key: "shouldKeepCustomerBoundDiscountAfterCustomerChange",
|
|
3064
|
+
value: function shouldKeepCustomerBoundDiscountAfterCustomerChange(discount) {
|
|
3065
|
+
return Boolean((discount === null || discount === void 0 ? void 0 : discount.isScan) || (discount === null || discount === void 0 ? void 0 : discount.isEditMode));
|
|
3066
|
+
}
|
|
2776
3067
|
}, {
|
|
2777
3068
|
key: "productHasCustomerBoundDiscount",
|
|
2778
3069
|
value: function productHasCustomerBoundDiscount(product) {
|
|
2779
|
-
var
|
|
3070
|
+
var _this17 = this;
|
|
2780
3071
|
if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
|
|
2781
|
-
return
|
|
3072
|
+
return _this17.isCustomerBoundDiscount(discount);
|
|
2782
3073
|
})) {
|
|
2783
3074
|
return true;
|
|
2784
3075
|
}
|
|
2785
3076
|
return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
|
|
2786
3077
|
return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
|
|
2787
|
-
return
|
|
3078
|
+
return _this17.isCustomerBoundDiscount(discount);
|
|
2788
3079
|
});
|
|
2789
3080
|
});
|
|
2790
3081
|
}
|
|
2791
3082
|
}, {
|
|
2792
3083
|
key: "shouldSkipDiscountCalculation",
|
|
2793
3084
|
value: function shouldSkipDiscountCalculation(tempOrder) {
|
|
2794
|
-
var _this$store$
|
|
2795
|
-
_this$store$
|
|
2796
|
-
|
|
3085
|
+
var _this$store$discount17,
|
|
3086
|
+
_this$store$discount18,
|
|
3087
|
+
_this18 = this;
|
|
2797
3088
|
if (this.hasActiveCustomerBoundDiscount) return false;
|
|
2798
|
-
var discountList = ((_this$store$
|
|
3089
|
+
var discountList = ((_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 || (_this$store$discount18 = _this$store$discount17.getDiscountList) === null || _this$store$discount18 === void 0 ? void 0 : _this$store$discount18.call(_this$store$discount17)) || [];
|
|
2799
3090
|
if (discountList.length > 0) return false;
|
|
2800
3091
|
return !(tempOrder.products || []).some(function (product) {
|
|
2801
|
-
return
|
|
3092
|
+
return _this18.productHasCustomerBoundDiscount(product);
|
|
2802
3093
|
});
|
|
2803
3094
|
}
|
|
2804
3095
|
}, {
|
|
2805
3096
|
key: "clearCustomerBoundDiscounts",
|
|
2806
3097
|
value: function clearCustomerBoundDiscounts(tempOrder) {
|
|
2807
|
-
var
|
|
3098
|
+
var _this19 = this,
|
|
2808
3099
|
_discountModule$getDi,
|
|
2809
3100
|
_discountModule$getOr,
|
|
2810
3101
|
_discountModule$setDi,
|
|
@@ -2813,7 +3104,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2813
3104
|
var filterDiscountList = function filterDiscountList(discountList) {
|
|
2814
3105
|
if (!Array.isArray(discountList)) return [];
|
|
2815
3106
|
return discountList.filter(function (discount) {
|
|
2816
|
-
var shouldRemove =
|
|
3107
|
+
var shouldRemove = _this19.isCustomerBoundDiscount(discount);
|
|
2817
3108
|
if (shouldRemove) didRemoveCustomerBoundDiscount = true;
|
|
2818
3109
|
return !shouldRemove;
|
|
2819
3110
|
});
|
|
@@ -2840,12 +3131,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2840
3131
|
var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
|
|
2841
3132
|
var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
|
|
2842
3133
|
var nextDiscounts = currentDiscounts.filter(function (discount) {
|
|
2843
|
-
if (discount
|
|
2844
|
-
return !
|
|
3134
|
+
if (_this19.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
3135
|
+
return !_this19.isCustomerBoundDiscount(discount);
|
|
2845
3136
|
});
|
|
2846
3137
|
var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
|
|
2847
|
-
if (discount
|
|
2848
|
-
return !
|
|
3138
|
+
if (_this19.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
3139
|
+
return !_this19.isCustomerBoundDiscount(discount);
|
|
2849
3140
|
});
|
|
2850
3141
|
void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
|
|
2851
3142
|
void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
|
|
@@ -2860,14 +3151,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2860
3151
|
}, {
|
|
2861
3152
|
key: "updateTempOrderCustomer",
|
|
2862
3153
|
value: function updateTempOrderCustomer(customer) {
|
|
2863
|
-
var _tempOrder$customer_i2,
|
|
3154
|
+
var _tempOrder$customer_i2, _ref55, _ref56, _customer$customer_id, _ref57, _ref58, _ref59, _customer$customer_na, _ref60, _customer$country_cal, _tempOrder$customer_i3;
|
|
2864
3155
|
var tempOrder = this.ensureTempOrder();
|
|
2865
3156
|
var previousCustomerId = (_tempOrder$customer_i2 = tempOrder.customer_id) !== null && _tempOrder$customer_i2 !== void 0 ? _tempOrder$customer_i2 : null;
|
|
2866
|
-
var customerId = (
|
|
2867
|
-
var customerName = (
|
|
3157
|
+
var customerId = (_ref55 = (_ref56 = (_customer$customer_id = customer.customer_id) !== null && _customer$customer_id !== void 0 ? _customer$customer_id : customer.customerId) !== null && _ref56 !== void 0 ? _ref56 : customer.id) !== null && _ref55 !== void 0 ? _ref55 : null;
|
|
3158
|
+
var customerName = (_ref57 = (_ref58 = (_ref59 = (_customer$customer_na = customer.customer_name) !== null && _customer$customer_na !== void 0 ? _customer$customer_na : customer.customerName) !== null && _ref59 !== void 0 ? _ref59 : customer.display_name) !== null && _ref58 !== void 0 ? _ref58 : customer.name) !== null && _ref57 !== void 0 ? _ref57 : '';
|
|
2868
3159
|
tempOrder.customer_id = customerId === null || customerId === undefined || customerId === '' ? null : Number(customerId);
|
|
2869
3160
|
tempOrder.customer_name = String(customerName || '');
|
|
2870
|
-
tempOrder.country_calling_code = String((
|
|
3161
|
+
tempOrder.country_calling_code = String((_ref60 = (_customer$country_cal = customer.country_calling_code) !== null && _customer$country_cal !== void 0 ? _customer$country_cal : customer.countryCallingCode) !== null && _ref60 !== void 0 ? _ref60 : '');
|
|
2871
3162
|
tempOrder.phone = String(customer.phone || '');
|
|
2872
3163
|
tempOrder.email = String(customer.email || '');
|
|
2873
3164
|
tempOrder.customer = this.buildTempOrderCustomer({
|
|
@@ -2916,8 +3207,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2916
3207
|
}
|
|
2917
3208
|
var nextCustomerId = (_tempOrder$customer_i5 = tempOrder.customer_id) !== null && _tempOrder$customer_i5 !== void 0 ? _tempOrder$customer_i5 : null;
|
|
2918
3209
|
if (String(previousCustomerId !== null && previousCustomerId !== void 0 ? previousCustomerId : '') !== String(nextCustomerId !== null && nextCustomerId !== void 0 ? nextCustomerId : '')) {
|
|
3210
|
+
this.store.availableWalletIds = [];
|
|
2919
3211
|
clearTempOrderHolderAssignments(tempOrder);
|
|
2920
3212
|
this.clearCustomerBoundDiscounts(tempOrder);
|
|
3213
|
+
this.applyDiscount();
|
|
2921
3214
|
}
|
|
2922
3215
|
this.persistTempOrder();
|
|
2923
3216
|
this.saveDraftInBackground();
|
|
@@ -2959,6 +3252,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2959
3252
|
tempOrder.email = '';
|
|
2960
3253
|
tempOrder.customer = null;
|
|
2961
3254
|
if (tempOrder._extend) delete tempOrder._extend.customerSnapshot;
|
|
3255
|
+
this.store.availableWalletIds = [];
|
|
2962
3256
|
this.clearCustomerBoundDiscounts(tempOrder);
|
|
2963
3257
|
this.persistTempOrder();
|
|
2964
3258
|
this.saveDraftInBackground();
|
|
@@ -3012,7 +3306,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3012
3306
|
}, {
|
|
3013
3307
|
key: "addOrderPayment",
|
|
3014
3308
|
value: function addOrderPayment(payment) {
|
|
3015
|
-
var
|
|
3309
|
+
var _this20 = this;
|
|
3016
3310
|
this.logInfo('addOrderPayment', {
|
|
3017
3311
|
payment: payment
|
|
3018
3312
|
});
|
|
@@ -3029,7 +3323,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3029
3323
|
void this.recalculateSummary({
|
|
3030
3324
|
createIfMissing: true
|
|
3031
3325
|
}).catch(function (error) {
|
|
3032
|
-
|
|
3326
|
+
_this20.logError('recalculate summary after addOrderPayment failed', {
|
|
3033
3327
|
error: error instanceof Error ? error.message : String(error)
|
|
3034
3328
|
});
|
|
3035
3329
|
});
|
|
@@ -3084,67 +3378,172 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3084
3378
|
this.persistTempOrder();
|
|
3085
3379
|
return tempOrder.payments;
|
|
3086
3380
|
}
|
|
3087
|
-
|
|
3088
|
-
/**
|
|
3089
|
-
* 覆盖当前订单中的 wallet pass 支付项。
|
|
3090
|
-
*
|
|
3091
|
-
* 判断口径与 PaymentModal 保持一致:voucher_id 存在且不为 0 的支付项
|
|
3092
|
-
* 视为 wallet pass;其它支付项保持不变。
|
|
3093
|
-
*/
|
|
3094
3381
|
}, {
|
|
3095
|
-
key: "
|
|
3096
|
-
value: function
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
};
|
|
3102
|
-
var hasSyncedOrderPayment = function hasSyncedOrderPayment(payment) {
|
|
3103
|
-
return payment.order_payment_id !== undefined && payment.order_payment_id !== null;
|
|
3104
|
-
};
|
|
3105
|
-
// const normalizeVoucherPaymentStatus = (payment: OrderPaymentSource): OrderPaymentSource => {
|
|
3106
|
-
// const paymentRecord = payment as Record<string, any>;
|
|
3107
|
-
// // if (paymentRecord.status !== 'active') return payment;
|
|
3108
|
-
// // return {
|
|
3109
|
-
// // ...paymentRecord,
|
|
3110
|
-
// // status: 'paid',
|
|
3111
|
-
// // };
|
|
3112
|
-
// if (paymentRecord.status === 'active') {
|
|
3113
|
-
// paymentRecord.status = 'paid'
|
|
3114
|
-
// }
|
|
3115
|
-
// return paymentRecord
|
|
3116
|
-
// };
|
|
3117
|
-
var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
|
|
3118
|
-
return _this19.normalizePaymentSource(payment, {
|
|
3119
|
-
defaultPaid: true
|
|
3382
|
+
key: "confirmPendingVoucherPaymentsInList",
|
|
3383
|
+
value: function confirmPendingVoucherPaymentsInList(payments) {
|
|
3384
|
+
return (payments || []).map(function (payment) {
|
|
3385
|
+
if (!isPendingVoucherPaymentRecord(payment)) return payment;
|
|
3386
|
+
return _objectSpread(_objectSpread({}, payment), {}, {
|
|
3387
|
+
status: ORDER_PAYMENT_STATUS_PAID
|
|
3120
3388
|
});
|
|
3121
|
-
})).filter(function (payment) {
|
|
3122
|
-
return isVoucherPayment(payment);
|
|
3123
3389
|
});
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3390
|
+
}
|
|
3391
|
+
}, {
|
|
3392
|
+
key: "discardPendingVoucherPaymentsFromList",
|
|
3393
|
+
value: function discardPendingVoucherPaymentsFromList(payments) {
|
|
3394
|
+
return (payments || []).filter(function (payment) {
|
|
3395
|
+
return !isPendingVoucherPaymentRecord(payment);
|
|
3396
|
+
});
|
|
3397
|
+
}
|
|
3398
|
+
}, {
|
|
3399
|
+
key: "prepareVoucherPaymentsForSubmit",
|
|
3400
|
+
value: function prepareVoucherPaymentsForSubmit(payments) {
|
|
3401
|
+
var confirmPendingVoucherPayments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
3402
|
+
var mappedPayments = mapPaymentItemsToOrderPayments(payments || []);
|
|
3403
|
+
return confirmPendingVoucherPayments ? this.confirmPendingVoucherPaymentsInList(mappedPayments) : this.discardPendingVoucherPaymentsFromList(mappedPayments);
|
|
3404
|
+
}
|
|
3405
|
+
}, {
|
|
3406
|
+
key: "applyPaymentLifecycleChange",
|
|
3407
|
+
value: function applyPaymentLifecycleChange(tempOrder, options) {
|
|
3408
|
+
var _this21 = this;
|
|
3409
|
+
this.updateTempOrderPaymentStatus(tempOrder);
|
|
3410
|
+
if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
|
|
3411
|
+
this.persistTempOrder();
|
|
3412
|
+
}
|
|
3413
|
+
if ((options === null || options === void 0 ? void 0 : options.recalculateSummary) === false) return;
|
|
3414
|
+
var logContext = (options === null || options === void 0 ? void 0 : options.logContext) || 'payment lifecycle change';
|
|
3415
|
+
void this.recalculateSummary({
|
|
3416
|
+
createIfMissing: true
|
|
3417
|
+
}).catch(function (error) {
|
|
3418
|
+
_this21.logError("recalculate summary after ".concat(logContext, " failed"), {
|
|
3419
|
+
error: error instanceof Error ? error.message : String(error)
|
|
3420
|
+
});
|
|
3421
|
+
});
|
|
3422
|
+
}
|
|
3423
|
+
}, {
|
|
3424
|
+
key: "confirmPendingVoucherPayments",
|
|
3425
|
+
value: function confirmPendingVoucherPayments(options) {
|
|
3426
|
+
var tempOrder = this.ensureTempOrder();
|
|
3427
|
+
var payments = tempOrder.payments || [];
|
|
3428
|
+
var hasPendingVoucher = payments.some(function (payment) {
|
|
3429
|
+
return isPendingVoucherPaymentRecord(payment);
|
|
3430
|
+
});
|
|
3431
|
+
if (!hasPendingVoucher) return payments;
|
|
3432
|
+
tempOrder.payments = this.confirmPendingVoucherPaymentsInList(payments);
|
|
3433
|
+
this.applyPaymentLifecycleChange(tempOrder, _objectSpread(_objectSpread({}, options), {}, {
|
|
3434
|
+
logContext: 'confirmPendingVoucherPayments'
|
|
3435
|
+
}));
|
|
3436
|
+
// this.recalculateSummary();
|
|
3437
|
+
return tempOrder.payments;
|
|
3438
|
+
}
|
|
3439
|
+
}, {
|
|
3440
|
+
key: "discardPendingVoucherPayments",
|
|
3441
|
+
value: function discardPendingVoucherPayments(options) {
|
|
3442
|
+
var tempOrder = this.ensureTempOrder();
|
|
3443
|
+
var payments = tempOrder.payments || [];
|
|
3444
|
+
var nextPayments = this.discardPendingVoucherPaymentsFromList(payments);
|
|
3445
|
+
if (nextPayments.length === payments.length) return payments;
|
|
3446
|
+
tempOrder.payments = nextPayments;
|
|
3447
|
+
this.applyPaymentLifecycleChange(tempOrder, _objectSpread(_objectSpread({}, options), {}, {
|
|
3448
|
+
logContext: 'discardPendingVoucherPayments'
|
|
3449
|
+
}));
|
|
3450
|
+
return tempOrder.payments;
|
|
3451
|
+
}
|
|
3452
|
+
|
|
3453
|
+
/**
|
|
3454
|
+
* 覆盖当前订单中的 wallet pass 支付项。
|
|
3455
|
+
*
|
|
3456
|
+
* 判断口径与 PaymentModal 保持一致:voucher_id 存在且不为 0 的支付项
|
|
3457
|
+
* 视为 wallet pass;其它支付项保持不变。
|
|
3458
|
+
*/
|
|
3459
|
+
}, {
|
|
3460
|
+
key: "updateVoucherOrderPayments",
|
|
3461
|
+
value: function updateVoucherOrderPayments(payments, options) {
|
|
3462
|
+
var _this22 = this;
|
|
3463
|
+
var tempOrder = this.ensureTempOrder();
|
|
3464
|
+
var isOrderPaymentType = function isOrderPaymentType(value) {
|
|
3465
|
+
return value === 'normal' || value === 'deposit';
|
|
3466
|
+
};
|
|
3467
|
+
var voucherOrderPaymentType = this.resolveNextOrderPaymentType(tempOrder);
|
|
3468
|
+
var withVoucherPaymentType = function withVoucherPaymentType(payment) {
|
|
3469
|
+
var paymentRecord = payment;
|
|
3470
|
+
if (!isVoucherPaymentRecord(paymentRecord)) return payment;
|
|
3471
|
+
var explicitPaymentType = isOrderPaymentType(paymentRecord.order_payment_type) ? paymentRecord.order_payment_type : isOrderPaymentType(paymentRecord.type) ? paymentRecord.type : undefined;
|
|
3472
|
+
var nextPaymentType = explicitPaymentType || voucherOrderPaymentType;
|
|
3473
|
+
var shouldPreserveCustomPaymentType = paymentRecord.custom_payment_type === undefined && paymentRecord.type !== undefined && !isOrderPaymentType(paymentRecord.type);
|
|
3474
|
+
return _objectSpread(_objectSpread(_objectSpread({}, paymentRecord), shouldPreserveCustomPaymentType ? {
|
|
3475
|
+
custom_payment_type: paymentRecord.type
|
|
3476
|
+
} : {}), {}, {
|
|
3477
|
+
type: nextPaymentType,
|
|
3478
|
+
order_payment_type: nextPaymentType
|
|
3479
|
+
});
|
|
3480
|
+
};
|
|
3481
|
+
var normalizeVoucherPaymentStatus = function normalizeVoucherPaymentStatus(payment) {
|
|
3482
|
+
var paymentRecord = payment;
|
|
3483
|
+
if (!isVoucherPaymentRecord(paymentRecord)) return payment;
|
|
3484
|
+
if (hasSyncedOrderPaymentRecord(paymentRecord) && (paymentRecord.status === undefined || paymentRecord.status === 'active')) {
|
|
3485
|
+
return _objectSpread(_objectSpread({}, paymentRecord), {}, {
|
|
3486
|
+
status: ORDER_PAYMENT_STATUS_PAID
|
|
3487
|
+
});
|
|
3488
|
+
}
|
|
3489
|
+
if (paymentRecord.status !== undefined && paymentRecord.status !== 'active') {
|
|
3490
|
+
return payment;
|
|
3491
|
+
}
|
|
3492
|
+
return _objectSpread(_objectSpread({}, paymentRecord), {}, {
|
|
3493
|
+
status: (options === null || options === void 0 ? void 0 : options.status) || ORDER_PAYMENT_STATUS_PENDING
|
|
3494
|
+
});
|
|
3495
|
+
};
|
|
3496
|
+
var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
|
|
3497
|
+
return _this22.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
|
|
3498
|
+
defaultPaid: false
|
|
3499
|
+
});
|
|
3500
|
+
})).filter(function (payment) {
|
|
3501
|
+
return isVoucherPaymentRecord(payment);
|
|
3502
|
+
});
|
|
3503
|
+
var nonVoucherPayments = (tempOrder.payments || []).filter(function (payment) {
|
|
3504
|
+
return !isVoucherPaymentRecord(payment);
|
|
3505
|
+
});
|
|
3506
|
+
var normalizeCommittedVoucherPayment = function normalizeCommittedVoucherPayment(payment) {
|
|
3507
|
+
if (hasSyncedOrderPaymentRecord(payment) && (payment.status === undefined || payment.status === 'active')) {
|
|
3508
|
+
return _objectSpread(_objectSpread({}, payment), {}, {
|
|
3509
|
+
status: ORDER_PAYMENT_STATUS_PAID
|
|
3510
|
+
});
|
|
3511
|
+
}
|
|
3512
|
+
return payment;
|
|
3513
|
+
};
|
|
3514
|
+
var committedVoucherPayments = (tempOrder.payments || []).filter(function (payment) {
|
|
3515
|
+
return isCommittedVoucherPaymentRecord(payment);
|
|
3516
|
+
}).map(function (payment) {
|
|
3517
|
+
return normalizeCommittedVoucherPayment(payment);
|
|
3518
|
+
});
|
|
3519
|
+
var committedVoucherPaymentIds = new Set(committedVoucherPayments.filter(function (payment) {
|
|
3520
|
+
return hasSyncedOrderPaymentRecord(payment);
|
|
3521
|
+
}).map(function (payment) {
|
|
3522
|
+
return String(payment.order_payment_id);
|
|
3523
|
+
}));
|
|
3524
|
+
var committedVoucherIds = new Set(committedVoucherPayments.map(function (payment) {
|
|
3525
|
+
return String(payment.voucher_id);
|
|
3526
|
+
}));
|
|
3527
|
+
var replaceableVouchers = mappedVouchers.filter(function (payment) {
|
|
3528
|
+
if (hasSyncedOrderPaymentRecord(payment) && committedVoucherPaymentIds.has(String(payment.order_payment_id))) {
|
|
3529
|
+
return false;
|
|
3530
|
+
}
|
|
3531
|
+
if (payment.voucher_id !== undefined && committedVoucherIds.has(String(payment.voucher_id))) {
|
|
3532
|
+
return false;
|
|
3533
|
+
}
|
|
3534
|
+
return true;
|
|
3136
3535
|
});
|
|
3137
3536
|
var cappedVouchers = this.capVoucherPaymentsByRemainingAmount({
|
|
3138
3537
|
vouchers: replaceableVouchers,
|
|
3139
|
-
nonVoucherPayments: [].concat(_toConsumableArray(nonVoucherPayments), _toConsumableArray(
|
|
3538
|
+
nonVoucherPayments: [].concat(_toConsumableArray(nonVoucherPayments), _toConsumableArray(committedVoucherPayments))
|
|
3140
3539
|
});
|
|
3141
|
-
tempOrder.payments = [].concat(_toConsumableArray(nonVoucherPayments), _toConsumableArray(
|
|
3540
|
+
tempOrder.payments = [].concat(_toConsumableArray(nonVoucherPayments), _toConsumableArray(committedVoucherPayments), _toConsumableArray(cappedVouchers));
|
|
3142
3541
|
this.updateTempOrderPaymentStatus(tempOrder);
|
|
3143
3542
|
this.persistTempOrder();
|
|
3144
3543
|
void this.recalculateSummary({
|
|
3145
3544
|
createIfMissing: true
|
|
3146
3545
|
}).catch(function (error) {
|
|
3147
|
-
|
|
3546
|
+
_this22.logError('recalculate summary after updateVoucherOrderPayments failed', {
|
|
3148
3547
|
error: error instanceof Error ? error.message : String(error)
|
|
3149
3548
|
});
|
|
3150
3549
|
});
|
|
@@ -3153,45 +3552,45 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3153
3552
|
}, {
|
|
3154
3553
|
key: "shouldMergeProductToOrder",
|
|
3155
3554
|
value: function () {
|
|
3156
|
-
var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3555
|
+
var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
|
|
3157
3556
|
var _this$orderHooks;
|
|
3158
3557
|
var onBeforeMergeProductToOrder, result;
|
|
3159
|
-
return _regeneratorRuntime().wrap(function
|
|
3160
|
-
while (1) switch (
|
|
3558
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context17) {
|
|
3559
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
3161
3560
|
case 0:
|
|
3162
3561
|
onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
|
|
3163
3562
|
if (onBeforeMergeProductToOrder) {
|
|
3164
|
-
|
|
3563
|
+
_context17.next = 3;
|
|
3165
3564
|
break;
|
|
3166
3565
|
}
|
|
3167
|
-
return
|
|
3566
|
+
return _context17.abrupt("return", true);
|
|
3168
3567
|
case 3:
|
|
3169
|
-
|
|
3568
|
+
_context17.next = 5;
|
|
3170
3569
|
return onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
3171
3570
|
defaultShouldMerge: true
|
|
3172
3571
|
}));
|
|
3173
3572
|
case 5:
|
|
3174
|
-
result =
|
|
3573
|
+
result = _context17.sent;
|
|
3175
3574
|
if (!(typeof result === 'boolean')) {
|
|
3176
|
-
|
|
3575
|
+
_context17.next = 8;
|
|
3177
3576
|
break;
|
|
3178
3577
|
}
|
|
3179
|
-
return
|
|
3578
|
+
return _context17.abrupt("return", result);
|
|
3180
3579
|
case 8:
|
|
3181
3580
|
if (!(result && _typeof(result) === 'object' && typeof result.shouldMerge === 'boolean')) {
|
|
3182
|
-
|
|
3581
|
+
_context17.next = 10;
|
|
3183
3582
|
break;
|
|
3184
3583
|
}
|
|
3185
|
-
return
|
|
3584
|
+
return _context17.abrupt("return", result.shouldMerge);
|
|
3186
3585
|
case 10:
|
|
3187
|
-
return
|
|
3586
|
+
return _context17.abrupt("return", true);
|
|
3188
3587
|
case 11:
|
|
3189
3588
|
case "end":
|
|
3190
|
-
return
|
|
3589
|
+
return _context17.stop();
|
|
3191
3590
|
}
|
|
3192
|
-
},
|
|
3591
|
+
}, _callee15, this);
|
|
3193
3592
|
}));
|
|
3194
|
-
function shouldMergeProductToOrder(
|
|
3593
|
+
function shouldMergeProductToOrder(_x14) {
|
|
3195
3594
|
return _shouldMergeProductToOrder.apply(this, arguments);
|
|
3196
3595
|
}
|
|
3197
3596
|
return shouldMergeProductToOrder;
|
|
@@ -3211,8 +3610,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3211
3610
|
}, {
|
|
3212
3611
|
key: "hasLinkedBookingUid",
|
|
3213
3612
|
value: function hasLinkedBookingUid(product) {
|
|
3214
|
-
var _product$booking_uid, _product$
|
|
3215
|
-
var bookingUid = (_product$booking_uid = product === null || product === void 0 ? void 0 : product.booking_uid) !== null && _product$booking_uid !== void 0 ? _product$booking_uid : product === null || product === void 0 || (_product$
|
|
3613
|
+
var _product$booking_uid, _product$metadata9;
|
|
3614
|
+
var bookingUid = (_product$booking_uid = product === null || product === void 0 ? void 0 : product.booking_uid) !== null && _product$booking_uid !== void 0 ? _product$booking_uid : product === null || product === void 0 || (_product$metadata9 = product.metadata) === null || _product$metadata9 === void 0 ? void 0 : _product$metadata9.booking_uid;
|
|
3216
3615
|
return bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '';
|
|
3217
3616
|
}
|
|
3218
3617
|
|
|
@@ -3227,30 +3626,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3227
3626
|
}, {
|
|
3228
3627
|
key: "finalizeProductOrderMutation",
|
|
3229
3628
|
value: function () {
|
|
3230
|
-
var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3231
|
-
return _regeneratorRuntime().wrap(function
|
|
3232
|
-
while (1) switch (
|
|
3629
|
+
var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(tempOrder, options) {
|
|
3630
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context18) {
|
|
3631
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
3233
3632
|
case 0:
|
|
3234
3633
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
3235
3634
|
if (options !== null && options !== void 0 && options.skipEditDiscountConfigRefresh) {
|
|
3236
|
-
|
|
3635
|
+
_context18.next = 4;
|
|
3237
3636
|
break;
|
|
3238
3637
|
}
|
|
3239
|
-
|
|
3638
|
+
_context18.next = 4;
|
|
3240
3639
|
return this.ensureEditDiscountConfigForProductChange(tempOrder);
|
|
3241
3640
|
case 4:
|
|
3242
3641
|
if (options !== null && options !== void 0 && options.skipDiscountRecalculation) {
|
|
3243
|
-
|
|
3642
|
+
_context18.next = 7;
|
|
3244
3643
|
break;
|
|
3245
3644
|
}
|
|
3246
|
-
|
|
3645
|
+
_context18.next = 7;
|
|
3247
3646
|
return this.applyPromotion();
|
|
3248
3647
|
case 7:
|
|
3249
3648
|
if (!(options !== null && options !== void 0 && options.skipDiscountRecalculation)) {
|
|
3250
3649
|
this.applyDiscount();
|
|
3251
3650
|
}
|
|
3252
3651
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
3253
|
-
|
|
3652
|
+
_context18.next = 11;
|
|
3254
3653
|
return this.recalculateSummary({
|
|
3255
3654
|
createIfMissing: true
|
|
3256
3655
|
});
|
|
@@ -3258,11 +3657,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3258
3657
|
this.persistTempOrder();
|
|
3259
3658
|
case 12:
|
|
3260
3659
|
case "end":
|
|
3261
|
-
return
|
|
3660
|
+
return _context18.stop();
|
|
3262
3661
|
}
|
|
3263
|
-
},
|
|
3662
|
+
}, _callee16, this);
|
|
3264
3663
|
}));
|
|
3265
|
-
function finalizeProductOrderMutation(
|
|
3664
|
+
function finalizeProductOrderMutation(_x15, _x16) {
|
|
3266
3665
|
return _finalizeProductOrderMutation.apply(this, arguments);
|
|
3267
3666
|
}
|
|
3268
3667
|
return finalizeProductOrderMutation;
|
|
@@ -3277,13 +3676,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3277
3676
|
}, {
|
|
3278
3677
|
key: "appendProductLineToTempOrder",
|
|
3279
3678
|
value: (function () {
|
|
3280
|
-
var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3679
|
+
var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(tempOrder, product, booking) {
|
|
3281
3680
|
var _booking_uid,
|
|
3282
3681
|
_metadata,
|
|
3283
|
-
|
|
3682
|
+
_this23 = this;
|
|
3284
3683
|
var linked, productToAdd, incomingFingerprint, normalizedIncoming, incomingBookingUid, hasIncomingGoodPass, hasIncomingProductNote, hasIncomingBookingUid, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList;
|
|
3285
|
-
return _regeneratorRuntime().wrap(function
|
|
3286
|
-
while (1) switch (
|
|
3684
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context19) {
|
|
3685
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
3287
3686
|
case 0:
|
|
3288
3687
|
linked = booking ? this.createLinkedProductAndBooking({
|
|
3289
3688
|
product: product,
|
|
@@ -3305,9 +3704,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3305
3704
|
hasIncomingBookingUid = this.hasLinkedBookingUid(productToAdd) || this.hasLinkedBookingUid(normalizedIncoming);
|
|
3306
3705
|
shouldForceNewLine = !!booking || hasIncomingProductNote || hasIncomingBookingUid;
|
|
3307
3706
|
matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
3308
|
-
|
|
3309
|
-
if (
|
|
3707
|
+
var _item$metadata3;
|
|
3708
|
+
if (_this23.hasGoodPassDiscount(item)) return false;
|
|
3709
|
+
if (_this23.hasOrderProductLineNote(item)) return false;
|
|
3310
3710
|
if (item.order_detail_id !== undefined && item.order_detail_id !== null) return false;
|
|
3711
|
+
if ((_item$metadata3 = item.metadata) !== null && _item$metadata3 !== void 0 && _item$metadata3.is_edit_for_runtime) return false;
|
|
3311
3712
|
if (item.product_id !== productToAdd.product_id) return false;
|
|
3312
3713
|
if (item.product_variant_id !== productToAdd.product_variant_id) return false;
|
|
3313
3714
|
var existedFingerprint = buildProductLineFingerprint(getProductSkuOptions(item), item.product_bundle);
|
|
@@ -3316,10 +3717,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3316
3717
|
matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
|
|
3317
3718
|
existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
|
|
3318
3719
|
if (!matchedProduct) {
|
|
3319
|
-
|
|
3720
|
+
_context19.next = 20;
|
|
3320
3721
|
break;
|
|
3321
3722
|
}
|
|
3322
|
-
|
|
3723
|
+
_context19.next = 17;
|
|
3323
3724
|
return this.shouldMergeProductToOrder({
|
|
3324
3725
|
incomingProduct: productToAdd,
|
|
3325
3726
|
normalizedIncoming: normalizedIncoming,
|
|
@@ -3331,13 +3732,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3331
3732
|
booking: booking
|
|
3332
3733
|
});
|
|
3333
3734
|
case 17:
|
|
3334
|
-
|
|
3335
|
-
|
|
3735
|
+
_context19.t0 = _context19.sent;
|
|
3736
|
+
_context19.next = 21;
|
|
3336
3737
|
break;
|
|
3337
3738
|
case 20:
|
|
3338
|
-
|
|
3739
|
+
_context19.t0 = false;
|
|
3339
3740
|
case 21:
|
|
3340
|
-
shouldMerge =
|
|
3741
|
+
shouldMerge = _context19.t0;
|
|
3341
3742
|
if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
|
|
3342
3743
|
this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
|
|
3343
3744
|
if (linked) {
|
|
@@ -3391,11 +3792,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3391
3792
|
}
|
|
3392
3793
|
case 24:
|
|
3393
3794
|
case "end":
|
|
3394
|
-
return
|
|
3795
|
+
return _context19.stop();
|
|
3395
3796
|
}
|
|
3396
|
-
},
|
|
3797
|
+
}, _callee17, this);
|
|
3397
3798
|
}));
|
|
3398
|
-
function appendProductLineToTempOrder(
|
|
3799
|
+
function appendProductLineToTempOrder(_x17, _x18, _x19) {
|
|
3399
3800
|
return _appendProductLineToTempOrder.apply(this, arguments);
|
|
3400
3801
|
}
|
|
3401
3802
|
return appendProductLineToTempOrder;
|
|
@@ -3411,58 +3812,61 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3411
3812
|
}, {
|
|
3412
3813
|
key: "addProductToOrder",
|
|
3413
3814
|
value: (function () {
|
|
3414
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3415
|
-
var tempOrder,
|
|
3416
|
-
return _regeneratorRuntime().wrap(function
|
|
3417
|
-
while (1) switch (
|
|
3815
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(product, booking) {
|
|
3816
|
+
var tempOrder, _ref61, _productRecord$num, productRecord, splitCount, i, singleLine;
|
|
3817
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context20) {
|
|
3818
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
3418
3819
|
case 0:
|
|
3419
3820
|
tempOrder = this.ensureTempOrder();
|
|
3420
|
-
debugger;
|
|
3421
3821
|
if (!booking) {
|
|
3422
|
-
|
|
3822
|
+
_context20.next = 18;
|
|
3423
3823
|
break;
|
|
3424
3824
|
}
|
|
3425
3825
|
productRecord = product;
|
|
3426
|
-
splitCount = getSafeProductNum((
|
|
3826
|
+
splitCount = getSafeProductNum((_ref61 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref61 !== void 0 ? _ref61 : 1);
|
|
3427
3827
|
if (!(splitCount > 1)) {
|
|
3428
|
-
|
|
3828
|
+
_context20.next = 18;
|
|
3429
3829
|
break;
|
|
3430
3830
|
}
|
|
3431
3831
|
i = 0;
|
|
3432
|
-
case
|
|
3832
|
+
case 6:
|
|
3433
3833
|
if (!(i < splitCount)) {
|
|
3434
|
-
|
|
3834
|
+
_context20.next = 15;
|
|
3435
3835
|
break;
|
|
3436
3836
|
}
|
|
3437
3837
|
singleLine = cloneDeep(productRecord);
|
|
3438
3838
|
singleLine.num = 1;
|
|
3439
3839
|
delete singleLine.product_quantity;
|
|
3440
|
-
|
|
3840
|
+
_context20.next = 12;
|
|
3441
3841
|
return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
|
|
3442
|
-
case
|
|
3842
|
+
case 12:
|
|
3443
3843
|
i += 1;
|
|
3444
|
-
|
|
3844
|
+
_context20.next = 6;
|
|
3445
3845
|
break;
|
|
3446
|
-
case
|
|
3447
|
-
|
|
3846
|
+
case 15:
|
|
3847
|
+
_context20.next = 17;
|
|
3448
3848
|
return this.finalizeProductOrderMutation(tempOrder);
|
|
3849
|
+
case 17:
|
|
3850
|
+
return _context20.abrupt("return", tempOrder.products);
|
|
3449
3851
|
case 18:
|
|
3450
|
-
|
|
3451
|
-
case 19:
|
|
3452
|
-
_context19.next = 21;
|
|
3852
|
+
_context20.next = 20;
|
|
3453
3853
|
return this.appendProductLineToTempOrder(tempOrder, product, booking);
|
|
3454
|
-
case
|
|
3455
|
-
|
|
3854
|
+
case 20:
|
|
3855
|
+
_context20.next = 22;
|
|
3456
3856
|
return this.finalizeProductOrderMutation(tempOrder);
|
|
3457
|
-
case
|
|
3458
|
-
|
|
3857
|
+
case 22:
|
|
3858
|
+
this.logInfo('addProductToOrder success', {
|
|
3859
|
+
product_id: product.product_id,
|
|
3860
|
+
with_booking: !!booking
|
|
3861
|
+
});
|
|
3862
|
+
return _context20.abrupt("return", tempOrder.products);
|
|
3459
3863
|
case 24:
|
|
3460
3864
|
case "end":
|
|
3461
|
-
return
|
|
3865
|
+
return _context20.stop();
|
|
3462
3866
|
}
|
|
3463
|
-
},
|
|
3867
|
+
}, _callee18, this);
|
|
3464
3868
|
}));
|
|
3465
|
-
function addProductToOrder(
|
|
3869
|
+
function addProductToOrder(_x20, _x21) {
|
|
3466
3870
|
return _addProductToOrder.apply(this, arguments);
|
|
3467
3871
|
}
|
|
3468
3872
|
return addProductToOrder;
|
|
@@ -3480,90 +3884,93 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3480
3884
|
}, {
|
|
3481
3885
|
key: "addProductsToOrder",
|
|
3482
3886
|
value: (function () {
|
|
3483
|
-
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3484
|
-
var tempOrder, _iterator20, _step20, item, product, booking,
|
|
3485
|
-
return _regeneratorRuntime().wrap(function
|
|
3486
|
-
while (1) switch (
|
|
3887
|
+
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(items, options) {
|
|
3888
|
+
var tempOrder, _iterator20, _step20, item, product, booking, _ref62, _productRecord$num2, productRecord, splitCount, i, singleLine;
|
|
3889
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context21) {
|
|
3890
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
3487
3891
|
case 0:
|
|
3488
3892
|
tempOrder = this.ensureTempOrder();
|
|
3489
3893
|
if (!(!Array.isArray(items) || items.length === 0)) {
|
|
3490
|
-
|
|
3894
|
+
_context21.next = 3;
|
|
3491
3895
|
break;
|
|
3492
3896
|
}
|
|
3493
|
-
return
|
|
3897
|
+
return _context21.abrupt("return", tempOrder.products);
|
|
3494
3898
|
case 3:
|
|
3495
3899
|
_iterator20 = _createForOfIteratorHelper(items || []);
|
|
3496
|
-
|
|
3900
|
+
_context21.prev = 4;
|
|
3497
3901
|
_iterator20.s();
|
|
3498
3902
|
case 6:
|
|
3499
3903
|
if ((_step20 = _iterator20.n()).done) {
|
|
3500
|
-
|
|
3904
|
+
_context21.next = 30;
|
|
3501
3905
|
break;
|
|
3502
3906
|
}
|
|
3503
3907
|
item = _step20.value;
|
|
3504
3908
|
product = item.product, booking = item.booking;
|
|
3505
3909
|
if (product) {
|
|
3506
|
-
|
|
3910
|
+
_context21.next = 11;
|
|
3507
3911
|
break;
|
|
3508
3912
|
}
|
|
3509
|
-
return
|
|
3913
|
+
return _context21.abrupt("continue", 28);
|
|
3510
3914
|
case 11:
|
|
3511
3915
|
if (!booking) {
|
|
3512
|
-
|
|
3916
|
+
_context21.next = 26;
|
|
3513
3917
|
break;
|
|
3514
3918
|
}
|
|
3515
3919
|
productRecord = product;
|
|
3516
|
-
splitCount = getSafeProductNum((
|
|
3920
|
+
splitCount = getSafeProductNum((_ref62 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref62 !== void 0 ? _ref62 : 1);
|
|
3517
3921
|
if (!(splitCount > 1)) {
|
|
3518
|
-
|
|
3922
|
+
_context21.next = 26;
|
|
3519
3923
|
break;
|
|
3520
3924
|
}
|
|
3521
3925
|
i = 0;
|
|
3522
3926
|
case 16:
|
|
3523
3927
|
if (!(i < splitCount)) {
|
|
3524
|
-
|
|
3928
|
+
_context21.next = 25;
|
|
3525
3929
|
break;
|
|
3526
3930
|
}
|
|
3527
3931
|
singleLine = cloneDeep(productRecord);
|
|
3528
3932
|
singleLine.num = 1;
|
|
3529
3933
|
delete singleLine.product_quantity;
|
|
3530
|
-
|
|
3934
|
+
_context21.next = 22;
|
|
3531
3935
|
return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
|
|
3532
3936
|
case 22:
|
|
3533
3937
|
i += 1;
|
|
3534
|
-
|
|
3938
|
+
_context21.next = 16;
|
|
3535
3939
|
break;
|
|
3536
3940
|
case 25:
|
|
3537
|
-
return
|
|
3941
|
+
return _context21.abrupt("continue", 28);
|
|
3538
3942
|
case 26:
|
|
3539
|
-
|
|
3943
|
+
_context21.next = 28;
|
|
3540
3944
|
return this.appendProductLineToTempOrder(tempOrder, product, booking);
|
|
3541
3945
|
case 28:
|
|
3542
|
-
|
|
3946
|
+
_context21.next = 6;
|
|
3543
3947
|
break;
|
|
3544
3948
|
case 30:
|
|
3545
|
-
|
|
3949
|
+
_context21.next = 35;
|
|
3546
3950
|
break;
|
|
3547
3951
|
case 32:
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
_iterator20.e(
|
|
3952
|
+
_context21.prev = 32;
|
|
3953
|
+
_context21.t0 = _context21["catch"](4);
|
|
3954
|
+
_iterator20.e(_context21.t0);
|
|
3551
3955
|
case 35:
|
|
3552
|
-
|
|
3956
|
+
_context21.prev = 35;
|
|
3553
3957
|
_iterator20.f();
|
|
3554
|
-
return
|
|
3958
|
+
return _context21.finish(35);
|
|
3555
3959
|
case 38:
|
|
3556
|
-
|
|
3960
|
+
_context21.next = 40;
|
|
3557
3961
|
return this.finalizeProductOrderMutation(tempOrder, options);
|
|
3558
3962
|
case 40:
|
|
3559
|
-
|
|
3560
|
-
|
|
3963
|
+
this.logInfo('addProductsToOrder success', {
|
|
3964
|
+
itemsCount: items.length
|
|
3965
|
+
});
|
|
3966
|
+
return _context21.abrupt("return", tempOrder.products);
|
|
3967
|
+
case 42:
|
|
3561
3968
|
case "end":
|
|
3562
|
-
return
|
|
3969
|
+
return _context21.stop();
|
|
3563
3970
|
}
|
|
3564
|
-
},
|
|
3971
|
+
}, _callee19, this, [[4, 32, 35, 38]]);
|
|
3565
3972
|
}));
|
|
3566
|
-
function addProductsToOrder(
|
|
3973
|
+
function addProductsToOrder(_x22, _x23) {
|
|
3567
3974
|
return _addProductsToOrder.apply(this, arguments);
|
|
3568
3975
|
}
|
|
3569
3976
|
return addProductsToOrder;
|
|
@@ -3590,26 +3997,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3590
3997
|
}, {
|
|
3591
3998
|
key: "getBundleRuntimeIdentity",
|
|
3592
3999
|
value: function getBundleRuntimeIdentity(bundle) {
|
|
3593
|
-
var
|
|
4000
|
+
var _ref63, _bundle$bundle_id2, _ref64, _bundle$bundle_group_2, _ref65, _ref66, _bundle$bundle_produc3, _ref67, _bundle$bundle_varian3;
|
|
3594
4001
|
if (!bundle || _typeof(bundle) !== 'object') return '';
|
|
3595
|
-
return [(
|
|
4002
|
+
return [(_ref63 = (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id) !== null && _ref63 !== void 0 ? _ref63 : '', (_ref64 = (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id) !== null && _ref64 !== void 0 ? _ref64 : '', (_ref65 = (_ref66 = (_bundle$bundle_produc3 = bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle._bundle_product_id) !== null && _ref66 !== void 0 ? _ref66 : bundle.product_id) !== null && _ref65 !== void 0 ? _ref65 : '', (_ref67 = (_bundle$bundle_varian3 = bundle.bundle_variant_id) !== null && _bundle$bundle_varian3 !== void 0 ? _bundle$bundle_varian3 : bundle.product_variant_id) !== null && _ref67 !== void 0 ? _ref67 : 0].join('|');
|
|
3596
4003
|
}
|
|
3597
4004
|
}, {
|
|
3598
4005
|
key: "preservePersistedBundlePriceFields",
|
|
3599
4006
|
value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
|
|
3600
|
-
var
|
|
4007
|
+
var _this24 = this;
|
|
3601
4008
|
if (!Array.isArray(nextBundles)) return nextBundles;
|
|
3602
4009
|
if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
|
|
3603
4010
|
var previousByIdentity = new Map();
|
|
3604
4011
|
previousBundles.forEach(function (bundle) {
|
|
3605
|
-
var identity =
|
|
4012
|
+
var identity = _this24.getBundleRuntimeIdentity(bundle);
|
|
3606
4013
|
if (identity) previousByIdentity.set(identity, bundle);
|
|
3607
4014
|
});
|
|
3608
4015
|
return nextBundles.map(function (bundle, index) {
|
|
3609
4016
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
3610
|
-
var previous = previousByIdentity.get(
|
|
4017
|
+
var previous = previousByIdentity.get(_this24.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
|
|
3611
4018
|
if (!previous || _typeof(previous) !== 'object') return bundle;
|
|
3612
|
-
return _objectSpread(_objectSpread({}, bundle),
|
|
4019
|
+
return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
|
|
4020
|
+
cover: previous.cover
|
|
4021
|
+
} : {}), {}, {
|
|
3613
4022
|
price: previous.price,
|
|
3614
4023
|
custom_price: previous.custom_price,
|
|
3615
4024
|
bundle_payment_price: previous.bundle_payment_price,
|
|
@@ -3622,7 +4031,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3622
4031
|
}, {
|
|
3623
4032
|
key: "applyOrderProductUpdateToTempOrder",
|
|
3624
4033
|
value: function applyOrderProductUpdateToTempOrder(tempOrder, params) {
|
|
3625
|
-
var _targetProduct$metada2, _product_sku, _metadata2, _metadata3, _metadata4, _metadata5, _metadata6, _metadata7, _nextProduct$metadata, _targetProduct$
|
|
4034
|
+
var _targetProduct$metada2, _product_sku, _metadata2, _metadata3, _metadata4, _metadata5, _metadata6, _metadata7, _metadata8, _metadata9, _metadata10, _nextProduct$metadata, _targetProduct$metada15, _tempOrder$products$p, _tempOrder$products$p2;
|
|
3626
4035
|
var product_id = params.product_id,
|
|
3627
4036
|
product_variant_id = params.product_variant_id,
|
|
3628
4037
|
updates = params.updates,
|
|
@@ -3650,8 +4059,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3650
4059
|
if (unique_identification_number !== undefined) {
|
|
3651
4060
|
var targetUid = String(unique_identification_number);
|
|
3652
4061
|
productIndex = tempOrder.products.findIndex(function (item) {
|
|
3653
|
-
var _item$
|
|
3654
|
-
return String(((_item$
|
|
4062
|
+
var _item$metadata4;
|
|
4063
|
+
return String(((_item$metadata4 = item.metadata) === null || _item$metadata4 === void 0 ? void 0 : _item$metadata4.unique_identification_number) || item.unique_identification_number || '') === targetUid;
|
|
3655
4064
|
});
|
|
3656
4065
|
}
|
|
3657
4066
|
if (productIndex === -1) {
|
|
@@ -3682,9 +4091,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3682
4091
|
// 如果 caller 走推荐路径(updates.metadata.* 显式指定主价),保留 metadata 由 normalize 认它。
|
|
3683
4092
|
var callerUpdatesTopPrice = Object.prototype.hasOwnProperty.call(updates || {}, 'selling_price') || Object.prototype.hasOwnProperty.call(updates || {}, 'original_price');
|
|
3684
4093
|
var callerUpdatesMainMeta = (updates === null || updates === void 0 || (_metadata2 = updates.metadata) === null || _metadata2 === void 0 ? void 0 : _metadata2.main_product_selling_price) !== undefined || (updates === null || updates === void 0 || (_metadata3 = updates.metadata) === null || _metadata3 === void 0 ? void 0 : _metadata3.main_product_original_price) !== undefined || (updates === null || updates === void 0 || (_metadata4 = updates.metadata) === null || _metadata4 === void 0 ? void 0 : _metadata4.source_product_price) !== undefined;
|
|
4094
|
+
var callerUpdatesSourcePrice = (updates === null || updates === void 0 || (_metadata5 = updates.metadata) === null || _metadata5 === void 0 ? void 0 : _metadata5.source_product_price) !== undefined;
|
|
4095
|
+
var callerUpdatesMainSellingPrice = (updates === null || updates === void 0 || (_metadata6 = updates.metadata) === null || _metadata6 === void 0 ? void 0 : _metadata6.main_product_selling_price) !== undefined;
|
|
4096
|
+
var callerUpdatesMainOriginalPrice = (updates === null || updates === void 0 || (_metadata7 = updates.metadata) === null || _metadata7 === void 0 ? void 0 : _metadata7.main_product_original_price) !== undefined;
|
|
4097
|
+
var previousLineFingerprint = buildProductLineFingerprint(getProductSkuOptions(targetProduct), targetProduct.product_bundle);
|
|
4098
|
+
var nextLineFingerprint = buildProductLineFingerprint(getProductSkuOptions(nextProduct), nextProduct.product_bundle);
|
|
4099
|
+
var callerChangesVariant = Number(product_variant_id || 0) !== Number(targetProduct.product_variant_id || 0);
|
|
4100
|
+
var callerChangesLineConfiguration = callerChangesVariant || previousLineFingerprint !== nextLineFingerprint;
|
|
3685
4101
|
var isPersistedOrderLine = targetProduct.order_detail_id !== undefined && targetProduct.order_detail_id !== null;
|
|
3686
4102
|
var callerChangesDiscountList = Array.isArray(updates === null || updates === void 0 ? void 0 : updates.discount_list) && updates.discount_list.length > 0 && !isSameDiscountList(updates.discount_list, targetProduct.discount_list);
|
|
3687
|
-
var callerUpdatesManualPrice = (updates === null || updates === void 0 || (
|
|
4103
|
+
var callerUpdatesManualPrice = (updates === null || updates === void 0 || (_metadata8 = updates.metadata) === null || _metadata8 === void 0 ? void 0 : _metadata8.price_override) !== undefined || (updates === null || updates === void 0 || (_metadata9 = updates.metadata) === null || _metadata9 === void 0 ? void 0 : _metadata9.is_manual_discount) !== undefined || (updates === null || updates === void 0 || (_metadata10 = updates.metadata) === null || _metadata10 === void 0 ? void 0 : _metadata10.product_discount_reason) !== undefined || callerChangesDiscountList;
|
|
3688
4104
|
var callerAllowsBookingReprice = function () {
|
|
3689
4105
|
if (params.allow_booking_reprice !== true || !booking || !callerUpdatesTopPrice || !callerUpdatesMainMeta) {
|
|
3690
4106
|
return false;
|
|
@@ -3697,7 +4113,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3697
4113
|
};
|
|
3698
4114
|
return hasChangedPrice(updates.selling_price, targetProduct.selling_price) || hasChangedPrice(updates.original_price, targetProduct.original_price);
|
|
3699
4115
|
}();
|
|
3700
|
-
if (isPersistedOrderLine && !callerUpdatesManualPrice && !callerAllowsBookingReprice) {
|
|
4116
|
+
if (isPersistedOrderLine && !callerChangesLineConfiguration && !callerUpdatesManualPrice && !callerAllowsBookingReprice) {
|
|
3701
4117
|
var _targetProduct$metada3, _targetProduct$metada4, _targetProduct$metada5, _targetProduct$metada6, _targetProduct$metada7;
|
|
3702
4118
|
nextProduct.selling_price = targetProduct.selling_price;
|
|
3703
4119
|
nextProduct.original_price = targetProduct.original_price;
|
|
@@ -3709,19 +4125,60 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3709
4125
|
price_schema_version: (_targetProduct$metada6 = (_targetProduct$metada7 = targetProduct.metadata) === null || _targetProduct$metada7 === void 0 ? void 0 : _targetProduct$metada7.price_schema_version) !== null && _targetProduct$metada6 !== void 0 ? _targetProduct$metada6 : 2
|
|
3710
4126
|
});
|
|
3711
4127
|
nextProduct.product_bundle = this.preservePersistedBundlePriceFields(targetProduct.product_bundle, nextProduct.product_bundle);
|
|
3712
|
-
} else if (
|
|
4128
|
+
} else if (callerChangesLineConfiguration && callerUpdatesSourcePrice && (!callerUpdatesMainSellingPrice || !callerUpdatesMainOriginalPrice)) {
|
|
4129
|
+
var _targetProduct$metada8, _targetProduct$metada9;
|
|
4130
|
+
// 新配置只传了 source 时,不能把未传的 main_product_* 从旧行继承下来。
|
|
4131
|
+
// 以新 source + 新 option 重建券前价;券后价未显式提供时保留旧主商品折扣额。
|
|
4132
|
+
var previousMainOriginal = new Decimal(Number((_targetProduct$metada8 = targetProduct.metadata) === null || _targetProduct$metada8 === void 0 ? void 0 : _targetProduct$metada8.main_product_original_price) || 0);
|
|
4133
|
+
var previousMainSelling = new Decimal(Number((_targetProduct$metada9 = targetProduct.metadata) === null || _targetProduct$metada9 === void 0 ? void 0 : _targetProduct$metada9.main_product_selling_price) || previousMainOriginal.toNumber());
|
|
4134
|
+
var preservedDiscount = previousMainOriginal.minus(previousMainSelling);
|
|
4135
|
+
var nextMainOriginal = new Decimal(Number(updates.metadata.source_product_price) || 0).plus(sumOptionUnitPrice(getProductSkuOptions(nextProduct)));
|
|
4136
|
+
nextProduct.metadata = _objectSpread(_objectSpread({}, nextProduct.metadata || {}), {}, {
|
|
4137
|
+
source_product_price: String(updates.metadata.source_product_price),
|
|
4138
|
+
main_product_original_price: callerUpdatesMainOriginalPrice ? String(updates.metadata.main_product_original_price) : nextMainOriginal.toDecimalPlaces(2).toFixed(2),
|
|
4139
|
+
main_product_selling_price: callerUpdatesMainSellingPrice ? String(updates.metadata.main_product_selling_price) : nextMainOriginal.minus(preservedDiscount).toDecimalPlaces(2).toFixed(2),
|
|
4140
|
+
price_schema_version: 2
|
|
4141
|
+
});
|
|
4142
|
+
} else if (callerChangesVariant && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
4143
|
+
// variant 已变化但 caller 没有显式报价时,旧 v2 metadata 不能继续充当权威价格源。
|
|
4144
|
+
// 清理后由 normalize 优先读取 metadata.origin.variant 中新 variant 的目录价;
|
|
4145
|
+
// 顶层 original/selling 的旧差额仍会作为 legacy discount 迁移到新价格。
|
|
3713
4146
|
var existedMeta = nextProduct.metadata || {};
|
|
3714
4147
|
nextProduct.metadata = _objectSpread({}, existedMeta);
|
|
3715
4148
|
delete nextProduct.metadata.source_product_price;
|
|
3716
4149
|
delete nextProduct.metadata.main_product_selling_price;
|
|
3717
4150
|
delete nextProduct.metadata.main_product_original_price;
|
|
3718
4151
|
delete nextProduct.metadata.price_schema_version;
|
|
4152
|
+
} else if (callerChangesLineConfiguration && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
4153
|
+
var _ref68, _targetProduct$metada10, _targetProduct$metada11, _ref69, _targetProduct$metada12, _targetProduct$metada13, _targetProduct$metada14;
|
|
4154
|
+
// 仅 option / bundle 变化时,保留历史 source 和主商品折扣金额,
|
|
4155
|
+
// 但必须让 original 与 selling 一起随新的 option 金额移动。
|
|
4156
|
+
var previousOptionSum = sumOptionUnitPrice(getProductSkuOptions(targetProduct));
|
|
4157
|
+
var nextOptionSum = sumOptionUnitPrice(getProductSkuOptions(nextProduct));
|
|
4158
|
+
var _previousMainOriginal = new Decimal(Number((_ref68 = (_targetProduct$metada10 = (_targetProduct$metada11 = targetProduct.metadata) === null || _targetProduct$metada11 === void 0 ? void 0 : _targetProduct$metada11.main_product_original_price) !== null && _targetProduct$metada10 !== void 0 ? _targetProduct$metada10 : targetProduct.original_price) !== null && _ref68 !== void 0 ? _ref68 : 0) || 0);
|
|
4159
|
+
var _previousMainSelling = new Decimal(Number((_ref69 = (_targetProduct$metada12 = (_targetProduct$metada13 = targetProduct.metadata) === null || _targetProduct$metada13 === void 0 ? void 0 : _targetProduct$metada13.main_product_selling_price) !== null && _targetProduct$metada12 !== void 0 ? _targetProduct$metada12 : targetProduct.selling_price) !== null && _ref69 !== void 0 ? _ref69 : _previousMainOriginal.toNumber()) || 0);
|
|
4160
|
+
var _preservedDiscount = _previousMainOriginal.minus(_previousMainSelling);
|
|
4161
|
+
var previousSource = ((_targetProduct$metada14 = targetProduct.metadata) === null || _targetProduct$metada14 === void 0 ? void 0 : _targetProduct$metada14.source_product_price) != null ? new Decimal(Number(targetProduct.metadata.source_product_price) || 0) : _previousMainOriginal.minus(previousOptionSum);
|
|
4162
|
+
var _nextMainOriginal = previousSource.plus(nextOptionSum);
|
|
4163
|
+
nextProduct.metadata = _objectSpread(_objectSpread({}, nextProduct.metadata || {}), {}, {
|
|
4164
|
+
source_product_price: previousSource.toDecimalPlaces(2).toFixed(2),
|
|
4165
|
+
main_product_original_price: _nextMainOriginal.toDecimalPlaces(2).toFixed(2),
|
|
4166
|
+
main_product_selling_price: _nextMainOriginal.minus(_preservedDiscount).toDecimalPlaces(2).toFixed(2),
|
|
4167
|
+
price_schema_version: 2
|
|
4168
|
+
});
|
|
4169
|
+
} else if (callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
4170
|
+
var _existedMeta = nextProduct.metadata || {};
|
|
4171
|
+
nextProduct.metadata = _objectSpread({}, _existedMeta);
|
|
4172
|
+
delete nextProduct.metadata.source_product_price;
|
|
4173
|
+
delete nextProduct.metadata.main_product_selling_price;
|
|
4174
|
+
delete nextProduct.metadata.main_product_original_price;
|
|
4175
|
+
delete nextProduct.metadata.price_schema_version;
|
|
3719
4176
|
}
|
|
3720
4177
|
// normalizeOrderProduct 幂等:v2 metadata 存在 → 保留 main_product_* 折扣重算 composite;
|
|
3721
4178
|
// 否则 → 把顶层 selling_price 视作 source,派生 main_product_* 并写 price_schema_version: 2。
|
|
3722
4179
|
var normalizedProduct = mergeOrderProductDisplayFields(nextProduct, normalizeOrderProduct(nextProduct));
|
|
3723
4180
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
3724
|
-
var preservedBookingUid = nextProduct.booking_uid || ((_nextProduct$metadata = nextProduct.metadata) === null || _nextProduct$metadata === void 0 ? void 0 : _nextProduct$metadata.booking_uid) || targetProduct.booking_uid || ((_targetProduct$
|
|
4181
|
+
var preservedBookingUid = nextProduct.booking_uid || ((_nextProduct$metadata = nextProduct.metadata) === null || _nextProduct$metadata === void 0 ? void 0 : _nextProduct$metadata.booking_uid) || targetProduct.booking_uid || ((_targetProduct$metada15 = targetProduct.metadata) === null || _targetProduct$metada15 === void 0 ? void 0 : _targetProduct$metada15.booking_uid);
|
|
3725
4182
|
if (!booking && preservedBookingUid) {
|
|
3726
4183
|
normalizedProduct.booking_uid = preservedBookingUid;
|
|
3727
4184
|
normalizedProduct.metadata = _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
|
|
@@ -3729,8 +4186,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3729
4186
|
});
|
|
3730
4187
|
}
|
|
3731
4188
|
if (booking) {
|
|
3732
|
-
var _normalizedProduct$me, _targetProduct$
|
|
3733
|
-
var productUid = String(((_normalizedProduct$me = normalizedProduct.metadata) === null || _normalizedProduct$me === void 0 ? void 0 : _normalizedProduct$me.unique_identification_number) || ((_targetProduct$
|
|
4189
|
+
var _normalizedProduct$me, _targetProduct$metada16;
|
|
4190
|
+
var productUid = String(((_normalizedProduct$me = normalizedProduct.metadata) === null || _normalizedProduct$me === void 0 ? void 0 : _normalizedProduct$me.unique_identification_number) || ((_targetProduct$metada16 = targetProduct.metadata) === null || _targetProduct$metada16 === void 0 ? void 0 : _targetProduct$metada16.unique_identification_number) || unique_identification_number || createUuidV4());
|
|
3734
4191
|
normalizedProduct.metadata = _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
|
|
3735
4192
|
unique_identification_number: productUid
|
|
3736
4193
|
});
|
|
@@ -3753,36 +4210,42 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3753
4210
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
3754
4211
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
3755
4212
|
this.captureProductRuntime(tempOrder, updates, tempOrder.products[productIndex], (_tempOrder$products$p = tempOrder.products[productIndex].metadata) === null || _tempOrder$products$p === void 0 ? void 0 : _tempOrder$products$p.unique_identification_number);
|
|
4213
|
+
return (_tempOrder$products$p2 = tempOrder.products[productIndex].metadata) === null || _tempOrder$products$p2 === void 0 ? void 0 : _tempOrder$products$p2.unique_identification_number;
|
|
3756
4214
|
}
|
|
3757
4215
|
}, {
|
|
3758
4216
|
key: "updateOrderProduct",
|
|
3759
4217
|
value: function () {
|
|
3760
|
-
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3761
|
-
var tempOrder;
|
|
3762
|
-
return _regeneratorRuntime().wrap(function
|
|
3763
|
-
while (1) switch (
|
|
4218
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
|
|
4219
|
+
var tempOrder, updatedProductUid;
|
|
4220
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context22) {
|
|
4221
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
3764
4222
|
case 0:
|
|
3765
4223
|
tempOrder = this.ensureTempOrder();
|
|
3766
|
-
this.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
3767
|
-
|
|
4224
|
+
updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
4225
|
+
_context22.next = 4;
|
|
3768
4226
|
return this.applyPromotion();
|
|
3769
4227
|
case 4:
|
|
3770
|
-
this.applyDiscount(
|
|
4228
|
+
this.applyDiscount({
|
|
4229
|
+
reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
|
|
4230
|
+
});
|
|
3771
4231
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
3772
|
-
|
|
4232
|
+
_context22.next = 8;
|
|
3773
4233
|
return this.recalculateSummary({
|
|
3774
4234
|
createIfMissing: true
|
|
3775
4235
|
});
|
|
3776
4236
|
case 8:
|
|
3777
4237
|
this.persistTempOrder();
|
|
3778
|
-
|
|
3779
|
-
|
|
4238
|
+
this.logInfo('updateOrderProduct success', {
|
|
4239
|
+
params: params
|
|
4240
|
+
});
|
|
4241
|
+
return _context22.abrupt("return", tempOrder.products);
|
|
4242
|
+
case 11:
|
|
3780
4243
|
case "end":
|
|
3781
|
-
return
|
|
4244
|
+
return _context22.stop();
|
|
3782
4245
|
}
|
|
3783
|
-
},
|
|
4246
|
+
}, _callee20, this);
|
|
3784
4247
|
}));
|
|
3785
|
-
function updateOrderProduct(
|
|
4248
|
+
function updateOrderProduct(_x24) {
|
|
3786
4249
|
return _updateOrderProduct.apply(this, arguments);
|
|
3787
4250
|
}
|
|
3788
4251
|
return updateOrderProduct;
|
|
@@ -3790,33 +4253,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3790
4253
|
}, {
|
|
3791
4254
|
key: "updateOrderProducts",
|
|
3792
4255
|
value: function () {
|
|
3793
|
-
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3794
|
-
var
|
|
3795
|
-
var tempOrder;
|
|
3796
|
-
return _regeneratorRuntime().wrap(function
|
|
3797
|
-
while (1) switch (
|
|
4256
|
+
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(paramsList) {
|
|
4257
|
+
var _this25 = this;
|
|
4258
|
+
var tempOrder, reapplyBookingDiscountProductUids;
|
|
4259
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context23) {
|
|
4260
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
3798
4261
|
case 0:
|
|
3799
4262
|
tempOrder = this.ensureTempOrder();
|
|
3800
4263
|
if (paramsList.length) {
|
|
3801
|
-
|
|
4264
|
+
_context23.next = 3;
|
|
3802
4265
|
break;
|
|
3803
4266
|
}
|
|
3804
|
-
return
|
|
4267
|
+
return _context23.abrupt("return", tempOrder.products);
|
|
3805
4268
|
case 3:
|
|
3806
|
-
paramsList.
|
|
3807
|
-
|
|
4269
|
+
reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
|
|
4270
|
+
var updatedProductUid = _this25.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
4271
|
+
// 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
|
|
4272
|
+
if (params.allow_booking_discount_reapply && updatedProductUid) {
|
|
4273
|
+
acc.push(String(updatedProductUid));
|
|
4274
|
+
}
|
|
4275
|
+
return acc;
|
|
4276
|
+
}, []);
|
|
4277
|
+
_context23.next = 6;
|
|
4278
|
+
return this.finalizeAfterProductsMutation(tempOrder, {
|
|
4279
|
+
reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
|
|
3808
4280
|
});
|
|
3809
|
-
_context22.next = 6;
|
|
3810
|
-
return this.finalizeAfterProductsMutation(tempOrder);
|
|
3811
4281
|
case 6:
|
|
3812
|
-
|
|
3813
|
-
|
|
4282
|
+
this.logInfo('updateOrderProduct success', {
|
|
4283
|
+
paramsList: paramsList
|
|
4284
|
+
});
|
|
4285
|
+
return _context23.abrupt("return", tempOrder.products);
|
|
4286
|
+
case 8:
|
|
3814
4287
|
case "end":
|
|
3815
|
-
return
|
|
4288
|
+
return _context23.stop();
|
|
3816
4289
|
}
|
|
3817
|
-
},
|
|
4290
|
+
}, _callee21, this);
|
|
3818
4291
|
}));
|
|
3819
|
-
function updateOrderProducts(
|
|
4292
|
+
function updateOrderProducts(_x25) {
|
|
3820
4293
|
return _updateOrderProducts.apply(this, arguments);
|
|
3821
4294
|
}
|
|
3822
4295
|
return updateOrderProducts;
|
|
@@ -3824,11 +4297,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3824
4297
|
}, {
|
|
3825
4298
|
key: "updateOrderProductQuantity",
|
|
3826
4299
|
value: function () {
|
|
3827
|
-
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3828
|
-
var _targetProduct$
|
|
4300
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
|
|
4301
|
+
var _targetProduct$metada17;
|
|
3829
4302
|
var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct;
|
|
3830
|
-
return _regeneratorRuntime().wrap(function
|
|
3831
|
-
while (1) switch (
|
|
4303
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context24) {
|
|
4304
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
3832
4305
|
case 0:
|
|
3833
4306
|
product_id = params.product_id, product_variant_id = params.product_variant_id, num = params.num, unique_identification_number = params.unique_identification_number, identity_key = params.identity_key, product_sku = params.product_sku, product_bundle = params.product_bundle;
|
|
3834
4307
|
tempOrder = this.ensureTempOrder();
|
|
@@ -3849,15 +4322,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3849
4322
|
if (unique_identification_number !== undefined) {
|
|
3850
4323
|
targetUid = String(unique_identification_number);
|
|
3851
4324
|
productIndex = tempOrder.products.findIndex(function (item) {
|
|
3852
|
-
var _item$
|
|
3853
|
-
return String(((_item$
|
|
4325
|
+
var _item$metadata5;
|
|
4326
|
+
return String(((_item$metadata5 = item.metadata) === null || _item$metadata5 === void 0 ? void 0 : _item$metadata5.unique_identification_number) || item.unique_identification_number || '') === targetUid;
|
|
3854
4327
|
});
|
|
3855
4328
|
}
|
|
3856
4329
|
if (productIndex === -1) {
|
|
3857
4330
|
productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
|
|
3858
4331
|
}
|
|
3859
4332
|
if (!(productIndex === -1)) {
|
|
3860
|
-
|
|
4333
|
+
_context24.next = 12;
|
|
3861
4334
|
break;
|
|
3862
4335
|
}
|
|
3863
4336
|
throw new Error('[Order] 目标商品不存在,无法更新数量');
|
|
@@ -3866,30 +4339,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3866
4339
|
normalizedProduct = normalizeOrderProduct(_objectSpread(_objectSpread({}, targetProduct), {}, {
|
|
3867
4340
|
num: getSafeProductNum(num),
|
|
3868
4341
|
metadata: _objectSpread(_objectSpread({}, targetProduct.metadata || {}), {}, {
|
|
3869
|
-
unique_identification_number: ((_targetProduct$
|
|
4342
|
+
unique_identification_number: ((_targetProduct$metada17 = targetProduct.metadata) === null || _targetProduct$metada17 === void 0 ? void 0 : _targetProduct$metada17.unique_identification_number) || unique_identification_number
|
|
3870
4343
|
})
|
|
3871
4344
|
}));
|
|
3872
4345
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
3873
4346
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
3874
|
-
|
|
4347
|
+
_context24.next = 18;
|
|
3875
4348
|
return this.applyPromotion();
|
|
3876
4349
|
case 18:
|
|
3877
4350
|
this.applyDiscount();
|
|
3878
4351
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
3879
|
-
|
|
4352
|
+
_context24.next = 22;
|
|
3880
4353
|
return this.recalculateSummary({
|
|
3881
4354
|
createIfMissing: true
|
|
3882
4355
|
});
|
|
3883
4356
|
case 22:
|
|
3884
4357
|
this.persistTempOrder();
|
|
3885
|
-
|
|
3886
|
-
|
|
4358
|
+
this.logInfo('updateOrderProductQuantity success', {
|
|
4359
|
+
params: params
|
|
4360
|
+
});
|
|
4361
|
+
return _context24.abrupt("return", tempOrder.products);
|
|
4362
|
+
case 25:
|
|
3887
4363
|
case "end":
|
|
3888
|
-
return
|
|
4364
|
+
return _context24.stop();
|
|
3889
4365
|
}
|
|
3890
|
-
},
|
|
4366
|
+
}, _callee22, this);
|
|
3891
4367
|
}));
|
|
3892
|
-
function updateOrderProductQuantity(
|
|
4368
|
+
function updateOrderProductQuantity(_x26) {
|
|
3893
4369
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
3894
4370
|
}
|
|
3895
4371
|
return updateOrderProductQuantity;
|
|
@@ -3930,17 +4406,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3930
4406
|
}, {
|
|
3931
4407
|
key: "finalizeAfterProductsMutation",
|
|
3932
4408
|
value: (function () {
|
|
3933
|
-
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3934
|
-
return _regeneratorRuntime().wrap(function
|
|
3935
|
-
while (1) switch (
|
|
4409
|
+
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(tempOrder, options) {
|
|
4410
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context25) {
|
|
4411
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
3936
4412
|
case 0:
|
|
3937
4413
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
3938
|
-
|
|
4414
|
+
_context25.next = 3;
|
|
3939
4415
|
return this.applyPromotion();
|
|
3940
4416
|
case 3:
|
|
3941
|
-
this.applyDiscount(
|
|
4417
|
+
this.applyDiscount({
|
|
4418
|
+
reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids
|
|
4419
|
+
});
|
|
3942
4420
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
3943
|
-
|
|
4421
|
+
_context25.next = 7;
|
|
3944
4422
|
return this.recalculateSummary({
|
|
3945
4423
|
createIfMissing: true
|
|
3946
4424
|
});
|
|
@@ -3948,11 +4426,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3948
4426
|
this.persistTempOrder();
|
|
3949
4427
|
case 8:
|
|
3950
4428
|
case "end":
|
|
3951
|
-
return
|
|
4429
|
+
return _context25.stop();
|
|
3952
4430
|
}
|
|
3953
|
-
},
|
|
4431
|
+
}, _callee23, this);
|
|
3954
4432
|
}));
|
|
3955
|
-
function finalizeAfterProductsMutation(
|
|
4433
|
+
function finalizeAfterProductsMutation(_x27, _x28) {
|
|
3956
4434
|
return _finalizeAfterProductsMutation.apply(this, arguments);
|
|
3957
4435
|
}
|
|
3958
4436
|
return finalizeAfterProductsMutation;
|
|
@@ -3967,18 +4445,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3967
4445
|
}, {
|
|
3968
4446
|
key: "removeProductsFromOrder",
|
|
3969
4447
|
value: (function () {
|
|
3970
|
-
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3971
|
-
var
|
|
4448
|
+
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(identities) {
|
|
4449
|
+
var _this26 = this;
|
|
3972
4450
|
var tempOrder, productsBeforeRemove, bookingsBeforeRemove, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3;
|
|
3973
|
-
return _regeneratorRuntime().wrap(function
|
|
3974
|
-
while (1) switch (
|
|
4451
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context27) {
|
|
4452
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
3975
4453
|
case 0:
|
|
3976
4454
|
tempOrder = this.ensureTempOrder();
|
|
3977
4455
|
if (identities.length) {
|
|
3978
|
-
|
|
4456
|
+
_context27.next = 3;
|
|
3979
4457
|
break;
|
|
3980
4458
|
}
|
|
3981
|
-
return
|
|
4459
|
+
return _context27.abrupt("return", tempOrder.products);
|
|
3982
4460
|
case 3:
|
|
3983
4461
|
productsBeforeRemove = tempOrder.products || [];
|
|
3984
4462
|
bookingsBeforeRemove = tempOrder.bookings || [];
|
|
@@ -4001,29 +4479,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4001
4479
|
}
|
|
4002
4480
|
linkedBookingUidsToRemove = new Set();
|
|
4003
4481
|
_iterator21 = _createForOfIteratorHelper(matchedProducts);
|
|
4004
|
-
|
|
4482
|
+
_context27.prev = 11;
|
|
4005
4483
|
_loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
|
|
4006
|
-
var
|
|
4484
|
+
var _metadata11, _metadata12, _metadata13, _metadata14;
|
|
4007
4485
|
var product, productUid, productBookingUid, isAddTimeProduct;
|
|
4008
|
-
return _regeneratorRuntime().wrap(function _loop3$(
|
|
4009
|
-
while (1) switch (
|
|
4486
|
+
return _regeneratorRuntime().wrap(function _loop3$(_context26) {
|
|
4487
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
4010
4488
|
case 0:
|
|
4011
4489
|
product = _step21.value;
|
|
4012
|
-
productUid = (product === null || product === void 0 || (
|
|
4013
|
-
productBookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (
|
|
4014
|
-
isAddTimeProduct = (product === null || product === void 0 || (
|
|
4490
|
+
productUid = (product === null || product === void 0 || (_metadata11 = product.metadata) === null || _metadata11 === void 0 ? void 0 : _metadata11.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
4491
|
+
productBookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_metadata12 = product.metadata) === null || _metadata12 === void 0 ? void 0 : _metadata12.booking_uid);
|
|
4492
|
+
isAddTimeProduct = (product === null || product === void 0 || (_metadata13 = product.metadata) === null || _metadata13 === void 0 ? void 0 : _metadata13.product_add_schedule_time) !== undefined && (product === null || product === void 0 || (_metadata14 = product.metadata) === null || _metadata14 === void 0 ? void 0 : _metadata14.product_add_schedule_time) !== null;
|
|
4015
4493
|
if (!isAddTimeProduct) {
|
|
4016
|
-
|
|
4494
|
+
_context26.next = 6;
|
|
4017
4495
|
break;
|
|
4018
4496
|
}
|
|
4019
|
-
return
|
|
4497
|
+
return _context26.abrupt("return", 1);
|
|
4020
4498
|
case 6:
|
|
4021
4499
|
if (productBookingUid !== undefined && productBookingUid !== null && productBookingUid !== '') {
|
|
4022
4500
|
linkedBookingUidsToRemove.add(String(productBookingUid));
|
|
4023
4501
|
}
|
|
4024
4502
|
if (productUid !== undefined && productUid !== null && productUid !== '') {
|
|
4025
4503
|
bookingsBeforeRemove.forEach(function (booking) {
|
|
4026
|
-
var bookingUid =
|
|
4504
|
+
var bookingUid = _this26.getBookingUniqueIdentificationNumber(booking);
|
|
4027
4505
|
if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
|
|
4028
4506
|
linkedBookingUidsToRemove.add(bookingUid);
|
|
4029
4507
|
}
|
|
@@ -4031,37 +4509,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4031
4509
|
}
|
|
4032
4510
|
case 8:
|
|
4033
4511
|
case "end":
|
|
4034
|
-
return
|
|
4512
|
+
return _context26.stop();
|
|
4035
4513
|
}
|
|
4036
4514
|
}, _loop3);
|
|
4037
4515
|
});
|
|
4038
4516
|
_iterator21.s();
|
|
4039
4517
|
case 14:
|
|
4040
4518
|
if ((_step21 = _iterator21.n()).done) {
|
|
4041
|
-
|
|
4519
|
+
_context27.next = 20;
|
|
4042
4520
|
break;
|
|
4043
4521
|
}
|
|
4044
|
-
return
|
|
4522
|
+
return _context27.delegateYield(_loop3(), "t0", 16);
|
|
4045
4523
|
case 16:
|
|
4046
|
-
if (!
|
|
4047
|
-
|
|
4524
|
+
if (!_context27.t0) {
|
|
4525
|
+
_context27.next = 18;
|
|
4048
4526
|
break;
|
|
4049
4527
|
}
|
|
4050
|
-
return
|
|
4528
|
+
return _context27.abrupt("continue", 18);
|
|
4051
4529
|
case 18:
|
|
4052
|
-
|
|
4530
|
+
_context27.next = 14;
|
|
4053
4531
|
break;
|
|
4054
4532
|
case 20:
|
|
4055
|
-
|
|
4533
|
+
_context27.next = 25;
|
|
4056
4534
|
break;
|
|
4057
4535
|
case 22:
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
_iterator21.e(
|
|
4536
|
+
_context27.prev = 22;
|
|
4537
|
+
_context27.t1 = _context27["catch"](11);
|
|
4538
|
+
_iterator21.e(_context27.t1);
|
|
4061
4539
|
case 25:
|
|
4062
|
-
|
|
4540
|
+
_context27.prev = 25;
|
|
4063
4541
|
_iterator21.f();
|
|
4064
|
-
return
|
|
4542
|
+
return _context27.finish(25);
|
|
4065
4543
|
case 28:
|
|
4066
4544
|
if (linkedBookingUidsToRemove.size > 0) {
|
|
4067
4545
|
// 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
|
|
@@ -4072,17 +4550,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4072
4550
|
return !(isAddTimeProduct && lineBookingUid !== undefined && lineBookingUid !== null && linkedBookingUidsToRemove.has(String(lineBookingUid)));
|
|
4073
4551
|
});
|
|
4074
4552
|
}
|
|
4075
|
-
|
|
4553
|
+
_context27.next = 31;
|
|
4076
4554
|
return this.finalizeAfterProductsMutation(tempOrder);
|
|
4077
4555
|
case 31:
|
|
4078
|
-
|
|
4079
|
-
|
|
4556
|
+
this.logInfo('removeProductsFromOrder success', {
|
|
4557
|
+
identities: identities
|
|
4558
|
+
});
|
|
4559
|
+
return _context27.abrupt("return", tempOrder.products);
|
|
4560
|
+
case 33:
|
|
4080
4561
|
case "end":
|
|
4081
|
-
return
|
|
4562
|
+
return _context27.stop();
|
|
4082
4563
|
}
|
|
4083
|
-
},
|
|
4564
|
+
}, _callee24, this, [[11, 22, 25, 28]]);
|
|
4084
4565
|
}));
|
|
4085
|
-
function removeProductsFromOrder(
|
|
4566
|
+
function removeProductsFromOrder(_x29) {
|
|
4086
4567
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
4087
4568
|
}
|
|
4088
4569
|
return removeProductsFromOrder;
|
|
@@ -4090,18 +4571,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4090
4571
|
}, {
|
|
4091
4572
|
key: "removeProductFromOrder",
|
|
4092
4573
|
value: function () {
|
|
4093
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4094
|
-
return _regeneratorRuntime().wrap(function
|
|
4095
|
-
while (1) switch (
|
|
4574
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(identity) {
|
|
4575
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context28) {
|
|
4576
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
4096
4577
|
case 0:
|
|
4097
|
-
return
|
|
4578
|
+
return _context28.abrupt("return", this.removeProductsFromOrder([identity]));
|
|
4098
4579
|
case 1:
|
|
4099
4580
|
case "end":
|
|
4100
|
-
return
|
|
4581
|
+
return _context28.stop();
|
|
4101
4582
|
}
|
|
4102
|
-
},
|
|
4583
|
+
}, _callee25, this);
|
|
4103
4584
|
}));
|
|
4104
|
-
function removeProductFromOrder(
|
|
4585
|
+
function removeProductFromOrder(_x30) {
|
|
4105
4586
|
return _removeProductFromOrder.apply(this, arguments);
|
|
4106
4587
|
}
|
|
4107
4588
|
return removeProductFromOrder;
|
|
@@ -4113,10 +4594,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4113
4594
|
}, {
|
|
4114
4595
|
key: "clearOrderCartLines",
|
|
4115
4596
|
value: (function () {
|
|
4116
|
-
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4597
|
+
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
|
|
4117
4598
|
var tempOrder;
|
|
4118
|
-
return _regeneratorRuntime().wrap(function
|
|
4119
|
-
while (1) switch (
|
|
4599
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context29) {
|
|
4600
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
4120
4601
|
case 0:
|
|
4121
4602
|
tempOrder = this.ensureTempOrder();
|
|
4122
4603
|
tempOrder.products = [];
|
|
@@ -4127,23 +4608,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4127
4608
|
productsByUid: {}
|
|
4128
4609
|
});
|
|
4129
4610
|
}
|
|
4130
|
-
|
|
4611
|
+
_context29.next = 7;
|
|
4131
4612
|
return this.applyPromotion();
|
|
4132
4613
|
case 7:
|
|
4133
4614
|
this.applyDiscount();
|
|
4134
4615
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4135
|
-
|
|
4616
|
+
_context29.next = 11;
|
|
4136
4617
|
return this.recalculateSummary({
|
|
4137
4618
|
createIfMissing: true
|
|
4138
4619
|
});
|
|
4139
4620
|
case 11:
|
|
4140
4621
|
this.persistTempOrder();
|
|
4141
|
-
|
|
4142
|
-
|
|
4622
|
+
this.logInfo('clearOrderCartLines success', {});
|
|
4623
|
+
return _context29.abrupt("return", tempOrder);
|
|
4624
|
+
case 14:
|
|
4143
4625
|
case "end":
|
|
4144
|
-
return
|
|
4626
|
+
return _context29.stop();
|
|
4145
4627
|
}
|
|
4146
|
-
},
|
|
4628
|
+
}, _callee26, this);
|
|
4147
4629
|
}));
|
|
4148
4630
|
function clearOrderCartLines() {
|
|
4149
4631
|
return _clearOrderCartLines.apply(this, arguments);
|
|
@@ -4154,23 +4636,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4154
4636
|
}, {
|
|
4155
4637
|
key: "buildCurrentSubmitPayloadForLocalPrint",
|
|
4156
4638
|
value: function buildCurrentSubmitPayloadForLocalPrint(params) {
|
|
4157
|
-
var _params$cacheId, _this$
|
|
4639
|
+
var _params$cacheId, _this$otherParams3, _ref70, _params$businessCode, _this$otherParams4, _this$otherParams5;
|
|
4158
4640
|
var tempOrder = this.ensureTempOrder();
|
|
4159
4641
|
this.persistTempOrder();
|
|
4160
4642
|
var payload = buildSubmitPayload({
|
|
4161
4643
|
tempOrder: tempOrder,
|
|
4162
4644
|
cacheId: (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId,
|
|
4163
|
-
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$
|
|
4164
|
-
businessCode: (
|
|
4645
|
+
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.platform),
|
|
4646
|
+
businessCode: (_ref70 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.businessCode) !== null && _ref70 !== void 0 ? _ref70 : (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.business_code,
|
|
4165
4647
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
4166
4648
|
type: params === null || params === void 0 ? void 0 : params.type,
|
|
4167
4649
|
summary: this.store.summary || createEmptySummary(),
|
|
4168
4650
|
enhance: function enhance(nextPayload) {
|
|
4169
|
-
var
|
|
4651
|
+
var _ref71, _tempOrder$order_numb, _ref72, _tempOrder$shop_order, _ref73, _tempOrder$shop_full_;
|
|
4170
4652
|
return _objectSpread(_objectSpread({}, nextPayload), {}, {
|
|
4171
|
-
order_number: (
|
|
4172
|
-
shop_order_number: (
|
|
4173
|
-
shop_full_order_number: (
|
|
4653
|
+
order_number: (_ref71 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref71 !== void 0 ? _ref71 : null,
|
|
4654
|
+
shop_order_number: (_ref72 = (_tempOrder$shop_order = tempOrder.shop_order_number) !== null && _tempOrder$shop_order !== void 0 ? _tempOrder$shop_order : nextPayload.shop_order_number) !== null && _ref72 !== void 0 ? _ref72 : null,
|
|
4655
|
+
shop_full_order_number: (_ref73 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref73 !== void 0 ? _ref73 : null,
|
|
4174
4656
|
small_ticket_data_flag: 1
|
|
4175
4657
|
});
|
|
4176
4658
|
}
|
|
@@ -4181,17 +4663,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4181
4663
|
}, {
|
|
4182
4664
|
key: "applyLocalPrintOrderNumbers",
|
|
4183
4665
|
value: function () {
|
|
4184
|
-
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4666
|
+
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(order) {
|
|
4185
4667
|
var tempOrder, shopOrderNumber, shopFullOrderNumber;
|
|
4186
|
-
return _regeneratorRuntime().wrap(function
|
|
4187
|
-
while (1) switch (
|
|
4668
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context30) {
|
|
4669
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
4188
4670
|
case 0:
|
|
4189
4671
|
tempOrder = this.ensureTempOrder();
|
|
4190
4672
|
if (!(!order || _typeof(order) !== 'object')) {
|
|
4191
|
-
|
|
4673
|
+
_context30.next = 3;
|
|
4192
4674
|
break;
|
|
4193
4675
|
}
|
|
4194
|
-
return
|
|
4676
|
+
return _context30.abrupt("return", tempOrder);
|
|
4195
4677
|
case 3:
|
|
4196
4678
|
shopOrderNumber = order.shop_order_number;
|
|
4197
4679
|
shopFullOrderNumber = order.shop_full_order_number;
|
|
@@ -4202,17 +4684,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4202
4684
|
tempOrder.shop_full_order_number = String(shopFullOrderNumber);
|
|
4203
4685
|
}
|
|
4204
4686
|
this.persistTempOrder();
|
|
4205
|
-
|
|
4687
|
+
_context30.next = 10;
|
|
4206
4688
|
return this.saveDraft();
|
|
4207
4689
|
case 10:
|
|
4208
|
-
return
|
|
4690
|
+
return _context30.abrupt("return", tempOrder);
|
|
4209
4691
|
case 11:
|
|
4210
4692
|
case "end":
|
|
4211
|
-
return
|
|
4693
|
+
return _context30.stop();
|
|
4212
4694
|
}
|
|
4213
|
-
},
|
|
4695
|
+
}, _callee27, this);
|
|
4214
4696
|
}));
|
|
4215
|
-
function applyLocalPrintOrderNumbers(
|
|
4697
|
+
function applyLocalPrintOrderNumbers(_x31) {
|
|
4216
4698
|
return _applyLocalPrintOrderNumbers.apply(this, arguments);
|
|
4217
4699
|
}
|
|
4218
4700
|
return applyLocalPrintOrderNumbers;
|
|
@@ -4226,18 +4708,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4226
4708
|
}, {
|
|
4227
4709
|
key: "submitTempOrder",
|
|
4228
4710
|
value: (function () {
|
|
4229
|
-
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4230
|
-
return _regeneratorRuntime().wrap(function
|
|
4231
|
-
while (1) switch (
|
|
4711
|
+
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
|
|
4712
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context31) {
|
|
4713
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
4232
4714
|
case 0:
|
|
4233
|
-
return
|
|
4715
|
+
return _context31.abrupt("return", this.runSubmitTempOrder(params));
|
|
4234
4716
|
case 1:
|
|
4235
4717
|
case "end":
|
|
4236
|
-
return
|
|
4718
|
+
return _context31.stop();
|
|
4237
4719
|
}
|
|
4238
|
-
},
|
|
4720
|
+
}, _callee28, this);
|
|
4239
4721
|
}));
|
|
4240
|
-
function submitTempOrder(
|
|
4722
|
+
function submitTempOrder(_x32) {
|
|
4241
4723
|
return _submitTempOrder.apply(this, arguments);
|
|
4242
4724
|
}
|
|
4243
4725
|
return submitTempOrder;
|
|
@@ -4245,20 +4727,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4245
4727
|
}, {
|
|
4246
4728
|
key: "submitTempOrderAsync",
|
|
4247
4729
|
value: function () {
|
|
4248
|
-
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4249
|
-
return _regeneratorRuntime().wrap(function
|
|
4250
|
-
while (1) switch (
|
|
4730
|
+
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
|
|
4731
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context32) {
|
|
4732
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
4251
4733
|
case 0:
|
|
4252
|
-
return
|
|
4734
|
+
return _context32.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
4253
4735
|
syncMode: true
|
|
4254
4736
|
})));
|
|
4255
4737
|
case 1:
|
|
4256
4738
|
case "end":
|
|
4257
|
-
return
|
|
4739
|
+
return _context32.stop();
|
|
4258
4740
|
}
|
|
4259
|
-
},
|
|
4741
|
+
}, _callee29, this);
|
|
4260
4742
|
}));
|
|
4261
|
-
function submitTempOrderAsync(
|
|
4743
|
+
function submitTempOrderAsync(_x33) {
|
|
4262
4744
|
return _submitTempOrderAsync.apply(this, arguments);
|
|
4263
4745
|
}
|
|
4264
4746
|
return submitTempOrderAsync;
|
|
@@ -4266,42 +4748,57 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4266
4748
|
}, {
|
|
4267
4749
|
key: "runSubmitTempOrder",
|
|
4268
4750
|
value: function () {
|
|
4269
|
-
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4270
|
-
var _params$cacheId2, _this$
|
|
4271
|
-
var tempOrder, latestSummary, effectiveCacheId,
|
|
4272
|
-
return _regeneratorRuntime().wrap(function
|
|
4273
|
-
while (1) switch (
|
|
4751
|
+
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
|
|
4752
|
+
var _params$cacheId2, _this$otherParams6, _ref74, _ref75, _submitSnapshot$busin, _this$otherParams7, _this$otherParams8, _submitSnapshot$type;
|
|
4753
|
+
var tempOrder, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
|
|
4754
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context33) {
|
|
4755
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
4274
4756
|
case 0:
|
|
4275
4757
|
tempOrder = this.ensureTempOrder();
|
|
4758
|
+
shouldConfirmPendingVoucherPayments = (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== false;
|
|
4759
|
+
hasPaymentOverride = (params === null || params === void 0 ? void 0 : params.payments) !== undefined;
|
|
4760
|
+
preparedPaymentOverride = hasPaymentOverride ? this.prepareVoucherPaymentsForSubmit((params === null || params === void 0 ? void 0 : params.payments) || [], shouldConfirmPendingVoucherPayments) : undefined;
|
|
4761
|
+
if (!hasPaymentOverride) {
|
|
4762
|
+
if (shouldConfirmPendingVoucherPayments) {
|
|
4763
|
+
this.confirmPendingVoucherPayments({
|
|
4764
|
+
persist: false,
|
|
4765
|
+
recalculateSummary: false
|
|
4766
|
+
});
|
|
4767
|
+
} else {
|
|
4768
|
+
this.discardPendingVoucherPayments({
|
|
4769
|
+
persist: false,
|
|
4770
|
+
recalculateSummary: false
|
|
4771
|
+
});
|
|
4772
|
+
}
|
|
4773
|
+
}
|
|
4276
4774
|
this.persistTempOrder();
|
|
4277
|
-
|
|
4775
|
+
_context33.next = 8;
|
|
4278
4776
|
return this.recalculateSummary({
|
|
4279
4777
|
createIfMissing: true
|
|
4280
4778
|
});
|
|
4281
|
-
case
|
|
4282
|
-
|
|
4283
|
-
if (
|
|
4284
|
-
|
|
4779
|
+
case 8:
|
|
4780
|
+
_context33.t1 = _context33.sent;
|
|
4781
|
+
if (_context33.t1) {
|
|
4782
|
+
_context33.next = 11;
|
|
4285
4783
|
break;
|
|
4286
4784
|
}
|
|
4287
|
-
|
|
4288
|
-
case
|
|
4289
|
-
|
|
4290
|
-
if (
|
|
4291
|
-
|
|
4785
|
+
_context33.t1 = this.store.summary;
|
|
4786
|
+
case 11:
|
|
4787
|
+
_context33.t0 = _context33.t1;
|
|
4788
|
+
if (_context33.t0) {
|
|
4789
|
+
_context33.next = 14;
|
|
4292
4790
|
break;
|
|
4293
4791
|
}
|
|
4294
|
-
|
|
4295
|
-
case
|
|
4296
|
-
latestSummary =
|
|
4792
|
+
_context33.t0 = createEmptySummary();
|
|
4793
|
+
case 14:
|
|
4794
|
+
latestSummary = _context33.t0;
|
|
4297
4795
|
effectiveCacheId = (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId;
|
|
4298
|
-
hasPaymentOverride = (params === null || params === void 0 ? void 0 : params.payments) !== undefined;
|
|
4299
4796
|
hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
|
|
4300
4797
|
hasSmallTicketDataFlagOverride = (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined;
|
|
4301
4798
|
enhancePayload = hasPaymentOverride || hasPaymentStatusOverride || hasSmallTicketDataFlagOverride || params !== null && params !== void 0 && params.enhancePayload ? function (payload, ctx) {
|
|
4302
4799
|
var nextPayload = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, payload), hasPaymentOverride ? {
|
|
4303
|
-
payments:
|
|
4304
|
-
} : {}), hasPaymentStatusOverride ? {
|
|
4800
|
+
payments: preparedPaymentOverride || []
|
|
4801
|
+
} : {}), hasPaymentStatusOverride && !shouldConfirmPendingVoucherPayments ? {
|
|
4305
4802
|
payment_status: params === null || params === void 0 ? void 0 : params.paymentStatus
|
|
4306
4803
|
} : {}), hasSmallTicketDataFlagOverride ? {
|
|
4307
4804
|
small_ticket_data_flag: params === null || params === void 0 ? void 0 : params.smallTicketDataFlag
|
|
@@ -4309,17 +4806,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4309
4806
|
var enhancedPayload = params !== null && params !== void 0 && params.enhancePayload ? params.enhancePayload(nextPayload, ctx) : nextPayload;
|
|
4310
4807
|
return enhancedPayload;
|
|
4311
4808
|
} : undefined;
|
|
4809
|
+
submitSnapshot = this.getLastOrderSubmitSnapshot();
|
|
4312
4810
|
payload = buildSubmitPayload({
|
|
4313
4811
|
tempOrder: tempOrder,
|
|
4314
4812
|
cacheId: effectiveCacheId,
|
|
4315
|
-
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$
|
|
4316
|
-
businessCode: (
|
|
4813
|
+
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform),
|
|
4814
|
+
businessCode: (_ref74 = (_ref75 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref75 !== void 0 ? _ref75 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.businessCode) !== null && _ref74 !== void 0 ? _ref74 : (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.business_code,
|
|
4317
4815
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
4318
|
-
type: params === null || params === void 0 ? void 0 : params.type,
|
|
4816
|
+
type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
|
|
4319
4817
|
summary: latestSummary,
|
|
4320
4818
|
request_unique_idempotency_token: params === null || params === void 0 ? void 0 : params.request_unique_idempotency_token,
|
|
4321
4819
|
enhance: enhancePayload
|
|
4322
4820
|
});
|
|
4821
|
+
console.log('[Order.runSubmitTempOrder.payload]', payload);
|
|
4323
4822
|
if (params !== null && params !== void 0 && params.syncMode) {
|
|
4324
4823
|
payload.sync_mode = true;
|
|
4325
4824
|
}
|
|
@@ -4327,10 +4826,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4327
4826
|
if (!payload.created_at) {
|
|
4328
4827
|
payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
4329
4828
|
}
|
|
4330
|
-
|
|
4829
|
+
_context33.next = 26;
|
|
4331
4830
|
return this.saveDraft();
|
|
4332
|
-
case
|
|
4333
|
-
|
|
4831
|
+
case 26:
|
|
4832
|
+
_context33.prev = 26;
|
|
4334
4833
|
this.logInfo('submitTempOrder calling sales checkout', {
|
|
4335
4834
|
orderId: payload.order_id,
|
|
4336
4835
|
externalSaleNumber: payload.external_sale_number,
|
|
@@ -4340,76 +4839,78 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4340
4839
|
smallTicketDataFlag: payload.small_ticket_data_flag,
|
|
4341
4840
|
syncMode: payload.sync_mode
|
|
4342
4841
|
});
|
|
4343
|
-
|
|
4842
|
+
_context33.next = 30;
|
|
4344
4843
|
return this.submitSalesOrder({
|
|
4345
4844
|
query: payload
|
|
4346
4845
|
});
|
|
4347
|
-
case
|
|
4348
|
-
result =
|
|
4349
|
-
|
|
4846
|
+
case 30:
|
|
4847
|
+
result = _context33.sent;
|
|
4848
|
+
_context33.next = 43;
|
|
4350
4849
|
break;
|
|
4351
|
-
case
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
backendErrorResponse = this.extractSubmitErrorResponse(
|
|
4850
|
+
case 33:
|
|
4851
|
+
_context33.prev = 33;
|
|
4852
|
+
_context33.t2 = _context33["catch"](26);
|
|
4853
|
+
backendErrorResponse = this.extractSubmitErrorResponse(_context33.t2);
|
|
4355
4854
|
if (!backendErrorResponse) {
|
|
4356
|
-
|
|
4855
|
+
_context33.next = 40;
|
|
4357
4856
|
break;
|
|
4358
4857
|
}
|
|
4359
4858
|
this.store.syncState = 'failed';
|
|
4360
4859
|
this.logSubmitBackendRejected(backendErrorResponse, payload);
|
|
4361
|
-
return
|
|
4362
|
-
case
|
|
4860
|
+
return _context33.abrupt("return", backendErrorResponse);
|
|
4861
|
+
case 40:
|
|
4363
4862
|
this.store.syncState = 'failed';
|
|
4364
4863
|
this.logError('submitTempOrder failed', {
|
|
4365
|
-
error:
|
|
4864
|
+
error: _context33.t2 instanceof Error ? _context33.t2.message : String(_context33.t2),
|
|
4366
4865
|
orderId: payload.order_id,
|
|
4367
4866
|
externalSaleNumber: payload.external_sale_number,
|
|
4368
4867
|
paymentStatus: payload.payment_status,
|
|
4369
4868
|
paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
|
|
4370
4869
|
});
|
|
4371
|
-
throw
|
|
4372
|
-
case
|
|
4870
|
+
throw _context33.t2;
|
|
4871
|
+
case 43:
|
|
4373
4872
|
if (!this.isSubmitResponseRejected(result)) {
|
|
4374
|
-
|
|
4873
|
+
_context33.next = 47;
|
|
4375
4874
|
break;
|
|
4376
4875
|
}
|
|
4377
4876
|
this.store.syncState = 'failed';
|
|
4378
4877
|
this.logSubmitBackendRejected(result, payload);
|
|
4379
|
-
return
|
|
4380
|
-
case
|
|
4878
|
+
return _context33.abrupt("return", result);
|
|
4879
|
+
case 47:
|
|
4381
4880
|
submittedOrderId = this.extractOrderIdFromSubmitResult(result);
|
|
4382
4881
|
this.logInfo('runSubmitTempOrder: 提交成功', {
|
|
4383
4882
|
submittedOrderId: submittedOrderId,
|
|
4384
4883
|
result: result,
|
|
4385
|
-
tempOrder: tempOrder
|
|
4884
|
+
tempOrder: _objectSpread(_objectSpread({}, tempOrder), {}, {
|
|
4885
|
+
_extend: undefined
|
|
4886
|
+
})
|
|
4386
4887
|
});
|
|
4387
4888
|
if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
|
|
4388
|
-
|
|
4889
|
+
_context33.next = 56;
|
|
4389
4890
|
break;
|
|
4390
4891
|
}
|
|
4391
4892
|
tempOrder.order_id = submittedOrderId;
|
|
4392
4893
|
resultRecord = result;
|
|
4393
|
-
|
|
4894
|
+
_context33.next = 54;
|
|
4394
4895
|
return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
|
|
4395
|
-
case
|
|
4396
|
-
|
|
4896
|
+
case 54:
|
|
4897
|
+
_context33.next = 57;
|
|
4397
4898
|
break;
|
|
4398
|
-
case
|
|
4899
|
+
case 56:
|
|
4399
4900
|
if (this.isLocalPendingSubmitResult(result)) {
|
|
4400
4901
|
this.store.syncState = 'local';
|
|
4401
4902
|
} else {
|
|
4402
4903
|
this.store.syncState = 'submitted';
|
|
4403
4904
|
}
|
|
4404
|
-
case
|
|
4405
|
-
return
|
|
4406
|
-
case
|
|
4905
|
+
case 57:
|
|
4906
|
+
return _context33.abrupt("return", result);
|
|
4907
|
+
case 58:
|
|
4407
4908
|
case "end":
|
|
4408
|
-
return
|
|
4909
|
+
return _context33.stop();
|
|
4409
4910
|
}
|
|
4410
|
-
},
|
|
4911
|
+
}, _callee30, this, [[26, 33]]);
|
|
4411
4912
|
}));
|
|
4412
|
-
function runSubmitTempOrder(
|
|
4913
|
+
function runSubmitTempOrder(_x34) {
|
|
4413
4914
|
return _runSubmitTempOrder.apply(this, arguments);
|
|
4414
4915
|
}
|
|
4415
4916
|
return runSubmitTempOrder;
|
|
@@ -4417,10 +4918,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4417
4918
|
}, {
|
|
4418
4919
|
key: "markLocalOrderSynced",
|
|
4419
4920
|
value: function () {
|
|
4420
|
-
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4921
|
+
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(orderId, remoteOrder) {
|
|
4421
4922
|
var tempOrder;
|
|
4422
|
-
return _regeneratorRuntime().wrap(function
|
|
4423
|
-
while (1) switch (
|
|
4923
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context34) {
|
|
4924
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
4424
4925
|
case 0:
|
|
4425
4926
|
tempOrder = this.ensureTempOrder();
|
|
4426
4927
|
tempOrder.order_id = orderId;
|
|
@@ -4428,15 +4929,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4428
4929
|
this.store.lastOrderInfo = remoteOrder;
|
|
4429
4930
|
this.store.syncState = 'submitted';
|
|
4430
4931
|
this.persistTempOrder();
|
|
4431
|
-
|
|
4932
|
+
_context34.next = 8;
|
|
4432
4933
|
return this.saveDraft();
|
|
4433
4934
|
case 8:
|
|
4434
4935
|
case "end":
|
|
4435
|
-
return
|
|
4936
|
+
return _context34.stop();
|
|
4436
4937
|
}
|
|
4437
|
-
},
|
|
4938
|
+
}, _callee31, this);
|
|
4438
4939
|
}));
|
|
4439
|
-
function markLocalOrderSynced(
|
|
4940
|
+
function markLocalOrderSynced(_x35, _x36) {
|
|
4440
4941
|
return _markLocalOrderSynced.apply(this, arguments);
|
|
4441
4942
|
}
|
|
4442
4943
|
return markLocalOrderSynced;
|
|
@@ -4479,10 +4980,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4479
4980
|
value: function extractSubmitErrorResponse(error) {
|
|
4480
4981
|
var _error$response,
|
|
4481
4982
|
_error$response2,
|
|
4482
|
-
|
|
4983
|
+
_this27 = this;
|
|
4483
4984
|
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];
|
|
4484
4985
|
return candidates.find(function (candidate) {
|
|
4485
|
-
return
|
|
4986
|
+
return _this27.isSubmitErrorResponse(candidate);
|
|
4486
4987
|
}) || null;
|
|
4487
4988
|
}
|
|
4488
4989
|
}, {
|
|
@@ -4509,48 +5010,47 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4509
5010
|
}, {
|
|
4510
5011
|
key: "syncPaymentsToOrder",
|
|
4511
5012
|
value: function () {
|
|
4512
|
-
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4513
|
-
var
|
|
4514
|
-
|
|
4515
|
-
|
|
5013
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
|
|
5014
|
+
var _params$confirmPendin;
|
|
5015
|
+
var tempOrder, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, submitResult;
|
|
5016
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context35) {
|
|
5017
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
4516
5018
|
case 0:
|
|
4517
5019
|
tempOrder = this.ensureTempOrder();
|
|
4518
5020
|
mappedPayments = mapPaymentItemsToOrderPayments(params.payments || []);
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
5021
|
+
shouldConfirmPendingVoucherPayments = (_params$confirmPendin = params.confirmPendingVoucherPayments) !== null && _params$confirmPendin !== void 0 ? _params$confirmPendin : params.submitWhenPaid === true;
|
|
5022
|
+
effectivePayments = shouldConfirmPendingVoucherPayments ? this.confirmPendingVoucherPaymentsInList(mappedPayments) : params.confirmPendingVoucherPayments === false ? this.discardPendingVoucherPaymentsFromList(mappedPayments) : mappedPayments;
|
|
5023
|
+
completion = this.getPaymentCompletion(effectivePayments);
|
|
5024
|
+
orderPaidPaymentTotal = this.calculateOrderPaidPaymentTotal(effectivePayments);
|
|
5025
|
+
paymentStatus = completion.isOrderFullyPaid ? params.paymentStatus || 'paid' : orderPaidPaymentTotal.gt(0) ? 'partially_paid' : 'payment_processing';
|
|
5026
|
+
tempOrder.payments = effectivePayments;
|
|
4524
5027
|
tempOrder.payment_status = paymentStatus;
|
|
4525
5028
|
this.persistTempOrder();
|
|
4526
|
-
|
|
5029
|
+
_context35.next = 12;
|
|
4527
5030
|
return this.saveDraft();
|
|
4528
|
-
case
|
|
5031
|
+
case 12:
|
|
4529
5032
|
if (params.submitWhenPaid) {
|
|
4530
|
-
|
|
5033
|
+
_context35.next = 14;
|
|
4531
5034
|
break;
|
|
4532
5035
|
}
|
|
4533
|
-
return
|
|
4534
|
-
|
|
4535
|
-
});
|
|
4536
|
-
case 13:
|
|
5036
|
+
return _context35.abrupt("return", completion);
|
|
5037
|
+
case 14:
|
|
4537
5038
|
if (!(this.store.syncState === 'submitting')) {
|
|
4538
|
-
|
|
5039
|
+
_context35.next = 16;
|
|
4539
5040
|
break;
|
|
4540
5041
|
}
|
|
4541
|
-
return
|
|
4542
|
-
|
|
4543
|
-
});
|
|
4544
|
-
case 15:
|
|
5042
|
+
return _context35.abrupt("return", completion);
|
|
5043
|
+
case 16:
|
|
4545
5044
|
this.store.syncState = 'submitting';
|
|
4546
|
-
paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder,
|
|
4547
|
-
|
|
5045
|
+
paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, effectivePayments);
|
|
5046
|
+
_context35.next = 20;
|
|
4548
5047
|
return this.submitTempOrder({
|
|
4549
|
-
payments:
|
|
5048
|
+
payments: effectivePayments,
|
|
4550
5049
|
paymentStatus: paymentStatus,
|
|
4551
5050
|
smallTicketDataFlag: params.smallTicketDataFlag,
|
|
4552
5051
|
businessCode: params.businessCode,
|
|
4553
5052
|
channel: params.channel,
|
|
5053
|
+
confirmPendingVoucherPayments: true,
|
|
4554
5054
|
enhancePayload: function enhancePayload(payload) {
|
|
4555
5055
|
var nextPayload = _objectSpread(_objectSpread({}, payload), {}, {
|
|
4556
5056
|
request_unique_idempotency_token: paymentSyncIdempotencyToken
|
|
@@ -4558,19 +5058,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4558
5058
|
return nextPayload;
|
|
4559
5059
|
}
|
|
4560
5060
|
});
|
|
4561
|
-
case
|
|
4562
|
-
submitResult =
|
|
4563
|
-
return
|
|
4564
|
-
isFullyPaid: isFullyPaid,
|
|
5061
|
+
case 20:
|
|
5062
|
+
submitResult = _context35.sent;
|
|
5063
|
+
return _context35.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
|
|
4565
5064
|
submitResult: submitResult
|
|
4566
|
-
});
|
|
4567
|
-
case
|
|
5065
|
+
}));
|
|
5066
|
+
case 22:
|
|
4568
5067
|
case "end":
|
|
4569
|
-
return
|
|
5068
|
+
return _context35.stop();
|
|
4570
5069
|
}
|
|
4571
|
-
},
|
|
5070
|
+
}, _callee32, this);
|
|
4572
5071
|
}));
|
|
4573
|
-
function syncPaymentsToOrder(
|
|
5072
|
+
function syncPaymentsToOrder(_x37) {
|
|
4574
5073
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
4575
5074
|
}
|
|
4576
5075
|
return syncPaymentsToOrder;
|
|
@@ -4659,11 +5158,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4659
5158
|
}, {
|
|
4660
5159
|
key: "submitOrder",
|
|
4661
5160
|
value: function () {
|
|
4662
|
-
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5161
|
+
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(order) {
|
|
4663
5162
|
var _order$query$cartItem, _params$bookings, _params$relation_prod;
|
|
4664
5163
|
var url, query, fetchUrl, params;
|
|
4665
|
-
return _regeneratorRuntime().wrap(function
|
|
4666
|
-
while (1) switch (
|
|
5164
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context36) {
|
|
5165
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
4667
5166
|
case 0:
|
|
4668
5167
|
this.logInfo('submitOrder called', {
|
|
4669
5168
|
url: order.url,
|
|
@@ -4683,14 +5182,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4683
5182
|
relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
|
|
4684
5183
|
scheduleDate: params.schedule_date
|
|
4685
5184
|
});
|
|
4686
|
-
return
|
|
5185
|
+
return _context36.abrupt("return", this.request.post(fetchUrl, params));
|
|
4687
5186
|
case 6:
|
|
4688
5187
|
case "end":
|
|
4689
|
-
return
|
|
5188
|
+
return _context36.stop();
|
|
4690
5189
|
}
|
|
4691
|
-
},
|
|
5190
|
+
}, _callee33, this);
|
|
4692
5191
|
}));
|
|
4693
|
-
function submitOrder(
|
|
5192
|
+
function submitOrder(_x38) {
|
|
4694
5193
|
return _submitOrder.apply(this, arguments);
|
|
4695
5194
|
}
|
|
4696
5195
|
return submitOrder;
|
|
@@ -4698,13 +5197,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4698
5197
|
}, {
|
|
4699
5198
|
key: "cancelOrder",
|
|
4700
5199
|
value: function () {
|
|
4701
|
-
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5200
|
+
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
|
|
4702
5201
|
var payload;
|
|
4703
|
-
return _regeneratorRuntime().wrap(function
|
|
4704
|
-
while (1) switch (
|
|
5202
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context37) {
|
|
5203
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
4705
5204
|
case 0:
|
|
4706
5205
|
if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
|
|
4707
|
-
|
|
5206
|
+
_context37.next = 2;
|
|
4708
5207
|
break;
|
|
4709
5208
|
}
|
|
4710
5209
|
throw new Error('取消订单失败:order_ids 不能为空');
|
|
@@ -4720,16 +5219,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4720
5219
|
method: 'PUT',
|
|
4721
5220
|
orderIdsCount: params.order_ids.length
|
|
4722
5221
|
});
|
|
4723
|
-
return
|
|
5222
|
+
return _context37.abrupt("return", this.request.put('/order/update-status', payload, {
|
|
4724
5223
|
isShopApi: true
|
|
4725
5224
|
}));
|
|
4726
5225
|
case 5:
|
|
4727
5226
|
case "end":
|
|
4728
|
-
return
|
|
5227
|
+
return _context37.stop();
|
|
4729
5228
|
}
|
|
4730
|
-
},
|
|
5229
|
+
}, _callee34, this);
|
|
4731
5230
|
}));
|
|
4732
|
-
function cancelOrder(
|
|
5231
|
+
function cancelOrder(_x39) {
|
|
4733
5232
|
return _cancelOrder.apply(this, arguments);
|
|
4734
5233
|
}
|
|
4735
5234
|
return cancelOrder;
|
|
@@ -4737,19 +5236,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4737
5236
|
}, {
|
|
4738
5237
|
key: "changeBookingStatus",
|
|
4739
5238
|
value: function () {
|
|
4740
|
-
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5239
|
+
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
|
|
4741
5240
|
var url, payload;
|
|
4742
|
-
return _regeneratorRuntime().wrap(function
|
|
4743
|
-
while (1) switch (
|
|
5241
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context38) {
|
|
5242
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
4744
5243
|
case 0:
|
|
4745
5244
|
if (params.booking_id) {
|
|
4746
|
-
|
|
5245
|
+
_context38.next = 2;
|
|
4747
5246
|
break;
|
|
4748
5247
|
}
|
|
4749
5248
|
throw new Error('变更预约状态失败:booking_id 不能为空');
|
|
4750
5249
|
case 2:
|
|
4751
5250
|
if (params.appointment_status) {
|
|
4752
|
-
|
|
5251
|
+
_context38.next = 4;
|
|
4753
5252
|
break;
|
|
4754
5253
|
}
|
|
4755
5254
|
throw new Error('变更预约状态失败:appointment_status 不能为空');
|
|
@@ -4764,16 +5263,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4764
5263
|
bookingId: params.booking_id,
|
|
4765
5264
|
appointmentStatus: params.appointment_status
|
|
4766
5265
|
});
|
|
4767
|
-
return
|
|
5266
|
+
return _context38.abrupt("return", this.request.put(url, payload, {
|
|
4768
5267
|
isShopApi: true
|
|
4769
5268
|
}));
|
|
4770
5269
|
case 8:
|
|
4771
5270
|
case "end":
|
|
4772
|
-
return
|
|
5271
|
+
return _context38.stop();
|
|
4773
5272
|
}
|
|
4774
|
-
},
|
|
5273
|
+
}, _callee35, this);
|
|
4775
5274
|
}));
|
|
4776
|
-
function changeBookingStatus(
|
|
5275
|
+
function changeBookingStatus(_x40) {
|
|
4777
5276
|
return _changeBookingStatus.apply(this, arguments);
|
|
4778
5277
|
}
|
|
4779
5278
|
return changeBookingStatus;
|
|
@@ -4791,11 +5290,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4791
5290
|
}, {
|
|
4792
5291
|
key: "createOrderByCheckout",
|
|
4793
5292
|
value: (function () {
|
|
4794
|
-
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5293
|
+
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
|
|
4795
5294
|
var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3, _params$bookings3, _params$relation_prod3, _params$payments4;
|
|
4796
5295
|
var onlineStorePaymentCodeList, _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, _orderData$bookings2, _orderData$relation_p2, _orderData$payments4, _orderData$payments5, _response$data, orderData, response;
|
|
4797
|
-
return _regeneratorRuntime().wrap(function
|
|
4798
|
-
while (1) switch (
|
|
5296
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context39) {
|
|
5297
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
4799
5298
|
case 0:
|
|
4800
5299
|
// 过滤掉由在线店铺下单的 payment 支付数据
|
|
4801
5300
|
onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
|
|
@@ -4829,7 +5328,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4829
5328
|
relationProductsCount: ((_params$relation_prod3 = params.relation_products) === null || _params$relation_prod3 === void 0 ? void 0 : _params$relation_prod3.length) || 0,
|
|
4830
5329
|
paymentsCount: ((_params$payments4 = params.payments) === null || _params$payments4 === void 0 ? void 0 : _params$payments4.length) || 0
|
|
4831
5330
|
});
|
|
4832
|
-
|
|
5331
|
+
_context39.prev = 4;
|
|
4833
5332
|
// 构建订单数据,设置默认值并允许 params 覆盖
|
|
4834
5333
|
orderData = _objectSpread({
|
|
4835
5334
|
sales_channel: 'my_pisel',
|
|
@@ -4891,13 +5390,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4891
5390
|
hasOrderId: !!orderData.order_id,
|
|
4892
5391
|
smallTicketDataFlag: orderData.small_ticket_data_flag
|
|
4893
5392
|
});
|
|
4894
|
-
|
|
5393
|
+
_context39.next = 12;
|
|
4895
5394
|
return this.request.post('/order/checkout', orderData, {
|
|
4896
5395
|
osServer: true,
|
|
4897
5396
|
customToast: function customToast() {}
|
|
4898
5397
|
});
|
|
4899
5398
|
case 12:
|
|
4900
|
-
response =
|
|
5399
|
+
response = _context39.sent;
|
|
4901
5400
|
this.logInfo('Order API called successfully', {
|
|
4902
5401
|
response: response
|
|
4903
5402
|
});
|
|
@@ -4905,22 +5404,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4905
5404
|
success: !!response,
|
|
4906
5405
|
hasOrderId: !!(response !== null && response !== void 0 && (_response$data = response.data) !== null && _response$data !== void 0 && _response$data.order_id || response !== null && response !== void 0 && response.order_id)
|
|
4907
5406
|
});
|
|
4908
|
-
return
|
|
5407
|
+
return _context39.abrupt("return", response);
|
|
4909
5408
|
case 18:
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
console.error('[Order] createOrderByCheckout 创建订单失败:',
|
|
5409
|
+
_context39.prev = 18;
|
|
5410
|
+
_context39.t0 = _context39["catch"](4);
|
|
5411
|
+
console.error('[Order] createOrderByCheckout 创建订单失败:', _context39.t0);
|
|
4913
5412
|
this.logInfo('Order API called failed', {
|
|
4914
|
-
error:
|
|
5413
|
+
error: _context39.t0 instanceof Error ? _context39.t0.message : String(_context39.t0)
|
|
4915
5414
|
});
|
|
4916
|
-
throw
|
|
5415
|
+
throw _context39.t0;
|
|
4917
5416
|
case 23:
|
|
4918
5417
|
case "end":
|
|
4919
|
-
return
|
|
5418
|
+
return _context39.stop();
|
|
4920
5419
|
}
|
|
4921
|
-
},
|
|
5420
|
+
}, _callee36, this, [[4, 18]]);
|
|
4922
5421
|
}));
|
|
4923
|
-
function createOrderByCheckout(
|
|
5422
|
+
function createOrderByCheckout(_x41) {
|
|
4924
5423
|
return _createOrderByCheckout.apply(this, arguments);
|
|
4925
5424
|
}
|
|
4926
5425
|
return createOrderByCheckout;
|
|
@@ -4928,24 +5427,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4928
5427
|
}, {
|
|
4929
5428
|
key: "submitSalesOrder",
|
|
4930
5429
|
value: function () {
|
|
4931
|
-
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5430
|
+
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
|
|
4932
5431
|
var url, query, fetchUrl;
|
|
4933
|
-
return _regeneratorRuntime().wrap(function
|
|
4934
|
-
while (1) switch (
|
|
5432
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context40) {
|
|
5433
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
4935
5434
|
case 0:
|
|
4936
5435
|
url = params.url, query = params.query;
|
|
4937
5436
|
fetchUrl = url || '/order/sales/checkout';
|
|
4938
|
-
return
|
|
5437
|
+
return _context40.abrupt("return", this.request.post(fetchUrl, query, {
|
|
4939
5438
|
osServer: true,
|
|
4940
5439
|
customToast: function customToast() {}
|
|
4941
5440
|
}));
|
|
4942
5441
|
case 3:
|
|
4943
5442
|
case "end":
|
|
4944
|
-
return
|
|
5443
|
+
return _context40.stop();
|
|
4945
5444
|
}
|
|
4946
|
-
},
|
|
5445
|
+
}, _callee37, this);
|
|
4947
5446
|
}));
|
|
4948
|
-
function submitSalesOrder(
|
|
5447
|
+
function submitSalesOrder(_x42) {
|
|
4949
5448
|
return _submitSalesOrder.apply(this, arguments);
|
|
4950
5449
|
}
|
|
4951
5450
|
return submitSalesOrder;
|
|
@@ -4959,37 +5458,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4959
5458
|
}, {
|
|
4960
5459
|
key: "sendCustomerPayLink",
|
|
4961
5460
|
value: (function () {
|
|
4962
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5461
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
|
|
4963
5462
|
var _params$emails;
|
|
4964
5463
|
var orderIds;
|
|
4965
|
-
return _regeneratorRuntime().wrap(function
|
|
4966
|
-
while (1) switch (
|
|
5464
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context41) {
|
|
5465
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
4967
5466
|
case 0:
|
|
4968
5467
|
orderIds = params.order_ids || params.orderIds || [];
|
|
4969
5468
|
if (orderIds.length) {
|
|
4970
|
-
|
|
5469
|
+
_context41.next = 3;
|
|
4971
5470
|
break;
|
|
4972
5471
|
}
|
|
4973
5472
|
throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
|
|
4974
5473
|
case 3:
|
|
4975
5474
|
if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
|
|
4976
|
-
|
|
5475
|
+
_context41.next = 5;
|
|
4977
5476
|
break;
|
|
4978
5477
|
}
|
|
4979
5478
|
throw new Error('发送支付链接需要至少一个邮箱');
|
|
4980
5479
|
case 5:
|
|
4981
|
-
return
|
|
5480
|
+
return _context41.abrupt("return", this.request.post('/order/batch-email', {
|
|
4982
5481
|
order_ids: orderIds,
|
|
4983
5482
|
notify_action: params.notify_action || 'order_payment_reminder',
|
|
4984
5483
|
emails: params.emails
|
|
4985
5484
|
}));
|
|
4986
5485
|
case 6:
|
|
4987
5486
|
case "end":
|
|
4988
|
-
return
|
|
5487
|
+
return _context41.stop();
|
|
4989
5488
|
}
|
|
4990
|
-
},
|
|
5489
|
+
}, _callee38, this);
|
|
4991
5490
|
}));
|
|
4992
|
-
function sendCustomerPayLink(
|
|
5491
|
+
function sendCustomerPayLink(_x43) {
|
|
4993
5492
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
4994
5493
|
}
|
|
4995
5494
|
return sendCustomerPayLink;
|
|
@@ -4997,14 +5496,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4997
5496
|
}, {
|
|
4998
5497
|
key: "getSalesOrderByLookup",
|
|
4999
5498
|
value: function () {
|
|
5000
|
-
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5499
|
+
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
|
|
5001
5500
|
var lookup, res;
|
|
5002
|
-
return _regeneratorRuntime().wrap(function
|
|
5003
|
-
while (1) switch (
|
|
5501
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context42) {
|
|
5502
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
5004
5503
|
case 0:
|
|
5005
5504
|
lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
|
|
5006
5505
|
if (lookup) {
|
|
5007
|
-
|
|
5506
|
+
_context42.next = 3;
|
|
5008
5507
|
break;
|
|
5009
5508
|
}
|
|
5010
5509
|
throw new Error('加载销售详情需要 lookup');
|
|
@@ -5013,7 +5512,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5013
5512
|
if (lookup.startsWith('LOCAL_')) {
|
|
5014
5513
|
params.forceRemote = false;
|
|
5015
5514
|
}
|
|
5016
|
-
|
|
5515
|
+
_context42.next = 6;
|
|
5017
5516
|
return this.request.get("/order/sales/".concat(encodeURIComponent(lookup)), _objectSpread({
|
|
5018
5517
|
with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info']
|
|
5019
5518
|
}, params.forceRemote ? {
|
|
@@ -5022,18 +5521,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5022
5521
|
osServer: true
|
|
5023
5522
|
});
|
|
5024
5523
|
case 6:
|
|
5025
|
-
res =
|
|
5524
|
+
res = _context42.sent;
|
|
5026
5525
|
if (res.code === 200) {
|
|
5027
5526
|
this.store.lastOrderInfo = res.data;
|
|
5028
5527
|
}
|
|
5029
|
-
return
|
|
5528
|
+
return _context42.abrupt("return", res);
|
|
5030
5529
|
case 9:
|
|
5031
5530
|
case "end":
|
|
5032
|
-
return
|
|
5531
|
+
return _context42.stop();
|
|
5033
5532
|
}
|
|
5034
|
-
},
|
|
5533
|
+
}, _callee39, this);
|
|
5035
5534
|
}));
|
|
5036
|
-
function getSalesOrderByLookup(
|
|
5535
|
+
function getSalesOrderByLookup(_x44) {
|
|
5037
5536
|
return _getSalesOrderByLookup.apply(this, arguments);
|
|
5038
5537
|
}
|
|
5039
5538
|
return getSalesOrderByLookup;
|
|
@@ -5047,14 +5546,36 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5047
5546
|
}, {
|
|
5048
5547
|
key: "hydrateTempOrderFromRecord",
|
|
5049
5548
|
value: (function () {
|
|
5050
|
-
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5051
|
-
var _this$store$
|
|
5052
|
-
var raw, nextTempOrder, rawSummary, summarySurcharges, hydratedEditDiscounts, currentDiscounts, shouldSkipEmptyDiscountSync, _this$store$
|
|
5053
|
-
return _regeneratorRuntime().wrap(function
|
|
5054
|
-
while (1) switch (
|
|
5549
|
+
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(record, options) {
|
|
5550
|
+
var _this$store$discount19;
|
|
5551
|
+
var sourceRaw, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, nextTempOrder, rawSummary, summarySurcharges, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount20, _this$store$discount21;
|
|
5552
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context43) {
|
|
5553
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
5055
5554
|
case 0:
|
|
5056
|
-
|
|
5057
|
-
|
|
5555
|
+
sourceRaw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
|
|
5556
|
+
identityReadySource = this.seedAnonymousBookingUidsFromProducts(sourceRaw);
|
|
5557
|
+
normalizedCollections = normalizeOrderCollections(identityReadySource);
|
|
5558
|
+
raw = normalizedCollections.order;
|
|
5559
|
+
hasIdentityChanges = Object.values(normalizedCollections.stats).some(function (stats) {
|
|
5560
|
+
return stats.backfilledUidCount > 0 || stats.collapsedDuplicateCount > 0 || stats.uidConflictCount > 0 || stats.anonymousRowCount > 0;
|
|
5561
|
+
});
|
|
5562
|
+
if (hasIdentityChanges) {
|
|
5563
|
+
identityLogMetadata = {
|
|
5564
|
+
collections: normalizedCollections.stats,
|
|
5565
|
+
uidRemapCount: normalizedCollections.uidRemaps.length
|
|
5566
|
+
};
|
|
5567
|
+
hasIdentityWarnings = Object.values(normalizedCollections.stats).some(function (stats) {
|
|
5568
|
+
return stats.uidConflictCount > 0 || stats.anonymousRowCount > 0;
|
|
5569
|
+
});
|
|
5570
|
+
if (hasIdentityWarnings) {
|
|
5571
|
+
this.logWarning('Normalized hydrated order collection identities', identityLogMetadata);
|
|
5572
|
+
} else {
|
|
5573
|
+
this.logInfo('Normalized hydrated order collection identities', identityLogMetadata);
|
|
5574
|
+
}
|
|
5575
|
+
}
|
|
5576
|
+
nextTempOrder = this.normalizeTempOrderForRuntime(raw, {
|
|
5577
|
+
makeEditMark: true
|
|
5578
|
+
});
|
|
5058
5579
|
rawSummary = raw.summary && _typeof(raw.summary) === 'object' ? raw.summary : {};
|
|
5059
5580
|
summarySurcharges = Array.isArray(rawSummary.surcharges) ? rawSummary.surcharges.map(function (s) {
|
|
5060
5581
|
return _objectSpread({}, s || {});
|
|
@@ -5067,43 +5588,59 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5067
5588
|
originalSalesSnapshot: {
|
|
5068
5589
|
summary: cloneDeep(this.store.summary),
|
|
5069
5590
|
products: cloneDeep(nextTempOrder.products || []),
|
|
5591
|
+
bookings: cloneDeep(nextTempOrder.bookings || []),
|
|
5070
5592
|
payments: cloneDeep(nextTempOrder.payments || []),
|
|
5071
5593
|
surcharges: cloneDeep(nextTempOrder.surcharges || []),
|
|
5594
|
+
shop_discount: nextTempOrder.shop_discount || '0.00',
|
|
5072
5595
|
productFingerprint: this.buildOrderProductsFingerprint(nextTempOrder.products || [])
|
|
5073
5596
|
}
|
|
5074
5597
|
});
|
|
5075
|
-
|
|
5598
|
+
// lastOrderInfo carries the exact backend snapshot used by deposit/type recovery.
|
|
5599
|
+
// Runtime collection repair lives in tempOrder/originalSalesSnapshot and must not
|
|
5600
|
+
// rewrite this protocol snapshot as a side effect of hydration.
|
|
5601
|
+
this.store.lastOrderInfo = sourceRaw.lastOrderInfo || sourceRaw;
|
|
5076
5602
|
hydratedEditDiscounts = this.collectHydratedEditDiscounts(nextTempOrder.products);
|
|
5077
|
-
currentDiscounts = typeof ((_this$store$
|
|
5078
|
-
|
|
5603
|
+
currentDiscounts = typeof ((_this$store$discount19 = this.store.discount) === null || _this$store$discount19 === void 0 ? void 0 : _this$store$discount19.getDiscountList) === 'function' ? this.store.discount.getDiscountList() || [] : [];
|
|
5604
|
+
currentScanDiscounts = currentDiscounts.filter(function (discount) {
|
|
5605
|
+
return discount === null || discount === void 0 ? void 0 : discount.isScan;
|
|
5606
|
+
});
|
|
5607
|
+
hydratedDiscountIds = new Set(hydratedEditDiscounts.map(function (discount) {
|
|
5608
|
+
return discount === null || discount === void 0 ? void 0 : discount.id;
|
|
5609
|
+
}));
|
|
5610
|
+
retainedScanDiscounts = currentScanDiscounts.filter(function (discount) {
|
|
5611
|
+
return !hydratedDiscountIds.has(discount === null || discount === void 0 ? void 0 : discount.id);
|
|
5612
|
+
});
|
|
5613
|
+
nextDiscounts = [].concat(_toConsumableArray(hydratedEditDiscounts), _toConsumableArray(retainedScanDiscounts));
|
|
5614
|
+
shouldSkipEmptyDiscountSync = nextDiscounts.length === 0 && currentDiscounts.length === 0;
|
|
5079
5615
|
if (shouldSkipEmptyDiscountSync) {
|
|
5080
|
-
|
|
5616
|
+
_context43.next = 26;
|
|
5081
5617
|
break;
|
|
5082
5618
|
}
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5619
|
+
OrderModule.populateSavedAmounts(nextTempOrder.products, nextDiscounts);
|
|
5620
|
+
_context43.next = 24;
|
|
5621
|
+
return (_this$store$discount20 = this.store.discount) === null || _this$store$discount20 === void 0 ? void 0 : _this$store$discount20.setOriginalDiscountList(nextDiscounts);
|
|
5622
|
+
case 24:
|
|
5623
|
+
_context43.next = 26;
|
|
5624
|
+
return (_this$store$discount21 = this.store.discount) === null || _this$store$discount21 === void 0 ? void 0 : _this$store$discount21.setDiscountList(nextDiscounts);
|
|
5625
|
+
case 26:
|
|
5089
5626
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
5090
|
-
|
|
5627
|
+
_context43.next = 29;
|
|
5091
5628
|
break;
|
|
5092
5629
|
}
|
|
5093
|
-
|
|
5630
|
+
_context43.next = 29;
|
|
5094
5631
|
return this.recalculateSummary({
|
|
5095
5632
|
createIfMissing: false
|
|
5096
5633
|
});
|
|
5097
|
-
case
|
|
5634
|
+
case 29:
|
|
5098
5635
|
this.persistTempOrder();
|
|
5099
|
-
return
|
|
5100
|
-
case
|
|
5636
|
+
return _context43.abrupt("return", nextTempOrder);
|
|
5637
|
+
case 31:
|
|
5101
5638
|
case "end":
|
|
5102
|
-
return
|
|
5639
|
+
return _context43.stop();
|
|
5103
5640
|
}
|
|
5104
|
-
},
|
|
5641
|
+
}, _callee40, this);
|
|
5105
5642
|
}));
|
|
5106
|
-
function hydrateTempOrderFromRecord(
|
|
5643
|
+
function hydrateTempOrderFromRecord(_x45, _x46) {
|
|
5107
5644
|
return _hydrateTempOrderFromRecord.apply(this, arguments);
|
|
5108
5645
|
}
|
|
5109
5646
|
return hydrateTempOrderFromRecord;
|
|
@@ -5141,10 +5678,83 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5141
5678
|
}
|
|
5142
5679
|
return next;
|
|
5143
5680
|
}
|
|
5681
|
+
|
|
5682
|
+
/**
|
|
5683
|
+
* 匿名 booking 没有服务端行 ID 时,商品侧已有的 booking_uid 就是唯一可用的强引用。
|
|
5684
|
+
* 在统一规范化生成 UUID 前先复用它;已落库 booking 仍按 schedule_event_id 派生稳定 UID。
|
|
5685
|
+
*/
|
|
5686
|
+
}, {
|
|
5687
|
+
key: "seedAnonymousBookingUidsFromProducts",
|
|
5688
|
+
value: function seedAnonymousBookingUidsFromProducts(raw) {
|
|
5689
|
+
if (!raw || _typeof(raw) !== 'object') return {};
|
|
5690
|
+
if (!Array.isArray(raw.bookings) || !Array.isArray(raw.products)) return raw;
|
|
5691
|
+
var bookingUidsByProductUid = new Map();
|
|
5692
|
+
var _iterator22 = _createForOfIteratorHelper(raw.products),
|
|
5693
|
+
_step22;
|
|
5694
|
+
try {
|
|
5695
|
+
for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
|
|
5696
|
+
var _product$metadata10;
|
|
5697
|
+
var product = _step22.value;
|
|
5698
|
+
var productUid = getOrderCollectionUid('product', product);
|
|
5699
|
+
var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata10 = product.metadata) === null || _product$metadata10 === void 0 ? void 0 : _product$metadata10.booking_uid);
|
|
5700
|
+
if (!productUid || bookingUid === undefined || bookingUid === null || bookingUid === '') {
|
|
5701
|
+
continue;
|
|
5702
|
+
}
|
|
5703
|
+
var candidates = bookingUidsByProductUid.get(productUid) || new Set();
|
|
5704
|
+
candidates.add(String(bookingUid));
|
|
5705
|
+
bookingUidsByProductUid.set(productUid, candidates);
|
|
5706
|
+
}
|
|
5707
|
+
} catch (err) {
|
|
5708
|
+
_iterator22.e(err);
|
|
5709
|
+
} finally {
|
|
5710
|
+
_iterator22.f();
|
|
5711
|
+
}
|
|
5712
|
+
if (bookingUidsByProductUid.size === 0) return raw;
|
|
5713
|
+
var anonymousBookingCountByProductUid = new Map();
|
|
5714
|
+
var _iterator23 = _createForOfIteratorHelper(raw.bookings),
|
|
5715
|
+
_step23;
|
|
5716
|
+
try {
|
|
5717
|
+
for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {
|
|
5718
|
+
var _booking$metadata7;
|
|
5719
|
+
var booking = _step23.value;
|
|
5720
|
+
if (getOrderCollectionPersistentId('booking', booking) || getOrderCollectionUid('booking', booking)) {
|
|
5721
|
+
continue;
|
|
5722
|
+
}
|
|
5723
|
+
var _productUid = (booking === null || booking === void 0 ? void 0 : booking.product_uid) || (booking === null || booking === void 0 || (_booking$metadata7 = booking.metadata) === null || _booking$metadata7 === void 0 ? void 0 : _booking$metadata7.product_uid);
|
|
5724
|
+
if (_productUid === undefined || _productUid === null || _productUid === '') continue;
|
|
5725
|
+
var key = String(_productUid);
|
|
5726
|
+
anonymousBookingCountByProductUid.set(key, (anonymousBookingCountByProductUid.get(key) || 0) + 1);
|
|
5727
|
+
}
|
|
5728
|
+
} catch (err) {
|
|
5729
|
+
_iterator23.e(err);
|
|
5730
|
+
} finally {
|
|
5731
|
+
_iterator23.f();
|
|
5732
|
+
}
|
|
5733
|
+
return _objectSpread(_objectSpread({}, raw), {}, {
|
|
5734
|
+
bookings: raw.bookings.map(function (booking) {
|
|
5735
|
+
var _booking$metadata6;
|
|
5736
|
+
if (getOrderCollectionPersistentId('booking', booking) || getOrderCollectionUid('booking', booking)) {
|
|
5737
|
+
return booking;
|
|
5738
|
+
}
|
|
5739
|
+
var productUid = (booking === null || booking === void 0 ? void 0 : booking.product_uid) || (booking === null || booking === void 0 || (_booking$metadata6 = booking.metadata) === null || _booking$metadata6 === void 0 ? void 0 : _booking$metadata6.product_uid);
|
|
5740
|
+
if (productUid === undefined || productUid === null || productUid === '') {
|
|
5741
|
+
return booking;
|
|
5742
|
+
}
|
|
5743
|
+
var productUidKey = String(productUid);
|
|
5744
|
+
// 多条匿名 booking 共用同一商品引用时身份仍然不明确,不能借商品字段猜测合并。
|
|
5745
|
+
if (anonymousBookingCountByProductUid.get(productUidKey) !== 1) {
|
|
5746
|
+
return booking;
|
|
5747
|
+
}
|
|
5748
|
+
var bookingUidCandidates = bookingUidsByProductUid.get(productUidKey);
|
|
5749
|
+
var bookingUid = (bookingUidCandidates === null || bookingUidCandidates === void 0 ? void 0 : bookingUidCandidates.size) === 1 ? _toConsumableArray(bookingUidCandidates)[0] : null;
|
|
5750
|
+
return bookingUid ? setOrderCollectionUid('booking', booking, bookingUid) : booking;
|
|
5751
|
+
})
|
|
5752
|
+
});
|
|
5753
|
+
}
|
|
5144
5754
|
}, {
|
|
5145
5755
|
key: "normalizeTempOrderForRuntime",
|
|
5146
5756
|
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
5147
|
-
var
|
|
5757
|
+
var _this28 = this;
|
|
5148
5758
|
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), raw || {});
|
|
5149
5759
|
// ES 列表详情使用 id 表示订单主键;OS 详情态统一依赖 order_id 驱动操作按钮。
|
|
5150
5760
|
if ((nextTempOrder.order_id === undefined || nextTempOrder.order_id === null) && (raw === null || raw === void 0 ? void 0 : raw.id) !== undefined && (raw === null || raw === void 0 ? void 0 : raw.id) !== null) {
|
|
@@ -5167,10 +5777,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5167
5777
|
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
5168
5778
|
var rawProducts = Array.isArray(raw.products) ? raw.products : [];
|
|
5169
5779
|
nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
|
|
5170
|
-
return
|
|
5780
|
+
return _this28.normalizeHydratedOrderProduct(p, {
|
|
5781
|
+
makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
|
|
5782
|
+
});
|
|
5171
5783
|
}) : [];
|
|
5172
5784
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
5173
|
-
var booking =
|
|
5785
|
+
var booking = _this28.normalizeHydratedBookingHolder(b || {});
|
|
5174
5786
|
return _objectSpread(_objectSpread({}, booking), {}, {
|
|
5175
5787
|
is_all: normalizeBookingIsAll(booking),
|
|
5176
5788
|
sub_type: normalizeBookingSubType(booking)
|
|
@@ -5196,19 +5808,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5196
5808
|
};
|
|
5197
5809
|
var tempOrderExtend = nextTempOrder._extend;
|
|
5198
5810
|
var productsByUid = tempOrderExtend.productsByUid || {};
|
|
5199
|
-
var
|
|
5200
|
-
|
|
5811
|
+
var _iterator24 = _createForOfIteratorHelper(nextTempOrder.products.entries()),
|
|
5812
|
+
_step24;
|
|
5201
5813
|
try {
|
|
5202
|
-
for (
|
|
5203
|
-
var _product$
|
|
5204
|
-
var
|
|
5205
|
-
index =
|
|
5206
|
-
product =
|
|
5207
|
-
var uid = (_product$
|
|
5814
|
+
for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
|
|
5815
|
+
var _product$metadata11, _ref76, _ref77, _existed$origin, _rawProduct$metadata;
|
|
5816
|
+
var _step24$value = _slicedToArray(_step24.value, 2),
|
|
5817
|
+
index = _step24$value[0],
|
|
5818
|
+
product = _step24$value[1];
|
|
5819
|
+
var uid = (_product$metadata11 = product.metadata) === null || _product$metadata11 === void 0 ? void 0 : _product$metadata11.unique_identification_number;
|
|
5208
5820
|
if (!uid) continue;
|
|
5209
5821
|
var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
|
|
5210
5822
|
var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
|
|
5211
|
-
var origin = (
|
|
5823
|
+
var origin = (_ref76 = (_ref77 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref77 !== void 0 ? _ref77 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref76 !== void 0 ? _ref76 : rawProduct;
|
|
5212
5824
|
var originSnapshot = cloneDeep(origin);
|
|
5213
5825
|
var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
|
|
5214
5826
|
if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
|
|
@@ -5224,9 +5836,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5224
5836
|
});
|
|
5225
5837
|
}
|
|
5226
5838
|
} catch (err) {
|
|
5227
|
-
|
|
5839
|
+
_iterator24.e(err);
|
|
5228
5840
|
} finally {
|
|
5229
|
-
|
|
5841
|
+
_iterator24.f();
|
|
5230
5842
|
}
|
|
5231
5843
|
tempOrderExtend.productsByUid = productsByUid;
|
|
5232
5844
|
this.hydrateLinkedBookingIdentity(nextTempOrder);
|
|
@@ -5242,8 +5854,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5242
5854
|
var bookingUidByProductUid = new Map();
|
|
5243
5855
|
var productByUid = new Map();
|
|
5244
5856
|
(tempOrder.products || []).forEach(function (product) {
|
|
5245
|
-
var _product$
|
|
5246
|
-
var productUid = (product === null || product === void 0 || (_product$
|
|
5857
|
+
var _product$metadata12;
|
|
5858
|
+
var productUid = (product === null || product === void 0 || (_product$metadata12 = product.metadata) === null || _product$metadata12 === void 0 ? void 0 : _product$metadata12.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
5247
5859
|
if (productUid !== undefined && productUid !== null && String(productUid) !== '') {
|
|
5248
5860
|
productByUid.set(String(productUid), product);
|
|
5249
5861
|
}
|
|
@@ -5264,18 +5876,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5264
5876
|
bookingUidByProductUid.set(String(productUid), bookingUid);
|
|
5265
5877
|
});
|
|
5266
5878
|
(tempOrder.products || []).forEach(function (product) {
|
|
5267
|
-
var _product$
|
|
5268
|
-
var productUid = (product === null || product === void 0 || (_product$
|
|
5879
|
+
var _product$metadata13;
|
|
5880
|
+
var productUid = (product === null || product === void 0 || (_product$metadata13 = product.metadata) === null || _product$metadata13 === void 0 ? void 0 : _product$metadata13.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
5269
5881
|
if (productUid === undefined || productUid === null || String(productUid) === '') return;
|
|
5270
5882
|
var bookingUid = bookingUidByProductUid.get(String(productUid));
|
|
5271
5883
|
if (!bookingUid) return;
|
|
5272
5884
|
if (!product.metadata || _typeof(product.metadata) !== 'object') {
|
|
5273
5885
|
product.metadata = {};
|
|
5274
5886
|
}
|
|
5275
|
-
|
|
5887
|
+
// booking 已经过统一身份规范化;以它为准同步商品侧旧引用,避免两侧 UID 断链。
|
|
5888
|
+
var linkedBookingUid = String(bookingUid);
|
|
5276
5889
|
product.booking_uid = linkedBookingUid;
|
|
5277
5890
|
product.metadata.booking_uid = linkedBookingUid;
|
|
5278
5891
|
});
|
|
5892
|
+
this.syncLinkedBookingHoldersToProducts(tempOrder);
|
|
5279
5893
|
}
|
|
5280
5894
|
}, {
|
|
5281
5895
|
key: "pickHydratedDisplayText",
|
|
@@ -5299,18 +5913,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5299
5913
|
var segments = [];
|
|
5300
5914
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
5301
5915
|
if (Array.isArray(sku.variant)) {
|
|
5302
|
-
var
|
|
5303
|
-
|
|
5916
|
+
var _iterator25 = _createForOfIteratorHelper(sku.variant),
|
|
5917
|
+
_step25;
|
|
5304
5918
|
try {
|
|
5305
|
-
for (
|
|
5306
|
-
var variant =
|
|
5919
|
+
for (_iterator25.s(); !(_step25 = _iterator25.n()).done;) {
|
|
5920
|
+
var variant = _step25.value;
|
|
5307
5921
|
var segment = this.formatHydratedNamePair(variant === null || variant === void 0 ? void 0 : variant.group, variant === null || variant === void 0 ? void 0 : variant.item);
|
|
5308
5922
|
if (segment) segments.push(segment);
|
|
5309
5923
|
}
|
|
5310
5924
|
} catch (err) {
|
|
5311
|
-
|
|
5925
|
+
_iterator25.e(err);
|
|
5312
5926
|
} finally {
|
|
5313
|
-
|
|
5927
|
+
_iterator25.f();
|
|
5314
5928
|
}
|
|
5315
5929
|
}
|
|
5316
5930
|
return segments.join(', ');
|
|
@@ -5318,10 +5932,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5318
5932
|
}, {
|
|
5319
5933
|
key: "normalizeHydratedProductOptionItem",
|
|
5320
5934
|
value: function normalizeHydratedProductOptionItem(optionItem) {
|
|
5321
|
-
var
|
|
5322
|
-
var rawNum = (
|
|
5935
|
+
var _ref78, _optionItem$num, _ref79, _optionItem$add_price;
|
|
5936
|
+
var rawNum = (_ref78 = (_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 && _ref78 !== void 0 ? _ref78 : 1;
|
|
5323
5937
|
var parsedNum = Number(rawNum);
|
|
5324
|
-
var rawPrice = (
|
|
5938
|
+
var rawPrice = (_ref79 = (_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 && _ref79 !== void 0 ? _ref79 : 0;
|
|
5325
5939
|
var parsedPrice = Number(rawPrice);
|
|
5326
5940
|
var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
|
|
5327
5941
|
option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
|
|
@@ -5337,8 +5951,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5337
5951
|
}
|
|
5338
5952
|
}, {
|
|
5339
5953
|
key: "normalizeHydratedOrderProduct",
|
|
5340
|
-
value: function normalizeHydratedOrderProduct(product) {
|
|
5341
|
-
var
|
|
5954
|
+
value: function normalizeHydratedOrderProduct(product, options) {
|
|
5955
|
+
var _this29 = this;
|
|
5342
5956
|
var row = _objectSpread({}, product || {});
|
|
5343
5957
|
if (row.num === undefined && row.product_quantity !== undefined) {
|
|
5344
5958
|
row.num = row.product_quantity;
|
|
@@ -5346,7 +5960,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5346
5960
|
var productSku = ensureProductSku(row);
|
|
5347
5961
|
row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
|
|
5348
5962
|
option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
|
|
5349
|
-
return
|
|
5963
|
+
return _this29.normalizeHydratedProductOptionItem(optionItem || {});
|
|
5350
5964
|
}))
|
|
5351
5965
|
});
|
|
5352
5966
|
delete row["product_".concat('option', "_item")];
|
|
@@ -5355,10 +5969,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5355
5969
|
if (row.booking_uid && !row.metadata.booking_uid) {
|
|
5356
5970
|
row.metadata.booking_uid = row.booking_uid;
|
|
5357
5971
|
}
|
|
5972
|
+
row = restoreHydratedBundleDiscounts(row, normalizeOrderProductDiscountList);
|
|
5358
5973
|
var existingIdentity = row.metadata.unique_identification_number || row.unique_identification_number;
|
|
5359
5974
|
if (!existingIdentity) {
|
|
5360
5975
|
row.metadata.unique_identification_number = createUuidV4();
|
|
5361
5976
|
}
|
|
5977
|
+
// 从云端、本地数据库中获取到的商品数据,先打上 runtime 标记,提供给 UI 做 saved items.
|
|
5978
|
+
if (options !== null && options !== void 0 && options.makeEditMark) {
|
|
5979
|
+
row.metadata.is_edit_for_runtime = true;
|
|
5980
|
+
}
|
|
5362
5981
|
var normalized = normalizeOrderProduct(row);
|
|
5363
5982
|
normalized.discount_list = normalizeOrderProductDiscountList(normalized.discount_list);
|
|
5364
5983
|
var result = _objectSpread(_objectSpread(_objectSpread({}, row), normalized), {}, {
|
|
@@ -5366,7 +5985,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5366
5985
|
metadata: _objectSpread(_objectSpread({}, row.metadata), normalized.metadata)
|
|
5367
5986
|
});
|
|
5368
5987
|
if (result.metadata) delete result.metadata.price_schema_version;
|
|
5369
|
-
|
|
5988
|
+
var restored = restoreHydratedBundleDiscounts(result, normalizeOrderProductDiscountList);
|
|
5989
|
+
return this.sanitizeOrderProductForTempOrder(restored);
|
|
5370
5990
|
}
|
|
5371
5991
|
}, {
|
|
5372
5992
|
key: "getLastOrderInfo",
|
|
@@ -5377,31 +5997,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5377
5997
|
}, {
|
|
5378
5998
|
key: "getOrderInfo",
|
|
5379
5999
|
value: function () {
|
|
5380
|
-
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6000
|
+
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(order_id) {
|
|
5381
6001
|
var res;
|
|
5382
|
-
return _regeneratorRuntime().wrap(function
|
|
5383
|
-
while (1) switch (
|
|
6002
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context44) {
|
|
6003
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
5384
6004
|
case 0:
|
|
5385
|
-
|
|
6005
|
+
_context44.next = 2;
|
|
5386
6006
|
return this.request.get("/order/sales/".concat(order_id), {
|
|
5387
6007
|
with: ['products', 'bookings']
|
|
5388
6008
|
}, {
|
|
5389
6009
|
osServer: true
|
|
5390
6010
|
});
|
|
5391
6011
|
case 2:
|
|
5392
|
-
res =
|
|
5393
|
-
return
|
|
6012
|
+
res = _context44.sent;
|
|
6013
|
+
return _context44.abrupt("return", res);
|
|
5394
6014
|
case 4:
|
|
5395
6015
|
case "end":
|
|
5396
|
-
return
|
|
6016
|
+
return _context44.stop();
|
|
5397
6017
|
}
|
|
5398
|
-
},
|
|
6018
|
+
}, _callee41, this);
|
|
5399
6019
|
}));
|
|
5400
|
-
function getOrderInfo(
|
|
6020
|
+
function getOrderInfo(_x47) {
|
|
5401
6021
|
return _getOrderInfo.apply(this, arguments);
|
|
5402
6022
|
}
|
|
5403
6023
|
return getOrderInfo;
|
|
5404
6024
|
}()
|
|
6025
|
+
}, {
|
|
6026
|
+
key: "getVouchers",
|
|
6027
|
+
value: function getVouchers() {
|
|
6028
|
+
var _this$store$tempOrder5;
|
|
6029
|
+
return ((_this$store$tempOrder5 = this.store.tempOrder) === null || _this$store$tempOrder5 === void 0 ? void 0 : _this$store$tempOrder5.vouchers) || [];
|
|
6030
|
+
}
|
|
5405
6031
|
}], [{
|
|
5406
6032
|
key: "populateSavedAmounts",
|
|
5407
6033
|
value: function populateSavedAmounts(productList, discountList) {
|
|
@@ -5427,70 +6053,70 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5427
6053
|
addDiscountAmount(savedMap, discountKey, amount);
|
|
5428
6054
|
addDiscountAmount(isPersistedProduct || discount.order_discount_id != null ? editModeSavedMap : runtimeSavedMap, discountKey, amount);
|
|
5429
6055
|
};
|
|
5430
|
-
var
|
|
5431
|
-
|
|
6056
|
+
var _iterator26 = _createForOfIteratorHelper(productList),
|
|
6057
|
+
_step26;
|
|
5432
6058
|
try {
|
|
5433
|
-
for (
|
|
5434
|
-
var product =
|
|
6059
|
+
for (_iterator26.s(); !(_step26 = _iterator26.n()).done;) {
|
|
6060
|
+
var product = _step26.value;
|
|
5435
6061
|
var qty = product.num || 1;
|
|
5436
6062
|
var isPersistedProduct = Boolean(product.order_detail_id || product.orderDetailId || product.booking_id);
|
|
5437
|
-
var
|
|
5438
|
-
|
|
6063
|
+
var _iterator28 = _createForOfIteratorHelper(product.discount_list || []),
|
|
6064
|
+
_step28;
|
|
5439
6065
|
try {
|
|
5440
|
-
for (
|
|
5441
|
-
var pd =
|
|
6066
|
+
for (_iterator28.s(); !(_step28 = _iterator28.n()).done;) {
|
|
6067
|
+
var pd = _step28.value;
|
|
5442
6068
|
addProductDiscountAmount(pd, qty, isPersistedProduct);
|
|
5443
6069
|
}
|
|
5444
6070
|
} catch (err) {
|
|
5445
|
-
|
|
6071
|
+
_iterator28.e(err);
|
|
5446
6072
|
} finally {
|
|
5447
|
-
|
|
6073
|
+
_iterator28.f();
|
|
5448
6074
|
}
|
|
5449
|
-
var
|
|
5450
|
-
|
|
6075
|
+
var _iterator29 = _createForOfIteratorHelper(product.product_bundle || []),
|
|
6076
|
+
_step29;
|
|
5451
6077
|
try {
|
|
5452
|
-
for (
|
|
5453
|
-
var
|
|
5454
|
-
var bundle =
|
|
6078
|
+
for (_iterator29.s(); !(_step29 = _iterator29.n()).done;) {
|
|
6079
|
+
var _ref80, _bundle$num3;
|
|
6080
|
+
var bundle = _step29.value;
|
|
5455
6081
|
var isPersistedBundleProduct = isPersistedProduct || Boolean((bundle === null || bundle === void 0 ? void 0 : bundle.order_detail_id) || (bundle === null || bundle === void 0 ? void 0 : bundle.orderDetailId) || (bundle === null || bundle === void 0 ? void 0 : bundle.booking_id));
|
|
5456
|
-
var bundleQty = new Decimal(Number(qty) || 1).times(Number((
|
|
5457
|
-
var
|
|
5458
|
-
|
|
6082
|
+
var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref80 = (_bundle$num3 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num3 !== void 0 ? _bundle$num3 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity) !== null && _ref80 !== void 0 ? _ref80 : 1) || 1).toNumber();
|
|
6083
|
+
var _iterator30 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
|
|
6084
|
+
_step30;
|
|
5459
6085
|
try {
|
|
5460
|
-
for (
|
|
5461
|
-
var _pd =
|
|
6086
|
+
for (_iterator30.s(); !(_step30 = _iterator30.n()).done;) {
|
|
6087
|
+
var _pd = _step30.value;
|
|
5462
6088
|
addProductDiscountAmount(_pd, bundleQty, isPersistedBundleProduct);
|
|
5463
6089
|
}
|
|
5464
6090
|
} catch (err) {
|
|
5465
|
-
|
|
6091
|
+
_iterator30.e(err);
|
|
5466
6092
|
} finally {
|
|
5467
|
-
|
|
6093
|
+
_iterator30.f();
|
|
5468
6094
|
}
|
|
5469
6095
|
}
|
|
5470
6096
|
} catch (err) {
|
|
5471
|
-
|
|
6097
|
+
_iterator29.e(err);
|
|
5472
6098
|
} finally {
|
|
5473
|
-
|
|
6099
|
+
_iterator29.f();
|
|
5474
6100
|
}
|
|
5475
6101
|
}
|
|
5476
6102
|
} catch (err) {
|
|
5477
|
-
|
|
6103
|
+
_iterator26.e(err);
|
|
5478
6104
|
} finally {
|
|
5479
|
-
|
|
6105
|
+
_iterator26.f();
|
|
5480
6106
|
}
|
|
5481
|
-
var
|
|
5482
|
-
|
|
6107
|
+
var _iterator27 = _createForOfIteratorHelper(discountList),
|
|
6108
|
+
_step27;
|
|
5483
6109
|
try {
|
|
5484
|
-
for (
|
|
5485
|
-
var d =
|
|
6110
|
+
for (_iterator27.s(); !(_step27 = _iterator27.n()).done;) {
|
|
6111
|
+
var d = _step27.value;
|
|
5486
6112
|
var key = d.id;
|
|
5487
6113
|
var sourceMap = d.isEditMode ? editModeSavedMap : editModeDiscountKeys.has(key) ? runtimeSavedMap : savedMap;
|
|
5488
6114
|
d.savedAmount = d.isSelected && key != null && sourceMap.has(key) ? sourceMap.get(key).toNumber() : 0;
|
|
5489
6115
|
}
|
|
5490
6116
|
} catch (err) {
|
|
5491
|
-
|
|
6117
|
+
_iterator27.e(err);
|
|
5492
6118
|
} finally {
|
|
5493
|
-
|
|
6119
|
+
_iterator27.f();
|
|
5494
6120
|
}
|
|
5495
6121
|
}
|
|
5496
6122
|
}]);
|