@pisell/pisellos 1.0.3 → 1.0.5

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.
@@ -1909,6 +1909,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1909
1909
  var hasOverlap = !dayjs(item.time.start_at).isAfter(dayjs(timeSlots.start_at)) && !dayjs(item.time.end_at).isBefore(dayjs(timeSlots.end_at));
1910
1910
  return hasOverlap ? sum + item.pax : sum;
1911
1911
  }, 0);
1912
+
1913
+ // 如果资源是单个预约,并且有 totalCapacity,则认为在当前 timeSlots 资源已经被选择过,就不可用了
1914
+ if (n.resourceType === 'single' && totalCapacity > 0) {
1915
+ return 0; // continue
1916
+ }
1912
1917
  var canUseTime = mTimes.find(function (item) {
1913
1918
  var _cartItem$_productOri12;
1914
1919
  var res = getIsUsableByTimeItem({
@@ -2357,7 +2362,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2357
2362
  var resourcesEndTime = targetResourceTimes.reduce(function (acc, curr) {
2358
2363
  return dayjs(curr.end_at).isBefore(dayjs(acc.end_at)) ? curr : acc;
2359
2364
  }, targetResourceTimes[0]);
2360
- var endTime = dayjs(resourcesEndTime.end_at).isBefore(dayjs(operating_day_boundary)) ? resourcesEndTime.end_at : operating_day_boundary;
2365
+
2366
+ // 将 operating_day_boundary 转换为与 resourcesEndTime.end_at 相同日期的完整日期时间
2367
+ var resourceDate = dayjs(resourcesEndTime.end_at).format('YYYY-MM-DD');
2368
+ var operatingBoundaryDateTime = "".concat(resourceDate, " ").concat(operating_day_boundary);
2369
+ var endTime = dayjs(resourcesEndTime.end_at).isBefore(dayjs(operatingBoundaryDateTime)) ? resourcesEndTime.end_at : operatingBoundaryDateTime;
2361
2370
  // 修复:如果 endTime 只是时间格式(如 "17:00"),需要加上日期
2362
2371
  var formattedEndTime;
2363
2372
  if (typeof endTime === 'string' && endTime.includes(':') && !endTime.includes(' ') && !endTime.includes('T')) {
@@ -1227,6 +1227,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1227
1227
  },
1228
1228
  0
1229
1229
  );
1230
+ if (n.resourceType === "single" && totalCapacity > 0) {
1231
+ continue;
1232
+ }
1230
1233
  const canUseTime = mTimes.find((item) => {
1231
1234
  var _a2;
1232
1235
  const res = (0, import_resources.getIsUsableByTimeItem)({
@@ -1615,7 +1618,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1615
1618
  const resourcesEndTime = targetResourceTimes.reduce((acc, curr) => {
1616
1619
  return (0, import_dayjs.default)(curr.end_at).isBefore((0, import_dayjs.default)(acc.end_at)) ? curr : acc;
1617
1620
  }, targetResourceTimes[0]);
1618
- const endTime = (0, import_dayjs.default)(resourcesEndTime.end_at).isBefore((0, import_dayjs.default)(operating_day_boundary)) ? resourcesEndTime.end_at : operating_day_boundary;
1621
+ const resourceDate = (0, import_dayjs.default)(resourcesEndTime.end_at).format("YYYY-MM-DD");
1622
+ const operatingBoundaryDateTime = `${resourceDate} ${operating_day_boundary}`;
1623
+ const endTime = (0, import_dayjs.default)(resourcesEndTime.end_at).isBefore((0, import_dayjs.default)(operatingBoundaryDateTime)) ? resourcesEndTime.end_at : operatingBoundaryDateTime;
1619
1624
  let formattedEndTime;
1620
1625
  if (typeof endTime === "string" && endTime.includes(":") && !endTime.includes(" ") && !endTime.includes("T")) {
1621
1626
  const currentDate = timeSlots.start_at.format("YYYY-MM-DD");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "1.0.3",
4
+ "version": "1.0.5",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",