@pisell/pisellos 0.0.516 → 0.0.518

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 (47) hide show
  1. package/dist/modules/Cart/utils/cartProduct.js +1 -1
  2. package/dist/modules/Order/index.d.ts +1 -1
  3. package/dist/modules/Order/utils.js +16 -13
  4. package/dist/modules/ProductList/index.js +2 -1
  5. package/dist/modules/Quotation/index.d.ts +1 -1
  6. package/dist/modules/Quotation/index.js +2 -2
  7. package/dist/modules/Rules/index.js +1 -0
  8. package/dist/modules/ScanOrderLogger/index.d.ts +2 -0
  9. package/dist/modules/ScanOrderLogger/index.js +15 -2
  10. package/dist/modules/ScanOrderLogger/providers/feishu.js +45 -27
  11. package/dist/modules/ScanOrderLogger/types.d.ts +1 -0
  12. package/dist/solution/BookingByStep/index.d.ts +2 -2
  13. package/dist/solution/BookingByStep/index.js +2 -1
  14. package/dist/solution/BookingTicket/index.d.ts +1 -1
  15. package/dist/solution/ScanOrder/index.d.ts +7 -1
  16. package/dist/solution/ScanOrder/index.js +207 -97
  17. package/dist/solution/ScanOrder/utils.js +5 -5
  18. package/dist/solution/VenueBooking/index.d.ts +2 -0
  19. package/dist/solution/VenueBooking/index.js +94 -42
  20. package/dist/solution/VenueBooking/types.d.ts +1 -0
  21. package/dist/solution/VenueBooking/utils/resource.js +1 -0
  22. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
  23. package/dist/solution/VenueBooking/utils/slotMerge.js +16 -1
  24. package/lib/modules/Cart/utils/cartProduct.js +1 -1
  25. package/lib/modules/Order/index.d.ts +1 -1
  26. package/lib/modules/Order/utils.js +2 -13
  27. package/lib/modules/ProductList/index.js +2 -1
  28. package/lib/modules/Quotation/index.d.ts +1 -1
  29. package/lib/modules/Quotation/index.js +2 -2
  30. package/lib/modules/Rules/index.js +1 -0
  31. package/lib/modules/ScanOrderLogger/index.d.ts +2 -0
  32. package/lib/modules/ScanOrderLogger/index.js +13 -1
  33. package/lib/modules/ScanOrderLogger/providers/feishu.js +15 -6
  34. package/lib/modules/ScanOrderLogger/types.d.ts +1 -0
  35. package/lib/solution/BookingByStep/index.d.ts +2 -2
  36. package/lib/solution/BookingByStep/index.js +2 -2
  37. package/lib/solution/BookingTicket/index.d.ts +1 -1
  38. package/lib/solution/ScanOrder/index.d.ts +7 -1
  39. package/lib/solution/ScanOrder/index.js +114 -28
  40. package/lib/solution/ScanOrder/utils.js +2 -2
  41. package/lib/solution/VenueBooking/index.d.ts +2 -0
  42. package/lib/solution/VenueBooking/index.js +45 -7
  43. package/lib/solution/VenueBooking/types.d.ts +1 -0
  44. package/lib/solution/VenueBooking/utils/resource.js +1 -0
  45. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
  46. package/lib/solution/VenueBooking/utils/slotMerge.js +13 -1
  47. package/package.json +1 -1
@@ -2,15 +2,15 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableTo
2
2
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
3
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
4
4
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
5
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
6
5
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
7
6
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
8
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; }
9
8
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
10
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
11
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
12
9
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
13
10
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
11
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
12
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
13
+ 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); }
14
14
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15
15
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
16
16
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
@@ -94,15 +94,50 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
94
94
  moduleName: 'scanOrder'
95
95
  };
96
96
  }
97
+ }, {
98
+ key: "safeStringify",
99
+ value: function safeStringify(value) {
100
+ try {
101
+ return JSON.stringify(value);
102
+ } catch (_unused) {
103
+ return undefined;
104
+ }
105
+ }
106
+ }, {
107
+ key: "pickErrorMessage",
108
+ value: function pickErrorMessage(error) {
109
+ var _error$data, _error$response, _error$error;
110
+ var candidates = [error.message, (_error$data = error.data) === null || _error$data === void 0 ? void 0 : _error$data.message, (_error$response = error.response) === null || _error$response === void 0 || (_error$response = _error$response.data) === null || _error$response === void 0 ? void 0 : _error$response.message, (_error$error = error.error) === null || _error$error === void 0 ? void 0 : _error$error.message];
111
+ for (var _i = 0, _candidates = candidates; _i < _candidates.length; _i++) {
112
+ var candidate = _candidates[_i];
113
+ if (typeof candidate === 'string' && candidate.trim()) return candidate;
114
+ }
115
+ return undefined;
116
+ }
97
117
  }, {
98
118
  key: "serializeError",
99
119
  value: function serializeError(error) {
100
120
  if (error instanceof Error) {
101
- return JSON.stringify({
121
+ return {
102
122
  name: error.name,
103
123
  message: error.message,
104
124
  stack: error.stack
105
- });
125
+ };
126
+ }
127
+ if (error && _typeof(error) === 'object') {
128
+ var raw = error;
129
+ var message = this.pickErrorMessage(raw) || this.safeStringify(raw) || String(error);
130
+ return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, typeof raw.name === 'string' ? {
131
+ name: raw.name
132
+ } : {}), {}, {
133
+ message: message
134
+ }, 'code' in raw ? {
135
+ code: raw.code
136
+ } : {}), 'status' in raw ? {
137
+ status: raw.status
138
+ } : {}), this.safeStringify(raw) ? {
139
+ raw: this.safeStringify(raw)
140
+ } : {});
106
141
  }
107
142
  return {
108
143
  message: String(error)
@@ -192,6 +227,16 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
192
227
  })
193
228
  });
194
229
  }
230
+ }, {
231
+ key: "assertProductListLoaded",
232
+ value: function assertProductListLoaded(method, result) {
233
+ var payload = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
234
+ if (Array.isArray(result)) return result;
235
+ var error = result instanceof Error ? result : new Error('商品列表接口返回异常');
236
+ this.logMethodError(method, error, payload);
237
+ error.__scanOrderLogged = true;
238
+ throw error;
239
+ }
195
240
  }, {
196
241
  key: "addLog",
197
242
  value: function () {
@@ -228,8 +273,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
228
273
  value: function resolveCustomerIdFromLoginPayload(payload) {
229
274
  var _payload$user, _payload$user2, _payload$user3, _payload$user4, _payload$account, _payload$account2, _payload$account3, _payload$_origin;
230
275
  var candidates = [payload === null || payload === void 0 ? void 0 : payload.customerId, payload === null || payload === void 0 ? void 0 : payload.customer_id, payload === null || payload === void 0 ? void 0 : payload.id, payload === null || payload === void 0 || (_payload$user = payload.user) === null || _payload$user === void 0 ? void 0 : _payload$user.customerId, payload === null || payload === void 0 || (_payload$user2 = payload.user) === null || _payload$user2 === void 0 ? void 0 : _payload$user2.customer_id, payload === null || payload === void 0 || (_payload$user3 = payload.user) === null || _payload$user3 === void 0 ? void 0 : _payload$user3.id, payload === null || payload === void 0 || (_payload$user4 = payload.user) === null || _payload$user4 === void 0 || (_payload$user4 = _payload$user4._origin) === null || _payload$user4 === void 0 ? void 0 : _payload$user4.customer_id, payload === null || payload === void 0 || (_payload$account = payload.account) === null || _payload$account === void 0 ? void 0 : _payload$account.customerId, payload === null || payload === void 0 || (_payload$account2 = payload.account) === null || _payload$account2 === void 0 ? void 0 : _payload$account2.customer_id, payload === null || payload === void 0 || (_payload$account3 = payload.account) === null || _payload$account3 === void 0 ? void 0 : _payload$account3.id, payload === null || payload === void 0 || (_payload$_origin = payload._origin) === null || _payload$_origin === void 0 ? void 0 : _payload$_origin.customer_id];
231
- for (var _i = 0, _candidates = candidates; _i < _candidates.length; _i++) {
232
- var candidate = _candidates[_i];
276
+ for (var _i2 = 0, _candidates2 = candidates; _i2 < _candidates2.length; _i2++) {
277
+ var candidate = _candidates2[_i2];
233
278
  var customerId = this.normalizeCustomerId(candidate);
234
279
  if (customerId) return customerId;
235
280
  }
@@ -399,18 +444,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
399
444
  key: "destroyRegisteredChildModules",
400
445
  value: function () {
401
446
  var _destroyRegisteredChildModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
402
- var modules, _i2, _modules, mod;
447
+ var modules, _i3, _modules, mod;
403
448
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
404
449
  while (1) switch (_context6.prev = _context6.next) {
405
450
  case 0:
406
451
  modules = [this.store.schedule, this.store.salesSummary, this.store.order, this.store.products, this.store.scanOrderLogger];
407
- _i2 = 0, _modules = modules;
452
+ _i3 = 0, _modules = modules;
408
453
  case 2:
409
- if (!(_i2 < _modules.length)) {
454
+ if (!(_i3 < _modules.length)) {
410
455
  _context6.next = 10;
411
456
  break;
412
457
  }
413
- mod = _modules[_i2];
458
+ mod = _modules[_i3];
414
459
  if (!(mod && typeof mod.destroy === 'function')) {
415
460
  _context6.next = 7;
416
461
  break;
@@ -418,7 +463,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
418
463
  _context6.next = 7;
419
464
  return Promise.resolve(mod.destroy());
420
465
  case 7:
421
- _i2++;
466
+ _i3++;
422
467
  _context6.next = 2;
423
468
  break;
424
469
  case 10:
@@ -497,7 +542,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
497
542
  var loggerProvider = ((_this4$otherParams = _this4.otherParams) === null || _this4$otherParams === void 0 ? void 0 : _this4$otherParams.scanOrderLoggerProvider) || 'feishu';
498
543
  var loggerConfig = ((_this4$otherParams2 = _this4.otherParams) === null || _this4$otherParams2 === void 0 ? void 0 : _this4$otherParams2.scanOrderLoggerConfig) || {
499
544
  feishu: {
500
- webhook: 'https://open.feishu.cn/open-apis/bot/v2/hook/216b3fe6-af98-424e-8706-f0471241a7ed'
545
+ webhook: 'https://open.feishu.cn/open-apis/bot/v2/hook/216b3fe6-af98-424e-8706-f0471241a7ed',
546
+ errorHook: 'https://open.feishu.cn/open-apis/bot/v2/hook/015b7c2a-dd3c-4c30-9898-ef0f5253111f'
501
547
  }
502
548
  };
503
549
  _this4.core.registerModule(targetModule, {
@@ -1247,7 +1293,50 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1247
1293
  return _onCustomerLogin.apply(this, arguments);
1248
1294
  }
1249
1295
  return onCustomerLogin;
1250
- }() // ScanOrder 提交 payload enhancer:
1296
+ }()
1297
+ }, {
1298
+ key: "findReservationRuleResource",
1299
+ value: function findReservationRuleResource(formId) {
1300
+ if (formId == null) return undefined;
1301
+ var numericFormId = Number(formId);
1302
+ if (!Number.isFinite(numericFormId) || numericFormId <= 0) return undefined;
1303
+ var _iterator4 = _createForOfIteratorHelper(this.enabledReservationRuleProducts),
1304
+ _step4;
1305
+ try {
1306
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
1307
+ var _product$product_reso;
1308
+ var product = _step4.value;
1309
+ var resources = product === null || product === void 0 || (_product$product_reso = product.product_resource) === null || _product$product_reso === void 0 ? void 0 : _product$product_reso.resources;
1310
+ if (!Array.isArray(resources)) continue;
1311
+ var matched = resources.find(function (resource) {
1312
+ return Number(resource === null || resource === void 0 ? void 0 : resource.id) === numericFormId;
1313
+ });
1314
+ if (matched) return matched;
1315
+ }
1316
+ } catch (err) {
1317
+ _iterator4.e(err);
1318
+ } finally {
1319
+ _iterator4.f();
1320
+ }
1321
+ return undefined;
1322
+ }
1323
+ }, {
1324
+ key: "buildScanOrderResourceMetadata",
1325
+ value: function buildScanOrderResourceMetadata(params) {
1326
+ var _ruleResource$title;
1327
+ var resourceState = params.resourceState,
1328
+ resourceName = params.resourceName;
1329
+ var ruleResource = this.findReservationRuleResource(resourceState.tableFormId);
1330
+ var combined = ruleResource === null || ruleResource === void 0 ? void 0 : ruleResource.combined_resource;
1331
+ var isCombined = !!(combined && combined.status === 1 && Array.isArray(combined.resource_ids));
1332
+ return {
1333
+ form_name: (_ruleResource$title = ruleResource === null || ruleResource === void 0 ? void 0 : ruleResource.title) !== null && _ruleResource$title !== void 0 ? _ruleResource$title : '',
1334
+ resource_name: resourceName,
1335
+ combined_resource: isCombined ? combined : null
1336
+ };
1337
+ }
1338
+
1339
+ // ScanOrder 提交 payload enhancer:
1251
1340
  // - 给所有 booking 注入 appointment_status: 'started'(扫码点餐语义)
1252
1341
  // - 给所有 booking 的 metadata 注入 resource_select_type(来自预约规则商品的 resource.type)
1253
1342
  // - 给第一条 booking 补 resources 与 product_uid(仅当存在 resource / rule product)
@@ -1292,7 +1381,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1292
1381
  form_id: resourceState.tableFormId,
1293
1382
  relation_id: (_resourceState$relati = resourceState.relationId) !== null && _resourceState$relati !== void 0 ? _resourceState$relati : resourceId,
1294
1383
  capacity: resolveResourceCapacity(),
1295
- metadata: {}
1384
+ metadata: _this5.buildScanOrderResourceMetadata({
1385
+ resourceState: resourceState,
1386
+ resourceName: mainField
1387
+ })
1296
1388
  } : undefined;
1297
1389
  var ruleProductUid = ruleProduct ? createUuidV4() : undefined;
1298
1390
  // 默认 resolveResourceCapacity(single 为桌台容量,其余多为 1);有 collect_pax 时 value 优先用人数
@@ -1776,17 +1868,17 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1776
1868
  if (visited.has(value)) return;
1777
1869
  visited.add(value);
1778
1870
  if (Array.isArray(value)) {
1779
- var _iterator4 = _createForOfIteratorHelper(value),
1780
- _step4;
1871
+ var _iterator5 = _createForOfIteratorHelper(value),
1872
+ _step5;
1781
1873
  try {
1782
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
1783
- var item = _step4.value;
1874
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
1875
+ var item = _step5.value;
1784
1876
  collectFromValue(item);
1785
1877
  }
1786
1878
  } catch (err) {
1787
- _iterator4.e(err);
1879
+ _iterator5.e(err);
1788
1880
  } finally {
1789
- _iterator4.f();
1881
+ _iterator5.f();
1790
1882
  }
1791
1883
  return;
1792
1884
  }
@@ -1802,8 +1894,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1802
1894
  sourceMap.set(key, node);
1803
1895
  }
1804
1896
  }
1805
- for (var _i3 = 0, _Object$values = Object.values(node); _i3 < _Object$values.length; _i3++) {
1806
- var childValue = _Object$values[_i3];
1897
+ for (var _i4 = 0, _Object$values = Object.values(node); _i4 < _Object$values.length; _i4++) {
1898
+ var childValue = _Object$values[_i4];
1807
1899
  if (childValue && _typeof(childValue) === 'object') {
1808
1900
  collectFromValue(childValue);
1809
1901
  }
@@ -1947,7 +2039,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1947
2039
  key: "applyPrefillByItemRule",
1948
2040
  value: function () {
1949
2041
  var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
1950
- var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges, _iterator5, _step5, _prefillItem$product_, _targetProduct$_origi, _targetProduct$_origi2, _targetProduct$_origi3, prefillItem, productId, productVariantId, targetQuantity, sourceItem, productIndex, _sourceItem$price, sellingPrice, targetProduct, existedQuantity, delta, nextProduct, hasQuantityChanged, hasOriginChanged;
2042
+ var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges, _iterator6, _step6, _prefillItem$product_, _targetProduct$_origi, _targetProduct$_origi2, _targetProduct$_origi3, prefillItem, productId, productVariantId, targetQuantity, sourceItem, productIndex, _sourceItem$price, sellingPrice, targetProduct, existedQuantity, delta, nextProduct, hasQuantityChanged, hasOriginChanged;
1951
2043
  return _regeneratorRuntime().wrap(function _callee29$(_context29) {
1952
2044
  while (1) switch (_context29.prev = _context29.next) {
1953
2045
  case 0:
@@ -1992,15 +2084,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1992
2084
  productSourceMap = _context29.sent;
1993
2085
  tempOrder = this.ensureTempOrder();
1994
2086
  hasChanges = false;
1995
- _iterator5 = _createForOfIteratorHelper(prefillItems);
2087
+ _iterator6 = _createForOfIteratorHelper(prefillItems);
1996
2088
  _context29.prev = 20;
1997
- _iterator5.s();
2089
+ _iterator6.s();
1998
2090
  case 22:
1999
- if ((_step5 = _iterator5.n()).done) {
2091
+ if ((_step6 = _iterator6.n()).done) {
2000
2092
  _context29.next = 47;
2001
2093
  break;
2002
2094
  }
2003
- prefillItem = _step5.value;
2095
+ prefillItem = _step6.value;
2004
2096
  productId = Number(prefillItem.product_id);
2005
2097
  productVariantId = Number((_prefillItem$product_ = prefillItem.product_variant_id) !== null && _prefillItem$product_ !== void 0 ? _prefillItem$product_ : 0);
2006
2098
  targetQuantity = toNonNegativeInt(prefillItem.quantity);
@@ -2071,10 +2163,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2071
2163
  case 49:
2072
2164
  _context29.prev = 49;
2073
2165
  _context29.t0 = _context29["catch"](20);
2074
- _iterator5.e(_context29.t0);
2166
+ _iterator6.e(_context29.t0);
2075
2167
  case 52:
2076
2168
  _context29.prev = 52;
2077
- _iterator5.f();
2169
+ _iterator6.f();
2078
2170
  return _context29.finish(52);
2079
2171
  case 55:
2080
2172
  if (!hasChanges) {
@@ -2462,7 +2554,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2462
2554
  key: "checkResourceAvailable",
2463
2555
  value: function () {
2464
2556
  var _checkResourceAvailable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(resourceId, hasOrderId) {
2465
- var _this$otherParams10, _this$otherParams10$g, _occupyDetail$form_re, _occupyDetail$form_re2, _this$otherParams11, _this$store$order5, _this$store$order7, _this$store$order7$ge, _this$otherParams12, openData, dineInConfig, closedBehaviorValue, closedMessage, basicUnavailableMessage, pauseMessage, makeShopClosed, operatingHourIds, outsideOperatingHours, scheduleList, now, tempOrder, reservationLinkIds, pendingRequestEntryPax, pendingRequestPaxMin, pendingRequestPaxMax, reservationProductList, scheduleDate, scheduleDatetime, loaded, occupancyMinutes, paxBounds, occupyDetail, resourceSelectType, resourceState, availabilityInfo, _this$store$order6, _res$data, res, entryPaxNumber, lastOrderInfo, historicalItems;
2557
+ var _this$otherParams$bus, _this$otherParams10, _this$otherParams$cha, _this$otherParams11, _this$otherParams12, _this$otherParams12$g, _occupyDetail$form_re, _occupyDetail$form_re2, _this$otherParams13, _this$store$order5, _this$store$order7, _this$store$order7$ge, _this$otherParams14, businessCode, channel, openDataTarget, openData, dineInConfig, closedBehaviorValue, closedMessage, basicUnavailableMessage, pauseMessage, makeShopClosed, operatingHourIds, outsideOperatingHours, scheduleList, now, tempOrder, reservationLinkIds, pendingRequestEntryPax, pendingRequestPaxMin, pendingRequestPaxMax, reservationProductList, scheduleDate, scheduleDatetime, loaded, occupancyMinutes, paxBounds, error, occupyDetail, resourceSelectType, resourceState, availabilityInfo, _this$store$order6, _res$data, res, entryPaxNumber, lastOrderInfo, historicalItems;
2466
2558
  return _regeneratorRuntime().wrap(function _callee36$(_context36) {
2467
2559
  while (1) switch (_context36.prev = _context36.next) {
2468
2560
  case 0:
@@ -2470,25 +2562,28 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2470
2562
  resourceId: resourceId
2471
2563
  });
2472
2564
  _context36.prev = 1;
2473
- _context36.next = 4;
2474
- return (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 || (_this$otherParams10$g = _this$otherParams10.getOpenData) === null || _this$otherParams10$g === void 0 ? void 0 : _this$otherParams10$g.call(_this$otherParams10, {
2565
+ businessCode = String((_this$otherParams$bus = (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.businessCode) !== null && _this$otherParams$bus !== void 0 ? _this$otherParams$bus : '').trim();
2566
+ channel = String((_this$otherParams$cha = (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.channel) !== null && _this$otherParams$cha !== void 0 ? _this$otherParams$cha : '').trim();
2567
+ openDataTarget = businessCode && channel ? "".concat(businessCode, "+").concat(channel) : 'dine_in+scan_to_order';
2568
+ _context36.next = 7;
2569
+ return (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 || (_this$otherParams12$g = _this$otherParams12.getOpenData) === null || _this$otherParams12$g === void 0 ? void 0 : _this$otherParams12$g.call(_this$otherParams12, {
2475
2570
  scope: 'board',
2476
- target: 'dine_in+scan_to_order',
2571
+ target: openDataTarget,
2477
2572
  section_code: ['basic', 'fulfillment', 'reservation', 'sale', 'menu', 'availability', 'workflow']
2478
2573
  });
2479
- case 4:
2574
+ case 7:
2480
2575
  openData = _context36.sent;
2481
2576
  if (!((openData === null || openData === void 0 ? void 0 : openData.status) === false)) {
2482
- _context36.next = 7;
2577
+ _context36.next = 10;
2483
2578
  break;
2484
2579
  }
2485
2580
  throw new Error((openData === null || openData === void 0 ? void 0 : openData.message) || '获取店铺配置失败');
2486
- case 7:
2581
+ case 10:
2487
2582
  dineInConfig = (openData === null || openData === void 0 ? void 0 : openData.data) || {};
2488
2583
  this.otherParams.dineInConfig = dineInConfig;
2489
- _context36.next = 11;
2584
+ _context36.next = 14;
2490
2585
  return this.syncItemRuleConfigsFromDineInConfig(dineInConfig);
2491
- case 11:
2586
+ case 14:
2492
2587
  closedBehaviorValue = dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.closed_behavior'];
2493
2588
  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']);
2494
2589
  basicUnavailableMessage = (dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['basic.unavailable_message']) || closedMessage;
@@ -2505,21 +2600,21 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2505
2600
  };
2506
2601
  }; // 1. 基础开关 basic.enable 关闭
2507
2602
  if (!((dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['basic.enable']) === false)) {
2508
- _context36.next = 18;
2603
+ _context36.next = 21;
2509
2604
  break;
2510
2605
  }
2511
2606
  return _context36.abrupt("return", makeShopClosed(basicUnavailableMessage));
2512
- case 18:
2607
+ case 21:
2513
2608
  if (!toBoolean(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.paused'])) {
2514
- _context36.next = 21;
2609
+ _context36.next = 24;
2515
2610
  break;
2516
2611
  }
2517
2612
  if (!((dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.pause_behavior']) === 'hide_all')) {
2518
- _context36.next = 21;
2613
+ _context36.next = 24;
2519
2614
  break;
2520
2615
  }
2521
2616
  return _context36.abrupt("return", makeShopClosed(pauseMessage));
2522
- case 21:
2617
+ case 24:
2523
2618
  // 3. 营业时间 operating_hours 闸门
2524
2619
  operatingHourIds = Array.isArray(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.operating_hours']) ? dineInConfig['availability.operating_hours'].map(function (id) {
2525
2620
  return Number(id);
@@ -2535,27 +2630,27 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2535
2630
  }
2536
2631
  }
2537
2632
  if (!(outsideOperatingHours && closedBehaviorValue !== 'show_menu_disabled')) {
2538
- _context36.next = 26;
2633
+ _context36.next = 29;
2539
2634
  break;
2540
2635
  }
2541
2636
  return _context36.abrupt("return", makeShopClosed(closedMessage, closedBehaviorValue));
2542
- case 26:
2637
+ case 29:
2543
2638
  // Step1: 先加载预约规则商品,拿到 enabledReservationRuleProducts 与容量附加信息
2544
2639
  // (resourceSelectType 需要基于这些商品 + 占用接口的 form_id 计算,故必须前置)
2545
2640
  tempOrder = this.ensureTempOrder();
2546
2641
  reservationLinkIds = collectLinkProductIdsFromReservationRules(dineInConfig['fulfillment.enabled_resource_rules']);
2547
2642
  if (!(reservationLinkIds.length === 0)) {
2548
- _context36.next = 32;
2643
+ _context36.next = 35;
2549
2644
  break;
2550
2645
  }
2551
2646
  this.enabledReservationRuleProducts = [];
2552
- _context36.next = 43;
2647
+ _context36.next = 46;
2553
2648
  break;
2554
- case 32:
2649
+ case 35:
2555
2650
  tempOrder.metadata = _objectSpread({}, tempOrder.metadata || {});
2556
2651
  delete tempOrder.metadata.table_occupancy_duration;
2557
2652
  reservationProductList = new ProductList("".concat(this.name, "_reservationEnabledRules"), this.defaultVersion);
2558
- _context36.next = 37;
2653
+ _context36.next = 40;
2559
2654
  return reservationProductList.initialize(this.core, {
2560
2655
  store: {
2561
2656
  list: [],
@@ -2567,17 +2662,17 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2567
2662
  cacheId: this.cacheId
2568
2663
  })
2569
2664
  });
2570
- case 37:
2665
+ case 40:
2571
2666
  scheduleDate = dayjs().format('YYYY-MM-DD');
2572
2667
  scheduleDatetime = dayjs().format('YYYY-MM-DD HH:mm:ss');
2573
- _context36.next = 41;
2668
+ _context36.next = 44;
2574
2669
  return reservationProductList.loadProducts({
2575
2670
  product_ids: reservationLinkIds,
2576
2671
  schedule_date: scheduleDate,
2577
2672
  schedule_datetime: scheduleDatetime,
2578
2673
  cacheId: this.cacheId
2579
2674
  });
2580
- case 41:
2675
+ case 44:
2581
2676
  loaded = _context36.sent;
2582
2677
  if (Array.isArray(loaded)) {
2583
2678
  this.enabledReservationRuleProducts = loaded;
@@ -2593,19 +2688,19 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2593
2688
  }
2594
2689
  } else {
2595
2690
  this.enabledReservationRuleProducts = [];
2596
- void this.addScanOrderLog({
2597
- level: 'error',
2598
- title: '[ScanOrder] enabled_reservation_rules product query failed',
2599
- payload: {
2600
- linkIds: reservationLinkIds,
2601
- error: this.serializeError(loaded)
2602
- }
2691
+ error = loaded instanceof Error ? loaded : new Error('预约规则商品列表接口返回异常');
2692
+ this.logMethodError('loadReservationRuleProducts', error, {
2693
+ resourceId: resourceId,
2694
+ reservationLinkIds: reservationLinkIds,
2695
+ scheduleDate: scheduleDate,
2696
+ scheduleDatetime: scheduleDatetime,
2697
+ cacheId: this.cacheId
2603
2698
  });
2604
2699
  }
2605
- case 43:
2606
- _context36.next = 45;
2700
+ case 46:
2701
+ _context36.next = 48;
2607
2702
  return this.fetchResourceOccupyDetailByResourceId(resourceId);
2608
- case 45:
2703
+ case 48:
2609
2704
  occupyDetail = _context36.sent;
2610
2705
  // Step3: 结合预约规则商品的 product_resource.resources 与占用接口返回的 form_id,
2611
2706
  // 计算当前桌台的 resourceSelectType(single/multiple/capacity)
@@ -2639,30 +2734,30 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2639
2734
  } : {}), this.store.resource.requestPaxMax !== undefined ? {
2640
2735
  requestPaxMax: this.store.resource.requestPaxMax
2641
2736
  } : {});
2642
- tempOrder.relation_id = resourceId || ((_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.relation_id);
2737
+ tempOrder.relation_id = resourceId || ((_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.relation_id);
2643
2738
  tempOrder.table_form_id = resourceState.tableFormId;
2644
2739
  tempOrder.resource_id = resourceId;
2645
2740
  (_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 || _this$store$order5.persistTempOrder();
2646
2741
 
2647
2742
  // 空闲状态下自动准备本地临时订单,供后续“购物车式”商品操作使用
2648
2743
  if (!(availabilityInfo.mode === 'idle')) {
2649
- _context36.next = 60;
2744
+ _context36.next = 63;
2650
2745
  break;
2651
2746
  }
2652
- _context36.next = 60;
2747
+ _context36.next = 63;
2653
2748
  return this.addNewOrder();
2654
- case 60:
2749
+ case 63:
2655
2750
  // 如果是加单模式,tempOrder 里 需要记录 lastOrderId,提交的时候走加单接口
2656
2751
  if (availabilityInfo.mode === 'additional_order' || availabilityInfo.mode === 'additional_order_with_code') {
2657
2752
  tempOrder.order_id = resourceState.lastOrderId;
2658
2753
  }
2659
2754
  if (!tempOrder.order_id) {
2660
- _context36.next = 69;
2755
+ _context36.next = 72;
2661
2756
  break;
2662
2757
  }
2663
- _context36.next = 64;
2758
+ _context36.next = 67;
2664
2759
  return (_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 ? void 0 : _this$store$order6.getOrderInfoByRemote(tempOrder.order_id);
2665
- case 64:
2760
+ case 67:
2666
2761
  res = _context36.sent;
2667
2762
  // 找到下单的时候输入的 entryPaxNumber
2668
2763
  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) {
@@ -2670,12 +2765,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2670
2765
  return (_p$metadata = p.metadata) === null || _p$metadata === void 0 ? void 0 : _p$metadata.collect_pax;
2671
2766
  })) === null || _res$data === void 0 || (_res$data = _res$data.metadata) === null || _res$data === void 0 ? void 0 : _res$data.collect_pax;
2672
2767
  if (!entryPaxNumber) {
2673
- _context36.next = 69;
2768
+ _context36.next = 72;
2674
2769
  break;
2675
2770
  }
2676
- _context36.next = 69;
2771
+ _context36.next = 72;
2677
2772
  return this.setEntryPaxNumber(entryPaxNumber);
2678
- case 69:
2773
+ case 72:
2679
2774
  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);
2680
2775
  historicalItems = hasOrderId && Array.isArray(lastOrderInfo === null || lastOrderInfo === void 0 ? void 0 : lastOrderInfo.products) ? lastOrderInfo.products.reduce(function (acc, p) {
2681
2776
  if (typeof (p === null || p === void 0 ? void 0 : p.product_id) !== 'number') return acc;
@@ -2687,13 +2782,13 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2687
2782
  } : {}));
2688
2783
  return acc;
2689
2784
  }, []) : []; // pax 由 setEntryPaxNumber 负责写入 itemRuleRuntimeConfig.pax
2690
- _context36.next = 73;
2785
+ _context36.next = 76;
2691
2786
  return this.setItemRuleRuntimeConfig({
2692
- serviceType: (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.businessCode,
2787
+ serviceType: (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.businessCode,
2693
2788
  submissionIndex: hasOrderId ? 1 : 0,
2694
2789
  historicalItems: historicalItems
2695
2790
  });
2696
- case 73:
2791
+ case 76:
2697
2792
  // operating_hours 超出营业时段 + closed_behavior=show_menu_disabled:
2698
2793
  // 允许浏览商品但 UI 层需拦截“下一步”,这里覆盖最终 mode 并回传错误提示
2699
2794
  if (outsideOperatingHours && closedBehaviorValue === 'show_menu_disabled') {
@@ -2715,18 +2810,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2715
2810
  isFull: resourceState.isFull
2716
2811
  });
2717
2812
  return _context36.abrupt("return", availabilityInfo);
2718
- case 78:
2719
- _context36.prev = 78;
2813
+ case 81:
2814
+ _context36.prev = 81;
2720
2815
  _context36.t0 = _context36["catch"](1);
2721
2816
  this.logMethodError('checkResourceAvailable', _context36.t0.message, {
2722
2817
  resourceId: resourceId
2723
2818
  });
2724
2819
  throw _context36.t0;
2725
- case 82:
2820
+ case 85:
2726
2821
  case "end":
2727
2822
  return _context36.stop();
2728
2823
  }
2729
- }, _callee36, this, [[1, 78]]);
2824
+ }, _callee36, this, [[1, 81]]);
2730
2825
  }));
2731
2826
  function checkResourceAvailable(_x18, _x19) {
2732
2827
  return _checkResourceAvailable.apply(this, arguments);
@@ -2769,41 +2864,56 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2769
2864
  key: "getProductList",
2770
2865
  value: function () {
2771
2866
  var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
2772
- var _this$otherParams13;
2773
- var menu_list_ids, _this$store$products, res, formattedRes;
2867
+ var _this$otherParams15;
2868
+ var menu_list_ids, res, productList, formattedRes;
2774
2869
  return _regeneratorRuntime().wrap(function _callee38$(_context38) {
2775
2870
  while (1) switch (_context38.prev = _context38.next) {
2776
2871
  case 0:
2777
2872
  this.logMethodStart('getProductList');
2778
2873
  // 可以直接通过配置里的 menu 读取
2779
- menu_list_ids = ((_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 || (_this$otherParams13 = _this$otherParams13.dineInConfig) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13['menu.associated_menus'].map(function (n) {
2874
+ menu_list_ids = ((_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 || (_this$otherParams15 = _this$otherParams15.dineInConfig) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15['menu.associated_menus'].map(function (n) {
2780
2875
  return Number(n.value);
2781
2876
  })) || [];
2782
2877
  _context38.prev = 2;
2783
- _context38.next = 5;
2784
- return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
2878
+ if (this.store.products) {
2879
+ _context38.next = 5;
2880
+ break;
2881
+ }
2882
+ throw new Error('products 模块未初始化');
2883
+ case 5:
2884
+ _context38.next = 7;
2885
+ return this.store.products.loadProducts({
2785
2886
  menu_list_ids: menu_list_ids,
2786
2887
  cacheId: this.cacheId,
2787
2888
  schedule_date: dayjs().format('YYYY-MM-DD'),
2788
2889
  schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
2789
2890
  });
2790
- case 5:
2891
+ case 7:
2791
2892
  res = _context38.sent;
2792
- formattedRes = attachItemRuleLimitsToTopLevelProducts(res, this.store.itemRuleQuantityLimits || []);
2893
+ productList = this.assertProductListLoaded('getProductList', res, {
2894
+ menu_list_ids: menu_list_ids,
2895
+ cacheId: this.cacheId
2896
+ });
2897
+ formattedRes = attachItemRuleLimitsToTopLevelProducts(productList, this.store.itemRuleQuantityLimits || []);
2793
2898
  this.logMethodSuccess('getProductList', {
2794
2899
  menuCount: menu_list_ids.length
2795
2900
  });
2796
2901
  return _context38.abrupt("return", formattedRes);
2797
- case 11:
2798
- _context38.prev = 11;
2902
+ case 14:
2903
+ _context38.prev = 14;
2799
2904
  _context38.t0 = _context38["catch"](2);
2800
- this.logMethodError('getProductList', _context38.t0.message);
2905
+ if (!(_context38.t0 !== null && _context38.t0 !== void 0 && _context38.t0.__scanOrderLogged)) {
2906
+ this.logMethodError('getProductList', _context38.t0, {
2907
+ menu_list_ids: menu_list_ids,
2908
+ cacheId: this.cacheId
2909
+ });
2910
+ }
2801
2911
  throw _context38.t0;
2802
- case 15:
2912
+ case 18:
2803
2913
  case "end":
2804
2914
  return _context38.stop();
2805
2915
  }
2806
- }, _callee38, this, [[2, 11]]);
2916
+ }, _callee38, this, [[2, 14]]);
2807
2917
  }));
2808
2918
  function getProductList() {
2809
2919
  return _getProductList.apply(this, arguments);
@@ -2870,7 +2980,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2870
2980
  var raw = this.window.localStorage.getItem(key) || '{}';
2871
2981
  var parsed = JSON.parse(raw);
2872
2982
  return parsed && _typeof(parsed) === 'object' ? parsed : {};
2873
- } catch (_unused) {
2983
+ } catch (_unused2) {
2874
2984
  return {};
2875
2985
  }
2876
2986
  }
@@ -2979,9 +3089,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2979
3089
  }, {
2980
3090
  key: "getFulfillmentModes",
2981
3091
  value: function getFulfillmentModes() {
2982
- var _this$otherParams14;
3092
+ var _this$otherParams16;
2983
3093
  this.logMethodStart('getFulfillmentModes');
2984
- var dineInConfig = ((_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.dineInConfig) || {};
3094
+ var dineInConfig = ((_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.dineInConfig) || {};
2985
3095
  var result = {
2986
3096
  enablePickup: Boolean(dineInConfig['fulfillment.enable_pickup']),
2987
3097
  enableTableService: Boolean(dineInConfig['fulfillment.enable_table_service'])
@@ -2995,9 +3105,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2995
3105
  }, {
2996
3106
  key: "checkManualPickupRef",
2997
3107
  value: function checkManualPickupRef() {
2998
- var _this$otherParams15;
3108
+ var _this$otherParams17;
2999
3109
  this.logMethodStart('checkManualPickupRef');
3000
- var dineInConfig = ((_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.dineInConfig) || {};
3110
+ var dineInConfig = ((_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.dineInConfig) || {};
3001
3111
  var refMode = dineInConfig['fulfillment.fulfillment_ref_mode'];
3002
3112
  var manualInputType = dineInConfig['fulfillment.manual_input_type'];
3003
3113
  var enabled = refMode === 'manual_input';