@pisell/pisellos 2.2.180 → 2.2.182
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/promotion/index.js +9 -0
- package/dist/modules/BookingContext/index.d.ts +37 -0
- package/dist/modules/BookingContext/index.js +436 -0
- package/dist/modules/BookingContext/types.d.ts +102 -0
- package/dist/modules/BookingContext/types.js +51 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +276 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +137 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +75 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +215 -0
- package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/dist/modules/BookingContext/utils/flexible.js +56 -0
- package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/dist/modules/BookingContext/utils/formatResourceList.js +38 -0
- package/dist/modules/BookingContext/utils/index.d.ts +11 -0
- package/dist/modules/BookingContext/utils/index.js +11 -0
- package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/dist/modules/BookingContext/utils/noResource.js +77 -0
- package/dist/modules/BookingContext/utils/productExtend.d.ts +72 -0
- package/dist/modules/BookingContext/utils/productExtend.js +339 -0
- package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/dist/modules/BookingContext/utils/resourceErrors.js +74 -0
- package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/dist/modules/BookingContext/utils/resourceSelection.js +24 -0
- package/dist/modules/BookingContext/utils/resources.d.ts +80 -0
- package/dist/modules/BookingContext/utils/resources.js +486 -0
- package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/dist/modules/BookingContext/utils/serviceTimes.js +151 -0
- package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/dist/modules/BookingContext/utils/timeSlices.js +100 -0
- package/dist/modules/Customer/index.d.ts +6 -0
- package/dist/modules/Customer/index.js +129 -83
- package/dist/modules/Customer/types.d.ts +2 -0
- package/dist/modules/Discount/index.js +4 -3
- package/dist/modules/Discount/types.d.ts +1 -0
- package/dist/modules/Order/index.d.ts +101 -10
- package/dist/modules/Order/index.js +1444 -490
- package/dist/modules/Order/types.d.ts +201 -18
- package/dist/modules/Order/types.js +31 -0
- package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/dist/modules/Order/utils/manualProductDiscount.js +210 -0
- package/dist/modules/Order/utils.d.ts +83 -1
- package/dist/modules/Order/utils.js +405 -61
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Quotation/index.d.ts +0 -1
- package/dist/modules/Quotation/index.js +23 -21
- package/dist/modules/Rules/index.d.ts +4 -0
- package/dist/modules/Rules/index.js +43 -39
- package/dist/modules/Rules/types.d.ts +1 -0
- package/dist/modules/SalesSummary/index.js +4 -2
- package/dist/modules/SalesSummary/utils.js +21 -7
- package/dist/modules/Schedule/index.js +6 -2
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +2 -1
- package/dist/server/index.js +87 -29
- package/dist/server/modules/order/index.d.ts +23 -0
- package/dist/server/modules/order/index.js +123 -46
- package/dist/server/modules/order/utils/filterOrders.js +20 -6
- package/dist/server/modules/products/index.d.ts +1 -1
- package/dist/server/modules/products/index.js +130 -113
- package/dist/server/modules/schedule/index.js +13 -6
- package/dist/solution/BaseSales/index.d.ts +89 -7
- package/dist/solution/BaseSales/index.js +1489 -366
- package/dist/solution/BaseSales/types.d.ts +67 -1
- package/dist/solution/BaseSales/types.js +3 -1
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +275 -0
- package/dist/solution/BaseSales/utils/cartPromotion.js +1258 -0
- package/dist/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
- package/dist/solution/BaseSales/utils/quotationPrice.js +237 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +68 -16
- package/dist/solution/BaseSales/utils.js +46 -8
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +152 -2
- package/dist/solution/BookingTicket/index.js +848 -184
- package/dist/solution/BookingTicket/types.d.ts +2 -0
- package/dist/solution/BookingTicket/types.js +3 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +113 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.js +346 -0
- package/dist/solution/BookingTicket/utils/cartView.js +4 -2
- package/dist/solution/ScanOrder/index.d.ts +9 -3
- package/dist/solution/ScanOrder/index.js +231 -128
- package/dist/solution/ScanOrder/utils.js +46 -8
- package/dist/solution/VenueBooking/index.d.ts +5 -2
- package/dist/solution/VenueBooking/index.js +103 -55
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +10 -0
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/BookingContext/index.d.ts +37 -0
- package/lib/modules/BookingContext/index.js +297 -0
- package/lib/modules/BookingContext/types.d.ts +102 -0
- package/lib/modules/BookingContext/types.js +34 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +271 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +141 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +75 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +198 -0
- package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/lib/modules/BookingContext/utils/flexible.js +80 -0
- package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/lib/modules/BookingContext/utils/formatResourceList.js +50 -0
- package/lib/modules/BookingContext/utils/index.d.ts +11 -0
- package/lib/modules/BookingContext/utils/index.js +43 -0
- package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/lib/modules/BookingContext/utils/noResource.js +90 -0
- package/lib/modules/BookingContext/utils/productExtend.d.ts +72 -0
- package/lib/modules/BookingContext/utils/productExtend.js +283 -0
- package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/lib/modules/BookingContext/utils/resourceErrors.js +80 -0
- package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/lib/modules/BookingContext/utils/resourceSelection.js +46 -0
- package/lib/modules/BookingContext/utils/resources.d.ts +80 -0
- package/lib/modules/BookingContext/utils/resources.js +377 -0
- package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/lib/modules/BookingContext/utils/serviceTimes.js +162 -0
- package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/lib/modules/BookingContext/utils/timeSlices.js +124 -0
- package/lib/modules/Customer/index.d.ts +6 -0
- package/lib/modules/Customer/index.js +26 -11
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Discount/index.js +5 -1
- package/lib/modules/Discount/types.d.ts +1 -0
- package/lib/modules/Order/index.d.ts +101 -10
- package/lib/modules/Order/index.js +751 -114
- package/lib/modules/Order/types.d.ts +201 -18
- package/lib/modules/Order/types.js +1 -0
- package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/lib/modules/Order/utils/manualProductDiscount.js +206 -0
- package/lib/modules/Order/utils.d.ts +83 -1
- package/lib/modules/Order/utils.js +340 -22
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Quotation/index.d.ts +0 -1
- package/lib/modules/Quotation/index.js +18 -15
- package/lib/modules/Rules/index.d.ts +4 -0
- package/lib/modules/Rules/index.js +26 -27
- package/lib/modules/Rules/types.d.ts +1 -0
- package/lib/modules/SalesSummary/index.js +4 -2
- package/lib/modules/SalesSummary/utils.js +21 -7
- package/lib/modules/Schedule/index.js +3 -1
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +3 -1
- package/lib/server/index.js +41 -4
- package/lib/server/modules/order/index.d.ts +23 -0
- package/lib/server/modules/order/index.js +46 -14
- package/lib/server/modules/order/utils/filterOrders.js +12 -4
- package/lib/server/modules/products/index.d.ts +1 -1
- package/lib/server/modules/products/index.js +30 -20
- package/lib/server/modules/schedule/index.js +2 -1
- package/lib/solution/BaseSales/index.d.ts +89 -7
- package/lib/solution/BaseSales/index.js +742 -23
- package/lib/solution/BaseSales/types.d.ts +67 -1
- package/lib/solution/BaseSales/types.js +3 -1
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +275 -0
- package/lib/solution/BaseSales/utils/cartPromotion.js +836 -0
- package/lib/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
- package/lib/solution/BaseSales/utils/quotationPrice.js +277 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +71 -12
- package/lib/solution/BaseSales/utils.js +46 -6
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +152 -2
- package/lib/solution/BookingTicket/index.js +389 -9
- package/lib/solution/BookingTicket/types.d.ts +2 -0
- package/lib/solution/BookingTicket/types.js +6 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +113 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.js +318 -0
- package/lib/solution/BookingTicket/utils/cartView.js +4 -2
- package/lib/solution/ScanOrder/index.d.ts +9 -3
- package/lib/solution/ScanOrder/index.js +147 -66
- package/lib/solution/ScanOrder/utils.js +46 -6
- package/lib/solution/VenueBooking/index.d.ts +5 -2
- package/lib/solution/VenueBooking/index.js +50 -14
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +10 -0
- package/package.json +1 -1
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
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; } } }; }
|
|
2
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
|
+
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."); }
|
|
2
4
|
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); }
|
|
5
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
3
7
|
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; }
|
|
4
8
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
5
|
-
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; }
|
|
6
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; }
|
|
7
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
|
+
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; }
|
|
8
12
|
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); } }
|
|
9
13
|
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); }); }; }
|
|
10
14
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
@@ -23,13 +27,16 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
23
27
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
24
28
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
25
29
|
import { BaseModule } from "../../modules/BaseModule";
|
|
30
|
+
import { BaseSalesHookNames } from "./types";
|
|
26
31
|
import { OrderModule } from "../../modules/Order";
|
|
27
32
|
import Decimal from 'decimal.js';
|
|
28
33
|
import { createModule } from "../BookingByStep/types";
|
|
29
|
-
import { composeLinePrice, sumOptionUnitPrice } from "../../modules/Order/utils";
|
|
34
|
+
import { composeLinePrice, createUuidV4, sumOptionUnitPrice } from "../../modules/Order/utils";
|
|
30
35
|
import dayjs from 'dayjs';
|
|
31
36
|
export * from "./types";
|
|
37
|
+
import { QuotationModule } from "../../modules/Quotation";
|
|
32
38
|
import { transformBaseProductToOrderProduct as _transformBaseProductToOrderProduct } from "./utils/transformBaseProductToOrderProduct";
|
|
39
|
+
import { calculateBaseSalesProductBookingPrice } from "./utils/quotationPrice";
|
|
33
40
|
export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
34
41
|
_inherits(BaseSalesImpl, _BaseModule);
|
|
35
42
|
var _super = _createSuper(BaseSalesImpl);
|
|
@@ -43,6 +50,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
43
50
|
_defineProperty(_assertThisInitialized(_this), "initializeOptions", {});
|
|
44
51
|
_defineProperty(_assertThisInitialized(_this), "logger", void 0);
|
|
45
52
|
// LoggerManager 实例
|
|
53
|
+
_defineProperty(_assertThisInitialized(_this), "appPlugin", void 0);
|
|
46
54
|
_defineProperty(_assertThisInitialized(_this), "store", {
|
|
47
55
|
order: undefined
|
|
48
56
|
});
|
|
@@ -56,17 +64,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
56
64
|
_defineProperty(_assertThisInitialized(_this), "request", void 0);
|
|
57
65
|
// 当前缓存中已加载的最新 SalesDetail;只读 getter 走它对外暴露详情数据。
|
|
58
66
|
_defineProperty(_assertThisInitialized(_this), "currentSalesDetail", null);
|
|
67
|
+
_defineProperty(_assertThisInitialized(_this), "discountConfigCacheKey", null);
|
|
68
|
+
_defineProperty(_assertThisInitialized(_this), "hasManualDiscountSelection", false);
|
|
59
69
|
return _this;
|
|
60
70
|
}
|
|
61
71
|
|
|
62
72
|
/**
|
|
63
73
|
* 子类可覆盖此方法以追加/收敛要注册的子模块。
|
|
64
|
-
* 默认包含通用销售模块:products / order / salesSummary / schedule / payment。
|
|
74
|
+
* 默认包含通用销售模块:products / order / salesSummary / schedule / payment / quotation。
|
|
65
75
|
*/
|
|
66
76
|
_createClass(BaseSalesImpl, [{
|
|
67
77
|
key: "getRegisteredModuleNames",
|
|
68
78
|
value: function getRegisteredModuleNames() {
|
|
69
|
-
return ['products', 'order', 'salesSummary', 'schedule', 'payment'];
|
|
79
|
+
return ['products', 'order', 'salesSummary', 'schedule', 'payment', 'quotation'];
|
|
70
80
|
}
|
|
71
81
|
|
|
72
82
|
/**
|
|
@@ -121,6 +131,251 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
121
131
|
get: function get() {
|
|
122
132
|
return this.store.payment;
|
|
123
133
|
}
|
|
134
|
+
}, {
|
|
135
|
+
key: "getCurrentOrderCustomerId",
|
|
136
|
+
value: function getCurrentOrderCustomerId() {
|
|
137
|
+
var _this$store$order, _this$store$order$get;
|
|
138
|
+
var tempOrder = (_this$store$order = this.store.order) === null || _this$store$order === void 0 || (_this$store$order$get = _this$store$order.getTempOrder) === null || _this$store$order$get === void 0 ? void 0 : _this$store$order$get.call(_this$store$order);
|
|
139
|
+
var customerId = tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.customer_id;
|
|
140
|
+
if (customerId === null || customerId === undefined) return undefined;
|
|
141
|
+
return customerId;
|
|
142
|
+
}
|
|
143
|
+
}, {
|
|
144
|
+
key: "applyQuotationScheduleResolver",
|
|
145
|
+
value: function applyQuotationScheduleResolver(quotation) {
|
|
146
|
+
var scheduleModule = this.store.schedule;
|
|
147
|
+
if (!scheduleModule) return;
|
|
148
|
+
quotation.setScheduleResolver(function (id) {
|
|
149
|
+
var _scheduleModule$getSc;
|
|
150
|
+
var schedules = ((_scheduleModule$getSc = scheduleModule.getScheduleListByIds) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule, [id])) || [];
|
|
151
|
+
return schedules[0];
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}, {
|
|
155
|
+
key: "loadQuotationForPriceQuery",
|
|
156
|
+
value: function () {
|
|
157
|
+
var _loadQuotationForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
|
|
158
|
+
var _this$otherParams;
|
|
159
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
160
|
+
while (1) switch (_context.prev = _context.next) {
|
|
161
|
+
case 0:
|
|
162
|
+
if (params.quotation) {
|
|
163
|
+
_context.next = 2;
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
return _context.abrupt("return");
|
|
167
|
+
case 2:
|
|
168
|
+
this.applyQuotationScheduleResolver(params.quotation);
|
|
169
|
+
_context.next = 5;
|
|
170
|
+
return params.quotation.loadQuotations({
|
|
171
|
+
channel: params.channel || ((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.channel),
|
|
172
|
+
customer_id: params.customer_id
|
|
173
|
+
});
|
|
174
|
+
case 5:
|
|
175
|
+
case "end":
|
|
176
|
+
return _context.stop();
|
|
177
|
+
}
|
|
178
|
+
}, _callee, this);
|
|
179
|
+
}));
|
|
180
|
+
function loadQuotationForPriceQuery(_x) {
|
|
181
|
+
return _loadQuotationForPriceQuery.apply(this, arguments);
|
|
182
|
+
}
|
|
183
|
+
return loadQuotationForPriceQuery;
|
|
184
|
+
}()
|
|
185
|
+
}, {
|
|
186
|
+
key: "getPriceQueryProductId",
|
|
187
|
+
value: function getPriceQueryProductId(product) {
|
|
188
|
+
var _product$product_id;
|
|
189
|
+
var productId = Number((_product$product_id = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : product === null || product === void 0 ? void 0 : product.id);
|
|
190
|
+
if (!Number.isFinite(productId)) return null;
|
|
191
|
+
return productId;
|
|
192
|
+
}
|
|
193
|
+
}, {
|
|
194
|
+
key: "getPriceQuerySchedule",
|
|
195
|
+
value: function getPriceQuerySchedule(params) {
|
|
196
|
+
var booking = params.booking || {};
|
|
197
|
+
if (typeof booking.start_date === 'string' && booking.start_date.trim()) {
|
|
198
|
+
var scheduleDate = booking.start_date.trim();
|
|
199
|
+
var startTime = typeof booking.start_time === 'string' && booking.start_time.trim() ? booking.start_time.trim() : '00:00:00';
|
|
200
|
+
var datetime = dayjs("".concat(scheduleDate, " ").concat(startTime));
|
|
201
|
+
return {
|
|
202
|
+
schedule_date: scheduleDate,
|
|
203
|
+
schedule_datetime: datetime.isValid() ? datetime.format('YYYY-MM-DD HH:mm:ss') : "".concat(scheduleDate, " ").concat(startTime)
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
if (typeof params.datetime === 'string' && params.datetime.trim()) {
|
|
207
|
+
var _datetime = dayjs(params.datetime.trim());
|
|
208
|
+
if (_datetime.isValid()) {
|
|
209
|
+
return {
|
|
210
|
+
schedule_date: _datetime.format('YYYY-MM-DD'),
|
|
211
|
+
schedule_datetime: _datetime.format('YYYY-MM-DD HH:mm:ss')
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
var now = dayjs();
|
|
216
|
+
return {
|
|
217
|
+
schedule_date: now.format('YYYY-MM-DD'),
|
|
218
|
+
schedule_datetime: now.format('YYYY-MM-DD HH:mm:ss')
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
}, {
|
|
222
|
+
key: "loadProductForPriceQuery",
|
|
223
|
+
value: function () {
|
|
224
|
+
var _loadProductForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params, customerId) {
|
|
225
|
+
var product, productId, schedule, _this$otherParams2, _response$data, response, list;
|
|
226
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
227
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
228
|
+
case 0:
|
|
229
|
+
product = params.product || {};
|
|
230
|
+
productId = this.getPriceQueryProductId(product);
|
|
231
|
+
if (!(productId === null || !this.request)) {
|
|
232
|
+
_context2.next = 4;
|
|
233
|
+
break;
|
|
234
|
+
}
|
|
235
|
+
return _context2.abrupt("return", null);
|
|
236
|
+
case 4:
|
|
237
|
+
schedule = this.getPriceQuerySchedule(params);
|
|
238
|
+
_context2.prev = 5;
|
|
239
|
+
_context2.next = 8;
|
|
240
|
+
return this.request.post('/product/query', {
|
|
241
|
+
ids: [productId],
|
|
242
|
+
open_quotation: 1,
|
|
243
|
+
open_bundle: 1,
|
|
244
|
+
status: 'published',
|
|
245
|
+
num: 1,
|
|
246
|
+
skip: 1,
|
|
247
|
+
customer_id: customerId,
|
|
248
|
+
schedule_date: schedule.schedule_date,
|
|
249
|
+
schedule_datetime: schedule.schedule_datetime,
|
|
250
|
+
application_code: params.channel || ((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.channel)
|
|
251
|
+
}, {
|
|
252
|
+
osServer: true,
|
|
253
|
+
customToast: function customToast() {}
|
|
254
|
+
});
|
|
255
|
+
case 8:
|
|
256
|
+
response = _context2.sent;
|
|
257
|
+
list = (response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.list) || (response === null || response === void 0 ? void 0 : response.list) || [];
|
|
258
|
+
if (Array.isArray(list)) {
|
|
259
|
+
_context2.next = 12;
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
262
|
+
return _context2.abrupt("return", null);
|
|
263
|
+
case 12:
|
|
264
|
+
return _context2.abrupt("return", list.find(function (item) {
|
|
265
|
+
var _item$id;
|
|
266
|
+
return Number((_item$id = item === null || item === void 0 ? void 0 : item.id) !== null && _item$id !== void 0 ? _item$id : item === null || item === void 0 ? void 0 : item.product_id) === productId;
|
|
267
|
+
}) || null);
|
|
268
|
+
case 15:
|
|
269
|
+
_context2.prev = 15;
|
|
270
|
+
_context2.t0 = _context2["catch"](5);
|
|
271
|
+
this.logWarning('loadProductForPriceQuery: 商品重查失败,使用入参 fallback', {
|
|
272
|
+
productId: productId,
|
|
273
|
+
error: _context2.t0 instanceof Error ? _context2.t0.message : String(_context2.t0)
|
|
274
|
+
});
|
|
275
|
+
return _context2.abrupt("return", null);
|
|
276
|
+
case 19:
|
|
277
|
+
case "end":
|
|
278
|
+
return _context2.stop();
|
|
279
|
+
}
|
|
280
|
+
}, _callee2, this, [[5, 15]]);
|
|
281
|
+
}));
|
|
282
|
+
function loadProductForPriceQuery(_x2, _x3) {
|
|
283
|
+
return _loadProductForPriceQuery.apply(this, arguments);
|
|
284
|
+
}
|
|
285
|
+
return loadProductForPriceQuery;
|
|
286
|
+
}()
|
|
287
|
+
}, {
|
|
288
|
+
key: "getAuthoritativeBundleItems",
|
|
289
|
+
value: function getAuthoritativeBundleItems(product) {
|
|
290
|
+
if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) return product.product_bundle;
|
|
291
|
+
var groups = Array.isArray(product === null || product === void 0 ? void 0 : product.bundle_group) ? product.bundle_group : Array.isArray(product === null || product === void 0 ? void 0 : product.bundleGroup) ? product.bundleGroup : [];
|
|
292
|
+
return groups.flatMap(function (group) {
|
|
293
|
+
var items = Array.isArray(group === null || group === void 0 ? void 0 : group.bundle_item) ? group.bundle_item : Array.isArray(group === null || group === void 0 ? void 0 : group.bundleItem) ? group.bundleItem : [];
|
|
294
|
+
return items.map(function (item) {
|
|
295
|
+
var _item$group_id, _ref, _item$bundle_group_id;
|
|
296
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
297
|
+
group_id: (_item$group_id = item === null || item === void 0 ? void 0 : item.group_id) !== null && _item$group_id !== void 0 ? _item$group_id : group === null || group === void 0 ? void 0 : group.id,
|
|
298
|
+
bundle_group_id: (_ref = (_item$bundle_group_id = item === null || item === void 0 ? void 0 : item.bundle_group_id) !== null && _item$bundle_group_id !== void 0 ? _item$bundle_group_id : item === null || item === void 0 ? void 0 : item.group_id) !== null && _ref !== void 0 ? _ref : group === null || group === void 0 ? void 0 : group.id
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
}, {
|
|
304
|
+
key: "findAuthoritativeBundleItem",
|
|
305
|
+
value: function findAuthoritativeBundleItem(bundle, candidates) {
|
|
306
|
+
var _bundle$bundle_id, _bundle$bundle_produc, _bundle$bundle_group_;
|
|
307
|
+
var bundleId = (_bundle$bundle_id = bundle.bundle_id) !== null && _bundle$bundle_id !== void 0 ? _bundle$bundle_id : bundle.id;
|
|
308
|
+
if (bundleId != null) {
|
|
309
|
+
var matchedById = candidates.find(function (item) {
|
|
310
|
+
var _item$bundle_id;
|
|
311
|
+
return String((_item$bundle_id = item === null || item === void 0 ? void 0 : item.bundle_id) !== null && _item$bundle_id !== void 0 ? _item$bundle_id : item === null || item === void 0 ? void 0 : item.id) === String(bundleId);
|
|
312
|
+
});
|
|
313
|
+
if (matchedById) return matchedById;
|
|
314
|
+
}
|
|
315
|
+
var productId = (_bundle$bundle_produc = bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle._bundle_product_id;
|
|
316
|
+
var groupId = (_bundle$bundle_group_ = bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle.group_id;
|
|
317
|
+
return candidates.find(function (item) {
|
|
318
|
+
var _item$bundle_product_, _item$bundle_group_id2;
|
|
319
|
+
var itemProductId = (_item$bundle_product_ = item === null || item === void 0 ? void 0 : item.bundle_product_id) !== null && _item$bundle_product_ !== void 0 ? _item$bundle_product_ : item === null || item === void 0 ? void 0 : item._bundle_product_id;
|
|
320
|
+
var itemGroupId = (_item$bundle_group_id2 = item === null || item === void 0 ? void 0 : item.bundle_group_id) !== null && _item$bundle_group_id2 !== void 0 ? _item$bundle_group_id2 : item === null || item === void 0 ? void 0 : item.group_id;
|
|
321
|
+
if (productId == null || String(itemProductId) !== String(productId)) return false;
|
|
322
|
+
if (groupId == null) return true;
|
|
323
|
+
return String(itemGroupId) === String(groupId);
|
|
324
|
+
}) || null;
|
|
325
|
+
}
|
|
326
|
+
}, {
|
|
327
|
+
key: "getAuthoritativeBundleUnitPrice",
|
|
328
|
+
value: function getAuthoritativeBundleUnitPrice(bundle) {
|
|
329
|
+
var _ref2, _ref3, _ref4, _bundle$price;
|
|
330
|
+
return (_ref2 = (_ref3 = (_ref4 = (_bundle$price = bundle.price) !== null && _bundle$price !== void 0 ? _bundle$price : bundle.bundle_selling_price) !== null && _ref4 !== void 0 ? _ref4 : bundle.custom_price) !== null && _ref3 !== void 0 ? _ref3 : bundle.product_price) !== null && _ref2 !== void 0 ? _ref2 : bundle.base_price;
|
|
331
|
+
}
|
|
332
|
+
}, {
|
|
333
|
+
key: "mergeProductForPriceQuery",
|
|
334
|
+
value: function mergeProductForPriceQuery(product, authoritativeProduct) {
|
|
335
|
+
var _this2 = this,
|
|
336
|
+
_product$id,
|
|
337
|
+
_ref5,
|
|
338
|
+
_product$product_id2,
|
|
339
|
+
_ref6,
|
|
340
|
+
_product$product_vari,
|
|
341
|
+
_ref7,
|
|
342
|
+
_product$num,
|
|
343
|
+
_ref8,
|
|
344
|
+
_product$quantity,
|
|
345
|
+
_product$product_opti,
|
|
346
|
+
_product$metadata;
|
|
347
|
+
if (!authoritativeProduct) return product;
|
|
348
|
+
var selectedBundles = Array.isArray(product.product_bundle) ? product.product_bundle : [];
|
|
349
|
+
var authoritativeBundles = this.getAuthoritativeBundleItems(authoritativeProduct);
|
|
350
|
+
var productBundle = selectedBundles.map(function (bundle) {
|
|
351
|
+
var _authoritativeBundle$, _authoritativeBundle$2;
|
|
352
|
+
var authoritativeBundle = _this2.findAuthoritativeBundleItem(bundle, authoritativeBundles);
|
|
353
|
+
var unitPrice = authoritativeBundle ? _this2.getAuthoritativeBundleUnitPrice(authoritativeBundle) : undefined;
|
|
354
|
+
if (unitPrice === undefined || unitPrice === null || unitPrice === '') return bundle;
|
|
355
|
+
return _objectSpread(_objectSpread({}, bundle), {}, {
|
|
356
|
+
price: unitPrice,
|
|
357
|
+
bundle_selling_price: unitPrice,
|
|
358
|
+
base_price: (_authoritativeBundle$ = authoritativeBundle === null || authoritativeBundle === void 0 ? void 0 : authoritativeBundle.base_price) !== null && _authoritativeBundle$ !== void 0 ? _authoritativeBundle$ : bundle.base_price,
|
|
359
|
+
product_price: (_authoritativeBundle$2 = authoritativeBundle === null || authoritativeBundle === void 0 ? void 0 : authoritativeBundle.product_price) !== null && _authoritativeBundle$2 !== void 0 ? _authoritativeBundle$2 : bundle.product_price
|
|
360
|
+
});
|
|
361
|
+
});
|
|
362
|
+
return _objectSpread(_objectSpread(_objectSpread({}, product), authoritativeProduct), {}, {
|
|
363
|
+
id: (_product$id = product.id) !== null && _product$id !== void 0 ? _product$id : authoritativeProduct.id,
|
|
364
|
+
product_id: (_ref5 = (_product$product_id2 = product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : authoritativeProduct.product_id) !== null && _ref5 !== void 0 ? _ref5 : authoritativeProduct.id,
|
|
365
|
+
product_variant_id: (_ref6 = (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : authoritativeProduct.product_variant_id) !== null && _ref6 !== void 0 ? _ref6 : 0,
|
|
366
|
+
num: (_ref7 = (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : product.quantity) !== null && _ref7 !== void 0 ? _ref7 : authoritativeProduct.num,
|
|
367
|
+
quantity: (_ref8 = (_product$quantity = product.quantity) !== null && _product$quantity !== void 0 ? _product$quantity : product.num) !== null && _ref8 !== void 0 ? _ref8 : authoritativeProduct.quantity,
|
|
368
|
+
product_option_item: (_product$product_opti = product.product_option_item) !== null && _product$product_opti !== void 0 ? _product$product_opti : authoritativeProduct.product_option_item,
|
|
369
|
+
product_bundle: productBundle,
|
|
370
|
+
metadata: (_product$metadata = product.metadata) !== null && _product$metadata !== void 0 ? _product$metadata : authoritativeProduct.metadata
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
}, {
|
|
374
|
+
key: "getSubmitOrderSalesChannel",
|
|
375
|
+
value: function getSubmitOrderSalesChannel() {
|
|
376
|
+
var _this$otherParams3;
|
|
377
|
+
return (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.channel;
|
|
378
|
+
}
|
|
124
379
|
|
|
125
380
|
/**
|
|
126
381
|
* 工厂入口:根据子模块名实例化对应模块。
|
|
@@ -130,6 +385,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
130
385
|
}, {
|
|
131
386
|
key: "createSubModule",
|
|
132
387
|
value: function createSubModule(moduleName) {
|
|
388
|
+
if (moduleName === 'quotation') {
|
|
389
|
+
return new QuotationModule("".concat(this.name, "_quotation"));
|
|
390
|
+
}
|
|
133
391
|
return createModule(moduleName, this.name);
|
|
134
392
|
}
|
|
135
393
|
}, {
|
|
@@ -163,77 +421,128 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
163
421
|
return {};
|
|
164
422
|
}
|
|
165
423
|
}
|
|
424
|
+
}, {
|
|
425
|
+
key: "getAppData",
|
|
426
|
+
value: function getAppData(key) {
|
|
427
|
+
var _this$appPlugin$getDa, _this$appPlugin, _app$models, _app$models$getStore, _app$models$getStore$, _app$models$getStore$2;
|
|
428
|
+
var getData = (_this$appPlugin$getDa = (_this$appPlugin = this.appPlugin).getData) === null || _this$appPlugin$getDa === void 0 ? void 0 : _this$appPlugin$getDa.call(_this$appPlugin);
|
|
429
|
+
if (typeof getData === 'function') return getData(key);
|
|
430
|
+
var app = this.appPlugin.getApp();
|
|
431
|
+
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');
|
|
432
|
+
return coreData === null || coreData === void 0 ? void 0 : coreData[key];
|
|
433
|
+
}
|
|
434
|
+
}, {
|
|
435
|
+
key: "syncAppDataToTempOrder",
|
|
436
|
+
value: function syncAppDataToTempOrder(tempOrder) {
|
|
437
|
+
var isPriceIncludeTax = this.getAppData('is_price_include_tax');
|
|
438
|
+
var taxCountryCode = this.getAppData('tax_country_code');
|
|
439
|
+
var currencyCode = this.getAppData('shop_currency_code');
|
|
440
|
+
var currencySymbol = this.getAppData('shop_symbol');
|
|
441
|
+
var isChanged = false;
|
|
442
|
+
if (isPriceIncludeTax !== undefined) {
|
|
443
|
+
var nextIsPriceIncludeTax = Number(isPriceIncludeTax);
|
|
444
|
+
if ((nextIsPriceIncludeTax === 0 || nextIsPriceIncludeTax === 1) && tempOrder.is_price_include_tax !== nextIsPriceIncludeTax) {
|
|
445
|
+
tempOrder.is_price_include_tax = nextIsPriceIncludeTax;
|
|
446
|
+
isChanged = true;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
if (taxCountryCode !== undefined) {
|
|
450
|
+
var nextTaxCountryCode = String(taxCountryCode || '');
|
|
451
|
+
if (tempOrder.tax_country_code !== nextTaxCountryCode) {
|
|
452
|
+
tempOrder.tax_country_code = nextTaxCountryCode;
|
|
453
|
+
isChanged = true;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
if (currencyCode !== undefined) {
|
|
457
|
+
var nextCurrencyCode = String(currencyCode || '');
|
|
458
|
+
if (tempOrder.currency_code !== nextCurrencyCode) {
|
|
459
|
+
tempOrder.currency_code = nextCurrencyCode;
|
|
460
|
+
isChanged = true;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
if (currencySymbol !== undefined) {
|
|
464
|
+
var nextCurrencySymbol = String(currencySymbol || '');
|
|
465
|
+
if (tempOrder.currency_symbol !== nextCurrencySymbol) {
|
|
466
|
+
tempOrder.currency_symbol = nextCurrencySymbol;
|
|
467
|
+
isChanged = true;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
return isChanged;
|
|
471
|
+
}
|
|
166
472
|
}, {
|
|
167
473
|
key: "initialize",
|
|
168
474
|
value: function () {
|
|
169
|
-
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
170
|
-
var _this$
|
|
171
|
-
|
|
475
|
+
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(core) {
|
|
476
|
+
var _this$otherParams4,
|
|
477
|
+
_this3 = this,
|
|
478
|
+
_this$otherParams5;
|
|
172
479
|
var options,
|
|
173
|
-
appPlugin,
|
|
174
480
|
app,
|
|
175
481
|
targetCacheData,
|
|
176
482
|
moduleNames,
|
|
177
|
-
|
|
178
|
-
return _regeneratorRuntime().wrap(function
|
|
179
|
-
while (1) switch (
|
|
483
|
+
_args3 = arguments;
|
|
484
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
485
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
180
486
|
case 0:
|
|
181
|
-
options =
|
|
487
|
+
options = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
|
|
182
488
|
this.core = core;
|
|
183
489
|
this.initializeOptions = options || {};
|
|
184
490
|
// this.store = { ...this.store, ...(options.store as Partial<BaseSalesState>) };
|
|
185
491
|
this.otherParams = options.otherParams || {};
|
|
186
|
-
this.cacheId = (_this$
|
|
492
|
+
this.cacheId = (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.cacheId;
|
|
187
493
|
this.window = core.getPlugin('window');
|
|
188
494
|
this.request = core.getPlugin('request');
|
|
189
495
|
|
|
190
496
|
// 获取 logger 实例
|
|
191
|
-
appPlugin = core.getPlugin('app');
|
|
192
|
-
if (appPlugin) {
|
|
193
|
-
|
|
497
|
+
this.appPlugin = core.getPlugin('app');
|
|
498
|
+
if (this.appPlugin) {
|
|
499
|
+
_context3.next = 10;
|
|
194
500
|
break;
|
|
195
501
|
}
|
|
196
502
|
throw new Error('Checkout 解决方案需要 app 插件支持');
|
|
197
503
|
case 10:
|
|
198
|
-
app = appPlugin.getApp();
|
|
504
|
+
app = this.appPlugin.getApp();
|
|
199
505
|
this.logger = app.logger;
|
|
200
506
|
targetCacheData = this.readSessionCacheData();
|
|
201
507
|
moduleNames = this.getRegisteredModuleNames();
|
|
202
508
|
moduleNames.forEach(function (step) {
|
|
203
|
-
var targetModule =
|
|
509
|
+
var targetModule = _this3.createSubModule(step);
|
|
204
510
|
if (!targetModule) {
|
|
205
511
|
throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
|
|
206
512
|
}
|
|
207
|
-
var hooks =
|
|
208
|
-
|
|
209
|
-
|
|
513
|
+
var hooks = _this3.getSubModuleHooks(step);
|
|
514
|
+
_this3.store[step] = targetModule;
|
|
515
|
+
_this3.core.registerModule(targetModule, _objectSpread(_objectSpread({
|
|
210
516
|
initialState: (targetCacheData === null || targetCacheData === void 0 ? void 0 : targetCacheData[targetModule.name]) || {}
|
|
211
517
|
}, hooks ? {
|
|
212
518
|
hooks: hooks
|
|
213
519
|
} : {}), {}, {
|
|
214
|
-
otherParams: _objectSpread(_objectSpread({},
|
|
215
|
-
salesSummaryModuleName: "".concat(
|
|
216
|
-
fatherModule:
|
|
217
|
-
openCache:
|
|
218
|
-
cacheId:
|
|
520
|
+
otherParams: _objectSpread(_objectSpread({}, _this3.otherParams), {}, {
|
|
521
|
+
salesSummaryModuleName: "".concat(_this3.name, "_salesSummary"),
|
|
522
|
+
fatherModule: _this3.name,
|
|
523
|
+
openCache: _this3.cacheId ? true : false,
|
|
524
|
+
cacheId: _this3.cacheId
|
|
219
525
|
})
|
|
220
526
|
}));
|
|
221
527
|
});
|
|
222
528
|
if (!this.store.schedule) {
|
|
223
|
-
|
|
529
|
+
_context3.next = 18;
|
|
224
530
|
break;
|
|
225
531
|
}
|
|
226
|
-
|
|
532
|
+
_context3.next = 18;
|
|
227
533
|
return this.store.schedule.loadAllSchedule();
|
|
228
534
|
case 18:
|
|
535
|
+
if (this.store.order && typeof ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.enableTempOrderPersist) === 'boolean') {
|
|
536
|
+
this.store.order.setEnableTempOrderPersist(this.otherParams.enableTempOrderPersist);
|
|
537
|
+
}
|
|
229
538
|
this.core.effects.emit("".concat(this.name, ":onInited"), {});
|
|
230
|
-
case
|
|
539
|
+
case 20:
|
|
231
540
|
case "end":
|
|
232
|
-
return
|
|
541
|
+
return _context3.stop();
|
|
233
542
|
}
|
|
234
|
-
},
|
|
543
|
+
}, _callee3, this);
|
|
235
544
|
}));
|
|
236
|
-
function initialize(
|
|
545
|
+
function initialize(_x4) {
|
|
237
546
|
return _initialize.apply(this, arguments);
|
|
238
547
|
}
|
|
239
548
|
return initialize;
|
|
@@ -241,13 +550,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
241
550
|
}, {
|
|
242
551
|
key: "destroy",
|
|
243
552
|
value: function () {
|
|
244
|
-
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
245
|
-
var
|
|
246
|
-
return _regeneratorRuntime().wrap(function
|
|
247
|
-
while (1) switch (
|
|
553
|
+
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
554
|
+
var _this4 = this;
|
|
555
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
556
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
248
557
|
case 0:
|
|
249
558
|
Object.keys(this.store).forEach(function (key) {
|
|
250
|
-
var sub =
|
|
559
|
+
var sub = _this4.store[key];
|
|
251
560
|
if (sub && typeof sub.destroy === 'function') {
|
|
252
561
|
try {
|
|
253
562
|
sub.destroy();
|
|
@@ -257,15 +566,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
257
566
|
}
|
|
258
567
|
});
|
|
259
568
|
this.currentSalesDetail = null;
|
|
260
|
-
|
|
569
|
+
_context4.next = 4;
|
|
261
570
|
return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
|
|
262
571
|
case 4:
|
|
263
572
|
_get(_getPrototypeOf(BaseSalesImpl.prototype), "destroy", this).call(this);
|
|
264
573
|
case 5:
|
|
265
574
|
case "end":
|
|
266
|
-
return
|
|
575
|
+
return _context4.stop();
|
|
267
576
|
}
|
|
268
|
-
},
|
|
577
|
+
}, _callee4, this);
|
|
269
578
|
}));
|
|
270
579
|
function destroy() {
|
|
271
580
|
return _destroy.apply(this, arguments);
|
|
@@ -282,13 +591,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
282
591
|
}, {
|
|
283
592
|
key: "loadSalesDetail",
|
|
284
593
|
value: (function () {
|
|
285
|
-
var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
594
|
+
var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(orderIdOrParams) {
|
|
286
595
|
var params, externalSaleNumber, localRecord, _sales, res, message, sales;
|
|
287
|
-
return _regeneratorRuntime().wrap(function
|
|
288
|
-
while (1) switch (
|
|
596
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
597
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
289
598
|
case 0:
|
|
290
599
|
if (this.store.order) {
|
|
291
|
-
|
|
600
|
+
_context5.next = 2;
|
|
292
601
|
break;
|
|
293
602
|
}
|
|
294
603
|
throw new Error('order 模块未初始化');
|
|
@@ -298,107 +607,107 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
298
607
|
};
|
|
299
608
|
externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
|
|
300
609
|
if (params.forceRemote) {
|
|
301
|
-
|
|
610
|
+
_context5.next = 35;
|
|
302
611
|
break;
|
|
303
612
|
}
|
|
304
613
|
if (!(params.orderId !== undefined)) {
|
|
305
|
-
|
|
614
|
+
_context5.next = 11;
|
|
306
615
|
break;
|
|
307
616
|
}
|
|
308
|
-
|
|
617
|
+
_context5.next = 8;
|
|
309
618
|
return this.store.order.getLocalOrderByOrderId(params.orderId);
|
|
310
619
|
case 8:
|
|
311
|
-
|
|
312
|
-
|
|
620
|
+
_context5.t0 = _context5.sent;
|
|
621
|
+
_context5.next = 26;
|
|
313
622
|
break;
|
|
314
623
|
case 11:
|
|
315
624
|
if (!externalSaleNumber) {
|
|
316
|
-
|
|
625
|
+
_context5.next = 17;
|
|
317
626
|
break;
|
|
318
627
|
}
|
|
319
|
-
|
|
628
|
+
_context5.next = 14;
|
|
320
629
|
return this.store.order.getLocalOrderByExternalSaleNumber(externalSaleNumber);
|
|
321
630
|
case 14:
|
|
322
|
-
|
|
323
|
-
|
|
631
|
+
_context5.t1 = _context5.sent;
|
|
632
|
+
_context5.next = 25;
|
|
324
633
|
break;
|
|
325
634
|
case 17:
|
|
326
635
|
if (!params.orderNumber) {
|
|
327
|
-
|
|
636
|
+
_context5.next = 23;
|
|
328
637
|
break;
|
|
329
638
|
}
|
|
330
|
-
|
|
639
|
+
_context5.next = 20;
|
|
331
640
|
return this.store.order.getLocalOrderByOrderNumber(params.orderNumber);
|
|
332
641
|
case 20:
|
|
333
|
-
|
|
334
|
-
|
|
642
|
+
_context5.t2 = _context5.sent;
|
|
643
|
+
_context5.next = 24;
|
|
335
644
|
break;
|
|
336
645
|
case 23:
|
|
337
|
-
|
|
646
|
+
_context5.t2 = null;
|
|
338
647
|
case 24:
|
|
339
|
-
|
|
648
|
+
_context5.t1 = _context5.t2;
|
|
340
649
|
case 25:
|
|
341
|
-
|
|
650
|
+
_context5.t0 = _context5.t1;
|
|
342
651
|
case 26:
|
|
343
|
-
localRecord =
|
|
652
|
+
localRecord = _context5.t0;
|
|
344
653
|
if (!localRecord) {
|
|
345
|
-
|
|
654
|
+
_context5.next = 35;
|
|
346
655
|
break;
|
|
347
656
|
}
|
|
348
|
-
|
|
657
|
+
_context5.next = 30;
|
|
349
658
|
return this.store.order.hydrateTempOrderFromRecord(localRecord, {
|
|
350
659
|
recalcOnHydrate: false
|
|
351
660
|
});
|
|
352
661
|
case 30:
|
|
353
|
-
_sales =
|
|
662
|
+
_sales = _context5.sent;
|
|
354
663
|
this.currentSalesDetail = _sales;
|
|
355
|
-
|
|
664
|
+
_context5.next = 34;
|
|
356
665
|
return this.core.effects.emit("".concat(this.name, ":onSalesOrderLoaded"), {
|
|
357
666
|
sales: _sales
|
|
358
667
|
});
|
|
359
668
|
case 34:
|
|
360
|
-
return
|
|
669
|
+
return _context5.abrupt("return", _sales);
|
|
361
670
|
case 35:
|
|
362
671
|
if (!(params.orderId === undefined || params.orderId === null)) {
|
|
363
|
-
|
|
672
|
+
_context5.next = 37;
|
|
364
673
|
break;
|
|
365
674
|
}
|
|
366
675
|
throw new Error('加载销售详情需要 orderId,或本地库中存在对应 externalSaleNumber/orderNumber');
|
|
367
676
|
case 37:
|
|
368
|
-
|
|
677
|
+
_context5.next = 39;
|
|
369
678
|
return this.store.order.getOrderInfoByRemote(Number(params.orderId));
|
|
370
679
|
case 39:
|
|
371
|
-
res =
|
|
680
|
+
res = _context5.sent;
|
|
372
681
|
if (!(!res || res.code !== 200)) {
|
|
373
|
-
|
|
682
|
+
_context5.next = 43;
|
|
374
683
|
break;
|
|
375
684
|
}
|
|
376
685
|
message = res && (res.message || res.msg) || "\u52A0\u8F7D\u9500\u552E\u8BE6\u60C5\u5931\u8D25: ".concat(params.orderId);
|
|
377
686
|
throw new Error(message);
|
|
378
687
|
case 43:
|
|
379
|
-
|
|
688
|
+
_context5.next = 45;
|
|
380
689
|
return this.store.order.hydrateTempOrderFromRecord(res.data, {
|
|
381
690
|
recalcOnHydrate: false
|
|
382
691
|
});
|
|
383
692
|
case 45:
|
|
384
|
-
sales =
|
|
385
|
-
|
|
693
|
+
sales = _context5.sent;
|
|
694
|
+
_context5.next = 48;
|
|
386
695
|
return this.store.order.saveDraft();
|
|
387
696
|
case 48:
|
|
388
697
|
this.currentSalesDetail = sales;
|
|
389
|
-
|
|
698
|
+
_context5.next = 51;
|
|
390
699
|
return this.core.effects.emit("".concat(this.name, ":onSalesOrderLoaded"), {
|
|
391
700
|
sales: sales
|
|
392
701
|
});
|
|
393
702
|
case 51:
|
|
394
|
-
return
|
|
703
|
+
return _context5.abrupt("return", sales);
|
|
395
704
|
case 52:
|
|
396
705
|
case "end":
|
|
397
|
-
return
|
|
706
|
+
return _context5.stop();
|
|
398
707
|
}
|
|
399
|
-
},
|
|
708
|
+
}, _callee5, this);
|
|
400
709
|
}));
|
|
401
|
-
function loadSalesDetail(
|
|
710
|
+
function loadSalesDetail(_x5) {
|
|
402
711
|
return _loadSalesDetail.apply(this, arguments);
|
|
403
712
|
}
|
|
404
713
|
return loadSalesDetail;
|
|
@@ -471,10 +780,45 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
471
780
|
}, {
|
|
472
781
|
key: "getTempOrder",
|
|
473
782
|
value: function getTempOrder() {
|
|
474
|
-
var _this$store$
|
|
475
|
-
var result = ((_this$store$
|
|
783
|
+
var _this$store$order2;
|
|
784
|
+
var result = ((_this$store$order2 = this.store.order) === null || _this$store$order2 === void 0 ? void 0 : _this$store$order2.getTempOrder()) || null;
|
|
476
785
|
return result;
|
|
477
786
|
}
|
|
787
|
+
}, {
|
|
788
|
+
key: "replaceTempOrder",
|
|
789
|
+
value: function () {
|
|
790
|
+
var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(tempOrder) {
|
|
791
|
+
var nextTempOrder;
|
|
792
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
793
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
794
|
+
case 0:
|
|
795
|
+
if (this.store.order) {
|
|
796
|
+
_context6.next = 2;
|
|
797
|
+
break;
|
|
798
|
+
}
|
|
799
|
+
throw new Error('order 模块未初始化');
|
|
800
|
+
case 2:
|
|
801
|
+
_context6.next = 4;
|
|
802
|
+
return this.store.order.replaceTempOrder(tempOrder);
|
|
803
|
+
case 4:
|
|
804
|
+
nextTempOrder = _context6.sent;
|
|
805
|
+
_context6.next = 7;
|
|
806
|
+
return this.effectsEmit('onTempOrderReplaced', {
|
|
807
|
+
tempOrder: nextTempOrder
|
|
808
|
+
});
|
|
809
|
+
case 7:
|
|
810
|
+
return _context6.abrupt("return", nextTempOrder);
|
|
811
|
+
case 8:
|
|
812
|
+
case "end":
|
|
813
|
+
return _context6.stop();
|
|
814
|
+
}
|
|
815
|
+
}, _callee6, this);
|
|
816
|
+
}));
|
|
817
|
+
function replaceTempOrder(_x6) {
|
|
818
|
+
return _replaceTempOrder.apply(this, arguments);
|
|
819
|
+
}
|
|
820
|
+
return replaceTempOrder;
|
|
821
|
+
}()
|
|
478
822
|
}, {
|
|
479
823
|
key: "getOrderIdentity",
|
|
480
824
|
value: function getOrderIdentity() {
|
|
@@ -508,14 +852,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
508
852
|
}, {
|
|
509
853
|
key: "updateTempOrderNote",
|
|
510
854
|
value: function updateTempOrderNote(note) {
|
|
855
|
+
var sync = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
511
856
|
try {
|
|
512
857
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
513
|
-
var result = this.store.order.updateTempOrderNote(note);
|
|
858
|
+
var result = this.store.order.updateTempOrderNote(note, sync);
|
|
514
859
|
return result;
|
|
515
860
|
} catch (error) {
|
|
516
861
|
throw error;
|
|
517
862
|
}
|
|
518
863
|
}
|
|
864
|
+
}, {
|
|
865
|
+
key: "updateRemoteOrderNote",
|
|
866
|
+
value: function updateRemoteOrderNote(orderId, note) {
|
|
867
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
868
|
+
this.store.order.syncTempOrderNoteToRemote(orderId, note);
|
|
869
|
+
}
|
|
519
870
|
}, {
|
|
520
871
|
key: "updateTempOrderShopDiscount",
|
|
521
872
|
value: function updateTempOrderShopDiscount(amount) {
|
|
@@ -528,6 +879,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
528
879
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
529
880
|
return this.store.order.updateTempOrderContactsInfo(contactsInfo);
|
|
530
881
|
}
|
|
882
|
+
|
|
883
|
+
/** @deprecated OrderModule 不再负责 tempOrder localStorage 持久化。 */
|
|
884
|
+
}, {
|
|
885
|
+
key: "setEnableTempOrderPersist",
|
|
886
|
+
value: function setEnableTempOrderPersist(enabled) {
|
|
887
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
888
|
+
this.store.order.setEnableTempOrderPersist(enabled);
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
/** 是否允许 saveDraft 写入 IndexedDB 草稿。 */
|
|
892
|
+
}, {
|
|
893
|
+
key: "isTempOrderPersistEnabled",
|
|
894
|
+
value: function isTempOrderPersistEnabled() {
|
|
895
|
+
if (!this.store.order) return false;
|
|
896
|
+
return this.store.order.isTempOrderPersistEnabled();
|
|
897
|
+
}
|
|
531
898
|
}, {
|
|
532
899
|
key: "ensureTempOrder",
|
|
533
900
|
value: function ensureTempOrder() {
|
|
@@ -539,32 +906,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
539
906
|
}, {
|
|
540
907
|
key: "addNewOrder",
|
|
541
908
|
value: function () {
|
|
542
|
-
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
909
|
+
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
543
910
|
var tempOrder;
|
|
544
|
-
return _regeneratorRuntime().wrap(function
|
|
545
|
-
while (1) switch (
|
|
911
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
912
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
546
913
|
case 0:
|
|
547
|
-
|
|
914
|
+
_context7.prev = 0;
|
|
548
915
|
if (this.store.order) {
|
|
549
|
-
|
|
916
|
+
_context7.next = 3;
|
|
550
917
|
break;
|
|
551
918
|
}
|
|
552
919
|
throw new Error('order 模块未初始化');
|
|
553
920
|
case 3:
|
|
554
|
-
|
|
921
|
+
_context7.next = 5;
|
|
555
922
|
return this.store.order.addNewOrder();
|
|
556
923
|
case 5:
|
|
557
|
-
tempOrder =
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
924
|
+
tempOrder = _context7.sent;
|
|
925
|
+
if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
|
|
926
|
+
_context7.next = 10;
|
|
927
|
+
break;
|
|
928
|
+
}
|
|
929
|
+
this.store.order.persistTempOrder();
|
|
930
|
+
_context7.next = 10;
|
|
931
|
+
return this.store.order.saveDraft();
|
|
932
|
+
case 10:
|
|
933
|
+
return _context7.abrupt("return", tempOrder);
|
|
934
|
+
case 13:
|
|
935
|
+
_context7.prev = 13;
|
|
936
|
+
_context7.t0 = _context7["catch"](0);
|
|
937
|
+
throw _context7.t0;
|
|
938
|
+
case 16:
|
|
564
939
|
case "end":
|
|
565
|
-
return
|
|
940
|
+
return _context7.stop();
|
|
566
941
|
}
|
|
567
|
-
},
|
|
942
|
+
}, _callee7, this, [[0, 13]]);
|
|
568
943
|
}));
|
|
569
944
|
function addNewOrder() {
|
|
570
945
|
return _addNewOrder.apply(this, arguments);
|
|
@@ -574,22 +949,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
574
949
|
}, {
|
|
575
950
|
key: "saveDraft",
|
|
576
951
|
value: function () {
|
|
577
|
-
var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
578
|
-
return _regeneratorRuntime().wrap(function
|
|
579
|
-
while (1) switch (
|
|
952
|
+
var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
953
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
954
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
580
955
|
case 0:
|
|
581
956
|
if (this.store.order) {
|
|
582
|
-
|
|
957
|
+
_context8.next = 2;
|
|
583
958
|
break;
|
|
584
959
|
}
|
|
585
960
|
throw new Error('order 模块未初始化');
|
|
586
961
|
case 2:
|
|
587
|
-
return
|
|
962
|
+
return _context8.abrupt("return", this.store.order.saveDraft());
|
|
588
963
|
case 3:
|
|
589
964
|
case "end":
|
|
590
|
-
return
|
|
965
|
+
return _context8.stop();
|
|
591
966
|
}
|
|
592
|
-
},
|
|
967
|
+
}, _callee8, this);
|
|
593
968
|
}));
|
|
594
969
|
function saveDraft() {
|
|
595
970
|
return _saveDraft.apply(this, arguments);
|
|
@@ -600,36 +975,113 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
600
975
|
}, {
|
|
601
976
|
key: "restoreOrder",
|
|
602
977
|
value: function () {
|
|
603
|
-
var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
978
|
+
var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
604
979
|
var tempOrder;
|
|
605
|
-
return _regeneratorRuntime().wrap(function
|
|
606
|
-
while (1) switch (
|
|
980
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
981
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
607
982
|
case 0:
|
|
608
|
-
|
|
983
|
+
_context9.prev = 0;
|
|
609
984
|
if (this.store.order) {
|
|
610
|
-
|
|
985
|
+
_context9.next = 3;
|
|
611
986
|
break;
|
|
612
987
|
}
|
|
613
988
|
throw new Error('scanOrder 解决方案需要 order 模块支持');
|
|
614
989
|
case 3:
|
|
615
990
|
// this.store.resource = null;
|
|
616
991
|
tempOrder = this.store.order.restoreOrder();
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
992
|
+
this.currentSalesDetail = null;
|
|
993
|
+
this.discountConfigCacheKey = null;
|
|
994
|
+
this.hasManualDiscountSelection = false;
|
|
995
|
+
_context9.next = 9;
|
|
996
|
+
return this.effectsEmit('onTempOrderReplaced', {
|
|
997
|
+
tempOrder: tempOrder
|
|
998
|
+
});
|
|
999
|
+
case 9:
|
|
1000
|
+
if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
|
|
1001
|
+
_context9.next = 13;
|
|
1002
|
+
break;
|
|
1003
|
+
}
|
|
1004
|
+
this.store.order.persistTempOrder();
|
|
1005
|
+
_context9.next = 13;
|
|
1006
|
+
return this.store.order.saveDraft();
|
|
1007
|
+
case 13:
|
|
1008
|
+
return _context9.abrupt("return", tempOrder);
|
|
1009
|
+
case 16:
|
|
1010
|
+
_context9.prev = 16;
|
|
1011
|
+
_context9.t0 = _context9["catch"](0);
|
|
1012
|
+
throw _context9.t0;
|
|
1013
|
+
case 19:
|
|
623
1014
|
case "end":
|
|
624
|
-
return
|
|
1015
|
+
return _context9.stop();
|
|
625
1016
|
}
|
|
626
|
-
},
|
|
1017
|
+
}, _callee9, this, [[0, 16]]);
|
|
627
1018
|
}));
|
|
628
1019
|
function restoreOrder() {
|
|
629
1020
|
return _restoreOrder.apply(this, arguments);
|
|
630
1021
|
}
|
|
631
1022
|
return restoreOrder;
|
|
632
1023
|
}()
|
|
1024
|
+
/**
|
|
1025
|
+
* 仅清空 tempOrder 购物车行(products / bookings / discount_list)。
|
|
1026
|
+
* 同步清空内存中的 salesDetail 商品/预约视图,避免编辑态仍读到旧 bookings。
|
|
1027
|
+
*/
|
|
1028
|
+
}, {
|
|
1029
|
+
key: "clearOrderCartLines",
|
|
1030
|
+
value: (function () {
|
|
1031
|
+
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
1032
|
+
var tempOrder;
|
|
1033
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
1034
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
1035
|
+
case 0:
|
|
1036
|
+
_context10.prev = 0;
|
|
1037
|
+
if (this.store.order) {
|
|
1038
|
+
_context10.next = 3;
|
|
1039
|
+
break;
|
|
1040
|
+
}
|
|
1041
|
+
throw new Error('order 模块未初始化');
|
|
1042
|
+
case 3:
|
|
1043
|
+
_context10.next = 5;
|
|
1044
|
+
return this.store.order.clearOrderCartLines();
|
|
1045
|
+
case 5:
|
|
1046
|
+
tempOrder = _context10.sent;
|
|
1047
|
+
if (this.currentSalesDetail) {
|
|
1048
|
+
this.currentSalesDetail = _objectSpread(_objectSpread({}, this.currentSalesDetail), {}, {
|
|
1049
|
+
products: [],
|
|
1050
|
+
bookings: [],
|
|
1051
|
+
rootBooking: null,
|
|
1052
|
+
bookingsByProductUid: {},
|
|
1053
|
+
discount_list: []
|
|
1054
|
+
});
|
|
1055
|
+
}
|
|
1056
|
+
_context10.next = 9;
|
|
1057
|
+
return this.effectsEmit('onTempOrderReplaced', {
|
|
1058
|
+
tempOrder: tempOrder
|
|
1059
|
+
});
|
|
1060
|
+
case 9:
|
|
1061
|
+
if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
|
|
1062
|
+
_context10.next = 13;
|
|
1063
|
+
break;
|
|
1064
|
+
}
|
|
1065
|
+
this.store.order.persistTempOrder();
|
|
1066
|
+
_context10.next = 13;
|
|
1067
|
+
return this.store.order.saveDraft();
|
|
1068
|
+
case 13:
|
|
1069
|
+
return _context10.abrupt("return", tempOrder);
|
|
1070
|
+
case 16:
|
|
1071
|
+
_context10.prev = 16;
|
|
1072
|
+
_context10.t0 = _context10["catch"](0);
|
|
1073
|
+
throw _context10.t0;
|
|
1074
|
+
case 19:
|
|
1075
|
+
case "end":
|
|
1076
|
+
return _context10.stop();
|
|
1077
|
+
}
|
|
1078
|
+
}, _callee10, this, [[0, 16]]);
|
|
1079
|
+
}));
|
|
1080
|
+
function clearOrderCartLines() {
|
|
1081
|
+
return _clearOrderCartLines.apply(this, arguments);
|
|
1082
|
+
}
|
|
1083
|
+
return clearOrderCartLines;
|
|
1084
|
+
}())
|
|
633
1085
|
}, {
|
|
634
1086
|
key: "getOrderProducts",
|
|
635
1087
|
value: function getOrderProducts() {
|
|
@@ -640,37 +1092,384 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
640
1092
|
}, {
|
|
641
1093
|
key: "getSummary",
|
|
642
1094
|
value: function () {
|
|
643
|
-
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1095
|
+
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
644
1096
|
var summary;
|
|
645
|
-
return _regeneratorRuntime().wrap(function
|
|
646
|
-
while (1) switch (
|
|
1097
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
1098
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
647
1099
|
case 0:
|
|
648
|
-
|
|
1100
|
+
_context11.prev = 0;
|
|
649
1101
|
if (this.store.order) {
|
|
650
|
-
|
|
1102
|
+
_context11.next = 3;
|
|
651
1103
|
break;
|
|
652
1104
|
}
|
|
653
1105
|
throw new Error('order 模块未初始化');
|
|
654
1106
|
case 3:
|
|
655
|
-
|
|
1107
|
+
_context11.next = 5;
|
|
656
1108
|
return this.store.order.getOrderSummary();
|
|
657
1109
|
case 5:
|
|
658
|
-
summary =
|
|
659
|
-
return
|
|
1110
|
+
summary = _context11.sent;
|
|
1111
|
+
return _context11.abrupt("return", summary);
|
|
660
1112
|
case 9:
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
throw
|
|
1113
|
+
_context11.prev = 9;
|
|
1114
|
+
_context11.t0 = _context11["catch"](0);
|
|
1115
|
+
throw _context11.t0;
|
|
1116
|
+
case 12:
|
|
1117
|
+
case "end":
|
|
1118
|
+
return _context11.stop();
|
|
1119
|
+
}
|
|
1120
|
+
}, _callee11, this, [[0, 9]]);
|
|
1121
|
+
}));
|
|
1122
|
+
function getSummary() {
|
|
1123
|
+
return _getSummary.apply(this, arguments);
|
|
1124
|
+
}
|
|
1125
|
+
return getSummary;
|
|
1126
|
+
}()
|
|
1127
|
+
}, {
|
|
1128
|
+
key: "getHistoricalProductDiscountList",
|
|
1129
|
+
value: function getHistoricalProductDiscountList(products) {
|
|
1130
|
+
var _this5 = this;
|
|
1131
|
+
var historyDiscountList = [];
|
|
1132
|
+
products.forEach(function (item) {
|
|
1133
|
+
if (!_this5.isPersistedOrderProduct(item)) return;
|
|
1134
|
+
(item.discount_list || []).forEach(function (discount) {
|
|
1135
|
+
var _discount$discount, _discount$metadata, _discount$discount2, _discount$discount3, _discount$discount4;
|
|
1136
|
+
var discountId = ((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) || discount.id;
|
|
1137
|
+
if (!discountId || !['good_pass', 'discount_card'].includes(discount.type)) return;
|
|
1138
|
+
var quantity = item.quantity || item.num || item.product_quantity || 1;
|
|
1139
|
+
var savedAmount = new Decimal(discount.amount || 0).times(quantity).plus((discount === null || discount === void 0 || (_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.product_discount_difference) || 0);
|
|
1140
|
+
var index = historyDiscountList.findIndex(function (n) {
|
|
1141
|
+
return n.id === discountId;
|
|
1142
|
+
});
|
|
1143
|
+
if (index !== -1) {
|
|
1144
|
+
historyDiscountList[index] = _objectSpread(_objectSpread({}, historyDiscountList[index]), {}, {
|
|
1145
|
+
amount: new Decimal(historyDiscountList[index].amount || 0).plus(discount.amount || 0).toNumber(),
|
|
1146
|
+
savedAmount: savedAmount.plus(historyDiscountList[index].savedAmount || 0).toNumber()
|
|
1147
|
+
});
|
|
1148
|
+
return;
|
|
1149
|
+
}
|
|
1150
|
+
historyDiscountList.push(_objectSpread(_objectSpread({}, discount), {}, {
|
|
1151
|
+
id: discountId,
|
|
1152
|
+
tag: discount.tag || discount.type,
|
|
1153
|
+
name: discount.name || ((_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 || (_discount$discount2 = _discount$discount2.title) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.auto),
|
|
1154
|
+
format_title: ((_discount$discount3 = discount.discount) === null || _discount$discount3 === void 0 ? void 0 : _discount$discount3.title) || discount.format_title,
|
|
1155
|
+
isEditMode: true,
|
|
1156
|
+
limited_relation_product_data: {},
|
|
1157
|
+
savedAmount: savedAmount.toNumber(),
|
|
1158
|
+
isAvailable: true,
|
|
1159
|
+
isDisabled: true,
|
|
1160
|
+
isSelected: true,
|
|
1161
|
+
product_id: ((_discount$discount4 = discount.discount) === null || _discount$discount4 === void 0 ? void 0 : _discount$discount4.product_id) || discount.product_id
|
|
1162
|
+
}));
|
|
1163
|
+
});
|
|
1164
|
+
});
|
|
1165
|
+
return historyDiscountList;
|
|
1166
|
+
}
|
|
1167
|
+
}, {
|
|
1168
|
+
key: "isPersistedOrderProduct",
|
|
1169
|
+
value: function isPersistedOrderProduct(product) {
|
|
1170
|
+
var _product$order_detail, _product$booking_id;
|
|
1171
|
+
var orderDetailId = (_product$order_detail = product.order_detail_id) !== null && _product$order_detail !== void 0 ? _product$order_detail : product.orderDetailId;
|
|
1172
|
+
if (orderDetailId !== undefined && orderDetailId !== null && orderDetailId !== '') {
|
|
1173
|
+
return true;
|
|
1174
|
+
}
|
|
1175
|
+
var bookingId = (_product$booking_id = product.booking_id) !== null && _product$booking_id !== void 0 ? _product$booking_id : product.bookingId;
|
|
1176
|
+
return bookingId !== undefined && bookingId !== null && bookingId !== '';
|
|
1177
|
+
}
|
|
1178
|
+
}, {
|
|
1179
|
+
key: "mergeHistoricalDiscountList",
|
|
1180
|
+
value: function mergeHistoricalDiscountList(discountList, products) {
|
|
1181
|
+
var historyDiscountList = this.getHistoricalProductDiscountList(products);
|
|
1182
|
+
var historyIds = new Set(historyDiscountList.map(function (discount) {
|
|
1183
|
+
return discount.id;
|
|
1184
|
+
}));
|
|
1185
|
+
return [].concat(_toConsumableArray(historyDiscountList), _toConsumableArray((discountList || []).filter(function (discount) {
|
|
1186
|
+
return !historyIds.has(discount.id);
|
|
1187
|
+
})));
|
|
1188
|
+
}
|
|
1189
|
+
}, {
|
|
1190
|
+
key: "mergeCurrentDiscountSelectionState",
|
|
1191
|
+
value: function mergeCurrentDiscountSelectionState(discountList, currentDiscountList) {
|
|
1192
|
+
if (!currentDiscountList.length) return discountList;
|
|
1193
|
+
var currentDiscountMap = new Map(currentDiscountList.map(function (discount) {
|
|
1194
|
+
return [discount.id, discount];
|
|
1195
|
+
}));
|
|
1196
|
+
return discountList.map(function (discount) {
|
|
1197
|
+
var currentDiscount = currentDiscountMap.get(discount.id);
|
|
1198
|
+
if (!currentDiscount) return discount;
|
|
1199
|
+
if (currentDiscount.isManualSelect) {
|
|
1200
|
+
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
1201
|
+
isSelected: false,
|
|
1202
|
+
isManualSelect: true
|
|
1203
|
+
});
|
|
1204
|
+
}
|
|
1205
|
+
if (currentDiscount.isSelected) {
|
|
1206
|
+
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
1207
|
+
isSelected: true,
|
|
1208
|
+
isManualSelect: false
|
|
1209
|
+
});
|
|
1210
|
+
}
|
|
1211
|
+
return discount;
|
|
1212
|
+
});
|
|
1213
|
+
}
|
|
1214
|
+
}, {
|
|
1215
|
+
key: "loadDiscountConfig",
|
|
1216
|
+
value: function () {
|
|
1217
|
+
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(params) {
|
|
1218
|
+
var _this$getOrderIdentit, _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _discountModule$getDi, _discountModule$getOr, _discountModule$getDi2;
|
|
1219
|
+
var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, discountConfigCacheKey, preparedDiscountList, _discountModule$setOr, nextDiscountList, _tempOrder$holder, _tempOrder$holder2, _orderStore$summary, holders, result, _iterator, _step, _product$metadata2, _tempOrder$_extend3, _product$metadata3, _product$metadata$sou, _product$metadata4, _product$metadata5, _product$original_pri, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice, summary;
|
|
1220
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
1221
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1222
|
+
case 0:
|
|
1223
|
+
if (this.store.order) {
|
|
1224
|
+
_context12.next = 2;
|
|
1225
|
+
break;
|
|
1226
|
+
}
|
|
1227
|
+
throw new Error('order 模块未初始化');
|
|
1228
|
+
case 2:
|
|
1229
|
+
tempOrder = this.store.order.ensureTempOrder();
|
|
1230
|
+
orderStore = this.store.order.store || {};
|
|
1231
|
+
discountModule = orderStore.discount;
|
|
1232
|
+
rulesModule = orderStore.rules;
|
|
1233
|
+
orderId = tempOrder.order_id || ((_this$getOrderIdentit = this.getOrderIdentity) === null || _this$getOrderIdentit === void 0 || (_this$getOrderIdentit = _this$getOrderIdentit.call(this)) === null || _this$getOrderIdentit === void 0 ? void 0 : _this$getOrderIdentit.orderId);
|
|
1234
|
+
customerId = Number((params === null || params === void 0 ? void 0 : params.customerId) || 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);
|
|
1235
|
+
currentDiscountList = (discountModule === null || discountModule === void 0 || (_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
|
|
1236
|
+
originalDiscountList = (discountModule === null || discountModule === void 0 || (_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
|
|
1237
|
+
hasManualDiscountSelection = this.hasManualDiscountSelection || currentDiscountList.some(function (discount) {
|
|
1238
|
+
return discount.isManualSelect;
|
|
1239
|
+
});
|
|
1240
|
+
discountAction = (params === null || params === void 0 ? void 0 : params.action) || (orderId ? 'edit' : 'create');
|
|
1241
|
+
discountConfigCacheKey = [customerId, discountAction, Number(orderId) || 0].join(':');
|
|
1242
|
+
preparedDiscountList = [];
|
|
1243
|
+
if (!(customerId && customerId !== 1)) {
|
|
1244
|
+
_context12.next = 25;
|
|
1245
|
+
break;
|
|
1246
|
+
}
|
|
1247
|
+
if (!(this.discountConfigCacheKey === discountConfigCacheKey)) {
|
|
1248
|
+
_context12.next = 19;
|
|
1249
|
+
break;
|
|
1250
|
+
}
|
|
1251
|
+
preparedDiscountList = originalDiscountList;
|
|
1252
|
+
_context12.next = 25;
|
|
1253
|
+
break;
|
|
1254
|
+
case 19:
|
|
1255
|
+
_context12.next = 21;
|
|
1256
|
+
return this.store.order.loadDiscountConfig({
|
|
1257
|
+
customerId: customerId,
|
|
1258
|
+
action: discountAction,
|
|
1259
|
+
orderId: Number(orderId) || undefined,
|
|
1260
|
+
apply: false
|
|
1261
|
+
});
|
|
1262
|
+
case 21:
|
|
1263
|
+
preparedDiscountList = _context12.sent;
|
|
1264
|
+
this.discountConfigCacheKey = discountConfigCacheKey;
|
|
1265
|
+
_context12.next = 25;
|
|
1266
|
+
return discountModule === null || discountModule === void 0 || (_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, preparedDiscountList);
|
|
1267
|
+
case 25:
|
|
1268
|
+
if (!(hasManualDiscountSelection && currentDiscountList.length)) {
|
|
1269
|
+
_context12.next = 27;
|
|
1270
|
+
break;
|
|
1271
|
+
}
|
|
1272
|
+
return _context12.abrupt("return", {
|
|
1273
|
+
productList: tempOrder.products || [],
|
|
1274
|
+
discountList: currentDiscountList
|
|
1275
|
+
});
|
|
1276
|
+
case 27:
|
|
1277
|
+
nextDiscountList = this.mergeHistoricalDiscountList(preparedDiscountList || (discountModule === null || discountModule === void 0 || (_discountModule$getDi2 = discountModule.getDiscountList) === null || _discountModule$getDi2 === void 0 ? void 0 : _discountModule$getDi2.call(discountModule)) || [], tempOrder.products || []);
|
|
1278
|
+
nextDiscountList = this.mergeCurrentDiscountSelectionState(nextDiscountList, currentDiscountList);
|
|
1279
|
+
_context12.next = 31;
|
|
1280
|
+
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1281
|
+
case 31:
|
|
1282
|
+
if (!rulesModule) {
|
|
1283
|
+
_context12.next = 67;
|
|
1284
|
+
break;
|
|
1285
|
+
}
|
|
1286
|
+
holders = (_tempOrder$holder = tempOrder.holder) !== null && _tempOrder$holder !== void 0 && _tempOrder$holder.form_record_id ? [{
|
|
1287
|
+
form_record_id: tempOrder.holder.form_record_id
|
|
1288
|
+
}] : [];
|
|
1289
|
+
result = rulesModule.calcDiscount({
|
|
1290
|
+
productList: tempOrder.products,
|
|
1291
|
+
discountList: nextDiscountList,
|
|
1292
|
+
holders: holders,
|
|
1293
|
+
isFormSubject: !!((_tempOrder$holder2 = tempOrder.holder) !== null && _tempOrder$holder2 !== void 0 && _tempOrder$holder2.type) && tempOrder.holder.type === 'form',
|
|
1294
|
+
orderTotalAmount: Number(((_orderStore$summary = orderStore.summary) === null || _orderStore$summary === void 0 ? void 0 : _orderStore$summary.total_amount) || 0)
|
|
1295
|
+
}) || {
|
|
1296
|
+
productList: tempOrder.products,
|
|
1297
|
+
discountList: nextDiscountList
|
|
1298
|
+
};
|
|
1299
|
+
if (result.productList) {
|
|
1300
|
+
tempOrder.products = result.productList;
|
|
1301
|
+
}
|
|
1302
|
+
_iterator = _createForOfIteratorHelper(tempOrder.products || []);
|
|
1303
|
+
_context12.prev = 36;
|
|
1304
|
+
_iterator.s();
|
|
1305
|
+
case 38:
|
|
1306
|
+
if ((_step = _iterator.n()).done) {
|
|
1307
|
+
_context12.next = 53;
|
|
1308
|
+
break;
|
|
1309
|
+
}
|
|
1310
|
+
product = _step.value;
|
|
1311
|
+
productUid = (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.unique_identification_number;
|
|
1312
|
+
runtimeOrigin = productUid ? (_tempOrder$_extend3 = tempOrder._extend) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3.productsByUid) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3[productUid]) === null || _tempOrder$_extend3 === void 0 ? void 0 : _tempOrder$_extend3.origin : undefined;
|
|
1313
|
+
if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || (_product$metadata3 = product.metadata) !== null && _product$metadata3 !== void 0 && _product$metadata3.is_manual_discount)) {
|
|
1314
|
+
_context12.next = 44;
|
|
1315
|
+
break;
|
|
1316
|
+
}
|
|
1317
|
+
return _context12.abrupt("continue", 51);
|
|
1318
|
+
case 44:
|
|
1319
|
+
totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
|
|
1320
|
+
return sum + Number(pd.amount || 0);
|
|
1321
|
+
}, 0);
|
|
1322
|
+
optionSum = sumOptionUnitPrice(product.product_option_item);
|
|
1323
|
+
sourcePrice = (_product$metadata$sou = (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.source_product_price) !== null && _product$metadata$sou !== void 0 ? _product$metadata$sou : ((_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.main_product_original_price) != null ? new Decimal(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : (_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : '0';
|
|
1324
|
+
newSourceSellingPrice = new Decimal(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
1325
|
+
newMainSellingPrice = new Decimal(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
1326
|
+
if (product.metadata) {
|
|
1327
|
+
product.metadata.main_product_selling_price = newMainSellingPrice;
|
|
1328
|
+
product.metadata.price_schema_version = 2;
|
|
1329
|
+
}
|
|
1330
|
+
product.selling_price = composeLinePrice({
|
|
1331
|
+
mainPrice: newMainSellingPrice,
|
|
1332
|
+
bundle: product.product_bundle
|
|
1333
|
+
});
|
|
1334
|
+
case 51:
|
|
1335
|
+
_context12.next = 38;
|
|
1336
|
+
break;
|
|
1337
|
+
case 53:
|
|
1338
|
+
_context12.next = 58;
|
|
1339
|
+
break;
|
|
1340
|
+
case 55:
|
|
1341
|
+
_context12.prev = 55;
|
|
1342
|
+
_context12.t0 = _context12["catch"](36);
|
|
1343
|
+
_iterator.e(_context12.t0);
|
|
1344
|
+
case 58:
|
|
1345
|
+
_context12.prev = 58;
|
|
1346
|
+
_iterator.f();
|
|
1347
|
+
return _context12.finish(58);
|
|
1348
|
+
case 61:
|
|
1349
|
+
if (!result.discountList) {
|
|
1350
|
+
_context12.next = 67;
|
|
1351
|
+
break;
|
|
1352
|
+
}
|
|
1353
|
+
nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
|
|
1354
|
+
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
1355
|
+
_context12.next = 66;
|
|
1356
|
+
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1357
|
+
case 66:
|
|
1358
|
+
tempOrder.discount_list = nextDiscountList.filter(function (discount) {
|
|
1359
|
+
return discount.isSelected;
|
|
1360
|
+
});
|
|
1361
|
+
case 67:
|
|
1362
|
+
_context12.next = 69;
|
|
1363
|
+
return this.store.order.recalculateSummary({
|
|
1364
|
+
createIfMissing: true
|
|
1365
|
+
});
|
|
1366
|
+
case 69:
|
|
1367
|
+
summary = _context12.sent;
|
|
1368
|
+
this.store.order.persistTempOrder();
|
|
1369
|
+
_context12.next = 73;
|
|
1370
|
+
return this.effectsEmit('onDiscountApplied', {
|
|
1371
|
+
productList: tempOrder.products || [],
|
|
1372
|
+
discountList: nextDiscountList,
|
|
1373
|
+
selectedDiscountList: tempOrder.discount_list || [],
|
|
1374
|
+
tempOrder: tempOrder
|
|
1375
|
+
});
|
|
1376
|
+
case 73:
|
|
1377
|
+
return _context12.abrupt("return", {
|
|
1378
|
+
productList: tempOrder.products || [],
|
|
1379
|
+
discountList: nextDiscountList
|
|
1380
|
+
});
|
|
1381
|
+
case 74:
|
|
1382
|
+
case "end":
|
|
1383
|
+
return _context12.stop();
|
|
1384
|
+
}
|
|
1385
|
+
}, _callee12, this, [[36, 55, 58, 61]]);
|
|
1386
|
+
}));
|
|
1387
|
+
function loadDiscountConfig(_x7) {
|
|
1388
|
+
return _loadDiscountConfig.apply(this, arguments);
|
|
1389
|
+
}
|
|
1390
|
+
return loadDiscountConfig;
|
|
1391
|
+
}()
|
|
1392
|
+
}, {
|
|
1393
|
+
key: "bestDiscount",
|
|
1394
|
+
value: function () {
|
|
1395
|
+
var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(cb) {
|
|
1396
|
+
var _discountModule$getOr2, _discountModule$getDi3;
|
|
1397
|
+
var tempOrder, orderStore, discountModule, rulesModule, originalDiscountList, currentDiscountList, nextDiscountList, result, _tempOrder$holder3, _tempOrder$holder4, _orderStore$summary2, holders;
|
|
1398
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1399
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1400
|
+
case 0:
|
|
1401
|
+
if (this.store.order) {
|
|
1402
|
+
_context13.next = 2;
|
|
1403
|
+
break;
|
|
1404
|
+
}
|
|
1405
|
+
throw new Error('order 模块未初始化');
|
|
1406
|
+
case 2:
|
|
1407
|
+
tempOrder = this.store.order.ensureTempOrder();
|
|
1408
|
+
orderStore = this.store.order.store || {};
|
|
1409
|
+
discountModule = orderStore.discount;
|
|
1410
|
+
rulesModule = orderStore.rules;
|
|
1411
|
+
originalDiscountList = (discountModule === null || discountModule === void 0 || (_discountModule$getOr2 = discountModule.getOriginalDiscountList) === null || _discountModule$getOr2 === void 0 ? void 0 : _discountModule$getOr2.call(discountModule)) || this.getDiscountList();
|
|
1412
|
+
currentDiscountList = (discountModule === null || discountModule === void 0 || (_discountModule$getDi3 = discountModule.getDiscountList) === null || _discountModule$getDi3 === void 0 ? void 0 : _discountModule$getDi3.call(discountModule)) || [];
|
|
1413
|
+
nextDiscountList = this.mergeHistoricalDiscountList(originalDiscountList || [], tempOrder.products || []);
|
|
1414
|
+
result = {
|
|
1415
|
+
productList: tempOrder.products || [],
|
|
1416
|
+
discountList: nextDiscountList
|
|
1417
|
+
};
|
|
1418
|
+
_context13.next = 12;
|
|
1419
|
+
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
664
1420
|
case 12:
|
|
1421
|
+
if (!rulesModule) {
|
|
1422
|
+
_context13.next = 23;
|
|
1423
|
+
break;
|
|
1424
|
+
}
|
|
1425
|
+
holders = (_tempOrder$holder3 = tempOrder.holder) !== null && _tempOrder$holder3 !== void 0 && _tempOrder$holder3.form_record_id ? [{
|
|
1426
|
+
form_record_id: tempOrder.holder.form_record_id
|
|
1427
|
+
}] : [];
|
|
1428
|
+
result = rulesModule.calcDiscount({
|
|
1429
|
+
productList: tempOrder.products,
|
|
1430
|
+
discountList: nextDiscountList,
|
|
1431
|
+
holders: holders,
|
|
1432
|
+
isFormSubject: !!((_tempOrder$holder4 = tempOrder.holder) !== null && _tempOrder$holder4 !== void 0 && _tempOrder$holder4.type) && tempOrder.holder.type === 'form',
|
|
1433
|
+
orderTotalAmount: Number(((_orderStore$summary2 = orderStore.summary) === null || _orderStore$summary2 === void 0 ? void 0 : _orderStore$summary2.total_amount) || 0)
|
|
1434
|
+
}) || result;
|
|
1435
|
+
if (result.productList) {
|
|
1436
|
+
tempOrder.products = result.productList;
|
|
1437
|
+
}
|
|
1438
|
+
if (!result.discountList) {
|
|
1439
|
+
_context13.next = 23;
|
|
1440
|
+
break;
|
|
1441
|
+
}
|
|
1442
|
+
nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
|
|
1443
|
+
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
1444
|
+
_context13.next = 21;
|
|
1445
|
+
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1446
|
+
case 21:
|
|
1447
|
+
tempOrder.discount_list = nextDiscountList.filter(function (discount) {
|
|
1448
|
+
return discount.isSelected;
|
|
1449
|
+
});
|
|
1450
|
+
result = {
|
|
1451
|
+
productList: tempOrder.products,
|
|
1452
|
+
discountList: nextDiscountList
|
|
1453
|
+
};
|
|
1454
|
+
case 23:
|
|
1455
|
+
_context13.next = 25;
|
|
1456
|
+
return this.store.order.recalculateSummary({
|
|
1457
|
+
createIfMissing: true
|
|
1458
|
+
});
|
|
1459
|
+
case 25:
|
|
1460
|
+
this.store.order.persistTempOrder();
|
|
1461
|
+
cb === null || cb === void 0 || cb(result);
|
|
1462
|
+
return _context13.abrupt("return", result);
|
|
1463
|
+
case 28:
|
|
665
1464
|
case "end":
|
|
666
|
-
return
|
|
1465
|
+
return _context13.stop();
|
|
667
1466
|
}
|
|
668
|
-
},
|
|
1467
|
+
}, _callee13, this);
|
|
669
1468
|
}));
|
|
670
|
-
function
|
|
671
|
-
return
|
|
1469
|
+
function bestDiscount(_x8) {
|
|
1470
|
+
return _bestDiscount.apply(this, arguments);
|
|
672
1471
|
}
|
|
673
|
-
return
|
|
1472
|
+
return bestDiscount;
|
|
674
1473
|
}()
|
|
675
1474
|
}, {
|
|
676
1475
|
key: "getDiscountList",
|
|
@@ -681,49 +1480,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
681
1480
|
}, {
|
|
682
1481
|
key: "scanPromotionCode",
|
|
683
1482
|
value: function () {
|
|
684
|
-
var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1483
|
+
var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(code, customerId) {
|
|
685
1484
|
var raw;
|
|
686
|
-
return _regeneratorRuntime().wrap(function
|
|
687
|
-
while (1) switch (
|
|
1485
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1486
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
688
1487
|
case 0:
|
|
689
|
-
|
|
1488
|
+
_context14.prev = 0;
|
|
690
1489
|
if (this.store.order) {
|
|
691
|
-
|
|
1490
|
+
_context14.next = 3;
|
|
692
1491
|
break;
|
|
693
1492
|
}
|
|
694
1493
|
throw new Error('order 模块未初始化');
|
|
695
1494
|
case 3:
|
|
696
|
-
|
|
1495
|
+
_context14.next = 5;
|
|
697
1496
|
return this.store.order.scanCode(code, customerId);
|
|
698
1497
|
case 5:
|
|
699
|
-
raw =
|
|
1498
|
+
raw = _context14.sent;
|
|
700
1499
|
if (!raw.isAvailable) {
|
|
701
|
-
|
|
1500
|
+
_context14.next = 10;
|
|
702
1501
|
break;
|
|
703
1502
|
}
|
|
704
|
-
|
|
1503
|
+
_context14.next = 9;
|
|
705
1504
|
return this.store.order.recalculateSummary({
|
|
706
1505
|
createIfMissing: true
|
|
707
1506
|
});
|
|
708
1507
|
case 9:
|
|
709
1508
|
this.store.order.persistTempOrder();
|
|
710
1509
|
case 10:
|
|
711
|
-
return
|
|
1510
|
+
return _context14.abrupt("return", {
|
|
712
1511
|
isAvailable: raw.isAvailable,
|
|
713
1512
|
type: raw.type,
|
|
714
1513
|
unavailableReason: raw.unavailableReason
|
|
715
1514
|
});
|
|
716
1515
|
case 13:
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
throw
|
|
1516
|
+
_context14.prev = 13;
|
|
1517
|
+
_context14.t0 = _context14["catch"](0);
|
|
1518
|
+
throw _context14.t0;
|
|
720
1519
|
case 16:
|
|
721
1520
|
case "end":
|
|
722
|
-
return
|
|
1521
|
+
return _context14.stop();
|
|
723
1522
|
}
|
|
724
|
-
},
|
|
1523
|
+
}, _callee14, this, [[0, 13]]);
|
|
725
1524
|
}));
|
|
726
|
-
function scanPromotionCode(
|
|
1525
|
+
function scanPromotionCode(_x9, _x10) {
|
|
727
1526
|
return _scanPromotionCode.apply(this, arguments);
|
|
728
1527
|
}
|
|
729
1528
|
return scanPromotionCode;
|
|
@@ -731,14 +1530,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
731
1530
|
}, {
|
|
732
1531
|
key: "setDiscountSelected",
|
|
733
1532
|
value: function () {
|
|
734
|
-
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
735
|
-
var _tempOrder$
|
|
736
|
-
return _regeneratorRuntime().wrap(function
|
|
737
|
-
while (1) switch (
|
|
1533
|
+
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
|
|
1534
|
+
var _tempOrder$holder5, list, updated, tempOrder, orderStore, discountModule, rulesModule, holders, nextDiscountList, _tempOrder$holder6, result, beforeSelectedIds, _iterator2, _step2, d, selectedResourceIds, _iterator3, _step3, _product$metadata6, _tempOrder$_extend4, _product$metadata7, _product$metadata$sou2, _product$metadata8, _product$metadata9, _product$original_pri2, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
|
|
1535
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1536
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
738
1537
|
case 0:
|
|
739
|
-
|
|
1538
|
+
_context15.prev = 0;
|
|
740
1539
|
if (this.store.order) {
|
|
741
|
-
|
|
1540
|
+
_context15.next = 3;
|
|
742
1541
|
break;
|
|
743
1542
|
}
|
|
744
1543
|
throw new Error('order 模块未初始化');
|
|
@@ -750,23 +1549,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
750
1549
|
isManualSelect: !params.isSelected
|
|
751
1550
|
}) : d;
|
|
752
1551
|
});
|
|
1552
|
+
this.hasManualDiscountSelection = true;
|
|
753
1553
|
tempOrder = this.store.order.ensureTempOrder();
|
|
754
1554
|
orderStore = this.store.order.store || {};
|
|
755
1555
|
discountModule = orderStore.discount;
|
|
756
1556
|
rulesModule = orderStore.rules;
|
|
757
|
-
holders = (_tempOrder$
|
|
1557
|
+
holders = (_tempOrder$holder5 = tempOrder.holder) !== null && _tempOrder$holder5 !== void 0 && _tempOrder$holder5.form_record_id ? [{
|
|
758
1558
|
form_record_id: tempOrder.holder.form_record_id
|
|
759
1559
|
}] : [];
|
|
760
1560
|
nextDiscountList = updated;
|
|
761
|
-
|
|
1561
|
+
_context15.next = 14;
|
|
762
1562
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(updated);
|
|
763
|
-
case
|
|
1563
|
+
case 14:
|
|
764
1564
|
if (rulesModule) {
|
|
765
1565
|
result = rulesModule.calcDiscount({
|
|
766
1566
|
productList: tempOrder.products,
|
|
767
1567
|
discountList: updated,
|
|
768
1568
|
holders: holders,
|
|
769
|
-
isFormSubject: !!((_tempOrder$
|
|
1569
|
+
isFormSubject: !!((_tempOrder$holder6 = tempOrder.holder) !== null && _tempOrder$holder6 !== void 0 && _tempOrder$holder6.type) && tempOrder.holder.type === 'form'
|
|
770
1570
|
}, {
|
|
771
1571
|
discountId: params.discountId,
|
|
772
1572
|
isSelected: params.isSelected
|
|
@@ -785,18 +1585,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
785
1585
|
}).map(function (d) {
|
|
786
1586
|
return d.id;
|
|
787
1587
|
}));
|
|
788
|
-
|
|
1588
|
+
_iterator2 = _createForOfIteratorHelper(nextDiscountList);
|
|
789
1589
|
try {
|
|
790
|
-
for (
|
|
791
|
-
d =
|
|
1590
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
1591
|
+
d = _step2.value;
|
|
792
1592
|
if (d.isSelected && !beforeSelectedIds.has(d.id)) {
|
|
793
1593
|
d.isSelected = false;
|
|
1594
|
+
d.isManualSelect = true;
|
|
794
1595
|
}
|
|
795
1596
|
}
|
|
796
1597
|
} catch (err) {
|
|
797
|
-
|
|
1598
|
+
_iterator2.e(err);
|
|
798
1599
|
} finally {
|
|
799
|
-
|
|
1600
|
+
_iterator2.f();
|
|
800
1601
|
}
|
|
801
1602
|
}
|
|
802
1603
|
}
|
|
@@ -806,23 +1607,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
806
1607
|
}).map(function (d) {
|
|
807
1608
|
return d.id;
|
|
808
1609
|
}));
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
case
|
|
813
|
-
if ((
|
|
814
|
-
|
|
1610
|
+
_iterator3 = _createForOfIteratorHelper(tempOrder.products);
|
|
1611
|
+
_context15.prev = 17;
|
|
1612
|
+
_iterator3.s();
|
|
1613
|
+
case 19:
|
|
1614
|
+
if ((_step3 = _iterator3.n()).done) {
|
|
1615
|
+
_context15.next = 35;
|
|
815
1616
|
break;
|
|
816
1617
|
}
|
|
817
|
-
product =
|
|
818
|
-
productUid = (_product$
|
|
819
|
-
runtimeOrigin = productUid ? (_tempOrder$
|
|
820
|
-
if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || (_product$
|
|
821
|
-
|
|
1618
|
+
product = _step3.value;
|
|
1619
|
+
productUid = (_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.unique_identification_number;
|
|
1620
|
+
runtimeOrigin = productUid ? (_tempOrder$_extend4 = tempOrder._extend) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4.productsByUid) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4[productUid]) === null || _tempOrder$_extend4 === void 0 ? void 0 : _tempOrder$_extend4.origin : undefined;
|
|
1621
|
+
if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || (_product$metadata7 = product.metadata) !== null && _product$metadata7 !== void 0 && _product$metadata7.is_manual_discount)) {
|
|
1622
|
+
_context15.next = 25;
|
|
822
1623
|
break;
|
|
823
1624
|
}
|
|
824
|
-
return
|
|
825
|
-
case
|
|
1625
|
+
return _context15.abrupt("continue", 33);
|
|
1626
|
+
case 25:
|
|
826
1627
|
product.discount_list = (product.discount_list || []).filter(function (pd) {
|
|
827
1628
|
var _pd$discount$resource, _pd$discount;
|
|
828
1629
|
var rid = (_pd$discount$resource = (_pd$discount = pd.discount) === null || _pd$discount === void 0 ? void 0 : _pd$discount.resource_id) !== null && _pd$discount$resource !== void 0 ? _pd$discount$resource : pd.id;
|
|
@@ -835,7 +1636,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
835
1636
|
return sum + (pd.amount || 0);
|
|
836
1637
|
}, 0); // TODO 这块逻辑需要拿掉
|
|
837
1638
|
optionSum = sumOptionUnitPrice(product.product_option_item);
|
|
838
|
-
sourcePrice = (_product$metadata$
|
|
1639
|
+
sourcePrice = (_product$metadata$sou2 = (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.source_product_price) !== null && _product$metadata$sou2 !== void 0 ? _product$metadata$sou2 : ((_product$metadata9 = product.metadata) === null || _product$metadata9 === void 0 ? void 0 : _product$metadata9.main_product_original_price) != null ? new Decimal(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : (_product$original_pri2 = product.original_price) !== null && _product$original_pri2 !== void 0 ? _product$original_pri2 : '0';
|
|
839
1640
|
newSourceSellingPrice = new Decimal(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
840
1641
|
newMainSellingPrice = new Decimal(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
841
1642
|
if (product.metadata) {
|
|
@@ -846,66 +1647,134 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
846
1647
|
mainPrice: newMainSellingPrice,
|
|
847
1648
|
bundle: product.product_bundle
|
|
848
1649
|
});
|
|
849
|
-
case
|
|
850
|
-
|
|
1650
|
+
case 33:
|
|
1651
|
+
_context15.next = 19;
|
|
851
1652
|
break;
|
|
852
|
-
case
|
|
853
|
-
|
|
1653
|
+
case 35:
|
|
1654
|
+
_context15.next = 40;
|
|
854
1655
|
break;
|
|
855
|
-
case
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
case
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
return
|
|
863
|
-
case
|
|
1656
|
+
case 37:
|
|
1657
|
+
_context15.prev = 37;
|
|
1658
|
+
_context15.t0 = _context15["catch"](17);
|
|
1659
|
+
_iterator3.e(_context15.t0);
|
|
1660
|
+
case 40:
|
|
1661
|
+
_context15.prev = 40;
|
|
1662
|
+
_iterator3.f();
|
|
1663
|
+
return _context15.finish(40);
|
|
1664
|
+
case 43:
|
|
864
1665
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
865
|
-
|
|
1666
|
+
_context15.next = 46;
|
|
866
1667
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
867
|
-
case
|
|
1668
|
+
case 46:
|
|
868
1669
|
tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
|
|
869
1670
|
return d.isSelected;
|
|
870
1671
|
});
|
|
871
|
-
|
|
1672
|
+
_context15.next = 49;
|
|
872
1673
|
return this.store.order.recalculateSummary({
|
|
873
1674
|
createIfMissing: true
|
|
874
1675
|
});
|
|
875
|
-
case
|
|
1676
|
+
case 49:
|
|
876
1677
|
this.store.order.persistTempOrder();
|
|
877
|
-
|
|
1678
|
+
this.effectsEmit('onDiscountApplied', {
|
|
1679
|
+
productList: tempOrder.products,
|
|
1680
|
+
discountList: nextDiscountList,
|
|
1681
|
+
selectedDiscountList: tempOrder.discount_list,
|
|
1682
|
+
tempOrder: tempOrder
|
|
1683
|
+
});
|
|
1684
|
+
_context15.next = 56;
|
|
878
1685
|
break;
|
|
879
|
-
case
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
throw
|
|
883
|
-
case
|
|
1686
|
+
case 53:
|
|
1687
|
+
_context15.prev = 53;
|
|
1688
|
+
_context15.t1 = _context15["catch"](0);
|
|
1689
|
+
throw _context15.t1;
|
|
1690
|
+
case 56:
|
|
884
1691
|
case "end":
|
|
885
|
-
return
|
|
1692
|
+
return _context15.stop();
|
|
886
1693
|
}
|
|
887
|
-
},
|
|
1694
|
+
}, _callee15, this, [[0, 53], [17, 37, 40, 43]]);
|
|
888
1695
|
}));
|
|
889
|
-
function setDiscountSelected(
|
|
1696
|
+
function setDiscountSelected(_x11) {
|
|
890
1697
|
return _setDiscountSelected.apply(this, arguments);
|
|
891
1698
|
}
|
|
892
1699
|
return setDiscountSelected;
|
|
893
1700
|
}()
|
|
1701
|
+
}, {
|
|
1702
|
+
key: "applyDiscountCalculationResult",
|
|
1703
|
+
value: function () {
|
|
1704
|
+
var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(result) {
|
|
1705
|
+
var tempOrder, orderStore, discountModule;
|
|
1706
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1707
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1708
|
+
case 0:
|
|
1709
|
+
_context16.prev = 0;
|
|
1710
|
+
if (this.store.order) {
|
|
1711
|
+
_context16.next = 3;
|
|
1712
|
+
break;
|
|
1713
|
+
}
|
|
1714
|
+
throw new Error('order 模块未初始化');
|
|
1715
|
+
case 3:
|
|
1716
|
+
if (result) {
|
|
1717
|
+
_context16.next = 5;
|
|
1718
|
+
break;
|
|
1719
|
+
}
|
|
1720
|
+
return _context16.abrupt("return");
|
|
1721
|
+
case 5:
|
|
1722
|
+
tempOrder = this.store.order.ensureTempOrder();
|
|
1723
|
+
orderStore = this.store.order.store || {};
|
|
1724
|
+
discountModule = orderStore.discount;
|
|
1725
|
+
if (result.productList) {
|
|
1726
|
+
tempOrder.products = result.productList;
|
|
1727
|
+
}
|
|
1728
|
+
if (!result.discountList) {
|
|
1729
|
+
_context16.next = 14;
|
|
1730
|
+
break;
|
|
1731
|
+
}
|
|
1732
|
+
OrderModule.populateSavedAmounts(tempOrder.products, result.discountList);
|
|
1733
|
+
_context16.next = 13;
|
|
1734
|
+
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(result.discountList);
|
|
1735
|
+
case 13:
|
|
1736
|
+
tempOrder.discount_list = result.discountList.filter(function (discount) {
|
|
1737
|
+
return discount.isSelected;
|
|
1738
|
+
});
|
|
1739
|
+
case 14:
|
|
1740
|
+
_context16.next = 16;
|
|
1741
|
+
return this.store.order.recalculateSummary({
|
|
1742
|
+
createIfMissing: true
|
|
1743
|
+
});
|
|
1744
|
+
case 16:
|
|
1745
|
+
this.store.order.persistTempOrder();
|
|
1746
|
+
_context16.next = 22;
|
|
1747
|
+
break;
|
|
1748
|
+
case 19:
|
|
1749
|
+
_context16.prev = 19;
|
|
1750
|
+
_context16.t0 = _context16["catch"](0);
|
|
1751
|
+
throw _context16.t0;
|
|
1752
|
+
case 22:
|
|
1753
|
+
case "end":
|
|
1754
|
+
return _context16.stop();
|
|
1755
|
+
}
|
|
1756
|
+
}, _callee16, this, [[0, 19]]);
|
|
1757
|
+
}));
|
|
1758
|
+
function applyDiscountCalculationResult(_x12) {
|
|
1759
|
+
return _applyDiscountCalculationResult.apply(this, arguments);
|
|
1760
|
+
}
|
|
1761
|
+
return applyDiscountCalculationResult;
|
|
1762
|
+
}()
|
|
894
1763
|
}, {
|
|
895
1764
|
key: "submitScanOrder",
|
|
896
1765
|
value: function () {
|
|
897
|
-
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
898
|
-
return _regeneratorRuntime().wrap(function
|
|
899
|
-
while (1) switch (
|
|
1766
|
+
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params) {
|
|
1767
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1768
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
900
1769
|
case 0:
|
|
901
|
-
return
|
|
1770
|
+
return _context17.abrupt("return", this.submitSalesOrder(params));
|
|
902
1771
|
case 1:
|
|
903
1772
|
case "end":
|
|
904
|
-
return
|
|
1773
|
+
return _context17.stop();
|
|
905
1774
|
}
|
|
906
|
-
},
|
|
1775
|
+
}, _callee17, this);
|
|
907
1776
|
}));
|
|
908
|
-
function submitScanOrder(
|
|
1777
|
+
function submitScanOrder(_x13) {
|
|
909
1778
|
return _submitScanOrder.apply(this, arguments);
|
|
910
1779
|
}
|
|
911
1780
|
return submitScanOrder;
|
|
@@ -919,14 +1788,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
919
1788
|
}, {
|
|
920
1789
|
key: "submitSalesOrder",
|
|
921
1790
|
value: (function () {
|
|
922
|
-
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
923
|
-
var _this$
|
|
1791
|
+
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(params) {
|
|
1792
|
+
var _this$otherParams6, _this$otherParams7, _this$otherParams8;
|
|
924
1793
|
var submitParams;
|
|
925
|
-
return _regeneratorRuntime().wrap(function
|
|
926
|
-
while (1) switch (
|
|
1794
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1795
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
927
1796
|
case 0:
|
|
928
1797
|
if (this.store.order) {
|
|
929
|
-
|
|
1798
|
+
_context18.next = 2;
|
|
930
1799
|
break;
|
|
931
1800
|
}
|
|
932
1801
|
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
@@ -934,10 +1803,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
934
1803
|
this.store.order.persistTempOrder();
|
|
935
1804
|
submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
936
1805
|
cacheId: this.cacheId,
|
|
937
|
-
platform: (_this$
|
|
938
|
-
businessCode: (_this$
|
|
939
|
-
channel:
|
|
940
|
-
type: (_this$
|
|
1806
|
+
platform: (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform,
|
|
1807
|
+
businessCode: (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.businessCode,
|
|
1808
|
+
channel: this.getSubmitOrderSalesChannel(),
|
|
1809
|
+
type: (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.type
|
|
941
1810
|
}, (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
|
|
942
1811
|
payments: params.payments
|
|
943
1812
|
} : {}), (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined ? {
|
|
@@ -947,14 +1816,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
947
1816
|
} : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
|
|
948
1817
|
enhancePayload: params.enhancePayload
|
|
949
1818
|
} : {});
|
|
950
|
-
|
|
951
|
-
|
|
1819
|
+
console.log(submitParams, 'submitParams123');
|
|
1820
|
+
return _context18.abrupt("return", this.store.order.submitTempOrder(submitParams));
|
|
1821
|
+
case 6:
|
|
952
1822
|
case "end":
|
|
953
|
-
return
|
|
1823
|
+
return _context18.stop();
|
|
954
1824
|
}
|
|
955
|
-
},
|
|
1825
|
+
}, _callee18, this);
|
|
956
1826
|
}));
|
|
957
|
-
function submitSalesOrder(
|
|
1827
|
+
function submitSalesOrder(_x14) {
|
|
958
1828
|
return _submitSalesOrder.apply(this, arguments);
|
|
959
1829
|
}
|
|
960
1830
|
return submitSalesOrder;
|
|
@@ -962,24 +1832,75 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
962
1832
|
}, {
|
|
963
1833
|
key: "syncPaymentsToOrder",
|
|
964
1834
|
value: function () {
|
|
965
|
-
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
966
|
-
|
|
967
|
-
|
|
1835
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
|
|
1836
|
+
var _params$channel;
|
|
1837
|
+
var channel, syncParams, syncState, payments, syncResult;
|
|
1838
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1839
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
968
1840
|
case 0:
|
|
969
1841
|
if (this.store.order) {
|
|
970
|
-
|
|
1842
|
+
_context19.next = 2;
|
|
971
1843
|
break;
|
|
972
1844
|
}
|
|
973
1845
|
throw new Error('order 模块未初始化');
|
|
974
1846
|
case 2:
|
|
975
|
-
|
|
976
|
-
|
|
1847
|
+
channel = (_params$channel = params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel();
|
|
1848
|
+
syncParams = _objectSpread(_objectSpread({}, params), channel !== undefined ? {
|
|
1849
|
+
channel: channel
|
|
1850
|
+
} : {});
|
|
1851
|
+
syncState = this.store.order.getOrderSyncState();
|
|
1852
|
+
if (!(params.submitWhenPaid && syncState === 'submitting')) {
|
|
1853
|
+
_context19.next = 7;
|
|
1854
|
+
break;
|
|
1855
|
+
}
|
|
1856
|
+
return _context19.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
|
|
1857
|
+
case 7:
|
|
1858
|
+
payments = params.payments || [];
|
|
1859
|
+
_context19.next = 10;
|
|
1860
|
+
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncStart, {
|
|
1861
|
+
payments: payments,
|
|
1862
|
+
params: syncParams,
|
|
1863
|
+
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
1864
|
+
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
1865
|
+
});
|
|
1866
|
+
case 10:
|
|
1867
|
+
_context19.prev = 10;
|
|
1868
|
+
_context19.next = 13;
|
|
1869
|
+
return this.store.order.syncPaymentsToOrder(syncParams);
|
|
1870
|
+
case 13:
|
|
1871
|
+
syncResult = _context19.sent;
|
|
1872
|
+
_context19.next = 16;
|
|
1873
|
+
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
|
|
1874
|
+
ok: true,
|
|
1875
|
+
syncResult: syncResult,
|
|
1876
|
+
payments: this.store.order.getOrderPayments(),
|
|
1877
|
+
params: syncParams,
|
|
1878
|
+
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
1879
|
+
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
1880
|
+
});
|
|
1881
|
+
case 16:
|
|
1882
|
+
return _context19.abrupt("return", syncResult);
|
|
1883
|
+
case 19:
|
|
1884
|
+
_context19.prev = 19;
|
|
1885
|
+
_context19.t0 = _context19["catch"](10);
|
|
1886
|
+
_context19.next = 23;
|
|
1887
|
+
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
|
|
1888
|
+
ok: false,
|
|
1889
|
+
error: _context19.t0,
|
|
1890
|
+
payments: this.store.order.getOrderPayments(),
|
|
1891
|
+
params: syncParams,
|
|
1892
|
+
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
1893
|
+
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
1894
|
+
});
|
|
1895
|
+
case 23:
|
|
1896
|
+
throw _context19.t0;
|
|
1897
|
+
case 24:
|
|
977
1898
|
case "end":
|
|
978
|
-
return
|
|
1899
|
+
return _context19.stop();
|
|
979
1900
|
}
|
|
980
|
-
},
|
|
1901
|
+
}, _callee19, this, [[10, 19]]);
|
|
981
1902
|
}));
|
|
982
|
-
function syncPaymentsToOrder(
|
|
1903
|
+
function syncPaymentsToOrder(_x15) {
|
|
983
1904
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
984
1905
|
}
|
|
985
1906
|
return syncPaymentsToOrder;
|
|
@@ -1003,8 +1924,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1003
1924
|
}, {
|
|
1004
1925
|
key: "addOrderPayment",
|
|
1005
1926
|
value: function addOrderPayment(payment) {
|
|
1927
|
+
var _this6 = this;
|
|
1006
1928
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
1007
|
-
|
|
1929
|
+
var paymentRecord = payment;
|
|
1930
|
+
var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
|
|
1931
|
+
if (!metadata.unique_identification_number) {
|
|
1932
|
+
metadata.unique_identification_number = createUuidV4();
|
|
1933
|
+
}
|
|
1934
|
+
var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread({}, paymentRecord), {}, {
|
|
1935
|
+
metadata: metadata
|
|
1936
|
+
}));
|
|
1937
|
+
var amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
1938
|
+
var syncState = this.store.order.getOrderSyncState();
|
|
1939
|
+
if (amountSnapshot && syncState !== 'submitting') {
|
|
1940
|
+
var paymentStatus = Number(amountSnapshot.amountGap || 0) <= 0 ? 'paid' : 'partially_paid';
|
|
1941
|
+
void this.syncPaymentsToOrder({
|
|
1942
|
+
payments: payments,
|
|
1943
|
+
paymentStatus: paymentStatus,
|
|
1944
|
+
submitWhenPaid: true,
|
|
1945
|
+
smallTicketDataFlag: 1
|
|
1946
|
+
}).catch(function (error) {
|
|
1947
|
+
_this6.logError('auto sync payments failed', {
|
|
1948
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1949
|
+
});
|
|
1950
|
+
});
|
|
1951
|
+
}
|
|
1952
|
+
return payments;
|
|
1008
1953
|
}
|
|
1009
1954
|
|
|
1010
1955
|
/** 更新当前订单中的指定支付项。 */
|
|
@@ -1033,20 +1978,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1033
1978
|
}, {
|
|
1034
1979
|
key: "getWalletProductList",
|
|
1035
1980
|
value: function getWalletProductList() {
|
|
1036
|
-
var _this$store$
|
|
1037
|
-
var tempOrder = (_this$store$
|
|
1981
|
+
var _this$store$order3, _tempOrder$products, _tempOrder$products2;
|
|
1982
|
+
var tempOrder = (_this$store$order3 = this.store.order) === null || _this$store$order3 === void 0 ? void 0 : _this$store$order3.getTempOrder();
|
|
1038
1983
|
if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$products = tempOrder.products) !== null && _tempOrder$products !== void 0 && _tempOrder$products.length)) return [];
|
|
1039
|
-
|
|
1040
|
-
|
|
1984
|
+
// 过滤出有 product_id的商品来,如果没有代表他是自定义商品,不需要参与 wallet
|
|
1985
|
+
var products = tempOrder === null || tempOrder === void 0 || (_tempOrder$products2 = tempOrder.products) === null || _tempOrder$products2 === void 0 ? void 0 : _tempOrder$products2.filter(function (n) {
|
|
1986
|
+
return n.product_id;
|
|
1987
|
+
});
|
|
1988
|
+
return products.map(function (product) {
|
|
1989
|
+
var _product$product_vari2, _product$is_charge_ta, _product$holder_id, _metadata$main_produc, _metadata$main_produc2;
|
|
1041
1990
|
var metadata = product.metadata || {};
|
|
1042
1991
|
return {
|
|
1043
1992
|
product_id: product.product_id,
|
|
1044
|
-
product_variant_id: String((_product$
|
|
1993
|
+
product_variant_id: String((_product$product_vari2 = product.product_variant_id) !== null && _product$product_vari2 !== void 0 ? _product$product_vari2 : ''),
|
|
1045
1994
|
quantity: product.num || 1,
|
|
1046
1995
|
is_price_include_tax: tempOrder.is_price_include_tax,
|
|
1047
1996
|
is_charge_tax: (_product$is_charge_ta = product.is_charge_tax) !== null && _product$is_charge_ta !== void 0 ? _product$is_charge_ta : 0,
|
|
1048
1997
|
tax_fee: product.tax_fee,
|
|
1049
1998
|
selling_price: Number(product.selling_price || 0),
|
|
1999
|
+
discount_list: product.discount_list || [],
|
|
1050
2000
|
holder_id: (_product$holder_id = product.holder_id) !== null && _product$holder_id !== void 0 ? _product$holder_id : metadata.holder_id,
|
|
1051
2001
|
original_price: product.original_price,
|
|
1052
2002
|
main_product_original_price: (_metadata$main_produc = metadata.main_product_original_price) !== null && _metadata$main_produc !== void 0 ? _metadata$main_produc : product.original_price,
|
|
@@ -1057,11 +2007,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1057
2007
|
surcharge_rounding_remainder: metadata.surcharge_rounding_remainder
|
|
1058
2008
|
},
|
|
1059
2009
|
product_bundle: (product.product_bundle || []).map(function (bundle) {
|
|
2010
|
+
var _bundle$bundle_id2, _bundle$bundle_produc2, _bundle$bundle_group_2;
|
|
1060
2011
|
var bundleMetadata = bundle.metadata || {};
|
|
1061
2012
|
return {
|
|
1062
2013
|
is_price_include_tax: tempOrder.is_price_include_tax,
|
|
1063
|
-
|
|
1064
|
-
|
|
2014
|
+
// 套餐子项在 tempOrder 上常为 id(如 1718),prepare/deduction 协议要求 bundle_id
|
|
2015
|
+
bundle_id: (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id,
|
|
2016
|
+
bundle_product_id: (_bundle$bundle_produc2 = bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle._bundle_product_id,
|
|
2017
|
+
bundle_group_id: (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id,
|
|
1065
2018
|
bundle_variant_id: bundle.bundle_variant_id,
|
|
1066
2019
|
price_type: bundle.price_type,
|
|
1067
2020
|
price_type_ext: bundle.price_type_ext,
|
|
@@ -1082,20 +2035,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1082
2035
|
}, {
|
|
1083
2036
|
key: "initWalletData",
|
|
1084
2037
|
value: function () {
|
|
1085
|
-
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1086
|
-
var _params$order_wait_pa,
|
|
2038
|
+
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
|
|
2039
|
+
var _params$order_wait_pa, _ref9, _tempOrder$is_price_i;
|
|
1087
2040
|
var snapshot, tempOrder, amount, walletBusinessData, result;
|
|
1088
|
-
return _regeneratorRuntime().wrap(function
|
|
1089
|
-
while (1) switch (
|
|
2041
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
2042
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1090
2043
|
case 0:
|
|
1091
2044
|
if (this.store.order) {
|
|
1092
|
-
|
|
2045
|
+
_context20.next = 2;
|
|
1093
2046
|
break;
|
|
1094
2047
|
}
|
|
1095
2048
|
throw new Error('order 模块未初始化');
|
|
1096
2049
|
case 2:
|
|
1097
2050
|
if (this.store.payment) {
|
|
1098
|
-
|
|
2051
|
+
_context20.next = 4;
|
|
1099
2052
|
break;
|
|
1100
2053
|
}
|
|
1101
2054
|
throw new Error('payment 模块未初始化');
|
|
@@ -1104,10 +2057,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1104
2057
|
tempOrder = snapshot === null || snapshot === void 0 ? void 0 : snapshot.tempOrder;
|
|
1105
2058
|
amount = snapshot === null || snapshot === void 0 ? void 0 : snapshot.amount;
|
|
1106
2059
|
if (!(!tempOrder || !amount)) {
|
|
1107
|
-
|
|
2060
|
+
_context20.next = 9;
|
|
1108
2061
|
break;
|
|
1109
2062
|
}
|
|
1110
|
-
return
|
|
2063
|
+
return _context20.abrupt("return", {
|
|
1111
2064
|
walletRecommendList: [],
|
|
1112
2065
|
userIdentificationCodes: [],
|
|
1113
2066
|
transformList: [],
|
|
@@ -1126,15 +2079,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1126
2079
|
},
|
|
1127
2080
|
products: this.getWalletProductList(),
|
|
1128
2081
|
order_wait_pay_amount: (_params$order_wait_pa = params === null || params === void 0 ? void 0 : params.order_wait_pay_amount) !== null && _params$order_wait_pa !== void 0 ? _params$order_wait_pa : Number(amount.amountGap || 0),
|
|
1129
|
-
is_price_include_tax: (
|
|
2082
|
+
is_price_include_tax: (_ref9 = (_tempOrder$is_price_i = tempOrder.is_price_include_tax) !== null && _tempOrder$is_price_i !== void 0 ? _tempOrder$is_price_i : this.otherParams.is_price_include_tax) !== null && _ref9 !== void 0 ? _ref9 : 1
|
|
1130
2083
|
}, snapshot.identity.orderId ? {
|
|
1131
2084
|
payment_order_id: String(snapshot.identity.orderId)
|
|
1132
2085
|
} : {});
|
|
1133
|
-
|
|
2086
|
+
_context20.next = 12;
|
|
1134
2087
|
return this.store.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
|
|
1135
2088
|
case 12:
|
|
1136
|
-
result =
|
|
1137
|
-
|
|
2089
|
+
result = _context20.sent;
|
|
2090
|
+
_context20.next = 15;
|
|
1138
2091
|
return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
|
|
1139
2092
|
orderId: snapshot.identity.orderId,
|
|
1140
2093
|
customerId: walletBusinessData.customer_id,
|
|
@@ -1146,14 +2099,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1146
2099
|
timestamp: Date.now()
|
|
1147
2100
|
});
|
|
1148
2101
|
case 15:
|
|
1149
|
-
return
|
|
2102
|
+
return _context20.abrupt("return", result);
|
|
1150
2103
|
case 16:
|
|
1151
2104
|
case "end":
|
|
1152
|
-
return
|
|
2105
|
+
return _context20.stop();
|
|
1153
2106
|
}
|
|
1154
|
-
},
|
|
2107
|
+
}, _callee20, this);
|
|
1155
2108
|
}));
|
|
1156
|
-
function initWalletData(
|
|
2109
|
+
function initWalletData(_x16) {
|
|
1157
2110
|
return _initWalletData.apply(this, arguments);
|
|
1158
2111
|
}
|
|
1159
2112
|
return initWalletData;
|
|
@@ -1180,27 +2133,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1180
2133
|
}, {
|
|
1181
2134
|
key: "getPaymentMethodsAsync",
|
|
1182
2135
|
value: (function () {
|
|
1183
|
-
var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2136
|
+
var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
1184
2137
|
var response;
|
|
1185
|
-
return _regeneratorRuntime().wrap(function
|
|
1186
|
-
while (1) switch (
|
|
2138
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
2139
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1187
2140
|
case 0:
|
|
1188
2141
|
if (!this.store.payment) {
|
|
1189
|
-
|
|
2142
|
+
_context21.next = 2;
|
|
1190
2143
|
break;
|
|
1191
2144
|
}
|
|
1192
|
-
return
|
|
2145
|
+
return _context21.abrupt("return", this.store.payment.getPayMethodListAsync());
|
|
1193
2146
|
case 2:
|
|
1194
|
-
|
|
2147
|
+
_context21.next = 4;
|
|
1195
2148
|
return this.request.get('/pay/custom-payment/all');
|
|
1196
2149
|
case 4:
|
|
1197
|
-
response =
|
|
1198
|
-
return
|
|
2150
|
+
response = _context21.sent;
|
|
2151
|
+
return _context21.abrupt("return", (response === null || response === void 0 ? void 0 : response.data) || []);
|
|
1199
2152
|
case 6:
|
|
1200
2153
|
case "end":
|
|
1201
|
-
return
|
|
2154
|
+
return _context21.stop();
|
|
1202
2155
|
}
|
|
1203
|
-
},
|
|
2156
|
+
}, _callee21, this);
|
|
1204
2157
|
}));
|
|
1205
2158
|
function getPaymentMethodsAsync() {
|
|
1206
2159
|
return _getPaymentMethodsAsync.apply(this, arguments);
|
|
@@ -1241,49 +2194,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1241
2194
|
}, {
|
|
1242
2195
|
key: "sendCustomerPayLink",
|
|
1243
2196
|
value: (function () {
|
|
1244
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1245
|
-
var orderIds,
|
|
1246
|
-
return _regeneratorRuntime().wrap(function
|
|
1247
|
-
while (1) switch (
|
|
2197
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
|
|
2198
|
+
var orderIds, _ref10, _ref11, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
|
|
2199
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
2200
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1248
2201
|
case 0:
|
|
1249
2202
|
if (this.store.order) {
|
|
1250
|
-
|
|
2203
|
+
_context22.next = 2;
|
|
1251
2204
|
break;
|
|
1252
2205
|
}
|
|
1253
2206
|
throw new Error('order 模块未初始化');
|
|
1254
2207
|
case 2:
|
|
1255
2208
|
orderIds = params.order_ids || params.orderIds || [];
|
|
1256
2209
|
if (!(!orderIds.length || params.submitBeforeSend)) {
|
|
1257
|
-
|
|
2210
|
+
_context22.next = 11;
|
|
1258
2211
|
break;
|
|
1259
2212
|
}
|
|
1260
|
-
|
|
2213
|
+
_context22.next = 6;
|
|
1261
2214
|
return this.submitSalesOrder({
|
|
1262
2215
|
smallTicketDataFlag: 1
|
|
1263
2216
|
});
|
|
1264
2217
|
case 6:
|
|
1265
|
-
submitResult =
|
|
1266
|
-
orderId = (
|
|
2218
|
+
submitResult = _context22.sent;
|
|
2219
|
+
orderId = (_ref10 = (_ref11 = (_submitResult$data$or = submitResult === null || submitResult === void 0 || (_submitResult$data = submitResult.data) === null || _submitResult$data === void 0 ? void 0 : _submitResult$data.order_id) !== null && _submitResult$data$or !== void 0 ? _submitResult$data$or : submitResult === null || submitResult === void 0 ? void 0 : submitResult.order_id) !== null && _ref11 !== void 0 ? _ref11 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref10 !== void 0 ? _ref10 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
|
|
1267
2220
|
if (orderId) {
|
|
1268
|
-
|
|
2221
|
+
_context22.next = 10;
|
|
1269
2222
|
break;
|
|
1270
2223
|
}
|
|
1271
2224
|
throw new Error('本地订单提交云端失败,无法发送支付链接');
|
|
1272
2225
|
case 10:
|
|
1273
2226
|
orderIds = [orderId];
|
|
1274
2227
|
case 11:
|
|
1275
|
-
return
|
|
2228
|
+
return _context22.abrupt("return", this.store.order.sendCustomerPayLink({
|
|
1276
2229
|
emails: params.emails,
|
|
1277
2230
|
notify_action: params.notify_action,
|
|
1278
2231
|
order_ids: orderIds
|
|
1279
2232
|
}));
|
|
1280
2233
|
case 12:
|
|
1281
2234
|
case "end":
|
|
1282
|
-
return
|
|
2235
|
+
return _context22.stop();
|
|
1283
2236
|
}
|
|
1284
|
-
},
|
|
2237
|
+
}, _callee22, this);
|
|
1285
2238
|
}));
|
|
1286
|
-
function sendCustomerPayLink(
|
|
2239
|
+
function sendCustomerPayLink(_x17) {
|
|
1287
2240
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
1288
2241
|
}
|
|
1289
2242
|
return sendCustomerPayLink;
|
|
@@ -1293,76 +2246,162 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1293
2246
|
value: function transformBaseProductToOrderProduct(params) {
|
|
1294
2247
|
return _transformBaseProductToOrderProduct(params);
|
|
1295
2248
|
}
|
|
2249
|
+
}, {
|
|
2250
|
+
key: "calculateProductBookingPrice",
|
|
2251
|
+
value: function () {
|
|
2252
|
+
var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
|
|
2253
|
+
var _params$customer_id;
|
|
2254
|
+
var quotation, customerId, authoritativeProduct, product;
|
|
2255
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
2256
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
2257
|
+
case 0:
|
|
2258
|
+
quotation = this.store.quotation;
|
|
2259
|
+
customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : this.getCurrentOrderCustomerId();
|
|
2260
|
+
_context23.next = 4;
|
|
2261
|
+
return this.loadProductForPriceQuery(params, customerId);
|
|
2262
|
+
case 4:
|
|
2263
|
+
authoritativeProduct = _context23.sent;
|
|
2264
|
+
product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
|
|
2265
|
+
_context23.next = 8;
|
|
2266
|
+
return this.loadQuotationForPriceQuery({
|
|
2267
|
+
quotation: quotation,
|
|
2268
|
+
customer_id: customerId,
|
|
2269
|
+
channel: params.channel
|
|
2270
|
+
});
|
|
2271
|
+
case 8:
|
|
2272
|
+
return _context23.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
|
|
2273
|
+
product: product,
|
|
2274
|
+
fallback_price: authoritativeProduct ? undefined : params.fallback_price,
|
|
2275
|
+
customer_id: customerId,
|
|
2276
|
+
quotation: quotation
|
|
2277
|
+
})));
|
|
2278
|
+
case 9:
|
|
2279
|
+
case "end":
|
|
2280
|
+
return _context23.stop();
|
|
2281
|
+
}
|
|
2282
|
+
}, _callee23, this);
|
|
2283
|
+
}));
|
|
2284
|
+
function calculateProductBookingPrice(_x18) {
|
|
2285
|
+
return _calculateProductBookingPrice.apply(this, arguments);
|
|
2286
|
+
}
|
|
2287
|
+
return calculateProductBookingPrice;
|
|
2288
|
+
}()
|
|
1296
2289
|
}, {
|
|
1297
2290
|
key: "addProductToOrder",
|
|
1298
2291
|
value: function () {
|
|
1299
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2292
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(product, booking) {
|
|
1300
2293
|
var products;
|
|
1301
|
-
return _regeneratorRuntime().wrap(function
|
|
1302
|
-
while (1) switch (
|
|
2294
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
2295
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1303
2296
|
case 0:
|
|
1304
|
-
|
|
2297
|
+
_context24.prev = 0;
|
|
1305
2298
|
if (this.store.order) {
|
|
1306
|
-
|
|
2299
|
+
_context24.next = 3;
|
|
1307
2300
|
break;
|
|
1308
2301
|
}
|
|
1309
2302
|
throw new Error('order 模块未初始化');
|
|
1310
2303
|
case 3:
|
|
1311
|
-
|
|
2304
|
+
_context24.next = 5;
|
|
1312
2305
|
return this.store.order.addProductToOrder(product, booking);
|
|
1313
2306
|
case 5:
|
|
1314
|
-
products =
|
|
1315
|
-
return
|
|
2307
|
+
products = _context24.sent;
|
|
2308
|
+
return _context24.abrupt("return", products);
|
|
1316
2309
|
case 9:
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
throw
|
|
2310
|
+
_context24.prev = 9;
|
|
2311
|
+
_context24.t0 = _context24["catch"](0);
|
|
2312
|
+
throw _context24.t0;
|
|
1320
2313
|
case 12:
|
|
1321
2314
|
case "end":
|
|
1322
|
-
return
|
|
2315
|
+
return _context24.stop();
|
|
1323
2316
|
}
|
|
1324
|
-
},
|
|
2317
|
+
}, _callee24, this, [[0, 9]]);
|
|
1325
2318
|
}));
|
|
1326
|
-
function addProductToOrder(
|
|
2319
|
+
function addProductToOrder(_x19, _x20) {
|
|
1327
2320
|
return _addProductToOrder.apply(this, arguments);
|
|
1328
2321
|
}
|
|
1329
2322
|
return addProductToOrder;
|
|
1330
2323
|
}()
|
|
1331
2324
|
}, {
|
|
1332
|
-
key: "
|
|
2325
|
+
key: "updateOrderProduct",
|
|
1333
2326
|
value: function () {
|
|
1334
|
-
var
|
|
2327
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
|
|
1335
2328
|
var products;
|
|
1336
|
-
return _regeneratorRuntime().wrap(function
|
|
1337
|
-
while (1) switch (
|
|
2329
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
2330
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
1338
2331
|
case 0:
|
|
1339
|
-
|
|
2332
|
+
_context25.prev = 0;
|
|
1340
2333
|
if (this.store.order) {
|
|
1341
|
-
|
|
2334
|
+
_context25.next = 3;
|
|
1342
2335
|
break;
|
|
1343
2336
|
}
|
|
1344
2337
|
throw new Error('order 模块未初始化');
|
|
1345
2338
|
case 3:
|
|
1346
|
-
|
|
1347
|
-
return this.store.order.
|
|
2339
|
+
_context25.next = 5;
|
|
2340
|
+
return this.store.order.updateOrderProduct(params);
|
|
1348
2341
|
case 5:
|
|
1349
|
-
products =
|
|
1350
|
-
return
|
|
2342
|
+
products = _context25.sent;
|
|
2343
|
+
return _context25.abrupt("return", products);
|
|
1351
2344
|
case 9:
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
throw
|
|
2345
|
+
_context25.prev = 9;
|
|
2346
|
+
_context25.t0 = _context25["catch"](0);
|
|
2347
|
+
throw _context25.t0;
|
|
1355
2348
|
case 12:
|
|
1356
2349
|
case "end":
|
|
1357
|
-
return
|
|
2350
|
+
return _context25.stop();
|
|
2351
|
+
}
|
|
2352
|
+
}, _callee25, this, [[0, 9]]);
|
|
2353
|
+
}));
|
|
2354
|
+
function updateOrderProduct(_x21) {
|
|
2355
|
+
return _updateOrderProduct.apply(this, arguments);
|
|
2356
|
+
}
|
|
2357
|
+
return updateOrderProduct;
|
|
2358
|
+
}()
|
|
2359
|
+
}, {
|
|
2360
|
+
key: "updateOrderProductQuantity",
|
|
2361
|
+
value: function () {
|
|
2362
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
|
|
2363
|
+
var products;
|
|
2364
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
2365
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
2366
|
+
case 0:
|
|
2367
|
+
_context26.prev = 0;
|
|
2368
|
+
if (this.store.order) {
|
|
2369
|
+
_context26.next = 3;
|
|
2370
|
+
break;
|
|
2371
|
+
}
|
|
2372
|
+
throw new Error('order 模块未初始化');
|
|
2373
|
+
case 3:
|
|
2374
|
+
_context26.next = 5;
|
|
2375
|
+
return this.store.order.updateOrderProductQuantity(params);
|
|
2376
|
+
case 5:
|
|
2377
|
+
products = _context26.sent;
|
|
2378
|
+
return _context26.abrupt("return", products);
|
|
2379
|
+
case 9:
|
|
2380
|
+
_context26.prev = 9;
|
|
2381
|
+
_context26.t0 = _context26["catch"](0);
|
|
2382
|
+
throw _context26.t0;
|
|
2383
|
+
case 12:
|
|
2384
|
+
case "end":
|
|
2385
|
+
return _context26.stop();
|
|
1358
2386
|
}
|
|
1359
|
-
},
|
|
2387
|
+
}, _callee26, this, [[0, 9]]);
|
|
1360
2388
|
}));
|
|
1361
|
-
function
|
|
1362
|
-
return
|
|
2389
|
+
function updateOrderProductQuantity(_x22) {
|
|
2390
|
+
return _updateOrderProductQuantity.apply(this, arguments);
|
|
1363
2391
|
}
|
|
1364
|
-
return
|
|
2392
|
+
return updateOrderProductQuantity;
|
|
1365
2393
|
}()
|
|
2394
|
+
}, {
|
|
2395
|
+
key: "updateOrderBooking",
|
|
2396
|
+
value: function updateOrderBooking(params) {
|
|
2397
|
+
try {
|
|
2398
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
2399
|
+
return this.store.order.updateOrderBooking(params);
|
|
2400
|
+
} catch (error) {
|
|
2401
|
+
throw error;
|
|
2402
|
+
}
|
|
2403
|
+
}
|
|
2404
|
+
|
|
1366
2405
|
/**
|
|
1367
2406
|
* 设置单行商品备注(与整单 `updateTempOrderNote` 区分)。
|
|
1368
2407
|
* 多行同 SKU 时必须传入与删除/更新一致的 unique_identification_number。
|
|
@@ -1370,12 +2409,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1370
2409
|
}, {
|
|
1371
2410
|
key: "setOrderProductLineNote",
|
|
1372
2411
|
value: (function () {
|
|
1373
|
-
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2412
|
+
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(identity, note) {
|
|
1374
2413
|
var params, products;
|
|
1375
|
-
return _regeneratorRuntime().wrap(function
|
|
1376
|
-
while (1) switch (
|
|
2414
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
2415
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
1377
2416
|
case 0:
|
|
1378
|
-
|
|
2417
|
+
_context27.prev = 0;
|
|
1379
2418
|
params = {
|
|
1380
2419
|
product_id: identity.product_id,
|
|
1381
2420
|
product_variant_id: identity.product_variant_id,
|
|
@@ -1390,22 +2429,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1390
2429
|
params.product_option_item = identity.product_option_item;
|
|
1391
2430
|
}
|
|
1392
2431
|
if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
|
|
1393
|
-
|
|
1394
|
-
return this.
|
|
2432
|
+
_context27.next = 7;
|
|
2433
|
+
return this.updateOrderProduct(params);
|
|
1395
2434
|
case 7:
|
|
1396
|
-
products =
|
|
1397
|
-
return
|
|
2435
|
+
products = _context27.sent;
|
|
2436
|
+
return _context27.abrupt("return", products);
|
|
1398
2437
|
case 11:
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
throw
|
|
2438
|
+
_context27.prev = 11;
|
|
2439
|
+
_context27.t0 = _context27["catch"](0);
|
|
2440
|
+
throw _context27.t0;
|
|
1402
2441
|
case 14:
|
|
1403
2442
|
case "end":
|
|
1404
|
-
return
|
|
2443
|
+
return _context27.stop();
|
|
1405
2444
|
}
|
|
1406
|
-
},
|
|
2445
|
+
}, _callee27, this, [[0, 11]]);
|
|
1407
2446
|
}));
|
|
1408
|
-
function setOrderProductLineNote(
|
|
2447
|
+
function setOrderProductLineNote(_x23, _x24) {
|
|
1409
2448
|
return _setOrderProductLineNote.apply(this, arguments);
|
|
1410
2449
|
}
|
|
1411
2450
|
return setOrderProductLineNote;
|
|
@@ -1413,54 +2452,138 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1413
2452
|
}, {
|
|
1414
2453
|
key: "removeProductFromOrder",
|
|
1415
2454
|
value: function () {
|
|
1416
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2455
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(identity) {
|
|
1417
2456
|
var products;
|
|
1418
|
-
return _regeneratorRuntime().wrap(function
|
|
1419
|
-
while (1) switch (
|
|
2457
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
2458
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
1420
2459
|
case 0:
|
|
1421
|
-
|
|
2460
|
+
_context28.prev = 0;
|
|
1422
2461
|
if (this.store.order) {
|
|
1423
|
-
|
|
2462
|
+
_context28.next = 3;
|
|
1424
2463
|
break;
|
|
1425
2464
|
}
|
|
1426
2465
|
throw new Error('order 模块未初始化');
|
|
1427
2466
|
case 3:
|
|
1428
|
-
|
|
2467
|
+
_context28.next = 5;
|
|
1429
2468
|
return this.store.order.removeProductFromOrder(identity);
|
|
1430
2469
|
case 5:
|
|
1431
|
-
products =
|
|
1432
|
-
return
|
|
2470
|
+
products = _context28.sent;
|
|
2471
|
+
return _context28.abrupt("return", products);
|
|
1433
2472
|
case 9:
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
throw
|
|
2473
|
+
_context28.prev = 9;
|
|
2474
|
+
_context28.t0 = _context28["catch"](0);
|
|
2475
|
+
throw _context28.t0;
|
|
1437
2476
|
case 12:
|
|
1438
2477
|
case "end":
|
|
1439
|
-
return
|
|
2478
|
+
return _context28.stop();
|
|
1440
2479
|
}
|
|
1441
|
-
},
|
|
2480
|
+
}, _callee28, this, [[0, 9]]);
|
|
1442
2481
|
}));
|
|
1443
|
-
function removeProductFromOrder(
|
|
2482
|
+
function removeProductFromOrder(_x25) {
|
|
1444
2483
|
return _removeProductFromOrder.apply(this, arguments);
|
|
1445
2484
|
}
|
|
1446
2485
|
return removeProductFromOrder;
|
|
1447
|
-
}() //
|
|
2486
|
+
}() // ─── 促销/赠品 透传(迁移自 booking usePromotion) ────────────────
|
|
2487
|
+
/**
|
|
2488
|
+
* 注入促销评估器到底层 OrderModule。
|
|
2489
|
+
*
|
|
2490
|
+
* @example
|
|
2491
|
+
* solution.setPromotionEvaluator(appHelper.utils.promotionEvaluator);
|
|
2492
|
+
*/
|
|
2493
|
+
}, {
|
|
2494
|
+
key: "setPromotionEvaluator",
|
|
2495
|
+
value: function setPromotionEvaluator(evaluator) {
|
|
2496
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
2497
|
+
this.store.order.setPromotionEvaluator(evaluator);
|
|
2498
|
+
}
|
|
2499
|
+
|
|
2500
|
+
/**
|
|
2501
|
+
* 注入赠品选择 resolver。UI 层(SalesSdk)通过 bridge 提供。
|
|
2502
|
+
*
|
|
2503
|
+
* @example
|
|
2504
|
+
* solution.setGiftSelectResolver(async (ctx) => bridge.request(ctx));
|
|
2505
|
+
*/
|
|
2506
|
+
}, {
|
|
2507
|
+
key: "setGiftSelectResolver",
|
|
2508
|
+
value: function setGiftSelectResolver(resolver) {
|
|
2509
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
2510
|
+
this.store.order.setGiftSelectResolver(resolver);
|
|
2511
|
+
}
|
|
2512
|
+
|
|
2513
|
+
/**
|
|
2514
|
+
* 为商品目录追加促销标签,供 SalesSdkProductProvider 等商品列表入口复用。
|
|
2515
|
+
*
|
|
2516
|
+
* @example
|
|
2517
|
+
* const products = solution.appendPromotionTags(catalogProducts);
|
|
2518
|
+
*/
|
|
2519
|
+
}, {
|
|
2520
|
+
key: "appendPromotionTags",
|
|
2521
|
+
value: function appendPromotionTags(products) {
|
|
2522
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
2523
|
+
return this.store.order.appendPromotionTags(products);
|
|
2524
|
+
}
|
|
2525
|
+
|
|
2526
|
+
/**
|
|
2527
|
+
* 主动触发一次促销应用(一般写路径会自动触发,少数场景如客户切换后可手动调)。
|
|
2528
|
+
*/
|
|
2529
|
+
}, {
|
|
2530
|
+
key: "applyPromotion",
|
|
2531
|
+
value: (function () {
|
|
2532
|
+
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
|
|
2533
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
2534
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
2535
|
+
case 0:
|
|
2536
|
+
if (this.store.order) {
|
|
2537
|
+
_context29.next = 2;
|
|
2538
|
+
break;
|
|
2539
|
+
}
|
|
2540
|
+
throw new Error('order 模块未初始化');
|
|
2541
|
+
case 2:
|
|
2542
|
+
_context29.next = 4;
|
|
2543
|
+
return this.store.order.applyPromotion();
|
|
2544
|
+
case 4:
|
|
2545
|
+
case "end":
|
|
2546
|
+
return _context29.stop();
|
|
2547
|
+
}
|
|
2548
|
+
}, _callee29, this);
|
|
2549
|
+
}));
|
|
2550
|
+
function applyPromotion() {
|
|
2551
|
+
return _applyPromotion.apply(this, arguments);
|
|
2552
|
+
}
|
|
2553
|
+
return applyPromotion;
|
|
2554
|
+
}() /** 最近一次促销计算输出的未满足提示。 */)
|
|
2555
|
+
}, {
|
|
2556
|
+
key: "getUnfulfilledPromotions",
|
|
2557
|
+
value: function getUnfulfilledPromotions() {
|
|
2558
|
+
var _this$store$order4;
|
|
2559
|
+
return ((_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 ? void 0 : _this$store$order4.getUnfulfilledPromotions()) || [];
|
|
2560
|
+
}
|
|
2561
|
+
|
|
2562
|
+
/** 最近一次促销计算输出的赠品操作 diff。 */
|
|
2563
|
+
}, {
|
|
2564
|
+
key: "getLastGiftActions",
|
|
2565
|
+
value: function getLastGiftActions() {
|
|
2566
|
+
var _this$store$order5;
|
|
2567
|
+
return ((_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 ? void 0 : _this$store$order5.getLastGiftActions()) || null;
|
|
2568
|
+
}
|
|
2569
|
+
|
|
2570
|
+
// 获取商品列表
|
|
1448
2571
|
// TODO 需要跟 webpos 内的对齐一下
|
|
1449
2572
|
}, {
|
|
1450
2573
|
key: "getProductList",
|
|
1451
2574
|
value: function () {
|
|
1452
|
-
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1453
|
-
var _this$
|
|
2575
|
+
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
|
|
2576
|
+
var _this$otherParams9;
|
|
1454
2577
|
var menu_list_ids, _this$store$products, res;
|
|
1455
|
-
return _regeneratorRuntime().wrap(function
|
|
1456
|
-
while (1) switch (
|
|
2578
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2579
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
1457
2580
|
case 0:
|
|
1458
2581
|
// 可以直接通过配置里的 menu 读取
|
|
1459
|
-
menu_list_ids = ((_this$
|
|
2582
|
+
menu_list_ids = ((_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 || (_this$otherParams9 = _this$otherParams9.dineInConfig) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9['menu.associated_menus'].map(function (n) {
|
|
1460
2583
|
return Number(n.value);
|
|
1461
2584
|
})) || [];
|
|
1462
|
-
|
|
1463
|
-
|
|
2585
|
+
_context30.prev = 1;
|
|
2586
|
+
_context30.next = 4;
|
|
1464
2587
|
return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
|
|
1465
2588
|
menu_list_ids: menu_list_ids,
|
|
1466
2589
|
cacheId: this.cacheId,
|
|
@@ -1468,17 +2591,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1468
2591
|
schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
1469
2592
|
});
|
|
1470
2593
|
case 4:
|
|
1471
|
-
res =
|
|
1472
|
-
return
|
|
2594
|
+
res = _context30.sent;
|
|
2595
|
+
return _context30.abrupt("return", res);
|
|
1473
2596
|
case 8:
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
throw
|
|
2597
|
+
_context30.prev = 8;
|
|
2598
|
+
_context30.t0 = _context30["catch"](1);
|
|
2599
|
+
throw _context30.t0;
|
|
1477
2600
|
case 11:
|
|
1478
2601
|
case "end":
|
|
1479
|
-
return
|
|
2602
|
+
return _context30.stop();
|
|
1480
2603
|
}
|
|
1481
|
-
},
|
|
2604
|
+
}, _callee30, this, [[1, 8]]);
|
|
1482
2605
|
}));
|
|
1483
2606
|
function getProductList() {
|
|
1484
2607
|
return _getProductList.apply(this, arguments);
|
|
@@ -1493,15 +2616,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1493
2616
|
}, {
|
|
1494
2617
|
key: "setOtherParams",
|
|
1495
2618
|
value: function () {
|
|
1496
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1497
|
-
var
|
|
1498
|
-
|
|
2619
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
|
|
2620
|
+
var _ref12,
|
|
2621
|
+
_ref12$cover,
|
|
1499
2622
|
cover,
|
|
1500
|
-
|
|
1501
|
-
return _regeneratorRuntime().wrap(function
|
|
1502
|
-
while (1) switch (
|
|
2623
|
+
_args31 = arguments;
|
|
2624
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
2625
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
1503
2626
|
case 0:
|
|
1504
|
-
|
|
2627
|
+
_ref12 = _args31.length > 1 && _args31[1] !== undefined ? _args31[1] : {}, _ref12$cover = _ref12.cover, cover = _ref12$cover === void 0 ? false : _ref12$cover;
|
|
1505
2628
|
if (cover) {
|
|
1506
2629
|
this.otherParams = params;
|
|
1507
2630
|
} else {
|
|
@@ -1509,11 +2632,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1509
2632
|
}
|
|
1510
2633
|
case 2:
|
|
1511
2634
|
case "end":
|
|
1512
|
-
return
|
|
2635
|
+
return _context31.stop();
|
|
1513
2636
|
}
|
|
1514
|
-
},
|
|
2637
|
+
}, _callee31, this);
|
|
1515
2638
|
}));
|
|
1516
|
-
function setOtherParams(
|
|
2639
|
+
function setOtherParams(_x26) {
|
|
1517
2640
|
return _setOtherParams.apply(this, arguments);
|
|
1518
2641
|
}
|
|
1519
2642
|
return setOtherParams;
|