@pisell/pisellos 0.0.132 → 0.0.134

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.
@@ -1568,7 +1568,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1568
1568
  } else {
1569
1569
  var _cartItem$_productOri4, _this9$shopStore$get;
1570
1570
  var hasFlexibleDuration = ((_cartItem$_productOri4 = cartItem._productOrigin) === null || _cartItem$_productOri4 === void 0 || (_cartItem$_productOri4 = _cartItem$_productOri4.duration) === null || _cartItem$_productOri4 === void 0 ? void 0 : _cartItem$_productOri4.type) === 'flexible';
1571
- var operating_day_boundary = (_this9$shopStore$get = _this9.shopStore.get('core')) === null || _this9$shopStore$get === void 0 || (_this9$shopStore$get = _this9$shopStore$get.core) === null || _this9$shopStore$get === void 0 || (_this9$shopStore$get = _this9$shopStore$get.operating_day_boundary) === null || _this9$shopStore$get === void 0 ? void 0 : _this9$shopStore$get.time;
1571
+ var operating_day_boundary = (_this9$shopStore$get = _this9.shopStore.get('core')) === null || _this9$shopStore$get === void 0 || (_this9$shopStore$get = _this9$shopStore$get.core) === null || _this9$shopStore$get === void 0 ? void 0 : _this9$shopStore$get.operating_day_boundary;
1572
1572
  productResources.forEach(function (item) {
1573
1573
  // 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
1574
1574
  // 同时,在这一步尝试去拉一下时间片,基于商品的时长,看每个资源是否还有空余时间能对这个商品做服务,如果没有则过滤
@@ -2298,7 +2298,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2298
2298
  var _item$_productOrigin17;
2299
2299
  return ((_item$_productOrigin17 = item._productOrigin) === null || _item$_productOrigin17 === void 0 || (_item$_productOrigin17 = _item$_productOrigin17.duration) === null || _item$_productOrigin17 === void 0 ? void 0 : _item$_productOrigin17.type) === 'flexible';
2300
2300
  });
2301
- var operating_day_boundary = (_this$shopStore$get = this.shopStore.get('core')) === null || _this$shopStore$get === void 0 || (_this$shopStore$get = _this$shopStore$get.core) === null || _this$shopStore$get === void 0 || (_this$shopStore$get = _this$shopStore$get.operating_day_boundary) === null || _this$shopStore$get === void 0 ? void 0 : _this$shopStore$get.time;
2301
+ var operating_day_boundary = (_this$shopStore$get = this.shopStore.get('core')) === null || _this$shopStore$get === void 0 || (_this$shopStore$get = _this$shopStore$get.core) === null || _this$shopStore$get === void 0 ? void 0 : _this$shopStore$get.operating_day_boundary;
2302
2302
  var timeSlots = getTimeSlicesByResources({
2303
2303
  resourceIds: resourceIds,
2304
2304
  resourcesMap: resourcesMap,
@@ -2338,7 +2338,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2338
2338
  }, {});
2339
2339
 
2340
2340
  // 店铺营业结束时间
2341
- var operating_day_boundary = (_this$shopStore$get2 = this.shopStore.get('core')) === null || _this$shopStore$get2 === void 0 || (_this$shopStore$get2 = _this$shopStore$get2.core) === null || _this$shopStore$get2 === void 0 || (_this$shopStore$get2 = _this$shopStore$get2.operating_day_boundary) === null || _this$shopStore$get2 === void 0 ? void 0 : _this$shopStore$get2.time;
2341
+ var operating_day_boundary = (_this$shopStore$get2 = this.shopStore.get('core')) === null || _this$shopStore$get2 === void 0 || (_this$shopStore$get2 = _this$shopStore$get2.core) === null || _this$shopStore$get2 === void 0 ? void 0 : _this$shopStore$get2.operating_day_boundary;
2342
2342
 
2343
2343
  // 处理每个账号的商品
2344
2344
  Object.values(itemsByAccount).forEach(function (accountItems) {
@@ -2363,7 +2363,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2363
2363
  var resourcesEndTime = targetResourceTimes.reduce(function (acc, curr) {
2364
2364
  return dayjs(curr.end_at).isBefore(dayjs(acc.end_at)) ? curr : acc;
2365
2365
  }, targetResourceTimes[0]);
2366
- var endTime = dayjs(resourcesEndTime.end_at).isBefore(dayjs(operating_day_boundary)) ? resourcesEndTime.end_at : operating_day_boundary;
2366
+
2367
+ // 将 operating_day_boundary 转换为与 resourcesEndTime.end_at 相同日期的完整日期时间
2368
+ var resourceDate = dayjs(resourcesEndTime.end_at).format('YYYY-MM-DD');
2369
+ var operatingBoundaryDateTime = "".concat(resourceDate, " ").concat(operating_day_boundary.type === 'start_time' ? "23:59" : operating_day_boundary.time);
2370
+ var endTime = dayjs(resourcesEndTime.end_at).isBefore(dayjs(operatingBoundaryDateTime)) ? resourcesEndTime.end_at : operatingBoundaryDateTime;
2367
2371
  // 修复:如果 endTime 只是时间格式(如 "17:00"),需要加上日期
2368
2372
  var formattedEndTime;
2369
2373
  if (typeof endTime === 'string' && endTime.includes(':') && !endTime.includes(' ') && !endTime.includes('T')) {
@@ -97,7 +97,10 @@ export declare const getTimeSlicesByResource: ({ resource, duration, split, curr
97
97
  } | undefined;
98
98
  } | undefined;
99
99
  hasFlexibleDuration?: boolean | undefined;
100
- operating_day_boundary?: string | undefined;
100
+ operating_day_boundary?: {
101
+ type: string;
102
+ time: string;
103
+ } | undefined;
101
104
  }) => TimeSliceItem[];
102
105
  /**
103
106
  * @title: 获取时间切片列表的交集
@@ -154,7 +157,10 @@ export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, dur
154
157
  } | undefined;
155
158
  } | undefined;
156
159
  hasFlexibleDuration?: boolean | undefined;
157
- operating_day_boundary?: string | undefined;
160
+ operating_day_boundary?: {
161
+ type: string;
162
+ time: string;
163
+ } | undefined;
158
164
  }) => any[];
159
165
  /**
160
166
  * @title: 获取其他人的已选资源
@@ -463,7 +463,8 @@ export var getTimeSlicesByResource = function getTimeSlicesByResource(_ref5) {
463
463
  }
464
464
  if (_status.usable) {
465
465
  // 如果有hasFlexibleDuration,且timeSlice.start_at 大于等于operating_day_boundary,则不添加时间切片
466
- if (hasFlexibleDuration && operating_day_boundary && timeSlice.start_time >= operating_day_boundary) {
466
+ var operatingBoundaryDateTime = (operating_day_boundary === null || operating_day_boundary === void 0 ? void 0 : operating_day_boundary.type) === 'start_time' ? "23:59" : operating_day_boundary === null || operating_day_boundary === void 0 ? void 0 : operating_day_boundary.time;
467
+ if (hasFlexibleDuration && operating_day_boundary && timeSlice.start_time >= (operatingBoundaryDateTime || "23:59")) {
467
468
  break;
468
469
  }
469
470
  // 添加时间切片 09:00 ~ 10:00 09:20 ~ 10:20 09:00 ~ 10:00 09:20 ~ 10:20 11:00 ~ 12:00 11:20 ~ 12:20
@@ -824,7 +824,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
824
824
  const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
825
825
  const arr = [];
826
826
  cartItems.forEach((cartItem) => {
827
- var _a, _b, _c, _d, _e, _f, _g, _h;
827
+ var _a, _b, _c, _d, _e, _f, _g;
828
828
  let selectedResources = [];
829
829
  const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
830
830
  capacity: (_a = cartItem._productOrigin) == null ? void 0 : _a.capacity,
@@ -904,7 +904,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
904
904
  });
905
905
  } else {
906
906
  const hasFlexibleDuration = ((_e = (_d = cartItem._productOrigin) == null ? void 0 : _d.duration) == null ? void 0 : _e.type) === "flexible";
907
- const operating_day_boundary = (_h = (_g = (_f = this.shopStore.get("core")) == null ? void 0 : _f.core) == null ? void 0 : _g.operating_day_boundary) == null ? void 0 : _h.time;
907
+ const operating_day_boundary = (_g = (_f = this.shopStore.get("core")) == null ? void 0 : _f.core) == null ? void 0 : _g.operating_day_boundary;
908
908
  productResources.forEach((item) => {
909
909
  item.renderList = item.renderList.filter((n) => {
910
910
  var _a2, _b2, _c2;
@@ -1479,7 +1479,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1479
1479
  }
1480
1480
  // 从购物车中获取已经分配好第一步资源的所有时间片
1481
1481
  getTimeSlotByAllResources(resources_code) {
1482
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
1482
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1483
1483
  let dateRange = this.store.date.getDateRange();
1484
1484
  const resources = [];
1485
1485
  const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
@@ -1489,7 +1489,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1489
1489
  let maxCutOffTime = void 0;
1490
1490
  let maxCutOffTimeValue = (0, import_dayjs.default)();
1491
1491
  cartItems.forEach((item) => {
1492
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2;
1492
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i;
1493
1493
  (_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.forEach((n) => {
1494
1494
  if (n.code === resources_code) {
1495
1495
  resources.push(...n.renderList || []);
@@ -1502,7 +1502,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1502
1502
  resourcesTypeId = (_g2 = (_f2 = (_e2 = (_d2 = item == null ? void 0 : item._productOrigin) == null ? void 0 : _d2.product_resource) == null ? void 0 : _e2.resources) == null ? void 0 : _f2.find(
1503
1503
  (n) => n.code === resources_code
1504
1504
  )) == null ? void 0 : _g2.id;
1505
- if (((_h2 = item._productOrigin) == null ? void 0 : _h2.cut_off_time) && ((_i2 = item._productOrigin) == null ? void 0 : _i2.cut_off_time.type) === "advance") {
1505
+ if (((_h2 = item._productOrigin) == null ? void 0 : _h2.cut_off_time) && ((_i = item._productOrigin) == null ? void 0 : _i.cut_off_time.type) === "advance") {
1506
1506
  const currentCutOffTime = (0, import_dayjs.default)().add(
1507
1507
  item._productOrigin.cut_off_time.unit,
1508
1508
  item._productOrigin.cut_off_time.unit_type
@@ -1571,7 +1571,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1571
1571
  var _a2, _b2;
1572
1572
  return ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.type) === "flexible";
1573
1573
  });
1574
- const operating_day_boundary = (_i = (_h = (_g = this.shopStore.get("core")) == null ? void 0 : _g.core) == null ? void 0 : _h.operating_day_boundary) == null ? void 0 : _i.time;
1574
+ const operating_day_boundary = (_h = (_g = this.shopStore.get("core")) == null ? void 0 : _g.core) == null ? void 0 : _h.operating_day_boundary;
1575
1575
  const timeSlots = (0, import_resources.getTimeSlicesByResources)({
1576
1576
  resourceIds,
1577
1577
  resourcesMap,
@@ -1587,7 +1587,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1587
1587
  }
1588
1588
  // 提交时间切片,绑定到对应购物车的商品上,更新购物车---只有 duration 商品
1589
1589
  submitTimeSlot(timeSlots) {
1590
- var _a, _b, _c;
1590
+ var _a, _b;
1591
1591
  const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
1592
1592
  const allResources = this.store.date.getResourcesListByDate(timeSlots.start_at.format("YYYY-MM-DD"));
1593
1593
  const itemsByAccount = cartItems.reduce(
@@ -1601,25 +1601,27 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1601
1601
  },
1602
1602
  {}
1603
1603
  );
1604
- const operating_day_boundary = (_c = (_b = (_a = this.shopStore.get("core")) == null ? void 0 : _a.core) == null ? void 0 : _b.operating_day_boundary) == null ? void 0 : _c.time;
1604
+ const operating_day_boundary = (_b = (_a = this.shopStore.get("core")) == null ? void 0 : _a.core) == null ? void 0 : _b.operating_day_boundary;
1605
1605
  Object.values(itemsByAccount).forEach((accountItems) => {
1606
1606
  let currentStartTime = timeSlots.start_at.format("YYYY-MM-DD HH:mm");
1607
1607
  accountItems.forEach((item, index) => {
1608
1608
  var _a2;
1609
1609
  const newResources = (0, import_lodash_es.cloneDeep)(item._origin.resources);
1610
1610
  newResources.forEach((resource) => {
1611
- var _a3, _b2, _c2, _d, _e;
1611
+ var _a3, _b2, _c, _d, _e;
1612
1612
  if (((_b2 = (_a3 = item._productOrigin) == null ? void 0 : _a3.duration) == null ? void 0 : _b2.type) === "flexible") {
1613
1613
  item.duration = {
1614
1614
  type: "minutes",
1615
1615
  value: 10
1616
1616
  };
1617
1617
  resource.startTime = timeSlots.start_at.format("YYYY-MM-DD HH:mm");
1618
- const targetResourceTimes = (_c2 = allResources == null ? void 0 : allResources.find((n) => n.id === resource.id)) == null ? void 0 : _c2.times;
1618
+ const targetResourceTimes = (_c = allResources == null ? void 0 : allResources.find((n) => n.id === resource.id)) == null ? void 0 : _c.times;
1619
1619
  const resourcesEndTime = targetResourceTimes.reduce((acc, curr) => {
1620
1620
  return (0, import_dayjs.default)(curr.end_at).isBefore((0, import_dayjs.default)(acc.end_at)) ? curr : acc;
1621
1621
  }, targetResourceTimes[0]);
1622
- const endTime = (0, import_dayjs.default)(resourcesEndTime.end_at).isBefore((0, import_dayjs.default)(operating_day_boundary)) ? resourcesEndTime.end_at : operating_day_boundary;
1622
+ const resourceDate = (0, import_dayjs.default)(resourcesEndTime.end_at).format("YYYY-MM-DD");
1623
+ const operatingBoundaryDateTime = `${resourceDate} ${operating_day_boundary.type === "start_time" ? "23:59" : operating_day_boundary.time}`;
1624
+ const endTime = (0, import_dayjs.default)(resourcesEndTime.end_at).isBefore((0, import_dayjs.default)(operatingBoundaryDateTime)) ? resourcesEndTime.end_at : operatingBoundaryDateTime;
1623
1625
  let formattedEndTime;
1624
1626
  if (typeof endTime === "string" && endTime.includes(":") && !endTime.includes(" ") && !endTime.includes("T")) {
1625
1627
  const currentDate = timeSlots.start_at.format("YYYY-MM-DD");
@@ -97,7 +97,10 @@ export declare const getTimeSlicesByResource: ({ resource, duration, split, curr
97
97
  } | undefined;
98
98
  } | undefined;
99
99
  hasFlexibleDuration?: boolean | undefined;
100
- operating_day_boundary?: string | undefined;
100
+ operating_day_boundary?: {
101
+ type: string;
102
+ time: string;
103
+ } | undefined;
101
104
  }) => TimeSliceItem[];
102
105
  /**
103
106
  * @title: 获取时间切片列表的交集
@@ -154,7 +157,10 @@ export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, dur
154
157
  } | undefined;
155
158
  } | undefined;
156
159
  hasFlexibleDuration?: boolean | undefined;
157
- operating_day_boundary?: string | undefined;
160
+ operating_day_boundary?: {
161
+ type: string;
162
+ time: string;
163
+ } | undefined;
158
164
  }) => any[];
159
165
  /**
160
166
  * @title: 获取其他人的已选资源
@@ -366,7 +366,8 @@ var getTimeSlicesByResource = ({
366
366
  resourcesUseableMap[resource.id] = _status.usable;
367
367
  }
368
368
  if (_status.usable) {
369
- if (hasFlexibleDuration && operating_day_boundary && timeSlice.start_time >= operating_day_boundary) {
369
+ const operatingBoundaryDateTime = (operating_day_boundary == null ? void 0 : operating_day_boundary.type) === "start_time" ? "23:59" : operating_day_boundary == null ? void 0 : operating_day_boundary.time;
370
+ if (hasFlexibleDuration && operating_day_boundary && timeSlice.start_time >= (operatingBoundaryDateTime || "23:59")) {
370
371
  break;
371
372
  }
372
373
  timeSlices.push({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.132",
4
+ "version": "0.0.134",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",