@pisell/pisellos 0.0.418 → 0.0.419

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.
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "normal" | "duration" | "session";
52
+ getProductType(): "duration" | "session" | "normal";
53
53
  }
@@ -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);
@@ -2743,9 +2763,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2743
2763
  // n.start_at 是 2025-06-30 15:00 end_at 2025-06-30 17:00
2744
2764
  // item.start 是 2025-06-30 16:00 item.end 是 2025-06-30 19:00
2745
2765
  // 需要判断 n.start_at 和 n.end_at 是否在 item.start 和 item.end 之间
2746
- // 如果 n.start_at 和 n.end_at 在 item.start 和 item.end 有交集,则此时间需要计算
2766
+ // 如果是仅用于计算的资源, n.start_at 和 n.end_at 在 item.start 和 item.end 有交集,则此时间需要计算
2767
+ // https://project.feishu.cn/v2qint/bug/detail/6657165010
2747
2768
  var mTimes = m.times.filter(function (n) {
2748
- return !dayjs(n.start_at).isAfter(dayjs(item.start), 'minute') && !dayjs(n.end_at).isBefore(dayjs(item.end), 'minute') || dayjs(n.start_at).isBefore(dayjs(item.end), 'minute') && dayjs(n.end_at).isAfter(dayjs(item.start), 'minute');
2769
+ return !dayjs(n.start_at).isAfter(dayjs(item.start), 'minute') && !dayjs(n.end_at).isBefore(dayjs(item.end), 'minute') || m.onlyComputed && dayjs(n.start_at).isBefore(dayjs(item.end), 'minute') && dayjs(n.end_at).isAfter(dayjs(item.start), 'minute');
2749
2770
  });
2750
2771
  // 如果在这个区间的时间一个都没有,可以直接认为这个资源不可用
2751
2772
  if (mTimes.length === 0) {
@@ -320,7 +320,7 @@ export function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, all
320
320
  resourcesInType.forEach(function (resource) {
321
321
  // 过滤出在时间段内的资源时间片
322
322
  var availableTimes = resource.times.filter(function (time) {
323
- return !dayjs(time.start_at).isAfter(dayjs(timeSlotStart), 'minute') && !dayjs(time.end_at).isBefore(dayjs(timeSlotEnd), 'minute') || dayjs(time.start_at).isBefore(dayjs(timeSlotEnd), 'minute') && dayjs(time.end_at).isAfter(dayjs(timeSlotStart), 'minute');
323
+ return !dayjs(time.start_at).isAfter(dayjs(timeSlotStart), 'minute') && !dayjs(time.end_at).isBefore(dayjs(timeSlotEnd), 'minute') || resource.onlyComputed && dayjs(time.start_at).isBefore(dayjs(timeSlotEnd), 'minute') && dayjs(time.end_at).isAfter(dayjs(timeSlotStart), 'minute');
324
324
  });
325
325
  if (availableTimes.length > 0) {
326
326
  // 简化逻辑:如果资源在时间段内有可用时间,就计算其容量
@@ -123,7 +123,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
123
123
  * 获取当前的客户搜索条件
124
124
  * @returns 当前搜索条件
125
125
  */
126
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
126
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
127
127
  /**
128
128
  * 获取客户列表状态(包含滚动加载相关状态)
129
129
  * @returns 客户状态
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "normal" | "duration" | "session";
52
+ getProductType(): "duration" | "session" | "normal";
53
53
  }
@@ -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);
@@ -1926,7 +1944,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1926
1944
  let currentResourcesSummaryCount = 0;
1927
1945
  const currentResourcesTimeSlotCanUsedArr = [];
1928
1946
  const mTimes = m.times.filter((n) => {
1929
- return !(0, import_dayjs.default)(n.start_at).isAfter((0, import_dayjs.default)(item.start), "minute") && !(0, import_dayjs.default)(n.end_at).isBefore((0, import_dayjs.default)(item.end), "minute") || (0, import_dayjs.default)(n.start_at).isBefore((0, import_dayjs.default)(item.end), "minute") && (0, import_dayjs.default)(n.end_at).isAfter((0, import_dayjs.default)(item.start), "minute");
1947
+ return !(0, import_dayjs.default)(n.start_at).isAfter((0, import_dayjs.default)(item.start), "minute") && !(0, import_dayjs.default)(n.end_at).isBefore((0, import_dayjs.default)(item.end), "minute") || m.onlyComputed && (0, import_dayjs.default)(n.start_at).isBefore((0, import_dayjs.default)(item.end), "minute") && (0, import_dayjs.default)(n.end_at).isAfter((0, import_dayjs.default)(item.start), "minute");
1930
1948
  });
1931
1949
  if (mTimes.length === 0) {
1932
1950
  return;
@@ -230,7 +230,7 @@ function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, allResourc
230
230
  let totalAvailableCapacity = 0;
231
231
  resourcesInType.forEach((resource) => {
232
232
  const availableTimes = resource.times.filter((time) => {
233
- return !(0, import_dayjs.default)(time.start_at).isAfter((0, import_dayjs.default)(timeSlotStart), "minute") && !(0, import_dayjs.default)(time.end_at).isBefore((0, import_dayjs.default)(timeSlotEnd), "minute") || (0, import_dayjs.default)(time.start_at).isBefore((0, import_dayjs.default)(timeSlotEnd), "minute") && (0, import_dayjs.default)(time.end_at).isAfter((0, import_dayjs.default)(timeSlotStart), "minute");
233
+ return !(0, import_dayjs.default)(time.start_at).isAfter((0, import_dayjs.default)(timeSlotStart), "minute") && !(0, import_dayjs.default)(time.end_at).isBefore((0, import_dayjs.default)(timeSlotEnd), "minute") || resource.onlyComputed && (0, import_dayjs.default)(time.start_at).isBefore((0, import_dayjs.default)(timeSlotEnd), "minute") && (0, import_dayjs.default)(time.end_at).isAfter((0, import_dayjs.default)(timeSlotStart), "minute");
234
234
  });
235
235
  if (availableTimes.length > 0) {
236
236
  totalAvailableCapacity += resource.capacity || 0;
@@ -123,7 +123,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
123
123
  * 获取当前的客户搜索条件
124
124
  * @returns 当前搜索条件
125
125
  */
126
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
126
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
127
127
  /**
128
128
  * 获取客户列表状态(包含滚动加载相关状态)
129
129
  * @returns 客户状态
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.418",
4
+ "version": "0.0.419",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",