@pisell/pisellos 3.0.89 → 3.0.91
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/index.d.ts +1 -0
- package/dist/model/index.js +1 -0
- package/dist/model/strategy/adapter/index.d.ts +7 -0
- package/dist/model/strategy/adapter/index.js +7 -0
- 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/model/strategy/adapter/promotion/adapter.d.ts +66 -0
- package/dist/model/strategy/adapter/promotion/adapter.js +271 -0
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +213 -0
- package/dist/model/strategy/adapter/promotion/evaluator.js +1206 -0
- package/dist/model/strategy/adapter/promotion/examples.d.ts +138 -0
- package/dist/model/strategy/adapter/promotion/examples.js +166 -0
- package/dist/model/strategy/adapter/promotion/index.d.ts +4 -0
- package/dist/model/strategy/adapter/promotion/index.js +0 -0
- package/dist/model/strategy/adapter/promotion/type.d.ts +447 -0
- package/dist/model/strategy/adapter/promotion/type.js +209 -0
- package/dist/model/strategy/adapter/type.d.ts +28 -0
- package/dist/model/strategy/adapter/type.js +1 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +84 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.js +502 -0
- package/dist/model/strategy/adapter/walletPass/example.d.ts +4 -0
- package/dist/model/strategy/adapter/walletPass/example.js +258 -0
- package/dist/model/strategy/adapter/walletPass/index.d.ts +32 -0
- package/dist/model/strategy/adapter/walletPass/index.js +182 -0
- package/dist/model/strategy/adapter/walletPass/locales.d.ts +1 -0
- package/dist/model/strategy/adapter/walletPass/locales.js +26 -0
- package/dist/model/strategy/adapter/walletPass/type.d.ts +187 -0
- package/dist/model/strategy/adapter/walletPass/type.js +1 -0
- package/dist/model/strategy/adapter/walletPass/utils.d.ts +50 -0
- package/dist/model/strategy/adapter/walletPass/utils.js +1104 -0
- package/dist/model/strategy/engine.d.ts +106 -0
- package/dist/model/strategy/engine.js +611 -0
- package/dist/model/strategy/index.d.ts +3 -0
- package/dist/model/strategy/index.js +8 -0
- package/dist/model/strategy/strategy-example.d.ts +5 -0
- package/dist/model/strategy/strategy-example.js +331 -0
- package/dist/model/strategy/type.d.ts +228 -0
- package/dist/model/strategy/type.js +94 -0
- package/dist/modules/Cart/utils/cartProduct.js +1 -0
- package/dist/modules/Discount/index.d.ts +4 -2
- package/dist/modules/Discount/index.js +90 -3
- package/dist/modules/Discount/types.d.ts +6 -0
- 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 +66 -1
- package/dist/modules/Order/index.js +884 -10
- package/dist/modules/Order/types.d.ts +174 -12
- package/dist/modules/Order/types.js +2 -0
- package/dist/modules/Order/utils.d.ts +118 -0
- package/dist/modules/Order/utils.js +586 -2
- package/dist/modules/Product/utils.js +2 -2
- package/dist/modules/ProductList/index.d.ts +3 -1
- package/dist/modules/ProductList/index.js +19 -11
- package/dist/modules/Quotation/index.d.ts +48 -0
- package/dist/modules/Quotation/index.js +248 -0
- package/dist/modules/Quotation/types.d.ts +42 -0
- package/dist/modules/Quotation/types.js +1 -0
- package/dist/modules/Rules/index.js +17 -18
- package/dist/modules/SalesSummary/index.d.ts +63 -0
- package/dist/modules/SalesSummary/index.js +174 -0
- package/dist/modules/SalesSummary/types.d.ts +60 -0
- package/dist/modules/SalesSummary/types.js +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +30 -0
- package/dist/modules/SalesSummary/utils.js +480 -0
- package/dist/modules/ScanOrderLogger/index.d.ts +23 -0
- package/dist/modules/ScanOrderLogger/index.js +174 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.js +221 -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 +53 -0
- package/dist/modules/ScanOrderLogger/types.js +1 -0
- package/dist/modules/Schedule/getDateIsInSchedule.js +11 -18
- package/dist/modules/Schedule/utils.d.ts +1 -1
- package/dist/modules/Summary/utils.d.ts +3 -3
- package/dist/modules/Summary/utils.js +41 -31
- package/dist/modules/index.d.ts +4 -0
- package/dist/modules/index.js +5 -1
- package/dist/solution/BookingByStep/index.d.ts +3 -3
- package/dist/solution/BookingByStep/index.js +2 -1
- package/dist/solution/BookingByStep/types.d.ts +3 -1
- package/dist/solution/BookingByStep/types.js +5 -1
- package/dist/solution/ScanOrder/index.d.ts +158 -0
- package/dist/solution/ScanOrder/index.js +3474 -0
- package/dist/solution/ScanOrder/types.d.ts +306 -0
- package/dist/solution/ScanOrder/types.js +35 -0
- package/dist/solution/ScanOrder/utils.d.ts +172 -0
- package/dist/solution/ScanOrder/utils.js +796 -0
- package/dist/solution/ShopDiscount/index.d.ts +1 -0
- package/dist/solution/ShopDiscount/index.js +23 -18
- package/dist/solution/VenueBooking/index.d.ts +201 -0
- package/dist/solution/VenueBooking/index.js +3472 -0
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/dist/solution/VenueBooking/types.d.ts +154 -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 +131 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +38 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +239 -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 +2 -0
- package/dist/solution/index.js +3 -1
- package/lib/apis/picoding.d.ts +0 -0
- package/lib/apis/picoding.js +0 -0
- package/lib/model/index.d.ts +1 -0
- package/lib/model/index.js +23 -0
- package/lib/model/strategy/adapter/index.d.ts +7 -0
- package/lib/model/strategy/adapter/index.js +57 -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/adapter.d.ts +66 -0
- package/lib/model/strategy/adapter/promotion/adapter.js +217 -0
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +213 -0
- package/lib/model/strategy/adapter/promotion/evaluator.js +844 -0
- package/lib/model/strategy/adapter/promotion/examples.d.ts +138 -0
- package/lib/model/strategy/adapter/promotion/examples.js +192 -0
- package/lib/model/strategy/adapter/promotion/index.d.ts +4 -0
- package/lib/model/strategy/adapter/promotion/index.js +0 -0
- package/lib/model/strategy/adapter/promotion/type.d.ts +447 -0
- package/lib/model/strategy/adapter/promotion/type.js +51 -0
- package/lib/model/strategy/adapter/type.d.ts +28 -0
- package/lib/model/strategy/adapter/type.js +17 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +84 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.js +424 -0
- package/lib/model/strategy/adapter/walletPass/example.d.ts +4 -0
- package/lib/model/strategy/adapter/walletPass/example.js +207 -0
- package/lib/model/strategy/adapter/walletPass/index.d.ts +32 -0
- package/lib/model/strategy/adapter/walletPass/index.js +142 -0
- package/lib/model/strategy/adapter/walletPass/locales.d.ts +1 -0
- package/lib/model/strategy/adapter/walletPass/locales.js +54 -0
- package/lib/model/strategy/adapter/walletPass/type.d.ts +187 -0
- package/lib/model/strategy/adapter/walletPass/type.js +17 -0
- package/lib/model/strategy/adapter/walletPass/utils.d.ts +50 -0
- package/lib/model/strategy/adapter/walletPass/utils.js +791 -0
- package/lib/model/strategy/engine.d.ts +106 -0
- package/lib/model/strategy/engine.js +450 -0
- package/lib/model/strategy/index.d.ts +3 -0
- package/lib/model/strategy/index.js +38 -0
- package/lib/model/strategy/strategy-example.d.ts +5 -0
- package/lib/model/strategy/strategy-example.js +318 -0
- package/lib/model/strategy/type.d.ts +228 -0
- package/lib/model/strategy/type.js +44 -0
- package/lib/modules/Cart/utils/cartProduct.js +1 -0
- package/lib/modules/Discount/index.d.ts +4 -2
- package/lib/modules/Discount/index.js +60 -2
- package/lib/modules/Discount/types.d.ts +6 -0
- 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 +66 -1
- package/lib/modules/Order/index.js +525 -0
- package/lib/modules/Order/types.d.ts +174 -12
- package/lib/modules/Order/utils.d.ts +118 -0
- package/lib/modules/Order/utils.js +483 -2
- package/lib/modules/Product/utils.js +2 -2
- package/lib/modules/ProductList/index.d.ts +3 -1
- package/lib/modules/ProductList/index.js +45 -34
- package/lib/modules/Quotation/index.d.ts +48 -0
- package/lib/modules/Quotation/index.js +152 -0
- package/lib/modules/Quotation/types.d.ts +42 -0
- package/lib/modules/Quotation/types.js +17 -0
- package/lib/modules/Rules/index.js +17 -18
- package/lib/modules/SalesSummary/index.d.ts +63 -0
- package/lib/modules/SalesSummary/index.js +105 -0
- package/lib/modules/SalesSummary/types.d.ts +60 -0
- package/lib/modules/SalesSummary/types.js +17 -0
- package/lib/modules/SalesSummary/utils.d.ts +30 -0
- package/lib/modules/SalesSummary/utils.js +420 -0
- package/lib/modules/ScanOrderLogger/index.d.ts +23 -0
- package/lib/modules/ScanOrderLogger/index.js +147 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.js +157 -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 +53 -0
- package/lib/modules/ScanOrderLogger/types.js +17 -0
- package/lib/modules/Schedule/getDateIsInSchedule.js +9 -11
- package/lib/modules/Schedule/utils.d.ts +1 -1
- package/lib/modules/Summary/utils.d.ts +3 -3
- package/lib/modules/Summary/utils.js +22 -16
- package/lib/modules/index.d.ts +4 -0
- package/lib/modules/index.js +9 -1
- package/lib/solution/BookingByStep/index.d.ts +3 -3
- package/lib/solution/BookingByStep/index.js +2 -2
- package/lib/solution/BookingByStep/types.d.ts +3 -1
- package/lib/solution/BookingByStep/types.js +10 -0
- package/lib/solution/ScanOrder/index.d.ts +158 -0
- package/lib/solution/ScanOrder/index.js +2135 -0
- package/lib/solution/ScanOrder/types.d.ts +306 -0
- package/lib/solution/ScanOrder/types.js +36 -0
- package/lib/solution/ScanOrder/utils.d.ts +172 -0
- package/lib/solution/ScanOrder/utils.js +658 -0
- package/lib/solution/ShopDiscount/index.d.ts +1 -0
- package/lib/solution/ShopDiscount/index.js +4 -2
- package/lib/solution/VenueBooking/index.d.ts +201 -0
- package/lib/solution/VenueBooking/index.js +1937 -0
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/lib/solution/VenueBooking/types.d.ts +154 -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 +92 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +38 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +237 -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 +2 -0
- package/lib/solution/index.js +5 -1
- package/package.json +1 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
function
|
|
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
2
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
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."); }
|
|
4
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
5
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
6
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
7
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; }
|
|
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); }
|
|
8
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; }
|
|
9
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; }
|
|
10
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; }
|
|
@@ -24,8 +25,13 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
24
25
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
25
26
|
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); }
|
|
26
27
|
import { BaseModule } from "../BaseModule";
|
|
27
|
-
import { generateDuration, getAllDiscountList, mergeRelationForms } from "./utils";
|
|
28
|
+
import { generateDuration, getAllDiscountList, mergeRelationForms, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, filterProductsForScanOrderMore, isTempOrder } from "./utils";
|
|
28
29
|
import { isNormalProduct } from "../Product/utils";
|
|
30
|
+
import { buildProductLineFingerprint, getProductIdentityIndex, getSafeProductNum, isIdentityMatch, normalizeOrderProduct } from "../../solution/ScanOrder/utils";
|
|
31
|
+
import { DiscountModule } from "../Discount";
|
|
32
|
+
import { RulesModule } from "../Rules";
|
|
33
|
+
import { UnavailableReason } from "../Rules/types";
|
|
34
|
+
import Decimal from 'decimal.js';
|
|
29
35
|
export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
30
36
|
_inherits(OrderModule, _BaseModule);
|
|
31
37
|
var _super = _createSuper(OrderModule);
|
|
@@ -37,19 +43,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
37
43
|
_defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
|
|
38
44
|
_defineProperty(_assertThisInitialized(_this), "store", void 0);
|
|
39
45
|
_defineProperty(_assertThisInitialized(_this), "request", void 0);
|
|
46
|
+
_defineProperty(_assertThisInitialized(_this), "window", void 0);
|
|
47
|
+
_defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
|
|
48
|
+
_defineProperty(_assertThisInitialized(_this), "salesSummaryModuleName", void 0);
|
|
49
|
+
_defineProperty(_assertThisInitialized(_this), "rulesHooksOverride", void 0);
|
|
40
50
|
return _this;
|
|
41
51
|
}
|
|
42
52
|
_createClass(OrderModule, [{
|
|
43
53
|
key: "initialize",
|
|
44
54
|
value: function () {
|
|
45
55
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
|
|
56
|
+
var _otherParams$rules;
|
|
57
|
+
var otherParams;
|
|
46
58
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
47
59
|
while (1) switch (_context.prev = _context.next) {
|
|
48
60
|
case 0:
|
|
49
61
|
this.core = core;
|
|
50
62
|
this.store = options.store;
|
|
63
|
+
if (!this.store.tempOrder) {
|
|
64
|
+
this.store.tempOrder = null;
|
|
65
|
+
}
|
|
51
66
|
this.request = this.core.getPlugin('request');
|
|
52
|
-
|
|
67
|
+
this.window = this.core.getPlugin('window');
|
|
68
|
+
otherParams = options.otherParams || {};
|
|
69
|
+
this.cacheId = otherParams.cacheId;
|
|
70
|
+
this.salesSummaryModuleName = otherParams.salesSummaryModuleName;
|
|
71
|
+
this.rulesHooksOverride = (_otherParams$rules = otherParams.rules) === null || _otherParams$rules === void 0 ? void 0 : _otherParams$rules.hooks;
|
|
72
|
+
this.registerDiscountModules(options);
|
|
73
|
+
this.restoreTempOrderFromStorage();
|
|
74
|
+
case 11:
|
|
53
75
|
case "end":
|
|
54
76
|
return _context.stop();
|
|
55
77
|
}
|
|
@@ -59,6 +81,720 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
59
81
|
return _initialize.apply(this, arguments);
|
|
60
82
|
}
|
|
61
83
|
return initialize;
|
|
84
|
+
}() // ─── Discount: 子模块注册 ───
|
|
85
|
+
}, {
|
|
86
|
+
key: "registerDiscountModules",
|
|
87
|
+
value: function registerDiscountModules(options) {
|
|
88
|
+
var _targetCacheData;
|
|
89
|
+
var targetCacheData = {};
|
|
90
|
+
if (this.cacheId && this.window) {
|
|
91
|
+
var sessionData = this.window.sessionStorage.getItem(this.name);
|
|
92
|
+
if (sessionData) {
|
|
93
|
+
try {
|
|
94
|
+
var data = JSON.parse(sessionData);
|
|
95
|
+
targetCacheData = (data === null || data === void 0 ? void 0 : data[this.cacheId]) || {};
|
|
96
|
+
} catch (_unused) {
|
|
97
|
+
// sessionStorage 损坏则忽略,按空 initialState 走
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
var discount = new DiscountModule("".concat(this.name, "_discount"));
|
|
102
|
+
this.core.registerModule(discount, {
|
|
103
|
+
initialState: (_targetCacheData = targetCacheData) === null || _targetCacheData === void 0 ? void 0 : _targetCacheData[discount.name],
|
|
104
|
+
otherParams: {
|
|
105
|
+
fatherModule: this.name,
|
|
106
|
+
openCache: !!this.cacheId,
|
|
107
|
+
cacheId: this.cacheId
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
this.store.discount = discount;
|
|
111
|
+
var rules = new RulesModule("".concat(this.name, "_rules"));
|
|
112
|
+
this.core.registerModule(rules, {
|
|
113
|
+
hooks: this.rulesHooksOverride || this.createDefaultRulesHooks()
|
|
114
|
+
});
|
|
115
|
+
this.store.rules = rules;
|
|
116
|
+
}
|
|
117
|
+
}, {
|
|
118
|
+
key: "createDefaultRulesHooks",
|
|
119
|
+
value: function createDefaultRulesHooks() {
|
|
120
|
+
return createDefaultOrderRulesHooks();
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// ─── Discount: 公共 API ───
|
|
124
|
+
}, {
|
|
125
|
+
key: "loadDiscountConfig",
|
|
126
|
+
value: function () {
|
|
127
|
+
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
|
|
128
|
+
var _this$store$discount, _this$store$tempOrder;
|
|
129
|
+
var discountList, _this$store$discount2;
|
|
130
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
131
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
132
|
+
case 0:
|
|
133
|
+
_context2.next = 2;
|
|
134
|
+
return (_this$store$discount = this.store.discount) === null || _this$store$discount === void 0 ? void 0 : _this$store$discount.loadPrepareConfig({
|
|
135
|
+
customer_id: params.customerId,
|
|
136
|
+
action: params.action || 'create',
|
|
137
|
+
with_good_pass: 1,
|
|
138
|
+
with_discount_card: 1,
|
|
139
|
+
with_wallet_pass_holder: 1,
|
|
140
|
+
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
141
|
+
});
|
|
142
|
+
case 2:
|
|
143
|
+
discountList = _context2.sent;
|
|
144
|
+
if (discountList) {
|
|
145
|
+
(_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 || _this$store$discount2.setDiscountList(discountList);
|
|
146
|
+
}
|
|
147
|
+
if ((_this$store$tempOrder = this.store.tempOrder) !== null && _this$store$tempOrder !== void 0 && (_this$store$tempOrder = _this$store$tempOrder.products) !== null && _this$store$tempOrder !== void 0 && _this$store$tempOrder.length) {
|
|
148
|
+
this.applyDiscount();
|
|
149
|
+
}
|
|
150
|
+
case 5:
|
|
151
|
+
case "end":
|
|
152
|
+
return _context2.stop();
|
|
153
|
+
}
|
|
154
|
+
}, _callee2, this);
|
|
155
|
+
}));
|
|
156
|
+
function loadDiscountConfig(_x3) {
|
|
157
|
+
return _loadDiscountConfig.apply(this, arguments);
|
|
158
|
+
}
|
|
159
|
+
return loadDiscountConfig;
|
|
160
|
+
}()
|
|
161
|
+
}, {
|
|
162
|
+
key: "getDiscountList",
|
|
163
|
+
value: function getDiscountList() {
|
|
164
|
+
var _this$store$discount3;
|
|
165
|
+
return ((_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.getDiscountList()) || [];
|
|
166
|
+
}
|
|
167
|
+
}, {
|
|
168
|
+
key: "scanCode",
|
|
169
|
+
value: function () {
|
|
170
|
+
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(code, customerId) {
|
|
171
|
+
var _this$store$discount4, _tempOrder$holder, _tempOrder$holder2;
|
|
172
|
+
var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref, isAvailable, newDiscountList, unavailableReason, _this$store$discount5;
|
|
173
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
174
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
175
|
+
case 0:
|
|
176
|
+
_context3.next = 2;
|
|
177
|
+
return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.batchSearch(code, customerId);
|
|
178
|
+
case 2:
|
|
179
|
+
_context3.t0 = _context3.sent;
|
|
180
|
+
if (_context3.t0) {
|
|
181
|
+
_context3.next = 5;
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
_context3.t0 = {
|
|
185
|
+
discountList: [],
|
|
186
|
+
unavailableReasonKey: null
|
|
187
|
+
};
|
|
188
|
+
case 5:
|
|
189
|
+
resultDiscountWithReason = _context3.t0;
|
|
190
|
+
resultDiscountList = resultDiscountWithReason.discountList, unavailableReasonKey = resultDiscountWithReason.unavailableReasonKey;
|
|
191
|
+
rulesModule = this.store.rules;
|
|
192
|
+
if (rulesModule) {
|
|
193
|
+
_context3.next = 10;
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
return _context3.abrupt("return", {
|
|
197
|
+
type: 'clientCalc',
|
|
198
|
+
isAvailable: false,
|
|
199
|
+
discountList: this.getDiscountList(),
|
|
200
|
+
unavailableReason: UnavailableReason.Unknown
|
|
201
|
+
});
|
|
202
|
+
case 10:
|
|
203
|
+
if (resultDiscountList.length) {
|
|
204
|
+
_context3.next = 12;
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
return _context3.abrupt("return", {
|
|
208
|
+
type: 'server',
|
|
209
|
+
isAvailable: false,
|
|
210
|
+
discountList: this.getDiscountList(),
|
|
211
|
+
unavailableReasonKey: unavailableReasonKey
|
|
212
|
+
});
|
|
213
|
+
case 12:
|
|
214
|
+
withScanList = resultDiscountList.map(function (item) {
|
|
215
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
216
|
+
isScan: true
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
currentSelected = this.getDiscountList().filter(function (n) {
|
|
220
|
+
return n.isSelected;
|
|
221
|
+
});
|
|
222
|
+
if (!(currentSelected.length && currentSelected.some(function (n) {
|
|
223
|
+
return withScanList.some(function (m) {
|
|
224
|
+
return m.id === n.id;
|
|
225
|
+
});
|
|
226
|
+
}))) {
|
|
227
|
+
_context3.next = 16;
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
return _context3.abrupt("return", {
|
|
231
|
+
type: 'clientCalc',
|
|
232
|
+
isAvailable: true,
|
|
233
|
+
discountList: this.getDiscountList()
|
|
234
|
+
});
|
|
235
|
+
case 16:
|
|
236
|
+
tempOrder = this.store.tempOrder;
|
|
237
|
+
holders = tempOrder !== null && tempOrder !== void 0 && (_tempOrder$holder = tempOrder.holder) !== null && _tempOrder$holder !== void 0 && _tempOrder$holder.form_record_id ? [{
|
|
238
|
+
form_record_id: tempOrder.holder.form_record_id
|
|
239
|
+
}] : [];
|
|
240
|
+
_ref = rulesModule.isDiscountListAvailable({
|
|
241
|
+
productList: (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || [],
|
|
242
|
+
oldDiscountList: this.getDiscountList(),
|
|
243
|
+
newDiscountList: withScanList,
|
|
244
|
+
holders: holders,
|
|
245
|
+
isFormSubject: !!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$holder2 = tempOrder.holder) !== null && _tempOrder$holder2 !== void 0 && _tempOrder$holder2.type) && tempOrder.holder.type === 'form'
|
|
246
|
+
}) || {
|
|
247
|
+
isAvailable: false,
|
|
248
|
+
discountList: this.getDiscountList()
|
|
249
|
+
}, isAvailable = _ref.isAvailable, newDiscountList = _ref.discountList, unavailableReason = _ref.unavailableReason;
|
|
250
|
+
if (isAvailable && newDiscountList) {
|
|
251
|
+
(_this$store$discount5 = this.store.discount) === null || _this$store$discount5 === void 0 || _this$store$discount5.setDiscountList(newDiscountList);
|
|
252
|
+
this.applyDiscount();
|
|
253
|
+
}
|
|
254
|
+
return _context3.abrupt("return", {
|
|
255
|
+
type: 'clientCalc',
|
|
256
|
+
isAvailable: isAvailable || false,
|
|
257
|
+
discountList: newDiscountList || this.getDiscountList(),
|
|
258
|
+
unavailableReason: unavailableReason
|
|
259
|
+
});
|
|
260
|
+
case 21:
|
|
261
|
+
case "end":
|
|
262
|
+
return _context3.stop();
|
|
263
|
+
}
|
|
264
|
+
}, _callee3, this);
|
|
265
|
+
}));
|
|
266
|
+
function scanCode(_x4, _x5) {
|
|
267
|
+
return _scanCode.apply(this, arguments);
|
|
268
|
+
}
|
|
269
|
+
return scanCode;
|
|
270
|
+
}()
|
|
271
|
+
}, {
|
|
272
|
+
key: "applyDiscount",
|
|
273
|
+
value: function applyDiscount() {
|
|
274
|
+
var _this$store$discount6, _tempOrder$holder3, _tempOrder$holder4;
|
|
275
|
+
var tempOrder = this.store.tempOrder;
|
|
276
|
+
// 任意 products CRUD 后都应当重算 discount 状态;即使 products 为空,
|
|
277
|
+
// 也需要让 Rules.calcDiscount 把 DiscountModule 的 isSelected / isAvailable /
|
|
278
|
+
// appliedProductDetails / savedAmount 以及 tempOrder.discount_list 复位。
|
|
279
|
+
if (!tempOrder) return;
|
|
280
|
+
var rulesModule = this.store.rules;
|
|
281
|
+
if (!rulesModule) return;
|
|
282
|
+
var discountList = ((_this$store$discount6 = this.store.discount) === null || _this$store$discount6 === void 0 ? void 0 : _this$store$discount6.getDiscountList()) || [];
|
|
283
|
+
var holders = (_tempOrder$holder3 = tempOrder.holder) !== null && _tempOrder$holder3 !== void 0 && _tempOrder$holder3.form_record_id ? [{
|
|
284
|
+
form_record_id: tempOrder.holder.form_record_id
|
|
285
|
+
}] : [];
|
|
286
|
+
var result = rulesModule.calcDiscount({
|
|
287
|
+
productList: tempOrder.products,
|
|
288
|
+
discountList: discountList,
|
|
289
|
+
holders: holders,
|
|
290
|
+
isFormSubject: !!((_tempOrder$holder4 = tempOrder.holder) !== null && _tempOrder$holder4 !== void 0 && _tempOrder$holder4.type) && tempOrder.holder.type === 'form'
|
|
291
|
+
});
|
|
292
|
+
if (result !== null && result !== void 0 && result.productList) {
|
|
293
|
+
tempOrder.products = result.productList;
|
|
294
|
+
}
|
|
295
|
+
if (result !== null && result !== void 0 && result.discountList) {
|
|
296
|
+
var _this$store$discount7;
|
|
297
|
+
OrderModule.populateSavedAmounts(result.productList || tempOrder.products, result.discountList);
|
|
298
|
+
(_this$store$discount7 = this.store.discount) === null || _this$store$discount7 === void 0 || _this$store$discount7.setDiscountList(result.discountList);
|
|
299
|
+
tempOrder.discount_list = result.discountList.filter(function (d) {
|
|
300
|
+
return d.isSelected;
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// ─── TempOrder: 初始化入口 ───
|
|
306
|
+
}, {
|
|
307
|
+
key: "initTempOrder",
|
|
308
|
+
value: function initTempOrder(params) {
|
|
309
|
+
if (params.cacheId !== undefined) this.cacheId = params.cacheId;
|
|
310
|
+
if (params.salesSummaryModuleName !== undefined) this.salesSummaryModuleName = params.salesSummaryModuleName;
|
|
311
|
+
this.restoreTempOrderFromStorage();
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// ─── TempOrder: localStorage 持久化 ───
|
|
315
|
+
}, {
|
|
316
|
+
key: "getTempOrderStorageKey",
|
|
317
|
+
value: function getTempOrderStorageKey() {
|
|
318
|
+
if (!this.cacheId) return null;
|
|
319
|
+
return "scanOrder:tempOrder:".concat(this.cacheId);
|
|
320
|
+
}
|
|
321
|
+
}, {
|
|
322
|
+
key: "restoreTempOrderFromStorage",
|
|
323
|
+
value: function restoreTempOrderFromStorage() {
|
|
324
|
+
var key = this.getTempOrderStorageKey();
|
|
325
|
+
if (!key) return;
|
|
326
|
+
if (!this.window) return;
|
|
327
|
+
var cachedData = this.window.localStorage.getItem(key);
|
|
328
|
+
if (!cachedData) return;
|
|
329
|
+
try {
|
|
330
|
+
var parsedData = JSON.parse(cachedData);
|
|
331
|
+
if (!isTempOrder(parsedData)) {
|
|
332
|
+
this.window.localStorage.removeItem(key);
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
if (Array.isArray(parsedData.products)) {
|
|
336
|
+
for (var i = 0; i < parsedData.products.length; i++) {
|
|
337
|
+
var p = parsedData.products[i];
|
|
338
|
+
if (!p || _typeof(p) !== 'object') continue;
|
|
339
|
+
if (!Array.isArray(p.product_option_item)) {
|
|
340
|
+
p.product_option_item = [];
|
|
341
|
+
}
|
|
342
|
+
if (!Array.isArray(p.product_bundle)) {
|
|
343
|
+
p.product_bundle = [];
|
|
344
|
+
}
|
|
345
|
+
// 不透明 identity 契约:旧缓存里可能没有 identity_key,
|
|
346
|
+
// 此处统一回填 UUID 并同步 metadata.unique_identification_number,
|
|
347
|
+
// 避免升级后 UI 侧持有的 rowKey 找不到对应行。
|
|
348
|
+
var row = p;
|
|
349
|
+
if (typeof row.identity_key !== 'string' || row.identity_key.length === 0) {
|
|
350
|
+
var newKey = createUuidV4();
|
|
351
|
+
row.identity_key = newKey;
|
|
352
|
+
if (!row.metadata || _typeof(row.metadata) !== 'object') {
|
|
353
|
+
row.metadata = {};
|
|
354
|
+
}
|
|
355
|
+
if (!row.metadata.unique_identification_number) {
|
|
356
|
+
row.metadata.unique_identification_number = newKey;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
// 价格 schema 迁移:重跑 normalizeOrderProduct。
|
|
360
|
+
// `metadata.price_schema_version === 2` → 已是新语义,保留现有 main_product_* 折扣;
|
|
361
|
+
// 否则(v1 或无 metadata)→ 走 legacyDiscount 反推分支,基于新的 source + options
|
|
362
|
+
// 重算出含 option 的 main_product_*,并打上 price_schema_version: 2。
|
|
363
|
+
// 幂等:多次 restore 不会重复叠加 option/bundle。
|
|
364
|
+
parsedData.products[i] = normalizeOrderProduct(row);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
this.store.tempOrder = parsedData;
|
|
368
|
+
} catch (_unused2) {
|
|
369
|
+
var _this$window;
|
|
370
|
+
(_this$window = this.window) === null || _this$window === void 0 || (_this$window = _this$window.localStorage) === null || _this$window === void 0 || _this$window.removeItem(key);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}, {
|
|
374
|
+
key: "persistTempOrder",
|
|
375
|
+
value: function persistTempOrder() {
|
|
376
|
+
var key = this.getTempOrderStorageKey();
|
|
377
|
+
if (!key || !this.store.tempOrder) return;
|
|
378
|
+
if (!this.window) return;
|
|
379
|
+
this.window.localStorage.setItem(key, JSON.stringify(this.store.tempOrder));
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// ─── TempOrder: 创建 & 获取 ───
|
|
383
|
+
}, {
|
|
384
|
+
key: "createDefaultTempOrderInstance",
|
|
385
|
+
value: function createDefaultTempOrderInstance() {
|
|
386
|
+
return createDefaultTempOrder({
|
|
387
|
+
now: formatDateTime(new Date()),
|
|
388
|
+
summary: createEmptySummary()
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
}, {
|
|
392
|
+
key: "ensureTempOrder",
|
|
393
|
+
value: function ensureTempOrder() {
|
|
394
|
+
if (this.store.tempOrder) return this.store.tempOrder;
|
|
395
|
+
var newOrder = this.createDefaultTempOrderInstance();
|
|
396
|
+
this.store.tempOrder = newOrder;
|
|
397
|
+
this.persistTempOrder();
|
|
398
|
+
return newOrder;
|
|
399
|
+
}
|
|
400
|
+
}, {
|
|
401
|
+
key: "restoreOrder",
|
|
402
|
+
value: function restoreOrder() {
|
|
403
|
+
var freshTempOrder = this.createDefaultTempOrderInstance();
|
|
404
|
+
this.store.tempOrder = freshTempOrder;
|
|
405
|
+
this.persistTempOrder();
|
|
406
|
+
return freshTempOrder;
|
|
407
|
+
}
|
|
408
|
+
}, {
|
|
409
|
+
key: "getTempOrder",
|
|
410
|
+
value: function getTempOrder() {
|
|
411
|
+
return this.store.tempOrder;
|
|
412
|
+
}
|
|
413
|
+
}, {
|
|
414
|
+
key: "addNewOrder",
|
|
415
|
+
value: function () {
|
|
416
|
+
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
417
|
+
var tempOrder;
|
|
418
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
419
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
420
|
+
case 0:
|
|
421
|
+
tempOrder = this.ensureTempOrder();
|
|
422
|
+
_context4.next = 3;
|
|
423
|
+
return this.recalculateSummary({
|
|
424
|
+
createIfMissing: true
|
|
425
|
+
});
|
|
426
|
+
case 3:
|
|
427
|
+
this.persistTempOrder();
|
|
428
|
+
return _context4.abrupt("return", tempOrder);
|
|
429
|
+
case 5:
|
|
430
|
+
case "end":
|
|
431
|
+
return _context4.stop();
|
|
432
|
+
}
|
|
433
|
+
}, _callee4, this);
|
|
434
|
+
}));
|
|
435
|
+
function addNewOrder() {
|
|
436
|
+
return _addNewOrder.apply(this, arguments);
|
|
437
|
+
}
|
|
438
|
+
return addNewOrder;
|
|
439
|
+
}()
|
|
440
|
+
}, {
|
|
441
|
+
key: "getOrderProducts",
|
|
442
|
+
value: function getOrderProducts() {
|
|
443
|
+
var tempOrder = this.ensureTempOrder();
|
|
444
|
+
return tempOrder.products;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
// ─── TempOrder: 金额汇总 ───
|
|
448
|
+
}, {
|
|
449
|
+
key: "getSalesSummary",
|
|
450
|
+
value: function getSalesSummary() {
|
|
451
|
+
if (!this.salesSummaryModuleName) return null;
|
|
452
|
+
return this.core.getModule(this.salesSummaryModuleName);
|
|
453
|
+
}
|
|
454
|
+
}, {
|
|
455
|
+
key: "recalculateSummary",
|
|
456
|
+
value: function () {
|
|
457
|
+
var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(options) {
|
|
458
|
+
var tempOrder, salesSummary, summary;
|
|
459
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
460
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
461
|
+
case 0:
|
|
462
|
+
tempOrder = options !== null && options !== void 0 && options.createIfMissing ? this.ensureTempOrder() : this.store.tempOrder;
|
|
463
|
+
if (tempOrder) {
|
|
464
|
+
_context5.next = 3;
|
|
465
|
+
break;
|
|
466
|
+
}
|
|
467
|
+
return _context5.abrupt("return", null);
|
|
468
|
+
case 3:
|
|
469
|
+
salesSummary = this.getSalesSummary();
|
|
470
|
+
if (salesSummary) {
|
|
471
|
+
_context5.next = 8;
|
|
472
|
+
break;
|
|
473
|
+
}
|
|
474
|
+
tempOrder.summary = createEmptySummary();
|
|
475
|
+
tempOrder.surcharge_fee = tempOrder.summary.surcharge_fee;
|
|
476
|
+
return _context5.abrupt("return", tempOrder.summary);
|
|
477
|
+
case 8:
|
|
478
|
+
_context5.next = 10;
|
|
479
|
+
return salesSummary.getSummary({
|
|
480
|
+
products: tempOrder.products
|
|
481
|
+
});
|
|
482
|
+
case 10:
|
|
483
|
+
summary = _context5.sent;
|
|
484
|
+
tempOrder.summary = summary;
|
|
485
|
+
if (summary.is_price_include_tax !== undefined) {
|
|
486
|
+
tempOrder.is_price_include_tax = summary.is_price_include_tax;
|
|
487
|
+
}
|
|
488
|
+
if (typeof summary.tax_title === 'string') {
|
|
489
|
+
tempOrder.tax_title = summary.tax_title;
|
|
490
|
+
}
|
|
491
|
+
tempOrder.surcharge_fee = summary.surcharge_fee;
|
|
492
|
+
tempOrder.surcharges = summary.surcharges || [];
|
|
493
|
+
tempOrder.deposit_amount = summary.deposit_amount || '0.00';
|
|
494
|
+
tempOrder.is_deposit = summary.deposit_amount !== '0.00' ? 1 : 0;
|
|
495
|
+
tempOrder.shop_discount = summary.discount_amount || '0.00';
|
|
496
|
+
return _context5.abrupt("return", tempOrder.summary);
|
|
497
|
+
case 20:
|
|
498
|
+
case "end":
|
|
499
|
+
return _context5.stop();
|
|
500
|
+
}
|
|
501
|
+
}, _callee5, this);
|
|
502
|
+
}));
|
|
503
|
+
function recalculateSummary(_x6) {
|
|
504
|
+
return _recalculateSummary.apply(this, arguments);
|
|
505
|
+
}
|
|
506
|
+
return recalculateSummary;
|
|
507
|
+
}()
|
|
508
|
+
}, {
|
|
509
|
+
key: "getScanOrderSummary",
|
|
510
|
+
value: function () {
|
|
511
|
+
var _getScanOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
512
|
+
var summary;
|
|
513
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
514
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
515
|
+
case 0:
|
|
516
|
+
_context6.next = 2;
|
|
517
|
+
return this.recalculateSummary({
|
|
518
|
+
createIfMissing: true
|
|
519
|
+
});
|
|
520
|
+
case 2:
|
|
521
|
+
summary = _context6.sent;
|
|
522
|
+
if (summary) {
|
|
523
|
+
_context6.next = 5;
|
|
524
|
+
break;
|
|
525
|
+
}
|
|
526
|
+
return _context6.abrupt("return", createEmptySummary());
|
|
527
|
+
case 5:
|
|
528
|
+
this.persistTempOrder();
|
|
529
|
+
return _context6.abrupt("return", summary);
|
|
530
|
+
case 7:
|
|
531
|
+
case "end":
|
|
532
|
+
return _context6.stop();
|
|
533
|
+
}
|
|
534
|
+
}, _callee6, this);
|
|
535
|
+
}));
|
|
536
|
+
function getScanOrderSummary() {
|
|
537
|
+
return _getScanOrderSummary.apply(this, arguments);
|
|
538
|
+
}
|
|
539
|
+
return getScanOrderSummary;
|
|
540
|
+
}() // ─── TempOrder: 备注 ───
|
|
541
|
+
}, {
|
|
542
|
+
key: "updateTempOrderNote",
|
|
543
|
+
value: function updateTempOrderNote(note) {
|
|
544
|
+
var tempOrder = this.ensureTempOrder();
|
|
545
|
+
tempOrder.note = String(note || '');
|
|
546
|
+
this.persistTempOrder();
|
|
547
|
+
return tempOrder.note;
|
|
548
|
+
}
|
|
549
|
+
}, {
|
|
550
|
+
key: "updateTempOrderBuzzer",
|
|
551
|
+
value: function updateTempOrderBuzzer(buzzer) {
|
|
552
|
+
var tempOrder = this.ensureTempOrder();
|
|
553
|
+
tempOrder.buzzer = String(buzzer || '');
|
|
554
|
+
this.persistTempOrder();
|
|
555
|
+
return tempOrder.buzzer;
|
|
556
|
+
}
|
|
557
|
+
}, {
|
|
558
|
+
key: "updateTempOrderContactsInfo",
|
|
559
|
+
value: function updateTempOrderContactsInfo(contactsInfo) {
|
|
560
|
+
var tempOrder = this.ensureTempOrder();
|
|
561
|
+
tempOrder.contacts_info = Array.isArray(contactsInfo) ? contactsInfo : [];
|
|
562
|
+
this.persistTempOrder();
|
|
563
|
+
return tempOrder.contacts_info;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
// ─── TempOrder: 商品 CRUD ───
|
|
567
|
+
}, {
|
|
568
|
+
key: "addProductToOrder",
|
|
569
|
+
value: function () {
|
|
570
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(product) {
|
|
571
|
+
var tempOrder, hasExplicitIdentityKey, normalizedProduct, productIndex, targetProduct, incomingFingerprint, matchedIndex, _normalizedProduct, _targetProduct, _normalizedProduct2;
|
|
572
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
573
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
574
|
+
case 0:
|
|
575
|
+
tempOrder = this.ensureTempOrder();
|
|
576
|
+
hasExplicitIdentityKey = typeof product.identity_key === 'string' && product.identity_key.length > 0;
|
|
577
|
+
if (hasExplicitIdentityKey) {
|
|
578
|
+
// 调用方自持 identity_key(如 VenueBooking 外部生成)→ 走严格 identity 合并。
|
|
579
|
+
normalizedProduct = normalizeOrderProduct(product);
|
|
580
|
+
productIndex = getProductIdentityIndex(tempOrder.products, normalizedProduct);
|
|
581
|
+
if (productIndex === -1) {
|
|
582
|
+
tempOrder.products.push(normalizedProduct);
|
|
583
|
+
} else {
|
|
584
|
+
targetProduct = tempOrder.products[productIndex];
|
|
585
|
+
tempOrder.products[productIndex] = _objectSpread(_objectSpread(_objectSpread({}, targetProduct), normalizedProduct), {}, {
|
|
586
|
+
num: getSafeProductNum(targetProduct.num + normalizedProduct.num),
|
|
587
|
+
_origin: normalizedProduct._origin || targetProduct._origin
|
|
588
|
+
});
|
|
589
|
+
}
|
|
590
|
+
} else {
|
|
591
|
+
// 无 identity_key:按 SKU + 内容指纹(options + bundle)匹配既有行以累加数量;
|
|
592
|
+
// 命中时保留已有 identity_key,未命中才由 normalizeOrderProduct 自动生成 UUID。
|
|
593
|
+
incomingFingerprint = buildProductLineFingerprint(product.product_option_item, product.product_bundle);
|
|
594
|
+
matchedIndex = tempOrder.products.findIndex(function (item) {
|
|
595
|
+
if (item.product_id !== product.product_id) return false;
|
|
596
|
+
if (item.product_variant_id !== product.product_variant_id) return false;
|
|
597
|
+
var existedFingerprint = buildProductLineFingerprint(item.product_option_item, item.product_bundle);
|
|
598
|
+
return existedFingerprint === incomingFingerprint;
|
|
599
|
+
});
|
|
600
|
+
if (matchedIndex === -1) {
|
|
601
|
+
_normalizedProduct = normalizeOrderProduct(product);
|
|
602
|
+
tempOrder.products.push(_normalizedProduct);
|
|
603
|
+
} else {
|
|
604
|
+
_targetProduct = tempOrder.products[matchedIndex];
|
|
605
|
+
_normalizedProduct2 = normalizeOrderProduct(_objectSpread(_objectSpread({}, product), {}, {
|
|
606
|
+
identity_key: _targetProduct.identity_key
|
|
607
|
+
}));
|
|
608
|
+
tempOrder.products[matchedIndex] = _objectSpread(_objectSpread(_objectSpread({}, _targetProduct), _normalizedProduct2), {}, {
|
|
609
|
+
identity_key: _targetProduct.identity_key,
|
|
610
|
+
num: getSafeProductNum(_targetProduct.num + _normalizedProduct2.num),
|
|
611
|
+
_origin: _normalizedProduct2._origin || _targetProduct._origin
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
this.applyDiscount();
|
|
616
|
+
_context7.next = 6;
|
|
617
|
+
return this.recalculateSummary({
|
|
618
|
+
createIfMissing: true
|
|
619
|
+
});
|
|
620
|
+
case 6:
|
|
621
|
+
this.persistTempOrder();
|
|
622
|
+
return _context7.abrupt("return", tempOrder.products);
|
|
623
|
+
case 8:
|
|
624
|
+
case "end":
|
|
625
|
+
return _context7.stop();
|
|
626
|
+
}
|
|
627
|
+
}, _callee7, this);
|
|
628
|
+
}));
|
|
629
|
+
function addProductToOrder(_x7) {
|
|
630
|
+
return _addProductToOrder.apply(this, arguments);
|
|
631
|
+
}
|
|
632
|
+
return addProductToOrder;
|
|
633
|
+
}()
|
|
634
|
+
}, {
|
|
635
|
+
key: "updateProductInOrder",
|
|
636
|
+
value: function () {
|
|
637
|
+
var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params) {
|
|
638
|
+
var _metadata, _metadata2, _metadata3;
|
|
639
|
+
var product_id, product_variant_id, updates, identity_key, product_option_item, product_bundle, tempOrder, identityLookup, productIndex, targetProduct, nextProduct, callerUpdatesTopPrice, callerUpdatesMainMeta, existedMeta;
|
|
640
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
641
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
642
|
+
case 0:
|
|
643
|
+
product_id = params.product_id, product_variant_id = params.product_variant_id, updates = params.updates, identity_key = params.identity_key, product_option_item = params.product_option_item, product_bundle = params.product_bundle;
|
|
644
|
+
tempOrder = this.ensureTempOrder();
|
|
645
|
+
identityLookup = {
|
|
646
|
+
product_id: product_id,
|
|
647
|
+
product_variant_id: product_variant_id
|
|
648
|
+
};
|
|
649
|
+
if (identity_key !== undefined) identityLookup.identity_key = identity_key;
|
|
650
|
+
if (product_option_item !== undefined) identityLookup.product_option_item = product_option_item;
|
|
651
|
+
if (product_bundle !== undefined) identityLookup.product_bundle = product_bundle;
|
|
652
|
+
productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
|
|
653
|
+
if (!(productIndex === -1)) {
|
|
654
|
+
_context8.next = 9;
|
|
655
|
+
break;
|
|
656
|
+
}
|
|
657
|
+
throw new Error('[Order] 目标商品不存在,无法更新');
|
|
658
|
+
case 9:
|
|
659
|
+
targetProduct = tempOrder.products[productIndex];
|
|
660
|
+
nextProduct = _objectSpread(_objectSpread(_objectSpread({}, targetProduct), updates), {}, {
|
|
661
|
+
product_id: product_id,
|
|
662
|
+
product_variant_id: product_variant_id
|
|
663
|
+
});
|
|
664
|
+
nextProduct.num = getSafeProductNum(nextProduct.num);
|
|
665
|
+
// 兜底:caller 通过 updates 直接改了 selling_price / original_price 时,
|
|
666
|
+
// 视为 "重新给 source-level 主价"(caller 侧旧约定仍是 main-only 单价)。
|
|
667
|
+
// 清掉 metadata 里的 source_product_price / main_product_* / price_schema_version,
|
|
668
|
+
// 让 normalize 把顶层 selling_price 当作 source 来重算 main_original(=source+options) /
|
|
669
|
+
// main_selling / composite;否则旧 metadata 会反压顶层新值,触发口径不一致。
|
|
670
|
+
// 如果 caller 走推荐路径(updates.metadata.* 显式指定主价),保留 metadata 由 normalize 认它。
|
|
671
|
+
callerUpdatesTopPrice = Object.prototype.hasOwnProperty.call(updates || {}, 'selling_price') || Object.prototype.hasOwnProperty.call(updates || {}, 'original_price');
|
|
672
|
+
callerUpdatesMainMeta = (updates === null || updates === void 0 || (_metadata = updates.metadata) === null || _metadata === void 0 ? void 0 : _metadata.main_product_selling_price) !== undefined || (updates === null || updates === void 0 || (_metadata2 = updates.metadata) === null || _metadata2 === void 0 ? void 0 : _metadata2.main_product_original_price) !== undefined || (updates === null || updates === void 0 || (_metadata3 = updates.metadata) === null || _metadata3 === void 0 ? void 0 : _metadata3.source_product_price) !== undefined;
|
|
673
|
+
if (callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
674
|
+
existedMeta = nextProduct.metadata || {};
|
|
675
|
+
nextProduct.metadata = _objectSpread({}, existedMeta);
|
|
676
|
+
delete nextProduct.metadata.source_product_price;
|
|
677
|
+
delete nextProduct.metadata.main_product_selling_price;
|
|
678
|
+
delete nextProduct.metadata.main_product_original_price;
|
|
679
|
+
delete nextProduct.metadata.price_schema_version;
|
|
680
|
+
}
|
|
681
|
+
// normalizeOrderProduct 幂等:v2 metadata 存在 → 保留 main_product_* 折扣重算 composite;
|
|
682
|
+
// 否则 → 把顶层 selling_price 视作 source,派生 main_product_* 并写 price_schema_version: 2。
|
|
683
|
+
tempOrder.products[productIndex] = normalizeOrderProduct(nextProduct);
|
|
684
|
+
this.applyDiscount();
|
|
685
|
+
_context8.next = 19;
|
|
686
|
+
return this.recalculateSummary({
|
|
687
|
+
createIfMissing: true
|
|
688
|
+
});
|
|
689
|
+
case 19:
|
|
690
|
+
this.persistTempOrder();
|
|
691
|
+
return _context8.abrupt("return", tempOrder.products);
|
|
692
|
+
case 21:
|
|
693
|
+
case "end":
|
|
694
|
+
return _context8.stop();
|
|
695
|
+
}
|
|
696
|
+
}, _callee8, this);
|
|
697
|
+
}));
|
|
698
|
+
function updateProductInOrder(_x8) {
|
|
699
|
+
return _updateProductInOrder.apply(this, arguments);
|
|
700
|
+
}
|
|
701
|
+
return updateProductInOrder;
|
|
702
|
+
}()
|
|
703
|
+
}, {
|
|
704
|
+
key: "removeProductFromOrder",
|
|
705
|
+
value: function () {
|
|
706
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(identity) {
|
|
707
|
+
var tempOrder;
|
|
708
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
709
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
710
|
+
case 0:
|
|
711
|
+
tempOrder = this.ensureTempOrder();
|
|
712
|
+
tempOrder.products = tempOrder.products.filter(function (item) {
|
|
713
|
+
return !isIdentityMatch(item, identity);
|
|
714
|
+
});
|
|
715
|
+
this.applyDiscount();
|
|
716
|
+
_context9.next = 5;
|
|
717
|
+
return this.recalculateSummary({
|
|
718
|
+
createIfMissing: true
|
|
719
|
+
});
|
|
720
|
+
case 5:
|
|
721
|
+
this.persistTempOrder();
|
|
722
|
+
return _context9.abrupt("return", tempOrder.products);
|
|
723
|
+
case 7:
|
|
724
|
+
case "end":
|
|
725
|
+
return _context9.stop();
|
|
726
|
+
}
|
|
727
|
+
}, _callee9, this);
|
|
728
|
+
}));
|
|
729
|
+
function removeProductFromOrder(_x9) {
|
|
730
|
+
return _removeProductFromOrder.apply(this, arguments);
|
|
731
|
+
}
|
|
732
|
+
return removeProductFromOrder;
|
|
733
|
+
}() // ─── TempOrder: 提交 ───
|
|
734
|
+
}, {
|
|
735
|
+
key: "submitTempOrder",
|
|
736
|
+
value: function () {
|
|
737
|
+
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
|
|
738
|
+
var _params$cacheId;
|
|
739
|
+
var tempOrder, effectiveCacheId, payload, result, products, moreResult;
|
|
740
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
741
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
742
|
+
case 0:
|
|
743
|
+
tempOrder = this.ensureTempOrder();
|
|
744
|
+
this.persistTempOrder();
|
|
745
|
+
effectiveCacheId = (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId;
|
|
746
|
+
payload = buildSubmitPayload({
|
|
747
|
+
tempOrder: tempOrder,
|
|
748
|
+
cacheId: effectiveCacheId,
|
|
749
|
+
platform: params === null || params === void 0 ? void 0 : params.platform,
|
|
750
|
+
businessCode: params === null || params === void 0 ? void 0 : params.businessCode,
|
|
751
|
+
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
752
|
+
type: params === null || params === void 0 ? void 0 : params.type,
|
|
753
|
+
enhance: params === null || params === void 0 ? void 0 : params.enhancePayload
|
|
754
|
+
});
|
|
755
|
+
if (!tempOrder.order_id) {
|
|
756
|
+
_context10.next = 12;
|
|
757
|
+
break;
|
|
758
|
+
}
|
|
759
|
+
products = filterProductsForScanOrderMore(payload.products);
|
|
760
|
+
_context10.next = 8;
|
|
761
|
+
return this.scanOrderMore({
|
|
762
|
+
query: {
|
|
763
|
+
order_id: tempOrder.order_id,
|
|
764
|
+
products: products,
|
|
765
|
+
request_unique_idempotency_token: payload.request_unique_idempotency_token
|
|
766
|
+
}
|
|
767
|
+
});
|
|
768
|
+
case 8:
|
|
769
|
+
moreResult = _context10.sent;
|
|
770
|
+
if (moreResult.code === 200) {
|
|
771
|
+
result = {
|
|
772
|
+
data: {
|
|
773
|
+
order_id: tempOrder.order_id
|
|
774
|
+
}
|
|
775
|
+
};
|
|
776
|
+
}
|
|
777
|
+
_context10.next = 15;
|
|
778
|
+
break;
|
|
779
|
+
case 12:
|
|
780
|
+
_context10.next = 14;
|
|
781
|
+
return this.submitScanOrder({
|
|
782
|
+
query: payload
|
|
783
|
+
});
|
|
784
|
+
case 14:
|
|
785
|
+
result = _context10.sent;
|
|
786
|
+
case 15:
|
|
787
|
+
return _context10.abrupt("return", result);
|
|
788
|
+
case 16:
|
|
789
|
+
case "end":
|
|
790
|
+
return _context10.stop();
|
|
791
|
+
}
|
|
792
|
+
}, _callee10, this);
|
|
793
|
+
}));
|
|
794
|
+
function submitTempOrder(_x10) {
|
|
795
|
+
return _submitTempOrder.apply(this, arguments);
|
|
796
|
+
}
|
|
797
|
+
return submitTempOrder;
|
|
62
798
|
}()
|
|
63
799
|
}, {
|
|
64
800
|
key: "createOrder",
|
|
@@ -138,26 +874,164 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
138
874
|
}, {
|
|
139
875
|
key: "submitOrder",
|
|
140
876
|
value: function () {
|
|
141
|
-
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
877
|
+
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(order) {
|
|
142
878
|
var url, query, fetchUrl, params;
|
|
143
|
-
return _regeneratorRuntime().wrap(function
|
|
144
|
-
while (1) switch (
|
|
879
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
880
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
145
881
|
case 0:
|
|
146
882
|
url = order.url, query = order.query;
|
|
147
883
|
fetchUrl = url || '/order/appointment';
|
|
148
884
|
params = this.createOrder(query);
|
|
149
|
-
return
|
|
885
|
+
return _context11.abrupt("return", this.request.post(fetchUrl, params));
|
|
150
886
|
case 4:
|
|
151
887
|
case "end":
|
|
152
|
-
return
|
|
888
|
+
return _context11.stop();
|
|
153
889
|
}
|
|
154
|
-
},
|
|
890
|
+
}, _callee11, this);
|
|
155
891
|
}));
|
|
156
|
-
function submitOrder(
|
|
892
|
+
function submitOrder(_x11) {
|
|
157
893
|
return _submitOrder.apply(this, arguments);
|
|
158
894
|
}
|
|
159
895
|
return submitOrder;
|
|
160
896
|
}()
|
|
897
|
+
}, {
|
|
898
|
+
key: "submitScanOrder",
|
|
899
|
+
value: function () {
|
|
900
|
+
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(params) {
|
|
901
|
+
var url, query, fetchUrl;
|
|
902
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
903
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
904
|
+
case 0:
|
|
905
|
+
url = params.url, query = params.query;
|
|
906
|
+
fetchUrl = url || '/order/sales/checkout';
|
|
907
|
+
return _context12.abrupt("return", this.request.post(fetchUrl, query, {
|
|
908
|
+
customToast: function customToast() {}
|
|
909
|
+
}));
|
|
910
|
+
case 3:
|
|
911
|
+
case "end":
|
|
912
|
+
return _context12.stop();
|
|
913
|
+
}
|
|
914
|
+
}, _callee12, this);
|
|
915
|
+
}));
|
|
916
|
+
function submitScanOrder(_x12) {
|
|
917
|
+
return _submitScanOrder.apply(this, arguments);
|
|
918
|
+
}
|
|
919
|
+
return submitScanOrder;
|
|
920
|
+
}()
|
|
921
|
+
}, {
|
|
922
|
+
key: "scanOrderMore",
|
|
923
|
+
value: function () {
|
|
924
|
+
var _scanOrderMore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(params) {
|
|
925
|
+
var url, query, fetchUrl, requestBody;
|
|
926
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
927
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
928
|
+
case 0:
|
|
929
|
+
url = params.url, query = params.query;
|
|
930
|
+
fetchUrl = url || "/order/order/product/".concat(query.order_id);
|
|
931
|
+
requestBody = {
|
|
932
|
+
products: query.products,
|
|
933
|
+
request_unique_idempotency_token: query.request_unique_idempotency_token
|
|
934
|
+
};
|
|
935
|
+
return _context13.abrupt("return", this.request.put(fetchUrl, requestBody, {
|
|
936
|
+
customToast: function customToast() {}
|
|
937
|
+
}));
|
|
938
|
+
case 4:
|
|
939
|
+
case "end":
|
|
940
|
+
return _context13.stop();
|
|
941
|
+
}
|
|
942
|
+
}, _callee13, this);
|
|
943
|
+
}));
|
|
944
|
+
function scanOrderMore(_x13) {
|
|
945
|
+
return _scanOrderMore.apply(this, arguments);
|
|
946
|
+
}
|
|
947
|
+
return scanOrderMore;
|
|
948
|
+
}() // TODO 获取详情的接口
|
|
949
|
+
}, {
|
|
950
|
+
key: "getOrderInfoByRemote",
|
|
951
|
+
value: function () {
|
|
952
|
+
var _getOrderInfoByRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(order_id) {
|
|
953
|
+
var res;
|
|
954
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
955
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
956
|
+
case 0:
|
|
957
|
+
_context14.next = 2;
|
|
958
|
+
return this.request.get("/order/sales/".concat(order_id), {
|
|
959
|
+
with: ['products', 'scheduleEvents']
|
|
960
|
+
});
|
|
961
|
+
case 2:
|
|
962
|
+
res = _context14.sent;
|
|
963
|
+
if (res.code === 200 && this.store.tempOrder) {
|
|
964
|
+
this.store.tempOrder.lastOrderInfo = res.data;
|
|
965
|
+
}
|
|
966
|
+
return _context14.abrupt("return", res);
|
|
967
|
+
case 5:
|
|
968
|
+
case "end":
|
|
969
|
+
return _context14.stop();
|
|
970
|
+
}
|
|
971
|
+
}, _callee14, this);
|
|
972
|
+
}));
|
|
973
|
+
function getOrderInfoByRemote(_x14) {
|
|
974
|
+
return _getOrderInfoByRemote.apply(this, arguments);
|
|
975
|
+
}
|
|
976
|
+
return getOrderInfoByRemote;
|
|
977
|
+
}()
|
|
978
|
+
}, {
|
|
979
|
+
key: "getLastOrderInfo",
|
|
980
|
+
value: function getLastOrderInfo() {
|
|
981
|
+
var _this$store;
|
|
982
|
+
return (_this$store = this.store) === null || _this$store === void 0 || (_this$store = _this$store.tempOrder) === null || _this$store === void 0 ? void 0 : _this$store.lastOrderInfo;
|
|
983
|
+
}
|
|
984
|
+
}], [{
|
|
985
|
+
key: "populateSavedAmounts",
|
|
986
|
+
value:
|
|
987
|
+
/**
|
|
988
|
+
* Populate `savedAmount` on each discount based on product-level discount details.
|
|
989
|
+
* Only selected discounts get a non-zero value.
|
|
990
|
+
*/
|
|
991
|
+
function populateSavedAmounts(productList, discountList) {
|
|
992
|
+
var savedMap = new Map();
|
|
993
|
+
var _iterator = _createForOfIteratorHelper(productList),
|
|
994
|
+
_step;
|
|
995
|
+
try {
|
|
996
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
997
|
+
var product = _step.value;
|
|
998
|
+
var qty = product.num || 1;
|
|
999
|
+
var _iterator3 = _createForOfIteratorHelper(product.discount_list || []),
|
|
1000
|
+
_step3;
|
|
1001
|
+
try {
|
|
1002
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
1003
|
+
var _pd$discount, _pd$metadata;
|
|
1004
|
+
var pd = _step3.value;
|
|
1005
|
+
var discountKey = ((_pd$discount = pd.discount) === null || _pd$discount === void 0 ? void 0 : _pd$discount.resource_id) || pd.id;
|
|
1006
|
+
if (discountKey == null) continue;
|
|
1007
|
+
var amount = new Decimal(pd.amount || 0).times(qty).plus(((_pd$metadata = pd.metadata) === null || _pd$metadata === void 0 ? void 0 : _pd$metadata.product_discount_difference) || 0);
|
|
1008
|
+
savedMap.set(discountKey, (savedMap.get(discountKey) || new Decimal(0)).plus(amount));
|
|
1009
|
+
}
|
|
1010
|
+
} catch (err) {
|
|
1011
|
+
_iterator3.e(err);
|
|
1012
|
+
} finally {
|
|
1013
|
+
_iterator3.f();
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
} catch (err) {
|
|
1017
|
+
_iterator.e(err);
|
|
1018
|
+
} finally {
|
|
1019
|
+
_iterator.f();
|
|
1020
|
+
}
|
|
1021
|
+
var _iterator2 = _createForOfIteratorHelper(discountList),
|
|
1022
|
+
_step2;
|
|
1023
|
+
try {
|
|
1024
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
1025
|
+
var d = _step2.value;
|
|
1026
|
+
var key = d.id;
|
|
1027
|
+
d.savedAmount = d.isSelected && key != null && savedMap.has(key) ? savedMap.get(key).toNumber() : 0;
|
|
1028
|
+
}
|
|
1029
|
+
} catch (err) {
|
|
1030
|
+
_iterator2.e(err);
|
|
1031
|
+
} finally {
|
|
1032
|
+
_iterator2.f();
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
161
1035
|
}]);
|
|
162
1036
|
return OrderModule;
|
|
163
1037
|
}(BaseModule);
|