@pisell/pisellos 2.1.170 → 2.1.172
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/index.d.ts +1 -1
- package/dist/index.js +1 -3
- package/dist/model/strategy/adapter/index.d.ts +0 -4
- package/dist/model/strategy/adapter/index.js +1 -5
- package/dist/model/strategy/adapter/promotion/evaluator.js +99 -26
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.js +61 -8
- package/dist/model/strategy/adapter/walletPass/locales.js +12 -3
- package/dist/model/strategy/engine.d.ts +18 -5
- package/dist/model/strategy/engine.js +145 -45
- package/dist/model/strategy/type.d.ts +17 -0
- package/dist/model/strategy/type.js +4 -0
- package/dist/modules/Cart/types.d.ts +2 -0
- package/dist/modules/Cart/utils/cartProduct.js +56 -25
- package/dist/modules/Cart/utils/changePrice.js +9 -16
- package/dist/modules/Discount/index.d.ts +4 -13
- package/dist/modules/Discount/index.js +12 -124
- package/dist/modules/Discount/types.d.ts +18 -13
- package/dist/modules/Order/index.d.ts +1 -67
- package/dist/modules/Order/index.js +30 -918
- package/dist/modules/Order/types.d.ts +12 -176
- package/dist/modules/Order/types.js +0 -2
- package/dist/modules/Order/utils.d.ts +0 -118
- package/dist/modules/Order/utils.js +2 -586
- package/dist/modules/Payment/index.d.ts +2 -1
- package/dist/modules/Payment/index.js +10 -7
- package/dist/modules/Payment/utils.js +3 -0
- package/dist/modules/Payment/walletpass.d.ts +23 -0
- package/dist/modules/Payment/walletpass.js +191 -95
- package/dist/modules/Product/utils.js +2 -2
- package/dist/modules/ProductList/index.d.ts +2 -4
- package/dist/modules/ProductList/index.js +12 -24
- package/dist/modules/Rules/index.d.ts +9 -5
- package/dist/modules/Rules/index.js +669 -173
- package/dist/modules/Rules/types.d.ts +2 -0
- package/dist/modules/Schedule/getDateIsInSchedule.js +18 -16
- package/dist/modules/Schedule/utils.d.ts +1 -1
- package/dist/modules/Summary/types.d.ts +2 -0
- package/dist/modules/Summary/utils.d.ts +9 -3
- package/dist/modules/Summary/utils.js +57 -67
- package/dist/modules/index.d.ts +0 -4
- package/dist/modules/index.js +1 -5
- package/dist/plugins/window.d.ts +2 -0
- package/dist/solution/BookingByStep/index.d.ts +3 -2
- package/dist/solution/BookingByStep/index.js +43 -46
- package/dist/solution/BookingByStep/types.d.ts +1 -3
- package/dist/solution/BookingByStep/types.js +1 -5
- package/dist/solution/BookingByStep/utils/timeslots.d.ts +1 -3
- package/dist/solution/BookingByStep/utils/timeslots.js +12 -19
- package/dist/solution/Checkout/index.js +2 -0
- package/dist/solution/ShopDiscount/index.d.ts +2 -3
- package/dist/solution/ShopDiscount/index.js +60 -62
- package/dist/solution/ShopDiscount/types.d.ts +1 -1
- package/dist/solution/ShopDiscount/types.js +2 -1
- package/dist/solution/ShopDiscount/utils.js +26 -12
- package/dist/solution/index.d.ts +0 -2
- package/dist/solution/index.js +1 -3
- package/lib/index.d.ts +1 -1
- package/lib/index.js +3 -4
- package/lib/model/strategy/adapter/index.d.ts +0 -4
- package/lib/model/strategy/adapter/index.js +2 -13
- package/lib/model/strategy/adapter/promotion/evaluator.js +57 -8
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.js +34 -3
- package/lib/model/strategy/adapter/walletPass/locales.js +12 -3
- package/lib/model/strategy/engine.d.ts +18 -5
- package/lib/model/strategy/engine.js +85 -21
- package/lib/model/strategy/type.d.ts +17 -0
- package/lib/modules/Cart/types.d.ts +2 -0
- package/lib/modules/Cart/utils/cartProduct.js +39 -12
- package/lib/modules/Cart/utils/changePrice.js +9 -13
- package/lib/modules/Discount/index.d.ts +4 -13
- package/lib/modules/Discount/index.js +5 -76
- package/lib/modules/Discount/types.d.ts +18 -13
- package/lib/modules/Order/index.d.ts +1 -67
- package/lib/modules/Order/index.js +1 -525
- package/lib/modules/Order/types.d.ts +12 -176
- package/lib/modules/Order/utils.d.ts +0 -118
- package/lib/modules/Order/utils.js +2 -483
- package/lib/modules/Payment/index.d.ts +2 -1
- package/lib/modules/Payment/index.js +1 -0
- package/lib/modules/Payment/utils.js +3 -0
- package/lib/modules/Payment/walletpass.d.ts +23 -0
- package/lib/modules/Payment/walletpass.js +94 -17
- package/lib/modules/Product/utils.js +2 -2
- package/lib/modules/ProductList/index.d.ts +2 -4
- package/lib/modules/ProductList/index.js +39 -46
- package/lib/modules/Rules/index.d.ts +9 -5
- package/lib/modules/Rules/index.js +776 -292
- package/lib/modules/Rules/types.d.ts +2 -0
- package/lib/modules/Schedule/getDateIsInSchedule.js +11 -13
- package/lib/modules/Schedule/utils.d.ts +1 -1
- package/lib/modules/Summary/types.d.ts +2 -0
- package/lib/modules/Summary/utils.d.ts +9 -3
- package/lib/modules/Summary/utils.js +34 -45
- package/lib/modules/index.d.ts +0 -4
- package/lib/modules/index.js +1 -9
- package/lib/plugins/window.d.ts +2 -0
- package/lib/solution/BookingByStep/index.d.ts +3 -2
- package/lib/solution/BookingByStep/index.js +4 -6
- package/lib/solution/BookingByStep/types.d.ts +1 -3
- package/lib/solution/BookingByStep/types.js +0 -10
- package/lib/solution/BookingByStep/utils/timeslots.d.ts +1 -3
- package/lib/solution/BookingByStep/utils/timeslots.js +11 -19
- package/lib/solution/Checkout/index.js +2 -0
- package/lib/solution/ShopDiscount/index.d.ts +2 -3
- package/lib/solution/ShopDiscount/index.js +27 -22
- package/lib/solution/ShopDiscount/types.d.ts +1 -1
- package/lib/solution/ShopDiscount/utils.js +10 -6
- package/lib/solution/index.d.ts +0 -2
- package/lib/solution/index.js +1 -5
- package/package.json +2 -2
- package/dist/apis/picoding.d.ts +0 -0
- package/dist/apis/picoding.js +0 -1
- package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
- package/dist/model/strategy/adapter/dataVariant/adapter.js +0 -167
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +0 -867
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
- package/dist/model/strategy/adapter/dataVariant/examples.js +0 -277
- package/dist/model/strategy/adapter/dataVariant/index.d.ts +0 -4
- package/dist/model/strategy/adapter/dataVariant/index.js +0 -4
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +0 -149
- package/dist/model/strategy/adapter/dataVariant/type.js +0 -54
- package/dist/modules/OpenData/index.d.ts +0 -24
- package/dist/modules/OpenData/index.js +0 -173
- package/dist/modules/OpenData/types.d.ts +0 -73
- package/dist/modules/OpenData/types.js +0 -1
- package/dist/modules/OpenData/utils.d.ts +0 -2
- package/dist/modules/OpenData/utils.js +0 -75
- package/dist/modules/Quotation/index.d.ts +0 -48
- package/dist/modules/Quotation/index.js +0 -248
- package/dist/modules/Quotation/types.d.ts +0 -42
- package/dist/modules/Quotation/types.js +0 -1
- package/dist/modules/SalesSummary/index.d.ts +0 -63
- package/dist/modules/SalesSummary/index.js +0 -174
- package/dist/modules/SalesSummary/types.d.ts +0 -60
- package/dist/modules/SalesSummary/types.js +0 -1
- package/dist/modules/SalesSummary/utils.d.ts +0 -30
- package/dist/modules/SalesSummary/utils.js +0 -480
- package/dist/modules/ScanOrderLogger/index.d.ts +0 -23
- package/dist/modules/ScanOrderLogger/index.js +0 -174
- package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +0 -2
- package/dist/modules/ScanOrderLogger/providers/feishu.js +0 -221
- package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +0 -2
- package/dist/modules/ScanOrderLogger/providers/grafana.js +0 -50
- package/dist/modules/ScanOrderLogger/types.d.ts +0 -53
- package/dist/modules/ScanOrderLogger/types.js +0 -1
- package/dist/solution/ScanOrder/index.d.ts +0 -158
- package/dist/solution/ScanOrder/index.js +0 -3474
- package/dist/solution/ScanOrder/types.d.ts +0 -306
- package/dist/solution/ScanOrder/types.js +0 -35
- package/dist/solution/ScanOrder/utils.d.ts +0 -172
- package/dist/solution/ScanOrder/utils.js +0 -796
- package/dist/solution/VenueBooking/index.d.ts +0 -252
- package/dist/solution/VenueBooking/index.js +0 -3769
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +0 -343
- package/dist/solution/VenueBooking/types.d.ts +0 -156
- package/dist/solution/VenueBooking/types.js +0 -22
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +0 -11
- package/dist/solution/VenueBooking/utils/dateSummary.js +0 -91
- package/dist/solution/VenueBooking/utils/resource.d.ts +0 -14
- package/dist/solution/VenueBooking/utils/resource.js +0 -131
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -32
- package/dist/solution/VenueBooking/utils/slotMerge.js +0 -233
- package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -71
- package/dist/solution/VenueBooking/utils/smartPricing.js +0 -302
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -34
- package/dist/solution/VenueBooking/utils/timeSlot.js +0 -458
- package/dist/solution/VenueBooking/utils.d.ts +0 -1
- package/dist/solution/VenueBooking/utils.js +0 -1
- package/lib/apis/picoding.d.ts +0 -0
- package/lib/apis/picoding.js +0 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
- package/lib/model/strategy/adapter/dataVariant/adapter.js +0 -149
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +0 -666
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
- package/lib/model/strategy/adapter/dataVariant/examples.js +0 -293
- package/lib/model/strategy/adapter/dataVariant/index.d.ts +0 -4
- package/lib/model/strategy/adapter/dataVariant/index.js +0 -38
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +0 -149
- package/lib/model/strategy/adapter/dataVariant/type.js +0 -31
- package/lib/modules/OpenData/index.d.ts +0 -24
- package/lib/modules/OpenData/index.js +0 -119
- package/lib/modules/OpenData/types.d.ts +0 -73
- package/lib/modules/OpenData/types.js +0 -17
- package/lib/modules/OpenData/utils.d.ts +0 -2
- package/lib/modules/OpenData/utils.js +0 -111
- package/lib/modules/Quotation/index.d.ts +0 -48
- package/lib/modules/Quotation/index.js +0 -152
- package/lib/modules/Quotation/types.d.ts +0 -42
- package/lib/modules/Quotation/types.js +0 -17
- package/lib/modules/SalesSummary/index.d.ts +0 -63
- package/lib/modules/SalesSummary/index.js +0 -105
- package/lib/modules/SalesSummary/types.d.ts +0 -60
- package/lib/modules/SalesSummary/types.js +0 -17
- package/lib/modules/SalesSummary/utils.d.ts +0 -30
- package/lib/modules/SalesSummary/utils.js +0 -420
- package/lib/modules/ScanOrderLogger/index.d.ts +0 -23
- package/lib/modules/ScanOrderLogger/index.js +0 -147
- package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +0 -2
- package/lib/modules/ScanOrderLogger/providers/feishu.js +0 -157
- package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +0 -2
- package/lib/modules/ScanOrderLogger/providers/grafana.js +0 -52
- package/lib/modules/ScanOrderLogger/types.d.ts +0 -53
- package/lib/modules/ScanOrderLogger/types.js +0 -17
- package/lib/solution/ScanOrder/index.d.ts +0 -158
- package/lib/solution/ScanOrder/index.js +0 -2135
- package/lib/solution/ScanOrder/types.d.ts +0 -306
- package/lib/solution/ScanOrder/types.js +0 -36
- package/lib/solution/ScanOrder/utils.d.ts +0 -172
- package/lib/solution/ScanOrder/utils.js +0 -658
- package/lib/solution/VenueBooking/index.d.ts +0 -252
- package/lib/solution/VenueBooking/index.js +0 -2204
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -343
- package/lib/solution/VenueBooking/types.d.ts +0 -156
- package/lib/solution/VenueBooking/types.js +0 -45
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +0 -11
- package/lib/solution/VenueBooking/utils/dateSummary.js +0 -105
- package/lib/solution/VenueBooking/utils/resource.d.ts +0 -14
- package/lib/solution/VenueBooking/utils/resource.js +0 -92
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -32
- package/lib/solution/VenueBooking/utils/slotMerge.js +0 -236
- package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -71
- package/lib/solution/VenueBooking/utils/smartPricing.js +0 -225
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -34
- package/lib/solution/VenueBooking/utils/timeSlot.js +0 -343
- package/lib/solution/VenueBooking/utils.d.ts +0 -1
- package/lib/solution/VenueBooking/utils.js +0 -69
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
function
|
|
1
|
+
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); }
|
|
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); }
|
|
9
8
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
9
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
10
|
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; }
|
|
@@ -25,17 +24,14 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
25
24
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
26
25
|
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); }
|
|
27
26
|
import { BaseModule } from "../BaseModule";
|
|
28
|
-
import { generateDuration, getAllDiscountList, mergeRelationForms
|
|
27
|
+
import { generateDuration, getAllDiscountList, mergeRelationForms } from "./utils";
|
|
29
28
|
import { isNormalProduct } from "../Product/utils";
|
|
30
29
|
import dayjs from 'dayjs';
|
|
31
|
-
import { buildProductLineFingerprint, getProductIdentityIndex, getSafeProductNum, isIdentityMatch, normalizeOrderProduct } from "../../solution/ScanOrder/utils";
|
|
32
|
-
import { DiscountModule } from "../Discount";
|
|
33
|
-
import { RulesModule } from "../Rules";
|
|
34
|
-
import { UnavailableReason } from "../Rules/types";
|
|
35
|
-
import Decimal from 'decimal.js';
|
|
36
30
|
export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
37
31
|
_inherits(OrderModule, _BaseModule);
|
|
38
32
|
var _super = _createSuper(OrderModule);
|
|
33
|
+
// LoggerManager 实例
|
|
34
|
+
|
|
39
35
|
function OrderModule(name, version) {
|
|
40
36
|
var _this;
|
|
41
37
|
_classCallCheck(this, OrderModule);
|
|
@@ -45,49 +41,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
45
41
|
_defineProperty(_assertThisInitialized(_this), "store", void 0);
|
|
46
42
|
_defineProperty(_assertThisInitialized(_this), "request", void 0);
|
|
47
43
|
_defineProperty(_assertThisInitialized(_this), "logger", void 0);
|
|
48
|
-
// LoggerManager 实例
|
|
49
|
-
_defineProperty(_assertThisInitialized(_this), "window", void 0);
|
|
50
|
-
_defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
|
|
51
|
-
_defineProperty(_assertThisInitialized(_this), "salesSummaryModuleName", void 0);
|
|
52
|
-
_defineProperty(_assertThisInitialized(_this), "rulesHooksOverride", void 0);
|
|
53
44
|
return _this;
|
|
54
45
|
}
|
|
55
46
|
_createClass(OrderModule, [{
|
|
56
47
|
key: "initialize",
|
|
57
48
|
value: function () {
|
|
58
49
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
|
|
59
|
-
var
|
|
60
|
-
var otherParams, appPlugin, app;
|
|
50
|
+
var appPlugin, app;
|
|
61
51
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
62
52
|
while (1) switch (_context.prev = _context.next) {
|
|
63
53
|
case 0:
|
|
64
54
|
this.core = core;
|
|
65
55
|
this.store = options.store;
|
|
66
|
-
if (!this.store.tempOrder) {
|
|
67
|
-
this.store.tempOrder = null;
|
|
68
|
-
}
|
|
69
|
-
if (!Array.isArray(this.store.availableWalletIds)) {
|
|
70
|
-
this.store.availableWalletIds = [];
|
|
71
|
-
}
|
|
72
56
|
this.request = this.core.getPlugin('request');
|
|
73
|
-
this.window = this.core.getPlugin('window');
|
|
74
|
-
otherParams = options.otherParams || {};
|
|
75
|
-
this.cacheId = otherParams.cacheId;
|
|
76
|
-
this.salesSummaryModuleName = otherParams.salesSummaryModuleName;
|
|
77
|
-
this.rulesHooksOverride = (_otherParams$rules = otherParams.rules) === null || _otherParams$rules === void 0 ? void 0 : _otherParams$rules.hooks;
|
|
78
|
-
this.registerDiscountModules(options);
|
|
79
|
-
this.restoreTempOrderFromStorage();
|
|
80
57
|
appPlugin = this.core.getPlugin('app');
|
|
81
58
|
if (appPlugin) {
|
|
82
|
-
_context.next =
|
|
59
|
+
_context.next = 6;
|
|
83
60
|
break;
|
|
84
61
|
}
|
|
85
62
|
throw new Error('Order 模块需要 app 插件支持');
|
|
86
|
-
case
|
|
63
|
+
case 6:
|
|
87
64
|
app = appPlugin.getApp();
|
|
88
65
|
this.logger = app.logger;
|
|
89
66
|
this.logInfo('OrderModule initialized successfully');
|
|
90
|
-
case
|
|
67
|
+
case 9:
|
|
91
68
|
case "end":
|
|
92
69
|
return _context.stop();
|
|
93
70
|
}
|
|
@@ -142,733 +119,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
142
119
|
});
|
|
143
120
|
}
|
|
144
121
|
}
|
|
145
|
-
|
|
146
|
-
// ─── Discount: 子模块注册 ───
|
|
147
|
-
}, {
|
|
148
|
-
key: "registerDiscountModules",
|
|
149
|
-
value: function registerDiscountModules(options) {
|
|
150
|
-
var _targetCacheData;
|
|
151
|
-
var targetCacheData = {};
|
|
152
|
-
if (this.cacheId && this.window) {
|
|
153
|
-
var sessionData = this.window.sessionStorage.getItem(this.name);
|
|
154
|
-
if (sessionData) {
|
|
155
|
-
try {
|
|
156
|
-
var data = JSON.parse(sessionData);
|
|
157
|
-
targetCacheData = (data === null || data === void 0 ? void 0 : data[this.cacheId]) || {};
|
|
158
|
-
} catch (_unused) {
|
|
159
|
-
// sessionStorage 损坏则忽略,按空 initialState 走
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
var discount = new DiscountModule("".concat(this.name, "_discount"));
|
|
164
|
-
this.core.registerModule(discount, {
|
|
165
|
-
initialState: (_targetCacheData = targetCacheData) === null || _targetCacheData === void 0 ? void 0 : _targetCacheData[discount.name],
|
|
166
|
-
otherParams: {
|
|
167
|
-
fatherModule: this.name,
|
|
168
|
-
openCache: !!this.cacheId,
|
|
169
|
-
cacheId: this.cacheId
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
this.store.discount = discount;
|
|
173
|
-
var rules = new RulesModule("".concat(this.name, "_rules"));
|
|
174
|
-
this.core.registerModule(rules, {
|
|
175
|
-
hooks: this.rulesHooksOverride || this.createDefaultRulesHooks()
|
|
176
|
-
});
|
|
177
|
-
this.store.rules = rules;
|
|
178
|
-
}
|
|
179
|
-
}, {
|
|
180
|
-
key: "createDefaultRulesHooks",
|
|
181
|
-
value: function createDefaultRulesHooks() {
|
|
182
|
-
return createDefaultOrderRulesHooks();
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// ─── Discount: 公共 API ───
|
|
186
|
-
}, {
|
|
187
|
-
key: "loadDiscountConfig",
|
|
188
|
-
value: function () {
|
|
189
|
-
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
|
|
190
|
-
var _this$store$discount, _this$store$tempOrder;
|
|
191
|
-
var prepareConfig, discountList, _this$store$discount2;
|
|
192
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
193
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
194
|
-
case 0:
|
|
195
|
-
_context2.next = 2;
|
|
196
|
-
return (_this$store$discount = this.store.discount) === null || _this$store$discount === void 0 ? void 0 : _this$store$discount.loadPrepareConfig({
|
|
197
|
-
customer_id: params.customerId,
|
|
198
|
-
action: params.action || 'create',
|
|
199
|
-
with_good_pass: 1,
|
|
200
|
-
with_discount_card: 1,
|
|
201
|
-
with_wallet_pass_holder: 1,
|
|
202
|
-
with_available_wallet_flag: 1,
|
|
203
|
-
with_available_wallet_pass_flag: 1,
|
|
204
|
-
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
205
|
-
});
|
|
206
|
-
case 2:
|
|
207
|
-
prepareConfig = _context2.sent;
|
|
208
|
-
discountList = prepareConfig === null || prepareConfig === void 0 ? void 0 : prepareConfig.discountList;
|
|
209
|
-
this.store.availableWalletIds = (prepareConfig === null || prepareConfig === void 0 ? void 0 : prepareConfig.availableWalletIds) || [];
|
|
210
|
-
if (discountList) {
|
|
211
|
-
(_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 || _this$store$discount2.setDiscountList(discountList);
|
|
212
|
-
}
|
|
213
|
-
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) {
|
|
214
|
-
this.applyDiscount();
|
|
215
|
-
}
|
|
216
|
-
case 7:
|
|
217
|
-
case "end":
|
|
218
|
-
return _context2.stop();
|
|
219
|
-
}
|
|
220
|
-
}, _callee2, this);
|
|
221
|
-
}));
|
|
222
|
-
function loadDiscountConfig(_x3) {
|
|
223
|
-
return _loadDiscountConfig.apply(this, arguments);
|
|
224
|
-
}
|
|
225
|
-
return loadDiscountConfig;
|
|
226
|
-
}()
|
|
227
|
-
}, {
|
|
228
|
-
key: "getDiscountList",
|
|
229
|
-
value: function getDiscountList() {
|
|
230
|
-
var _this$store$discount3;
|
|
231
|
-
return ((_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.getDiscountList()) || [];
|
|
232
|
-
}
|
|
233
|
-
}, {
|
|
234
|
-
key: "getAvailableWalletIds",
|
|
235
|
-
value: function getAvailableWalletIds() {
|
|
236
|
-
return this.store.availableWalletIds || [];
|
|
237
|
-
}
|
|
238
|
-
}, {
|
|
239
|
-
key: "scanCode",
|
|
240
|
-
value: function () {
|
|
241
|
-
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(code, customerId) {
|
|
242
|
-
var _this$store$discount4, _tempOrder$holder, _tempOrder$holder2;
|
|
243
|
-
var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref, isAvailable, newDiscountList, unavailableReason, _this$store$discount5;
|
|
244
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
245
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
246
|
-
case 0:
|
|
247
|
-
_context3.next = 2;
|
|
248
|
-
return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.batchSearch(code, {
|
|
249
|
-
customerId: customerId
|
|
250
|
-
});
|
|
251
|
-
case 2:
|
|
252
|
-
_context3.t0 = _context3.sent;
|
|
253
|
-
if (_context3.t0) {
|
|
254
|
-
_context3.next = 5;
|
|
255
|
-
break;
|
|
256
|
-
}
|
|
257
|
-
_context3.t0 = {
|
|
258
|
-
discountList: [],
|
|
259
|
-
unavailableReasonKey: null
|
|
260
|
-
};
|
|
261
|
-
case 5:
|
|
262
|
-
resultDiscountWithReason = _context3.t0;
|
|
263
|
-
resultDiscountList = resultDiscountWithReason.discountList, unavailableReasonKey = resultDiscountWithReason.unavailableReasonKey;
|
|
264
|
-
rulesModule = this.store.rules;
|
|
265
|
-
if (rulesModule) {
|
|
266
|
-
_context3.next = 10;
|
|
267
|
-
break;
|
|
268
|
-
}
|
|
269
|
-
return _context3.abrupt("return", {
|
|
270
|
-
type: 'clientCalc',
|
|
271
|
-
isAvailable: false,
|
|
272
|
-
discountList: this.getDiscountList(),
|
|
273
|
-
unavailableReason: UnavailableReason.Unknown
|
|
274
|
-
});
|
|
275
|
-
case 10:
|
|
276
|
-
if (resultDiscountList.length) {
|
|
277
|
-
_context3.next = 12;
|
|
278
|
-
break;
|
|
279
|
-
}
|
|
280
|
-
return _context3.abrupt("return", {
|
|
281
|
-
type: 'server',
|
|
282
|
-
isAvailable: false,
|
|
283
|
-
discountList: this.getDiscountList(),
|
|
284
|
-
unavailableReasonKey: unavailableReasonKey
|
|
285
|
-
});
|
|
286
|
-
case 12:
|
|
287
|
-
withScanList = resultDiscountList.map(function (item) {
|
|
288
|
-
return _objectSpread(_objectSpread({}, item), {}, {
|
|
289
|
-
isScan: true
|
|
290
|
-
});
|
|
291
|
-
});
|
|
292
|
-
currentSelected = this.getDiscountList().filter(function (n) {
|
|
293
|
-
return n.isSelected;
|
|
294
|
-
});
|
|
295
|
-
if (!(currentSelected.length && currentSelected.some(function (n) {
|
|
296
|
-
return withScanList.some(function (m) {
|
|
297
|
-
return m.id === n.id;
|
|
298
|
-
});
|
|
299
|
-
}))) {
|
|
300
|
-
_context3.next = 16;
|
|
301
|
-
break;
|
|
302
|
-
}
|
|
303
|
-
return _context3.abrupt("return", {
|
|
304
|
-
type: 'clientCalc',
|
|
305
|
-
isAvailable: true,
|
|
306
|
-
discountList: this.getDiscountList()
|
|
307
|
-
});
|
|
308
|
-
case 16:
|
|
309
|
-
tempOrder = this.store.tempOrder;
|
|
310
|
-
holders = tempOrder !== null && tempOrder !== void 0 && (_tempOrder$holder = tempOrder.holder) !== null && _tempOrder$holder !== void 0 && _tempOrder$holder.form_record_id ? [{
|
|
311
|
-
form_record_id: tempOrder.holder.form_record_id
|
|
312
|
-
}] : [];
|
|
313
|
-
_ref = rulesModule.isDiscountListAvailable({
|
|
314
|
-
productList: (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || [],
|
|
315
|
-
oldDiscountList: this.getDiscountList(),
|
|
316
|
-
newDiscountList: withScanList,
|
|
317
|
-
holders: holders,
|
|
318
|
-
isFormSubject: !!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$holder2 = tempOrder.holder) !== null && _tempOrder$holder2 !== void 0 && _tempOrder$holder2.type) && tempOrder.holder.type === 'form'
|
|
319
|
-
}) || {
|
|
320
|
-
isAvailable: false,
|
|
321
|
-
discountList: this.getDiscountList()
|
|
322
|
-
}, isAvailable = _ref.isAvailable, newDiscountList = _ref.discountList, unavailableReason = _ref.unavailableReason;
|
|
323
|
-
if (isAvailable && newDiscountList) {
|
|
324
|
-
(_this$store$discount5 = this.store.discount) === null || _this$store$discount5 === void 0 || _this$store$discount5.setDiscountList(newDiscountList);
|
|
325
|
-
this.applyDiscount();
|
|
326
|
-
}
|
|
327
|
-
return _context3.abrupt("return", {
|
|
328
|
-
type: 'clientCalc',
|
|
329
|
-
isAvailable: isAvailable || false,
|
|
330
|
-
discountList: newDiscountList || this.getDiscountList(),
|
|
331
|
-
unavailableReason: unavailableReason
|
|
332
|
-
});
|
|
333
|
-
case 21:
|
|
334
|
-
case "end":
|
|
335
|
-
return _context3.stop();
|
|
336
|
-
}
|
|
337
|
-
}, _callee3, this);
|
|
338
|
-
}));
|
|
339
|
-
function scanCode(_x4, _x5) {
|
|
340
|
-
return _scanCode.apply(this, arguments);
|
|
341
|
-
}
|
|
342
|
-
return scanCode;
|
|
343
|
-
}()
|
|
344
|
-
}, {
|
|
345
|
-
key: "applyDiscount",
|
|
346
|
-
value: function applyDiscount() {
|
|
347
|
-
var _this$store$discount6, _tempOrder$holder3, _tempOrder$holder4;
|
|
348
|
-
var tempOrder = this.store.tempOrder;
|
|
349
|
-
// 任意 products CRUD 后都应当重算 discount 状态;即使 products 为空,
|
|
350
|
-
// 也需要让 Rules.calcDiscount 把 DiscountModule 的 isSelected / isAvailable /
|
|
351
|
-
// appliedProductDetails / savedAmount 以及 tempOrder.discount_list 复位。
|
|
352
|
-
if (!tempOrder) return;
|
|
353
|
-
var rulesModule = this.store.rules;
|
|
354
|
-
if (!rulesModule) return;
|
|
355
|
-
var discountList = ((_this$store$discount6 = this.store.discount) === null || _this$store$discount6 === void 0 ? void 0 : _this$store$discount6.getDiscountList()) || [];
|
|
356
|
-
var holders = (_tempOrder$holder3 = tempOrder.holder) !== null && _tempOrder$holder3 !== void 0 && _tempOrder$holder3.form_record_id ? [{
|
|
357
|
-
form_record_id: tempOrder.holder.form_record_id
|
|
358
|
-
}] : [];
|
|
359
|
-
var result = rulesModule.calcDiscount({
|
|
360
|
-
productList: tempOrder.products,
|
|
361
|
-
discountList: discountList,
|
|
362
|
-
holders: holders,
|
|
363
|
-
isFormSubject: !!((_tempOrder$holder4 = tempOrder.holder) !== null && _tempOrder$holder4 !== void 0 && _tempOrder$holder4.type) && tempOrder.holder.type === 'form'
|
|
364
|
-
});
|
|
365
|
-
if (result !== null && result !== void 0 && result.productList) {
|
|
366
|
-
tempOrder.products = result.productList;
|
|
367
|
-
}
|
|
368
|
-
if (result !== null && result !== void 0 && result.discountList) {
|
|
369
|
-
var _this$store$discount7;
|
|
370
|
-
OrderModule.populateSavedAmounts(result.productList || tempOrder.products, result.discountList);
|
|
371
|
-
(_this$store$discount7 = this.store.discount) === null || _this$store$discount7 === void 0 || _this$store$discount7.setDiscountList(result.discountList);
|
|
372
|
-
tempOrder.discount_list = result.discountList.filter(function (d) {
|
|
373
|
-
return d.isSelected;
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
// ─── TempOrder: 初始化入口 ───
|
|
379
|
-
}, {
|
|
380
|
-
key: "initTempOrder",
|
|
381
|
-
value: function initTempOrder(params) {
|
|
382
|
-
if (params.cacheId !== undefined) this.cacheId = params.cacheId;
|
|
383
|
-
if (params.salesSummaryModuleName !== undefined) this.salesSummaryModuleName = params.salesSummaryModuleName;
|
|
384
|
-
this.restoreTempOrderFromStorage();
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
// ─── TempOrder: localStorage 持久化 ───
|
|
388
|
-
}, {
|
|
389
|
-
key: "getTempOrderStorageKey",
|
|
390
|
-
value: function getTempOrderStorageKey() {
|
|
391
|
-
if (!this.cacheId) return null;
|
|
392
|
-
return "scanOrder:tempOrder:".concat(this.cacheId);
|
|
393
|
-
}
|
|
394
|
-
}, {
|
|
395
|
-
key: "restoreTempOrderFromStorage",
|
|
396
|
-
value: function restoreTempOrderFromStorage() {
|
|
397
|
-
var key = this.getTempOrderStorageKey();
|
|
398
|
-
if (!key) return;
|
|
399
|
-
if (!this.window) return;
|
|
400
|
-
var cachedData = this.window.localStorage.getItem(key);
|
|
401
|
-
if (!cachedData) return;
|
|
402
|
-
try {
|
|
403
|
-
var parsedData = JSON.parse(cachedData);
|
|
404
|
-
if (!isTempOrder(parsedData)) {
|
|
405
|
-
this.window.localStorage.removeItem(key);
|
|
406
|
-
return;
|
|
407
|
-
}
|
|
408
|
-
if (Array.isArray(parsedData.products)) {
|
|
409
|
-
for (var i = 0; i < parsedData.products.length; i++) {
|
|
410
|
-
var p = parsedData.products[i];
|
|
411
|
-
if (!p || _typeof(p) !== 'object') continue;
|
|
412
|
-
if (!Array.isArray(p.product_option_item)) {
|
|
413
|
-
p.product_option_item = [];
|
|
414
|
-
}
|
|
415
|
-
if (!Array.isArray(p.product_bundle)) {
|
|
416
|
-
p.product_bundle = [];
|
|
417
|
-
}
|
|
418
|
-
// 不透明 identity 契约:旧缓存里可能没有 identity_key,
|
|
419
|
-
// 此处统一回填 UUID 并同步 metadata.unique_identification_number,
|
|
420
|
-
// 避免升级后 UI 侧持有的 rowKey 找不到对应行。
|
|
421
|
-
var row = p;
|
|
422
|
-
if (typeof row.identity_key !== 'string' || row.identity_key.length === 0) {
|
|
423
|
-
var newKey = createUuidV4();
|
|
424
|
-
row.identity_key = newKey;
|
|
425
|
-
if (!row.metadata || _typeof(row.metadata) !== 'object') {
|
|
426
|
-
row.metadata = {};
|
|
427
|
-
}
|
|
428
|
-
if (!row.metadata.unique_identification_number) {
|
|
429
|
-
row.metadata.unique_identification_number = newKey;
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
// 价格 schema 迁移:重跑 normalizeOrderProduct。
|
|
433
|
-
// `metadata.price_schema_version === 2` → 已是新语义,保留现有 main_product_* 折扣;
|
|
434
|
-
// 否则(v1 或无 metadata)→ 走 legacyDiscount 反推分支,基于新的 source + options
|
|
435
|
-
// 重算出含 option 的 main_product_*,并打上 price_schema_version: 2。
|
|
436
|
-
// 幂等:多次 restore 不会重复叠加 option/bundle。
|
|
437
|
-
parsedData.products[i] = normalizeOrderProduct(row);
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
this.store.tempOrder = parsedData;
|
|
441
|
-
} catch (_unused2) {
|
|
442
|
-
var _this$window;
|
|
443
|
-
(_this$window = this.window) === null || _this$window === void 0 || (_this$window = _this$window.localStorage) === null || _this$window === void 0 || _this$window.removeItem(key);
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
}, {
|
|
447
|
-
key: "persistTempOrder",
|
|
448
|
-
value: function persistTempOrder() {
|
|
449
|
-
var key = this.getTempOrderStorageKey();
|
|
450
|
-
if (!key || !this.store.tempOrder) return;
|
|
451
|
-
if (!this.window) return;
|
|
452
|
-
this.window.localStorage.setItem(key, JSON.stringify(this.store.tempOrder));
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
// ─── TempOrder: 创建 & 获取 ───
|
|
456
|
-
}, {
|
|
457
|
-
key: "createDefaultTempOrderInstance",
|
|
458
|
-
value: function createDefaultTempOrderInstance() {
|
|
459
|
-
return createDefaultTempOrder({
|
|
460
|
-
now: formatDateTime(new Date()),
|
|
461
|
-
summary: createEmptySummary()
|
|
462
|
-
});
|
|
463
|
-
}
|
|
464
|
-
}, {
|
|
465
|
-
key: "ensureTempOrder",
|
|
466
|
-
value: function ensureTempOrder() {
|
|
467
|
-
if (this.store.tempOrder) return this.store.tempOrder;
|
|
468
|
-
var newOrder = this.createDefaultTempOrderInstance();
|
|
469
|
-
this.store.tempOrder = newOrder;
|
|
470
|
-
this.persistTempOrder();
|
|
471
|
-
return newOrder;
|
|
472
|
-
}
|
|
473
|
-
}, {
|
|
474
|
-
key: "restoreOrder",
|
|
475
|
-
value: function restoreOrder() {
|
|
476
|
-
var freshTempOrder = this.createDefaultTempOrderInstance();
|
|
477
|
-
this.store.tempOrder = freshTempOrder;
|
|
478
|
-
this.persistTempOrder();
|
|
479
|
-
return freshTempOrder;
|
|
480
|
-
}
|
|
481
|
-
}, {
|
|
482
|
-
key: "getTempOrder",
|
|
483
|
-
value: function getTempOrder() {
|
|
484
|
-
return this.store.tempOrder;
|
|
485
|
-
}
|
|
486
|
-
}, {
|
|
487
|
-
key: "addNewOrder",
|
|
488
|
-
value: function () {
|
|
489
|
-
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
490
|
-
var tempOrder;
|
|
491
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
492
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
493
|
-
case 0:
|
|
494
|
-
tempOrder = this.ensureTempOrder();
|
|
495
|
-
_context4.next = 3;
|
|
496
|
-
return this.recalculateSummary({
|
|
497
|
-
createIfMissing: true
|
|
498
|
-
});
|
|
499
|
-
case 3:
|
|
500
|
-
this.persistTempOrder();
|
|
501
|
-
return _context4.abrupt("return", tempOrder);
|
|
502
|
-
case 5:
|
|
503
|
-
case "end":
|
|
504
|
-
return _context4.stop();
|
|
505
|
-
}
|
|
506
|
-
}, _callee4, this);
|
|
507
|
-
}));
|
|
508
|
-
function addNewOrder() {
|
|
509
|
-
return _addNewOrder.apply(this, arguments);
|
|
510
|
-
}
|
|
511
|
-
return addNewOrder;
|
|
512
|
-
}()
|
|
513
|
-
}, {
|
|
514
|
-
key: "getOrderProducts",
|
|
515
|
-
value: function getOrderProducts() {
|
|
516
|
-
var tempOrder = this.ensureTempOrder();
|
|
517
|
-
return tempOrder.products;
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
// ─── TempOrder: 金额汇总 ───
|
|
521
|
-
}, {
|
|
522
|
-
key: "getSalesSummary",
|
|
523
|
-
value: function getSalesSummary() {
|
|
524
|
-
if (!this.salesSummaryModuleName) return null;
|
|
525
|
-
return this.core.getModule(this.salesSummaryModuleName);
|
|
526
|
-
}
|
|
527
|
-
}, {
|
|
528
|
-
key: "recalculateSummary",
|
|
529
|
-
value: function () {
|
|
530
|
-
var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(options) {
|
|
531
|
-
var tempOrder, salesSummary, summary;
|
|
532
|
-
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
533
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
534
|
-
case 0:
|
|
535
|
-
tempOrder = options !== null && options !== void 0 && options.createIfMissing ? this.ensureTempOrder() : this.store.tempOrder;
|
|
536
|
-
if (tempOrder) {
|
|
537
|
-
_context5.next = 3;
|
|
538
|
-
break;
|
|
539
|
-
}
|
|
540
|
-
return _context5.abrupt("return", null);
|
|
541
|
-
case 3:
|
|
542
|
-
salesSummary = this.getSalesSummary();
|
|
543
|
-
if (salesSummary) {
|
|
544
|
-
_context5.next = 8;
|
|
545
|
-
break;
|
|
546
|
-
}
|
|
547
|
-
tempOrder.summary = createEmptySummary();
|
|
548
|
-
tempOrder.surcharge_fee = tempOrder.summary.surcharge_fee;
|
|
549
|
-
return _context5.abrupt("return", tempOrder.summary);
|
|
550
|
-
case 8:
|
|
551
|
-
_context5.next = 10;
|
|
552
|
-
return salesSummary.getSummary({
|
|
553
|
-
products: tempOrder.products
|
|
554
|
-
});
|
|
555
|
-
case 10:
|
|
556
|
-
summary = _context5.sent;
|
|
557
|
-
tempOrder.summary = summary;
|
|
558
|
-
if (summary.is_price_include_tax !== undefined) {
|
|
559
|
-
tempOrder.is_price_include_tax = summary.is_price_include_tax;
|
|
560
|
-
}
|
|
561
|
-
if (typeof summary.tax_title === 'string') {
|
|
562
|
-
tempOrder.tax_title = summary.tax_title;
|
|
563
|
-
}
|
|
564
|
-
tempOrder.surcharge_fee = summary.surcharge_fee;
|
|
565
|
-
tempOrder.surcharges = summary.surcharges || [];
|
|
566
|
-
tempOrder.deposit_amount = summary.deposit_amount || '0.00';
|
|
567
|
-
tempOrder.is_deposit = summary.deposit_amount !== '0.00' ? 1 : 0;
|
|
568
|
-
tempOrder.shop_discount = summary.discount_amount || '0.00';
|
|
569
|
-
return _context5.abrupt("return", tempOrder.summary);
|
|
570
|
-
case 20:
|
|
571
|
-
case "end":
|
|
572
|
-
return _context5.stop();
|
|
573
|
-
}
|
|
574
|
-
}, _callee5, this);
|
|
575
|
-
}));
|
|
576
|
-
function recalculateSummary(_x6) {
|
|
577
|
-
return _recalculateSummary.apply(this, arguments);
|
|
578
|
-
}
|
|
579
|
-
return recalculateSummary;
|
|
580
|
-
}()
|
|
581
|
-
}, {
|
|
582
|
-
key: "getScanOrderSummary",
|
|
583
|
-
value: function () {
|
|
584
|
-
var _getScanOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
585
|
-
var summary;
|
|
586
|
-
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
587
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
588
|
-
case 0:
|
|
589
|
-
_context6.next = 2;
|
|
590
|
-
return this.recalculateSummary({
|
|
591
|
-
createIfMissing: true
|
|
592
|
-
});
|
|
593
|
-
case 2:
|
|
594
|
-
summary = _context6.sent;
|
|
595
|
-
if (summary) {
|
|
596
|
-
_context6.next = 5;
|
|
597
|
-
break;
|
|
598
|
-
}
|
|
599
|
-
return _context6.abrupt("return", createEmptySummary());
|
|
600
|
-
case 5:
|
|
601
|
-
this.persistTempOrder();
|
|
602
|
-
return _context6.abrupt("return", summary);
|
|
603
|
-
case 7:
|
|
604
|
-
case "end":
|
|
605
|
-
return _context6.stop();
|
|
606
|
-
}
|
|
607
|
-
}, _callee6, this);
|
|
608
|
-
}));
|
|
609
|
-
function getScanOrderSummary() {
|
|
610
|
-
return _getScanOrderSummary.apply(this, arguments);
|
|
611
|
-
}
|
|
612
|
-
return getScanOrderSummary;
|
|
613
|
-
}() // ─── TempOrder: 备注 ───
|
|
614
|
-
}, {
|
|
615
|
-
key: "updateTempOrderNote",
|
|
616
|
-
value: function updateTempOrderNote(note) {
|
|
617
|
-
var tempOrder = this.ensureTempOrder();
|
|
618
|
-
tempOrder.note = String(note || '');
|
|
619
|
-
this.persistTempOrder();
|
|
620
|
-
return tempOrder.note;
|
|
621
|
-
}
|
|
622
|
-
}, {
|
|
623
|
-
key: "updateTempOrderBuzzer",
|
|
624
|
-
value: function updateTempOrderBuzzer(buzzer) {
|
|
625
|
-
var tempOrder = this.ensureTempOrder();
|
|
626
|
-
tempOrder.buzzer = String(buzzer || '');
|
|
627
|
-
this.persistTempOrder();
|
|
628
|
-
return tempOrder.buzzer;
|
|
629
|
-
}
|
|
630
|
-
}, {
|
|
631
|
-
key: "updateTempOrderContactsInfo",
|
|
632
|
-
value: function updateTempOrderContactsInfo(contactsInfo) {
|
|
633
|
-
var tempOrder = this.ensureTempOrder();
|
|
634
|
-
tempOrder.contacts_info = Array.isArray(contactsInfo) ? contactsInfo : [];
|
|
635
|
-
this.persistTempOrder();
|
|
636
|
-
return tempOrder.contacts_info;
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
// ─── TempOrder: 商品 CRUD ───
|
|
640
|
-
}, {
|
|
641
|
-
key: "addProductToOrder",
|
|
642
|
-
value: function () {
|
|
643
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(product) {
|
|
644
|
-
var tempOrder, hasExplicitIdentityKey, normalizedProduct, productIndex, targetProduct, incomingFingerprint, matchedIndex, _normalizedProduct, _targetProduct, _normalizedProduct2;
|
|
645
|
-
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
646
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
647
|
-
case 0:
|
|
648
|
-
tempOrder = this.ensureTempOrder();
|
|
649
|
-
hasExplicitIdentityKey = typeof product.identity_key === 'string' && product.identity_key.length > 0;
|
|
650
|
-
if (hasExplicitIdentityKey) {
|
|
651
|
-
// 调用方自持 identity_key(如 VenueBooking 外部生成)→ 走严格 identity 合并。
|
|
652
|
-
normalizedProduct = normalizeOrderProduct(product);
|
|
653
|
-
productIndex = getProductIdentityIndex(tempOrder.products, normalizedProduct);
|
|
654
|
-
if (productIndex === -1) {
|
|
655
|
-
tempOrder.products.push(normalizedProduct);
|
|
656
|
-
} else {
|
|
657
|
-
targetProduct = tempOrder.products[productIndex];
|
|
658
|
-
tempOrder.products[productIndex] = _objectSpread(_objectSpread(_objectSpread({}, targetProduct), normalizedProduct), {}, {
|
|
659
|
-
num: getSafeProductNum(targetProduct.num + normalizedProduct.num),
|
|
660
|
-
_origin: normalizedProduct._origin || targetProduct._origin
|
|
661
|
-
});
|
|
662
|
-
}
|
|
663
|
-
} else {
|
|
664
|
-
// 无 identity_key:按 SKU + 内容指纹(options + bundle)匹配既有行以累加数量;
|
|
665
|
-
// 命中时保留已有 identity_key,未命中才由 normalizeOrderProduct 自动生成 UUID。
|
|
666
|
-
incomingFingerprint = buildProductLineFingerprint(product.product_option_item, product.product_bundle);
|
|
667
|
-
matchedIndex = tempOrder.products.findIndex(function (item) {
|
|
668
|
-
if (item.product_id !== product.product_id) return false;
|
|
669
|
-
if (item.product_variant_id !== product.product_variant_id) return false;
|
|
670
|
-
var existedFingerprint = buildProductLineFingerprint(item.product_option_item, item.product_bundle);
|
|
671
|
-
return existedFingerprint === incomingFingerprint;
|
|
672
|
-
});
|
|
673
|
-
if (matchedIndex === -1) {
|
|
674
|
-
_normalizedProduct = normalizeOrderProduct(product);
|
|
675
|
-
tempOrder.products.push(_normalizedProduct);
|
|
676
|
-
} else {
|
|
677
|
-
_targetProduct = tempOrder.products[matchedIndex];
|
|
678
|
-
_normalizedProduct2 = normalizeOrderProduct(_objectSpread(_objectSpread({}, product), {}, {
|
|
679
|
-
identity_key: _targetProduct.identity_key
|
|
680
|
-
}));
|
|
681
|
-
tempOrder.products[matchedIndex] = _objectSpread(_objectSpread(_objectSpread({}, _targetProduct), _normalizedProduct2), {}, {
|
|
682
|
-
identity_key: _targetProduct.identity_key,
|
|
683
|
-
num: getSafeProductNum(_targetProduct.num + _normalizedProduct2.num),
|
|
684
|
-
_origin: _normalizedProduct2._origin || _targetProduct._origin
|
|
685
|
-
});
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
this.applyDiscount();
|
|
689
|
-
_context7.next = 6;
|
|
690
|
-
return this.recalculateSummary({
|
|
691
|
-
createIfMissing: true
|
|
692
|
-
});
|
|
693
|
-
case 6:
|
|
694
|
-
this.persistTempOrder();
|
|
695
|
-
return _context7.abrupt("return", tempOrder.products);
|
|
696
|
-
case 8:
|
|
697
|
-
case "end":
|
|
698
|
-
return _context7.stop();
|
|
699
|
-
}
|
|
700
|
-
}, _callee7, this);
|
|
701
|
-
}));
|
|
702
|
-
function addProductToOrder(_x7) {
|
|
703
|
-
return _addProductToOrder.apply(this, arguments);
|
|
704
|
-
}
|
|
705
|
-
return addProductToOrder;
|
|
706
|
-
}()
|
|
707
|
-
}, {
|
|
708
|
-
key: "updateProductInOrder",
|
|
709
|
-
value: function () {
|
|
710
|
-
var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params) {
|
|
711
|
-
var _metadata, _metadata2, _metadata3;
|
|
712
|
-
var product_id, product_variant_id, updates, identity_key, product_option_item, product_bundle, tempOrder, identityLookup, productIndex, targetProduct, nextProduct, callerUpdatesTopPrice, callerUpdatesMainMeta, existedMeta;
|
|
713
|
-
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
714
|
-
while (1) switch (_context8.prev = _context8.next) {
|
|
715
|
-
case 0:
|
|
716
|
-
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;
|
|
717
|
-
tempOrder = this.ensureTempOrder();
|
|
718
|
-
identityLookup = {
|
|
719
|
-
product_id: product_id,
|
|
720
|
-
product_variant_id: product_variant_id
|
|
721
|
-
};
|
|
722
|
-
if (identity_key !== undefined) identityLookup.identity_key = identity_key;
|
|
723
|
-
if (product_option_item !== undefined) identityLookup.product_option_item = product_option_item;
|
|
724
|
-
if (product_bundle !== undefined) identityLookup.product_bundle = product_bundle;
|
|
725
|
-
productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
|
|
726
|
-
if (!(productIndex === -1)) {
|
|
727
|
-
_context8.next = 9;
|
|
728
|
-
break;
|
|
729
|
-
}
|
|
730
|
-
throw new Error('[Order] 目标商品不存在,无法更新');
|
|
731
|
-
case 9:
|
|
732
|
-
targetProduct = tempOrder.products[productIndex];
|
|
733
|
-
nextProduct = _objectSpread(_objectSpread(_objectSpread({}, targetProduct), updates), {}, {
|
|
734
|
-
product_id: product_id,
|
|
735
|
-
product_variant_id: product_variant_id
|
|
736
|
-
});
|
|
737
|
-
nextProduct.num = getSafeProductNum(nextProduct.num);
|
|
738
|
-
// 兜底:caller 通过 updates 直接改了 selling_price / original_price 时,
|
|
739
|
-
// 视为 "重新给 source-level 主价"(caller 侧旧约定仍是 main-only 单价)。
|
|
740
|
-
// 清掉 metadata 里的 source_product_price / main_product_* / price_schema_version,
|
|
741
|
-
// 让 normalize 把顶层 selling_price 当作 source 来重算 main_original(=source+options) /
|
|
742
|
-
// main_selling / composite;否则旧 metadata 会反压顶层新值,触发口径不一致。
|
|
743
|
-
// 如果 caller 走推荐路径(updates.metadata.* 显式指定主价),保留 metadata 由 normalize 认它。
|
|
744
|
-
callerUpdatesTopPrice = Object.prototype.hasOwnProperty.call(updates || {}, 'selling_price') || Object.prototype.hasOwnProperty.call(updates || {}, 'original_price');
|
|
745
|
-
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;
|
|
746
|
-
if (callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
747
|
-
existedMeta = nextProduct.metadata || {};
|
|
748
|
-
nextProduct.metadata = _objectSpread({}, existedMeta);
|
|
749
|
-
delete nextProduct.metadata.source_product_price;
|
|
750
|
-
delete nextProduct.metadata.main_product_selling_price;
|
|
751
|
-
delete nextProduct.metadata.main_product_original_price;
|
|
752
|
-
delete nextProduct.metadata.price_schema_version;
|
|
753
|
-
}
|
|
754
|
-
// normalizeOrderProduct 幂等:v2 metadata 存在 → 保留 main_product_* 折扣重算 composite;
|
|
755
|
-
// 否则 → 把顶层 selling_price 视作 source,派生 main_product_* 并写 price_schema_version: 2。
|
|
756
|
-
tempOrder.products[productIndex] = normalizeOrderProduct(nextProduct);
|
|
757
|
-
this.applyDiscount();
|
|
758
|
-
_context8.next = 19;
|
|
759
|
-
return this.recalculateSummary({
|
|
760
|
-
createIfMissing: true
|
|
761
|
-
});
|
|
762
|
-
case 19:
|
|
763
|
-
this.persistTempOrder();
|
|
764
|
-
return _context8.abrupt("return", tempOrder.products);
|
|
765
|
-
case 21:
|
|
766
|
-
case "end":
|
|
767
|
-
return _context8.stop();
|
|
768
|
-
}
|
|
769
|
-
}, _callee8, this);
|
|
770
|
-
}));
|
|
771
|
-
function updateProductInOrder(_x8) {
|
|
772
|
-
return _updateProductInOrder.apply(this, arguments);
|
|
773
|
-
}
|
|
774
|
-
return updateProductInOrder;
|
|
775
|
-
}()
|
|
776
|
-
}, {
|
|
777
|
-
key: "removeProductFromOrder",
|
|
778
|
-
value: function () {
|
|
779
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(identity) {
|
|
780
|
-
var tempOrder;
|
|
781
|
-
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
782
|
-
while (1) switch (_context9.prev = _context9.next) {
|
|
783
|
-
case 0:
|
|
784
|
-
tempOrder = this.ensureTempOrder();
|
|
785
|
-
tempOrder.products = tempOrder.products.filter(function (item) {
|
|
786
|
-
return !isIdentityMatch(item, identity);
|
|
787
|
-
});
|
|
788
|
-
this.applyDiscount();
|
|
789
|
-
_context9.next = 5;
|
|
790
|
-
return this.recalculateSummary({
|
|
791
|
-
createIfMissing: true
|
|
792
|
-
});
|
|
793
|
-
case 5:
|
|
794
|
-
this.persistTempOrder();
|
|
795
|
-
return _context9.abrupt("return", tempOrder.products);
|
|
796
|
-
case 7:
|
|
797
|
-
case "end":
|
|
798
|
-
return _context9.stop();
|
|
799
|
-
}
|
|
800
|
-
}, _callee9, this);
|
|
801
|
-
}));
|
|
802
|
-
function removeProductFromOrder(_x9) {
|
|
803
|
-
return _removeProductFromOrder.apply(this, arguments);
|
|
804
|
-
}
|
|
805
|
-
return removeProductFromOrder;
|
|
806
|
-
}() // ─── TempOrder: 提交 ───
|
|
807
|
-
}, {
|
|
808
|
-
key: "submitTempOrder",
|
|
809
|
-
value: function () {
|
|
810
|
-
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
|
|
811
|
-
var _params$cacheId;
|
|
812
|
-
var tempOrder, effectiveCacheId, payload, result, products, moreResult;
|
|
813
|
-
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
814
|
-
while (1) switch (_context10.prev = _context10.next) {
|
|
815
|
-
case 0:
|
|
816
|
-
tempOrder = this.ensureTempOrder();
|
|
817
|
-
this.persistTempOrder();
|
|
818
|
-
effectiveCacheId = (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId;
|
|
819
|
-
payload = buildSubmitPayload({
|
|
820
|
-
tempOrder: tempOrder,
|
|
821
|
-
cacheId: effectiveCacheId,
|
|
822
|
-
platform: params === null || params === void 0 ? void 0 : params.platform,
|
|
823
|
-
businessCode: params === null || params === void 0 ? void 0 : params.businessCode,
|
|
824
|
-
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
825
|
-
type: params === null || params === void 0 ? void 0 : params.type,
|
|
826
|
-
enhance: params === null || params === void 0 ? void 0 : params.enhancePayload
|
|
827
|
-
});
|
|
828
|
-
if (!tempOrder.order_id) {
|
|
829
|
-
_context10.next = 12;
|
|
830
|
-
break;
|
|
831
|
-
}
|
|
832
|
-
products = filterProductsForScanOrderMore(payload.products);
|
|
833
|
-
_context10.next = 8;
|
|
834
|
-
return this.scanOrderMore({
|
|
835
|
-
query: {
|
|
836
|
-
order_id: tempOrder.order_id,
|
|
837
|
-
products: products,
|
|
838
|
-
request_unique_idempotency_token: payload.request_unique_idempotency_token
|
|
839
|
-
}
|
|
840
|
-
});
|
|
841
|
-
case 8:
|
|
842
|
-
moreResult = _context10.sent;
|
|
843
|
-
if (moreResult.code === 200) {
|
|
844
|
-
result = {
|
|
845
|
-
data: {
|
|
846
|
-
order_id: tempOrder.order_id
|
|
847
|
-
}
|
|
848
|
-
};
|
|
849
|
-
}
|
|
850
|
-
_context10.next = 15;
|
|
851
|
-
break;
|
|
852
|
-
case 12:
|
|
853
|
-
_context10.next = 14;
|
|
854
|
-
return this.submitScanOrder({
|
|
855
|
-
query: payload
|
|
856
|
-
});
|
|
857
|
-
case 14:
|
|
858
|
-
result = _context10.sent;
|
|
859
|
-
case 15:
|
|
860
|
-
return _context10.abrupt("return", result);
|
|
861
|
-
case 16:
|
|
862
|
-
case "end":
|
|
863
|
-
return _context10.stop();
|
|
864
|
-
}
|
|
865
|
-
}, _callee10, this);
|
|
866
|
-
}));
|
|
867
|
-
function submitTempOrder(_x10) {
|
|
868
|
-
return _submitTempOrder.apply(this, arguments);
|
|
869
|
-
}
|
|
870
|
-
return submitTempOrder;
|
|
871
|
-
}()
|
|
872
122
|
}, {
|
|
873
123
|
key: "createOrder",
|
|
874
124
|
value: function createOrder(params) {
|
|
@@ -953,11 +203,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
953
203
|
}, {
|
|
954
204
|
key: "submitOrder",
|
|
955
205
|
value: function () {
|
|
956
|
-
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
206
|
+
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(order) {
|
|
957
207
|
var _order$query$cartItem, _params$bookings, _params$relation_prod;
|
|
958
208
|
var url, query, fetchUrl, params;
|
|
959
|
-
return _regeneratorRuntime().wrap(function
|
|
960
|
-
while (1) switch (
|
|
209
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
210
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
961
211
|
case 0:
|
|
962
212
|
this.logInfo('submitOrder called', {
|
|
963
213
|
url: order.url,
|
|
@@ -977,14 +227,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
977
227
|
relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
|
|
978
228
|
scheduleDate: params.schedule_date
|
|
979
229
|
});
|
|
980
|
-
return
|
|
230
|
+
return _context2.abrupt("return", this.request.post(fetchUrl, params));
|
|
981
231
|
case 6:
|
|
982
232
|
case "end":
|
|
983
|
-
return
|
|
233
|
+
return _context2.stop();
|
|
984
234
|
}
|
|
985
|
-
},
|
|
235
|
+
}, _callee2, this);
|
|
986
236
|
}));
|
|
987
|
-
function submitOrder(
|
|
237
|
+
function submitOrder(_x3) {
|
|
988
238
|
return _submitOrder.apply(this, arguments);
|
|
989
239
|
}
|
|
990
240
|
return submitOrder;
|
|
@@ -1002,11 +252,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1002
252
|
}, {
|
|
1003
253
|
key: "createOrderByCheckout",
|
|
1004
254
|
value: (function () {
|
|
1005
|
-
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
255
|
+
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
1006
256
|
var _params$bookings2, _params$relation_prod2, _params$payments, _params$payments2, _params$bookings3, _params$relation_prod3, _params$payments3;
|
|
1007
257
|
var _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, _orderData$bookings2, _orderData$relation_p2, _orderData$payments4, _orderData$payments5, _response$data, orderData, response;
|
|
1008
|
-
return _regeneratorRuntime().wrap(function
|
|
1009
|
-
while (1) switch (
|
|
258
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
259
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
1010
260
|
case 0:
|
|
1011
261
|
this.logInfo('createOrderByCheckout called', {
|
|
1012
262
|
type: params.type,
|
|
@@ -1035,7 +285,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1035
285
|
relationProductsCount: ((_params$relation_prod3 = params.relation_products) === null || _params$relation_prod3 === void 0 ? void 0 : _params$relation_prod3.length) || 0,
|
|
1036
286
|
paymentsCount: ((_params$payments3 = params.payments) === null || _params$payments3 === void 0 ? void 0 : _params$payments3.length) || 0
|
|
1037
287
|
});
|
|
1038
|
-
|
|
288
|
+
_context3.prev = 2;
|
|
1039
289
|
// 构建订单数据,设置默认值并允许 params 覆盖
|
|
1040
290
|
orderData = _objectSpread({
|
|
1041
291
|
sales_channel: 'my_pisel',
|
|
@@ -1099,10 +349,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1099
349
|
});
|
|
1100
350
|
|
|
1101
351
|
// 调用后端接口
|
|
1102
|
-
|
|
352
|
+
_context3.next = 10;
|
|
1103
353
|
return this.request.post('/order/checkout', orderData);
|
|
1104
354
|
case 10:
|
|
1105
|
-
response =
|
|
355
|
+
response = _context3.sent;
|
|
1106
356
|
this.logInfo('Order API called successfully', {
|
|
1107
357
|
response: response
|
|
1108
358
|
});
|
|
@@ -1110,164 +360,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1110
360
|
success: !!response,
|
|
1111
361
|
hasOrderId: !!(response !== null && response !== void 0 && (_response$data = response.data) !== null && _response$data !== void 0 && _response$data.order_id || response !== null && response !== void 0 && response.order_id)
|
|
1112
362
|
});
|
|
1113
|
-
return
|
|
363
|
+
return _context3.abrupt("return", response);
|
|
1114
364
|
case 16:
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
console.error('[Order] createOrderByCheckout 创建订单失败:',
|
|
365
|
+
_context3.prev = 16;
|
|
366
|
+
_context3.t0 = _context3["catch"](2);
|
|
367
|
+
console.error('[Order] createOrderByCheckout 创建订单失败:', _context3.t0);
|
|
1118
368
|
this.logInfo('Order API called failed', {
|
|
1119
|
-
error:
|
|
369
|
+
error: _context3.t0 instanceof Error ? _context3.t0.message : String(_context3.t0)
|
|
1120
370
|
});
|
|
1121
|
-
throw
|
|
371
|
+
throw _context3.t0;
|
|
1122
372
|
case 21:
|
|
1123
373
|
case "end":
|
|
1124
|
-
return
|
|
374
|
+
return _context3.stop();
|
|
1125
375
|
}
|
|
1126
|
-
},
|
|
376
|
+
}, _callee3, this, [[2, 16]]);
|
|
1127
377
|
}));
|
|
1128
|
-
function createOrderByCheckout(
|
|
378
|
+
function createOrderByCheckout(_x4) {
|
|
1129
379
|
return _createOrderByCheckout.apply(this, arguments);
|
|
1130
380
|
}
|
|
1131
381
|
return createOrderByCheckout;
|
|
1132
382
|
}())
|
|
1133
|
-
}, {
|
|
1134
|
-
key: "submitScanOrder",
|
|
1135
|
-
value: function () {
|
|
1136
|
-
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(params) {
|
|
1137
|
-
var url, query, fetchUrl;
|
|
1138
|
-
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1139
|
-
while (1) switch (_context13.prev = _context13.next) {
|
|
1140
|
-
case 0:
|
|
1141
|
-
url = params.url, query = params.query;
|
|
1142
|
-
fetchUrl = url || '/order/sales/checkout';
|
|
1143
|
-
return _context13.abrupt("return", this.request.post(fetchUrl, query, {
|
|
1144
|
-
customToast: function customToast() {}
|
|
1145
|
-
}));
|
|
1146
|
-
case 3:
|
|
1147
|
-
case "end":
|
|
1148
|
-
return _context13.stop();
|
|
1149
|
-
}
|
|
1150
|
-
}, _callee13, this);
|
|
1151
|
-
}));
|
|
1152
|
-
function submitScanOrder(_x13) {
|
|
1153
|
-
return _submitScanOrder.apply(this, arguments);
|
|
1154
|
-
}
|
|
1155
|
-
return submitScanOrder;
|
|
1156
|
-
}()
|
|
1157
|
-
}, {
|
|
1158
|
-
key: "scanOrderMore",
|
|
1159
|
-
value: function () {
|
|
1160
|
-
var _scanOrderMore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(params) {
|
|
1161
|
-
var url, query, fetchUrl, requestBody;
|
|
1162
|
-
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1163
|
-
while (1) switch (_context14.prev = _context14.next) {
|
|
1164
|
-
case 0:
|
|
1165
|
-
url = params.url, query = params.query;
|
|
1166
|
-
fetchUrl = url || "/order/order/product/".concat(query.order_id);
|
|
1167
|
-
requestBody = {
|
|
1168
|
-
products: query.products,
|
|
1169
|
-
request_unique_idempotency_token: query.request_unique_idempotency_token
|
|
1170
|
-
};
|
|
1171
|
-
return _context14.abrupt("return", this.request.put(fetchUrl, requestBody, {
|
|
1172
|
-
customToast: function customToast() {}
|
|
1173
|
-
}));
|
|
1174
|
-
case 4:
|
|
1175
|
-
case "end":
|
|
1176
|
-
return _context14.stop();
|
|
1177
|
-
}
|
|
1178
|
-
}, _callee14, this);
|
|
1179
|
-
}));
|
|
1180
|
-
function scanOrderMore(_x14) {
|
|
1181
|
-
return _scanOrderMore.apply(this, arguments);
|
|
1182
|
-
}
|
|
1183
|
-
return scanOrderMore;
|
|
1184
|
-
}() // TODO 获取详情的接口
|
|
1185
|
-
}, {
|
|
1186
|
-
key: "getOrderInfoByRemote",
|
|
1187
|
-
value: function () {
|
|
1188
|
-
var _getOrderInfoByRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(order_id) {
|
|
1189
|
-
var res;
|
|
1190
|
-
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1191
|
-
while (1) switch (_context15.prev = _context15.next) {
|
|
1192
|
-
case 0:
|
|
1193
|
-
_context15.next = 2;
|
|
1194
|
-
return this.request.get("/order/sales/".concat(order_id), {
|
|
1195
|
-
with: ['products', 'scheduleEvents']
|
|
1196
|
-
});
|
|
1197
|
-
case 2:
|
|
1198
|
-
res = _context15.sent;
|
|
1199
|
-
if (res.code === 200 && this.store.tempOrder) {
|
|
1200
|
-
this.store.tempOrder.lastOrderInfo = res.data;
|
|
1201
|
-
}
|
|
1202
|
-
return _context15.abrupt("return", res);
|
|
1203
|
-
case 5:
|
|
1204
|
-
case "end":
|
|
1205
|
-
return _context15.stop();
|
|
1206
|
-
}
|
|
1207
|
-
}, _callee15, this);
|
|
1208
|
-
}));
|
|
1209
|
-
function getOrderInfoByRemote(_x15) {
|
|
1210
|
-
return _getOrderInfoByRemote.apply(this, arguments);
|
|
1211
|
-
}
|
|
1212
|
-
return getOrderInfoByRemote;
|
|
1213
|
-
}()
|
|
1214
|
-
}, {
|
|
1215
|
-
key: "getLastOrderInfo",
|
|
1216
|
-
value: function getLastOrderInfo() {
|
|
1217
|
-
var _this$store;
|
|
1218
|
-
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;
|
|
1219
|
-
}
|
|
1220
|
-
}], [{
|
|
1221
|
-
key: "populateSavedAmounts",
|
|
1222
|
-
value:
|
|
1223
|
-
/**
|
|
1224
|
-
* Populate `savedAmount` on each discount based on product-level discount details.
|
|
1225
|
-
* Only selected discounts get a non-zero value.
|
|
1226
|
-
*/
|
|
1227
|
-
function populateSavedAmounts(productList, discountList) {
|
|
1228
|
-
var savedMap = new Map();
|
|
1229
|
-
var _iterator = _createForOfIteratorHelper(productList),
|
|
1230
|
-
_step;
|
|
1231
|
-
try {
|
|
1232
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
1233
|
-
var product = _step.value;
|
|
1234
|
-
var qty = product.num || 1;
|
|
1235
|
-
var _iterator3 = _createForOfIteratorHelper(product.discount_list || []),
|
|
1236
|
-
_step3;
|
|
1237
|
-
try {
|
|
1238
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
1239
|
-
var _pd$discount, _pd$metadata;
|
|
1240
|
-
var pd = _step3.value;
|
|
1241
|
-
var discountKey = ((_pd$discount = pd.discount) === null || _pd$discount === void 0 ? void 0 : _pd$discount.resource_id) || pd.id;
|
|
1242
|
-
if (discountKey == null) continue;
|
|
1243
|
-
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);
|
|
1244
|
-
savedMap.set(discountKey, (savedMap.get(discountKey) || new Decimal(0)).plus(amount));
|
|
1245
|
-
}
|
|
1246
|
-
} catch (err) {
|
|
1247
|
-
_iterator3.e(err);
|
|
1248
|
-
} finally {
|
|
1249
|
-
_iterator3.f();
|
|
1250
|
-
}
|
|
1251
|
-
}
|
|
1252
|
-
} catch (err) {
|
|
1253
|
-
_iterator.e(err);
|
|
1254
|
-
} finally {
|
|
1255
|
-
_iterator.f();
|
|
1256
|
-
}
|
|
1257
|
-
var _iterator2 = _createForOfIteratorHelper(discountList),
|
|
1258
|
-
_step2;
|
|
1259
|
-
try {
|
|
1260
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
1261
|
-
var d = _step2.value;
|
|
1262
|
-
var key = d.id;
|
|
1263
|
-
d.savedAmount = d.isSelected && key != null && savedMap.has(key) ? savedMap.get(key).toNumber() : 0;
|
|
1264
|
-
}
|
|
1265
|
-
} catch (err) {
|
|
1266
|
-
_iterator2.e(err);
|
|
1267
|
-
} finally {
|
|
1268
|
-
_iterator2.f();
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1271
383
|
}]);
|
|
1272
384
|
return OrderModule;
|
|
1273
385
|
}(BaseModule);
|