@pisell/pisellos 0.0.90 → 0.0.92

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.
@@ -1915,11 +1915,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1915
1915
  // if (cartItems?.[0].start_date) return [];
1916
1916
  var resourceIds = [];
1917
1917
  var resourcesTypeId = undefined;
1918
+ var isSingleResource = false;
1918
1919
  cartItems.forEach(function (item) {
1919
1920
  var _item$_productOrigin11, _item$_productOrigin12;
1920
1921
  (_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) {
1921
1922
  if (n.code === resources_code) {
1922
1923
  resources.push.apply(resources, _toConsumableArray(n.renderList || []));
1924
+ isSingleResource = n.type === 'single';
1923
1925
  }
1924
1926
  });
1925
1927
  // item._origin.resources?.forEach((n: any) => {
@@ -1950,8 +1952,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1950
1952
  var checkDuration = function checkDuration(cartItems) {
1951
1953
  var accountDuration = 0;
1952
1954
  cartItems.forEach(function (item) {
1953
- var _item$_productOrigin$3, _item$_productOrigin13;
1954
- 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;
1955
+ // 单个预约累加账号 多个预约取最大值
1956
+ if (isSingleResource) {
1957
+ var _item$_productOrigin$3, _item$_productOrigin13;
1958
+ 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;
1959
+ } else {
1960
+ var _item$_productOrigin$4, _item$_productOrigin14;
1961
+ if (accountDuration < ((_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)) {
1962
+ var _item$_productOrigin$5, _item$_productOrigin15;
1963
+ accountDuration = (_item$_productOrigin$5 = (_item$_productOrigin15 = item._productOrigin) === null || _item$_productOrigin15 === void 0 || (_item$_productOrigin15 = _item$_productOrigin15.duration) === null || _item$_productOrigin15 === void 0 ? void 0 : _item$_productOrigin15.value) !== null && _item$_productOrigin$5 !== void 0 ? _item$_productOrigin$5 : 0;
1964
+ }
1965
+ }
1955
1966
  });
1956
1967
  if (accountDuration > duration) {
1957
1968
  duration = accountDuration;
@@ -2021,9 +2032,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2021
2032
  var _newResources$;
2022
2033
  var newResources = cloneDeep(item._origin.resources);
2023
2034
  newResources.forEach(function (resource) {
2024
- var _item$_productOrigin$4, _item$_productOrigin14, _ref11, _item$_productOrigin15;
2035
+ var _item$_productOrigin$6, _item$_productOrigin16, _ref11, _item$_productOrigin17;
2025
2036
  resource.startTime = currentStartTime;
2026
- 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');
2037
+ resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$6 = (_item$_productOrigin16 = item._productOrigin) === null || _item$_productOrigin16 === void 0 || (_item$_productOrigin16 = _item$_productOrigin16.duration) === null || _item$_productOrigin16 === void 0 ? void 0 : _item$_productOrigin16.value) !== null && _item$_productOrigin$6 !== void 0 ? _item$_productOrigin$6 : 0, (_ref11 = (_item$_productOrigin17 = item._productOrigin) === null || _item$_productOrigin17 === void 0 || (_item$_productOrigin17 = _item$_productOrigin17.duration) === null || _item$_productOrigin17 === void 0 ? void 0 : _item$_productOrigin17.type) !== null && _ref11 !== void 0 ? _ref11 : 'minutes').format('YYYY-MM-DD HH:mm');
2027
2038
  delete resource.times;
2028
2039
  });
2029
2040
  _this10.store.cart.updateItem({
@@ -205,6 +205,10 @@ export var getIsUsableByTimeItem = function getIsUsableByTimeItem(_ref2) {
205
205
  canBookingForOngoing = true;
206
206
  }
207
207
  }
208
+ } else if (type === 'ongoing' && (ongoing === null || ongoing === void 0 ? void 0 : ongoing.type) === 'before_end') {
209
+ if (dayjs(timeSlice.end_at).isAfter(earliest)) {
210
+ canBookingForOngoing = true;
211
+ }
208
212
  } else {
209
213
  if (unit) {
210
214
  earliest = earliest.add(unit, unit_type);
@@ -1290,11 +1290,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1290
1290
  const cartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
1291
1291
  const resourceIds = [];
1292
1292
  let resourcesTypeId = void 0;
1293
+ let isSingleResource = false;
1293
1294
  cartItems.forEach((item) => {
1294
1295
  var _a2, _b2, _c2, _d2, _e2, _f2, _g;
1295
1296
  (_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.forEach((n) => {
1296
1297
  if (n.code === resources_code) {
1297
1298
  resources.push(...n.renderList || []);
1299
+ isSingleResource = n.type === "single";
1298
1300
  }
1299
1301
  });
1300
1302
  if (item.resource_id) {
@@ -1317,8 +1319,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1317
1319
  const checkDuration = (cartItems2) => {
1318
1320
  let accountDuration = 0;
1319
1321
  cartItems2.forEach((item) => {
1320
- var _a2, _b2;
1321
- accountDuration += ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) ?? 0;
1322
+ var _a2, _b2, _c2, _d2, _e2, _f2;
1323
+ if (isSingleResource) {
1324
+ accountDuration += ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) ?? 0;
1325
+ } else {
1326
+ if (accountDuration < (((_d2 = (_c2 = item._productOrigin) == null ? void 0 : _c2.duration) == null ? void 0 : _d2.value) ?? 0)) {
1327
+ accountDuration = ((_f2 = (_e2 = item._productOrigin) == null ? void 0 : _e2.duration) == null ? void 0 : _f2.value) ?? 0;
1328
+ }
1329
+ }
1322
1330
  });
1323
1331
  if (accountDuration > duration) {
1324
1332
  duration = accountDuration;
@@ -149,6 +149,10 @@ var getIsUsableByTimeItem = ({
149
149
  canBookingForOngoing = true;
150
150
  }
151
151
  }
152
+ } else if (type === "ongoing" && (ongoing == null ? void 0 : ongoing.type) === "before_end") {
153
+ if ((0, import_dayjs.default)(timeSlice.end_at).isAfter(earliest)) {
154
+ canBookingForOngoing = true;
155
+ }
152
156
  } else {
153
157
  if (unit) {
154
158
  earliest = earliest.add(unit, unit_type);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.90",
4
+ "version": "0.0.92",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",