@pisell/pisellos 2.0.18 → 2.0.19

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.
@@ -112,8 +112,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
112
112
  throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
113
113
  }
114
114
  });
115
+ this.loadAllSchedule();
115
116
  this.core.effects.emit(BookingByStepHooks.onInited, {});
116
- case 15:
117
+ case 16:
117
118
  case "end":
118
119
  return _context.stop();
119
120
  }
@@ -306,7 +307,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
306
307
  while (1) switch (_context4.prev = _context4.next) {
307
308
  case 0:
308
309
  _context4.next = 2;
309
- return this.request.get("/schedule?num=999");
310
+ return this.request.get("/schedule", {
311
+ num: 999
312
+ }, {
313
+ useCache: true
314
+ });
310
315
  case 2:
311
316
  scheduleList = _context4.sent;
312
317
  this.store.schedule.setScheduleList(((_scheduleList$data = scheduleList.data) === null || _scheduleList$data === void 0 ? void 0 : _scheduleList$data.list) || []);
@@ -1069,72 +1074,75 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1069
1074
  if (n.resource) allOriginResources.push.apply(allOriginResources, _toConsumableArray(n.resource));
1070
1075
  });
1071
1076
  }
1072
- // 更新购物车后,需要判定购物车里是否存在多个账号选择了相同资源的情况,如果是,且资源是单个预约,则要把选择了相同资源的 product._origin.resources 给去除
1073
- var cartItems = this.store.cart.getItems();
1074
- cartItems.forEach(function (item) {
1075
- if (item._id !== targetCartItem._id) {
1076
- var _item$_origin$resourc;
1077
- var resources = (_item$_origin$resourc = item._origin.resources) === null || _item$_origin$resourc === void 0 ? void 0 : _item$_origin$resourc.filter(function (m) {
1078
- // 检查当前资源是否与目标资源的任何资源匹配
1079
- return !targetCartItem._origin.resources.some(function (targetRes) {
1080
- // 如果新更新进来的资源不是单个预约,其实就不需要检测了资源重叠了,但是需要检测资源 capacity 是否足够
1081
- if (targetRes.resourceType !== 'single') {
1082
- var _item$_productOrigin2;
1083
- var _formatCapacity = formatDefaultCapacitys({
1084
- capacity: (_item$_productOrigin2 = item._productOrigin) === null || _item$_productOrigin2 === void 0 ? void 0 : _item$_productOrigin2.capacity,
1085
- product_bundle: item._origin.product.product_bundle
1086
- });
1087
- var _currentCapacity = getSumCapacity({
1088
- capacity: _formatCapacity
1089
- });
1090
- var originResource = allOriginResources.find(function (n) {
1091
- return n.id === targetRes.id;
1092
- });
1093
- if (currentResourcesCapacityMap[targetRes.id] + _currentCapacity > (originResource === null || originResource === void 0 ? void 0 : originResource.capacity)) {
1094
- return true;
1077
+ // 只有在更新资源的时候做这个判断,其他情况下不做处理
1078
+ if (params.resources) {
1079
+ // 更新购物车后,需要判定购物车里是否存在多个账号选择了相同资源的情况,如果是,且资源是单个预约,则要把选择了相同资源的 product._origin.resources 给去除
1080
+ var cartItems = this.store.cart.getItems();
1081
+ cartItems.forEach(function (item) {
1082
+ if (item._id !== targetCartItem._id) {
1083
+ var _item$_origin$resourc;
1084
+ var resources = (_item$_origin$resourc = item._origin.resources) === null || _item$_origin$resourc === void 0 ? void 0 : _item$_origin$resourc.filter(function (m) {
1085
+ // 检查当前资源是否与目标资源的任何资源匹配
1086
+ return !targetCartItem._origin.resources.some(function (targetRes) {
1087
+ // 如果新更新进来的资源不是单个预约,其实就不需要检测了资源重叠了,但是需要检测资源 capacity 是否足够
1088
+ if (targetRes.resourceType !== 'single') {
1089
+ var _item$_productOrigin2;
1090
+ var _formatCapacity = formatDefaultCapacitys({
1091
+ capacity: (_item$_productOrigin2 = item._productOrigin) === null || _item$_productOrigin2 === void 0 ? void 0 : _item$_productOrigin2.capacity,
1092
+ product_bundle: item._origin.product.product_bundle
1093
+ });
1094
+ var _currentCapacity = getSumCapacity({
1095
+ capacity: _formatCapacity
1096
+ });
1097
+ var originResource = allOriginResources.find(function (n) {
1098
+ return n.id === targetRes.id;
1099
+ });
1100
+ if (currentResourcesCapacityMap[targetRes.id] + _currentCapacity > (originResource === null || originResource === void 0 ? void 0 : originResource.capacity)) {
1101
+ return true;
1102
+ }
1103
+ currentResourcesCapacityMap[targetRes.id] += _currentCapacity;
1104
+ return false;
1105
+ }
1106
+ if (item.holder_id !== (targetCartItem === null || targetCartItem === void 0 ? void 0 : targetCartItem.holder_id)) {
1107
+ var _targetRes$metadata$c, _m$metadata$combined_;
1108
+ // 检查主资源ID是否匹配
1109
+ if (targetRes.id === m.id) return true;
1110
+ // 检查组合资源的情况
1111
+ if (((_targetRes$metadata$c = targetRes.metadata.combined_resource) === null || _targetRes$metadata$c === void 0 ? void 0 : _targetRes$metadata$c.status) === 1 && (
1112
+ // 如果现在选择的是组合资源,需要判断
1113
+ // 1、当前其他购物车里是否选了当前组合资源的子资源
1114
+ // 2、如果其他购物车里的商品也是组合资源,出了组合资源本身的 id 需要判断,还需要判断子资源的 id 是否有交集
1115
+ targetRes.metadata.combined_resource.resource_ids.includes(m.id) || targetRes.metadata.combined_resource.resource_ids.some(function (n) {
1116
+ return m.metadata.combined_resource.resource_ids.includes(n);
1117
+ }))) return true;
1118
+ if (((_m$metadata$combined_ = m.metadata.combined_resource) === null || _m$metadata$combined_ === void 0 ? void 0 : _m$metadata$combined_.status) === 1 && m.metadata.combined_resource.resource_ids.includes(targetRes.id)) return true;
1095
1119
  }
1096
- currentResourcesCapacityMap[targetRes.id] += _currentCapacity;
1097
1120
  return false;
1098
- }
1099
- if (item.holder_id !== (targetCartItem === null || targetCartItem === void 0 ? void 0 : targetCartItem.holder_id)) {
1100
- var _targetRes$metadata$c, _m$metadata$combined_;
1101
- // 检查主资源ID是否匹配
1102
- if (targetRes.id === m.id) return true;
1103
- // 检查组合资源的情况
1104
- if (((_targetRes$metadata$c = targetRes.metadata.combined_resource) === null || _targetRes$metadata$c === void 0 ? void 0 : _targetRes$metadata$c.status) === 1 && (
1105
- // 如果现在选择的是组合资源,需要判断
1106
- // 1、当前其他购物车里是否选了当前组合资源的子资源
1107
- // 2、如果其他购物车里的商品也是组合资源,出了组合资源本身的 id 需要判断,还需要判断子资源的 id 是否有交集
1108
- targetRes.metadata.combined_resource.resource_ids.includes(m.id) || targetRes.metadata.combined_resource.resource_ids.some(function (n) {
1109
- return m.metadata.combined_resource.resource_ids.includes(n);
1110
- }))) return true;
1111
- if (((_m$metadata$combined_ = m.metadata.combined_resource) === null || _m$metadata$combined_ === void 0 ? void 0 : _m$metadata$combined_.status) === 1 && m.metadata.combined_resource.resource_ids.includes(targetRes.id)) return true;
1112
- }
1113
- return false;
1114
- });
1115
- });
1116
- // session 类商品应该只调用清空 resource 的方法
1117
- if (item.start_time) {
1118
- var start_time = item.start_time;
1119
- var end_time = item.end_time;
1120
- var start_date = item.start_date;
1121
- var end_date = item.end_date;
1122
- _this5.store.cart.updateItem({
1123
- _id: item._id,
1124
- resources: resources,
1125
- date: {
1126
- startTime: dayjs("".concat(start_date, " ").concat(start_time)).format('YYYY-MM-DD HH:mm'),
1127
- endTime: dayjs("".concat(end_date, " ").concat(end_time)).format('YYYY-MM-DD HH:mm')
1128
- }
1129
- });
1130
- } else {
1131
- _this5.store.cart.updateItem({
1132
- _id: item._id,
1133
- resources: resources
1121
+ });
1134
1122
  });
1123
+ // session 类商品应该只调用清空 resource 的方法
1124
+ if (item.start_time) {
1125
+ var start_time = item.start_time;
1126
+ var end_time = item.end_time;
1127
+ var start_date = item.start_date;
1128
+ var end_date = item.end_date;
1129
+ _this5.store.cart.updateItem({
1130
+ _id: item._id,
1131
+ resources: resources,
1132
+ date: {
1133
+ startTime: dayjs("".concat(start_date, " ").concat(start_time)).format('YYYY-MM-DD HH:mm'),
1134
+ endTime: dayjs("".concat(end_date, " ").concat(end_time)).format('YYYY-MM-DD HH:mm')
1135
+ }
1136
+ });
1137
+ } else {
1138
+ _this5.store.cart.updateItem({
1139
+ _id: item._id,
1140
+ resources: resources
1141
+ });
1142
+ }
1135
1143
  }
1136
- }
1137
- });
1144
+ });
1145
+ }
1138
1146
  }
1139
1147
 
1140
1148
  // 删除购物车里某个商品
@@ -1745,16 +1753,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1745
1753
  };
1746
1754
  }
1747
1755
  if (recordTimeSlots) {
1748
- var _item$_productOrigin4;
1756
+ var _item$_productOrigin4, _item$_productOrigin5;
1749
1757
  // 同一账号下,如果当前商品不是第一个,则需要根据上一个商品的 end_time 和 duration 计算出当前商品的 start_time 和 end_time
1750
1758
  // 前提:当前资源是单个预约才需要这么做
1751
1759
  var currentResourceConfig = (_item$_productOrigin4 = item._productOrigin) === null || _item$_productOrigin4 === void 0 || (_item$_productOrigin4 = _item$_productOrigin4.product_resource) === null || _item$_productOrigin4 === void 0 || (_item$_productOrigin4 = _item$_productOrigin4.resources) === null || _item$_productOrigin4 === void 0 ? void 0 : _item$_productOrigin4.find(function (n) {
1752
1760
  return n.code === resources_code;
1753
1761
  });
1754
- if (index !== 0 && recordTimeSlots && (currentResourceConfig === null || currentResourceConfig === void 0 ? void 0 : currentResourceConfig.type) === 'single') {
1755
- var _item$_productOrigin$, _item$_productOrigin5, _ref9, _item$_productOrigin6, _item$_productOrigin$2, _item$_productOrigin7, _ref10, _item$_productOrigin8;
1756
- var start_at = dayjs(recordTimeSlots.end_time).add((_item$_productOrigin$ = (_item$_productOrigin5 = item._productOrigin) === null || _item$_productOrigin5 === void 0 || (_item$_productOrigin5 = _item$_productOrigin5.duration) === null || _item$_productOrigin5 === void 0 ? void 0 : _item$_productOrigin5.value) !== null && _item$_productOrigin$ !== void 0 ? _item$_productOrigin$ : 0, (_ref9 = (_item$_productOrigin6 = item._productOrigin) === null || _item$_productOrigin6 === void 0 || (_item$_productOrigin6 = _item$_productOrigin6.duration) === null || _item$_productOrigin6 === void 0 ? void 0 : _item$_productOrigin6.type) !== null && _ref9 !== void 0 ? _ref9 : 'minutes');
1757
- var end_at = start_at.add((_item$_productOrigin$2 = (_item$_productOrigin7 = item._productOrigin) === null || _item$_productOrigin7 === void 0 || (_item$_productOrigin7 = _item$_productOrigin7.duration) === null || _item$_productOrigin7 === void 0 ? void 0 : _item$_productOrigin7.value) !== null && _item$_productOrigin$2 !== void 0 ? _item$_productOrigin$2 : 0, (_ref10 = (_item$_productOrigin8 = item._productOrigin) === null || _item$_productOrigin8 === void 0 || (_item$_productOrigin8 = _item$_productOrigin8.duration) === null || _item$_productOrigin8 === void 0 ? void 0 : _item$_productOrigin8.type) !== null && _ref10 !== void 0 ? _ref10 : 'minutes');
1762
+ // 只有 duration 类商品需要这个操作
1763
+ if (index !== 0 && recordTimeSlots && (currentResourceConfig === null || currentResourceConfig === void 0 ? void 0 : currentResourceConfig.type) === 'single' && (_item$_productOrigin5 = item._productOrigin) !== null && _item$_productOrigin5 !== void 0 && _item$_productOrigin5.duration) {
1764
+ var _item$_productOrigin$, _item$_productOrigin6, _ref9, _item$_productOrigin7, _item$_productOrigin$2, _item$_productOrigin8, _ref10, _item$_productOrigin9;
1765
+ var start_at = dayjs(recordTimeSlots.end_time).add((_item$_productOrigin$ = (_item$_productOrigin6 = item._productOrigin) === null || _item$_productOrigin6 === void 0 || (_item$_productOrigin6 = _item$_productOrigin6.duration) === null || _item$_productOrigin6 === void 0 ? void 0 : _item$_productOrigin6.value) !== null && _item$_productOrigin$ !== void 0 ? _item$_productOrigin$ : 0, (_ref9 = (_item$_productOrigin7 = item._productOrigin) === null || _item$_productOrigin7 === void 0 || (_item$_productOrigin7 = _item$_productOrigin7.duration) === null || _item$_productOrigin7 === void 0 ? void 0 : _item$_productOrigin7.type) !== null && _ref9 !== void 0 ? _ref9 : 'minutes');
1766
+ var end_at = start_at.add((_item$_productOrigin$2 = (_item$_productOrigin8 = item._productOrigin) === null || _item$_productOrigin8 === void 0 || (_item$_productOrigin8 = _item$_productOrigin8.duration) === null || _item$_productOrigin8 === void 0 ? void 0 : _item$_productOrigin8.value) !== null && _item$_productOrigin$2 !== void 0 ? _item$_productOrigin$2 : 0, (_ref10 = (_item$_productOrigin9 = item._productOrigin) === null || _item$_productOrigin9 === void 0 || (_item$_productOrigin9 = _item$_productOrigin9.duration) === null || _item$_productOrigin9 === void 0 ? void 0 : _item$_productOrigin9.type) !== null && _ref10 !== void 0 ? _ref10 : 'minutes');
1758
1767
  recordTimeSlots = {
1759
1768
  start_time: start_at.format('HH:mm'),
1760
1769
  end_time: end_at.format('HH:mm'),
@@ -1796,12 +1805,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1796
1805
  errorList.push(item._id);
1797
1806
  }
1798
1807
  } else {
1799
- var _item$_productOrigin9, _productResources$fin;
1808
+ var _item$_productOrigin10, _productResources$fin;
1800
1809
  // 这里必须每次循环重新读,避免前一次循环操作了购物车,导致数据变更
1801
1810
  var allCartItems = cloneDeep(_this8.store.cart.getItems());
1802
1811
  // 如果没有传递 timeSlots,代表是第一种资源,则直接拿商品的 duration,到资源列表里找一个公共可用的
1803
1812
  var selectedResources = [];
1804
- var _resources = cloneDeep(((_item$_productOrigin9 = item._productOrigin) === null || _item$_productOrigin9 === void 0 || (_item$_productOrigin9 = _item$_productOrigin9.product_resource) === null || _item$_productOrigin9 === void 0 ? void 0 : _item$_productOrigin9.resources) || []);
1813
+ var _resources = cloneDeep(((_item$_productOrigin10 = item._productOrigin) === null || _item$_productOrigin10 === void 0 || (_item$_productOrigin10 = _item$_productOrigin10.product_resource) === null || _item$_productOrigin10 === void 0 ? void 0 : _item$_productOrigin10.resources) || []);
1805
1814
  var currentResourcesRenderList = [];
1806
1815
  _resources.forEach(function (n) {
1807
1816
  var _n$renderList;
@@ -1901,8 +1910,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1901
1910
  var resourceIds = [];
1902
1911
  var resourcesTypeId = undefined;
1903
1912
  cartItems.forEach(function (item) {
1904
- var _item$_productOrigin10, _item$_productOrigin11;
1905
- (_item$_productOrigin10 = item._productOrigin) === null || _item$_productOrigin10 === void 0 || (_item$_productOrigin10 = _item$_productOrigin10.product_resource) === null || _item$_productOrigin10 === void 0 || (_item$_productOrigin10 = _item$_productOrigin10.resources) === null || _item$_productOrigin10 === void 0 || _item$_productOrigin10.forEach(function (n) {
1913
+ var _item$_productOrigin11, _item$_productOrigin12;
1914
+ (_item$_productOrigin11 = item._productOrigin) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.product_resource) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.resources) === null || _item$_productOrigin11 === void 0 || _item$_productOrigin11.forEach(function (n) {
1906
1915
  if (n.code === resources_code) {
1907
1916
  resources.push.apply(resources, _toConsumableArray(n.renderList || []));
1908
1917
  }
@@ -1913,9 +1922,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1913
1922
  if (item.resource_id) {
1914
1923
  resourceIds.push(item.resource_id);
1915
1924
  }
1916
- resourcesTypeId = item === null || item === void 0 || (_item$_productOrigin11 = item._productOrigin) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.product_resource) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.resources) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.find(function (n) {
1925
+ resourcesTypeId = item === null || item === void 0 || (_item$_productOrigin12 = item._productOrigin) === null || _item$_productOrigin12 === void 0 || (_item$_productOrigin12 = _item$_productOrigin12.product_resource) === null || _item$_productOrigin12 === void 0 || (_item$_productOrigin12 = _item$_productOrigin12.resources) === null || _item$_productOrigin12 === void 0 || (_item$_productOrigin12 = _item$_productOrigin12.find(function (n) {
1917
1926
  return n.code === resources_code;
1918
- })) === null || _item$_productOrigin11 === void 0 ? void 0 : _item$_productOrigin11.id;
1927
+ })) === null || _item$_productOrigin12 === void 0 ? void 0 : _item$_productOrigin12.id;
1919
1928
  });
1920
1929
  // 保险起见,在这里如果 dateRange 里也有 resources 的话,也 push 进去
1921
1930
  if ((_dateRange = dateRange) !== null && _dateRange !== void 0 && (_dateRange = _dateRange[0]) !== null && _dateRange !== void 0 && (_dateRange = _dateRange.resource) !== null && _dateRange !== void 0 && _dateRange.length) {
@@ -1935,8 +1944,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1935
1944
  var checkDuration = function checkDuration(cartItems) {
1936
1945
  var accountDuration = 0;
1937
1946
  cartItems.forEach(function (item) {
1938
- var _item$_productOrigin$3, _item$_productOrigin12;
1939
- accountDuration += (_item$_productOrigin$3 = (_item$_productOrigin12 = item._productOrigin) === null || _item$_productOrigin12 === void 0 || (_item$_productOrigin12 = _item$_productOrigin12.duration) === null || _item$_productOrigin12 === void 0 ? void 0 : _item$_productOrigin12.value) !== null && _item$_productOrigin$3 !== void 0 ? _item$_productOrigin$3 : 0;
1947
+ var _item$_productOrigin$3, _item$_productOrigin13;
1948
+ accountDuration += (_item$_productOrigin$3 = (_item$_productOrigin13 = item._productOrigin) === null || _item$_productOrigin13 === void 0 || (_item$_productOrigin13 = _item$_productOrigin13.duration) === null || _item$_productOrigin13 === void 0 ? void 0 : _item$_productOrigin13.value) !== null && _item$_productOrigin$3 !== void 0 ? _item$_productOrigin$3 : 0;
1940
1949
  });
1941
1950
  if (accountDuration > duration) {
1942
1951
  duration = accountDuration;
@@ -2006,9 +2015,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2006
2015
  var _newResources$;
2007
2016
  var newResources = cloneDeep(item._origin.resources);
2008
2017
  newResources.forEach(function (resource) {
2009
- var _item$_productOrigin$4, _item$_productOrigin13, _ref11, _item$_productOrigin14;
2018
+ var _item$_productOrigin$4, _item$_productOrigin14, _ref11, _item$_productOrigin15;
2010
2019
  resource.startTime = currentStartTime;
2011
- resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$4 = (_item$_productOrigin13 = item._productOrigin) === null || _item$_productOrigin13 === void 0 || (_item$_productOrigin13 = _item$_productOrigin13.duration) === null || _item$_productOrigin13 === void 0 ? void 0 : _item$_productOrigin13.value) !== null && _item$_productOrigin$4 !== void 0 ? _item$_productOrigin$4 : 0, (_ref11 = (_item$_productOrigin14 = item._productOrigin) === null || _item$_productOrigin14 === void 0 || (_item$_productOrigin14 = _item$_productOrigin14.duration) === null || _item$_productOrigin14 === void 0 ? void 0 : _item$_productOrigin14.type) !== null && _ref11 !== void 0 ? _ref11 : 'minutes').format('YYYY-MM-DD HH:mm');
2020
+ resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$4 = (_item$_productOrigin14 = item._productOrigin) === null || _item$_productOrigin14 === void 0 || (_item$_productOrigin14 = _item$_productOrigin14.duration) === null || _item$_productOrigin14 === void 0 ? void 0 : _item$_productOrigin14.value) !== null && _item$_productOrigin$4 !== void 0 ? _item$_productOrigin$4 : 0, (_ref11 = (_item$_productOrigin15 = item._productOrigin) === null || _item$_productOrigin15 === void 0 || (_item$_productOrigin15 = _item$_productOrigin15.duration) === null || _item$_productOrigin15 === void 0 ? void 0 : _item$_productOrigin15.type) !== null && _ref11 !== void 0 ? _ref11 : 'minutes').format('YYYY-MM-DD HH:mm');
2012
2021
  delete resource.times;
2013
2022
  });
2014
2023
  _this10.store.cart.updateItem({
@@ -102,6 +102,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
102
102
  throw new Error(`模块 ${step} 不存在`);
103
103
  }
104
104
  });
105
+ this.loadAllSchedule();
105
106
  this.core.effects.emit(import_types.BookingByStepHooks.onInited, {});
106
107
  }
107
108
  // 初始化step
@@ -214,7 +215,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
214
215
  // 加载当前店铺下所有 schedule
215
216
  async loadAllSchedule() {
216
217
  var _a;
217
- const scheduleList = await this.request.get(`/schedule?num=999`);
218
+ const scheduleList = await this.request.get(`/schedule`, { num: 999 }, { useCache: true });
218
219
  this.store.schedule.setScheduleList(((_a = scheduleList.data) == null ? void 0 : _a.list) || []);
219
220
  }
220
221
  // ui 层提供日期的起始范围,返回一个起始范围内日期的可用情况
@@ -527,69 +528,71 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
527
528
  allOriginResources.push(...n.resource);
528
529
  });
529
530
  }
530
- const cartItems = this.store.cart.getItems();
531
- cartItems.forEach((item) => {
532
- var _a2;
533
- if (item._id !== targetCartItem._id) {
534
- const resources = (_a2 = item._origin.resources) == null ? void 0 : _a2.filter((m) => {
535
- return !targetCartItem._origin.resources.some((targetRes) => {
536
- var _a3, _b, _c;
537
- if (targetRes.resourceType !== "single") {
538
- const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
539
- capacity: (_a3 = item._productOrigin) == null ? void 0 : _a3.capacity,
540
- product_bundle: item._origin.product.product_bundle
541
- });
542
- const currentCapacity = (0, import_resources.getSumCapacity)({ capacity: formatCapacity });
543
- const originResource = allOriginResources.find((n) => n.id === targetRes.id);
544
- if (currentResourcesCapacityMap[targetRes.id] + currentCapacity > (originResource == null ? void 0 : originResource.capacity)) {
545
- return true;
531
+ if (params.resources) {
532
+ const cartItems = this.store.cart.getItems();
533
+ cartItems.forEach((item) => {
534
+ var _a2;
535
+ if (item._id !== targetCartItem._id) {
536
+ const resources = (_a2 = item._origin.resources) == null ? void 0 : _a2.filter((m) => {
537
+ return !targetCartItem._origin.resources.some((targetRes) => {
538
+ var _a3, _b, _c;
539
+ if (targetRes.resourceType !== "single") {
540
+ const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
541
+ capacity: (_a3 = item._productOrigin) == null ? void 0 : _a3.capacity,
542
+ product_bundle: item._origin.product.product_bundle
543
+ });
544
+ const currentCapacity = (0, import_resources.getSumCapacity)({ capacity: formatCapacity });
545
+ const originResource = allOriginResources.find((n) => n.id === targetRes.id);
546
+ if (currentResourcesCapacityMap[targetRes.id] + currentCapacity > (originResource == null ? void 0 : originResource.capacity)) {
547
+ return true;
548
+ }
549
+ currentResourcesCapacityMap[targetRes.id] += currentCapacity;
550
+ return false;
551
+ }
552
+ if (item.holder_id !== (targetCartItem == null ? void 0 : targetCartItem.holder_id)) {
553
+ if (targetRes.id === m.id)
554
+ return true;
555
+ if (((_b = targetRes.metadata.combined_resource) == null ? void 0 : _b.status) === 1 && // 如果现在选择的是组合资源,需要判断
556
+ // 1、当前其他购物车里是否选了当前组合资源的子资源
557
+ // 2、如果其他购物车里的商品也是组合资源,出了组合资源本身的 id 需要判断,还需要判断子资源的 id 是否有交集
558
+ (targetRes.metadata.combined_resource.resource_ids.includes(
559
+ m.id
560
+ ) || targetRes.metadata.combined_resource.resource_ids.some(
561
+ (n) => {
562
+ return m.metadata.combined_resource.resource_ids.includes(
563
+ n
564
+ );
565
+ }
566
+ )))
567
+ return true;
568
+ if (((_c = m.metadata.combined_resource) == null ? void 0 : _c.status) === 1 && m.metadata.combined_resource.resource_ids.includes(targetRes.id))
569
+ return true;
546
570
  }
547
- currentResourcesCapacityMap[targetRes.id] += currentCapacity;
548
571
  return false;
549
- }
550
- if (item.holder_id !== (targetCartItem == null ? void 0 : targetCartItem.holder_id)) {
551
- if (targetRes.id === m.id)
552
- return true;
553
- if (((_b = targetRes.metadata.combined_resource) == null ? void 0 : _b.status) === 1 && // 如果现在选择的是组合资源,需要判断
554
- // 1、当前其他购物车里是否选了当前组合资源的子资源
555
- // 2、如果其他购物车里的商品也是组合资源,出了组合资源本身的 id 需要判断,还需要判断子资源的 id 是否有交集
556
- (targetRes.metadata.combined_resource.resource_ids.includes(
557
- m.id
558
- ) || targetRes.metadata.combined_resource.resource_ids.some(
559
- (n) => {
560
- return m.metadata.combined_resource.resource_ids.includes(
561
- n
562
- );
563
- }
564
- )))
565
- return true;
566
- if (((_c = m.metadata.combined_resource) == null ? void 0 : _c.status) === 1 && m.metadata.combined_resource.resource_ids.includes(targetRes.id))
567
- return true;
568
- }
569
- return false;
570
- });
571
- });
572
- if (item.start_time) {
573
- const start_time = item.start_time;
574
- const end_time = item.end_time;
575
- const start_date = item.start_date;
576
- const end_date = item.end_date;
577
- this.store.cart.updateItem({
578
- _id: item._id,
579
- resources,
580
- date: {
581
- startTime: (0, import_dayjs.default)(`${start_date} ${start_time}`).format("YYYY-MM-DD HH:mm"),
582
- endTime: (0, import_dayjs.default)(`${end_date} ${end_time}`).format("YYYY-MM-DD HH:mm")
583
- }
584
- });
585
- } else {
586
- this.store.cart.updateItem({
587
- _id: item._id,
588
- resources
572
+ });
589
573
  });
574
+ if (item.start_time) {
575
+ const start_time = item.start_time;
576
+ const end_time = item.end_time;
577
+ const start_date = item.start_date;
578
+ const end_date = item.end_date;
579
+ this.store.cart.updateItem({
580
+ _id: item._id,
581
+ resources,
582
+ date: {
583
+ startTime: (0, import_dayjs.default)(`${start_date} ${start_time}`).format("YYYY-MM-DD HH:mm"),
584
+ endTime: (0, import_dayjs.default)(`${end_date} ${end_time}`).format("YYYY-MM-DD HH:mm")
585
+ }
586
+ });
587
+ } else {
588
+ this.store.cart.updateItem({
589
+ _id: item._id,
590
+ resources
591
+ });
592
+ }
590
593
  }
591
- }
592
- });
594
+ });
595
+ }
593
596
  }
594
597
  // 删除购物车里某个商品
595
598
  deleteCart(cartItemId) {
@@ -1114,7 +1117,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1114
1117
  const selectForCartResources = (cartItems2) => {
1115
1118
  let recordTimeSlots = (0, import_lodash_es.cloneDeep)(timeSlots);
1116
1119
  cartItems2.forEach((item, index) => {
1117
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
1120
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
1118
1121
  const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
1119
1122
  capacity: (_a2 = item._productOrigin) == null ? void 0 : _a2.capacity,
1120
1123
  product_bundle: item._origin.product.product_bundle
@@ -1130,14 +1133,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1130
1133
  }
1131
1134
  if (recordTimeSlots) {
1132
1135
  const currentResourceConfig = (_d = (_c = (_b = item._productOrigin) == null ? void 0 : _b.product_resource) == null ? void 0 : _c.resources) == null ? void 0 : _d.find((n) => n.code === resources_code);
1133
- if (index !== 0 && recordTimeSlots && (currentResourceConfig == null ? void 0 : currentResourceConfig.type) === "single") {
1136
+ if (index !== 0 && recordTimeSlots && (currentResourceConfig == null ? void 0 : currentResourceConfig.type) === "single" && ((_e = item._productOrigin) == null ? void 0 : _e.duration)) {
1134
1137
  let start_at = (0, import_dayjs.default)(recordTimeSlots.end_time).add(
1135
- ((_f = (_e = item._productOrigin) == null ? void 0 : _e.duration) == null ? void 0 : _f.value) ?? 0,
1136
- ((_h = (_g = item._productOrigin) == null ? void 0 : _g.duration) == null ? void 0 : _h.type) ?? "minutes"
1138
+ ((_g = (_f = item._productOrigin) == null ? void 0 : _f.duration) == null ? void 0 : _g.value) ?? 0,
1139
+ ((_i = (_h = item._productOrigin) == null ? void 0 : _h.duration) == null ? void 0 : _i.type) ?? "minutes"
1137
1140
  );
1138
1141
  let end_at = start_at.add(
1139
- ((_j = (_i = item._productOrigin) == null ? void 0 : _i.duration) == null ? void 0 : _j.value) ?? 0,
1140
- ((_l = (_k = item._productOrigin) == null ? void 0 : _k.duration) == null ? void 0 : _l.type) ?? "minutes"
1142
+ ((_k = (_j = item._productOrigin) == null ? void 0 : _j.duration) == null ? void 0 : _k.value) ?? 0,
1143
+ ((_m = (_l = item._productOrigin) == null ? void 0 : _l.duration) == null ? void 0 : _m.type) ?? "minutes"
1141
1144
  );
1142
1145
  recordTimeSlots = {
1143
1146
  start_time: start_at.format("HH:mm"),
@@ -1182,7 +1185,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1182
1185
  const allCartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
1183
1186
  let selectedResources = [];
1184
1187
  const resources2 = (0, import_lodash_es.cloneDeep)(
1185
- ((_n = (_m = item._productOrigin) == null ? void 0 : _m.product_resource) == null ? void 0 : _n.resources) || []
1188
+ ((_o = (_n = item._productOrigin) == null ? void 0 : _n.product_resource) == null ? void 0 : _o.resources) || []
1186
1189
  );
1187
1190
  const currentResourcesRenderList = [];
1188
1191
  resources2.forEach((n) => {
@@ -1230,11 +1233,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1230
1233
  return recordCount >= currentCapacity;
1231
1234
  });
1232
1235
  });
1233
- const targetRenderList = (_o = productResources.find(
1236
+ const targetRenderList = (_p = productResources.find(
1234
1237
  (n) => n.code === resources_code
1235
- )) == null ? void 0 : _o.renderList;
1238
+ )) == null ? void 0 : _p.renderList;
1236
1239
  if (targetRenderList && targetRenderList.length > 0) {
1237
- if ((_p = item._origin.resources) == null ? void 0 : _p.some(
1240
+ if ((_q = item._origin.resources) == null ? void 0 : _q.some(
1238
1241
  (n) => n.form_id === targetRenderList[0].form_id
1239
1242
  )) {
1240
1243
  return;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.0.18",
4
+ "version": "2.0.19",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",