@pisell/pisellos 3.0.10 → 3.0.12

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.
@@ -38,11 +38,12 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
38
38
  * 删除step
39
39
  */
40
40
  removeStep(key: string): void;
41
- loadProducts({ category_ids, product_ids, collection, schedule_ids, }: {
41
+ loadProducts({ category_ids, product_ids, collection, schedule_ids, schedule_date, }: {
42
42
  category_ids?: number[];
43
43
  product_ids?: number[];
44
44
  collection?: number | string[];
45
45
  schedule_ids?: number[];
46
+ schedule_date?: string;
46
47
  }): Promise<any>;
47
48
  loadProductByScheduleDate({ date, product_ids, category_ids, }: {
48
49
  date: string;
@@ -193,11 +193,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
193
193
  value: function () {
194
194
  var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref) {
195
195
  var _schedule_ids;
196
- var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, _ref$schedule_ids, schedule_ids, schedule_ids_data, productsData;
196
+ var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, _ref$schedule_ids, schedule_ids, schedule_date, schedule_ids_data, productsData;
197
197
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
198
198
  while (1) switch (_context2.prev = _context2.next) {
199
199
  case 0:
200
- _ref$category_ids = _ref.category_ids, category_ids = _ref$category_ids === void 0 ? [] : _ref$category_ids, _ref$product_ids = _ref.product_ids, product_ids = _ref$product_ids === void 0 ? [] : _ref$product_ids, _ref$collection = _ref.collection, collection = _ref$collection === void 0 ? [] : _ref$collection, _ref$schedule_ids = _ref.schedule_ids, schedule_ids = _ref$schedule_ids === void 0 ? [] : _ref$schedule_ids;
200
+ _ref$category_ids = _ref.category_ids, category_ids = _ref$category_ids === void 0 ? [] : _ref$category_ids, _ref$product_ids = _ref.product_ids, product_ids = _ref$product_ids === void 0 ? [] : _ref$product_ids, _ref$collection = _ref.collection, collection = _ref$collection === void 0 ? [] : _ref$collection, _ref$schedule_ids = _ref.schedule_ids, schedule_ids = _ref$schedule_ids === void 0 ? [] : _ref$schedule_ids, schedule_date = _ref.schedule_date;
201
201
  // 如果 schedule_ids 为空,则需要尝试从 schedule 模块里获取
202
202
  if (!((_schedule_ids = schedule_ids) !== null && _schedule_ids !== void 0 && _schedule_ids.length)) {
203
203
  schedule_ids_data = this.store.schedule.getScheduleListByIds(schedule_ids).map(function (n) {
@@ -220,7 +220,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
220
220
  ids: product_ids,
221
221
  collection: collection,
222
222
  front_end_cache_id: this.cacheId,
223
- client_schedule_ids: schedule_ids
223
+ client_schedule_ids: schedule_ids,
224
+ schedule_date: schedule_date
224
225
  }, {
225
226
  useCache: true
226
227
  });
@@ -269,7 +270,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
269
270
  return this.loadProducts({
270
271
  schedule_ids: scheduleIds,
271
272
  product_ids: product_ids,
272
- category_ids: category_ids
273
+ category_ids: category_ids,
274
+ schedule_date: date
273
275
  });
274
276
  case 6:
275
277
  return _context3.abrupt("return", _context3.sent);
@@ -1207,11 +1209,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1207
1209
  currentCount: recordCount + (currentCapacity || 0),
1208
1210
  resourcesUseableMap: resourcesUseableMap
1209
1211
  });
1210
- if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false) {
1212
+ // 如果仅仅是因为子资源容量不够,不应该标记子资源是被占用的情况
1213
+ if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
1211
1214
  resourcesUseableMap[m.id] = res.usable;
1212
1215
  }
1213
1216
  return res.usable;
1214
1217
  });
1218
+ if (m.onlyComputed) return false;
1215
1219
  // 在已经选定时间的情况下,只要canUseTime 里有一个 false,那就代表不可用
1216
1220
  return !canUseArr.some(function (n) {
1217
1221
  return n === false;
@@ -1223,6 +1227,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1223
1227
  // 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
1224
1228
  item.renderList = item.renderList.filter(function (n) {
1225
1229
  var recordCount = n.capacity || 0;
1230
+ if (n.onlyComputed) return false;
1226
1231
  return recordCount >= currentCapacity;
1227
1232
  });
1228
1233
  });
@@ -1275,6 +1280,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1275
1280
  capacity: formatCapacity
1276
1281
  });
1277
1282
  var productResources = getResourcesByProduct(resourcesMap, ((_targetCartItem$_prod3 = targetCartItem._productOrigin) === null || _targetCartItem$_prod3 === void 0 || (_targetCartItem$_prod3 = _targetCartItem$_prod3.product_resource) === null || _targetCartItem$_prod3 === void 0 ? void 0 : _targetCartItem$_prod3.resources) || [], selectedResources, currentCapacity);
1283
+ productResources.forEach(function (item) {
1284
+ item.renderList = item.renderList.filter(function (n) {
1285
+ var recordCount = n.capacity || 0;
1286
+ if (n.onlyComputed) return false;
1287
+ return recordCount >= currentCapacity;
1288
+ });
1289
+ });
1278
1290
  if (productResources) {
1279
1291
  return {
1280
1292
  id: targetCartItem.id,
@@ -1378,7 +1390,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1378
1390
  currentCount: recordCount + (capacity || 0),
1379
1391
  resourcesUseableMap: resourcesUseableMap
1380
1392
  });
1381
- if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[n.id]) !== false) {
1393
+ // 如果只是因为子资源容量不够,而不是子资源被预约导致没时间片,不应该标记子资源为不可用,从而影响组合资源的情况
1394
+ if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[n.id]) !== false && res.reason !== 'capacityOnly') {
1382
1395
  resourcesUseableMap[n.id] = res.usable;
1383
1396
  }
1384
1397
  return res.usable;
@@ -1535,6 +1548,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1535
1548
  selectedResources = getOthersCartSelectedResources(allCartItems, item._id, _resourcesMap);
1536
1549
  }
1537
1550
  var productResources = getResourcesByProduct(_resourcesMap, cloneDeep(_resources), selectedResources, currentCapacity);
1551
+ productResources.forEach(function (item) {
1552
+ item.renderList = item.renderList.filter(function (n) {
1553
+ var recordCount = n.capacity || 0;
1554
+ if (n.onlyComputed) return false;
1555
+ return recordCount >= currentCapacity;
1556
+ });
1557
+ });
1538
1558
  // 自动选择 productResources 中对应 resources_code 的资源
1539
1559
  var targetRenderList = (_productResources$fin = productResources.find(function (n) {
1540
1560
  return n.code === resources_code;
@@ -1615,7 +1635,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1615
1635
  if ((_dateRange = dateRange) !== null && _dateRange !== void 0 && (_dateRange = _dateRange[0]) !== null && _dateRange !== void 0 && (_dateRange = _dateRange.resource) !== null && _dateRange !== void 0 && _dateRange.length) {
1616
1636
  // resources.push(...dateRange[0].resource);
1617
1637
  dateRange[0].resource.forEach(function (n) {
1618
- if (n.form_id === resourcesTypeId) {
1638
+ if (n.form_id === resourcesTypeId && !resources.find(function (m) {
1639
+ return m.id === n.id;
1640
+ })) {
1619
1641
  resources.push(n);
1620
1642
  }
1621
1643
  });
@@ -1840,10 +1862,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1840
1862
  currentCount: 1,
1841
1863
  resourcesUseableMap: resourcesUseableMap
1842
1864
  });
1843
- if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false) {
1865
+ if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
1844
1866
  resourcesUseableMap[m.id] = res.usable;
1845
1867
  }
1846
- if (res.usable && res.remainingCapacity >= count) {
1868
+ if (res.usable && res.remainingCapacity >= count && !m.onlyComputed) {
1847
1869
  count = res.remainingCapacity;
1848
1870
  }
1849
1871
  });
@@ -38,6 +38,7 @@ export declare const getIsUsableByTimeItem: ({ timeSlice, time, resource, curren
38
38
  capacity: boolean;
39
39
  usable: boolean;
40
40
  remainingCapacity: number;
41
+ reason: string;
41
42
  };
42
43
  /**
43
44
  * @title: 获取商品下绑定的资源列表
@@ -95,6 +96,15 @@ export declare const getTimesIntersection: (times: TimeSliceItem[], count: numbe
95
96
  * @Date: 2024-09-19 20:23
96
97
  */
97
98
  export declare const getResourcesByIds: (resourcesMap: Record<string, ResourceItem>, ids: number[]) => ResourceItem[];
99
+ /**
100
+ * @title: 合并子资源的时间切片至组合资源
101
+ * @description:
102
+ * @param {ResourceItem[]} resources
103
+ * @param {Record<string, ResourceItem>} resourcesMap
104
+ * @return {*}
105
+ * @Author: zhiwei.Wang
106
+ */
107
+ export declare const mergeSubResourcesTimeSlices: (resources: ResourceItem[], resourcesMap: Record<string, ResourceItem>) => void;
98
108
  /**
99
109
  * @title: 根据资源id列表获取时间切片
100
110
  * @description: 传入一个技师id列表, 找出技师列表中公共的时间切片
@@ -113,7 +113,8 @@ var checkCapacity = function checkCapacity(_ref) {
113
113
  if (currentCount > resource.capacity) {
114
114
  return {
115
115
  status: false,
116
- capacity: resource.capacity
116
+ capacity: resource.capacity,
117
+ reason: 'capacityOnly'
117
118
  };
118
119
  }
119
120
  var conflict = (event_list || []).filter(function (d) {
@@ -179,7 +180,9 @@ export var getIsUsableByTimeItem = function getIsUsableByTimeItem(_ref2) {
179
180
  afterToDay: false,
180
181
  capacity: false,
181
182
  usable: false,
182
- remainingCapacity: 0 // 剩余容量
183
+ remainingCapacity: 0,
184
+ // 剩余容量
185
+ reason: ''
183
186
  };
184
187
  // 最早可预约时间为 当前日期之后并且提前量之后
185
188
  var earliest = dayjs();
@@ -204,6 +207,7 @@ export var getIsUsableByTimeItem = function getIsUsableByTimeItem(_ref2) {
204
207
  }
205
208
  });
206
209
  }
210
+ status.reason = checkCapacityResult.reason || '';
207
211
  if (!checkCapacityResult.status) {
208
212
  return status;
209
213
  }
@@ -238,6 +242,16 @@ export var getResourcesByProduct = function getResourcesByProduct(resourcesMap,
238
242
  resourcesMap[d].combined_resource.resource_ids.forEach(function (id) {
239
243
  if (resourcesMap[id]) {
240
244
  combiningResources.push(resourcesMap[id]);
245
+ childAcc.push(Object.assign({}, resourcesMap[id], {
246
+ form_id: form_id,
247
+ resourceType: item.type,
248
+ children: combiningResources,
249
+ onlyComputed: true,
250
+ // 是否是只用来计算用,组合资源里,假设商品只关联了组合资源没关联子资源,需要通过这个计算来在后面从 renderList 里删除这个资源
251
+ metadata: _objectSpread(_objectSpread({}, resourcesMap[id].metadata), {}, {
252
+ combined_resource: resourcesMap[id].combined_resource
253
+ })
254
+ }));
241
255
  }
242
256
  });
243
257
  }
@@ -260,6 +274,16 @@ export var getResourcesByProduct = function getResourcesByProduct(resourcesMap,
260
274
  resourcesMap[d].combined_resource.resource_ids.forEach(function (id) {
261
275
  if (resourcesMap[id]) {
262
276
  combiningResources.push(resourcesMap[id]);
277
+ childAcc.push(Object.assign({}, resourcesMap[id], {
278
+ form_id: form_id,
279
+ resourceType: item.type,
280
+ children: combiningResources,
281
+ onlyComputed: true,
282
+ // 是否是只用来计算用,组合资源里,假设商品只关联了组合资源没关联子资源,需要通过这个计算来在后面从 renderList 里删除这个资源
283
+ metadata: _objectSpread(_objectSpread({}, resourcesMap[id].metadata), {}, {
284
+ combined_resource: resourcesMap[id].combined_resource
285
+ })
286
+ }));
263
287
  }
264
288
  });
265
289
  }
@@ -458,6 +482,37 @@ export var getResourcesByIds = function getResourcesByIds(resourcesMap, ids) {
458
482
  });
459
483
  };
460
484
 
485
+ /**
486
+ * @title: 合并子资源的时间切片至组合资源
487
+ * @description:
488
+ * @param {ResourceItem[]} resources
489
+ * @param {Record<string, ResourceItem>} resourcesMap
490
+ * @return {*}
491
+ * @Author: zhiwei.Wang
492
+ */
493
+ export var mergeSubResourcesTimeSlices = function mergeSubResourcesTimeSlices(resources, resourcesMap) {
494
+ return resources.forEach(function (item) {
495
+ var _item$combined_resour;
496
+ if ((item === null || item === void 0 || (_item$combined_resour = item.combined_resource) === null || _item$combined_resour === void 0 ? void 0 : _item$combined_resour.status) === 1) {
497
+ var _item$combined_resour2;
498
+ item === null || item === void 0 || (_item$combined_resour2 = item.combined_resource) === null || _item$combined_resour2 === void 0 || _item$combined_resour2.resource_ids.forEach(function (id) {
499
+ var subResource = resourcesMap[id];
500
+ if (subResource) {
501
+ subResource.times.forEach(function (time) {
502
+ var fatherResourcesTime = item.times.find(function (n) {
503
+ return n.start_at === time.start_at && n.end_at === time.end_at;
504
+ });
505
+ if (fatherResourcesTime) {
506
+ var _fatherResourcesTime$;
507
+ (_fatherResourcesTime$ = fatherResourcesTime.event_list).push.apply(_fatherResourcesTime$, _toConsumableArray(time.event_list || []));
508
+ }
509
+ });
510
+ }
511
+ });
512
+ }
513
+ });
514
+ };
515
+
461
516
  /**
462
517
  * @title: 根据资源id列表获取时间切片
463
518
  * @description: 传入一个技师id列表, 找出技师列表中公共的时间切片
@@ -476,6 +531,7 @@ export var getTimeSlicesByResources = function getTimeSlicesByResources(_ref5) {
476
531
  resourcesUseableMap = _ref5.resourcesUseableMap;
477
532
  // 获取资源列表
478
533
  var resources = getResourcesByIds(resourcesMap, resourceIds);
534
+ mergeSubResourcesTimeSlices(resources, resourcesMap);
479
535
  // 资源排下序,把单个资源靠前,组合资源排在后面
480
536
  resources.sort(function (a, b) {
481
537
  var _a$metadata, _b$metadata;
@@ -38,11 +38,12 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
38
38
  * 删除step
39
39
  */
40
40
  removeStep(key: string): void;
41
- loadProducts({ category_ids, product_ids, collection, schedule_ids, }: {
41
+ loadProducts({ category_ids, product_ids, collection, schedule_ids, schedule_date, }: {
42
42
  category_ids?: number[];
43
43
  product_ids?: number[];
44
44
  collection?: number | string[];
45
45
  schedule_ids?: number[];
46
+ schedule_date?: string;
46
47
  }): Promise<any>;
47
48
  loadProductByScheduleDate({ date, product_ids, category_ids, }: {
48
49
  date: string;
@@ -151,7 +151,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
151
151
  category_ids = [],
152
152
  product_ids = [],
153
153
  collection = [],
154
- schedule_ids = []
154
+ schedule_ids = [],
155
+ schedule_date
155
156
  }) {
156
157
  if (!(schedule_ids == null ? void 0 : schedule_ids.length)) {
157
158
  const schedule_ids_data = this.store.schedule.getScheduleListByIds(schedule_ids).map((n) => n.id);
@@ -178,7 +179,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
178
179
  ids: product_ids,
179
180
  collection,
180
181
  front_end_cache_id: this.cacheId,
181
- client_schedule_ids: schedule_ids
182
+ client_schedule_ids: schedule_ids,
183
+ schedule_date
182
184
  },
183
185
  { useCache: true }
184
186
  );
@@ -196,7 +198,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
196
198
  { date, status: "available", week: "", weekNum: 0 }
197
199
  ]);
198
200
  const scheduleIds = scheduleList.filter((n) => n.date === date).flatMap((n) => n.schedule_id);
199
- return await this.loadProducts({ schedule_ids: scheduleIds, product_ids, category_ids });
201
+ return await this.loadProducts({ schedule_ids: scheduleIds, product_ids, category_ids, schedule_date: date });
200
202
  }
201
203
  // 加载当前店铺下所有 schedule
202
204
  async loadAllSchedule() {
@@ -659,11 +661,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
659
661
  currentCount: recordCount + (currentCapacity || 0),
660
662
  resourcesUseableMap
661
663
  });
662
- if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false) {
664
+ if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== "capacityOnly") {
663
665
  resourcesUseableMap[m.id] = res.usable;
664
666
  }
665
667
  return res.usable;
666
668
  });
669
+ if (m.onlyComputed)
670
+ return false;
667
671
  return !canUseArr.some((n2) => n2 === false);
668
672
  });
669
673
  });
@@ -671,6 +675,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
671
675
  productResources.forEach((item) => {
672
676
  item.renderList = item.renderList.filter((n) => {
673
677
  const recordCount = n.capacity || 0;
678
+ if (n.onlyComputed)
679
+ return false;
674
680
  return recordCount >= currentCapacity;
675
681
  });
676
682
  });
@@ -728,6 +734,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
728
734
  selectedResources,
729
735
  currentCapacity
730
736
  );
737
+ productResources.forEach((item) => {
738
+ item.renderList = item.renderList.filter((n) => {
739
+ const recordCount = n.capacity || 0;
740
+ if (n.onlyComputed)
741
+ return false;
742
+ return recordCount >= currentCapacity;
743
+ });
744
+ });
731
745
  if (productResources) {
732
746
  return {
733
747
  id: targetCartItem.id,
@@ -806,7 +820,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
806
820
  currentCount: recordCount + (capacity || 0),
807
821
  resourcesUseableMap
808
822
  });
809
- if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[n.id]) !== false) {
823
+ if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[n.id]) !== false && res.reason !== "capacityOnly") {
810
824
  resourcesUseableMap[n.id] = res.usable;
811
825
  }
812
826
  return res.usable;
@@ -952,6 +966,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
952
966
  selectedResources,
953
967
  currentCapacity
954
968
  );
969
+ productResources.forEach((item2) => {
970
+ item2.renderList = item2.renderList.filter((n) => {
971
+ const recordCount = n.capacity || 0;
972
+ if (n.onlyComputed)
973
+ return false;
974
+ return recordCount >= currentCapacity;
975
+ });
976
+ });
955
977
  const targetRenderList = (_l = productResources.find(
956
978
  (n) => n.code === resources_code
957
979
  )) == null ? void 0 : _l.renderList;
@@ -1012,7 +1034,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1012
1034
  });
1013
1035
  if ((_b = (_a = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _a.resource) == null ? void 0 : _b.length) {
1014
1036
  dateRange[0].resource.forEach((n) => {
1015
- if (n.form_id === resourcesTypeId) {
1037
+ if (n.form_id === resourcesTypeId && !resources.find((m) => m.id === n.id)) {
1016
1038
  resources.push(n);
1017
1039
  }
1018
1040
  });
@@ -1209,10 +1231,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1209
1231
  currentCount: 1,
1210
1232
  resourcesUseableMap
1211
1233
  });
1212
- if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false) {
1234
+ if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== "capacityOnly") {
1213
1235
  resourcesUseableMap[m.id] = res.usable;
1214
1236
  }
1215
- if (res.usable && res.remainingCapacity >= count) {
1237
+ if (res.usable && res.remainingCapacity >= count && !m.onlyComputed) {
1216
1238
  count = res.remainingCapacity;
1217
1239
  }
1218
1240
  });
@@ -38,6 +38,7 @@ export declare const getIsUsableByTimeItem: ({ timeSlice, time, resource, curren
38
38
  capacity: boolean;
39
39
  usable: boolean;
40
40
  remainingCapacity: number;
41
+ reason: string;
41
42
  };
42
43
  /**
43
44
  * @title: 获取商品下绑定的资源列表
@@ -95,6 +96,15 @@ export declare const getTimesIntersection: (times: TimeSliceItem[], count: numbe
95
96
  * @Date: 2024-09-19 20:23
96
97
  */
97
98
  export declare const getResourcesByIds: (resourcesMap: Record<string, ResourceItem>, ids: number[]) => ResourceItem[];
99
+ /**
100
+ * @title: 合并子资源的时间切片至组合资源
101
+ * @description:
102
+ * @param {ResourceItem[]} resources
103
+ * @param {Record<string, ResourceItem>} resourcesMap
104
+ * @return {*}
105
+ * @Author: zhiwei.Wang
106
+ */
107
+ export declare const mergeSubResourcesTimeSlices: (resources: ResourceItem[], resourcesMap: Record<string, ResourceItem>) => void;
98
108
  /**
99
109
  * @title: 根据资源id列表获取时间切片
100
110
  * @description: 传入一个技师id列表, 找出技师列表中公共的时间切片
@@ -40,7 +40,8 @@ __export(resources_exports, {
40
40
  getSumCapacity: () => getSumCapacity,
41
41
  getTimeSlicesByResource: () => getTimeSlicesByResource,
42
42
  getTimeSlicesByResources: () => getTimeSlicesByResources,
43
- getTimesIntersection: () => getTimesIntersection
43
+ getTimesIntersection: () => getTimesIntersection,
44
+ mergeSubResourcesTimeSlices: () => mergeSubResourcesTimeSlices
44
45
  });
45
46
  module.exports = __toCommonJS(resources_exports);
46
47
  var import_dayjs = __toESM(require("dayjs"));
@@ -84,7 +85,8 @@ var checkCapacity = ({
84
85
  if (currentCount > resource.capacity) {
85
86
  return {
86
87
  status: false,
87
- capacity: resource.capacity
88
+ capacity: resource.capacity,
89
+ reason: "capacityOnly"
88
90
  };
89
91
  }
90
92
  let conflict = (event_list || []).filter((d) => {
@@ -132,8 +134,9 @@ var getIsUsableByTimeItem = ({
132
134
  afterToDay: false,
133
135
  capacity: false,
134
136
  usable: false,
135
- remainingCapacity: 0
137
+ remainingCapacity: 0,
136
138
  // 剩余容量
139
+ reason: ""
137
140
  };
138
141
  let earliest = (0, import_dayjs.default)();
139
142
  if (!checkAfterToDay(timeSlice.start_at, earliest)) {
@@ -154,6 +157,7 @@ var getIsUsableByTimeItem = ({
154
157
  }
155
158
  });
156
159
  }
160
+ status.reason = checkCapacityResult.reason || "";
157
161
  if (!checkCapacityResult.status) {
158
162
  return status;
159
163
  }
@@ -178,6 +182,19 @@ var getResourcesByProduct = (resourcesMap, resources, selectedResources, capacit
178
182
  (id) => {
179
183
  if (resourcesMap[id]) {
180
184
  combiningResources.push(resourcesMap[id]);
185
+ childAcc.push(
186
+ Object.assign({}, resourcesMap[id], {
187
+ form_id,
188
+ resourceType: item.type,
189
+ children: combiningResources,
190
+ onlyComputed: true,
191
+ // 是否是只用来计算用,组合资源里,假设商品只关联了组合资源没关联子资源,需要通过这个计算来在后面从 renderList 里删除这个资源
192
+ metadata: {
193
+ ...resourcesMap[id].metadata,
194
+ combined_resource: resourcesMap[id].combined_resource
195
+ }
196
+ })
197
+ );
181
198
  }
182
199
  }
183
200
  );
@@ -207,6 +224,19 @@ var getResourcesByProduct = (resourcesMap, resources, selectedResources, capacit
207
224
  (id) => {
208
225
  if (resourcesMap[id]) {
209
226
  combiningResources.push(resourcesMap[id]);
227
+ childAcc.push(
228
+ Object.assign({}, resourcesMap[id], {
229
+ form_id,
230
+ resourceType: item.type,
231
+ children: combiningResources,
232
+ onlyComputed: true,
233
+ // 是否是只用来计算用,组合资源里,假设商品只关联了组合资源没关联子资源,需要通过这个计算来在后面从 renderList 里删除这个资源
234
+ metadata: {
235
+ ...resourcesMap[id].metadata,
236
+ combined_resource: resourcesMap[id].combined_resource
237
+ }
238
+ })
239
+ );
210
240
  }
211
241
  }
212
242
  );
@@ -335,6 +365,24 @@ var getTimesIntersection = (times, count) => {
335
365
  var getResourcesByIds = (resourcesMap, ids) => {
336
366
  return (ids || []).map((id) => resourcesMap[id]);
337
367
  };
368
+ var mergeSubResourcesTimeSlices = (resources, resourcesMap) => {
369
+ return resources.forEach((item) => {
370
+ var _a, _b;
371
+ if (((_a = item == null ? void 0 : item.combined_resource) == null ? void 0 : _a.status) === 1) {
372
+ (_b = item == null ? void 0 : item.combined_resource) == null ? void 0 : _b.resource_ids.forEach((id) => {
373
+ const subResource = resourcesMap[id];
374
+ if (subResource) {
375
+ subResource.times.forEach((time) => {
376
+ const fatherResourcesTime = item.times.find((n) => n.start_at === time.start_at && n.end_at === time.end_at);
377
+ if (fatherResourcesTime) {
378
+ fatherResourcesTime.event_list.push(...time.event_list || []);
379
+ }
380
+ });
381
+ }
382
+ });
383
+ }
384
+ });
385
+ };
338
386
  var getTimeSlicesByResources = ({
339
387
  resourceIds,
340
388
  resourcesMap,
@@ -345,6 +393,7 @@ var getTimeSlicesByResources = ({
345
393
  resourcesUseableMap
346
394
  }) => {
347
395
  let resources = getResourcesByIds(resourcesMap, resourceIds);
396
+ mergeSubResourcesTimeSlices(resources, resourcesMap);
348
397
  resources.sort((a, b) => {
349
398
  var _a, _b, _c, _d;
350
399
  const aIsCombined = ((_b = (_a = a.metadata) == null ? void 0 : _a.combined_resource) == null ? void 0 : _b.status) === 1;
@@ -506,5 +555,6 @@ var checkSubResourcesCapacity = (resource) => {
506
555
  getSumCapacity,
507
556
  getTimeSlicesByResource,
508
557
  getTimeSlicesByResources,
509
- getTimesIntersection
558
+ getTimesIntersection,
559
+ mergeSubResourcesTimeSlices
510
560
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "3.0.10",
4
+ "version": "3.0.12",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",