@pisell/pisellos 2.2.147 → 2.2.149
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/apis/picoding.d.ts +0 -0
- package/dist/apis/picoding.js +1 -0
- package/dist/model/strategy/adapter/index.d.ts +2 -0
- package/dist/model/strategy/adapter/index.js +3 -1
- package/dist/model/strategy/adapter/itemRule/adapter.d.ts +67 -0
- package/dist/model/strategy/adapter/itemRule/adapter.js +483 -0
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
- package/dist/model/strategy/adapter/itemRule/evaluator.js +169 -0
- package/dist/model/strategy/adapter/itemRule/examples.d.ts +79 -0
- package/dist/model/strategy/adapter/itemRule/examples.js +382 -0
- package/dist/model/strategy/adapter/itemRule/index.d.ts +5 -0
- package/dist/model/strategy/adapter/itemRule/index.js +5 -0
- package/dist/model/strategy/adapter/itemRule/type.d.ts +225 -0
- package/dist/model/strategy/adapter/itemRule/type.js +101 -0
- package/dist/modules/Cart/types.d.ts +2 -0
- package/dist/modules/Cart/utils/cartProduct.js +22 -1
- package/dist/modules/Cart/utils/changePrice.js +6 -0
- package/dist/modules/Date/index.d.ts +1 -1
- package/dist/modules/Date/index.js +16 -8
- package/dist/modules/Date/types.d.ts +3 -1
- package/dist/modules/OpenData/index.d.ts +24 -0
- package/dist/modules/OpenData/index.js +173 -0
- package/dist/modules/OpenData/types.d.ts +73 -0
- package/dist/modules/OpenData/types.js +1 -0
- package/dist/modules/OpenData/utils.d.ts +2 -0
- package/dist/modules/OpenData/utils.js +75 -0
- package/dist/modules/Order/index.d.ts +171 -1
- package/dist/modules/Order/index.js +2052 -112
- package/dist/modules/Order/types.d.ts +441 -20
- package/dist/modules/Order/types.js +23 -0
- package/dist/modules/Order/utils.d.ts +120 -0
- package/dist/modules/Order/utils.js +653 -2
- package/dist/modules/Product/utils.js +2 -2
- package/dist/modules/ProductList/index.js +2 -1
- package/dist/modules/Quotation/index.d.ts +8 -1
- package/dist/modules/Quotation/index.js +40 -10
- package/dist/modules/Quotation/types.d.ts +5 -0
- package/dist/modules/Rules/index.d.ts +3 -1
- package/dist/modules/Rules/index.js +136 -50
- package/dist/modules/Rules/types.d.ts +6 -0
- package/dist/modules/Rules/types.js +8 -0
- package/dist/modules/SalesSummary/index.d.ts +70 -0
- package/dist/modules/SalesSummary/index.js +175 -0
- package/dist/modules/SalesSummary/types.d.ts +64 -0
- package/dist/modules/SalesSummary/types.js +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +34 -0
- package/dist/modules/SalesSummary/utils.js +488 -0
- package/dist/modules/ScanOrderLogger/index.d.ts +21 -0
- package/dist/modules/ScanOrderLogger/index.js +161 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.js +203 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.js +50 -0
- package/dist/modules/ScanOrderLogger/types.d.ts +52 -0
- package/dist/modules/ScanOrderLogger/types.js +1 -0
- package/dist/modules/Schedule/getDateIsInSchedule.js +7 -7
- package/dist/modules/Schedule/index.d.ts +4 -13
- package/dist/modules/Schedule/index.js +6 -23
- package/dist/modules/Schedule/utils.d.ts +1 -1
- package/dist/modules/Summary/index.d.ts +3 -0
- package/dist/modules/Summary/index.js +134 -15
- package/dist/modules/Summary/types.d.ts +7 -0
- package/dist/modules/Summary/utils.d.ts +104 -1
- package/dist/modules/Summary/utils.js +1116 -13
- package/dist/modules/index.d.ts +4 -0
- package/dist/modules/index.js +5 -1
- package/dist/server/index.d.ts +41 -4
- package/dist/server/index.js +900 -405
- package/dist/server/modules/order/index.d.ts +10 -2
- package/dist/server/modules/order/index.js +251 -196
- package/dist/server/modules/products/index.d.ts +26 -0
- package/dist/server/modules/products/index.js +618 -338
- package/dist/server/modules/products/types.d.ts +5 -1
- package/dist/solution/BaseSales/index.d.ts +175 -0
- package/dist/solution/BaseSales/index.js +1293 -0
- package/dist/solution/BaseSales/types.d.ts +305 -0
- package/dist/solution/BaseSales/types.js +38 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +143 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +159 -0
- package/dist/solution/BaseSales/utils.d.ts +40 -0
- package/dist/solution/BaseSales/utils.js +222 -0
- package/dist/solution/BookingByStep/index.d.ts +14 -0
- package/dist/solution/BookingByStep/index.js +699 -212
- package/dist/solution/BookingByStep/types.d.ts +3 -1
- package/dist/solution/BookingByStep/types.js +5 -1
- package/dist/solution/BookingByStep/utils/capacity.js +1 -1
- package/dist/solution/BookingByStep/utils/resources.js +6 -1
- package/dist/solution/BookingTicket/index.d.ts +113 -15
- package/dist/solution/BookingTicket/index.js +534 -196
- package/dist/solution/BookingTicket/types.d.ts +69 -6
- package/dist/solution/BookingTicket/types.js +40 -9
- package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +37 -0
- package/dist/solution/BookingTicket/utils/bookingStatus.js +66 -0
- package/dist/solution/BookingTicket/utils/cartView.d.ts +26 -0
- package/dist/solution/BookingTicket/utils/cartView.js +84 -0
- package/dist/solution/Sales/index.d.ts +1 -0
- package/dist/solution/Sales/index.js +1 -0
- package/dist/solution/ScanOrder/index.d.ts +146 -0
- package/dist/solution/ScanOrder/index.js +3029 -0
- package/dist/solution/ScanOrder/types.d.ts +305 -0
- package/dist/solution/ScanOrder/types.js +35 -0
- package/dist/solution/ScanOrder/utils.d.ts +167 -0
- package/dist/solution/ScanOrder/utils.js +768 -0
- package/dist/solution/ShopDiscount/index.d.ts +2 -0
- package/dist/solution/ShopDiscount/index.js +9 -5
- package/dist/solution/ShopDiscount/types.d.ts +4 -0
- package/dist/solution/VenueBooking/index.d.ts +197 -0
- package/dist/solution/VenueBooking/index.js +3411 -0
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/dist/solution/VenueBooking/types.d.ts +153 -0
- package/dist/solution/VenueBooking/types.js +21 -0
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +104 -0
- package/dist/solution/VenueBooking/utils/resource.d.ts +14 -0
- package/dist/solution/VenueBooking/utils/resource.js +130 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +34 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +224 -0
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/dist/solution/VenueBooking/utils/timeSlot.js +453 -0
- package/dist/solution/VenueBooking/utils.d.ts +1 -0
- package/dist/solution/VenueBooking/utils.js +1 -0
- package/dist/solution/index.d.ts +3 -0
- package/dist/solution/index.js +4 -1
- package/lib/apis/picoding.d.ts +0 -0
- package/lib/apis/picoding.js +0 -0
- package/lib/model/strategy/adapter/index.d.ts +2 -0
- package/lib/model/strategy/adapter/index.js +6 -0
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +67 -0
- package/lib/model/strategy/adapter/itemRule/adapter.js +377 -0
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
- package/lib/model/strategy/adapter/itemRule/evaluator.js +124 -0
- package/lib/model/strategy/adapter/itemRule/examples.d.ts +79 -0
- package/lib/model/strategy/adapter/itemRule/examples.js +316 -0
- package/lib/model/strategy/adapter/itemRule/index.d.ts +5 -0
- package/lib/model/strategy/adapter/itemRule/index.js +60 -0
- package/lib/model/strategy/adapter/itemRule/type.d.ts +225 -0
- package/lib/model/strategy/adapter/itemRule/type.js +46 -0
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/Cart/types.d.ts +2 -0
- package/lib/modules/Cart/utils/cartProduct.js +17 -1
- package/lib/modules/Cart/utils/changePrice.js +5 -0
- package/lib/modules/Date/index.d.ts +1 -1
- package/lib/modules/Date/index.js +7 -1
- package/lib/modules/Date/types.d.ts +3 -1
- package/lib/modules/OpenData/index.d.ts +24 -0
- package/lib/modules/OpenData/index.js +119 -0
- package/lib/modules/OpenData/types.d.ts +73 -0
- package/lib/modules/OpenData/types.js +17 -0
- package/lib/modules/OpenData/utils.d.ts +2 -0
- package/lib/modules/OpenData/utils.js +111 -0
- package/lib/modules/Order/index.d.ts +171 -1
- package/lib/modules/Order/index.js +1396 -5
- package/lib/modules/Order/types.d.ts +441 -20
- package/lib/modules/Order/types.js +1 -0
- package/lib/modules/Order/utils.d.ts +120 -0
- package/lib/modules/Order/utils.js +562 -2
- package/lib/modules/Product/utils.js +2 -2
- package/lib/modules/ProductList/index.js +2 -1
- package/lib/modules/Quotation/index.d.ts +8 -1
- package/lib/modules/Quotation/index.js +33 -4
- package/lib/modules/Quotation/types.d.ts +5 -0
- package/lib/modules/Rules/index.d.ts +3 -1
- package/lib/modules/Rules/index.js +46 -6
- package/lib/modules/Rules/types.d.ts +6 -0
- package/lib/modules/Rules/types.js +11 -2
- package/lib/modules/SalesSummary/index.d.ts +70 -0
- package/lib/modules/SalesSummary/index.js +106 -0
- package/lib/modules/SalesSummary/types.d.ts +64 -0
- package/lib/modules/SalesSummary/types.js +17 -0
- package/lib/modules/SalesSummary/utils.d.ts +34 -0
- package/lib/modules/SalesSummary/utils.js +430 -0
- package/lib/modules/ScanOrderLogger/index.d.ts +21 -0
- package/lib/modules/ScanOrderLogger/index.js +135 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.js +148 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.js +52 -0
- package/lib/modules/ScanOrderLogger/types.d.ts +52 -0
- package/lib/modules/ScanOrderLogger/types.js +17 -0
- package/lib/modules/Schedule/getDateIsInSchedule.js +5 -5
- package/lib/modules/Schedule/index.d.ts +4 -13
- package/lib/modules/Schedule/index.js +4 -15
- package/lib/modules/Schedule/utils.d.ts +1 -1
- package/lib/modules/Summary/index.d.ts +3 -0
- package/lib/modules/Summary/index.js +61 -2
- package/lib/modules/Summary/types.d.ts +7 -0
- package/lib/modules/Summary/utils.d.ts +104 -1
- package/lib/modules/Summary/utils.js +659 -8
- package/lib/modules/index.d.ts +4 -0
- package/lib/modules/index.js +9 -1
- package/lib/server/index.d.ts +41 -4
- package/lib/server/index.js +272 -10
- package/lib/server/modules/order/index.d.ts +10 -2
- package/lib/server/modules/order/index.js +31 -4
- package/lib/server/modules/products/index.d.ts +26 -0
- package/lib/server/modules/products/index.js +174 -22
- package/lib/server/modules/products/types.d.ts +5 -1
- package/lib/solution/BaseSales/index.d.ts +175 -0
- package/lib/solution/BaseSales/index.js +655 -0
- package/lib/solution/BaseSales/types.d.ts +305 -0
- package/lib/solution/BaseSales/types.js +40 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +143 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +160 -0
- package/lib/solution/BaseSales/utils.d.ts +40 -0
- package/lib/solution/BaseSales/utils.js +200 -0
- package/lib/solution/BookingByStep/index.d.ts +14 -0
- package/lib/solution/BookingByStep/index.js +469 -91
- package/lib/solution/BookingByStep/types.d.ts +3 -1
- package/lib/solution/BookingByStep/types.js +10 -0
- package/lib/solution/BookingByStep/utils/capacity.js +1 -1
- package/lib/solution/BookingByStep/utils/resources.js +5 -2
- package/lib/solution/BookingTicket/index.d.ts +113 -15
- package/lib/solution/BookingTicket/index.js +253 -61
- package/lib/solution/BookingTicket/types.d.ts +69 -6
- package/lib/solution/BookingTicket/types.js +16 -14
- package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +37 -0
- package/lib/solution/BookingTicket/utils/bookingStatus.js +65 -0
- package/lib/solution/BookingTicket/utils/cartView.d.ts +26 -0
- package/lib/solution/BookingTicket/utils/cartView.js +103 -0
- package/lib/solution/Sales/index.d.ts +1 -0
- package/lib/solution/ScanOrder/index.d.ts +146 -0
- package/lib/solution/ScanOrder/index.js +1820 -0
- package/lib/solution/ScanOrder/types.d.ts +305 -0
- package/lib/solution/ScanOrder/types.js +36 -0
- package/lib/solution/ScanOrder/utils.d.ts +167 -0
- package/lib/solution/ScanOrder/utils.js +639 -0
- package/lib/solution/ShopDiscount/index.d.ts +2 -0
- package/lib/solution/ShopDiscount/index.js +9 -4
- package/lib/solution/ShopDiscount/types.d.ts +4 -0
- package/lib/solution/VenueBooking/index.d.ts +197 -0
- package/lib/solution/VenueBooking/index.js +1892 -0
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/lib/solution/VenueBooking/types.d.ts +153 -0
- package/lib/solution/VenueBooking/types.js +44 -0
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +110 -0
- package/lib/solution/VenueBooking/utils/resource.d.ts +14 -0
- package/lib/solution/VenueBooking/utils/resource.js +91 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +34 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +225 -0
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/lib/solution/VenueBooking/utils/timeSlot.js +339 -0
- package/lib/solution/VenueBooking/utils.d.ts +1 -0
- package/lib/solution/VenueBooking/utils.js +69 -0
- package/lib/solution/index.d.ts +3 -0
- package/lib/solution/index.js +7 -1
- package/package.json +1 -1
|
@@ -0,0 +1,1293 @@
|
|
|
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 _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); }
|
|
3
|
+
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
|
+
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
|
+
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
|
+
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; }
|
|
8
|
+
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
|
+
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
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
11
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
12
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
13
|
+
function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
|
|
14
|
+
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
15
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
16
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
17
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
18
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
19
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
20
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
21
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
22
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
23
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
24
|
+
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
|
+
import { BaseModule } from "../../modules/BaseModule";
|
|
26
|
+
import { OrderModule } from "../../modules/Order";
|
|
27
|
+
import Decimal from 'decimal.js';
|
|
28
|
+
import { createModule } from "../BookingByStep/types";
|
|
29
|
+
import { composeLinePrice, sumOptionUnitPrice } from "../../modules/Order/utils";
|
|
30
|
+
import dayjs from 'dayjs';
|
|
31
|
+
export * from "./types";
|
|
32
|
+
export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
33
|
+
_inherits(BaseSalesImpl, _BaseModule);
|
|
34
|
+
var _super = _createSuper(BaseSalesImpl);
|
|
35
|
+
function BaseSalesImpl(name, version) {
|
|
36
|
+
var _this;
|
|
37
|
+
_classCallCheck(this, BaseSalesImpl);
|
|
38
|
+
_this = _super.call(this, name, version);
|
|
39
|
+
_defineProperty(_assertThisInitialized(_this), "defaultName", 'baseSales');
|
|
40
|
+
_defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
|
|
41
|
+
_defineProperty(_assertThisInitialized(_this), "isSolution", true);
|
|
42
|
+
_defineProperty(_assertThisInitialized(_this), "initializeOptions", {});
|
|
43
|
+
_defineProperty(_assertThisInitialized(_this), "store", {
|
|
44
|
+
order: undefined
|
|
45
|
+
});
|
|
46
|
+
_defineProperty(_assertThisInitialized(_this), "otherParams", {});
|
|
47
|
+
_defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
|
|
48
|
+
/**
|
|
49
|
+
* window / request 暴露为 public:现存外部工具(如 BookingTicket Scan)通过
|
|
50
|
+
* `solution.window` / `solution.request` 直接访问插件,保持原有契约不破坏。
|
|
51
|
+
*/
|
|
52
|
+
_defineProperty(_assertThisInitialized(_this), "window", void 0);
|
|
53
|
+
_defineProperty(_assertThisInitialized(_this), "request", void 0);
|
|
54
|
+
// 当前缓存中已加载的最新 SalesDetail;只读 getter 走它对外暴露详情数据。
|
|
55
|
+
_defineProperty(_assertThisInitialized(_this), "currentSalesDetail", null);
|
|
56
|
+
return _this;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 子类可覆盖此方法以追加/收敛要注册的子模块。
|
|
61
|
+
* 默认包含通用销售模块:products / order / salesSummary / schedule。
|
|
62
|
+
*/
|
|
63
|
+
_createClass(BaseSalesImpl, [{
|
|
64
|
+
key: "getRegisteredModuleNames",
|
|
65
|
+
value: function getRegisteredModuleNames() {
|
|
66
|
+
return ['products', 'order', 'salesSummary', 'schedule'];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* 工厂入口:根据子模块名实例化对应模块。
|
|
71
|
+
* 默认使用 BookingByStep 公共 `createModule`。子类若需引入额外类型(如 customer),
|
|
72
|
+
* 可覆盖此方法并把未识别的 name 委托给 `super.createSubModule(name)`。
|
|
73
|
+
*/
|
|
74
|
+
}, {
|
|
75
|
+
key: "createSubModule",
|
|
76
|
+
value: function createSubModule(moduleName) {
|
|
77
|
+
return createModule(moduleName, this.name);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* 读取 sessionStorage[this.name][cacheId],作为子模块 initialState 的来源。
|
|
82
|
+
* sessionStorage 损坏时静默忽略,按空状态注册。
|
|
83
|
+
*/
|
|
84
|
+
}, {
|
|
85
|
+
key: "readSessionCacheData",
|
|
86
|
+
value: function readSessionCacheData() {
|
|
87
|
+
if (!this.cacheId || !this.window) return {};
|
|
88
|
+
try {
|
|
89
|
+
var sessionData = this.window.sessionStorage.getItem(this.name);
|
|
90
|
+
if (!sessionData) return {};
|
|
91
|
+
var data = JSON.parse(sessionData);
|
|
92
|
+
return data && data[this.cacheId] || {};
|
|
93
|
+
} catch (_unused) {
|
|
94
|
+
return {};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}, {
|
|
98
|
+
key: "initialize",
|
|
99
|
+
value: function () {
|
|
100
|
+
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core) {
|
|
101
|
+
var _this$otherParams,
|
|
102
|
+
_this2 = this;
|
|
103
|
+
var options,
|
|
104
|
+
targetCacheData,
|
|
105
|
+
moduleNames,
|
|
106
|
+
_args = arguments;
|
|
107
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
108
|
+
while (1) switch (_context.prev = _context.next) {
|
|
109
|
+
case 0:
|
|
110
|
+
options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
|
|
111
|
+
this.core = core;
|
|
112
|
+
this.initializeOptions = options || {};
|
|
113
|
+
// this.store = { ...this.store, ...(options.store as Partial<BaseSalesState>) };
|
|
114
|
+
this.otherParams = options.otherParams || {};
|
|
115
|
+
this.cacheId = (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.cacheId;
|
|
116
|
+
this.window = core.getPlugin('window');
|
|
117
|
+
this.request = core.getPlugin('request');
|
|
118
|
+
targetCacheData = this.readSessionCacheData();
|
|
119
|
+
moduleNames = this.getRegisteredModuleNames();
|
|
120
|
+
moduleNames.forEach(function (step) {
|
|
121
|
+
var targetModule = _this2.createSubModule(step);
|
|
122
|
+
if (!targetModule) {
|
|
123
|
+
throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
|
|
124
|
+
}
|
|
125
|
+
_this2.store[step] = targetModule;
|
|
126
|
+
_this2.core.registerModule(targetModule, {
|
|
127
|
+
initialState: (targetCacheData === null || targetCacheData === void 0 ? void 0 : targetCacheData[targetModule.name]) || {},
|
|
128
|
+
otherParams: _objectSpread(_objectSpread({}, _this2.otherParams), {}, {
|
|
129
|
+
salesSummaryModuleName: "".concat(_this2.name, "_salesSummary"),
|
|
130
|
+
fatherModule: _this2.name,
|
|
131
|
+
openCache: _this2.cacheId ? true : false,
|
|
132
|
+
cacheId: _this2.cacheId
|
|
133
|
+
})
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
if (!this.store.schedule) {
|
|
137
|
+
_context.next = 13;
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
_context.next = 13;
|
|
141
|
+
return this.store.schedule.loadAllSchedule();
|
|
142
|
+
case 13:
|
|
143
|
+
this.core.effects.emit("".concat(this.name, ":onInited"), {});
|
|
144
|
+
case 14:
|
|
145
|
+
case "end":
|
|
146
|
+
return _context.stop();
|
|
147
|
+
}
|
|
148
|
+
}, _callee, this);
|
|
149
|
+
}));
|
|
150
|
+
function initialize(_x) {
|
|
151
|
+
return _initialize.apply(this, arguments);
|
|
152
|
+
}
|
|
153
|
+
return initialize;
|
|
154
|
+
}()
|
|
155
|
+
}, {
|
|
156
|
+
key: "destroy",
|
|
157
|
+
value: function () {
|
|
158
|
+
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
159
|
+
var _this3 = this;
|
|
160
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
161
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
162
|
+
case 0:
|
|
163
|
+
Object.keys(this.store).forEach(function (key) {
|
|
164
|
+
var sub = _this3.store[key];
|
|
165
|
+
if (sub && typeof sub.destroy === 'function') {
|
|
166
|
+
try {
|
|
167
|
+
sub.destroy();
|
|
168
|
+
} catch (error) {
|
|
169
|
+
console.warn("[BaseSales] \u5B50\u6A21\u5757 ".concat(key, " \u9500\u6BC1\u5931\u8D25"), error);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
this.currentSalesDetail = null;
|
|
174
|
+
_context2.next = 4;
|
|
175
|
+
return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
|
|
176
|
+
case 4:
|
|
177
|
+
_get(_getPrototypeOf(BaseSalesImpl.prototype), "destroy", this).call(this);
|
|
178
|
+
case 5:
|
|
179
|
+
case "end":
|
|
180
|
+
return _context2.stop();
|
|
181
|
+
}
|
|
182
|
+
}, _callee2, this);
|
|
183
|
+
}));
|
|
184
|
+
function destroy() {
|
|
185
|
+
return _destroy.apply(this, arguments);
|
|
186
|
+
}
|
|
187
|
+
return destroy;
|
|
188
|
+
}()
|
|
189
|
+
/**
|
|
190
|
+
* 加载销售订单到统一 tempOrder 工作区。
|
|
191
|
+
* 有 app.sqlite 时优先读取本地记录;本地未命中或 forceRemote=true 时再拉云端。
|
|
192
|
+
*
|
|
193
|
+
* 子类可在 `super.loadSalesDetail` 之后基于返回的 `sales` 做业务侧装配
|
|
194
|
+
* (比如把 `sales.customer` 写入 CustomerModule、emit 业务 hook 等)。
|
|
195
|
+
*/
|
|
196
|
+
}, {
|
|
197
|
+
key: "loadSalesDetail",
|
|
198
|
+
value: (function () {
|
|
199
|
+
var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(orderIdOrParams) {
|
|
200
|
+
var params, externalSaleNumber, localRecord, _sales, res, message, sales;
|
|
201
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
202
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
203
|
+
case 0:
|
|
204
|
+
if (this.store.order) {
|
|
205
|
+
_context3.next = 2;
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
throw new Error('order 模块未初始化');
|
|
209
|
+
case 2:
|
|
210
|
+
params = _typeof(orderIdOrParams) === 'object' ? orderIdOrParams : {
|
|
211
|
+
orderId: orderIdOrParams
|
|
212
|
+
};
|
|
213
|
+
externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
|
|
214
|
+
if (params.forceRemote) {
|
|
215
|
+
_context3.next = 35;
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
if (!(params.orderId !== undefined)) {
|
|
219
|
+
_context3.next = 11;
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
_context3.next = 8;
|
|
223
|
+
return this.store.order.getLocalOrderByOrderId(params.orderId);
|
|
224
|
+
case 8:
|
|
225
|
+
_context3.t0 = _context3.sent;
|
|
226
|
+
_context3.next = 26;
|
|
227
|
+
break;
|
|
228
|
+
case 11:
|
|
229
|
+
if (!externalSaleNumber) {
|
|
230
|
+
_context3.next = 17;
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
_context3.next = 14;
|
|
234
|
+
return this.store.order.getLocalOrderByExternalSaleNumber(externalSaleNumber);
|
|
235
|
+
case 14:
|
|
236
|
+
_context3.t1 = _context3.sent;
|
|
237
|
+
_context3.next = 25;
|
|
238
|
+
break;
|
|
239
|
+
case 17:
|
|
240
|
+
if (!params.orderNumber) {
|
|
241
|
+
_context3.next = 23;
|
|
242
|
+
break;
|
|
243
|
+
}
|
|
244
|
+
_context3.next = 20;
|
|
245
|
+
return this.store.order.getLocalOrderByOrderNumber(params.orderNumber);
|
|
246
|
+
case 20:
|
|
247
|
+
_context3.t2 = _context3.sent;
|
|
248
|
+
_context3.next = 24;
|
|
249
|
+
break;
|
|
250
|
+
case 23:
|
|
251
|
+
_context3.t2 = null;
|
|
252
|
+
case 24:
|
|
253
|
+
_context3.t1 = _context3.t2;
|
|
254
|
+
case 25:
|
|
255
|
+
_context3.t0 = _context3.t1;
|
|
256
|
+
case 26:
|
|
257
|
+
localRecord = _context3.t0;
|
|
258
|
+
if (!localRecord) {
|
|
259
|
+
_context3.next = 35;
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
262
|
+
_context3.next = 30;
|
|
263
|
+
return this.store.order.hydrateTempOrderFromRecord(localRecord, {
|
|
264
|
+
recalcOnHydrate: false
|
|
265
|
+
});
|
|
266
|
+
case 30:
|
|
267
|
+
_sales = _context3.sent;
|
|
268
|
+
this.currentSalesDetail = _sales;
|
|
269
|
+
_context3.next = 34;
|
|
270
|
+
return this.core.effects.emit("".concat(this.name, ":onSalesOrderLoaded"), {
|
|
271
|
+
sales: _sales
|
|
272
|
+
});
|
|
273
|
+
case 34:
|
|
274
|
+
return _context3.abrupt("return", _sales);
|
|
275
|
+
case 35:
|
|
276
|
+
if (!(params.orderId === undefined || params.orderId === null)) {
|
|
277
|
+
_context3.next = 37;
|
|
278
|
+
break;
|
|
279
|
+
}
|
|
280
|
+
throw new Error('加载销售详情需要 orderId,或本地库中存在对应 externalSaleNumber/orderNumber');
|
|
281
|
+
case 37:
|
|
282
|
+
_context3.next = 39;
|
|
283
|
+
return this.store.order.getOrderInfoByRemote(Number(params.orderId));
|
|
284
|
+
case 39:
|
|
285
|
+
res = _context3.sent;
|
|
286
|
+
if (!(!res || res.code !== 200)) {
|
|
287
|
+
_context3.next = 43;
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
message = res && (res.message || res.msg) || "\u52A0\u8F7D\u9500\u552E\u8BE6\u60C5\u5931\u8D25: ".concat(params.orderId);
|
|
291
|
+
throw new Error(message);
|
|
292
|
+
case 43:
|
|
293
|
+
_context3.next = 45;
|
|
294
|
+
return this.store.order.hydrateTempOrderFromRecord(res.data, {
|
|
295
|
+
recalcOnHydrate: false
|
|
296
|
+
});
|
|
297
|
+
case 45:
|
|
298
|
+
sales = _context3.sent;
|
|
299
|
+
_context3.next = 48;
|
|
300
|
+
return this.store.order.saveDraft();
|
|
301
|
+
case 48:
|
|
302
|
+
this.currentSalesDetail = sales;
|
|
303
|
+
_context3.next = 51;
|
|
304
|
+
return this.core.effects.emit("".concat(this.name, ":onSalesOrderLoaded"), {
|
|
305
|
+
sales: sales
|
|
306
|
+
});
|
|
307
|
+
case 51:
|
|
308
|
+
return _context3.abrupt("return", sales);
|
|
309
|
+
case 52:
|
|
310
|
+
case "end":
|
|
311
|
+
return _context3.stop();
|
|
312
|
+
}
|
|
313
|
+
}, _callee3, this);
|
|
314
|
+
}));
|
|
315
|
+
function loadSalesDetail(_x2) {
|
|
316
|
+
return _loadSalesDetail.apply(this, arguments);
|
|
317
|
+
}
|
|
318
|
+
return loadSalesDetail;
|
|
319
|
+
}() /** 获取当前已加载的销售详情(只读快照)。未加载过则返回 null。 */)
|
|
320
|
+
}, {
|
|
321
|
+
key: "getSalesOrder",
|
|
322
|
+
value: function getSalesOrder() {
|
|
323
|
+
return this.currentSalesDetail;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/** 获取销售详情顶部业务字段(订单号/状态/金额等通用字段集合)。 */
|
|
327
|
+
}, {
|
|
328
|
+
key: "getOrderHeader",
|
|
329
|
+
value: function getOrderHeader() {
|
|
330
|
+
if (!this.currentSalesDetail) return null;
|
|
331
|
+
return this.currentSalesDetail.header || this.currentSalesDetail;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/** 获取所有 booking(含 root + children),按服务端原始顺序输出。 */
|
|
335
|
+
}, {
|
|
336
|
+
key: "getBookings",
|
|
337
|
+
value: function getBookings() {
|
|
338
|
+
var _this$currentSalesDet;
|
|
339
|
+
return ((_this$currentSalesDet = this.currentSalesDetail) === null || _this$currentSalesDet === void 0 ? void 0 : _this$currentSalesDet.bookings) || [];
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/** 获取根 booking(is_next === 0 / is_root === 1),多个时取第一个。 */
|
|
343
|
+
}, {
|
|
344
|
+
key: "getRootBooking",
|
|
345
|
+
value: function getRootBooking() {
|
|
346
|
+
if (!this.currentSalesDetail) return null;
|
|
347
|
+
if (this.currentSalesDetail.rootBooking) return this.currentSalesDetail.rootBooking;
|
|
348
|
+
var bookings = this.currentSalesDetail.bookings || [];
|
|
349
|
+
return bookings.find(function (booking) {
|
|
350
|
+
var parentId = booking === null || booking === void 0 ? void 0 : booking.parent_id;
|
|
351
|
+
return parentId === 0 || parentId === null || parentId === undefined;
|
|
352
|
+
}) || null;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/** 按 product_uid 反查 booking 列表(用于商品行 ↔ booking 映射)。 */
|
|
356
|
+
}, {
|
|
357
|
+
key: "getChildBookingsByProductUid",
|
|
358
|
+
value: function getChildBookingsByProductUid(productUid) {
|
|
359
|
+
var _this$currentSalesDet2;
|
|
360
|
+
if (!this.currentSalesDetail || !productUid) return [];
|
|
361
|
+
var indexed = (_this$currentSalesDet2 = this.currentSalesDetail.bookingsByProductUid) === null || _this$currentSalesDet2 === void 0 ? void 0 : _this$currentSalesDet2[productUid];
|
|
362
|
+
if (indexed) return indexed;
|
|
363
|
+
return (this.currentSalesDetail.bookings || []).filter(function (booking) {
|
|
364
|
+
var _booking$metadata;
|
|
365
|
+
var uid = (booking === null || booking === void 0 ? void 0 : booking.product_uid) || (booking === null || booking === void 0 || (_booking$metadata = booking.metadata) === null || _booking$metadata === void 0 ? void 0 : _booking$metadata.product_uid);
|
|
366
|
+
return String(uid || '') === String(productUid);
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/** 获取支付列表(已支付/退款等明细)。 */
|
|
371
|
+
}, {
|
|
372
|
+
key: "getPayments",
|
|
373
|
+
value: function getPayments() {
|
|
374
|
+
var _this$currentSalesDet3;
|
|
375
|
+
return ((_this$currentSalesDet3 = this.currentSalesDetail) === null || _this$currentSalesDet3 === void 0 ? void 0 : _this$currentSalesDet3.payments) || [];
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/** 获取附加费用(运费/服务费/税费等)。 */
|
|
379
|
+
}, {
|
|
380
|
+
key: "getSurcharges",
|
|
381
|
+
value: function getSurcharges() {
|
|
382
|
+
var _this$currentSalesDet4;
|
|
383
|
+
return ((_this$currentSalesDet4 = this.currentSalesDetail) === null || _this$currentSalesDet4 === void 0 ? void 0 : _this$currentSalesDet4.surcharges) || [];
|
|
384
|
+
}
|
|
385
|
+
}, {
|
|
386
|
+
key: "getTempOrder",
|
|
387
|
+
value: function getTempOrder() {
|
|
388
|
+
var _this$store$order;
|
|
389
|
+
var result = ((_this$store$order = this.store.order) === null || _this$store$order === void 0 ? void 0 : _this$store$order.getTempOrder()) || null;
|
|
390
|
+
return result;
|
|
391
|
+
}
|
|
392
|
+
}, {
|
|
393
|
+
key: "getOrderIdentity",
|
|
394
|
+
value: function getOrderIdentity() {
|
|
395
|
+
if (!this.store.order) return null;
|
|
396
|
+
return this.store.order.getOrderIdentity();
|
|
397
|
+
}
|
|
398
|
+
}, {
|
|
399
|
+
key: "getOrderSnapshot",
|
|
400
|
+
value: function getOrderSnapshot() {
|
|
401
|
+
if (!this.store.order) return null;
|
|
402
|
+
return this.store.order.getOrderSnapshot();
|
|
403
|
+
}
|
|
404
|
+
}, {
|
|
405
|
+
key: "getOrderSyncState",
|
|
406
|
+
value: function getOrderSyncState() {
|
|
407
|
+
if (!this.store.order) return 'local';
|
|
408
|
+
return this.store.order.getOrderSyncState();
|
|
409
|
+
}
|
|
410
|
+
}, {
|
|
411
|
+
key: "getOrderAmountSnapshot",
|
|
412
|
+
value: function getOrderAmountSnapshot() {
|
|
413
|
+
if (!this.store.order) return null;
|
|
414
|
+
return this.store.order.getOrderAmountSnapshot();
|
|
415
|
+
}
|
|
416
|
+
}, {
|
|
417
|
+
key: "getTempOrderNote",
|
|
418
|
+
value: function getTempOrderNote() {
|
|
419
|
+
if (!this.store.order) return '';
|
|
420
|
+
return this.store.order.getTempOrderNote();
|
|
421
|
+
}
|
|
422
|
+
}, {
|
|
423
|
+
key: "updateTempOrderNote",
|
|
424
|
+
value: function updateTempOrderNote(note) {
|
|
425
|
+
try {
|
|
426
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
427
|
+
var result = this.store.order.updateTempOrderNote(note);
|
|
428
|
+
return result;
|
|
429
|
+
} catch (error) {
|
|
430
|
+
throw error;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}, {
|
|
434
|
+
key: "updateOrderShopDiscount",
|
|
435
|
+
value: function updateOrderShopDiscount(amount) {
|
|
436
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
437
|
+
return this.store.order.updateTempOrderShopDiscount(amount);
|
|
438
|
+
}
|
|
439
|
+
}, {
|
|
440
|
+
key: "ensureTempOrder",
|
|
441
|
+
value: function ensureTempOrder() {
|
|
442
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
443
|
+
return this.store.order.ensureTempOrder();
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
// 主动创建临时订单;若已存在则直接返回已有订单
|
|
447
|
+
}, {
|
|
448
|
+
key: "addNewOrder",
|
|
449
|
+
value: function () {
|
|
450
|
+
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
451
|
+
var tempOrder;
|
|
452
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
453
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
454
|
+
case 0:
|
|
455
|
+
_context4.prev = 0;
|
|
456
|
+
if (this.store.order) {
|
|
457
|
+
_context4.next = 3;
|
|
458
|
+
break;
|
|
459
|
+
}
|
|
460
|
+
throw new Error('order 模块未初始化');
|
|
461
|
+
case 3:
|
|
462
|
+
_context4.next = 5;
|
|
463
|
+
return this.store.order.addNewOrder();
|
|
464
|
+
case 5:
|
|
465
|
+
tempOrder = _context4.sent;
|
|
466
|
+
return _context4.abrupt("return", tempOrder);
|
|
467
|
+
case 9:
|
|
468
|
+
_context4.prev = 9;
|
|
469
|
+
_context4.t0 = _context4["catch"](0);
|
|
470
|
+
throw _context4.t0;
|
|
471
|
+
case 12:
|
|
472
|
+
case "end":
|
|
473
|
+
return _context4.stop();
|
|
474
|
+
}
|
|
475
|
+
}, _callee4, this, [[0, 9]]);
|
|
476
|
+
}));
|
|
477
|
+
function addNewOrder() {
|
|
478
|
+
return _addNewOrder.apply(this, arguments);
|
|
479
|
+
}
|
|
480
|
+
return addNewOrder;
|
|
481
|
+
}()
|
|
482
|
+
}, {
|
|
483
|
+
key: "saveDraft",
|
|
484
|
+
value: function () {
|
|
485
|
+
var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
486
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
487
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
488
|
+
case 0:
|
|
489
|
+
if (this.store.order) {
|
|
490
|
+
_context5.next = 2;
|
|
491
|
+
break;
|
|
492
|
+
}
|
|
493
|
+
throw new Error('order 模块未初始化');
|
|
494
|
+
case 2:
|
|
495
|
+
return _context5.abrupt("return", this.store.order.saveDraft());
|
|
496
|
+
case 3:
|
|
497
|
+
case "end":
|
|
498
|
+
return _context5.stop();
|
|
499
|
+
}
|
|
500
|
+
}, _callee5, this);
|
|
501
|
+
}));
|
|
502
|
+
function saveDraft() {
|
|
503
|
+
return _saveDraft.apply(this, arguments);
|
|
504
|
+
}
|
|
505
|
+
return saveDraft;
|
|
506
|
+
}() // 重置 tempOrder 与与上一单强相关的运行态(resource/entryPaxNumber/enabledReservationRuleProducts),
|
|
507
|
+
// 适用于从支付页通过 react-router 跳回继续下单时清理残留数据
|
|
508
|
+
}, {
|
|
509
|
+
key: "restoreOrder",
|
|
510
|
+
value: function () {
|
|
511
|
+
var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
512
|
+
var tempOrder;
|
|
513
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
514
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
515
|
+
case 0:
|
|
516
|
+
_context6.prev = 0;
|
|
517
|
+
if (this.store.order) {
|
|
518
|
+
_context6.next = 3;
|
|
519
|
+
break;
|
|
520
|
+
}
|
|
521
|
+
throw new Error('scanOrder 解决方案需要 order 模块支持');
|
|
522
|
+
case 3:
|
|
523
|
+
// this.store.resource = null;
|
|
524
|
+
tempOrder = this.store.order.restoreOrder();
|
|
525
|
+
return _context6.abrupt("return", tempOrder);
|
|
526
|
+
case 7:
|
|
527
|
+
_context6.prev = 7;
|
|
528
|
+
_context6.t0 = _context6["catch"](0);
|
|
529
|
+
throw _context6.t0;
|
|
530
|
+
case 10:
|
|
531
|
+
case "end":
|
|
532
|
+
return _context6.stop();
|
|
533
|
+
}
|
|
534
|
+
}, _callee6, this, [[0, 7]]);
|
|
535
|
+
}));
|
|
536
|
+
function restoreOrder() {
|
|
537
|
+
return _restoreOrder.apply(this, arguments);
|
|
538
|
+
}
|
|
539
|
+
return restoreOrder;
|
|
540
|
+
}()
|
|
541
|
+
}, {
|
|
542
|
+
key: "getOrderProducts",
|
|
543
|
+
value: function getOrderProducts() {
|
|
544
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
545
|
+
var products = this.store.order.getOrderProducts();
|
|
546
|
+
return products;
|
|
547
|
+
}
|
|
548
|
+
}, {
|
|
549
|
+
key: "getSummary",
|
|
550
|
+
value: function () {
|
|
551
|
+
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
552
|
+
var summary;
|
|
553
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
554
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
555
|
+
case 0:
|
|
556
|
+
_context7.prev = 0;
|
|
557
|
+
if (this.store.order) {
|
|
558
|
+
_context7.next = 3;
|
|
559
|
+
break;
|
|
560
|
+
}
|
|
561
|
+
throw new Error('order 模块未初始化');
|
|
562
|
+
case 3:
|
|
563
|
+
_context7.next = 5;
|
|
564
|
+
return this.store.order.getOrderSummary();
|
|
565
|
+
case 5:
|
|
566
|
+
summary = _context7.sent;
|
|
567
|
+
return _context7.abrupt("return", summary);
|
|
568
|
+
case 9:
|
|
569
|
+
_context7.prev = 9;
|
|
570
|
+
_context7.t0 = _context7["catch"](0);
|
|
571
|
+
throw _context7.t0;
|
|
572
|
+
case 12:
|
|
573
|
+
case "end":
|
|
574
|
+
return _context7.stop();
|
|
575
|
+
}
|
|
576
|
+
}, _callee7, this, [[0, 9]]);
|
|
577
|
+
}));
|
|
578
|
+
function getSummary() {
|
|
579
|
+
return _getSummary.apply(this, arguments);
|
|
580
|
+
}
|
|
581
|
+
return getSummary;
|
|
582
|
+
}()
|
|
583
|
+
}, {
|
|
584
|
+
key: "getDiscountList",
|
|
585
|
+
value: function getDiscountList() {
|
|
586
|
+
if (!this.store.order) return [];
|
|
587
|
+
return this.store.order.getDiscountList();
|
|
588
|
+
}
|
|
589
|
+
}, {
|
|
590
|
+
key: "scanPromotionCode",
|
|
591
|
+
value: function () {
|
|
592
|
+
var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(code, customerId) {
|
|
593
|
+
var raw;
|
|
594
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
595
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
596
|
+
case 0:
|
|
597
|
+
_context8.prev = 0;
|
|
598
|
+
if (this.store.order) {
|
|
599
|
+
_context8.next = 3;
|
|
600
|
+
break;
|
|
601
|
+
}
|
|
602
|
+
throw new Error('order 模块未初始化');
|
|
603
|
+
case 3:
|
|
604
|
+
_context8.next = 5;
|
|
605
|
+
return this.store.order.scanCode(code, customerId);
|
|
606
|
+
case 5:
|
|
607
|
+
raw = _context8.sent;
|
|
608
|
+
if (!raw.isAvailable) {
|
|
609
|
+
_context8.next = 10;
|
|
610
|
+
break;
|
|
611
|
+
}
|
|
612
|
+
_context8.next = 9;
|
|
613
|
+
return this.store.order.recalculateSummary({
|
|
614
|
+
createIfMissing: true
|
|
615
|
+
});
|
|
616
|
+
case 9:
|
|
617
|
+
this.store.order.persistTempOrder();
|
|
618
|
+
case 10:
|
|
619
|
+
return _context8.abrupt("return", {
|
|
620
|
+
isAvailable: raw.isAvailable,
|
|
621
|
+
type: raw.type,
|
|
622
|
+
unavailableReason: raw.unavailableReason
|
|
623
|
+
});
|
|
624
|
+
case 13:
|
|
625
|
+
_context8.prev = 13;
|
|
626
|
+
_context8.t0 = _context8["catch"](0);
|
|
627
|
+
throw _context8.t0;
|
|
628
|
+
case 16:
|
|
629
|
+
case "end":
|
|
630
|
+
return _context8.stop();
|
|
631
|
+
}
|
|
632
|
+
}, _callee8, this, [[0, 13]]);
|
|
633
|
+
}));
|
|
634
|
+
function scanPromotionCode(_x3, _x4) {
|
|
635
|
+
return _scanPromotionCode.apply(this, arguments);
|
|
636
|
+
}
|
|
637
|
+
return scanPromotionCode;
|
|
638
|
+
}() // TODO 需要优化,这段逻辑太长了,里面应该有些历史遗留问题
|
|
639
|
+
}, {
|
|
640
|
+
key: "setDiscountSelected",
|
|
641
|
+
value: function () {
|
|
642
|
+
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
|
|
643
|
+
var _tempOrder$holder, list, updated, tempOrder, orderStore, discountModule, rulesModule, holders, nextDiscountList, _tempOrder$holder2, result, beforeSelectedIds, _iterator, _step, d, selectedResourceIds, _iterator2, _step2, _product$metadata, _tempOrder$_extend, _product$metadata2, _product$metadata$sou, _product$metadata3, _product$metadata4, _product$original_pri, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
|
|
644
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
645
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
646
|
+
case 0:
|
|
647
|
+
_context9.prev = 0;
|
|
648
|
+
if (this.store.order) {
|
|
649
|
+
_context9.next = 3;
|
|
650
|
+
break;
|
|
651
|
+
}
|
|
652
|
+
throw new Error('order 模块未初始化');
|
|
653
|
+
case 3:
|
|
654
|
+
list = this.store.order.getDiscountList();
|
|
655
|
+
updated = list.map(function (d) {
|
|
656
|
+
return d.id === params.discountId ? _objectSpread(_objectSpread({}, d), {}, {
|
|
657
|
+
isSelected: params.isSelected,
|
|
658
|
+
isManualSelect: !params.isSelected
|
|
659
|
+
}) : d;
|
|
660
|
+
});
|
|
661
|
+
tempOrder = this.store.order.ensureTempOrder();
|
|
662
|
+
orderStore = this.store.order.store || {};
|
|
663
|
+
discountModule = orderStore.discount;
|
|
664
|
+
rulesModule = orderStore.rules;
|
|
665
|
+
holders = (_tempOrder$holder = tempOrder.holder) !== null && _tempOrder$holder !== void 0 && _tempOrder$holder.form_record_id ? [{
|
|
666
|
+
form_record_id: tempOrder.holder.form_record_id
|
|
667
|
+
}] : [];
|
|
668
|
+
nextDiscountList = updated;
|
|
669
|
+
_context9.next = 13;
|
|
670
|
+
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(updated);
|
|
671
|
+
case 13:
|
|
672
|
+
if (rulesModule) {
|
|
673
|
+
result = rulesModule.calcDiscount({
|
|
674
|
+
productList: tempOrder.products,
|
|
675
|
+
discountList: updated,
|
|
676
|
+
holders: holders,
|
|
677
|
+
isFormSubject: !!((_tempOrder$holder2 = tempOrder.holder) !== null && _tempOrder$holder2 !== void 0 && _tempOrder$holder2.type) && tempOrder.holder.type === 'form'
|
|
678
|
+
}, {
|
|
679
|
+
discountId: params.discountId,
|
|
680
|
+
isSelected: params.isSelected
|
|
681
|
+
}) || {
|
|
682
|
+
productList: tempOrder.products,
|
|
683
|
+
discountList: updated
|
|
684
|
+
};
|
|
685
|
+
if (result !== null && result !== void 0 && result.productList) {
|
|
686
|
+
tempOrder.products = result.productList;
|
|
687
|
+
}
|
|
688
|
+
if (result !== null && result !== void 0 && result.discountList) {
|
|
689
|
+
nextDiscountList = result.discountList;
|
|
690
|
+
if (!params.isSelected) {
|
|
691
|
+
beforeSelectedIds = new Set(updated.filter(function (d) {
|
|
692
|
+
return d.isSelected;
|
|
693
|
+
}).map(function (d) {
|
|
694
|
+
return d.id;
|
|
695
|
+
}));
|
|
696
|
+
_iterator = _createForOfIteratorHelper(nextDiscountList);
|
|
697
|
+
try {
|
|
698
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
699
|
+
d = _step.value;
|
|
700
|
+
if (d.isSelected && !beforeSelectedIds.has(d.id)) {
|
|
701
|
+
d.isSelected = false;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
} catch (err) {
|
|
705
|
+
_iterator.e(err);
|
|
706
|
+
} finally {
|
|
707
|
+
_iterator.f();
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
selectedResourceIds = new Set(nextDiscountList.filter(function (d) {
|
|
713
|
+
return d.isSelected;
|
|
714
|
+
}).map(function (d) {
|
|
715
|
+
return d.id;
|
|
716
|
+
}));
|
|
717
|
+
_iterator2 = _createForOfIteratorHelper(tempOrder.products);
|
|
718
|
+
_context9.prev = 16;
|
|
719
|
+
_iterator2.s();
|
|
720
|
+
case 18:
|
|
721
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
722
|
+
_context9.next = 34;
|
|
723
|
+
break;
|
|
724
|
+
}
|
|
725
|
+
product = _step2.value;
|
|
726
|
+
productUid = (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.unique_identification_number;
|
|
727
|
+
runtimeOrigin = productUid ? (_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 || (_tempOrder$_extend = _tempOrder$_extend.productsByUid) === null || _tempOrder$_extend === void 0 || (_tempOrder$_extend = _tempOrder$_extend[productUid]) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend.origin : undefined;
|
|
728
|
+
if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || (_product$metadata2 = product.metadata) !== null && _product$metadata2 !== void 0 && _product$metadata2.is_manual_discount)) {
|
|
729
|
+
_context9.next = 24;
|
|
730
|
+
break;
|
|
731
|
+
}
|
|
732
|
+
return _context9.abrupt("continue", 32);
|
|
733
|
+
case 24:
|
|
734
|
+
product.discount_list = (product.discount_list || []).filter(function (pd) {
|
|
735
|
+
var _pd$discount$resource, _pd$discount;
|
|
736
|
+
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;
|
|
737
|
+
return rid != null && selectedResourceIds.has(rid);
|
|
738
|
+
});
|
|
739
|
+
|
|
740
|
+
// 券作用于 source(不含 option、不含 bundle);算出新 source 折后价后补回 options
|
|
741
|
+
// 写入含 option 的 main_product_selling_price,再合成 composite 回写 selling_price。
|
|
742
|
+
totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
|
|
743
|
+
return sum + (pd.amount || 0);
|
|
744
|
+
}, 0); // TODO 这块逻辑需要拿掉
|
|
745
|
+
optionSum = sumOptionUnitPrice(product.product_option_item);
|
|
746
|
+
sourcePrice = (_product$metadata$sou = (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.source_product_price) !== null && _product$metadata$sou !== void 0 ? _product$metadata$sou : ((_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.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';
|
|
747
|
+
newSourceSellingPrice = new Decimal(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
748
|
+
newMainSellingPrice = new Decimal(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
749
|
+
if (product.metadata) {
|
|
750
|
+
product.metadata.main_product_selling_price = newMainSellingPrice;
|
|
751
|
+
product.metadata.price_schema_version = 2;
|
|
752
|
+
}
|
|
753
|
+
product.selling_price = composeLinePrice({
|
|
754
|
+
mainPrice: newMainSellingPrice,
|
|
755
|
+
bundle: product.product_bundle
|
|
756
|
+
});
|
|
757
|
+
case 32:
|
|
758
|
+
_context9.next = 18;
|
|
759
|
+
break;
|
|
760
|
+
case 34:
|
|
761
|
+
_context9.next = 39;
|
|
762
|
+
break;
|
|
763
|
+
case 36:
|
|
764
|
+
_context9.prev = 36;
|
|
765
|
+
_context9.t0 = _context9["catch"](16);
|
|
766
|
+
_iterator2.e(_context9.t0);
|
|
767
|
+
case 39:
|
|
768
|
+
_context9.prev = 39;
|
|
769
|
+
_iterator2.f();
|
|
770
|
+
return _context9.finish(39);
|
|
771
|
+
case 42:
|
|
772
|
+
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
773
|
+
_context9.next = 45;
|
|
774
|
+
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
775
|
+
case 45:
|
|
776
|
+
tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
|
|
777
|
+
return d.isSelected;
|
|
778
|
+
});
|
|
779
|
+
_context9.next = 48;
|
|
780
|
+
return this.store.order.recalculateSummary({
|
|
781
|
+
createIfMissing: true
|
|
782
|
+
});
|
|
783
|
+
case 48:
|
|
784
|
+
this.store.order.persistTempOrder();
|
|
785
|
+
_context9.next = 54;
|
|
786
|
+
break;
|
|
787
|
+
case 51:
|
|
788
|
+
_context9.prev = 51;
|
|
789
|
+
_context9.t1 = _context9["catch"](0);
|
|
790
|
+
throw _context9.t1;
|
|
791
|
+
case 54:
|
|
792
|
+
case "end":
|
|
793
|
+
return _context9.stop();
|
|
794
|
+
}
|
|
795
|
+
}, _callee9, this, [[0, 51], [16, 36, 39, 42]]);
|
|
796
|
+
}));
|
|
797
|
+
function setDiscountSelected(_x5) {
|
|
798
|
+
return _setDiscountSelected.apply(this, arguments);
|
|
799
|
+
}
|
|
800
|
+
return setDiscountSelected;
|
|
801
|
+
}()
|
|
802
|
+
}, {
|
|
803
|
+
key: "submitScanOrder",
|
|
804
|
+
value: function () {
|
|
805
|
+
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
|
|
806
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
807
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
808
|
+
case 0:
|
|
809
|
+
return _context10.abrupt("return", this.submitSalesOrder(params));
|
|
810
|
+
case 1:
|
|
811
|
+
case "end":
|
|
812
|
+
return _context10.stop();
|
|
813
|
+
}
|
|
814
|
+
}, _callee10, this);
|
|
815
|
+
}));
|
|
816
|
+
function submitScanOrder(_x6) {
|
|
817
|
+
return _submitScanOrder.apply(this, arguments);
|
|
818
|
+
}
|
|
819
|
+
return submitScanOrder;
|
|
820
|
+
}()
|
|
821
|
+
/**
|
|
822
|
+
* 提交当前 Sales 订单。
|
|
823
|
+
*
|
|
824
|
+
* PaymentModal 场景通过 smallTicketDataFlag=1 请求 B 端小票数据;
|
|
825
|
+
* payments 会交给 OrderModule 统一映射为 Sales 协议支付项。
|
|
826
|
+
*/
|
|
827
|
+
}, {
|
|
828
|
+
key: "submitSalesOrder",
|
|
829
|
+
value: (function () {
|
|
830
|
+
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(params) {
|
|
831
|
+
var _this$otherParams2, _this$otherParams3, _this$otherParams4, _this$otherParams5;
|
|
832
|
+
var submitParams;
|
|
833
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
834
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
835
|
+
case 0:
|
|
836
|
+
if (this.store.order) {
|
|
837
|
+
_context11.next = 2;
|
|
838
|
+
break;
|
|
839
|
+
}
|
|
840
|
+
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
841
|
+
case 2:
|
|
842
|
+
this.store.order.persistTempOrder();
|
|
843
|
+
submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
844
|
+
cacheId: this.cacheId,
|
|
845
|
+
platform: (_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.platform,
|
|
846
|
+
businessCode: (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.businessCode,
|
|
847
|
+
channel: (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.channel,
|
|
848
|
+
type: (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.type
|
|
849
|
+
}, (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
|
|
850
|
+
payments: params.payments
|
|
851
|
+
} : {}), (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined ? {
|
|
852
|
+
paymentStatus: params.paymentStatus
|
|
853
|
+
} : {}), (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined ? {
|
|
854
|
+
smallTicketDataFlag: params.smallTicketDataFlag
|
|
855
|
+
} : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
|
|
856
|
+
enhancePayload: params.enhancePayload
|
|
857
|
+
} : {});
|
|
858
|
+
return _context11.abrupt("return", this.store.order.submitTempOrder(submitParams));
|
|
859
|
+
case 5:
|
|
860
|
+
case "end":
|
|
861
|
+
return _context11.stop();
|
|
862
|
+
}
|
|
863
|
+
}, _callee11, this);
|
|
864
|
+
}));
|
|
865
|
+
function submitSalesOrder(_x7) {
|
|
866
|
+
return _submitSalesOrder.apply(this, arguments);
|
|
867
|
+
}
|
|
868
|
+
return submitSalesOrder;
|
|
869
|
+
}())
|
|
870
|
+
}, {
|
|
871
|
+
key: "syncPaymentsToOrder",
|
|
872
|
+
value: function () {
|
|
873
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(params) {
|
|
874
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
875
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
876
|
+
case 0:
|
|
877
|
+
if (this.store.order) {
|
|
878
|
+
_context12.next = 2;
|
|
879
|
+
break;
|
|
880
|
+
}
|
|
881
|
+
throw new Error('order 模块未初始化');
|
|
882
|
+
case 2:
|
|
883
|
+
return _context12.abrupt("return", this.store.order.syncPaymentsToOrder(params));
|
|
884
|
+
case 3:
|
|
885
|
+
case "end":
|
|
886
|
+
return _context12.stop();
|
|
887
|
+
}
|
|
888
|
+
}, _callee12, this);
|
|
889
|
+
}));
|
|
890
|
+
function syncPaymentsToOrder(_x8) {
|
|
891
|
+
return _syncPaymentsToOrder.apply(this, arguments);
|
|
892
|
+
}
|
|
893
|
+
return syncPaymentsToOrder;
|
|
894
|
+
}() /** 读取当前 BaseSales 订单上下文中的 Sales 协议支付项。 */
|
|
895
|
+
}, {
|
|
896
|
+
key: "getOrderPayments",
|
|
897
|
+
value: function getOrderPayments() {
|
|
898
|
+
if (!this.store.order) return [];
|
|
899
|
+
return this.store.order.getOrderPayments();
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
/** 覆盖当前订单支付项,内部由 OrderModule 清洗为 Sales 协议字段。 */
|
|
903
|
+
}, {
|
|
904
|
+
key: "setOrderPayments",
|
|
905
|
+
value: function setOrderPayments(payments) {
|
|
906
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
907
|
+
return this.store.order.setOrderPayments(payments);
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
/** 追加单个支付项到当前订单。 */
|
|
911
|
+
}, {
|
|
912
|
+
key: "addOrderPayment",
|
|
913
|
+
value: function addOrderPayment(payment) {
|
|
914
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
915
|
+
return this.store.order.addOrderPayment(payment);
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
/** 更新当前订单中的指定支付项。 */
|
|
919
|
+
}, {
|
|
920
|
+
key: "updateOrderPayment",
|
|
921
|
+
value: function updateOrderPayment(paymentIdentity, updates) {
|
|
922
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
923
|
+
return this.store.order.updateOrderPayment(paymentIdentity, updates);
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
/** 删除当前订单中的指定支付项。 */
|
|
927
|
+
}, {
|
|
928
|
+
key: "deleteOrderPayment",
|
|
929
|
+
value: function deleteOrderPayment(paymentIdentity) {
|
|
930
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
931
|
+
return this.store.order.deleteOrderPayment(paymentIdentity);
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
/** 覆盖 wallet pass 支付项,同时保留普通支付项。 */
|
|
935
|
+
}, {
|
|
936
|
+
key: "updateVoucherOrderPayments",
|
|
937
|
+
value: function updateVoucherOrderPayments(payments) {
|
|
938
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
939
|
+
return this.store.order.updateVoucherOrderPayments(payments);
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
/**
|
|
943
|
+
* 更新当前订单客户字段。
|
|
944
|
+
*
|
|
945
|
+
* 这是 PaymentModal 客户切换的订单事实入口;外部客户模块同步应由
|
|
946
|
+
* 调用方通过 onCustomerChange 回调完成。
|
|
947
|
+
*/
|
|
948
|
+
}, {
|
|
949
|
+
key: "updateOrderCustomer",
|
|
950
|
+
value: function updateOrderCustomer(customer) {
|
|
951
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
952
|
+
var result = this.store.order.updateTempOrderCustomer(customer);
|
|
953
|
+
this.store.order.recalculateSummary({
|
|
954
|
+
createIfMissing: true
|
|
955
|
+
});
|
|
956
|
+
this.store.order.persistTempOrder();
|
|
957
|
+
return result;
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
/** 获取可用支付方式列表,供 PaymentModal 渲染支付选项。 */
|
|
961
|
+
}, {
|
|
962
|
+
key: "getPaymentMethodsAsync",
|
|
963
|
+
value: (function () {
|
|
964
|
+
var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
965
|
+
var response;
|
|
966
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
967
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
968
|
+
case 0:
|
|
969
|
+
_context13.next = 2;
|
|
970
|
+
return this.request.get('/pay/custom-payment/all');
|
|
971
|
+
case 2:
|
|
972
|
+
response = _context13.sent;
|
|
973
|
+
return _context13.abrupt("return", (response === null || response === void 0 ? void 0 : response.data) || []);
|
|
974
|
+
case 4:
|
|
975
|
+
case "end":
|
|
976
|
+
return _context13.stop();
|
|
977
|
+
}
|
|
978
|
+
}, _callee13, this);
|
|
979
|
+
}));
|
|
980
|
+
function getPaymentMethodsAsync() {
|
|
981
|
+
return _getPaymentMethodsAsync.apply(this, arguments);
|
|
982
|
+
}
|
|
983
|
+
return getPaymentMethodsAsync;
|
|
984
|
+
}() /** 轻量舍入能力,供现金支付 UI 计算 rounding_amount。 */)
|
|
985
|
+
}, {
|
|
986
|
+
key: "roundAmount",
|
|
987
|
+
value: function roundAmount(params) {
|
|
988
|
+
var amount = new Decimal(params.amount || 0);
|
|
989
|
+
var interval = new Decimal(params.interval || 0.05);
|
|
990
|
+
var rule = params.rule || 'standard_rounding';
|
|
991
|
+
var quotient = amount.div(interval);
|
|
992
|
+
var roundedQuotient;
|
|
993
|
+
if (rule === 'always_up') {
|
|
994
|
+
roundedQuotient = quotient.ceil();
|
|
995
|
+
} else if (rule === 'always_down') {
|
|
996
|
+
roundedQuotient = quotient.floor();
|
|
997
|
+
} else if (rule === 'standard_down') {
|
|
998
|
+
roundedQuotient = quotient.toDecimalPlaces(0, Decimal.ROUND_HALF_DOWN);
|
|
999
|
+
} else {
|
|
1000
|
+
roundedQuotient = quotient.toDecimalPlaces(0, Decimal.ROUND_HALF_UP);
|
|
1001
|
+
}
|
|
1002
|
+
var roundedAmount = roundedQuotient.times(interval).toDecimalPlaces(2);
|
|
1003
|
+
return {
|
|
1004
|
+
originalAmount: amount.toFixed(2),
|
|
1005
|
+
roundedAmount: roundedAmount.toFixed(2),
|
|
1006
|
+
roundingDifference: roundedAmount.minus(amount).toFixed(2)
|
|
1007
|
+
};
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
/**
|
|
1011
|
+
* 发送支付链接。
|
|
1012
|
+
*
|
|
1013
|
+
* 如果没有 orderIds 或显式 submitBeforeSend,会先提交当前本地订单到云端;
|
|
1014
|
+
* 只有成功拿到远端 order_id 后才调用 OrderModule 发送邮件。
|
|
1015
|
+
*/
|
|
1016
|
+
}, {
|
|
1017
|
+
key: "sendCustomerPayLink",
|
|
1018
|
+
value: (function () {
|
|
1019
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(params) {
|
|
1020
|
+
var orderIds, _ref, _ref2, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
|
|
1021
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1022
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1023
|
+
case 0:
|
|
1024
|
+
if (this.store.order) {
|
|
1025
|
+
_context14.next = 2;
|
|
1026
|
+
break;
|
|
1027
|
+
}
|
|
1028
|
+
throw new Error('order 模块未初始化');
|
|
1029
|
+
case 2:
|
|
1030
|
+
orderIds = params.order_ids || params.orderIds || [];
|
|
1031
|
+
if (!(!orderIds.length || params.submitBeforeSend)) {
|
|
1032
|
+
_context14.next = 11;
|
|
1033
|
+
break;
|
|
1034
|
+
}
|
|
1035
|
+
_context14.next = 6;
|
|
1036
|
+
return this.submitSalesOrder({
|
|
1037
|
+
smallTicketDataFlag: 1
|
|
1038
|
+
});
|
|
1039
|
+
case 6:
|
|
1040
|
+
submitResult = _context14.sent;
|
|
1041
|
+
orderId = (_ref = (_ref2 = (_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 && _ref2 !== void 0 ? _ref2 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref !== void 0 ? _ref : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
|
|
1042
|
+
if (orderId) {
|
|
1043
|
+
_context14.next = 10;
|
|
1044
|
+
break;
|
|
1045
|
+
}
|
|
1046
|
+
throw new Error('本地订单提交云端失败,无法发送支付链接');
|
|
1047
|
+
case 10:
|
|
1048
|
+
orderIds = [orderId];
|
|
1049
|
+
case 11:
|
|
1050
|
+
return _context14.abrupt("return", this.store.order.sendCustomerPayLink({
|
|
1051
|
+
emails: params.emails,
|
|
1052
|
+
notify_action: params.notify_action,
|
|
1053
|
+
order_ids: orderIds
|
|
1054
|
+
}));
|
|
1055
|
+
case 12:
|
|
1056
|
+
case "end":
|
|
1057
|
+
return _context14.stop();
|
|
1058
|
+
}
|
|
1059
|
+
}, _callee14, this);
|
|
1060
|
+
}));
|
|
1061
|
+
function sendCustomerPayLink(_x9) {
|
|
1062
|
+
return _sendCustomerPayLink.apply(this, arguments);
|
|
1063
|
+
}
|
|
1064
|
+
return sendCustomerPayLink;
|
|
1065
|
+
}())
|
|
1066
|
+
}, {
|
|
1067
|
+
key: "addProductToOrder",
|
|
1068
|
+
value: function () {
|
|
1069
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(product, booking) {
|
|
1070
|
+
var products;
|
|
1071
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1072
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1073
|
+
case 0:
|
|
1074
|
+
_context15.prev = 0;
|
|
1075
|
+
if (this.store.order) {
|
|
1076
|
+
_context15.next = 3;
|
|
1077
|
+
break;
|
|
1078
|
+
}
|
|
1079
|
+
throw new Error('order 模块未初始化');
|
|
1080
|
+
case 3:
|
|
1081
|
+
_context15.next = 5;
|
|
1082
|
+
return this.store.order.addProductToOrder(product, booking);
|
|
1083
|
+
case 5:
|
|
1084
|
+
products = _context15.sent;
|
|
1085
|
+
return _context15.abrupt("return", products);
|
|
1086
|
+
case 9:
|
|
1087
|
+
_context15.prev = 9;
|
|
1088
|
+
_context15.t0 = _context15["catch"](0);
|
|
1089
|
+
throw _context15.t0;
|
|
1090
|
+
case 12:
|
|
1091
|
+
case "end":
|
|
1092
|
+
return _context15.stop();
|
|
1093
|
+
}
|
|
1094
|
+
}, _callee15, this, [[0, 9]]);
|
|
1095
|
+
}));
|
|
1096
|
+
function addProductToOrder(_x10, _x11) {
|
|
1097
|
+
return _addProductToOrder.apply(this, arguments);
|
|
1098
|
+
}
|
|
1099
|
+
return addProductToOrder;
|
|
1100
|
+
}()
|
|
1101
|
+
}, {
|
|
1102
|
+
key: "updateProductInOrder",
|
|
1103
|
+
value: function () {
|
|
1104
|
+
var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(params) {
|
|
1105
|
+
var products;
|
|
1106
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1107
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1108
|
+
case 0:
|
|
1109
|
+
_context16.prev = 0;
|
|
1110
|
+
if (this.store.order) {
|
|
1111
|
+
_context16.next = 3;
|
|
1112
|
+
break;
|
|
1113
|
+
}
|
|
1114
|
+
throw new Error('order 模块未初始化');
|
|
1115
|
+
case 3:
|
|
1116
|
+
_context16.next = 5;
|
|
1117
|
+
return this.store.order.updateProductInOrder(params);
|
|
1118
|
+
case 5:
|
|
1119
|
+
products = _context16.sent;
|
|
1120
|
+
return _context16.abrupt("return", products);
|
|
1121
|
+
case 9:
|
|
1122
|
+
_context16.prev = 9;
|
|
1123
|
+
_context16.t0 = _context16["catch"](0);
|
|
1124
|
+
throw _context16.t0;
|
|
1125
|
+
case 12:
|
|
1126
|
+
case "end":
|
|
1127
|
+
return _context16.stop();
|
|
1128
|
+
}
|
|
1129
|
+
}, _callee16, this, [[0, 9]]);
|
|
1130
|
+
}));
|
|
1131
|
+
function updateProductInOrder(_x12) {
|
|
1132
|
+
return _updateProductInOrder.apply(this, arguments);
|
|
1133
|
+
}
|
|
1134
|
+
return updateProductInOrder;
|
|
1135
|
+
}()
|
|
1136
|
+
/**
|
|
1137
|
+
* 设置单行商品备注(与整单 `updateTempOrderNote` 区分)。
|
|
1138
|
+
* 多行同 SKU 时必须传入与删除/更新一致的 unique_identification_number。
|
|
1139
|
+
*/
|
|
1140
|
+
}, {
|
|
1141
|
+
key: "setOrderProductLineNote",
|
|
1142
|
+
value: (function () {
|
|
1143
|
+
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(identity, note) {
|
|
1144
|
+
var params, products;
|
|
1145
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1146
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1147
|
+
case 0:
|
|
1148
|
+
_context17.prev = 0;
|
|
1149
|
+
params = {
|
|
1150
|
+
product_id: identity.product_id,
|
|
1151
|
+
product_variant_id: identity.product_variant_id,
|
|
1152
|
+
updates: {
|
|
1153
|
+
note: String(note || '')
|
|
1154
|
+
}
|
|
1155
|
+
};
|
|
1156
|
+
if (identity.unique_identification_number !== undefined) {
|
|
1157
|
+
params.unique_identification_number = identity.unique_identification_number;
|
|
1158
|
+
}
|
|
1159
|
+
if (identity.product_option_item !== undefined) {
|
|
1160
|
+
params.product_option_item = identity.product_option_item;
|
|
1161
|
+
}
|
|
1162
|
+
if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
|
|
1163
|
+
_context17.next = 7;
|
|
1164
|
+
return this.updateProductInOrder(params);
|
|
1165
|
+
case 7:
|
|
1166
|
+
products = _context17.sent;
|
|
1167
|
+
return _context17.abrupt("return", products);
|
|
1168
|
+
case 11:
|
|
1169
|
+
_context17.prev = 11;
|
|
1170
|
+
_context17.t0 = _context17["catch"](0);
|
|
1171
|
+
throw _context17.t0;
|
|
1172
|
+
case 14:
|
|
1173
|
+
case "end":
|
|
1174
|
+
return _context17.stop();
|
|
1175
|
+
}
|
|
1176
|
+
}, _callee17, this, [[0, 11]]);
|
|
1177
|
+
}));
|
|
1178
|
+
function setOrderProductLineNote(_x13, _x14) {
|
|
1179
|
+
return _setOrderProductLineNote.apply(this, arguments);
|
|
1180
|
+
}
|
|
1181
|
+
return setOrderProductLineNote;
|
|
1182
|
+
}())
|
|
1183
|
+
}, {
|
|
1184
|
+
key: "removeProductFromOrder",
|
|
1185
|
+
value: function () {
|
|
1186
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(identity) {
|
|
1187
|
+
var products;
|
|
1188
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1189
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1190
|
+
case 0:
|
|
1191
|
+
_context18.prev = 0;
|
|
1192
|
+
if (this.store.order) {
|
|
1193
|
+
_context18.next = 3;
|
|
1194
|
+
break;
|
|
1195
|
+
}
|
|
1196
|
+
throw new Error('order 模块未初始化');
|
|
1197
|
+
case 3:
|
|
1198
|
+
_context18.next = 5;
|
|
1199
|
+
return this.store.order.removeProductFromOrder(identity);
|
|
1200
|
+
case 5:
|
|
1201
|
+
products = _context18.sent;
|
|
1202
|
+
return _context18.abrupt("return", products);
|
|
1203
|
+
case 9:
|
|
1204
|
+
_context18.prev = 9;
|
|
1205
|
+
_context18.t0 = _context18["catch"](0);
|
|
1206
|
+
throw _context18.t0;
|
|
1207
|
+
case 12:
|
|
1208
|
+
case "end":
|
|
1209
|
+
return _context18.stop();
|
|
1210
|
+
}
|
|
1211
|
+
}, _callee18, this, [[0, 9]]);
|
|
1212
|
+
}));
|
|
1213
|
+
function removeProductFromOrder(_x15) {
|
|
1214
|
+
return _removeProductFromOrder.apply(this, arguments);
|
|
1215
|
+
}
|
|
1216
|
+
return removeProductFromOrder;
|
|
1217
|
+
}() // 获取商品列表
|
|
1218
|
+
// TODO 需要跟 webpos 内的对齐一下
|
|
1219
|
+
}, {
|
|
1220
|
+
key: "getProductList",
|
|
1221
|
+
value: function () {
|
|
1222
|
+
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
|
|
1223
|
+
var _this$otherParams6;
|
|
1224
|
+
var menu_list_ids, _this$store$products, res;
|
|
1225
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1226
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1227
|
+
case 0:
|
|
1228
|
+
// 可以直接通过配置里的 menu 读取
|
|
1229
|
+
menu_list_ids = ((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 || (_this$otherParams6 = _this$otherParams6.dineInConfig) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6['menu.associated_menus'].map(function (n) {
|
|
1230
|
+
return Number(n.value);
|
|
1231
|
+
})) || [];
|
|
1232
|
+
_context19.prev = 1;
|
|
1233
|
+
_context19.next = 4;
|
|
1234
|
+
return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
|
|
1235
|
+
menu_list_ids: menu_list_ids,
|
|
1236
|
+
cacheId: this.cacheId,
|
|
1237
|
+
schedule_date: dayjs().format('YYYY-MM-DD'),
|
|
1238
|
+
schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
1239
|
+
});
|
|
1240
|
+
case 4:
|
|
1241
|
+
res = _context19.sent;
|
|
1242
|
+
return _context19.abrupt("return", res);
|
|
1243
|
+
case 8:
|
|
1244
|
+
_context19.prev = 8;
|
|
1245
|
+
_context19.t0 = _context19["catch"](1);
|
|
1246
|
+
throw _context19.t0;
|
|
1247
|
+
case 11:
|
|
1248
|
+
case "end":
|
|
1249
|
+
return _context19.stop();
|
|
1250
|
+
}
|
|
1251
|
+
}, _callee19, this, [[1, 8]]);
|
|
1252
|
+
}));
|
|
1253
|
+
function getProductList() {
|
|
1254
|
+
return _getProductList.apply(this, arguments);
|
|
1255
|
+
}
|
|
1256
|
+
return getProductList;
|
|
1257
|
+
}()
|
|
1258
|
+
}, {
|
|
1259
|
+
key: "getOtherParams",
|
|
1260
|
+
value: function getOtherParams() {
|
|
1261
|
+
return this.otherParams;
|
|
1262
|
+
}
|
|
1263
|
+
}, {
|
|
1264
|
+
key: "setOtherParams",
|
|
1265
|
+
value: function () {
|
|
1266
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
|
|
1267
|
+
var _ref3,
|
|
1268
|
+
_ref3$cover,
|
|
1269
|
+
cover,
|
|
1270
|
+
_args20 = arguments;
|
|
1271
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1272
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1273
|
+
case 0:
|
|
1274
|
+
_ref3 = _args20.length > 1 && _args20[1] !== undefined ? _args20[1] : {}, _ref3$cover = _ref3.cover, cover = _ref3$cover === void 0 ? false : _ref3$cover;
|
|
1275
|
+
if (cover) {
|
|
1276
|
+
this.otherParams = params;
|
|
1277
|
+
} else {
|
|
1278
|
+
this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
|
|
1279
|
+
}
|
|
1280
|
+
case 2:
|
|
1281
|
+
case "end":
|
|
1282
|
+
return _context20.stop();
|
|
1283
|
+
}
|
|
1284
|
+
}, _callee20, this);
|
|
1285
|
+
}));
|
|
1286
|
+
function setOtherParams(_x16) {
|
|
1287
|
+
return _setOtherParams.apply(this, arguments);
|
|
1288
|
+
}
|
|
1289
|
+
return setOtherParams;
|
|
1290
|
+
}()
|
|
1291
|
+
}]);
|
|
1292
|
+
return BaseSalesImpl;
|
|
1293
|
+
}(BaseModule);
|