@pisell/pisellos 2.1.130 → 2.1.131
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/Order/index.d.ts +3 -6
- package/dist/modules/Order/index.js +119 -41
- package/dist/modules/Order/types.d.ts +23 -5
- package/dist/modules/Order/types.js +2 -0
- package/dist/modules/Order/utils.d.ts +66 -11
- package/dist/modules/Order/utils.js +281 -45
- package/dist/modules/SalesSummary/utils.js +33 -68
- package/dist/modules/ScanOrderLogger/providers/feishu.js +168 -60
- package/dist/modules/ScanOrderLogger/types.d.ts +6 -0
- package/dist/modules/Summary/utils.js +6 -21
- package/dist/solution/ScanOrder/index.d.ts +31 -6
- package/dist/solution/ScanOrder/index.js +1062 -498
- package/dist/solution/ScanOrder/types.d.ts +52 -2
- package/dist/solution/ScanOrder/types.js +16 -1
- package/dist/solution/ScanOrder/utils.d.ts +41 -5
- package/dist/solution/ScanOrder/utils.js +214 -33
- package/dist/solution/VenueBooking/index.d.ts +2 -5
- package/dist/solution/VenueBooking/index.js +35 -27
- package/lib/modules/Order/index.d.ts +3 -6
- package/lib/modules/Order/index.js +109 -30
- package/lib/modules/Order/types.d.ts +23 -5
- package/lib/modules/Order/utils.d.ts +66 -11
- package/lib/modules/Order/utils.js +181 -16
- package/lib/modules/SalesSummary/utils.js +13 -47
- package/lib/modules/ScanOrderLogger/providers/feishu.js +100 -34
- package/lib/modules/ScanOrderLogger/types.d.ts +6 -0
- package/lib/modules/Summary/utils.js +4 -18
- package/lib/solution/ScanOrder/index.d.ts +31 -6
- package/lib/solution/ScanOrder/index.js +315 -14
- package/lib/solution/ScanOrder/types.d.ts +52 -2
- package/lib/solution/ScanOrder/utils.d.ts +41 -5
- package/lib/solution/ScanOrder/utils.js +150 -20
- package/lib/solution/VenueBooking/index.d.ts +2 -5
- package/lib/solution/VenueBooking/index.js +13 -6
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
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
1
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
2
|
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
|
-
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
3
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
4
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
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
5
|
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); }
|
|
6
|
+
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; } } }; }
|
|
7
|
+
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); }
|
|
8
|
+
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; }
|
|
9
9
|
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; }
|
|
10
10
|
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; }
|
|
11
11
|
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; }
|
|
@@ -14,6 +14,8 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
|
|
|
14
14
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
15
15
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
16
16
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
17
|
+
function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
|
|
18
|
+
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
17
19
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
18
20
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
19
21
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
@@ -26,12 +28,16 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
26
28
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
27
29
|
import { BaseModule } from "../../modules/BaseModule";
|
|
28
30
|
import { ScanOrderHooks } from "./types";
|
|
29
|
-
import {
|
|
31
|
+
import { OrderModule } from "../../modules/Order";
|
|
32
|
+
import { AccountHooks } from "../../modules/Account/types";
|
|
33
|
+
import { RegisterAndLoginHooks } from "../RegisterAndLogin/types";
|
|
34
|
+
import Decimal from 'decimal.js';
|
|
35
|
+
import { attachItemRuleLimitsToTopLevelProducts, buildProductKey, buildItemRuleBusinessData, collectLinkProductIdsFromReservationRules, computeResourceIsFull, createEmptySummary, getProductIdentityIndex, getSafeProductNum, hasCustomCapacityProduct, pickFirstCustomCapacityDimensionId, pickFirstCustomCapacityPaxBounds, normalizeEnabledItemRuleIds, normalizeOrderProduct, normalizeItemRuleStrategies, pickFirstDurationMinutesFromProducts, toNonNegativeInt, toPriceString, toBoolean, toPositiveString } from "./utils";
|
|
30
36
|
import { createModule } from "../BookingByStep/types";
|
|
31
37
|
import { ProductList } from "../../modules/ProductList";
|
|
32
38
|
import { ScheduleModule } from "../../modules/Schedule";
|
|
33
39
|
import { getDateIsInSchedule } from "../../modules/Schedule/getDateIsInSchedule";
|
|
34
|
-
import { createUuidV4, normalizeSubmitCollectPaxValue } from "../../modules/Order/utils";
|
|
40
|
+
import { composeLinePrice, createUuidV4, normalizeSubmitCollectPaxValue, sumOptionUnitPrice } from "../../modules/Order/utils";
|
|
35
41
|
import dayjs from 'dayjs';
|
|
36
42
|
import { ItemRuleEvaluator } from "../../model/strategy/adapter/itemRule";
|
|
37
43
|
export * from "./types";
|
|
@@ -72,8 +78,13 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
72
78
|
_defineProperty(_assertThisInitialized(_this), "itemRuleRuntimeConfig", {});
|
|
73
79
|
/** 最近一次 checkResourceAvailable 从预约规则 link 拉取的商品快照 */
|
|
74
80
|
_defineProperty(_assertThisInitialized(_this), "enabledReservationRuleProducts", []);
|
|
81
|
+
_defineProperty(_assertThisInitialized(_this), "loginEffectDisposers", []);
|
|
82
|
+
_defineProperty(_assertThisInitialized(_this), "customerLoginRefreshInFlight", null);
|
|
83
|
+
_defineProperty(_assertThisInitialized(_this), "customerLoginRefreshIdInFlight", null);
|
|
75
84
|
return _this;
|
|
76
85
|
}
|
|
86
|
+
|
|
87
|
+
/** 与 `otherParams.cacheId` 一致,供宿主在 URL 变化时判断是否需要重新注册模块 */
|
|
77
88
|
_createClass(ScanOrderImpl, [{
|
|
78
89
|
key: "getScanOrderLoggerContext",
|
|
79
90
|
value: function getScanOrderLoggerContext() {
|
|
@@ -205,25 +216,241 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
205
216
|
}
|
|
206
217
|
return addLog;
|
|
207
218
|
}()
|
|
219
|
+
}, {
|
|
220
|
+
key: "normalizeCustomerId",
|
|
221
|
+
value: function normalizeCustomerId(value) {
|
|
222
|
+
var customerId = Number(value);
|
|
223
|
+
if (!Number.isFinite(customerId) || customerId <= 0) return null;
|
|
224
|
+
return customerId;
|
|
225
|
+
}
|
|
226
|
+
}, {
|
|
227
|
+
key: "resolveCustomerIdFromLoginPayload",
|
|
228
|
+
value: function resolveCustomerIdFromLoginPayload(payload) {
|
|
229
|
+
var _payload$user, _payload$user2, _payload$user3, _payload$user4, _payload$account, _payload$account2, _payload$account3, _payload$_origin;
|
|
230
|
+
var candidates = [payload === null || payload === void 0 ? void 0 : payload.customerId, payload === null || payload === void 0 ? void 0 : payload.customer_id, payload === null || payload === void 0 ? void 0 : payload.id, payload === null || payload === void 0 || (_payload$user = payload.user) === null || _payload$user === void 0 ? void 0 : _payload$user.customerId, payload === null || payload === void 0 || (_payload$user2 = payload.user) === null || _payload$user2 === void 0 ? void 0 : _payload$user2.customer_id, payload === null || payload === void 0 || (_payload$user3 = payload.user) === null || _payload$user3 === void 0 ? void 0 : _payload$user3.id, payload === null || payload === void 0 || (_payload$user4 = payload.user) === null || _payload$user4 === void 0 || (_payload$user4 = _payload$user4._origin) === null || _payload$user4 === void 0 ? void 0 : _payload$user4.customer_id, payload === null || payload === void 0 || (_payload$account = payload.account) === null || _payload$account === void 0 ? void 0 : _payload$account.customerId, payload === null || payload === void 0 || (_payload$account2 = payload.account) === null || _payload$account2 === void 0 ? void 0 : _payload$account2.customer_id, payload === null || payload === void 0 || (_payload$account3 = payload.account) === null || _payload$account3 === void 0 ? void 0 : _payload$account3.id, payload === null || payload === void 0 || (_payload$_origin = payload._origin) === null || _payload$_origin === void 0 ? void 0 : _payload$_origin.customer_id];
|
|
231
|
+
for (var _i = 0, _candidates = candidates; _i < _candidates.length; _i++) {
|
|
232
|
+
var candidate = _candidates[_i];
|
|
233
|
+
var customerId = this.normalizeCustomerId(candidate);
|
|
234
|
+
if (customerId) return customerId;
|
|
235
|
+
}
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
}, {
|
|
239
|
+
key: "clearLoginEffectListeners",
|
|
240
|
+
value: function clearLoginEffectListeners() {
|
|
241
|
+
var _iterator = _createForOfIteratorHelper(this.loginEffectDisposers),
|
|
242
|
+
_step;
|
|
243
|
+
try {
|
|
244
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
245
|
+
var dispose = _step.value;
|
|
246
|
+
dispose();
|
|
247
|
+
}
|
|
248
|
+
} catch (err) {
|
|
249
|
+
_iterator.e(err);
|
|
250
|
+
} finally {
|
|
251
|
+
_iterator.f();
|
|
252
|
+
}
|
|
253
|
+
this.loginEffectDisposers = [];
|
|
254
|
+
}
|
|
255
|
+
}, {
|
|
256
|
+
key: "registerLoginEffect",
|
|
257
|
+
value: function registerLoginEffect(event, callback) {
|
|
258
|
+
var _this$core;
|
|
259
|
+
var effects = (_this$core = this.core) === null || _this$core === void 0 ? void 0 : _this$core.effects;
|
|
260
|
+
if (!(effects !== null && effects !== void 0 && effects.on)) return;
|
|
261
|
+
effects.on(event, callback);
|
|
262
|
+
this.loginEffectDisposers.push(function () {
|
|
263
|
+
if (typeof effects.off === 'function') {
|
|
264
|
+
effects.off(event, callback);
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
}, {
|
|
269
|
+
key: "registerCustomerLoginListeners",
|
|
270
|
+
value: function registerCustomerLoginListeners() {
|
|
271
|
+
var _this2 = this;
|
|
272
|
+
this.clearLoginEffectListeners();
|
|
273
|
+
var createHandleLogin = function createHandleLogin() {
|
|
274
|
+
return /*#__PURE__*/function () {
|
|
275
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(payload) {
|
|
276
|
+
var customerId;
|
|
277
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
278
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
279
|
+
case 0:
|
|
280
|
+
customerId = _this2.resolveCustomerIdFromLoginPayload(payload);
|
|
281
|
+
if (customerId) {
|
|
282
|
+
_context3.next = 3;
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
return _context3.abrupt("return");
|
|
286
|
+
case 3:
|
|
287
|
+
_context3.next = 5;
|
|
288
|
+
return _this2.refreshOrderMarketingAfterLogin({
|
|
289
|
+
customerId: customerId
|
|
290
|
+
});
|
|
291
|
+
case 5:
|
|
292
|
+
case "end":
|
|
293
|
+
return _context3.stop();
|
|
294
|
+
}
|
|
295
|
+
}, _callee3);
|
|
296
|
+
}));
|
|
297
|
+
return function (_x3) {
|
|
298
|
+
return _ref.apply(this, arguments);
|
|
299
|
+
};
|
|
300
|
+
}();
|
|
301
|
+
};
|
|
302
|
+
this.registerLoginEffect(ScanOrderImpl.PISELL1_LOGIN_SUCCESS, createHandleLogin());
|
|
303
|
+
this.registerLoginEffect(AccountHooks.OnLogin, createHandleLogin());
|
|
304
|
+
this.registerLoginEffect(RegisterAndLoginHooks.onLoginSuccess, createHandleLogin());
|
|
305
|
+
}
|
|
306
|
+
}, {
|
|
307
|
+
key: "refreshOrderMarketingAfterLogin",
|
|
308
|
+
value: function () {
|
|
309
|
+
var _refreshOrderMarketingAfterLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(params) {
|
|
310
|
+
var _this3 = this;
|
|
311
|
+
var refreshTask;
|
|
312
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
313
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
314
|
+
case 0:
|
|
315
|
+
if (this.store.order) {
|
|
316
|
+
_context5.next = 2;
|
|
317
|
+
break;
|
|
318
|
+
}
|
|
319
|
+
throw new Error('order 模块未初始化');
|
|
320
|
+
case 2:
|
|
321
|
+
if (!this.customerLoginRefreshInFlight) {
|
|
322
|
+
_context5.next = 9;
|
|
323
|
+
break;
|
|
324
|
+
}
|
|
325
|
+
if (!(this.customerLoginRefreshIdInFlight === params.customerId)) {
|
|
326
|
+
_context5.next = 7;
|
|
327
|
+
break;
|
|
328
|
+
}
|
|
329
|
+
_context5.next = 6;
|
|
330
|
+
return this.customerLoginRefreshInFlight;
|
|
331
|
+
case 6:
|
|
332
|
+
return _context5.abrupt("return");
|
|
333
|
+
case 7:
|
|
334
|
+
_context5.next = 9;
|
|
335
|
+
return this.customerLoginRefreshInFlight;
|
|
336
|
+
case 9:
|
|
337
|
+
this.customerLoginRefreshIdInFlight = params.customerId;
|
|
338
|
+
refreshTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
339
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
340
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
341
|
+
case 0:
|
|
342
|
+
_context4.next = 2;
|
|
343
|
+
return _this3.store.order.loadDiscountConfig({
|
|
344
|
+
customerId: params.customerId
|
|
345
|
+
});
|
|
346
|
+
case 2:
|
|
347
|
+
_context4.next = 4;
|
|
348
|
+
return _this3.store.order.recalculateSummary({
|
|
349
|
+
createIfMissing: true
|
|
350
|
+
});
|
|
351
|
+
case 4:
|
|
352
|
+
_this3.store.order.persistTempOrder();
|
|
353
|
+
_context4.next = 7;
|
|
354
|
+
return _this3.refreshItemRuleQuantityLimits();
|
|
355
|
+
case 7:
|
|
356
|
+
_context4.next = 9;
|
|
357
|
+
return _this3.refreshCartValidationPassed();
|
|
358
|
+
case 9:
|
|
359
|
+
case "end":
|
|
360
|
+
return _context4.stop();
|
|
361
|
+
}
|
|
362
|
+
}, _callee4);
|
|
363
|
+
}))();
|
|
364
|
+
this.customerLoginRefreshInFlight = refreshTask;
|
|
365
|
+
_context5.prev = 12;
|
|
366
|
+
_context5.next = 15;
|
|
367
|
+
return refreshTask;
|
|
368
|
+
case 15:
|
|
369
|
+
_context5.next = 20;
|
|
370
|
+
break;
|
|
371
|
+
case 17:
|
|
372
|
+
_context5.prev = 17;
|
|
373
|
+
_context5.t0 = _context5["catch"](12);
|
|
374
|
+
throw _context5.t0;
|
|
375
|
+
case 20:
|
|
376
|
+
_context5.prev = 20;
|
|
377
|
+
if (this.customerLoginRefreshInFlight === refreshTask) {
|
|
378
|
+
this.customerLoginRefreshInFlight = null;
|
|
379
|
+
this.customerLoginRefreshIdInFlight = null;
|
|
380
|
+
}
|
|
381
|
+
return _context5.finish(20);
|
|
382
|
+
case 23:
|
|
383
|
+
case "end":
|
|
384
|
+
return _context5.stop();
|
|
385
|
+
}
|
|
386
|
+
}, _callee5, this, [[12, 17, 20, 23]]);
|
|
387
|
+
}));
|
|
388
|
+
function refreshOrderMarketingAfterLogin(_x4) {
|
|
389
|
+
return _refreshOrderMarketingAfterLogin.apply(this, arguments);
|
|
390
|
+
}
|
|
391
|
+
return refreshOrderMarketingAfterLogin;
|
|
392
|
+
}()
|
|
393
|
+
}, {
|
|
394
|
+
key: "getCacheId",
|
|
395
|
+
value: function getCacheId() {
|
|
396
|
+
return this.cacheId;
|
|
397
|
+
}
|
|
398
|
+
}, {
|
|
399
|
+
key: "destroyRegisteredChildModules",
|
|
400
|
+
value: function () {
|
|
401
|
+
var _destroyRegisteredChildModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
402
|
+
var modules, _i2, _modules, mod;
|
|
403
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
404
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
405
|
+
case 0:
|
|
406
|
+
modules = [this.store.schedule, this.store.salesSummary, this.store.order, this.store.products, this.store.scanOrderLogger];
|
|
407
|
+
_i2 = 0, _modules = modules;
|
|
408
|
+
case 2:
|
|
409
|
+
if (!(_i2 < _modules.length)) {
|
|
410
|
+
_context6.next = 10;
|
|
411
|
+
break;
|
|
412
|
+
}
|
|
413
|
+
mod = _modules[_i2];
|
|
414
|
+
if (!(mod && typeof mod.destroy === 'function')) {
|
|
415
|
+
_context6.next = 7;
|
|
416
|
+
break;
|
|
417
|
+
}
|
|
418
|
+
_context6.next = 7;
|
|
419
|
+
return Promise.resolve(mod.destroy());
|
|
420
|
+
case 7:
|
|
421
|
+
_i2++;
|
|
422
|
+
_context6.next = 2;
|
|
423
|
+
break;
|
|
424
|
+
case 10:
|
|
425
|
+
case "end":
|
|
426
|
+
return _context6.stop();
|
|
427
|
+
}
|
|
428
|
+
}, _callee6, this);
|
|
429
|
+
}));
|
|
430
|
+
function destroyRegisteredChildModules() {
|
|
431
|
+
return _destroyRegisteredChildModules.apply(this, arguments);
|
|
432
|
+
}
|
|
433
|
+
return destroyRegisteredChildModules;
|
|
434
|
+
}()
|
|
208
435
|
}, {
|
|
209
436
|
key: "initialize",
|
|
210
437
|
value: function () {
|
|
211
|
-
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
438
|
+
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(core) {
|
|
212
439
|
var _options$otherParams,
|
|
213
440
|
_this$otherParams,
|
|
214
441
|
_this$otherParams2,
|
|
215
442
|
_this$otherParams3,
|
|
216
|
-
|
|
443
|
+
_this4 = this;
|
|
217
444
|
var options,
|
|
218
445
|
moduleArr,
|
|
219
446
|
scheduleModule,
|
|
220
447
|
_this$store$order,
|
|
221
448
|
_this$store$order2,
|
|
222
|
-
|
|
223
|
-
return _regeneratorRuntime().wrap(function
|
|
224
|
-
while (1) switch (
|
|
449
|
+
_args7 = arguments;
|
|
450
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
451
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
225
452
|
case 0:
|
|
226
|
-
options =
|
|
453
|
+
options = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : {};
|
|
227
454
|
this.logMethodStart('initialize');
|
|
228
455
|
this.core = core;
|
|
229
456
|
this.initializeOptions = options || {};
|
|
@@ -245,14 +472,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
245
472
|
this.window = core.getPlugin('window');
|
|
246
473
|
this.request = core.getPlugin('request');
|
|
247
474
|
if (this.window) {
|
|
248
|
-
|
|
475
|
+
_context7.next = 21;
|
|
249
476
|
break;
|
|
250
477
|
}
|
|
251
478
|
this.logMethodError('initialize', 'window plugin missing');
|
|
252
479
|
throw new Error('scanOrder解决方案需要 window 插件支持');
|
|
253
480
|
case 21:
|
|
254
481
|
if (this.request) {
|
|
255
|
-
|
|
482
|
+
_context7.next = 24;
|
|
256
483
|
break;
|
|
257
484
|
}
|
|
258
485
|
this.logMethodError('initialize', 'request plugin missing');
|
|
@@ -260,33 +487,33 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
260
487
|
case 24:
|
|
261
488
|
moduleArr = ['scanOrderLogger', 'products', 'order', 'salesSummary'];
|
|
262
489
|
moduleArr.forEach(function (step) {
|
|
263
|
-
var targetModule = createModule(step,
|
|
490
|
+
var targetModule = createModule(step, _this4.name);
|
|
264
491
|
if (targetModule) {
|
|
265
|
-
var
|
|
266
|
-
|
|
492
|
+
var _this4$store$order, _this4$otherParams, _this4$otherParams2, _this4$otherParams3, _this4$otherParams4;
|
|
493
|
+
_this4.store[step] = targetModule;
|
|
267
494
|
var initialState = step === 'salesSummary' ? {
|
|
268
|
-
summary: ((
|
|
495
|
+
summary: ((_this4$store$order = _this4.store.order) === null || _this4$store$order === void 0 || (_this4$store$order = _this4$store$order.getTempOrder()) === null || _this4$store$order === void 0 ? void 0 : _this4$store$order.summary) || createEmptySummary()
|
|
269
496
|
} : {};
|
|
270
|
-
var loggerProvider = ((
|
|
271
|
-
var loggerConfig = ((
|
|
497
|
+
var loggerProvider = ((_this4$otherParams = _this4.otherParams) === null || _this4$otherParams === void 0 ? void 0 : _this4$otherParams.scanOrderLoggerProvider) || 'feishu';
|
|
498
|
+
var loggerConfig = ((_this4$otherParams2 = _this4.otherParams) === null || _this4$otherParams2 === void 0 ? void 0 : _this4$otherParams2.scanOrderLoggerConfig) || {
|
|
272
499
|
feishu: {
|
|
273
500
|
webhook: 'https://open.feishu.cn/open-apis/bot/v2/hook/216b3fe6-af98-424e-8706-f0471241a7ed'
|
|
274
501
|
}
|
|
275
502
|
};
|
|
276
|
-
|
|
503
|
+
_this4.core.registerModule(targetModule, {
|
|
277
504
|
initialState: initialState,
|
|
278
|
-
otherParams: _objectSpread(_objectSpread({},
|
|
279
|
-
fatherModule:
|
|
280
|
-
openCache: (
|
|
281
|
-
cacheId: (
|
|
282
|
-
salesSummaryModuleName: "".concat(
|
|
505
|
+
otherParams: _objectSpread(_objectSpread({}, _this4.otherParams), {}, {
|
|
506
|
+
fatherModule: _this4.name,
|
|
507
|
+
openCache: (_this4$otherParams3 = _this4.otherParams) !== null && _this4$otherParams3 !== void 0 && _this4$otherParams3.cacheId ? true : false,
|
|
508
|
+
cacheId: (_this4$otherParams4 = _this4.otherParams) === null || _this4$otherParams4 === void 0 ? void 0 : _this4$otherParams4.cacheId,
|
|
509
|
+
salesSummaryModuleName: "".concat(_this4.name, "_salesSummary"),
|
|
283
510
|
provider: loggerProvider,
|
|
284
511
|
providerConfig: loggerConfig,
|
|
285
|
-
context:
|
|
512
|
+
context: _this4.getScanOrderLoggerContext()
|
|
286
513
|
})
|
|
287
514
|
});
|
|
288
515
|
} else {
|
|
289
|
-
|
|
516
|
+
_this4.logMethodError('initialize', "module ".concat(step, " missing"));
|
|
290
517
|
throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
|
|
291
518
|
}
|
|
292
519
|
});
|
|
@@ -300,64 +527,65 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
300
527
|
fatherModule: this.name
|
|
301
528
|
})
|
|
302
529
|
});
|
|
530
|
+
this.registerCustomerLoginListeners();
|
|
303
531
|
console.log('[ScanOrder] 初始化开始');
|
|
304
|
-
|
|
305
|
-
|
|
532
|
+
_context7.prev = 32;
|
|
533
|
+
_context7.next = 35;
|
|
306
534
|
return (_this$store$order = this.store.order) === null || _this$store$order === void 0 ? void 0 : _this$store$order.recalculateSummary({
|
|
307
535
|
createIfMissing: false
|
|
308
536
|
});
|
|
309
|
-
case
|
|
537
|
+
case 35:
|
|
310
538
|
(_this$store$order2 = this.store.order) === null || _this$store$order2 === void 0 || _this$store$order2.persistTempOrder();
|
|
311
|
-
|
|
539
|
+
_context7.next = 38;
|
|
312
540
|
return this.loadRuntimeConfigs();
|
|
313
|
-
case
|
|
541
|
+
case 38:
|
|
314
542
|
if (!this.store.schedule) {
|
|
315
|
-
|
|
543
|
+
_context7.next = 47;
|
|
316
544
|
break;
|
|
317
545
|
}
|
|
318
|
-
|
|
319
|
-
|
|
546
|
+
_context7.prev = 39;
|
|
547
|
+
_context7.next = 42;
|
|
320
548
|
return this.store.schedule.loadAllSchedule();
|
|
321
|
-
case
|
|
322
|
-
|
|
549
|
+
case 42:
|
|
550
|
+
_context7.next = 47;
|
|
323
551
|
break;
|
|
324
|
-
case
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
console.warn('[ScanOrder] loadAllSchedule 失败,operating_hours 判定将跳过',
|
|
328
|
-
case
|
|
329
|
-
|
|
552
|
+
case 44:
|
|
553
|
+
_context7.prev = 44;
|
|
554
|
+
_context7.t0 = _context7["catch"](39);
|
|
555
|
+
console.warn('[ScanOrder] loadAllSchedule 失败,operating_hours 判定将跳过', _context7.t0);
|
|
556
|
+
case 47:
|
|
557
|
+
_context7.next = 49;
|
|
330
558
|
return this.refreshItemRuleQuantityLimits();
|
|
331
|
-
case
|
|
559
|
+
case 49:
|
|
332
560
|
this.store.status = 'ready';
|
|
333
561
|
console.log('[ScanOrder] 初始化完成');
|
|
334
|
-
|
|
562
|
+
_context7.next = 53;
|
|
335
563
|
return this.core.effects.emit(ScanOrderHooks.onInited, {
|
|
336
564
|
status: this.store.status
|
|
337
565
|
});
|
|
338
|
-
case
|
|
566
|
+
case 53:
|
|
339
567
|
this.logMethodSuccess('initialize', {
|
|
340
568
|
status: this.store.status
|
|
341
569
|
});
|
|
342
|
-
|
|
570
|
+
_context7.next = 63;
|
|
343
571
|
break;
|
|
344
|
-
case
|
|
345
|
-
|
|
346
|
-
|
|
572
|
+
case 56:
|
|
573
|
+
_context7.prev = 56;
|
|
574
|
+
_context7.t1 = _context7["catch"](32);
|
|
347
575
|
this.store.status = 'error';
|
|
348
|
-
this.store.error =
|
|
349
|
-
console.error('[ScanOrder] 初始化失败',
|
|
350
|
-
this.logMethodError('initialize',
|
|
576
|
+
this.store.error = _context7.t1 instanceof Error ? _context7.t1.message : '初始化失败';
|
|
577
|
+
console.error('[ScanOrder] 初始化失败', _context7.t1);
|
|
578
|
+
this.logMethodError('initialize', _context7.t1, {
|
|
351
579
|
status: this.store.status
|
|
352
580
|
});
|
|
353
|
-
throw
|
|
354
|
-
case
|
|
581
|
+
throw _context7.t1;
|
|
582
|
+
case 63:
|
|
355
583
|
case "end":
|
|
356
|
-
return
|
|
584
|
+
return _context7.stop();
|
|
357
585
|
}
|
|
358
|
-
},
|
|
586
|
+
}, _callee7, this, [[32, 56], [39, 44]]);
|
|
359
587
|
}));
|
|
360
|
-
function initialize(
|
|
588
|
+
function initialize(_x5) {
|
|
361
589
|
return _initialize.apply(this, arguments);
|
|
362
590
|
}
|
|
363
591
|
return initialize;
|
|
@@ -365,21 +593,26 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
365
593
|
}, {
|
|
366
594
|
key: "destroy",
|
|
367
595
|
value: function () {
|
|
368
|
-
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
369
|
-
return _regeneratorRuntime().wrap(function
|
|
370
|
-
while (1) switch (
|
|
596
|
+
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
597
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
598
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
371
599
|
case 0:
|
|
372
600
|
this.logMethodStart('destroy');
|
|
373
|
-
|
|
601
|
+
this.clearLoginEffectListeners();
|
|
602
|
+
_context8.next = 4;
|
|
374
603
|
return this.core.effects.emit(ScanOrderHooks.onDestroy, {});
|
|
375
|
-
case
|
|
604
|
+
case 4:
|
|
605
|
+
_context8.next = 6;
|
|
606
|
+
return this.destroyRegisteredChildModules();
|
|
607
|
+
case 6:
|
|
608
|
+
_get(_getPrototypeOf(ScanOrderImpl.prototype), "destroy", this).call(this);
|
|
376
609
|
console.log('[ScanOrder] 已销毁');
|
|
377
610
|
this.logMethodSuccess('destroy');
|
|
378
|
-
case
|
|
611
|
+
case 9:
|
|
379
612
|
case "end":
|
|
380
|
-
return
|
|
613
|
+
return _context8.stop();
|
|
381
614
|
}
|
|
382
|
-
},
|
|
615
|
+
}, _callee8, this);
|
|
383
616
|
}));
|
|
384
617
|
function destroy() {
|
|
385
618
|
return _destroy.apply(this, arguments);
|
|
@@ -389,33 +622,33 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
389
622
|
}, {
|
|
390
623
|
key: "retryInit",
|
|
391
624
|
value: function () {
|
|
392
|
-
var _retryInit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
393
|
-
return _regeneratorRuntime().wrap(function
|
|
394
|
-
while (1) switch (
|
|
625
|
+
var _retryInit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
626
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
627
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
395
628
|
case 0:
|
|
396
629
|
this.logMethodStart('retryInit');
|
|
397
630
|
// TODO: 细化重试策略(指数退避、最大重试次数)后替换当前实现
|
|
398
631
|
console.log('[ScanOrder] retryInit 调用');
|
|
399
|
-
|
|
632
|
+
_context9.next = 4;
|
|
400
633
|
return this.core.effects.emit(ScanOrderHooks.onRetryInit, {});
|
|
401
634
|
case 4:
|
|
402
|
-
|
|
403
|
-
|
|
635
|
+
_context9.prev = 4;
|
|
636
|
+
_context9.next = 7;
|
|
404
637
|
return this.initialize(this.core, this.initializeOptions);
|
|
405
638
|
case 7:
|
|
406
639
|
this.logMethodSuccess('retryInit');
|
|
407
|
-
|
|
640
|
+
_context9.next = 14;
|
|
408
641
|
break;
|
|
409
642
|
case 10:
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
this.logMethodError('retryInit',
|
|
413
|
-
throw
|
|
643
|
+
_context9.prev = 10;
|
|
644
|
+
_context9.t0 = _context9["catch"](4);
|
|
645
|
+
this.logMethodError('retryInit', _context9.t0);
|
|
646
|
+
throw _context9.t0;
|
|
414
647
|
case 14:
|
|
415
648
|
case "end":
|
|
416
|
-
return
|
|
649
|
+
return _context9.stop();
|
|
417
650
|
}
|
|
418
|
-
},
|
|
651
|
+
}, _callee9, this, [[4, 10]]);
|
|
419
652
|
}));
|
|
420
653
|
function retryInit() {
|
|
421
654
|
return _retryInit.apply(this, arguments);
|
|
@@ -425,23 +658,23 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
425
658
|
}, {
|
|
426
659
|
key: "refresh",
|
|
427
660
|
value: function () {
|
|
428
|
-
var _refresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
429
|
-
return _regeneratorRuntime().wrap(function
|
|
430
|
-
while (1) switch (
|
|
661
|
+
var _refresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
662
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
663
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
431
664
|
case 0:
|
|
432
665
|
this.logMethodStart('refresh');
|
|
433
666
|
// TODO: 接入真实刷新逻辑(资源重拉取、流程重建)后替换当前实现
|
|
434
667
|
console.log('[ScanOrder] refresh 调用');
|
|
435
|
-
|
|
668
|
+
_context10.prev = 2;
|
|
436
669
|
this.store.status = 'initializing';
|
|
437
|
-
|
|
670
|
+
_context10.next = 6;
|
|
438
671
|
return this.loadRuntimeConfigs();
|
|
439
672
|
case 6:
|
|
440
|
-
|
|
673
|
+
_context10.next = 8;
|
|
441
674
|
return this.refreshItemRuleQuantityLimits();
|
|
442
675
|
case 8:
|
|
443
676
|
this.store.status = 'ready';
|
|
444
|
-
|
|
677
|
+
_context10.next = 11;
|
|
445
678
|
return this.core.effects.emit(ScanOrderHooks.onRefresh, {
|
|
446
679
|
status: this.store.status
|
|
447
680
|
});
|
|
@@ -449,18 +682,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
449
682
|
this.logMethodSuccess('refresh', {
|
|
450
683
|
status: this.store.status
|
|
451
684
|
});
|
|
452
|
-
|
|
685
|
+
_context10.next = 18;
|
|
453
686
|
break;
|
|
454
687
|
case 14:
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
this.logMethodError('refresh',
|
|
458
|
-
throw
|
|
688
|
+
_context10.prev = 14;
|
|
689
|
+
_context10.t0 = _context10["catch"](2);
|
|
690
|
+
this.logMethodError('refresh', _context10.t0);
|
|
691
|
+
throw _context10.t0;
|
|
459
692
|
case 18:
|
|
460
693
|
case "end":
|
|
461
|
-
return
|
|
694
|
+
return _context10.stop();
|
|
462
695
|
}
|
|
463
|
-
},
|
|
696
|
+
}, _callee10, this, [[2, 14]]);
|
|
464
697
|
}));
|
|
465
698
|
function refresh() {
|
|
466
699
|
return _refresh.apply(this, arguments);
|
|
@@ -624,37 +857,37 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
624
857
|
}, {
|
|
625
858
|
key: "addNewOrder",
|
|
626
859
|
value: function () {
|
|
627
|
-
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
860
|
+
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
628
861
|
var tempOrder;
|
|
629
|
-
return _regeneratorRuntime().wrap(function
|
|
630
|
-
while (1) switch (
|
|
862
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
863
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
631
864
|
case 0:
|
|
632
865
|
this.logMethodStart('addNewOrder');
|
|
633
|
-
|
|
866
|
+
_context11.prev = 1;
|
|
634
867
|
if (this.store.order) {
|
|
635
|
-
|
|
868
|
+
_context11.next = 4;
|
|
636
869
|
break;
|
|
637
870
|
}
|
|
638
871
|
throw new Error('order 模块未初始化');
|
|
639
872
|
case 4:
|
|
640
|
-
|
|
873
|
+
_context11.next = 6;
|
|
641
874
|
return this.store.order.addNewOrder();
|
|
642
875
|
case 6:
|
|
643
|
-
tempOrder =
|
|
876
|
+
tempOrder = _context11.sent;
|
|
644
877
|
this.logMethodSuccess('addNewOrder', {
|
|
645
878
|
productCount: tempOrder.products.length
|
|
646
879
|
});
|
|
647
|
-
return
|
|
880
|
+
return _context11.abrupt("return", tempOrder);
|
|
648
881
|
case 11:
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
this.logMethodError('addNewOrder',
|
|
652
|
-
throw
|
|
882
|
+
_context11.prev = 11;
|
|
883
|
+
_context11.t0 = _context11["catch"](1);
|
|
884
|
+
this.logMethodError('addNewOrder', _context11.t0);
|
|
885
|
+
throw _context11.t0;
|
|
653
886
|
case 15:
|
|
654
887
|
case "end":
|
|
655
|
-
return
|
|
888
|
+
return _context11.stop();
|
|
656
889
|
}
|
|
657
|
-
},
|
|
890
|
+
}, _callee11, this, [[1, 11]]);
|
|
658
891
|
}));
|
|
659
892
|
function addNewOrder() {
|
|
660
893
|
return _addNewOrder.apply(this, arguments);
|
|
@@ -665,15 +898,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
665
898
|
}, {
|
|
666
899
|
key: "restoreOrder",
|
|
667
900
|
value: function () {
|
|
668
|
-
var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
901
|
+
var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
669
902
|
var tempOrder;
|
|
670
|
-
return _regeneratorRuntime().wrap(function
|
|
671
|
-
while (1) switch (
|
|
903
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
904
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
672
905
|
case 0:
|
|
673
906
|
this.logMethodStart('restoreOrder');
|
|
674
|
-
|
|
907
|
+
_context12.prev = 1;
|
|
675
908
|
if (this.store.order) {
|
|
676
|
-
|
|
909
|
+
_context12.next = 4;
|
|
677
910
|
break;
|
|
678
911
|
}
|
|
679
912
|
throw new Error('scanOrder 解决方案需要 order 模块支持');
|
|
@@ -683,17 +916,17 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
683
916
|
this.enabledReservationRuleProducts = [];
|
|
684
917
|
tempOrder = this.store.order.restoreOrder();
|
|
685
918
|
this.logMethodSuccess('restoreOrder');
|
|
686
|
-
return
|
|
919
|
+
return _context12.abrupt("return", tempOrder);
|
|
687
920
|
case 12:
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
this.logMethodError('restoreOrder',
|
|
691
|
-
throw
|
|
921
|
+
_context12.prev = 12;
|
|
922
|
+
_context12.t0 = _context12["catch"](1);
|
|
923
|
+
this.logMethodError('restoreOrder', _context12.t0);
|
|
924
|
+
throw _context12.t0;
|
|
692
925
|
case 16:
|
|
693
926
|
case "end":
|
|
694
|
-
return
|
|
927
|
+
return _context12.stop();
|
|
695
928
|
}
|
|
696
|
-
},
|
|
929
|
+
}, _callee12, this, [[1, 12]]);
|
|
697
930
|
}));
|
|
698
931
|
function restoreOrder() {
|
|
699
932
|
return _restoreOrder.apply(this, arguments);
|
|
@@ -714,42 +947,306 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
714
947
|
}, {
|
|
715
948
|
key: "getSummary",
|
|
716
949
|
value: function () {
|
|
717
|
-
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
950
|
+
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
718
951
|
var summary;
|
|
719
|
-
return _regeneratorRuntime().wrap(function
|
|
720
|
-
while (1) switch (
|
|
952
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
953
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
721
954
|
case 0:
|
|
722
955
|
this.logMethodStart('getSummary');
|
|
723
|
-
|
|
956
|
+
_context13.prev = 1;
|
|
724
957
|
if (this.store.order) {
|
|
725
|
-
|
|
958
|
+
_context13.next = 4;
|
|
726
959
|
break;
|
|
727
960
|
}
|
|
728
961
|
throw new Error('order 模块未初始化');
|
|
729
962
|
case 4:
|
|
730
|
-
|
|
963
|
+
_context13.next = 6;
|
|
731
964
|
return this.store.order.getScanOrderSummary();
|
|
732
965
|
case 6:
|
|
733
|
-
summary =
|
|
966
|
+
summary = _context13.sent;
|
|
734
967
|
this.logMethodSuccess('getSummary', {
|
|
735
968
|
totalAmount: summary.total_amount
|
|
736
969
|
});
|
|
737
|
-
return
|
|
970
|
+
return _context13.abrupt("return", summary);
|
|
738
971
|
case 11:
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
this.logMethodError('getSummary',
|
|
742
|
-
throw
|
|
972
|
+
_context13.prev = 11;
|
|
973
|
+
_context13.t0 = _context13["catch"](1);
|
|
974
|
+
this.logMethodError('getSummary', _context13.t0);
|
|
975
|
+
throw _context13.t0;
|
|
743
976
|
case 15:
|
|
744
977
|
case "end":
|
|
745
|
-
return
|
|
978
|
+
return _context13.stop();
|
|
746
979
|
}
|
|
747
|
-
},
|
|
980
|
+
}, _callee13, this, [[1, 11]]);
|
|
748
981
|
}));
|
|
749
982
|
function getSummary() {
|
|
750
983
|
return _getSummary.apply(this, arguments);
|
|
751
984
|
}
|
|
752
985
|
return getSummary;
|
|
986
|
+
}()
|
|
987
|
+
}, {
|
|
988
|
+
key: "getDiscountList",
|
|
989
|
+
value: function getDiscountList() {
|
|
990
|
+
if (!this.store.order) return [];
|
|
991
|
+
return this.store.order.getDiscountList();
|
|
992
|
+
}
|
|
993
|
+
}, {
|
|
994
|
+
key: "scanCode",
|
|
995
|
+
value: function () {
|
|
996
|
+
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(code, customerId) {
|
|
997
|
+
var raw;
|
|
998
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
999
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1000
|
+
case 0:
|
|
1001
|
+
this.logMethodStart('scanCode', {
|
|
1002
|
+
code: code
|
|
1003
|
+
});
|
|
1004
|
+
_context14.prev = 1;
|
|
1005
|
+
if (this.store.order) {
|
|
1006
|
+
_context14.next = 4;
|
|
1007
|
+
break;
|
|
1008
|
+
}
|
|
1009
|
+
throw new Error('order 模块未初始化');
|
|
1010
|
+
case 4:
|
|
1011
|
+
_context14.next = 6;
|
|
1012
|
+
return this.store.order.scanCode(code, customerId);
|
|
1013
|
+
case 6:
|
|
1014
|
+
raw = _context14.sent;
|
|
1015
|
+
if (!raw.isAvailable) {
|
|
1016
|
+
_context14.next = 11;
|
|
1017
|
+
break;
|
|
1018
|
+
}
|
|
1019
|
+
_context14.next = 10;
|
|
1020
|
+
return this.store.order.recalculateSummary({
|
|
1021
|
+
createIfMissing: true
|
|
1022
|
+
});
|
|
1023
|
+
case 10:
|
|
1024
|
+
this.store.order.persistTempOrder();
|
|
1025
|
+
case 11:
|
|
1026
|
+
this.logMethodSuccess('scanCode', {
|
|
1027
|
+
isAvailable: raw.isAvailable
|
|
1028
|
+
});
|
|
1029
|
+
return _context14.abrupt("return", {
|
|
1030
|
+
isAvailable: raw.isAvailable,
|
|
1031
|
+
type: raw.type,
|
|
1032
|
+
unavailableReason: raw.unavailableReason
|
|
1033
|
+
});
|
|
1034
|
+
case 15:
|
|
1035
|
+
_context14.prev = 15;
|
|
1036
|
+
_context14.t0 = _context14["catch"](1);
|
|
1037
|
+
this.logMethodError('scanCode', _context14.t0);
|
|
1038
|
+
throw _context14.t0;
|
|
1039
|
+
case 19:
|
|
1040
|
+
case "end":
|
|
1041
|
+
return _context14.stop();
|
|
1042
|
+
}
|
|
1043
|
+
}, _callee14, this, [[1, 15]]);
|
|
1044
|
+
}));
|
|
1045
|
+
function scanCode(_x6, _x7) {
|
|
1046
|
+
return _scanCode.apply(this, arguments);
|
|
1047
|
+
}
|
|
1048
|
+
return scanCode;
|
|
1049
|
+
}()
|
|
1050
|
+
}, {
|
|
1051
|
+
key: "setDiscountSelected",
|
|
1052
|
+
value: function () {
|
|
1053
|
+
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
|
|
1054
|
+
var _tempOrder$holder, list, updated, tempOrder, orderStore, discountModule, rulesModule, holders, nextDiscountList, _tempOrder$holder2, result, beforeSelectedIds, _iterator2, _step2, d, selectedResourceIds, _iterator3, _step3, _product$_origin, _product$metadata$sou, _product$metadata, _product$metadata2, _product$original_pri, product, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
|
|
1055
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1056
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1057
|
+
case 0:
|
|
1058
|
+
this.logMethodStart('setDiscountSelected', params);
|
|
1059
|
+
_context15.prev = 1;
|
|
1060
|
+
if (this.store.order) {
|
|
1061
|
+
_context15.next = 4;
|
|
1062
|
+
break;
|
|
1063
|
+
}
|
|
1064
|
+
throw new Error('order 模块未初始化');
|
|
1065
|
+
case 4:
|
|
1066
|
+
list = this.store.order.getDiscountList();
|
|
1067
|
+
updated = list.map(function (d) {
|
|
1068
|
+
return d.id === params.discountId ? _objectSpread(_objectSpread({}, d), {}, {
|
|
1069
|
+
isSelected: params.isSelected,
|
|
1070
|
+
isManualSelect: !params.isSelected
|
|
1071
|
+
}) : d;
|
|
1072
|
+
});
|
|
1073
|
+
tempOrder = this.store.order.ensureTempOrder();
|
|
1074
|
+
orderStore = this.store.order.store || {};
|
|
1075
|
+
discountModule = orderStore.discount;
|
|
1076
|
+
rulesModule = orderStore.rules;
|
|
1077
|
+
holders = (_tempOrder$holder = tempOrder.holder) !== null && _tempOrder$holder !== void 0 && _tempOrder$holder.form_record_id ? [{
|
|
1078
|
+
form_record_id: tempOrder.holder.form_record_id
|
|
1079
|
+
}] : [];
|
|
1080
|
+
nextDiscountList = updated;
|
|
1081
|
+
_context15.next = 14;
|
|
1082
|
+
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(updated);
|
|
1083
|
+
case 14:
|
|
1084
|
+
if (rulesModule) {
|
|
1085
|
+
result = rulesModule.calcDiscount({
|
|
1086
|
+
productList: tempOrder.products,
|
|
1087
|
+
discountList: updated,
|
|
1088
|
+
holders: holders,
|
|
1089
|
+
isFormSubject: !!((_tempOrder$holder2 = tempOrder.holder) !== null && _tempOrder$holder2 !== void 0 && _tempOrder$holder2.type) && tempOrder.holder.type === 'form'
|
|
1090
|
+
}, {
|
|
1091
|
+
discountId: params.discountId,
|
|
1092
|
+
isSelected: params.isSelected
|
|
1093
|
+
}) || {
|
|
1094
|
+
productList: tempOrder.products,
|
|
1095
|
+
discountList: updated
|
|
1096
|
+
};
|
|
1097
|
+
if (result !== null && result !== void 0 && result.productList) {
|
|
1098
|
+
tempOrder.products = result.productList;
|
|
1099
|
+
}
|
|
1100
|
+
if (result !== null && result !== void 0 && result.discountList) {
|
|
1101
|
+
nextDiscountList = result.discountList;
|
|
1102
|
+
if (!params.isSelected) {
|
|
1103
|
+
beforeSelectedIds = new Set(updated.filter(function (d) {
|
|
1104
|
+
return d.isSelected;
|
|
1105
|
+
}).map(function (d) {
|
|
1106
|
+
return d.id;
|
|
1107
|
+
}));
|
|
1108
|
+
_iterator2 = _createForOfIteratorHelper(nextDiscountList);
|
|
1109
|
+
try {
|
|
1110
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
1111
|
+
d = _step2.value;
|
|
1112
|
+
if (d.isSelected && !beforeSelectedIds.has(d.id)) {
|
|
1113
|
+
d.isSelected = false;
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
} catch (err) {
|
|
1117
|
+
_iterator2.e(err);
|
|
1118
|
+
} finally {
|
|
1119
|
+
_iterator2.f();
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
selectedResourceIds = new Set(nextDiscountList.filter(function (d) {
|
|
1125
|
+
return d.isSelected;
|
|
1126
|
+
}).map(function (d) {
|
|
1127
|
+
return d.id;
|
|
1128
|
+
}));
|
|
1129
|
+
_iterator3 = _createForOfIteratorHelper(tempOrder.products);
|
|
1130
|
+
_context15.prev = 17;
|
|
1131
|
+
_iterator3.s();
|
|
1132
|
+
case 19:
|
|
1133
|
+
if ((_step3 = _iterator3.n()).done) {
|
|
1134
|
+
_context15.next = 33;
|
|
1135
|
+
break;
|
|
1136
|
+
}
|
|
1137
|
+
product = _step3.value;
|
|
1138
|
+
if (!((_product$_origin = product._origin) !== null && _product$_origin !== void 0 && _product$_origin.isManualDiscount)) {
|
|
1139
|
+
_context15.next = 23;
|
|
1140
|
+
break;
|
|
1141
|
+
}
|
|
1142
|
+
return _context15.abrupt("continue", 31);
|
|
1143
|
+
case 23:
|
|
1144
|
+
product.discount_list = (product.discount_list || []).filter(function (pd) {
|
|
1145
|
+
var _pd$discount$resource, _pd$discount;
|
|
1146
|
+
var rid = (_pd$discount$resource = (_pd$discount = pd.discount) === null || _pd$discount === void 0 ? void 0 : _pd$discount.resource_id) !== null && _pd$discount$resource !== void 0 ? _pd$discount$resource : pd.id;
|
|
1147
|
+
return rid != null && selectedResourceIds.has(rid);
|
|
1148
|
+
});
|
|
1149
|
+
|
|
1150
|
+
// 券作用于 source(不含 option、不含 bundle);算出新 source 折后价后补回 options
|
|
1151
|
+
// 写入含 option 的 main_product_selling_price,再合成 composite 回写 selling_price。
|
|
1152
|
+
totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
|
|
1153
|
+
return sum + (pd.amount || 0);
|
|
1154
|
+
}, 0);
|
|
1155
|
+
optionSum = sumOptionUnitPrice(product.product_option_item);
|
|
1156
|
+
sourcePrice = (_product$metadata$sou = (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.source_product_price) !== null && _product$metadata$sou !== void 0 ? _product$metadata$sou : ((_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.main_product_original_price) != null ? new Decimal(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : (_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : '0';
|
|
1157
|
+
newSourceSellingPrice = new Decimal(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
1158
|
+
newMainSellingPrice = new Decimal(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
1159
|
+
if (product.metadata) {
|
|
1160
|
+
product.metadata.main_product_selling_price = newMainSellingPrice;
|
|
1161
|
+
product.metadata.price_schema_version = 2;
|
|
1162
|
+
}
|
|
1163
|
+
product.selling_price = composeLinePrice({
|
|
1164
|
+
mainPrice: newMainSellingPrice,
|
|
1165
|
+
bundle: product.product_bundle
|
|
1166
|
+
});
|
|
1167
|
+
case 31:
|
|
1168
|
+
_context15.next = 19;
|
|
1169
|
+
break;
|
|
1170
|
+
case 33:
|
|
1171
|
+
_context15.next = 38;
|
|
1172
|
+
break;
|
|
1173
|
+
case 35:
|
|
1174
|
+
_context15.prev = 35;
|
|
1175
|
+
_context15.t0 = _context15["catch"](17);
|
|
1176
|
+
_iterator3.e(_context15.t0);
|
|
1177
|
+
case 38:
|
|
1178
|
+
_context15.prev = 38;
|
|
1179
|
+
_iterator3.f();
|
|
1180
|
+
return _context15.finish(38);
|
|
1181
|
+
case 41:
|
|
1182
|
+
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
1183
|
+
_context15.next = 44;
|
|
1184
|
+
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1185
|
+
case 44:
|
|
1186
|
+
tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
|
|
1187
|
+
return d.isSelected;
|
|
1188
|
+
});
|
|
1189
|
+
_context15.next = 47;
|
|
1190
|
+
return this.store.order.recalculateSummary({
|
|
1191
|
+
createIfMissing: true
|
|
1192
|
+
});
|
|
1193
|
+
case 47:
|
|
1194
|
+
this.store.order.persistTempOrder();
|
|
1195
|
+
this.logMethodSuccess('setDiscountSelected', params);
|
|
1196
|
+
_context15.next = 55;
|
|
1197
|
+
break;
|
|
1198
|
+
case 51:
|
|
1199
|
+
_context15.prev = 51;
|
|
1200
|
+
_context15.t1 = _context15["catch"](1);
|
|
1201
|
+
this.logMethodError('setDiscountSelected', _context15.t1);
|
|
1202
|
+
throw _context15.t1;
|
|
1203
|
+
case 55:
|
|
1204
|
+
case "end":
|
|
1205
|
+
return _context15.stop();
|
|
1206
|
+
}
|
|
1207
|
+
}, _callee15, this, [[1, 51], [17, 35, 38, 41]]);
|
|
1208
|
+
}));
|
|
1209
|
+
function setDiscountSelected(_x8) {
|
|
1210
|
+
return _setDiscountSelected.apply(this, arguments);
|
|
1211
|
+
}
|
|
1212
|
+
return setDiscountSelected;
|
|
1213
|
+
}()
|
|
1214
|
+
}, {
|
|
1215
|
+
key: "onCustomerLogin",
|
|
1216
|
+
value: function () {
|
|
1217
|
+
var _onCustomerLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(params) {
|
|
1218
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1219
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1220
|
+
case 0:
|
|
1221
|
+
this.logMethodStart('onCustomerLogin', {
|
|
1222
|
+
customerId: params.customerId
|
|
1223
|
+
});
|
|
1224
|
+
_context16.prev = 1;
|
|
1225
|
+
_context16.next = 4;
|
|
1226
|
+
return this.refreshOrderMarketingAfterLogin({
|
|
1227
|
+
customerId: params.customerId
|
|
1228
|
+
});
|
|
1229
|
+
case 4:
|
|
1230
|
+
this.logMethodSuccess('onCustomerLogin', {
|
|
1231
|
+
customerId: params.customerId
|
|
1232
|
+
});
|
|
1233
|
+
_context16.next = 11;
|
|
1234
|
+
break;
|
|
1235
|
+
case 7:
|
|
1236
|
+
_context16.prev = 7;
|
|
1237
|
+
_context16.t0 = _context16["catch"](1);
|
|
1238
|
+
this.logMethodError('onCustomerLogin', _context16.t0);
|
|
1239
|
+
throw _context16.t0;
|
|
1240
|
+
case 11:
|
|
1241
|
+
case "end":
|
|
1242
|
+
return _context16.stop();
|
|
1243
|
+
}
|
|
1244
|
+
}, _callee16, this, [[1, 7]]);
|
|
1245
|
+
}));
|
|
1246
|
+
function onCustomerLogin(_x9) {
|
|
1247
|
+
return _onCustomerLogin.apply(this, arguments);
|
|
1248
|
+
}
|
|
1249
|
+
return onCustomerLogin;
|
|
753
1250
|
}() // ScanOrder 提交 payload enhancer:
|
|
754
1251
|
// - 给所有 booking 注入 appointment_status: 'started'(扫码点餐语义)
|
|
755
1252
|
// - 给所有 booking 的 metadata 注入 resource_select_type(来自预约规则商品的 resource.type)
|
|
@@ -758,6 +1255,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
758
1255
|
}, {
|
|
759
1256
|
key: "buildSubmitPayloadEnhancer",
|
|
760
1257
|
value: function buildSubmitPayloadEnhancer() {
|
|
1258
|
+
var _this5 = this;
|
|
761
1259
|
var ruleProduct = this.enabledReservationRuleProducts[0];
|
|
762
1260
|
var resourceState = this.store.resource;
|
|
763
1261
|
var resourceSelectType = resourceState === null || resourceState === void 0 ? void 0 : resourceState.resourceSelectType;
|
|
@@ -773,10 +1271,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
773
1271
|
}
|
|
774
1272
|
return 1;
|
|
775
1273
|
};
|
|
776
|
-
return function (payload,
|
|
777
|
-
var _tempOrder$resource_i,
|
|
778
|
-
var bookingUuid =
|
|
779
|
-
tempOrder =
|
|
1274
|
+
return function (payload, _ref3) {
|
|
1275
|
+
var _tempOrder$resource_i, _ref4, _pickOriginal, _resourceState$table_2, _resourceState$relati, _tempOrder$metadata, _pickFirstCustomCapac;
|
|
1276
|
+
var bookingUuid = _ref3.bookingUuid,
|
|
1277
|
+
tempOrder = _ref3.tempOrder;
|
|
780
1278
|
var resourceId = (_tempOrder$resource_i = tempOrder.resource_id) !== null && _tempOrder$resource_i !== void 0 ? _tempOrder$resource_i : resourceState === null || resourceState === void 0 ? void 0 : resourceState.relationId;
|
|
781
1279
|
var pickOriginal = function pickOriginal(value) {
|
|
782
1280
|
if (value && _typeof(value) === 'object' && !Array.isArray(value)) {
|
|
@@ -785,7 +1283,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
785
1283
|
}
|
|
786
1284
|
return undefined;
|
|
787
1285
|
};
|
|
788
|
-
var mainField = (
|
|
1286
|
+
var mainField = (_ref4 = (_pickOriginal = pickOriginal(tempOrder.table_number)) !== null && _pickOriginal !== void 0 ? _pickOriginal : pickOriginal(resourceState === null || resourceState === void 0 || (_resourceState$table_2 = resourceState.table_form_record) === null || _resourceState$table_2 === void 0 ? void 0 : _resourceState$table_2.name)) !== null && _ref4 !== void 0 ? _ref4 : '';
|
|
789
1287
|
var resourceEntry = resourceState && resourceId ? {
|
|
790
1288
|
relation_type: 'form',
|
|
791
1289
|
like_status: 'common',
|
|
@@ -797,7 +1295,11 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
797
1295
|
metadata: {}
|
|
798
1296
|
} : undefined;
|
|
799
1297
|
var ruleProductUid = ruleProduct ? createUuidV4() : undefined;
|
|
800
|
-
|
|
1298
|
+
// 默认 resolveResourceCapacity(single 为桌台容量,其余多为 1);有 collect_pax 时 value 优先用人数
|
|
1299
|
+
var rawCollectPax = (_tempOrder$metadata = tempOrder.metadata) === null || _tempOrder$metadata === void 0 ? void 0 : _tempOrder$metadata.collect_pax;
|
|
1300
|
+
var hasCollectPaxForCapacity = rawCollectPax !== null && rawCollectPax !== undefined && rawCollectPax !== '';
|
|
1301
|
+
var bookingCapacityValue = hasCollectPaxForCapacity ? normalizeSubmitCollectPaxValue(rawCollectPax) : resolveResourceCapacity();
|
|
1302
|
+
var bookingCapacityDimensionId = (_pickFirstCustomCapac = pickFirstCustomCapacityDimensionId(_this5.enabledReservationRuleProducts)) !== null && _pickFirstCustomCapac !== void 0 ? _pickFirstCustomCapac : 0;
|
|
801
1303
|
var nextBookings = (payload.bookings || []).map(function (booking, idx) {
|
|
802
1304
|
return _objectSpread(_objectSpread(_objectSpread({}, booking), {}, {
|
|
803
1305
|
appointment_status: 'started',
|
|
@@ -805,7 +1307,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
805
1307
|
resource_select_type: resourceSelectType
|
|
806
1308
|
} : {}), resourceSelectType ? {
|
|
807
1309
|
capacity: [{
|
|
808
|
-
id:
|
|
1310
|
+
id: bookingCapacityDimensionId,
|
|
809
1311
|
value: bookingCapacityValue,
|
|
810
1312
|
name: ''
|
|
811
1313
|
}]
|
|
@@ -817,10 +1319,11 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
817
1319
|
} : {});
|
|
818
1320
|
});
|
|
819
1321
|
var nextProducts = _toConsumableArray(payload.products || []);
|
|
820
|
-
|
|
821
|
-
|
|
1322
|
+
// 加餐(已有 order_id)走 scanOrderMore,原单已含 booking 规则行,勿再追加虚拟规则商品
|
|
1323
|
+
if (ruleProduct && ruleProductUid && !tempOrder.order_id) {
|
|
1324
|
+
var _ruleProduct$price, _ref5, _ruleProduct$original, _ruleProduct$is_gst;
|
|
822
1325
|
var sellingPrice = String((_ruleProduct$price = ruleProduct.price) !== null && _ruleProduct$price !== void 0 ? _ruleProduct$price : '0.00');
|
|
823
|
-
var originalPrice = String((
|
|
1326
|
+
var originalPrice = String((_ref5 = (_ruleProduct$original = ruleProduct.original_price) !== null && _ruleProduct$original !== void 0 ? _ruleProduct$original : ruleProduct.price) !== null && _ref5 !== void 0 ? _ref5 : '0.00');
|
|
824
1327
|
nextProducts.push({
|
|
825
1328
|
product_id: ruleProduct.id,
|
|
826
1329
|
product_variant_id: 0,
|
|
@@ -849,18 +1352,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
849
1352
|
}, {
|
|
850
1353
|
key: "submitScanOrder",
|
|
851
1354
|
value: function () {
|
|
852
|
-
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1355
|
+
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
853
1356
|
var _this$store$resource, _this$otherParams4, _this$otherParams5, _this$otherParams6, _this$otherParams7, _tempOrder$products, pax, tempOrderForSubmit, resourceTableName, enhancePayload, result, tempOrder;
|
|
854
|
-
return _regeneratorRuntime().wrap(function
|
|
855
|
-
while (1) switch (
|
|
1357
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1358
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
856
1359
|
case 0:
|
|
857
1360
|
this.logMethodStart('submitScanOrder');
|
|
858
|
-
|
|
859
|
-
|
|
1361
|
+
_context17.prev = 1;
|
|
1362
|
+
_context17.next = 4;
|
|
860
1363
|
return this.validateBeforeSubmitByItemRule();
|
|
861
1364
|
case 4:
|
|
862
1365
|
if (this.store.order) {
|
|
863
|
-
|
|
1366
|
+
_context17.next = 6;
|
|
864
1367
|
break;
|
|
865
1368
|
}
|
|
866
1369
|
throw new Error('scanOrder解决方案需要 order 模块支持');
|
|
@@ -880,7 +1383,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
880
1383
|
}
|
|
881
1384
|
this.store.order.persistTempOrder();
|
|
882
1385
|
enhancePayload = this.buildSubmitPayloadEnhancer();
|
|
883
|
-
|
|
1386
|
+
_context17.next = 17;
|
|
884
1387
|
return this.store.order.submitTempOrder({
|
|
885
1388
|
cacheId: this.cacheId,
|
|
886
1389
|
platform: (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.platform,
|
|
@@ -890,22 +1393,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
890
1393
|
enhancePayload: enhancePayload
|
|
891
1394
|
});
|
|
892
1395
|
case 17:
|
|
893
|
-
result =
|
|
1396
|
+
result = _context17.sent;
|
|
894
1397
|
tempOrder = this.store.order.getTempOrder();
|
|
895
1398
|
this.logMethodSuccess('submitScanOrder', {
|
|
896
1399
|
productCount: (tempOrder === null || tempOrder === void 0 || (_tempOrder$products = tempOrder.products) === null || _tempOrder$products === void 0 ? void 0 : _tempOrder$products.length) || 0
|
|
897
1400
|
});
|
|
898
|
-
return
|
|
1401
|
+
return _context17.abrupt("return", result);
|
|
899
1402
|
case 23:
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
this.logMethodError('submitScanOrder',
|
|
903
|
-
throw
|
|
1403
|
+
_context17.prev = 23;
|
|
1404
|
+
_context17.t0 = _context17["catch"](1);
|
|
1405
|
+
this.logMethodError('submitScanOrder', _context17.t0);
|
|
1406
|
+
throw _context17.t0;
|
|
904
1407
|
case 27:
|
|
905
1408
|
case "end":
|
|
906
|
-
return
|
|
1409
|
+
return _context17.stop();
|
|
907
1410
|
}
|
|
908
|
-
},
|
|
1411
|
+
}, _callee17, this, [[1, 23]]);
|
|
909
1412
|
}));
|
|
910
1413
|
function submitScanOrder() {
|
|
911
1414
|
return _submitScanOrder.apply(this, arguments);
|
|
@@ -915,48 +1418,48 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
915
1418
|
}, {
|
|
916
1419
|
key: "addProductToOrder",
|
|
917
1420
|
value: function () {
|
|
918
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1421
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(product) {
|
|
919
1422
|
var products;
|
|
920
|
-
return _regeneratorRuntime().wrap(function
|
|
921
|
-
while (1) switch (
|
|
1423
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1424
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
922
1425
|
case 0:
|
|
923
1426
|
this.logMethodStart('addProductToOrder', {
|
|
924
1427
|
product_id: product.product_id,
|
|
925
1428
|
product_variant_id: product.product_variant_id
|
|
926
1429
|
});
|
|
927
|
-
|
|
1430
|
+
_context18.prev = 1;
|
|
928
1431
|
if (this.store.order) {
|
|
929
|
-
|
|
1432
|
+
_context18.next = 4;
|
|
930
1433
|
break;
|
|
931
1434
|
}
|
|
932
1435
|
throw new Error('order 模块未初始化');
|
|
933
1436
|
case 4:
|
|
934
|
-
|
|
1437
|
+
_context18.next = 6;
|
|
935
1438
|
return this.store.order.addProductToOrder(product);
|
|
936
1439
|
case 6:
|
|
937
|
-
products =
|
|
938
|
-
|
|
1440
|
+
products = _context18.sent;
|
|
1441
|
+
_context18.next = 9;
|
|
939
1442
|
return this.refreshItemRuleQuantityLimits();
|
|
940
1443
|
case 9:
|
|
941
|
-
|
|
1444
|
+
_context18.next = 11;
|
|
942
1445
|
return this.refreshCartValidationPassed();
|
|
943
1446
|
case 11:
|
|
944
1447
|
this.logMethodSuccess('addProductToOrder', {
|
|
945
1448
|
productCount: products.length
|
|
946
1449
|
});
|
|
947
|
-
return
|
|
1450
|
+
return _context18.abrupt("return", products);
|
|
948
1451
|
case 15:
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
this.logMethodError('addProductToOrder',
|
|
952
|
-
throw
|
|
1452
|
+
_context18.prev = 15;
|
|
1453
|
+
_context18.t0 = _context18["catch"](1);
|
|
1454
|
+
this.logMethodError('addProductToOrder', _context18.t0);
|
|
1455
|
+
throw _context18.t0;
|
|
953
1456
|
case 19:
|
|
954
1457
|
case "end":
|
|
955
|
-
return
|
|
1458
|
+
return _context18.stop();
|
|
956
1459
|
}
|
|
957
|
-
},
|
|
1460
|
+
}, _callee18, this, [[1, 15]]);
|
|
958
1461
|
}));
|
|
959
|
-
function addProductToOrder(
|
|
1462
|
+
function addProductToOrder(_x10) {
|
|
960
1463
|
return _addProductToOrder.apply(this, arguments);
|
|
961
1464
|
}
|
|
962
1465
|
return addProductToOrder;
|
|
@@ -964,97 +1467,150 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
964
1467
|
}, {
|
|
965
1468
|
key: "updateProductInOrder",
|
|
966
1469
|
value: function () {
|
|
967
|
-
var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1470
|
+
var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
|
|
968
1471
|
var products;
|
|
969
|
-
return _regeneratorRuntime().wrap(function
|
|
970
|
-
while (1) switch (
|
|
1472
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1473
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
971
1474
|
case 0:
|
|
972
1475
|
this.logMethodStart('updateProductInOrder', {
|
|
973
1476
|
product_id: params.product_id,
|
|
974
1477
|
product_variant_id: params.product_variant_id
|
|
975
1478
|
});
|
|
976
|
-
|
|
1479
|
+
_context19.prev = 1;
|
|
977
1480
|
if (this.store.order) {
|
|
978
|
-
|
|
1481
|
+
_context19.next = 4;
|
|
979
1482
|
break;
|
|
980
1483
|
}
|
|
981
1484
|
throw new Error('order 模块未初始化');
|
|
982
1485
|
case 4:
|
|
983
|
-
|
|
1486
|
+
_context19.next = 6;
|
|
984
1487
|
return this.store.order.updateProductInOrder(params);
|
|
985
1488
|
case 6:
|
|
986
|
-
products =
|
|
987
|
-
|
|
1489
|
+
products = _context19.sent;
|
|
1490
|
+
_context19.next = 9;
|
|
988
1491
|
return this.refreshItemRuleQuantityLimits();
|
|
989
1492
|
case 9:
|
|
990
|
-
|
|
1493
|
+
_context19.next = 11;
|
|
991
1494
|
return this.refreshCartValidationPassed();
|
|
992
1495
|
case 11:
|
|
993
1496
|
this.logMethodSuccess('updateProductInOrder', {
|
|
994
1497
|
productCount: products.length
|
|
995
1498
|
});
|
|
996
|
-
return
|
|
1499
|
+
return _context19.abrupt("return", products);
|
|
997
1500
|
case 15:
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
this.logMethodError('updateProductInOrder',
|
|
1001
|
-
throw
|
|
1501
|
+
_context19.prev = 15;
|
|
1502
|
+
_context19.t0 = _context19["catch"](1);
|
|
1503
|
+
this.logMethodError('updateProductInOrder', _context19.t0);
|
|
1504
|
+
throw _context19.t0;
|
|
1002
1505
|
case 19:
|
|
1003
1506
|
case "end":
|
|
1004
|
-
return
|
|
1507
|
+
return _context19.stop();
|
|
1005
1508
|
}
|
|
1006
|
-
},
|
|
1509
|
+
}, _callee19, this, [[1, 15]]);
|
|
1007
1510
|
}));
|
|
1008
|
-
function updateProductInOrder(
|
|
1511
|
+
function updateProductInOrder(_x11) {
|
|
1009
1512
|
return _updateProductInOrder.apply(this, arguments);
|
|
1010
1513
|
}
|
|
1011
1514
|
return updateProductInOrder;
|
|
1012
1515
|
}()
|
|
1516
|
+
/**
|
|
1517
|
+
* 设置单行商品备注(与整单 `updateTempOrderNote` 区分)。
|
|
1518
|
+
* 多行同 SKU 时必须传入与删除/更新一致的 identity(如 `identity_key`)。
|
|
1519
|
+
*/
|
|
1520
|
+
}, {
|
|
1521
|
+
key: "setOrderProductLineNote",
|
|
1522
|
+
value: (function () {
|
|
1523
|
+
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(identity, note) {
|
|
1524
|
+
var params, products;
|
|
1525
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1526
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1527
|
+
case 0:
|
|
1528
|
+
this.logMethodStart('setOrderProductLineNote', {
|
|
1529
|
+
product_id: identity.product_id,
|
|
1530
|
+
product_variant_id: identity.product_variant_id
|
|
1531
|
+
});
|
|
1532
|
+
_context20.prev = 1;
|
|
1533
|
+
params = {
|
|
1534
|
+
product_id: identity.product_id,
|
|
1535
|
+
product_variant_id: identity.product_variant_id,
|
|
1536
|
+
updates: {
|
|
1537
|
+
note: String(note || '')
|
|
1538
|
+
}
|
|
1539
|
+
};
|
|
1540
|
+
if (identity.identity_key !== undefined) params.identity_key = identity.identity_key;
|
|
1541
|
+
if (identity.product_option_item !== undefined) {
|
|
1542
|
+
params.product_option_item = identity.product_option_item;
|
|
1543
|
+
}
|
|
1544
|
+
if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
|
|
1545
|
+
_context20.next = 8;
|
|
1546
|
+
return this.updateProductInOrder(params);
|
|
1547
|
+
case 8:
|
|
1548
|
+
products = _context20.sent;
|
|
1549
|
+
this.logMethodSuccess('setOrderProductLineNote', {
|
|
1550
|
+
productCount: products.length
|
|
1551
|
+
});
|
|
1552
|
+
return _context20.abrupt("return", products);
|
|
1553
|
+
case 13:
|
|
1554
|
+
_context20.prev = 13;
|
|
1555
|
+
_context20.t0 = _context20["catch"](1);
|
|
1556
|
+
this.logMethodError('setOrderProductLineNote', _context20.t0);
|
|
1557
|
+
throw _context20.t0;
|
|
1558
|
+
case 17:
|
|
1559
|
+
case "end":
|
|
1560
|
+
return _context20.stop();
|
|
1561
|
+
}
|
|
1562
|
+
}, _callee20, this, [[1, 13]]);
|
|
1563
|
+
}));
|
|
1564
|
+
function setOrderProductLineNote(_x12, _x13) {
|
|
1565
|
+
return _setOrderProductLineNote.apply(this, arguments);
|
|
1566
|
+
}
|
|
1567
|
+
return setOrderProductLineNote;
|
|
1568
|
+
}())
|
|
1013
1569
|
}, {
|
|
1014
1570
|
key: "removeProductFromOrder",
|
|
1015
1571
|
value: function () {
|
|
1016
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1572
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(identity) {
|
|
1017
1573
|
var products;
|
|
1018
|
-
return _regeneratorRuntime().wrap(function
|
|
1019
|
-
while (1) switch (
|
|
1574
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1575
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1020
1576
|
case 0:
|
|
1021
1577
|
this.logMethodStart('removeProductFromOrder', {
|
|
1022
1578
|
product_id: identity.product_id,
|
|
1023
1579
|
product_variant_id: identity.product_variant_id
|
|
1024
1580
|
});
|
|
1025
|
-
|
|
1581
|
+
_context21.prev = 1;
|
|
1026
1582
|
if (this.store.order) {
|
|
1027
|
-
|
|
1583
|
+
_context21.next = 4;
|
|
1028
1584
|
break;
|
|
1029
1585
|
}
|
|
1030
1586
|
throw new Error('order 模块未初始化');
|
|
1031
1587
|
case 4:
|
|
1032
|
-
|
|
1588
|
+
_context21.next = 6;
|
|
1033
1589
|
return this.store.order.removeProductFromOrder(identity);
|
|
1034
1590
|
case 6:
|
|
1035
|
-
products =
|
|
1036
|
-
|
|
1591
|
+
products = _context21.sent;
|
|
1592
|
+
_context21.next = 9;
|
|
1037
1593
|
return this.refreshItemRuleQuantityLimits();
|
|
1038
1594
|
case 9:
|
|
1039
|
-
|
|
1595
|
+
_context21.next = 11;
|
|
1040
1596
|
return this.refreshCartValidationPassed();
|
|
1041
1597
|
case 11:
|
|
1042
1598
|
this.logMethodSuccess('removeProductFromOrder', {
|
|
1043
1599
|
productCount: products.length
|
|
1044
1600
|
});
|
|
1045
|
-
return
|
|
1601
|
+
return _context21.abrupt("return", products);
|
|
1046
1602
|
case 15:
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
this.logMethodError('removeProductFromOrder',
|
|
1050
|
-
throw
|
|
1603
|
+
_context21.prev = 15;
|
|
1604
|
+
_context21.t0 = _context21["catch"](1);
|
|
1605
|
+
this.logMethodError('removeProductFromOrder', _context21.t0);
|
|
1606
|
+
throw _context21.t0;
|
|
1051
1607
|
case 19:
|
|
1052
1608
|
case "end":
|
|
1053
|
-
return
|
|
1609
|
+
return _context21.stop();
|
|
1054
1610
|
}
|
|
1055
|
-
},
|
|
1611
|
+
}, _callee21, this, [[1, 15]]);
|
|
1056
1612
|
}));
|
|
1057
|
-
function removeProductFromOrder(
|
|
1613
|
+
function removeProductFromOrder(_x14) {
|
|
1058
1614
|
return _removeProductFromOrder.apply(this, arguments);
|
|
1059
1615
|
}
|
|
1060
1616
|
return removeProductFromOrder;
|
|
@@ -1062,26 +1618,26 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1062
1618
|
}, {
|
|
1063
1619
|
key: "loadRuntimeConfigs",
|
|
1064
1620
|
value: function () {
|
|
1065
|
-
var _loadRuntimeConfigs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1621
|
+
var _loadRuntimeConfigs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
|
|
1066
1622
|
var itemRuleConfigs;
|
|
1067
|
-
return _regeneratorRuntime().wrap(function
|
|
1068
|
-
while (1) switch (
|
|
1623
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
1624
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1069
1625
|
case 0:
|
|
1070
|
-
|
|
1626
|
+
_context22.next = 2;
|
|
1071
1627
|
return this.ensureItemRuleConfigsLoaded();
|
|
1072
1628
|
case 2:
|
|
1073
|
-
itemRuleConfigs =
|
|
1629
|
+
itemRuleConfigs = _context22.sent;
|
|
1074
1630
|
this.logMethodSuccess('loadRuntimeConfigs', {
|
|
1075
1631
|
itemRuleCount: itemRuleConfigs.length
|
|
1076
1632
|
});
|
|
1077
|
-
return
|
|
1633
|
+
return _context22.abrupt("return", {
|
|
1078
1634
|
itemRuleConfigs: itemRuleConfigs
|
|
1079
1635
|
});
|
|
1080
1636
|
case 5:
|
|
1081
1637
|
case "end":
|
|
1082
|
-
return
|
|
1638
|
+
return _context22.stop();
|
|
1083
1639
|
}
|
|
1084
|
-
},
|
|
1640
|
+
}, _callee22, this);
|
|
1085
1641
|
}));
|
|
1086
1642
|
function loadRuntimeConfigs() {
|
|
1087
1643
|
return _loadRuntimeConfigs.apply(this, arguments);
|
|
@@ -1091,15 +1647,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1091
1647
|
}, {
|
|
1092
1648
|
key: "syncItemRuleConfigsFromDineInConfig",
|
|
1093
1649
|
value: function () {
|
|
1094
|
-
var _syncItemRuleConfigsFromDineInConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1650
|
+
var _syncItemRuleConfigsFromDineInConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(dineInConfig) {
|
|
1095
1651
|
var enableItemRules, strategyModelIds, itemRuleConfigs;
|
|
1096
|
-
return _regeneratorRuntime().wrap(function
|
|
1097
|
-
while (1) switch (
|
|
1652
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
1653
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1098
1654
|
case 0:
|
|
1099
1655
|
enableItemRules = toBoolean(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['sale.enable_item_rules']);
|
|
1100
1656
|
strategyModelIds = normalizeEnabledItemRuleIds(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['sale.enabled_item_rules']);
|
|
1101
1657
|
if (!(!enableItemRules || !strategyModelIds.length)) {
|
|
1102
|
-
|
|
1658
|
+
_context23.next = 8;
|
|
1103
1659
|
break;
|
|
1104
1660
|
}
|
|
1105
1661
|
this.itemRuleConfigs = [];
|
|
@@ -1110,12 +1666,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1110
1666
|
strategyModelIds: [],
|
|
1111
1667
|
itemRuleCount: 0
|
|
1112
1668
|
});
|
|
1113
|
-
return
|
|
1669
|
+
return _context23.abrupt("return", []);
|
|
1114
1670
|
case 8:
|
|
1115
|
-
|
|
1671
|
+
_context23.next = 10;
|
|
1116
1672
|
return this.fetchItemRuleConfigsByModelIds(strategyModelIds);
|
|
1117
1673
|
case 10:
|
|
1118
|
-
itemRuleConfigs =
|
|
1674
|
+
itemRuleConfigs = _context23.sent;
|
|
1119
1675
|
this.itemRuleConfigs = itemRuleConfigs;
|
|
1120
1676
|
this.itemRuleConfigsPromise = Promise.resolve(itemRuleConfigs);
|
|
1121
1677
|
this.itemRuleEvaluator.setStrategyConfigs(itemRuleConfigs);
|
|
@@ -1124,14 +1680,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1124
1680
|
strategyModelIds: strategyModelIds,
|
|
1125
1681
|
itemRuleCount: itemRuleConfigs.length
|
|
1126
1682
|
});
|
|
1127
|
-
return
|
|
1683
|
+
return _context23.abrupt("return", itemRuleConfigs);
|
|
1128
1684
|
case 16:
|
|
1129
1685
|
case "end":
|
|
1130
|
-
return
|
|
1686
|
+
return _context23.stop();
|
|
1131
1687
|
}
|
|
1132
|
-
},
|
|
1688
|
+
}, _callee23, this);
|
|
1133
1689
|
}));
|
|
1134
|
-
function syncItemRuleConfigsFromDineInConfig(
|
|
1690
|
+
function syncItemRuleConfigsFromDineInConfig(_x15) {
|
|
1135
1691
|
return _syncItemRuleConfigsFromDineInConfig.apply(this, arguments);
|
|
1136
1692
|
}
|
|
1137
1693
|
return syncItemRuleConfigsFromDineInConfig;
|
|
@@ -1139,22 +1695,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1139
1695
|
}, {
|
|
1140
1696
|
key: "fetchItemRuleConfigsByModelIds",
|
|
1141
1697
|
value: function () {
|
|
1142
|
-
var _fetchItemRuleConfigsByModelIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1698
|
+
var _fetchItemRuleConfigsByModelIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(strategyModelIds) {
|
|
1143
1699
|
var result, configs;
|
|
1144
|
-
return _regeneratorRuntime().wrap(function
|
|
1145
|
-
while (1) switch (
|
|
1700
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
1701
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1146
1702
|
case 0:
|
|
1147
1703
|
this.logMethodStart('fetchItemRuleConfigsByModelIds', {
|
|
1148
1704
|
strategyModelIds: strategyModelIds
|
|
1149
1705
|
});
|
|
1150
1706
|
if (strategyModelIds.length) {
|
|
1151
|
-
|
|
1707
|
+
_context24.next = 3;
|
|
1152
1708
|
break;
|
|
1153
1709
|
}
|
|
1154
|
-
return
|
|
1710
|
+
return _context24.abrupt("return", []);
|
|
1155
1711
|
case 3:
|
|
1156
|
-
|
|
1157
|
-
|
|
1712
|
+
_context24.prev = 3;
|
|
1713
|
+
_context24.next = 6;
|
|
1158
1714
|
return this.request.get('/promotion', {
|
|
1159
1715
|
skip: 1,
|
|
1160
1716
|
num: 99,
|
|
@@ -1162,7 +1718,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1162
1718
|
ids: strategyModelIds
|
|
1163
1719
|
});
|
|
1164
1720
|
case 6:
|
|
1165
|
-
result =
|
|
1721
|
+
result = _context24.sent;
|
|
1166
1722
|
configs = [];
|
|
1167
1723
|
if (result.code === 200) {
|
|
1168
1724
|
configs = result.data.list.map(function (item) {
|
|
@@ -1173,22 +1729,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1173
1729
|
strategyModelIds: strategyModelIds,
|
|
1174
1730
|
strategyCount: configs.length
|
|
1175
1731
|
});
|
|
1176
|
-
return
|
|
1732
|
+
return _context24.abrupt("return", configs);
|
|
1177
1733
|
case 13:
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
this.logMethodError('fetchItemRuleConfigsByModelIds',
|
|
1734
|
+
_context24.prev = 13;
|
|
1735
|
+
_context24.t0 = _context24["catch"](3);
|
|
1736
|
+
this.logMethodError('fetchItemRuleConfigsByModelIds', _context24.t0, {
|
|
1181
1737
|
strategyModelIds: strategyModelIds
|
|
1182
1738
|
});
|
|
1183
1739
|
// A:策略加载失败时不阻塞下单
|
|
1184
|
-
return
|
|
1740
|
+
return _context24.abrupt("return", []);
|
|
1185
1741
|
case 17:
|
|
1186
1742
|
case "end":
|
|
1187
|
-
return
|
|
1743
|
+
return _context24.stop();
|
|
1188
1744
|
}
|
|
1189
|
-
},
|
|
1745
|
+
}, _callee24, this, [[3, 13]]);
|
|
1190
1746
|
}));
|
|
1191
|
-
function fetchItemRuleConfigsByModelIds(
|
|
1747
|
+
function fetchItemRuleConfigsByModelIds(_x16) {
|
|
1192
1748
|
return _fetchItemRuleConfigsByModelIds.apply(this, arguments);
|
|
1193
1749
|
}
|
|
1194
1750
|
return fetchItemRuleConfigsByModelIds;
|
|
@@ -1196,22 +1752,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1196
1752
|
}, {
|
|
1197
1753
|
key: "buildPrefillProductSourceMap",
|
|
1198
1754
|
value: function () {
|
|
1199
|
-
var _buildPrefillProductSourceMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1755
|
+
var _buildPrefillProductSourceMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
|
|
1200
1756
|
var sourceMap, productList, visited, collectFromValue;
|
|
1201
|
-
return _regeneratorRuntime().wrap(function
|
|
1202
|
-
while (1) switch (
|
|
1757
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
1758
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
1203
1759
|
case 0:
|
|
1204
1760
|
sourceMap = new Map();
|
|
1205
|
-
|
|
1206
|
-
|
|
1761
|
+
_context25.prev = 1;
|
|
1762
|
+
_context25.next = 4;
|
|
1207
1763
|
return this.getProductList();
|
|
1208
1764
|
case 4:
|
|
1209
|
-
productList =
|
|
1765
|
+
productList = _context25.sent;
|
|
1210
1766
|
if (Array.isArray(productList)) {
|
|
1211
|
-
|
|
1767
|
+
_context25.next = 7;
|
|
1212
1768
|
break;
|
|
1213
1769
|
}
|
|
1214
|
-
return
|
|
1770
|
+
return _context25.abrupt("return", sourceMap);
|
|
1215
1771
|
case 7:
|
|
1216
1772
|
visited = new Set();
|
|
1217
1773
|
collectFromValue = function collectFromValue(value) {
|
|
@@ -1220,17 +1776,17 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1220
1776
|
if (visited.has(value)) return;
|
|
1221
1777
|
visited.add(value);
|
|
1222
1778
|
if (Array.isArray(value)) {
|
|
1223
|
-
var
|
|
1224
|
-
|
|
1779
|
+
var _iterator4 = _createForOfIteratorHelper(value),
|
|
1780
|
+
_step4;
|
|
1225
1781
|
try {
|
|
1226
|
-
for (
|
|
1227
|
-
var item =
|
|
1782
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
1783
|
+
var item = _step4.value;
|
|
1228
1784
|
collectFromValue(item);
|
|
1229
1785
|
}
|
|
1230
1786
|
} catch (err) {
|
|
1231
|
-
|
|
1787
|
+
_iterator4.e(err);
|
|
1232
1788
|
} finally {
|
|
1233
|
-
|
|
1789
|
+
_iterator4.f();
|
|
1234
1790
|
}
|
|
1235
1791
|
return;
|
|
1236
1792
|
}
|
|
@@ -1238,35 +1794,35 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1238
1794
|
var rawProductId = (_node$product_id = node.product_id) !== null && _node$product_id !== void 0 ? _node$product_id : node.id;
|
|
1239
1795
|
var productId = Number(rawProductId);
|
|
1240
1796
|
if (Number.isFinite(productId) && productId > 0) {
|
|
1241
|
-
var
|
|
1242
|
-
var productVariantId = Number((
|
|
1797
|
+
var _ref6, _node$product_variant;
|
|
1798
|
+
var productVariantId = Number((_ref6 = (_node$product_variant = node.product_variant_id) !== null && _node$product_variant !== void 0 ? _node$product_variant : node.variant_id) !== null && _ref6 !== void 0 ? _ref6 : 0);
|
|
1243
1799
|
var normalizedVariantId = Number.isNaN(productVariantId) ? 0 : productVariantId;
|
|
1244
1800
|
var key = buildProductKey(productId, normalizedVariantId);
|
|
1245
1801
|
if (!sourceMap.has(key)) {
|
|
1246
1802
|
sourceMap.set(key, node);
|
|
1247
1803
|
}
|
|
1248
1804
|
}
|
|
1249
|
-
for (var
|
|
1250
|
-
var childValue = _Object$values[
|
|
1805
|
+
for (var _i3 = 0, _Object$values = Object.values(node); _i3 < _Object$values.length; _i3++) {
|
|
1806
|
+
var childValue = _Object$values[_i3];
|
|
1251
1807
|
if (childValue && _typeof(childValue) === 'object') {
|
|
1252
1808
|
collectFromValue(childValue);
|
|
1253
1809
|
}
|
|
1254
1810
|
}
|
|
1255
1811
|
};
|
|
1256
1812
|
collectFromValue(productList);
|
|
1257
|
-
|
|
1813
|
+
_context25.next = 15;
|
|
1258
1814
|
break;
|
|
1259
1815
|
case 12:
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
this.logMethodError('buildPrefillProductSourceMap',
|
|
1816
|
+
_context25.prev = 12;
|
|
1817
|
+
_context25.t0 = _context25["catch"](1);
|
|
1818
|
+
this.logMethodError('buildPrefillProductSourceMap', _context25.t0);
|
|
1263
1819
|
case 15:
|
|
1264
|
-
return
|
|
1820
|
+
return _context25.abrupt("return", sourceMap);
|
|
1265
1821
|
case 16:
|
|
1266
1822
|
case "end":
|
|
1267
|
-
return
|
|
1823
|
+
return _context25.stop();
|
|
1268
1824
|
}
|
|
1269
|
-
},
|
|
1825
|
+
}, _callee25, this, [[1, 12]]);
|
|
1270
1826
|
}));
|
|
1271
1827
|
function buildPrefillProductSourceMap() {
|
|
1272
1828
|
return _buildPrefillProductSourceMap.apply(this, arguments);
|
|
@@ -1281,58 +1837,58 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1281
1837
|
}, {
|
|
1282
1838
|
key: "ensureItemRuleConfigsLoaded",
|
|
1283
1839
|
value: function () {
|
|
1284
|
-
var _ensureItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1285
|
-
var
|
|
1840
|
+
var _ensureItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
|
|
1841
|
+
var _this6 = this;
|
|
1286
1842
|
var loadedConfigs;
|
|
1287
|
-
return _regeneratorRuntime().wrap(function
|
|
1288
|
-
while (1) switch (
|
|
1843
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
1844
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
1289
1845
|
case 0:
|
|
1290
1846
|
if (!(this.itemRuleConfigs.length > 0)) {
|
|
1291
|
-
|
|
1847
|
+
_context27.next = 2;
|
|
1292
1848
|
break;
|
|
1293
1849
|
}
|
|
1294
|
-
return
|
|
1850
|
+
return _context27.abrupt("return", this.itemRuleConfigs);
|
|
1295
1851
|
case 2:
|
|
1296
1852
|
if (!this.itemRuleConfigsPromise) {
|
|
1297
|
-
|
|
1853
|
+
_context27.next = 4;
|
|
1298
1854
|
break;
|
|
1299
1855
|
}
|
|
1300
|
-
return
|
|
1856
|
+
return _context27.abrupt("return", this.itemRuleConfigsPromise);
|
|
1301
1857
|
case 4:
|
|
1302
|
-
this.itemRuleConfigsPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1858
|
+
this.itemRuleConfigsPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
|
|
1303
1859
|
var runtimeConfig, staticConfigs;
|
|
1304
|
-
return _regeneratorRuntime().wrap(function
|
|
1305
|
-
while (1) switch (
|
|
1860
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
1861
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
1306
1862
|
case 0:
|
|
1307
|
-
runtimeConfig =
|
|
1863
|
+
runtimeConfig = _this6.getItemRuleRuntimeConfig();
|
|
1308
1864
|
staticConfigs = normalizeItemRuleStrategies(runtimeConfig.strategyConfigs);
|
|
1309
1865
|
if (!(staticConfigs.length > 0)) {
|
|
1310
|
-
|
|
1866
|
+
_context26.next = 6;
|
|
1311
1867
|
break;
|
|
1312
1868
|
}
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
return
|
|
1869
|
+
_this6.itemRuleConfigs = staticConfigs;
|
|
1870
|
+
_this6.itemRuleEvaluator.setStrategyConfigs(staticConfigs);
|
|
1871
|
+
return _context26.abrupt("return", _this6.itemRuleConfigs);
|
|
1316
1872
|
case 6:
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
return
|
|
1873
|
+
_this6.itemRuleConfigs = [];
|
|
1874
|
+
_this6.itemRuleEvaluator.setStrategyConfigs([]);
|
|
1875
|
+
return _context26.abrupt("return", _this6.itemRuleConfigs);
|
|
1320
1876
|
case 9:
|
|
1321
1877
|
case "end":
|
|
1322
|
-
return
|
|
1878
|
+
return _context26.stop();
|
|
1323
1879
|
}
|
|
1324
|
-
},
|
|
1880
|
+
}, _callee26);
|
|
1325
1881
|
}))();
|
|
1326
|
-
|
|
1882
|
+
_context27.next = 7;
|
|
1327
1883
|
return this.itemRuleConfigsPromise;
|
|
1328
1884
|
case 7:
|
|
1329
|
-
loadedConfigs =
|
|
1330
|
-
return
|
|
1885
|
+
loadedConfigs = _context27.sent;
|
|
1886
|
+
return _context27.abrupt("return", loadedConfigs);
|
|
1331
1887
|
case 9:
|
|
1332
1888
|
case "end":
|
|
1333
|
-
return
|
|
1889
|
+
return _context27.stop();
|
|
1334
1890
|
}
|
|
1335
|
-
},
|
|
1891
|
+
}, _callee27, this);
|
|
1336
1892
|
}));
|
|
1337
1893
|
function ensureItemRuleConfigsLoaded() {
|
|
1338
1894
|
return _ensureItemRuleConfigsLoaded.apply(this, arguments);
|
|
@@ -1342,22 +1898,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1342
1898
|
}, {
|
|
1343
1899
|
key: "refreshItemRuleQuantityLimits",
|
|
1344
1900
|
value: function () {
|
|
1345
|
-
var _refreshItemRuleQuantityLimits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1901
|
+
var _refreshItemRuleQuantityLimits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
|
|
1346
1902
|
var strategyConfigs, businessData, limits;
|
|
1347
|
-
return _regeneratorRuntime().wrap(function
|
|
1348
|
-
while (1) switch (
|
|
1903
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
1904
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
1349
1905
|
case 0:
|
|
1350
|
-
|
|
1351
|
-
|
|
1906
|
+
_context28.prev = 0;
|
|
1907
|
+
_context28.next = 3;
|
|
1352
1908
|
return this.ensureItemRuleConfigsLoaded();
|
|
1353
1909
|
case 3:
|
|
1354
|
-
strategyConfigs =
|
|
1910
|
+
strategyConfigs = _context28.sent;
|
|
1355
1911
|
if (strategyConfigs.length) {
|
|
1356
|
-
|
|
1912
|
+
_context28.next = 7;
|
|
1357
1913
|
break;
|
|
1358
1914
|
}
|
|
1359
1915
|
this.store.itemRuleQuantityLimits = [];
|
|
1360
|
-
return
|
|
1916
|
+
return _context28.abrupt("return", []);
|
|
1361
1917
|
case 7:
|
|
1362
1918
|
businessData = buildItemRuleBusinessData({
|
|
1363
1919
|
tempOrder: this.ensureTempOrder(),
|
|
@@ -1369,18 +1925,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1369
1925
|
this.logMethodSuccess('refreshItemRuleQuantityLimits', {
|
|
1370
1926
|
limitCount: limits.length
|
|
1371
1927
|
});
|
|
1372
|
-
return
|
|
1928
|
+
return _context28.abrupt("return", limits);
|
|
1373
1929
|
case 14:
|
|
1374
|
-
|
|
1375
|
-
|
|
1930
|
+
_context28.prev = 14;
|
|
1931
|
+
_context28.t0 = _context28["catch"](0);
|
|
1376
1932
|
this.store.itemRuleQuantityLimits = [];
|
|
1377
|
-
this.logMethodError('refreshItemRuleQuantityLimits',
|
|
1378
|
-
return
|
|
1933
|
+
this.logMethodError('refreshItemRuleQuantityLimits', _context28.t0);
|
|
1934
|
+
return _context28.abrupt("return", []);
|
|
1379
1935
|
case 19:
|
|
1380
1936
|
case "end":
|
|
1381
|
-
return
|
|
1937
|
+
return _context28.stop();
|
|
1382
1938
|
}
|
|
1383
|
-
},
|
|
1939
|
+
}, _callee28, this, [[0, 14]]);
|
|
1384
1940
|
}));
|
|
1385
1941
|
function refreshItemRuleQuantityLimits() {
|
|
1386
1942
|
return _refreshItemRuleQuantityLimits.apply(this, arguments);
|
|
@@ -1390,32 +1946,32 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1390
1946
|
}, {
|
|
1391
1947
|
key: "applyPrefillByItemRule",
|
|
1392
1948
|
value: function () {
|
|
1393
|
-
var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1394
|
-
var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges,
|
|
1395
|
-
return _regeneratorRuntime().wrap(function
|
|
1396
|
-
while (1) switch (
|
|
1949
|
+
var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
|
|
1950
|
+
var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges, _iterator5, _step5, _prefillItem$product_, _targetProduct$_origi, _targetProduct$_origi2, _targetProduct$_origi3, prefillItem, productId, productVariantId, targetQuantity, sourceItem, productIndex, _sourceItem$price, sellingPrice, targetProduct, existedQuantity, delta, nextProduct, hasQuantityChanged, hasOriginChanged;
|
|
1951
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
1952
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
1397
1953
|
case 0:
|
|
1398
1954
|
if (!this.itemRulePrefillApplied) {
|
|
1399
|
-
|
|
1955
|
+
_context29.next = 2;
|
|
1400
1956
|
break;
|
|
1401
1957
|
}
|
|
1402
|
-
return
|
|
1958
|
+
return _context29.abrupt("return");
|
|
1403
1959
|
case 2:
|
|
1404
1960
|
if (this.store.order) {
|
|
1405
|
-
|
|
1961
|
+
_context29.next = 4;
|
|
1406
1962
|
break;
|
|
1407
1963
|
}
|
|
1408
|
-
return
|
|
1964
|
+
return _context29.abrupt("return");
|
|
1409
1965
|
case 4:
|
|
1410
|
-
|
|
1966
|
+
_context29.next = 6;
|
|
1411
1967
|
return this.ensureItemRuleConfigsLoaded();
|
|
1412
1968
|
case 6:
|
|
1413
|
-
strategyConfigs =
|
|
1969
|
+
strategyConfigs = _context29.sent;
|
|
1414
1970
|
if (strategyConfigs.length) {
|
|
1415
|
-
|
|
1971
|
+
_context29.next = 9;
|
|
1416
1972
|
break;
|
|
1417
1973
|
}
|
|
1418
|
-
return
|
|
1974
|
+
return _context29.abrupt("return");
|
|
1419
1975
|
case 9:
|
|
1420
1976
|
businessData = buildItemRuleBusinessData({
|
|
1421
1977
|
tempOrder: this.ensureTempOrder(),
|
|
@@ -1424,41 +1980,41 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1424
1980
|
});
|
|
1425
1981
|
prefillItems = this.itemRuleEvaluator.getPrefillItems(businessData);
|
|
1426
1982
|
if (prefillItems.length) {
|
|
1427
|
-
|
|
1983
|
+
_context29.next = 14;
|
|
1428
1984
|
break;
|
|
1429
1985
|
}
|
|
1430
1986
|
this.itemRulePrefillApplied = true;
|
|
1431
|
-
return
|
|
1987
|
+
return _context29.abrupt("return");
|
|
1432
1988
|
case 14:
|
|
1433
|
-
|
|
1989
|
+
_context29.next = 16;
|
|
1434
1990
|
return this.buildPrefillProductSourceMap();
|
|
1435
1991
|
case 16:
|
|
1436
|
-
productSourceMap =
|
|
1992
|
+
productSourceMap = _context29.sent;
|
|
1437
1993
|
tempOrder = this.ensureTempOrder();
|
|
1438
1994
|
hasChanges = false;
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1995
|
+
_iterator5 = _createForOfIteratorHelper(prefillItems);
|
|
1996
|
+
_context29.prev = 20;
|
|
1997
|
+
_iterator5.s();
|
|
1442
1998
|
case 22:
|
|
1443
|
-
if ((
|
|
1444
|
-
|
|
1999
|
+
if ((_step5 = _iterator5.n()).done) {
|
|
2000
|
+
_context29.next = 47;
|
|
1445
2001
|
break;
|
|
1446
2002
|
}
|
|
1447
|
-
prefillItem =
|
|
2003
|
+
prefillItem = _step5.value;
|
|
1448
2004
|
productId = Number(prefillItem.product_id);
|
|
1449
2005
|
productVariantId = Number((_prefillItem$product_ = prefillItem.product_variant_id) !== null && _prefillItem$product_ !== void 0 ? _prefillItem$product_ : 0);
|
|
1450
2006
|
targetQuantity = toNonNegativeInt(prefillItem.quantity);
|
|
1451
2007
|
if (!(!Number.isFinite(productId) || targetQuantity <= 0)) {
|
|
1452
|
-
|
|
2008
|
+
_context29.next = 29;
|
|
1453
2009
|
break;
|
|
1454
2010
|
}
|
|
1455
|
-
return
|
|
2011
|
+
return _context29.abrupt("continue", 45);
|
|
1456
2012
|
case 29:
|
|
1457
2013
|
if (!Number.isNaN(productVariantId)) {
|
|
1458
|
-
|
|
2014
|
+
_context29.next = 31;
|
|
1459
2015
|
break;
|
|
1460
2016
|
}
|
|
1461
|
-
return
|
|
2017
|
+
return _context29.abrupt("continue", 45);
|
|
1462
2018
|
case 31:
|
|
1463
2019
|
sourceItem = productSourceMap.get(buildProductKey(productId, productVariantId)) || productSourceMap.get(buildProductKey(productId, 0)) || null;
|
|
1464
2020
|
productIndex = getProductIdentityIndex(tempOrder.products, {
|
|
@@ -1466,7 +2022,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1466
2022
|
product_variant_id: productVariantId
|
|
1467
2023
|
});
|
|
1468
2024
|
if (!(productIndex === -1)) {
|
|
1469
|
-
|
|
2025
|
+
_context29.next = 38;
|
|
1470
2026
|
break;
|
|
1471
2027
|
}
|
|
1472
2028
|
sellingPrice = toPriceString((_sourceItem$price = sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.price) !== null && _sourceItem$price !== void 0 ? _sourceItem$price : sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.selling_price, '0.00');
|
|
@@ -1486,7 +2042,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1486
2042
|
})
|
|
1487
2043
|
})));
|
|
1488
2044
|
hasChanges = true;
|
|
1489
|
-
return
|
|
2045
|
+
return _context29.abrupt("continue", 45);
|
|
1490
2046
|
case 38:
|
|
1491
2047
|
targetProduct = tempOrder.products[productIndex];
|
|
1492
2048
|
existedQuantity = toNonNegativeInt(targetProduct.num);
|
|
@@ -1507,34 +2063,34 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1507
2063
|
hasChanges = true;
|
|
1508
2064
|
}
|
|
1509
2065
|
case 45:
|
|
1510
|
-
|
|
2066
|
+
_context29.next = 22;
|
|
1511
2067
|
break;
|
|
1512
2068
|
case 47:
|
|
1513
|
-
|
|
2069
|
+
_context29.next = 52;
|
|
1514
2070
|
break;
|
|
1515
2071
|
case 49:
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
2072
|
+
_context29.prev = 49;
|
|
2073
|
+
_context29.t0 = _context29["catch"](20);
|
|
2074
|
+
_iterator5.e(_context29.t0);
|
|
1519
2075
|
case 52:
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
return
|
|
2076
|
+
_context29.prev = 52;
|
|
2077
|
+
_iterator5.f();
|
|
2078
|
+
return _context29.finish(52);
|
|
1523
2079
|
case 55:
|
|
1524
2080
|
if (!hasChanges) {
|
|
1525
|
-
|
|
2081
|
+
_context29.next = 60;
|
|
1526
2082
|
break;
|
|
1527
2083
|
}
|
|
1528
2084
|
// Prefill 属于 products CRUD 的一种形式:新增后让 Rules 重算,以支持自动应用可用优惠券。
|
|
1529
2085
|
this.store.order.applyDiscount();
|
|
1530
|
-
|
|
2086
|
+
_context29.next = 59;
|
|
1531
2087
|
return this.store.order.recalculateSummary({
|
|
1532
2088
|
createIfMissing: true
|
|
1533
2089
|
});
|
|
1534
2090
|
case 59:
|
|
1535
2091
|
this.store.order.persistTempOrder();
|
|
1536
2092
|
case 60:
|
|
1537
|
-
|
|
2093
|
+
_context29.next = 62;
|
|
1538
2094
|
return this.refreshItemRuleQuantityLimits();
|
|
1539
2095
|
case 62:
|
|
1540
2096
|
this.itemRulePrefillApplied = true;
|
|
@@ -1544,9 +2100,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1544
2100
|
});
|
|
1545
2101
|
case 64:
|
|
1546
2102
|
case "end":
|
|
1547
|
-
return
|
|
2103
|
+
return _context29.stop();
|
|
1548
2104
|
}
|
|
1549
|
-
},
|
|
2105
|
+
}, _callee29, this, [[20, 49, 52, 55]]);
|
|
1550
2106
|
}));
|
|
1551
2107
|
function applyPrefillByItemRule() {
|
|
1552
2108
|
return _applyPrefillByItemRule.apply(this, arguments);
|
|
@@ -1556,31 +2112,31 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1556
2112
|
}, {
|
|
1557
2113
|
key: "applyItemRulePrefill",
|
|
1558
2114
|
value: function () {
|
|
1559
|
-
var _applyItemRulePrefill = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2115
|
+
var _applyItemRulePrefill = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
|
|
1560
2116
|
var _this$store$order4, _this$store$order4$ge;
|
|
1561
|
-
return _regeneratorRuntime().wrap(function
|
|
1562
|
-
while (1) switch (
|
|
2117
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2118
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
1563
2119
|
case 0:
|
|
1564
2120
|
if (!((_this$store$order4 = this.store.order) !== null && _this$store$order4 !== void 0 && (_this$store$order4$ge = _this$store$order4.getLastOrderInfo) !== null && _this$store$order4$ge !== void 0 && _this$store$order4$ge.call(_this$store$order4))) {
|
|
1565
|
-
|
|
2121
|
+
_context30.next = 2;
|
|
1566
2122
|
break;
|
|
1567
2123
|
}
|
|
1568
|
-
return
|
|
2124
|
+
return _context30.abrupt("return");
|
|
1569
2125
|
case 2:
|
|
1570
2126
|
this.logMethodStart('applyItemRulePrefill');
|
|
1571
|
-
|
|
2127
|
+
_context30.next = 5;
|
|
1572
2128
|
return this.applyPrefillByItemRule();
|
|
1573
2129
|
case 5:
|
|
1574
|
-
|
|
2130
|
+
_context30.next = 7;
|
|
1575
2131
|
return this.refreshItemRuleQuantityLimits();
|
|
1576
2132
|
case 7:
|
|
1577
|
-
|
|
2133
|
+
_context30.next = 9;
|
|
1578
2134
|
return this.refreshCartValidationPassed();
|
|
1579
2135
|
case 9:
|
|
1580
2136
|
case "end":
|
|
1581
|
-
return
|
|
2137
|
+
return _context30.stop();
|
|
1582
2138
|
}
|
|
1583
|
-
},
|
|
2139
|
+
}, _callee30, this);
|
|
1584
2140
|
}));
|
|
1585
2141
|
function applyItemRulePrefill() {
|
|
1586
2142
|
return _applyItemRulePrefill.apply(this, arguments);
|
|
@@ -1590,20 +2146,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1590
2146
|
}, {
|
|
1591
2147
|
key: "evaluateCartValidationByItemRule",
|
|
1592
2148
|
value: function () {
|
|
1593
|
-
var _evaluateCartValidationByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2149
|
+
var _evaluateCartValidationByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
|
|
1594
2150
|
var strategyConfigs, businessData;
|
|
1595
|
-
return _regeneratorRuntime().wrap(function
|
|
1596
|
-
while (1) switch (
|
|
2151
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
2152
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
1597
2153
|
case 0:
|
|
1598
|
-
|
|
2154
|
+
_context31.next = 2;
|
|
1599
2155
|
return this.ensureItemRuleConfigsLoaded();
|
|
1600
2156
|
case 2:
|
|
1601
|
-
strategyConfigs =
|
|
2157
|
+
strategyConfigs = _context31.sent;
|
|
1602
2158
|
if (strategyConfigs.length) {
|
|
1603
|
-
|
|
2159
|
+
_context31.next = 5;
|
|
1604
2160
|
break;
|
|
1605
2161
|
}
|
|
1606
|
-
return
|
|
2162
|
+
return _context31.abrupt("return", {
|
|
1607
2163
|
passed: true,
|
|
1608
2164
|
failures: []
|
|
1609
2165
|
});
|
|
@@ -1613,12 +2169,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1613
2169
|
runtimeConfig: this.getItemRuleRuntimeConfig(),
|
|
1614
2170
|
itemRuleConfigs: this.itemRuleConfigs
|
|
1615
2171
|
});
|
|
1616
|
-
return
|
|
2172
|
+
return _context31.abrupt("return", this.itemRuleEvaluator.validateCart(businessData));
|
|
1617
2173
|
case 7:
|
|
1618
2174
|
case "end":
|
|
1619
|
-
return
|
|
2175
|
+
return _context31.stop();
|
|
1620
2176
|
}
|
|
1621
|
-
},
|
|
2177
|
+
}, _callee31, this);
|
|
1622
2178
|
}));
|
|
1623
2179
|
function evaluateCartValidationByItemRule() {
|
|
1624
2180
|
return _evaluateCartValidationByItemRule.apply(this, arguments);
|
|
@@ -1628,20 +2184,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1628
2184
|
}, {
|
|
1629
2185
|
key: "validateBeforeSubmitByItemRule",
|
|
1630
2186
|
value: function () {
|
|
1631
|
-
var _validateBeforeSubmitByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2187
|
+
var _validateBeforeSubmitByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
|
|
1632
2188
|
var validationResult, firstFailure, errorMessage, error;
|
|
1633
|
-
return _regeneratorRuntime().wrap(function
|
|
1634
|
-
while (1) switch (
|
|
2189
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
2190
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
1635
2191
|
case 0:
|
|
1636
|
-
|
|
2192
|
+
_context32.next = 2;
|
|
1637
2193
|
return this.evaluateCartValidationByItemRule();
|
|
1638
2194
|
case 2:
|
|
1639
|
-
validationResult =
|
|
2195
|
+
validationResult = _context32.sent;
|
|
1640
2196
|
if (!validationResult.passed) {
|
|
1641
|
-
|
|
2197
|
+
_context32.next = 5;
|
|
1642
2198
|
break;
|
|
1643
2199
|
}
|
|
1644
|
-
return
|
|
2200
|
+
return _context32.abrupt("return");
|
|
1645
2201
|
case 5:
|
|
1646
2202
|
firstFailure = validationResult.failures[0];
|
|
1647
2203
|
errorMessage = (firstFailure === null || firstFailure === void 0 ? void 0 : firstFailure.validationMessage) || '当前购物车未满足商品规则,请调整后再提交';
|
|
@@ -1650,9 +2206,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1650
2206
|
throw error;
|
|
1651
2207
|
case 10:
|
|
1652
2208
|
case "end":
|
|
1653
|
-
return
|
|
2209
|
+
return _context32.stop();
|
|
1654
2210
|
}
|
|
1655
|
-
},
|
|
2211
|
+
}, _callee32, this);
|
|
1656
2212
|
}));
|
|
1657
2213
|
function validateBeforeSubmitByItemRule() {
|
|
1658
2214
|
return _validateBeforeSubmitByItemRule.apply(this, arguments);
|
|
@@ -1662,10 +2218,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1662
2218
|
}, {
|
|
1663
2219
|
key: "refreshCartValidationPassed",
|
|
1664
2220
|
value: function () {
|
|
1665
|
-
var _refreshCartValidationPassed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2221
|
+
var _refreshCartValidationPassed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
|
|
1666
2222
|
var previous, nextState, validationResult, changed;
|
|
1667
|
-
return _regeneratorRuntime().wrap(function
|
|
1668
|
-
while (1) switch (
|
|
2223
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
2224
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
1669
2225
|
case 0:
|
|
1670
2226
|
previous = this.store.cartValidation || {
|
|
1671
2227
|
passed: null,
|
|
@@ -1675,20 +2231,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1675
2231
|
passed: null,
|
|
1676
2232
|
failures: []
|
|
1677
2233
|
};
|
|
1678
|
-
|
|
1679
|
-
|
|
2234
|
+
_context33.prev = 2;
|
|
2235
|
+
_context33.next = 5;
|
|
1680
2236
|
return this.evaluateCartValidationByItemRule();
|
|
1681
2237
|
case 5:
|
|
1682
|
-
validationResult =
|
|
2238
|
+
validationResult = _context33.sent;
|
|
1683
2239
|
nextState = {
|
|
1684
2240
|
passed: validationResult.passed,
|
|
1685
2241
|
failures: validationResult.failures || []
|
|
1686
2242
|
};
|
|
1687
|
-
|
|
2243
|
+
_context33.next = 12;
|
|
1688
2244
|
break;
|
|
1689
2245
|
case 9:
|
|
1690
|
-
|
|
1691
|
-
|
|
2246
|
+
_context33.prev = 9;
|
|
2247
|
+
_context33.t0 = _context33["catch"](2);
|
|
1692
2248
|
nextState = {
|
|
1693
2249
|
passed: false,
|
|
1694
2250
|
failures: []
|
|
@@ -1697,21 +2253,21 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1697
2253
|
this.store.cartValidation = nextState;
|
|
1698
2254
|
changed = previous.passed !== nextState.passed || previous.failures !== nextState.failures;
|
|
1699
2255
|
if (!changed) {
|
|
1700
|
-
|
|
2256
|
+
_context33.next = 17;
|
|
1701
2257
|
break;
|
|
1702
2258
|
}
|
|
1703
|
-
|
|
2259
|
+
_context33.next = 17;
|
|
1704
2260
|
return this.core.effects.emit(ScanOrderHooks.onCartValidationChanged, {
|
|
1705
2261
|
cartValidation: nextState,
|
|
1706
2262
|
cartValidationPassed: nextState.passed
|
|
1707
2263
|
});
|
|
1708
2264
|
case 17:
|
|
1709
|
-
return
|
|
2265
|
+
return _context33.abrupt("return", nextState.passed);
|
|
1710
2266
|
case 18:
|
|
1711
2267
|
case "end":
|
|
1712
|
-
return
|
|
2268
|
+
return _context33.stop();
|
|
1713
2269
|
}
|
|
1714
|
-
},
|
|
2270
|
+
}, _callee33, this, [[2, 9]]);
|
|
1715
2271
|
}));
|
|
1716
2272
|
function refreshCartValidationPassed() {
|
|
1717
2273
|
return _refreshCartValidationPassed.apply(this, arguments);
|
|
@@ -1721,14 +2277,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1721
2277
|
}, {
|
|
1722
2278
|
key: "setItemRuleRuntimeConfig",
|
|
1723
2279
|
value: function () {
|
|
1724
|
-
var _setItemRuleRuntimeConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2280
|
+
var _setItemRuleRuntimeConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
|
|
1725
2281
|
var _this$itemRuleRuntime, _this$itemRuleRuntime2;
|
|
1726
2282
|
var config,
|
|
1727
|
-
|
|
1728
|
-
return _regeneratorRuntime().wrap(function
|
|
1729
|
-
while (1) switch (
|
|
2283
|
+
_args34 = arguments;
|
|
2284
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
2285
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
1730
2286
|
case 0:
|
|
1731
|
-
config =
|
|
2287
|
+
config = _args34.length > 0 && _args34[0] !== undefined ? _args34[0] : {};
|
|
1732
2288
|
this.logMethodStart('setItemRuleRuntimeConfig');
|
|
1733
2289
|
this.itemRuleRuntimeConfig = _objectSpread(_objectSpread(_objectSpread({}, this.itemRuleRuntimeConfig), config), {}, {
|
|
1734
2290
|
pax: _objectSpread(_objectSpread({}, ((_this$itemRuleRuntime = this.itemRuleRuntimeConfig) === null || _this$itemRuleRuntime === void 0 ? void 0 : _this$itemRuleRuntime.pax) || {}), (config === null || config === void 0 ? void 0 : config.pax) || {}),
|
|
@@ -1740,10 +2296,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1740
2296
|
this.itemRuleEvaluator.setStrategyConfigs([]);
|
|
1741
2297
|
}
|
|
1742
2298
|
this.itemRulePrefillApplied = false;
|
|
1743
|
-
|
|
2299
|
+
_context34.next = 7;
|
|
1744
2300
|
return this.refreshItemRuleQuantityLimits();
|
|
1745
2301
|
case 7:
|
|
1746
|
-
|
|
2302
|
+
_context34.next = 9;
|
|
1747
2303
|
return this.refreshCartValidationPassed();
|
|
1748
2304
|
case 9:
|
|
1749
2305
|
this.logMethodSuccess('setItemRuleRuntimeConfig', {
|
|
@@ -1751,9 +2307,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1751
2307
|
});
|
|
1752
2308
|
case 10:
|
|
1753
2309
|
case "end":
|
|
1754
|
-
return
|
|
2310
|
+
return _context34.stop();
|
|
1755
2311
|
}
|
|
1756
|
-
},
|
|
2312
|
+
}, _callee34, this);
|
|
1757
2313
|
}));
|
|
1758
2314
|
function setItemRuleRuntimeConfig() {
|
|
1759
2315
|
return _setItemRuleRuntimeConfig.apply(this, arguments);
|
|
@@ -1770,7 +2326,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1770
2326
|
var tableFormId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.form_id);
|
|
1771
2327
|
var formRecord = (_detail$form_record = detail === null || detail === void 0 ? void 0 : detail.form_record) !== null && _detail$form_record !== void 0 ? _detail$form_record : null;
|
|
1772
2328
|
// 是否允许加餐
|
|
1773
|
-
var allowSnack = ((_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 || (_this$otherParams8 = _this$otherParams8.dineInConfig) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8['
|
|
2329
|
+
var allowSnack = ((_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 || (_this$otherParams8 = _this$otherParams8.dineInConfig) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8['sale.allow_add_items']) || false;
|
|
1774
2330
|
// 开启同桌验证 - 本期没有这个配置,默认关掉
|
|
1775
2331
|
var deskmateValid = false;
|
|
1776
2332
|
var isExclusive = resourceSelectType === 'single';
|
|
@@ -1852,27 +2408,27 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1852
2408
|
}, {
|
|
1853
2409
|
key: "fetchResourceOccupyDetailByResourceId",
|
|
1854
2410
|
value: function () {
|
|
1855
|
-
var _fetchResourceOccupyDetailByResourceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2411
|
+
var _fetchResourceOccupyDetailByResourceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(resourceId) {
|
|
1856
2412
|
var _this$otherParams9, _this$otherParams9$ge, _response$data$occupy, _response$data;
|
|
1857
2413
|
var formRecordId, shopId, response;
|
|
1858
|
-
return _regeneratorRuntime().wrap(function
|
|
1859
|
-
while (1) switch (
|
|
2414
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
2415
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
1860
2416
|
case 0:
|
|
1861
2417
|
formRecordId = Number(resourceId);
|
|
1862
2418
|
if (!(!Number.isFinite(formRecordId) || formRecordId <= 0)) {
|
|
1863
|
-
|
|
2419
|
+
_context35.next = 3;
|
|
1864
2420
|
break;
|
|
1865
2421
|
}
|
|
1866
2422
|
throw new Error("[ScanOrder] \u975E\u6CD5\u684C\u53F0 resourceId: ".concat(resourceId));
|
|
1867
2423
|
case 3:
|
|
1868
2424
|
shopId = (_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 || (_this$otherParams9$ge = _this$otherParams9.getStateData) === null || _this$otherParams9$ge === void 0 ? void 0 : _this$otherParams9$ge.call(_this$otherParams9, 'shop_id');
|
|
1869
2425
|
if (shopId) {
|
|
1870
|
-
|
|
2426
|
+
_context35.next = 6;
|
|
1871
2427
|
break;
|
|
1872
2428
|
}
|
|
1873
2429
|
throw new Error('[ScanOrder] 无法获取 shop_id');
|
|
1874
2430
|
case 6:
|
|
1875
|
-
|
|
2431
|
+
_context35.next = 8;
|
|
1876
2432
|
return this.request.get('/order/resource/occupy-detail', {
|
|
1877
2433
|
shop_id: shopId,
|
|
1878
2434
|
'form_record_ids[]': formRecordId,
|
|
@@ -1881,21 +2437,21 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1881
2437
|
with_resource_form_info: 1
|
|
1882
2438
|
});
|
|
1883
2439
|
case 8:
|
|
1884
|
-
response =
|
|
2440
|
+
response = _context35.sent;
|
|
1885
2441
|
if (response !== null && response !== void 0 && response.status) {
|
|
1886
|
-
|
|
2442
|
+
_context35.next = 11;
|
|
1887
2443
|
break;
|
|
1888
2444
|
}
|
|
1889
2445
|
throw new Error((response === null || response === void 0 ? void 0 : response.message) || '获取资源占用详情失败');
|
|
1890
2446
|
case 11:
|
|
1891
|
-
return
|
|
2447
|
+
return _context35.abrupt("return", (_response$data$occupy = response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 || (_response$data = _response$data.occupy_details) === null || _response$data === void 0 ? void 0 : _response$data[0]) !== null && _response$data$occupy !== void 0 ? _response$data$occupy : null);
|
|
1892
2448
|
case 12:
|
|
1893
2449
|
case "end":
|
|
1894
|
-
return
|
|
2450
|
+
return _context35.stop();
|
|
1895
2451
|
}
|
|
1896
|
-
},
|
|
2452
|
+
}, _callee35, this);
|
|
1897
2453
|
}));
|
|
1898
|
-
function fetchResourceOccupyDetailByResourceId(
|
|
2454
|
+
function fetchResourceOccupyDetailByResourceId(_x17) {
|
|
1899
2455
|
return _fetchResourceOccupyDetailByResourceId.apply(this, arguments);
|
|
1900
2456
|
}
|
|
1901
2457
|
return fetchResourceOccupyDetailByResourceId;
|
|
@@ -1905,32 +2461,32 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1905
2461
|
}, {
|
|
1906
2462
|
key: "checkResourceAvailable",
|
|
1907
2463
|
value: function () {
|
|
1908
|
-
var _checkResourceAvailable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2464
|
+
var _checkResourceAvailable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(resourceId, hasOrderId) {
|
|
1909
2465
|
var _this$otherParams10, _this$otherParams10$g, _occupyDetail$form_re, _occupyDetail$form_re2, _this$otherParams11, _this$store$order5, _this$store$order7, _this$store$order7$ge, _this$otherParams12, openData, dineInConfig, closedBehaviorValue, closedMessage, basicUnavailableMessage, pauseMessage, makeShopClosed, operatingHourIds, outsideOperatingHours, scheduleList, now, tempOrder, reservationLinkIds, pendingRequestEntryPax, pendingRequestPaxMin, pendingRequestPaxMax, reservationProductList, scheduleDate, scheduleDatetime, loaded, occupancyMinutes, paxBounds, occupyDetail, resourceSelectType, resourceState, availabilityInfo, _this$store$order6, _res$data, res, entryPaxNumber, lastOrderInfo, historicalItems;
|
|
1910
|
-
return _regeneratorRuntime().wrap(function
|
|
1911
|
-
while (1) switch (
|
|
2466
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
2467
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
1912
2468
|
case 0:
|
|
1913
2469
|
this.logMethodStart('checkResourceAvailable', {
|
|
1914
2470
|
resourceId: resourceId
|
|
1915
2471
|
});
|
|
1916
|
-
|
|
1917
|
-
|
|
2472
|
+
_context36.prev = 1;
|
|
2473
|
+
_context36.next = 4;
|
|
1918
2474
|
return (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 || (_this$otherParams10$g = _this$otherParams10.getOpenData) === null || _this$otherParams10$g === void 0 ? void 0 : _this$otherParams10$g.call(_this$otherParams10, {
|
|
1919
2475
|
scope: 'board',
|
|
1920
2476
|
target: 'dine_in+scan_to_order',
|
|
1921
2477
|
section_code: ['basic', 'fulfillment', 'reservation', 'sale', 'menu', 'availability', 'workflow']
|
|
1922
2478
|
});
|
|
1923
2479
|
case 4:
|
|
1924
|
-
openData =
|
|
2480
|
+
openData = _context36.sent;
|
|
1925
2481
|
if (!((openData === null || openData === void 0 ? void 0 : openData.status) === false)) {
|
|
1926
|
-
|
|
2482
|
+
_context36.next = 7;
|
|
1927
2483
|
break;
|
|
1928
2484
|
}
|
|
1929
2485
|
throw new Error((openData === null || openData === void 0 ? void 0 : openData.message) || '获取店铺配置失败');
|
|
1930
2486
|
case 7:
|
|
1931
2487
|
dineInConfig = (openData === null || openData === void 0 ? void 0 : openData.data) || {};
|
|
1932
2488
|
this.otherParams.dineInConfig = dineInConfig;
|
|
1933
|
-
|
|
2489
|
+
_context36.next = 11;
|
|
1934
2490
|
return this.syncItemRuleConfigsFromDineInConfig(dineInConfig);
|
|
1935
2491
|
case 11:
|
|
1936
2492
|
closedBehaviorValue = dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.closed_behavior'];
|
|
@@ -1949,20 +2505,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1949
2505
|
};
|
|
1950
2506
|
}; // 1. 基础开关 basic.enable 关闭
|
|
1951
2507
|
if (!((dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['basic.enable']) === false)) {
|
|
1952
|
-
|
|
2508
|
+
_context36.next = 18;
|
|
1953
2509
|
break;
|
|
1954
2510
|
}
|
|
1955
|
-
return
|
|
2511
|
+
return _context36.abrupt("return", makeShopClosed(basicUnavailableMessage));
|
|
1956
2512
|
case 18:
|
|
1957
2513
|
if (!toBoolean(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.paused'])) {
|
|
1958
|
-
|
|
2514
|
+
_context36.next = 21;
|
|
1959
2515
|
break;
|
|
1960
2516
|
}
|
|
1961
2517
|
if (!((dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.pause_behavior']) === 'hide_all')) {
|
|
1962
|
-
|
|
2518
|
+
_context36.next = 21;
|
|
1963
2519
|
break;
|
|
1964
2520
|
}
|
|
1965
|
-
return
|
|
2521
|
+
return _context36.abrupt("return", makeShopClosed(pauseMessage));
|
|
1966
2522
|
case 21:
|
|
1967
2523
|
// 3. 营业时间 operating_hours 闸门
|
|
1968
2524
|
operatingHourIds = Array.isArray(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.operating_hours']) ? dineInConfig['availability.operating_hours'].map(function (id) {
|
|
@@ -1979,27 +2535,27 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1979
2535
|
}
|
|
1980
2536
|
}
|
|
1981
2537
|
if (!(outsideOperatingHours && closedBehaviorValue !== 'show_menu_disabled')) {
|
|
1982
|
-
|
|
2538
|
+
_context36.next = 26;
|
|
1983
2539
|
break;
|
|
1984
2540
|
}
|
|
1985
|
-
return
|
|
2541
|
+
return _context36.abrupt("return", makeShopClosed(closedMessage, closedBehaviorValue));
|
|
1986
2542
|
case 26:
|
|
1987
2543
|
// Step1: 先加载预约规则商品,拿到 enabledReservationRuleProducts 与容量附加信息
|
|
1988
2544
|
// (resourceSelectType 需要基于这些商品 + 占用接口的 form_id 计算,故必须前置)
|
|
1989
2545
|
tempOrder = this.ensureTempOrder();
|
|
1990
2546
|
reservationLinkIds = collectLinkProductIdsFromReservationRules(dineInConfig['fulfillment.enabled_resource_rules']);
|
|
1991
2547
|
if (!(reservationLinkIds.length === 0)) {
|
|
1992
|
-
|
|
2548
|
+
_context36.next = 32;
|
|
1993
2549
|
break;
|
|
1994
2550
|
}
|
|
1995
2551
|
this.enabledReservationRuleProducts = [];
|
|
1996
|
-
|
|
2552
|
+
_context36.next = 43;
|
|
1997
2553
|
break;
|
|
1998
2554
|
case 32:
|
|
1999
2555
|
tempOrder.metadata = _objectSpread({}, tempOrder.metadata || {});
|
|
2000
2556
|
delete tempOrder.metadata.table_occupancy_duration;
|
|
2001
2557
|
reservationProductList = new ProductList("".concat(this.name, "_reservationEnabledRules"), this.defaultVersion);
|
|
2002
|
-
|
|
2558
|
+
_context36.next = 37;
|
|
2003
2559
|
return reservationProductList.initialize(this.core, {
|
|
2004
2560
|
store: {
|
|
2005
2561
|
list: [],
|
|
@@ -2014,7 +2570,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2014
2570
|
case 37:
|
|
2015
2571
|
scheduleDate = dayjs().format('YYYY-MM-DD');
|
|
2016
2572
|
scheduleDatetime = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
2017
|
-
|
|
2573
|
+
_context36.next = 41;
|
|
2018
2574
|
return reservationProductList.loadProducts({
|
|
2019
2575
|
product_ids: reservationLinkIds,
|
|
2020
2576
|
schedule_date: scheduleDate,
|
|
@@ -2022,7 +2578,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2022
2578
|
cacheId: this.cacheId
|
|
2023
2579
|
});
|
|
2024
2580
|
case 41:
|
|
2025
|
-
loaded =
|
|
2581
|
+
loaded = _context36.sent;
|
|
2026
2582
|
if (Array.isArray(loaded)) {
|
|
2027
2583
|
this.enabledReservationRuleProducts = loaded;
|
|
2028
2584
|
occupancyMinutes = pickFirstDurationMinutesFromProducts(loaded);
|
|
@@ -2047,10 +2603,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2047
2603
|
});
|
|
2048
2604
|
}
|
|
2049
2605
|
case 43:
|
|
2050
|
-
|
|
2606
|
+
_context36.next = 45;
|
|
2051
2607
|
return this.fetchResourceOccupyDetailByResourceId(resourceId);
|
|
2052
2608
|
case 45:
|
|
2053
|
-
occupyDetail =
|
|
2609
|
+
occupyDetail = _context36.sent;
|
|
2054
2610
|
// Step3: 结合预约规则商品的 product_resource.resources 与占用接口返回的 form_id,
|
|
2055
2611
|
// 计算当前桌台的 resourceSelectType(single/multiple/capacity)
|
|
2056
2612
|
resourceSelectType = this.resolveResourceSelectType(toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_id)); // Step4: 用 occupyDetail + resourceSelectType 规整为 resourceState
|
|
@@ -2090,10 +2646,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2090
2646
|
|
|
2091
2647
|
// 空闲状态下自动准备本地临时订单,供后续“购物车式”商品操作使用
|
|
2092
2648
|
if (!(availabilityInfo.mode === 'idle')) {
|
|
2093
|
-
|
|
2649
|
+
_context36.next = 60;
|
|
2094
2650
|
break;
|
|
2095
2651
|
}
|
|
2096
|
-
|
|
2652
|
+
_context36.next = 60;
|
|
2097
2653
|
return this.addNewOrder();
|
|
2098
2654
|
case 60:
|
|
2099
2655
|
// 如果是加单模式,tempOrder 里 需要记录 lastOrderId,提交的时候走加单接口
|
|
@@ -2101,23 +2657,23 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2101
2657
|
tempOrder.order_id = resourceState.lastOrderId;
|
|
2102
2658
|
}
|
|
2103
2659
|
if (!tempOrder.order_id) {
|
|
2104
|
-
|
|
2660
|
+
_context36.next = 69;
|
|
2105
2661
|
break;
|
|
2106
2662
|
}
|
|
2107
|
-
|
|
2663
|
+
_context36.next = 64;
|
|
2108
2664
|
return (_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 ? void 0 : _this$store$order6.getOrderInfoByRemote(tempOrder.order_id);
|
|
2109
2665
|
case 64:
|
|
2110
|
-
res =
|
|
2666
|
+
res = _context36.sent;
|
|
2111
2667
|
// 找到下单的时候输入的 entryPaxNumber
|
|
2112
2668
|
entryPaxNumber = res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 || (_res$data = _res$data.bookings) === null || _res$data === void 0 || (_res$data = _res$data.find(function (p) {
|
|
2113
2669
|
var _p$metadata;
|
|
2114
2670
|
return (_p$metadata = p.metadata) === null || _p$metadata === void 0 ? void 0 : _p$metadata.collect_pax;
|
|
2115
2671
|
})) === null || _res$data === void 0 || (_res$data = _res$data.metadata) === null || _res$data === void 0 ? void 0 : _res$data.collect_pax;
|
|
2116
2672
|
if (!entryPaxNumber) {
|
|
2117
|
-
|
|
2673
|
+
_context36.next = 69;
|
|
2118
2674
|
break;
|
|
2119
2675
|
}
|
|
2120
|
-
|
|
2676
|
+
_context36.next = 69;
|
|
2121
2677
|
return this.setEntryPaxNumber(entryPaxNumber);
|
|
2122
2678
|
case 69:
|
|
2123
2679
|
lastOrderInfo = (_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 || (_this$store$order7$ge = _this$store$order7.getLastOrderInfo) === null || _this$store$order7$ge === void 0 ? void 0 : _this$store$order7$ge.call(_this$store$order7);
|
|
@@ -2131,7 +2687,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2131
2687
|
} : {}));
|
|
2132
2688
|
return acc;
|
|
2133
2689
|
}, []) : []; // pax 由 setEntryPaxNumber 负责写入 itemRuleRuntimeConfig.pax
|
|
2134
|
-
|
|
2690
|
+
_context36.next = 73;
|
|
2135
2691
|
return this.setItemRuleRuntimeConfig({
|
|
2136
2692
|
serviceType: (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.businessCode,
|
|
2137
2693
|
submissionIndex: hasOrderId ? 1 : 0,
|
|
@@ -2158,21 +2714,21 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2158
2714
|
isExclusive: resourceState.isExclusive,
|
|
2159
2715
|
isFull: resourceState.isFull
|
|
2160
2716
|
});
|
|
2161
|
-
return
|
|
2717
|
+
return _context36.abrupt("return", availabilityInfo);
|
|
2162
2718
|
case 78:
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
this.logMethodError('checkResourceAvailable',
|
|
2719
|
+
_context36.prev = 78;
|
|
2720
|
+
_context36.t0 = _context36["catch"](1);
|
|
2721
|
+
this.logMethodError('checkResourceAvailable', _context36.t0.message, {
|
|
2166
2722
|
resourceId: resourceId
|
|
2167
2723
|
});
|
|
2168
|
-
throw
|
|
2724
|
+
throw _context36.t0;
|
|
2169
2725
|
case 82:
|
|
2170
2726
|
case "end":
|
|
2171
|
-
return
|
|
2727
|
+
return _context36.stop();
|
|
2172
2728
|
}
|
|
2173
|
-
},
|
|
2729
|
+
}, _callee36, this, [[1, 78]]);
|
|
2174
2730
|
}));
|
|
2175
|
-
function checkResourceAvailable(
|
|
2731
|
+
function checkResourceAvailable(_x18, _x19) {
|
|
2176
2732
|
return _checkResourceAvailable.apply(this, arguments);
|
|
2177
2733
|
}
|
|
2178
2734
|
return checkResourceAvailable;
|
|
@@ -2180,10 +2736,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2180
2736
|
}, {
|
|
2181
2737
|
key: "getAdditionalOrderInfo",
|
|
2182
2738
|
value: function () {
|
|
2183
|
-
var _getAdditionalOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2739
|
+
var _getAdditionalOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {
|
|
2184
2740
|
var result;
|
|
2185
|
-
return _regeneratorRuntime().wrap(function
|
|
2186
|
-
while (1) switch (
|
|
2741
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
2742
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
2187
2743
|
case 0:
|
|
2188
2744
|
this.logMethodStart('getAdditionalOrderInfo');
|
|
2189
2745
|
result = {
|
|
@@ -2197,12 +2753,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2197
2753
|
orderId: result.orderId,
|
|
2198
2754
|
orderStatus: result.orderStatus
|
|
2199
2755
|
});
|
|
2200
|
-
return
|
|
2756
|
+
return _context37.abrupt("return", result);
|
|
2201
2757
|
case 4:
|
|
2202
2758
|
case "end":
|
|
2203
|
-
return
|
|
2759
|
+
return _context37.stop();
|
|
2204
2760
|
}
|
|
2205
|
-
},
|
|
2761
|
+
}, _callee37, this);
|
|
2206
2762
|
}));
|
|
2207
2763
|
function getAdditionalOrderInfo() {
|
|
2208
2764
|
return _getAdditionalOrderInfo.apply(this, arguments);
|
|
@@ -2212,19 +2768,19 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2212
2768
|
}, {
|
|
2213
2769
|
key: "getProductList",
|
|
2214
2770
|
value: function () {
|
|
2215
|
-
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2771
|
+
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
|
|
2216
2772
|
var _this$otherParams13;
|
|
2217
2773
|
var menu_list_ids, _this$store$products, res, formattedRes;
|
|
2218
|
-
return _regeneratorRuntime().wrap(function
|
|
2219
|
-
while (1) switch (
|
|
2774
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
2775
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
2220
2776
|
case 0:
|
|
2221
2777
|
this.logMethodStart('getProductList');
|
|
2222
2778
|
// 可以直接通过配置里的 menu 读取
|
|
2223
2779
|
menu_list_ids = ((_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 || (_this$otherParams13 = _this$otherParams13.dineInConfig) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13['menu.associated_menus'].map(function (n) {
|
|
2224
2780
|
return Number(n.value);
|
|
2225
2781
|
})) || [];
|
|
2226
|
-
|
|
2227
|
-
|
|
2782
|
+
_context38.prev = 2;
|
|
2783
|
+
_context38.next = 5;
|
|
2228
2784
|
return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
|
|
2229
2785
|
menu_list_ids: menu_list_ids,
|
|
2230
2786
|
cacheId: this.cacheId,
|
|
@@ -2232,22 +2788,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2232
2788
|
schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
2233
2789
|
});
|
|
2234
2790
|
case 5:
|
|
2235
|
-
res =
|
|
2791
|
+
res = _context38.sent;
|
|
2236
2792
|
formattedRes = attachItemRuleLimitsToTopLevelProducts(res, this.store.itemRuleQuantityLimits || []);
|
|
2237
2793
|
this.logMethodSuccess('getProductList', {
|
|
2238
2794
|
menuCount: menu_list_ids.length
|
|
2239
2795
|
});
|
|
2240
|
-
return
|
|
2796
|
+
return _context38.abrupt("return", formattedRes);
|
|
2241
2797
|
case 11:
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
this.logMethodError('getProductList',
|
|
2245
|
-
throw
|
|
2798
|
+
_context38.prev = 11;
|
|
2799
|
+
_context38.t0 = _context38["catch"](2);
|
|
2800
|
+
this.logMethodError('getProductList', _context38.t0.message);
|
|
2801
|
+
throw _context38.t0;
|
|
2246
2802
|
case 15:
|
|
2247
2803
|
case "end":
|
|
2248
|
-
return
|
|
2804
|
+
return _context38.stop();
|
|
2249
2805
|
}
|
|
2250
|
-
},
|
|
2806
|
+
}, _callee38, this, [[2, 11]]);
|
|
2251
2807
|
}));
|
|
2252
2808
|
function getProductList() {
|
|
2253
2809
|
return _getProductList.apply(this, arguments);
|
|
@@ -2262,15 +2818,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2262
2818
|
}, {
|
|
2263
2819
|
key: "setOtherParams",
|
|
2264
2820
|
value: function () {
|
|
2265
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2266
|
-
var
|
|
2267
|
-
|
|
2821
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
|
|
2822
|
+
var _ref8,
|
|
2823
|
+
_ref8$cover,
|
|
2268
2824
|
cover,
|
|
2269
|
-
|
|
2270
|
-
return _regeneratorRuntime().wrap(function
|
|
2271
|
-
while (1) switch (
|
|
2825
|
+
_args39 = arguments;
|
|
2826
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
2827
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
2272
2828
|
case 0:
|
|
2273
|
-
|
|
2829
|
+
_ref8 = _args39.length > 1 && _args39[1] !== undefined ? _args39[1] : {}, _ref8$cover = _ref8.cover, cover = _ref8$cover === void 0 ? false : _ref8$cover;
|
|
2274
2830
|
if (cover) {
|
|
2275
2831
|
this.otherParams = params;
|
|
2276
2832
|
} else {
|
|
@@ -2278,19 +2834,26 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2278
2834
|
}
|
|
2279
2835
|
case 2:
|
|
2280
2836
|
case "end":
|
|
2281
|
-
return
|
|
2837
|
+
return _context39.stop();
|
|
2282
2838
|
}
|
|
2283
|
-
},
|
|
2839
|
+
}, _callee39, this);
|
|
2284
2840
|
}));
|
|
2285
|
-
function setOtherParams(
|
|
2841
|
+
function setOtherParams(_x20) {
|
|
2286
2842
|
return _setOtherParams.apply(this, arguments);
|
|
2287
2843
|
}
|
|
2288
2844
|
return setOtherParams;
|
|
2289
|
-
}() // ─── UI 状态缓存(按 cacheId 分桶,
|
|
2845
|
+
}() // ─── UI 状态缓存(按 cacheId 分桶,localStorage) ───
|
|
2290
2846
|
//
|
|
2291
2847
|
// 用于物料层持久化 UI 层面的轻量状态(如当前步骤、gate 标记、登录回跳意图等)。
|
|
2292
2848
|
// 桶键:pisell.scanOrder.uiState:<cacheId>;内部以 JSON object 形式存储多个字段。
|
|
2293
2849
|
// 无 cacheId 时所有方法自动降级为 no-op,上层不用判空。
|
|
2850
|
+
//
|
|
2851
|
+
// 之所以用 localStorage 而不是 sessionStorage:
|
|
2852
|
+
// 1. 与 Order 模块 openCache 下的 tempOrder 同栈,购物车在 / UIState 在,行为对齐;
|
|
2853
|
+
// 2. pisell1.login 整页 OAuth 跳转在 H5 壳 / iOS Safari 场景下可能丢 sessionStorage,
|
|
2854
|
+
// 导致登录回跳后 gate 标记失效、pax 弹窗重开、落点错误;localStorage 稳定不受影响。
|
|
2855
|
+
// 3. 失效由上层显式控制:提交成功 clearStepCache / entryContext 不一致 clearUIState /
|
|
2856
|
+
// pendingStep 登录回调 deleteUIState,足够约束生命周期。
|
|
2294
2857
|
}, {
|
|
2295
2858
|
key: "getUIStateBucketKey",
|
|
2296
2859
|
value: function getUIStateBucketKey() {
|
|
@@ -2302,9 +2865,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2302
2865
|
value: function readUIStateBucket() {
|
|
2303
2866
|
var _this$window;
|
|
2304
2867
|
var key = this.getUIStateBucketKey();
|
|
2305
|
-
if (!key || !((_this$window = this.window) !== null && _this$window !== void 0 && _this$window.
|
|
2868
|
+
if (!key || !((_this$window = this.window) !== null && _this$window !== void 0 && _this$window.localStorage)) return {};
|
|
2306
2869
|
try {
|
|
2307
|
-
var raw = this.window.
|
|
2870
|
+
var raw = this.window.localStorage.getItem(key) || '{}';
|
|
2308
2871
|
var parsed = JSON.parse(raw);
|
|
2309
2872
|
return parsed && _typeof(parsed) === 'object' ? parsed : {};
|
|
2310
2873
|
} catch (_unused) {
|
|
@@ -2316,9 +2879,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2316
2879
|
value: function writeUIStateBucket(bucket) {
|
|
2317
2880
|
var _this$window2;
|
|
2318
2881
|
var key = this.getUIStateBucketKey();
|
|
2319
|
-
if (!key || !((_this$window2 = this.window) !== null && _this$window2 !== void 0 && _this$window2.
|
|
2882
|
+
if (!key || !((_this$window2 = this.window) !== null && _this$window2 !== void 0 && _this$window2.localStorage)) return;
|
|
2320
2883
|
try {
|
|
2321
|
-
this.window.
|
|
2884
|
+
this.window.localStorage.setItem(key, JSON.stringify(bucket));
|
|
2322
2885
|
} catch (error) {
|
|
2323
2886
|
console.warn('[ScanOrder] writeUIStateBucket failed', error);
|
|
2324
2887
|
}
|
|
@@ -2355,9 +2918,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2355
2918
|
value: function clearUIState() {
|
|
2356
2919
|
var _this$window3;
|
|
2357
2920
|
var key = this.getUIStateBucketKey();
|
|
2358
|
-
if (!key || !((_this$window3 = this.window) !== null && _this$window3 !== void 0 && _this$window3.
|
|
2921
|
+
if (!key || !((_this$window3 = this.window) !== null && _this$window3 !== void 0 && _this$window3.localStorage)) return;
|
|
2359
2922
|
try {
|
|
2360
|
-
this.window.
|
|
2923
|
+
this.window.localStorage.removeItem(key);
|
|
2361
2924
|
} catch (error) {
|
|
2362
2925
|
console.warn('[ScanOrder] clearUIState failed', error);
|
|
2363
2926
|
}
|
|
@@ -2365,10 +2928,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2365
2928
|
}, {
|
|
2366
2929
|
key: "setEntryPaxNumber",
|
|
2367
2930
|
value: function () {
|
|
2368
|
-
var _setEntryPaxNumber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2931
|
+
var _setEntryPaxNumber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(number) {
|
|
2369
2932
|
var pax, t;
|
|
2370
|
-
return _regeneratorRuntime().wrap(function
|
|
2371
|
-
while (1) switch (
|
|
2933
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
2934
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
2372
2935
|
case 0:
|
|
2373
2936
|
pax = normalizeSubmitCollectPaxValue(number);
|
|
2374
2937
|
this.store.entryPaxNumber = pax;
|
|
@@ -2389,18 +2952,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2389
2952
|
}
|
|
2390
2953
|
});
|
|
2391
2954
|
this.itemRulePrefillApplied = false;
|
|
2392
|
-
|
|
2955
|
+
_context40.next = 7;
|
|
2393
2956
|
return this.refreshItemRuleQuantityLimits();
|
|
2394
2957
|
case 7:
|
|
2395
|
-
|
|
2958
|
+
_context40.next = 9;
|
|
2396
2959
|
return this.refreshCartValidationPassed();
|
|
2397
2960
|
case 9:
|
|
2398
2961
|
case "end":
|
|
2399
|
-
return
|
|
2962
|
+
return _context40.stop();
|
|
2400
2963
|
}
|
|
2401
|
-
},
|
|
2964
|
+
}, _callee40, this);
|
|
2402
2965
|
}));
|
|
2403
|
-
function setEntryPaxNumber(
|
|
2966
|
+
function setEntryPaxNumber(_x21) {
|
|
2404
2967
|
return _setEntryPaxNumber.apply(this, arguments);
|
|
2405
2968
|
}
|
|
2406
2969
|
return setEntryPaxNumber;
|
|
@@ -2453,4 +3016,5 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2453
3016
|
}]);
|
|
2454
3017
|
return ScanOrderImpl;
|
|
2455
3018
|
}(BaseModule);
|
|
3019
|
+
_defineProperty(ScanOrderImpl, "PISELL1_LOGIN_SUCCESS", 'pisell1.login.success');
|
|
2456
3020
|
_defineProperty(ScanOrderImpl, "UI_STATE_KEY_PREFIX", 'pisell.scanOrder.uiState:');
|