@pisell/pisellos 2.0.29 → 2.0.30

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.
@@ -143,7 +143,7 @@ var getDaysByRepeatWeek = function getDaysByRepeatWeek(params, isGetRange) {
143
143
  var _end = _start.add(scheduleDiff, 'second');
144
144
  if (isGetRange) {
145
145
  if (excludedDaysMap.has(_start.format('YYYY-MM-DD'))) {
146
- startTmp = startTmp.day(1).add(frequency, 'week');
146
+ startTmp = startTmp.day(1).add(frequency, 'day');
147
147
  continue;
148
148
  }
149
149
  var arr = getDataRange({
@@ -1266,7 +1266,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1266
1266
  var _item$_origin$resourc;
1267
1267
  var resources = (_item$_origin$resourc = item._origin.resources) === null || _item$_origin$resourc === void 0 ? void 0 : _item$_origin$resourc.filter(function (m) {
1268
1268
  // 检查当前资源是否与目标资源的任何资源匹配
1269
- return !targetCartItem._origin.resources.some(function (targetRes) {
1269
+ // 目标资源,应该只取跟当前 m.form_id 相同的资源
1270
+ var sameFormIdResources = targetCartItem._origin.resources.filter(function (n) {
1271
+ return n.form_id === m.form_id;
1272
+ });
1273
+ if (!(sameFormIdResources !== null && sameFormIdResources !== void 0 && sameFormIdResources.length)) {
1274
+ return true;
1275
+ }
1276
+ return !sameFormIdResources.some(function (targetRes) {
1270
1277
  // 如果新更新进来的资源不是单个预约,其实就不需要检测了资源重叠了,但是需要检测资源 capacity 是否足够
1271
1278
  if (targetRes.resourceType !== 'single') {
1272
1279
  var _item$_productOrigin2;
@@ -1280,10 +1287,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1280
1287
  var originResource = allOriginResources.find(function (n) {
1281
1288
  return n.id === targetRes.id;
1282
1289
  });
1283
- if (currentResourcesCapacityMap[targetRes.id] + _currentCapacity > (originResource === null || originResource === void 0 ? void 0 : originResource.capacity)) {
1290
+ if (currentResourcesCapacityMap[m.id] + _currentCapacity > (originResource === null || originResource === void 0 ? void 0 : originResource.capacity)) {
1284
1291
  return true;
1285
1292
  }
1286
- currentResourcesCapacityMap[targetRes.id] += _currentCapacity;
1293
+ currentResourcesCapacityMap[m.id] += _currentCapacity;
1287
1294
  return false;
1288
1295
  }
1289
1296
  if (item.holder_id !== (targetCartItem === null || targetCartItem === void 0 ? void 0 : targetCartItem.holder_id)) {
@@ -2860,7 +2867,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2860
2867
  openResources = ((_tempProducts = tempProducts) === null || _tempProducts === void 0 || (_tempProducts = _tempProducts.product_resource) === null || _tempProducts === void 0 || (_tempProducts = _tempProducts.resources) === null || _tempProducts === void 0 ? void 0 : _tempProducts.filter(function (m) {
2861
2868
  return m.status === 1;
2862
2869
  })) || []; // res.data 返回的一定是启用商品的资源列表,不需要再过滤了
2863
- allProductResources = sortCombinedResources(res.data);
2870
+ allProductResources = sortCombinedResources(res.data); // allProductResources 需要根据商品里的资源的单个预约多个预约补充resourceType
2871
+ allProductResources.forEach(function (m) {
2872
+ var _tempProducts2;
2873
+ var resource = (_tempProducts2 = tempProducts) === null || _tempProducts2 === void 0 || (_tempProducts2 = _tempProducts2.product_resource) === null || _tempProducts2 === void 0 || (_tempProducts2 = _tempProducts2.resources) === null || _tempProducts2 === void 0 ? void 0 : _tempProducts2.find(function (n) {
2874
+ return n.id === m.form_id;
2875
+ });
2876
+ if (resource) {
2877
+ m.resourceType = resource.type;
2878
+ }
2879
+ });
2864
2880
  targetSchedules = this.store.schedule.getScheduleListByIds(tempProducts['schedule.ids']);
2865
2881
  _loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
2866
2882
  var currentDateStr, status, _checkSessionProductL, latestStartDate, earliestEndDate, scheduleByDate, minTimeMaxTime, scheduleTimeSlots, timesSlotCanUse;
@@ -2917,7 +2933,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2917
2933
  return;
2918
2934
  }
2919
2935
  var targetCanUseTimes = mTimes.some(function (childTiem) {
2920
- var _tempProducts2;
2936
+ var _tempProducts3;
2921
2937
  // 挨个去匹配某个工作时间段结合当前日程时间,资源能不能用,有多少容量能用
2922
2938
  var res = getIsUsableByTimeItem({
2923
2939
  timeSlice: {
@@ -2930,7 +2946,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2930
2946
  resource: m,
2931
2947
  currentCount: 1,
2932
2948
  resourcesUseableMap: resourcesUseableMap,
2933
- cut_off_time: (_tempProducts2 = tempProducts) === null || _tempProducts2 === void 0 ? void 0 : _tempProducts2.cut_off_time
2949
+ cut_off_time: (_tempProducts3 = tempProducts) === null || _tempProducts3 === void 0 ? void 0 : _tempProducts3.cut_off_time
2934
2950
  });
2935
2951
  if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
2936
2952
  resourcesUseableMap[m.id] = res.usable;
@@ -2969,22 +2985,22 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2969
2985
  }
2970
2986
  }, _loop3);
2971
2987
  });
2972
- case 22:
2988
+ case 23:
2973
2989
  if (!(dayjs(currentDate).isBefore(dayjs(endDate), 'day') || dayjs(currentDate).isSame(dayjs(endDate), 'day'))) {
2974
- _context32.next = 28;
2990
+ _context32.next = 29;
2975
2991
  break;
2976
2992
  }
2977
- return _context32.delegateYield(_loop3(), "t0", 24);
2978
- case 24:
2993
+ return _context32.delegateYield(_loop3(), "t0", 25);
2994
+ case 25:
2979
2995
  if (!_context32.t0) {
2980
- _context32.next = 26;
2996
+ _context32.next = 27;
2981
2997
  break;
2982
2998
  }
2983
- return _context32.abrupt("break", 28);
2984
- case 26:
2985
- _context32.next = 22;
2999
+ return _context32.abrupt("break", 29);
3000
+ case 27:
3001
+ _context32.next = 23;
2986
3002
  break;
2987
- case 28:
3003
+ case 29:
2988
3004
  // 最终把资源数据也加到日期内
2989
3005
  dates = handleAvailableDateByResource(res.data, dates);
2990
3006
  this.store.date.setDateList(dates);
@@ -3000,7 +3016,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3000
3016
  dateList: dates,
3001
3017
  firstAvailableDate: firstAvailableDate
3002
3018
  });
3003
- case 32:
3019
+ case 33:
3004
3020
  case "end":
3005
3021
  return _context32.stop();
3006
3022
  }
@@ -143,7 +143,7 @@ var getDaysByRepeatWeek = (params, isGetRange) => {
143
143
  const _end = _start.add(scheduleDiff, "second");
144
144
  if (isGetRange) {
145
145
  if (excludedDaysMap.has(_start.format("YYYY-MM-DD"))) {
146
- startTmp = startTmp.day(1).add(frequency, "week");
146
+ startTmp = startTmp.day(1).add(frequency, "day");
147
147
  continue;
148
148
  }
149
149
  const arr = getDataRange({
@@ -643,7 +643,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
643
643
  var _a2;
644
644
  if (item._id !== targetCartItem._id) {
645
645
  const resources = (_a2 = item._origin.resources) == null ? void 0 : _a2.filter((m) => {
646
- return !targetCartItem._origin.resources.some((targetRes) => {
646
+ const sameFormIdResources = targetCartItem._origin.resources.filter((n) => n.form_id === m.form_id);
647
+ if (!(sameFormIdResources == null ? void 0 : sameFormIdResources.length)) {
648
+ return true;
649
+ }
650
+ return !sameFormIdResources.some((targetRes) => {
647
651
  var _a3, _b, _c;
648
652
  if (targetRes.resourceType !== "single") {
649
653
  const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
@@ -656,10 +660,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
656
660
  const originResource = allOriginResources.find(
657
661
  (n) => n.id === targetRes.id
658
662
  );
659
- if (currentResourcesCapacityMap[targetRes.id] + currentCapacity > (originResource == null ? void 0 : originResource.capacity)) {
663
+ if (currentResourcesCapacityMap[m.id] + currentCapacity > (originResource == null ? void 0 : originResource.capacity)) {
660
664
  return true;
661
665
  }
662
- currentResourcesCapacityMap[targetRes.id] += currentCapacity;
666
+ currentResourcesCapacityMap[m.id] += currentCapacity;
663
667
  return false;
664
668
  }
665
669
  if (item.holder_id !== (targetCartItem == null ? void 0 : targetCartItem.holder_id)) {
@@ -2019,6 +2023,15 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2019
2023
  (m) => m.status === 1
2020
2024
  )) || [];
2021
2025
  const allProductResources = (0, import_resources.sortCombinedResources)(res.data);
2026
+ allProductResources.forEach((m) => {
2027
+ var _a2, _b2;
2028
+ const resource = (_b2 = (_a2 = tempProducts == null ? void 0 : tempProducts.product_resource) == null ? void 0 : _a2.resources) == null ? void 0 : _b2.find(
2029
+ (n) => n.id === m.form_id
2030
+ );
2031
+ if (resource) {
2032
+ m.resourceType = resource.type;
2033
+ }
2034
+ });
2022
2035
  const targetSchedules = this.store.schedule.getScheduleListByIds(
2023
2036
  tempProducts["schedule.ids"]
2024
2037
  );
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.0.29",
4
+ "version": "2.0.30",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",