@pisell/pisellos 1.0.113 → 1.0.114

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.
@@ -308,7 +308,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
308
308
  date: string;
309
309
  status: string;
310
310
  week: string;
311
- weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
311
+ weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
312
312
  }[]>;
313
313
  submitTimeSlot(timeSlots: TimeSliceItem): void;
314
314
  private getScheduleDataByIds;
@@ -355,7 +355,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
355
355
  };
356
356
  setOtherData(key: string, value: any): void;
357
357
  getOtherData(key: string): any;
358
- getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
358
+ getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
359
359
  /**
360
360
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
361
361
  *
@@ -2208,12 +2208,22 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2208
2208
  }
2209
2209
  // 计算容量的辅助函数
2210
2210
  var calculateCapacityFromCartItems = function calculateCapacityFromCartItems(items) {
2211
+ var _items$0$_resourceOri;
2212
+ // 还需要增加一个判断,maxCapacity 必须是我单个人里选择的资源只有同一种的情况下才可以累加,否则单个账号都是 1
2213
+ var firstResource = (_items$0$_resourceOri = items[0]._resourceOrigin) === null || _items$0$_resourceOri === void 0 ? void 0 : _items$0$_resourceOri[0].id;
2214
+ var sameResourceLength = items.filter(function (item) {
2215
+ var _item$_resourceOrigin;
2216
+ return ((_item$_resourceOrigin = item._resourceOrigin) === null || _item$_resourceOrigin === void 0 ? void 0 : _item$_resourceOrigin[0].id) === firstResource;
2217
+ }).length;
2218
+ if (sameResourceLength !== items.length) {
2219
+ return 1;
2220
+ }
2211
2221
  return items.reduce(function (total, item) {
2212
2222
  return total + (getCapacityInfoByCartItem(item).currentCapacity || 0);
2213
2223
  }, 0);
2214
2224
  };
2215
2225
 
2216
- // 如果是多个预约,去要求出几个 holder 下最大的需求容量capacity
2226
+ // 如果是多个人预约,去要求出几个 holder 下最大的商品需求容量capacity
2217
2227
  var maxCapacity = 1;
2218
2228
  if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
2219
2229
  accountList.forEach(function (account) {
@@ -2368,6 +2378,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2368
2378
  }
2369
2379
  // 计算容量的辅助函数
2370
2380
  calculateCapacityFromCartItems = function calculateCapacityFromCartItems(items) {
2381
+ var _items$0$_resourceOri2;
2382
+ // 还需要增加一个判断,maxCapacity 必须是我单个人里选择的资源只有同一种的情况下才可以累加,否则单个账号都是 1
2383
+ var firstResource = (_items$0$_resourceOri2 = items[0]._resourceOrigin) === null || _items$0$_resourceOri2 === void 0 ? void 0 : _items$0$_resourceOri2[0].id;
2384
+ var sameResourceLength = items.filter(function (item) {
2385
+ var _item$_resourceOrigin2;
2386
+ return ((_item$_resourceOrigin2 = item._resourceOrigin) === null || _item$_resourceOrigin2 === void 0 ? void 0 : _item$_resourceOrigin2[0].id) === firstResource;
2387
+ }).length;
2388
+ if (sameResourceLength !== items.length) {
2389
+ return 1;
2390
+ }
2371
2391
  return items.reduce(function (total, item) {
2372
2392
  return total + (getCapacityInfoByCartItem(item).currentCapacity || 0);
2373
2393
  }, 0);
@@ -444,6 +444,10 @@ export var getTimeSlicesByResource = function getTimeSlicesByResource(_ref5) {
444
444
  // 解析开始和结束时间
445
445
  var startTime = dayjs("".concat(time.start_at));
446
446
  var endTime = dayjs("".concat(time.end_at));
447
+ // 结束时间要做修复,如果time.end_at 是超过了 currentDate 的那一天,则把 end_at 设置为 currentDate 那一天的 23:59:59
448
+ if (endTime.isAfter(dayjs(currentDate).endOf('day'))) {
449
+ endTime = dayjs(currentDate).endOf('day');
450
+ }
447
451
 
448
452
  // 当前切片的开始时间
449
453
  var currentStart = startTime;
@@ -308,7 +308,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
308
308
  date: string;
309
309
  status: string;
310
310
  week: string;
311
- weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
311
+ weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
312
312
  }[]>;
313
313
  submitTimeSlot(timeSlots: TimeSliceItem): void;
314
314
  private getScheduleDataByIds;
@@ -355,7 +355,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
355
355
  };
356
356
  setOtherData(key: string, value: any): void;
357
357
  getOtherData(key: string): any;
358
- getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
358
+ getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
359
359
  /**
360
360
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
361
361
  *
@@ -1530,6 +1530,15 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1530
1530
  }, 0);
1531
1531
  }
1532
1532
  const calculateCapacityFromCartItems = (items) => {
1533
+ var _a2;
1534
+ const firstResource = (_a2 = items[0]._resourceOrigin) == null ? void 0 : _a2[0].id;
1535
+ const sameResourceLength = items.filter((item) => {
1536
+ var _a3;
1537
+ return ((_a3 = item._resourceOrigin) == null ? void 0 : _a3[0].id) === firstResource;
1538
+ }).length;
1539
+ if (sameResourceLength !== items.length) {
1540
+ return 1;
1541
+ }
1533
1542
  return items.reduce((total, item) => {
1534
1543
  return total + ((0, import_capacity.getCapacityInfoByCartItem)(item).currentCapacity || 0);
1535
1544
  }, 0);
@@ -1656,6 +1665,15 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1656
1665
  }, 0);
1657
1666
  }
1658
1667
  const calculateCapacityFromCartItems = (items) => {
1668
+ var _a2;
1669
+ const firstResource = (_a2 = items[0]._resourceOrigin) == null ? void 0 : _a2[0].id;
1670
+ const sameResourceLength = items.filter((item) => {
1671
+ var _a3;
1672
+ return ((_a3 = item._resourceOrigin) == null ? void 0 : _a3[0].id) === firstResource;
1673
+ }).length;
1674
+ if (sameResourceLength !== items.length) {
1675
+ return 1;
1676
+ }
1659
1677
  return items.reduce((total, item) => {
1660
1678
  return total + ((0, import_capacity.getCapacityInfoByCartItem)(item).currentCapacity || 0);
1661
1679
  }, 0);
@@ -353,7 +353,10 @@ var getTimeSlicesByResource = ({
353
353
  });
354
354
  times.forEach((time) => {
355
355
  const startTime = (0, import_dayjs.default)(`${time.start_at}`);
356
- const endTime = (0, import_dayjs.default)(`${time.end_at}`);
356
+ let endTime = (0, import_dayjs.default)(`${time.end_at}`);
357
+ if (endTime.isAfter((0, import_dayjs.default)(currentDate).endOf("day"))) {
358
+ endTime = (0, import_dayjs.default)(currentDate).endOf("day");
359
+ }
357
360
  let currentStart = startTime;
358
361
  while (true) {
359
362
  const currentEnd = currentStart.add(duration, "minute");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "1.0.113",
4
+ "version": "1.0.114",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",