@pisell/pisellos 0.0.5 → 0.0.7

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 (75) hide show
  1. package/dist/core/index.d.ts +1 -0
  2. package/dist/core/index.js +7 -1
  3. package/dist/effects/index.d.ts +1 -1
  4. package/dist/effects/index.js +4 -5
  5. package/dist/modules/Account/index.d.ts +7 -1
  6. package/dist/modules/Account/index.js +67 -17
  7. package/dist/modules/Account/types.d.ts +2 -1
  8. package/dist/modules/AccountList/index.d.ts +18 -0
  9. package/dist/modules/AccountList/index.js +264 -0
  10. package/dist/modules/AccountList/types.d.ts +37 -0
  11. package/dist/modules/AccountList/types.js +17 -0
  12. package/dist/modules/BaseModule.js +1 -0
  13. package/dist/modules/Cart/index.d.ts +3 -1
  14. package/dist/modules/Cart/index.js +53 -12
  15. package/dist/modules/Cart/types.d.ts +3 -3
  16. package/dist/modules/Date/types.d.ts +2 -1
  17. package/dist/modules/Date/types.js +1 -0
  18. package/dist/modules/ProductList/index.d.ts +1 -1
  19. package/dist/modules/ProductList/index.js +20 -12
  20. package/dist/modules/Resource/index.d.ts +7 -5
  21. package/dist/modules/Resource/index.js +17 -20
  22. package/dist/modules/Resource/utils.d.ts +23 -0
  23. package/dist/modules/Resource/utils.js +28 -0
  24. package/dist/modules/Step/index.d.ts +19 -0
  25. package/dist/modules/Step/index.js +107 -0
  26. package/dist/modules/Step/tyeps.d.ts +18 -0
  27. package/dist/modules/Step/tyeps.js +1 -0
  28. package/dist/plugins/request.d.ts +1 -1
  29. package/dist/solution/BookingByStep/index.d.ts +29 -1
  30. package/dist/solution/BookingByStep/index.js +363 -12
  31. package/dist/solution/BookingByStep/types.d.ts +6 -2
  32. package/dist/solution/BookingByStep/types.js +29 -0
  33. package/dist/solution/BookingByStep/utils/resources.d.ts +61 -0
  34. package/dist/solution/BookingByStep/utils/resources.js +380 -0
  35. package/dist/solution/BuyTickets/index.js +1 -1
  36. package/dist/store/createStore.js +1 -1
  37. package/dist/types/index.d.ts +2 -1
  38. package/lib/core/index.d.ts +1 -0
  39. package/lib/core/index.js +5 -1
  40. package/lib/effects/index.d.ts +1 -1
  41. package/lib/effects/index.js +1 -2
  42. package/lib/modules/Account/index.d.ts +7 -1
  43. package/lib/modules/Account/index.js +34 -18
  44. package/lib/modules/Account/types.d.ts +2 -1
  45. package/lib/modules/AccountList/index.d.ts +18 -0
  46. package/lib/modules/AccountList/index.js +126 -0
  47. package/lib/modules/AccountList/types.d.ts +37 -0
  48. package/lib/modules/AccountList/types.js +33 -0
  49. package/lib/modules/BaseModule.js +1 -0
  50. package/lib/modules/Cart/index.d.ts +3 -1
  51. package/lib/modules/Cart/index.js +13 -3
  52. package/lib/modules/Cart/types.d.ts +3 -3
  53. package/lib/modules/Date/types.d.ts +2 -1
  54. package/lib/modules/Date/types.js +1 -0
  55. package/lib/modules/ProductList/index.d.ts +1 -1
  56. package/lib/modules/ProductList/index.js +8 -7
  57. package/lib/modules/Resource/index.d.ts +7 -5
  58. package/lib/modules/Resource/index.js +16 -20
  59. package/lib/modules/Resource/utils.d.ts +23 -0
  60. package/lib/modules/Resource/utils.js +39 -0
  61. package/lib/modules/Step/index.d.ts +19 -0
  62. package/lib/modules/Step/index.js +76 -0
  63. package/lib/modules/Step/tyeps.d.ts +18 -0
  64. package/lib/modules/Step/tyeps.js +17 -0
  65. package/lib/plugins/request.d.ts +1 -1
  66. package/lib/solution/BookingByStep/index.d.ts +29 -1
  67. package/lib/solution/BookingByStep/index.js +99 -5
  68. package/lib/solution/BookingByStep/types.d.ts +6 -2
  69. package/lib/solution/BookingByStep/types.js +33 -2
  70. package/lib/solution/BookingByStep/utils/resources.d.ts +61 -0
  71. package/lib/solution/BookingByStep/utils/resources.js +215 -0
  72. package/lib/solution/BuyTickets/index.js +1 -1
  73. package/lib/store/createStore.js +1 -1
  74. package/lib/types/index.d.ts +2 -1
  75. package/package.json +9 -8
@@ -1,3 +1,32 @@
1
+ import { ProductList, CartModule } from "../../modules";
2
+ import { AccountListModule } from "../../modules/AccountList";
3
+ import { DateModule } from "../../modules/Date";
4
+ import { GuestListModule } from "../../modules/Guests";
5
+ import { OrderModule } from "../../modules/Order";
6
+ import { PaymentModule } from "../../modules/Payment";
7
+ import { StepModule } from "../../modules/Step";
8
+ export function createModule(moduleName, solutionName, name, version) {
9
+ switch (moduleName) {
10
+ case 'cart':
11
+ return new CartModule("".concat(solutionName, "_").concat(name || moduleName), version);
12
+ case 'step':
13
+ return new StepModule("".concat(solutionName, "_").concat(name || moduleName), version);
14
+ case 'products':
15
+ return new ProductList("".concat(solutionName, "_").concat(name || moduleName), version);
16
+ case 'guests':
17
+ return new GuestListModule("".concat(solutionName, "_").concat(name || moduleName), version);
18
+ case 'date':
19
+ return new DateModule("".concat(solutionName, "_").concat(name || moduleName), version);
20
+ case 'accountList':
21
+ return new AccountListModule("".concat(solutionName, "_").concat(name || moduleName), version);
22
+ case 'order':
23
+ return new OrderModule("".concat(solutionName, "_").concat(name || moduleName), version);
24
+ case 'payment':
25
+ return new PaymentModule("".concat(solutionName, "_").concat(name || moduleName), version);
26
+ default:
27
+ throw new Error("Unknown module type: ".concat(moduleName));
28
+ }
29
+ }
1
30
  export var BookingByStepHooks = /*#__PURE__*/function (BookingByStepHooks) {
2
31
  BookingByStepHooks["onInited"] = "bookingByStep:onInited";
3
32
  BookingByStepHooks["onDestroy"] = "bookingByStep:onDestroy";
@@ -0,0 +1,61 @@
1
+ import { Dayjs } from 'dayjs';
2
+ /**
3
+ * 1. 获取资源列表
4
+ * 2. 根据当前选择的商品过滤出来对应的资源列表 getResourcesByProduct
5
+ * 3. 格式化资源相关 格式化资源列表 --> 格式化资源 --> 获取时间切片列表 --> 判断单个时间切片是否可用 formatResources
6
+ *
7
+ */
8
+ type DateType = Dayjs | string;
9
+ interface TimeSliceItem {
10
+ start: DateType;
11
+ end: DateType;
12
+ start_at: DateType;
13
+ end_at: DateType;
14
+ [key: string]: any;
15
+ }
16
+ interface ResourceItem {
17
+ [key: string]: any;
18
+ }
19
+ interface BookingItem {
20
+ [key: string]: any;
21
+ }
22
+ interface ProductItem {
23
+ [key: string]: any;
24
+ }
25
+ /**
26
+ * @title: 获取商品下绑定的资源列表
27
+ * @description:
28
+ * @param {any} resourcesMap
29
+ * @param {any} product
30
+ * @return {*}
31
+ * @Author: zhiwei.Wang
32
+ */
33
+ export declare const getResourcesByProduct: (resourcesMap: Record<string, ResourceItem>, product: ProductItem) => any;
34
+ export declare const getSumCapacity: () => number;
35
+ /**
36
+ * @title: 获取资源列表
37
+ * @description:
38
+ * @return {*}
39
+ * @Author: zhiwei.Wang
40
+ * @Date: 2024-01-09 13:38
41
+ */
42
+ export declare const formatResources: ({ booking, resources }: {
43
+ booking: BookingItem;
44
+ resources: ResourceItem[];
45
+ }) => {
46
+ list: ResourceItem[];
47
+ maps: any;
48
+ };
49
+ /**
50
+ * @title: 获取资源的时间切片列表
51
+ * @description:
52
+ * @return {*}
53
+ * @Author: zhiwei.Wang
54
+ */
55
+ export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate }: {
56
+ resource: ResourceItem;
57
+ duration: number;
58
+ split: number;
59
+ currentDate: DateType;
60
+ }) => TimeSliceItem[];
61
+ export {};
@@ -0,0 +1,380 @@
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 _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
7
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
8
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
9
+ 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; }
10
+ 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; }
11
+ 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; }
12
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
13
+ 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); }
14
+ import dayjs from 'dayjs';
15
+
16
+ /**
17
+ * 1. 获取资源列表
18
+ * 2. 根据当前选择的商品过滤出来对应的资源列表 getResourcesByProduct
19
+ * 3. 格式化资源相关 格式化资源列表 --> 格式化资源 --> 获取时间切片列表 --> 判断单个时间切片是否可用 formatResources
20
+ *
21
+ */
22
+
23
+ /**
24
+ * @title: 获取重叠剩余量
25
+ * @description:
26
+ * @param {any} eventList
27
+ * @param {number} current
28
+ * @return {*}
29
+ * @Author: zhiwei.Wang
30
+ */
31
+ var getUseableEventCount = function getUseableEventCount(eventList, current) {
32
+ return (eventList || []).reduce(function (pre, event) {
33
+ return pre - event.pax;
34
+ }, current || 0);
35
+ };
36
+
37
+ /**
38
+ * @title: 判断两个时间段是否有重叠
39
+ * @description:
40
+ * @param {object} event
41
+ * @param {object} current
42
+ * @return {*}
43
+ * @Author: zhiwei.Wang
44
+ */
45
+ var isConflict = function isConflict(event, current) {
46
+ var eventStart = dayjs(event.start_at);
47
+ var eventEnd = dayjs(event.end_at);
48
+ var currentStart = dayjs(current.start_at);
49
+ var _isBefore = currentStart.isBefore(eventEnd);
50
+ var _isAfter = true;
51
+
52
+ // 如果传递结束时间,则比对结束时间
53
+ if (current.end_at) {
54
+ var currentEnd = dayjs(current.end_at);
55
+ _isAfter = currentEnd.isAfter(eventStart);
56
+ }
57
+
58
+ // 检查是否有重叠
59
+ return _isBefore && _isAfter;
60
+ };
61
+
62
+ /**
63
+ * @title: 判断传入日期是否在当前日期之后
64
+ * @description:
65
+ * @param {any} date
66
+ * @param {any} today
67
+ * @return {*}
68
+ * @Author: zhiwei.Wang
69
+ */
70
+ var checkAfterToDay = function checkAfterToDay(date) {
71
+ var today = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : dayjs();
72
+ return dayjs(date).isAfter(dayjs(today));
73
+ };
74
+
75
+ /**
76
+ * @title: 格式化资源, 添加自定义参数
77
+ * @description:
78
+ * @param {any} resourceItem
79
+ * @return {*}
80
+ * @Author: zhiwei.Wang
81
+ * @Date: 2024-01-09 13:40
82
+ */
83
+ var formatResource = function formatResource(resourceItem, booking) {
84
+ // 当前资源
85
+ var _resourceItem = _objectSpread({}, resourceItem);
86
+
87
+ // 格式化times里面的数据
88
+ _resourceItem.timeSlices = getTimeSlicesByResource({
89
+ resource: _resourceItem,
90
+ duration: booking.duration,
91
+ split: 10,
92
+ currentDate: dayjs().format('YYYY-MM-DD')
93
+ });
94
+
95
+ // 格式化label
96
+ _resourceItem.labelText = _resourceItem.main_field;
97
+ return _resourceItem;
98
+ };
99
+
100
+ /**
101
+ * @title: 判断资源容量是否可用
102
+ * @description:
103
+ * @param {object} param1
104
+ * @return {*}
105
+ * @Author: zhiwei.Wang
106
+ */
107
+ var checkCapacity = function checkCapacity(_ref) {
108
+ var event_list = _ref.event_list,
109
+ timeSlice = _ref.timeSlice,
110
+ resource = _ref.resource,
111
+ _ref$currentCount = _ref.currentCount,
112
+ currentCount = _ref$currentCount === void 0 ? 1 : _ref$currentCount;
113
+ var conflict = (event_list || []).filter(function (d) {
114
+ return isConflict({
115
+ start_at: d.start_at,
116
+ end_at: d.end_at
117
+ }, {
118
+ start_at: timeSlice.start_at,
119
+ end_at: timeSlice.end_at
120
+ });
121
+ });
122
+
123
+ // 同一时间段内只能进行一个预约,无论容量是否已满。
124
+ if (resource.resourceType === 'single') {
125
+ // 0代表着不重叠,则满足条件
126
+ if (conflict.length === 0) {
127
+ return true;
128
+ } else {
129
+ return false;
130
+ }
131
+ } else {
132
+ // 减去重叠的总量
133
+ var conflictCount = getUseableEventCount(conflict, resource.capacity);
134
+
135
+ // 当前预约量 <= 总剩余容量
136
+ if (currentCount <= conflictCount) {
137
+ return true;
138
+ } else {
139
+ return false;
140
+ }
141
+ }
142
+ };
143
+
144
+ /**
145
+ * @title: 获取时间切片是否可用
146
+ * @description: 根据时间切片、资源、当前预约量判断时间切片是否可用
147
+ * @param {any} param1
148
+ * @return {*}
149
+ * @Author: zhiwei.Wang
150
+ */
151
+ var getIsUsableByTimeItem = function getIsUsableByTimeItem(_ref2) {
152
+ var timeSlice = _ref2.timeSlice,
153
+ time = _ref2.time,
154
+ resource = _ref2.resource,
155
+ _ref2$currentCount = _ref2.currentCount,
156
+ currentCount = _ref2$currentCount === void 0 ? 1 : _ref2$currentCount;
157
+ var status = {
158
+ afterToDay: false,
159
+ capacity: false,
160
+ usable: false
161
+ };
162
+ // 最早可预约时间为 当前日期之后并且提前量之后
163
+ var earliest = dayjs();
164
+
165
+ // 不可预约提前量时间之前的
166
+ if (!checkAfterToDay(timeSlice.start_at, earliest)) {
167
+ return status;
168
+ }
169
+ status.afterToDay = true;
170
+ if (!checkCapacity({
171
+ event_list: time === null || time === void 0 ? void 0 : time.event_list,
172
+ timeSlice: timeSlice,
173
+ resource: resource,
174
+ currentCount: currentCount
175
+ })) {
176
+ return status;
177
+ }
178
+ status.capacity = true;
179
+ status.usable = true;
180
+ return status;
181
+ };
182
+
183
+ /**
184
+ * @title: 获取商品下绑定的资源列表
185
+ * @description:
186
+ * @param {any} resourcesMap
187
+ * @param {any} product
188
+ * @return {*}
189
+ * @Author: zhiwei.Wang
190
+ */
191
+ export var getResourcesByProduct = function getResourcesByProduct(resourcesMap, product) {
192
+ var _product$product_reso;
193
+ // 过滤出开启的资源
194
+ var _resources = ((product === null || product === void 0 || (_product$product_reso = product.product_resource) === null || _product$product_reso === void 0 ? void 0 : _product$product_reso.resources) || []).filter(function (d) {
195
+ return d.status == 1;
196
+ });
197
+ var _iterator = _createForOfIteratorHelper(_resources),
198
+ _step;
199
+ try {
200
+ var _loop = function _loop() {
201
+ var item = _step.value;
202
+ // 资源类型id
203
+ var form_id = item.id;
204
+
205
+ // 去重 可选资源和必选资源可能会有重复的
206
+ item.optional_resource = (item.optional_resource || []).filter(function (d) {
207
+ return item.default_resource.indexOf(d) == -1;
208
+ });
209
+
210
+ // 可选项
211
+ var optional_resource = item.optional_resource.map(function (d) {
212
+ return (
213
+ // 合并数据, 将资源配置项添加到每一条内
214
+ resourcesMap[d] ? Object.assign({}, resourcesMap[d], {
215
+ form_id: form_id,
216
+ resourceType: item.type
217
+ }) : null
218
+ );
219
+ })
220
+ // 过滤空值, 商品绑定的资源可能已经不存在
221
+ .filter(function (d) {
222
+ return d;
223
+ });
224
+
225
+ // 默认项
226
+ var default_resource = item.default_resource.map(function (d) {
227
+ var item = resourcesMap[d];
228
+ if (item) {
229
+ item.is_default = 1;
230
+ return Object.assign({}, item, {
231
+ form_id: form_id,
232
+ resourceType: item.type
233
+ });
234
+ } else {
235
+ return null;
236
+ }
237
+ }).filter(function (d) {
238
+ return d;
239
+ });
240
+
241
+ // 合并渲染
242
+ item.renderList = optional_resource.concat(default_resource);
243
+
244
+ // 统一字段 将id改为form_id
245
+ item.form_id = form_id;
246
+ };
247
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
248
+ _loop();
249
+ }
250
+ } catch (err) {
251
+ _iterator.e(err);
252
+ } finally {
253
+ _iterator.f();
254
+ }
255
+ console.log('_resources', _resources);
256
+ return _resources;
257
+ };
258
+ export var getSumCapacity = function getSumCapacity() {
259
+ // let sum = 0;
260
+ // for (let item of booking._extend.capacity || []) {
261
+ // sum += item.value;
262
+ // }
263
+ // 一期默认为1人
264
+ return 1;
265
+ };
266
+
267
+ /**
268
+ * @title: 获取资源列表
269
+ * @description:
270
+ * @return {*}
271
+ * @Author: zhiwei.Wang
272
+ * @Date: 2024-01-09 13:38
273
+ */
274
+ export var formatResources = function formatResources(_ref3) {
275
+ var booking = _ref3.booking,
276
+ resources = _ref3.resources;
277
+ try {
278
+ var _list = _toConsumableArray(resources);
279
+ var maps = {};
280
+ var _iterator2 = _createForOfIteratorHelper(_list),
281
+ _step2;
282
+ try {
283
+ var _loop2 = function _loop2() {
284
+ var item = _step2.value;
285
+ var renderListMaps = {};
286
+ item.renderList = item.renderList.map(function (d) {
287
+ var res = formatResource(d, booking);
288
+ renderListMaps[res.id] = res;
289
+ return res;
290
+ }).sort(function (a, b) {
291
+ return b.usable ? 1 : -1;
292
+ });
293
+ maps[item.form_id] = _objectSpread(_objectSpread({}, item), {}, {
294
+ renderListMaps: renderListMaps
295
+ });
296
+ };
297
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
298
+ _loop2();
299
+ }
300
+ } catch (err) {
301
+ _iterator2.e(err);
302
+ } finally {
303
+ _iterator2.f();
304
+ }
305
+ return {
306
+ list: _list,
307
+ maps: maps
308
+ };
309
+ } catch (err) {
310
+ console.log('formatResourcesErr', err);
311
+ }
312
+ return {
313
+ list: [],
314
+ maps: {}
315
+ };
316
+ };
317
+
318
+ /**
319
+ * @title: 获取资源的时间切片列表
320
+ * @description:
321
+ * @return {*}
322
+ * @Author: zhiwei.Wang
323
+ */
324
+ export var getTimeSlicesByResource = function getTimeSlicesByResource(_ref4) {
325
+ var resource = _ref4.resource,
326
+ duration = _ref4.duration,
327
+ _ref4$split = _ref4.split,
328
+ split = _ref4$split === void 0 ? 10 : _ref4$split,
329
+ _ref4$currentDate = _ref4.currentDate,
330
+ currentDate = _ref4$currentDate === void 0 ? dayjs() : _ref4$currentDate;
331
+ var times = resource.times;
332
+
333
+ // 存储所有时间切片
334
+ var timeSlices = [];
335
+
336
+ // 处理每个时间范围
337
+ times.forEach(function (time) {
338
+ // 创建今天的日期字符串,用于构建完整的日期时间
339
+ var today = dayjs(currentDate).format('YYYY-MM-DD');
340
+
341
+ // 解析开始和结束时间
342
+ var startTime = dayjs("".concat(today, " ").concat(time.start_time));
343
+ var endTime = dayjs("".concat(today, " ").concat(time.end_time));
344
+
345
+ // 当前切片的开始时间
346
+ var currentStart = startTime;
347
+
348
+ // 生成时间切片
349
+ while (true) {
350
+ // 计算当前切片的结束时间
351
+ var currentEnd = currentStart.add(duration, 'minute');
352
+
353
+ // 如果结束时间超过了时间范围的结束时间,则停止
354
+ if (currentEnd.isAfter(endTime)) {
355
+ break;
356
+ }
357
+ var timeSlice = {
358
+ start: currentStart.format('HH:mm'),
359
+ end: currentEnd.format('HH:mm'),
360
+ start_at: currentStart,
361
+ end_at: currentEnd
362
+ };
363
+
364
+ // 添加时间切片
365
+ timeSlices.push(_objectSpread(_objectSpread({}, timeSlice), {}, {
366
+ // 这里需要补充这个时间段内是否可预约
367
+ _status: getIsUsableByTimeItem({
368
+ timeSlice: timeSlice,
369
+ time: time,
370
+ resource: resource,
371
+ currentCount: getSumCapacity()
372
+ })
373
+ }));
374
+
375
+ // 移动到下一个开始时间(增加10分钟)
376
+ currentStart = currentStart.add(split, 'minute');
377
+ }
378
+ });
379
+ return timeSlices;
380
+ };
@@ -93,7 +93,7 @@ export var BuyTicketsImpl = /*#__PURE__*/function (_BaseModule) {
93
93
  while (1) switch (_context2.prev = _context2.next) {
94
94
  case 0:
95
95
  _context2.next = 2;
96
- return this.request.post("".concat(this.core.context.apiBasePath, "/shop/product/query"), {
96
+ return this.request.post('/product/query', {
97
97
  ids: ids,
98
98
  open_quotation: 1,
99
99
  open_bundle: 1,
@@ -24,7 +24,7 @@ export function createStore(initialState, moduleName, onChange) {
24
24
  // timestamp: Date.now(),
25
25
  // });
26
26
  var result = Reflect.set(target, prop, value, receiver);
27
- onChange === null || onChange === void 0 || onChange("".concat(moduleName, ".").concat(String(prop)), value);
27
+ onChange === null || onChange === void 0 || onChange("".concat(String(prop)), value);
28
28
  return result;
29
29
  },
30
30
  deleteProperty: function deleteProperty(target, prop) {
@@ -33,12 +33,13 @@ export interface PisellCore {
33
33
  getPlugin: <T extends Plugin>(name: string) => T | null;
34
34
  hasPlugin: (name: string) => boolean;
35
35
  registerModule: (module: Module, options?: ModuleOptions) => void;
36
+ unregisterModule: (module: Module, options?: ModuleOptions) => void;
36
37
  getModule: <T extends Module>(name: string) => T | null;
37
38
  getModuleExports: <T = any>(name: string) => T | null;
38
39
  hasModule: (name: string) => boolean;
39
40
  effects: {
40
41
  on: (event: string, callback: (payload: any) => void) => void;
41
- emit: (event: string, payload: any) => Promise<{
42
+ emit: (event: string, payload: any, value?: any) => Promise<{
42
43
  status: boolean;
43
44
  data: any;
44
45
  }>;
@@ -17,6 +17,7 @@ declare class PisellOSCore implements PisellCore {
17
17
  getPlugin<T extends Plugin>(name: string): T | null;
18
18
  hasPlugin(name: string): boolean;
19
19
  registerModule(module: Module, options?: ModuleOptions): void;
20
+ unregisterModule(module: Module): void;
20
21
  getModule<T extends Module>(name: string): T | null;
21
22
  getModuleExports<T = any>(name: string): T | null;
22
23
  hasModule(name: string): boolean;
package/lib/core/index.js CHANGED
@@ -125,7 +125,7 @@ var PisellOSCore = class {
125
125
  module2.name,
126
126
  (path, value) => {
127
127
  console.log("core 检测到模块值更新", module2.name, path, value);
128
- this.effects.emit(`${module2.name}:changed`, value);
128
+ this.effects.emit(`${module2.name}:changed`, path, value);
129
129
  if (module2.storeChange)
130
130
  module2.storeChange(path, value);
131
131
  }
@@ -146,6 +146,10 @@ var PisellOSCore = class {
146
146
  throw error;
147
147
  }
148
148
  }
149
+ unregisterModule(module2) {
150
+ this.stores.delete(module2.name);
151
+ this.modules.delete(module2.name);
152
+ }
149
153
  getModule(name) {
150
154
  return this.modules.get(name) || null;
151
155
  }
@@ -8,7 +8,7 @@ declare class EffectsManager {
8
8
  off(event: string, callback: EffectCallback): void;
9
9
  offByModuleDestroy(module: string): void;
10
10
  once(event: string, callback: EffectCallback): void;
11
- emit(event: string, payload: any): Promise<{
11
+ emit(event: string, payload: any, value: any): Promise<{
12
12
  status: boolean;
13
13
  data: any;
14
14
  }>;
@@ -51,7 +51,7 @@ var EffectsManager = class {
51
51
  };
52
52
  this.on(event, wrapper);
53
53
  }
54
- async emit(event, payload) {
54
+ async emit(event, payload, value) {
55
55
  const callbacks = this.listeners.get(event);
56
56
  if (!callbacks)
57
57
  return { status: true, data: [] };
@@ -63,7 +63,6 @@ var EffectsManager = class {
63
63
  res.push(result);
64
64
  }
65
65
  }
66
- console.log(res);
67
66
  const isAllPass = res.every((r) => (r == null ? void 0 : r.status) !== false);
68
67
  resolve({ status: isAllPass, data: res });
69
68
  });
@@ -1,12 +1,15 @@
1
1
  import { Module, PisellCore, ModuleOptions } from '../../types';
2
2
  import { BaseModule } from '../BaseModule';
3
3
  import { Account, AccountModuleAPI } from './types';
4
+ export * from './types';
4
5
  export declare class AccountModule extends BaseModule implements Module, AccountModuleAPI {
5
6
  protected defaultName: string;
6
7
  protected defaultVersion: string;
7
- private state;
8
+ isGuest: boolean;
9
+ private store;
8
10
  constructor(name?: string, version?: string);
9
11
  initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
12
+ getId(): string;
10
13
  login(credentials: {
11
14
  username: string;
12
15
  password: string;
@@ -18,4 +21,7 @@ export declare class AccountModule extends BaseModule implements Module, Account
18
21
  isLoggedIn(): boolean;
19
22
  resetPassword(email: string): Promise<void>;
20
23
  updatePassword(oldPassword: string, newPassword: string): Promise<void>;
24
+ getLoginStatus(): Promise<boolean>;
25
+ getAccount(): Promise<Account | null>;
26
+ setAccountInfo(account: Account): void;
21
27
  }