@pisell/pisellos 2.1.41 → 2.2.2

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 (121) hide show
  1. package/dist/core/index.d.ts +8 -1
  2. package/dist/core/index.js +116 -42
  3. package/dist/modules/Customer/index.js +1 -1
  4. package/dist/modules/Order/index.js +4 -4
  5. package/dist/modules/Order/types.d.ts +0 -1
  6. package/dist/modules/Product/types.d.ts +19 -0
  7. package/dist/modules/ProductList/index.js +3 -11
  8. package/dist/modules/Schedule/types.d.ts +2 -0
  9. package/dist/plugins/request.d.ts +19 -1
  10. package/dist/plugins/request.js +11 -0
  11. package/dist/server/index.d.ts +152 -0
  12. package/dist/server/index.js +946 -0
  13. package/dist/server/modules/index.d.ts +16 -0
  14. package/dist/server/modules/index.js +21 -0
  15. package/dist/server/modules/menu/index.d.ts +63 -0
  16. package/dist/server/modules/menu/index.js +476 -0
  17. package/dist/server/modules/menu/types.d.ts +68 -0
  18. package/dist/server/modules/menu/types.js +16 -0
  19. package/dist/server/modules/products/index.d.ts +141 -0
  20. package/dist/server/modules/products/index.js +774 -0
  21. package/dist/server/modules/products/types.d.ts +94 -0
  22. package/dist/server/modules/products/types.js +43 -0
  23. package/dist/server/modules/quotation/index.d.ts +47 -0
  24. package/dist/server/modules/quotation/index.js +367 -0
  25. package/dist/server/modules/quotation/types.d.ts +50 -0
  26. package/dist/server/modules/quotation/types.js +20 -0
  27. package/dist/server/modules/schedule/index.d.ts +62 -0
  28. package/dist/server/modules/schedule/index.js +431 -0
  29. package/dist/server/modules/schedule/types.d.ts +1 -0
  30. package/dist/server/modules/schedule/types.js +2 -0
  31. package/dist/server/modules/schedule/utils.d.ts +32 -0
  32. package/dist/server/modules/schedule/utils.js +747 -0
  33. package/dist/server/types.d.ts +64 -0
  34. package/dist/server/types.js +1 -0
  35. package/dist/server/utils/index.d.ts +5 -0
  36. package/dist/server/utils/index.js +6 -0
  37. package/dist/server/utils/product.d.ts +18 -0
  38. package/dist/server/utils/product.js +339 -0
  39. package/dist/server/utils/schedule.d.ts +14 -0
  40. package/dist/server/utils/schedule.js +108 -0
  41. package/dist/server/utils/time.d.ts +18 -0
  42. package/dist/server/utils/time.js +53 -0
  43. package/dist/solution/BookingByStep/index.d.ts +2 -22
  44. package/dist/solution/BookingByStep/index.js +29 -502
  45. package/dist/solution/BookingByStep/utils/capacity.d.ts +2 -7
  46. package/dist/solution/BookingByStep/utils/capacity.js +8 -24
  47. package/dist/solution/BookingTicket/index.d.ts +8 -0
  48. package/dist/solution/BookingTicket/index.js +105 -71
  49. package/dist/solution/ShopDiscount/index.js +9 -27
  50. package/dist/solution/index.d.ts +0 -1
  51. package/dist/solution/index.js +0 -1
  52. package/dist/types/index.d.ts +26 -0
  53. package/lib/core/index.d.ts +8 -1
  54. package/lib/core/index.js +48 -1
  55. package/lib/modules/Customer/index.js +1 -1
  56. package/lib/modules/Order/index.js +2 -5
  57. package/lib/modules/Order/types.d.ts +0 -1
  58. package/lib/modules/Product/types.d.ts +19 -0
  59. package/lib/modules/ProductList/index.js +2 -10
  60. package/lib/modules/Schedule/types.d.ts +2 -0
  61. package/lib/plugins/request.d.ts +19 -1
  62. package/lib/plugins/request.js +11 -1
  63. package/lib/server/index.d.ts +152 -0
  64. package/lib/server/index.js +555 -0
  65. package/lib/server/modules/index.d.ts +16 -0
  66. package/lib/server/modules/index.js +47 -0
  67. package/lib/server/modules/menu/index.d.ts +63 -0
  68. package/lib/server/modules/menu/index.js +234 -0
  69. package/lib/server/modules/menu/types.d.ts +68 -0
  70. package/lib/server/modules/menu/types.js +33 -0
  71. package/lib/server/modules/products/index.d.ts +141 -0
  72. package/lib/server/modules/products/index.js +442 -0
  73. package/lib/server/modules/products/types.d.ts +94 -0
  74. package/lib/server/modules/products/types.js +35 -0
  75. package/lib/server/modules/quotation/index.d.ts +47 -0
  76. package/lib/server/modules/quotation/index.js +177 -0
  77. package/lib/server/modules/quotation/types.d.ts +50 -0
  78. package/lib/server/modules/quotation/types.js +33 -0
  79. package/lib/server/modules/schedule/index.d.ts +62 -0
  80. package/lib/server/modules/schedule/index.js +231 -0
  81. package/lib/server/modules/schedule/types.d.ts +1 -0
  82. package/lib/server/modules/schedule/types.js +23 -0
  83. package/lib/server/modules/schedule/utils.d.ts +32 -0
  84. package/lib/server/modules/schedule/utils.js +451 -0
  85. package/lib/server/types.d.ts +64 -0
  86. package/lib/server/types.js +17 -0
  87. package/lib/server/utils/index.d.ts +5 -0
  88. package/lib/server/utils/index.js +25 -0
  89. package/lib/server/utils/product.d.ts +18 -0
  90. package/lib/server/utils/product.js +262 -0
  91. package/lib/server/utils/schedule.d.ts +14 -0
  92. package/lib/server/utils/schedule.js +88 -0
  93. package/lib/server/utils/time.d.ts +18 -0
  94. package/lib/server/utils/time.js +70 -0
  95. package/lib/solution/BookingByStep/index.d.ts +2 -22
  96. package/lib/solution/BookingByStep/index.js +42 -321
  97. package/lib/solution/BookingByStep/utils/capacity.d.ts +2 -7
  98. package/lib/solution/BookingByStep/utils/capacity.js +8 -21
  99. package/lib/solution/BookingTicket/index.d.ts +8 -0
  100. package/lib/solution/BookingTicket/index.js +13 -0
  101. package/lib/solution/ShopDiscount/index.js +0 -9
  102. package/lib/solution/index.d.ts +0 -1
  103. package/lib/solution/index.js +0 -2
  104. package/lib/types/index.d.ts +26 -0
  105. package/package.json +2 -2
  106. package/dist/solution/RegisterAndLogin/config.d.ts +0 -87
  107. package/dist/solution/RegisterAndLogin/config.js +0 -792
  108. package/dist/solution/RegisterAndLogin/index.d.ts +0 -189
  109. package/dist/solution/RegisterAndLogin/index.js +0 -2667
  110. package/dist/solution/RegisterAndLogin/types.d.ts +0 -444
  111. package/dist/solution/RegisterAndLogin/types.js +0 -231
  112. package/dist/solution/RegisterAndLogin/utils.d.ts +0 -95
  113. package/dist/solution/RegisterAndLogin/utils.js +0 -322
  114. package/lib/solution/RegisterAndLogin/config.d.ts +0 -87
  115. package/lib/solution/RegisterAndLogin/config.js +0 -594
  116. package/lib/solution/RegisterAndLogin/index.d.ts +0 -189
  117. package/lib/solution/RegisterAndLogin/index.js +0 -1593
  118. package/lib/solution/RegisterAndLogin/types.d.ts +0 -444
  119. package/lib/solution/RegisterAndLogin/types.js +0 -78
  120. package/lib/solution/RegisterAndLogin/utils.d.ts +0 -95
  121. package/lib/solution/RegisterAndLogin/utils.js +0 -279
@@ -0,0 +1,946 @@
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 _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); }
3
+ 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
+ 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; }
5
+ 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; }
6
+ 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); }
7
+ 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; }
8
+ 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); } }
9
+ 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); }); }; }
10
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
11
+ 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); } }
12
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
13
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
14
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
15
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
16
+ import { ProductsModule } from "./modules/products";
17
+ import { MenuModule } from "./modules/menu";
18
+ import { QuotationModule } from "./modules/quotation";
19
+ import { ScheduleModuleEx } from "./modules/schedule";
20
+ import { extractScheduleIdsFromMenus, extractTimePointsFromSchedules } from "./utils/schedule";
21
+
22
+ // 重新导出类型供外部使用
23
+ /**
24
+ * Server 类
25
+ * 用于注册和管理服务端模块
26
+ */
27
+ var Server = /*#__PURE__*/function () {
28
+ function Server(core) {
29
+ var _this = this;
30
+ _classCallCheck(this, Server);
31
+ _defineProperty(this, "core", void 0);
32
+ // 模块实例
33
+ _defineProperty(this, "products", void 0);
34
+ _defineProperty(this, "menu", void 0);
35
+ _defineProperty(this, "quotation", void 0);
36
+ _defineProperty(this, "schedule", void 0);
37
+ // 路由注册表
38
+ _defineProperty(this, "router", {
39
+ get: {},
40
+ post: {},
41
+ put: {},
42
+ remove: {}
43
+ });
44
+ // 模块注册表 - 定义所有可用的模块配置
45
+ _defineProperty(this, "moduleRegistry", {
46
+ products: {
47
+ name: 'products',
48
+ moduleClass: ProductsModule,
49
+ moduleName: 'server_products',
50
+ version: '1.0.0',
51
+ defaultStore: {
52
+ list: [],
53
+ selectProducts: []
54
+ }
55
+ },
56
+ menu: {
57
+ name: 'menu',
58
+ moduleClass: MenuModule,
59
+ moduleName: 'server_menu',
60
+ version: '1.0.0',
61
+ defaultStore: {
62
+ menuList: []
63
+ }
64
+ },
65
+ quotation: {
66
+ name: 'quotation',
67
+ moduleClass: QuotationModule,
68
+ moduleName: 'server_quotation',
69
+ version: '1.0.0',
70
+ defaultStore: {
71
+ quotationList: []
72
+ }
73
+ },
74
+ schedule: {
75
+ name: 'schedule',
76
+ moduleClass: ScheduleModuleEx,
77
+ moduleName: 'server_schedule',
78
+ version: '1.1.0',
79
+ defaultStore: {
80
+ scheduleList: [],
81
+ availabilityDateList: [],
82
+ otherProductsIds: []
83
+ }
84
+ }
85
+ });
86
+ /**
87
+ * 处理商品查询请求(编排 Products、Menu、Schedule 模块)
88
+ * 这是一个业务编排方法,协调多个模块完成复杂的业务需求
89
+ */
90
+ _defineProperty(this, "handleProductQuery", /*#__PURE__*/function () {
91
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
92
+ var url, method, data, config, menu_list_ids, schedule_datetime, schedule_date, activeMenuList, menuList, allProductsWithPrice, filteredProducts;
93
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
94
+ while (1) switch (_context.prev = _context.next) {
95
+ case 0:
96
+ url = _ref.url, method = _ref.method, data = _ref.data, config = _ref.config;
97
+ console.log('[Server] handleProductQuery:', url, method, data, config);
98
+ menu_list_ids = data.menu_list_ids, schedule_datetime = data.schedule_datetime, schedule_date = data.schedule_date; // 检查必要的模块是否已注册
99
+ if (_this.products) {
100
+ _context.next = 6;
101
+ break;
102
+ }
103
+ console.error('[Server] Products 模块未注册');
104
+ return _context.abrupt("return", {
105
+ message: 'Products 模块未注册',
106
+ data: {
107
+ list: [],
108
+ count: 0
109
+ }
110
+ });
111
+ case 6:
112
+ if (_this.menu) {
113
+ _context.next = 9;
114
+ break;
115
+ }
116
+ console.error('[Server] Menu 模块未注册');
117
+ return _context.abrupt("return", {
118
+ message: 'Menu 模块未注册',
119
+ data: {
120
+ list: [],
121
+ count: 0
122
+ }
123
+ });
124
+ case 9:
125
+ if (_this.schedule) {
126
+ _context.next = 12;
127
+ break;
128
+ }
129
+ console.error('[Server] Schedule 模块未注册');
130
+ return _context.abrupt("return", {
131
+ message: 'Schedule 模块未注册',
132
+ data: {
133
+ list: [],
134
+ count: 0
135
+ }
136
+ });
137
+ case 12:
138
+ // 生效的餐牌列表
139
+ activeMenuList = []; // 如果有 menu_list_ids,获取对应的餐牌详情
140
+ if (menu_list_ids && Array.isArray(menu_list_ids) && menu_list_ids.length > 0) {
141
+ console.log('[Server] 获取餐牌详情,IDs:', menu_list_ids);
142
+
143
+ // 从 Menu 模块获取餐牌详情
144
+ menuList = _this.menu.getMenuByIds(menu_list_ids);
145
+ activeMenuList = menuList.filter(function (menu) {
146
+ var _this$schedule;
147
+ return ((_this$schedule = _this.schedule) === null || _this$schedule === void 0 ? void 0 : _this$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
148
+ });
149
+ }
150
+ console.log(activeMenuList, 'activeMenuList');
151
+
152
+ // 获取应用了价格的商品列表(带缓存,同一天直接返回缓存的商品)
153
+ // 传入 scheduleList 以便格式化器计算商品的可用时间段
154
+ _context.next = 17;
155
+ return _this.products.getProductsWithPrice(data.schedule_date, {
156
+ scheduleModule: _this.getSchedule()
157
+ });
158
+ case 17:
159
+ allProductsWithPrice = _context.sent;
160
+ console.log(allProductsWithPrice, 'allProductsWithPrice');
161
+
162
+ //根据生效的餐牌配置过滤商品
163
+ filteredProducts = _this.filterProductsByMenuConfig(allProductsWithPrice, activeMenuList); // 排序:优先使用 sort 排序,如果相同则使用 title 排序
164
+ filteredProducts = filteredProducts.sort(function (a, b) {
165
+ var sortDiff = Number(b.sort) - Number(a.sort);
166
+ if (sortDiff !== 0) {
167
+ return sortDiff;
168
+ }
169
+ // 如果 sort 相同,按 title 字母顺序排序
170
+ return (a.title || '').localeCompare(b.title || '');
171
+ });
172
+ console.log('[Server] 原始商品数量:', allProductsWithPrice.length);
173
+ console.log('[Server] 过滤后商品数量:', filteredProducts.length);
174
+ console.log(filteredProducts, 'filteredProducts');
175
+
176
+ // 返回组合后的数据
177
+ return _context.abrupt("return", {
178
+ code: 200,
179
+ data: {
180
+ list: filteredProducts,
181
+ count: filteredProducts.length
182
+ },
183
+ message: '',
184
+ status: true
185
+ });
186
+ case 25:
187
+ case "end":
188
+ return _context.stop();
189
+ }
190
+ }, _callee);
191
+ }));
192
+ return function (_x) {
193
+ return _ref2.apply(this, arguments);
194
+ };
195
+ }());
196
+ /**
197
+ * 处理获取日程时间段点的请求
198
+ * 通过餐牌ID列表获取所有相关日程的时间段点
199
+ */
200
+ _defineProperty(this, "handleGetScheduleTimePoints", /*#__PURE__*/function () {
201
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref3) {
202
+ var url, method, data, config, menu_list_ids, menuList, scheduleIds, scheduleList, timePoints;
203
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
204
+ while (1) switch (_context2.prev = _context2.next) {
205
+ case 0:
206
+ url = _ref3.url, method = _ref3.method, data = _ref3.data, config = _ref3.config;
207
+ console.log('[Server] handleGetScheduleTimePoints:', url, method, data, config);
208
+ menu_list_ids = data.menu_list_ids; // 检查必要的模块是否已注册
209
+ if (_this.menu) {
210
+ _context2.next = 6;
211
+ break;
212
+ }
213
+ console.error('[Server] Menu 模块未注册');
214
+ return _context2.abrupt("return", {
215
+ code: 500,
216
+ message: 'Menu 模块未注册',
217
+ data: [],
218
+ status: false
219
+ });
220
+ case 6:
221
+ if (_this.schedule) {
222
+ _context2.next = 9;
223
+ break;
224
+ }
225
+ console.error('[Server] Schedule 模块未注册');
226
+ return _context2.abrupt("return", {
227
+ code: 500,
228
+ message: 'Schedule 模块未注册',
229
+ data: [],
230
+ status: false
231
+ });
232
+ case 9:
233
+ if (!(!menu_list_ids || !Array.isArray(menu_list_ids) || menu_list_ids.length === 0)) {
234
+ _context2.next = 12;
235
+ break;
236
+ }
237
+ console.error('[Server] menu_list_ids 参数无效');
238
+ return _context2.abrupt("return", {
239
+ code: 400,
240
+ message: 'menu_list_ids 参数无效',
241
+ data: [],
242
+ status: false
243
+ });
244
+ case 12:
245
+ _context2.prev = 12;
246
+ // 1. 获取餐牌列表
247
+ menuList = _this.menu.getMenuByIds(menu_list_ids);
248
+ console.log("[Server] \u627E\u5230 ".concat(menuList.length, " \u4E2A\u9910\u724C"));
249
+
250
+ // 2. 提取所有的 schedule IDs
251
+ scheduleIds = extractScheduleIdsFromMenus(menuList);
252
+ console.log("[Server] \u63D0\u53D6\u5230 ".concat(scheduleIds.length, " \u4E2A\u65E5\u7A0BID:"), scheduleIds);
253
+ if (!(scheduleIds.length === 0)) {
254
+ _context2.next = 19;
255
+ break;
256
+ }
257
+ return _context2.abrupt("return", {
258
+ code: 200,
259
+ message: '没有找到相关日程',
260
+ data: [],
261
+ status: true
262
+ });
263
+ case 19:
264
+ // 3. 获取日程详情
265
+ scheduleList = _this.schedule.getScheduleByIds(scheduleIds);
266
+ console.log("[Server] \u627E\u5230 ".concat(scheduleList.length, " \u4E2A\u65E5\u7A0B"));
267
+
268
+ // 4. 提取时间点
269
+ timePoints = extractTimePointsFromSchedules(scheduleList);
270
+ console.log("[Server] \u63D0\u53D6\u5230 ".concat(timePoints.length, " \u4E2A\u65F6\u95F4\u70B9:"), timePoints);
271
+ return _context2.abrupt("return", {
272
+ code: 200,
273
+ message: '获取成功',
274
+ data: timePoints,
275
+ status: true
276
+ });
277
+ case 26:
278
+ _context2.prev = 26;
279
+ _context2.t0 = _context2["catch"](12);
280
+ console.error('[Server] 获取日程时间点失败:', _context2.t0);
281
+ return _context2.abrupt("return", {
282
+ code: 500,
283
+ message: "\u83B7\u53D6\u5931\u8D25: ".concat(_context2.t0 instanceof Error ? _context2.t0.message : '未知错误'),
284
+ data: [],
285
+ status: false
286
+ });
287
+ case 30:
288
+ case "end":
289
+ return _context2.stop();
290
+ }
291
+ }, _callee2, null, [[12, 26]]);
292
+ }));
293
+ return function (_x2) {
294
+ return _ref4.apply(this, arguments);
295
+ };
296
+ }());
297
+ this.core = core;
298
+ console.log('[Server] Server 初始化');
299
+ }
300
+
301
+ /**
302
+ * 注册路由
303
+ * @param routes 路由定义数组
304
+ */
305
+ _createClass(Server, [{
306
+ key: "registerRoutes",
307
+ value: function registerRoutes(routes) {
308
+ var _this2 = this;
309
+ routes.forEach(function (route) {
310
+ var method = route.method,
311
+ path = route.path,
312
+ handler = route.handler;
313
+ if (!_this2.router[method]) {
314
+ console.warn("[Server] \u4E0D\u652F\u6301\u7684 HTTP \u65B9\u6CD5: ".concat(method));
315
+ return;
316
+ }
317
+
318
+ // 检查路由是否已存在
319
+ if (_this2.router[method][path]) {
320
+ console.warn("[Server] \u8DEF\u7531\u5DF2\u5B58\u5728\uFF0C\u5C06\u88AB\u8986\u76D6: ".concat(method.toUpperCase(), " ").concat(path));
321
+ }
322
+ _this2.router[method][path] = handler;
323
+ console.log("[Server] \uD83D\uDCDD \u6CE8\u518C\u8DEF\u7531: ".concat(method.toUpperCase(), " ").concat(path));
324
+ });
325
+ }
326
+
327
+ /**
328
+ * 注册单个模块并自动注册其路由
329
+ * @param module 模块实例
330
+ * @param options 模块配置
331
+ * @param moduleName 模块名称(用于日志)
332
+ */
333
+ }, {
334
+ key: "registerModuleWithRoutes",
335
+ value: (function () {
336
+ var _registerModuleWithRoutes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(module, options, moduleName) {
337
+ var routes;
338
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
339
+ while (1) switch (_context3.prev = _context3.next) {
340
+ case 0:
341
+ _context3.next = 2;
342
+ return this.core.registerModule(module, options);
343
+ case 2:
344
+ console.log("[Server] \u2705 ".concat(moduleName, " \u6A21\u5757\u5DF2\u6CE8\u518C"));
345
+
346
+ // 自动注册模块的路由
347
+ if (typeof module.getRoutes === 'function') {
348
+ routes = module.getRoutes();
349
+ if (routes && routes.length > 0) {
350
+ this.registerRoutes(routes);
351
+ }
352
+ }
353
+ case 4:
354
+ case "end":
355
+ return _context3.stop();
356
+ }
357
+ }, _callee3, this);
358
+ }));
359
+ function registerModuleWithRoutes(_x3, _x4, _x5) {
360
+ return _registerModuleWithRoutes.apply(this, arguments);
361
+ }
362
+ return registerModuleWithRoutes;
363
+ }()
364
+ /**
365
+ * 根据模块名称注册单个模块
366
+ * @param moduleConfig 模块配置(可以是字符串或配置对象)
367
+ */
368
+ )
369
+ }, {
370
+ key: "registerModuleByName",
371
+ value: (function () {
372
+ var _registerModuleByName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(moduleConfig) {
373
+ var moduleName, shouldPreload, customConfig, registryConfig, ModuleClass, moduleInstance, moduleOptions;
374
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
375
+ while (1) switch (_context4.prev = _context4.next) {
376
+ case 0:
377
+ // 解析配置
378
+ moduleName = typeof moduleConfig === 'string' ? moduleConfig : moduleConfig.name;
379
+ shouldPreload = _typeof(moduleConfig) === 'object' ? moduleConfig.preload !== false : true;
380
+ customConfig = _typeof(moduleConfig) === 'object' ? moduleConfig.config : {}; // 查找模块配置
381
+ registryConfig = this.moduleRegistry[moduleName];
382
+ if (registryConfig) {
383
+ _context4.next = 6;
384
+ break;
385
+ }
386
+ throw new Error("[Server] \u672A\u627E\u5230\u6A21\u5757\u914D\u7F6E: ".concat(moduleName));
387
+ case 6:
388
+ // 创建模块实例
389
+ ModuleClass = registryConfig.moduleClass;
390
+ moduleInstance = new ModuleClass(registryConfig.moduleName, registryConfig.version); // 合并配置
391
+ moduleOptions = _objectSpread({
392
+ store: _objectSpread({}, registryConfig.defaultStore)
393
+ }, customConfig); // 注册模块和路由
394
+ _context4.next = 11;
395
+ return this.registerModuleWithRoutes(moduleInstance, moduleOptions, moduleName.charAt(0).toUpperCase() + moduleName.slice(1));
396
+ case 11:
397
+ // 保存模块实例
398
+ this[moduleName] = moduleInstance;
399
+ return _context4.abrupt("return", {
400
+ module: moduleInstance,
401
+ config: registryConfig,
402
+ shouldPreload: shouldPreload
403
+ });
404
+ case 13:
405
+ case "end":
406
+ return _context4.stop();
407
+ }
408
+ }, _callee4, this);
409
+ }));
410
+ function registerModuleByName(_x6) {
411
+ return _registerModuleByName.apply(this, arguments);
412
+ }
413
+ return registerModuleByName;
414
+ }()
415
+ /**
416
+ * 注册指定的服务端模块
417
+ * @param moduleConfigs 要注册的模块配置数组(模块名称或配置对象)
418
+ */
419
+ )
420
+ }, {
421
+ key: "registerModules",
422
+ value: (function () {
423
+ var _registerModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(moduleConfigs) {
424
+ var configs, registeredModules, _iterator, _step, config, result;
425
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
426
+ while (1) switch (_context5.prev = _context5.next) {
427
+ case 0:
428
+ console.log('[Server] 开始注册模块...');
429
+
430
+ // 如果没有指定模块,则注册所有模块
431
+ configs = moduleConfigs || Object.keys(this.moduleRegistry);
432
+ registeredModules = [];
433
+ _iterator = _createForOfIteratorHelper(configs);
434
+ _context5.prev = 4;
435
+ _iterator.s();
436
+ case 6:
437
+ if ((_step = _iterator.n()).done) {
438
+ _context5.next = 21;
439
+ break;
440
+ }
441
+ config = _step.value;
442
+ _context5.prev = 8;
443
+ _context5.next = 11;
444
+ return this.registerModuleByName(config);
445
+ case 11:
446
+ result = _context5.sent;
447
+ registeredModules.push(result);
448
+ _context5.next = 19;
449
+ break;
450
+ case 15:
451
+ _context5.prev = 15;
452
+ _context5.t0 = _context5["catch"](8);
453
+ console.error("[Server] \u6A21\u5757\u6CE8\u518C\u5931\u8D25:", _context5.t0);
454
+ throw _context5.t0;
455
+ case 19:
456
+ _context5.next = 6;
457
+ break;
458
+ case 21:
459
+ _context5.next = 26;
460
+ break;
461
+ case 23:
462
+ _context5.prev = 23;
463
+ _context5.t1 = _context5["catch"](4);
464
+ _iterator.e(_context5.t1);
465
+ case 26:
466
+ _context5.prev = 26;
467
+ _iterator.f();
468
+ return _context5.finish(26);
469
+ case 29:
470
+ console.log('[Server] ✅ 所有模块注册完成');
471
+ return _context5.abrupt("return", registeredModules);
472
+ case 31:
473
+ case "end":
474
+ return _context5.stop();
475
+ }
476
+ }, _callee5, this, [[4, 23, 26, 29], [8, 15]]);
477
+ }));
478
+ function registerModules(_x7) {
479
+ return _registerModules.apply(this, arguments);
480
+ }
481
+ return registerModules;
482
+ }()
483
+ /**
484
+ * 预加载指定模块的数据
485
+ * @param registeredModules 已注册的模块信息
486
+ */
487
+ )
488
+ }, {
489
+ key: "preloadModulesData",
490
+ value: (function () {
491
+ var _preloadModulesData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(registeredModules, options) {
492
+ var _iterator2, _step2, _step2$value, module, config, shouldPreload, _options$onModuleLoad, _options$onModuleLoad2;
493
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
494
+ while (1) switch (_context6.prev = _context6.next) {
495
+ case 0:
496
+ console.log('[Server] 开始预加载模块数据...');
497
+ _iterator2 = _createForOfIteratorHelper(registeredModules);
498
+ _context6.prev = 2;
499
+ _iterator2.s();
500
+ case 4:
501
+ if ((_step2 = _iterator2.n()).done) {
502
+ _context6.next = 26;
503
+ break;
504
+ }
505
+ _step2$value = _step2.value, module = _step2$value.module, config = _step2$value.config, shouldPreload = _step2$value.shouldPreload;
506
+ if (shouldPreload) {
507
+ _context6.next = 9;
508
+ break;
509
+ }
510
+ console.log("[Server] \u23ED\uFE0F \u8DF3\u8FC7 ".concat(config.name, " \u6A21\u5757\u9884\u52A0\u8F7D"));
511
+ return _context6.abrupt("continue", 24);
512
+ case 9:
513
+ if (!(typeof module.preload === 'function')) {
514
+ _context6.next = 23;
515
+ break;
516
+ }
517
+ _context6.prev = 10;
518
+ options === null || options === void 0 || (_options$onModuleLoad = options.onModuleLoad) === null || _options$onModuleLoad === void 0 || _options$onModuleLoad.call(options, config.name);
519
+ _context6.next = 14;
520
+ return module.preload();
521
+ case 14:
522
+ options === null || options === void 0 || (_options$onModuleLoad2 = options.onModuleLoadComplete) === null || _options$onModuleLoad2 === void 0 || _options$onModuleLoad2.call(options, config.name);
523
+ console.log("[Server] \u2705 ".concat(config.name, " \u6A21\u5757\u6570\u636E\u5DF2\u9884\u52A0\u8F7D"));
524
+ _context6.next = 21;
525
+ break;
526
+ case 18:
527
+ _context6.prev = 18;
528
+ _context6.t0 = _context6["catch"](10);
529
+ console.error("[Server] \u274C ".concat(config.name, " \u6A21\u5757\u9884\u52A0\u8F7D\u5931\u8D25:"), _context6.t0);
530
+ case 21:
531
+ _context6.next = 24;
532
+ break;
533
+ case 23:
534
+ console.log("[Server] \u26A0\uFE0F ".concat(config.name, " \u6A21\u5757\u672A\u5B9E\u73B0 preload() \u65B9\u6CD5"));
535
+ case 24:
536
+ _context6.next = 4;
537
+ break;
538
+ case 26:
539
+ _context6.next = 31;
540
+ break;
541
+ case 28:
542
+ _context6.prev = 28;
543
+ _context6.t1 = _context6["catch"](2);
544
+ _iterator2.e(_context6.t1);
545
+ case 31:
546
+ _context6.prev = 31;
547
+ _iterator2.f();
548
+ return _context6.finish(31);
549
+ case 34:
550
+ console.log('[Server] ✅ 所有模块数据预加载完成');
551
+ case 35:
552
+ case "end":
553
+ return _context6.stop();
554
+ }
555
+ }, _callee6, null, [[2, 28, 31, 34], [10, 18]]);
556
+ }));
557
+ function preloadModulesData(_x8, _x9) {
558
+ return _preloadModulesData.apply(this, arguments);
559
+ }
560
+ return preloadModulesData;
561
+ }()
562
+ /**
563
+ * 初始化 Server(注册模块并预加载数据)
564
+ * @param moduleConfigs 要注册的模块配置
565
+ * @param autoPreload 是否自动预加载数据
566
+ */
567
+ )
568
+ }, {
569
+ key: "initialize",
570
+ value: (function () {
571
+ var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(moduleConfigs) {
572
+ var autoPreload,
573
+ options,
574
+ registeredModules,
575
+ _args7 = arguments;
576
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
577
+ while (1) switch (_context7.prev = _context7.next) {
578
+ case 0:
579
+ autoPreload = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : true;
580
+ options = _args7.length > 2 ? _args7[2] : undefined;
581
+ // 注册 Server 层的业务路由
582
+ this.registerServerRoutes();
583
+
584
+ // 注册模块
585
+ _context7.next = 5;
586
+ return this.registerModules(moduleConfigs);
587
+ case 5:
588
+ registeredModules = _context7.sent;
589
+ if (!autoPreload) {
590
+ _context7.next = 9;
591
+ break;
592
+ }
593
+ _context7.next = 9;
594
+ return this.preloadModulesData(registeredModules, options);
595
+ case 9:
596
+ return _context7.abrupt("return", registeredModules);
597
+ case 10:
598
+ case "end":
599
+ return _context7.stop();
600
+ }
601
+ }, _callee7, this);
602
+ }));
603
+ function initialize(_x10) {
604
+ return _initialize.apply(this, arguments);
605
+ }
606
+ return initialize;
607
+ }()
608
+ /**
609
+ * 获取 Products 模块实例
610
+ */
611
+ )
612
+ }, {
613
+ key: "getProducts",
614
+ value: function getProducts() {
615
+ return this.products;
616
+ }
617
+
618
+ /**
619
+ * 获取 Menu 模块实例
620
+ */
621
+ }, {
622
+ key: "getMenu",
623
+ value: function getMenu() {
624
+ return this.menu;
625
+ }
626
+
627
+ /**
628
+ * 获取 Quotation 模块实例
629
+ */
630
+ }, {
631
+ key: "getQuotation",
632
+ value: function getQuotation() {
633
+ return this.quotation;
634
+ }
635
+
636
+ /**
637
+ * 获取 Schedule 模块实例
638
+ */
639
+ }, {
640
+ key: "getSchedule",
641
+ value: function getSchedule() {
642
+ return this.schedule;
643
+ }
644
+
645
+ /**
646
+ * 获取所有已注册的模块列表
647
+ */
648
+ }, {
649
+ key: "getRegisteredModules",
650
+ value: function getRegisteredModules() {
651
+ var modules = [];
652
+ if (this.products) modules.push('products');
653
+ if (this.menu) modules.push('menu');
654
+ if (this.quotation) modules.push('quotation');
655
+ if (this.schedule) modules.push('schedule');
656
+ return modules;
657
+ }
658
+
659
+ /**
660
+ * 清空所有server模块的IndexedDB缓存
661
+ * @returns Promise<void>
662
+ */
663
+ }, {
664
+ key: "clearAllIndexDB",
665
+ value: (function () {
666
+ var _clearAllIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
667
+ var clearTasks, moduleNames;
668
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
669
+ while (1) switch (_context8.prev = _context8.next) {
670
+ case 0:
671
+ console.log('[Server] 开始清空所有模块的IndexedDB缓存...');
672
+ clearTasks = [];
673
+ moduleNames = []; // 收集所有模块的清空任务
674
+ if (this.products) {
675
+ clearTasks.push(this.products.clear());
676
+ moduleNames.push('Products');
677
+ }
678
+ if (this.menu) {
679
+ clearTasks.push(this.menu.clear());
680
+ moduleNames.push('Menu');
681
+ }
682
+ if (this.quotation) {
683
+ clearTasks.push(this.quotation.clear());
684
+ moduleNames.push('Quotation');
685
+ }
686
+ if (this.schedule) {
687
+ clearTasks.push(this.schedule.clear());
688
+ moduleNames.push('Schedule');
689
+ }
690
+ if (!(clearTasks.length === 0)) {
691
+ _context8.next = 10;
692
+ break;
693
+ }
694
+ console.warn('[Server] 没有找到已注册的模块,无需清空');
695
+ return _context8.abrupt("return");
696
+ case 10:
697
+ _context8.prev = 10;
698
+ _context8.next = 13;
699
+ return Promise.all(clearTasks);
700
+ case 13:
701
+ console.log("[Server] \u2705 \u5DF2\u6210\u529F\u6E05\u7A7A\u6240\u6709\u6A21\u5757\u7684IndexedDB\u7F13\u5B58: ".concat(moduleNames.join(', ')));
702
+ _context8.next = 20;
703
+ break;
704
+ case 16:
705
+ _context8.prev = 16;
706
+ _context8.t0 = _context8["catch"](10);
707
+ console.error('[Server] ❌ 清空IndexedDB缓存时发生错误:', _context8.t0);
708
+ throw _context8.t0;
709
+ case 20:
710
+ case "end":
711
+ return _context8.stop();
712
+ }
713
+ }, _callee8, this, [[10, 16]]);
714
+ }));
715
+ function clearAllIndexDB() {
716
+ return _clearAllIndexDB.apply(this, arguments);
717
+ }
718
+ return clearAllIndexDB;
719
+ }()
720
+ /**
721
+ * 获取所有注册的路由
722
+ */
723
+ )
724
+ }, {
725
+ key: "getRoutes",
726
+ value: function getRoutes() {
727
+ return this.router;
728
+ }
729
+
730
+ /**
731
+ * 根据方法和路径获取路由处理函数
732
+ * @param method HTTP 方法
733
+ * @param path 路径
734
+ */
735
+ }, {
736
+ key: "getRouteHandler",
737
+ value: function getRouteHandler(method, path) {
738
+ var _this$router$method;
739
+ return (_this$router$method = this.router[method]) === null || _this$router$method === void 0 ? void 0 : _this$router$method[path];
740
+ }
741
+
742
+ /**
743
+ * 检查路由是否存在
744
+ * @param method HTTP 方法
745
+ * @param path 路径
746
+ */
747
+ }, {
748
+ key: "hasRoute",
749
+ value: function hasRoute(method, path) {
750
+ var _this$router$method2;
751
+ console.log(method, path, 'method, path');
752
+ return !!((_this$router$method2 = this.router[method]) !== null && _this$router$method2 !== void 0 && _this$router$method2[path]);
753
+ }
754
+
755
+ /**
756
+ * 执行路由处理函数
757
+ * @param method HTTP 方法
758
+ * @param path 路径
759
+ * @param params 请求参数
760
+ */
761
+ }, {
762
+ key: "handleRoute",
763
+ value: (function () {
764
+ var _handleRoute = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(method, path, params) {
765
+ var handler;
766
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
767
+ while (1) switch (_context9.prev = _context9.next) {
768
+ case 0:
769
+ console.log(method, path, params, 'method, path, params');
770
+ handler = this.getRouteHandler(method, path);
771
+ if (handler) {
772
+ _context9.next = 4;
773
+ break;
774
+ }
775
+ throw new Error("Route not found: ".concat(method.toUpperCase(), " ").concat(path));
776
+ case 4:
777
+ _context9.prev = 4;
778
+ _context9.next = 7;
779
+ return handler(params);
780
+ case 7:
781
+ return _context9.abrupt("return", _context9.sent);
782
+ case 10:
783
+ _context9.prev = 10;
784
+ _context9.t0 = _context9["catch"](4);
785
+ console.error("[Server] \u8DEF\u7531\u5904\u7406\u9519\u8BEF: ".concat(method.toUpperCase(), " ").concat(path), _context9.t0);
786
+ throw _context9.t0;
787
+ case 14:
788
+ case "end":
789
+ return _context9.stop();
790
+ }
791
+ }, _callee9, this, [[4, 10]]);
792
+ }));
793
+ function handleRoute(_x11, _x12, _x13) {
794
+ return _handleRoute.apply(this, arguments);
795
+ }
796
+ return handleRoute;
797
+ }()
798
+ /**
799
+ * 获取所有路由列表(用于调试和文档)
800
+ */
801
+ )
802
+ }, {
803
+ key: "getAllRoutes",
804
+ value: function getAllRoutes() {
805
+ var _this3 = this;
806
+ var routes = [];
807
+ ['get', 'post', 'put', 'remove'].forEach(function (method) {
808
+ Object.keys(_this3.router[method]).forEach(function (path) {
809
+ routes.push({
810
+ method: method,
811
+ path: path
812
+ });
813
+ });
814
+ });
815
+ return routes;
816
+ }
817
+
818
+ /**
819
+ * 注册 Server 层的业务路由
820
+ * 这些路由需要编排多个模块的数据
821
+ * @private
822
+ */
823
+ }, {
824
+ key: "registerServerRoutes",
825
+ value: function registerServerRoutes() {
826
+ console.log('[Server] 注册 Server 层业务路由...');
827
+
828
+ // 注册商品查询路由(带餐牌和日程信息)
829
+ this.registerRoutes([{
830
+ method: 'post',
831
+ path: '/shop/product/query',
832
+ handler: this.handleProductQuery.bind(this)
833
+ }, {
834
+ method: 'post',
835
+ path: '/shop/menu/schedule-time-points',
836
+ handler: this.handleGetScheduleTimePoints.bind(this)
837
+ }]);
838
+ }
839
+ }, {
840
+ key: "filterProductsByMenuConfig",
841
+ value:
842
+ /**
843
+ * 根据餐牌配置过滤商品
844
+ * @param products 所有商品列表
845
+ * @param activeMenuList 生效的餐牌列表
846
+ * @returns 过滤后的商品列表
847
+ * @private
848
+ */
849
+ function filterProductsByMenuConfig(products, activeMenuList) {
850
+ // 如果没有生效的餐牌,返回空数组
851
+ if (!activeMenuList || activeMenuList.length === 0) {
852
+ console.log('[Server] 没有生效的餐牌,返回空数组');
853
+ return [];
854
+ }
855
+
856
+ // 收集允许的商品 IDs 和集合 IDs
857
+ var allowedProductIds = new Set();
858
+ var allowedCollectionIds = new Set();
859
+ var hasProductAll = false;
860
+ var _iterator3 = _createForOfIteratorHelper(activeMenuList),
861
+ _step3;
862
+ try {
863
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
864
+ var menu = _step3.value;
865
+ var config = menu.partyroom_package;
866
+ if (!config) {
867
+ console.warn('[Server] 餐牌缺少 partyroom_package 配置:', menu);
868
+ continue;
869
+ }
870
+
871
+ // 如果有任何一个餐牌是 product_all,则返回所有商品
872
+ if (config.type === 'product_all') {
873
+ console.log('[Server] 餐牌允许所有商品:', menu.name);
874
+ hasProductAll = true;
875
+ break;
876
+ }
877
+
878
+ // 如果是 product_ids 类型,从 ProductItemType 中提取 product_id
879
+ if (config.type === 'products' && Array.isArray(config.products)) {
880
+ var productIds = config.products.map(function (item) {
881
+ return item.product_id;
882
+ });
883
+ productIds.forEach(function (id) {
884
+ return id && allowedProductIds.add(id);
885
+ });
886
+ console.log('[Server] 餐牌允许指定商品 (product_ids):', menu.name, productIds);
887
+ }
888
+
889
+ // 如果是 product_collection 类型,从 ProductItemType 中提取 product_collection_id
890
+ if (config.type === 'product_collection' && Array.isArray(config.products)) {
891
+ var collectionIds = config.products.map(function (item) {
892
+ return item.product_collection_id;
893
+ });
894
+ collectionIds.forEach(function (id) {
895
+ return id && allowedCollectionIds.add(id);
896
+ });
897
+ console.log('[Server] 餐牌允许商品集合 (product_collection):', menu.name, collectionIds);
898
+ }
899
+ }
900
+
901
+ // 如果有餐牌允许所有商品,返回所有商品
902
+ } catch (err) {
903
+ _iterator3.e(err);
904
+ } finally {
905
+ _iterator3.f();
906
+ }
907
+ if (hasProductAll) {
908
+ return products;
909
+ }
910
+
911
+ // 如果没有收集到任何商品 ID 和集合 ID,返回空数组
912
+ if (allowedProductIds.size === 0 && allowedCollectionIds.size === 0) {
913
+ console.log('[Server] 没有允许的商品和集合');
914
+ return [];
915
+ }
916
+ console.log('[Server] 允许的商品 IDs:', Array.from(allowedProductIds));
917
+ console.log('[Server] 允许的集合 IDs:', Array.from(allowedCollectionIds));
918
+
919
+ // 过滤商品
920
+ var filteredProducts = products.filter(function (product) {
921
+ // 1. 检查商品 ID 是否在允许列表中
922
+ if (allowedProductIds.has(product.id)) {
923
+ return true;
924
+ }
925
+
926
+ // 2. 检查商品是否属于允许的集合
927
+ if (allowedCollectionIds.size > 0 && Array.isArray(product.collection)) {
928
+ var hasMatchingCollection = product.collection.some(function (col) {
929
+ return allowedCollectionIds.has(col.id);
930
+ });
931
+ if (hasMatchingCollection) {
932
+ return true;
933
+ }
934
+ }
935
+ return false;
936
+ });
937
+ console.log('[Server] 过滤结果: 原始 %d 个,过滤后 %d 个', products.length, filteredProducts.length);
938
+ return filteredProducts;
939
+ }
940
+ }]);
941
+ return Server;
942
+ }();
943
+ export default Server;
944
+
945
+ // 导出模块类型
946
+ export * from "./modules";