@pisell/pisellos 2.2.93 → 2.2.95

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 (53) hide show
  1. package/dist/modules/Order/index.d.ts +1 -1
  2. package/dist/plugins/app-types/app/app.d.ts +1 -0
  3. package/dist/server/index.d.ts +55 -0
  4. package/dist/server/index.js +826 -207
  5. package/dist/server/modules/index.d.ts +6 -0
  6. package/dist/server/modules/index.js +7 -0
  7. package/dist/server/modules/order/index.d.ts +87 -0
  8. package/dist/server/modules/order/index.js +916 -0
  9. package/dist/server/modules/order/types.d.ts +530 -0
  10. package/dist/server/modules/order/types.js +141 -0
  11. package/dist/server/modules/order/utils/filterBookings.d.ts +6 -0
  12. package/dist/server/modules/order/utils/filterBookings.js +350 -0
  13. package/dist/server/modules/order/utils/filterOrders.d.ts +15 -0
  14. package/dist/server/modules/order/utils/filterOrders.js +226 -0
  15. package/dist/server/modules/resource/index.d.ts +88 -0
  16. package/dist/server/modules/resource/index.js +1202 -0
  17. package/dist/server/modules/resource/types.d.ts +121 -0
  18. package/dist/server/modules/resource/types.js +47 -0
  19. package/dist/solution/BookingByStep/index.d.ts +1 -1
  20. package/dist/solution/BookingTicket/index.d.ts +1 -1
  21. package/dist/solution/Sales/index.d.ts +96 -0
  22. package/dist/solution/Sales/index.js +562 -0
  23. package/dist/solution/Sales/types.d.ts +66 -0
  24. package/dist/solution/Sales/types.js +26 -0
  25. package/dist/solution/index.d.ts +1 -0
  26. package/dist/solution/index.js +2 -1
  27. package/lib/modules/Order/index.d.ts +1 -1
  28. package/lib/plugins/app-types/app/app.d.ts +1 -0
  29. package/lib/server/index.d.ts +55 -0
  30. package/lib/server/index.js +343 -1
  31. package/lib/server/modules/index.d.ts +6 -0
  32. package/lib/server/modules/index.js +16 -2
  33. package/lib/server/modules/order/index.d.ts +87 -0
  34. package/lib/server/modules/order/index.js +543 -0
  35. package/lib/server/modules/order/types.d.ts +530 -0
  36. package/lib/server/modules/order/types.js +34 -0
  37. package/lib/server/modules/order/utils/filterBookings.d.ts +6 -0
  38. package/lib/server/modules/order/utils/filterBookings.js +320 -0
  39. package/lib/server/modules/order/utils/filterOrders.d.ts +15 -0
  40. package/lib/server/modules/order/utils/filterOrders.js +197 -0
  41. package/lib/server/modules/resource/index.d.ts +88 -0
  42. package/lib/server/modules/resource/index.js +571 -0
  43. package/lib/server/modules/resource/types.d.ts +121 -0
  44. package/lib/server/modules/resource/types.js +35 -0
  45. package/lib/solution/BookingByStep/index.d.ts +1 -1
  46. package/lib/solution/BookingTicket/index.d.ts +1 -1
  47. package/lib/solution/Sales/index.d.ts +96 -0
  48. package/lib/solution/Sales/index.js +413 -0
  49. package/lib/solution/Sales/types.d.ts +66 -0
  50. package/lib/solution/Sales/types.js +35 -0
  51. package/lib/solution/index.d.ts +1 -0
  52. package/lib/solution/index.js +3 -1
  53. package/package.json +1 -1
@@ -0,0 +1,562 @@
1
+ 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); }
2
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
5
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
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; }
8
+ 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; }
9
+ 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; }
10
+ 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; }
11
+ 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); } }
12
+ 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); }); }; }
13
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
14
+ 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); } }
15
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
16
+ function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
17
+ function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
18
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
19
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
20
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
21
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
22
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
23
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
24
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
25
+ 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; }
26
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
27
+ 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); }
28
+ import dayjs from 'dayjs';
29
+ import { BaseModule } from "../../modules/BaseModule";
30
+ import { SalesHooks } from "./types";
31
+ export * from "./types";
32
+
33
+ /**
34
+ * Sales 解决方案基础骨架
35
+ *
36
+ * 当前阶段仅提供:
37
+ * - solution 目录结构
38
+ * - 标准入口导出
39
+ * - 基础生命周期占位
40
+ *
41
+ * 不提前实现 store 编排、初始化流程细节、状态计算逻辑。
42
+ */
43
+ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
44
+ _inherits(SalesImpl, _BaseModule);
45
+ var _super = _createSuper(SalesImpl);
46
+ function SalesImpl(name, version) {
47
+ var _this;
48
+ _classCallCheck(this, SalesImpl);
49
+ _this = _super.call(this, name, version);
50
+ _defineProperty(_assertThisInitialized(_this), "defaultName", 'sales');
51
+ _defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
52
+ _defineProperty(_assertThisInitialized(_this), "defaultTimelineBucketMinutes", 15);
53
+ _defineProperty(_assertThisInitialized(_this), "isSolution", true);
54
+ _defineProperty(_assertThisInitialized(_this), "store", void 0);
55
+ _defineProperty(_assertThisInitialized(_this), "options", {});
56
+ _defineProperty(_assertThisInitialized(_this), "otherParams", {});
57
+ _defineProperty(_assertThisInitialized(_this), "request", void 0);
58
+ return _this;
59
+ }
60
+ _createClass(SalesImpl, [{
61
+ key: "initialize",
62
+ value: function () {
63
+ var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core) {
64
+ var options,
65
+ appPlugin,
66
+ _args = arguments;
67
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
68
+ while (1) switch (_context.prev = _context.next) {
69
+ case 0:
70
+ options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
71
+ this.core = core;
72
+ this.options = options;
73
+ this.otherParams = options.otherParams || {};
74
+ appPlugin = this.core.getPlugin('app'); // @ts-ignore
75
+ this.request = appPlugin === null || appPlugin === void 0 ? void 0 : appPlugin.getApp().request;
76
+ if (this.request) {
77
+ _context.next = 8;
78
+ break;
79
+ }
80
+ throw new Error('Sales 解决方案需要 request 插件支持');
81
+ case 8:
82
+ // 初始化 store 状态
83
+ this.store = {
84
+ currentDay: dayjs().startOf('day'),
85
+ reservationList: []
86
+ };
87
+
88
+ // TODO(Rolo): 等领导提供 reservationList 的目标结构后,
89
+ // 在这里补充从 Server/Order 读取 currentDay 原始数据并转换为预约列表。
90
+ _context.next = 11;
91
+ return this.core.effects.emit("".concat(this.name, ":onInited"), {});
92
+ case 11:
93
+ case "end":
94
+ return _context.stop();
95
+ }
96
+ }, _callee, this);
97
+ }));
98
+ function initialize(_x) {
99
+ return _initialize.apply(this, arguments);
100
+ }
101
+ return initialize;
102
+ }() // -------------------------------------------------------------------------
103
+ // SalesModuleAPI 实现
104
+ // -------------------------------------------------------------------------
105
+ /** 获取当前 store 快照 */
106
+ }, {
107
+ key: "getState",
108
+ value: function getState() {
109
+ return _objectSpread({}, this.store);
110
+ }
111
+
112
+ /** 获取当前选择日期 */
113
+ }, {
114
+ key: "getCurrentDay",
115
+ value: function getCurrentDay() {
116
+ return this.store.currentDay;
117
+ }
118
+
119
+ /** 设置当前选择日期,会自动归一到当天 00:00:00 */
120
+ }, {
121
+ key: "setCurrentDay",
122
+ value: function setCurrentDay(currentDay) {
123
+ var normalized = dayjs(currentDay).startOf('day');
124
+ this.store.currentDay = normalized;
125
+ this.core.effects.emit(SalesHooks.onCurrentDayChanged, {
126
+ currentDay: normalized
127
+ });
128
+ return normalized;
129
+ }
130
+
131
+ /** 获取当前预约列表 */
132
+ }, {
133
+ key: "getReservationList",
134
+ value: function getReservationList() {
135
+ return _toConsumableArray(this.store.reservationList);
136
+ }
137
+
138
+ /** 覆盖设置当前预约列表 */
139
+ }, {
140
+ key: "setReservationList",
141
+ value: function setReservationList(reservationList) {
142
+ this.store.reservationList = reservationList;
143
+ this.core.effects.emit(SalesHooks.onReservationListChanged, {
144
+ reservationList: reservationList
145
+ });
146
+ return reservationList;
147
+ }
148
+
149
+ /** 重置预约列表为空 */
150
+ }, {
151
+ key: "resetReservationList",
152
+ value: function resetReservationList() {
153
+ this.store.reservationList = [];
154
+ this.core.effects.emit(SalesHooks.onReservationListChanged, {
155
+ reservationList: []
156
+ });
157
+ return [];
158
+ }
159
+
160
+ // -------------------------------------------------------------------------
161
+ // 生命周期
162
+ // -------------------------------------------------------------------------
163
+ }, {
164
+ key: "destroy",
165
+ value: function () {
166
+ var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
167
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
168
+ while (1) switch (_context2.prev = _context2.next) {
169
+ case 0:
170
+ _context2.next = 2;
171
+ return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
172
+ case 2:
173
+ _get(_getPrototypeOf(SalesImpl.prototype), "destroy", this).call(this);
174
+ case 3:
175
+ case "end":
176
+ return _context2.stop();
177
+ }
178
+ }, _callee2, this);
179
+ }));
180
+ function destroy() {
181
+ return _destroy.apply(this, arguments);
182
+ }
183
+ return destroy;
184
+ }()
185
+ /**
186
+ * 时间轴粒度(分钟)
187
+ * - 默认 15 分钟
188
+ * - 可通过 registerModule 时的 options.otherParams.timelineBucketMinutes 覆盖
189
+ */
190
+ }, {
191
+ key: "getTimelineBucketMinutes",
192
+ value: function getTimelineBucketMinutes() {
193
+ var _this$otherParams;
194
+ var dynamicBucket = Number((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.timelineBucketMinutes);
195
+ if (!Number.isFinite(dynamicBucket) || dynamicBucket <= 0) return this.defaultTimelineBucketMinutes;
196
+ return Math.floor(dynamicBucket);
197
+ }
198
+
199
+ /**
200
+ * 解析营业日统计窗口:
201
+ * - 当 operating_day_boundary.type === 'start_time'
202
+ * 使用「今天 + boundary.time」到「明天 + boundary.time」
203
+ * - 否则回退自然日(00:00 到次日 00:00)
204
+ */
205
+ }, {
206
+ key: "getTimelineRangeByOperatingBoundary",
207
+ value: function getTimelineRangeByOperatingBoundary() {
208
+ var _appPlugin$getApp, _appPlugin$getApp$get, _appPlugin$getApp$get2, _appPlugin$getApp$get3, _coreData$core;
209
+ var today = dayjs();
210
+ var defaultStart = today.startOf('day');
211
+ var defaultEndExclusive = defaultStart.add(1, 'day');
212
+ var appPlugin = this.core.getPlugin('app');
213
+ var coreData = appPlugin === null || appPlugin === void 0 || (_appPlugin$getApp = appPlugin.getApp()) === null || _appPlugin$getApp === void 0 || (_appPlugin$getApp = _appPlugin$getApp.data) === null || _appPlugin$getApp === void 0 || (_appPlugin$getApp = _appPlugin$getApp.store) === null || _appPlugin$getApp === void 0 || (_appPlugin$getApp$get = _appPlugin$getApp.getStore) === null || _appPlugin$getApp$get === void 0 || (_appPlugin$getApp$get2 = (_appPlugin$getApp$get3 = _appPlugin$getApp$get.call(_appPlugin$getApp)).getDataByModel) === null || _appPlugin$getApp$get2 === void 0 ? void 0 : _appPlugin$getApp$get2.call(_appPlugin$getApp$get3, 'core');
214
+ var operatingDayBoundary = coreData === null || coreData === void 0 || (_coreData$core = coreData.core) === null || _coreData$core === void 0 ? void 0 : _coreData$core.operating_day_boundary;
215
+ if ((operatingDayBoundary === null || operatingDayBoundary === void 0 ? void 0 : operatingDayBoundary.type) !== 'start_time') {
216
+ return {
217
+ startAt: defaultStart,
218
+ endExclusiveAt: defaultEndExclusive
219
+ };
220
+ }
221
+ var boundaryTime = String(operatingDayBoundary.time || '').trim();
222
+ var startAt = dayjs("".concat(today.format('YYYY-MM-DD'), " ").concat(boundaryTime));
223
+ if (!startAt.isValid()) {
224
+ return {
225
+ startAt: defaultStart,
226
+ endExclusiveAt: defaultEndExclusive
227
+ };
228
+ }
229
+ return {
230
+ startAt: startAt,
231
+ endExclusiveAt: startAt.add(1, 'day')
232
+ };
233
+ }
234
+
235
+ /**
236
+ * 统计时间轴每个时间片的预约数量。
237
+ * 算法使用差分数组,复杂度 O(n + s):
238
+ * - n = booking 数量
239
+ * - s = 时间片数量
240
+ */
241
+ }, {
242
+ key: "getTimelineHighlights",
243
+ value: function getTimelineHighlights() {
244
+ var bookingList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
245
+ var startDateTime = arguments.length > 1 ? arguments[1] : undefined;
246
+ var endDateTime = arguments.length > 2 ? arguments[2] : undefined;
247
+ var bucketMinutes = this.getTimelineBucketMinutes();
248
+ var bucketMs = bucketMinutes * 60 * 1000;
249
+ var customStartAt = startDateTime ? dayjs(startDateTime) : dayjs('');
250
+ var customEndExclusiveAt = endDateTime ? dayjs(endDateTime) : dayjs('');
251
+ var hasValidCustomRange = customStartAt.isValid() && customEndExclusiveAt.isValid();
252
+ var _ref = hasValidCustomRange ? {
253
+ startAt: customStartAt,
254
+ endExclusiveAt: customEndExclusiveAt
255
+ } : this.getTimelineRangeByOperatingBoundary(),
256
+ startAt = _ref.startAt,
257
+ endExclusiveAt = _ref.endExclusiveAt;
258
+ var startAtMs = startAt.valueOf();
259
+ var endExclusiveAtMs = endExclusiveAt.valueOf();
260
+ if (!startAt.isValid() || !endExclusiveAt.isValid() || endExclusiveAtMs <= startAtMs) return [];
261
+ var slotCount = Math.ceil((endExclusiveAtMs - startAtMs) / bucketMs);
262
+ if (slotCount <= 0) return [];
263
+ var diff = new Int32Array(slotCount + 1);
264
+ for (var i = 0; i < bookingList.length; i++) {
265
+ var booking = bookingList[i];
266
+ var bookingStartAt = this.toBookingDateTime(booking.start_date, booking.start_time);
267
+ var bookingEndAt = this.toBookingDateTime(booking.end_date, booking.end_time);
268
+ if (!bookingStartAt.isValid() || !bookingEndAt.isValid()) continue;
269
+ var overlapStartMs = Math.max(bookingStartAt.valueOf(), startAtMs);
270
+ // 结束时间按 <= 处理:转成右开区间时 +1ms,保证命中 end_time 所在时间片
271
+ var overlapEndExclusiveMs = Math.min(bookingEndAt.valueOf() + 1, endExclusiveAtMs);
272
+ if (overlapStartMs >= overlapEndExclusiveMs) continue;
273
+ var startIdx = Math.max(0, Math.ceil((overlapStartMs - startAtMs) / bucketMs));
274
+ var endIdx = Math.min(slotCount - 1, Math.floor((overlapEndExclusiveMs - 1 - startAtMs) / bucketMs));
275
+ if (startIdx > endIdx) continue;
276
+ diff[startIdx] += 1;
277
+ diff[endIdx + 1] -= 1;
278
+ }
279
+ var timeline = [];
280
+ var runningCount = 0;
281
+ for (var _i = 0; _i < slotCount; _i++) {
282
+ runningCount += diff[_i];
283
+ timeline.push(runningCount);
284
+ }
285
+ return timeline;
286
+ }
287
+
288
+ /** dayjs 未启用插件时,手动封装 >= 判断 */
289
+ }, {
290
+ key: "isSameOrAfter",
291
+ value: function isSameOrAfter(left, right) {
292
+ return left.isAfter(right) || left.isSame(right);
293
+ }
294
+
295
+ /** dayjs 未启用插件时,手动封装 <= 判断 */
296
+ }, {
297
+ key: "isSameOrBefore",
298
+ value: function isSameOrBefore(left, right) {
299
+ return left.isBefore(right) || left.isSame(right);
300
+ }
301
+
302
+ /**
303
+ * 将 booking 的日期/时间字段统一组装为 dayjs
304
+ * - date + time 都有:按完整时间解析
305
+ * - 只有一个字段:按单字段解析(兼容历史数据)
306
+ * - 都没有:返回 invalid
307
+ */
308
+ }, {
309
+ key: "toBookingDateTime",
310
+ value: function toBookingDateTime(date, time) {
311
+ if (!date && !time) return dayjs('');
312
+ if (date && time) return dayjs("".concat(date, " ").concat(time));
313
+ return dayjs(date || time);
314
+ }
315
+
316
+ /**
317
+ * 预约状态映射(面向 UI 的统一状态)
318
+ * 说明:locked 逻辑后续会补业务规则,这里先保留分支占位。
319
+ */
320
+ }, {
321
+ key: "getBookingStatus",
322
+ value: function getBookingStatus(appointmentStatus) {
323
+ if (appointmentStatus === 'started') return 'occupied';
324
+ if (appointmentStatus === 'new' || appointmentStatus === 'confirmed' || appointmentStatus === 'arrived') {
325
+ return 'reserved';
326
+ }
327
+ // TODO: locked 的业务规则后续补充。
328
+ if (appointmentStatus === 'locked') return 'locked';
329
+ return undefined;
330
+ }
331
+ }, {
332
+ key: "getResourceId",
333
+ value: function getResourceId(resource) {
334
+ var _ref2, _resource$id;
335
+ return (_ref2 = (_resource$id = resource.id) !== null && _resource$id !== void 0 ? _resource$id : resource.form_record_id) !== null && _ref2 !== void 0 ? _ref2 : '';
336
+ }
337
+
338
+ /**
339
+ * 资源下 bookings 的返回裁剪策略:
340
+ * 1) 优先返回当前时刻正在进行中的预约(允许并发返回多条)
341
+ * 2) 若无 active,返回已超时且仍占用中的预约(允许并发多条)
342
+ * 3) 若仍无,返回最近一组未来预约(同 start_time 的并发预约全部返回)
343
+ * 4) 最后兜底返回一条(避免资源有历史预约时完全无反馈)
344
+ */
345
+ }, {
346
+ key: "pickBookingsForCurrentPoint",
347
+ value: function pickBookingsForCurrentPoint(current, bookings) {
348
+ var _this2 = this;
349
+ if (bookings.length === 0) return [];
350
+ var currentDayStart = current.startOf('day');
351
+ var currentDayEnd = current.endOf('day');
352
+
353
+ // 仅保留与 current 当天有时间交集的预约,避免跨天误命中
354
+ var dayScopedBookings = bookings.filter(function (booking) {
355
+ var startAt = _this2.toBookingDateTime(booking.start_date, booking.start_time);
356
+ var endAt = _this2.toBookingDateTime(booking.end_date, booking.end_time);
357
+ if (!startAt.isValid() || !endAt.isValid()) return false;
358
+ return _this2.isSameOrBefore(startAt, currentDayEnd) && _this2.isSameOrAfter(endAt, currentDayStart);
359
+ });
360
+ if (dayScopedBookings.length === 0) return [];
361
+ var appendNextStartGroupIfNeeded = function appendNextStartGroupIfNeeded(selectedBookings) {
362
+ if (selectedBookings.length === 0) return selectedBookings;
363
+ var shouldAppendNextGroup = selectedBookings.some(function (booking) {
364
+ return booking.status === 'reserved' || booking.status === 'occupied';
365
+ });
366
+ if (!shouldAppendNextGroup) return selectedBookings;
367
+ var selectedStartValues = new Set(selectedBookings.map(function (booking) {
368
+ return _this2.toBookingDateTime(booking.start_date, booking.start_time);
369
+ }).filter(function (startAt) {
370
+ return startAt.isValid();
371
+ }).map(function (startAt) {
372
+ return startAt.valueOf();
373
+ }));
374
+ var futureCandidates = dayScopedBookings.filter(function (booking) {
375
+ var startAt = _this2.toBookingDateTime(booking.start_date, booking.start_time);
376
+ if (!startAt.isValid()) return false;
377
+ return startAt.isAfter(current) && !selectedStartValues.has(startAt.valueOf());
378
+ });
379
+ if (futureCandidates.length === 0) return selectedBookings;
380
+ var nextStartAt = _this2.toBookingDateTime(futureCandidates[0].start_date, futureCandidates[0].start_time).valueOf();
381
+ var nextStartGroup = futureCandidates.filter(function (booking) {
382
+ var startAt = _this2.toBookingDateTime(booking.start_date, booking.start_time);
383
+ return startAt.isValid() && startAt.valueOf() === nextStartAt;
384
+ });
385
+ if (nextStartGroup.length === 0) return selectedBookings;
386
+ return [].concat(_toConsumableArray(selectedBookings), _toConsumableArray(nextStartGroup));
387
+ };
388
+
389
+ // active: current 处于 [startAt, endAt] 区间
390
+ var activeBookings = dayScopedBookings.filter(function (booking) {
391
+ var startAt = _this2.toBookingDateTime(booking.start_date, booking.start_time);
392
+ var endAt = _this2.toBookingDateTime(booking.end_date, booking.end_time);
393
+ if (!startAt.isValid() || !endAt.isValid()) return false;
394
+ return _this2.isSameOrAfter(current, startAt) && _this2.isSameOrBefore(current, endAt);
395
+ });
396
+ if (activeBookings.length > 0) return appendNextStartGroupIfNeeded(activeBookings);
397
+
398
+ // timeout occupied: 占用中且超时
399
+ var timeoutOccupied = dayScopedBookings.filter(function (booking) {
400
+ return booking.status === 'occupied' && booking.isTimeout;
401
+ });
402
+ if (timeoutOccupied.length > 0) return appendNextStartGroupIfNeeded(timeoutOccupied);
403
+
404
+ // upcoming: 从未来预约里只取最早那一组(同 start_time)
405
+ var upcoming = dayScopedBookings.filter(function (booking) {
406
+ var startAt = _this2.toBookingDateTime(booking.start_date, booking.start_time);
407
+ return startAt.isValid() && startAt.isAfter(current) && startAt.isSame(current, 'day');
408
+ });
409
+ if (upcoming.length > 0) {
410
+ var firstStartAt = this.toBookingDateTime(upcoming[0].start_date, upcoming[0].start_time).valueOf();
411
+ var upcomingStartGroup = upcoming.filter(function (booking) {
412
+ var startAt = _this2.toBookingDateTime(booking.start_date, booking.start_time);
413
+ return startAt.valueOf() === firstStartAt;
414
+ });
415
+ return appendNextStartGroupIfNeeded(upcomingStartGroup);
416
+ }
417
+
418
+ // fallback: 全部是过去且非 timeout 的场景,保留末条便于前端兜底展示
419
+ var fallback = dayScopedBookings[dayScopedBookings.length - 1];
420
+ return fallback ? [fallback] : [];
421
+ }
422
+
423
+ /**
424
+ * 标准化单条 booking:
425
+ * - 过滤终态(rejected/cancelled/completed)
426
+ * - 注入 status / isTimeout / reserved_status
427
+ */
428
+ }, {
429
+ key: "normalizeMatchedBooking",
430
+ value: function normalizeMatchedBooking(current, booking) {
431
+ var _ref3, _booking$appointment_;
432
+ var appointmentStatus = String((_ref3 = (_booking$appointment_ = booking.appointment_status) !== null && _booking$appointment_ !== void 0 ? _booking$appointment_ : booking.status) !== null && _ref3 !== void 0 ? _ref3 : '');
433
+ if (appointmentStatus === 'rejected' || appointmentStatus === 'cancelled' || appointmentStatus === 'completed') {
434
+ return null;
435
+ }
436
+ var bookingStatus = this.getBookingStatus(appointmentStatus);
437
+ var endAt = this.toBookingDateTime(booking.end_date, booking.end_time);
438
+ var startAt = this.toBookingDateTime(booking.start_date, booking.start_time);
439
+ var isTimeout = bookingStatus === 'occupied' && endAt.isValid() && current.isAfter(endAt);
440
+ var timeoutTime = isTimeout ? current.diff(endAt, 'minute') : undefined;
441
+ var progressPercent = function () {
442
+ if (bookingStatus !== 'occupied') return 0;
443
+ if (!startAt.isValid() || !endAt.isValid()) return 0;
444
+ var totalMinutes = endAt.diff(startAt, 'minute');
445
+ if (totalMinutes <= 0) return 0;
446
+ var elapsedMinutes = current.diff(startAt, 'minute');
447
+ if (elapsedMinutes <= 0) return 0;
448
+ if (elapsedMinutes >= totalMinutes) return 100;
449
+ return Math.floor(elapsedMinutes / totalMinutes * 100);
450
+ }();
451
+ var reservedStatus;
452
+ var lateTime;
453
+ if (bookingStatus === 'reserved' && startAt.isValid() && endAt.isValid()) {
454
+ if (current.isBefore(startAt)) reservedStatus = 'not_arrived';
455
+ if (current.isAfter(endAt)) {
456
+ reservedStatus = 'late';
457
+ lateTime = current.diff(startAt, 'minute');
458
+ }
459
+ }
460
+ return _objectSpread(_objectSpread({}, booking), {}, {
461
+ status: bookingStatus,
462
+ isTimeout: isTimeout,
463
+ timeoutTime: timeoutTime,
464
+ progressPercent: progressPercent,
465
+ lateTime: lateTime,
466
+ reserved_status: reservedStatus
467
+ });
468
+ }
469
+ }, {
470
+ key: "getResourceBookingList",
471
+ value: function () {
472
+ var _getResourceBookingList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(currentTime) {
473
+ var _resourceResponse$dat,
474
+ _resourceResponse$dat2,
475
+ _this3 = this;
476
+ var bookingList,
477
+ current,
478
+ resourceResponse,
479
+ resourceList,
480
+ normalizedBookings,
481
+ bookingMap,
482
+ _args3 = arguments;
483
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
484
+ while (1) switch (_context3.prev = _context3.next) {
485
+ case 0:
486
+ bookingList = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : [];
487
+ // currentTime 约定为完整 datetime;非法值直接返回空,避免误判
488
+ current = dayjs(currentTime);
489
+ if (current.isValid()) {
490
+ _context3.next = 4;
491
+ break;
492
+ }
493
+ return _context3.abrupt("return", []);
494
+ case 4:
495
+ _context3.next = 6;
496
+ return this.request.get('/shop/form/resource/page', {
497
+ skip: 1,
498
+ num: 999
499
+ },
500
+ // @ts-ignore
501
+ {
502
+ osServer: true,
503
+ isShopApi: true
504
+ });
505
+ case 6:
506
+ resourceResponse = _context3.sent;
507
+ resourceList = (_resourceResponse$dat = resourceResponse === null || resourceResponse === void 0 || (_resourceResponse$dat2 = resourceResponse.data) === null || _resourceResponse$dat2 === void 0 ? void 0 : _resourceResponse$dat2.list) !== null && _resourceResponse$dat !== void 0 ? _resourceResponse$dat : [];
508
+ if (!(!Array.isArray(resourceList) || resourceList.length === 0)) {
509
+ _context3.next = 10;
510
+ break;
511
+ }
512
+ return _context3.abrupt("return", []);
513
+ case 10:
514
+ // 全局先做 booking 标准化 + start_time 升序,后续映射直接复用
515
+ normalizedBookings = bookingList.map(function (booking) {
516
+ return _this3.normalizeMatchedBooking(current, booking);
517
+ }).filter(function (booking) {
518
+ return Boolean(booking);
519
+ }).sort(function (left, right) {
520
+ var leftStartAt = _this3.toBookingDateTime(left.start_date, left.start_time).valueOf();
521
+ var rightStartAt = _this3.toBookingDateTime(right.start_date, right.start_time).valueOf();
522
+ return leftStartAt - rightStartAt;
523
+ }); // 建立 resourceId -> bookings[] 倒排索引,加速资源匹配
524
+ bookingMap = new Map();
525
+ normalizedBookings.forEach(function (booking) {
526
+ if (!Array.isArray(booking.resources)) return;
527
+ booking.resources.forEach(function (resource) {
528
+ var relationId = resource === null || resource === void 0 ? void 0 : resource.relation_id;
529
+ if (relationId === undefined || relationId === null) return;
530
+ var key = String(relationId);
531
+ var list = bookingMap.get(key) || [];
532
+ list.push(booking);
533
+ bookingMap.set(key, list);
534
+ });
535
+ });
536
+
537
+ // 输出:每个资源都返回;bookings 可能是 0 / 1 / 多条(并发场景)
538
+ return _context3.abrupt("return", resourceList.map(function (resource) {
539
+ var resourceId = _this3.getResourceId(resource);
540
+ var matchedBookings = bookingMap.get(String(resourceId)) || [];
541
+ var bookings = _this3.pickBookingsForCurrentPoint(current, matchedBookings);
542
+ return _objectSpread(_objectSpread({}, resource), {}, {
543
+ resource_id: resourceId,
544
+ bookings: bookings
545
+ });
546
+ }));
547
+ case 14:
548
+ case "end":
549
+ return _context3.stop();
550
+ }
551
+ }, _callee3, this);
552
+ }));
553
+ function getResourceBookingList(_x2) {
554
+ return _getResourceBookingList.apply(this, arguments);
555
+ }
556
+ return getResourceBookingList;
557
+ }()
558
+ }]);
559
+ return SalesImpl;
560
+ }(BaseModule);
561
+ export { SalesImpl as Sales };
562
+ export default SalesImpl;
@@ -0,0 +1,66 @@
1
+ import dayjs from 'dayjs';
2
+ import type { OrderData } from '../../server/modules/order/types';
3
+ import type { BookingData } from '../../server/modules/order/types';
4
+ import type { ResourceData, ResourceId } from '../../server/modules/resource/types';
5
+ export declare enum SalesHooks {
6
+ onInited = "sales:onInited",
7
+ onDestroy = "sales:onDestroy",
8
+ onCurrentDayChanged = "sales:onCurrentDayChanged",
9
+ onReservationListChanged = "sales:onReservationListChanged"
10
+ }
11
+ /**
12
+ * 预订记录类型(暂用 OrderData 占位)
13
+ *
14
+ * TODO(Rolo): 等领导提供 reservationList 的目标结构后,
15
+ * 将 Server/Order 原始数据转换为真正的 Reservation DTO,
16
+ * 当前不要直接把 OrderData 当作最终 UI 数据结构。
17
+ */
18
+ export type Reservation = OrderData;
19
+ export type SalesBookingStatus = 'reserved' | 'occupied' | 'locked' | undefined;
20
+ export type SalesReservedStatus = 'not_arrived' | 'late' | undefined;
21
+ export interface SalesResourceMatchedBooking extends Omit<BookingData, 'status'> {
22
+ status: SalesBookingStatus;
23
+ isTimeout: boolean;
24
+ timeoutTime?: number;
25
+ progressPercent?: number;
26
+ lateTime?: number;
27
+ reserved_status: SalesReservedStatus;
28
+ }
29
+ export interface SalesResourceBookingItem extends Omit<ResourceData, 'bookings'> {
30
+ resource_id: ResourceId;
31
+ bookings: SalesResourceMatchedBooking[];
32
+ }
33
+ export type SalesTimelineHighlights = number[];
34
+ /**
35
+ * Sales 解决方案状态
36
+ *
37
+ * - currentDay: 当前选择的日期,默认当天 00:00:00
38
+ * - reservationList: currentDay 对应的预约列表(数据来源于 Server/Order,转换逻辑待补)
39
+ */
40
+ export interface SalesState {
41
+ /** 当前选择的日期,默认当天 00:00:00 */
42
+ currentDay: dayjs.Dayjs;
43
+ /** 当前日期对应的预约列表 */
44
+ reservationList: Reservation[];
45
+ }
46
+ /**
47
+ * Sales 解决方案最小 API 面
48
+ */
49
+ export interface SalesModuleAPI {
50
+ /** 获取当前 store 快照 */
51
+ getState: () => SalesState;
52
+ /** 获取当前选择日期 */
53
+ getCurrentDay: () => dayjs.Dayjs;
54
+ /** 设置当前选择日期,会自动归一到当天 00:00:00 */
55
+ setCurrentDay: (currentDay: dayjs.ConfigType) => dayjs.Dayjs;
56
+ /** 获取当前预约列表 */
57
+ getReservationList: () => Reservation[];
58
+ /** 覆盖设置当前预约列表 */
59
+ setReservationList: (reservationList: Reservation[]) => Reservation[];
60
+ /** 重置预约列表为空 */
61
+ resetReservationList: () => Reservation[];
62
+ /** 获取资源维度的预约占用列表 */
63
+ getResourceBookingList: (currentTime: string, bookingList: BookingData[]) => Promise<SalesResourceBookingItem[]>;
64
+ /** 获取时间轴每个时间片的预约数量 */
65
+ getTimelineHighlights: (bookingList: BookingData[], startDateTime?: string, endDateTime?: string) => SalesTimelineHighlights;
66
+ }