@pisell/pisellos 0.0.500 → 0.0.502

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.
Files changed (68) hide show
  1. package/dist/model/strategy/adapter/itemRule/adapter.d.ts +8 -0
  2. package/dist/model/strategy/adapter/itemRule/adapter.js +52 -8
  3. package/dist/model/strategy/adapter/itemRule/examples.d.ts +15 -0
  4. package/dist/model/strategy/adapter/itemRule/examples.js +68 -1
  5. package/dist/model/strategy/adapter/itemRule/index.d.ts +1 -1
  6. package/dist/model/strategy/adapter/itemRule/index.js +1 -1
  7. package/dist/model/strategy/adapter/itemRule/type.d.ts +20 -1
  8. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  9. package/dist/modules/Order/index.d.ts +10 -0
  10. package/dist/modules/Order/index.js +64 -40
  11. package/dist/modules/Order/types.d.ts +13 -1
  12. package/dist/modules/Order/utils.d.ts +36 -1
  13. package/dist/modules/Order/utils.js +120 -24
  14. package/dist/modules/ProductList/index.js +2 -2
  15. package/dist/modules/Quotation/index.js +6 -3
  16. package/dist/modules/SalesSummary/types.d.ts +2 -1
  17. package/dist/modules/SalesSummary/utils.js +10 -10
  18. package/dist/modules/Schedule/utils.d.ts +1 -1
  19. package/dist/solution/ScanOrder/index.d.ts +22 -0
  20. package/dist/solution/ScanOrder/index.js +863 -369
  21. package/dist/solution/ScanOrder/types.d.ts +31 -8
  22. package/dist/solution/ScanOrder/utils.d.ts +26 -0
  23. package/dist/solution/ScanOrder/utils.js +191 -44
  24. package/dist/solution/VenueBooking/index.d.ts +42 -5
  25. package/dist/solution/VenueBooking/index.js +692 -280
  26. package/dist/solution/VenueBooking/types.d.ts +23 -0
  27. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +2 -1
  28. package/dist/solution/VenueBooking/utils/dateSummary.js +7 -5
  29. package/dist/solution/VenueBooking/utils/resource.d.ts +11 -1
  30. package/dist/solution/VenueBooking/utils/resource.js +57 -21
  31. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +5 -0
  32. package/dist/solution/VenueBooking/utils/slotMerge.js +33 -12
  33. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +1 -1
  34. package/dist/solution/VenueBooking/utils/timeSlot.js +259 -62
  35. package/lib/model/strategy/adapter/itemRule/adapter.d.ts +8 -0
  36. package/lib/model/strategy/adapter/itemRule/adapter.js +41 -2
  37. package/lib/model/strategy/adapter/itemRule/examples.d.ts +15 -0
  38. package/lib/model/strategy/adapter/itemRule/examples.js +47 -0
  39. package/lib/model/strategy/adapter/itemRule/index.d.ts +1 -1
  40. package/lib/model/strategy/adapter/itemRule/index.js +2 -0
  41. package/lib/model/strategy/adapter/itemRule/type.d.ts +20 -1
  42. package/lib/modules/Order/index.d.ts +10 -0
  43. package/lib/modules/Order/index.js +40 -43
  44. package/lib/modules/Order/types.d.ts +13 -1
  45. package/lib/modules/Order/utils.d.ts +36 -1
  46. package/lib/modules/Order/utils.js +100 -21
  47. package/lib/modules/ProductList/index.js +3 -2
  48. package/lib/modules/Quotation/index.js +3 -0
  49. package/lib/modules/SalesSummary/types.d.ts +2 -1
  50. package/lib/modules/SalesSummary/utils.js +2 -2
  51. package/lib/modules/Schedule/utils.d.ts +1 -1
  52. package/lib/solution/ScanOrder/index.d.ts +22 -0
  53. package/lib/solution/ScanOrder/index.js +376 -21
  54. package/lib/solution/ScanOrder/types.d.ts +31 -8
  55. package/lib/solution/ScanOrder/utils.d.ts +26 -0
  56. package/lib/solution/ScanOrder/utils.js +128 -19
  57. package/lib/solution/VenueBooking/index.d.ts +42 -5
  58. package/lib/solution/VenueBooking/index.js +356 -84
  59. package/lib/solution/VenueBooking/types.d.ts +23 -0
  60. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +2 -1
  61. package/lib/solution/VenueBooking/utils/dateSummary.js +14 -5
  62. package/lib/solution/VenueBooking/utils/resource.d.ts +11 -1
  63. package/lib/solution/VenueBooking/utils/resource.js +15 -4
  64. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +5 -0
  65. package/lib/solution/VenueBooking/utils/slotMerge.js +29 -12
  66. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +1 -1
  67. package/lib/solution/VenueBooking/utils/timeSlot.js +182 -43
  68. package/package.json +1 -1
@@ -1,5 +1,9 @@
1
1
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
2
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
2
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
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
3
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; }
4
8
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
5
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; }
@@ -22,8 +26,12 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
22
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); }
23
27
  import { BaseModule } from "../../modules/BaseModule";
24
28
  import { ScanOrderHooks } from "./types";
25
- import { attachItemRuleLimitsToTopLevelProducts, buildProductKey, buildItemRuleBusinessData, createEmptySummary, getProductIdentityIndex, getSafeProductNum, normalizeEnabledItemRuleIds, normalizeOrderProduct, normalizeItemRuleStrategies, toNonNegativeInt, toNonNegativeNumber, toPriceString, toBoolean, toPositiveString } from "./utils";
29
+ import { attachItemRuleLimitsToTopLevelProducts, buildProductKey, buildItemRuleBusinessData, collectLinkProductIdsFromReservationRules, createEmptySummary, getProductIdentityIndex, getSafeProductNum, hasCustomCapacityProduct, pickFirstCustomCapacityPaxBounds, normalizeEnabledItemRuleIds, normalizeOrderProduct, normalizeItemRuleStrategies, pickFirstDurationMinutesFromProducts, toNonNegativeInt, toNonNegativeNumber, toPriceString, toBoolean, toPositiveString } from "./utils";
26
30
  import { createModule } from "../BookingByStep/types";
31
+ import { ProductList } from "../../modules/ProductList";
32
+ import { ScheduleModule } from "../../modules/Schedule";
33
+ import { getDateIsInSchedule } from "../../modules/Schedule/getDateIsInSchedule";
34
+ import { createUuidV4, normalizeSubmitCollectPaxValue } from "../../modules/Order/utils";
27
35
  import dayjs from 'dayjs';
28
36
  import { ItemRuleEvaluator } from "../../model/strategy/adapter/itemRule";
29
37
  export * from "./types";
@@ -50,7 +58,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
50
58
  cartValidation: {
51
59
  passed: null,
52
60
  failures: []
53
- }
61
+ },
62
+ entryPaxNumber: 1
54
63
  });
55
64
  _defineProperty(_assertThisInitialized(_this), "otherParams", {});
56
65
  _defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
@@ -61,6 +70,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
61
70
  _defineProperty(_assertThisInitialized(_this), "itemRuleConfigsPromise", null);
62
71
  _defineProperty(_assertThisInitialized(_this), "itemRulePrefillApplied", false);
63
72
  _defineProperty(_assertThisInitialized(_this), "itemRuleRuntimeConfig", {});
73
+ /** 最近一次 checkResourceAvailable 从预约规则 link 拉取的商品快照 */
74
+ _defineProperty(_assertThisInitialized(_this), "enabledReservationRuleProducts", []);
64
75
  return _this;
65
76
  }
66
77
  _createClass(ScanOrderImpl, [{
@@ -205,6 +216,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
205
216
  _this2 = this;
206
217
  var options,
207
218
  moduleArr,
219
+ scheduleModule,
208
220
  _this$store$order,
209
221
  _this$store$order2,
210
222
  _args3 = arguments;
@@ -281,47 +293,69 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
281
293
  if (this.store.scanOrderLogger) {
282
294
  this.store.scanOrderLogger.setContext(this.getScanOrderLoggerContext());
283
295
  }
296
+ scheduleModule = new ScheduleModule("".concat(this.name, "_schedule"));
297
+ this.store.schedule = scheduleModule;
298
+ this.core.registerModule(scheduleModule, {
299
+ otherParams: _objectSpread(_objectSpread({}, this.otherParams), {}, {
300
+ fatherModule: this.name
301
+ })
302
+ });
284
303
  console.log('[ScanOrder] 初始化开始');
285
- _context3.prev = 28;
286
- _context3.next = 31;
304
+ _context3.prev = 31;
305
+ _context3.next = 34;
287
306
  return (_this$store$order = this.store.order) === null || _this$store$order === void 0 ? void 0 : _this$store$order.recalculateSummary({
288
307
  createIfMissing: false
289
308
  });
290
- case 31:
309
+ case 34:
291
310
  (_this$store$order2 = this.store.order) === null || _this$store$order2 === void 0 || _this$store$order2.persistTempOrder();
292
- _context3.next = 34;
311
+ _context3.next = 37;
293
312
  return this.loadRuntimeConfigs();
294
- case 34:
295
- _context3.next = 36;
313
+ case 37:
314
+ if (!this.store.schedule) {
315
+ _context3.next = 46;
316
+ break;
317
+ }
318
+ _context3.prev = 38;
319
+ _context3.next = 41;
320
+ return this.store.schedule.loadAllSchedule();
321
+ case 41:
322
+ _context3.next = 46;
323
+ 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;
296
330
  return this.refreshItemRuleQuantityLimits();
297
- case 36:
331
+ case 48:
298
332
  this.store.status = 'ready';
299
333
  console.log('[ScanOrder] 初始化完成');
300
- _context3.next = 40;
334
+ _context3.next = 52;
301
335
  return this.core.effects.emit(ScanOrderHooks.onInited, {
302
336
  status: this.store.status
303
337
  });
304
- case 40:
338
+ case 52:
305
339
  this.logMethodSuccess('initialize', {
306
340
  status: this.store.status
307
341
  });
308
- _context3.next = 50;
342
+ _context3.next = 62;
309
343
  break;
310
- case 43:
311
- _context3.prev = 43;
312
- _context3.t0 = _context3["catch"](28);
344
+ case 55:
345
+ _context3.prev = 55;
346
+ _context3.t1 = _context3["catch"](31);
313
347
  this.store.status = 'error';
314
- this.store.error = _context3.t0 instanceof Error ? _context3.t0.message : '初始化失败';
315
- console.error('[ScanOrder] 初始化失败', _context3.t0);
316
- this.logMethodError('initialize', _context3.t0, {
348
+ this.store.error = _context3.t1 instanceof Error ? _context3.t1.message : '初始化失败';
349
+ console.error('[ScanOrder] 初始化失败', _context3.t1);
350
+ this.logMethodError('initialize', _context3.t1, {
317
351
  status: this.store.status
318
352
  });
319
- throw _context3.t0;
320
- case 50:
353
+ throw _context3.t1;
354
+ case 62:
321
355
  case "end":
322
356
  return _context3.stop();
323
357
  }
324
- }, _callee3, this, [[28, 43]]);
358
+ }, _callee3, this, [[31, 55], [38, 43]]);
325
359
  }));
326
360
  function initialize(_x3) {
327
361
  return _initialize.apply(this, arguments);
@@ -529,6 +563,56 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
529
563
  throw error;
530
564
  }
531
565
  }
566
+
567
+ // 存储 UI 层选择的取餐方式到 tempOrder.metadata.shop_service_data
568
+ // service_type 在扫码点餐场景固定为 dine_in
569
+ }, {
570
+ key: "setPickupReferenceMode",
571
+ value: function setPickupReferenceMode(mode) {
572
+ this.logMethodStart('setPickupReferenceMode', {
573
+ mode: mode
574
+ });
575
+ try {
576
+ if (!this.store.order) throw new Error('order 模块未初始化');
577
+ var tempOrder = this.store.order.ensureTempOrder();
578
+ tempOrder.metadata = _objectSpread(_objectSpread({}, tempOrder.metadata || {}), {}, {
579
+ shop_service_data: _objectSpread(_objectSpread({}, (tempOrder.metadata || {}).shop_service_data || {}), {}, {
580
+ service_type: 'dine_in',
581
+ pickup_reference_mode: mode
582
+ })
583
+ });
584
+ this.store.order.persistTempOrder();
585
+ this.logMethodSuccess('setPickupReferenceMode', {
586
+ mode: mode
587
+ });
588
+ return tempOrder.metadata.shop_service_data;
589
+ } catch (error) {
590
+ this.logMethodError('setPickupReferenceMode', error, {
591
+ mode: mode
592
+ });
593
+ throw error;
594
+ }
595
+ }
596
+
597
+ // 存储用户自定义取餐标识到 tempOrder.buzzer
598
+ }, {
599
+ key: "setPickupRef",
600
+ value: function setPickupRef(buzzer) {
601
+ this.logMethodStart('setPickupRef', {
602
+ buzzerLength: String(buzzer || '').length
603
+ });
604
+ try {
605
+ if (!this.store.order) throw new Error('order 模块未初始化');
606
+ var result = this.store.order.updateTempOrderBuzzer(buzzer);
607
+ this.logMethodSuccess('setPickupRef', {
608
+ buzzerLength: result.length
609
+ });
610
+ return result;
611
+ } catch (error) {
612
+ this.logMethodError('setPickupRef', error);
613
+ throw error;
614
+ }
615
+ }
532
616
  }, {
533
617
  key: "ensureTempOrder",
534
618
  value: function ensureTempOrder() {
@@ -576,6 +660,45 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
576
660
  return _addNewOrder.apply(this, arguments);
577
661
  }
578
662
  return addNewOrder;
663
+ }() // 重置 tempOrder 与与上一单强相关的运行态(resource/entryPaxNumber/enabledReservationRuleProducts),
664
+ // 适用于从支付页通过 react-router 跳回继续下单时清理残留数据
665
+ }, {
666
+ key: "restoreOrder",
667
+ value: function () {
668
+ var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
669
+ var tempOrder;
670
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
671
+ while (1) switch (_context8.prev = _context8.next) {
672
+ case 0:
673
+ this.logMethodStart('restoreOrder');
674
+ _context8.prev = 1;
675
+ if (this.store.order) {
676
+ _context8.next = 4;
677
+ break;
678
+ }
679
+ throw new Error('scanOrder 解决方案需要 order 模块支持');
680
+ case 4:
681
+ this.store.resource = null;
682
+ this.store.entryPaxNumber = 1;
683
+ this.enabledReservationRuleProducts = [];
684
+ tempOrder = this.store.order.restoreOrder();
685
+ this.logMethodSuccess('restoreOrder');
686
+ return _context8.abrupt("return", tempOrder);
687
+ case 12:
688
+ _context8.prev = 12;
689
+ _context8.t0 = _context8["catch"](1);
690
+ this.logMethodError('restoreOrder', _context8.t0);
691
+ throw _context8.t0;
692
+ case 16:
693
+ case "end":
694
+ return _context8.stop();
695
+ }
696
+ }, _callee8, this, [[1, 12]]);
697
+ }));
698
+ function restoreOrder() {
699
+ return _restoreOrder.apply(this, arguments);
700
+ }
701
+ return restoreOrder;
579
702
  }()
580
703
  }, {
581
704
  key: "getOrderProducts",
@@ -591,83 +714,173 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
591
714
  }, {
592
715
  key: "getSummary",
593
716
  value: function () {
594
- var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
717
+ var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
595
718
  var summary;
596
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
597
- while (1) switch (_context8.prev = _context8.next) {
719
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
720
+ while (1) switch (_context9.prev = _context9.next) {
598
721
  case 0:
599
722
  this.logMethodStart('getSummary');
600
- _context8.prev = 1;
723
+ _context9.prev = 1;
601
724
  if (this.store.order) {
602
- _context8.next = 4;
725
+ _context9.next = 4;
603
726
  break;
604
727
  }
605
728
  throw new Error('order 模块未初始化');
606
729
  case 4:
607
- _context8.next = 6;
730
+ _context9.next = 6;
608
731
  return this.store.order.getScanOrderSummary();
609
732
  case 6:
610
- summary = _context8.sent;
733
+ summary = _context9.sent;
611
734
  this.logMethodSuccess('getSummary', {
612
735
  totalAmount: summary.total_amount
613
736
  });
614
- return _context8.abrupt("return", summary);
737
+ return _context9.abrupt("return", summary);
615
738
  case 11:
616
- _context8.prev = 11;
617
- _context8.t0 = _context8["catch"](1);
618
- this.logMethodError('getSummary', _context8.t0);
619
- throw _context8.t0;
739
+ _context9.prev = 11;
740
+ _context9.t0 = _context9["catch"](1);
741
+ this.logMethodError('getSummary', _context9.t0);
742
+ throw _context9.t0;
620
743
  case 15:
621
744
  case "end":
622
- return _context8.stop();
745
+ return _context9.stop();
623
746
  }
624
- }, _callee8, this, [[1, 11]]);
747
+ }, _callee9, this, [[1, 11]]);
625
748
  }));
626
749
  function getSummary() {
627
750
  return _getSummary.apply(this, arguments);
628
751
  }
629
752
  return getSummary;
630
- }()
753
+ }() // 根据 enabledReservationRuleProducts / store.resource 构造 submit payload enhancer:
754
+ // - 给第一条 booking 补 resources 与 product_uid
755
+ // - 追加一条 is_rule=true 的 rule product,与 booking 互相关联
756
+ // 无 rule product 也无 resource 时返回 undefined,跳过增强
757
+ }, {
758
+ key: "buildReservationRuleEnhancer",
759
+ value: function buildReservationRuleEnhancer() {
760
+ var ruleProduct = this.enabledReservationRuleProducts[0];
761
+ var resourceState = this.store.resource;
762
+ if (!ruleProduct && !resourceState) return undefined;
763
+ return function (payload, _ref) {
764
+ var _tempOrder$resource_i, _ref2, _pickOriginal, _resourceState$table_, _resourceState$relati;
765
+ var bookingUuid = _ref.bookingUuid,
766
+ tempOrder = _ref.tempOrder;
767
+ 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;
768
+ var pickOriginal = function pickOriginal(value) {
769
+ if (value && _typeof(value) === 'object' && !Array.isArray(value)) {
770
+ var original = value.original;
771
+ return typeof original === 'string' && original.length > 0 ? original : undefined;
772
+ }
773
+ return undefined;
774
+ };
775
+ var mainField = (_ref2 = (_pickOriginal = pickOriginal(tempOrder.table_number)) !== null && _pickOriginal !== void 0 ? _pickOriginal : pickOriginal(resourceState === null || resourceState === void 0 || (_resourceState$table_ = resourceState.table_form_record) === null || _resourceState$table_ === void 0 ? void 0 : _resourceState$table_.name)) !== null && _ref2 !== void 0 ? _ref2 : '';
776
+ var resourceEntry = resourceState && resourceId ? {
777
+ relation_type: 'form',
778
+ like_status: 'common',
779
+ id: Number(resourceId),
780
+ main_field: mainField,
781
+ form_id: resourceState.tableFormId,
782
+ relation_id: (_resourceState$relati = resourceState.relationId) !== null && _resourceState$relati !== void 0 ? _resourceState$relati : resourceId,
783
+ capacity: 1,
784
+ metadata: {}
785
+ } : undefined;
786
+ var ruleProductUid = ruleProduct ? createUuidV4() : undefined;
787
+ var nextBookings = (payload.bookings || []).map(function (booking, idx) {
788
+ return idx === 0 ? _objectSpread(_objectSpread(_objectSpread({}, booking), resourceEntry ? {
789
+ resources: [resourceEntry]
790
+ } : {}), ruleProductUid ? {
791
+ product_uid: ruleProductUid
792
+ } : {}) : booking;
793
+ });
794
+ var nextProducts = _toConsumableArray(payload.products || []);
795
+ if (ruleProduct && ruleProductUid) {
796
+ var _ruleProduct$price, _ref3, _ruleProduct$original, _ruleProduct$is_gst;
797
+ var sellingPrice = String((_ruleProduct$price = ruleProduct.price) !== null && _ruleProduct$price !== void 0 ? _ruleProduct$price : '0.00');
798
+ 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');
799
+ nextProducts.push({
800
+ product_id: ruleProduct.id,
801
+ product_variant_id: 0,
802
+ num: 1,
803
+ selling_price: sellingPrice,
804
+ original_price: originalPrice,
805
+ payment_price: sellingPrice,
806
+ is_charge_tax: (_ruleProduct$is_gst = ruleProduct.is_gst) !== null && _ruleProduct$is_gst !== void 0 ? _ruleProduct$is_gst : 0,
807
+ product_option_item: [],
808
+ discount_list: [],
809
+ product_bundle: [],
810
+ booking_uid: bookingUuid,
811
+ metadata: {
812
+ is_rule: true,
813
+ unique_identification_number: ruleProductUid,
814
+ booking_uid: bookingUuid
815
+ }
816
+ });
817
+ }
818
+ return _objectSpread(_objectSpread({}, payload), {}, {
819
+ bookings: nextBookings,
820
+ products: nextProducts
821
+ });
822
+ };
823
+ }
631
824
  }, {
632
825
  key: "submitScanOrder",
633
826
  value: function () {
634
- var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
635
- var _tempOrder$products, result, tempOrder;
636
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
637
- while (1) switch (_context9.prev = _context9.next) {
827
+ var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
828
+ var _this$store$resource, _this$otherParams4, _this$otherParams5, _this$otherParams6, _this$otherParams7, _tempOrder$products, pax, tempOrderForSubmit, resourceTableName, enhancePayload, result, tempOrder;
829
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
830
+ while (1) switch (_context10.prev = _context10.next) {
638
831
  case 0:
639
832
  this.logMethodStart('submitScanOrder');
640
- _context9.prev = 1;
641
- _context9.next = 4;
833
+ _context10.prev = 1;
834
+ _context10.next = 4;
642
835
  return this.validateBeforeSubmitByItemRule();
643
836
  case 4:
644
837
  if (this.store.order) {
645
- _context9.next = 6;
838
+ _context10.next = 6;
646
839
  break;
647
840
  }
648
841
  throw new Error('scanOrder解决方案需要 order 模块支持');
649
842
  case 6:
650
- _context9.next = 8;
843
+ pax = normalizeSubmitCollectPaxValue(this.store.entryPaxNumber);
844
+ this.store.entryPaxNumber = pax;
845
+ tempOrderForSubmit = this.store.order.ensureTempOrder();
846
+ tempOrderForSubmit.metadata = _objectSpread(_objectSpread({}, tempOrderForSubmit.metadata), {}, {
847
+ collect_pax: pax
848
+ });
849
+ tempOrderForSubmit.delivery_type = 'shop_service';
850
+ resourceTableName = (_this$store$resource = this.store.resource) === null || _this$store$resource === void 0 || (_this$store$resource = _this$store$resource.table_form_record) === null || _this$store$resource === void 0 ? void 0 : _this$store$resource.name;
851
+ if (resourceTableName && _typeof(resourceTableName) === 'object') {
852
+ tempOrderForSubmit.table_number = resourceTableName;
853
+ } else {
854
+ delete tempOrderForSubmit.table_number;
855
+ }
856
+ this.store.order.persistTempOrder();
857
+ enhancePayload = this.buildReservationRuleEnhancer();
858
+ _context10.next = 17;
651
859
  return this.store.order.submitTempOrder({
652
- cacheId: this.cacheId
860
+ cacheId: this.cacheId,
861
+ platform: (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.platform,
862
+ businessCode: (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.businessCode,
863
+ channel: (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.channel,
864
+ type: (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.type,
865
+ enhancePayload: enhancePayload
653
866
  });
654
- case 8:
655
- result = _context9.sent;
867
+ case 17:
868
+ result = _context10.sent;
656
869
  tempOrder = this.store.order.getTempOrder();
657
870
  this.logMethodSuccess('submitScanOrder', {
658
871
  productCount: (tempOrder === null || tempOrder === void 0 || (_tempOrder$products = tempOrder.products) === null || _tempOrder$products === void 0 ? void 0 : _tempOrder$products.length) || 0
659
872
  });
660
- return _context9.abrupt("return", result);
661
- case 14:
662
- _context9.prev = 14;
663
- _context9.t0 = _context9["catch"](1);
664
- this.logMethodError('submitScanOrder', _context9.t0);
665
- throw _context9.t0;
666
- case 18:
873
+ return _context10.abrupt("return", result);
874
+ case 23:
875
+ _context10.prev = 23;
876
+ _context10.t0 = _context10["catch"](1);
877
+ this.logMethodError('submitScanOrder', _context10.t0);
878
+ throw _context10.t0;
879
+ case 27:
667
880
  case "end":
668
- return _context9.stop();
881
+ return _context10.stop();
669
882
  }
670
- }, _callee9, this, [[1, 14]]);
883
+ }, _callee10, this, [[1, 23]]);
671
884
  }));
672
885
  function submitScanOrder() {
673
886
  return _submitScanOrder.apply(this, arguments);
@@ -677,46 +890,46 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
677
890
  }, {
678
891
  key: "addProductToOrder",
679
892
  value: function () {
680
- var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(product) {
893
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(product) {
681
894
  var products;
682
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
683
- while (1) switch (_context10.prev = _context10.next) {
895
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
896
+ while (1) switch (_context11.prev = _context11.next) {
684
897
  case 0:
685
898
  this.logMethodStart('addProductToOrder', {
686
899
  product_id: product.product_id,
687
900
  product_variant_id: product.product_variant_id
688
901
  });
689
- _context10.prev = 1;
902
+ _context11.prev = 1;
690
903
  if (this.store.order) {
691
- _context10.next = 4;
904
+ _context11.next = 4;
692
905
  break;
693
906
  }
694
907
  throw new Error('order 模块未初始化');
695
908
  case 4:
696
- _context10.next = 6;
909
+ _context11.next = 6;
697
910
  return this.store.order.addProductToOrder(product);
698
911
  case 6:
699
- products = _context10.sent;
700
- _context10.next = 9;
912
+ products = _context11.sent;
913
+ _context11.next = 9;
701
914
  return this.refreshItemRuleQuantityLimits();
702
915
  case 9:
703
- _context10.next = 11;
916
+ _context11.next = 11;
704
917
  return this.refreshCartValidationPassed();
705
918
  case 11:
706
919
  this.logMethodSuccess('addProductToOrder', {
707
920
  productCount: products.length
708
921
  });
709
- return _context10.abrupt("return", products);
922
+ return _context11.abrupt("return", products);
710
923
  case 15:
711
- _context10.prev = 15;
712
- _context10.t0 = _context10["catch"](1);
713
- this.logMethodError('addProductToOrder', _context10.t0);
714
- throw _context10.t0;
924
+ _context11.prev = 15;
925
+ _context11.t0 = _context11["catch"](1);
926
+ this.logMethodError('addProductToOrder', _context11.t0);
927
+ throw _context11.t0;
715
928
  case 19:
716
929
  case "end":
717
- return _context10.stop();
930
+ return _context11.stop();
718
931
  }
719
- }, _callee10, this, [[1, 15]]);
932
+ }, _callee11, this, [[1, 15]]);
720
933
  }));
721
934
  function addProductToOrder(_x4) {
722
935
  return _addProductToOrder.apply(this, arguments);
@@ -726,46 +939,46 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
726
939
  }, {
727
940
  key: "updateProductInOrder",
728
941
  value: function () {
729
- var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(params) {
942
+ var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(params) {
730
943
  var products;
731
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
732
- while (1) switch (_context11.prev = _context11.next) {
944
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
945
+ while (1) switch (_context12.prev = _context12.next) {
733
946
  case 0:
734
947
  this.logMethodStart('updateProductInOrder', {
735
948
  product_id: params.product_id,
736
949
  product_variant_id: params.product_variant_id
737
950
  });
738
- _context11.prev = 1;
951
+ _context12.prev = 1;
739
952
  if (this.store.order) {
740
- _context11.next = 4;
953
+ _context12.next = 4;
741
954
  break;
742
955
  }
743
956
  throw new Error('order 模块未初始化');
744
957
  case 4:
745
- _context11.next = 6;
958
+ _context12.next = 6;
746
959
  return this.store.order.updateProductInOrder(params);
747
960
  case 6:
748
- products = _context11.sent;
749
- _context11.next = 9;
961
+ products = _context12.sent;
962
+ _context12.next = 9;
750
963
  return this.refreshItemRuleQuantityLimits();
751
964
  case 9:
752
- _context11.next = 11;
965
+ _context12.next = 11;
753
966
  return this.refreshCartValidationPassed();
754
967
  case 11:
755
968
  this.logMethodSuccess('updateProductInOrder', {
756
969
  productCount: products.length
757
970
  });
758
- return _context11.abrupt("return", products);
971
+ return _context12.abrupt("return", products);
759
972
  case 15:
760
- _context11.prev = 15;
761
- _context11.t0 = _context11["catch"](1);
762
- this.logMethodError('updateProductInOrder', _context11.t0);
763
- throw _context11.t0;
973
+ _context12.prev = 15;
974
+ _context12.t0 = _context12["catch"](1);
975
+ this.logMethodError('updateProductInOrder', _context12.t0);
976
+ throw _context12.t0;
764
977
  case 19:
765
978
  case "end":
766
- return _context11.stop();
979
+ return _context12.stop();
767
980
  }
768
- }, _callee11, this, [[1, 15]]);
981
+ }, _callee12, this, [[1, 15]]);
769
982
  }));
770
983
  function updateProductInOrder(_x5) {
771
984
  return _updateProductInOrder.apply(this, arguments);
@@ -775,46 +988,46 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
775
988
  }, {
776
989
  key: "removeProductFromOrder",
777
990
  value: function () {
778
- var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(identity) {
991
+ var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(identity) {
779
992
  var products;
780
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
781
- while (1) switch (_context12.prev = _context12.next) {
993
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
994
+ while (1) switch (_context13.prev = _context13.next) {
782
995
  case 0:
783
996
  this.logMethodStart('removeProductFromOrder', {
784
997
  product_id: identity.product_id,
785
998
  product_variant_id: identity.product_variant_id
786
999
  });
787
- _context12.prev = 1;
1000
+ _context13.prev = 1;
788
1001
  if (this.store.order) {
789
- _context12.next = 4;
1002
+ _context13.next = 4;
790
1003
  break;
791
1004
  }
792
1005
  throw new Error('order 模块未初始化');
793
1006
  case 4:
794
- _context12.next = 6;
1007
+ _context13.next = 6;
795
1008
  return this.store.order.removeProductFromOrder(identity);
796
1009
  case 6:
797
- products = _context12.sent;
798
- _context12.next = 9;
1010
+ products = _context13.sent;
1011
+ _context13.next = 9;
799
1012
  return this.refreshItemRuleQuantityLimits();
800
1013
  case 9:
801
- _context12.next = 11;
1014
+ _context13.next = 11;
802
1015
  return this.refreshCartValidationPassed();
803
1016
  case 11:
804
1017
  this.logMethodSuccess('removeProductFromOrder', {
805
1018
  productCount: products.length
806
1019
  });
807
- return _context12.abrupt("return", products);
1020
+ return _context13.abrupt("return", products);
808
1021
  case 15:
809
- _context12.prev = 15;
810
- _context12.t0 = _context12["catch"](1);
811
- this.logMethodError('removeProductFromOrder', _context12.t0);
812
- throw _context12.t0;
1022
+ _context13.prev = 15;
1023
+ _context13.t0 = _context13["catch"](1);
1024
+ this.logMethodError('removeProductFromOrder', _context13.t0);
1025
+ throw _context13.t0;
813
1026
  case 19:
814
1027
  case "end":
815
- return _context12.stop();
1028
+ return _context13.stop();
816
1029
  }
817
- }, _callee12, this, [[1, 15]]);
1030
+ }, _callee13, this, [[1, 15]]);
818
1031
  }));
819
1032
  function removeProductFromOrder(_x6) {
820
1033
  return _removeProductFromOrder.apply(this, arguments);
@@ -824,26 +1037,26 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
824
1037
  }, {
825
1038
  key: "loadRuntimeConfigs",
826
1039
  value: function () {
827
- var _loadRuntimeConfigs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
1040
+ var _loadRuntimeConfigs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
828
1041
  var itemRuleConfigs;
829
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
830
- while (1) switch (_context13.prev = _context13.next) {
1042
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1043
+ while (1) switch (_context14.prev = _context14.next) {
831
1044
  case 0:
832
- _context13.next = 2;
1045
+ _context14.next = 2;
833
1046
  return this.ensureItemRuleConfigsLoaded();
834
1047
  case 2:
835
- itemRuleConfigs = _context13.sent;
1048
+ itemRuleConfigs = _context14.sent;
836
1049
  this.logMethodSuccess('loadRuntimeConfigs', {
837
1050
  itemRuleCount: itemRuleConfigs.length
838
1051
  });
839
- return _context13.abrupt("return", {
1052
+ return _context14.abrupt("return", {
840
1053
  itemRuleConfigs: itemRuleConfigs
841
1054
  });
842
1055
  case 5:
843
1056
  case "end":
844
- return _context13.stop();
1057
+ return _context14.stop();
845
1058
  }
846
- }, _callee13, this);
1059
+ }, _callee14, this);
847
1060
  }));
848
1061
  function loadRuntimeConfigs() {
849
1062
  return _loadRuntimeConfigs.apply(this, arguments);
@@ -853,15 +1066,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
853
1066
  }, {
854
1067
  key: "syncItemRuleConfigsFromDineInConfig",
855
1068
  value: function () {
856
- var _syncItemRuleConfigsFromDineInConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(dineInConfig) {
1069
+ var _syncItemRuleConfigsFromDineInConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(dineInConfig) {
857
1070
  var enableItemRules, strategyModelIds, itemRuleConfigs;
858
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
859
- while (1) switch (_context14.prev = _context14.next) {
1071
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1072
+ while (1) switch (_context15.prev = _context15.next) {
860
1073
  case 0:
861
1074
  enableItemRules = toBoolean(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['sale.enable_item_rules']);
862
1075
  strategyModelIds = normalizeEnabledItemRuleIds(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['sale.enabled_item_rules']);
863
1076
  if (!(!enableItemRules || !strategyModelIds.length)) {
864
- _context14.next = 8;
1077
+ _context15.next = 8;
865
1078
  break;
866
1079
  }
867
1080
  this.itemRuleConfigs = [];
@@ -872,12 +1085,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
872
1085
  strategyModelIds: [],
873
1086
  itemRuleCount: 0
874
1087
  });
875
- return _context14.abrupt("return", []);
1088
+ return _context15.abrupt("return", []);
876
1089
  case 8:
877
- _context14.next = 10;
1090
+ _context15.next = 10;
878
1091
  return this.fetchItemRuleConfigsByModelIds(strategyModelIds);
879
1092
  case 10:
880
- itemRuleConfigs = _context14.sent;
1093
+ itemRuleConfigs = _context15.sent;
881
1094
  this.itemRuleConfigs = itemRuleConfigs;
882
1095
  this.itemRuleConfigsPromise = Promise.resolve(itemRuleConfigs);
883
1096
  this.itemRuleEvaluator.setStrategyConfigs(itemRuleConfigs);
@@ -886,12 +1099,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
886
1099
  strategyModelIds: strategyModelIds,
887
1100
  itemRuleCount: itemRuleConfigs.length
888
1101
  });
889
- return _context14.abrupt("return", itemRuleConfigs);
1102
+ return _context15.abrupt("return", itemRuleConfigs);
890
1103
  case 16:
891
1104
  case "end":
892
- return _context14.stop();
1105
+ return _context15.stop();
893
1106
  }
894
- }, _callee14, this);
1107
+ }, _callee15, this);
895
1108
  }));
896
1109
  function syncItemRuleConfigsFromDineInConfig(_x7) {
897
1110
  return _syncItemRuleConfigsFromDineInConfig.apply(this, arguments);
@@ -901,22 +1114,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
901
1114
  }, {
902
1115
  key: "fetchItemRuleConfigsByModelIds",
903
1116
  value: function () {
904
- var _fetchItemRuleConfigsByModelIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(strategyModelIds) {
1117
+ var _fetchItemRuleConfigsByModelIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(strategyModelIds) {
905
1118
  var result, configs;
906
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
907
- while (1) switch (_context15.prev = _context15.next) {
1119
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1120
+ while (1) switch (_context16.prev = _context16.next) {
908
1121
  case 0:
909
1122
  this.logMethodStart('fetchItemRuleConfigsByModelIds', {
910
1123
  strategyModelIds: strategyModelIds
911
1124
  });
912
1125
  if (strategyModelIds.length) {
913
- _context15.next = 3;
1126
+ _context16.next = 3;
914
1127
  break;
915
1128
  }
916
- return _context15.abrupt("return", []);
1129
+ return _context16.abrupt("return", []);
917
1130
  case 3:
918
- _context15.prev = 3;
919
- _context15.next = 6;
1131
+ _context16.prev = 3;
1132
+ _context16.next = 6;
920
1133
  return this.request.get('/promotion', {
921
1134
  skip: 1,
922
1135
  num: 99,
@@ -924,7 +1137,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
924
1137
  ids: strategyModelIds
925
1138
  });
926
1139
  case 6:
927
- result = _context15.sent;
1140
+ result = _context16.sent;
928
1141
  configs = [];
929
1142
  if (result.code === 200) {
930
1143
  configs = result.data.list.map(function (item) {
@@ -935,20 +1148,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
935
1148
  strategyModelIds: strategyModelIds,
936
1149
  strategyCount: configs.length
937
1150
  });
938
- return _context15.abrupt("return", configs);
1151
+ return _context16.abrupt("return", configs);
939
1152
  case 13:
940
- _context15.prev = 13;
941
- _context15.t0 = _context15["catch"](3);
942
- this.logMethodError('fetchItemRuleConfigsByModelIds', _context15.t0, {
1153
+ _context16.prev = 13;
1154
+ _context16.t0 = _context16["catch"](3);
1155
+ this.logMethodError('fetchItemRuleConfigsByModelIds', _context16.t0, {
943
1156
  strategyModelIds: strategyModelIds
944
1157
  });
945
1158
  // A:策略加载失败时不阻塞下单
946
- return _context15.abrupt("return", []);
1159
+ return _context16.abrupt("return", []);
947
1160
  case 17:
948
1161
  case "end":
949
- return _context15.stop();
1162
+ return _context16.stop();
950
1163
  }
951
- }, _callee15, this, [[3, 13]]);
1164
+ }, _callee16, this, [[3, 13]]);
952
1165
  }));
953
1166
  function fetchItemRuleConfigsByModelIds(_x8) {
954
1167
  return _fetchItemRuleConfigsByModelIds.apply(this, arguments);
@@ -958,22 +1171,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
958
1171
  }, {
959
1172
  key: "buildPrefillProductSourceMap",
960
1173
  value: function () {
961
- var _buildPrefillProductSourceMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
1174
+ var _buildPrefillProductSourceMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
962
1175
  var sourceMap, productList, visited, collectFromValue;
963
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
964
- while (1) switch (_context16.prev = _context16.next) {
1176
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1177
+ while (1) switch (_context17.prev = _context17.next) {
965
1178
  case 0:
966
1179
  sourceMap = new Map();
967
- _context16.prev = 1;
968
- _context16.next = 4;
1180
+ _context17.prev = 1;
1181
+ _context17.next = 4;
969
1182
  return this.getProductList();
970
1183
  case 4:
971
- productList = _context16.sent;
1184
+ productList = _context17.sent;
972
1185
  if (Array.isArray(productList)) {
973
- _context16.next = 7;
1186
+ _context17.next = 7;
974
1187
  break;
975
1188
  }
976
- return _context16.abrupt("return", sourceMap);
1189
+ return _context17.abrupt("return", sourceMap);
977
1190
  case 7:
978
1191
  visited = new Set();
979
1192
  collectFromValue = function collectFromValue(value) {
@@ -1000,8 +1213,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1000
1213
  var rawProductId = (_node$product_id = node.product_id) !== null && _node$product_id !== void 0 ? _node$product_id : node.id;
1001
1214
  var productId = Number(rawProductId);
1002
1215
  if (Number.isFinite(productId) && productId > 0) {
1003
- var _ref, _node$product_variant;
1004
- var productVariantId = Number((_ref = (_node$product_variant = node.product_variant_id) !== null && _node$product_variant !== void 0 ? _node$product_variant : node.variant_id) !== null && _ref !== void 0 ? _ref : 0);
1216
+ var _ref4, _node$product_variant;
1217
+ 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);
1005
1218
  var normalizedVariantId = Number.isNaN(productVariantId) ? 0 : productVariantId;
1006
1219
  var key = buildProductKey(productId, normalizedVariantId);
1007
1220
  if (!sourceMap.has(key)) {
@@ -1016,19 +1229,19 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1016
1229
  }
1017
1230
  };
1018
1231
  collectFromValue(productList);
1019
- _context16.next = 15;
1232
+ _context17.next = 15;
1020
1233
  break;
1021
1234
  case 12:
1022
- _context16.prev = 12;
1023
- _context16.t0 = _context16["catch"](1);
1024
- this.logMethodError('buildPrefillProductSourceMap', _context16.t0);
1235
+ _context17.prev = 12;
1236
+ _context17.t0 = _context17["catch"](1);
1237
+ this.logMethodError('buildPrefillProductSourceMap', _context17.t0);
1025
1238
  case 15:
1026
- return _context16.abrupt("return", sourceMap);
1239
+ return _context17.abrupt("return", sourceMap);
1027
1240
  case 16:
1028
1241
  case "end":
1029
- return _context16.stop();
1242
+ return _context17.stop();
1030
1243
  }
1031
- }, _callee16, this, [[1, 12]]);
1244
+ }, _callee17, this, [[1, 12]]);
1032
1245
  }));
1033
1246
  function buildPrefillProductSourceMap() {
1034
1247
  return _buildPrefillProductSourceMap.apply(this, arguments);
@@ -1043,58 +1256,58 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1043
1256
  }, {
1044
1257
  key: "ensureItemRuleConfigsLoaded",
1045
1258
  value: function () {
1046
- var _ensureItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
1259
+ var _ensureItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
1047
1260
  var _this3 = this;
1048
1261
  var loadedConfigs;
1049
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1050
- while (1) switch (_context18.prev = _context18.next) {
1262
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1263
+ while (1) switch (_context19.prev = _context19.next) {
1051
1264
  case 0:
1052
1265
  if (!(this.itemRuleConfigs.length > 0)) {
1053
- _context18.next = 2;
1266
+ _context19.next = 2;
1054
1267
  break;
1055
1268
  }
1056
- return _context18.abrupt("return", this.itemRuleConfigs);
1269
+ return _context19.abrupt("return", this.itemRuleConfigs);
1057
1270
  case 2:
1058
1271
  if (!this.itemRuleConfigsPromise) {
1059
- _context18.next = 4;
1272
+ _context19.next = 4;
1060
1273
  break;
1061
1274
  }
1062
- return _context18.abrupt("return", this.itemRuleConfigsPromise);
1275
+ return _context19.abrupt("return", this.itemRuleConfigsPromise);
1063
1276
  case 4:
1064
- this.itemRuleConfigsPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1277
+ this.itemRuleConfigsPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
1065
1278
  var runtimeConfig, staticConfigs;
1066
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1067
- while (1) switch (_context17.prev = _context17.next) {
1279
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1280
+ while (1) switch (_context18.prev = _context18.next) {
1068
1281
  case 0:
1069
1282
  runtimeConfig = _this3.getItemRuleRuntimeConfig();
1070
1283
  staticConfigs = normalizeItemRuleStrategies(runtimeConfig.strategyConfigs);
1071
1284
  if (!(staticConfigs.length > 0)) {
1072
- _context17.next = 6;
1285
+ _context18.next = 6;
1073
1286
  break;
1074
1287
  }
1075
1288
  _this3.itemRuleConfigs = staticConfigs;
1076
1289
  _this3.itemRuleEvaluator.setStrategyConfigs(staticConfigs);
1077
- return _context17.abrupt("return", _this3.itemRuleConfigs);
1290
+ return _context18.abrupt("return", _this3.itemRuleConfigs);
1078
1291
  case 6:
1079
1292
  _this3.itemRuleConfigs = [];
1080
1293
  _this3.itemRuleEvaluator.setStrategyConfigs([]);
1081
- return _context17.abrupt("return", _this3.itemRuleConfigs);
1294
+ return _context18.abrupt("return", _this3.itemRuleConfigs);
1082
1295
  case 9:
1083
1296
  case "end":
1084
- return _context17.stop();
1297
+ return _context18.stop();
1085
1298
  }
1086
- }, _callee17);
1299
+ }, _callee18);
1087
1300
  }))();
1088
- _context18.next = 7;
1301
+ _context19.next = 7;
1089
1302
  return this.itemRuleConfigsPromise;
1090
1303
  case 7:
1091
- loadedConfigs = _context18.sent;
1092
- return _context18.abrupt("return", loadedConfigs);
1304
+ loadedConfigs = _context19.sent;
1305
+ return _context19.abrupt("return", loadedConfigs);
1093
1306
  case 9:
1094
1307
  case "end":
1095
- return _context18.stop();
1308
+ return _context19.stop();
1096
1309
  }
1097
- }, _callee18, this);
1310
+ }, _callee19, this);
1098
1311
  }));
1099
1312
  function ensureItemRuleConfigsLoaded() {
1100
1313
  return _ensureItemRuleConfigsLoaded.apply(this, arguments);
@@ -1104,22 +1317,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1104
1317
  }, {
1105
1318
  key: "refreshItemRuleQuantityLimits",
1106
1319
  value: function () {
1107
- var _refreshItemRuleQuantityLimits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
1320
+ var _refreshItemRuleQuantityLimits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
1108
1321
  var strategyConfigs, businessData, limits;
1109
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1110
- while (1) switch (_context19.prev = _context19.next) {
1322
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1323
+ while (1) switch (_context20.prev = _context20.next) {
1111
1324
  case 0:
1112
- _context19.prev = 0;
1113
- _context19.next = 3;
1325
+ _context20.prev = 0;
1326
+ _context20.next = 3;
1114
1327
  return this.ensureItemRuleConfigsLoaded();
1115
1328
  case 3:
1116
- strategyConfigs = _context19.sent;
1329
+ strategyConfigs = _context20.sent;
1117
1330
  if (strategyConfigs.length) {
1118
- _context19.next = 7;
1331
+ _context20.next = 7;
1119
1332
  break;
1120
1333
  }
1121
1334
  this.store.itemRuleQuantityLimits = [];
1122
- return _context19.abrupt("return", []);
1335
+ return _context20.abrupt("return", []);
1123
1336
  case 7:
1124
1337
  businessData = buildItemRuleBusinessData({
1125
1338
  tempOrder: this.ensureTempOrder(),
@@ -1131,18 +1344,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1131
1344
  this.logMethodSuccess('refreshItemRuleQuantityLimits', {
1132
1345
  limitCount: limits.length
1133
1346
  });
1134
- return _context19.abrupt("return", limits);
1347
+ return _context20.abrupt("return", limits);
1135
1348
  case 14:
1136
- _context19.prev = 14;
1137
- _context19.t0 = _context19["catch"](0);
1349
+ _context20.prev = 14;
1350
+ _context20.t0 = _context20["catch"](0);
1138
1351
  this.store.itemRuleQuantityLimits = [];
1139
- this.logMethodError('refreshItemRuleQuantityLimits', _context19.t0);
1140
- return _context19.abrupt("return", []);
1352
+ this.logMethodError('refreshItemRuleQuantityLimits', _context20.t0);
1353
+ return _context20.abrupt("return", []);
1141
1354
  case 19:
1142
1355
  case "end":
1143
- return _context19.stop();
1356
+ return _context20.stop();
1144
1357
  }
1145
- }, _callee19, this, [[0, 14]]);
1358
+ }, _callee20, this, [[0, 14]]);
1146
1359
  }));
1147
1360
  function refreshItemRuleQuantityLimits() {
1148
1361
  return _refreshItemRuleQuantityLimits.apply(this, arguments);
@@ -1152,32 +1365,32 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1152
1365
  }, {
1153
1366
  key: "applyPrefillByItemRule",
1154
1367
  value: function () {
1155
- var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
1156
- 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, _ref3, _sourceItem$original_, _ref4, _sourceItem$payment_p, sellingPrice, originalPrice, paymentPrice, targetProduct, existedQuantity, delta, nextProduct, hasQuantityChanged, hasOriginChanged;
1157
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1158
- while (1) switch (_context20.prev = _context20.next) {
1368
+ var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
1369
+ 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;
1370
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1371
+ while (1) switch (_context21.prev = _context21.next) {
1159
1372
  case 0:
1160
1373
  if (!this.itemRulePrefillApplied) {
1161
- _context20.next = 2;
1374
+ _context21.next = 2;
1162
1375
  break;
1163
1376
  }
1164
- return _context20.abrupt("return");
1377
+ return _context21.abrupt("return");
1165
1378
  case 2:
1166
1379
  if (this.store.order) {
1167
- _context20.next = 4;
1380
+ _context21.next = 4;
1168
1381
  break;
1169
1382
  }
1170
- return _context20.abrupt("return");
1383
+ return _context21.abrupt("return");
1171
1384
  case 4:
1172
- _context20.next = 6;
1385
+ _context21.next = 6;
1173
1386
  return this.ensureItemRuleConfigsLoaded();
1174
1387
  case 6:
1175
- strategyConfigs = _context20.sent;
1388
+ strategyConfigs = _context21.sent;
1176
1389
  if (strategyConfigs.length) {
1177
- _context20.next = 9;
1390
+ _context21.next = 9;
1178
1391
  break;
1179
1392
  }
1180
- return _context20.abrupt("return");
1393
+ return _context21.abrupt("return");
1181
1394
  case 9:
1182
1395
  businessData = buildItemRuleBusinessData({
1183
1396
  tempOrder: this.ensureTempOrder(),
@@ -1186,24 +1399,24 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1186
1399
  });
1187
1400
  prefillItems = this.itemRuleEvaluator.getPrefillItems(businessData);
1188
1401
  if (prefillItems.length) {
1189
- _context20.next = 14;
1402
+ _context21.next = 14;
1190
1403
  break;
1191
1404
  }
1192
1405
  this.itemRulePrefillApplied = true;
1193
- return _context20.abrupt("return");
1406
+ return _context21.abrupt("return");
1194
1407
  case 14:
1195
- _context20.next = 16;
1408
+ _context21.next = 16;
1196
1409
  return this.buildPrefillProductSourceMap();
1197
1410
  case 16:
1198
- productSourceMap = _context20.sent;
1411
+ productSourceMap = _context21.sent;
1199
1412
  tempOrder = this.ensureTempOrder();
1200
1413
  hasChanges = false;
1201
1414
  _iterator2 = _createForOfIteratorHelper(prefillItems);
1202
- _context20.prev = 20;
1415
+ _context21.prev = 20;
1203
1416
  _iterator2.s();
1204
1417
  case 22:
1205
1418
  if ((_step2 = _iterator2.n()).done) {
1206
- _context20.next = 49;
1419
+ _context21.next = 47;
1207
1420
  break;
1208
1421
  }
1209
1422
  prefillItem = _step2.value;
@@ -1211,16 +1424,16 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1211
1424
  productVariantId = Number((_prefillItem$product_ = prefillItem.product_variant_id) !== null && _prefillItem$product_ !== void 0 ? _prefillItem$product_ : 0);
1212
1425
  targetQuantity = toNonNegativeInt(prefillItem.quantity);
1213
1426
  if (!(!Number.isFinite(productId) || targetQuantity <= 0)) {
1214
- _context20.next = 29;
1427
+ _context21.next = 29;
1215
1428
  break;
1216
1429
  }
1217
- return _context20.abrupt("continue", 47);
1430
+ return _context21.abrupt("continue", 45);
1218
1431
  case 29:
1219
1432
  if (!Number.isNaN(productVariantId)) {
1220
- _context20.next = 31;
1433
+ _context21.next = 31;
1221
1434
  break;
1222
1435
  }
1223
- return _context20.abrupt("continue", 47);
1436
+ return _context21.abrupt("continue", 45);
1224
1437
  case 31:
1225
1438
  sourceItem = productSourceMap.get(buildProductKey(productId, productVariantId)) || productSourceMap.get(buildProductKey(productId, 0)) || null;
1226
1439
  productIndex = getProductIdentityIndex(tempOrder.products, {
@@ -1228,19 +1441,16 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1228
1441
  product_variant_id: productVariantId
1229
1442
  });
1230
1443
  if (!(productIndex === -1)) {
1231
- _context20.next = 40;
1444
+ _context21.next = 38;
1232
1445
  break;
1233
1446
  }
1234
1447
  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');
1235
- originalPrice = toPriceString((_ref3 = (_sourceItem$original_ = sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.original_price) !== null && _sourceItem$original_ !== void 0 ? _sourceItem$original_ : sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.price) !== null && _ref3 !== void 0 ? _ref3 : sellingPrice, sellingPrice);
1236
- paymentPrice = toPriceString((_ref4 = (_sourceItem$payment_p = sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.payment_price) !== null && _sourceItem$payment_p !== void 0 ? _sourceItem$payment_p : sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.price) !== null && _ref4 !== void 0 ? _ref4 : sellingPrice, sellingPrice);
1237
- tempOrder.products.push(normalizeOrderProduct({
1448
+ tempOrder.products.push(normalizeOrderProduct(_objectSpread(_objectSpread({}, sourceItem), {}, {
1238
1449
  product_id: productId,
1239
1450
  product_variant_id: productVariantId,
1240
1451
  num: targetQuantity,
1241
1452
  selling_price: sellingPrice,
1242
- original_price: originalPrice,
1243
- payment_price: paymentPrice,
1453
+ original_price: sellingPrice,
1244
1454
  metadata: {
1245
1455
  item_rule_prefill: true,
1246
1456
  item_rule_id: prefillItem.ruleId
@@ -1249,10 +1459,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1249
1459
  item_rule_prefill: true,
1250
1460
  item_rule_id: prefillItem.ruleId
1251
1461
  })
1252
- }));
1462
+ })));
1253
1463
  hasChanges = true;
1254
- return _context20.abrupt("continue", 47);
1255
- case 40:
1464
+ return _context21.abrupt("continue", 45);
1465
+ case 38:
1256
1466
  targetProduct = tempOrder.products[productIndex];
1257
1467
  existedQuantity = toNonNegativeInt(targetProduct.num);
1258
1468
  delta = targetQuantity - existedQuantity;
@@ -1271,45 +1481,47 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1271
1481
  tempOrder.products[productIndex] = nextProduct;
1272
1482
  hasChanges = true;
1273
1483
  }
1484
+ case 45:
1485
+ _context21.next = 22;
1486
+ break;
1274
1487
  case 47:
1275
- _context20.next = 22;
1488
+ _context21.next = 52;
1276
1489
  break;
1277
1490
  case 49:
1278
- _context20.next = 54;
1279
- break;
1280
- case 51:
1281
- _context20.prev = 51;
1282
- _context20.t0 = _context20["catch"](20);
1283
- _iterator2.e(_context20.t0);
1284
- case 54:
1285
- _context20.prev = 54;
1491
+ _context21.prev = 49;
1492
+ _context21.t0 = _context21["catch"](20);
1493
+ _iterator2.e(_context21.t0);
1494
+ case 52:
1495
+ _context21.prev = 52;
1286
1496
  _iterator2.f();
1287
- return _context20.finish(54);
1288
- case 57:
1497
+ return _context21.finish(52);
1498
+ case 55:
1289
1499
  if (!hasChanges) {
1290
- _context20.next = 61;
1500
+ _context21.next = 60;
1291
1501
  break;
1292
1502
  }
1293
- _context20.next = 60;
1503
+ // Prefill 属于 products CRUD 的一种形式:新增后让 Rules 重算,以支持自动应用可用优惠券。
1504
+ this.store.order.applyDiscount();
1505
+ _context21.next = 59;
1294
1506
  return this.store.order.recalculateSummary({
1295
1507
  createIfMissing: true
1296
1508
  });
1297
- case 60:
1509
+ case 59:
1298
1510
  this.store.order.persistTempOrder();
1299
- case 61:
1300
- _context20.next = 63;
1511
+ case 60:
1512
+ _context21.next = 62;
1301
1513
  return this.refreshItemRuleQuantityLimits();
1302
- case 63:
1514
+ case 62:
1303
1515
  this.itemRulePrefillApplied = true;
1304
1516
  this.logMethodSuccess('applyPrefillByItemRule', {
1305
1517
  prefillCount: prefillItems.length,
1306
1518
  hasChanges: hasChanges
1307
1519
  });
1308
- case 65:
1520
+ case 64:
1309
1521
  case "end":
1310
- return _context20.stop();
1522
+ return _context21.stop();
1311
1523
  }
1312
- }, _callee20, this, [[20, 51, 54, 57]]);
1524
+ }, _callee21, this, [[20, 49, 52, 55]]);
1313
1525
  }));
1314
1526
  function applyPrefillByItemRule() {
1315
1527
  return _applyPrefillByItemRule.apply(this, arguments);
@@ -1319,24 +1531,31 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1319
1531
  }, {
1320
1532
  key: "applyItemRulePrefill",
1321
1533
  value: function () {
1322
- var _applyItemRulePrefill = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
1323
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1324
- while (1) switch (_context21.prev = _context21.next) {
1534
+ var _applyItemRulePrefill = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
1535
+ var _this$store$order4, _this$store$order4$ge;
1536
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1537
+ while (1) switch (_context22.prev = _context22.next) {
1325
1538
  case 0:
1539
+ 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))) {
1540
+ _context22.next = 2;
1541
+ break;
1542
+ }
1543
+ return _context22.abrupt("return");
1544
+ case 2:
1326
1545
  this.logMethodStart('applyItemRulePrefill');
1327
- _context21.next = 3;
1546
+ _context22.next = 5;
1328
1547
  return this.applyPrefillByItemRule();
1329
- case 3:
1330
- _context21.next = 5;
1331
- return this.refreshItemRuleQuantityLimits();
1332
1548
  case 5:
1333
- _context21.next = 7;
1334
- return this.refreshCartValidationPassed();
1549
+ _context22.next = 7;
1550
+ return this.refreshItemRuleQuantityLimits();
1335
1551
  case 7:
1552
+ _context22.next = 9;
1553
+ return this.refreshCartValidationPassed();
1554
+ case 9:
1336
1555
  case "end":
1337
- return _context21.stop();
1556
+ return _context22.stop();
1338
1557
  }
1339
- }, _callee21, this);
1558
+ }, _callee22, this);
1340
1559
  }));
1341
1560
  function applyItemRulePrefill() {
1342
1561
  return _applyItemRulePrefill.apply(this, arguments);
@@ -1346,20 +1565,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1346
1565
  }, {
1347
1566
  key: "evaluateCartValidationByItemRule",
1348
1567
  value: function () {
1349
- var _evaluateCartValidationByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
1568
+ var _evaluateCartValidationByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
1350
1569
  var strategyConfigs, businessData;
1351
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1352
- while (1) switch (_context22.prev = _context22.next) {
1570
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1571
+ while (1) switch (_context23.prev = _context23.next) {
1353
1572
  case 0:
1354
- _context22.next = 2;
1573
+ _context23.next = 2;
1355
1574
  return this.ensureItemRuleConfigsLoaded();
1356
1575
  case 2:
1357
- strategyConfigs = _context22.sent;
1576
+ strategyConfigs = _context23.sent;
1358
1577
  if (strategyConfigs.length) {
1359
- _context22.next = 5;
1578
+ _context23.next = 5;
1360
1579
  break;
1361
1580
  }
1362
- return _context22.abrupt("return", {
1581
+ return _context23.abrupt("return", {
1363
1582
  passed: true,
1364
1583
  failures: []
1365
1584
  });
@@ -1369,12 +1588,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1369
1588
  runtimeConfig: this.getItemRuleRuntimeConfig(),
1370
1589
  itemRuleConfigs: this.itemRuleConfigs
1371
1590
  });
1372
- return _context22.abrupt("return", this.itemRuleEvaluator.validateCart(businessData));
1591
+ return _context23.abrupt("return", this.itemRuleEvaluator.validateCart(businessData));
1373
1592
  case 7:
1374
1593
  case "end":
1375
- return _context22.stop();
1594
+ return _context23.stop();
1376
1595
  }
1377
- }, _callee22, this);
1596
+ }, _callee23, this);
1378
1597
  }));
1379
1598
  function evaluateCartValidationByItemRule() {
1380
1599
  return _evaluateCartValidationByItemRule.apply(this, arguments);
@@ -1384,20 +1603,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1384
1603
  }, {
1385
1604
  key: "validateBeforeSubmitByItemRule",
1386
1605
  value: function () {
1387
- var _validateBeforeSubmitByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
1606
+ var _validateBeforeSubmitByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
1388
1607
  var validationResult, firstFailure, errorMessage, error;
1389
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1390
- while (1) switch (_context23.prev = _context23.next) {
1608
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1609
+ while (1) switch (_context24.prev = _context24.next) {
1391
1610
  case 0:
1392
- _context23.next = 2;
1611
+ _context24.next = 2;
1393
1612
  return this.evaluateCartValidationByItemRule();
1394
1613
  case 2:
1395
- validationResult = _context23.sent;
1614
+ validationResult = _context24.sent;
1396
1615
  if (!validationResult.passed) {
1397
- _context23.next = 5;
1616
+ _context24.next = 5;
1398
1617
  break;
1399
1618
  }
1400
- return _context23.abrupt("return");
1619
+ return _context24.abrupt("return");
1401
1620
  case 5:
1402
1621
  firstFailure = validationResult.failures[0];
1403
1622
  errorMessage = (firstFailure === null || firstFailure === void 0 ? void 0 : firstFailure.validationMessage) || '当前购物车未满足商品规则,请调整后再提交';
@@ -1406,9 +1625,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1406
1625
  throw error;
1407
1626
  case 10:
1408
1627
  case "end":
1409
- return _context23.stop();
1628
+ return _context24.stop();
1410
1629
  }
1411
- }, _callee23, this);
1630
+ }, _callee24, this);
1412
1631
  }));
1413
1632
  function validateBeforeSubmitByItemRule() {
1414
1633
  return _validateBeforeSubmitByItemRule.apply(this, arguments);
@@ -1418,10 +1637,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1418
1637
  }, {
1419
1638
  key: "refreshCartValidationPassed",
1420
1639
  value: function () {
1421
- var _refreshCartValidationPassed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
1640
+ var _refreshCartValidationPassed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
1422
1641
  var previous, nextState, validationResult, changed;
1423
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1424
- while (1) switch (_context24.prev = _context24.next) {
1642
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1643
+ while (1) switch (_context25.prev = _context25.next) {
1425
1644
  case 0:
1426
1645
  previous = this.store.cartValidation || {
1427
1646
  passed: null,
@@ -1431,20 +1650,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1431
1650
  passed: null,
1432
1651
  failures: []
1433
1652
  };
1434
- _context24.prev = 2;
1435
- _context24.next = 5;
1653
+ _context25.prev = 2;
1654
+ _context25.next = 5;
1436
1655
  return this.evaluateCartValidationByItemRule();
1437
1656
  case 5:
1438
- validationResult = _context24.sent;
1657
+ validationResult = _context25.sent;
1439
1658
  nextState = {
1440
1659
  passed: validationResult.passed,
1441
1660
  failures: validationResult.failures || []
1442
1661
  };
1443
- _context24.next = 12;
1662
+ _context25.next = 12;
1444
1663
  break;
1445
1664
  case 9:
1446
- _context24.prev = 9;
1447
- _context24.t0 = _context24["catch"](2);
1665
+ _context25.prev = 9;
1666
+ _context25.t0 = _context25["catch"](2);
1448
1667
  nextState = {
1449
1668
  passed: false,
1450
1669
  failures: []
@@ -1453,21 +1672,21 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1453
1672
  this.store.cartValidation = nextState;
1454
1673
  changed = previous.passed !== nextState.passed || previous.failures !== nextState.failures;
1455
1674
  if (!changed) {
1456
- _context24.next = 17;
1675
+ _context25.next = 17;
1457
1676
  break;
1458
1677
  }
1459
- _context24.next = 17;
1678
+ _context25.next = 17;
1460
1679
  return this.core.effects.emit(ScanOrderHooks.onCartValidationChanged, {
1461
1680
  cartValidation: nextState,
1462
1681
  cartValidationPassed: nextState.passed
1463
1682
  });
1464
1683
  case 17:
1465
- return _context24.abrupt("return", nextState.passed);
1684
+ return _context25.abrupt("return", nextState.passed);
1466
1685
  case 18:
1467
1686
  case "end":
1468
- return _context24.stop();
1687
+ return _context25.stop();
1469
1688
  }
1470
- }, _callee24, this, [[2, 9]]);
1689
+ }, _callee25, this, [[2, 9]]);
1471
1690
  }));
1472
1691
  function refreshCartValidationPassed() {
1473
1692
  return _refreshCartValidationPassed.apply(this, arguments);
@@ -1477,14 +1696,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1477
1696
  }, {
1478
1697
  key: "setItemRuleRuntimeConfig",
1479
1698
  value: function () {
1480
- var _setItemRuleRuntimeConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
1699
+ var _setItemRuleRuntimeConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
1481
1700
  var _this$itemRuleRuntime, _this$itemRuleRuntime2;
1482
1701
  var config,
1483
- _args25 = arguments;
1484
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1485
- while (1) switch (_context25.prev = _context25.next) {
1702
+ _args26 = arguments;
1703
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
1704
+ while (1) switch (_context26.prev = _context26.next) {
1486
1705
  case 0:
1487
- config = _args25.length > 0 && _args25[0] !== undefined ? _args25[0] : {};
1706
+ config = _args26.length > 0 && _args26[0] !== undefined ? _args26[0] : {};
1488
1707
  this.logMethodStart('setItemRuleRuntimeConfig');
1489
1708
  this.itemRuleRuntimeConfig = _objectSpread(_objectSpread(_objectSpread({}, this.itemRuleRuntimeConfig), config), {}, {
1490
1709
  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) || {}),
@@ -1496,10 +1715,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1496
1715
  this.itemRuleEvaluator.setStrategyConfigs([]);
1497
1716
  }
1498
1717
  this.itemRulePrefillApplied = false;
1499
- _context25.next = 7;
1718
+ _context26.next = 7;
1500
1719
  return this.refreshItemRuleQuantityLimits();
1501
1720
  case 7:
1502
- _context25.next = 9;
1721
+ _context26.next = 9;
1503
1722
  return this.refreshCartValidationPassed();
1504
1723
  case 9:
1505
1724
  this.logMethodSuccess('setItemRuleRuntimeConfig', {
@@ -1507,9 +1726,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1507
1726
  });
1508
1727
  case 10:
1509
1728
  case "end":
1510
- return _context25.stop();
1729
+ return _context26.stop();
1511
1730
  }
1512
- }, _callee25, this);
1731
+ }, _callee26, this);
1513
1732
  }));
1514
1733
  function setItemRuleRuntimeConfig() {
1515
1734
  return _setItemRuleRuntimeConfig.apply(this, arguments);
@@ -1519,7 +1738,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1519
1738
  }, {
1520
1739
  key: "normalizeResourceState",
1521
1740
  value: function normalizeResourceState(config, hasOrderId) {
1522
- var _this$otherParams4;
1741
+ var _this$otherParams8, _config$table_form_re;
1523
1742
  var orderNumberPrefix = Array.isArray(config === null || config === void 0 ? void 0 : config.order_number_prefix) ? (config === null || config === void 0 ? void 0 : config.order_number_prefix) || [] : [];
1524
1743
  var tableMaxNumber = Number((config === null || config === void 0 ? void 0 : config.table_max_number) || 1);
1525
1744
  var orderCount = toNonNegativeNumber(config === null || config === void 0 ? void 0 : config.order_count);
@@ -1528,7 +1747,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1528
1747
  var relationId = toPositiveString(config === null || config === void 0 ? void 0 : config.relation_id);
1529
1748
  var tableFormId = toPositiveString(config === null || config === void 0 ? void 0 : config.table_form_id);
1530
1749
  // 是否允许加餐
1531
- var allowSnack = ((_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 || (_this$otherParams4 = _this$otherParams4.dineInConfig) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4['workflow.allow_add_items']) || false;
1750
+ 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;
1532
1751
  // 开启同桌验证 - 本期没有这个配置,默认关掉
1533
1752
  var deskmateValid = false;
1534
1753
  var isExclusive = tableMaxNumber > 0 ? tableMaxNumber <= 1 : false;
@@ -1598,43 +1817,44 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1598
1817
  isExclusive: isExclusive,
1599
1818
  isFull: isFull,
1600
1819
  orderNumberPrefix: orderNumberPrefix,
1601
- raw: config
1820
+ raw: config,
1821
+ table_form_record: (_config$table_form_re = config === null || config === void 0 ? void 0 : config.table_form_record) !== null && _config$table_form_re !== void 0 ? _config$table_form_re : null
1602
1822
  });
1603
1823
  }
1604
1824
  }, {
1605
1825
  key: "fetchTableConfigByResourceId",
1606
1826
  value: function () {
1607
- var _fetchTableConfigByResourceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(resourceId) {
1827
+ var _fetchTableConfigByResourceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(resourceId) {
1608
1828
  var tableResourceId, response;
1609
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
1610
- while (1) switch (_context26.prev = _context26.next) {
1829
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
1830
+ while (1) switch (_context27.prev = _context27.next) {
1611
1831
  case 0:
1612
1832
  tableResourceId = Number(resourceId);
1613
1833
  if (!(!Number.isFinite(tableResourceId) || tableResourceId <= 0)) {
1614
- _context26.next = 3;
1834
+ _context27.next = 3;
1615
1835
  break;
1616
1836
  }
1617
1837
  throw new Error("[ScanOrder] \u975E\u6CD5\u684C\u53F0 resourceId: ".concat(resourceId));
1618
1838
  case 3:
1619
- _context26.next = 5;
1839
+ _context27.next = 5;
1620
1840
  return this.request.get('/order/dining/table/config', {
1621
1841
  table_resource_id: tableResourceId,
1622
1842
  with_table_form_info: 1
1623
1843
  });
1624
1844
  case 5:
1625
- response = _context26.sent;
1845
+ response = _context27.sent;
1626
1846
  if (response !== null && response !== void 0 && response.status) {
1627
- _context26.next = 8;
1847
+ _context27.next = 8;
1628
1848
  break;
1629
1849
  }
1630
1850
  throw new Error((response === null || response === void 0 ? void 0 : response.message) || '获取桌台配置失败');
1631
1851
  case 8:
1632
- return _context26.abrupt("return", (response === null || response === void 0 ? void 0 : response.data) || null);
1852
+ return _context27.abrupt("return", (response === null || response === void 0 ? void 0 : response.data) || null);
1633
1853
  case 9:
1634
1854
  case "end":
1635
- return _context26.stop();
1855
+ return _context27.stop();
1636
1856
  }
1637
- }, _callee26, this);
1857
+ }, _callee27, this);
1638
1858
  }));
1639
1859
  function fetchTableConfigByResourceId(_x9) {
1640
1860
  return _fetchTableConfigByResourceId.apply(this, arguments);
@@ -1646,58 +1866,89 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1646
1866
  }, {
1647
1867
  key: "checkResourceAvailable",
1648
1868
  value: function () {
1649
- var _checkResourceAvailable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(resourceId, hasOrderId) {
1650
- var _this$otherParams5, _this$otherParams5$ge, _config$table_form_re, _config$table_form_re2, _this$otherParams6, _this$store$order4, openData, dineInConfig, shopClosedInfo, config, resourceState, availabilityInfo, tempOrder;
1651
- return _regeneratorRuntime().wrap(function _callee27$(_context27) {
1652
- while (1) switch (_context27.prev = _context27.next) {
1869
+ var _checkResourceAvailable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(resourceId, hasOrderId) {
1870
+ var _this$otherParams9, _this$otherParams9$ge, _config$table_form_re2, _config$table_form_re3, _this$otherParams10, _this$store$order5, _this$store$order7, _this$store$order7$ge, _this$otherParams11, openData, dineInConfig, closedBehaviorValue, closedMessage, basicUnavailableMessage, pauseMessage, makeShopClosed, operatingHourIds, outsideOperatingHours, scheduleList, now, config, resourceState, availabilityInfo, tempOrder, reservationLinkIds, reservationProductList, scheduleDate, scheduleDatetime, loaded, occupancyMinutes, paxBounds, _this$store$order6, _res$data, res, entryPaxNumber, lastOrderInfo, historicalItems;
1871
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
1872
+ while (1) switch (_context28.prev = _context28.next) {
1653
1873
  case 0:
1654
1874
  this.logMethodStart('checkResourceAvailable', {
1655
1875
  resourceId: resourceId
1656
1876
  });
1657
- _context27.prev = 1;
1658
- _context27.next = 4;
1659
- return (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 || (_this$otherParams5$ge = _this$otherParams5.getOpenData) === null || _this$otherParams5$ge === void 0 ? void 0 : _this$otherParams5$ge.call(_this$otherParams5, {
1877
+ _context28.prev = 1;
1878
+ _context28.next = 4;
1879
+ return (_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 || (_this$otherParams9$ge = _this$otherParams9.getOpenData) === null || _this$otherParams9$ge === void 0 ? void 0 : _this$otherParams9$ge.call(_this$otherParams9, {
1660
1880
  scope: 'board',
1661
1881
  target: 'dine_in+scan_to_order',
1662
1882
  section_code: ['basic', 'fulfillment', 'reservation', 'sale', 'menu', 'availability', 'workflow']
1663
1883
  });
1664
1884
  case 4:
1665
- openData = _context27.sent;
1885
+ openData = _context28.sent;
1666
1886
  if (!((openData === null || openData === void 0 ? void 0 : openData.status) === false)) {
1667
- _context27.next = 7;
1887
+ _context28.next = 7;
1668
1888
  break;
1669
1889
  }
1670
1890
  throw new Error((openData === null || openData === void 0 ? void 0 : openData.message) || '获取店铺配置失败');
1671
1891
  case 7:
1672
1892
  dineInConfig = (openData === null || openData === void 0 ? void 0 : openData.data) || {};
1673
1893
  this.otherParams.dineInConfig = dineInConfig;
1674
- _context27.next = 11;
1894
+ _context28.next = 11;
1675
1895
  return this.syncItemRuleConfigsFromDineInConfig(dineInConfig);
1676
1896
  case 11:
1677
- shopClosedInfo = function shopClosedInfo() {
1897
+ closedBehaviorValue = dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.closed_behavior'];
1898
+ closedMessage = (dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.closed_message']) || (dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.message']) || (dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['basic.closed_message']);
1899
+ basicUnavailableMessage = (dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['basic.unavailable_message']) || closedMessage;
1900
+ pauseMessage = (dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.pause_message']) || closedMessage;
1901
+ makeShopClosed = function makeShopClosed(errorTips, closed_behavior) {
1678
1902
  return {
1679
1903
  mode: 'shop_closed',
1680
1904
  order_id: undefined,
1681
1905
  relation_id: undefined,
1682
1906
  table_form_id: undefined,
1683
1907
  deskmate_valid: false,
1684
- errorTips: (dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.pause_message']) || (dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.closed_message']) || (dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.message']) || (dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['basic.closed_message'])
1908
+ errorTips: errorTips,
1909
+ closed_behavior: closed_behavior
1685
1910
  };
1686
- }; // 检测是否暂停营业
1911
+ }; // 1. 基础开关 basic.enable 关闭
1912
+ if (!((dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['basic.enable']) === false)) {
1913
+ _context28.next = 18;
1914
+ break;
1915
+ }
1916
+ return _context28.abrupt("return", makeShopClosed(basicUnavailableMessage));
1917
+ case 18:
1687
1918
  if (!toBoolean(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.paused'])) {
1688
- _context27.next = 15;
1919
+ _context28.next = 21;
1689
1920
  break;
1690
1921
  }
1691
1922
  if (!((dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.pause_behavior']) === 'hide_all')) {
1692
- _context27.next = 15;
1923
+ _context28.next = 21;
1693
1924
  break;
1694
1925
  }
1695
- return _context27.abrupt("return", shopClosedInfo());
1696
- case 15:
1697
- _context27.next = 17;
1926
+ return _context28.abrupt("return", makeShopClosed(pauseMessage));
1927
+ case 21:
1928
+ // 3. 营业时间 operating_hours 闸门
1929
+ operatingHourIds = Array.isArray(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.operating_hours']) ? dineInConfig['availability.operating_hours'].map(function (id) {
1930
+ return Number(id);
1931
+ }).filter(function (id) {
1932
+ return Number.isFinite(id) && id > 0;
1933
+ }) : [];
1934
+ outsideOperatingHours = false;
1935
+ if (operatingHourIds.length && this.store.schedule) {
1936
+ scheduleList = this.store.schedule.getScheduleListByIds(operatingHourIds);
1937
+ if (scheduleList.length) {
1938
+ now = dayjs().format('YYYY-MM-DD HH:mm:ss');
1939
+ outsideOperatingHours = !getDateIsInSchedule(now, scheduleList);
1940
+ }
1941
+ }
1942
+ if (!(outsideOperatingHours && closedBehaviorValue !== 'show_menu_disabled')) {
1943
+ _context28.next = 26;
1944
+ break;
1945
+ }
1946
+ return _context28.abrupt("return", makeShopClosed(closedMessage, closedBehaviorValue));
1947
+ case 26:
1948
+ _context28.next = 28;
1698
1949
  return this.fetchTableConfigByResourceId(resourceId);
1699
- case 17:
1700
- config = _context27.sent;
1950
+ case 28:
1951
+ config = _context28.sent;
1701
1952
  resourceState = this.normalizeResourceState(config, hasOrderId);
1702
1953
  this.store.resource = resourceState;
1703
1954
  availabilityInfo = {
@@ -1706,33 +1957,160 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1706
1957
  relation_id: resourceState.relationId,
1707
1958
  table_form_id: resourceState.tableFormId,
1708
1959
  deskmate_valid: resourceState.deskmate_valid,
1709
- policy: config === null || config === void 0 || (_config$table_form_re = config.table_form_record) === null || _config$table_form_re === void 0 ? void 0 : _config$table_form_re.policy,
1710
- partyroom_booking: config === null || config === void 0 || (_config$table_form_re2 = config.table_form_record) === null || _config$table_form_re2 === void 0 ? void 0 : _config$table_form_re2.partyroom_booking
1960
+ table_form_record: resourceState.table_form_record,
1961
+ policy: config === null || config === void 0 || (_config$table_form_re2 = config.table_form_record) === null || _config$table_form_re2 === void 0 ? void 0 : _config$table_form_re2.policy,
1962
+ partyroom_booking: config === null || config === void 0 || (_config$table_form_re3 = config.table_form_record) === null || _config$table_form_re3 === void 0 ? void 0 : _config$table_form_re3.partyroom_booking
1711
1963
  };
1712
1964
  tempOrder = this.ensureTempOrder();
1713
- tempOrder.relation_id = resourceId || ((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.relation_id);
1965
+ tempOrder.relation_id = resourceId || ((_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.relation_id);
1714
1966
  tempOrder.table_form_id = resourceState.tableFormId;
1715
1967
  tempOrder.resource_id = resourceId;
1716
- (_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 || _this$store$order4.persistTempOrder();
1968
+ reservationLinkIds = collectLinkProductIdsFromReservationRules(dineInConfig['fulfillment.enabled_resource_rules']);
1969
+ if (!(reservationLinkIds.length === 0)) {
1970
+ _context28.next = 42;
1971
+ break;
1972
+ }
1973
+ this.enabledReservationRuleProducts = [];
1974
+ if (this.store.resource) {
1975
+ delete this.store.resource.requestEntryPax;
1976
+ delete this.store.resource.requestPaxMin;
1977
+ delete this.store.resource.requestPaxMax;
1978
+ }
1979
+ _context28.next = 53;
1980
+ break;
1981
+ case 42:
1982
+ tempOrder.metadata = _objectSpread({}, tempOrder.metadata || {});
1983
+ delete tempOrder.metadata.table_occupancy_duration;
1984
+ reservationProductList = new ProductList("".concat(this.name, "_reservationEnabledRules"), this.defaultVersion);
1985
+ _context28.next = 47;
1986
+ return reservationProductList.initialize(this.core, {
1987
+ store: {
1988
+ list: [],
1989
+ selectProducts: []
1990
+ },
1991
+ otherParams: _objectSpread(_objectSpread({}, this.otherParams), {}, {
1992
+ fatherModule: this.name,
1993
+ openCache: Boolean(this.cacheId),
1994
+ cacheId: this.cacheId
1995
+ })
1996
+ });
1997
+ case 47:
1998
+ scheduleDate = dayjs().format('YYYY-MM-DD');
1999
+ scheduleDatetime = dayjs().format('YYYY-MM-DD HH:mm:ss');
2000
+ _context28.next = 51;
2001
+ return reservationProductList.loadProducts({
2002
+ product_ids: reservationLinkIds,
2003
+ schedule_date: scheduleDate,
2004
+ schedule_datetime: scheduleDatetime,
2005
+ cacheId: this.cacheId
2006
+ });
2007
+ case 51:
2008
+ loaded = _context28.sent;
2009
+ if (Array.isArray(loaded)) {
2010
+ this.enabledReservationRuleProducts = loaded;
2011
+ occupancyMinutes = pickFirstDurationMinutesFromProducts(loaded);
2012
+ if (occupancyMinutes !== undefined) {
2013
+ tempOrder.metadata.table_occupancy_duration = occupancyMinutes;
2014
+ }
2015
+ if (hasCustomCapacityProduct(loaded)) {
2016
+ availabilityInfo.requestEntryPax = 1;
2017
+ if (this.store.resource) this.store.resource.requestEntryPax = 1;
2018
+ delete availabilityInfo.requestPaxMin;
2019
+ delete availabilityInfo.requestPaxMax;
2020
+ if (this.store.resource) {
2021
+ delete this.store.resource.requestPaxMin;
2022
+ delete this.store.resource.requestPaxMax;
2023
+ }
2024
+ paxBounds = pickFirstCustomCapacityPaxBounds(loaded);
2025
+ if ((paxBounds === null || paxBounds === void 0 ? void 0 : paxBounds.min) !== undefined) {
2026
+ availabilityInfo.requestPaxMin = paxBounds.min;
2027
+ if (this.store.resource) this.store.resource.requestPaxMin = paxBounds.min;
2028
+ }
2029
+ if ((paxBounds === null || paxBounds === void 0 ? void 0 : paxBounds.max) !== undefined) {
2030
+ availabilityInfo.requestPaxMax = paxBounds.max;
2031
+ if (this.store.resource) this.store.resource.requestPaxMax = paxBounds.max;
2032
+ }
2033
+ } else if (this.store.resource) {
2034
+ delete this.store.resource.requestEntryPax;
2035
+ delete this.store.resource.requestPaxMin;
2036
+ delete this.store.resource.requestPaxMax;
2037
+ }
2038
+ } else {
2039
+ this.enabledReservationRuleProducts = [];
2040
+ if (this.store.resource) {
2041
+ delete this.store.resource.requestEntryPax;
2042
+ delete this.store.resource.requestPaxMin;
2043
+ delete this.store.resource.requestPaxMax;
2044
+ }
2045
+ void this.addScanOrderLog({
2046
+ level: 'error',
2047
+ title: '[ScanOrder] enabled_reservation_rules product query failed',
2048
+ payload: {
2049
+ linkIds: reservationLinkIds,
2050
+ error: this.serializeError(loaded)
2051
+ }
2052
+ });
2053
+ }
2054
+ case 53:
2055
+ (_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 || _this$store$order5.persistTempOrder();
1717
2056
 
1718
2057
  // 空闲状态下自动准备本地临时订单,供后续“购物车式”商品操作使用
1719
2058
  if (!(availabilityInfo.mode === 'idle')) {
1720
- _context27.next = 29;
2059
+ _context28.next = 57;
1721
2060
  break;
1722
2061
  }
1723
- _context27.next = 29;
2062
+ _context28.next = 57;
1724
2063
  return this.addNewOrder();
1725
- case 29:
2064
+ case 57:
1726
2065
  // 如果是加单模式,tempOrder 里 需要记录 lastOrderId,提交的时候走加单接口
1727
2066
  if (availabilityInfo.mode === 'additional_order' || availabilityInfo.mode === 'additional_order_with_code') {
1728
2067
  tempOrder.order_id = resourceState.lastOrderId;
1729
2068
  }
1730
- _context27.next = 32;
1731
- return this.refreshItemRuleQuantityLimits();
1732
- case 32:
1733
- _context27.next = 34;
1734
- return this.refreshCartValidationPassed();
1735
- case 34:
2069
+ if (!tempOrder.order_id) {
2070
+ _context28.next = 66;
2071
+ break;
2072
+ }
2073
+ _context28.next = 61;
2074
+ return (_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 ? void 0 : _this$store$order6.getOrderInfoByRemote(tempOrder.order_id);
2075
+ case 61:
2076
+ res = _context28.sent;
2077
+ // 找到下单的时候输入的 entryPaxNumber
2078
+ 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) {
2079
+ var _p$metadata;
2080
+ return (_p$metadata = p.metadata) === null || _p$metadata === void 0 ? void 0 : _p$metadata.collect_pax;
2081
+ })) === null || _res$data === void 0 || (_res$data = _res$data.metadata) === null || _res$data === void 0 ? void 0 : _res$data.collect_pax;
2082
+ if (!entryPaxNumber) {
2083
+ _context28.next = 66;
2084
+ break;
2085
+ }
2086
+ _context28.next = 66;
2087
+ return this.setEntryPaxNumber(entryPaxNumber);
2088
+ case 66:
2089
+ 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);
2090
+ historicalItems = hasOrderId && Array.isArray(lastOrderInfo === null || lastOrderInfo === void 0 ? void 0 : lastOrderInfo.products) ? lastOrderInfo.products.reduce(function (acc, p) {
2091
+ if (typeof (p === null || p === void 0 ? void 0 : p.product_id) !== 'number') return acc;
2092
+ acc.push(_objectSpread({
2093
+ product_id: p.product_id,
2094
+ quantity: Number(p.product_quantity) || 0
2095
+ }, typeof p.product_variant_id === 'number' ? {
2096
+ product_variant_id: p.product_variant_id
2097
+ } : {}));
2098
+ return acc;
2099
+ }, []) : []; // pax 由 setEntryPaxNumber 负责写入 itemRuleRuntimeConfig.pax
2100
+ _context28.next = 70;
2101
+ return this.setItemRuleRuntimeConfig({
2102
+ serviceType: (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.businessCode,
2103
+ submissionIndex: hasOrderId ? 1 : 0,
2104
+ historicalItems: historicalItems
2105
+ });
2106
+ case 70:
2107
+ // operating_hours 超出营业时段 + closed_behavior=show_menu_disabled:
2108
+ // 允许浏览商品但 UI 层需拦截“下一步”,这里覆盖最终 mode 并回传错误提示
2109
+ if (outsideOperatingHours && closedBehaviorValue === 'show_menu_disabled') {
2110
+ availabilityInfo.mode = 'submit_disabled';
2111
+ availabilityInfo.errorTips = closedMessage;
2112
+ availabilityInfo.closed_behavior = closedBehaviorValue;
2113
+ }
1736
2114
  this.logMethodSuccess('checkResourceAvailable', {
1737
2115
  resourceId: resourceId,
1738
2116
  mode: availabilityInfo.mode,
@@ -1747,19 +2125,19 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1747
2125
  isExclusive: resourceState.isExclusive,
1748
2126
  isFull: resourceState.isFull
1749
2127
  });
1750
- return _context27.abrupt("return", availabilityInfo);
1751
- case 38:
1752
- _context27.prev = 38;
1753
- _context27.t0 = _context27["catch"](1);
1754
- this.logMethodError('checkResourceAvailable', _context27.t0, {
2128
+ return _context28.abrupt("return", availabilityInfo);
2129
+ case 75:
2130
+ _context28.prev = 75;
2131
+ _context28.t0 = _context28["catch"](1);
2132
+ this.logMethodError('checkResourceAvailable', _context28.t0, {
1755
2133
  resourceId: resourceId
1756
2134
  });
1757
- throw _context27.t0;
1758
- case 42:
2135
+ throw _context28.t0;
2136
+ case 79:
1759
2137
  case "end":
1760
- return _context27.stop();
2138
+ return _context28.stop();
1761
2139
  }
1762
- }, _callee27, this, [[1, 38]]);
2140
+ }, _callee28, this, [[1, 75]]);
1763
2141
  }));
1764
2142
  function checkResourceAvailable(_x10, _x11) {
1765
2143
  return _checkResourceAvailable.apply(this, arguments);
@@ -1769,10 +2147,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1769
2147
  }, {
1770
2148
  key: "getAdditionalOrderInfo",
1771
2149
  value: function () {
1772
- var _getAdditionalOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
2150
+ var _getAdditionalOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
1773
2151
  var result;
1774
- return _regeneratorRuntime().wrap(function _callee28$(_context28) {
1775
- while (1) switch (_context28.prev = _context28.next) {
2152
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2153
+ while (1) switch (_context29.prev = _context29.next) {
1776
2154
  case 0:
1777
2155
  this.logMethodStart('getAdditionalOrderInfo');
1778
2156
  result = {
@@ -1786,12 +2164,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1786
2164
  orderId: result.orderId,
1787
2165
  orderStatus: result.orderStatus
1788
2166
  });
1789
- return _context28.abrupt("return", result);
2167
+ return _context29.abrupt("return", result);
1790
2168
  case 4:
1791
2169
  case "end":
1792
- return _context28.stop();
2170
+ return _context29.stop();
1793
2171
  }
1794
- }, _callee28, this);
2172
+ }, _callee29, this);
1795
2173
  }));
1796
2174
  function getAdditionalOrderInfo() {
1797
2175
  return _getAdditionalOrderInfo.apply(this, arguments);
@@ -1801,19 +2179,19 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1801
2179
  }, {
1802
2180
  key: "getProductList",
1803
2181
  value: function () {
1804
- var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
1805
- var _this$otherParams7;
2182
+ var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
2183
+ var _this$otherParams12;
1806
2184
  var menu_list_ids, _this$store$products, res, formattedRes;
1807
- return _regeneratorRuntime().wrap(function _callee29$(_context29) {
1808
- while (1) switch (_context29.prev = _context29.next) {
2185
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2186
+ while (1) switch (_context30.prev = _context30.next) {
1809
2187
  case 0:
1810
2188
  this.logMethodStart('getProductList');
1811
2189
  // 可以直接通过配置里的 menu 读取
1812
- menu_list_ids = ((_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 || (_this$otherParams7 = _this$otherParams7.dineInConfig) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7['menu.associated_menus'].map(function (n) {
2190
+ menu_list_ids = ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 || (_this$otherParams12 = _this$otherParams12.dineInConfig) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12['menu.associated_menus'].map(function (n) {
1813
2191
  return Number(n.value);
1814
2192
  })) || [];
1815
- _context29.prev = 2;
1816
- _context29.next = 5;
2193
+ _context30.prev = 2;
2194
+ _context30.next = 5;
1817
2195
  return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
1818
2196
  menu_list_ids: menu_list_ids,
1819
2197
  cacheId: this.cacheId,
@@ -1821,22 +2199,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1821
2199
  schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
1822
2200
  });
1823
2201
  case 5:
1824
- res = _context29.sent;
2202
+ res = _context30.sent;
1825
2203
  formattedRes = attachItemRuleLimitsToTopLevelProducts(res, this.store.itemRuleQuantityLimits || []);
1826
2204
  this.logMethodSuccess('getProductList', {
1827
2205
  menuCount: menu_list_ids.length
1828
2206
  });
1829
- return _context29.abrupt("return", formattedRes);
2207
+ return _context30.abrupt("return", formattedRes);
1830
2208
  case 11:
1831
- _context29.prev = 11;
1832
- _context29.t0 = _context29["catch"](2);
1833
- this.logMethodError('getProductList', _context29.t0);
1834
- throw _context29.t0;
2209
+ _context30.prev = 11;
2210
+ _context30.t0 = _context30["catch"](2);
2211
+ this.logMethodError('getProductList', _context30.t0);
2212
+ throw _context30.t0;
1835
2213
  case 15:
1836
2214
  case "end":
1837
- return _context29.stop();
2215
+ return _context30.stop();
1838
2216
  }
1839
- }, _callee29, this, [[2, 11]]);
2217
+ }, _callee30, this, [[2, 11]]);
1840
2218
  }));
1841
2219
  function getProductList() {
1842
2220
  return _getProductList.apply(this, arguments);
@@ -1848,6 +2226,122 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1848
2226
  value: function getOtherParams() {
1849
2227
  return this.otherParams;
1850
2228
  }
2229
+ }, {
2230
+ key: "setOtherParams",
2231
+ value: function () {
2232
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
2233
+ var _ref6,
2234
+ _ref6$cover,
2235
+ cover,
2236
+ _args31 = arguments;
2237
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2238
+ while (1) switch (_context31.prev = _context31.next) {
2239
+ case 0:
2240
+ _ref6 = _args31.length > 1 && _args31[1] !== undefined ? _args31[1] : {}, _ref6$cover = _ref6.cover, cover = _ref6$cover === void 0 ? false : _ref6$cover;
2241
+ if (cover) {
2242
+ this.otherParams = params;
2243
+ } else {
2244
+ this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
2245
+ }
2246
+ case 2:
2247
+ case "end":
2248
+ return _context31.stop();
2249
+ }
2250
+ }, _callee31, this);
2251
+ }));
2252
+ function setOtherParams(_x12) {
2253
+ return _setOtherParams.apply(this, arguments);
2254
+ }
2255
+ return setOtherParams;
2256
+ }()
2257
+ }, {
2258
+ key: "setEntryPaxNumber",
2259
+ value: function () {
2260
+ var _setEntryPaxNumber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(number) {
2261
+ var pax, t;
2262
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2263
+ while (1) switch (_context32.prev = _context32.next) {
2264
+ case 0:
2265
+ pax = normalizeSubmitCollectPaxValue(number);
2266
+ this.store.entryPaxNumber = pax;
2267
+ if (this.store.order) {
2268
+ t = this.store.order.ensureTempOrder();
2269
+ t.metadata = _objectSpread(_objectSpread({}, t.metadata), {}, {
2270
+ collect_pax: pax
2271
+ });
2272
+ this.store.order.persistTempOrder();
2273
+ }
2274
+
2275
+ // pax 变化后同步到 itemRuleRuntimeConfig,并刷新限购 / 校验
2276
+ this.itemRuleRuntimeConfig = _objectSpread(_objectSpread({}, this.itemRuleRuntimeConfig), {}, {
2277
+ pax: {
2278
+ total: pax,
2279
+ adult: 0,
2280
+ child: 0
2281
+ }
2282
+ });
2283
+ this.itemRulePrefillApplied = false;
2284
+ _context32.next = 7;
2285
+ return this.refreshItemRuleQuantityLimits();
2286
+ case 7:
2287
+ _context32.next = 9;
2288
+ return this.refreshCartValidationPassed();
2289
+ case 9:
2290
+ case "end":
2291
+ return _context32.stop();
2292
+ }
2293
+ }, _callee32, this);
2294
+ }));
2295
+ function setEntryPaxNumber(_x13) {
2296
+ return _setEntryPaxNumber.apply(this, arguments);
2297
+ }
2298
+ return setEntryPaxNumber;
2299
+ }()
2300
+ }, {
2301
+ key: "getEntryPaxNumber",
2302
+ value: function getEntryPaxNumber() {
2303
+ return this.store.entryPaxNumber;
2304
+ }
2305
+
2306
+ // 读取取餐/送餐开关
2307
+ // 依赖 checkResourceAvailable 已缓存的 dineInConfig
2308
+ }, {
2309
+ key: "getFulfillmentModes",
2310
+ value: function getFulfillmentModes() {
2311
+ var _this$otherParams13;
2312
+ this.logMethodStart('getFulfillmentModes');
2313
+ var dineInConfig = ((_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.dineInConfig) || {};
2314
+ var result = {
2315
+ enablePickup: Boolean(dineInConfig['fulfillment.enable_pickup']),
2316
+ enableTableService: Boolean(dineInConfig['fulfillment.enable_table_service'])
2317
+ };
2318
+ this.logMethodSuccess('getFulfillmentModes', result);
2319
+ return result;
2320
+ }
2321
+
2322
+ // 判定后台是否开启客户自定义取餐标识
2323
+ // 依赖 checkResourceAvailable 已缓存的 dineInConfig
2324
+ }, {
2325
+ key: "checkManualPickupRef",
2326
+ value: function checkManualPickupRef() {
2327
+ var _this$otherParams14;
2328
+ this.logMethodStart('checkManualPickupRef');
2329
+ var dineInConfig = ((_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.dineInConfig) || {};
2330
+ var refMode = dineInConfig['fulfillment.fulfillment_ref_mode'];
2331
+ var manualInputType = dineInConfig['fulfillment.manual_input_type'];
2332
+ var enabled = refMode === 'manual_input';
2333
+ var result = enabled ? {
2334
+ enabled: true,
2335
+ manualInputType: manualInputType
2336
+ } : {
2337
+ enabled: false
2338
+ };
2339
+ this.logMethodSuccess('checkManualPickupRef', {
2340
+ enabled: enabled,
2341
+ manualInputType: enabled ? manualInputType : undefined
2342
+ });
2343
+ return result;
2344
+ }
1851
2345
  }]);
1852
2346
  return ScanOrderImpl;
1853
2347
  }(BaseModule);