@pisell/pisellos 2.2.264 → 2.2.266
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
- package/dist/model/strategy/adapter/dataVariant/adapter.js +167 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +780 -0
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/dist/model/strategy/adapter/dataVariant/examples.js +277 -0
- package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/dist/model/strategy/adapter/dataVariant/index.js +4 -0
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +148 -0
- package/dist/model/strategy/adapter/dataVariant/type.js +54 -0
- package/dist/model/strategy/adapter/index.d.ts +4 -0
- package/dist/model/strategy/adapter/index.js +5 -1
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +16 -10
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +32 -1
- package/dist/modules/Discount/index.d.ts +5 -2
- package/dist/modules/Discount/index.js +30 -7
- package/dist/modules/Discount/types.d.ts +4 -0
- package/dist/modules/Order/index.d.ts +41 -10
- package/dist/modules/Order/index.js +1379 -810
- package/dist/modules/Order/payment-utils.d.ts +26 -0
- package/dist/modules/Order/payment-utils.js +225 -0
- package/dist/modules/Order/types.d.ts +49 -1
- package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.js +410 -0
- package/dist/modules/Order/utils.d.ts +4 -3
- package/dist/modules/Order/utils.js +61 -64
- package/dist/modules/Payment/index.d.ts +2 -0
- package/dist/modules/Payment/index.js +78 -49
- package/dist/modules/Payment/types.d.ts +26 -24
- package/dist/modules/Payment/types.js +2 -0
- package/dist/modules/Product/types.d.ts +22 -0
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +4 -2
- package/dist/modules/ProductList/types.d.ts +2 -0
- package/dist/modules/Rules/index.d.ts +2 -8
- package/dist/modules/Rules/index.js +55 -9
- package/dist/modules/Rules/types.d.ts +10 -1
- package/dist/server/index.d.ts +71 -0
- package/dist/server/index.js +2504 -1187
- package/dist/server/modules/order/index.d.ts +56 -5
- package/dist/server/modules/order/index.js +1718 -834
- package/dist/server/modules/order/types.d.ts +15 -3
- package/dist/server/modules/order/types.js +1 -1
- package/dist/server/modules/products/index.d.ts +31 -8
- package/dist/server/modules/products/index.js +549 -390
- package/dist/server/modules/products/types.d.ts +18 -0
- package/dist/solution/BaseSales/index.d.ts +67 -4
- package/dist/solution/BaseSales/index.js +1476 -792
- package/dist/solution/BaseSales/types.d.ts +6 -1
- package/dist/solution/BaseSales/types.js +1 -1
- package/dist/solution/BaseSales/utils/cartPromotion.js +19 -7
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +9 -4
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +6 -8
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +14 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +94 -54
- package/dist/solution/BookingTicket/types.d.ts +2 -0
- package/dist/solution/Sales/index.d.ts +1 -0
- package/dist/solution/Sales/index.js +10 -2
- package/dist/solution/ShopDiscount/index.js +15 -14
- package/dist/utils/payment-number.d.ts +9 -0
- package/dist/utils/payment-number.js +69 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.js +149 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +583 -0
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/lib/model/strategy/adapter/dataVariant/examples.js +293 -0
- package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +148 -0
- package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
- package/lib/model/strategy/adapter/index.d.ts +4 -0
- package/lib/model/strategy/adapter/index.js +13 -2
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +23 -2
- package/lib/modules/Discount/index.d.ts +5 -2
- package/lib/modules/Discount/index.js +23 -3
- package/lib/modules/Discount/types.d.ts +4 -0
- package/lib/modules/Order/index.d.ts +41 -10
- package/lib/modules/Order/index.js +514 -122
- package/lib/modules/Order/payment-utils.d.ts +26 -0
- package/lib/modules/Order/payment-utils.js +224 -0
- package/lib/modules/Order/types.d.ts +49 -1
- package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.js +418 -0
- package/lib/modules/Order/utils.d.ts +4 -3
- package/lib/modules/Order/utils.js +26 -20
- package/lib/modules/Payment/index.d.ts +2 -0
- package/lib/modules/Payment/index.js +33 -12
- package/lib/modules/Payment/types.d.ts +26 -24
- package/lib/modules/Product/types.d.ts +22 -0
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +4 -2
- package/lib/modules/ProductList/types.d.ts +2 -0
- package/lib/modules/Rules/index.d.ts +2 -8
- package/lib/modules/Rules/index.js +57 -6
- package/lib/modules/Rules/types.d.ts +10 -1
- package/lib/server/index.d.ts +71 -0
- package/lib/server/index.js +1002 -52
- package/lib/server/modules/order/index.d.ts +56 -5
- package/lib/server/modules/order/index.js +798 -148
- package/lib/server/modules/order/types.d.ts +15 -3
- package/lib/server/modules/products/index.d.ts +31 -8
- package/lib/server/modules/products/index.js +134 -35
- package/lib/server/modules/products/types.d.ts +18 -0
- package/lib/solution/BaseSales/index.d.ts +67 -4
- package/lib/solution/BaseSales/index.js +496 -50
- package/lib/solution/BaseSales/types.d.ts +6 -1
- package/lib/solution/BaseSales/utils/cartPromotion.js +13 -1
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +9 -4
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +4 -5
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +8 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +39 -11
- package/lib/solution/BookingTicket/types.d.ts +2 -0
- package/lib/solution/Sales/index.d.ts +1 -0
- package/lib/solution/Sales/index.js +5 -3
- package/lib/solution/ShopDiscount/index.js +2 -1
- package/lib/utils/payment-number.d.ts +9 -0
- package/lib/utils/payment-number.js +64 -0
- package/package.json +1 -1
|
@@ -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; }
|
|
11
9
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
12
10
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13
11
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
14
12
|
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; }
|
|
@@ -35,10 +35,13 @@ import { OrderHooks } from "./types";
|
|
|
35
35
|
import { composeLinePrice, generateDuration, getAllDiscountList, mergeRelationForms, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments, normalizeOrderProductDiscountList, resolveEffectivePerUnitDiscount, ensureProductSku, getProductSkuOptions, normalizeProductSkuOptions, sumOptionUnitPrice, clearTempOrderHolderAssignments, getOrderProductLineUid, indexOrderProductsByUid, calculateOrderProductsDeposit, mergeOrderProductDisplayFields, resolveIsFormSubject } from "./utils";
|
|
36
36
|
import { isNormalProduct } from "../Product/utils";
|
|
37
37
|
import dayjs from 'dayjs';
|
|
38
|
+
import { ensureOrderPaymentNumber, mergeOrderPaymentRecord, resolveOrderPaymentIdentity } from "./payment-utils";
|
|
39
|
+
import { resolvePaymentNumberDevicePrefix, resolvePaymentNumberDevicePrefixFromDeviceId } from "../../utils/payment-number";
|
|
38
40
|
import { processCartPromotion, appendPromotionTags as _appendPromotionTags, getOrderProductUid as getPromotionUid } from "../../solution/BaseSales/utils/cartPromotion";
|
|
39
41
|
import { buildProductLineFingerprint, getProductIdentityIndex, getSafeProductNum, isIdentityMatch, normalizeOrderProduct } from "../../solution/ScanOrder/utils";
|
|
40
42
|
import { syncManualProductDiscountProductNum } from "./utils/manualProductDiscount";
|
|
41
43
|
import { expandHydratedProductsForDiscountCollection, restoreHydratedBundleDiscounts } from "./utils/bundleDiscountHydration";
|
|
44
|
+
import { getOrderCollectionPersistentId, getOrderCollectionUid, normalizeOrderCollections, setOrderCollectionUid } from "./utils/orderCollectionIdentity";
|
|
42
45
|
import { DiscountModule } from "../Discount";
|
|
43
46
|
import { RulesModule } from "../Rules";
|
|
44
47
|
import { UnavailableReason } from "../Rules/types";
|
|
@@ -82,6 +85,10 @@ function isPaidPaymentRecord(payment) {
|
|
|
82
85
|
function isCommittedVoucherPaymentRecord(payment) {
|
|
83
86
|
return isVoucherPaymentRecord(payment) && (payment === null || payment === void 0 ? void 0 : payment.status) !== 'voided' && (hasSyncedOrderPaymentRecord(payment) || isPaidPaymentRecord(payment));
|
|
84
87
|
}
|
|
88
|
+
function getVoucherPaymentLifecycleKey(payment) {
|
|
89
|
+
if (!isVoucherPaymentRecord(payment)) return null;
|
|
90
|
+
return "".concat(String(payment.voucher_id), "::").concat(String(payment.status || ''));
|
|
91
|
+
}
|
|
85
92
|
export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
86
93
|
_inherits(OrderModule, _BaseModule);
|
|
87
94
|
var _super = _createSuper(OrderModule);
|
|
@@ -96,6 +103,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
96
103
|
_defineProperty(_assertThisInitialized(_this), "logger", void 0);
|
|
97
104
|
// LoggerManager 实例
|
|
98
105
|
_defineProperty(_assertThisInitialized(_this), "window", void 0);
|
|
106
|
+
_defineProperty(_assertThisInitialized(_this), "appPlugin", void 0);
|
|
99
107
|
_defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
|
|
100
108
|
_defineProperty(_assertThisInitialized(_this), "salesSummaryModuleName", void 0);
|
|
101
109
|
_defineProperty(_assertThisInitialized(_this), "rulesHooksOverride", void 0);
|
|
@@ -158,9 +166,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
158
166
|
};
|
|
159
167
|
var existed = discountMap.get(key);
|
|
160
168
|
if (existed) {
|
|
169
|
+
var _existed$limited_rela;
|
|
161
170
|
existed.amount = Number(existed.amount || 0) + amount;
|
|
162
171
|
existed.used_par_value = String(Number(existed.used_par_value || 0) + amount);
|
|
163
172
|
existed.balance = String(Number(existed.balance || 0) + amount);
|
|
173
|
+
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 : [];
|
|
174
|
+
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)) {
|
|
175
|
+
existed.limited_relation_product_data = _objectSpread(_objectSpread({}, existed.limited_relation_product_data || {}), {}, {
|
|
176
|
+
product_ids: [].concat(_toConsumableArray(productIds), [product.product_id])
|
|
177
|
+
});
|
|
178
|
+
}
|
|
164
179
|
existed.applicableProductDetails = [].concat(_toConsumableArray(existed.applicableProductDetails || []), [detail]);
|
|
165
180
|
existed.appliedProductDetails = [].concat(_toConsumableArray(existed.appliedProductDetails || []), [detail]);
|
|
166
181
|
continue;
|
|
@@ -276,7 +291,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
276
291
|
value: function () {
|
|
277
292
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
|
|
278
293
|
var _otherParams$rules, _otherParams$order, _otherParams$hooks;
|
|
279
|
-
var
|
|
294
|
+
var app, otherParams;
|
|
280
295
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
281
296
|
while (1) switch (_context.prev = _context.next) {
|
|
282
297
|
case 0:
|
|
@@ -288,15 +303,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
288
303
|
if (!this.store.summary) {
|
|
289
304
|
this.store.summary = createEmptySummary();
|
|
290
305
|
}
|
|
306
|
+
if (!Array.isArray(this.store.availableWalletIds)) {
|
|
307
|
+
this.store.availableWalletIds = [];
|
|
308
|
+
}
|
|
291
309
|
this.request = this.core.getPlugin('request');
|
|
292
|
-
appPlugin = this.core.getPlugin('app');
|
|
293
|
-
if (appPlugin) {
|
|
294
|
-
_context.next =
|
|
310
|
+
this.appPlugin = this.core.getPlugin('app');
|
|
311
|
+
if (this.appPlugin) {
|
|
312
|
+
_context.next = 9;
|
|
295
313
|
break;
|
|
296
314
|
}
|
|
297
315
|
throw new Error('Order 模块需要 app 插件支持');
|
|
298
|
-
case
|
|
299
|
-
app = appPlugin.getApp();
|
|
316
|
+
case 9:
|
|
317
|
+
app = this.appPlugin.getApp();
|
|
300
318
|
this.logger = app.logger;
|
|
301
319
|
this.window = this.core.getPlugin('window');
|
|
302
320
|
otherParams = options.otherParams || {};
|
|
@@ -308,7 +326,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
308
326
|
this.otherParams = otherParams;
|
|
309
327
|
this.registerDiscountModules(options);
|
|
310
328
|
this.logInfo('OrderModule initialized successfully');
|
|
311
|
-
case
|
|
329
|
+
case 21:
|
|
312
330
|
case "end":
|
|
313
331
|
return _context.stop();
|
|
314
332
|
}
|
|
@@ -485,7 +503,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
485
503
|
value: function () {
|
|
486
504
|
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
487
505
|
var _this$store$tempOrder, _this$store$discount, _this$store$tempOrder2;
|
|
488
|
-
var orderId, discountList, _this$store$discount2, _this$store$discount3, _this$store$discount4, currentEditDiscounts, runtimeDiscountIds, runtimeDiscounts, mergedDiscountList;
|
|
506
|
+
var orderId, prepareConfigResult, discountList, _this$store$discount2, _this$store$discount3, _this$store$discount4, currentDiscountList, currentEditDiscounts, currentScanDiscounts, currentScanDiscountIds, runtimeDiscountIds, runtimeDiscounts, mergedDiscountList;
|
|
489
507
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
490
508
|
while (1) switch (_context3.prev = _context3.next) {
|
|
491
509
|
case 0:
|
|
@@ -497,37 +515,49 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
497
515
|
with_good_pass: 1,
|
|
498
516
|
with_discount_card: 1,
|
|
499
517
|
with_wallet_pass_holder: 1,
|
|
518
|
+
with_available_wallet_flag: 1,
|
|
519
|
+
with_available_wallet_pass_flag: 1,
|
|
500
520
|
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
501
521
|
}, orderId ? {
|
|
502
522
|
order_id: orderId
|
|
503
523
|
} : {}));
|
|
504
524
|
case 3:
|
|
505
|
-
|
|
525
|
+
prepareConfigResult = _context3.sent;
|
|
526
|
+
discountList = prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.discountList;
|
|
527
|
+
this.store.availableWalletIds = (prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.availableWalletIds) || [];
|
|
506
528
|
if (!discountList) {
|
|
507
|
-
_context3.next =
|
|
529
|
+
_context3.next = 18;
|
|
508
530
|
break;
|
|
509
531
|
}
|
|
510
|
-
|
|
532
|
+
currentDiscountList = ((_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 ? void 0 : _this$store$discount2.getDiscountList()) || [];
|
|
533
|
+
currentEditDiscounts = currentDiscountList.filter(function (discount) {
|
|
511
534
|
return discount === null || discount === void 0 ? void 0 : discount.isEditMode;
|
|
512
535
|
});
|
|
536
|
+
currentScanDiscounts = currentDiscountList.filter(function (discount) {
|
|
537
|
+
return discount === null || discount === void 0 ? void 0 : discount.isScan;
|
|
538
|
+
});
|
|
539
|
+
currentScanDiscountIds = new Set(currentScanDiscounts.map(function (discount) {
|
|
540
|
+
return discount === null || discount === void 0 ? void 0 : discount.id;
|
|
541
|
+
}));
|
|
513
542
|
runtimeDiscountIds = new Set();
|
|
514
543
|
runtimeDiscounts = discountList.filter(function (discount) {
|
|
544
|
+
if (currentScanDiscountIds.has(discount === null || discount === void 0 ? void 0 : discount.id)) return false;
|
|
515
545
|
if (runtimeDiscountIds.has(discount === null || discount === void 0 ? void 0 : discount.id)) return false;
|
|
516
546
|
runtimeDiscountIds.add(discount === null || discount === void 0 ? void 0 : discount.id);
|
|
517
547
|
return true;
|
|
518
548
|
});
|
|
519
|
-
mergedDiscountList = [].concat(_toConsumableArray(currentEditDiscounts), _toConsumableArray(runtimeDiscounts));
|
|
520
|
-
_context3.next =
|
|
549
|
+
mergedDiscountList = [].concat(_toConsumableArray(currentEditDiscounts), _toConsumableArray(currentScanDiscounts), _toConsumableArray(runtimeDiscounts));
|
|
550
|
+
_context3.next = 16;
|
|
521
551
|
return (_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.setOriginalDiscountList(mergedDiscountList);
|
|
522
|
-
case
|
|
523
|
-
_context3.next =
|
|
552
|
+
case 16:
|
|
553
|
+
_context3.next = 18;
|
|
524
554
|
return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.setDiscountList(mergedDiscountList);
|
|
525
|
-
case
|
|
555
|
+
case 18:
|
|
526
556
|
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) {
|
|
527
557
|
this.applyDiscount();
|
|
528
558
|
}
|
|
529
559
|
return _context3.abrupt("return", this.getDiscountList());
|
|
530
|
-
case
|
|
560
|
+
case 20:
|
|
531
561
|
case "end":
|
|
532
562
|
return _context3.stop();
|
|
533
563
|
}
|
|
@@ -545,33 +575,76 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
545
575
|
return ((_this$store$discount5 = this.store.discount) === null || _this$store$discount5 === void 0 ? void 0 : _this$store$discount5.getDiscountList()) || [];
|
|
546
576
|
}
|
|
547
577
|
}, {
|
|
548
|
-
key: "
|
|
578
|
+
key: "getAvailableWalletIds",
|
|
579
|
+
value: function getAvailableWalletIds() {
|
|
580
|
+
return Array.isArray(this.store.availableWalletIds) ? _toConsumableArray(this.store.availableWalletIds) : [];
|
|
581
|
+
}
|
|
582
|
+
}, {
|
|
583
|
+
key: "syncScannedDiscountsToOriginalDiscountList",
|
|
549
584
|
value: function () {
|
|
550
|
-
var
|
|
551
|
-
var
|
|
552
|
-
var
|
|
585
|
+
var _syncScannedDiscountsToOriginalDiscountList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(discountList) {
|
|
586
|
+
var _this$store$discount6, _this$store$discount7, _this$store$discount8, _this$store$discount9;
|
|
587
|
+
var scanDiscounts, scanDiscountIds, originalDiscounts, nextOriginalDiscounts;
|
|
553
588
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
554
589
|
while (1) switch (_context4.prev = _context4.next) {
|
|
590
|
+
case 0:
|
|
591
|
+
scanDiscounts = (discountList || []).filter(function (discount) {
|
|
592
|
+
return discount === null || discount === void 0 ? void 0 : discount.isScan;
|
|
593
|
+
});
|
|
594
|
+
if (scanDiscounts.length) {
|
|
595
|
+
_context4.next = 3;
|
|
596
|
+
break;
|
|
597
|
+
}
|
|
598
|
+
return _context4.abrupt("return");
|
|
599
|
+
case 3:
|
|
600
|
+
scanDiscountIds = new Set(scanDiscounts.map(function (discount) {
|
|
601
|
+
return discount === null || discount === void 0 ? void 0 : discount.id;
|
|
602
|
+
}));
|
|
603
|
+
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)) || [];
|
|
604
|
+
nextOriginalDiscounts = [].concat(_toConsumableArray(scanDiscounts), _toConsumableArray(originalDiscounts.filter(function (discount) {
|
|
605
|
+
return !scanDiscountIds.has(discount === null || discount === void 0 ? void 0 : discount.id);
|
|
606
|
+
})));
|
|
607
|
+
_context4.next = 8;
|
|
608
|
+
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);
|
|
609
|
+
case 8:
|
|
610
|
+
case "end":
|
|
611
|
+
return _context4.stop();
|
|
612
|
+
}
|
|
613
|
+
}, _callee4, this);
|
|
614
|
+
}));
|
|
615
|
+
function syncScannedDiscountsToOriginalDiscountList(_x4) {
|
|
616
|
+
return _syncScannedDiscountsToOriginalDiscountList.apply(this, arguments);
|
|
617
|
+
}
|
|
618
|
+
return syncScannedDiscountsToOriginalDiscountList;
|
|
619
|
+
}()
|
|
620
|
+
}, {
|
|
621
|
+
key: "ensureEditDiscountConfigForProductChange",
|
|
622
|
+
value: function () {
|
|
623
|
+
var _ensureEditDiscountConfigForProductChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(tempOrder) {
|
|
624
|
+
var _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _this$store$discount10;
|
|
625
|
+
var orderId, customerId, currentDiscountList, hasRuntimeDiscounts;
|
|
626
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
627
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
555
628
|
case 0:
|
|
556
629
|
orderId = tempOrder.order_id;
|
|
557
630
|
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);
|
|
558
631
|
if (!(!orderId || !customerId || customerId === 1)) {
|
|
559
|
-
|
|
632
|
+
_context5.next = 4;
|
|
560
633
|
break;
|
|
561
634
|
}
|
|
562
|
-
return
|
|
635
|
+
return _context5.abrupt("return");
|
|
563
636
|
case 4:
|
|
564
|
-
currentDiscountList = ((_this$store$
|
|
637
|
+
currentDiscountList = ((_this$store$discount10 = this.store.discount) === null || _this$store$discount10 === void 0 ? void 0 : _this$store$discount10.getDiscountList()) || [];
|
|
565
638
|
hasRuntimeDiscounts = currentDiscountList.some(function (discount) {
|
|
566
639
|
return !(discount !== null && discount !== void 0 && discount.isEditMode);
|
|
567
640
|
});
|
|
568
641
|
if (!hasRuntimeDiscounts) {
|
|
569
|
-
|
|
642
|
+
_context5.next = 8;
|
|
570
643
|
break;
|
|
571
644
|
}
|
|
572
|
-
return
|
|
645
|
+
return _context5.abrupt("return");
|
|
573
646
|
case 8:
|
|
574
|
-
|
|
647
|
+
_context5.next = 10;
|
|
575
648
|
return this.loadDiscountConfig({
|
|
576
649
|
customerId: customerId,
|
|
577
650
|
action: 'edit',
|
|
@@ -580,11 +653,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
580
653
|
});
|
|
581
654
|
case 10:
|
|
582
655
|
case "end":
|
|
583
|
-
return
|
|
656
|
+
return _context5.stop();
|
|
584
657
|
}
|
|
585
|
-
},
|
|
658
|
+
}, _callee5, this);
|
|
586
659
|
}));
|
|
587
|
-
function ensureEditDiscountConfigForProductChange(
|
|
660
|
+
function ensureEditDiscountConfigForProductChange(_x5) {
|
|
588
661
|
return _ensureEditDiscountConfigForProductChange.apply(this, arguments);
|
|
589
662
|
}
|
|
590
663
|
return ensureEditDiscountConfigForProductChange;
|
|
@@ -592,35 +665,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
592
665
|
}, {
|
|
593
666
|
key: "scanCode",
|
|
594
667
|
value: function () {
|
|
595
|
-
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
596
|
-
var _this$store$
|
|
597
|
-
var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref13, isAvailable, newDiscountList, unavailableReason, _this$store$
|
|
598
|
-
return _regeneratorRuntime().wrap(function
|
|
599
|
-
while (1) switch (
|
|
668
|
+
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(code, customerId) {
|
|
669
|
+
var _this$store$discount11, _tempOrder$holder, _this$store$summary;
|
|
670
|
+
var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref13, isAvailable, newDiscountList, unavailableReason, _this$store$discount12;
|
|
671
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
672
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
600
673
|
case 0:
|
|
601
|
-
|
|
602
|
-
return (_this$store$
|
|
674
|
+
_context6.next = 2;
|
|
675
|
+
return (_this$store$discount11 = this.store.discount) === null || _this$store$discount11 === void 0 ? void 0 : _this$store$discount11.batchSearch(code, {
|
|
603
676
|
customerId: customerId
|
|
604
677
|
});
|
|
605
678
|
case 2:
|
|
606
|
-
|
|
607
|
-
if (
|
|
608
|
-
|
|
679
|
+
_context6.t0 = _context6.sent;
|
|
680
|
+
if (_context6.t0) {
|
|
681
|
+
_context6.next = 5;
|
|
609
682
|
break;
|
|
610
683
|
}
|
|
611
|
-
|
|
684
|
+
_context6.t0 = {
|
|
612
685
|
discountList: [],
|
|
613
686
|
unavailableReasonKey: null
|
|
614
687
|
};
|
|
615
688
|
case 5:
|
|
616
|
-
resultDiscountWithReason =
|
|
689
|
+
resultDiscountWithReason = _context6.t0;
|
|
617
690
|
resultDiscountList = resultDiscountWithReason.discountList, unavailableReasonKey = resultDiscountWithReason.unavailableReasonKey;
|
|
618
691
|
rulesModule = this.store.rules;
|
|
619
692
|
if (rulesModule) {
|
|
620
|
-
|
|
693
|
+
_context6.next = 10;
|
|
621
694
|
break;
|
|
622
695
|
}
|
|
623
|
-
return
|
|
696
|
+
return _context6.abrupt("return", {
|
|
624
697
|
type: 'clientCalc',
|
|
625
698
|
isAvailable: false,
|
|
626
699
|
discountList: this.getDiscountList(),
|
|
@@ -629,10 +702,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
629
702
|
});
|
|
630
703
|
case 10:
|
|
631
704
|
if (resultDiscountList.length) {
|
|
632
|
-
|
|
705
|
+
_context6.next = 12;
|
|
633
706
|
break;
|
|
634
707
|
}
|
|
635
|
-
return
|
|
708
|
+
return _context6.abrupt("return", {
|
|
636
709
|
type: 'server',
|
|
637
710
|
isAvailable: false,
|
|
638
711
|
discountList: this.getDiscountList(),
|
|
@@ -653,16 +726,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
653
726
|
return m.id === n.id;
|
|
654
727
|
});
|
|
655
728
|
}))) {
|
|
656
|
-
|
|
729
|
+
_context6.next = 18;
|
|
657
730
|
break;
|
|
658
731
|
}
|
|
659
|
-
|
|
732
|
+
_context6.next = 17;
|
|
733
|
+
return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
734
|
+
case 17:
|
|
735
|
+
return _context6.abrupt("return", {
|
|
660
736
|
type: 'clientCalc',
|
|
661
737
|
isAvailable: true,
|
|
662
738
|
discountList: this.getDiscountList(),
|
|
663
739
|
scannedDiscountList: resultDiscountList
|
|
664
740
|
});
|
|
665
|
-
case
|
|
741
|
+
case 18:
|
|
666
742
|
tempOrder = this.store.tempOrder;
|
|
667
743
|
holders = (tempOrder === null || tempOrder === void 0 || (_tempOrder$holder = tempOrder.holder) === null || _tempOrder$holder === void 0 ? void 0 : _tempOrder$holder.form_record) || [];
|
|
668
744
|
_ref13 = rulesModule.isDiscountListAvailable({
|
|
@@ -678,33 +754,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
678
754
|
isAvailable: false,
|
|
679
755
|
discountList: this.getDiscountList()
|
|
680
756
|
}, isAvailable = _ref13.isAvailable, newDiscountList = _ref13.discountList, unavailableReason = _ref13.unavailableReason;
|
|
681
|
-
if (isAvailable && newDiscountList) {
|
|
682
|
-
|
|
683
|
-
|
|
757
|
+
if (!(isAvailable && newDiscountList)) {
|
|
758
|
+
_context6.next = 26;
|
|
759
|
+
break;
|
|
684
760
|
}
|
|
685
|
-
|
|
761
|
+
(_this$store$discount12 = this.store.discount) === null || _this$store$discount12 === void 0 || _this$store$discount12.setDiscountList(newDiscountList);
|
|
762
|
+
this.applyDiscount();
|
|
763
|
+
_context6.next = 26;
|
|
764
|
+
return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
765
|
+
case 26:
|
|
766
|
+
return _context6.abrupt("return", {
|
|
686
767
|
type: 'clientCalc',
|
|
687
768
|
isAvailable: isAvailable || false,
|
|
688
769
|
discountList: newDiscountList || this.getDiscountList(),
|
|
689
770
|
scannedDiscountList: resultDiscountList,
|
|
690
771
|
unavailableReason: unavailableReason
|
|
691
772
|
});
|
|
692
|
-
case
|
|
773
|
+
case 27:
|
|
693
774
|
case "end":
|
|
694
|
-
return
|
|
775
|
+
return _context6.stop();
|
|
695
776
|
}
|
|
696
|
-
},
|
|
777
|
+
}, _callee6, this);
|
|
697
778
|
}));
|
|
698
|
-
function scanCode(
|
|
779
|
+
function scanCode(_x6, _x7) {
|
|
699
780
|
return _scanCode.apply(this, arguments);
|
|
700
781
|
}
|
|
701
782
|
return scanCode;
|
|
702
783
|
}()
|
|
703
784
|
}, {
|
|
704
785
|
key: "applyDiscount",
|
|
705
|
-
value: function applyDiscount() {
|
|
706
|
-
var _this$store$
|
|
707
|
-
_tempOrder$holder2,
|
|
786
|
+
value: function applyDiscount(options) {
|
|
787
|
+
var _this$store$discount13,
|
|
708
788
|
_this$store$summary2,
|
|
709
789
|
_this2 = this;
|
|
710
790
|
var tempOrder = this.store.tempOrder;
|
|
@@ -714,20 +794,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
714
794
|
if (!tempOrder) return;
|
|
715
795
|
this.syncLinkedBookingHoldersToProducts(tempOrder);
|
|
716
796
|
delete tempOrder.discount_list;
|
|
717
|
-
var discountList = ((_this$store$
|
|
797
|
+
var discountList = ((_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.getDiscountList()) || [];
|
|
718
798
|
var shouldSkipDiscountCalculation = this.shouldSkipDiscountCalculation(tempOrder);
|
|
719
799
|
if (shouldSkipDiscountCalculation) return;
|
|
720
800
|
var rulesModule = this.store.rules;
|
|
721
801
|
if (!rulesModule) return;
|
|
722
|
-
var holders = ((_tempOrder$holder2 = tempOrder.holder) === null || _tempOrder$holder2 === void 0 ? void 0 : _tempOrder$holder2.form_record) || [];
|
|
723
802
|
var result = rulesModule.calcDiscount({
|
|
724
803
|
productList: tempOrder.products,
|
|
725
804
|
discountList: discountList,
|
|
726
|
-
holders:
|
|
805
|
+
holders: [],
|
|
727
806
|
isFormSubject: function isFormSubject(product) {
|
|
728
807
|
return resolveIsFormSubject(tempOrder, product);
|
|
729
808
|
},
|
|
730
809
|
orderTotalAmount: Number(((_this$store$summary2 = this.store.summary) === null || _this$store$summary2 === void 0 ? void 0 : _this$store$summary2.total_amount) || 0)
|
|
810
|
+
}, {
|
|
811
|
+
reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids
|
|
731
812
|
});
|
|
732
813
|
if (result !== null && result !== void 0 && result.productList) {
|
|
733
814
|
var previousProductsByUid = indexOrderProductsByUid(tempOrder.products);
|
|
@@ -745,9 +826,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
745
826
|
}));
|
|
746
827
|
}
|
|
747
828
|
if (result !== null && result !== void 0 && result.discountList) {
|
|
748
|
-
var _this$store$
|
|
829
|
+
var _this$store$discount14;
|
|
749
830
|
OrderModule.populateSavedAmounts(result.productList || tempOrder.products, result.discountList);
|
|
750
|
-
(_this$store$
|
|
831
|
+
(_this$store$discount14 = this.store.discount) === null || _this$store$discount14 === void 0 || _this$store$discount14.setDiscountList(result.discountList);
|
|
751
832
|
}
|
|
752
833
|
this.hasActiveCustomerBoundDiscount = (tempOrder.products || []).some(function (product) {
|
|
753
834
|
return _this2.productHasCustomerBoundDiscount(product);
|
|
@@ -809,42 +890,42 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
809
890
|
}, {
|
|
810
891
|
key: "applyPromotion",
|
|
811
892
|
value: (function () {
|
|
812
|
-
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
893
|
+
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
813
894
|
var _this$promotionEvalua,
|
|
814
895
|
_this$promotionEvalua2,
|
|
815
896
|
_this3 = this;
|
|
816
897
|
var tempOrder, strategyConfigs, result, removeSet, _iterator3, _step3, reduce, _iterator6, _step6, _loop2, _iterator4, _step4, _loop, payload;
|
|
817
|
-
return _regeneratorRuntime().wrap(function
|
|
818
|
-
while (1) switch (
|
|
898
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context9) {
|
|
899
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
819
900
|
case 0:
|
|
820
901
|
if (!this.isApplyingPromotion) {
|
|
821
|
-
|
|
902
|
+
_context9.next = 2;
|
|
822
903
|
break;
|
|
823
904
|
}
|
|
824
|
-
return
|
|
905
|
+
return _context9.abrupt("return");
|
|
825
906
|
case 2:
|
|
826
907
|
if (this.promotionEvaluator) {
|
|
827
|
-
|
|
908
|
+
_context9.next = 4;
|
|
828
909
|
break;
|
|
829
910
|
}
|
|
830
|
-
return
|
|
911
|
+
return _context9.abrupt("return");
|
|
831
912
|
case 4:
|
|
832
913
|
tempOrder = this.store.tempOrder;
|
|
833
914
|
if (tempOrder) {
|
|
834
|
-
|
|
915
|
+
_context9.next = 7;
|
|
835
916
|
break;
|
|
836
917
|
}
|
|
837
|
-
return
|
|
918
|
+
return _context9.abrupt("return");
|
|
838
919
|
case 7:
|
|
839
920
|
strategyConfigs = (_this$promotionEvalua = (_this$promotionEvalua2 = this.promotionEvaluator).getStrategyConfigs) === null || _this$promotionEvalua === void 0 ? void 0 : _this$promotionEvalua.call(_this$promotionEvalua2);
|
|
840
921
|
if (!(Array.isArray(strategyConfigs) && strategyConfigs.length === 0)) {
|
|
841
|
-
|
|
922
|
+
_context9.next = 10;
|
|
842
923
|
break;
|
|
843
924
|
}
|
|
844
|
-
return
|
|
925
|
+
return _context9.abrupt("return");
|
|
845
926
|
case 10:
|
|
846
927
|
this.isApplyingPromotion = true;
|
|
847
|
-
|
|
928
|
+
_context9.prev = 11;
|
|
848
929
|
result = processCartPromotion(tempOrder.products, this.promotionEvaluator); // step 1: toRemove —— 直接过滤
|
|
849
930
|
if (result.giftActions.toRemove.length > 0) {
|
|
850
931
|
removeSet = new Set(result.giftActions.toRemove.map(String));
|
|
@@ -856,20 +937,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
856
937
|
|
|
857
938
|
// step 2: toReduce —— 调整数量
|
|
858
939
|
_iterator3 = _createForOfIteratorHelper(result.giftActions.toReduce);
|
|
859
|
-
|
|
940
|
+
_context9.prev = 15;
|
|
860
941
|
_iterator3.s();
|
|
861
942
|
case 17:
|
|
862
943
|
if ((_step3 = _iterator3.n()).done) {
|
|
863
|
-
|
|
944
|
+
_context9.next = 37;
|
|
864
945
|
break;
|
|
865
946
|
}
|
|
866
947
|
reduce = _step3.value;
|
|
867
948
|
_iterator6 = _createForOfIteratorHelper(reduce.items);
|
|
868
|
-
|
|
949
|
+
_context9.prev = 20;
|
|
869
950
|
_loop2 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop2() {
|
|
870
951
|
var item, product;
|
|
871
|
-
return _regeneratorRuntime().wrap(function _loop2$(
|
|
872
|
-
while (1) switch (
|
|
952
|
+
return _regeneratorRuntime().wrap(function _loop2$(_context8) {
|
|
953
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
873
954
|
case 0:
|
|
874
955
|
item = _step6.value;
|
|
875
956
|
product = result.products.find(function (p) {
|
|
@@ -880,52 +961,52 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
880
961
|
}
|
|
881
962
|
case 3:
|
|
882
963
|
case "end":
|
|
883
|
-
return
|
|
964
|
+
return _context8.stop();
|
|
884
965
|
}
|
|
885
966
|
}, _loop2);
|
|
886
967
|
});
|
|
887
968
|
_iterator6.s();
|
|
888
969
|
case 23:
|
|
889
970
|
if ((_step6 = _iterator6.n()).done) {
|
|
890
|
-
|
|
971
|
+
_context9.next = 27;
|
|
891
972
|
break;
|
|
892
973
|
}
|
|
893
|
-
return
|
|
974
|
+
return _context9.delegateYield(_loop2(), "t0", 25);
|
|
894
975
|
case 25:
|
|
895
|
-
|
|
976
|
+
_context9.next = 23;
|
|
896
977
|
break;
|
|
897
978
|
case 27:
|
|
898
|
-
|
|
979
|
+
_context9.next = 32;
|
|
899
980
|
break;
|
|
900
981
|
case 29:
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
_iterator6.e(
|
|
982
|
+
_context9.prev = 29;
|
|
983
|
+
_context9.t1 = _context9["catch"](20);
|
|
984
|
+
_iterator6.e(_context9.t1);
|
|
904
985
|
case 32:
|
|
905
|
-
|
|
986
|
+
_context9.prev = 32;
|
|
906
987
|
_iterator6.f();
|
|
907
|
-
return
|
|
988
|
+
return _context9.finish(32);
|
|
908
989
|
case 35:
|
|
909
|
-
|
|
990
|
+
_context9.next = 17;
|
|
910
991
|
break;
|
|
911
992
|
case 37:
|
|
912
|
-
|
|
993
|
+
_context9.next = 42;
|
|
913
994
|
break;
|
|
914
995
|
case 39:
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
_iterator3.e(
|
|
996
|
+
_context9.prev = 39;
|
|
997
|
+
_context9.t2 = _context9["catch"](15);
|
|
998
|
+
_iterator3.e(_context9.t2);
|
|
918
999
|
case 42:
|
|
919
|
-
|
|
1000
|
+
_context9.prev = 42;
|
|
920
1001
|
_iterator3.f();
|
|
921
|
-
return
|
|
1002
|
+
return _context9.finish(42);
|
|
922
1003
|
case 45:
|
|
923
1004
|
if (!(result.giftActions.toAdd.length > 0)) {
|
|
924
|
-
|
|
1005
|
+
_context9.next = 68;
|
|
925
1006
|
break;
|
|
926
1007
|
}
|
|
927
1008
|
if (this.giftSelectResolver) {
|
|
928
|
-
|
|
1009
|
+
_context9.next = 50;
|
|
929
1010
|
break;
|
|
930
1011
|
}
|
|
931
1012
|
if (result.giftActions.toAdd.some(function (g) {
|
|
@@ -936,19 +1017,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
936
1017
|
} else {
|
|
937
1018
|
console.warn('[OrderModule] giftSelectResolver not set, skip applying single-option gifts', result.giftActions.toAdd);
|
|
938
1019
|
}
|
|
939
|
-
|
|
1020
|
+
_context9.next = 68;
|
|
940
1021
|
break;
|
|
941
1022
|
case 50:
|
|
942
1023
|
_iterator4 = _createForOfIteratorHelper(result.giftActions.toAdd);
|
|
943
|
-
|
|
1024
|
+
_context9.prev = 51;
|
|
944
1025
|
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
945
1026
|
var addAction, _sameStrategy$metadat, sameStrategy, giftResult, giftProducts, giftBookings, _iterator5, _step5, _step5$value, index, gp, booking, linked;
|
|
946
|
-
return _regeneratorRuntime().wrap(function _loop$(
|
|
947
|
-
while (1) switch (
|
|
1027
|
+
return _regeneratorRuntime().wrap(function _loop$(_context7) {
|
|
1028
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
948
1029
|
case 0:
|
|
949
1030
|
addAction = _step4.value;
|
|
950
1031
|
if (!(addAction.giftOptions.length === 1)) {
|
|
951
|
-
|
|
1032
|
+
_context7.next = 6;
|
|
952
1033
|
break;
|
|
953
1034
|
}
|
|
954
1035
|
sameStrategy = result.products.find(function (p) {
|
|
@@ -956,14 +1037,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
956
1037
|
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;
|
|
957
1038
|
});
|
|
958
1039
|
if (!(sameStrategy && !sameStrategy.booking_uid && !((_sameStrategy$metadat = sameStrategy.metadata) !== null && _sameStrategy$metadat !== void 0 && _sameStrategy$metadat.booking_uid))) {
|
|
959
|
-
|
|
1040
|
+
_context7.next = 6;
|
|
960
1041
|
break;
|
|
961
1042
|
}
|
|
962
1043
|
sameStrategy.num = (Number(sameStrategy.num) || 0) + (addAction.giftCount || 1);
|
|
963
|
-
return
|
|
1044
|
+
return _context7.abrupt("return", 1);
|
|
964
1045
|
case 6:
|
|
965
|
-
|
|
966
|
-
|
|
1046
|
+
_context7.prev = 6;
|
|
1047
|
+
_context7.next = 9;
|
|
967
1048
|
return _this3.giftSelectResolver({
|
|
968
1049
|
strategyId: addAction.strategyId,
|
|
969
1050
|
strategyName: addAction.strategyName,
|
|
@@ -972,31 +1053,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
972
1053
|
sourceProductIds: addAction.sourceProductIds
|
|
973
1054
|
});
|
|
974
1055
|
case 9:
|
|
975
|
-
giftResult =
|
|
1056
|
+
giftResult = _context7.sent;
|
|
976
1057
|
giftProducts = Array.isArray(giftResult) ? giftResult : giftResult === null || giftResult === void 0 ? void 0 : giftResult.products;
|
|
977
1058
|
giftBookings = Array.isArray(giftResult) ? [] : (giftResult === null || giftResult === void 0 ? void 0 : giftResult.bookings) || [];
|
|
978
1059
|
if (!(Array.isArray(giftProducts) && giftProducts.length > 0)) {
|
|
979
|
-
|
|
1060
|
+
_context7.next = 37;
|
|
980
1061
|
break;
|
|
981
1062
|
}
|
|
982
1063
|
_iterator5 = _createForOfIteratorHelper(giftProducts.entries());
|
|
983
|
-
|
|
1064
|
+
_context7.prev = 14;
|
|
984
1065
|
_iterator5.s();
|
|
985
1066
|
case 16:
|
|
986
1067
|
if ((_step5 = _iterator5.n()).done) {
|
|
987
|
-
|
|
1068
|
+
_context7.next = 29;
|
|
988
1069
|
break;
|
|
989
1070
|
}
|
|
990
1071
|
_step5$value = _slicedToArray(_step5.value, 2), index = _step5$value[0], gp = _step5$value[1];
|
|
991
1072
|
if (gp) {
|
|
992
|
-
|
|
1073
|
+
_context7.next = 20;
|
|
993
1074
|
break;
|
|
994
1075
|
}
|
|
995
|
-
return
|
|
1076
|
+
return _context7.abrupt("continue", 27);
|
|
996
1077
|
case 20:
|
|
997
1078
|
booking = giftBookings[index];
|
|
998
1079
|
if (!booking) {
|
|
999
|
-
|
|
1080
|
+
_context7.next = 26;
|
|
1000
1081
|
break;
|
|
1001
1082
|
}
|
|
1002
1083
|
linked = _this3.createLinkedProductAndBooking({
|
|
@@ -1005,65 +1086,65 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1005
1086
|
});
|
|
1006
1087
|
result.products.push(linked.product);
|
|
1007
1088
|
tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
|
|
1008
|
-
return
|
|
1089
|
+
return _context7.abrupt("continue", 27);
|
|
1009
1090
|
case 26:
|
|
1010
1091
|
// normalize 略过:调用方应保证返回完整 OrderProduct。
|
|
1011
1092
|
result.products.push(gp);
|
|
1012
1093
|
case 27:
|
|
1013
|
-
|
|
1094
|
+
_context7.next = 16;
|
|
1014
1095
|
break;
|
|
1015
1096
|
case 29:
|
|
1016
|
-
|
|
1097
|
+
_context7.next = 34;
|
|
1017
1098
|
break;
|
|
1018
1099
|
case 31:
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
_iterator5.e(
|
|
1100
|
+
_context7.prev = 31;
|
|
1101
|
+
_context7.t0 = _context7["catch"](14);
|
|
1102
|
+
_iterator5.e(_context7.t0);
|
|
1022
1103
|
case 34:
|
|
1023
|
-
|
|
1104
|
+
_context7.prev = 34;
|
|
1024
1105
|
_iterator5.f();
|
|
1025
|
-
return
|
|
1106
|
+
return _context7.finish(34);
|
|
1026
1107
|
case 37:
|
|
1027
|
-
|
|
1108
|
+
_context7.next = 42;
|
|
1028
1109
|
break;
|
|
1029
1110
|
case 39:
|
|
1030
|
-
|
|
1031
|
-
|
|
1111
|
+
_context7.prev = 39;
|
|
1112
|
+
_context7.t1 = _context7["catch"](6);
|
|
1032
1113
|
// 用户取消 / 选择失败 → 视为放弃本次新增
|
|
1033
|
-
console.warn('[OrderModule] giftSelectResolver rejected, skip add gift', addAction.strategyId,
|
|
1114
|
+
console.warn('[OrderModule] giftSelectResolver rejected, skip add gift', addAction.strategyId, _context7.t1);
|
|
1034
1115
|
case 42:
|
|
1035
1116
|
case "end":
|
|
1036
|
-
return
|
|
1117
|
+
return _context7.stop();
|
|
1037
1118
|
}
|
|
1038
1119
|
}, _loop, null, [[6, 39], [14, 31, 34, 37]]);
|
|
1039
1120
|
});
|
|
1040
1121
|
_iterator4.s();
|
|
1041
1122
|
case 54:
|
|
1042
1123
|
if ((_step4 = _iterator4.n()).done) {
|
|
1043
|
-
|
|
1124
|
+
_context9.next = 60;
|
|
1044
1125
|
break;
|
|
1045
1126
|
}
|
|
1046
|
-
return
|
|
1127
|
+
return _context9.delegateYield(_loop(), "t3", 56);
|
|
1047
1128
|
case 56:
|
|
1048
|
-
if (!
|
|
1049
|
-
|
|
1129
|
+
if (!_context9.t3) {
|
|
1130
|
+
_context9.next = 58;
|
|
1050
1131
|
break;
|
|
1051
1132
|
}
|
|
1052
|
-
return
|
|
1133
|
+
return _context9.abrupt("continue", 58);
|
|
1053
1134
|
case 58:
|
|
1054
|
-
|
|
1135
|
+
_context9.next = 54;
|
|
1055
1136
|
break;
|
|
1056
1137
|
case 60:
|
|
1057
|
-
|
|
1138
|
+
_context9.next = 65;
|
|
1058
1139
|
break;
|
|
1059
1140
|
case 62:
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
_iterator4.e(
|
|
1141
|
+
_context9.prev = 62;
|
|
1142
|
+
_context9.t4 = _context9["catch"](51);
|
|
1143
|
+
_iterator4.e(_context9.t4);
|
|
1063
1144
|
case 65:
|
|
1064
|
-
|
|
1145
|
+
_context9.prev = 65;
|
|
1065
1146
|
_iterator4.f();
|
|
1066
|
-
return
|
|
1147
|
+
return _context9.finish(65);
|
|
1067
1148
|
case 68:
|
|
1068
1149
|
tempOrder.products = result.products;
|
|
1069
1150
|
this.lastUnfulfilledPromotions = result.unfulfilledPromotions;
|
|
@@ -1082,21 +1163,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1082
1163
|
products: tempOrder.products
|
|
1083
1164
|
};
|
|
1084
1165
|
this.effectsEmit('onPromotionApplied', payload);
|
|
1085
|
-
|
|
1166
|
+
_context9.next = 78;
|
|
1086
1167
|
break;
|
|
1087
1168
|
case 75:
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
console.error('[OrderModule] applyPromotion failed',
|
|
1169
|
+
_context9.prev = 75;
|
|
1170
|
+
_context9.t5 = _context9["catch"](11);
|
|
1171
|
+
console.error('[OrderModule] applyPromotion failed', _context9.t5);
|
|
1091
1172
|
case 78:
|
|
1092
|
-
|
|
1173
|
+
_context9.prev = 78;
|
|
1093
1174
|
this.isApplyingPromotion = false;
|
|
1094
|
-
return
|
|
1175
|
+
return _context9.finish(78);
|
|
1095
1176
|
case 81:
|
|
1096
1177
|
case "end":
|
|
1097
|
-
return
|
|
1178
|
+
return _context9.stop();
|
|
1098
1179
|
}
|
|
1099
|
-
},
|
|
1180
|
+
}, _callee7, this, [[11, 75, 78, 81], [15, 39, 42, 45], [20, 29, 32, 35], [51, 62, 65, 68]]);
|
|
1100
1181
|
}));
|
|
1101
1182
|
function applyPromotion() {
|
|
1102
1183
|
return _applyPromotion.apply(this, arguments);
|
|
@@ -1218,14 +1299,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1218
1299
|
}, {
|
|
1219
1300
|
key: "saveDraft",
|
|
1220
1301
|
value: function () {
|
|
1221
|
-
var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1222
|
-
return _regeneratorRuntime().wrap(function
|
|
1223
|
-
while (1) switch (
|
|
1302
|
+
var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
1303
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context10) {
|
|
1304
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
1224
1305
|
case 0:
|
|
1225
1306
|
case "end":
|
|
1226
|
-
return
|
|
1307
|
+
return _context10.stop();
|
|
1227
1308
|
}
|
|
1228
|
-
},
|
|
1309
|
+
}, _callee8);
|
|
1229
1310
|
}));
|
|
1230
1311
|
function saveDraft() {
|
|
1231
1312
|
return _saveDraft.apply(this, arguments);
|
|
@@ -1240,18 +1321,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1240
1321
|
}, {
|
|
1241
1322
|
key: "hydrateTempOrderFromLocalRecord",
|
|
1242
1323
|
value: function () {
|
|
1243
|
-
var _hydrateTempOrderFromLocalRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1244
|
-
return _regeneratorRuntime().wrap(function
|
|
1245
|
-
while (1) switch (
|
|
1324
|
+
var _hydrateTempOrderFromLocalRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(record) {
|
|
1325
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context11) {
|
|
1326
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1246
1327
|
case 0:
|
|
1247
|
-
return
|
|
1328
|
+
return _context11.abrupt("return", this.hydrateTempOrderFromRecord(record));
|
|
1248
1329
|
case 1:
|
|
1249
1330
|
case "end":
|
|
1250
|
-
return
|
|
1331
|
+
return _context11.stop();
|
|
1251
1332
|
}
|
|
1252
|
-
},
|
|
1333
|
+
}, _callee9, this);
|
|
1253
1334
|
}));
|
|
1254
|
-
function hydrateTempOrderFromLocalRecord(
|
|
1335
|
+
function hydrateTempOrderFromLocalRecord(_x8) {
|
|
1255
1336
|
return _hydrateTempOrderFromLocalRecord.apply(this, arguments);
|
|
1256
1337
|
}
|
|
1257
1338
|
return hydrateTempOrderFromLocalRecord;
|
|
@@ -1285,6 +1366,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1285
1366
|
return sum.plus(_this4.calculatePaymentEffectiveAmount(payment));
|
|
1286
1367
|
}, new Decimal(0));
|
|
1287
1368
|
}
|
|
1369
|
+
}, {
|
|
1370
|
+
key: "calculateOrderPaidPaymentTotal",
|
|
1371
|
+
value: function calculateOrderPaidPaymentTotal(payments) {
|
|
1372
|
+
var _this5 = this;
|
|
1373
|
+
return mapPaymentItemsToOrderPayments(payments, {
|
|
1374
|
+
includeVoided: false
|
|
1375
|
+
}).reduce(function (sum, payment) {
|
|
1376
|
+
if (!isPaidPaymentRecord(payment)) return sum;
|
|
1377
|
+
return sum.plus(_this5.calculatePaymentGapAmount(payment));
|
|
1378
|
+
}, new Decimal(0));
|
|
1379
|
+
}
|
|
1288
1380
|
}, {
|
|
1289
1381
|
key: "getDepositAmount",
|
|
1290
1382
|
value: function getDepositAmount(tempOrder, summary) {
|
|
@@ -1385,7 +1477,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1385
1477
|
var summary = this.store.summary || createEmptySummary();
|
|
1386
1478
|
var paymentList = payments || tempOrder.payments || [];
|
|
1387
1479
|
var refundAmount = this.getSummaryRefundAmount(summary);
|
|
1388
|
-
var netPaidAmount = Decimal.max(this.
|
|
1480
|
+
var netPaidAmount = Decimal.max(this.calculateOrderPaidPaymentTotal(paymentList).minus(refundAmount), 0);
|
|
1389
1481
|
var depositAmount = this.getDepositAmount(tempOrder, summary);
|
|
1390
1482
|
var orderExpectedAmount = this.getOrderExpectedAmount(summary);
|
|
1391
1483
|
var isDepositFullyPaid = this.isDepositCovered({
|
|
@@ -1407,17 +1499,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1407
1499
|
}, {
|
|
1408
1500
|
key: "calculateDepositPaidAmount",
|
|
1409
1501
|
value: function calculateDepositPaidAmount(payments) {
|
|
1410
|
-
var
|
|
1502
|
+
var _this6 = this;
|
|
1411
1503
|
return (payments || []).reduce(function (sum, payment) {
|
|
1412
1504
|
var paymentRecord = payment;
|
|
1413
1505
|
if (!isPaidPaymentRecord(paymentRecord)) return sum;
|
|
1414
1506
|
var isDepositPayment = paymentRecord.type === 'deposit' || paymentRecord.order_payment_type === 'deposit';
|
|
1415
1507
|
if (!isDepositPayment) return sum;
|
|
1416
|
-
|
|
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));
|
|
1508
|
+
return sum.plus(_this6.calculatePaymentGapAmount(paymentRecord));
|
|
1421
1509
|
}, new Decimal(0));
|
|
1422
1510
|
}
|
|
1423
1511
|
}, {
|
|
@@ -1429,19 +1517,44 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1429
1517
|
var depositPaidAmount = this.calculateDepositPaidAmount(tempOrder.payments || []);
|
|
1430
1518
|
return depositPaidAmount.lt(depositAmount) ? 'deposit' : 'normal';
|
|
1431
1519
|
}
|
|
1520
|
+
}, {
|
|
1521
|
+
key: "getPaymentNumberAppData",
|
|
1522
|
+
value: function getPaymentNumberAppData(key) {
|
|
1523
|
+
var _appPlugin$getData, _app$models, _app$models$getStore, _app$models$getStore$, _app$models$getStore$2;
|
|
1524
|
+
var appPlugin = this.appPlugin;
|
|
1525
|
+
if (!appPlugin) return undefined;
|
|
1526
|
+
var getData = (_appPlugin$getData = appPlugin.getData) === null || _appPlugin$getData === void 0 ? void 0 : _appPlugin$getData.call(appPlugin);
|
|
1527
|
+
if (typeof getData === 'function') return getData(key);
|
|
1528
|
+
var app = appPlugin.getApp();
|
|
1529
|
+
var coreData = app === null || app === void 0 || (_app$models = app.models) === null || _app$models === void 0 || (_app$models$getStore = _app$models.getStore) === null || _app$models$getStore === void 0 || (_app$models$getStore$ = (_app$models$getStore$2 = _app$models$getStore.call(_app$models)).getDataByModel) === null || _app$models$getStore$ === void 0 ? void 0 : _app$models$getStore$.call(_app$models$getStore$2, 'core', 'core');
|
|
1530
|
+
return coreData === null || coreData === void 0 ? void 0 : coreData[key];
|
|
1531
|
+
}
|
|
1532
|
+
}, {
|
|
1533
|
+
key: "getPaymentNumberDevicePrefixSync",
|
|
1534
|
+
value: function getPaymentNumberDevicePrefixSync() {
|
|
1535
|
+
var _this7 = this;
|
|
1536
|
+
return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
|
|
1537
|
+
return _this7.getPaymentNumberAppData(key);
|
|
1538
|
+
});
|
|
1539
|
+
}
|
|
1540
|
+
}, {
|
|
1541
|
+
key: "getPaymentNumberDevicePrefixAsync",
|
|
1542
|
+
value: function getPaymentNumberDevicePrefixAsync() {
|
|
1543
|
+
var _this8 = this;
|
|
1544
|
+
return resolvePaymentNumberDevicePrefix(function (key) {
|
|
1545
|
+
return _this8.getPaymentNumberAppData(key);
|
|
1546
|
+
});
|
|
1547
|
+
}
|
|
1432
1548
|
}, {
|
|
1433
1549
|
key: "normalizePaymentSource",
|
|
1434
1550
|
value: function normalizePaymentSource(payment, options) {
|
|
1435
1551
|
var _ref19, _paymentRecord$origin;
|
|
1436
1552
|
var paymentRecord = payment;
|
|
1437
1553
|
var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
|
|
1438
|
-
|
|
1439
|
-
metadata.unique_payment_number = createUuidV4();
|
|
1440
|
-
}
|
|
1441
|
-
var normalized = _objectSpread(_objectSpread({}, paymentRecord), {}, {
|
|
1554
|
+
var normalized = ensureOrderPaymentNumber(_objectSpread(_objectSpread({}, paymentRecord), {}, {
|
|
1442
1555
|
metadata: metadata,
|
|
1443
1556
|
origin_amount: (_ref19 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref19 !== void 0 ? _ref19 : '0.00'
|
|
1444
|
-
});
|
|
1557
|
+
}), (options === null || options === void 0 ? void 0 : options.devicePrefix) || this.getPaymentNumberDevicePrefixSync(), createUuidV4);
|
|
1445
1558
|
if (paymentRecord.status !== undefined) {
|
|
1446
1559
|
normalized.status = paymentRecord.status;
|
|
1447
1560
|
} else if ((options === null || options === void 0 ? void 0 : options.defaultPaid) !== false) {
|
|
@@ -1454,8 +1567,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1454
1567
|
value: function updateTempOrderPaymentStatus(tempOrder, options) {
|
|
1455
1568
|
var summary = (options === null || options === void 0 ? void 0 : options.summary) || this.store.summary || createEmptySummary();
|
|
1456
1569
|
var paymentTotal = this.calculatePaymentTotal(tempOrder.payments || []);
|
|
1570
|
+
var orderPaymentTotal = this.calculateOrderPaidPaymentTotal(tempOrder.payments || []);
|
|
1457
1571
|
var refundAmount = this.getSummaryRefundAmount(summary);
|
|
1458
|
-
var netPaymentTotal = Decimal.max(
|
|
1572
|
+
var netPaymentTotal = Decimal.max(orderPaymentTotal.minus(refundAmount), 0);
|
|
1459
1573
|
var targetAmount = this.calculatePaymentTargetAmount(tempOrder, summary, netPaymentTotal);
|
|
1460
1574
|
if (this.shouldKeepPaymentStatusAfterAmountRecalc(tempOrder.payment_status, {
|
|
1461
1575
|
netPaymentTotal: netPaymentTotal,
|
|
@@ -1521,7 +1635,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1521
1635
|
key: "capVoucherPaymentsByRemainingAmount",
|
|
1522
1636
|
value: function capVoucherPaymentsByRemainingAmount(params) {
|
|
1523
1637
|
var targetAmount = this.getPaymentTargetAmount();
|
|
1524
|
-
var nonVoucherTotal = this.
|
|
1638
|
+
var nonVoucherTotal = this.calculateOrderPaidPaymentTotal(params.nonVoucherPayments);
|
|
1525
1639
|
if (targetAmount.lte(0)) return [];
|
|
1526
1640
|
var remainingAmount = Decimal.max(targetAmount.minus(nonVoucherTotal), 0);
|
|
1527
1641
|
var cappedVouchers = [];
|
|
@@ -1558,16 +1672,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1558
1672
|
}, {
|
|
1559
1673
|
key: "calculatePaidPaymentSummary",
|
|
1560
1674
|
value: function calculatePaidPaymentSummary(payments) {
|
|
1561
|
-
var
|
|
1675
|
+
var _this9 = this;
|
|
1562
1676
|
return (payments || []).reduce(function (summary, payment) {
|
|
1563
1677
|
var paymentRecord = payment;
|
|
1564
1678
|
if (!isPaidPaymentRecord(paymentRecord)) return summary;
|
|
1565
1679
|
return {
|
|
1566
1680
|
customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
|
|
1567
|
-
orderPaidAmount: summary.orderPaidAmount.plus(paymentRecord
|
|
1568
|
-
gapPaidAmount: summary.gapPaidAmount.plus(
|
|
1569
|
-
payServiceChargeAmount: summary.payServiceChargeAmount.plus(
|
|
1570
|
-
roundingAmount: summary.roundingAmount.plus(
|
|
1681
|
+
orderPaidAmount: summary.orderPaidAmount.plus(_this9.calculatePaymentOrderAmount(paymentRecord)),
|
|
1682
|
+
gapPaidAmount: summary.gapPaidAmount.plus(_this9.calculatePaymentGapAmount(paymentRecord)),
|
|
1683
|
+
payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this9.calculatePaymentServiceFee(paymentRecord)),
|
|
1684
|
+
roundingAmount: summary.roundingAmount.plus(_this9.calculatePaymentRoundingAmount(paymentRecord))
|
|
1571
1685
|
};
|
|
1572
1686
|
}, {
|
|
1573
1687
|
customerPaidAmount: new Decimal(0),
|
|
@@ -1591,11 +1705,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1591
1705
|
}, {
|
|
1592
1706
|
key: "calculatePaymentGapAmount",
|
|
1593
1707
|
value: function calculatePaymentGapAmount(payment) {
|
|
1594
|
-
if (payment.origin_amount
|
|
1595
|
-
|
|
1708
|
+
if (payment.origin_amount !== undefined && payment.origin_amount !== null && payment.origin_amount !== '') {
|
|
1709
|
+
var _rounding = new Decimal(payment.rounding_amount || 0);
|
|
1710
|
+
return new Decimal(payment.origin_amount || 0).minus(_rounding);
|
|
1596
1711
|
}
|
|
1597
1712
|
var rounding = new Decimal(payment.rounding_amount || 0);
|
|
1598
|
-
|
|
1713
|
+
var amount = new Decimal(payment.amount || 0);
|
|
1714
|
+
var serviceFee = this.calculatePaymentServiceFee(payment);
|
|
1715
|
+
if (serviceFee.lte(0)) return amount.minus(rounding);
|
|
1716
|
+
if (!hasSyncedOrderPaymentRecord(payment)) return new Decimal(0);
|
|
1717
|
+
return Decimal.max(amount.minus(serviceFee), 0).minus(rounding);
|
|
1718
|
+
}
|
|
1719
|
+
}, {
|
|
1720
|
+
key: "calculatePaymentOrderAmount",
|
|
1721
|
+
value: function calculatePaymentOrderAmount(payment) {
|
|
1722
|
+
if (payment.origin_amount !== undefined && payment.origin_amount !== null && payment.origin_amount !== '') {
|
|
1723
|
+
return new Decimal(payment.origin_amount || 0);
|
|
1724
|
+
}
|
|
1725
|
+
var amount = new Decimal(payment.amount || 0);
|
|
1726
|
+
var serviceFee = this.calculatePaymentServiceFee(payment);
|
|
1727
|
+
if (serviceFee.lte(0)) return amount;
|
|
1728
|
+
if (!hasSyncedOrderPaymentRecord(payment)) return new Decimal(0);
|
|
1729
|
+
return Decimal.max(amount.minus(serviceFee), 0);
|
|
1599
1730
|
}
|
|
1600
1731
|
}, {
|
|
1601
1732
|
key: "calculatePaymentRoundingAmount",
|
|
@@ -1752,15 +1883,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1752
1883
|
}, {
|
|
1753
1884
|
key: "normalizeFingerprintValue",
|
|
1754
1885
|
value: function normalizeFingerprintValue(value) {
|
|
1755
|
-
var
|
|
1886
|
+
var _this10 = this;
|
|
1756
1887
|
if (Array.isArray(value)) {
|
|
1757
1888
|
return value.map(function (item) {
|
|
1758
|
-
return
|
|
1889
|
+
return _this10.normalizeFingerprintValue(item);
|
|
1759
1890
|
});
|
|
1760
1891
|
}
|
|
1761
1892
|
if (!value || _typeof(value) !== 'object') return value !== null && value !== void 0 ? value : '';
|
|
1762
1893
|
return Object.keys(value).sort().reduce(function (result, key) {
|
|
1763
|
-
result[key] =
|
|
1894
|
+
result[key] = _this10.normalizeFingerprintValue(value[key]);
|
|
1764
1895
|
return result;
|
|
1765
1896
|
}, {});
|
|
1766
1897
|
}
|
|
@@ -1775,7 +1906,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1775
1906
|
_sku$barcode,
|
|
1776
1907
|
_ref20,
|
|
1777
1908
|
_sku$variant_id,
|
|
1778
|
-
|
|
1909
|
+
_this11 = this;
|
|
1779
1910
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
1780
1911
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
1781
1912
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -1809,7 +1940,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1809
1940
|
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,
|
|
1810
1941
|
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,
|
|
1811
1942
|
num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
|
|
1812
|
-
add_price:
|
|
1943
|
+
add_price: _this11.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)
|
|
1813
1944
|
};
|
|
1814
1945
|
})
|
|
1815
1946
|
}),
|
|
@@ -1819,8 +1950,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1819
1950
|
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,
|
|
1820
1951
|
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,
|
|
1821
1952
|
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),
|
|
1822
|
-
price:
|
|
1823
|
-
bundle_selling_price:
|
|
1953
|
+
price: _this11.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
|
|
1954
|
+
bundle_selling_price: _this11.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
|
|
1824
1955
|
price_type: (_bundle$price_type = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type !== void 0 ? _bundle$price_type : '',
|
|
1825
1956
|
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 : ''
|
|
1826
1957
|
};
|
|
@@ -1830,7 +1961,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1830
1961
|
return {
|
|
1831
1962
|
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 : '',
|
|
1832
1963
|
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,
|
|
1833
|
-
amount:
|
|
1964
|
+
amount: _this11.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
1834
1965
|
};
|
|
1835
1966
|
}))
|
|
1836
1967
|
};
|
|
@@ -1838,9 +1969,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1838
1969
|
}, {
|
|
1839
1970
|
key: "buildOrderProductsFingerprint",
|
|
1840
1971
|
value: function buildOrderProductsFingerprint(products) {
|
|
1841
|
-
var
|
|
1972
|
+
var _this12 = this;
|
|
1842
1973
|
var items = (products || []).map(function (product) {
|
|
1843
|
-
return
|
|
1974
|
+
return _this12.buildProductFingerprintItem(product);
|
|
1844
1975
|
});
|
|
1845
1976
|
items.sort(function (left, right) {
|
|
1846
1977
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -1862,7 +1993,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1862
1993
|
_sku$barcode2,
|
|
1863
1994
|
_ref30,
|
|
1864
1995
|
_sku$variant_id2,
|
|
1865
|
-
|
|
1996
|
+
_this13 = this;
|
|
1866
1997
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
1867
1998
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
1868
1999
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -1893,7 +2024,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1893
2024
|
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,
|
|
1894
2025
|
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,
|
|
1895
2026
|
num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
|
|
1896
|
-
add_price:
|
|
2027
|
+
add_price: _this13.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)
|
|
1897
2028
|
};
|
|
1898
2029
|
})
|
|
1899
2030
|
}),
|
|
@@ -1907,14 +2038,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1907
2038
|
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),
|
|
1908
2039
|
price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
|
|
1909
2040
|
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 : '',
|
|
1910
|
-
option:
|
|
2041
|
+
option: _this13.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
|
|
1911
2042
|
var _ref38, _option$id3, _option$option_group_5, _ref39, _option$option_group_6, _option$num3, _option$add_price3;
|
|
1912
2043
|
return {
|
|
1913
2044
|
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,
|
|
1914
2045
|
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,
|
|
1915
2046
|
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,
|
|
1916
2047
|
num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
|
|
1917
|
-
add_price:
|
|
2048
|
+
add_price: _this13.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)
|
|
1918
2049
|
};
|
|
1919
2050
|
}))
|
|
1920
2051
|
};
|
|
@@ -1924,7 +2055,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1924
2055
|
return {
|
|
1925
2056
|
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 : '',
|
|
1926
2057
|
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,
|
|
1927
|
-
amount:
|
|
2058
|
+
amount: _this13.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
1928
2059
|
};
|
|
1929
2060
|
}))
|
|
1930
2061
|
};
|
|
@@ -1932,9 +2063,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1932
2063
|
}, {
|
|
1933
2064
|
key: "buildOrderProductsStructuralFingerprint",
|
|
1934
2065
|
value: function buildOrderProductsStructuralFingerprint(products) {
|
|
1935
|
-
var
|
|
2066
|
+
var _this14 = this;
|
|
1936
2067
|
var items = (products || []).map(function (product) {
|
|
1937
|
-
return
|
|
2068
|
+
return _this14.buildProductStructuralFingerprintItem(product);
|
|
1938
2069
|
});
|
|
1939
2070
|
items.sort(function (left, right) {
|
|
1940
2071
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -2010,13 +2141,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2010
2141
|
key: "restoreOriginalSnapshotIfProductsUnchanged",
|
|
2011
2142
|
value: function restoreOriginalSnapshotIfProductsUnchanged(tempOrder, snapshot) {
|
|
2012
2143
|
var currentFingerprint = this.buildOrderProductsFingerprint(tempOrder.products);
|
|
2144
|
+
var manualDepositOverride = this.getManualDepositOverride(tempOrder);
|
|
2013
2145
|
if (currentFingerprint !== snapshot.productFingerprint) {
|
|
2014
2146
|
var currentStructuralFingerprint = this.buildOrderProductsStructuralFingerprint(tempOrder.products);
|
|
2015
2147
|
var snapshotStructuralFingerprint = this.buildOrderProductsStructuralFingerprint(Array.isArray(snapshot.products) ? snapshot.products : []);
|
|
2016
2148
|
if (currentStructuralFingerprint !== snapshotStructuralFingerprint) return null;
|
|
2017
2149
|
}
|
|
2018
2150
|
var summary = _objectSpread(_objectSpread({}, createEmptySummary()), cloneDeep(snapshot.summary || {}));
|
|
2019
|
-
|
|
2151
|
+
var shouldUseManualDepositOverride = Boolean(manualDepositOverride && manualDepositOverride.productStructuralFingerprint === this.buildOrderProductsStructuralFingerprint(tempOrder.products));
|
|
2152
|
+
if (shouldUseManualDepositOverride) {
|
|
2153
|
+
summary = this.applyDepositAmountToSummary(tempOrder, summary, manualDepositOverride.amount);
|
|
2154
|
+
} else if (manualDepositOverride) {
|
|
2155
|
+
this.clearManualDepositOverride(tempOrder);
|
|
2156
|
+
}
|
|
2157
|
+
var isPayableAmountUnchanged = this.isSnapshotPayableAmountUnchanged(tempOrder, snapshot, summary);
|
|
2158
|
+
if (!isPayableAmountUnchanged) return null;
|
|
2020
2159
|
if (Array.isArray(snapshot.products)) {
|
|
2021
2160
|
tempOrder.products = cloneDeep(snapshot.products);
|
|
2022
2161
|
}
|
|
@@ -2026,7 +2165,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2026
2165
|
tempOrder.surcharge_fee = summary.surcharge_fee || tempOrder.surcharge_fee;
|
|
2027
2166
|
tempOrder.deposit_amount = summary.deposit_amount || '0.00';
|
|
2028
2167
|
tempOrder.is_deposit = summary.deposit_amount !== '0.00' ? 1 : 0;
|
|
2168
|
+
var previousSummary = this.store.summary;
|
|
2029
2169
|
this.store.summary = summary;
|
|
2170
|
+
this.updateTempOrderPaymentStatus(tempOrder, {
|
|
2171
|
+
previousSummary: previousSummary,
|
|
2172
|
+
summary: summary
|
|
2173
|
+
});
|
|
2030
2174
|
return summary;
|
|
2031
2175
|
}
|
|
2032
2176
|
}, {
|
|
@@ -2138,7 +2282,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2138
2282
|
}, {
|
|
2139
2283
|
key: "restoreOrder",
|
|
2140
2284
|
value: function restoreOrder() {
|
|
2141
|
-
var _this$store$
|
|
2285
|
+
var _this$store$discount15, _this$store$discount16;
|
|
2142
2286
|
this.logInfo('restoreOrder start', {});
|
|
2143
2287
|
var freshTempOrder = this.createDefaultTempOrderInstance();
|
|
2144
2288
|
this.ensureExternalSaleNumber(freshTempOrder);
|
|
@@ -2146,8 +2290,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2146
2290
|
this.store.summary = createEmptySummary();
|
|
2147
2291
|
this.store.lastOrderInfo = undefined;
|
|
2148
2292
|
this.store.syncState = undefined;
|
|
2149
|
-
void ((_this$store$
|
|
2150
|
-
void ((_this$store$
|
|
2293
|
+
void ((_this$store$discount15 = this.store.discount) === null || _this$store$discount15 === void 0 ? void 0 : _this$store$discount15.setOriginalDiscountList([]));
|
|
2294
|
+
void ((_this$store$discount16 = this.store.discount) === null || _this$store$discount16 === void 0 ? void 0 : _this$store$discount16.setDiscountList([]));
|
|
2151
2295
|
this.persistTempOrder();
|
|
2152
2296
|
return freshTempOrder;
|
|
2153
2297
|
}
|
|
@@ -2159,13 +2303,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2159
2303
|
}, {
|
|
2160
2304
|
key: "replaceTempOrder",
|
|
2161
2305
|
value: function () {
|
|
2162
|
-
var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2306
|
+
var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(tempOrder, options) {
|
|
2163
2307
|
var nextTempOrder;
|
|
2164
|
-
return _regeneratorRuntime().wrap(function
|
|
2165
|
-
while (1) switch (
|
|
2308
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context12) {
|
|
2309
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
2166
2310
|
case 0:
|
|
2167
2311
|
if (isTempOrder(tempOrder)) {
|
|
2168
|
-
|
|
2312
|
+
_context12.next = 2;
|
|
2169
2313
|
break;
|
|
2170
2314
|
}
|
|
2171
2315
|
throw new Error('无效的 tempOrder 数据');
|
|
@@ -2175,15 +2319,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2175
2319
|
});
|
|
2176
2320
|
this.store.tempOrder = nextTempOrder;
|
|
2177
2321
|
if (!((options === null || options === void 0 ? void 0 : options.recalculateSummary) !== false)) {
|
|
2178
|
-
|
|
2322
|
+
_context12.next = 9;
|
|
2179
2323
|
break;
|
|
2180
2324
|
}
|
|
2181
|
-
|
|
2325
|
+
_context12.next = 7;
|
|
2182
2326
|
return this.recalculateSummary({
|
|
2183
2327
|
createIfMissing: false
|
|
2184
2328
|
});
|
|
2185
2329
|
case 7:
|
|
2186
|
-
|
|
2330
|
+
_context12.next = 10;
|
|
2187
2331
|
break;
|
|
2188
2332
|
case 9:
|
|
2189
2333
|
this.store.summary = createEmptySummary();
|
|
@@ -2192,20 +2336,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2192
2336
|
this.persistTempOrder();
|
|
2193
2337
|
}
|
|
2194
2338
|
if (!(options !== null && options !== void 0 && options.saveDraft)) {
|
|
2195
|
-
|
|
2339
|
+
_context12.next = 14;
|
|
2196
2340
|
break;
|
|
2197
2341
|
}
|
|
2198
|
-
|
|
2342
|
+
_context12.next = 14;
|
|
2199
2343
|
return this.saveDraft();
|
|
2200
2344
|
case 14:
|
|
2201
|
-
return
|
|
2345
|
+
return _context12.abrupt("return", nextTempOrder);
|
|
2202
2346
|
case 15:
|
|
2203
2347
|
case "end":
|
|
2204
|
-
return
|
|
2348
|
+
return _context12.stop();
|
|
2205
2349
|
}
|
|
2206
|
-
},
|
|
2350
|
+
}, _callee10, this);
|
|
2207
2351
|
}));
|
|
2208
|
-
function replaceTempOrder(
|
|
2352
|
+
function replaceTempOrder(_x9, _x10) {
|
|
2209
2353
|
return _replaceTempOrder.apply(this, arguments);
|
|
2210
2354
|
}
|
|
2211
2355
|
return replaceTempOrder;
|
|
@@ -2291,32 +2435,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2291
2435
|
}, {
|
|
2292
2436
|
key: "addNewOrder",
|
|
2293
2437
|
value: function () {
|
|
2294
|
-
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2438
|
+
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
2295
2439
|
var tempOrder;
|
|
2296
|
-
return _regeneratorRuntime().wrap(function
|
|
2297
|
-
while (1) switch (
|
|
2440
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context13) {
|
|
2441
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
2298
2442
|
case 0:
|
|
2299
2443
|
tempOrder = this.ensureTempOrder();
|
|
2300
2444
|
this.ensureExternalSaleNumber(tempOrder);
|
|
2301
|
-
|
|
2445
|
+
_context13.next = 4;
|
|
2302
2446
|
return this.recalculateSummary({
|
|
2303
2447
|
createIfMissing: true
|
|
2304
2448
|
});
|
|
2305
2449
|
case 4:
|
|
2306
2450
|
this.persistTempOrder();
|
|
2307
2451
|
if (!this.draftPersistEnabled) {
|
|
2308
|
-
|
|
2452
|
+
_context13.next = 8;
|
|
2309
2453
|
break;
|
|
2310
2454
|
}
|
|
2311
|
-
|
|
2455
|
+
_context13.next = 8;
|
|
2312
2456
|
return this.saveDraft();
|
|
2313
2457
|
case 8:
|
|
2314
|
-
return
|
|
2458
|
+
return _context13.abrupt("return", tempOrder);
|
|
2315
2459
|
case 9:
|
|
2316
2460
|
case "end":
|
|
2317
|
-
return
|
|
2461
|
+
return _context13.stop();
|
|
2318
2462
|
}
|
|
2319
|
-
},
|
|
2463
|
+
}, _callee11, this);
|
|
2320
2464
|
}));
|
|
2321
2465
|
function addNewOrder() {
|
|
2322
2466
|
return _addNewOrder.apply(this, arguments);
|
|
@@ -2349,9 +2493,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2349
2493
|
}, {
|
|
2350
2494
|
key: "sanitizeTempOrderProducts",
|
|
2351
2495
|
value: function sanitizeTempOrderProducts(tempOrder) {
|
|
2352
|
-
var
|
|
2496
|
+
var _this15 = this;
|
|
2353
2497
|
tempOrder.products = (tempOrder.products || []).map(function (product) {
|
|
2354
|
-
return
|
|
2498
|
+
return _this15.sanitizeOrderProductForTempOrder(product);
|
|
2355
2499
|
});
|
|
2356
2500
|
}
|
|
2357
2501
|
}, {
|
|
@@ -2454,7 +2598,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2454
2598
|
}, {
|
|
2455
2599
|
key: "syncLinkedBookingHoldersToProducts",
|
|
2456
2600
|
value: function syncLinkedBookingHoldersToProducts(tempOrder) {
|
|
2457
|
-
var
|
|
2601
|
+
var _this16 = this;
|
|
2458
2602
|
var bookings = tempOrder.bookings || [];
|
|
2459
2603
|
var products = tempOrder.products || [];
|
|
2460
2604
|
if (!bookings.length || !products.length) return;
|
|
@@ -2479,7 +2623,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2479
2623
|
var bookingUid = product.booking_uid || ((_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.booking_uid);
|
|
2480
2624
|
var linkedBooking = (productUid !== undefined && productUid !== null && String(productUid) !== '' ? bookingByProductUid.get(String(productUid)) : undefined) || (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '' ? bookingByBookingUid.get(String(bookingUid)) : undefined);
|
|
2481
2625
|
if (linkedBooking) {
|
|
2482
|
-
|
|
2626
|
+
_this16.setProductHolderFromBooking(product, linkedBooking);
|
|
2483
2627
|
}
|
|
2484
2628
|
});
|
|
2485
2629
|
}
|
|
@@ -2517,7 +2661,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2517
2661
|
}, {
|
|
2518
2662
|
key: "buildTempOrderHolderFromBookings",
|
|
2519
2663
|
value: function buildTempOrderHolderFromBookings(tempOrder) {
|
|
2520
|
-
var _baseHolder$customer_, _baseHolder, _ref46, _baseHolder$form_id, _baseHolder2, _tempOrder$
|
|
2664
|
+
var _baseHolder$customer_, _baseHolder, _ref46, _baseHolder$form_id, _baseHolder2, _tempOrder$holder2, _baseHolder3, _this$otherParams;
|
|
2521
2665
|
var holderRecords = [];
|
|
2522
2666
|
var holderNames = [];
|
|
2523
2667
|
var baseHolder = null;
|
|
@@ -2564,7 +2708,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2564
2708
|
}
|
|
2565
2709
|
var nextHolder = {
|
|
2566
2710
|
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,
|
|
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$
|
|
2711
|
+
form_id: (_ref46 = (_baseHolder$form_id = (_baseHolder2 = baseHolder) === null || _baseHolder2 === void 0 ? void 0 : _baseHolder2.form_id) !== null && _baseHolder$form_id !== void 0 ? _baseHolder$form_id : (_tempOrder$holder2 = tempOrder.holder) === null || _tempOrder$holder2 === void 0 ? void 0 : _tempOrder$holder2.form_id) !== null && _ref46 !== void 0 ? _ref46 : 0,
|
|
2568
2712
|
form_record: holderRecords
|
|
2569
2713
|
};
|
|
2570
2714
|
if (holderNames.length) {
|
|
@@ -2607,9 +2751,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2607
2751
|
}, {
|
|
2608
2752
|
key: "findBookingIndexByUniqueIdentificationNumber",
|
|
2609
2753
|
value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
|
|
2610
|
-
var
|
|
2754
|
+
var _this17 = this;
|
|
2611
2755
|
return (tempOrder.bookings || []).findIndex(function (booking) {
|
|
2612
|
-
return
|
|
2756
|
+
return _this17.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
|
|
2613
2757
|
});
|
|
2614
2758
|
}
|
|
2615
2759
|
}, {
|
|
@@ -2617,12 +2761,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2617
2761
|
value: function removeLinkedBookingsForProduct(tempOrder, product) {
|
|
2618
2762
|
var _product$metadata7,
|
|
2619
2763
|
_product$metadata8,
|
|
2620
|
-
|
|
2764
|
+
_this18 = this;
|
|
2621
2765
|
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);
|
|
2622
2766
|
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);
|
|
2623
2767
|
if (!productUid && !bookingUid) return;
|
|
2624
2768
|
tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
2625
|
-
var currentBookingUid =
|
|
2769
|
+
var currentBookingUid = _this18.getBookingUniqueIdentificationNumber(booking);
|
|
2626
2770
|
if (bookingUid && currentBookingUid === String(bookingUid)) return false;
|
|
2627
2771
|
if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
|
|
2628
2772
|
return true;
|
|
@@ -2668,18 +2812,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2668
2812
|
}, {
|
|
2669
2813
|
key: "recalculateSummary",
|
|
2670
2814
|
value: function () {
|
|
2671
|
-
var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2815
|
+
var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(options) {
|
|
2672
2816
|
var _this$otherParams2, _ref47, _salesSummaryResult$e;
|
|
2673
2817
|
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;
|
|
2674
|
-
return _regeneratorRuntime().wrap(function
|
|
2675
|
-
while (1) switch (
|
|
2818
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context14) {
|
|
2819
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
2676
2820
|
case 0:
|
|
2677
2821
|
tempOrder = options !== null && options !== void 0 && options.createIfMissing ? this.ensureTempOrder() : this.store.tempOrder;
|
|
2678
2822
|
if (tempOrder) {
|
|
2679
|
-
|
|
2823
|
+
_context14.next = 3;
|
|
2680
2824
|
break;
|
|
2681
2825
|
}
|
|
2682
|
-
return
|
|
2826
|
+
return _context14.abrupt("return", null);
|
|
2683
2827
|
case 3:
|
|
2684
2828
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
2685
2829
|
originalSnapshot = this.getOriginalSalesSnapshot(tempOrder);
|
|
@@ -2687,10 +2831,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2687
2831
|
shouldReuseOriginalSnapshot = originalSnapshot && !hasShopDiscountChanged;
|
|
2688
2832
|
snapshotSummary = shouldReuseOriginalSnapshot ? this.restoreOriginalSnapshotIfProductsUnchanged(tempOrder, originalSnapshot) : null;
|
|
2689
2833
|
if (!snapshotSummary) {
|
|
2690
|
-
|
|
2834
|
+
_context14.next = 10;
|
|
2691
2835
|
break;
|
|
2692
2836
|
}
|
|
2693
|
-
return
|
|
2837
|
+
return _context14.abrupt("return", snapshotSummary);
|
|
2694
2838
|
case 10:
|
|
2695
2839
|
shouldFullRecalculateFromSnapshot = Boolean(originalSnapshot);
|
|
2696
2840
|
summaryProducts = shouldFullRecalculateFromSnapshot ? cloneDeep(tempOrder.products || []) : tempOrder.products;
|
|
@@ -2702,7 +2846,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2702
2846
|
totalRefundAmount = existedSummary.total_refund_amount || '0.00';
|
|
2703
2847
|
paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
|
|
2704
2848
|
if (salesSummary) {
|
|
2705
|
-
|
|
2849
|
+
_context14.next = 26;
|
|
2706
2850
|
break;
|
|
2707
2851
|
}
|
|
2708
2852
|
emptyBaseSummary = _objectSpread(_objectSpread(_objectSpread({}, createEmptySummary()), existedSummary), {}, {
|
|
@@ -2728,9 +2872,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2728
2872
|
previousSummary: existedSummary,
|
|
2729
2873
|
summary: emptySummary
|
|
2730
2874
|
});
|
|
2731
|
-
return
|
|
2875
|
+
return _context14.abrupt("return", this.store.summary);
|
|
2732
2876
|
case 26:
|
|
2733
|
-
|
|
2877
|
+
_context14.next = 28;
|
|
2734
2878
|
return salesSummary.getSummary(_objectSpread({
|
|
2735
2879
|
products: summaryProducts,
|
|
2736
2880
|
isPriceIncludeTax: tempOrder.is_price_include_tax,
|
|
@@ -2739,7 +2883,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2739
2883
|
channel: this.otherParams.channel
|
|
2740
2884
|
} : {}));
|
|
2741
2885
|
case 28:
|
|
2742
|
-
salesSummaryResult =
|
|
2886
|
+
salesSummaryResult = _context14.sent;
|
|
2743
2887
|
if (shouldFullRecalculateFromSnapshot) {
|
|
2744
2888
|
tempOrder.products = summaryProducts;
|
|
2745
2889
|
}
|
|
@@ -2784,14 +2928,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2784
2928
|
previousSummary: existedSummary,
|
|
2785
2929
|
summary: summary
|
|
2786
2930
|
});
|
|
2787
|
-
return
|
|
2931
|
+
return _context14.abrupt("return", this.store.summary);
|
|
2788
2932
|
case 46:
|
|
2789
2933
|
case "end":
|
|
2790
|
-
return
|
|
2934
|
+
return _context14.stop();
|
|
2791
2935
|
}
|
|
2792
|
-
},
|
|
2936
|
+
}, _callee12, this);
|
|
2793
2937
|
}));
|
|
2794
|
-
function recalculateSummary(
|
|
2938
|
+
function recalculateSummary(_x11) {
|
|
2795
2939
|
return _recalculateSummary.apply(this, arguments);
|
|
2796
2940
|
}
|
|
2797
2941
|
return recalculateSummary;
|
|
@@ -2799,30 +2943,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2799
2943
|
}, {
|
|
2800
2944
|
key: "getOrderSummary",
|
|
2801
2945
|
value: function () {
|
|
2802
|
-
var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2946
|
+
var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
2803
2947
|
var summary;
|
|
2804
|
-
return _regeneratorRuntime().wrap(function
|
|
2805
|
-
while (1) switch (
|
|
2948
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context15) {
|
|
2949
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
2806
2950
|
case 0:
|
|
2807
|
-
|
|
2951
|
+
_context15.next = 2;
|
|
2808
2952
|
return this.recalculateSummary({
|
|
2809
2953
|
createIfMissing: true
|
|
2810
2954
|
});
|
|
2811
2955
|
case 2:
|
|
2812
|
-
summary =
|
|
2956
|
+
summary = _context15.sent;
|
|
2813
2957
|
if (summary) {
|
|
2814
|
-
|
|
2958
|
+
_context15.next = 5;
|
|
2815
2959
|
break;
|
|
2816
2960
|
}
|
|
2817
|
-
return
|
|
2961
|
+
return _context15.abrupt("return", createEmptySummary());
|
|
2818
2962
|
case 5:
|
|
2819
2963
|
this.persistTempOrder();
|
|
2820
|
-
return
|
|
2964
|
+
return _context15.abrupt("return", summary);
|
|
2821
2965
|
case 7:
|
|
2822
2966
|
case "end":
|
|
2823
|
-
return
|
|
2967
|
+
return _context15.stop();
|
|
2824
2968
|
}
|
|
2825
|
-
},
|
|
2969
|
+
}, _callee13, this);
|
|
2826
2970
|
}));
|
|
2827
2971
|
function getOrderSummary() {
|
|
2828
2972
|
return _getOrderSummary.apply(this, arguments);
|
|
@@ -2846,23 +2990,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2846
2990
|
}, {
|
|
2847
2991
|
key: "syncTempOrderNoteToRemote",
|
|
2848
2992
|
value: function () {
|
|
2849
|
-
var _syncTempOrderNoteToRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2850
|
-
return _regeneratorRuntime().wrap(function
|
|
2851
|
-
while (1) switch (
|
|
2993
|
+
var _syncTempOrderNoteToRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(orderId, note) {
|
|
2994
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context16) {
|
|
2995
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
2852
2996
|
case 0:
|
|
2853
|
-
|
|
2997
|
+
_context16.next = 2;
|
|
2854
2998
|
return this.request.put("/order/order/".concat(orderId, "/note"), {
|
|
2855
2999
|
note: note
|
|
2856
3000
|
});
|
|
2857
3001
|
case 2:
|
|
2858
|
-
return
|
|
3002
|
+
return _context16.abrupt("return", note);
|
|
2859
3003
|
case 3:
|
|
2860
3004
|
case "end":
|
|
2861
|
-
return
|
|
3005
|
+
return _context16.stop();
|
|
2862
3006
|
}
|
|
2863
|
-
},
|
|
3007
|
+
}, _callee14, this);
|
|
2864
3008
|
}));
|
|
2865
|
-
function syncTempOrderNoteToRemote(
|
|
3009
|
+
function syncTempOrderNoteToRemote(_x12, _x13) {
|
|
2866
3010
|
return _syncTempOrderNoteToRemote.apply(this, arguments);
|
|
2867
3011
|
}
|
|
2868
3012
|
return syncTempOrderNoteToRemote;
|
|
@@ -2947,38 +3091,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2947
3091
|
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;
|
|
2948
3092
|
return type === 'good_pass' || type === 'discount_card' || type === 'product_discount_card';
|
|
2949
3093
|
}
|
|
3094
|
+
}, {
|
|
3095
|
+
key: "shouldKeepCustomerBoundDiscountAfterCustomerChange",
|
|
3096
|
+
value: function shouldKeepCustomerBoundDiscountAfterCustomerChange(discount) {
|
|
3097
|
+
return Boolean((discount === null || discount === void 0 ? void 0 : discount.isScan) || (discount === null || discount === void 0 ? void 0 : discount.isEditMode));
|
|
3098
|
+
}
|
|
2950
3099
|
}, {
|
|
2951
3100
|
key: "productHasCustomerBoundDiscount",
|
|
2952
3101
|
value: function productHasCustomerBoundDiscount(product) {
|
|
2953
|
-
var
|
|
3102
|
+
var _this19 = this;
|
|
2954
3103
|
if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
|
|
2955
|
-
return
|
|
3104
|
+
return _this19.isCustomerBoundDiscount(discount);
|
|
2956
3105
|
})) {
|
|
2957
3106
|
return true;
|
|
2958
3107
|
}
|
|
2959
3108
|
return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
|
|
2960
3109
|
return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
|
|
2961
|
-
return
|
|
3110
|
+
return _this19.isCustomerBoundDiscount(discount);
|
|
2962
3111
|
});
|
|
2963
3112
|
});
|
|
2964
3113
|
}
|
|
2965
3114
|
}, {
|
|
2966
3115
|
key: "shouldSkipDiscountCalculation",
|
|
2967
3116
|
value: function shouldSkipDiscountCalculation(tempOrder) {
|
|
2968
|
-
var _this$store$
|
|
2969
|
-
_this$store$
|
|
2970
|
-
|
|
3117
|
+
var _this$store$discount17,
|
|
3118
|
+
_this$store$discount18,
|
|
3119
|
+
_this20 = this;
|
|
2971
3120
|
if (this.hasActiveCustomerBoundDiscount) return false;
|
|
2972
|
-
var discountList = ((_this$store$
|
|
3121
|
+
var discountList = ((_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 || (_this$store$discount18 = _this$store$discount17.getDiscountList) === null || _this$store$discount18 === void 0 ? void 0 : _this$store$discount18.call(_this$store$discount17)) || [];
|
|
2973
3122
|
if (discountList.length > 0) return false;
|
|
2974
3123
|
return !(tempOrder.products || []).some(function (product) {
|
|
2975
|
-
return
|
|
3124
|
+
return _this20.productHasCustomerBoundDiscount(product);
|
|
2976
3125
|
});
|
|
2977
3126
|
}
|
|
2978
3127
|
}, {
|
|
2979
3128
|
key: "clearCustomerBoundDiscounts",
|
|
2980
3129
|
value: function clearCustomerBoundDiscounts(tempOrder) {
|
|
2981
|
-
var
|
|
3130
|
+
var _this21 = this,
|
|
2982
3131
|
_discountModule$getDi,
|
|
2983
3132
|
_discountModule$getOr,
|
|
2984
3133
|
_discountModule$setDi,
|
|
@@ -2987,7 +3136,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2987
3136
|
var filterDiscountList = function filterDiscountList(discountList) {
|
|
2988
3137
|
if (!Array.isArray(discountList)) return [];
|
|
2989
3138
|
return discountList.filter(function (discount) {
|
|
2990
|
-
var shouldRemove =
|
|
3139
|
+
var shouldRemove = _this21.isCustomerBoundDiscount(discount);
|
|
2991
3140
|
if (shouldRemove) didRemoveCustomerBoundDiscount = true;
|
|
2992
3141
|
return !shouldRemove;
|
|
2993
3142
|
});
|
|
@@ -3014,12 +3163,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3014
3163
|
var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
|
|
3015
3164
|
var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
|
|
3016
3165
|
var nextDiscounts = currentDiscounts.filter(function (discount) {
|
|
3017
|
-
if (discount
|
|
3018
|
-
return !
|
|
3166
|
+
if (_this21.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
3167
|
+
return !_this21.isCustomerBoundDiscount(discount);
|
|
3019
3168
|
});
|
|
3020
3169
|
var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
|
|
3021
|
-
if (discount
|
|
3022
|
-
return !
|
|
3170
|
+
if (_this21.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
3171
|
+
return !_this21.isCustomerBoundDiscount(discount);
|
|
3023
3172
|
});
|
|
3024
3173
|
void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
|
|
3025
3174
|
void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
|
|
@@ -3090,6 +3239,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3090
3239
|
}
|
|
3091
3240
|
var nextCustomerId = (_tempOrder$customer_i5 = tempOrder.customer_id) !== null && _tempOrder$customer_i5 !== void 0 ? _tempOrder$customer_i5 : null;
|
|
3092
3241
|
if (String(previousCustomerId !== null && previousCustomerId !== void 0 ? previousCustomerId : '') !== String(nextCustomerId !== null && nextCustomerId !== void 0 ? nextCustomerId : '')) {
|
|
3242
|
+
this.store.availableWalletIds = [];
|
|
3093
3243
|
clearTempOrderHolderAssignments(tempOrder);
|
|
3094
3244
|
this.clearCustomerBoundDiscounts(tempOrder);
|
|
3095
3245
|
this.applyDiscount();
|
|
@@ -3134,6 +3284,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3134
3284
|
tempOrder.email = '';
|
|
3135
3285
|
tempOrder.customer = null;
|
|
3136
3286
|
if (tempOrder._extend) delete tempOrder._extend.customerSnapshot;
|
|
3287
|
+
this.store.availableWalletIds = [];
|
|
3137
3288
|
this.clearCustomerBoundDiscounts(tempOrder);
|
|
3138
3289
|
this.persistTempOrder();
|
|
3139
3290
|
this.saveDraftInBackground();
|
|
@@ -3171,23 +3322,71 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3171
3322
|
* 用一组支付来源覆盖当前订单支付项。
|
|
3172
3323
|
*
|
|
3173
3324
|
* 入参允许来自 PaymentModule 的 PaymentItem,内部统一映射为 Sales 协议:
|
|
3174
|
-
* uuid
|
|
3325
|
+
* 新支付来源的 uuid 会作为 payment_number 的唯一号段,id -> custom_payment_id,
|
|
3175
3326
|
* isSynced 等运行态字段不会进入 tempOrder.payments。
|
|
3176
3327
|
*/
|
|
3177
3328
|
}, {
|
|
3178
3329
|
key: "setOrderPayments",
|
|
3179
3330
|
value: function setOrderPayments(payments) {
|
|
3331
|
+
var _this22 = this;
|
|
3180
3332
|
var tempOrder = this.ensureTempOrder();
|
|
3181
|
-
tempOrder.payments = mapPaymentItemsToOrderPayments(payments)
|
|
3333
|
+
tempOrder.payments = mapPaymentItemsToOrderPayments((payments || []).map(function (payment) {
|
|
3334
|
+
return _this22.normalizePaymentSource(payment, {
|
|
3335
|
+
defaultPaid: false
|
|
3336
|
+
});
|
|
3337
|
+
}));
|
|
3182
3338
|
this.persistTempOrder();
|
|
3183
3339
|
return tempOrder.payments;
|
|
3184
3340
|
}
|
|
3185
3341
|
|
|
3186
|
-
/**
|
|
3342
|
+
/** 同步兼容入口:按调用当下的 device_id 或 LOCAL 生成支付编号。 */
|
|
3187
3343
|
}, {
|
|
3188
3344
|
key: "addOrderPayment",
|
|
3189
3345
|
value: function addOrderPayment(payment) {
|
|
3190
|
-
var
|
|
3346
|
+
var hasPaymentNumber = String(payment.payment_number || '').trim() !== '';
|
|
3347
|
+
return this.addOrderPaymentWithDevicePrefix(payment, hasPaymentNumber ? 'LOCAL' : this.getPaymentNumberDevicePrefixSync());
|
|
3348
|
+
}
|
|
3349
|
+
|
|
3350
|
+
/** 异步入口:创建支付项时读取最新 IoT 设备短号。 */
|
|
3351
|
+
}, {
|
|
3352
|
+
key: "addOrderPaymentAsync",
|
|
3353
|
+
value: (function () {
|
|
3354
|
+
var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(payment) {
|
|
3355
|
+
var hasPaymentNumber, devicePrefix;
|
|
3356
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context17) {
|
|
3357
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
3358
|
+
case 0:
|
|
3359
|
+
hasPaymentNumber = String(payment.payment_number || '').trim() !== '';
|
|
3360
|
+
if (!hasPaymentNumber) {
|
|
3361
|
+
_context17.next = 5;
|
|
3362
|
+
break;
|
|
3363
|
+
}
|
|
3364
|
+
_context17.t0 = 'LOCAL';
|
|
3365
|
+
_context17.next = 8;
|
|
3366
|
+
break;
|
|
3367
|
+
case 5:
|
|
3368
|
+
_context17.next = 7;
|
|
3369
|
+
return this.getPaymentNumberDevicePrefixAsync();
|
|
3370
|
+
case 7:
|
|
3371
|
+
_context17.t0 = _context17.sent;
|
|
3372
|
+
case 8:
|
|
3373
|
+
devicePrefix = _context17.t0;
|
|
3374
|
+
return _context17.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
|
|
3375
|
+
case 10:
|
|
3376
|
+
case "end":
|
|
3377
|
+
return _context17.stop();
|
|
3378
|
+
}
|
|
3379
|
+
}, _callee15, this);
|
|
3380
|
+
}));
|
|
3381
|
+
function addOrderPaymentAsync(_x14) {
|
|
3382
|
+
return _addOrderPaymentAsync.apply(this, arguments);
|
|
3383
|
+
}
|
|
3384
|
+
return addOrderPaymentAsync;
|
|
3385
|
+
}())
|
|
3386
|
+
}, {
|
|
3387
|
+
key: "addOrderPaymentWithDevicePrefix",
|
|
3388
|
+
value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
|
|
3389
|
+
var _this23 = this;
|
|
3191
3390
|
this.logInfo('addOrderPayment', {
|
|
3192
3391
|
payment: payment
|
|
3193
3392
|
});
|
|
@@ -3197,14 +3396,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3197
3396
|
type: orderPaymentType,
|
|
3198
3397
|
order_payment_type: orderPaymentType
|
|
3199
3398
|
}), {
|
|
3200
|
-
defaultPaid: true
|
|
3399
|
+
defaultPaid: true,
|
|
3400
|
+
devicePrefix: devicePrefix
|
|
3201
3401
|
})]);
|
|
3202
3402
|
tempOrder.payments = [].concat(_toConsumableArray(tempOrder.payments || []), _toConsumableArray(mapped));
|
|
3203
3403
|
this.persistTempOrder();
|
|
3204
3404
|
void this.recalculateSummary({
|
|
3205
3405
|
createIfMissing: true
|
|
3206
3406
|
}).catch(function (error) {
|
|
3207
|
-
|
|
3407
|
+
_this23.logError('recalculate summary after addOrderPayment failed', {
|
|
3208
3408
|
error: error instanceof Error ? error.message : String(error)
|
|
3209
3409
|
});
|
|
3210
3410
|
});
|
|
@@ -3212,49 +3412,80 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3212
3412
|
}
|
|
3213
3413
|
|
|
3214
3414
|
/**
|
|
3215
|
-
*
|
|
3216
|
-
*
|
|
3217
|
-
* 该方法服务 PaymentModal 的 void / 编辑场景;更新 metadata 时会做浅合并,
|
|
3218
|
-
* 避免覆盖 unique_payment_number、现金实付/找零等已有元数据。
|
|
3415
|
+
* 默认按支付唯一号精确更新;仅显式指定 legacy 时兼容历史支付标识。
|
|
3416
|
+
* metadata 与 transactions 会分别合并,避免覆盖支付会话号和已有交易记录。
|
|
3219
3417
|
*/
|
|
3220
3418
|
}, {
|
|
3221
3419
|
key: "updateOrderPayment",
|
|
3222
|
-
value: function
|
|
3223
|
-
var
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3420
|
+
value: (function () {
|
|
3421
|
+
var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(paymentIdentity, updates) {
|
|
3422
|
+
var options,
|
|
3423
|
+
tempOrder,
|
|
3424
|
+
identity,
|
|
3425
|
+
matchMode,
|
|
3426
|
+
matchedPayment,
|
|
3427
|
+
updatedPayment,
|
|
3428
|
+
summary,
|
|
3429
|
+
payments,
|
|
3430
|
+
_args18 = arguments;
|
|
3431
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context18) {
|
|
3432
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
3433
|
+
case 0:
|
|
3434
|
+
options = _args18.length > 2 && _args18[2] !== undefined ? _args18[2] : {};
|
|
3435
|
+
tempOrder = this.ensureTempOrder();
|
|
3436
|
+
identity = String(paymentIdentity);
|
|
3437
|
+
matchMode = options.matchBy === 'compat' || options.matchBy === 'legacy' ? 'compat' : 'payment_number';
|
|
3438
|
+
matchedPayment = resolveOrderPaymentIdentity(tempOrder.payments || [], identity, matchMode);
|
|
3439
|
+
if (matchedPayment) {
|
|
3440
|
+
_context18.next = 7;
|
|
3441
|
+
break;
|
|
3442
|
+
}
|
|
3443
|
+
throw new Error("\u672A\u627E\u5230\u652F\u4ED8\u9879: ".concat(identity));
|
|
3444
|
+
case 7:
|
|
3445
|
+
updatedPayment = null;
|
|
3446
|
+
tempOrder.payments = (tempOrder.payments || []).map(function (payment, index) {
|
|
3447
|
+
if (index !== matchedPayment.index) return payment;
|
|
3448
|
+
var nextPayment = mergeOrderPaymentRecord(payment, _objectSpread(_objectSpread({}, updates), {}, {
|
|
3449
|
+
updated_at: updates.updated_at || dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
3450
|
+
}));
|
|
3451
|
+
updatedPayment = nextPayment;
|
|
3452
|
+
return nextPayment;
|
|
3453
|
+
});
|
|
3454
|
+
this.persistTempOrder();
|
|
3455
|
+
_context18.next = 12;
|
|
3456
|
+
return this.recalculateSummary({
|
|
3457
|
+
createIfMissing: true
|
|
3458
|
+
});
|
|
3459
|
+
case 12:
|
|
3460
|
+
summary = _context18.sent;
|
|
3461
|
+
this.persistTempOrder();
|
|
3462
|
+
payments = tempOrder.payments;
|
|
3463
|
+
return _context18.abrupt("return", {
|
|
3464
|
+
updated: true,
|
|
3465
|
+
payment: payments[matchedPayment.index] || updatedPayment,
|
|
3466
|
+
payments: payments,
|
|
3467
|
+
summary: summary
|
|
3468
|
+
});
|
|
3469
|
+
case 16:
|
|
3470
|
+
case "end":
|
|
3471
|
+
return _context18.stop();
|
|
3472
|
+
}
|
|
3473
|
+
}, _callee16, this);
|
|
3474
|
+
}));
|
|
3475
|
+
function updateOrderPayment(_x15, _x16) {
|
|
3476
|
+
return _updateOrderPayment.apply(this, arguments);
|
|
3477
|
+
}
|
|
3478
|
+
return updateOrderPayment;
|
|
3479
|
+
}() /** 从当前订单支付项中移除指定支付项。 */)
|
|
3244
3480
|
}, {
|
|
3245
3481
|
key: "deleteOrderPayment",
|
|
3246
3482
|
value: function deleteOrderPayment(paymentIdentity) {
|
|
3247
3483
|
var tempOrder = this.ensureTempOrder();
|
|
3248
3484
|
var identity = String(paymentIdentity);
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
var customPaymentId = payment === null || payment === void 0 ? void 0 : payment.custom_payment_id;
|
|
3254
|
-
var uuid = payment === null || payment === void 0 ? void 0 : payment.uuid;
|
|
3255
|
-
return ![uniquePaymentNumber, orderPaymentId, customPaymentId, uuid].some(function (value) {
|
|
3256
|
-
return value !== undefined && String(value) === identity;
|
|
3257
|
-
});
|
|
3485
|
+
var matchedPayment = resolveOrderPaymentIdentity(tempOrder.payments || [], identity, 'compat');
|
|
3486
|
+
if (!matchedPayment) return tempOrder.payments;
|
|
3487
|
+
tempOrder.payments = (tempOrder.payments || []).filter(function (_, index) {
|
|
3488
|
+
return index !== matchedPayment.index;
|
|
3258
3489
|
});
|
|
3259
3490
|
this.persistTempOrder();
|
|
3260
3491
|
return tempOrder.payments;
|
|
@@ -3286,7 +3517,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3286
3517
|
}, {
|
|
3287
3518
|
key: "applyPaymentLifecycleChange",
|
|
3288
3519
|
value: function applyPaymentLifecycleChange(tempOrder, options) {
|
|
3289
|
-
var
|
|
3520
|
+
var _this24 = this;
|
|
3290
3521
|
this.updateTempOrderPaymentStatus(tempOrder);
|
|
3291
3522
|
if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
|
|
3292
3523
|
this.persistTempOrder();
|
|
@@ -3296,7 +3527,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3296
3527
|
void this.recalculateSummary({
|
|
3297
3528
|
createIfMissing: true
|
|
3298
3529
|
}).catch(function (error) {
|
|
3299
|
-
|
|
3530
|
+
_this24.logError("recalculate summary after ".concat(logContext, " failed"), {
|
|
3300
3531
|
error: error instanceof Error ? error.message : String(error)
|
|
3301
3532
|
});
|
|
3302
3533
|
});
|
|
@@ -3340,7 +3571,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3340
3571
|
}, {
|
|
3341
3572
|
key: "updateVoucherOrderPayments",
|
|
3342
3573
|
value: function updateVoucherOrderPayments(payments, options) {
|
|
3343
|
-
var
|
|
3574
|
+
var _this25 = this;
|
|
3344
3575
|
var tempOrder = this.ensureTempOrder();
|
|
3345
3576
|
var isOrderPaymentType = function isOrderPaymentType(value) {
|
|
3346
3577
|
return value === 'normal' || value === 'deposit';
|
|
@@ -3375,8 +3606,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3375
3606
|
});
|
|
3376
3607
|
};
|
|
3377
3608
|
var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
|
|
3378
|
-
return
|
|
3379
|
-
defaultPaid: false
|
|
3609
|
+
return _this25.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
|
|
3610
|
+
defaultPaid: false,
|
|
3611
|
+
devicePrefix: options === null || options === void 0 ? void 0 : options.devicePrefix
|
|
3380
3612
|
});
|
|
3381
3613
|
})).filter(function (payment) {
|
|
3382
3614
|
return isVoucherPaymentRecord(payment);
|
|
@@ -3402,14 +3634,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3402
3634
|
}).map(function (payment) {
|
|
3403
3635
|
return String(payment.order_payment_id);
|
|
3404
3636
|
}));
|
|
3405
|
-
var
|
|
3406
|
-
return
|
|
3637
|
+
var committedVoucherLifecycleKeys = new Set(committedVoucherPayments.map(function (payment) {
|
|
3638
|
+
return getVoucherPaymentLifecycleKey(payment);
|
|
3639
|
+
}).filter(function (key) {
|
|
3640
|
+
return key !== null;
|
|
3407
3641
|
}));
|
|
3408
3642
|
var replaceableVouchers = mappedVouchers.filter(function (payment) {
|
|
3409
3643
|
if (hasSyncedOrderPaymentRecord(payment) && committedVoucherPaymentIds.has(String(payment.order_payment_id))) {
|
|
3410
3644
|
return false;
|
|
3411
3645
|
}
|
|
3412
|
-
|
|
3646
|
+
var lifecycleKey = getVoucherPaymentLifecycleKey(payment);
|
|
3647
|
+
if (lifecycleKey && committedVoucherLifecycleKeys.has(lifecycleKey)) {
|
|
3413
3648
|
return false;
|
|
3414
3649
|
}
|
|
3415
3650
|
return true;
|
|
@@ -3424,54 +3659,93 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3424
3659
|
void this.recalculateSummary({
|
|
3425
3660
|
createIfMissing: true
|
|
3426
3661
|
}).catch(function (error) {
|
|
3427
|
-
|
|
3662
|
+
_this25.logError('recalculate summary after updateVoucherOrderPayments failed', {
|
|
3428
3663
|
error: error instanceof Error ? error.message : String(error)
|
|
3429
3664
|
});
|
|
3430
3665
|
});
|
|
3431
3666
|
return tempOrder.payments;
|
|
3432
3667
|
}
|
|
3433
3668
|
}, {
|
|
3434
|
-
key: "
|
|
3669
|
+
key: "updateVoucherOrderPaymentsAsync",
|
|
3435
3670
|
value: function () {
|
|
3436
|
-
var
|
|
3437
|
-
var
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
while (1) switch (_context16.prev = _context16.next) {
|
|
3671
|
+
var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(payments, options) {
|
|
3672
|
+
var needsPaymentNumber, devicePrefix;
|
|
3673
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context19) {
|
|
3674
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
3441
3675
|
case 0:
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3676
|
+
needsPaymentNumber = (payments || []).some(function (payment) {
|
|
3677
|
+
return String(payment.payment_number || '').trim() === '';
|
|
3678
|
+
});
|
|
3679
|
+
if (!needsPaymentNumber) {
|
|
3680
|
+
_context19.next = 7;
|
|
3445
3681
|
break;
|
|
3446
3682
|
}
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
case
|
|
3454
|
-
|
|
3683
|
+
_context19.next = 4;
|
|
3684
|
+
return this.getPaymentNumberDevicePrefixAsync();
|
|
3685
|
+
case 4:
|
|
3686
|
+
_context19.t0 = _context19.sent;
|
|
3687
|
+
_context19.next = 8;
|
|
3688
|
+
break;
|
|
3689
|
+
case 7:
|
|
3690
|
+
_context19.t0 = 'LOCAL';
|
|
3691
|
+
case 8:
|
|
3692
|
+
devicePrefix = _context19.t0;
|
|
3693
|
+
return _context19.abrupt("return", this.updateVoucherOrderPayments(payments, _objectSpread(_objectSpread({}, options), {}, {
|
|
3694
|
+
devicePrefix: devicePrefix
|
|
3695
|
+
})));
|
|
3696
|
+
case 10:
|
|
3697
|
+
case "end":
|
|
3698
|
+
return _context19.stop();
|
|
3699
|
+
}
|
|
3700
|
+
}, _callee17, this);
|
|
3701
|
+
}));
|
|
3702
|
+
function updateVoucherOrderPaymentsAsync(_x17, _x18) {
|
|
3703
|
+
return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
|
|
3704
|
+
}
|
|
3705
|
+
return updateVoucherOrderPaymentsAsync;
|
|
3706
|
+
}()
|
|
3707
|
+
}, {
|
|
3708
|
+
key: "shouldMergeProductToOrder",
|
|
3709
|
+
value: function () {
|
|
3710
|
+
var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(params) {
|
|
3711
|
+
var _this$orderHooks;
|
|
3712
|
+
var onBeforeMergeProductToOrder, result;
|
|
3713
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context20) {
|
|
3714
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
3715
|
+
case 0:
|
|
3716
|
+
onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
|
|
3717
|
+
if (onBeforeMergeProductToOrder) {
|
|
3718
|
+
_context20.next = 3;
|
|
3719
|
+
break;
|
|
3720
|
+
}
|
|
3721
|
+
return _context20.abrupt("return", true);
|
|
3722
|
+
case 3:
|
|
3723
|
+
_context20.next = 5;
|
|
3724
|
+
return onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
3725
|
+
defaultShouldMerge: true
|
|
3726
|
+
}));
|
|
3727
|
+
case 5:
|
|
3728
|
+
result = _context20.sent;
|
|
3455
3729
|
if (!(typeof result === 'boolean')) {
|
|
3456
|
-
|
|
3730
|
+
_context20.next = 8;
|
|
3457
3731
|
break;
|
|
3458
3732
|
}
|
|
3459
|
-
return
|
|
3733
|
+
return _context20.abrupt("return", result);
|
|
3460
3734
|
case 8:
|
|
3461
3735
|
if (!(result && _typeof(result) === 'object' && typeof result.shouldMerge === 'boolean')) {
|
|
3462
|
-
|
|
3736
|
+
_context20.next = 10;
|
|
3463
3737
|
break;
|
|
3464
3738
|
}
|
|
3465
|
-
return
|
|
3739
|
+
return _context20.abrupt("return", result.shouldMerge);
|
|
3466
3740
|
case 10:
|
|
3467
|
-
return
|
|
3741
|
+
return _context20.abrupt("return", true);
|
|
3468
3742
|
case 11:
|
|
3469
3743
|
case "end":
|
|
3470
|
-
return
|
|
3744
|
+
return _context20.stop();
|
|
3471
3745
|
}
|
|
3472
|
-
},
|
|
3746
|
+
}, _callee18, this);
|
|
3473
3747
|
}));
|
|
3474
|
-
function shouldMergeProductToOrder(
|
|
3748
|
+
function shouldMergeProductToOrder(_x19) {
|
|
3475
3749
|
return _shouldMergeProductToOrder.apply(this, arguments);
|
|
3476
3750
|
}
|
|
3477
3751
|
return shouldMergeProductToOrder;
|
|
@@ -3507,30 +3781,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3507
3781
|
}, {
|
|
3508
3782
|
key: "finalizeProductOrderMutation",
|
|
3509
3783
|
value: function () {
|
|
3510
|
-
var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3511
|
-
return _regeneratorRuntime().wrap(function
|
|
3512
|
-
while (1) switch (
|
|
3784
|
+
var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(tempOrder, options) {
|
|
3785
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context21) {
|
|
3786
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
3513
3787
|
case 0:
|
|
3514
3788
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
3515
3789
|
if (options !== null && options !== void 0 && options.skipEditDiscountConfigRefresh) {
|
|
3516
|
-
|
|
3790
|
+
_context21.next = 4;
|
|
3517
3791
|
break;
|
|
3518
3792
|
}
|
|
3519
|
-
|
|
3793
|
+
_context21.next = 4;
|
|
3520
3794
|
return this.ensureEditDiscountConfigForProductChange(tempOrder);
|
|
3521
3795
|
case 4:
|
|
3522
3796
|
if (options !== null && options !== void 0 && options.skipDiscountRecalculation) {
|
|
3523
|
-
|
|
3797
|
+
_context21.next = 7;
|
|
3524
3798
|
break;
|
|
3525
3799
|
}
|
|
3526
|
-
|
|
3800
|
+
_context21.next = 7;
|
|
3527
3801
|
return this.applyPromotion();
|
|
3528
3802
|
case 7:
|
|
3529
3803
|
if (!(options !== null && options !== void 0 && options.skipDiscountRecalculation)) {
|
|
3530
3804
|
this.applyDiscount();
|
|
3531
3805
|
}
|
|
3532
3806
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
3533
|
-
|
|
3807
|
+
_context21.next = 11;
|
|
3534
3808
|
return this.recalculateSummary({
|
|
3535
3809
|
createIfMissing: true
|
|
3536
3810
|
});
|
|
@@ -3538,11 +3812,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3538
3812
|
this.persistTempOrder();
|
|
3539
3813
|
case 12:
|
|
3540
3814
|
case "end":
|
|
3541
|
-
return
|
|
3815
|
+
return _context21.stop();
|
|
3542
3816
|
}
|
|
3543
|
-
},
|
|
3817
|
+
}, _callee19, this);
|
|
3544
3818
|
}));
|
|
3545
|
-
function finalizeProductOrderMutation(
|
|
3819
|
+
function finalizeProductOrderMutation(_x20, _x21) {
|
|
3546
3820
|
return _finalizeProductOrderMutation.apply(this, arguments);
|
|
3547
3821
|
}
|
|
3548
3822
|
return finalizeProductOrderMutation;
|
|
@@ -3557,13 +3831,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3557
3831
|
}, {
|
|
3558
3832
|
key: "appendProductLineToTempOrder",
|
|
3559
3833
|
value: (function () {
|
|
3560
|
-
var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3834
|
+
var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(tempOrder, product, booking) {
|
|
3561
3835
|
var _booking_uid,
|
|
3562
3836
|
_metadata,
|
|
3563
|
-
|
|
3837
|
+
_this26 = this;
|
|
3564
3838
|
var linked, productToAdd, incomingFingerprint, normalizedIncoming, incomingBookingUid, hasIncomingGoodPass, hasIncomingProductNote, hasIncomingBookingUid, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList;
|
|
3565
|
-
return _regeneratorRuntime().wrap(function
|
|
3566
|
-
while (1) switch (
|
|
3839
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context22) {
|
|
3840
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
3567
3841
|
case 0:
|
|
3568
3842
|
linked = booking ? this.createLinkedProductAndBooking({
|
|
3569
3843
|
product: product,
|
|
@@ -3585,9 +3859,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3585
3859
|
hasIncomingBookingUid = this.hasLinkedBookingUid(productToAdd) || this.hasLinkedBookingUid(normalizedIncoming);
|
|
3586
3860
|
shouldForceNewLine = !!booking || hasIncomingProductNote || hasIncomingBookingUid;
|
|
3587
3861
|
matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
3588
|
-
|
|
3589
|
-
if (
|
|
3862
|
+
var _item$metadata3;
|
|
3863
|
+
if (_this26.hasGoodPassDiscount(item)) return false;
|
|
3864
|
+
if (_this26.hasOrderProductLineNote(item)) return false;
|
|
3590
3865
|
if (item.order_detail_id !== undefined && item.order_detail_id !== null) return false;
|
|
3866
|
+
if ((_item$metadata3 = item.metadata) !== null && _item$metadata3 !== void 0 && _item$metadata3.is_edit_for_runtime) return false;
|
|
3591
3867
|
if (item.product_id !== productToAdd.product_id) return false;
|
|
3592
3868
|
if (item.product_variant_id !== productToAdd.product_variant_id) return false;
|
|
3593
3869
|
var existedFingerprint = buildProductLineFingerprint(getProductSkuOptions(item), item.product_bundle);
|
|
@@ -3596,10 +3872,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3596
3872
|
matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
|
|
3597
3873
|
existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
|
|
3598
3874
|
if (!matchedProduct) {
|
|
3599
|
-
|
|
3875
|
+
_context22.next = 20;
|
|
3600
3876
|
break;
|
|
3601
3877
|
}
|
|
3602
|
-
|
|
3878
|
+
_context22.next = 17;
|
|
3603
3879
|
return this.shouldMergeProductToOrder({
|
|
3604
3880
|
incomingProduct: productToAdd,
|
|
3605
3881
|
normalizedIncoming: normalizedIncoming,
|
|
@@ -3611,13 +3887,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3611
3887
|
booking: booking
|
|
3612
3888
|
});
|
|
3613
3889
|
case 17:
|
|
3614
|
-
|
|
3615
|
-
|
|
3890
|
+
_context22.t0 = _context22.sent;
|
|
3891
|
+
_context22.next = 21;
|
|
3616
3892
|
break;
|
|
3617
3893
|
case 20:
|
|
3618
|
-
|
|
3894
|
+
_context22.t0 = false;
|
|
3619
3895
|
case 21:
|
|
3620
|
-
shouldMerge =
|
|
3896
|
+
shouldMerge = _context22.t0;
|
|
3621
3897
|
if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
|
|
3622
3898
|
this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
|
|
3623
3899
|
if (linked) {
|
|
@@ -3671,11 +3947,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3671
3947
|
}
|
|
3672
3948
|
case 24:
|
|
3673
3949
|
case "end":
|
|
3674
|
-
return
|
|
3950
|
+
return _context22.stop();
|
|
3675
3951
|
}
|
|
3676
|
-
},
|
|
3952
|
+
}, _callee20, this);
|
|
3677
3953
|
}));
|
|
3678
|
-
function appendProductLineToTempOrder(
|
|
3954
|
+
function appendProductLineToTempOrder(_x22, _x23, _x24) {
|
|
3679
3955
|
return _appendProductLineToTempOrder.apply(this, arguments);
|
|
3680
3956
|
}
|
|
3681
3957
|
return appendProductLineToTempOrder;
|
|
@@ -3691,61 +3967,61 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3691
3967
|
}, {
|
|
3692
3968
|
key: "addProductToOrder",
|
|
3693
3969
|
value: (function () {
|
|
3694
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3970
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(product, booking) {
|
|
3695
3971
|
var tempOrder, _ref61, _productRecord$num, productRecord, splitCount, i, singleLine;
|
|
3696
|
-
return _regeneratorRuntime().wrap(function
|
|
3697
|
-
while (1) switch (
|
|
3972
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context23) {
|
|
3973
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
3698
3974
|
case 0:
|
|
3699
3975
|
tempOrder = this.ensureTempOrder();
|
|
3700
3976
|
if (!booking) {
|
|
3701
|
-
|
|
3977
|
+
_context23.next = 18;
|
|
3702
3978
|
break;
|
|
3703
3979
|
}
|
|
3704
3980
|
productRecord = product;
|
|
3705
3981
|
splitCount = getSafeProductNum((_ref61 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref61 !== void 0 ? _ref61 : 1);
|
|
3706
3982
|
if (!(splitCount > 1)) {
|
|
3707
|
-
|
|
3983
|
+
_context23.next = 18;
|
|
3708
3984
|
break;
|
|
3709
3985
|
}
|
|
3710
3986
|
i = 0;
|
|
3711
3987
|
case 6:
|
|
3712
3988
|
if (!(i < splitCount)) {
|
|
3713
|
-
|
|
3989
|
+
_context23.next = 15;
|
|
3714
3990
|
break;
|
|
3715
3991
|
}
|
|
3716
3992
|
singleLine = cloneDeep(productRecord);
|
|
3717
3993
|
singleLine.num = 1;
|
|
3718
3994
|
delete singleLine.product_quantity;
|
|
3719
|
-
|
|
3995
|
+
_context23.next = 12;
|
|
3720
3996
|
return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
|
|
3721
3997
|
case 12:
|
|
3722
3998
|
i += 1;
|
|
3723
|
-
|
|
3999
|
+
_context23.next = 6;
|
|
3724
4000
|
break;
|
|
3725
4001
|
case 15:
|
|
3726
|
-
|
|
4002
|
+
_context23.next = 17;
|
|
3727
4003
|
return this.finalizeProductOrderMutation(tempOrder);
|
|
3728
4004
|
case 17:
|
|
3729
|
-
return
|
|
4005
|
+
return _context23.abrupt("return", tempOrder.products);
|
|
3730
4006
|
case 18:
|
|
3731
|
-
|
|
4007
|
+
_context23.next = 20;
|
|
3732
4008
|
return this.appendProductLineToTempOrder(tempOrder, product, booking);
|
|
3733
4009
|
case 20:
|
|
3734
|
-
|
|
4010
|
+
_context23.next = 22;
|
|
3735
4011
|
return this.finalizeProductOrderMutation(tempOrder);
|
|
3736
4012
|
case 22:
|
|
3737
4013
|
this.logInfo('addProductToOrder success', {
|
|
3738
4014
|
product_id: product.product_id,
|
|
3739
4015
|
with_booking: !!booking
|
|
3740
4016
|
});
|
|
3741
|
-
return
|
|
4017
|
+
return _context23.abrupt("return", tempOrder.products);
|
|
3742
4018
|
case 24:
|
|
3743
4019
|
case "end":
|
|
3744
|
-
return
|
|
4020
|
+
return _context23.stop();
|
|
3745
4021
|
}
|
|
3746
|
-
},
|
|
4022
|
+
}, _callee21, this);
|
|
3747
4023
|
}));
|
|
3748
|
-
function addProductToOrder(
|
|
4024
|
+
function addProductToOrder(_x25, _x26) {
|
|
3749
4025
|
return _addProductToOrder.apply(this, arguments);
|
|
3750
4026
|
}
|
|
3751
4027
|
return addProductToOrder;
|
|
@@ -3763,93 +4039,93 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3763
4039
|
}, {
|
|
3764
4040
|
key: "addProductsToOrder",
|
|
3765
4041
|
value: (function () {
|
|
3766
|
-
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4042
|
+
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(items, options) {
|
|
3767
4043
|
var tempOrder, _iterator20, _step20, item, product, booking, _ref62, _productRecord$num2, productRecord, splitCount, i, singleLine;
|
|
3768
|
-
return _regeneratorRuntime().wrap(function
|
|
3769
|
-
while (1) switch (
|
|
4044
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context24) {
|
|
4045
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
3770
4046
|
case 0:
|
|
3771
4047
|
tempOrder = this.ensureTempOrder();
|
|
3772
4048
|
if (!(!Array.isArray(items) || items.length === 0)) {
|
|
3773
|
-
|
|
4049
|
+
_context24.next = 3;
|
|
3774
4050
|
break;
|
|
3775
4051
|
}
|
|
3776
|
-
return
|
|
4052
|
+
return _context24.abrupt("return", tempOrder.products);
|
|
3777
4053
|
case 3:
|
|
3778
4054
|
_iterator20 = _createForOfIteratorHelper(items || []);
|
|
3779
|
-
|
|
4055
|
+
_context24.prev = 4;
|
|
3780
4056
|
_iterator20.s();
|
|
3781
4057
|
case 6:
|
|
3782
4058
|
if ((_step20 = _iterator20.n()).done) {
|
|
3783
|
-
|
|
4059
|
+
_context24.next = 30;
|
|
3784
4060
|
break;
|
|
3785
4061
|
}
|
|
3786
4062
|
item = _step20.value;
|
|
3787
4063
|
product = item.product, booking = item.booking;
|
|
3788
4064
|
if (product) {
|
|
3789
|
-
|
|
4065
|
+
_context24.next = 11;
|
|
3790
4066
|
break;
|
|
3791
4067
|
}
|
|
3792
|
-
return
|
|
4068
|
+
return _context24.abrupt("continue", 28);
|
|
3793
4069
|
case 11:
|
|
3794
4070
|
if (!booking) {
|
|
3795
|
-
|
|
4071
|
+
_context24.next = 26;
|
|
3796
4072
|
break;
|
|
3797
4073
|
}
|
|
3798
4074
|
productRecord = product;
|
|
3799
4075
|
splitCount = getSafeProductNum((_ref62 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref62 !== void 0 ? _ref62 : 1);
|
|
3800
4076
|
if (!(splitCount > 1)) {
|
|
3801
|
-
|
|
4077
|
+
_context24.next = 26;
|
|
3802
4078
|
break;
|
|
3803
4079
|
}
|
|
3804
4080
|
i = 0;
|
|
3805
4081
|
case 16:
|
|
3806
4082
|
if (!(i < splitCount)) {
|
|
3807
|
-
|
|
4083
|
+
_context24.next = 25;
|
|
3808
4084
|
break;
|
|
3809
4085
|
}
|
|
3810
4086
|
singleLine = cloneDeep(productRecord);
|
|
3811
4087
|
singleLine.num = 1;
|
|
3812
4088
|
delete singleLine.product_quantity;
|
|
3813
|
-
|
|
4089
|
+
_context24.next = 22;
|
|
3814
4090
|
return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
|
|
3815
4091
|
case 22:
|
|
3816
4092
|
i += 1;
|
|
3817
|
-
|
|
4093
|
+
_context24.next = 16;
|
|
3818
4094
|
break;
|
|
3819
4095
|
case 25:
|
|
3820
|
-
return
|
|
4096
|
+
return _context24.abrupt("continue", 28);
|
|
3821
4097
|
case 26:
|
|
3822
|
-
|
|
4098
|
+
_context24.next = 28;
|
|
3823
4099
|
return this.appendProductLineToTempOrder(tempOrder, product, booking);
|
|
3824
4100
|
case 28:
|
|
3825
|
-
|
|
4101
|
+
_context24.next = 6;
|
|
3826
4102
|
break;
|
|
3827
4103
|
case 30:
|
|
3828
|
-
|
|
4104
|
+
_context24.next = 35;
|
|
3829
4105
|
break;
|
|
3830
4106
|
case 32:
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
_iterator20.e(
|
|
4107
|
+
_context24.prev = 32;
|
|
4108
|
+
_context24.t0 = _context24["catch"](4);
|
|
4109
|
+
_iterator20.e(_context24.t0);
|
|
3834
4110
|
case 35:
|
|
3835
|
-
|
|
4111
|
+
_context24.prev = 35;
|
|
3836
4112
|
_iterator20.f();
|
|
3837
|
-
return
|
|
4113
|
+
return _context24.finish(35);
|
|
3838
4114
|
case 38:
|
|
3839
|
-
|
|
4115
|
+
_context24.next = 40;
|
|
3840
4116
|
return this.finalizeProductOrderMutation(tempOrder, options);
|
|
3841
4117
|
case 40:
|
|
3842
4118
|
this.logInfo('addProductsToOrder success', {
|
|
3843
4119
|
itemsCount: items.length
|
|
3844
4120
|
});
|
|
3845
|
-
return
|
|
4121
|
+
return _context24.abrupt("return", tempOrder.products);
|
|
3846
4122
|
case 42:
|
|
3847
4123
|
case "end":
|
|
3848
|
-
return
|
|
4124
|
+
return _context24.stop();
|
|
3849
4125
|
}
|
|
3850
|
-
},
|
|
4126
|
+
}, _callee22, this, [[4, 32, 35, 38]]);
|
|
3851
4127
|
}));
|
|
3852
|
-
function addProductsToOrder(
|
|
4128
|
+
function addProductsToOrder(_x27, _x28) {
|
|
3853
4129
|
return _addProductsToOrder.apply(this, arguments);
|
|
3854
4130
|
}
|
|
3855
4131
|
return addProductsToOrder;
|
|
@@ -3883,19 +4159,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3883
4159
|
}, {
|
|
3884
4160
|
key: "preservePersistedBundlePriceFields",
|
|
3885
4161
|
value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
|
|
3886
|
-
var
|
|
4162
|
+
var _this27 = this;
|
|
3887
4163
|
if (!Array.isArray(nextBundles)) return nextBundles;
|
|
3888
4164
|
if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
|
|
3889
4165
|
var previousByIdentity = new Map();
|
|
3890
4166
|
previousBundles.forEach(function (bundle) {
|
|
3891
|
-
var identity =
|
|
4167
|
+
var identity = _this27.getBundleRuntimeIdentity(bundle);
|
|
3892
4168
|
if (identity) previousByIdentity.set(identity, bundle);
|
|
3893
4169
|
});
|
|
3894
4170
|
return nextBundles.map(function (bundle, index) {
|
|
3895
4171
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
3896
|
-
var previous = previousByIdentity.get(
|
|
4172
|
+
var previous = previousByIdentity.get(_this27.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
|
|
3897
4173
|
if (!previous || _typeof(previous) !== 'object') return bundle;
|
|
3898
|
-
return _objectSpread(_objectSpread({}, bundle),
|
|
4174
|
+
return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
|
|
4175
|
+
cover: previous.cover
|
|
4176
|
+
} : {}), {}, {
|
|
3899
4177
|
price: previous.price,
|
|
3900
4178
|
custom_price: previous.custom_price,
|
|
3901
4179
|
bundle_payment_price: previous.bundle_payment_price,
|
|
@@ -3908,7 +4186,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3908
4186
|
}, {
|
|
3909
4187
|
key: "applyOrderProductUpdateToTempOrder",
|
|
3910
4188
|
value: function applyOrderProductUpdateToTempOrder(tempOrder, params) {
|
|
3911
|
-
var _targetProduct$metada2, _product_sku, _metadata2, _metadata3, _metadata4, _metadata5, _metadata6, _metadata7, _nextProduct$metadata, _targetProduct$
|
|
4189
|
+
var _targetProduct$metada2, _product_sku, _metadata2, _metadata3, _metadata4, _metadata5, _metadata6, _metadata7, _metadata8, _metadata9, _metadata10, _nextProduct$metadata, _targetProduct$metada15, _tempOrder$products$p, _tempOrder$products$p2;
|
|
3912
4190
|
var product_id = params.product_id,
|
|
3913
4191
|
product_variant_id = params.product_variant_id,
|
|
3914
4192
|
updates = params.updates,
|
|
@@ -3936,8 +4214,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3936
4214
|
if (unique_identification_number !== undefined) {
|
|
3937
4215
|
var targetUid = String(unique_identification_number);
|
|
3938
4216
|
productIndex = tempOrder.products.findIndex(function (item) {
|
|
3939
|
-
var _item$
|
|
3940
|
-
return String(((_item$
|
|
4217
|
+
var _item$metadata4;
|
|
4218
|
+
return String(((_item$metadata4 = item.metadata) === null || _item$metadata4 === void 0 ? void 0 : _item$metadata4.unique_identification_number) || item.unique_identification_number || '') === targetUid;
|
|
3941
4219
|
});
|
|
3942
4220
|
}
|
|
3943
4221
|
if (productIndex === -1) {
|
|
@@ -3968,9 +4246,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3968
4246
|
// 如果 caller 走推荐路径(updates.metadata.* 显式指定主价),保留 metadata 由 normalize 认它。
|
|
3969
4247
|
var callerUpdatesTopPrice = Object.prototype.hasOwnProperty.call(updates || {}, 'selling_price') || Object.prototype.hasOwnProperty.call(updates || {}, 'original_price');
|
|
3970
4248
|
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;
|
|
4249
|
+
var callerUpdatesSourcePrice = (updates === null || updates === void 0 || (_metadata5 = updates.metadata) === null || _metadata5 === void 0 ? void 0 : _metadata5.source_product_price) !== undefined;
|
|
4250
|
+
var callerUpdatesMainSellingPrice = (updates === null || updates === void 0 || (_metadata6 = updates.metadata) === null || _metadata6 === void 0 ? void 0 : _metadata6.main_product_selling_price) !== undefined;
|
|
4251
|
+
var callerUpdatesMainOriginalPrice = (updates === null || updates === void 0 || (_metadata7 = updates.metadata) === null || _metadata7 === void 0 ? void 0 : _metadata7.main_product_original_price) !== undefined;
|
|
4252
|
+
var previousLineFingerprint = buildProductLineFingerprint(getProductSkuOptions(targetProduct), targetProduct.product_bundle);
|
|
4253
|
+
var nextLineFingerprint = buildProductLineFingerprint(getProductSkuOptions(nextProduct), nextProduct.product_bundle);
|
|
4254
|
+
var callerChangesVariant = Number(product_variant_id || 0) !== Number(targetProduct.product_variant_id || 0);
|
|
4255
|
+
var callerChangesLineConfiguration = callerChangesVariant || previousLineFingerprint !== nextLineFingerprint;
|
|
3971
4256
|
var isPersistedOrderLine = targetProduct.order_detail_id !== undefined && targetProduct.order_detail_id !== null;
|
|
3972
4257
|
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);
|
|
3973
|
-
var callerUpdatesManualPrice = (updates === null || updates === void 0 || (
|
|
4258
|
+
var callerUpdatesManualPrice = (updates === null || updates === void 0 || (_metadata8 = updates.metadata) === null || _metadata8 === void 0 ? void 0 : _metadata8.price_override) !== undefined || (updates === null || updates === void 0 || (_metadata9 = updates.metadata) === null || _metadata9 === void 0 ? void 0 : _metadata9.is_manual_discount) !== undefined || (updates === null || updates === void 0 || (_metadata10 = updates.metadata) === null || _metadata10 === void 0 ? void 0 : _metadata10.product_discount_reason) !== undefined || callerChangesDiscountList;
|
|
3974
4259
|
var callerAllowsBookingReprice = function () {
|
|
3975
4260
|
if (params.allow_booking_reprice !== true || !booking || !callerUpdatesTopPrice || !callerUpdatesMainMeta) {
|
|
3976
4261
|
return false;
|
|
@@ -3983,7 +4268,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3983
4268
|
};
|
|
3984
4269
|
return hasChangedPrice(updates.selling_price, targetProduct.selling_price) || hasChangedPrice(updates.original_price, targetProduct.original_price);
|
|
3985
4270
|
}();
|
|
3986
|
-
if (isPersistedOrderLine && !callerUpdatesManualPrice && !callerAllowsBookingReprice) {
|
|
4271
|
+
if (isPersistedOrderLine && !callerChangesLineConfiguration && !callerUpdatesManualPrice && !callerAllowsBookingReprice) {
|
|
3987
4272
|
var _targetProduct$metada3, _targetProduct$metada4, _targetProduct$metada5, _targetProduct$metada6, _targetProduct$metada7;
|
|
3988
4273
|
nextProduct.selling_price = targetProduct.selling_price;
|
|
3989
4274
|
nextProduct.original_price = targetProduct.original_price;
|
|
@@ -3995,19 +4280,60 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3995
4280
|
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
|
|
3996
4281
|
});
|
|
3997
4282
|
nextProduct.product_bundle = this.preservePersistedBundlePriceFields(targetProduct.product_bundle, nextProduct.product_bundle);
|
|
3998
|
-
} else if (
|
|
4283
|
+
} else if (callerChangesLineConfiguration && callerUpdatesSourcePrice && (!callerUpdatesMainSellingPrice || !callerUpdatesMainOriginalPrice)) {
|
|
4284
|
+
var _targetProduct$metada8, _targetProduct$metada9;
|
|
4285
|
+
// 新配置只传了 source 时,不能把未传的 main_product_* 从旧行继承下来。
|
|
4286
|
+
// 以新 source + 新 option 重建券前价;券后价未显式提供时保留旧主商品折扣额。
|
|
4287
|
+
var previousMainOriginal = new Decimal(Number((_targetProduct$metada8 = targetProduct.metadata) === null || _targetProduct$metada8 === void 0 ? void 0 : _targetProduct$metada8.main_product_original_price) || 0);
|
|
4288
|
+
var previousMainSelling = new Decimal(Number((_targetProduct$metada9 = targetProduct.metadata) === null || _targetProduct$metada9 === void 0 ? void 0 : _targetProduct$metada9.main_product_selling_price) || previousMainOriginal.toNumber());
|
|
4289
|
+
var preservedDiscount = previousMainOriginal.minus(previousMainSelling);
|
|
4290
|
+
var nextMainOriginal = new Decimal(Number(updates.metadata.source_product_price) || 0).plus(sumOptionUnitPrice(getProductSkuOptions(nextProduct)));
|
|
4291
|
+
nextProduct.metadata = _objectSpread(_objectSpread({}, nextProduct.metadata || {}), {}, {
|
|
4292
|
+
source_product_price: String(updates.metadata.source_product_price),
|
|
4293
|
+
main_product_original_price: callerUpdatesMainOriginalPrice ? String(updates.metadata.main_product_original_price) : nextMainOriginal.toDecimalPlaces(2).toFixed(2),
|
|
4294
|
+
main_product_selling_price: callerUpdatesMainSellingPrice ? String(updates.metadata.main_product_selling_price) : nextMainOriginal.minus(preservedDiscount).toDecimalPlaces(2).toFixed(2),
|
|
4295
|
+
price_schema_version: 2
|
|
4296
|
+
});
|
|
4297
|
+
} else if (callerChangesVariant && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
4298
|
+
// variant 已变化但 caller 没有显式报价时,旧 v2 metadata 不能继续充当权威价格源。
|
|
4299
|
+
// 清理后由 normalize 优先读取 metadata.origin.variant 中新 variant 的目录价;
|
|
4300
|
+
// 顶层 original/selling 的旧差额仍会作为 legacy discount 迁移到新价格。
|
|
3999
4301
|
var existedMeta = nextProduct.metadata || {};
|
|
4000
4302
|
nextProduct.metadata = _objectSpread({}, existedMeta);
|
|
4001
4303
|
delete nextProduct.metadata.source_product_price;
|
|
4002
4304
|
delete nextProduct.metadata.main_product_selling_price;
|
|
4003
4305
|
delete nextProduct.metadata.main_product_original_price;
|
|
4004
4306
|
delete nextProduct.metadata.price_schema_version;
|
|
4307
|
+
} else if (callerChangesLineConfiguration && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
4308
|
+
var _ref68, _targetProduct$metada10, _targetProduct$metada11, _ref69, _targetProduct$metada12, _targetProduct$metada13, _targetProduct$metada14;
|
|
4309
|
+
// 仅 option / bundle 变化时,保留历史 source 和主商品折扣金额,
|
|
4310
|
+
// 但必须让 original 与 selling 一起随新的 option 金额移动。
|
|
4311
|
+
var previousOptionSum = sumOptionUnitPrice(getProductSkuOptions(targetProduct));
|
|
4312
|
+
var nextOptionSum = sumOptionUnitPrice(getProductSkuOptions(nextProduct));
|
|
4313
|
+
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);
|
|
4314
|
+
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);
|
|
4315
|
+
var _preservedDiscount = _previousMainOriginal.minus(_previousMainSelling);
|
|
4316
|
+
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);
|
|
4317
|
+
var _nextMainOriginal = previousSource.plus(nextOptionSum);
|
|
4318
|
+
nextProduct.metadata = _objectSpread(_objectSpread({}, nextProduct.metadata || {}), {}, {
|
|
4319
|
+
source_product_price: previousSource.toDecimalPlaces(2).toFixed(2),
|
|
4320
|
+
main_product_original_price: _nextMainOriginal.toDecimalPlaces(2).toFixed(2),
|
|
4321
|
+
main_product_selling_price: _nextMainOriginal.minus(_preservedDiscount).toDecimalPlaces(2).toFixed(2),
|
|
4322
|
+
price_schema_version: 2
|
|
4323
|
+
});
|
|
4324
|
+
} else if (callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
4325
|
+
var _existedMeta = nextProduct.metadata || {};
|
|
4326
|
+
nextProduct.metadata = _objectSpread({}, _existedMeta);
|
|
4327
|
+
delete nextProduct.metadata.source_product_price;
|
|
4328
|
+
delete nextProduct.metadata.main_product_selling_price;
|
|
4329
|
+
delete nextProduct.metadata.main_product_original_price;
|
|
4330
|
+
delete nextProduct.metadata.price_schema_version;
|
|
4005
4331
|
}
|
|
4006
4332
|
// normalizeOrderProduct 幂等:v2 metadata 存在 → 保留 main_product_* 折扣重算 composite;
|
|
4007
4333
|
// 否则 → 把顶层 selling_price 视作 source,派生 main_product_* 并写 price_schema_version: 2。
|
|
4008
4334
|
var normalizedProduct = mergeOrderProductDisplayFields(nextProduct, normalizeOrderProduct(nextProduct));
|
|
4009
4335
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
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$
|
|
4336
|
+
var preservedBookingUid = nextProduct.booking_uid || ((_nextProduct$metadata = nextProduct.metadata) === null || _nextProduct$metadata === void 0 ? void 0 : _nextProduct$metadata.booking_uid) || targetProduct.booking_uid || ((_targetProduct$metada15 = targetProduct.metadata) === null || _targetProduct$metada15 === void 0 ? void 0 : _targetProduct$metada15.booking_uid);
|
|
4011
4337
|
if (!booking && preservedBookingUid) {
|
|
4012
4338
|
normalizedProduct.booking_uid = preservedBookingUid;
|
|
4013
4339
|
normalizedProduct.metadata = _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
|
|
@@ -4015,8 +4341,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4015
4341
|
});
|
|
4016
4342
|
}
|
|
4017
4343
|
if (booking) {
|
|
4018
|
-
var _normalizedProduct$me, _targetProduct$
|
|
4019
|
-
var productUid = String(((_normalizedProduct$me = normalizedProduct.metadata) === null || _normalizedProduct$me === void 0 ? void 0 : _normalizedProduct$me.unique_identification_number) || ((_targetProduct$
|
|
4344
|
+
var _normalizedProduct$me, _targetProduct$metada16;
|
|
4345
|
+
var productUid = String(((_normalizedProduct$me = normalizedProduct.metadata) === null || _normalizedProduct$me === void 0 ? void 0 : _normalizedProduct$me.unique_identification_number) || ((_targetProduct$metada16 = targetProduct.metadata) === null || _targetProduct$metada16 === void 0 ? void 0 : _targetProduct$metada16.unique_identification_number) || unique_identification_number || createUuidV4());
|
|
4020
4346
|
normalizedProduct.metadata = _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
|
|
4021
4347
|
unique_identification_number: productUid
|
|
4022
4348
|
});
|
|
@@ -4039,23 +4365,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4039
4365
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
4040
4366
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
4041
4367
|
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);
|
|
4368
|
+
return (_tempOrder$products$p2 = tempOrder.products[productIndex].metadata) === null || _tempOrder$products$p2 === void 0 ? void 0 : _tempOrder$products$p2.unique_identification_number;
|
|
4042
4369
|
}
|
|
4043
4370
|
}, {
|
|
4044
4371
|
key: "updateOrderProduct",
|
|
4045
4372
|
value: function () {
|
|
4046
|
-
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4047
|
-
var tempOrder;
|
|
4048
|
-
return _regeneratorRuntime().wrap(function
|
|
4049
|
-
while (1) switch (
|
|
4373
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
|
|
4374
|
+
var tempOrder, updatedProductUid;
|
|
4375
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context25) {
|
|
4376
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
4050
4377
|
case 0:
|
|
4051
4378
|
tempOrder = this.ensureTempOrder();
|
|
4052
|
-
this.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
4053
|
-
|
|
4379
|
+
updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
4380
|
+
_context25.next = 4;
|
|
4054
4381
|
return this.applyPromotion();
|
|
4055
4382
|
case 4:
|
|
4056
|
-
this.applyDiscount(
|
|
4383
|
+
this.applyDiscount({
|
|
4384
|
+
reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
|
|
4385
|
+
});
|
|
4057
4386
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4058
|
-
|
|
4387
|
+
_context25.next = 8;
|
|
4059
4388
|
return this.recalculateSummary({
|
|
4060
4389
|
createIfMissing: true
|
|
4061
4390
|
});
|
|
@@ -4064,14 +4393,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4064
4393
|
this.logInfo('updateOrderProduct success', {
|
|
4065
4394
|
params: params
|
|
4066
4395
|
});
|
|
4067
|
-
return
|
|
4396
|
+
return _context25.abrupt("return", tempOrder.products);
|
|
4068
4397
|
case 11:
|
|
4069
4398
|
case "end":
|
|
4070
|
-
return
|
|
4399
|
+
return _context25.stop();
|
|
4071
4400
|
}
|
|
4072
|
-
},
|
|
4401
|
+
}, _callee23, this);
|
|
4073
4402
|
}));
|
|
4074
|
-
function updateOrderProduct(
|
|
4403
|
+
function updateOrderProduct(_x29) {
|
|
4075
4404
|
return _updateOrderProduct.apply(this, arguments);
|
|
4076
4405
|
}
|
|
4077
4406
|
return updateOrderProduct;
|
|
@@ -4079,36 +4408,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4079
4408
|
}, {
|
|
4080
4409
|
key: "updateOrderProducts",
|
|
4081
4410
|
value: function () {
|
|
4082
|
-
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4083
|
-
var
|
|
4084
|
-
var tempOrder;
|
|
4085
|
-
return _regeneratorRuntime().wrap(function
|
|
4086
|
-
while (1) switch (
|
|
4411
|
+
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(paramsList) {
|
|
4412
|
+
var _this28 = this;
|
|
4413
|
+
var tempOrder, reapplyBookingDiscountProductUids;
|
|
4414
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context26) {
|
|
4415
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
4087
4416
|
case 0:
|
|
4088
4417
|
tempOrder = this.ensureTempOrder();
|
|
4089
4418
|
if (paramsList.length) {
|
|
4090
|
-
|
|
4419
|
+
_context26.next = 3;
|
|
4091
4420
|
break;
|
|
4092
4421
|
}
|
|
4093
|
-
return
|
|
4422
|
+
return _context26.abrupt("return", tempOrder.products);
|
|
4094
4423
|
case 3:
|
|
4095
|
-
paramsList.
|
|
4096
|
-
|
|
4424
|
+
reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
|
|
4425
|
+
var updatedProductUid = _this28.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
4426
|
+
// 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
|
|
4427
|
+
if (params.allow_booking_discount_reapply && updatedProductUid) {
|
|
4428
|
+
acc.push(String(updatedProductUid));
|
|
4429
|
+
}
|
|
4430
|
+
return acc;
|
|
4431
|
+
}, []);
|
|
4432
|
+
_context26.next = 6;
|
|
4433
|
+
return this.finalizeAfterProductsMutation(tempOrder, {
|
|
4434
|
+
reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
|
|
4097
4435
|
});
|
|
4098
|
-
_context22.next = 6;
|
|
4099
|
-
return this.finalizeAfterProductsMutation(tempOrder);
|
|
4100
4436
|
case 6:
|
|
4101
4437
|
this.logInfo('updateOrderProduct success', {
|
|
4102
4438
|
paramsList: paramsList
|
|
4103
4439
|
});
|
|
4104
|
-
return
|
|
4440
|
+
return _context26.abrupt("return", tempOrder.products);
|
|
4105
4441
|
case 8:
|
|
4106
4442
|
case "end":
|
|
4107
|
-
return
|
|
4443
|
+
return _context26.stop();
|
|
4108
4444
|
}
|
|
4109
|
-
},
|
|
4445
|
+
}, _callee24, this);
|
|
4110
4446
|
}));
|
|
4111
|
-
function updateOrderProducts(
|
|
4447
|
+
function updateOrderProducts(_x30) {
|
|
4112
4448
|
return _updateOrderProducts.apply(this, arguments);
|
|
4113
4449
|
}
|
|
4114
4450
|
return updateOrderProducts;
|
|
@@ -4116,11 +4452,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4116
4452
|
}, {
|
|
4117
4453
|
key: "updateOrderProductQuantity",
|
|
4118
4454
|
value: function () {
|
|
4119
|
-
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4120
|
-
var _targetProduct$
|
|
4455
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
|
|
4456
|
+
var _targetProduct$metada17;
|
|
4121
4457
|
var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct;
|
|
4122
|
-
return _regeneratorRuntime().wrap(function
|
|
4123
|
-
while (1) switch (
|
|
4458
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context27) {
|
|
4459
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
4124
4460
|
case 0:
|
|
4125
4461
|
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;
|
|
4126
4462
|
tempOrder = this.ensureTempOrder();
|
|
@@ -4141,15 +4477,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4141
4477
|
if (unique_identification_number !== undefined) {
|
|
4142
4478
|
targetUid = String(unique_identification_number);
|
|
4143
4479
|
productIndex = tempOrder.products.findIndex(function (item) {
|
|
4144
|
-
var _item$
|
|
4145
|
-
return String(((_item$
|
|
4480
|
+
var _item$metadata5;
|
|
4481
|
+
return String(((_item$metadata5 = item.metadata) === null || _item$metadata5 === void 0 ? void 0 : _item$metadata5.unique_identification_number) || item.unique_identification_number || '') === targetUid;
|
|
4146
4482
|
});
|
|
4147
4483
|
}
|
|
4148
4484
|
if (productIndex === -1) {
|
|
4149
4485
|
productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
|
|
4150
4486
|
}
|
|
4151
4487
|
if (!(productIndex === -1)) {
|
|
4152
|
-
|
|
4488
|
+
_context27.next = 12;
|
|
4153
4489
|
break;
|
|
4154
4490
|
}
|
|
4155
4491
|
throw new Error('[Order] 目标商品不存在,无法更新数量');
|
|
@@ -4158,17 +4494,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4158
4494
|
normalizedProduct = normalizeOrderProduct(_objectSpread(_objectSpread({}, targetProduct), {}, {
|
|
4159
4495
|
num: getSafeProductNum(num),
|
|
4160
4496
|
metadata: _objectSpread(_objectSpread({}, targetProduct.metadata || {}), {}, {
|
|
4161
|
-
unique_identification_number: ((_targetProduct$
|
|
4497
|
+
unique_identification_number: ((_targetProduct$metada17 = targetProduct.metadata) === null || _targetProduct$metada17 === void 0 ? void 0 : _targetProduct$metada17.unique_identification_number) || unique_identification_number
|
|
4162
4498
|
})
|
|
4163
4499
|
}));
|
|
4164
4500
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
4165
4501
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
4166
|
-
|
|
4502
|
+
_context27.next = 18;
|
|
4167
4503
|
return this.applyPromotion();
|
|
4168
4504
|
case 18:
|
|
4169
4505
|
this.applyDiscount();
|
|
4170
4506
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4171
|
-
|
|
4507
|
+
_context27.next = 22;
|
|
4172
4508
|
return this.recalculateSummary({
|
|
4173
4509
|
createIfMissing: true
|
|
4174
4510
|
});
|
|
@@ -4177,14 +4513,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4177
4513
|
this.logInfo('updateOrderProductQuantity success', {
|
|
4178
4514
|
params: params
|
|
4179
4515
|
});
|
|
4180
|
-
return
|
|
4516
|
+
return _context27.abrupt("return", tempOrder.products);
|
|
4181
4517
|
case 25:
|
|
4182
4518
|
case "end":
|
|
4183
|
-
return
|
|
4519
|
+
return _context27.stop();
|
|
4184
4520
|
}
|
|
4185
|
-
},
|
|
4521
|
+
}, _callee25, this);
|
|
4186
4522
|
}));
|
|
4187
|
-
function updateOrderProductQuantity(
|
|
4523
|
+
function updateOrderProductQuantity(_x31) {
|
|
4188
4524
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
4189
4525
|
}
|
|
4190
4526
|
return updateOrderProductQuantity;
|
|
@@ -4225,17 +4561,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4225
4561
|
}, {
|
|
4226
4562
|
key: "finalizeAfterProductsMutation",
|
|
4227
4563
|
value: (function () {
|
|
4228
|
-
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4229
|
-
return _regeneratorRuntime().wrap(function
|
|
4230
|
-
while (1) switch (
|
|
4564
|
+
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(tempOrder, options) {
|
|
4565
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context28) {
|
|
4566
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
4231
4567
|
case 0:
|
|
4232
4568
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
4233
|
-
|
|
4569
|
+
_context28.next = 3;
|
|
4234
4570
|
return this.applyPromotion();
|
|
4235
4571
|
case 3:
|
|
4236
|
-
this.applyDiscount(
|
|
4572
|
+
this.applyDiscount({
|
|
4573
|
+
reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids
|
|
4574
|
+
});
|
|
4237
4575
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4238
|
-
|
|
4576
|
+
_context28.next = 7;
|
|
4239
4577
|
return this.recalculateSummary({
|
|
4240
4578
|
createIfMissing: true
|
|
4241
4579
|
});
|
|
@@ -4243,11 +4581,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4243
4581
|
this.persistTempOrder();
|
|
4244
4582
|
case 8:
|
|
4245
4583
|
case "end":
|
|
4246
|
-
return
|
|
4584
|
+
return _context28.stop();
|
|
4247
4585
|
}
|
|
4248
|
-
},
|
|
4586
|
+
}, _callee26, this);
|
|
4249
4587
|
}));
|
|
4250
|
-
function finalizeAfterProductsMutation(
|
|
4588
|
+
function finalizeAfterProductsMutation(_x32, _x33) {
|
|
4251
4589
|
return _finalizeAfterProductsMutation.apply(this, arguments);
|
|
4252
4590
|
}
|
|
4253
4591
|
return finalizeAfterProductsMutation;
|
|
@@ -4262,18 +4600,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4262
4600
|
}, {
|
|
4263
4601
|
key: "removeProductsFromOrder",
|
|
4264
4602
|
value: (function () {
|
|
4265
|
-
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4266
|
-
var
|
|
4603
|
+
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(identities) {
|
|
4604
|
+
var _this29 = this;
|
|
4267
4605
|
var tempOrder, productsBeforeRemove, bookingsBeforeRemove, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3;
|
|
4268
|
-
return _regeneratorRuntime().wrap(function
|
|
4269
|
-
while (1) switch (
|
|
4606
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context30) {
|
|
4607
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
4270
4608
|
case 0:
|
|
4271
4609
|
tempOrder = this.ensureTempOrder();
|
|
4272
4610
|
if (identities.length) {
|
|
4273
|
-
|
|
4611
|
+
_context30.next = 3;
|
|
4274
4612
|
break;
|
|
4275
4613
|
}
|
|
4276
|
-
return
|
|
4614
|
+
return _context30.abrupt("return", tempOrder.products);
|
|
4277
4615
|
case 3:
|
|
4278
4616
|
productsBeforeRemove = tempOrder.products || [];
|
|
4279
4617
|
bookingsBeforeRemove = tempOrder.bookings || [];
|
|
@@ -4296,29 +4634,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4296
4634
|
}
|
|
4297
4635
|
linkedBookingUidsToRemove = new Set();
|
|
4298
4636
|
_iterator21 = _createForOfIteratorHelper(matchedProducts);
|
|
4299
|
-
|
|
4637
|
+
_context30.prev = 11;
|
|
4300
4638
|
_loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
|
|
4301
|
-
var
|
|
4639
|
+
var _metadata11, _metadata12, _metadata13, _metadata14;
|
|
4302
4640
|
var product, productUid, productBookingUid, isAddTimeProduct;
|
|
4303
|
-
return _regeneratorRuntime().wrap(function _loop3$(
|
|
4304
|
-
while (1) switch (
|
|
4641
|
+
return _regeneratorRuntime().wrap(function _loop3$(_context29) {
|
|
4642
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
4305
4643
|
case 0:
|
|
4306
4644
|
product = _step21.value;
|
|
4307
|
-
productUid = (product === null || product === void 0 || (
|
|
4308
|
-
productBookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (
|
|
4309
|
-
isAddTimeProduct = (product === null || product === void 0 || (
|
|
4645
|
+
productUid = (product === null || product === void 0 || (_metadata11 = product.metadata) === null || _metadata11 === void 0 ? void 0 : _metadata11.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
4646
|
+
productBookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_metadata12 = product.metadata) === null || _metadata12 === void 0 ? void 0 : _metadata12.booking_uid);
|
|
4647
|
+
isAddTimeProduct = (product === null || product === void 0 || (_metadata13 = product.metadata) === null || _metadata13 === void 0 ? void 0 : _metadata13.product_add_schedule_time) !== undefined && (product === null || product === void 0 || (_metadata14 = product.metadata) === null || _metadata14 === void 0 ? void 0 : _metadata14.product_add_schedule_time) !== null;
|
|
4310
4648
|
if (!isAddTimeProduct) {
|
|
4311
|
-
|
|
4649
|
+
_context29.next = 6;
|
|
4312
4650
|
break;
|
|
4313
4651
|
}
|
|
4314
|
-
return
|
|
4652
|
+
return _context29.abrupt("return", 1);
|
|
4315
4653
|
case 6:
|
|
4316
4654
|
if (productBookingUid !== undefined && productBookingUid !== null && productBookingUid !== '') {
|
|
4317
4655
|
linkedBookingUidsToRemove.add(String(productBookingUid));
|
|
4318
4656
|
}
|
|
4319
4657
|
if (productUid !== undefined && productUid !== null && productUid !== '') {
|
|
4320
4658
|
bookingsBeforeRemove.forEach(function (booking) {
|
|
4321
|
-
var bookingUid =
|
|
4659
|
+
var bookingUid = _this29.getBookingUniqueIdentificationNumber(booking);
|
|
4322
4660
|
if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
|
|
4323
4661
|
linkedBookingUidsToRemove.add(bookingUid);
|
|
4324
4662
|
}
|
|
@@ -4326,37 +4664,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4326
4664
|
}
|
|
4327
4665
|
case 8:
|
|
4328
4666
|
case "end":
|
|
4329
|
-
return
|
|
4667
|
+
return _context29.stop();
|
|
4330
4668
|
}
|
|
4331
4669
|
}, _loop3);
|
|
4332
4670
|
});
|
|
4333
4671
|
_iterator21.s();
|
|
4334
4672
|
case 14:
|
|
4335
4673
|
if ((_step21 = _iterator21.n()).done) {
|
|
4336
|
-
|
|
4674
|
+
_context30.next = 20;
|
|
4337
4675
|
break;
|
|
4338
4676
|
}
|
|
4339
|
-
return
|
|
4677
|
+
return _context30.delegateYield(_loop3(), "t0", 16);
|
|
4340
4678
|
case 16:
|
|
4341
|
-
if (!
|
|
4342
|
-
|
|
4679
|
+
if (!_context30.t0) {
|
|
4680
|
+
_context30.next = 18;
|
|
4343
4681
|
break;
|
|
4344
4682
|
}
|
|
4345
|
-
return
|
|
4683
|
+
return _context30.abrupt("continue", 18);
|
|
4346
4684
|
case 18:
|
|
4347
|
-
|
|
4685
|
+
_context30.next = 14;
|
|
4348
4686
|
break;
|
|
4349
4687
|
case 20:
|
|
4350
|
-
|
|
4688
|
+
_context30.next = 25;
|
|
4351
4689
|
break;
|
|
4352
4690
|
case 22:
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
_iterator21.e(
|
|
4691
|
+
_context30.prev = 22;
|
|
4692
|
+
_context30.t1 = _context30["catch"](11);
|
|
4693
|
+
_iterator21.e(_context30.t1);
|
|
4356
4694
|
case 25:
|
|
4357
|
-
|
|
4695
|
+
_context30.prev = 25;
|
|
4358
4696
|
_iterator21.f();
|
|
4359
|
-
return
|
|
4697
|
+
return _context30.finish(25);
|
|
4360
4698
|
case 28:
|
|
4361
4699
|
if (linkedBookingUidsToRemove.size > 0) {
|
|
4362
4700
|
// 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
|
|
@@ -4367,20 +4705,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4367
4705
|
return !(isAddTimeProduct && lineBookingUid !== undefined && lineBookingUid !== null && linkedBookingUidsToRemove.has(String(lineBookingUid)));
|
|
4368
4706
|
});
|
|
4369
4707
|
}
|
|
4370
|
-
|
|
4708
|
+
_context30.next = 31;
|
|
4371
4709
|
return this.finalizeAfterProductsMutation(tempOrder);
|
|
4372
4710
|
case 31:
|
|
4373
4711
|
this.logInfo('removeProductsFromOrder success', {
|
|
4374
4712
|
identities: identities
|
|
4375
4713
|
});
|
|
4376
|
-
return
|
|
4714
|
+
return _context30.abrupt("return", tempOrder.products);
|
|
4377
4715
|
case 33:
|
|
4378
4716
|
case "end":
|
|
4379
|
-
return
|
|
4717
|
+
return _context30.stop();
|
|
4380
4718
|
}
|
|
4381
|
-
},
|
|
4719
|
+
}, _callee27, this, [[11, 22, 25, 28]]);
|
|
4382
4720
|
}));
|
|
4383
|
-
function removeProductsFromOrder(
|
|
4721
|
+
function removeProductsFromOrder(_x34) {
|
|
4384
4722
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
4385
4723
|
}
|
|
4386
4724
|
return removeProductsFromOrder;
|
|
@@ -4388,18 +4726,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4388
4726
|
}, {
|
|
4389
4727
|
key: "removeProductFromOrder",
|
|
4390
4728
|
value: function () {
|
|
4391
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4392
|
-
return _regeneratorRuntime().wrap(function
|
|
4393
|
-
while (1) switch (
|
|
4729
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(identity) {
|
|
4730
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context31) {
|
|
4731
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
4394
4732
|
case 0:
|
|
4395
|
-
return
|
|
4733
|
+
return _context31.abrupt("return", this.removeProductsFromOrder([identity]));
|
|
4396
4734
|
case 1:
|
|
4397
4735
|
case "end":
|
|
4398
|
-
return
|
|
4736
|
+
return _context31.stop();
|
|
4399
4737
|
}
|
|
4400
|
-
},
|
|
4738
|
+
}, _callee28, this);
|
|
4401
4739
|
}));
|
|
4402
|
-
function removeProductFromOrder(
|
|
4740
|
+
function removeProductFromOrder(_x35) {
|
|
4403
4741
|
return _removeProductFromOrder.apply(this, arguments);
|
|
4404
4742
|
}
|
|
4405
4743
|
return removeProductFromOrder;
|
|
@@ -4411,10 +4749,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4411
4749
|
}, {
|
|
4412
4750
|
key: "clearOrderCartLines",
|
|
4413
4751
|
value: (function () {
|
|
4414
|
-
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4752
|
+
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
|
|
4415
4753
|
var tempOrder;
|
|
4416
|
-
return _regeneratorRuntime().wrap(function
|
|
4417
|
-
while (1) switch (
|
|
4754
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context32) {
|
|
4755
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
4418
4756
|
case 0:
|
|
4419
4757
|
tempOrder = this.ensureTempOrder();
|
|
4420
4758
|
tempOrder.products = [];
|
|
@@ -4425,24 +4763,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4425
4763
|
productsByUid: {}
|
|
4426
4764
|
});
|
|
4427
4765
|
}
|
|
4428
|
-
|
|
4766
|
+
_context32.next = 7;
|
|
4429
4767
|
return this.applyPromotion();
|
|
4430
4768
|
case 7:
|
|
4431
4769
|
this.applyDiscount();
|
|
4432
4770
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4433
|
-
|
|
4771
|
+
_context32.next = 11;
|
|
4434
4772
|
return this.recalculateSummary({
|
|
4435
4773
|
createIfMissing: true
|
|
4436
4774
|
});
|
|
4437
4775
|
case 11:
|
|
4438
4776
|
this.persistTempOrder();
|
|
4439
4777
|
this.logInfo('clearOrderCartLines success', {});
|
|
4440
|
-
return
|
|
4778
|
+
return _context32.abrupt("return", tempOrder);
|
|
4441
4779
|
case 14:
|
|
4442
4780
|
case "end":
|
|
4443
|
-
return
|
|
4781
|
+
return _context32.stop();
|
|
4444
4782
|
}
|
|
4445
|
-
},
|
|
4783
|
+
}, _callee29, this);
|
|
4446
4784
|
}));
|
|
4447
4785
|
function clearOrderCartLines() {
|
|
4448
4786
|
return _clearOrderCartLines.apply(this, arguments);
|
|
@@ -4453,23 +4791,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4453
4791
|
}, {
|
|
4454
4792
|
key: "buildCurrentSubmitPayloadForLocalPrint",
|
|
4455
4793
|
value: function buildCurrentSubmitPayloadForLocalPrint(params) {
|
|
4456
|
-
var _params$cacheId, _this$otherParams3,
|
|
4794
|
+
var _params$cacheId, _this$otherParams3, _ref70, _params$businessCode, _this$otherParams4, _this$otherParams5;
|
|
4457
4795
|
var tempOrder = this.ensureTempOrder();
|
|
4458
4796
|
this.persistTempOrder();
|
|
4459
4797
|
var payload = buildSubmitPayload({
|
|
4460
4798
|
tempOrder: tempOrder,
|
|
4461
4799
|
cacheId: (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId,
|
|
4462
4800
|
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.platform),
|
|
4463
|
-
businessCode: (
|
|
4801
|
+
businessCode: (_ref70 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.businessCode) !== null && _ref70 !== void 0 ? _ref70 : (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.business_code,
|
|
4464
4802
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
4465
4803
|
type: params === null || params === void 0 ? void 0 : params.type,
|
|
4466
4804
|
summary: this.store.summary || createEmptySummary(),
|
|
4467
4805
|
enhance: function enhance(nextPayload) {
|
|
4468
|
-
var
|
|
4806
|
+
var _ref71, _tempOrder$order_numb, _ref72, _tempOrder$shop_order, _ref73, _tempOrder$shop_full_;
|
|
4469
4807
|
return _objectSpread(_objectSpread({}, nextPayload), {}, {
|
|
4470
|
-
order_number: (
|
|
4471
|
-
shop_order_number: (
|
|
4472
|
-
shop_full_order_number: (
|
|
4808
|
+
order_number: (_ref71 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref71 !== void 0 ? _ref71 : null,
|
|
4809
|
+
shop_order_number: (_ref72 = (_tempOrder$shop_order = tempOrder.shop_order_number) !== null && _tempOrder$shop_order !== void 0 ? _tempOrder$shop_order : nextPayload.shop_order_number) !== null && _ref72 !== void 0 ? _ref72 : null,
|
|
4810
|
+
shop_full_order_number: (_ref73 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref73 !== void 0 ? _ref73 : null,
|
|
4473
4811
|
small_ticket_data_flag: 1
|
|
4474
4812
|
});
|
|
4475
4813
|
}
|
|
@@ -4480,17 +4818,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4480
4818
|
}, {
|
|
4481
4819
|
key: "applyLocalPrintOrderNumbers",
|
|
4482
4820
|
value: function () {
|
|
4483
|
-
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4821
|
+
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(order) {
|
|
4484
4822
|
var tempOrder, shopOrderNumber, shopFullOrderNumber;
|
|
4485
|
-
return _regeneratorRuntime().wrap(function
|
|
4486
|
-
while (1) switch (
|
|
4823
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context33) {
|
|
4824
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
4487
4825
|
case 0:
|
|
4488
4826
|
tempOrder = this.ensureTempOrder();
|
|
4489
4827
|
if (!(!order || _typeof(order) !== 'object')) {
|
|
4490
|
-
|
|
4828
|
+
_context33.next = 3;
|
|
4491
4829
|
break;
|
|
4492
4830
|
}
|
|
4493
|
-
return
|
|
4831
|
+
return _context33.abrupt("return", tempOrder);
|
|
4494
4832
|
case 3:
|
|
4495
4833
|
shopOrderNumber = order.shop_order_number;
|
|
4496
4834
|
shopFullOrderNumber = order.shop_full_order_number;
|
|
@@ -4501,21 +4839,88 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4501
4839
|
tempOrder.shop_full_order_number = String(shopFullOrderNumber);
|
|
4502
4840
|
}
|
|
4503
4841
|
this.persistTempOrder();
|
|
4504
|
-
|
|
4842
|
+
_context33.next = 10;
|
|
4505
4843
|
return this.saveDraft();
|
|
4506
4844
|
case 10:
|
|
4507
|
-
return
|
|
4845
|
+
return _context33.abrupt("return", tempOrder);
|
|
4508
4846
|
case 11:
|
|
4509
4847
|
case "end":
|
|
4510
|
-
return
|
|
4848
|
+
return _context33.stop();
|
|
4511
4849
|
}
|
|
4512
|
-
},
|
|
4850
|
+
}, _callee30, this);
|
|
4513
4851
|
}));
|
|
4514
|
-
function applyLocalPrintOrderNumbers(
|
|
4852
|
+
function applyLocalPrintOrderNumbers(_x36) {
|
|
4515
4853
|
return _applyLocalPrintOrderNumbers.apply(this, arguments);
|
|
4516
4854
|
}
|
|
4517
4855
|
return applyLocalPrintOrderNumbers;
|
|
4518
4856
|
}()
|
|
4857
|
+
}, {
|
|
4858
|
+
key: "saveTempOrderAsDraft",
|
|
4859
|
+
value: function () {
|
|
4860
|
+
var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
|
|
4861
|
+
var _params$cacheId2, _this$otherParams6, _ref74, _params$businessCode2, _this$otherParams7, _this$otherParams8, _params$type, _this$otherParams9, _payload$products;
|
|
4862
|
+
var tempOrder, latestSummary, payload;
|
|
4863
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context34) {
|
|
4864
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
4865
|
+
case 0:
|
|
4866
|
+
tempOrder = this.ensureTempOrder();
|
|
4867
|
+
this.ensureExternalSaleNumber(tempOrder);
|
|
4868
|
+
this.persistTempOrder();
|
|
4869
|
+
_context34.next = 5;
|
|
4870
|
+
return this.recalculateSummary({
|
|
4871
|
+
createIfMissing: true
|
|
4872
|
+
});
|
|
4873
|
+
case 5:
|
|
4874
|
+
_context34.t1 = _context34.sent;
|
|
4875
|
+
if (_context34.t1) {
|
|
4876
|
+
_context34.next = 8;
|
|
4877
|
+
break;
|
|
4878
|
+
}
|
|
4879
|
+
_context34.t1 = this.store.summary;
|
|
4880
|
+
case 8:
|
|
4881
|
+
_context34.t0 = _context34.t1;
|
|
4882
|
+
if (_context34.t0) {
|
|
4883
|
+
_context34.next = 11;
|
|
4884
|
+
break;
|
|
4885
|
+
}
|
|
4886
|
+
_context34.t0 = createEmptySummary();
|
|
4887
|
+
case 11:
|
|
4888
|
+
latestSummary = _context34.t0;
|
|
4889
|
+
payload = buildSubmitPayload({
|
|
4890
|
+
tempOrder: tempOrder,
|
|
4891
|
+
cacheId: (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId,
|
|
4892
|
+
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform),
|
|
4893
|
+
businessCode: (_ref74 = (_params$businessCode2 = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode2 !== void 0 ? _params$businessCode2 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.businessCode) !== null && _ref74 !== void 0 ? _ref74 : (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.business_code,
|
|
4894
|
+
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
4895
|
+
type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.type,
|
|
4896
|
+
summary: latestSummary,
|
|
4897
|
+
enhance: params === null || params === void 0 ? void 0 : params.enhancePayload
|
|
4898
|
+
});
|
|
4899
|
+
if (!payload.created_at) {
|
|
4900
|
+
payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
4901
|
+
}
|
|
4902
|
+
payload.need_sync = 0;
|
|
4903
|
+
payload.is_draft_order = 1;
|
|
4904
|
+
this.logInfo('saveTempOrderAsDraft calling sales draft', {
|
|
4905
|
+
orderId: payload.order_id,
|
|
4906
|
+
externalSaleNumber: payload.external_sale_number,
|
|
4907
|
+
productsCount: ((_payload$products = payload.products) === null || _payload$products === void 0 ? void 0 : _payload$products.length) || 0
|
|
4908
|
+
});
|
|
4909
|
+
return _context34.abrupt("return", this.request.post('/order/sales/draft', payload, {
|
|
4910
|
+
osServer: true,
|
|
4911
|
+
customToast: function customToast() {}
|
|
4912
|
+
}));
|
|
4913
|
+
case 18:
|
|
4914
|
+
case "end":
|
|
4915
|
+
return _context34.stop();
|
|
4916
|
+
}
|
|
4917
|
+
}, _callee31, this);
|
|
4918
|
+
}));
|
|
4919
|
+
function saveTempOrderAsDraft(_x37) {
|
|
4920
|
+
return _saveTempOrderAsDraft.apply(this, arguments);
|
|
4921
|
+
}
|
|
4922
|
+
return saveTempOrderAsDraft;
|
|
4923
|
+
}()
|
|
4519
4924
|
/**
|
|
4520
4925
|
* 提交当前 Sales tempOrder。
|
|
4521
4926
|
*
|
|
@@ -4525,18 +4930,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4525
4930
|
}, {
|
|
4526
4931
|
key: "submitTempOrder",
|
|
4527
4932
|
value: (function () {
|
|
4528
|
-
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4529
|
-
return _regeneratorRuntime().wrap(function
|
|
4530
|
-
while (1) switch (
|
|
4933
|
+
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
|
|
4934
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context35) {
|
|
4935
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
4531
4936
|
case 0:
|
|
4532
|
-
return
|
|
4937
|
+
return _context35.abrupt("return", this.runSubmitTempOrder(params));
|
|
4533
4938
|
case 1:
|
|
4534
4939
|
case "end":
|
|
4535
|
-
return
|
|
4940
|
+
return _context35.stop();
|
|
4536
4941
|
}
|
|
4537
|
-
},
|
|
4942
|
+
}, _callee32, this);
|
|
4538
4943
|
}));
|
|
4539
|
-
function submitTempOrder(
|
|
4944
|
+
function submitTempOrder(_x38) {
|
|
4540
4945
|
return _submitTempOrder.apply(this, arguments);
|
|
4541
4946
|
}
|
|
4542
4947
|
return submitTempOrder;
|
|
@@ -4544,20 +4949,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4544
4949
|
}, {
|
|
4545
4950
|
key: "submitTempOrderAsync",
|
|
4546
4951
|
value: function () {
|
|
4547
|
-
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4548
|
-
return _regeneratorRuntime().wrap(function
|
|
4549
|
-
while (1) switch (
|
|
4952
|
+
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
|
|
4953
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context36) {
|
|
4954
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
4550
4955
|
case 0:
|
|
4551
|
-
return
|
|
4956
|
+
return _context36.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
4552
4957
|
syncMode: true
|
|
4553
4958
|
})));
|
|
4554
4959
|
case 1:
|
|
4555
4960
|
case "end":
|
|
4556
|
-
return
|
|
4961
|
+
return _context36.stop();
|
|
4557
4962
|
}
|
|
4558
|
-
},
|
|
4963
|
+
}, _callee33, this);
|
|
4559
4964
|
}));
|
|
4560
|
-
function submitTempOrderAsync(
|
|
4965
|
+
function submitTempOrderAsync(_x39) {
|
|
4561
4966
|
return _submitTempOrderAsync.apply(this, arguments);
|
|
4562
4967
|
}
|
|
4563
4968
|
return submitTempOrderAsync;
|
|
@@ -4565,11 +4970,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4565
4970
|
}, {
|
|
4566
4971
|
key: "runSubmitTempOrder",
|
|
4567
4972
|
value: function () {
|
|
4568
|
-
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4569
|
-
var _params$
|
|
4973
|
+
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
|
|
4974
|
+
var _params$cacheId3, _this$otherParams10, _ref75, _ref76, _submitSnapshot$busin, _this$otherParams11, _this$otherParams12, _submitSnapshot$type;
|
|
4570
4975
|
var tempOrder, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
|
|
4571
|
-
return _regeneratorRuntime().wrap(function
|
|
4572
|
-
while (1) switch (
|
|
4976
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context37) {
|
|
4977
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
4573
4978
|
case 0:
|
|
4574
4979
|
tempOrder = this.ensureTempOrder();
|
|
4575
4980
|
shouldConfirmPendingVoucherPayments = (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== false;
|
|
@@ -4589,27 +4994,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4589
4994
|
}
|
|
4590
4995
|
}
|
|
4591
4996
|
this.persistTempOrder();
|
|
4592
|
-
|
|
4997
|
+
_context37.next = 8;
|
|
4593
4998
|
return this.recalculateSummary({
|
|
4594
4999
|
createIfMissing: true
|
|
4595
5000
|
});
|
|
4596
5001
|
case 8:
|
|
4597
|
-
|
|
4598
|
-
if (
|
|
4599
|
-
|
|
5002
|
+
_context37.t1 = _context37.sent;
|
|
5003
|
+
if (_context37.t1) {
|
|
5004
|
+
_context37.next = 11;
|
|
4600
5005
|
break;
|
|
4601
5006
|
}
|
|
4602
|
-
|
|
5007
|
+
_context37.t1 = this.store.summary;
|
|
4603
5008
|
case 11:
|
|
4604
|
-
|
|
4605
|
-
if (
|
|
4606
|
-
|
|
5009
|
+
_context37.t0 = _context37.t1;
|
|
5010
|
+
if (_context37.t0) {
|
|
5011
|
+
_context37.next = 14;
|
|
4607
5012
|
break;
|
|
4608
5013
|
}
|
|
4609
|
-
|
|
5014
|
+
_context37.t0 = createEmptySummary();
|
|
4610
5015
|
case 14:
|
|
4611
|
-
latestSummary =
|
|
4612
|
-
effectiveCacheId = (_params$
|
|
5016
|
+
latestSummary = _context37.t0;
|
|
5017
|
+
effectiveCacheId = (_params$cacheId3 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId3 !== void 0 ? _params$cacheId3 : this.cacheId;
|
|
4613
5018
|
hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
|
|
4614
5019
|
hasSmallTicketDataFlagOverride = (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined;
|
|
4615
5020
|
enhancePayload = hasPaymentOverride || hasPaymentStatusOverride || hasSmallTicketDataFlagOverride || params !== null && params !== void 0 && params.enhancePayload ? function (payload, ctx) {
|
|
@@ -4627,8 +5032,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4627
5032
|
payload = buildSubmitPayload({
|
|
4628
5033
|
tempOrder: tempOrder,
|
|
4629
5034
|
cacheId: effectiveCacheId,
|
|
4630
|
-
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$
|
|
4631
|
-
businessCode: (
|
|
5035
|
+
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.platform),
|
|
5036
|
+
businessCode: (_ref75 = (_ref76 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref76 !== void 0 ? _ref76 : (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.businessCode) !== null && _ref75 !== void 0 ? _ref75 : (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.business_code,
|
|
4632
5037
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
4633
5038
|
type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
|
|
4634
5039
|
summary: latestSummary,
|
|
@@ -4643,10 +5048,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4643
5048
|
if (!payload.created_at) {
|
|
4644
5049
|
payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
4645
5050
|
}
|
|
4646
|
-
|
|
5051
|
+
_context37.next = 26;
|
|
4647
5052
|
return this.saveDraft();
|
|
4648
5053
|
case 26:
|
|
4649
|
-
|
|
5054
|
+
_context37.prev = 26;
|
|
4650
5055
|
this.logInfo('submitTempOrder calling sales checkout', {
|
|
4651
5056
|
orderId: payload.order_id,
|
|
4652
5057
|
externalSaleNumber: payload.external_sale_number,
|
|
@@ -4656,43 +5061,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4656
5061
|
smallTicketDataFlag: payload.small_ticket_data_flag,
|
|
4657
5062
|
syncMode: payload.sync_mode
|
|
4658
5063
|
});
|
|
4659
|
-
|
|
5064
|
+
_context37.next = 30;
|
|
4660
5065
|
return this.submitSalesOrder({
|
|
4661
5066
|
query: payload
|
|
4662
5067
|
});
|
|
4663
5068
|
case 30:
|
|
4664
|
-
result =
|
|
4665
|
-
|
|
5069
|
+
result = _context37.sent;
|
|
5070
|
+
_context37.next = 43;
|
|
4666
5071
|
break;
|
|
4667
5072
|
case 33:
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
backendErrorResponse = this.extractSubmitErrorResponse(
|
|
5073
|
+
_context37.prev = 33;
|
|
5074
|
+
_context37.t2 = _context37["catch"](26);
|
|
5075
|
+
backendErrorResponse = this.extractSubmitErrorResponse(_context37.t2);
|
|
4671
5076
|
if (!backendErrorResponse) {
|
|
4672
|
-
|
|
5077
|
+
_context37.next = 40;
|
|
4673
5078
|
break;
|
|
4674
5079
|
}
|
|
4675
5080
|
this.store.syncState = 'failed';
|
|
4676
5081
|
this.logSubmitBackendRejected(backendErrorResponse, payload);
|
|
4677
|
-
return
|
|
5082
|
+
return _context37.abrupt("return", backendErrorResponse);
|
|
4678
5083
|
case 40:
|
|
4679
5084
|
this.store.syncState = 'failed';
|
|
4680
5085
|
this.logError('submitTempOrder failed', {
|
|
4681
|
-
error:
|
|
5086
|
+
error: _context37.t2 instanceof Error ? _context37.t2.message : String(_context37.t2),
|
|
4682
5087
|
orderId: payload.order_id,
|
|
4683
5088
|
externalSaleNumber: payload.external_sale_number,
|
|
4684
5089
|
paymentStatus: payload.payment_status,
|
|
4685
5090
|
paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
|
|
4686
5091
|
});
|
|
4687
|
-
throw
|
|
5092
|
+
throw _context37.t2;
|
|
4688
5093
|
case 43:
|
|
4689
5094
|
if (!this.isSubmitResponseRejected(result)) {
|
|
4690
|
-
|
|
5095
|
+
_context37.next = 47;
|
|
4691
5096
|
break;
|
|
4692
5097
|
}
|
|
4693
5098
|
this.store.syncState = 'failed';
|
|
4694
5099
|
this.logSubmitBackendRejected(result, payload);
|
|
4695
|
-
return
|
|
5100
|
+
return _context37.abrupt("return", result);
|
|
4696
5101
|
case 47:
|
|
4697
5102
|
submittedOrderId = this.extractOrderIdFromSubmitResult(result);
|
|
4698
5103
|
this.logInfo('runSubmitTempOrder: 提交成功', {
|
|
@@ -4703,15 +5108,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4703
5108
|
})
|
|
4704
5109
|
});
|
|
4705
5110
|
if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
|
|
4706
|
-
|
|
5111
|
+
_context37.next = 56;
|
|
4707
5112
|
break;
|
|
4708
5113
|
}
|
|
4709
5114
|
tempOrder.order_id = submittedOrderId;
|
|
4710
5115
|
resultRecord = result;
|
|
4711
|
-
|
|
5116
|
+
_context37.next = 54;
|
|
4712
5117
|
return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
|
|
4713
5118
|
case 54:
|
|
4714
|
-
|
|
5119
|
+
_context37.next = 57;
|
|
4715
5120
|
break;
|
|
4716
5121
|
case 56:
|
|
4717
5122
|
if (this.isLocalPendingSubmitResult(result)) {
|
|
@@ -4720,14 +5125,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4720
5125
|
this.store.syncState = 'submitted';
|
|
4721
5126
|
}
|
|
4722
5127
|
case 57:
|
|
4723
|
-
return
|
|
5128
|
+
return _context37.abrupt("return", result);
|
|
4724
5129
|
case 58:
|
|
4725
5130
|
case "end":
|
|
4726
|
-
return
|
|
5131
|
+
return _context37.stop();
|
|
4727
5132
|
}
|
|
4728
|
-
},
|
|
5133
|
+
}, _callee34, this, [[26, 33]]);
|
|
4729
5134
|
}));
|
|
4730
|
-
function runSubmitTempOrder(
|
|
5135
|
+
function runSubmitTempOrder(_x40) {
|
|
4731
5136
|
return _runSubmitTempOrder.apply(this, arguments);
|
|
4732
5137
|
}
|
|
4733
5138
|
return runSubmitTempOrder;
|
|
@@ -4735,10 +5140,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4735
5140
|
}, {
|
|
4736
5141
|
key: "markLocalOrderSynced",
|
|
4737
5142
|
value: function () {
|
|
4738
|
-
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5143
|
+
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(orderId, remoteOrder) {
|
|
4739
5144
|
var tempOrder;
|
|
4740
|
-
return _regeneratorRuntime().wrap(function
|
|
4741
|
-
while (1) switch (
|
|
5145
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context38) {
|
|
5146
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
4742
5147
|
case 0:
|
|
4743
5148
|
tempOrder = this.ensureTempOrder();
|
|
4744
5149
|
tempOrder.order_id = orderId;
|
|
@@ -4746,15 +5151,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4746
5151
|
this.store.lastOrderInfo = remoteOrder;
|
|
4747
5152
|
this.store.syncState = 'submitted';
|
|
4748
5153
|
this.persistTempOrder();
|
|
4749
|
-
|
|
5154
|
+
_context38.next = 8;
|
|
4750
5155
|
return this.saveDraft();
|
|
4751
5156
|
case 8:
|
|
4752
5157
|
case "end":
|
|
4753
|
-
return
|
|
5158
|
+
return _context38.stop();
|
|
4754
5159
|
}
|
|
4755
|
-
},
|
|
5160
|
+
}, _callee35, this);
|
|
4756
5161
|
}));
|
|
4757
|
-
function markLocalOrderSynced(
|
|
5162
|
+
function markLocalOrderSynced(_x41, _x42) {
|
|
4758
5163
|
return _markLocalOrderSynced.apply(this, arguments);
|
|
4759
5164
|
}
|
|
4760
5165
|
return markLocalOrderSynced;
|
|
@@ -4797,10 +5202,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4797
5202
|
value: function extractSubmitErrorResponse(error) {
|
|
4798
5203
|
var _error$response,
|
|
4799
5204
|
_error$response2,
|
|
4800
|
-
|
|
5205
|
+
_this30 = this;
|
|
4801
5206
|
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];
|
|
4802
5207
|
return candidates.find(function (candidate) {
|
|
4803
|
-
return
|
|
5208
|
+
return _this30.isSubmitErrorResponse(candidate);
|
|
4804
5209
|
}) || null;
|
|
4805
5210
|
}
|
|
4806
5211
|
}, {
|
|
@@ -4827,40 +5232,63 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4827
5232
|
}, {
|
|
4828
5233
|
key: "syncPaymentsToOrder",
|
|
4829
5234
|
value: function () {
|
|
4830
|
-
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4831
|
-
var
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
5235
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
|
|
5236
|
+
var _this31 = this,
|
|
5237
|
+
_params$confirmPendin;
|
|
5238
|
+
var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, submitResult;
|
|
5239
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context39) {
|
|
5240
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
4835
5241
|
case 0:
|
|
4836
5242
|
tempOrder = this.ensureTempOrder();
|
|
4837
|
-
|
|
5243
|
+
needsPaymentNumber = (params.payments || []).some(function (payment) {
|
|
5244
|
+
return String(payment.payment_number || '').trim() === '';
|
|
5245
|
+
});
|
|
5246
|
+
if (!needsPaymentNumber) {
|
|
5247
|
+
_context39.next = 8;
|
|
5248
|
+
break;
|
|
5249
|
+
}
|
|
5250
|
+
_context39.next = 5;
|
|
5251
|
+
return this.getPaymentNumberDevicePrefixAsync();
|
|
5252
|
+
case 5:
|
|
5253
|
+
_context39.t0 = _context39.sent;
|
|
5254
|
+
_context39.next = 9;
|
|
5255
|
+
break;
|
|
5256
|
+
case 8:
|
|
5257
|
+
_context39.t0 = 'LOCAL';
|
|
5258
|
+
case 9:
|
|
5259
|
+
devicePrefix = _context39.t0;
|
|
5260
|
+
mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
|
|
5261
|
+
return _this31.normalizePaymentSource(payment, {
|
|
5262
|
+
defaultPaid: false,
|
|
5263
|
+
devicePrefix: devicePrefix
|
|
5264
|
+
});
|
|
5265
|
+
}));
|
|
4838
5266
|
shouldConfirmPendingVoucherPayments = (_params$confirmPendin = params.confirmPendingVoucherPayments) !== null && _params$confirmPendin !== void 0 ? _params$confirmPendin : params.submitWhenPaid === true;
|
|
4839
5267
|
effectivePayments = shouldConfirmPendingVoucherPayments ? this.confirmPendingVoucherPaymentsInList(mappedPayments) : params.confirmPendingVoucherPayments === false ? this.discardPendingVoucherPaymentsFromList(mappedPayments) : mappedPayments;
|
|
4840
5268
|
completion = this.getPaymentCompletion(effectivePayments);
|
|
4841
|
-
|
|
4842
|
-
paymentStatus = completion.isOrderFullyPaid ? params.paymentStatus || 'paid' :
|
|
5269
|
+
orderPaidPaymentTotal = this.calculateOrderPaidPaymentTotal(effectivePayments);
|
|
5270
|
+
paymentStatus = completion.isOrderFullyPaid ? params.paymentStatus || 'paid' : orderPaidPaymentTotal.gt(0) ? 'partially_paid' : 'payment_processing';
|
|
4843
5271
|
tempOrder.payments = effectivePayments;
|
|
4844
5272
|
tempOrder.payment_status = paymentStatus;
|
|
4845
5273
|
this.persistTempOrder();
|
|
4846
|
-
|
|
5274
|
+
_context39.next = 21;
|
|
4847
5275
|
return this.saveDraft();
|
|
4848
|
-
case
|
|
5276
|
+
case 21:
|
|
4849
5277
|
if (params.submitWhenPaid) {
|
|
4850
|
-
|
|
5278
|
+
_context39.next = 23;
|
|
4851
5279
|
break;
|
|
4852
5280
|
}
|
|
4853
|
-
return
|
|
4854
|
-
case
|
|
5281
|
+
return _context39.abrupt("return", completion);
|
|
5282
|
+
case 23:
|
|
4855
5283
|
if (!(this.store.syncState === 'submitting')) {
|
|
4856
|
-
|
|
5284
|
+
_context39.next = 25;
|
|
4857
5285
|
break;
|
|
4858
5286
|
}
|
|
4859
|
-
return
|
|
4860
|
-
case
|
|
5287
|
+
return _context39.abrupt("return", completion);
|
|
5288
|
+
case 25:
|
|
4861
5289
|
this.store.syncState = 'submitting';
|
|
4862
5290
|
paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, effectivePayments);
|
|
4863
|
-
|
|
5291
|
+
_context39.next = 29;
|
|
4864
5292
|
return this.submitTempOrder({
|
|
4865
5293
|
payments: effectivePayments,
|
|
4866
5294
|
paymentStatus: paymentStatus,
|
|
@@ -4875,18 +5303,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4875
5303
|
return nextPayload;
|
|
4876
5304
|
}
|
|
4877
5305
|
});
|
|
4878
|
-
case
|
|
4879
|
-
submitResult =
|
|
4880
|
-
return
|
|
5306
|
+
case 29:
|
|
5307
|
+
submitResult = _context39.sent;
|
|
5308
|
+
return _context39.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
|
|
4881
5309
|
submitResult: submitResult
|
|
4882
5310
|
}));
|
|
4883
|
-
case
|
|
5311
|
+
case 31:
|
|
4884
5312
|
case "end":
|
|
4885
|
-
return
|
|
5313
|
+
return _context39.stop();
|
|
4886
5314
|
}
|
|
4887
|
-
},
|
|
5315
|
+
}, _callee36, this);
|
|
4888
5316
|
}));
|
|
4889
|
-
function syncPaymentsToOrder(
|
|
5317
|
+
function syncPaymentsToOrder(_x43) {
|
|
4890
5318
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
4891
5319
|
}
|
|
4892
5320
|
return syncPaymentsToOrder;
|
|
@@ -4975,11 +5403,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4975
5403
|
}, {
|
|
4976
5404
|
key: "submitOrder",
|
|
4977
5405
|
value: function () {
|
|
4978
|
-
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5406
|
+
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(order) {
|
|
4979
5407
|
var _order$query$cartItem, _params$bookings, _params$relation_prod;
|
|
4980
5408
|
var url, query, fetchUrl, params;
|
|
4981
|
-
return _regeneratorRuntime().wrap(function
|
|
4982
|
-
while (1) switch (
|
|
5409
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context40) {
|
|
5410
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
4983
5411
|
case 0:
|
|
4984
5412
|
this.logInfo('submitOrder called', {
|
|
4985
5413
|
url: order.url,
|
|
@@ -4999,14 +5427,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4999
5427
|
relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
|
|
5000
5428
|
scheduleDate: params.schedule_date
|
|
5001
5429
|
});
|
|
5002
|
-
return
|
|
5430
|
+
return _context40.abrupt("return", this.request.post(fetchUrl, params));
|
|
5003
5431
|
case 6:
|
|
5004
5432
|
case "end":
|
|
5005
|
-
return
|
|
5433
|
+
return _context40.stop();
|
|
5006
5434
|
}
|
|
5007
|
-
},
|
|
5435
|
+
}, _callee37, this);
|
|
5008
5436
|
}));
|
|
5009
|
-
function submitOrder(
|
|
5437
|
+
function submitOrder(_x44) {
|
|
5010
5438
|
return _submitOrder.apply(this, arguments);
|
|
5011
5439
|
}
|
|
5012
5440
|
return submitOrder;
|
|
@@ -5014,13 +5442,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5014
5442
|
}, {
|
|
5015
5443
|
key: "cancelOrder",
|
|
5016
5444
|
value: function () {
|
|
5017
|
-
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5445
|
+
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
|
|
5018
5446
|
var payload;
|
|
5019
|
-
return _regeneratorRuntime().wrap(function
|
|
5020
|
-
while (1) switch (
|
|
5447
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context41) {
|
|
5448
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
5021
5449
|
case 0:
|
|
5022
5450
|
if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
|
|
5023
|
-
|
|
5451
|
+
_context41.next = 2;
|
|
5024
5452
|
break;
|
|
5025
5453
|
}
|
|
5026
5454
|
throw new Error('取消订单失败:order_ids 不能为空');
|
|
@@ -5036,16 +5464,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5036
5464
|
method: 'PUT',
|
|
5037
5465
|
orderIdsCount: params.order_ids.length
|
|
5038
5466
|
});
|
|
5039
|
-
return
|
|
5467
|
+
return _context41.abrupt("return", this.request.put('/order/update-status', payload, {
|
|
5040
5468
|
isShopApi: true
|
|
5041
5469
|
}));
|
|
5042
5470
|
case 5:
|
|
5043
5471
|
case "end":
|
|
5044
|
-
return
|
|
5472
|
+
return _context41.stop();
|
|
5045
5473
|
}
|
|
5046
|
-
},
|
|
5474
|
+
}, _callee38, this);
|
|
5047
5475
|
}));
|
|
5048
|
-
function cancelOrder(
|
|
5476
|
+
function cancelOrder(_x45) {
|
|
5049
5477
|
return _cancelOrder.apply(this, arguments);
|
|
5050
5478
|
}
|
|
5051
5479
|
return cancelOrder;
|
|
@@ -5053,19 +5481,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5053
5481
|
}, {
|
|
5054
5482
|
key: "changeBookingStatus",
|
|
5055
5483
|
value: function () {
|
|
5056
|
-
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5484
|
+
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
|
|
5057
5485
|
var url, payload;
|
|
5058
|
-
return _regeneratorRuntime().wrap(function
|
|
5059
|
-
while (1) switch (
|
|
5486
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context42) {
|
|
5487
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
5060
5488
|
case 0:
|
|
5061
5489
|
if (params.booking_id) {
|
|
5062
|
-
|
|
5490
|
+
_context42.next = 2;
|
|
5063
5491
|
break;
|
|
5064
5492
|
}
|
|
5065
5493
|
throw new Error('变更预约状态失败:booking_id 不能为空');
|
|
5066
5494
|
case 2:
|
|
5067
5495
|
if (params.appointment_status) {
|
|
5068
|
-
|
|
5496
|
+
_context42.next = 4;
|
|
5069
5497
|
break;
|
|
5070
5498
|
}
|
|
5071
5499
|
throw new Error('变更预约状态失败:appointment_status 不能为空');
|
|
@@ -5080,16 +5508,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5080
5508
|
bookingId: params.booking_id,
|
|
5081
5509
|
appointmentStatus: params.appointment_status
|
|
5082
5510
|
});
|
|
5083
|
-
return
|
|
5511
|
+
return _context42.abrupt("return", this.request.put(url, payload, {
|
|
5084
5512
|
isShopApi: true
|
|
5085
5513
|
}));
|
|
5086
5514
|
case 8:
|
|
5087
5515
|
case "end":
|
|
5088
|
-
return
|
|
5516
|
+
return _context42.stop();
|
|
5089
5517
|
}
|
|
5090
|
-
},
|
|
5518
|
+
}, _callee39, this);
|
|
5091
5519
|
}));
|
|
5092
|
-
function changeBookingStatus(
|
|
5520
|
+
function changeBookingStatus(_x46) {
|
|
5093
5521
|
return _changeBookingStatus.apply(this, arguments);
|
|
5094
5522
|
}
|
|
5095
5523
|
return changeBookingStatus;
|
|
@@ -5107,11 +5535,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5107
5535
|
}, {
|
|
5108
5536
|
key: "createOrderByCheckout",
|
|
5109
5537
|
value: (function () {
|
|
5110
|
-
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5538
|
+
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
|
|
5111
5539
|
var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3, _params$bookings3, _params$relation_prod3, _params$payments4;
|
|
5112
5540
|
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;
|
|
5113
|
-
return _regeneratorRuntime().wrap(function
|
|
5114
|
-
while (1) switch (
|
|
5541
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context43) {
|
|
5542
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
5115
5543
|
case 0:
|
|
5116
5544
|
// 过滤掉由在线店铺下单的 payment 支付数据
|
|
5117
5545
|
onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
|
|
@@ -5145,7 +5573,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5145
5573
|
relationProductsCount: ((_params$relation_prod3 = params.relation_products) === null || _params$relation_prod3 === void 0 ? void 0 : _params$relation_prod3.length) || 0,
|
|
5146
5574
|
paymentsCount: ((_params$payments4 = params.payments) === null || _params$payments4 === void 0 ? void 0 : _params$payments4.length) || 0
|
|
5147
5575
|
});
|
|
5148
|
-
|
|
5576
|
+
_context43.prev = 4;
|
|
5149
5577
|
// 构建订单数据,设置默认值并允许 params 覆盖
|
|
5150
5578
|
orderData = _objectSpread({
|
|
5151
5579
|
sales_channel: 'my_pisel',
|
|
@@ -5207,13 +5635,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5207
5635
|
hasOrderId: !!orderData.order_id,
|
|
5208
5636
|
smallTicketDataFlag: orderData.small_ticket_data_flag
|
|
5209
5637
|
});
|
|
5210
|
-
|
|
5638
|
+
_context43.next = 12;
|
|
5211
5639
|
return this.request.post('/order/checkout', orderData, {
|
|
5212
5640
|
osServer: true,
|
|
5213
5641
|
customToast: function customToast() {}
|
|
5214
5642
|
});
|
|
5215
5643
|
case 12:
|
|
5216
|
-
response =
|
|
5644
|
+
response = _context43.sent;
|
|
5217
5645
|
this.logInfo('Order API called successfully', {
|
|
5218
5646
|
response: response
|
|
5219
5647
|
});
|
|
@@ -5221,22 +5649,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5221
5649
|
success: !!response,
|
|
5222
5650
|
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)
|
|
5223
5651
|
});
|
|
5224
|
-
return
|
|
5652
|
+
return _context43.abrupt("return", response);
|
|
5225
5653
|
case 18:
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
console.error('[Order] createOrderByCheckout 创建订单失败:',
|
|
5654
|
+
_context43.prev = 18;
|
|
5655
|
+
_context43.t0 = _context43["catch"](4);
|
|
5656
|
+
console.error('[Order] createOrderByCheckout 创建订单失败:', _context43.t0);
|
|
5229
5657
|
this.logInfo('Order API called failed', {
|
|
5230
|
-
error:
|
|
5658
|
+
error: _context43.t0 instanceof Error ? _context43.t0.message : String(_context43.t0)
|
|
5231
5659
|
});
|
|
5232
|
-
throw
|
|
5660
|
+
throw _context43.t0;
|
|
5233
5661
|
case 23:
|
|
5234
5662
|
case "end":
|
|
5235
|
-
return
|
|
5663
|
+
return _context43.stop();
|
|
5236
5664
|
}
|
|
5237
|
-
},
|
|
5665
|
+
}, _callee40, this, [[4, 18]]);
|
|
5238
5666
|
}));
|
|
5239
|
-
function createOrderByCheckout(
|
|
5667
|
+
function createOrderByCheckout(_x47) {
|
|
5240
5668
|
return _createOrderByCheckout.apply(this, arguments);
|
|
5241
5669
|
}
|
|
5242
5670
|
return createOrderByCheckout;
|
|
@@ -5244,24 +5672,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5244
5672
|
}, {
|
|
5245
5673
|
key: "submitSalesOrder",
|
|
5246
5674
|
value: function () {
|
|
5247
|
-
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5675
|
+
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
|
|
5248
5676
|
var url, query, fetchUrl;
|
|
5249
|
-
return _regeneratorRuntime().wrap(function
|
|
5250
|
-
while (1) switch (
|
|
5677
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context44) {
|
|
5678
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
5251
5679
|
case 0:
|
|
5252
5680
|
url = params.url, query = params.query;
|
|
5253
5681
|
fetchUrl = url || '/order/sales/checkout';
|
|
5254
|
-
return
|
|
5682
|
+
return _context44.abrupt("return", this.request.post(fetchUrl, query, {
|
|
5255
5683
|
osServer: true,
|
|
5256
5684
|
customToast: function customToast() {}
|
|
5257
5685
|
}));
|
|
5258
5686
|
case 3:
|
|
5259
5687
|
case "end":
|
|
5260
|
-
return
|
|
5688
|
+
return _context44.stop();
|
|
5261
5689
|
}
|
|
5262
|
-
},
|
|
5690
|
+
}, _callee41, this);
|
|
5263
5691
|
}));
|
|
5264
|
-
function submitSalesOrder(
|
|
5692
|
+
function submitSalesOrder(_x48) {
|
|
5265
5693
|
return _submitSalesOrder.apply(this, arguments);
|
|
5266
5694
|
}
|
|
5267
5695
|
return submitSalesOrder;
|
|
@@ -5275,37 +5703,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5275
5703
|
}, {
|
|
5276
5704
|
key: "sendCustomerPayLink",
|
|
5277
5705
|
value: (function () {
|
|
5278
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5706
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
|
|
5279
5707
|
var _params$emails;
|
|
5280
5708
|
var orderIds;
|
|
5281
|
-
return _regeneratorRuntime().wrap(function
|
|
5282
|
-
while (1) switch (
|
|
5709
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context45) {
|
|
5710
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
5283
5711
|
case 0:
|
|
5284
5712
|
orderIds = params.order_ids || params.orderIds || [];
|
|
5285
5713
|
if (orderIds.length) {
|
|
5286
|
-
|
|
5714
|
+
_context45.next = 3;
|
|
5287
5715
|
break;
|
|
5288
5716
|
}
|
|
5289
5717
|
throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
|
|
5290
5718
|
case 3:
|
|
5291
5719
|
if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
|
|
5292
|
-
|
|
5720
|
+
_context45.next = 5;
|
|
5293
5721
|
break;
|
|
5294
5722
|
}
|
|
5295
5723
|
throw new Error('发送支付链接需要至少一个邮箱');
|
|
5296
5724
|
case 5:
|
|
5297
|
-
return
|
|
5725
|
+
return _context45.abrupt("return", this.request.post('/order/batch-email', {
|
|
5298
5726
|
order_ids: orderIds,
|
|
5299
5727
|
notify_action: params.notify_action || 'order_payment_reminder',
|
|
5300
5728
|
emails: params.emails
|
|
5301
5729
|
}));
|
|
5302
5730
|
case 6:
|
|
5303
5731
|
case "end":
|
|
5304
|
-
return
|
|
5732
|
+
return _context45.stop();
|
|
5305
5733
|
}
|
|
5306
|
-
},
|
|
5734
|
+
}, _callee42, this);
|
|
5307
5735
|
}));
|
|
5308
|
-
function sendCustomerPayLink(
|
|
5736
|
+
function sendCustomerPayLink(_x49) {
|
|
5309
5737
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
5310
5738
|
}
|
|
5311
5739
|
return sendCustomerPayLink;
|
|
@@ -5313,14 +5741,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5313
5741
|
}, {
|
|
5314
5742
|
key: "getSalesOrderByLookup",
|
|
5315
5743
|
value: function () {
|
|
5316
|
-
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5744
|
+
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
|
|
5317
5745
|
var lookup, res;
|
|
5318
|
-
return _regeneratorRuntime().wrap(function
|
|
5319
|
-
while (1) switch (
|
|
5746
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context46) {
|
|
5747
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
5320
5748
|
case 0:
|
|
5321
5749
|
lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
|
|
5322
5750
|
if (lookup) {
|
|
5323
|
-
|
|
5751
|
+
_context46.next = 3;
|
|
5324
5752
|
break;
|
|
5325
5753
|
}
|
|
5326
5754
|
throw new Error('加载销售详情需要 lookup');
|
|
@@ -5329,7 +5757,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5329
5757
|
if (lookup.startsWith('LOCAL_')) {
|
|
5330
5758
|
params.forceRemote = false;
|
|
5331
5759
|
}
|
|
5332
|
-
|
|
5760
|
+
_context46.next = 6;
|
|
5333
5761
|
return this.request.get("/order/sales/".concat(encodeURIComponent(lookup)), _objectSpread({
|
|
5334
5762
|
with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info']
|
|
5335
5763
|
}, params.forceRemote ? {
|
|
@@ -5338,18 +5766,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5338
5766
|
osServer: true
|
|
5339
5767
|
});
|
|
5340
5768
|
case 6:
|
|
5341
|
-
res =
|
|
5769
|
+
res = _context46.sent;
|
|
5342
5770
|
if (res.code === 200) {
|
|
5343
5771
|
this.store.lastOrderInfo = res.data;
|
|
5344
5772
|
}
|
|
5345
|
-
return
|
|
5773
|
+
return _context46.abrupt("return", res);
|
|
5346
5774
|
case 9:
|
|
5347
5775
|
case "end":
|
|
5348
|
-
return
|
|
5776
|
+
return _context46.stop();
|
|
5349
5777
|
}
|
|
5350
|
-
},
|
|
5778
|
+
}, _callee43, this);
|
|
5351
5779
|
}));
|
|
5352
|
-
function getSalesOrderByLookup(
|
|
5780
|
+
function getSalesOrderByLookup(_x50) {
|
|
5353
5781
|
return _getSalesOrderByLookup.apply(this, arguments);
|
|
5354
5782
|
}
|
|
5355
5783
|
return getSalesOrderByLookup;
|
|
@@ -5363,14 +5791,42 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5363
5791
|
}, {
|
|
5364
5792
|
key: "hydrateTempOrderFromRecord",
|
|
5365
5793
|
value: (function () {
|
|
5366
|
-
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5367
|
-
var _this$store$
|
|
5368
|
-
var raw, nextTempOrder, rawSummary, summarySurcharges, hydratedEditDiscounts, currentDiscounts, shouldSkipEmptyDiscountSync, _this$store$
|
|
5369
|
-
return _regeneratorRuntime().wrap(function
|
|
5370
|
-
while (1) switch (
|
|
5794
|
+
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(record, options) {
|
|
5795
|
+
var _this$store$discount19;
|
|
5796
|
+
var sourceRaw, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, nextTempOrder, sourceLastOrderInfo, isDraftOrder, syntheticIdentityOptions, rawSummary, summarySurcharges, hadSyntheticDraftOrderId, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount20, _this$store$discount21;
|
|
5797
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context47) {
|
|
5798
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
5371
5799
|
case 0:
|
|
5372
|
-
|
|
5373
|
-
|
|
5800
|
+
sourceRaw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
|
|
5801
|
+
identityReadySource = this.seedAnonymousBookingUidsFromProducts(sourceRaw);
|
|
5802
|
+
normalizedCollections = normalizeOrderCollections(identityReadySource);
|
|
5803
|
+
raw = normalizedCollections.order;
|
|
5804
|
+
hasIdentityChanges = Object.values(normalizedCollections.stats).some(function (stats) {
|
|
5805
|
+
return stats.backfilledUidCount > 0 || stats.collapsedDuplicateCount > 0 || stats.uidConflictCount > 0 || stats.anonymousRowCount > 0;
|
|
5806
|
+
});
|
|
5807
|
+
if (hasIdentityChanges) {
|
|
5808
|
+
identityLogMetadata = {
|
|
5809
|
+
collections: normalizedCollections.stats,
|
|
5810
|
+
uidRemapCount: normalizedCollections.uidRemaps.length
|
|
5811
|
+
};
|
|
5812
|
+
hasIdentityWarnings = Object.values(normalizedCollections.stats).some(function (stats) {
|
|
5813
|
+
return stats.uidConflictCount > 0 || stats.anonymousRowCount > 0;
|
|
5814
|
+
});
|
|
5815
|
+
if (hasIdentityWarnings) {
|
|
5816
|
+
this.logWarning('Normalized hydrated order collection identities', identityLogMetadata);
|
|
5817
|
+
} else {
|
|
5818
|
+
this.logInfo('Normalized hydrated order collection identities', identityLogMetadata);
|
|
5819
|
+
}
|
|
5820
|
+
}
|
|
5821
|
+
nextTempOrder = this.normalizeTempOrderForRuntime(raw, {
|
|
5822
|
+
makeEditMark: true
|
|
5823
|
+
}); // Server list compatibility may synthesize order_id from external_sale_number; tempOrder must not.
|
|
5824
|
+
sourceLastOrderInfo = raw.lastOrderInfo || raw;
|
|
5825
|
+
isDraftOrder = Number(nextTempOrder.is_draft_order || 0) === 1;
|
|
5826
|
+
syntheticIdentityOptions = {
|
|
5827
|
+
isDraftOrder: isDraftOrder,
|
|
5828
|
+
externalSaleNumber: nextTempOrder.external_sale_number
|
|
5829
|
+
};
|
|
5374
5830
|
rawSummary = raw.summary && _typeof(raw.summary) === 'object' ? raw.summary : {};
|
|
5375
5831
|
summarySurcharges = Array.isArray(rawSummary.surcharges) ? rawSummary.surcharges.map(function (s) {
|
|
5376
5832
|
return _objectSpread({}, s || {});
|
|
@@ -5383,45 +5839,60 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5383
5839
|
originalSalesSnapshot: {
|
|
5384
5840
|
summary: cloneDeep(this.store.summary),
|
|
5385
5841
|
products: cloneDeep(nextTempOrder.products || []),
|
|
5842
|
+
bookings: cloneDeep(nextTempOrder.bookings || []),
|
|
5386
5843
|
payments: cloneDeep(nextTempOrder.payments || []),
|
|
5387
5844
|
surcharges: cloneDeep(nextTempOrder.surcharges || []),
|
|
5388
5845
|
shop_discount: nextTempOrder.shop_discount || '0.00',
|
|
5389
5846
|
productFingerprint: this.buildOrderProductsFingerprint(nextTempOrder.products || [])
|
|
5390
5847
|
}
|
|
5391
5848
|
});
|
|
5392
|
-
this.store.lastOrderInfo =
|
|
5849
|
+
this.store.lastOrderInfo = this.withoutSyntheticDraftOrderIdForRuntime(sourceLastOrderInfo, syntheticIdentityOptions);
|
|
5850
|
+
hadSyntheticDraftOrderId = this.isSyntheticDraftOrderIdForRuntime(raw, syntheticIdentityOptions) || this.isSyntheticDraftOrderIdForRuntime(sourceLastOrderInfo, syntheticIdentityOptions);
|
|
5851
|
+
if (hadSyntheticDraftOrderId && this.store.syncState !== 'submitting') {
|
|
5852
|
+
this.store.syncState = 'local';
|
|
5853
|
+
}
|
|
5393
5854
|
hydratedEditDiscounts = this.collectHydratedEditDiscounts(nextTempOrder.products);
|
|
5394
|
-
currentDiscounts = typeof ((_this$store$
|
|
5395
|
-
|
|
5855
|
+
currentDiscounts = typeof ((_this$store$discount19 = this.store.discount) === null || _this$store$discount19 === void 0 ? void 0 : _this$store$discount19.getDiscountList) === 'function' ? this.store.discount.getDiscountList() || [] : [];
|
|
5856
|
+
currentScanDiscounts = currentDiscounts.filter(function (discount) {
|
|
5857
|
+
return discount === null || discount === void 0 ? void 0 : discount.isScan;
|
|
5858
|
+
});
|
|
5859
|
+
hydratedDiscountIds = new Set(hydratedEditDiscounts.map(function (discount) {
|
|
5860
|
+
return discount === null || discount === void 0 ? void 0 : discount.id;
|
|
5861
|
+
}));
|
|
5862
|
+
retainedScanDiscounts = currentScanDiscounts.filter(function (discount) {
|
|
5863
|
+
return !hydratedDiscountIds.has(discount === null || discount === void 0 ? void 0 : discount.id);
|
|
5864
|
+
});
|
|
5865
|
+
nextDiscounts = [].concat(_toConsumableArray(hydratedEditDiscounts), _toConsumableArray(retainedScanDiscounts));
|
|
5866
|
+
shouldSkipEmptyDiscountSync = nextDiscounts.length === 0 && currentDiscounts.length === 0;
|
|
5396
5867
|
if (shouldSkipEmptyDiscountSync) {
|
|
5397
|
-
|
|
5868
|
+
_context47.next = 31;
|
|
5398
5869
|
break;
|
|
5399
5870
|
}
|
|
5400
|
-
OrderModule.populateSavedAmounts(nextTempOrder.products,
|
|
5401
|
-
|
|
5402
|
-
return (_this$store$
|
|
5403
|
-
case
|
|
5404
|
-
|
|
5405
|
-
return (_this$store$
|
|
5406
|
-
case
|
|
5871
|
+
OrderModule.populateSavedAmounts(nextTempOrder.products, nextDiscounts);
|
|
5872
|
+
_context47.next = 29;
|
|
5873
|
+
return (_this$store$discount20 = this.store.discount) === null || _this$store$discount20 === void 0 ? void 0 : _this$store$discount20.setOriginalDiscountList(nextDiscounts);
|
|
5874
|
+
case 29:
|
|
5875
|
+
_context47.next = 31;
|
|
5876
|
+
return (_this$store$discount21 = this.store.discount) === null || _this$store$discount21 === void 0 ? void 0 : _this$store$discount21.setDiscountList(nextDiscounts);
|
|
5877
|
+
case 31:
|
|
5407
5878
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
5408
|
-
|
|
5879
|
+
_context47.next = 34;
|
|
5409
5880
|
break;
|
|
5410
5881
|
}
|
|
5411
|
-
|
|
5882
|
+
_context47.next = 34;
|
|
5412
5883
|
return this.recalculateSummary({
|
|
5413
5884
|
createIfMissing: false
|
|
5414
5885
|
});
|
|
5415
|
-
case
|
|
5886
|
+
case 34:
|
|
5416
5887
|
this.persistTempOrder();
|
|
5417
|
-
return
|
|
5418
|
-
case
|
|
5888
|
+
return _context47.abrupt("return", nextTempOrder);
|
|
5889
|
+
case 36:
|
|
5419
5890
|
case "end":
|
|
5420
|
-
return
|
|
5891
|
+
return _context47.stop();
|
|
5421
5892
|
}
|
|
5422
|
-
},
|
|
5893
|
+
}, _callee44, this);
|
|
5423
5894
|
}));
|
|
5424
|
-
function hydrateTempOrderFromRecord(
|
|
5895
|
+
function hydrateTempOrderFromRecord(_x51, _x52) {
|
|
5425
5896
|
return _hydrateTempOrderFromRecord.apply(this, arguments);
|
|
5426
5897
|
}
|
|
5427
5898
|
return hydrateTempOrderFromRecord;
|
|
@@ -5459,14 +5930,88 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5459
5930
|
}
|
|
5460
5931
|
return next;
|
|
5461
5932
|
}
|
|
5933
|
+
|
|
5934
|
+
/**
|
|
5935
|
+
* 匿名 booking 没有服务端行 ID 时,商品侧已有的 booking_uid 就是唯一可用的强引用。
|
|
5936
|
+
* 在统一规范化生成 UUID 前先复用它;已落库 booking 仍按 schedule_event_id 派生稳定 UID。
|
|
5937
|
+
*/
|
|
5938
|
+
}, {
|
|
5939
|
+
key: "seedAnonymousBookingUidsFromProducts",
|
|
5940
|
+
value: function seedAnonymousBookingUidsFromProducts(raw) {
|
|
5941
|
+
if (!raw || _typeof(raw) !== 'object') return {};
|
|
5942
|
+
if (!Array.isArray(raw.bookings) || !Array.isArray(raw.products)) return raw;
|
|
5943
|
+
var bookingUidsByProductUid = new Map();
|
|
5944
|
+
var _iterator22 = _createForOfIteratorHelper(raw.products),
|
|
5945
|
+
_step22;
|
|
5946
|
+
try {
|
|
5947
|
+
for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
|
|
5948
|
+
var _product$metadata10;
|
|
5949
|
+
var product = _step22.value;
|
|
5950
|
+
var productUid = getOrderCollectionUid('product', product);
|
|
5951
|
+
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);
|
|
5952
|
+
if (!productUid || bookingUid === undefined || bookingUid === null || bookingUid === '') {
|
|
5953
|
+
continue;
|
|
5954
|
+
}
|
|
5955
|
+
var candidates = bookingUidsByProductUid.get(productUid) || new Set();
|
|
5956
|
+
candidates.add(String(bookingUid));
|
|
5957
|
+
bookingUidsByProductUid.set(productUid, candidates);
|
|
5958
|
+
}
|
|
5959
|
+
} catch (err) {
|
|
5960
|
+
_iterator22.e(err);
|
|
5961
|
+
} finally {
|
|
5962
|
+
_iterator22.f();
|
|
5963
|
+
}
|
|
5964
|
+
if (bookingUidsByProductUid.size === 0) return raw;
|
|
5965
|
+
var anonymousBookingCountByProductUid = new Map();
|
|
5966
|
+
var _iterator23 = _createForOfIteratorHelper(raw.bookings),
|
|
5967
|
+
_step23;
|
|
5968
|
+
try {
|
|
5969
|
+
for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {
|
|
5970
|
+
var _booking$metadata7;
|
|
5971
|
+
var booking = _step23.value;
|
|
5972
|
+
if (getOrderCollectionPersistentId('booking', booking) || getOrderCollectionUid('booking', booking)) {
|
|
5973
|
+
continue;
|
|
5974
|
+
}
|
|
5975
|
+
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);
|
|
5976
|
+
if (_productUid === undefined || _productUid === null || _productUid === '') continue;
|
|
5977
|
+
var key = String(_productUid);
|
|
5978
|
+
anonymousBookingCountByProductUid.set(key, (anonymousBookingCountByProductUid.get(key) || 0) + 1);
|
|
5979
|
+
}
|
|
5980
|
+
} catch (err) {
|
|
5981
|
+
_iterator23.e(err);
|
|
5982
|
+
} finally {
|
|
5983
|
+
_iterator23.f();
|
|
5984
|
+
}
|
|
5985
|
+
return _objectSpread(_objectSpread({}, raw), {}, {
|
|
5986
|
+
bookings: raw.bookings.map(function (booking) {
|
|
5987
|
+
var _booking$metadata6;
|
|
5988
|
+
if (getOrderCollectionPersistentId('booking', booking) || getOrderCollectionUid('booking', booking)) {
|
|
5989
|
+
return booking;
|
|
5990
|
+
}
|
|
5991
|
+
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);
|
|
5992
|
+
if (productUid === undefined || productUid === null || productUid === '') {
|
|
5993
|
+
return booking;
|
|
5994
|
+
}
|
|
5995
|
+
var productUidKey = String(productUid);
|
|
5996
|
+
// 多条匿名 booking 共用同一商品引用时身份仍然不明确,不能借商品字段猜测合并。
|
|
5997
|
+
if (anonymousBookingCountByProductUid.get(productUidKey) !== 1) {
|
|
5998
|
+
return booking;
|
|
5999
|
+
}
|
|
6000
|
+
var bookingUidCandidates = bookingUidsByProductUid.get(productUidKey);
|
|
6001
|
+
var bookingUid = (bookingUidCandidates === null || bookingUidCandidates === void 0 ? void 0 : bookingUidCandidates.size) === 1 ? _toConsumableArray(bookingUidCandidates)[0] : null;
|
|
6002
|
+
return bookingUid ? setOrderCollectionUid('booking', booking, bookingUid) : booking;
|
|
6003
|
+
})
|
|
6004
|
+
});
|
|
6005
|
+
}
|
|
5462
6006
|
}, {
|
|
5463
6007
|
key: "normalizeTempOrderForRuntime",
|
|
5464
6008
|
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
5465
|
-
var
|
|
5466
|
-
var
|
|
6009
|
+
var _this32 = this;
|
|
6010
|
+
var runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
|
|
6011
|
+
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
|
|
5467
6012
|
// ES 列表详情使用 id 表示订单主键;OS 详情态统一依赖 order_id 驱动操作按钮。
|
|
5468
|
-
if ((nextTempOrder.order_id === undefined || nextTempOrder.order_id === null) && (
|
|
5469
|
-
nextTempOrder.order_id =
|
|
6013
|
+
if ((nextTempOrder.order_id === undefined || nextTempOrder.order_id === null) && (runtimeRaw === null || runtimeRaw === void 0 ? void 0 : runtimeRaw.id) !== undefined && (runtimeRaw === null || runtimeRaw === void 0 ? void 0 : runtimeRaw.id) !== null) {
|
|
6014
|
+
nextTempOrder.order_id = runtimeRaw.id;
|
|
5470
6015
|
}
|
|
5471
6016
|
delete nextTempOrder.summary;
|
|
5472
6017
|
delete nextTempOrder.lastOrderInfo;
|
|
@@ -5485,10 +6030,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5485
6030
|
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
5486
6031
|
var rawProducts = Array.isArray(raw.products) ? raw.products : [];
|
|
5487
6032
|
nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
|
|
5488
|
-
return
|
|
6033
|
+
return _this32.normalizeHydratedOrderProduct(p, {
|
|
6034
|
+
makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
|
|
6035
|
+
});
|
|
5489
6036
|
}) : [];
|
|
5490
6037
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
5491
|
-
var booking =
|
|
6038
|
+
var booking = _this32.normalizeHydratedBookingHolder(b || {});
|
|
5492
6039
|
return _objectSpread(_objectSpread({}, booking), {}, {
|
|
5493
6040
|
is_all: normalizeBookingIsAll(booking),
|
|
5494
6041
|
sub_type: normalizeBookingSubType(booking)
|
|
@@ -5514,19 +6061,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5514
6061
|
};
|
|
5515
6062
|
var tempOrderExtend = nextTempOrder._extend;
|
|
5516
6063
|
var productsByUid = tempOrderExtend.productsByUid || {};
|
|
5517
|
-
var
|
|
5518
|
-
|
|
6064
|
+
var _iterator24 = _createForOfIteratorHelper(nextTempOrder.products.entries()),
|
|
6065
|
+
_step24;
|
|
5519
6066
|
try {
|
|
5520
|
-
for (
|
|
5521
|
-
var _product$
|
|
5522
|
-
var
|
|
5523
|
-
index =
|
|
5524
|
-
product =
|
|
5525
|
-
var uid = (_product$
|
|
6067
|
+
for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
|
|
6068
|
+
var _product$metadata11, _ref77, _ref78, _existed$origin, _rawProduct$metadata;
|
|
6069
|
+
var _step24$value = _slicedToArray(_step24.value, 2),
|
|
6070
|
+
index = _step24$value[0],
|
|
6071
|
+
product = _step24$value[1];
|
|
6072
|
+
var uid = (_product$metadata11 = product.metadata) === null || _product$metadata11 === void 0 ? void 0 : _product$metadata11.unique_identification_number;
|
|
5526
6073
|
if (!uid) continue;
|
|
5527
6074
|
var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
|
|
5528
6075
|
var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
|
|
5529
|
-
var origin = (
|
|
6076
|
+
var origin = (_ref77 = (_ref78 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref78 !== void 0 ? _ref78 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref77 !== void 0 ? _ref77 : rawProduct;
|
|
5530
6077
|
var originSnapshot = cloneDeep(origin);
|
|
5531
6078
|
var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
|
|
5532
6079
|
if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
|
|
@@ -5542,9 +6089,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5542
6089
|
});
|
|
5543
6090
|
}
|
|
5544
6091
|
} catch (err) {
|
|
5545
|
-
|
|
6092
|
+
_iterator24.e(err);
|
|
5546
6093
|
} finally {
|
|
5547
|
-
|
|
6094
|
+
_iterator24.f();
|
|
5548
6095
|
}
|
|
5549
6096
|
tempOrderExtend.productsByUid = productsByUid;
|
|
5550
6097
|
this.hydrateLinkedBookingIdentity(nextTempOrder);
|
|
@@ -5554,14 +6101,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5554
6101
|
nextTempOrder.vouchers = raw.vouchers || [];
|
|
5555
6102
|
return nextTempOrder;
|
|
5556
6103
|
}
|
|
6104
|
+
}, {
|
|
6105
|
+
key: "isSyntheticDraftOrderIdForRuntime",
|
|
6106
|
+
value: function isSyntheticDraftOrderIdForRuntime(record, options) {
|
|
6107
|
+
var _options$isDraftOrder, _record$external_sale;
|
|
6108
|
+
var isDraftOrder = (_options$isDraftOrder = options === null || options === void 0 ? void 0 : options.isDraftOrder) !== null && _options$isDraftOrder !== void 0 ? _options$isDraftOrder : Number((record === null || record === void 0 ? void 0 : record.is_draft_order) || 0) === 1;
|
|
6109
|
+
var externalSaleNumber = (_record$external_sale = record === null || record === void 0 ? void 0 : record.external_sale_number) !== null && _record$external_sale !== void 0 ? _record$external_sale : options === null || options === void 0 ? void 0 : options.externalSaleNumber;
|
|
6110
|
+
var orderId = record === null || record === void 0 ? void 0 : record.order_id;
|
|
6111
|
+
return Boolean(isDraftOrder && orderId !== undefined && orderId !== null && orderId !== '' && externalSaleNumber !== undefined && externalSaleNumber !== null && externalSaleNumber !== '' && String(orderId) === String(externalSaleNumber));
|
|
6112
|
+
}
|
|
6113
|
+
}, {
|
|
6114
|
+
key: "withoutSyntheticDraftOrderIdForRuntime",
|
|
6115
|
+
value: function withoutSyntheticDraftOrderIdForRuntime(record, options) {
|
|
6116
|
+
if (!this.isSyntheticDraftOrderIdForRuntime(record, options)) return record;
|
|
6117
|
+
return _objectSpread(_objectSpread({}, record), {}, {
|
|
6118
|
+
order_id: null
|
|
6119
|
+
});
|
|
6120
|
+
}
|
|
5557
6121
|
}, {
|
|
5558
6122
|
key: "hydrateLinkedBookingIdentity",
|
|
5559
6123
|
value: function hydrateLinkedBookingIdentity(tempOrder) {
|
|
5560
6124
|
var bookingUidByProductUid = new Map();
|
|
5561
6125
|
var productByUid = new Map();
|
|
5562
6126
|
(tempOrder.products || []).forEach(function (product) {
|
|
5563
|
-
var _product$
|
|
5564
|
-
var productUid = (product === null || product === void 0 || (_product$
|
|
6127
|
+
var _product$metadata12;
|
|
6128
|
+
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);
|
|
5565
6129
|
if (productUid !== undefined && productUid !== null && String(productUid) !== '') {
|
|
5566
6130
|
productByUid.set(String(productUid), product);
|
|
5567
6131
|
}
|
|
@@ -5582,15 +6146,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5582
6146
|
bookingUidByProductUid.set(String(productUid), bookingUid);
|
|
5583
6147
|
});
|
|
5584
6148
|
(tempOrder.products || []).forEach(function (product) {
|
|
5585
|
-
var _product$
|
|
5586
|
-
var productUid = (product === null || product === void 0 || (_product$
|
|
6149
|
+
var _product$metadata13;
|
|
6150
|
+
var productUid = (product === null || product === void 0 || (_product$metadata13 = product.metadata) === null || _product$metadata13 === void 0 ? void 0 : _product$metadata13.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
5587
6151
|
if (productUid === undefined || productUid === null || String(productUid) === '') return;
|
|
5588
6152
|
var bookingUid = bookingUidByProductUid.get(String(productUid));
|
|
5589
6153
|
if (!bookingUid) return;
|
|
5590
6154
|
if (!product.metadata || _typeof(product.metadata) !== 'object') {
|
|
5591
6155
|
product.metadata = {};
|
|
5592
6156
|
}
|
|
5593
|
-
|
|
6157
|
+
// booking 已经过统一身份规范化;以它为准同步商品侧旧引用,避免两侧 UID 断链。
|
|
6158
|
+
var linkedBookingUid = String(bookingUid);
|
|
5594
6159
|
product.booking_uid = linkedBookingUid;
|
|
5595
6160
|
product.metadata.booking_uid = linkedBookingUid;
|
|
5596
6161
|
});
|
|
@@ -5618,18 +6183,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5618
6183
|
var segments = [];
|
|
5619
6184
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
5620
6185
|
if (Array.isArray(sku.variant)) {
|
|
5621
|
-
var
|
|
5622
|
-
|
|
6186
|
+
var _iterator25 = _createForOfIteratorHelper(sku.variant),
|
|
6187
|
+
_step25;
|
|
5623
6188
|
try {
|
|
5624
|
-
for (
|
|
5625
|
-
var variant =
|
|
6189
|
+
for (_iterator25.s(); !(_step25 = _iterator25.n()).done;) {
|
|
6190
|
+
var variant = _step25.value;
|
|
5626
6191
|
var segment = this.formatHydratedNamePair(variant === null || variant === void 0 ? void 0 : variant.group, variant === null || variant === void 0 ? void 0 : variant.item);
|
|
5627
6192
|
if (segment) segments.push(segment);
|
|
5628
6193
|
}
|
|
5629
6194
|
} catch (err) {
|
|
5630
|
-
|
|
6195
|
+
_iterator25.e(err);
|
|
5631
6196
|
} finally {
|
|
5632
|
-
|
|
6197
|
+
_iterator25.f();
|
|
5633
6198
|
}
|
|
5634
6199
|
}
|
|
5635
6200
|
return segments.join(', ');
|
|
@@ -5637,10 +6202,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5637
6202
|
}, {
|
|
5638
6203
|
key: "normalizeHydratedProductOptionItem",
|
|
5639
6204
|
value: function normalizeHydratedProductOptionItem(optionItem) {
|
|
5640
|
-
var
|
|
5641
|
-
var rawNum = (
|
|
6205
|
+
var _ref79, _optionItem$num, _ref80, _optionItem$add_price;
|
|
6206
|
+
var rawNum = (_ref79 = (_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 && _ref79 !== void 0 ? _ref79 : 1;
|
|
5642
6207
|
var parsedNum = Number(rawNum);
|
|
5643
|
-
var rawPrice = (
|
|
6208
|
+
var rawPrice = (_ref80 = (_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 && _ref80 !== void 0 ? _ref80 : 0;
|
|
5644
6209
|
var parsedPrice = Number(rawPrice);
|
|
5645
6210
|
var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
|
|
5646
6211
|
option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
|
|
@@ -5656,8 +6221,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5656
6221
|
}
|
|
5657
6222
|
}, {
|
|
5658
6223
|
key: "normalizeHydratedOrderProduct",
|
|
5659
|
-
value: function normalizeHydratedOrderProduct(product) {
|
|
5660
|
-
var
|
|
6224
|
+
value: function normalizeHydratedOrderProduct(product, options) {
|
|
6225
|
+
var _this33 = this;
|
|
5661
6226
|
var row = _objectSpread({}, product || {});
|
|
5662
6227
|
if (row.num === undefined && row.product_quantity !== undefined) {
|
|
5663
6228
|
row.num = row.product_quantity;
|
|
@@ -5665,7 +6230,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5665
6230
|
var productSku = ensureProductSku(row);
|
|
5666
6231
|
row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
|
|
5667
6232
|
option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
|
|
5668
|
-
return
|
|
6233
|
+
return _this33.normalizeHydratedProductOptionItem(optionItem || {});
|
|
5669
6234
|
}))
|
|
5670
6235
|
});
|
|
5671
6236
|
delete row["product_".concat('option', "_item")];
|
|
@@ -5679,6 +6244,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5679
6244
|
if (!existingIdentity) {
|
|
5680
6245
|
row.metadata.unique_identification_number = createUuidV4();
|
|
5681
6246
|
}
|
|
6247
|
+
// 从云端、本地数据库中获取到的商品数据,先打上 runtime 标记,提供给 UI 做 saved items.
|
|
6248
|
+
if (options !== null && options !== void 0 && options.makeEditMark) {
|
|
6249
|
+
row.metadata.is_edit_for_runtime = true;
|
|
6250
|
+
}
|
|
5682
6251
|
var normalized = normalizeOrderProduct(row);
|
|
5683
6252
|
normalized.discount_list = normalizeOrderProductDiscountList(normalized.discount_list);
|
|
5684
6253
|
var result = _objectSpread(_objectSpread(_objectSpread({}, row), normalized), {}, {
|
|
@@ -5698,27 +6267,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5698
6267
|
}, {
|
|
5699
6268
|
key: "getOrderInfo",
|
|
5700
6269
|
value: function () {
|
|
5701
|
-
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6270
|
+
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(order_id) {
|
|
5702
6271
|
var res;
|
|
5703
|
-
return _regeneratorRuntime().wrap(function
|
|
5704
|
-
while (1) switch (
|
|
6272
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context48) {
|
|
6273
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
5705
6274
|
case 0:
|
|
5706
|
-
|
|
6275
|
+
_context48.next = 2;
|
|
5707
6276
|
return this.request.get("/order/sales/".concat(order_id), {
|
|
5708
6277
|
with: ['products', 'bookings']
|
|
5709
6278
|
}, {
|
|
5710
6279
|
osServer: true
|
|
5711
6280
|
});
|
|
5712
6281
|
case 2:
|
|
5713
|
-
res =
|
|
5714
|
-
return
|
|
6282
|
+
res = _context48.sent;
|
|
6283
|
+
return _context48.abrupt("return", res);
|
|
5715
6284
|
case 4:
|
|
5716
6285
|
case "end":
|
|
5717
|
-
return
|
|
6286
|
+
return _context48.stop();
|
|
5718
6287
|
}
|
|
5719
|
-
},
|
|
6288
|
+
}, _callee45, this);
|
|
5720
6289
|
}));
|
|
5721
|
-
function getOrderInfo(
|
|
6290
|
+
function getOrderInfo(_x53) {
|
|
5722
6291
|
return _getOrderInfo.apply(this, arguments);
|
|
5723
6292
|
}
|
|
5724
6293
|
return getOrderInfo;
|
|
@@ -5754,70 +6323,70 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5754
6323
|
addDiscountAmount(savedMap, discountKey, amount);
|
|
5755
6324
|
addDiscountAmount(isPersistedProduct || discount.order_discount_id != null ? editModeSavedMap : runtimeSavedMap, discountKey, amount);
|
|
5756
6325
|
};
|
|
5757
|
-
var
|
|
5758
|
-
|
|
6326
|
+
var _iterator26 = _createForOfIteratorHelper(productList),
|
|
6327
|
+
_step26;
|
|
5759
6328
|
try {
|
|
5760
|
-
for (
|
|
5761
|
-
var product =
|
|
6329
|
+
for (_iterator26.s(); !(_step26 = _iterator26.n()).done;) {
|
|
6330
|
+
var product = _step26.value;
|
|
5762
6331
|
var qty = product.num || 1;
|
|
5763
6332
|
var isPersistedProduct = Boolean(product.order_detail_id || product.orderDetailId || product.booking_id);
|
|
5764
|
-
var
|
|
5765
|
-
|
|
6333
|
+
var _iterator28 = _createForOfIteratorHelper(product.discount_list || []),
|
|
6334
|
+
_step28;
|
|
5766
6335
|
try {
|
|
5767
|
-
for (
|
|
5768
|
-
var pd =
|
|
6336
|
+
for (_iterator28.s(); !(_step28 = _iterator28.n()).done;) {
|
|
6337
|
+
var pd = _step28.value;
|
|
5769
6338
|
addProductDiscountAmount(pd, qty, isPersistedProduct);
|
|
5770
6339
|
}
|
|
5771
6340
|
} catch (err) {
|
|
5772
|
-
|
|
6341
|
+
_iterator28.e(err);
|
|
5773
6342
|
} finally {
|
|
5774
|
-
|
|
6343
|
+
_iterator28.f();
|
|
5775
6344
|
}
|
|
5776
|
-
var
|
|
5777
|
-
|
|
6345
|
+
var _iterator29 = _createForOfIteratorHelper(product.product_bundle || []),
|
|
6346
|
+
_step29;
|
|
5778
6347
|
try {
|
|
5779
|
-
for (
|
|
5780
|
-
var
|
|
5781
|
-
var bundle =
|
|
6348
|
+
for (_iterator29.s(); !(_step29 = _iterator29.n()).done;) {
|
|
6349
|
+
var _ref81, _bundle$num3;
|
|
6350
|
+
var bundle = _step29.value;
|
|
5782
6351
|
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));
|
|
5783
|
-
var bundleQty = new Decimal(Number(qty) || 1).times(Number((
|
|
5784
|
-
var
|
|
5785
|
-
|
|
6352
|
+
var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref81 = (_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 && _ref81 !== void 0 ? _ref81 : 1) || 1).toNumber();
|
|
6353
|
+
var _iterator30 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
|
|
6354
|
+
_step30;
|
|
5786
6355
|
try {
|
|
5787
|
-
for (
|
|
5788
|
-
var _pd =
|
|
6356
|
+
for (_iterator30.s(); !(_step30 = _iterator30.n()).done;) {
|
|
6357
|
+
var _pd = _step30.value;
|
|
5789
6358
|
addProductDiscountAmount(_pd, bundleQty, isPersistedBundleProduct);
|
|
5790
6359
|
}
|
|
5791
6360
|
} catch (err) {
|
|
5792
|
-
|
|
6361
|
+
_iterator30.e(err);
|
|
5793
6362
|
} finally {
|
|
5794
|
-
|
|
6363
|
+
_iterator30.f();
|
|
5795
6364
|
}
|
|
5796
6365
|
}
|
|
5797
6366
|
} catch (err) {
|
|
5798
|
-
|
|
6367
|
+
_iterator29.e(err);
|
|
5799
6368
|
} finally {
|
|
5800
|
-
|
|
6369
|
+
_iterator29.f();
|
|
5801
6370
|
}
|
|
5802
6371
|
}
|
|
5803
6372
|
} catch (err) {
|
|
5804
|
-
|
|
6373
|
+
_iterator26.e(err);
|
|
5805
6374
|
} finally {
|
|
5806
|
-
|
|
6375
|
+
_iterator26.f();
|
|
5807
6376
|
}
|
|
5808
|
-
var
|
|
5809
|
-
|
|
6377
|
+
var _iterator27 = _createForOfIteratorHelper(discountList),
|
|
6378
|
+
_step27;
|
|
5810
6379
|
try {
|
|
5811
|
-
for (
|
|
5812
|
-
var d =
|
|
6380
|
+
for (_iterator27.s(); !(_step27 = _iterator27.n()).done;) {
|
|
6381
|
+
var d = _step27.value;
|
|
5813
6382
|
var key = d.id;
|
|
5814
6383
|
var sourceMap = d.isEditMode ? editModeSavedMap : editModeDiscountKeys.has(key) ? runtimeSavedMap : savedMap;
|
|
5815
6384
|
d.savedAmount = d.isSelected && key != null && sourceMap.has(key) ? sourceMap.get(key).toNumber() : 0;
|
|
5816
6385
|
}
|
|
5817
6386
|
} catch (err) {
|
|
5818
|
-
|
|
6387
|
+
_iterator27.e(err);
|
|
5819
6388
|
} finally {
|
|
5820
|
-
|
|
6389
|
+
_iterator27.f();
|
|
5821
6390
|
}
|
|
5822
6391
|
}
|
|
5823
6392
|
}]);
|