@pisell/pisellos 3.0.14 → 3.0.16

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.
@@ -1196,7 +1196,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1196
1196
  capacity: formatCapacity
1197
1197
  });
1198
1198
  var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri2 = cartItem._productOrigin) === null || _cartItem$_productOri2 === void 0 || (_cartItem$_productOri2 = _cartItem$_productOri2.product_resource) === null || _cartItem$_productOri2 === void 0 ? void 0 : _cartItem$_productOri2.resources) || [], selectedResources, currentCapacity);
1199
- debugger;
1200
1199
  // 如果购物车里已经有了时间片,则需要按照时间片过滤
1201
1200
  if (cartItem._origin.start_time) {
1202
1201
  var startTime = dayjs("".concat(cartItem._origin.start_date, " ").concat(cartItem._origin.start_time));
@@ -1253,10 +1252,19 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1253
1252
  } else {
1254
1253
  productResources.forEach(function (item) {
1255
1254
  // 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
1255
+ // 同时,在这一步尝试去拉一下时间片,基于商品的时长,看每个资源是否还有空余时间能对这个商品做服务,如果没有则过滤
1256
1256
  item.renderList = item.renderList.filter(function (n) {
1257
+ var _cartItem$_productOri3;
1257
1258
  var recordCount = n.capacity || 0;
1258
1259
  if (n.onlyComputed) return false;
1259
- return recordCount >= currentCapacity;
1260
+ // 查一下这个资源基于商品的可用时间片
1261
+ var timeSlots = getTimeSlicesByResource({
1262
+ resource: n,
1263
+ duration: ((_cartItem$_productOri3 = cartItem._productOrigin) === null || _cartItem$_productOri3 === void 0 || (_cartItem$_productOri3 = _cartItem$_productOri3.duration) === null || _cartItem$_productOri3 === void 0 ? void 0 : _cartItem$_productOri3.value) || 0,
1264
+ split: 10,
1265
+ currentDate: dateRange[0].date
1266
+ });
1267
+ return recordCount >= currentCapacity && timeSlots.length > 0;
1260
1268
  });
1261
1269
  });
1262
1270
  }
@@ -1352,7 +1360,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1352
1360
  }, {
1353
1361
  key: "autoSelectAccountResources",
1354
1362
  value: function autoSelectAccountResources(_ref8) {
1355
- var _cartItem$_productOri3, _allProductResources$;
1363
+ var _cartItem$_productOri4, _allProductResources$;
1356
1364
  var cartItem = _ref8.cartItem,
1357
1365
  holder_id = _ref8.holder_id,
1358
1366
  resources_code = _ref8.resources_code,
@@ -1401,7 +1409,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1401
1409
  var resourcesMap = getResourcesMap(cloneDeep(AllResources));
1402
1410
  var allCartItems = cloneDeep(this.store.cart.getItems());
1403
1411
  var selectedResources = getOthersSelectedResources(allCartItems, holder_id, resourcesMap);
1404
- var allProductResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri3 = cartItem._productOrigin) === null || _cartItem$_productOri3 === void 0 || (_cartItem$_productOri3 = _cartItem$_productOri3.product_resource) === null || _cartItem$_productOri3 === void 0 ? void 0 : _cartItem$_productOri3.resources) || [], selectedResources, 1);
1412
+ var allProductResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri4 = cartItem._productOrigin) === null || _cartItem$_productOri4 === void 0 || (_cartItem$_productOri4 = _cartItem$_productOri4.product_resource) === null || _cartItem$_productOri4 === void 0 ? void 0 : _cartItem$_productOri4.resources) || [], selectedResources, 1);
1405
1413
  var resources = ((_allProductResources$ = allProductResources.find(function (n) {
1406
1414
  return n.code === resources_code;
1407
1415
  })) === null || _allProductResources$ === void 0 ? void 0 : _allProductResources$.renderList) || [];
@@ -1607,8 +1615,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1607
1615
  if ((_n$renderList = n.renderList) !== null && _n$renderList !== void 0 && _n$renderList.length) {
1608
1616
  // 过滤掉 capacity 小于 currentCapacity 的资源
1609
1617
  n.renderList = n.renderList.filter(function (m) {
1618
+ var _item$duration;
1610
1619
  var recordCount = m.capacity || 0;
1611
- return recordCount >= currentCapacity;
1620
+ var timeSlots = getTimeSlicesByResource({
1621
+ resource: m,
1622
+ duration: (item === null || item === void 0 || (_item$duration = item.duration) === null || _item$duration === void 0 ? void 0 : _item$duration.value) || 0,
1623
+ split: 10,
1624
+ currentDate: dateRange[0].date
1625
+ });
1626
+ return recordCount >= currentCapacity && timeSlots.length > 0;
1612
1627
  });
1613
1628
  currentResourcesRenderList.push.apply(currentResourcesRenderList, _toConsumableArray(n.renderList || []));
1614
1629
  }
@@ -1917,9 +1932,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1917
1932
  if (!aIsCombined && bIsCombined) return -1;
1918
1933
  return 0;
1919
1934
  });
1920
- var resourcesUseableMap = {};
1935
+
1921
1936
  // 计算每个日程切片下日程可用的资源的容量总和
1922
1937
  var formatScheduleTimeSlots = scheduleTimeSlots.map(function (item) {
1938
+ // 用来计算资源的可使用情况,针对单个schedule 时间片
1939
+ var resourcesUseableMap = {};
1923
1940
  var count = 0;
1924
1941
  // 遍历所有资源
1925
1942
  allProductResources === null || allProductResources === void 0 || allProductResources.forEach(function (m) {
@@ -1962,7 +1979,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1962
1979
  // 在已经选定时间的情况下,只要canUseTime如果有一个 false 那就不可用
1963
1980
  if (!currentResourcesTimeSlotCanUsedArr.some(function (n) {
1964
1981
  return n === false;
1965
- })) {
1982
+ }) && currentResourcesCount >= count) {
1966
1983
  count = currentResourcesCount;
1967
1984
  }
1968
1985
  });
@@ -110,7 +110,10 @@ var checkCapacity = function checkCapacity(_ref) {
110
110
  resource = _ref.resource,
111
111
  _ref$currentCount = _ref.currentCount,
112
112
  currentCount = _ref$currentCount === void 0 ? 1 : _ref$currentCount;
113
- if (currentCount > resource.capacity) {
113
+ // 单个预约:如果当前资源容量不足以满足需求的容量,且当前资源是没有被占用的,返回资源不可用标记,但在外部运算会通过 reason=capacityOnly 来处理组合资源可用
114
+ // 多个预约:只需判断容量是否足够
115
+ var isMultipleBooking = resource.resourceType === 'multiple';
116
+ if (currentCount > resource.capacity && (isMultipleBooking || !isMultipleBooking && event_list.length === 0)) {
114
117
  return {
115
118
  status: false,
116
119
  capacity: resource.capacity,
@@ -638,7 +638,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
638
638
  selectedResources,
639
639
  currentCapacity
640
640
  );
641
- debugger;
642
641
  if (cartItem._origin.start_time) {
643
642
  const startTime = (0, import_dayjs.default)(
644
643
  `${cartItem._origin.start_date} ${cartItem._origin.start_time}`
@@ -692,10 +691,17 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
692
691
  } else {
693
692
  productResources.forEach((item) => {
694
693
  item.renderList = item.renderList.filter((n) => {
694
+ var _a2, _b2;
695
695
  const recordCount = n.capacity || 0;
696
696
  if (n.onlyComputed)
697
697
  return false;
698
- return recordCount >= currentCapacity;
698
+ const timeSlots = (0, import_resources.getTimeSlicesByResource)({
699
+ resource: n,
700
+ duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 0,
701
+ split: 10,
702
+ currentDate: dateRange[0].date
703
+ });
704
+ return recordCount >= currentCapacity && timeSlots.length > 0;
699
705
  });
700
706
  });
701
707
  }
@@ -994,8 +1000,15 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
994
1000
  var _a3;
995
1001
  if ((_a3 = n.renderList) == null ? void 0 : _a3.length) {
996
1002
  n.renderList = n.renderList.filter((m) => {
1003
+ var _a4;
997
1004
  const recordCount = m.capacity || 0;
998
- return recordCount >= currentCapacity;
1005
+ const timeSlots2 = (0, import_resources.getTimeSlicesByResource)({
1006
+ resource: m,
1007
+ duration: ((_a4 = item == null ? void 0 : item.duration) == null ? void 0 : _a4.value) || 0,
1008
+ split: 10,
1009
+ currentDate: dateRange[0].date
1010
+ });
1011
+ return recordCount >= currentCapacity && timeSlots2.length > 0;
999
1012
  });
1000
1013
  currentResourcesRenderList.push(...n.renderList || []);
1001
1014
  }
@@ -1273,8 +1286,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1273
1286
  return -1;
1274
1287
  return 0;
1275
1288
  });
1276
- const resourcesUseableMap = {};
1277
1289
  const formatScheduleTimeSlots = scheduleTimeSlots.map((item) => {
1290
+ const resourcesUseableMap = {};
1278
1291
  let count = 0;
1279
1292
  allProductResources == null ? void 0 : allProductResources.forEach((m) => {
1280
1293
  let currentResourcesCount = 0;
@@ -1307,7 +1320,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1307
1320
  }
1308
1321
  currentResourcesTimeSlotCanUsedArr.push(res.usable);
1309
1322
  });
1310
- if (!currentResourcesTimeSlotCanUsedArr.some((n) => n === false)) {
1323
+ if (!currentResourcesTimeSlotCanUsedArr.some((n) => n === false) && currentResourcesCount >= count) {
1311
1324
  count = currentResourcesCount;
1312
1325
  }
1313
1326
  });
@@ -82,7 +82,8 @@ var checkCapacity = ({
82
82
  resource,
83
83
  currentCount = 1
84
84
  }) => {
85
- if (currentCount > resource.capacity) {
85
+ const isMultipleBooking = resource.resourceType === "multiple";
86
+ if (currentCount > resource.capacity && (isMultipleBooking || !isMultipleBooking && event_list.length === 0)) {
86
87
  return {
87
88
  status: false,
88
89
  capacity: resource.capacity,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "3.0.14",
4
+ "version": "3.0.16",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",