@pisell/pisellos 0.0.501 → 0.0.502

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