@pisell/pisellos 0.0.507 → 0.0.509

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