@pisell/pisellos 2.2.262 → 2.2.264
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/index.d.ts +0 -4
- package/dist/model/strategy/adapter/index.js +1 -5
- package/dist/model/strategy/adapter/promotion/adapter.d.ts +4 -0
- package/dist/model/strategy/adapter/promotion/adapter.js +23 -0
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
- package/dist/model/strategy/adapter/promotion/evaluator.js +279 -6
- package/dist/model/strategy/adapter/promotion/examples.d.ts +86 -0
- package/dist/model/strategy/adapter/promotion/examples.js +99 -0
- package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/dist/model/strategy/adapter/promotion/type.d.ts +90 -2
- package/dist/model/strategy/adapter/promotion/type.js +45 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +10 -16
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -2
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +1 -32
- package/dist/modules/Discount/index.d.ts +2 -5
- package/dist/modules/Discount/index.js +7 -30
- package/dist/modules/Discount/types.d.ts +0 -4
- package/dist/modules/Order/index.d.ts +2 -14
- package/dist/modules/Order/index.js +736 -1035
- package/dist/modules/Order/types.d.ts +0 -16
- package/dist/modules/Order/utils.d.ts +3 -4
- package/dist/modules/Order/utils.js +61 -54
- package/dist/modules/Product/types.d.ts +0 -22
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +2 -4
- package/dist/modules/ProductList/types.d.ts +0 -2
- package/dist/modules/Rules/index.d.ts +9 -2
- package/dist/modules/Rules/index.js +43 -69
- package/dist/modules/Rules/types.d.ts +1 -10
- package/dist/server/index.d.ts +0 -55
- package/dist/server/index.js +742 -1161
- package/dist/server/modules/order/index.d.ts +4 -10
- package/dist/server/modules/order/index.js +399 -404
- package/dist/server/modules/order/types.d.ts +0 -4
- package/dist/server/modules/products/index.d.ts +8 -31
- package/dist/server/modules/products/index.js +390 -549
- package/dist/server/modules/products/types.d.ts +0 -18
- package/dist/solution/BaseSales/index.d.ts +1 -21
- package/dist/solution/BaseSales/index.js +789 -1136
- package/dist/solution/BaseSales/types.d.ts +1 -6
- package/dist/solution/BaseSales/types.js +1 -1
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/dist/solution/BaseSales/utils/cartPromotion.js +97 -50
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +8 -6
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -14
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +25 -59
- package/dist/solution/BookingTicket/types.d.ts +0 -2
- package/dist/solution/ScanOrder/index.js +31 -20
- package/dist/solution/ShopDiscount/index.js +14 -15
- package/dist/solution/VenueBooking/index.js +30 -19
- package/lib/model/strategy/adapter/index.d.ts +0 -4
- package/lib/model/strategy/adapter/index.js +2 -13
- package/lib/model/strategy/adapter/promotion/adapter.d.ts +4 -0
- package/lib/model/strategy/adapter/promotion/adapter.js +20 -0
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
- package/lib/model/strategy/adapter/promotion/evaluator.js +235 -0
- package/lib/model/strategy/adapter/promotion/examples.d.ts +86 -0
- package/lib/model/strategy/adapter/promotion/examples.js +91 -0
- package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +51 -0
- package/lib/model/strategy/adapter/promotion/type.d.ts +90 -2
- package/lib/model/strategy/adapter/promotion/type.js +2 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -5
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -1
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +2 -23
- package/lib/modules/Discount/index.d.ts +2 -5
- package/lib/modules/Discount/index.js +3 -23
- package/lib/modules/Discount/types.d.ts +0 -4
- package/lib/modules/Order/index.d.ts +2 -14
- package/lib/modules/Order/index.js +60 -326
- package/lib/modules/Order/types.d.ts +0 -16
- package/lib/modules/Order/utils.d.ts +3 -4
- package/lib/modules/Order/utils.js +23 -22
- package/lib/modules/Product/types.d.ts +0 -22
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +2 -4
- package/lib/modules/ProductList/types.d.ts +0 -2
- package/lib/modules/Rules/index.d.ts +9 -2
- package/lib/modules/Rules/index.js +29 -61
- package/lib/modules/Rules/types.d.ts +1 -10
- package/lib/server/index.d.ts +0 -55
- package/lib/server/index.js +31 -327
- package/lib/server/modules/order/index.d.ts +4 -10
- package/lib/server/modules/order/index.js +139 -198
- package/lib/server/modules/order/types.d.ts +0 -4
- package/lib/server/modules/products/index.d.ts +8 -31
- package/lib/server/modules/products/index.js +35 -134
- package/lib/server/modules/products/types.d.ts +0 -18
- package/lib/solution/BaseSales/index.d.ts +1 -21
- package/lib/solution/BaseSales/index.js +72 -313
- package/lib/solution/BaseSales/types.d.ts +1 -6
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/lib/solution/BaseSales/utils/cartPromotion.js +64 -25
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +5 -4
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +0 -8
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +8 -33
- package/lib/solution/BookingTicket/types.d.ts +0 -2
- package/lib/solution/ScanOrder/index.js +8 -0
- package/lib/solution/ShopDiscount/index.js +1 -2
- package/lib/solution/VenueBooking/index.js +8 -0
- package/package.json +1 -1
- package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
- package/dist/model/strategy/adapter/dataVariant/adapter.js +0 -167
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +0 -780
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
- package/dist/model/strategy/adapter/dataVariant/examples.js +0 -277
- package/dist/model/strategy/adapter/dataVariant/index.d.ts +0 -4
- package/dist/model/strategy/adapter/dataVariant/index.js +0 -4
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +0 -148
- package/dist/model/strategy/adapter/dataVariant/type.js +0 -54
- package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +0 -53
- package/dist/modules/Order/utils/orderCollectionIdentity.js +0 -405
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
- package/lib/model/strategy/adapter/dataVariant/adapter.js +0 -149
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +0 -583
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
- package/lib/model/strategy/adapter/dataVariant/examples.js +0 -293
- package/lib/model/strategy/adapter/dataVariant/index.d.ts +0 -4
- package/lib/model/strategy/adapter/dataVariant/index.js +0 -38
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +0 -148
- package/lib/model/strategy/adapter/dataVariant/type.js +0 -31
- package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +0 -53
- package/lib/modules/Order/utils/orderCollectionIdentity.js +0 -415
|
@@ -6,12 +6,12 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
6
6
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
7
7
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
8
8
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
9
|
+
function 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; }
|
|
10
|
+
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; }
|
|
9
11
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
10
12
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
11
13
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
12
14
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
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
|
-
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; } } }; }
|
|
16
16
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
17
17
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
@@ -39,7 +39,6 @@ import { processCartPromotion, appendPromotionTags as _appendPromotionTags, getO
|
|
|
39
39
|
import { buildProductLineFingerprint, getProductIdentityIndex, getSafeProductNum, isIdentityMatch, normalizeOrderProduct } from "../../solution/ScanOrder/utils";
|
|
40
40
|
import { syncManualProductDiscountProductNum } from "./utils/manualProductDiscount";
|
|
41
41
|
import { expandHydratedProductsForDiscountCollection, restoreHydratedBundleDiscounts } from "./utils/bundleDiscountHydration";
|
|
42
|
-
import { getOrderCollectionPersistentId, getOrderCollectionUid, normalizeOrderCollections, setOrderCollectionUid } from "./utils/orderCollectionIdentity";
|
|
43
42
|
import { DiscountModule } from "../Discount";
|
|
44
43
|
import { RulesModule } from "../Rules";
|
|
45
44
|
import { UnavailableReason } from "../Rules/types";
|
|
@@ -159,16 +158,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
159
158
|
};
|
|
160
159
|
var existed = discountMap.get(key);
|
|
161
160
|
if (existed) {
|
|
162
|
-
var _existed$limited_rela;
|
|
163
161
|
existed.amount = Number(existed.amount || 0) + amount;
|
|
164
162
|
existed.used_par_value = String(Number(existed.used_par_value || 0) + amount);
|
|
165
163
|
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
164
|
existed.applicableProductDetails = [].concat(_toConsumableArray(existed.applicableProductDetails || []), [detail]);
|
|
173
165
|
existed.appliedProductDetails = [].concat(_toConsumableArray(existed.appliedProductDetails || []), [detail]);
|
|
174
166
|
continue;
|
|
@@ -296,17 +288,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
296
288
|
if (!this.store.summary) {
|
|
297
289
|
this.store.summary = createEmptySummary();
|
|
298
290
|
}
|
|
299
|
-
if (!Array.isArray(this.store.availableWalletIds)) {
|
|
300
|
-
this.store.availableWalletIds = [];
|
|
301
|
-
}
|
|
302
291
|
this.request = this.core.getPlugin('request');
|
|
303
292
|
appPlugin = this.core.getPlugin('app');
|
|
304
293
|
if (appPlugin) {
|
|
305
|
-
_context.next =
|
|
294
|
+
_context.next = 8;
|
|
306
295
|
break;
|
|
307
296
|
}
|
|
308
297
|
throw new Error('Order 模块需要 app 插件支持');
|
|
309
|
-
case
|
|
298
|
+
case 8:
|
|
310
299
|
app = appPlugin.getApp();
|
|
311
300
|
this.logger = app.logger;
|
|
312
301
|
this.window = this.core.getPlugin('window');
|
|
@@ -319,7 +308,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
319
308
|
this.otherParams = otherParams;
|
|
320
309
|
this.registerDiscountModules(options);
|
|
321
310
|
this.logInfo('OrderModule initialized successfully');
|
|
322
|
-
case
|
|
311
|
+
case 20:
|
|
323
312
|
case "end":
|
|
324
313
|
return _context.stop();
|
|
325
314
|
}
|
|
@@ -496,7 +485,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
496
485
|
value: function () {
|
|
497
486
|
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
498
487
|
var _this$store$tempOrder, _this$store$discount, _this$store$tempOrder2;
|
|
499
|
-
var orderId,
|
|
488
|
+
var orderId, discountList, _this$store$discount2, _this$store$discount3, _this$store$discount4, currentEditDiscounts, runtimeDiscountIds, runtimeDiscounts, mergedDiscountList;
|
|
500
489
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
501
490
|
while (1) switch (_context3.prev = _context3.next) {
|
|
502
491
|
case 0:
|
|
@@ -508,49 +497,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
508
497
|
with_good_pass: 1,
|
|
509
498
|
with_discount_card: 1,
|
|
510
499
|
with_wallet_pass_holder: 1,
|
|
511
|
-
with_available_wallet_flag: 1,
|
|
512
|
-
with_available_wallet_pass_flag: 1,
|
|
513
500
|
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
514
501
|
}, orderId ? {
|
|
515
502
|
order_id: orderId
|
|
516
503
|
} : {}));
|
|
517
504
|
case 3:
|
|
518
|
-
|
|
519
|
-
discountList = prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.discountList;
|
|
520
|
-
this.store.availableWalletIds = (prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.availableWalletIds) || [];
|
|
505
|
+
discountList = _context3.sent;
|
|
521
506
|
if (!discountList) {
|
|
522
|
-
_context3.next =
|
|
507
|
+
_context3.next = 13;
|
|
523
508
|
break;
|
|
524
509
|
}
|
|
525
|
-
|
|
526
|
-
currentEditDiscounts = currentDiscountList.filter(function (discount) {
|
|
510
|
+
currentEditDiscounts = (((_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 ? void 0 : _this$store$discount2.getDiscountList()) || []).filter(function (discount) {
|
|
527
511
|
return discount === null || discount === void 0 ? void 0 : discount.isEditMode;
|
|
528
512
|
});
|
|
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
|
-
}));
|
|
535
513
|
runtimeDiscountIds = new Set();
|
|
536
514
|
runtimeDiscounts = discountList.filter(function (discount) {
|
|
537
|
-
if (currentScanDiscountIds.has(discount === null || discount === void 0 ? void 0 : discount.id)) return false;
|
|
538
515
|
if (runtimeDiscountIds.has(discount === null || discount === void 0 ? void 0 : discount.id)) return false;
|
|
539
516
|
runtimeDiscountIds.add(discount === null || discount === void 0 ? void 0 : discount.id);
|
|
540
517
|
return true;
|
|
541
518
|
});
|
|
542
|
-
mergedDiscountList = [].concat(_toConsumableArray(currentEditDiscounts), _toConsumableArray(
|
|
543
|
-
_context3.next =
|
|
519
|
+
mergedDiscountList = [].concat(_toConsumableArray(currentEditDiscounts), _toConsumableArray(runtimeDiscounts));
|
|
520
|
+
_context3.next = 11;
|
|
544
521
|
return (_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.setOriginalDiscountList(mergedDiscountList);
|
|
545
|
-
case
|
|
546
|
-
_context3.next =
|
|
522
|
+
case 11:
|
|
523
|
+
_context3.next = 13;
|
|
547
524
|
return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.setDiscountList(mergedDiscountList);
|
|
548
|
-
case
|
|
525
|
+
case 13:
|
|
549
526
|
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) {
|
|
550
527
|
this.applyDiscount();
|
|
551
528
|
}
|
|
552
529
|
return _context3.abrupt("return", this.getDiscountList());
|
|
553
|
-
case
|
|
530
|
+
case 15:
|
|
554
531
|
case "end":
|
|
555
532
|
return _context3.stop();
|
|
556
533
|
}
|
|
@@ -567,77 +544,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
567
544
|
var _this$store$discount5;
|
|
568
545
|
return ((_this$store$discount5 = this.store.discount) === null || _this$store$discount5 === void 0 ? void 0 : _this$store$discount5.getDiscountList()) || [];
|
|
569
546
|
}
|
|
570
|
-
}, {
|
|
571
|
-
key: "getAvailableWalletIds",
|
|
572
|
-
value: function getAvailableWalletIds() {
|
|
573
|
-
return Array.isArray(this.store.availableWalletIds) ? _toConsumableArray(this.store.availableWalletIds) : [];
|
|
574
|
-
}
|
|
575
|
-
}, {
|
|
576
|
-
key: "syncScannedDiscountsToOriginalDiscountList",
|
|
577
|
-
value: function () {
|
|
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;
|
|
581
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
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
547
|
}, {
|
|
614
548
|
key: "ensureEditDiscountConfigForProductChange",
|
|
615
549
|
value: function () {
|
|
616
|
-
var _ensureEditDiscountConfigForProductChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
617
|
-
var _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _this$store$
|
|
550
|
+
var _ensureEditDiscountConfigForProductChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(tempOrder) {
|
|
551
|
+
var _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _this$store$discount6;
|
|
618
552
|
var orderId, customerId, currentDiscountList, hasRuntimeDiscounts;
|
|
619
|
-
return _regeneratorRuntime().wrap(function
|
|
620
|
-
while (1) switch (
|
|
553
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
554
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
621
555
|
case 0:
|
|
622
556
|
orderId = tempOrder.order_id;
|
|
623
557
|
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);
|
|
624
558
|
if (!(!orderId || !customerId || customerId === 1)) {
|
|
625
|
-
|
|
559
|
+
_context4.next = 4;
|
|
626
560
|
break;
|
|
627
561
|
}
|
|
628
|
-
return
|
|
562
|
+
return _context4.abrupt("return");
|
|
629
563
|
case 4:
|
|
630
|
-
currentDiscountList = ((_this$store$
|
|
564
|
+
currentDiscountList = ((_this$store$discount6 = this.store.discount) === null || _this$store$discount6 === void 0 ? void 0 : _this$store$discount6.getDiscountList()) || [];
|
|
631
565
|
hasRuntimeDiscounts = currentDiscountList.some(function (discount) {
|
|
632
566
|
return !(discount !== null && discount !== void 0 && discount.isEditMode);
|
|
633
567
|
});
|
|
634
568
|
if (!hasRuntimeDiscounts) {
|
|
635
|
-
|
|
569
|
+
_context4.next = 8;
|
|
636
570
|
break;
|
|
637
571
|
}
|
|
638
|
-
return
|
|
572
|
+
return _context4.abrupt("return");
|
|
639
573
|
case 8:
|
|
640
|
-
|
|
574
|
+
_context4.next = 10;
|
|
641
575
|
return this.loadDiscountConfig({
|
|
642
576
|
customerId: customerId,
|
|
643
577
|
action: 'edit',
|
|
@@ -646,11 +580,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
646
580
|
});
|
|
647
581
|
case 10:
|
|
648
582
|
case "end":
|
|
649
|
-
return
|
|
583
|
+
return _context4.stop();
|
|
650
584
|
}
|
|
651
|
-
},
|
|
585
|
+
}, _callee4, this);
|
|
652
586
|
}));
|
|
653
|
-
function ensureEditDiscountConfigForProductChange(
|
|
587
|
+
function ensureEditDiscountConfigForProductChange(_x4) {
|
|
654
588
|
return _ensureEditDiscountConfigForProductChange.apply(this, arguments);
|
|
655
589
|
}
|
|
656
590
|
return ensureEditDiscountConfigForProductChange;
|
|
@@ -658,35 +592,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
658
592
|
}, {
|
|
659
593
|
key: "scanCode",
|
|
660
594
|
value: function () {
|
|
661
|
-
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
662
|
-
var _this$store$
|
|
663
|
-
var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref13, isAvailable, newDiscountList, unavailableReason, _this$store$
|
|
664
|
-
return _regeneratorRuntime().wrap(function
|
|
665
|
-
while (1) switch (
|
|
595
|
+
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code, customerId) {
|
|
596
|
+
var _this$store$discount7, _tempOrder$holder, _this$store$summary;
|
|
597
|
+
var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref13, isAvailable, newDiscountList, unavailableReason, _this$store$discount8;
|
|
598
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
599
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
666
600
|
case 0:
|
|
667
|
-
|
|
668
|
-
return (_this$store$
|
|
601
|
+
_context5.next = 2;
|
|
602
|
+
return (_this$store$discount7 = this.store.discount) === null || _this$store$discount7 === void 0 ? void 0 : _this$store$discount7.batchSearch(code, {
|
|
669
603
|
customerId: customerId
|
|
670
604
|
});
|
|
671
605
|
case 2:
|
|
672
|
-
|
|
673
|
-
if (
|
|
674
|
-
|
|
606
|
+
_context5.t0 = _context5.sent;
|
|
607
|
+
if (_context5.t0) {
|
|
608
|
+
_context5.next = 5;
|
|
675
609
|
break;
|
|
676
610
|
}
|
|
677
|
-
|
|
611
|
+
_context5.t0 = {
|
|
678
612
|
discountList: [],
|
|
679
613
|
unavailableReasonKey: null
|
|
680
614
|
};
|
|
681
615
|
case 5:
|
|
682
|
-
resultDiscountWithReason =
|
|
616
|
+
resultDiscountWithReason = _context5.t0;
|
|
683
617
|
resultDiscountList = resultDiscountWithReason.discountList, unavailableReasonKey = resultDiscountWithReason.unavailableReasonKey;
|
|
684
618
|
rulesModule = this.store.rules;
|
|
685
619
|
if (rulesModule) {
|
|
686
|
-
|
|
620
|
+
_context5.next = 10;
|
|
687
621
|
break;
|
|
688
622
|
}
|
|
689
|
-
return
|
|
623
|
+
return _context5.abrupt("return", {
|
|
690
624
|
type: 'clientCalc',
|
|
691
625
|
isAvailable: false,
|
|
692
626
|
discountList: this.getDiscountList(),
|
|
@@ -695,10 +629,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
695
629
|
});
|
|
696
630
|
case 10:
|
|
697
631
|
if (resultDiscountList.length) {
|
|
698
|
-
|
|
632
|
+
_context5.next = 12;
|
|
699
633
|
break;
|
|
700
634
|
}
|
|
701
|
-
return
|
|
635
|
+
return _context5.abrupt("return", {
|
|
702
636
|
type: 'server',
|
|
703
637
|
isAvailable: false,
|
|
704
638
|
discountList: this.getDiscountList(),
|
|
@@ -719,19 +653,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
719
653
|
return m.id === n.id;
|
|
720
654
|
});
|
|
721
655
|
}))) {
|
|
722
|
-
|
|
656
|
+
_context5.next = 16;
|
|
723
657
|
break;
|
|
724
658
|
}
|
|
725
|
-
|
|
726
|
-
return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
727
|
-
case 17:
|
|
728
|
-
return _context6.abrupt("return", {
|
|
659
|
+
return _context5.abrupt("return", {
|
|
729
660
|
type: 'clientCalc',
|
|
730
661
|
isAvailable: true,
|
|
731
662
|
discountList: this.getDiscountList(),
|
|
732
663
|
scannedDiscountList: resultDiscountList
|
|
733
664
|
});
|
|
734
|
-
case
|
|
665
|
+
case 16:
|
|
735
666
|
tempOrder = this.store.tempOrder;
|
|
736
667
|
holders = (tempOrder === null || tempOrder === void 0 || (_tempOrder$holder = tempOrder.holder) === null || _tempOrder$holder === void 0 ? void 0 : _tempOrder$holder.form_record) || [];
|
|
737
668
|
_ref13 = rulesModule.isDiscountListAvailable({
|
|
@@ -747,37 +678,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
747
678
|
isAvailable: false,
|
|
748
679
|
discountList: this.getDiscountList()
|
|
749
680
|
}, isAvailable = _ref13.isAvailable, newDiscountList = _ref13.discountList, unavailableReason = _ref13.unavailableReason;
|
|
750
|
-
if (
|
|
751
|
-
|
|
752
|
-
|
|
681
|
+
if (isAvailable && newDiscountList) {
|
|
682
|
+
(_this$store$discount8 = this.store.discount) === null || _this$store$discount8 === void 0 || _this$store$discount8.setDiscountList(newDiscountList);
|
|
683
|
+
this.applyDiscount();
|
|
753
684
|
}
|
|
754
|
-
|
|
755
|
-
this.applyDiscount();
|
|
756
|
-
_context6.next = 26;
|
|
757
|
-
return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
758
|
-
case 26:
|
|
759
|
-
return _context6.abrupt("return", {
|
|
685
|
+
return _context5.abrupt("return", {
|
|
760
686
|
type: 'clientCalc',
|
|
761
687
|
isAvailable: isAvailable || false,
|
|
762
688
|
discountList: newDiscountList || this.getDiscountList(),
|
|
763
689
|
scannedDiscountList: resultDiscountList,
|
|
764
690
|
unavailableReason: unavailableReason
|
|
765
691
|
});
|
|
766
|
-
case
|
|
692
|
+
case 21:
|
|
767
693
|
case "end":
|
|
768
|
-
return
|
|
694
|
+
return _context5.stop();
|
|
769
695
|
}
|
|
770
|
-
},
|
|
696
|
+
}, _callee5, this);
|
|
771
697
|
}));
|
|
772
|
-
function scanCode(
|
|
698
|
+
function scanCode(_x5, _x6) {
|
|
773
699
|
return _scanCode.apply(this, arguments);
|
|
774
700
|
}
|
|
775
701
|
return scanCode;
|
|
776
702
|
}()
|
|
777
703
|
}, {
|
|
778
704
|
key: "applyDiscount",
|
|
779
|
-
value: function applyDiscount(
|
|
780
|
-
var _this$store$
|
|
705
|
+
value: function applyDiscount() {
|
|
706
|
+
var _this$store$discount9,
|
|
707
|
+
_tempOrder$holder2,
|
|
781
708
|
_this$store$summary2,
|
|
782
709
|
_this2 = this;
|
|
783
710
|
var tempOrder = this.store.tempOrder;
|
|
@@ -787,21 +714,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
787
714
|
if (!tempOrder) return;
|
|
788
715
|
this.syncLinkedBookingHoldersToProducts(tempOrder);
|
|
789
716
|
delete tempOrder.discount_list;
|
|
790
|
-
var discountList = ((_this$store$
|
|
717
|
+
var discountList = ((_this$store$discount9 = this.store.discount) === null || _this$store$discount9 === void 0 ? void 0 : _this$store$discount9.getDiscountList()) || [];
|
|
791
718
|
var shouldSkipDiscountCalculation = this.shouldSkipDiscountCalculation(tempOrder);
|
|
792
719
|
if (shouldSkipDiscountCalculation) return;
|
|
793
720
|
var rulesModule = this.store.rules;
|
|
794
721
|
if (!rulesModule) return;
|
|
722
|
+
var holders = ((_tempOrder$holder2 = tempOrder.holder) === null || _tempOrder$holder2 === void 0 ? void 0 : _tempOrder$holder2.form_record) || [];
|
|
795
723
|
var result = rulesModule.calcDiscount({
|
|
796
724
|
productList: tempOrder.products,
|
|
797
725
|
discountList: discountList,
|
|
798
|
-
holders:
|
|
726
|
+
holders: holders,
|
|
799
727
|
isFormSubject: function isFormSubject(product) {
|
|
800
728
|
return resolveIsFormSubject(tempOrder, product);
|
|
801
729
|
},
|
|
802
730
|
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
|
|
805
731
|
});
|
|
806
732
|
if (result !== null && result !== void 0 && result.productList) {
|
|
807
733
|
var previousProductsByUid = indexOrderProductsByUid(tempOrder.products);
|
|
@@ -819,9 +745,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
819
745
|
}));
|
|
820
746
|
}
|
|
821
747
|
if (result !== null && result !== void 0 && result.discountList) {
|
|
822
|
-
var _this$store$
|
|
748
|
+
var _this$store$discount10;
|
|
823
749
|
OrderModule.populateSavedAmounts(result.productList || tempOrder.products, result.discountList);
|
|
824
|
-
(_this$store$
|
|
750
|
+
(_this$store$discount10 = this.store.discount) === null || _this$store$discount10 === void 0 || _this$store$discount10.setDiscountList(result.discountList);
|
|
825
751
|
}
|
|
826
752
|
this.hasActiveCustomerBoundDiscount = (tempOrder.products || []).some(function (product) {
|
|
827
753
|
return _this2.productHasCustomerBoundDiscount(product);
|
|
@@ -883,42 +809,42 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
883
809
|
}, {
|
|
884
810
|
key: "applyPromotion",
|
|
885
811
|
value: (function () {
|
|
886
|
-
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
812
|
+
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
887
813
|
var _this$promotionEvalua,
|
|
888
814
|
_this$promotionEvalua2,
|
|
889
815
|
_this3 = this;
|
|
890
816
|
var tempOrder, strategyConfigs, result, removeSet, _iterator3, _step3, reduce, _iterator6, _step6, _loop2, _iterator4, _step4, _loop, payload;
|
|
891
|
-
return _regeneratorRuntime().wrap(function
|
|
892
|
-
while (1) switch (
|
|
817
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context8) {
|
|
818
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
893
819
|
case 0:
|
|
894
820
|
if (!this.isApplyingPromotion) {
|
|
895
|
-
|
|
821
|
+
_context8.next = 2;
|
|
896
822
|
break;
|
|
897
823
|
}
|
|
898
|
-
return
|
|
824
|
+
return _context8.abrupt("return");
|
|
899
825
|
case 2:
|
|
900
826
|
if (this.promotionEvaluator) {
|
|
901
|
-
|
|
827
|
+
_context8.next = 4;
|
|
902
828
|
break;
|
|
903
829
|
}
|
|
904
|
-
return
|
|
830
|
+
return _context8.abrupt("return");
|
|
905
831
|
case 4:
|
|
906
832
|
tempOrder = this.store.tempOrder;
|
|
907
833
|
if (tempOrder) {
|
|
908
|
-
|
|
834
|
+
_context8.next = 7;
|
|
909
835
|
break;
|
|
910
836
|
}
|
|
911
|
-
return
|
|
837
|
+
return _context8.abrupt("return");
|
|
912
838
|
case 7:
|
|
913
839
|
strategyConfigs = (_this$promotionEvalua = (_this$promotionEvalua2 = this.promotionEvaluator).getStrategyConfigs) === null || _this$promotionEvalua === void 0 ? void 0 : _this$promotionEvalua.call(_this$promotionEvalua2);
|
|
914
840
|
if (!(Array.isArray(strategyConfigs) && strategyConfigs.length === 0)) {
|
|
915
|
-
|
|
841
|
+
_context8.next = 10;
|
|
916
842
|
break;
|
|
917
843
|
}
|
|
918
|
-
return
|
|
844
|
+
return _context8.abrupt("return");
|
|
919
845
|
case 10:
|
|
920
846
|
this.isApplyingPromotion = true;
|
|
921
|
-
|
|
847
|
+
_context8.prev = 11;
|
|
922
848
|
result = processCartPromotion(tempOrder.products, this.promotionEvaluator); // step 1: toRemove —— 直接过滤
|
|
923
849
|
if (result.giftActions.toRemove.length > 0) {
|
|
924
850
|
removeSet = new Set(result.giftActions.toRemove.map(String));
|
|
@@ -930,20 +856,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
930
856
|
|
|
931
857
|
// step 2: toReduce —— 调整数量
|
|
932
858
|
_iterator3 = _createForOfIteratorHelper(result.giftActions.toReduce);
|
|
933
|
-
|
|
859
|
+
_context8.prev = 15;
|
|
934
860
|
_iterator3.s();
|
|
935
861
|
case 17:
|
|
936
862
|
if ((_step3 = _iterator3.n()).done) {
|
|
937
|
-
|
|
863
|
+
_context8.next = 37;
|
|
938
864
|
break;
|
|
939
865
|
}
|
|
940
866
|
reduce = _step3.value;
|
|
941
867
|
_iterator6 = _createForOfIteratorHelper(reduce.items);
|
|
942
|
-
|
|
868
|
+
_context8.prev = 20;
|
|
943
869
|
_loop2 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop2() {
|
|
944
870
|
var item, product;
|
|
945
|
-
return _regeneratorRuntime().wrap(function _loop2$(
|
|
946
|
-
while (1) switch (
|
|
871
|
+
return _regeneratorRuntime().wrap(function _loop2$(_context7) {
|
|
872
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
947
873
|
case 0:
|
|
948
874
|
item = _step6.value;
|
|
949
875
|
product = result.products.find(function (p) {
|
|
@@ -954,52 +880,52 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
954
880
|
}
|
|
955
881
|
case 3:
|
|
956
882
|
case "end":
|
|
957
|
-
return
|
|
883
|
+
return _context7.stop();
|
|
958
884
|
}
|
|
959
885
|
}, _loop2);
|
|
960
886
|
});
|
|
961
887
|
_iterator6.s();
|
|
962
888
|
case 23:
|
|
963
889
|
if ((_step6 = _iterator6.n()).done) {
|
|
964
|
-
|
|
890
|
+
_context8.next = 27;
|
|
965
891
|
break;
|
|
966
892
|
}
|
|
967
|
-
return
|
|
893
|
+
return _context8.delegateYield(_loop2(), "t0", 25);
|
|
968
894
|
case 25:
|
|
969
|
-
|
|
895
|
+
_context8.next = 23;
|
|
970
896
|
break;
|
|
971
897
|
case 27:
|
|
972
|
-
|
|
898
|
+
_context8.next = 32;
|
|
973
899
|
break;
|
|
974
900
|
case 29:
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
_iterator6.e(
|
|
901
|
+
_context8.prev = 29;
|
|
902
|
+
_context8.t1 = _context8["catch"](20);
|
|
903
|
+
_iterator6.e(_context8.t1);
|
|
978
904
|
case 32:
|
|
979
|
-
|
|
905
|
+
_context8.prev = 32;
|
|
980
906
|
_iterator6.f();
|
|
981
|
-
return
|
|
907
|
+
return _context8.finish(32);
|
|
982
908
|
case 35:
|
|
983
|
-
|
|
909
|
+
_context8.next = 17;
|
|
984
910
|
break;
|
|
985
911
|
case 37:
|
|
986
|
-
|
|
912
|
+
_context8.next = 42;
|
|
987
913
|
break;
|
|
988
914
|
case 39:
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
_iterator3.e(
|
|
915
|
+
_context8.prev = 39;
|
|
916
|
+
_context8.t2 = _context8["catch"](15);
|
|
917
|
+
_iterator3.e(_context8.t2);
|
|
992
918
|
case 42:
|
|
993
|
-
|
|
919
|
+
_context8.prev = 42;
|
|
994
920
|
_iterator3.f();
|
|
995
|
-
return
|
|
921
|
+
return _context8.finish(42);
|
|
996
922
|
case 45:
|
|
997
923
|
if (!(result.giftActions.toAdd.length > 0)) {
|
|
998
|
-
|
|
924
|
+
_context8.next = 68;
|
|
999
925
|
break;
|
|
1000
926
|
}
|
|
1001
927
|
if (this.giftSelectResolver) {
|
|
1002
|
-
|
|
928
|
+
_context8.next = 50;
|
|
1003
929
|
break;
|
|
1004
930
|
}
|
|
1005
931
|
if (result.giftActions.toAdd.some(function (g) {
|
|
@@ -1010,19 +936,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1010
936
|
} else {
|
|
1011
937
|
console.warn('[OrderModule] giftSelectResolver not set, skip applying single-option gifts', result.giftActions.toAdd);
|
|
1012
938
|
}
|
|
1013
|
-
|
|
939
|
+
_context8.next = 68;
|
|
1014
940
|
break;
|
|
1015
941
|
case 50:
|
|
1016
942
|
_iterator4 = _createForOfIteratorHelper(result.giftActions.toAdd);
|
|
1017
|
-
|
|
943
|
+
_context8.prev = 51;
|
|
1018
944
|
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
1019
945
|
var addAction, _sameStrategy$metadat, sameStrategy, giftResult, giftProducts, giftBookings, _iterator5, _step5, _step5$value, index, gp, booking, linked;
|
|
1020
|
-
return _regeneratorRuntime().wrap(function _loop$(
|
|
1021
|
-
while (1) switch (
|
|
946
|
+
return _regeneratorRuntime().wrap(function _loop$(_context6) {
|
|
947
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
1022
948
|
case 0:
|
|
1023
949
|
addAction = _step4.value;
|
|
1024
950
|
if (!(addAction.giftOptions.length === 1)) {
|
|
1025
|
-
|
|
951
|
+
_context6.next = 6;
|
|
1026
952
|
break;
|
|
1027
953
|
}
|
|
1028
954
|
sameStrategy = result.products.find(function (p) {
|
|
@@ -1030,14 +956,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1030
956
|
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;
|
|
1031
957
|
});
|
|
1032
958
|
if (!(sameStrategy && !sameStrategy.booking_uid && !((_sameStrategy$metadat = sameStrategy.metadata) !== null && _sameStrategy$metadat !== void 0 && _sameStrategy$metadat.booking_uid))) {
|
|
1033
|
-
|
|
959
|
+
_context6.next = 6;
|
|
1034
960
|
break;
|
|
1035
961
|
}
|
|
1036
962
|
sameStrategy.num = (Number(sameStrategy.num) || 0) + (addAction.giftCount || 1);
|
|
1037
|
-
return
|
|
963
|
+
return _context6.abrupt("return", 1);
|
|
1038
964
|
case 6:
|
|
1039
|
-
|
|
1040
|
-
|
|
965
|
+
_context6.prev = 6;
|
|
966
|
+
_context6.next = 9;
|
|
1041
967
|
return _this3.giftSelectResolver({
|
|
1042
968
|
strategyId: addAction.strategyId,
|
|
1043
969
|
strategyName: addAction.strategyName,
|
|
@@ -1046,31 +972,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1046
972
|
sourceProductIds: addAction.sourceProductIds
|
|
1047
973
|
});
|
|
1048
974
|
case 9:
|
|
1049
|
-
giftResult =
|
|
975
|
+
giftResult = _context6.sent;
|
|
1050
976
|
giftProducts = Array.isArray(giftResult) ? giftResult : giftResult === null || giftResult === void 0 ? void 0 : giftResult.products;
|
|
1051
977
|
giftBookings = Array.isArray(giftResult) ? [] : (giftResult === null || giftResult === void 0 ? void 0 : giftResult.bookings) || [];
|
|
1052
978
|
if (!(Array.isArray(giftProducts) && giftProducts.length > 0)) {
|
|
1053
|
-
|
|
979
|
+
_context6.next = 37;
|
|
1054
980
|
break;
|
|
1055
981
|
}
|
|
1056
982
|
_iterator5 = _createForOfIteratorHelper(giftProducts.entries());
|
|
1057
|
-
|
|
983
|
+
_context6.prev = 14;
|
|
1058
984
|
_iterator5.s();
|
|
1059
985
|
case 16:
|
|
1060
986
|
if ((_step5 = _iterator5.n()).done) {
|
|
1061
|
-
|
|
987
|
+
_context6.next = 29;
|
|
1062
988
|
break;
|
|
1063
989
|
}
|
|
1064
990
|
_step5$value = _slicedToArray(_step5.value, 2), index = _step5$value[0], gp = _step5$value[1];
|
|
1065
991
|
if (gp) {
|
|
1066
|
-
|
|
992
|
+
_context6.next = 20;
|
|
1067
993
|
break;
|
|
1068
994
|
}
|
|
1069
|
-
return
|
|
995
|
+
return _context6.abrupt("continue", 27);
|
|
1070
996
|
case 20:
|
|
1071
997
|
booking = giftBookings[index];
|
|
1072
998
|
if (!booking) {
|
|
1073
|
-
|
|
999
|
+
_context6.next = 26;
|
|
1074
1000
|
break;
|
|
1075
1001
|
}
|
|
1076
1002
|
linked = _this3.createLinkedProductAndBooking({
|
|
@@ -1079,65 +1005,65 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1079
1005
|
});
|
|
1080
1006
|
result.products.push(linked.product);
|
|
1081
1007
|
tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
|
|
1082
|
-
return
|
|
1008
|
+
return _context6.abrupt("continue", 27);
|
|
1083
1009
|
case 26:
|
|
1084
1010
|
// normalize 略过:调用方应保证返回完整 OrderProduct。
|
|
1085
1011
|
result.products.push(gp);
|
|
1086
1012
|
case 27:
|
|
1087
|
-
|
|
1013
|
+
_context6.next = 16;
|
|
1088
1014
|
break;
|
|
1089
1015
|
case 29:
|
|
1090
|
-
|
|
1016
|
+
_context6.next = 34;
|
|
1091
1017
|
break;
|
|
1092
1018
|
case 31:
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
_iterator5.e(
|
|
1019
|
+
_context6.prev = 31;
|
|
1020
|
+
_context6.t0 = _context6["catch"](14);
|
|
1021
|
+
_iterator5.e(_context6.t0);
|
|
1096
1022
|
case 34:
|
|
1097
|
-
|
|
1023
|
+
_context6.prev = 34;
|
|
1098
1024
|
_iterator5.f();
|
|
1099
|
-
return
|
|
1025
|
+
return _context6.finish(34);
|
|
1100
1026
|
case 37:
|
|
1101
|
-
|
|
1027
|
+
_context6.next = 42;
|
|
1102
1028
|
break;
|
|
1103
1029
|
case 39:
|
|
1104
|
-
|
|
1105
|
-
|
|
1030
|
+
_context6.prev = 39;
|
|
1031
|
+
_context6.t1 = _context6["catch"](6);
|
|
1106
1032
|
// 用户取消 / 选择失败 → 视为放弃本次新增
|
|
1107
|
-
console.warn('[OrderModule] giftSelectResolver rejected, skip add gift', addAction.strategyId,
|
|
1033
|
+
console.warn('[OrderModule] giftSelectResolver rejected, skip add gift', addAction.strategyId, _context6.t1);
|
|
1108
1034
|
case 42:
|
|
1109
1035
|
case "end":
|
|
1110
|
-
return
|
|
1036
|
+
return _context6.stop();
|
|
1111
1037
|
}
|
|
1112
1038
|
}, _loop, null, [[6, 39], [14, 31, 34, 37]]);
|
|
1113
1039
|
});
|
|
1114
1040
|
_iterator4.s();
|
|
1115
1041
|
case 54:
|
|
1116
1042
|
if ((_step4 = _iterator4.n()).done) {
|
|
1117
|
-
|
|
1043
|
+
_context8.next = 60;
|
|
1118
1044
|
break;
|
|
1119
1045
|
}
|
|
1120
|
-
return
|
|
1046
|
+
return _context8.delegateYield(_loop(), "t3", 56);
|
|
1121
1047
|
case 56:
|
|
1122
|
-
if (!
|
|
1123
|
-
|
|
1048
|
+
if (!_context8.t3) {
|
|
1049
|
+
_context8.next = 58;
|
|
1124
1050
|
break;
|
|
1125
1051
|
}
|
|
1126
|
-
return
|
|
1052
|
+
return _context8.abrupt("continue", 58);
|
|
1127
1053
|
case 58:
|
|
1128
|
-
|
|
1054
|
+
_context8.next = 54;
|
|
1129
1055
|
break;
|
|
1130
1056
|
case 60:
|
|
1131
|
-
|
|
1057
|
+
_context8.next = 65;
|
|
1132
1058
|
break;
|
|
1133
1059
|
case 62:
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
_iterator4.e(
|
|
1060
|
+
_context8.prev = 62;
|
|
1061
|
+
_context8.t4 = _context8["catch"](51);
|
|
1062
|
+
_iterator4.e(_context8.t4);
|
|
1137
1063
|
case 65:
|
|
1138
|
-
|
|
1064
|
+
_context8.prev = 65;
|
|
1139
1065
|
_iterator4.f();
|
|
1140
|
-
return
|
|
1066
|
+
return _context8.finish(65);
|
|
1141
1067
|
case 68:
|
|
1142
1068
|
tempOrder.products = result.products;
|
|
1143
1069
|
this.lastUnfulfilledPromotions = result.unfulfilledPromotions;
|
|
@@ -1156,21 +1082,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1156
1082
|
products: tempOrder.products
|
|
1157
1083
|
};
|
|
1158
1084
|
this.effectsEmit('onPromotionApplied', payload);
|
|
1159
|
-
|
|
1085
|
+
_context8.next = 78;
|
|
1160
1086
|
break;
|
|
1161
1087
|
case 75:
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
console.error('[OrderModule] applyPromotion failed',
|
|
1088
|
+
_context8.prev = 75;
|
|
1089
|
+
_context8.t5 = _context8["catch"](11);
|
|
1090
|
+
console.error('[OrderModule] applyPromotion failed', _context8.t5);
|
|
1165
1091
|
case 78:
|
|
1166
|
-
|
|
1092
|
+
_context8.prev = 78;
|
|
1167
1093
|
this.isApplyingPromotion = false;
|
|
1168
|
-
return
|
|
1094
|
+
return _context8.finish(78);
|
|
1169
1095
|
case 81:
|
|
1170
1096
|
case "end":
|
|
1171
|
-
return
|
|
1097
|
+
return _context8.stop();
|
|
1172
1098
|
}
|
|
1173
|
-
},
|
|
1099
|
+
}, _callee6, this, [[11, 75, 78, 81], [15, 39, 42, 45], [20, 29, 32, 35], [51, 62, 65, 68]]);
|
|
1174
1100
|
}));
|
|
1175
1101
|
function applyPromotion() {
|
|
1176
1102
|
return _applyPromotion.apply(this, arguments);
|
|
@@ -1292,14 +1218,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1292
1218
|
}, {
|
|
1293
1219
|
key: "saveDraft",
|
|
1294
1220
|
value: function () {
|
|
1295
|
-
var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1296
|
-
return _regeneratorRuntime().wrap(function
|
|
1297
|
-
while (1) switch (
|
|
1221
|
+
var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
1222
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context9) {
|
|
1223
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
1298
1224
|
case 0:
|
|
1299
1225
|
case "end":
|
|
1300
|
-
return
|
|
1226
|
+
return _context9.stop();
|
|
1301
1227
|
}
|
|
1302
|
-
},
|
|
1228
|
+
}, _callee7);
|
|
1303
1229
|
}));
|
|
1304
1230
|
function saveDraft() {
|
|
1305
1231
|
return _saveDraft.apply(this, arguments);
|
|
@@ -1314,18 +1240,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1314
1240
|
}, {
|
|
1315
1241
|
key: "hydrateTempOrderFromLocalRecord",
|
|
1316
1242
|
value: function () {
|
|
1317
|
-
var _hydrateTempOrderFromLocalRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1318
|
-
return _regeneratorRuntime().wrap(function
|
|
1319
|
-
while (1) switch (
|
|
1243
|
+
var _hydrateTempOrderFromLocalRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(record) {
|
|
1244
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context10) {
|
|
1245
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
1320
1246
|
case 0:
|
|
1321
|
-
return
|
|
1247
|
+
return _context10.abrupt("return", this.hydrateTempOrderFromRecord(record));
|
|
1322
1248
|
case 1:
|
|
1323
1249
|
case "end":
|
|
1324
|
-
return
|
|
1250
|
+
return _context10.stop();
|
|
1325
1251
|
}
|
|
1326
|
-
},
|
|
1252
|
+
}, _callee8, this);
|
|
1327
1253
|
}));
|
|
1328
|
-
function hydrateTempOrderFromLocalRecord(
|
|
1254
|
+
function hydrateTempOrderFromLocalRecord(_x7) {
|
|
1329
1255
|
return _hydrateTempOrderFromLocalRecord.apply(this, arguments);
|
|
1330
1256
|
}
|
|
1331
1257
|
return hydrateTempOrderFromLocalRecord;
|
|
@@ -1359,17 +1285,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1359
1285
|
return sum.plus(_this4.calculatePaymentEffectiveAmount(payment));
|
|
1360
1286
|
}, new Decimal(0));
|
|
1361
1287
|
}
|
|
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
|
-
}
|
|
1373
1288
|
}, {
|
|
1374
1289
|
key: "getDepositAmount",
|
|
1375
1290
|
value: function getDepositAmount(tempOrder, summary) {
|
|
@@ -1470,7 +1385,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1470
1385
|
var summary = this.store.summary || createEmptySummary();
|
|
1471
1386
|
var paymentList = payments || tempOrder.payments || [];
|
|
1472
1387
|
var refundAmount = this.getSummaryRefundAmount(summary);
|
|
1473
|
-
var netPaidAmount = Decimal.max(this.
|
|
1388
|
+
var netPaidAmount = Decimal.max(this.calculatePaymentTotal(paymentList).minus(refundAmount), 0);
|
|
1474
1389
|
var depositAmount = this.getDepositAmount(tempOrder, summary);
|
|
1475
1390
|
var orderExpectedAmount = this.getOrderExpectedAmount(summary);
|
|
1476
1391
|
var isDepositFullyPaid = this.isDepositCovered({
|
|
@@ -1492,13 +1407,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1492
1407
|
}, {
|
|
1493
1408
|
key: "calculateDepositPaidAmount",
|
|
1494
1409
|
value: function calculateDepositPaidAmount(payments) {
|
|
1495
|
-
var
|
|
1410
|
+
var _this5 = this;
|
|
1496
1411
|
return (payments || []).reduce(function (sum, payment) {
|
|
1497
1412
|
var paymentRecord = payment;
|
|
1498
1413
|
if (!isPaidPaymentRecord(paymentRecord)) return sum;
|
|
1499
1414
|
var isDepositPayment = paymentRecord.type === 'deposit' || paymentRecord.order_payment_type === 'deposit';
|
|
1500
1415
|
if (!isDepositPayment) return sum;
|
|
1501
|
-
|
|
1416
|
+
if (paymentRecord.origin_amount !== undefined && paymentRecord.origin_amount !== null && paymentRecord.origin_amount !== '') {
|
|
1417
|
+
return sum.plus(_this5.calculatePaymentGapAmount(paymentRecord));
|
|
1418
|
+
}
|
|
1419
|
+
var rounding = new Decimal(paymentRecord.rounding_amount || 0);
|
|
1420
|
+
return sum.plus(new Decimal(paymentRecord.amount || 0).minus(rounding));
|
|
1502
1421
|
}, new Decimal(0));
|
|
1503
1422
|
}
|
|
1504
1423
|
}, {
|
|
@@ -1535,9 +1454,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1535
1454
|
value: function updateTempOrderPaymentStatus(tempOrder, options) {
|
|
1536
1455
|
var summary = (options === null || options === void 0 ? void 0 : options.summary) || this.store.summary || createEmptySummary();
|
|
1537
1456
|
var paymentTotal = this.calculatePaymentTotal(tempOrder.payments || []);
|
|
1538
|
-
var orderPaymentTotal = this.calculateOrderPaidPaymentTotal(tempOrder.payments || []);
|
|
1539
1457
|
var refundAmount = this.getSummaryRefundAmount(summary);
|
|
1540
|
-
var netPaymentTotal = Decimal.max(
|
|
1458
|
+
var netPaymentTotal = Decimal.max(paymentTotal.minus(refundAmount), 0);
|
|
1541
1459
|
var targetAmount = this.calculatePaymentTargetAmount(tempOrder, summary, netPaymentTotal);
|
|
1542
1460
|
if (this.shouldKeepPaymentStatusAfterAmountRecalc(tempOrder.payment_status, {
|
|
1543
1461
|
netPaymentTotal: netPaymentTotal,
|
|
@@ -1603,7 +1521,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1603
1521
|
key: "capVoucherPaymentsByRemainingAmount",
|
|
1604
1522
|
value: function capVoucherPaymentsByRemainingAmount(params) {
|
|
1605
1523
|
var targetAmount = this.getPaymentTargetAmount();
|
|
1606
|
-
var nonVoucherTotal = this.
|
|
1524
|
+
var nonVoucherTotal = this.calculatePaymentTotal(params.nonVoucherPayments);
|
|
1607
1525
|
if (targetAmount.lte(0)) return [];
|
|
1608
1526
|
var remainingAmount = Decimal.max(targetAmount.minus(nonVoucherTotal), 0);
|
|
1609
1527
|
var cappedVouchers = [];
|
|
@@ -1640,16 +1558,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1640
1558
|
}, {
|
|
1641
1559
|
key: "calculatePaidPaymentSummary",
|
|
1642
1560
|
value: function calculatePaidPaymentSummary(payments) {
|
|
1643
|
-
var
|
|
1561
|
+
var _this6 = this;
|
|
1644
1562
|
return (payments || []).reduce(function (summary, payment) {
|
|
1645
1563
|
var paymentRecord = payment;
|
|
1646
1564
|
if (!isPaidPaymentRecord(paymentRecord)) return summary;
|
|
1647
1565
|
return {
|
|
1648
1566
|
customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
|
|
1649
|
-
orderPaidAmount: summary.orderPaidAmount.plus(
|
|
1650
|
-
gapPaidAmount: summary.gapPaidAmount.plus(
|
|
1651
|
-
payServiceChargeAmount: summary.payServiceChargeAmount.plus(
|
|
1652
|
-
roundingAmount: summary.roundingAmount.plus(
|
|
1567
|
+
orderPaidAmount: summary.orderPaidAmount.plus(paymentRecord.origin_amount || 0),
|
|
1568
|
+
gapPaidAmount: summary.gapPaidAmount.plus(_this6.calculatePaymentGapAmount(paymentRecord)),
|
|
1569
|
+
payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this6.calculatePaymentServiceFee(paymentRecord)),
|
|
1570
|
+
roundingAmount: summary.roundingAmount.plus(_this6.calculatePaymentRoundingAmount(paymentRecord))
|
|
1653
1571
|
};
|
|
1654
1572
|
}, {
|
|
1655
1573
|
customerPaidAmount: new Decimal(0),
|
|
@@ -1673,28 +1591,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1673
1591
|
}, {
|
|
1674
1592
|
key: "calculatePaymentGapAmount",
|
|
1675
1593
|
value: function calculatePaymentGapAmount(payment) {
|
|
1676
|
-
if (payment.origin_amount
|
|
1677
|
-
|
|
1678
|
-
return new Decimal(payment.origin_amount || 0).minus(_rounding);
|
|
1594
|
+
if (payment.origin_amount === undefined || payment.origin_amount === null || payment.origin_amount === '') {
|
|
1595
|
+
return new Decimal(0);
|
|
1679
1596
|
}
|
|
1680
1597
|
var rounding = new Decimal(payment.rounding_amount || 0);
|
|
1681
|
-
|
|
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);
|
|
1598
|
+
return new Decimal(payment.origin_amount || 0).minus(rounding);
|
|
1698
1599
|
}
|
|
1699
1600
|
}, {
|
|
1700
1601
|
key: "calculatePaymentRoundingAmount",
|
|
@@ -1851,15 +1752,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1851
1752
|
}, {
|
|
1852
1753
|
key: "normalizeFingerprintValue",
|
|
1853
1754
|
value: function normalizeFingerprintValue(value) {
|
|
1854
|
-
var
|
|
1755
|
+
var _this7 = this;
|
|
1855
1756
|
if (Array.isArray(value)) {
|
|
1856
1757
|
return value.map(function (item) {
|
|
1857
|
-
return
|
|
1758
|
+
return _this7.normalizeFingerprintValue(item);
|
|
1858
1759
|
});
|
|
1859
1760
|
}
|
|
1860
1761
|
if (!value || _typeof(value) !== 'object') return value !== null && value !== void 0 ? value : '';
|
|
1861
1762
|
return Object.keys(value).sort().reduce(function (result, key) {
|
|
1862
|
-
result[key] =
|
|
1763
|
+
result[key] = _this7.normalizeFingerprintValue(value[key]);
|
|
1863
1764
|
return result;
|
|
1864
1765
|
}, {});
|
|
1865
1766
|
}
|
|
@@ -1874,7 +1775,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1874
1775
|
_sku$barcode,
|
|
1875
1776
|
_ref20,
|
|
1876
1777
|
_sku$variant_id,
|
|
1877
|
-
|
|
1778
|
+
_this8 = this;
|
|
1878
1779
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
1879
1780
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
1880
1781
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -1908,7 +1809,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1908
1809
|
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,
|
|
1909
1810
|
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,
|
|
1910
1811
|
num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
|
|
1911
|
-
add_price:
|
|
1812
|
+
add_price: _this8.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)
|
|
1912
1813
|
};
|
|
1913
1814
|
})
|
|
1914
1815
|
}),
|
|
@@ -1918,8 +1819,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1918
1819
|
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
1820
|
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,
|
|
1920
1821
|
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),
|
|
1921
|
-
price:
|
|
1922
|
-
bundle_selling_price:
|
|
1822
|
+
price: _this8.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
|
|
1823
|
+
bundle_selling_price: _this8.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
|
|
1923
1824
|
price_type: (_bundle$price_type = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type !== void 0 ? _bundle$price_type : '',
|
|
1924
1825
|
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 : ''
|
|
1925
1826
|
};
|
|
@@ -1929,7 +1830,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1929
1830
|
return {
|
|
1930
1831
|
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
1832
|
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:
|
|
1833
|
+
amount: _this8.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
1933
1834
|
};
|
|
1934
1835
|
}))
|
|
1935
1836
|
};
|
|
@@ -1937,9 +1838,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1937
1838
|
}, {
|
|
1938
1839
|
key: "buildOrderProductsFingerprint",
|
|
1939
1840
|
value: function buildOrderProductsFingerprint(products) {
|
|
1940
|
-
var
|
|
1841
|
+
var _this9 = this;
|
|
1941
1842
|
var items = (products || []).map(function (product) {
|
|
1942
|
-
return
|
|
1843
|
+
return _this9.buildProductFingerprintItem(product);
|
|
1943
1844
|
});
|
|
1944
1845
|
items.sort(function (left, right) {
|
|
1945
1846
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -1961,7 +1862,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1961
1862
|
_sku$barcode2,
|
|
1962
1863
|
_ref30,
|
|
1963
1864
|
_sku$variant_id2,
|
|
1964
|
-
|
|
1865
|
+
_this10 = this;
|
|
1965
1866
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
1966
1867
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
1967
1868
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -1992,7 +1893,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1992
1893
|
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,
|
|
1993
1894
|
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,
|
|
1994
1895
|
num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
|
|
1995
|
-
add_price:
|
|
1896
|
+
add_price: _this10.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)
|
|
1996
1897
|
};
|
|
1997
1898
|
})
|
|
1998
1899
|
}),
|
|
@@ -2006,14 +1907,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2006
1907
|
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),
|
|
2007
1908
|
price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
|
|
2008
1909
|
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 : '',
|
|
2009
|
-
option:
|
|
1910
|
+
option: _this10.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
|
|
2010
1911
|
var _ref38, _option$id3, _option$option_group_5, _ref39, _option$option_group_6, _option$num3, _option$add_price3;
|
|
2011
1912
|
return {
|
|
2012
1913
|
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,
|
|
2013
1914
|
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,
|
|
2014
1915
|
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,
|
|
2015
1916
|
num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
|
|
2016
|
-
add_price:
|
|
1917
|
+
add_price: _this10.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)
|
|
2017
1918
|
};
|
|
2018
1919
|
}))
|
|
2019
1920
|
};
|
|
@@ -2023,7 +1924,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2023
1924
|
return {
|
|
2024
1925
|
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
1926
|
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:
|
|
1927
|
+
amount: _this10.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
2027
1928
|
};
|
|
2028
1929
|
}))
|
|
2029
1930
|
};
|
|
@@ -2031,9 +1932,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2031
1932
|
}, {
|
|
2032
1933
|
key: "buildOrderProductsStructuralFingerprint",
|
|
2033
1934
|
value: function buildOrderProductsStructuralFingerprint(products) {
|
|
2034
|
-
var
|
|
1935
|
+
var _this11 = this;
|
|
2035
1936
|
var items = (products || []).map(function (product) {
|
|
2036
|
-
return
|
|
1937
|
+
return _this11.buildProductStructuralFingerprintItem(product);
|
|
2037
1938
|
});
|
|
2038
1939
|
items.sort(function (left, right) {
|
|
2039
1940
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -2109,21 +2010,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2109
2010
|
key: "restoreOriginalSnapshotIfProductsUnchanged",
|
|
2110
2011
|
value: function restoreOriginalSnapshotIfProductsUnchanged(tempOrder, snapshot) {
|
|
2111
2012
|
var currentFingerprint = this.buildOrderProductsFingerprint(tempOrder.products);
|
|
2112
|
-
var manualDepositOverride = this.getManualDepositOverride(tempOrder);
|
|
2113
2013
|
if (currentFingerprint !== snapshot.productFingerprint) {
|
|
2114
2014
|
var currentStructuralFingerprint = this.buildOrderProductsStructuralFingerprint(tempOrder.products);
|
|
2115
2015
|
var snapshotStructuralFingerprint = this.buildOrderProductsStructuralFingerprint(Array.isArray(snapshot.products) ? snapshot.products : []);
|
|
2116
2016
|
if (currentStructuralFingerprint !== snapshotStructuralFingerprint) return null;
|
|
2117
2017
|
}
|
|
2118
2018
|
var summary = _objectSpread(_objectSpread({}, createEmptySummary()), cloneDeep(snapshot.summary || {}));
|
|
2119
|
-
|
|
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;
|
|
2019
|
+
if (!this.isSnapshotPayableAmountUnchanged(tempOrder, snapshot, summary)) return null;
|
|
2127
2020
|
if (Array.isArray(snapshot.products)) {
|
|
2128
2021
|
tempOrder.products = cloneDeep(snapshot.products);
|
|
2129
2022
|
}
|
|
@@ -2133,12 +2026,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2133
2026
|
tempOrder.surcharge_fee = summary.surcharge_fee || tempOrder.surcharge_fee;
|
|
2134
2027
|
tempOrder.deposit_amount = summary.deposit_amount || '0.00';
|
|
2135
2028
|
tempOrder.is_deposit = summary.deposit_amount !== '0.00' ? 1 : 0;
|
|
2136
|
-
var previousSummary = this.store.summary;
|
|
2137
2029
|
this.store.summary = summary;
|
|
2138
|
-
this.updateTempOrderPaymentStatus(tempOrder, {
|
|
2139
|
-
previousSummary: previousSummary,
|
|
2140
|
-
summary: summary
|
|
2141
|
-
});
|
|
2142
2030
|
return summary;
|
|
2143
2031
|
}
|
|
2144
2032
|
}, {
|
|
@@ -2250,7 +2138,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2250
2138
|
}, {
|
|
2251
2139
|
key: "restoreOrder",
|
|
2252
2140
|
value: function restoreOrder() {
|
|
2253
|
-
var _this$store$
|
|
2141
|
+
var _this$store$discount11, _this$store$discount12;
|
|
2254
2142
|
this.logInfo('restoreOrder start', {});
|
|
2255
2143
|
var freshTempOrder = this.createDefaultTempOrderInstance();
|
|
2256
2144
|
this.ensureExternalSaleNumber(freshTempOrder);
|
|
@@ -2258,8 +2146,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2258
2146
|
this.store.summary = createEmptySummary();
|
|
2259
2147
|
this.store.lastOrderInfo = undefined;
|
|
2260
2148
|
this.store.syncState = undefined;
|
|
2261
|
-
void ((_this$store$
|
|
2262
|
-
void ((_this$store$
|
|
2149
|
+
void ((_this$store$discount11 = this.store.discount) === null || _this$store$discount11 === void 0 ? void 0 : _this$store$discount11.setOriginalDiscountList([]));
|
|
2150
|
+
void ((_this$store$discount12 = this.store.discount) === null || _this$store$discount12 === void 0 ? void 0 : _this$store$discount12.setDiscountList([]));
|
|
2263
2151
|
this.persistTempOrder();
|
|
2264
2152
|
return freshTempOrder;
|
|
2265
2153
|
}
|
|
@@ -2271,13 +2159,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2271
2159
|
}, {
|
|
2272
2160
|
key: "replaceTempOrder",
|
|
2273
2161
|
value: function () {
|
|
2274
|
-
var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2162
|
+
var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(tempOrder, options) {
|
|
2275
2163
|
var nextTempOrder;
|
|
2276
|
-
return _regeneratorRuntime().wrap(function
|
|
2277
|
-
while (1) switch (
|
|
2164
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context11) {
|
|
2165
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
2278
2166
|
case 0:
|
|
2279
2167
|
if (isTempOrder(tempOrder)) {
|
|
2280
|
-
|
|
2168
|
+
_context11.next = 2;
|
|
2281
2169
|
break;
|
|
2282
2170
|
}
|
|
2283
2171
|
throw new Error('无效的 tempOrder 数据');
|
|
@@ -2287,15 +2175,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2287
2175
|
});
|
|
2288
2176
|
this.store.tempOrder = nextTempOrder;
|
|
2289
2177
|
if (!((options === null || options === void 0 ? void 0 : options.recalculateSummary) !== false)) {
|
|
2290
|
-
|
|
2178
|
+
_context11.next = 9;
|
|
2291
2179
|
break;
|
|
2292
2180
|
}
|
|
2293
|
-
|
|
2181
|
+
_context11.next = 7;
|
|
2294
2182
|
return this.recalculateSummary({
|
|
2295
2183
|
createIfMissing: false
|
|
2296
2184
|
});
|
|
2297
2185
|
case 7:
|
|
2298
|
-
|
|
2186
|
+
_context11.next = 10;
|
|
2299
2187
|
break;
|
|
2300
2188
|
case 9:
|
|
2301
2189
|
this.store.summary = createEmptySummary();
|
|
@@ -2304,20 +2192,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2304
2192
|
this.persistTempOrder();
|
|
2305
2193
|
}
|
|
2306
2194
|
if (!(options !== null && options !== void 0 && options.saveDraft)) {
|
|
2307
|
-
|
|
2195
|
+
_context11.next = 14;
|
|
2308
2196
|
break;
|
|
2309
2197
|
}
|
|
2310
|
-
|
|
2198
|
+
_context11.next = 14;
|
|
2311
2199
|
return this.saveDraft();
|
|
2312
2200
|
case 14:
|
|
2313
|
-
return
|
|
2201
|
+
return _context11.abrupt("return", nextTempOrder);
|
|
2314
2202
|
case 15:
|
|
2315
2203
|
case "end":
|
|
2316
|
-
return
|
|
2204
|
+
return _context11.stop();
|
|
2317
2205
|
}
|
|
2318
|
-
},
|
|
2206
|
+
}, _callee9, this);
|
|
2319
2207
|
}));
|
|
2320
|
-
function replaceTempOrder(
|
|
2208
|
+
function replaceTempOrder(_x8, _x9) {
|
|
2321
2209
|
return _replaceTempOrder.apply(this, arguments);
|
|
2322
2210
|
}
|
|
2323
2211
|
return replaceTempOrder;
|
|
@@ -2403,32 +2291,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2403
2291
|
}, {
|
|
2404
2292
|
key: "addNewOrder",
|
|
2405
2293
|
value: function () {
|
|
2406
|
-
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2294
|
+
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
2407
2295
|
var tempOrder;
|
|
2408
|
-
return _regeneratorRuntime().wrap(function
|
|
2409
|
-
while (1) switch (
|
|
2296
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context12) {
|
|
2297
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
2410
2298
|
case 0:
|
|
2411
2299
|
tempOrder = this.ensureTempOrder();
|
|
2412
2300
|
this.ensureExternalSaleNumber(tempOrder);
|
|
2413
|
-
|
|
2301
|
+
_context12.next = 4;
|
|
2414
2302
|
return this.recalculateSummary({
|
|
2415
2303
|
createIfMissing: true
|
|
2416
2304
|
});
|
|
2417
2305
|
case 4:
|
|
2418
2306
|
this.persistTempOrder();
|
|
2419
2307
|
if (!this.draftPersistEnabled) {
|
|
2420
|
-
|
|
2308
|
+
_context12.next = 8;
|
|
2421
2309
|
break;
|
|
2422
2310
|
}
|
|
2423
|
-
|
|
2311
|
+
_context12.next = 8;
|
|
2424
2312
|
return this.saveDraft();
|
|
2425
2313
|
case 8:
|
|
2426
|
-
return
|
|
2314
|
+
return _context12.abrupt("return", tempOrder);
|
|
2427
2315
|
case 9:
|
|
2428
2316
|
case "end":
|
|
2429
|
-
return
|
|
2317
|
+
return _context12.stop();
|
|
2430
2318
|
}
|
|
2431
|
-
},
|
|
2319
|
+
}, _callee10, this);
|
|
2432
2320
|
}));
|
|
2433
2321
|
function addNewOrder() {
|
|
2434
2322
|
return _addNewOrder.apply(this, arguments);
|
|
@@ -2461,9 +2349,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2461
2349
|
}, {
|
|
2462
2350
|
key: "sanitizeTempOrderProducts",
|
|
2463
2351
|
value: function sanitizeTempOrderProducts(tempOrder) {
|
|
2464
|
-
var
|
|
2352
|
+
var _this12 = this;
|
|
2465
2353
|
tempOrder.products = (tempOrder.products || []).map(function (product) {
|
|
2466
|
-
return
|
|
2354
|
+
return _this12.sanitizeOrderProductForTempOrder(product);
|
|
2467
2355
|
});
|
|
2468
2356
|
}
|
|
2469
2357
|
}, {
|
|
@@ -2566,7 +2454,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2566
2454
|
}, {
|
|
2567
2455
|
key: "syncLinkedBookingHoldersToProducts",
|
|
2568
2456
|
value: function syncLinkedBookingHoldersToProducts(tempOrder) {
|
|
2569
|
-
var
|
|
2457
|
+
var _this13 = this;
|
|
2570
2458
|
var bookings = tempOrder.bookings || [];
|
|
2571
2459
|
var products = tempOrder.products || [];
|
|
2572
2460
|
if (!bookings.length || !products.length) return;
|
|
@@ -2591,7 +2479,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2591
2479
|
var bookingUid = product.booking_uid || ((_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.booking_uid);
|
|
2592
2480
|
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
2481
|
if (linkedBooking) {
|
|
2594
|
-
|
|
2482
|
+
_this13.setProductHolderFromBooking(product, linkedBooking);
|
|
2595
2483
|
}
|
|
2596
2484
|
});
|
|
2597
2485
|
}
|
|
@@ -2629,7 +2517,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2629
2517
|
}, {
|
|
2630
2518
|
key: "buildTempOrderHolderFromBookings",
|
|
2631
2519
|
value: function buildTempOrderHolderFromBookings(tempOrder) {
|
|
2632
|
-
var _baseHolder$customer_, _baseHolder, _ref46, _baseHolder$form_id, _baseHolder2, _tempOrder$
|
|
2520
|
+
var _baseHolder$customer_, _baseHolder, _ref46, _baseHolder$form_id, _baseHolder2, _tempOrder$holder3, _baseHolder3, _this$otherParams;
|
|
2633
2521
|
var holderRecords = [];
|
|
2634
2522
|
var holderNames = [];
|
|
2635
2523
|
var baseHolder = null;
|
|
@@ -2676,7 +2564,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2676
2564
|
}
|
|
2677
2565
|
var nextHolder = {
|
|
2678
2566
|
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,
|
|
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$
|
|
2567
|
+
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$holder3 = tempOrder.holder) === null || _tempOrder$holder3 === void 0 ? void 0 : _tempOrder$holder3.form_id) !== null && _ref46 !== void 0 ? _ref46 : 0,
|
|
2680
2568
|
form_record: holderRecords
|
|
2681
2569
|
};
|
|
2682
2570
|
if (holderNames.length) {
|
|
@@ -2719,9 +2607,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2719
2607
|
}, {
|
|
2720
2608
|
key: "findBookingIndexByUniqueIdentificationNumber",
|
|
2721
2609
|
value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
|
|
2722
|
-
var
|
|
2610
|
+
var _this14 = this;
|
|
2723
2611
|
return (tempOrder.bookings || []).findIndex(function (booking) {
|
|
2724
|
-
return
|
|
2612
|
+
return _this14.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
|
|
2725
2613
|
});
|
|
2726
2614
|
}
|
|
2727
2615
|
}, {
|
|
@@ -2729,12 +2617,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2729
2617
|
value: function removeLinkedBookingsForProduct(tempOrder, product) {
|
|
2730
2618
|
var _product$metadata7,
|
|
2731
2619
|
_product$metadata8,
|
|
2732
|
-
|
|
2620
|
+
_this15 = this;
|
|
2733
2621
|
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
2622
|
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);
|
|
2735
2623
|
if (!productUid && !bookingUid) return;
|
|
2736
2624
|
tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
2737
|
-
var currentBookingUid =
|
|
2625
|
+
var currentBookingUid = _this15.getBookingUniqueIdentificationNumber(booking);
|
|
2738
2626
|
if (bookingUid && currentBookingUid === String(bookingUid)) return false;
|
|
2739
2627
|
if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
|
|
2740
2628
|
return true;
|
|
@@ -2780,18 +2668,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2780
2668
|
}, {
|
|
2781
2669
|
key: "recalculateSummary",
|
|
2782
2670
|
value: function () {
|
|
2783
|
-
var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2671
|
+
var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(options) {
|
|
2784
2672
|
var _this$otherParams2, _ref47, _salesSummaryResult$e;
|
|
2785
2673
|
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
|
|
2787
|
-
while (1) switch (
|
|
2674
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context13) {
|
|
2675
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
2788
2676
|
case 0:
|
|
2789
2677
|
tempOrder = options !== null && options !== void 0 && options.createIfMissing ? this.ensureTempOrder() : this.store.tempOrder;
|
|
2790
2678
|
if (tempOrder) {
|
|
2791
|
-
|
|
2679
|
+
_context13.next = 3;
|
|
2792
2680
|
break;
|
|
2793
2681
|
}
|
|
2794
|
-
return
|
|
2682
|
+
return _context13.abrupt("return", null);
|
|
2795
2683
|
case 3:
|
|
2796
2684
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
2797
2685
|
originalSnapshot = this.getOriginalSalesSnapshot(tempOrder);
|
|
@@ -2799,10 +2687,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2799
2687
|
shouldReuseOriginalSnapshot = originalSnapshot && !hasShopDiscountChanged;
|
|
2800
2688
|
snapshotSummary = shouldReuseOriginalSnapshot ? this.restoreOriginalSnapshotIfProductsUnchanged(tempOrder, originalSnapshot) : null;
|
|
2801
2689
|
if (!snapshotSummary) {
|
|
2802
|
-
|
|
2690
|
+
_context13.next = 10;
|
|
2803
2691
|
break;
|
|
2804
2692
|
}
|
|
2805
|
-
return
|
|
2693
|
+
return _context13.abrupt("return", snapshotSummary);
|
|
2806
2694
|
case 10:
|
|
2807
2695
|
shouldFullRecalculateFromSnapshot = Boolean(originalSnapshot);
|
|
2808
2696
|
summaryProducts = shouldFullRecalculateFromSnapshot ? cloneDeep(tempOrder.products || []) : tempOrder.products;
|
|
@@ -2814,7 +2702,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2814
2702
|
totalRefundAmount = existedSummary.total_refund_amount || '0.00';
|
|
2815
2703
|
paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
|
|
2816
2704
|
if (salesSummary) {
|
|
2817
|
-
|
|
2705
|
+
_context13.next = 26;
|
|
2818
2706
|
break;
|
|
2819
2707
|
}
|
|
2820
2708
|
emptyBaseSummary = _objectSpread(_objectSpread(_objectSpread({}, createEmptySummary()), existedSummary), {}, {
|
|
@@ -2840,9 +2728,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2840
2728
|
previousSummary: existedSummary,
|
|
2841
2729
|
summary: emptySummary
|
|
2842
2730
|
});
|
|
2843
|
-
return
|
|
2731
|
+
return _context13.abrupt("return", this.store.summary);
|
|
2844
2732
|
case 26:
|
|
2845
|
-
|
|
2733
|
+
_context13.next = 28;
|
|
2846
2734
|
return salesSummary.getSummary(_objectSpread({
|
|
2847
2735
|
products: summaryProducts,
|
|
2848
2736
|
isPriceIncludeTax: tempOrder.is_price_include_tax,
|
|
@@ -2851,7 +2739,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2851
2739
|
channel: this.otherParams.channel
|
|
2852
2740
|
} : {}));
|
|
2853
2741
|
case 28:
|
|
2854
|
-
salesSummaryResult =
|
|
2742
|
+
salesSummaryResult = _context13.sent;
|
|
2855
2743
|
if (shouldFullRecalculateFromSnapshot) {
|
|
2856
2744
|
tempOrder.products = summaryProducts;
|
|
2857
2745
|
}
|
|
@@ -2896,14 +2784,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2896
2784
|
previousSummary: existedSummary,
|
|
2897
2785
|
summary: summary
|
|
2898
2786
|
});
|
|
2899
|
-
return
|
|
2787
|
+
return _context13.abrupt("return", this.store.summary);
|
|
2900
2788
|
case 46:
|
|
2901
2789
|
case "end":
|
|
2902
|
-
return
|
|
2790
|
+
return _context13.stop();
|
|
2903
2791
|
}
|
|
2904
|
-
},
|
|
2792
|
+
}, _callee11, this);
|
|
2905
2793
|
}));
|
|
2906
|
-
function recalculateSummary(
|
|
2794
|
+
function recalculateSummary(_x10) {
|
|
2907
2795
|
return _recalculateSummary.apply(this, arguments);
|
|
2908
2796
|
}
|
|
2909
2797
|
return recalculateSummary;
|
|
@@ -2911,30 +2799,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2911
2799
|
}, {
|
|
2912
2800
|
key: "getOrderSummary",
|
|
2913
2801
|
value: function () {
|
|
2914
|
-
var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2802
|
+
var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
2915
2803
|
var summary;
|
|
2916
|
-
return _regeneratorRuntime().wrap(function
|
|
2917
|
-
while (1) switch (
|
|
2804
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context14) {
|
|
2805
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
2918
2806
|
case 0:
|
|
2919
|
-
|
|
2807
|
+
_context14.next = 2;
|
|
2920
2808
|
return this.recalculateSummary({
|
|
2921
2809
|
createIfMissing: true
|
|
2922
2810
|
});
|
|
2923
2811
|
case 2:
|
|
2924
|
-
summary =
|
|
2812
|
+
summary = _context14.sent;
|
|
2925
2813
|
if (summary) {
|
|
2926
|
-
|
|
2814
|
+
_context14.next = 5;
|
|
2927
2815
|
break;
|
|
2928
2816
|
}
|
|
2929
|
-
return
|
|
2817
|
+
return _context14.abrupt("return", createEmptySummary());
|
|
2930
2818
|
case 5:
|
|
2931
2819
|
this.persistTempOrder();
|
|
2932
|
-
return
|
|
2820
|
+
return _context14.abrupt("return", summary);
|
|
2933
2821
|
case 7:
|
|
2934
2822
|
case "end":
|
|
2935
|
-
return
|
|
2823
|
+
return _context14.stop();
|
|
2936
2824
|
}
|
|
2937
|
-
},
|
|
2825
|
+
}, _callee12, this);
|
|
2938
2826
|
}));
|
|
2939
2827
|
function getOrderSummary() {
|
|
2940
2828
|
return _getOrderSummary.apply(this, arguments);
|
|
@@ -2958,23 +2846,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2958
2846
|
}, {
|
|
2959
2847
|
key: "syncTempOrderNoteToRemote",
|
|
2960
2848
|
value: function () {
|
|
2961
|
-
var _syncTempOrderNoteToRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2962
|
-
return _regeneratorRuntime().wrap(function
|
|
2963
|
-
while (1) switch (
|
|
2849
|
+
var _syncTempOrderNoteToRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderId, note) {
|
|
2850
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context15) {
|
|
2851
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
2964
2852
|
case 0:
|
|
2965
|
-
|
|
2853
|
+
_context15.next = 2;
|
|
2966
2854
|
return this.request.put("/order/order/".concat(orderId, "/note"), {
|
|
2967
2855
|
note: note
|
|
2968
2856
|
});
|
|
2969
2857
|
case 2:
|
|
2970
|
-
return
|
|
2858
|
+
return _context15.abrupt("return", note);
|
|
2971
2859
|
case 3:
|
|
2972
2860
|
case "end":
|
|
2973
|
-
return
|
|
2861
|
+
return _context15.stop();
|
|
2974
2862
|
}
|
|
2975
|
-
},
|
|
2863
|
+
}, _callee13, this);
|
|
2976
2864
|
}));
|
|
2977
|
-
function syncTempOrderNoteToRemote(
|
|
2865
|
+
function syncTempOrderNoteToRemote(_x11, _x12) {
|
|
2978
2866
|
return _syncTempOrderNoteToRemote.apply(this, arguments);
|
|
2979
2867
|
}
|
|
2980
2868
|
return syncTempOrderNoteToRemote;
|
|
@@ -3059,43 +2947,38 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3059
2947
|
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;
|
|
3060
2948
|
return type === 'good_pass' || type === 'discount_card' || type === 'product_discount_card';
|
|
3061
2949
|
}
|
|
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
|
-
}
|
|
3067
2950
|
}, {
|
|
3068
2951
|
key: "productHasCustomerBoundDiscount",
|
|
3069
2952
|
value: function productHasCustomerBoundDiscount(product) {
|
|
3070
|
-
var
|
|
2953
|
+
var _this16 = this;
|
|
3071
2954
|
if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
|
|
3072
|
-
return
|
|
2955
|
+
return _this16.isCustomerBoundDiscount(discount);
|
|
3073
2956
|
})) {
|
|
3074
2957
|
return true;
|
|
3075
2958
|
}
|
|
3076
2959
|
return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
|
|
3077
2960
|
return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
|
|
3078
|
-
return
|
|
2961
|
+
return _this16.isCustomerBoundDiscount(discount);
|
|
3079
2962
|
});
|
|
3080
2963
|
});
|
|
3081
2964
|
}
|
|
3082
2965
|
}, {
|
|
3083
2966
|
key: "shouldSkipDiscountCalculation",
|
|
3084
2967
|
value: function shouldSkipDiscountCalculation(tempOrder) {
|
|
3085
|
-
var _this$store$
|
|
3086
|
-
_this$store$
|
|
3087
|
-
|
|
2968
|
+
var _this$store$discount13,
|
|
2969
|
+
_this$store$discount14,
|
|
2970
|
+
_this17 = this;
|
|
3088
2971
|
if (this.hasActiveCustomerBoundDiscount) return false;
|
|
3089
|
-
var discountList = ((_this$store$
|
|
2972
|
+
var discountList = ((_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 || (_this$store$discount14 = _this$store$discount13.getDiscountList) === null || _this$store$discount14 === void 0 ? void 0 : _this$store$discount14.call(_this$store$discount13)) || [];
|
|
3090
2973
|
if (discountList.length > 0) return false;
|
|
3091
2974
|
return !(tempOrder.products || []).some(function (product) {
|
|
3092
|
-
return
|
|
2975
|
+
return _this17.productHasCustomerBoundDiscount(product);
|
|
3093
2976
|
});
|
|
3094
2977
|
}
|
|
3095
2978
|
}, {
|
|
3096
2979
|
key: "clearCustomerBoundDiscounts",
|
|
3097
2980
|
value: function clearCustomerBoundDiscounts(tempOrder) {
|
|
3098
|
-
var
|
|
2981
|
+
var _this18 = this,
|
|
3099
2982
|
_discountModule$getDi,
|
|
3100
2983
|
_discountModule$getOr,
|
|
3101
2984
|
_discountModule$setDi,
|
|
@@ -3104,7 +2987,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3104
2987
|
var filterDiscountList = function filterDiscountList(discountList) {
|
|
3105
2988
|
if (!Array.isArray(discountList)) return [];
|
|
3106
2989
|
return discountList.filter(function (discount) {
|
|
3107
|
-
var shouldRemove =
|
|
2990
|
+
var shouldRemove = _this18.isCustomerBoundDiscount(discount);
|
|
3108
2991
|
if (shouldRemove) didRemoveCustomerBoundDiscount = true;
|
|
3109
2992
|
return !shouldRemove;
|
|
3110
2993
|
});
|
|
@@ -3131,12 +3014,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3131
3014
|
var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
|
|
3132
3015
|
var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
|
|
3133
3016
|
var nextDiscounts = currentDiscounts.filter(function (discount) {
|
|
3134
|
-
if (
|
|
3135
|
-
return !
|
|
3017
|
+
if (discount !== null && discount !== void 0 && discount.isEditMode) return true;
|
|
3018
|
+
return !_this18.isCustomerBoundDiscount(discount);
|
|
3136
3019
|
});
|
|
3137
3020
|
var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
|
|
3138
|
-
if (
|
|
3139
|
-
return !
|
|
3021
|
+
if (discount !== null && discount !== void 0 && discount.isEditMode) return true;
|
|
3022
|
+
return !_this18.isCustomerBoundDiscount(discount);
|
|
3140
3023
|
});
|
|
3141
3024
|
void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
|
|
3142
3025
|
void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
|
|
@@ -3207,7 +3090,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3207
3090
|
}
|
|
3208
3091
|
var nextCustomerId = (_tempOrder$customer_i5 = tempOrder.customer_id) !== null && _tempOrder$customer_i5 !== void 0 ? _tempOrder$customer_i5 : null;
|
|
3209
3092
|
if (String(previousCustomerId !== null && previousCustomerId !== void 0 ? previousCustomerId : '') !== String(nextCustomerId !== null && nextCustomerId !== void 0 ? nextCustomerId : '')) {
|
|
3210
|
-
this.store.availableWalletIds = [];
|
|
3211
3093
|
clearTempOrderHolderAssignments(tempOrder);
|
|
3212
3094
|
this.clearCustomerBoundDiscounts(tempOrder);
|
|
3213
3095
|
this.applyDiscount();
|
|
@@ -3252,7 +3134,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3252
3134
|
tempOrder.email = '';
|
|
3253
3135
|
tempOrder.customer = null;
|
|
3254
3136
|
if (tempOrder._extend) delete tempOrder._extend.customerSnapshot;
|
|
3255
|
-
this.store.availableWalletIds = [];
|
|
3256
3137
|
this.clearCustomerBoundDiscounts(tempOrder);
|
|
3257
3138
|
this.persistTempOrder();
|
|
3258
3139
|
this.saveDraftInBackground();
|
|
@@ -3306,7 +3187,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3306
3187
|
}, {
|
|
3307
3188
|
key: "addOrderPayment",
|
|
3308
3189
|
value: function addOrderPayment(payment) {
|
|
3309
|
-
var
|
|
3190
|
+
var _this19 = this;
|
|
3310
3191
|
this.logInfo('addOrderPayment', {
|
|
3311
3192
|
payment: payment
|
|
3312
3193
|
});
|
|
@@ -3323,7 +3204,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3323
3204
|
void this.recalculateSummary({
|
|
3324
3205
|
createIfMissing: true
|
|
3325
3206
|
}).catch(function (error) {
|
|
3326
|
-
|
|
3207
|
+
_this19.logError('recalculate summary after addOrderPayment failed', {
|
|
3327
3208
|
error: error instanceof Error ? error.message : String(error)
|
|
3328
3209
|
});
|
|
3329
3210
|
});
|
|
@@ -3405,7 +3286,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3405
3286
|
}, {
|
|
3406
3287
|
key: "applyPaymentLifecycleChange",
|
|
3407
3288
|
value: function applyPaymentLifecycleChange(tempOrder, options) {
|
|
3408
|
-
var
|
|
3289
|
+
var _this20 = this;
|
|
3409
3290
|
this.updateTempOrderPaymentStatus(tempOrder);
|
|
3410
3291
|
if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
|
|
3411
3292
|
this.persistTempOrder();
|
|
@@ -3415,7 +3296,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3415
3296
|
void this.recalculateSummary({
|
|
3416
3297
|
createIfMissing: true
|
|
3417
3298
|
}).catch(function (error) {
|
|
3418
|
-
|
|
3299
|
+
_this20.logError("recalculate summary after ".concat(logContext, " failed"), {
|
|
3419
3300
|
error: error instanceof Error ? error.message : String(error)
|
|
3420
3301
|
});
|
|
3421
3302
|
});
|
|
@@ -3459,7 +3340,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3459
3340
|
}, {
|
|
3460
3341
|
key: "updateVoucherOrderPayments",
|
|
3461
3342
|
value: function updateVoucherOrderPayments(payments, options) {
|
|
3462
|
-
var
|
|
3343
|
+
var _this21 = this;
|
|
3463
3344
|
var tempOrder = this.ensureTempOrder();
|
|
3464
3345
|
var isOrderPaymentType = function isOrderPaymentType(value) {
|
|
3465
3346
|
return value === 'normal' || value === 'deposit';
|
|
@@ -3494,7 +3375,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3494
3375
|
});
|
|
3495
3376
|
};
|
|
3496
3377
|
var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
|
|
3497
|
-
return
|
|
3378
|
+
return _this21.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
|
|
3498
3379
|
defaultPaid: false
|
|
3499
3380
|
});
|
|
3500
3381
|
})).filter(function (payment) {
|
|
@@ -3543,7 +3424,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3543
3424
|
void this.recalculateSummary({
|
|
3544
3425
|
createIfMissing: true
|
|
3545
3426
|
}).catch(function (error) {
|
|
3546
|
-
|
|
3427
|
+
_this21.logError('recalculate summary after updateVoucherOrderPayments failed', {
|
|
3547
3428
|
error: error instanceof Error ? error.message : String(error)
|
|
3548
3429
|
});
|
|
3549
3430
|
});
|
|
@@ -3552,45 +3433,45 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3552
3433
|
}, {
|
|
3553
3434
|
key: "shouldMergeProductToOrder",
|
|
3554
3435
|
value: function () {
|
|
3555
|
-
var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3436
|
+
var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(params) {
|
|
3556
3437
|
var _this$orderHooks;
|
|
3557
3438
|
var onBeforeMergeProductToOrder, result;
|
|
3558
|
-
return _regeneratorRuntime().wrap(function
|
|
3559
|
-
while (1) switch (
|
|
3439
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context16) {
|
|
3440
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
3560
3441
|
case 0:
|
|
3561
3442
|
onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
|
|
3562
3443
|
if (onBeforeMergeProductToOrder) {
|
|
3563
|
-
|
|
3444
|
+
_context16.next = 3;
|
|
3564
3445
|
break;
|
|
3565
3446
|
}
|
|
3566
|
-
return
|
|
3447
|
+
return _context16.abrupt("return", true);
|
|
3567
3448
|
case 3:
|
|
3568
|
-
|
|
3449
|
+
_context16.next = 5;
|
|
3569
3450
|
return onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
3570
3451
|
defaultShouldMerge: true
|
|
3571
3452
|
}));
|
|
3572
3453
|
case 5:
|
|
3573
|
-
result =
|
|
3454
|
+
result = _context16.sent;
|
|
3574
3455
|
if (!(typeof result === 'boolean')) {
|
|
3575
|
-
|
|
3456
|
+
_context16.next = 8;
|
|
3576
3457
|
break;
|
|
3577
3458
|
}
|
|
3578
|
-
return
|
|
3459
|
+
return _context16.abrupt("return", result);
|
|
3579
3460
|
case 8:
|
|
3580
3461
|
if (!(result && _typeof(result) === 'object' && typeof result.shouldMerge === 'boolean')) {
|
|
3581
|
-
|
|
3462
|
+
_context16.next = 10;
|
|
3582
3463
|
break;
|
|
3583
3464
|
}
|
|
3584
|
-
return
|
|
3465
|
+
return _context16.abrupt("return", result.shouldMerge);
|
|
3585
3466
|
case 10:
|
|
3586
|
-
return
|
|
3467
|
+
return _context16.abrupt("return", true);
|
|
3587
3468
|
case 11:
|
|
3588
3469
|
case "end":
|
|
3589
|
-
return
|
|
3470
|
+
return _context16.stop();
|
|
3590
3471
|
}
|
|
3591
|
-
},
|
|
3472
|
+
}, _callee14, this);
|
|
3592
3473
|
}));
|
|
3593
|
-
function shouldMergeProductToOrder(
|
|
3474
|
+
function shouldMergeProductToOrder(_x13) {
|
|
3594
3475
|
return _shouldMergeProductToOrder.apply(this, arguments);
|
|
3595
3476
|
}
|
|
3596
3477
|
return shouldMergeProductToOrder;
|
|
@@ -3626,30 +3507,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3626
3507
|
}, {
|
|
3627
3508
|
key: "finalizeProductOrderMutation",
|
|
3628
3509
|
value: function () {
|
|
3629
|
-
var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3630
|
-
return _regeneratorRuntime().wrap(function
|
|
3631
|
-
while (1) switch (
|
|
3510
|
+
var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(tempOrder, options) {
|
|
3511
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context17) {
|
|
3512
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
3632
3513
|
case 0:
|
|
3633
3514
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
3634
3515
|
if (options !== null && options !== void 0 && options.skipEditDiscountConfigRefresh) {
|
|
3635
|
-
|
|
3516
|
+
_context17.next = 4;
|
|
3636
3517
|
break;
|
|
3637
3518
|
}
|
|
3638
|
-
|
|
3519
|
+
_context17.next = 4;
|
|
3639
3520
|
return this.ensureEditDiscountConfigForProductChange(tempOrder);
|
|
3640
3521
|
case 4:
|
|
3641
3522
|
if (options !== null && options !== void 0 && options.skipDiscountRecalculation) {
|
|
3642
|
-
|
|
3523
|
+
_context17.next = 7;
|
|
3643
3524
|
break;
|
|
3644
3525
|
}
|
|
3645
|
-
|
|
3526
|
+
_context17.next = 7;
|
|
3646
3527
|
return this.applyPromotion();
|
|
3647
3528
|
case 7:
|
|
3648
3529
|
if (!(options !== null && options !== void 0 && options.skipDiscountRecalculation)) {
|
|
3649
3530
|
this.applyDiscount();
|
|
3650
3531
|
}
|
|
3651
3532
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
3652
|
-
|
|
3533
|
+
_context17.next = 11;
|
|
3653
3534
|
return this.recalculateSummary({
|
|
3654
3535
|
createIfMissing: true
|
|
3655
3536
|
});
|
|
@@ -3657,11 +3538,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3657
3538
|
this.persistTempOrder();
|
|
3658
3539
|
case 12:
|
|
3659
3540
|
case "end":
|
|
3660
|
-
return
|
|
3541
|
+
return _context17.stop();
|
|
3661
3542
|
}
|
|
3662
|
-
},
|
|
3543
|
+
}, _callee15, this);
|
|
3663
3544
|
}));
|
|
3664
|
-
function finalizeProductOrderMutation(
|
|
3545
|
+
function finalizeProductOrderMutation(_x14, _x15) {
|
|
3665
3546
|
return _finalizeProductOrderMutation.apply(this, arguments);
|
|
3666
3547
|
}
|
|
3667
3548
|
return finalizeProductOrderMutation;
|
|
@@ -3676,13 +3557,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3676
3557
|
}, {
|
|
3677
3558
|
key: "appendProductLineToTempOrder",
|
|
3678
3559
|
value: (function () {
|
|
3679
|
-
var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3560
|
+
var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(tempOrder, product, booking) {
|
|
3680
3561
|
var _booking_uid,
|
|
3681
3562
|
_metadata,
|
|
3682
|
-
|
|
3563
|
+
_this22 = this;
|
|
3683
3564
|
var linked, productToAdd, incomingFingerprint, normalizedIncoming, incomingBookingUid, hasIncomingGoodPass, hasIncomingProductNote, hasIncomingBookingUid, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList;
|
|
3684
|
-
return _regeneratorRuntime().wrap(function
|
|
3685
|
-
while (1) switch (
|
|
3565
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context18) {
|
|
3566
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
3686
3567
|
case 0:
|
|
3687
3568
|
linked = booking ? this.createLinkedProductAndBooking({
|
|
3688
3569
|
product: product,
|
|
@@ -3704,11 +3585,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3704
3585
|
hasIncomingBookingUid = this.hasLinkedBookingUid(productToAdd) || this.hasLinkedBookingUid(normalizedIncoming);
|
|
3705
3586
|
shouldForceNewLine = !!booking || hasIncomingProductNote || hasIncomingBookingUid;
|
|
3706
3587
|
matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
3707
|
-
|
|
3708
|
-
if (
|
|
3709
|
-
if (_this23.hasOrderProductLineNote(item)) return false;
|
|
3588
|
+
if (_this22.hasGoodPassDiscount(item)) return false;
|
|
3589
|
+
if (_this22.hasOrderProductLineNote(item)) return false;
|
|
3710
3590
|
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;
|
|
3712
3591
|
if (item.product_id !== productToAdd.product_id) return false;
|
|
3713
3592
|
if (item.product_variant_id !== productToAdd.product_variant_id) return false;
|
|
3714
3593
|
var existedFingerprint = buildProductLineFingerprint(getProductSkuOptions(item), item.product_bundle);
|
|
@@ -3717,10 +3596,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3717
3596
|
matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
|
|
3718
3597
|
existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
|
|
3719
3598
|
if (!matchedProduct) {
|
|
3720
|
-
|
|
3599
|
+
_context18.next = 20;
|
|
3721
3600
|
break;
|
|
3722
3601
|
}
|
|
3723
|
-
|
|
3602
|
+
_context18.next = 17;
|
|
3724
3603
|
return this.shouldMergeProductToOrder({
|
|
3725
3604
|
incomingProduct: productToAdd,
|
|
3726
3605
|
normalizedIncoming: normalizedIncoming,
|
|
@@ -3732,13 +3611,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3732
3611
|
booking: booking
|
|
3733
3612
|
});
|
|
3734
3613
|
case 17:
|
|
3735
|
-
|
|
3736
|
-
|
|
3614
|
+
_context18.t0 = _context18.sent;
|
|
3615
|
+
_context18.next = 21;
|
|
3737
3616
|
break;
|
|
3738
3617
|
case 20:
|
|
3739
|
-
|
|
3618
|
+
_context18.t0 = false;
|
|
3740
3619
|
case 21:
|
|
3741
|
-
shouldMerge =
|
|
3620
|
+
shouldMerge = _context18.t0;
|
|
3742
3621
|
if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
|
|
3743
3622
|
this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
|
|
3744
3623
|
if (linked) {
|
|
@@ -3792,11 +3671,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3792
3671
|
}
|
|
3793
3672
|
case 24:
|
|
3794
3673
|
case "end":
|
|
3795
|
-
return
|
|
3674
|
+
return _context18.stop();
|
|
3796
3675
|
}
|
|
3797
|
-
},
|
|
3676
|
+
}, _callee16, this);
|
|
3798
3677
|
}));
|
|
3799
|
-
function appendProductLineToTempOrder(_x17, _x18
|
|
3678
|
+
function appendProductLineToTempOrder(_x16, _x17, _x18) {
|
|
3800
3679
|
return _appendProductLineToTempOrder.apply(this, arguments);
|
|
3801
3680
|
}
|
|
3802
3681
|
return appendProductLineToTempOrder;
|
|
@@ -3812,61 +3691,61 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3812
3691
|
}, {
|
|
3813
3692
|
key: "addProductToOrder",
|
|
3814
3693
|
value: (function () {
|
|
3815
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3694
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(product, booking) {
|
|
3816
3695
|
var tempOrder, _ref61, _productRecord$num, productRecord, splitCount, i, singleLine;
|
|
3817
|
-
return _regeneratorRuntime().wrap(function
|
|
3818
|
-
while (1) switch (
|
|
3696
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context19) {
|
|
3697
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
3819
3698
|
case 0:
|
|
3820
3699
|
tempOrder = this.ensureTempOrder();
|
|
3821
3700
|
if (!booking) {
|
|
3822
|
-
|
|
3701
|
+
_context19.next = 18;
|
|
3823
3702
|
break;
|
|
3824
3703
|
}
|
|
3825
3704
|
productRecord = product;
|
|
3826
3705
|
splitCount = getSafeProductNum((_ref61 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref61 !== void 0 ? _ref61 : 1);
|
|
3827
3706
|
if (!(splitCount > 1)) {
|
|
3828
|
-
|
|
3707
|
+
_context19.next = 18;
|
|
3829
3708
|
break;
|
|
3830
3709
|
}
|
|
3831
3710
|
i = 0;
|
|
3832
3711
|
case 6:
|
|
3833
3712
|
if (!(i < splitCount)) {
|
|
3834
|
-
|
|
3713
|
+
_context19.next = 15;
|
|
3835
3714
|
break;
|
|
3836
3715
|
}
|
|
3837
3716
|
singleLine = cloneDeep(productRecord);
|
|
3838
3717
|
singleLine.num = 1;
|
|
3839
3718
|
delete singleLine.product_quantity;
|
|
3840
|
-
|
|
3719
|
+
_context19.next = 12;
|
|
3841
3720
|
return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
|
|
3842
3721
|
case 12:
|
|
3843
3722
|
i += 1;
|
|
3844
|
-
|
|
3723
|
+
_context19.next = 6;
|
|
3845
3724
|
break;
|
|
3846
3725
|
case 15:
|
|
3847
|
-
|
|
3726
|
+
_context19.next = 17;
|
|
3848
3727
|
return this.finalizeProductOrderMutation(tempOrder);
|
|
3849
3728
|
case 17:
|
|
3850
|
-
return
|
|
3729
|
+
return _context19.abrupt("return", tempOrder.products);
|
|
3851
3730
|
case 18:
|
|
3852
|
-
|
|
3731
|
+
_context19.next = 20;
|
|
3853
3732
|
return this.appendProductLineToTempOrder(tempOrder, product, booking);
|
|
3854
3733
|
case 20:
|
|
3855
|
-
|
|
3734
|
+
_context19.next = 22;
|
|
3856
3735
|
return this.finalizeProductOrderMutation(tempOrder);
|
|
3857
3736
|
case 22:
|
|
3858
3737
|
this.logInfo('addProductToOrder success', {
|
|
3859
3738
|
product_id: product.product_id,
|
|
3860
3739
|
with_booking: !!booking
|
|
3861
3740
|
});
|
|
3862
|
-
return
|
|
3741
|
+
return _context19.abrupt("return", tempOrder.products);
|
|
3863
3742
|
case 24:
|
|
3864
3743
|
case "end":
|
|
3865
|
-
return
|
|
3744
|
+
return _context19.stop();
|
|
3866
3745
|
}
|
|
3867
|
-
},
|
|
3746
|
+
}, _callee17, this);
|
|
3868
3747
|
}));
|
|
3869
|
-
function addProductToOrder(
|
|
3748
|
+
function addProductToOrder(_x19, _x20) {
|
|
3870
3749
|
return _addProductToOrder.apply(this, arguments);
|
|
3871
3750
|
}
|
|
3872
3751
|
return addProductToOrder;
|
|
@@ -3884,93 +3763,93 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3884
3763
|
}, {
|
|
3885
3764
|
key: "addProductsToOrder",
|
|
3886
3765
|
value: (function () {
|
|
3887
|
-
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3766
|
+
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(items, options) {
|
|
3888
3767
|
var tempOrder, _iterator20, _step20, item, product, booking, _ref62, _productRecord$num2, productRecord, splitCount, i, singleLine;
|
|
3889
|
-
return _regeneratorRuntime().wrap(function
|
|
3890
|
-
while (1) switch (
|
|
3768
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context20) {
|
|
3769
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
3891
3770
|
case 0:
|
|
3892
3771
|
tempOrder = this.ensureTempOrder();
|
|
3893
3772
|
if (!(!Array.isArray(items) || items.length === 0)) {
|
|
3894
|
-
|
|
3773
|
+
_context20.next = 3;
|
|
3895
3774
|
break;
|
|
3896
3775
|
}
|
|
3897
|
-
return
|
|
3776
|
+
return _context20.abrupt("return", tempOrder.products);
|
|
3898
3777
|
case 3:
|
|
3899
3778
|
_iterator20 = _createForOfIteratorHelper(items || []);
|
|
3900
|
-
|
|
3779
|
+
_context20.prev = 4;
|
|
3901
3780
|
_iterator20.s();
|
|
3902
3781
|
case 6:
|
|
3903
3782
|
if ((_step20 = _iterator20.n()).done) {
|
|
3904
|
-
|
|
3783
|
+
_context20.next = 30;
|
|
3905
3784
|
break;
|
|
3906
3785
|
}
|
|
3907
3786
|
item = _step20.value;
|
|
3908
3787
|
product = item.product, booking = item.booking;
|
|
3909
3788
|
if (product) {
|
|
3910
|
-
|
|
3789
|
+
_context20.next = 11;
|
|
3911
3790
|
break;
|
|
3912
3791
|
}
|
|
3913
|
-
return
|
|
3792
|
+
return _context20.abrupt("continue", 28);
|
|
3914
3793
|
case 11:
|
|
3915
3794
|
if (!booking) {
|
|
3916
|
-
|
|
3795
|
+
_context20.next = 26;
|
|
3917
3796
|
break;
|
|
3918
3797
|
}
|
|
3919
3798
|
productRecord = product;
|
|
3920
3799
|
splitCount = getSafeProductNum((_ref62 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref62 !== void 0 ? _ref62 : 1);
|
|
3921
3800
|
if (!(splitCount > 1)) {
|
|
3922
|
-
|
|
3801
|
+
_context20.next = 26;
|
|
3923
3802
|
break;
|
|
3924
3803
|
}
|
|
3925
3804
|
i = 0;
|
|
3926
3805
|
case 16:
|
|
3927
3806
|
if (!(i < splitCount)) {
|
|
3928
|
-
|
|
3807
|
+
_context20.next = 25;
|
|
3929
3808
|
break;
|
|
3930
3809
|
}
|
|
3931
3810
|
singleLine = cloneDeep(productRecord);
|
|
3932
3811
|
singleLine.num = 1;
|
|
3933
3812
|
delete singleLine.product_quantity;
|
|
3934
|
-
|
|
3813
|
+
_context20.next = 22;
|
|
3935
3814
|
return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
|
|
3936
3815
|
case 22:
|
|
3937
3816
|
i += 1;
|
|
3938
|
-
|
|
3817
|
+
_context20.next = 16;
|
|
3939
3818
|
break;
|
|
3940
3819
|
case 25:
|
|
3941
|
-
return
|
|
3820
|
+
return _context20.abrupt("continue", 28);
|
|
3942
3821
|
case 26:
|
|
3943
|
-
|
|
3822
|
+
_context20.next = 28;
|
|
3944
3823
|
return this.appendProductLineToTempOrder(tempOrder, product, booking);
|
|
3945
3824
|
case 28:
|
|
3946
|
-
|
|
3825
|
+
_context20.next = 6;
|
|
3947
3826
|
break;
|
|
3948
3827
|
case 30:
|
|
3949
|
-
|
|
3828
|
+
_context20.next = 35;
|
|
3950
3829
|
break;
|
|
3951
3830
|
case 32:
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
_iterator20.e(
|
|
3831
|
+
_context20.prev = 32;
|
|
3832
|
+
_context20.t0 = _context20["catch"](4);
|
|
3833
|
+
_iterator20.e(_context20.t0);
|
|
3955
3834
|
case 35:
|
|
3956
|
-
|
|
3835
|
+
_context20.prev = 35;
|
|
3957
3836
|
_iterator20.f();
|
|
3958
|
-
return
|
|
3837
|
+
return _context20.finish(35);
|
|
3959
3838
|
case 38:
|
|
3960
|
-
|
|
3839
|
+
_context20.next = 40;
|
|
3961
3840
|
return this.finalizeProductOrderMutation(tempOrder, options);
|
|
3962
3841
|
case 40:
|
|
3963
3842
|
this.logInfo('addProductsToOrder success', {
|
|
3964
3843
|
itemsCount: items.length
|
|
3965
3844
|
});
|
|
3966
|
-
return
|
|
3845
|
+
return _context20.abrupt("return", tempOrder.products);
|
|
3967
3846
|
case 42:
|
|
3968
3847
|
case "end":
|
|
3969
|
-
return
|
|
3848
|
+
return _context20.stop();
|
|
3970
3849
|
}
|
|
3971
|
-
},
|
|
3850
|
+
}, _callee18, this, [[4, 32, 35, 38]]);
|
|
3972
3851
|
}));
|
|
3973
|
-
function addProductsToOrder(
|
|
3852
|
+
function addProductsToOrder(_x21, _x22) {
|
|
3974
3853
|
return _addProductsToOrder.apply(this, arguments);
|
|
3975
3854
|
}
|
|
3976
3855
|
return addProductsToOrder;
|
|
@@ -4004,21 +3883,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4004
3883
|
}, {
|
|
4005
3884
|
key: "preservePersistedBundlePriceFields",
|
|
4006
3885
|
value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
|
|
4007
|
-
var
|
|
3886
|
+
var _this23 = this;
|
|
4008
3887
|
if (!Array.isArray(nextBundles)) return nextBundles;
|
|
4009
3888
|
if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
|
|
4010
3889
|
var previousByIdentity = new Map();
|
|
4011
3890
|
previousBundles.forEach(function (bundle) {
|
|
4012
|
-
var identity =
|
|
3891
|
+
var identity = _this23.getBundleRuntimeIdentity(bundle);
|
|
4013
3892
|
if (identity) previousByIdentity.set(identity, bundle);
|
|
4014
3893
|
});
|
|
4015
3894
|
return nextBundles.map(function (bundle, index) {
|
|
4016
3895
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
4017
|
-
var previous = previousByIdentity.get(
|
|
3896
|
+
var previous = previousByIdentity.get(_this23.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
|
|
4018
3897
|
if (!previous || _typeof(previous) !== 'object') return bundle;
|
|
4019
|
-
return _objectSpread(_objectSpread(
|
|
4020
|
-
cover: previous.cover
|
|
4021
|
-
} : {}), {}, {
|
|
3898
|
+
return _objectSpread(_objectSpread({}, bundle), {}, {
|
|
4022
3899
|
price: previous.price,
|
|
4023
3900
|
custom_price: previous.custom_price,
|
|
4024
3901
|
bundle_payment_price: previous.bundle_payment_price,
|
|
@@ -4031,7 +3908,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4031
3908
|
}, {
|
|
4032
3909
|
key: "applyOrderProductUpdateToTempOrder",
|
|
4033
3910
|
value: function applyOrderProductUpdateToTempOrder(tempOrder, params) {
|
|
4034
|
-
var _targetProduct$metada2, _product_sku, _metadata2, _metadata3, _metadata4, _metadata5, _metadata6, _metadata7,
|
|
3911
|
+
var _targetProduct$metada2, _product_sku, _metadata2, _metadata3, _metadata4, _metadata5, _metadata6, _metadata7, _nextProduct$metadata, _targetProduct$metada8, _tempOrder$products$p;
|
|
4035
3912
|
var product_id = params.product_id,
|
|
4036
3913
|
product_variant_id = params.product_variant_id,
|
|
4037
3914
|
updates = params.updates,
|
|
@@ -4059,8 +3936,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4059
3936
|
if (unique_identification_number !== undefined) {
|
|
4060
3937
|
var targetUid = String(unique_identification_number);
|
|
4061
3938
|
productIndex = tempOrder.products.findIndex(function (item) {
|
|
4062
|
-
var _item$
|
|
4063
|
-
return String(((_item$
|
|
3939
|
+
var _item$metadata3;
|
|
3940
|
+
return String(((_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.unique_identification_number) || item.unique_identification_number || '') === targetUid;
|
|
4064
3941
|
});
|
|
4065
3942
|
}
|
|
4066
3943
|
if (productIndex === -1) {
|
|
@@ -4091,16 +3968,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4091
3968
|
// 如果 caller 走推荐路径(updates.metadata.* 显式指定主价),保留 metadata 由 normalize 认它。
|
|
4092
3969
|
var callerUpdatesTopPrice = Object.prototype.hasOwnProperty.call(updates || {}, 'selling_price') || Object.prototype.hasOwnProperty.call(updates || {}, 'original_price');
|
|
4093
3970
|
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;
|
|
4101
3971
|
var isPersistedOrderLine = targetProduct.order_detail_id !== undefined && targetProduct.order_detail_id !== null;
|
|
4102
3972
|
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);
|
|
4103
|
-
var callerUpdatesManualPrice = (updates === null || updates === void 0 || (
|
|
3973
|
+
var callerUpdatesManualPrice = (updates === null || updates === void 0 || (_metadata5 = updates.metadata) === null || _metadata5 === void 0 ? void 0 : _metadata5.price_override) !== undefined || (updates === null || updates === void 0 || (_metadata6 = updates.metadata) === null || _metadata6 === void 0 ? void 0 : _metadata6.is_manual_discount) !== undefined || (updates === null || updates === void 0 || (_metadata7 = updates.metadata) === null || _metadata7 === void 0 ? void 0 : _metadata7.product_discount_reason) !== undefined || callerChangesDiscountList;
|
|
4104
3974
|
var callerAllowsBookingReprice = function () {
|
|
4105
3975
|
if (params.allow_booking_reprice !== true || !booking || !callerUpdatesTopPrice || !callerUpdatesMainMeta) {
|
|
4106
3976
|
return false;
|
|
@@ -4113,7 +3983,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4113
3983
|
};
|
|
4114
3984
|
return hasChangedPrice(updates.selling_price, targetProduct.selling_price) || hasChangedPrice(updates.original_price, targetProduct.original_price);
|
|
4115
3985
|
}();
|
|
4116
|
-
if (isPersistedOrderLine && !
|
|
3986
|
+
if (isPersistedOrderLine && !callerUpdatesManualPrice && !callerAllowsBookingReprice) {
|
|
4117
3987
|
var _targetProduct$metada3, _targetProduct$metada4, _targetProduct$metada5, _targetProduct$metada6, _targetProduct$metada7;
|
|
4118
3988
|
nextProduct.selling_price = targetProduct.selling_price;
|
|
4119
3989
|
nextProduct.original_price = targetProduct.original_price;
|
|
@@ -4125,60 +3995,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4125
3995
|
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
|
|
4126
3996
|
});
|
|
4127
3997
|
nextProduct.product_bundle = this.preservePersistedBundlePriceFields(targetProduct.product_bundle, nextProduct.product_bundle);
|
|
4128
|
-
} else if (
|
|
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 迁移到新价格。
|
|
3998
|
+
} else if (callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
4146
3999
|
var existedMeta = nextProduct.metadata || {};
|
|
4147
4000
|
nextProduct.metadata = _objectSpread({}, existedMeta);
|
|
4148
4001
|
delete nextProduct.metadata.source_product_price;
|
|
4149
4002
|
delete nextProduct.metadata.main_product_selling_price;
|
|
4150
4003
|
delete nextProduct.metadata.main_product_original_price;
|
|
4151
4004
|
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;
|
|
4176
4005
|
}
|
|
4177
4006
|
// normalizeOrderProduct 幂等:v2 metadata 存在 → 保留 main_product_* 折扣重算 composite;
|
|
4178
4007
|
// 否则 → 把顶层 selling_price 视作 source,派生 main_product_* 并写 price_schema_version: 2。
|
|
4179
4008
|
var normalizedProduct = mergeOrderProductDisplayFields(nextProduct, normalizeOrderProduct(nextProduct));
|
|
4180
4009
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
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$
|
|
4010
|
+
var preservedBookingUid = nextProduct.booking_uid || ((_nextProduct$metadata = nextProduct.metadata) === null || _nextProduct$metadata === void 0 ? void 0 : _nextProduct$metadata.booking_uid) || targetProduct.booking_uid || ((_targetProduct$metada8 = targetProduct.metadata) === null || _targetProduct$metada8 === void 0 ? void 0 : _targetProduct$metada8.booking_uid);
|
|
4182
4011
|
if (!booking && preservedBookingUid) {
|
|
4183
4012
|
normalizedProduct.booking_uid = preservedBookingUid;
|
|
4184
4013
|
normalizedProduct.metadata = _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
|
|
@@ -4186,8 +4015,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4186
4015
|
});
|
|
4187
4016
|
}
|
|
4188
4017
|
if (booking) {
|
|
4189
|
-
var _normalizedProduct$me, _targetProduct$
|
|
4190
|
-
var productUid = String(((_normalizedProduct$me = normalizedProduct.metadata) === null || _normalizedProduct$me === void 0 ? void 0 : _normalizedProduct$me.unique_identification_number) || ((_targetProduct$
|
|
4018
|
+
var _normalizedProduct$me, _targetProduct$metada9;
|
|
4019
|
+
var productUid = String(((_normalizedProduct$me = normalizedProduct.metadata) === null || _normalizedProduct$me === void 0 ? void 0 : _normalizedProduct$me.unique_identification_number) || ((_targetProduct$metada9 = targetProduct.metadata) === null || _targetProduct$metada9 === void 0 ? void 0 : _targetProduct$metada9.unique_identification_number) || unique_identification_number || createUuidV4());
|
|
4191
4020
|
normalizedProduct.metadata = _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
|
|
4192
4021
|
unique_identification_number: productUid
|
|
4193
4022
|
});
|
|
@@ -4210,26 +4039,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4210
4039
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
4211
4040
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
4212
4041
|
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;
|
|
4214
4042
|
}
|
|
4215
4043
|
}, {
|
|
4216
4044
|
key: "updateOrderProduct",
|
|
4217
4045
|
value: function () {
|
|
4218
|
-
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4219
|
-
var tempOrder
|
|
4220
|
-
return _regeneratorRuntime().wrap(function
|
|
4221
|
-
while (1) switch (
|
|
4046
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
|
|
4047
|
+
var tempOrder;
|
|
4048
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context21) {
|
|
4049
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
4222
4050
|
case 0:
|
|
4223
4051
|
tempOrder = this.ensureTempOrder();
|
|
4224
|
-
|
|
4225
|
-
|
|
4052
|
+
this.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
4053
|
+
_context21.next = 4;
|
|
4226
4054
|
return this.applyPromotion();
|
|
4227
4055
|
case 4:
|
|
4228
|
-
this.applyDiscount(
|
|
4229
|
-
reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
|
|
4230
|
-
});
|
|
4056
|
+
this.applyDiscount();
|
|
4231
4057
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4232
|
-
|
|
4058
|
+
_context21.next = 8;
|
|
4233
4059
|
return this.recalculateSummary({
|
|
4234
4060
|
createIfMissing: true
|
|
4235
4061
|
});
|
|
@@ -4238,14 +4064,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4238
4064
|
this.logInfo('updateOrderProduct success', {
|
|
4239
4065
|
params: params
|
|
4240
4066
|
});
|
|
4241
|
-
return
|
|
4067
|
+
return _context21.abrupt("return", tempOrder.products);
|
|
4242
4068
|
case 11:
|
|
4243
4069
|
case "end":
|
|
4244
|
-
return
|
|
4070
|
+
return _context21.stop();
|
|
4245
4071
|
}
|
|
4246
|
-
},
|
|
4072
|
+
}, _callee19, this);
|
|
4247
4073
|
}));
|
|
4248
|
-
function updateOrderProduct(
|
|
4074
|
+
function updateOrderProduct(_x23) {
|
|
4249
4075
|
return _updateOrderProduct.apply(this, arguments);
|
|
4250
4076
|
}
|
|
4251
4077
|
return updateOrderProduct;
|
|
@@ -4253,43 +4079,36 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4253
4079
|
}, {
|
|
4254
4080
|
key: "updateOrderProducts",
|
|
4255
4081
|
value: function () {
|
|
4256
|
-
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4257
|
-
var
|
|
4258
|
-
var tempOrder
|
|
4259
|
-
return _regeneratorRuntime().wrap(function
|
|
4260
|
-
while (1) switch (
|
|
4082
|
+
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(paramsList) {
|
|
4083
|
+
var _this24 = this;
|
|
4084
|
+
var tempOrder;
|
|
4085
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context22) {
|
|
4086
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
4261
4087
|
case 0:
|
|
4262
4088
|
tempOrder = this.ensureTempOrder();
|
|
4263
4089
|
if (paramsList.length) {
|
|
4264
|
-
|
|
4090
|
+
_context22.next = 3;
|
|
4265
4091
|
break;
|
|
4266
4092
|
}
|
|
4267
|
-
return
|
|
4093
|
+
return _context22.abrupt("return", tempOrder.products);
|
|
4268
4094
|
case 3:
|
|
4269
|
-
|
|
4270
|
-
|
|
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
|
|
4095
|
+
paramsList.forEach(function (params) {
|
|
4096
|
+
_this24.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
4280
4097
|
});
|
|
4098
|
+
_context22.next = 6;
|
|
4099
|
+
return this.finalizeAfterProductsMutation(tempOrder);
|
|
4281
4100
|
case 6:
|
|
4282
4101
|
this.logInfo('updateOrderProduct success', {
|
|
4283
4102
|
paramsList: paramsList
|
|
4284
4103
|
});
|
|
4285
|
-
return
|
|
4104
|
+
return _context22.abrupt("return", tempOrder.products);
|
|
4286
4105
|
case 8:
|
|
4287
4106
|
case "end":
|
|
4288
|
-
return
|
|
4107
|
+
return _context22.stop();
|
|
4289
4108
|
}
|
|
4290
|
-
},
|
|
4109
|
+
}, _callee20, this);
|
|
4291
4110
|
}));
|
|
4292
|
-
function updateOrderProducts(
|
|
4111
|
+
function updateOrderProducts(_x24) {
|
|
4293
4112
|
return _updateOrderProducts.apply(this, arguments);
|
|
4294
4113
|
}
|
|
4295
4114
|
return updateOrderProducts;
|
|
@@ -4297,11 +4116,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4297
4116
|
}, {
|
|
4298
4117
|
key: "updateOrderProductQuantity",
|
|
4299
4118
|
value: function () {
|
|
4300
|
-
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4301
|
-
var _targetProduct$
|
|
4119
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
|
|
4120
|
+
var _targetProduct$metada10;
|
|
4302
4121
|
var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct;
|
|
4303
|
-
return _regeneratorRuntime().wrap(function
|
|
4304
|
-
while (1) switch (
|
|
4122
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context23) {
|
|
4123
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
4305
4124
|
case 0:
|
|
4306
4125
|
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;
|
|
4307
4126
|
tempOrder = this.ensureTempOrder();
|
|
@@ -4322,15 +4141,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4322
4141
|
if (unique_identification_number !== undefined) {
|
|
4323
4142
|
targetUid = String(unique_identification_number);
|
|
4324
4143
|
productIndex = tempOrder.products.findIndex(function (item) {
|
|
4325
|
-
var _item$
|
|
4326
|
-
return String(((_item$
|
|
4144
|
+
var _item$metadata4;
|
|
4145
|
+
return String(((_item$metadata4 = item.metadata) === null || _item$metadata4 === void 0 ? void 0 : _item$metadata4.unique_identification_number) || item.unique_identification_number || '') === targetUid;
|
|
4327
4146
|
});
|
|
4328
4147
|
}
|
|
4329
4148
|
if (productIndex === -1) {
|
|
4330
4149
|
productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
|
|
4331
4150
|
}
|
|
4332
4151
|
if (!(productIndex === -1)) {
|
|
4333
|
-
|
|
4152
|
+
_context23.next = 12;
|
|
4334
4153
|
break;
|
|
4335
4154
|
}
|
|
4336
4155
|
throw new Error('[Order] 目标商品不存在,无法更新数量');
|
|
@@ -4339,17 +4158,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4339
4158
|
normalizedProduct = normalizeOrderProduct(_objectSpread(_objectSpread({}, targetProduct), {}, {
|
|
4340
4159
|
num: getSafeProductNum(num),
|
|
4341
4160
|
metadata: _objectSpread(_objectSpread({}, targetProduct.metadata || {}), {}, {
|
|
4342
|
-
unique_identification_number: ((_targetProduct$
|
|
4161
|
+
unique_identification_number: ((_targetProduct$metada10 = targetProduct.metadata) === null || _targetProduct$metada10 === void 0 ? void 0 : _targetProduct$metada10.unique_identification_number) || unique_identification_number
|
|
4343
4162
|
})
|
|
4344
4163
|
}));
|
|
4345
4164
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
4346
4165
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
4347
|
-
|
|
4166
|
+
_context23.next = 18;
|
|
4348
4167
|
return this.applyPromotion();
|
|
4349
4168
|
case 18:
|
|
4350
4169
|
this.applyDiscount();
|
|
4351
4170
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4352
|
-
|
|
4171
|
+
_context23.next = 22;
|
|
4353
4172
|
return this.recalculateSummary({
|
|
4354
4173
|
createIfMissing: true
|
|
4355
4174
|
});
|
|
@@ -4358,14 +4177,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4358
4177
|
this.logInfo('updateOrderProductQuantity success', {
|
|
4359
4178
|
params: params
|
|
4360
4179
|
});
|
|
4361
|
-
return
|
|
4180
|
+
return _context23.abrupt("return", tempOrder.products);
|
|
4362
4181
|
case 25:
|
|
4363
4182
|
case "end":
|
|
4364
|
-
return
|
|
4183
|
+
return _context23.stop();
|
|
4365
4184
|
}
|
|
4366
|
-
},
|
|
4185
|
+
}, _callee21, this);
|
|
4367
4186
|
}));
|
|
4368
|
-
function updateOrderProductQuantity(
|
|
4187
|
+
function updateOrderProductQuantity(_x25) {
|
|
4369
4188
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
4370
4189
|
}
|
|
4371
4190
|
return updateOrderProductQuantity;
|
|
@@ -4406,19 +4225,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4406
4225
|
}, {
|
|
4407
4226
|
key: "finalizeAfterProductsMutation",
|
|
4408
4227
|
value: (function () {
|
|
4409
|
-
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4410
|
-
return _regeneratorRuntime().wrap(function
|
|
4411
|
-
while (1) switch (
|
|
4228
|
+
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(tempOrder) {
|
|
4229
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context24) {
|
|
4230
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
4412
4231
|
case 0:
|
|
4413
4232
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
4414
|
-
|
|
4233
|
+
_context24.next = 3;
|
|
4415
4234
|
return this.applyPromotion();
|
|
4416
4235
|
case 3:
|
|
4417
|
-
this.applyDiscount(
|
|
4418
|
-
reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids
|
|
4419
|
-
});
|
|
4236
|
+
this.applyDiscount();
|
|
4420
4237
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4421
|
-
|
|
4238
|
+
_context24.next = 7;
|
|
4422
4239
|
return this.recalculateSummary({
|
|
4423
4240
|
createIfMissing: true
|
|
4424
4241
|
});
|
|
@@ -4426,11 +4243,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4426
4243
|
this.persistTempOrder();
|
|
4427
4244
|
case 8:
|
|
4428
4245
|
case "end":
|
|
4429
|
-
return
|
|
4246
|
+
return _context24.stop();
|
|
4430
4247
|
}
|
|
4431
|
-
},
|
|
4248
|
+
}, _callee22, this);
|
|
4432
4249
|
}));
|
|
4433
|
-
function finalizeAfterProductsMutation(
|
|
4250
|
+
function finalizeAfterProductsMutation(_x26) {
|
|
4434
4251
|
return _finalizeAfterProductsMutation.apply(this, arguments);
|
|
4435
4252
|
}
|
|
4436
4253
|
return finalizeAfterProductsMutation;
|
|
@@ -4445,18 +4262,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4445
4262
|
}, {
|
|
4446
4263
|
key: "removeProductsFromOrder",
|
|
4447
4264
|
value: (function () {
|
|
4448
|
-
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4449
|
-
var
|
|
4265
|
+
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(identities) {
|
|
4266
|
+
var _this25 = this;
|
|
4450
4267
|
var tempOrder, productsBeforeRemove, bookingsBeforeRemove, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3;
|
|
4451
|
-
return _regeneratorRuntime().wrap(function
|
|
4452
|
-
while (1) switch (
|
|
4268
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context26) {
|
|
4269
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
4453
4270
|
case 0:
|
|
4454
4271
|
tempOrder = this.ensureTempOrder();
|
|
4455
4272
|
if (identities.length) {
|
|
4456
|
-
|
|
4273
|
+
_context26.next = 3;
|
|
4457
4274
|
break;
|
|
4458
4275
|
}
|
|
4459
|
-
return
|
|
4276
|
+
return _context26.abrupt("return", tempOrder.products);
|
|
4460
4277
|
case 3:
|
|
4461
4278
|
productsBeforeRemove = tempOrder.products || [];
|
|
4462
4279
|
bookingsBeforeRemove = tempOrder.bookings || [];
|
|
@@ -4479,29 +4296,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4479
4296
|
}
|
|
4480
4297
|
linkedBookingUidsToRemove = new Set();
|
|
4481
4298
|
_iterator21 = _createForOfIteratorHelper(matchedProducts);
|
|
4482
|
-
|
|
4299
|
+
_context26.prev = 11;
|
|
4483
4300
|
_loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
|
|
4484
|
-
var
|
|
4301
|
+
var _metadata8, _metadata9, _metadata10, _metadata11;
|
|
4485
4302
|
var product, productUid, productBookingUid, isAddTimeProduct;
|
|
4486
|
-
return _regeneratorRuntime().wrap(function _loop3$(
|
|
4487
|
-
while (1) switch (
|
|
4303
|
+
return _regeneratorRuntime().wrap(function _loop3$(_context25) {
|
|
4304
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
4488
4305
|
case 0:
|
|
4489
4306
|
product = _step21.value;
|
|
4490
|
-
productUid = (product === null || product === void 0 || (
|
|
4491
|
-
productBookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (
|
|
4492
|
-
isAddTimeProduct = (product === null || product === void 0 || (
|
|
4307
|
+
productUid = (product === null || product === void 0 || (_metadata8 = product.metadata) === null || _metadata8 === void 0 ? void 0 : _metadata8.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
4308
|
+
productBookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_metadata9 = product.metadata) === null || _metadata9 === void 0 ? void 0 : _metadata9.booking_uid);
|
|
4309
|
+
isAddTimeProduct = (product === null || product === void 0 || (_metadata10 = product.metadata) === null || _metadata10 === void 0 ? void 0 : _metadata10.product_add_schedule_time) !== undefined && (product === null || product === void 0 || (_metadata11 = product.metadata) === null || _metadata11 === void 0 ? void 0 : _metadata11.product_add_schedule_time) !== null;
|
|
4493
4310
|
if (!isAddTimeProduct) {
|
|
4494
|
-
|
|
4311
|
+
_context25.next = 6;
|
|
4495
4312
|
break;
|
|
4496
4313
|
}
|
|
4497
|
-
return
|
|
4314
|
+
return _context25.abrupt("return", 1);
|
|
4498
4315
|
case 6:
|
|
4499
4316
|
if (productBookingUid !== undefined && productBookingUid !== null && productBookingUid !== '') {
|
|
4500
4317
|
linkedBookingUidsToRemove.add(String(productBookingUid));
|
|
4501
4318
|
}
|
|
4502
4319
|
if (productUid !== undefined && productUid !== null && productUid !== '') {
|
|
4503
4320
|
bookingsBeforeRemove.forEach(function (booking) {
|
|
4504
|
-
var bookingUid =
|
|
4321
|
+
var bookingUid = _this25.getBookingUniqueIdentificationNumber(booking);
|
|
4505
4322
|
if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
|
|
4506
4323
|
linkedBookingUidsToRemove.add(bookingUid);
|
|
4507
4324
|
}
|
|
@@ -4509,37 +4326,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4509
4326
|
}
|
|
4510
4327
|
case 8:
|
|
4511
4328
|
case "end":
|
|
4512
|
-
return
|
|
4329
|
+
return _context25.stop();
|
|
4513
4330
|
}
|
|
4514
4331
|
}, _loop3);
|
|
4515
4332
|
});
|
|
4516
4333
|
_iterator21.s();
|
|
4517
4334
|
case 14:
|
|
4518
4335
|
if ((_step21 = _iterator21.n()).done) {
|
|
4519
|
-
|
|
4336
|
+
_context26.next = 20;
|
|
4520
4337
|
break;
|
|
4521
4338
|
}
|
|
4522
|
-
return
|
|
4339
|
+
return _context26.delegateYield(_loop3(), "t0", 16);
|
|
4523
4340
|
case 16:
|
|
4524
|
-
if (!
|
|
4525
|
-
|
|
4341
|
+
if (!_context26.t0) {
|
|
4342
|
+
_context26.next = 18;
|
|
4526
4343
|
break;
|
|
4527
4344
|
}
|
|
4528
|
-
return
|
|
4345
|
+
return _context26.abrupt("continue", 18);
|
|
4529
4346
|
case 18:
|
|
4530
|
-
|
|
4347
|
+
_context26.next = 14;
|
|
4531
4348
|
break;
|
|
4532
4349
|
case 20:
|
|
4533
|
-
|
|
4350
|
+
_context26.next = 25;
|
|
4534
4351
|
break;
|
|
4535
4352
|
case 22:
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
_iterator21.e(
|
|
4353
|
+
_context26.prev = 22;
|
|
4354
|
+
_context26.t1 = _context26["catch"](11);
|
|
4355
|
+
_iterator21.e(_context26.t1);
|
|
4539
4356
|
case 25:
|
|
4540
|
-
|
|
4357
|
+
_context26.prev = 25;
|
|
4541
4358
|
_iterator21.f();
|
|
4542
|
-
return
|
|
4359
|
+
return _context26.finish(25);
|
|
4543
4360
|
case 28:
|
|
4544
4361
|
if (linkedBookingUidsToRemove.size > 0) {
|
|
4545
4362
|
// 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
|
|
@@ -4550,20 +4367,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4550
4367
|
return !(isAddTimeProduct && lineBookingUid !== undefined && lineBookingUid !== null && linkedBookingUidsToRemove.has(String(lineBookingUid)));
|
|
4551
4368
|
});
|
|
4552
4369
|
}
|
|
4553
|
-
|
|
4370
|
+
_context26.next = 31;
|
|
4554
4371
|
return this.finalizeAfterProductsMutation(tempOrder);
|
|
4555
4372
|
case 31:
|
|
4556
4373
|
this.logInfo('removeProductsFromOrder success', {
|
|
4557
4374
|
identities: identities
|
|
4558
4375
|
});
|
|
4559
|
-
return
|
|
4376
|
+
return _context26.abrupt("return", tempOrder.products);
|
|
4560
4377
|
case 33:
|
|
4561
4378
|
case "end":
|
|
4562
|
-
return
|
|
4379
|
+
return _context26.stop();
|
|
4563
4380
|
}
|
|
4564
|
-
},
|
|
4381
|
+
}, _callee23, this, [[11, 22, 25, 28]]);
|
|
4565
4382
|
}));
|
|
4566
|
-
function removeProductsFromOrder(
|
|
4383
|
+
function removeProductsFromOrder(_x27) {
|
|
4567
4384
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
4568
4385
|
}
|
|
4569
4386
|
return removeProductsFromOrder;
|
|
@@ -4571,18 +4388,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4571
4388
|
}, {
|
|
4572
4389
|
key: "removeProductFromOrder",
|
|
4573
4390
|
value: function () {
|
|
4574
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4575
|
-
return _regeneratorRuntime().wrap(function
|
|
4576
|
-
while (1) switch (
|
|
4391
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(identity) {
|
|
4392
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context27) {
|
|
4393
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
4577
4394
|
case 0:
|
|
4578
|
-
return
|
|
4395
|
+
return _context27.abrupt("return", this.removeProductsFromOrder([identity]));
|
|
4579
4396
|
case 1:
|
|
4580
4397
|
case "end":
|
|
4581
|
-
return
|
|
4398
|
+
return _context27.stop();
|
|
4582
4399
|
}
|
|
4583
|
-
},
|
|
4400
|
+
}, _callee24, this);
|
|
4584
4401
|
}));
|
|
4585
|
-
function removeProductFromOrder(
|
|
4402
|
+
function removeProductFromOrder(_x28) {
|
|
4586
4403
|
return _removeProductFromOrder.apply(this, arguments);
|
|
4587
4404
|
}
|
|
4588
4405
|
return removeProductFromOrder;
|
|
@@ -4594,10 +4411,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4594
4411
|
}, {
|
|
4595
4412
|
key: "clearOrderCartLines",
|
|
4596
4413
|
value: (function () {
|
|
4597
|
-
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4414
|
+
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
|
|
4598
4415
|
var tempOrder;
|
|
4599
|
-
return _regeneratorRuntime().wrap(function
|
|
4600
|
-
while (1) switch (
|
|
4416
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context28) {
|
|
4417
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
4601
4418
|
case 0:
|
|
4602
4419
|
tempOrder = this.ensureTempOrder();
|
|
4603
4420
|
tempOrder.products = [];
|
|
@@ -4608,24 +4425,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4608
4425
|
productsByUid: {}
|
|
4609
4426
|
});
|
|
4610
4427
|
}
|
|
4611
|
-
|
|
4428
|
+
_context28.next = 7;
|
|
4612
4429
|
return this.applyPromotion();
|
|
4613
4430
|
case 7:
|
|
4614
4431
|
this.applyDiscount();
|
|
4615
4432
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4616
|
-
|
|
4433
|
+
_context28.next = 11;
|
|
4617
4434
|
return this.recalculateSummary({
|
|
4618
4435
|
createIfMissing: true
|
|
4619
4436
|
});
|
|
4620
4437
|
case 11:
|
|
4621
4438
|
this.persistTempOrder();
|
|
4622
4439
|
this.logInfo('clearOrderCartLines success', {});
|
|
4623
|
-
return
|
|
4440
|
+
return _context28.abrupt("return", tempOrder);
|
|
4624
4441
|
case 14:
|
|
4625
4442
|
case "end":
|
|
4626
|
-
return
|
|
4443
|
+
return _context28.stop();
|
|
4627
4444
|
}
|
|
4628
|
-
},
|
|
4445
|
+
}, _callee25, this);
|
|
4629
4446
|
}));
|
|
4630
4447
|
function clearOrderCartLines() {
|
|
4631
4448
|
return _clearOrderCartLines.apply(this, arguments);
|
|
@@ -4636,23 +4453,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4636
4453
|
}, {
|
|
4637
4454
|
key: "buildCurrentSubmitPayloadForLocalPrint",
|
|
4638
4455
|
value: function buildCurrentSubmitPayloadForLocalPrint(params) {
|
|
4639
|
-
var _params$cacheId, _this$otherParams3,
|
|
4456
|
+
var _params$cacheId, _this$otherParams3, _ref68, _params$businessCode, _this$otherParams4, _this$otherParams5;
|
|
4640
4457
|
var tempOrder = this.ensureTempOrder();
|
|
4641
4458
|
this.persistTempOrder();
|
|
4642
4459
|
var payload = buildSubmitPayload({
|
|
4643
4460
|
tempOrder: tempOrder,
|
|
4644
4461
|
cacheId: (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId,
|
|
4645
4462
|
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: (
|
|
4463
|
+
businessCode: (_ref68 = (_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 && _ref68 !== void 0 ? _ref68 : (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.business_code,
|
|
4647
4464
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
4648
4465
|
type: params === null || params === void 0 ? void 0 : params.type,
|
|
4649
4466
|
summary: this.store.summary || createEmptySummary(),
|
|
4650
4467
|
enhance: function enhance(nextPayload) {
|
|
4651
|
-
var
|
|
4468
|
+
var _ref69, _tempOrder$order_numb, _ref70, _tempOrder$shop_order, _ref71, _tempOrder$shop_full_;
|
|
4652
4469
|
return _objectSpread(_objectSpread({}, nextPayload), {}, {
|
|
4653
|
-
order_number: (
|
|
4654
|
-
shop_order_number: (
|
|
4655
|
-
shop_full_order_number: (
|
|
4470
|
+
order_number: (_ref69 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref69 !== void 0 ? _ref69 : null,
|
|
4471
|
+
shop_order_number: (_ref70 = (_tempOrder$shop_order = tempOrder.shop_order_number) !== null && _tempOrder$shop_order !== void 0 ? _tempOrder$shop_order : nextPayload.shop_order_number) !== null && _ref70 !== void 0 ? _ref70 : null,
|
|
4472
|
+
shop_full_order_number: (_ref71 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref71 !== void 0 ? _ref71 : null,
|
|
4656
4473
|
small_ticket_data_flag: 1
|
|
4657
4474
|
});
|
|
4658
4475
|
}
|
|
@@ -4663,17 +4480,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4663
4480
|
}, {
|
|
4664
4481
|
key: "applyLocalPrintOrderNumbers",
|
|
4665
4482
|
value: function () {
|
|
4666
|
-
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4483
|
+
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(order) {
|
|
4667
4484
|
var tempOrder, shopOrderNumber, shopFullOrderNumber;
|
|
4668
|
-
return _regeneratorRuntime().wrap(function
|
|
4669
|
-
while (1) switch (
|
|
4485
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context29) {
|
|
4486
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
4670
4487
|
case 0:
|
|
4671
4488
|
tempOrder = this.ensureTempOrder();
|
|
4672
4489
|
if (!(!order || _typeof(order) !== 'object')) {
|
|
4673
|
-
|
|
4490
|
+
_context29.next = 3;
|
|
4674
4491
|
break;
|
|
4675
4492
|
}
|
|
4676
|
-
return
|
|
4493
|
+
return _context29.abrupt("return", tempOrder);
|
|
4677
4494
|
case 3:
|
|
4678
4495
|
shopOrderNumber = order.shop_order_number;
|
|
4679
4496
|
shopFullOrderNumber = order.shop_full_order_number;
|
|
@@ -4684,17 +4501,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4684
4501
|
tempOrder.shop_full_order_number = String(shopFullOrderNumber);
|
|
4685
4502
|
}
|
|
4686
4503
|
this.persistTempOrder();
|
|
4687
|
-
|
|
4504
|
+
_context29.next = 10;
|
|
4688
4505
|
return this.saveDraft();
|
|
4689
4506
|
case 10:
|
|
4690
|
-
return
|
|
4507
|
+
return _context29.abrupt("return", tempOrder);
|
|
4691
4508
|
case 11:
|
|
4692
4509
|
case "end":
|
|
4693
|
-
return
|
|
4510
|
+
return _context29.stop();
|
|
4694
4511
|
}
|
|
4695
|
-
},
|
|
4512
|
+
}, _callee26, this);
|
|
4696
4513
|
}));
|
|
4697
|
-
function applyLocalPrintOrderNumbers(
|
|
4514
|
+
function applyLocalPrintOrderNumbers(_x29) {
|
|
4698
4515
|
return _applyLocalPrintOrderNumbers.apply(this, arguments);
|
|
4699
4516
|
}
|
|
4700
4517
|
return applyLocalPrintOrderNumbers;
|
|
@@ -4708,18 +4525,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4708
4525
|
}, {
|
|
4709
4526
|
key: "submitTempOrder",
|
|
4710
4527
|
value: (function () {
|
|
4711
|
-
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4712
|
-
return _regeneratorRuntime().wrap(function
|
|
4713
|
-
while (1) switch (
|
|
4528
|
+
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
|
|
4529
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context30) {
|
|
4530
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
4714
4531
|
case 0:
|
|
4715
|
-
return
|
|
4532
|
+
return _context30.abrupt("return", this.runSubmitTempOrder(params));
|
|
4716
4533
|
case 1:
|
|
4717
4534
|
case "end":
|
|
4718
|
-
return
|
|
4535
|
+
return _context30.stop();
|
|
4719
4536
|
}
|
|
4720
|
-
},
|
|
4537
|
+
}, _callee27, this);
|
|
4721
4538
|
}));
|
|
4722
|
-
function submitTempOrder(
|
|
4539
|
+
function submitTempOrder(_x30) {
|
|
4723
4540
|
return _submitTempOrder.apply(this, arguments);
|
|
4724
4541
|
}
|
|
4725
4542
|
return submitTempOrder;
|
|
@@ -4727,20 +4544,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4727
4544
|
}, {
|
|
4728
4545
|
key: "submitTempOrderAsync",
|
|
4729
4546
|
value: function () {
|
|
4730
|
-
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4731
|
-
return _regeneratorRuntime().wrap(function
|
|
4732
|
-
while (1) switch (
|
|
4547
|
+
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
|
|
4548
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context31) {
|
|
4549
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
4733
4550
|
case 0:
|
|
4734
|
-
return
|
|
4551
|
+
return _context31.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
4735
4552
|
syncMode: true
|
|
4736
4553
|
})));
|
|
4737
4554
|
case 1:
|
|
4738
4555
|
case "end":
|
|
4739
|
-
return
|
|
4556
|
+
return _context31.stop();
|
|
4740
4557
|
}
|
|
4741
|
-
},
|
|
4558
|
+
}, _callee28, this);
|
|
4742
4559
|
}));
|
|
4743
|
-
function submitTempOrderAsync(
|
|
4560
|
+
function submitTempOrderAsync(_x31) {
|
|
4744
4561
|
return _submitTempOrderAsync.apply(this, arguments);
|
|
4745
4562
|
}
|
|
4746
4563
|
return submitTempOrderAsync;
|
|
@@ -4748,11 +4565,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4748
4565
|
}, {
|
|
4749
4566
|
key: "runSubmitTempOrder",
|
|
4750
4567
|
value: function () {
|
|
4751
|
-
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4752
|
-
var _params$cacheId2, _this$otherParams6,
|
|
4568
|
+
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
|
|
4569
|
+
var _params$cacheId2, _this$otherParams6, _ref72, _ref73, _submitSnapshot$busin, _this$otherParams7, _this$otherParams8, _submitSnapshot$type;
|
|
4753
4570
|
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
|
|
4755
|
-
while (1) switch (
|
|
4571
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context32) {
|
|
4572
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
4756
4573
|
case 0:
|
|
4757
4574
|
tempOrder = this.ensureTempOrder();
|
|
4758
4575
|
shouldConfirmPendingVoucherPayments = (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== false;
|
|
@@ -4772,26 +4589,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4772
4589
|
}
|
|
4773
4590
|
}
|
|
4774
4591
|
this.persistTempOrder();
|
|
4775
|
-
|
|
4592
|
+
_context32.next = 8;
|
|
4776
4593
|
return this.recalculateSummary({
|
|
4777
4594
|
createIfMissing: true
|
|
4778
4595
|
});
|
|
4779
4596
|
case 8:
|
|
4780
|
-
|
|
4781
|
-
if (
|
|
4782
|
-
|
|
4597
|
+
_context32.t1 = _context32.sent;
|
|
4598
|
+
if (_context32.t1) {
|
|
4599
|
+
_context32.next = 11;
|
|
4783
4600
|
break;
|
|
4784
4601
|
}
|
|
4785
|
-
|
|
4602
|
+
_context32.t1 = this.store.summary;
|
|
4786
4603
|
case 11:
|
|
4787
|
-
|
|
4788
|
-
if (
|
|
4789
|
-
|
|
4604
|
+
_context32.t0 = _context32.t1;
|
|
4605
|
+
if (_context32.t0) {
|
|
4606
|
+
_context32.next = 14;
|
|
4790
4607
|
break;
|
|
4791
4608
|
}
|
|
4792
|
-
|
|
4609
|
+
_context32.t0 = createEmptySummary();
|
|
4793
4610
|
case 14:
|
|
4794
|
-
latestSummary =
|
|
4611
|
+
latestSummary = _context32.t0;
|
|
4795
4612
|
effectiveCacheId = (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId;
|
|
4796
4613
|
hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
|
|
4797
4614
|
hasSmallTicketDataFlagOverride = (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined;
|
|
@@ -4811,7 +4628,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4811
4628
|
tempOrder: tempOrder,
|
|
4812
4629
|
cacheId: effectiveCacheId,
|
|
4813
4630
|
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: (
|
|
4631
|
+
businessCode: (_ref72 = (_ref73 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref73 !== void 0 ? _ref73 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.businessCode) !== null && _ref72 !== void 0 ? _ref72 : (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.business_code,
|
|
4815
4632
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
4816
4633
|
type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
|
|
4817
4634
|
summary: latestSummary,
|
|
@@ -4826,10 +4643,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4826
4643
|
if (!payload.created_at) {
|
|
4827
4644
|
payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
4828
4645
|
}
|
|
4829
|
-
|
|
4646
|
+
_context32.next = 26;
|
|
4830
4647
|
return this.saveDraft();
|
|
4831
4648
|
case 26:
|
|
4832
|
-
|
|
4649
|
+
_context32.prev = 26;
|
|
4833
4650
|
this.logInfo('submitTempOrder calling sales checkout', {
|
|
4834
4651
|
orderId: payload.order_id,
|
|
4835
4652
|
externalSaleNumber: payload.external_sale_number,
|
|
@@ -4839,43 +4656,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4839
4656
|
smallTicketDataFlag: payload.small_ticket_data_flag,
|
|
4840
4657
|
syncMode: payload.sync_mode
|
|
4841
4658
|
});
|
|
4842
|
-
|
|
4659
|
+
_context32.next = 30;
|
|
4843
4660
|
return this.submitSalesOrder({
|
|
4844
4661
|
query: payload
|
|
4845
4662
|
});
|
|
4846
4663
|
case 30:
|
|
4847
|
-
result =
|
|
4848
|
-
|
|
4664
|
+
result = _context32.sent;
|
|
4665
|
+
_context32.next = 43;
|
|
4849
4666
|
break;
|
|
4850
4667
|
case 33:
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
backendErrorResponse = this.extractSubmitErrorResponse(
|
|
4668
|
+
_context32.prev = 33;
|
|
4669
|
+
_context32.t2 = _context32["catch"](26);
|
|
4670
|
+
backendErrorResponse = this.extractSubmitErrorResponse(_context32.t2);
|
|
4854
4671
|
if (!backendErrorResponse) {
|
|
4855
|
-
|
|
4672
|
+
_context32.next = 40;
|
|
4856
4673
|
break;
|
|
4857
4674
|
}
|
|
4858
4675
|
this.store.syncState = 'failed';
|
|
4859
4676
|
this.logSubmitBackendRejected(backendErrorResponse, payload);
|
|
4860
|
-
return
|
|
4677
|
+
return _context32.abrupt("return", backendErrorResponse);
|
|
4861
4678
|
case 40:
|
|
4862
4679
|
this.store.syncState = 'failed';
|
|
4863
4680
|
this.logError('submitTempOrder failed', {
|
|
4864
|
-
error:
|
|
4681
|
+
error: _context32.t2 instanceof Error ? _context32.t2.message : String(_context32.t2),
|
|
4865
4682
|
orderId: payload.order_id,
|
|
4866
4683
|
externalSaleNumber: payload.external_sale_number,
|
|
4867
4684
|
paymentStatus: payload.payment_status,
|
|
4868
4685
|
paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
|
|
4869
4686
|
});
|
|
4870
|
-
throw
|
|
4687
|
+
throw _context32.t2;
|
|
4871
4688
|
case 43:
|
|
4872
4689
|
if (!this.isSubmitResponseRejected(result)) {
|
|
4873
|
-
|
|
4690
|
+
_context32.next = 47;
|
|
4874
4691
|
break;
|
|
4875
4692
|
}
|
|
4876
4693
|
this.store.syncState = 'failed';
|
|
4877
4694
|
this.logSubmitBackendRejected(result, payload);
|
|
4878
|
-
return
|
|
4695
|
+
return _context32.abrupt("return", result);
|
|
4879
4696
|
case 47:
|
|
4880
4697
|
submittedOrderId = this.extractOrderIdFromSubmitResult(result);
|
|
4881
4698
|
this.logInfo('runSubmitTempOrder: 提交成功', {
|
|
@@ -4886,15 +4703,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4886
4703
|
})
|
|
4887
4704
|
});
|
|
4888
4705
|
if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
|
|
4889
|
-
|
|
4706
|
+
_context32.next = 56;
|
|
4890
4707
|
break;
|
|
4891
4708
|
}
|
|
4892
4709
|
tempOrder.order_id = submittedOrderId;
|
|
4893
4710
|
resultRecord = result;
|
|
4894
|
-
|
|
4711
|
+
_context32.next = 54;
|
|
4895
4712
|
return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
|
|
4896
4713
|
case 54:
|
|
4897
|
-
|
|
4714
|
+
_context32.next = 57;
|
|
4898
4715
|
break;
|
|
4899
4716
|
case 56:
|
|
4900
4717
|
if (this.isLocalPendingSubmitResult(result)) {
|
|
@@ -4903,14 +4720,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4903
4720
|
this.store.syncState = 'submitted';
|
|
4904
4721
|
}
|
|
4905
4722
|
case 57:
|
|
4906
|
-
return
|
|
4723
|
+
return _context32.abrupt("return", result);
|
|
4907
4724
|
case 58:
|
|
4908
4725
|
case "end":
|
|
4909
|
-
return
|
|
4726
|
+
return _context32.stop();
|
|
4910
4727
|
}
|
|
4911
|
-
},
|
|
4728
|
+
}, _callee29, this, [[26, 33]]);
|
|
4912
4729
|
}));
|
|
4913
|
-
function runSubmitTempOrder(
|
|
4730
|
+
function runSubmitTempOrder(_x32) {
|
|
4914
4731
|
return _runSubmitTempOrder.apply(this, arguments);
|
|
4915
4732
|
}
|
|
4916
4733
|
return runSubmitTempOrder;
|
|
@@ -4918,10 +4735,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4918
4735
|
}, {
|
|
4919
4736
|
key: "markLocalOrderSynced",
|
|
4920
4737
|
value: function () {
|
|
4921
|
-
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4738
|
+
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(orderId, remoteOrder) {
|
|
4922
4739
|
var tempOrder;
|
|
4923
|
-
return _regeneratorRuntime().wrap(function
|
|
4924
|
-
while (1) switch (
|
|
4740
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context33) {
|
|
4741
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
4925
4742
|
case 0:
|
|
4926
4743
|
tempOrder = this.ensureTempOrder();
|
|
4927
4744
|
tempOrder.order_id = orderId;
|
|
@@ -4929,15 +4746,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4929
4746
|
this.store.lastOrderInfo = remoteOrder;
|
|
4930
4747
|
this.store.syncState = 'submitted';
|
|
4931
4748
|
this.persistTempOrder();
|
|
4932
|
-
|
|
4749
|
+
_context33.next = 8;
|
|
4933
4750
|
return this.saveDraft();
|
|
4934
4751
|
case 8:
|
|
4935
4752
|
case "end":
|
|
4936
|
-
return
|
|
4753
|
+
return _context33.stop();
|
|
4937
4754
|
}
|
|
4938
|
-
},
|
|
4755
|
+
}, _callee30, this);
|
|
4939
4756
|
}));
|
|
4940
|
-
function markLocalOrderSynced(
|
|
4757
|
+
function markLocalOrderSynced(_x33, _x34) {
|
|
4941
4758
|
return _markLocalOrderSynced.apply(this, arguments);
|
|
4942
4759
|
}
|
|
4943
4760
|
return markLocalOrderSynced;
|
|
@@ -4980,10 +4797,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4980
4797
|
value: function extractSubmitErrorResponse(error) {
|
|
4981
4798
|
var _error$response,
|
|
4982
4799
|
_error$response2,
|
|
4983
|
-
|
|
4800
|
+
_this26 = this;
|
|
4984
4801
|
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];
|
|
4985
4802
|
return candidates.find(function (candidate) {
|
|
4986
|
-
return
|
|
4803
|
+
return _this26.isSubmitErrorResponse(candidate);
|
|
4987
4804
|
}) || null;
|
|
4988
4805
|
}
|
|
4989
4806
|
}, {
|
|
@@ -5010,40 +4827,40 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5010
4827
|
}, {
|
|
5011
4828
|
key: "syncPaymentsToOrder",
|
|
5012
4829
|
value: function () {
|
|
5013
|
-
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4830
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
|
|
5014
4831
|
var _params$confirmPendin;
|
|
5015
|
-
var tempOrder, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion,
|
|
5016
|
-
return _regeneratorRuntime().wrap(function
|
|
5017
|
-
while (1) switch (
|
|
4832
|
+
var tempOrder, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, paidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, submitResult;
|
|
4833
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context34) {
|
|
4834
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
5018
4835
|
case 0:
|
|
5019
4836
|
tempOrder = this.ensureTempOrder();
|
|
5020
4837
|
mappedPayments = mapPaymentItemsToOrderPayments(params.payments || []);
|
|
5021
4838
|
shouldConfirmPendingVoucherPayments = (_params$confirmPendin = params.confirmPendingVoucherPayments) !== null && _params$confirmPendin !== void 0 ? _params$confirmPendin : params.submitWhenPaid === true;
|
|
5022
4839
|
effectivePayments = shouldConfirmPendingVoucherPayments ? this.confirmPendingVoucherPaymentsInList(mappedPayments) : params.confirmPendingVoucherPayments === false ? this.discardPendingVoucherPaymentsFromList(mappedPayments) : mappedPayments;
|
|
5023
4840
|
completion = this.getPaymentCompletion(effectivePayments);
|
|
5024
|
-
|
|
5025
|
-
paymentStatus = completion.isOrderFullyPaid ? params.paymentStatus || 'paid' :
|
|
4841
|
+
paidPaymentTotal = this.calculatePaymentTotal(effectivePayments);
|
|
4842
|
+
paymentStatus = completion.isOrderFullyPaid ? params.paymentStatus || 'paid' : paidPaymentTotal.gt(0) ? 'partially_paid' : 'payment_processing';
|
|
5026
4843
|
tempOrder.payments = effectivePayments;
|
|
5027
4844
|
tempOrder.payment_status = paymentStatus;
|
|
5028
4845
|
this.persistTempOrder();
|
|
5029
|
-
|
|
4846
|
+
_context34.next = 12;
|
|
5030
4847
|
return this.saveDraft();
|
|
5031
4848
|
case 12:
|
|
5032
4849
|
if (params.submitWhenPaid) {
|
|
5033
|
-
|
|
4850
|
+
_context34.next = 14;
|
|
5034
4851
|
break;
|
|
5035
4852
|
}
|
|
5036
|
-
return
|
|
4853
|
+
return _context34.abrupt("return", completion);
|
|
5037
4854
|
case 14:
|
|
5038
4855
|
if (!(this.store.syncState === 'submitting')) {
|
|
5039
|
-
|
|
4856
|
+
_context34.next = 16;
|
|
5040
4857
|
break;
|
|
5041
4858
|
}
|
|
5042
|
-
return
|
|
4859
|
+
return _context34.abrupt("return", completion);
|
|
5043
4860
|
case 16:
|
|
5044
4861
|
this.store.syncState = 'submitting';
|
|
5045
4862
|
paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, effectivePayments);
|
|
5046
|
-
|
|
4863
|
+
_context34.next = 20;
|
|
5047
4864
|
return this.submitTempOrder({
|
|
5048
4865
|
payments: effectivePayments,
|
|
5049
4866
|
paymentStatus: paymentStatus,
|
|
@@ -5059,17 +4876,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5059
4876
|
}
|
|
5060
4877
|
});
|
|
5061
4878
|
case 20:
|
|
5062
|
-
submitResult =
|
|
5063
|
-
return
|
|
4879
|
+
submitResult = _context34.sent;
|
|
4880
|
+
return _context34.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
|
|
5064
4881
|
submitResult: submitResult
|
|
5065
4882
|
}));
|
|
5066
4883
|
case 22:
|
|
5067
4884
|
case "end":
|
|
5068
|
-
return
|
|
4885
|
+
return _context34.stop();
|
|
5069
4886
|
}
|
|
5070
|
-
},
|
|
4887
|
+
}, _callee31, this);
|
|
5071
4888
|
}));
|
|
5072
|
-
function syncPaymentsToOrder(
|
|
4889
|
+
function syncPaymentsToOrder(_x35) {
|
|
5073
4890
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
5074
4891
|
}
|
|
5075
4892
|
return syncPaymentsToOrder;
|
|
@@ -5158,11 +4975,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5158
4975
|
}, {
|
|
5159
4976
|
key: "submitOrder",
|
|
5160
4977
|
value: function () {
|
|
5161
|
-
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4978
|
+
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(order) {
|
|
5162
4979
|
var _order$query$cartItem, _params$bookings, _params$relation_prod;
|
|
5163
4980
|
var url, query, fetchUrl, params;
|
|
5164
|
-
return _regeneratorRuntime().wrap(function
|
|
5165
|
-
while (1) switch (
|
|
4981
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context35) {
|
|
4982
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
5166
4983
|
case 0:
|
|
5167
4984
|
this.logInfo('submitOrder called', {
|
|
5168
4985
|
url: order.url,
|
|
@@ -5182,14 +4999,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5182
4999
|
relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
|
|
5183
5000
|
scheduleDate: params.schedule_date
|
|
5184
5001
|
});
|
|
5185
|
-
return
|
|
5002
|
+
return _context35.abrupt("return", this.request.post(fetchUrl, params));
|
|
5186
5003
|
case 6:
|
|
5187
5004
|
case "end":
|
|
5188
|
-
return
|
|
5005
|
+
return _context35.stop();
|
|
5189
5006
|
}
|
|
5190
|
-
},
|
|
5007
|
+
}, _callee32, this);
|
|
5191
5008
|
}));
|
|
5192
|
-
function submitOrder(
|
|
5009
|
+
function submitOrder(_x36) {
|
|
5193
5010
|
return _submitOrder.apply(this, arguments);
|
|
5194
5011
|
}
|
|
5195
5012
|
return submitOrder;
|
|
@@ -5197,13 +5014,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5197
5014
|
}, {
|
|
5198
5015
|
key: "cancelOrder",
|
|
5199
5016
|
value: function () {
|
|
5200
|
-
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5017
|
+
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
|
|
5201
5018
|
var payload;
|
|
5202
|
-
return _regeneratorRuntime().wrap(function
|
|
5203
|
-
while (1) switch (
|
|
5019
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context36) {
|
|
5020
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
5204
5021
|
case 0:
|
|
5205
5022
|
if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
|
|
5206
|
-
|
|
5023
|
+
_context36.next = 2;
|
|
5207
5024
|
break;
|
|
5208
5025
|
}
|
|
5209
5026
|
throw new Error('取消订单失败:order_ids 不能为空');
|
|
@@ -5219,16 +5036,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5219
5036
|
method: 'PUT',
|
|
5220
5037
|
orderIdsCount: params.order_ids.length
|
|
5221
5038
|
});
|
|
5222
|
-
return
|
|
5039
|
+
return _context36.abrupt("return", this.request.put('/order/update-status', payload, {
|
|
5223
5040
|
isShopApi: true
|
|
5224
5041
|
}));
|
|
5225
5042
|
case 5:
|
|
5226
5043
|
case "end":
|
|
5227
|
-
return
|
|
5044
|
+
return _context36.stop();
|
|
5228
5045
|
}
|
|
5229
|
-
},
|
|
5046
|
+
}, _callee33, this);
|
|
5230
5047
|
}));
|
|
5231
|
-
function cancelOrder(
|
|
5048
|
+
function cancelOrder(_x37) {
|
|
5232
5049
|
return _cancelOrder.apply(this, arguments);
|
|
5233
5050
|
}
|
|
5234
5051
|
return cancelOrder;
|
|
@@ -5236,19 +5053,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5236
5053
|
}, {
|
|
5237
5054
|
key: "changeBookingStatus",
|
|
5238
5055
|
value: function () {
|
|
5239
|
-
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5056
|
+
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
|
|
5240
5057
|
var url, payload;
|
|
5241
|
-
return _regeneratorRuntime().wrap(function
|
|
5242
|
-
while (1) switch (
|
|
5058
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context37) {
|
|
5059
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
5243
5060
|
case 0:
|
|
5244
5061
|
if (params.booking_id) {
|
|
5245
|
-
|
|
5062
|
+
_context37.next = 2;
|
|
5246
5063
|
break;
|
|
5247
5064
|
}
|
|
5248
5065
|
throw new Error('变更预约状态失败:booking_id 不能为空');
|
|
5249
5066
|
case 2:
|
|
5250
5067
|
if (params.appointment_status) {
|
|
5251
|
-
|
|
5068
|
+
_context37.next = 4;
|
|
5252
5069
|
break;
|
|
5253
5070
|
}
|
|
5254
5071
|
throw new Error('变更预约状态失败:appointment_status 不能为空');
|
|
@@ -5263,16 +5080,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5263
5080
|
bookingId: params.booking_id,
|
|
5264
5081
|
appointmentStatus: params.appointment_status
|
|
5265
5082
|
});
|
|
5266
|
-
return
|
|
5083
|
+
return _context37.abrupt("return", this.request.put(url, payload, {
|
|
5267
5084
|
isShopApi: true
|
|
5268
5085
|
}));
|
|
5269
5086
|
case 8:
|
|
5270
5087
|
case "end":
|
|
5271
|
-
return
|
|
5088
|
+
return _context37.stop();
|
|
5272
5089
|
}
|
|
5273
|
-
},
|
|
5090
|
+
}, _callee34, this);
|
|
5274
5091
|
}));
|
|
5275
|
-
function changeBookingStatus(
|
|
5092
|
+
function changeBookingStatus(_x38) {
|
|
5276
5093
|
return _changeBookingStatus.apply(this, arguments);
|
|
5277
5094
|
}
|
|
5278
5095
|
return changeBookingStatus;
|
|
@@ -5290,11 +5107,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5290
5107
|
}, {
|
|
5291
5108
|
key: "createOrderByCheckout",
|
|
5292
5109
|
value: (function () {
|
|
5293
|
-
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5110
|
+
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
|
|
5294
5111
|
var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3, _params$bookings3, _params$relation_prod3, _params$payments4;
|
|
5295
5112
|
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;
|
|
5296
|
-
return _regeneratorRuntime().wrap(function
|
|
5297
|
-
while (1) switch (
|
|
5113
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context38) {
|
|
5114
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
5298
5115
|
case 0:
|
|
5299
5116
|
// 过滤掉由在线店铺下单的 payment 支付数据
|
|
5300
5117
|
onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
|
|
@@ -5328,7 +5145,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5328
5145
|
relationProductsCount: ((_params$relation_prod3 = params.relation_products) === null || _params$relation_prod3 === void 0 ? void 0 : _params$relation_prod3.length) || 0,
|
|
5329
5146
|
paymentsCount: ((_params$payments4 = params.payments) === null || _params$payments4 === void 0 ? void 0 : _params$payments4.length) || 0
|
|
5330
5147
|
});
|
|
5331
|
-
|
|
5148
|
+
_context38.prev = 4;
|
|
5332
5149
|
// 构建订单数据,设置默认值并允许 params 覆盖
|
|
5333
5150
|
orderData = _objectSpread({
|
|
5334
5151
|
sales_channel: 'my_pisel',
|
|
@@ -5390,13 +5207,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5390
5207
|
hasOrderId: !!orderData.order_id,
|
|
5391
5208
|
smallTicketDataFlag: orderData.small_ticket_data_flag
|
|
5392
5209
|
});
|
|
5393
|
-
|
|
5210
|
+
_context38.next = 12;
|
|
5394
5211
|
return this.request.post('/order/checkout', orderData, {
|
|
5395
5212
|
osServer: true,
|
|
5396
5213
|
customToast: function customToast() {}
|
|
5397
5214
|
});
|
|
5398
5215
|
case 12:
|
|
5399
|
-
response =
|
|
5216
|
+
response = _context38.sent;
|
|
5400
5217
|
this.logInfo('Order API called successfully', {
|
|
5401
5218
|
response: response
|
|
5402
5219
|
});
|
|
@@ -5404,22 +5221,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5404
5221
|
success: !!response,
|
|
5405
5222
|
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)
|
|
5406
5223
|
});
|
|
5407
|
-
return
|
|
5224
|
+
return _context38.abrupt("return", response);
|
|
5408
5225
|
case 18:
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
console.error('[Order] createOrderByCheckout 创建订单失败:',
|
|
5226
|
+
_context38.prev = 18;
|
|
5227
|
+
_context38.t0 = _context38["catch"](4);
|
|
5228
|
+
console.error('[Order] createOrderByCheckout 创建订单失败:', _context38.t0);
|
|
5412
5229
|
this.logInfo('Order API called failed', {
|
|
5413
|
-
error:
|
|
5230
|
+
error: _context38.t0 instanceof Error ? _context38.t0.message : String(_context38.t0)
|
|
5414
5231
|
});
|
|
5415
|
-
throw
|
|
5232
|
+
throw _context38.t0;
|
|
5416
5233
|
case 23:
|
|
5417
5234
|
case "end":
|
|
5418
|
-
return
|
|
5235
|
+
return _context38.stop();
|
|
5419
5236
|
}
|
|
5420
|
-
},
|
|
5237
|
+
}, _callee35, this, [[4, 18]]);
|
|
5421
5238
|
}));
|
|
5422
|
-
function createOrderByCheckout(
|
|
5239
|
+
function createOrderByCheckout(_x39) {
|
|
5423
5240
|
return _createOrderByCheckout.apply(this, arguments);
|
|
5424
5241
|
}
|
|
5425
5242
|
return createOrderByCheckout;
|
|
@@ -5427,24 +5244,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5427
5244
|
}, {
|
|
5428
5245
|
key: "submitSalesOrder",
|
|
5429
5246
|
value: function () {
|
|
5430
|
-
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5247
|
+
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
|
|
5431
5248
|
var url, query, fetchUrl;
|
|
5432
|
-
return _regeneratorRuntime().wrap(function
|
|
5433
|
-
while (1) switch (
|
|
5249
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context39) {
|
|
5250
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
5434
5251
|
case 0:
|
|
5435
5252
|
url = params.url, query = params.query;
|
|
5436
5253
|
fetchUrl = url || '/order/sales/checkout';
|
|
5437
|
-
return
|
|
5254
|
+
return _context39.abrupt("return", this.request.post(fetchUrl, query, {
|
|
5438
5255
|
osServer: true,
|
|
5439
5256
|
customToast: function customToast() {}
|
|
5440
5257
|
}));
|
|
5441
5258
|
case 3:
|
|
5442
5259
|
case "end":
|
|
5443
|
-
return
|
|
5260
|
+
return _context39.stop();
|
|
5444
5261
|
}
|
|
5445
|
-
},
|
|
5262
|
+
}, _callee36, this);
|
|
5446
5263
|
}));
|
|
5447
|
-
function submitSalesOrder(
|
|
5264
|
+
function submitSalesOrder(_x40) {
|
|
5448
5265
|
return _submitSalesOrder.apply(this, arguments);
|
|
5449
5266
|
}
|
|
5450
5267
|
return submitSalesOrder;
|
|
@@ -5458,37 +5275,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5458
5275
|
}, {
|
|
5459
5276
|
key: "sendCustomerPayLink",
|
|
5460
5277
|
value: (function () {
|
|
5461
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5278
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
|
|
5462
5279
|
var _params$emails;
|
|
5463
5280
|
var orderIds;
|
|
5464
|
-
return _regeneratorRuntime().wrap(function
|
|
5465
|
-
while (1) switch (
|
|
5281
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context40) {
|
|
5282
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
5466
5283
|
case 0:
|
|
5467
5284
|
orderIds = params.order_ids || params.orderIds || [];
|
|
5468
5285
|
if (orderIds.length) {
|
|
5469
|
-
|
|
5286
|
+
_context40.next = 3;
|
|
5470
5287
|
break;
|
|
5471
5288
|
}
|
|
5472
5289
|
throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
|
|
5473
5290
|
case 3:
|
|
5474
5291
|
if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
|
|
5475
|
-
|
|
5292
|
+
_context40.next = 5;
|
|
5476
5293
|
break;
|
|
5477
5294
|
}
|
|
5478
5295
|
throw new Error('发送支付链接需要至少一个邮箱');
|
|
5479
5296
|
case 5:
|
|
5480
|
-
return
|
|
5297
|
+
return _context40.abrupt("return", this.request.post('/order/batch-email', {
|
|
5481
5298
|
order_ids: orderIds,
|
|
5482
5299
|
notify_action: params.notify_action || 'order_payment_reminder',
|
|
5483
5300
|
emails: params.emails
|
|
5484
5301
|
}));
|
|
5485
5302
|
case 6:
|
|
5486
5303
|
case "end":
|
|
5487
|
-
return
|
|
5304
|
+
return _context40.stop();
|
|
5488
5305
|
}
|
|
5489
|
-
},
|
|
5306
|
+
}, _callee37, this);
|
|
5490
5307
|
}));
|
|
5491
|
-
function sendCustomerPayLink(
|
|
5308
|
+
function sendCustomerPayLink(_x41) {
|
|
5492
5309
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
5493
5310
|
}
|
|
5494
5311
|
return sendCustomerPayLink;
|
|
@@ -5496,14 +5313,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5496
5313
|
}, {
|
|
5497
5314
|
key: "getSalesOrderByLookup",
|
|
5498
5315
|
value: function () {
|
|
5499
|
-
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5316
|
+
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
|
|
5500
5317
|
var lookup, res;
|
|
5501
|
-
return _regeneratorRuntime().wrap(function
|
|
5502
|
-
while (1) switch (
|
|
5318
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context41) {
|
|
5319
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
5503
5320
|
case 0:
|
|
5504
5321
|
lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
|
|
5505
5322
|
if (lookup) {
|
|
5506
|
-
|
|
5323
|
+
_context41.next = 3;
|
|
5507
5324
|
break;
|
|
5508
5325
|
}
|
|
5509
5326
|
throw new Error('加载销售详情需要 lookup');
|
|
@@ -5512,7 +5329,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5512
5329
|
if (lookup.startsWith('LOCAL_')) {
|
|
5513
5330
|
params.forceRemote = false;
|
|
5514
5331
|
}
|
|
5515
|
-
|
|
5332
|
+
_context41.next = 6;
|
|
5516
5333
|
return this.request.get("/order/sales/".concat(encodeURIComponent(lookup)), _objectSpread({
|
|
5517
5334
|
with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info']
|
|
5518
5335
|
}, params.forceRemote ? {
|
|
@@ -5521,18 +5338,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5521
5338
|
osServer: true
|
|
5522
5339
|
});
|
|
5523
5340
|
case 6:
|
|
5524
|
-
res =
|
|
5341
|
+
res = _context41.sent;
|
|
5525
5342
|
if (res.code === 200) {
|
|
5526
5343
|
this.store.lastOrderInfo = res.data;
|
|
5527
5344
|
}
|
|
5528
|
-
return
|
|
5345
|
+
return _context41.abrupt("return", res);
|
|
5529
5346
|
case 9:
|
|
5530
5347
|
case "end":
|
|
5531
|
-
return
|
|
5348
|
+
return _context41.stop();
|
|
5532
5349
|
}
|
|
5533
|
-
},
|
|
5350
|
+
}, _callee38, this);
|
|
5534
5351
|
}));
|
|
5535
|
-
function getSalesOrderByLookup(
|
|
5352
|
+
function getSalesOrderByLookup(_x42) {
|
|
5536
5353
|
return _getSalesOrderByLookup.apply(this, arguments);
|
|
5537
5354
|
}
|
|
5538
5355
|
return getSalesOrderByLookup;
|
|
@@ -5546,36 +5363,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5546
5363
|
}, {
|
|
5547
5364
|
key: "hydrateTempOrderFromRecord",
|
|
5548
5365
|
value: (function () {
|
|
5549
|
-
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5550
|
-
var _this$store$
|
|
5551
|
-
var
|
|
5552
|
-
return _regeneratorRuntime().wrap(function
|
|
5553
|
-
while (1) switch (
|
|
5366
|
+
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(record, options) {
|
|
5367
|
+
var _this$store$discount15;
|
|
5368
|
+
var raw, nextTempOrder, rawSummary, summarySurcharges, hydratedEditDiscounts, currentDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount16, _this$store$discount17;
|
|
5369
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context42) {
|
|
5370
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
5554
5371
|
case 0:
|
|
5555
|
-
|
|
5556
|
-
|
|
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
|
-
});
|
|
5372
|
+
raw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
|
|
5373
|
+
nextTempOrder = this.normalizeTempOrderForRuntime(raw);
|
|
5579
5374
|
rawSummary = raw.summary && _typeof(raw.summary) === 'object' ? raw.summary : {};
|
|
5580
5375
|
summarySurcharges = Array.isArray(rawSummary.surcharges) ? rawSummary.surcharges.map(function (s) {
|
|
5581
5376
|
return _objectSpread({}, s || {});
|
|
@@ -5588,59 +5383,45 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5588
5383
|
originalSalesSnapshot: {
|
|
5589
5384
|
summary: cloneDeep(this.store.summary),
|
|
5590
5385
|
products: cloneDeep(nextTempOrder.products || []),
|
|
5591
|
-
bookings: cloneDeep(nextTempOrder.bookings || []),
|
|
5592
5386
|
payments: cloneDeep(nextTempOrder.payments || []),
|
|
5593
5387
|
surcharges: cloneDeep(nextTempOrder.surcharges || []),
|
|
5594
5388
|
shop_discount: nextTempOrder.shop_discount || '0.00',
|
|
5595
5389
|
productFingerprint: this.buildOrderProductsFingerprint(nextTempOrder.products || [])
|
|
5596
5390
|
}
|
|
5597
5391
|
});
|
|
5598
|
-
|
|
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;
|
|
5392
|
+
this.store.lastOrderInfo = raw.lastOrderInfo || raw;
|
|
5602
5393
|
hydratedEditDiscounts = this.collectHydratedEditDiscounts(nextTempOrder.products);
|
|
5603
|
-
currentDiscounts = typeof ((_this$store$
|
|
5604
|
-
|
|
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;
|
|
5394
|
+
currentDiscounts = typeof ((_this$store$discount15 = this.store.discount) === null || _this$store$discount15 === void 0 ? void 0 : _this$store$discount15.getDiscountList) === 'function' ? this.store.discount.getDiscountList() || [] : [];
|
|
5395
|
+
shouldSkipEmptyDiscountSync = hydratedEditDiscounts.length === 0 && currentDiscounts.length === 0;
|
|
5615
5396
|
if (shouldSkipEmptyDiscountSync) {
|
|
5616
|
-
|
|
5397
|
+
_context42.next = 17;
|
|
5617
5398
|
break;
|
|
5618
5399
|
}
|
|
5619
|
-
OrderModule.populateSavedAmounts(nextTempOrder.products,
|
|
5620
|
-
|
|
5621
|
-
return (_this$store$
|
|
5622
|
-
case
|
|
5623
|
-
|
|
5624
|
-
return (_this$store$
|
|
5625
|
-
case
|
|
5400
|
+
OrderModule.populateSavedAmounts(nextTempOrder.products, hydratedEditDiscounts);
|
|
5401
|
+
_context42.next = 15;
|
|
5402
|
+
return (_this$store$discount16 = this.store.discount) === null || _this$store$discount16 === void 0 ? void 0 : _this$store$discount16.setOriginalDiscountList(hydratedEditDiscounts);
|
|
5403
|
+
case 15:
|
|
5404
|
+
_context42.next = 17;
|
|
5405
|
+
return (_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 ? void 0 : _this$store$discount17.setDiscountList(hydratedEditDiscounts);
|
|
5406
|
+
case 17:
|
|
5626
5407
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
5627
|
-
|
|
5408
|
+
_context42.next = 20;
|
|
5628
5409
|
break;
|
|
5629
5410
|
}
|
|
5630
|
-
|
|
5411
|
+
_context42.next = 20;
|
|
5631
5412
|
return this.recalculateSummary({
|
|
5632
5413
|
createIfMissing: false
|
|
5633
5414
|
});
|
|
5634
|
-
case
|
|
5415
|
+
case 20:
|
|
5635
5416
|
this.persistTempOrder();
|
|
5636
|
-
return
|
|
5637
|
-
case
|
|
5417
|
+
return _context42.abrupt("return", nextTempOrder);
|
|
5418
|
+
case 22:
|
|
5638
5419
|
case "end":
|
|
5639
|
-
return
|
|
5420
|
+
return _context42.stop();
|
|
5640
5421
|
}
|
|
5641
|
-
},
|
|
5422
|
+
}, _callee39, this);
|
|
5642
5423
|
}));
|
|
5643
|
-
function hydrateTempOrderFromRecord(
|
|
5424
|
+
function hydrateTempOrderFromRecord(_x43, _x44) {
|
|
5644
5425
|
return _hydrateTempOrderFromRecord.apply(this, arguments);
|
|
5645
5426
|
}
|
|
5646
5427
|
return hydrateTempOrderFromRecord;
|
|
@@ -5678,83 +5459,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5678
5459
|
}
|
|
5679
5460
|
return next;
|
|
5680
5461
|
}
|
|
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
|
-
}
|
|
5754
5462
|
}, {
|
|
5755
5463
|
key: "normalizeTempOrderForRuntime",
|
|
5756
5464
|
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
5757
|
-
var
|
|
5465
|
+
var _this27 = this;
|
|
5758
5466
|
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), raw || {});
|
|
5759
5467
|
// ES 列表详情使用 id 表示订单主键;OS 详情态统一依赖 order_id 驱动操作按钮。
|
|
5760
5468
|
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) {
|
|
@@ -5777,12 +5485,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5777
5485
|
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
5778
5486
|
var rawProducts = Array.isArray(raw.products) ? raw.products : [];
|
|
5779
5487
|
nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
|
|
5780
|
-
return
|
|
5781
|
-
makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
|
|
5782
|
-
});
|
|
5488
|
+
return _this27.normalizeHydratedOrderProduct(p);
|
|
5783
5489
|
}) : [];
|
|
5784
5490
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
5785
|
-
var booking =
|
|
5491
|
+
var booking = _this27.normalizeHydratedBookingHolder(b || {});
|
|
5786
5492
|
return _objectSpread(_objectSpread({}, booking), {}, {
|
|
5787
5493
|
is_all: normalizeBookingIsAll(booking),
|
|
5788
5494
|
sub_type: normalizeBookingSubType(booking)
|
|
@@ -5808,19 +5514,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5808
5514
|
};
|
|
5809
5515
|
var tempOrderExtend = nextTempOrder._extend;
|
|
5810
5516
|
var productsByUid = tempOrderExtend.productsByUid || {};
|
|
5811
|
-
var
|
|
5812
|
-
|
|
5517
|
+
var _iterator22 = _createForOfIteratorHelper(nextTempOrder.products.entries()),
|
|
5518
|
+
_step22;
|
|
5813
5519
|
try {
|
|
5814
|
-
for (
|
|
5815
|
-
var _product$
|
|
5816
|
-
var
|
|
5817
|
-
index =
|
|
5818
|
-
product =
|
|
5819
|
-
var uid = (_product$
|
|
5520
|
+
for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
|
|
5521
|
+
var _product$metadata10, _ref74, _ref75, _existed$origin, _rawProduct$metadata;
|
|
5522
|
+
var _step22$value = _slicedToArray(_step22.value, 2),
|
|
5523
|
+
index = _step22$value[0],
|
|
5524
|
+
product = _step22$value[1];
|
|
5525
|
+
var uid = (_product$metadata10 = product.metadata) === null || _product$metadata10 === void 0 ? void 0 : _product$metadata10.unique_identification_number;
|
|
5820
5526
|
if (!uid) continue;
|
|
5821
5527
|
var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
|
|
5822
5528
|
var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
|
|
5823
|
-
var origin = (
|
|
5529
|
+
var origin = (_ref74 = (_ref75 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref75 !== void 0 ? _ref75 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref74 !== void 0 ? _ref74 : rawProduct;
|
|
5824
5530
|
var originSnapshot = cloneDeep(origin);
|
|
5825
5531
|
var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
|
|
5826
5532
|
if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
|
|
@@ -5836,9 +5542,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5836
5542
|
});
|
|
5837
5543
|
}
|
|
5838
5544
|
} catch (err) {
|
|
5839
|
-
|
|
5545
|
+
_iterator22.e(err);
|
|
5840
5546
|
} finally {
|
|
5841
|
-
|
|
5547
|
+
_iterator22.f();
|
|
5842
5548
|
}
|
|
5843
5549
|
tempOrderExtend.productsByUid = productsByUid;
|
|
5844
5550
|
this.hydrateLinkedBookingIdentity(nextTempOrder);
|
|
@@ -5854,8 +5560,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5854
5560
|
var bookingUidByProductUid = new Map();
|
|
5855
5561
|
var productByUid = new Map();
|
|
5856
5562
|
(tempOrder.products || []).forEach(function (product) {
|
|
5857
|
-
var _product$
|
|
5858
|
-
var productUid = (product === null || product === void 0 || (_product$
|
|
5563
|
+
var _product$metadata11;
|
|
5564
|
+
var productUid = (product === null || product === void 0 || (_product$metadata11 = product.metadata) === null || _product$metadata11 === void 0 ? void 0 : _product$metadata11.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
5859
5565
|
if (productUid !== undefined && productUid !== null && String(productUid) !== '') {
|
|
5860
5566
|
productByUid.set(String(productUid), product);
|
|
5861
5567
|
}
|
|
@@ -5876,16 +5582,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5876
5582
|
bookingUidByProductUid.set(String(productUid), bookingUid);
|
|
5877
5583
|
});
|
|
5878
5584
|
(tempOrder.products || []).forEach(function (product) {
|
|
5879
|
-
var _product$
|
|
5880
|
-
var productUid = (product === null || product === void 0 || (_product$
|
|
5585
|
+
var _product$metadata12;
|
|
5586
|
+
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);
|
|
5881
5587
|
if (productUid === undefined || productUid === null || String(productUid) === '') return;
|
|
5882
5588
|
var bookingUid = bookingUidByProductUid.get(String(productUid));
|
|
5883
5589
|
if (!bookingUid) return;
|
|
5884
5590
|
if (!product.metadata || _typeof(product.metadata) !== 'object') {
|
|
5885
5591
|
product.metadata = {};
|
|
5886
5592
|
}
|
|
5887
|
-
|
|
5888
|
-
var linkedBookingUid = String(bookingUid);
|
|
5593
|
+
var linkedBookingUid = String(product.booking_uid || product.metadata.booking_uid || bookingUid);
|
|
5889
5594
|
product.booking_uid = linkedBookingUid;
|
|
5890
5595
|
product.metadata.booking_uid = linkedBookingUid;
|
|
5891
5596
|
});
|
|
@@ -5913,18 +5618,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5913
5618
|
var segments = [];
|
|
5914
5619
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
5915
5620
|
if (Array.isArray(sku.variant)) {
|
|
5916
|
-
var
|
|
5917
|
-
|
|
5621
|
+
var _iterator23 = _createForOfIteratorHelper(sku.variant),
|
|
5622
|
+
_step23;
|
|
5918
5623
|
try {
|
|
5919
|
-
for (
|
|
5920
|
-
var variant =
|
|
5624
|
+
for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {
|
|
5625
|
+
var variant = _step23.value;
|
|
5921
5626
|
var segment = this.formatHydratedNamePair(variant === null || variant === void 0 ? void 0 : variant.group, variant === null || variant === void 0 ? void 0 : variant.item);
|
|
5922
5627
|
if (segment) segments.push(segment);
|
|
5923
5628
|
}
|
|
5924
5629
|
} catch (err) {
|
|
5925
|
-
|
|
5630
|
+
_iterator23.e(err);
|
|
5926
5631
|
} finally {
|
|
5927
|
-
|
|
5632
|
+
_iterator23.f();
|
|
5928
5633
|
}
|
|
5929
5634
|
}
|
|
5930
5635
|
return segments.join(', ');
|
|
@@ -5932,10 +5637,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5932
5637
|
}, {
|
|
5933
5638
|
key: "normalizeHydratedProductOptionItem",
|
|
5934
5639
|
value: function normalizeHydratedProductOptionItem(optionItem) {
|
|
5935
|
-
var
|
|
5936
|
-
var rawNum = (
|
|
5640
|
+
var _ref76, _optionItem$num, _ref77, _optionItem$add_price;
|
|
5641
|
+
var rawNum = (_ref76 = (_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 && _ref76 !== void 0 ? _ref76 : 1;
|
|
5937
5642
|
var parsedNum = Number(rawNum);
|
|
5938
|
-
var rawPrice = (
|
|
5643
|
+
var rawPrice = (_ref77 = (_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 && _ref77 !== void 0 ? _ref77 : 0;
|
|
5939
5644
|
var parsedPrice = Number(rawPrice);
|
|
5940
5645
|
var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
|
|
5941
5646
|
option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
|
|
@@ -5951,8 +5656,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5951
5656
|
}
|
|
5952
5657
|
}, {
|
|
5953
5658
|
key: "normalizeHydratedOrderProduct",
|
|
5954
|
-
value: function normalizeHydratedOrderProduct(product
|
|
5955
|
-
var
|
|
5659
|
+
value: function normalizeHydratedOrderProduct(product) {
|
|
5660
|
+
var _this28 = this;
|
|
5956
5661
|
var row = _objectSpread({}, product || {});
|
|
5957
5662
|
if (row.num === undefined && row.product_quantity !== undefined) {
|
|
5958
5663
|
row.num = row.product_quantity;
|
|
@@ -5960,7 +5665,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5960
5665
|
var productSku = ensureProductSku(row);
|
|
5961
5666
|
row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
|
|
5962
5667
|
option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
|
|
5963
|
-
return
|
|
5668
|
+
return _this28.normalizeHydratedProductOptionItem(optionItem || {});
|
|
5964
5669
|
}))
|
|
5965
5670
|
});
|
|
5966
5671
|
delete row["product_".concat('option', "_item")];
|
|
@@ -5974,10 +5679,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5974
5679
|
if (!existingIdentity) {
|
|
5975
5680
|
row.metadata.unique_identification_number = createUuidV4();
|
|
5976
5681
|
}
|
|
5977
|
-
// 从云端、本地数据库中获取到的商品数据,先打上 runtime 标记,提供给 UI 做 saved items.
|
|
5978
|
-
if (options !== null && options !== void 0 && options.makeEditMark) {
|
|
5979
|
-
row.metadata.is_edit_for_runtime = true;
|
|
5980
|
-
}
|
|
5981
5682
|
var normalized = normalizeOrderProduct(row);
|
|
5982
5683
|
normalized.discount_list = normalizeOrderProductDiscountList(normalized.discount_list);
|
|
5983
5684
|
var result = _objectSpread(_objectSpread(_objectSpread({}, row), normalized), {}, {
|
|
@@ -5997,27 +5698,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5997
5698
|
}, {
|
|
5998
5699
|
key: "getOrderInfo",
|
|
5999
5700
|
value: function () {
|
|
6000
|
-
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5701
|
+
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(order_id) {
|
|
6001
5702
|
var res;
|
|
6002
|
-
return _regeneratorRuntime().wrap(function
|
|
6003
|
-
while (1) switch (
|
|
5703
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context43) {
|
|
5704
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
6004
5705
|
case 0:
|
|
6005
|
-
|
|
5706
|
+
_context43.next = 2;
|
|
6006
5707
|
return this.request.get("/order/sales/".concat(order_id), {
|
|
6007
5708
|
with: ['products', 'bookings']
|
|
6008
5709
|
}, {
|
|
6009
5710
|
osServer: true
|
|
6010
5711
|
});
|
|
6011
5712
|
case 2:
|
|
6012
|
-
res =
|
|
6013
|
-
return
|
|
5713
|
+
res = _context43.sent;
|
|
5714
|
+
return _context43.abrupt("return", res);
|
|
6014
5715
|
case 4:
|
|
6015
5716
|
case "end":
|
|
6016
|
-
return
|
|
5717
|
+
return _context43.stop();
|
|
6017
5718
|
}
|
|
6018
|
-
},
|
|
5719
|
+
}, _callee40, this);
|
|
6019
5720
|
}));
|
|
6020
|
-
function getOrderInfo(
|
|
5721
|
+
function getOrderInfo(_x45) {
|
|
6021
5722
|
return _getOrderInfo.apply(this, arguments);
|
|
6022
5723
|
}
|
|
6023
5724
|
return getOrderInfo;
|
|
@@ -6053,70 +5754,70 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6053
5754
|
addDiscountAmount(savedMap, discountKey, amount);
|
|
6054
5755
|
addDiscountAmount(isPersistedProduct || discount.order_discount_id != null ? editModeSavedMap : runtimeSavedMap, discountKey, amount);
|
|
6055
5756
|
};
|
|
6056
|
-
var
|
|
6057
|
-
|
|
5757
|
+
var _iterator24 = _createForOfIteratorHelper(productList),
|
|
5758
|
+
_step24;
|
|
6058
5759
|
try {
|
|
6059
|
-
for (
|
|
6060
|
-
var product =
|
|
5760
|
+
for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
|
|
5761
|
+
var product = _step24.value;
|
|
6061
5762
|
var qty = product.num || 1;
|
|
6062
5763
|
var isPersistedProduct = Boolean(product.order_detail_id || product.orderDetailId || product.booking_id);
|
|
6063
|
-
var
|
|
6064
|
-
|
|
5764
|
+
var _iterator26 = _createForOfIteratorHelper(product.discount_list || []),
|
|
5765
|
+
_step26;
|
|
6065
5766
|
try {
|
|
6066
|
-
for (
|
|
6067
|
-
var pd =
|
|
5767
|
+
for (_iterator26.s(); !(_step26 = _iterator26.n()).done;) {
|
|
5768
|
+
var pd = _step26.value;
|
|
6068
5769
|
addProductDiscountAmount(pd, qty, isPersistedProduct);
|
|
6069
5770
|
}
|
|
6070
5771
|
} catch (err) {
|
|
6071
|
-
|
|
5772
|
+
_iterator26.e(err);
|
|
6072
5773
|
} finally {
|
|
6073
|
-
|
|
5774
|
+
_iterator26.f();
|
|
6074
5775
|
}
|
|
6075
|
-
var
|
|
6076
|
-
|
|
5776
|
+
var _iterator27 = _createForOfIteratorHelper(product.product_bundle || []),
|
|
5777
|
+
_step27;
|
|
6077
5778
|
try {
|
|
6078
|
-
for (
|
|
6079
|
-
var
|
|
6080
|
-
var bundle =
|
|
5779
|
+
for (_iterator27.s(); !(_step27 = _iterator27.n()).done;) {
|
|
5780
|
+
var _ref78, _bundle$num3;
|
|
5781
|
+
var bundle = _step27.value;
|
|
6081
5782
|
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));
|
|
6082
|
-
var bundleQty = new Decimal(Number(qty) || 1).times(Number((
|
|
6083
|
-
var
|
|
6084
|
-
|
|
5783
|
+
var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref78 = (_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 && _ref78 !== void 0 ? _ref78 : 1) || 1).toNumber();
|
|
5784
|
+
var _iterator28 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
|
|
5785
|
+
_step28;
|
|
6085
5786
|
try {
|
|
6086
|
-
for (
|
|
6087
|
-
var _pd =
|
|
5787
|
+
for (_iterator28.s(); !(_step28 = _iterator28.n()).done;) {
|
|
5788
|
+
var _pd = _step28.value;
|
|
6088
5789
|
addProductDiscountAmount(_pd, bundleQty, isPersistedBundleProduct);
|
|
6089
5790
|
}
|
|
6090
5791
|
} catch (err) {
|
|
6091
|
-
|
|
5792
|
+
_iterator28.e(err);
|
|
6092
5793
|
} finally {
|
|
6093
|
-
|
|
5794
|
+
_iterator28.f();
|
|
6094
5795
|
}
|
|
6095
5796
|
}
|
|
6096
5797
|
} catch (err) {
|
|
6097
|
-
|
|
5798
|
+
_iterator27.e(err);
|
|
6098
5799
|
} finally {
|
|
6099
|
-
|
|
5800
|
+
_iterator27.f();
|
|
6100
5801
|
}
|
|
6101
5802
|
}
|
|
6102
5803
|
} catch (err) {
|
|
6103
|
-
|
|
5804
|
+
_iterator24.e(err);
|
|
6104
5805
|
} finally {
|
|
6105
|
-
|
|
5806
|
+
_iterator24.f();
|
|
6106
5807
|
}
|
|
6107
|
-
var
|
|
6108
|
-
|
|
5808
|
+
var _iterator25 = _createForOfIteratorHelper(discountList),
|
|
5809
|
+
_step25;
|
|
6109
5810
|
try {
|
|
6110
|
-
for (
|
|
6111
|
-
var d =
|
|
5811
|
+
for (_iterator25.s(); !(_step25 = _iterator25.n()).done;) {
|
|
5812
|
+
var d = _step25.value;
|
|
6112
5813
|
var key = d.id;
|
|
6113
5814
|
var sourceMap = d.isEditMode ? editModeSavedMap : editModeDiscountKeys.has(key) ? runtimeSavedMap : savedMap;
|
|
6114
5815
|
d.savedAmount = d.isSelected && key != null && sourceMap.has(key) ? sourceMap.get(key).toNumber() : 0;
|
|
6115
5816
|
}
|
|
6116
5817
|
} catch (err) {
|
|
6117
|
-
|
|
5818
|
+
_iterator25.e(err);
|
|
6118
5819
|
} finally {
|
|
6119
|
-
|
|
5820
|
+
_iterator25.f();
|
|
6120
5821
|
}
|
|
6121
5822
|
}
|
|
6122
5823
|
}]);
|