@pisell/pisellos 0.0.501 → 0.0.503

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