@pisell/pisellos 0.0.432 → 0.0.434

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.
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
311
311
  date: string;
312
312
  status: string;
313
313
  week: string;
314
- weekNum: 0 | 2 | 1 | 3 | 5 | 4 | 6;
314
+ weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -358,7 +358,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
358
358
  };
359
359
  setOtherData(key: string, value: any): void;
360
360
  getOtherData(key: string): any;
361
- getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
361
+ getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
362
362
  /**
363
363
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
364
364
  *
@@ -2217,12 +2217,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2217
2217
  var _item$_resourceOrigin;
2218
2218
  return ((_item$_resourceOrigin = item._resourceOrigin) === null || _item$_resourceOrigin === void 0 ? void 0 : _item$_resourceOrigin[0].id) === firstResource;
2219
2219
  }).length;
2220
- if (sameResourceLength !== items.length) {
2220
+ if (sameResourceLength === items.length) {
2221
2221
  return 1;
2222
2222
  }
2223
- return items.reduce(function (total, item) {
2224
- return total + (getCapacityInfoByCartItem(item).currentCapacity || 0);
2225
- }, 0);
2223
+ // 找出单个购物车里最大的需求 capacity 即可
2224
+ return Math.max.apply(Math, _toConsumableArray(items.map(function (item) {
2225
+ return getCapacityInfoByCartItem(item).currentCapacity || 1;
2226
+ })));
2227
+ // return items.reduce((total, item) => {
2228
+ // return total + (getCapacityInfoByCartItem(item).currentCapacity || 0);
2229
+ // }, 0);
2226
2230
  };
2227
2231
 
2228
2232
  // 如果是多个人预约,去要求出几个 holder 下最大的商品需求容量capacity
@@ -2390,9 +2394,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2390
2394
  if (sameResourceLength !== items.length) {
2391
2395
  return 1;
2392
2396
  }
2393
- return items.reduce(function (total, item) {
2394
- return total + (getCapacityInfoByCartItem(item).currentCapacity || 0);
2395
- }, 0);
2397
+ // 找出单个购物车里最大的需求 capacity 即可
2398
+ return Math.max.apply(Math, _toConsumableArray(items.map(function (item) {
2399
+ return getCapacityInfoByCartItem(item).currentCapacity || 1;
2400
+ })));
2396
2401
  }; // 如果是多个预约,去要求出几个 holder 下最大的需求容量capacity
2397
2402
  maxCapacity = 1;
2398
2403
  if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
@@ -3155,6 +3160,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3155
3160
  itemsByResourceType[resourceCode] = [];
3156
3161
  }
3157
3162
  // 避免重复添加同一个商品
3163
+ // 如果之前添加过的依赖相同资源的跟我现在是同一个 holder,也不需要重复添加
3164
+ if (itemsByResourceType[resourceCode].find(function (item) {
3165
+ return item.holder_id === cartItem.holder_id;
3166
+ })) {
3167
+ return;
3168
+ }
3158
3169
  if (!itemsByResourceType[resourceCode].find(function (item) {
3159
3170
  return item._id === cartItem._id;
3160
3171
  })) {
@@ -4277,6 +4288,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
4277
4288
  }
4278
4289
  }
4279
4290
  });
4291
+ // 可能存在 renderList 没有的情况,则需要判断 resource.optional_resource 和 resource.default_resource 是否存在那个资源,如果不存在也打上 onlyComputed 的标记
4292
+ currentResourcesList.forEach(function (item) {
4293
+ var _resource$optional_re, _resource$default_res;
4294
+ if (!((_resource$optional_re = resource.optional_resource) !== null && _resource$optional_re !== void 0 && _resource$optional_re.includes(item.id)) && !((_resource$default_res = resource.default_resource) !== null && _resource$default_res !== void 0 && _resource$default_res.includes(item.id))) {
4295
+ item.onlyComputed = true;
4296
+ }
4297
+ });
4280
4298
  // currentResourcesList 排序,onlyComputed 的资源排在前面先计算
4281
4299
  currentResourcesList.sort(function (a, b) {
4282
4300
  return a.onlyComputed ? -1 : 1;
@@ -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, "skip" | "num">;
126
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
127
127
  /**
128
128
  * 获取客户列表状态(包含滚动加载相关状态)
129
129
  * @returns 客户状态
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
311
311
  date: string;
312
312
  status: string;
313
313
  week: string;
314
- weekNum: 0 | 2 | 1 | 3 | 5 | 4 | 6;
314
+ weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -358,7 +358,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
358
358
  };
359
359
  setOtherData(key: string, value: any): void;
360
360
  getOtherData(key: string): any;
361
- getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
361
+ getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
362
362
  /**
363
363
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
364
364
  *
@@ -1538,12 +1538,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1538
1538
  var _a3;
1539
1539
  return ((_a3 = item._resourceOrigin) == null ? void 0 : _a3[0].id) === firstResource;
1540
1540
  }).length;
1541
- if (sameResourceLength !== items.length) {
1541
+ if (sameResourceLength === items.length) {
1542
1542
  return 1;
1543
1543
  }
1544
- return items.reduce((total, item) => {
1545
- return total + ((0, import_capacity.getCapacityInfoByCartItem)(item).currentCapacity || 0);
1546
- }, 0);
1544
+ return Math.max(...items.map((item) => (0, import_capacity.getCapacityInfoByCartItem)(item).currentCapacity || 1));
1547
1545
  };
1548
1546
  let maxCapacity = 1;
1549
1547
  if (cartItems == null ? void 0 : cartItems[0].holder_id) {
@@ -1676,9 +1674,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1676
1674
  if (sameResourceLength !== items.length) {
1677
1675
  return 1;
1678
1676
  }
1679
- return items.reduce((total, item) => {
1680
- return total + ((0, import_capacity.getCapacityInfoByCartItem)(item).currentCapacity || 0);
1681
- }, 0);
1677
+ return Math.max(...items.map((item) => (0, import_capacity.getCapacityInfoByCartItem)(item).currentCapacity || 1));
1682
1678
  };
1683
1679
  let maxCapacity = 1;
1684
1680
  if (cartItems == null ? void 0 : cartItems[0].holder_id) {
@@ -2267,6 +2263,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2267
2263
  if (!itemsByResourceType[resourceCode]) {
2268
2264
  itemsByResourceType[resourceCode] = [];
2269
2265
  }
2266
+ if (itemsByResourceType[resourceCode].find((item) => item.holder_id === cartItem.holder_id)) {
2267
+ return;
2268
+ }
2270
2269
  if (!itemsByResourceType[resourceCode].find((item) => item._id === cartItem._id)) {
2271
2270
  itemsByResourceType[resourceCode].push(cartItem);
2272
2271
  }
@@ -2995,6 +2994,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2995
2994
  }
2996
2995
  }
2997
2996
  });
2997
+ currentResourcesList.forEach((item2) => {
2998
+ var _a3, _b2;
2999
+ if (!((_a3 = resource.optional_resource) == null ? void 0 : _a3.includes(item2.id)) && !((_b2 = resource.default_resource) == null ? void 0 : _b2.includes(item2.id))) {
3000
+ item2.onlyComputed = true;
3001
+ }
3002
+ });
2998
3003
  currentResourcesList.sort((a, b) => {
2999
3004
  return a.onlyComputed ? -1 : 1;
3000
3005
  });
@@ -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, "skip" | "num">;
126
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
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.432",
4
+ "version": "0.0.434",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",