@pisell/pisellos 0.0.127 → 0.0.128

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.
@@ -20,4 +20,5 @@ export declare class DateModule extends BaseModule implements Module, DateModule
20
20
  getResourceAvailableTimeList(params: IGetAvailableTimeListParams): Promise<ITime[]>;
21
21
  clearDateRange(): void;
22
22
  storeChange(): void;
23
+ getResourcesListByDate(date: string): any[] | undefined;
23
24
  }
@@ -232,6 +232,16 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
232
232
  });
233
233
  }
234
234
  }
235
+ }, {
236
+ key: "getResourcesListByDate",
237
+ value: function getResourcesListByDate(date) {
238
+ var _dateList$find;
239
+ var dateList = this.store.dateList;
240
+ var resourcesList = (_dateList$find = dateList.find(function (item) {
241
+ return item.date === date;
242
+ })) === null || _dateList$find === void 0 ? void 0 : _dateList$find.resource;
243
+ return resourcesList;
244
+ }
235
245
  }]);
236
246
  return DateModule;
237
247
  }(BaseModule);
@@ -87,6 +87,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
87
87
  }
88
88
  throw new Error('bookingByStep解决方案需要 request 插件支持');
89
89
  case 9:
90
+ if (this.shopStore) {
91
+ _context.next = 11;
92
+ break;
93
+ }
94
+ throw new Error('SummaryModule 需要 shopStore 插件支持');
95
+ case 11:
90
96
  // 如果有传 cacheid,默认需要收集上面这些模块里用户操作选中的数据
91
97
  // 并且在上面 registerModule 的时候,读取 sessionStroage 里的数据,塞进默认值
92
98
  targetCacheData = {};
@@ -120,7 +126,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
120
126
  });
121
127
  this.loadAllSchedule();
122
128
  this.core.effects.emit(BookingByStepHooks.onInited, {});
123
- case 16:
129
+ case 18:
124
130
  case "end":
125
131
  return _context.stop();
126
132
  }
@@ -1468,6 +1474,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1468
1474
  }, {
1469
1475
  key: "getResourcesList",
1470
1476
  value: function getResourcesList() {
1477
+ var _this9 = this;
1471
1478
  var dateRange = this.store.date.getDateRange();
1472
1479
  var resources = [];
1473
1480
  if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
@@ -1559,19 +1566,25 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1559
1566
  });
1560
1567
  });
1561
1568
  } else {
1569
+ var _cartItem$_productOri4, _this9$shopStore$get;
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;
1562
1572
  productResources.forEach(function (item) {
1563
1573
  // 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
1564
1574
  // 同时,在这一步尝试去拉一下时间片,基于商品的时长,看每个资源是否还有空余时间能对这个商品做服务,如果没有则过滤
1565
1575
  item.renderList = item.renderList.filter(function (n) {
1566
- var _cartItem$_productOri4;
1576
+ var _cartItem$_productOri5, _cartItem$_productOri6;
1567
1577
  var recordCount = n.capacity || 0;
1568
1578
  if (n.onlyComputed) return false;
1569
1579
  // 查一下这个资源基于商品的可用时间片
1570
1580
  var timeSlots = getTimeSlicesByResource({
1571
1581
  resource: n,
1572
- duration: ((_cartItem$_productOri4 = cartItem._productOrigin) === null || _cartItem$_productOri4 === void 0 || (_cartItem$_productOri4 = _cartItem$_productOri4.duration) === null || _cartItem$_productOri4 === void 0 ? void 0 : _cartItem$_productOri4.value) || 0,
1582
+ duration: ((_cartItem$_productOri5 = cartItem._productOrigin) === null || _cartItem$_productOri5 === void 0 || (_cartItem$_productOri5 = _cartItem$_productOri5.duration) === null || _cartItem$_productOri5 === void 0 ? void 0 : _cartItem$_productOri5.value) || 10,
1573
1583
  split: 10,
1574
- currentDate: dateRange[0].date
1584
+ currentDate: dateRange[0].date,
1585
+ hasFlexibleDuration: hasFlexibleDuration,
1586
+ cut_off_time: (_cartItem$_productOri6 = cartItem._productOrigin) === null || _cartItem$_productOri6 === void 0 ? void 0 : _cartItem$_productOri6.cut_off_time,
1587
+ operating_day_boundary: operating_day_boundary
1575
1588
  });
1576
1589
  return recordCount >= currentCapacity && timeSlots.length > 0;
1577
1590
  });
@@ -1615,10 +1628,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1615
1628
  });
1616
1629
  var arr = [];
1617
1630
  cartItems.forEach(function (cartItem) {
1618
- var _cartItem$_productOri5, _cartItem$_productOri6;
1631
+ var _cartItem$_productOri7, _cartItem$_productOri8;
1619
1632
  var selectedResources = [];
1620
1633
  var formatCapacity = formatDefaultCapacitys({
1621
- capacity: (_cartItem$_productOri5 = cartItem._productOrigin) === null || _cartItem$_productOri5 === void 0 ? void 0 : _cartItem$_productOri5.capacity,
1634
+ capacity: (_cartItem$_productOri7 = cartItem._productOrigin) === null || _cartItem$_productOri7 === void 0 ? void 0 : _cartItem$_productOri7.capacity,
1622
1635
  product_bundle: cartItem._origin.product.product_bundle
1623
1636
  });
1624
1637
  cartItem._origin.metadata.capacity = formatCapacity;
@@ -1630,7 +1643,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1630
1643
  } else {
1631
1644
  selectedResources = getOthersCartSelectedResources(cartItems, cartItem._id, resourcesMap);
1632
1645
  }
1633
- var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri6 = cartItem._productOrigin) === null || _cartItem$_productOri6 === void 0 || (_cartItem$_productOri6 = _cartItem$_productOri6.product_resource) === null || _cartItem$_productOri6 === void 0 ? void 0 : _cartItem$_productOri6.resources) || [], selectedResources, currentCapacity);
1646
+ var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri8 = cartItem._productOrigin) === null || _cartItem$_productOri8 === void 0 || (_cartItem$_productOri8 = _cartItem$_productOri8.product_resource) === null || _cartItem$_productOri8 === void 0 ? void 0 : _cartItem$_productOri8.resources) || [], selectedResources, currentCapacity);
1634
1647
  // 如果购物车里已经有了时间片,则需要按照时间片过滤
1635
1648
  if (cartItem._origin.start_time) {
1636
1649
  var startTime = dayjs("".concat(cartItem._origin.start_date, " ").concat(cartItem._origin.start_time));
@@ -1658,7 +1671,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1658
1671
  return false;
1659
1672
  }
1660
1673
  var canUseArr = mTimes.map(function (item) {
1661
- var _cartItem$_productOri7;
1674
+ var _cartItem$_productOri9;
1662
1675
  var res = getIsUsableByTimeItem({
1663
1676
  timeSlice: {
1664
1677
  start_time: startTime.format('HH:mm'),
@@ -1670,7 +1683,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1670
1683
  resource: m,
1671
1684
  currentCount: currentCapacity || 0,
1672
1685
  resourcesUseableMap: resourcesUseableMap,
1673
- cut_off_time: (_cartItem$_productOri7 = cartItem._productOrigin) === null || _cartItem$_productOri7 === void 0 ? void 0 : _cartItem$_productOri7.cut_off_time
1686
+ cut_off_time: (_cartItem$_productOri9 = cartItem._productOrigin) === null || _cartItem$_productOri9 === void 0 ? void 0 : _cartItem$_productOri9.cut_off_time
1674
1687
  });
1675
1688
  // 如果仅仅是因为子资源容量不够,不应该标记子资源是被占用的情况
1676
1689
  if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
@@ -1690,13 +1703,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1690
1703
  // 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
1691
1704
  // 同时,在这一步尝试去拉一下时间片,基于商品的时长,看每个资源是否还有空余时间能对这个商品做服务,如果没有则过滤
1692
1705
  item.renderList = item.renderList.filter(function (n) {
1693
- var _cartItem$_productOri8;
1706
+ var _cartItem$_productOri10;
1694
1707
  var recordCount = n.capacity || 0;
1695
1708
  if (n.onlyComputed) return false;
1696
1709
  // 查一下这个资源基于商品的可用时间片
1697
1710
  var timeSlots = getTimeSlicesByResource({
1698
1711
  resource: n,
1699
- duration: ((_cartItem$_productOri8 = cartItem._productOrigin) === null || _cartItem$_productOri8 === void 0 || (_cartItem$_productOri8 = _cartItem$_productOri8.duration) === null || _cartItem$_productOri8 === void 0 ? void 0 : _cartItem$_productOri8.value) || 0,
1712
+ duration: ((_cartItem$_productOri10 = cartItem._productOrigin) === null || _cartItem$_productOri10 === void 0 || (_cartItem$_productOri10 = _cartItem$_productOri10.duration) === null || _cartItem$_productOri10 === void 0 ? void 0 : _cartItem$_productOri10.value) || 10,
1700
1713
  split: 10,
1701
1714
  currentDate: dateRange[0].date
1702
1715
  });
@@ -1800,7 +1813,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1800
1813
  }, {
1801
1814
  key: "autoSelectAccountResources",
1802
1815
  value: function autoSelectAccountResources(_ref8) {
1803
- var _cartItem$_productOri9, _allProductResources$;
1816
+ var _cartItem$_productOri11, _allProductResources$;
1804
1817
  var cartItem = _ref8.cartItem,
1805
1818
  holder_id = _ref8.holder_id,
1806
1819
  resources_code = _ref8.resources_code,
@@ -1822,20 +1835,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1822
1835
  }
1823
1836
  // duration=所有商品时间的集合
1824
1837
  var duration = accountCartItems.reduce(function (acc, n) {
1825
- var _n$_productOrigin$dur, _n$_productOrigin2;
1826
- return acc + ((_n$_productOrigin$dur = (_n$_productOrigin2 = n._productOrigin) === null || _n$_productOrigin2 === void 0 || (_n$_productOrigin2 = _n$_productOrigin2.duration) === null || _n$_productOrigin2 === void 0 ? void 0 : _n$_productOrigin2.value) !== null && _n$_productOrigin$dur !== void 0 ? _n$_productOrigin$dur : 0);
1838
+ var _n$_productOrigin2;
1839
+ return acc + (((_n$_productOrigin2 = n._productOrigin) === null || _n$_productOrigin2 === void 0 || (_n$_productOrigin2 = _n$_productOrigin2.duration) === null || _n$_productOrigin2 === void 0 ? void 0 : _n$_productOrigin2.value) || 10);
1827
1840
  }, 0);
1828
- // 正常来说,能进这个业务的所有商品的 duration 类型都是一样的,所以这里取第一个商品的 duration 类型
1829
- // let durationType = accountCartItems[0]?._productOrigin?.duration?.type ?? "minutes";
1830
- // 取出账号下所对应类型的所有的可用资源
1831
- // let resourcesCartItems: any[] = [];
1832
- // accountCartItems.forEach((item) => {
1833
- // item._productOrigin?.product_resource?.resources?.forEach((n) => {
1834
- // if (n.code === resources_code) {
1835
- // resourcesCartItems.push(...(n.renderList || []));
1836
- // }
1837
- // });
1838
- // });
1839
1841
  var AllResources = [];
1840
1842
  if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
1841
1843
  dateRange.forEach(function (n) {
@@ -1852,7 +1854,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1852
1854
  var resourcesMap = getResourcesMap(cloneDeep(AllResources));
1853
1855
  var allCartItems = cloneDeep(this.store.cart.getItems());
1854
1856
  var selectedResources = getOthersSelectedResources(allCartItems, holder_id, resourcesMap);
1855
- var allProductResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri9 = cartItem._productOrigin) === null || _cartItem$_productOri9 === void 0 || (_cartItem$_productOri9 = _cartItem$_productOri9.product_resource) === null || _cartItem$_productOri9 === void 0 ? void 0 : _cartItem$_productOri9.resources) || [], selectedResources, 1);
1857
+ var allProductResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri11 = cartItem._productOrigin) === null || _cartItem$_productOri11 === void 0 || (_cartItem$_productOri11 = _cartItem$_productOri11.product_resource) === null || _cartItem$_productOri11 === void 0 ? void 0 : _cartItem$_productOri11.resources) || [], selectedResources, 1);
1856
1858
  var resources = ((_allProductResources$ = allProductResources.find(function (n) {
1857
1859
  return n.code === resources_code;
1858
1860
  })) === null || _allProductResources$ === void 0 ? void 0 : _allProductResources$.renderList) || [];
@@ -1908,14 +1910,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1908
1910
  return hasOverlap ? sum + item.pax : sum;
1909
1911
  }, 0);
1910
1912
  var canUseTime = mTimes.find(function (item) {
1911
- var _cartItem$_productOri10;
1913
+ var _cartItem$_productOri12;
1912
1914
  var res = getIsUsableByTimeItem({
1913
1915
  timeSlice: timeSlots,
1914
1916
  time: item,
1915
1917
  resource: n,
1916
1918
  currentCount: totalCapacity + (capacity || 0),
1917
1919
  resourcesUseableMap: resourcesUseableMap,
1918
- cut_off_time: (_cartItem$_productOri10 = cartItem._productOrigin) === null || _cartItem$_productOri10 === void 0 ? void 0 : _cartItem$_productOri10.cut_off_time
1920
+ cut_off_time: (_cartItem$_productOri12 = cartItem._productOrigin) === null || _cartItem$_productOri12 === void 0 ? void 0 : _cartItem$_productOri12.cut_off_time
1919
1921
  });
1920
1922
  // 如果只是因为子资源容量不够,而不是子资源被预约导致没时间片,不应该标记子资源为不可用,从而影响组合资源的情况
1921
1923
  if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[n.id]) !== false && res.reason !== 'capacityOnly') {
@@ -1978,7 +1980,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1978
1980
  key: "autoSelectAllProductResources",
1979
1981
  value: function autoSelectAllProductResources(resources_code, timeSlots) {
1980
1982
  var _dateRange$4,
1981
- _this9 = this;
1983
+ _this10 = this;
1982
1984
  var dateRange = this.store.date.getDateRange();
1983
1985
  var resources = [];
1984
1986
  if (dateRange !== null && dateRange !== void 0 && (_dateRange$4 = dateRange[0]) !== null && _dateRange$4 !== void 0 && _dateRange$4.date) {
@@ -2026,9 +2028,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2026
2028
  var resourceBookingType = (currentResourceConfig === null || currentResourceConfig === void 0 ? void 0 : currentResourceConfig.type) || 'single';
2027
2029
  // 只有 duration 类商品需要这个操作
2028
2030
  if (index !== 0 && recordTimeSlots && resourceBookingType === 'single' && (_item$_productOrigin5 = item._productOrigin) !== null && _item$_productOrigin5 !== void 0 && _item$_productOrigin5.duration) {
2029
- var _item$_productOrigin$, _item$_productOrigin6, _ref9, _item$_productOrigin7, _item$_productOrigin$2, _item$_productOrigin8, _ref10, _item$_productOrigin9;
2030
- 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');
2031
- 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');
2031
+ var _item$_productOrigin6, _item$_productOrigin7;
2032
+ var start_at = dayjs(recordTimeSlots.end_time).add(((_item$_productOrigin6 = item._productOrigin) === null || _item$_productOrigin6 === void 0 || (_item$_productOrigin6 = _item$_productOrigin6.duration) === null || _item$_productOrigin6 === void 0 ? void 0 : _item$_productOrigin6.value) || 10, 'minutes');
2033
+ var end_at = start_at.add(((_item$_productOrigin7 = item._productOrigin) === null || _item$_productOrigin7 === void 0 || (_item$_productOrigin7 = _item$_productOrigin7.duration) === null || _item$_productOrigin7 === void 0 ? void 0 : _item$_productOrigin7.value) || 10, 'minutes');
2032
2034
  recordTimeSlots = {
2033
2035
  start_time: start_at.format('HH:mm'),
2034
2036
  end_time: end_at.format('HH:mm'),
@@ -2037,7 +2039,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2037
2039
  };
2038
2040
  }
2039
2041
  // 如果传递了 timeSlots,代表是第二种资源,则直接拿 timeSlots 去匹配
2040
- var res = _this9.autoSelectAccountResources({
2042
+ var res = _this10.autoSelectAccountResources({
2041
2043
  cartItem: item,
2042
2044
  holder_id: item.holder_id,
2043
2045
  resources_code: resources_code,
@@ -2063,7 +2065,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2063
2065
  }
2064
2066
  res.selectedResource.capacity = currentCapacity;
2065
2067
  checkSubResourcesCapacity(res.selectedResource);
2066
- _this9.store.cart.updateItem({
2068
+ _this10.store.cart.updateItem({
2067
2069
  _id: item._id,
2068
2070
  // 这里要做去重,避免出现同样类型的资源被塞进同一个商品
2069
2071
  resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
@@ -2076,12 +2078,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2076
2078
  errorList.push(item._id);
2077
2079
  }
2078
2080
  } else {
2079
- var _item$_productOrigin10, _productResources$fin;
2081
+ var _item$_productOrigin8, _productResources$fin;
2080
2082
  // 这里必须每次循环重新读,避免前一次循环操作了购物车,导致数据变更
2081
- var allCartItems = cloneDeep(_this9.store.cart.getItems());
2083
+ var allCartItems = cloneDeep(_this10.store.cart.getItems());
2082
2084
  // 如果没有传递 timeSlots,代表是第一种资源,则直接拿商品的 duration,到资源列表里找一个公共可用的
2083
2085
  var selectedResources = [];
2084
- 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) || []);
2086
+ var _resources = cloneDeep(((_item$_productOrigin8 = item._productOrigin) === null || _item$_productOrigin8 === void 0 || (_item$_productOrigin8 = _item$_productOrigin8.product_resource) === null || _item$_productOrigin8 === void 0 ? void 0 : _item$_productOrigin8.resources) || []);
2085
2087
  var currentResourcesRenderList = [];
2086
2088
  _resources.forEach(function (n) {
2087
2089
  var _n$renderList;
@@ -2093,7 +2095,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2093
2095
  var recordCount = (m.capacity || 0) - (selectResourcesMap[m.id] || 0);
2094
2096
  var timeSlots = getTimeSlicesByResource({
2095
2097
  resource: m,
2096
- duration: (item === null || item === void 0 || (_item$duration = item.duration) === null || _item$duration === void 0 ? void 0 : _item$duration.value) || 0,
2098
+ duration: (item === null || item === void 0 || (_item$duration = item.duration) === null || _item$duration === void 0 ? void 0 : _item$duration.value) || 10,
2097
2099
  split: 10,
2098
2100
  currentDate: dateRange[0].date
2099
2101
  });
@@ -2142,7 +2144,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2142
2144
  } else {
2143
2145
  selectResourcesMap[targetResource.id] += currentCapacity;
2144
2146
  }
2145
- _this9.store.cart.updateItem({
2147
+ _this10.store.cart.updateItem({
2146
2148
  _id: item._id,
2147
2149
  resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
2148
2150
  return existingRes.resourceType !== targetRenderList[0].resourceType;
@@ -2162,7 +2164,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2162
2164
  // 如果购物车里没有 holderid数据,证明不按 holder 类流程预约走,给所有购物车一次性分派即可,不做账号下资源互斥逻辑
2163
2165
  if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
2164
2166
  accountList.forEach(function (account) {
2165
- var cartItems = _this9.store.cart.getCartByAccount(account.getId());
2167
+ var cartItems = _this10.store.cart.getCartByAccount(account.getId());
2166
2168
  selectForCartResources(cartItems);
2167
2169
  });
2168
2170
  } else {
@@ -2177,9 +2179,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2177
2179
  key: "getTimeSlotByAllResources",
2178
2180
  value: function getTimeSlotByAllResources(resources_code) {
2179
2181
  var _dateRange,
2180
- _this10 = this,
2182
+ _this11 = this,
2181
2183
  _cartItems$,
2182
- _cartItems$2;
2184
+ _cartItems$2,
2185
+ _this$shopStore$get;
2183
2186
  var dateRange = this.store.date.getDateRange();
2184
2187
  // 取出购物车中所有一已选择的第一步资源
2185
2188
  var resources = [];
@@ -2195,8 +2198,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2195
2198
  var maxCutOffTime = undefined;
2196
2199
  var maxCutOffTimeValue = dayjs();
2197
2200
  cartItems.forEach(function (item) {
2198
- var _item$_productOrigin11, _item$_productOrigin12, _item$_productOrigin13, _item$_productOrigin14;
2199
- (_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) {
2201
+ var _item$_productOrigin9, _item$_productOrigin10, _item$_productOrigin11, _item$_productOrigin12;
2202
+ (_item$_productOrigin9 = item._productOrigin) === null || _item$_productOrigin9 === void 0 || (_item$_productOrigin9 = _item$_productOrigin9.product_resource) === null || _item$_productOrigin9 === void 0 || (_item$_productOrigin9 = _item$_productOrigin9.resources) === null || _item$_productOrigin9 === void 0 || _item$_productOrigin9.forEach(function (n) {
2200
2203
  // TODO: 少了个 status 的判断
2201
2204
  if (n.code === resources_code) {
2202
2205
  resources.push.apply(resources, _toConsumableArray(n.renderList || []));
@@ -2209,10 +2212,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2209
2212
  if (item.resource_id) {
2210
2213
  resourceIds.push(item.resource_id);
2211
2214
  }
2212
- 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) {
2215
+ resourcesTypeId = item === null || item === void 0 || (_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 = _item$_productOrigin10.find(function (n) {
2213
2216
  return n.code === resources_code;
2214
- })) === null || _item$_productOrigin12 === void 0 ? void 0 : _item$_productOrigin12.id;
2215
- if ((_item$_productOrigin13 = item._productOrigin) !== null && _item$_productOrigin13 !== void 0 && _item$_productOrigin13.cut_off_time && ((_item$_productOrigin14 = item._productOrigin) === null || _item$_productOrigin14 === void 0 ? void 0 : _item$_productOrigin14.cut_off_time.type) === 'advance') {
2217
+ })) === null || _item$_productOrigin10 === void 0 ? void 0 : _item$_productOrigin10.id;
2218
+ if ((_item$_productOrigin11 = item._productOrigin) !== null && _item$_productOrigin11 !== void 0 && _item$_productOrigin11.cut_off_time && ((_item$_productOrigin12 = item._productOrigin) === null || _item$_productOrigin12 === void 0 ? void 0 : _item$_productOrigin12.cut_off_time.type) === 'advance') {
2216
2219
  var currentCutOffTime = dayjs().add(item._productOrigin.cut_off_time.unit, item._productOrigin.cut_off_time.unit_type);
2217
2220
  if (currentCutOffTime.isAfter(maxCutOffTimeValue, 'minute')) {
2218
2221
  maxCutOffTimeValue = currentCutOffTime;
@@ -2240,13 +2243,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2240
2243
  cartItems.forEach(function (item) {
2241
2244
  // 单个预约累加账号 多个预约取最大值
2242
2245
  if (isSingleResource) {
2243
- var _item$_productOrigin$3, _item$_productOrigin15;
2244
- accountDuration += (_item$_productOrigin$3 = (_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$3 !== void 0 ? _item$_productOrigin$3 : 0;
2246
+ var _item$_productOrigin13;
2247
+ accountDuration += ((_item$_productOrigin13 = item._productOrigin) === null || _item$_productOrigin13 === void 0 || (_item$_productOrigin13 = _item$_productOrigin13.duration) === null || _item$_productOrigin13 === void 0 ? void 0 : _item$_productOrigin13.value) || 10;
2245
2248
  } else {
2246
- var _item$_productOrigin$4, _item$_productOrigin16;
2247
- if (accountDuration < ((_item$_productOrigin$4 = (_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$4 !== void 0 ? _item$_productOrigin$4 : 0)) {
2248
- var _item$_productOrigin$5, _item$_productOrigin17;
2249
- accountDuration = (_item$_productOrigin$5 = (_item$_productOrigin17 = item._productOrigin) === null || _item$_productOrigin17 === void 0 || (_item$_productOrigin17 = _item$_productOrigin17.duration) === null || _item$_productOrigin17 === void 0 ? void 0 : _item$_productOrigin17.value) !== null && _item$_productOrigin$5 !== void 0 ? _item$_productOrigin$5 : 0;
2249
+ var _item$_productOrigin14;
2250
+ if (accountDuration < (((_item$_productOrigin14 = item._productOrigin) === null || _item$_productOrigin14 === void 0 || (_item$_productOrigin14 = _item$_productOrigin14.duration) === null || _item$_productOrigin14 === void 0 ? void 0 : _item$_productOrigin14.value) || 10)) {
2251
+ var _item$_productOrigin15;
2252
+ accountDuration = ((_item$_productOrigin15 = item._productOrigin) === null || _item$_productOrigin15 === void 0 || (_item$_productOrigin15 = _item$_productOrigin15.duration) === null || _item$_productOrigin15 === void 0 ? void 0 : _item$_productOrigin15.value) || 10;
2250
2253
  }
2251
2254
  }
2252
2255
  });
@@ -2256,7 +2259,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2256
2259
  };
2257
2260
  if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
2258
2261
  accountList.forEach(function (account) {
2259
- var cartItems = _this10.store.cart.getCartByAccount(account.getId());
2262
+ var cartItems = _this11.store.cart.getCartByAccount(account.getId());
2260
2263
  checkDuration(cartItems);
2261
2264
  });
2262
2265
  } else {
@@ -2282,6 +2285,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2282
2285
  }];
2283
2286
  }
2284
2287
  var resourcesUseableMap = {};
2288
+ var hasFlexibleDuration = cartItems.some(function (item) {
2289
+ var _item$_productOrigin16;
2290
+ return ((_item$_productOrigin16 = item._productOrigin) === null || _item$_productOrigin16 === void 0 || (_item$_productOrigin16 = _item$_productOrigin16.duration) === null || _item$_productOrigin16 === void 0 ? void 0 : _item$_productOrigin16.type) === 'flexible';
2291
+ });
2292
+ 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;
2285
2293
  var timeSlots = getTimeSlicesByResources({
2286
2294
  resourceIds: resourceIds,
2287
2295
  resourcesMap: resourcesMap,
@@ -2289,21 +2297,27 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2289
2297
  currentDate: dateRange[0].date,
2290
2298
  split: 10,
2291
2299
  resourcesUseableMap: resourcesUseableMap,
2292
- cut_off_time: maxCutOffTime
2300
+ cut_off_time: maxCutOffTime,
2301
+ hasFlexibleDuration: hasFlexibleDuration,
2302
+ operating_day_boundary: operating_day_boundary
2293
2303
  });
2294
2304
  return timeSlots;
2295
2305
  }
2296
2306
 
2297
- // 提交时间切片,绑定到对应购物车的商品上,更新购物车
2307
+ // 提交时间切片,绑定到对应购物车的商品上,更新购物车---只有 duration 商品
2298
2308
  }, {
2299
2309
  key: "submitTimeSlot",
2300
2310
  value: function submitTimeSlot(timeSlots) {
2301
- var _this11 = this;
2311
+ var _this$shopStore$get2,
2312
+ _this12 = this;
2302
2313
  // 以账号为维度处理数据。购物车里每一项的 startTime应该是前一个商品的 endTime,如果是第一个商品则用 timeSlots.start_at
2303
2314
  var cartItems = this.store.cart.getItems().filter(function (n) {
2304
2315
  return !isNormalProduct(n._productOrigin);
2305
2316
  });
2306
2317
 
2318
+ // 取出所有资源列表
2319
+ var allResources = this.store.date.getResourcesListByDate(timeSlots.start_at.format('YYYY-MM-DD'));
2320
+
2307
2321
  // 按账号分组
2308
2322
  var itemsByAccount = cartItems.reduce(function (acc, item) {
2309
2323
  var holderId = item.holder_id;
@@ -2314,6 +2328,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2314
2328
  return acc;
2315
2329
  }, {});
2316
2330
 
2331
+ // 店铺营业结束时间
2332
+ 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;
2333
+
2317
2334
  // 处理每个账号的商品
2318
2335
  Object.values(itemsByAccount).forEach(function (accountItems) {
2319
2336
  var currentStartTime = timeSlots.start_at.format('YYYY-MM-DD HH:mm');
@@ -2321,12 +2338,41 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2321
2338
  var _newResources$;
2322
2339
  var newResources = cloneDeep(item._origin.resources);
2323
2340
  newResources.forEach(function (resource) {
2324
- var _item$_productOrigin$6, _item$_productOrigin18, _ref11, _item$_productOrigin19;
2325
- resource.startTime = currentStartTime;
2326
- resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$6 = (_item$_productOrigin18 = item._productOrigin) === null || _item$_productOrigin18 === void 0 || (_item$_productOrigin18 = _item$_productOrigin18.duration) === null || _item$_productOrigin18 === void 0 ? void 0 : _item$_productOrigin18.value) !== null && _item$_productOrigin$6 !== void 0 ? _item$_productOrigin$6 : 0, (_ref11 = (_item$_productOrigin19 = item._productOrigin) === null || _item$_productOrigin19 === void 0 || (_item$_productOrigin19 = _item$_productOrigin19.duration) === null || _item$_productOrigin19 === void 0 ? void 0 : _item$_productOrigin19.type) !== null && _ref11 !== void 0 ? _ref11 : 'minutes').format('YYYY-MM-DD HH:mm');
2327
- delete resource.times;
2341
+ var _item$_productOrigin17;
2342
+ // 如果商品配置的是灵活时长,开始时间设置为提交的时间,结束时间从资源的可用最晚时间和店铺营业结束时间里取一个最早的
2343
+ if (((_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') {
2344
+ var _allResources$find;
2345
+ item.duration = {
2346
+ type: 'minutes',
2347
+ value: 10
2348
+ };
2349
+ resource.startTime = timeSlots.start_at.format('YYYY-MM-DD HH:mm');
2350
+ // 找到resource.times里最早的end_at
2351
+ var targetResourceTimes = allResources === null || allResources === void 0 || (_allResources$find = allResources.find(function (n) {
2352
+ return n.id === resource.id;
2353
+ })) === null || _allResources$find === void 0 ? void 0 : _allResources$find.times;
2354
+ var resourcesEndTime = targetResourceTimes.reduce(function (acc, curr) {
2355
+ return dayjs(curr.end_at).isBefore(dayjs(acc.end_at)) ? curr : acc;
2356
+ }, targetResourceTimes[0]);
2357
+ var endTime = dayjs(resourcesEndTime.end_at).isBefore(dayjs(operating_day_boundary)) ? resourcesEndTime.end_at : operating_day_boundary;
2358
+ // 修复:如果 endTime 只是时间格式(如 "17:00"),需要加上日期
2359
+ var formattedEndTime;
2360
+ if (typeof endTime === 'string' && endTime.includes(':') && !endTime.includes(' ') && !endTime.includes('T')) {
2361
+ // 如果是纯时间格式,与当前日期合并
2362
+ var currentDate = timeSlots.start_at.format('YYYY-MM-DD');
2363
+ formattedEndTime = dayjs("".concat(currentDate, " ").concat(endTime));
2364
+ } else {
2365
+ formattedEndTime = dayjs(endTime);
2366
+ }
2367
+ resource.endTime = formattedEndTime.format('YYYY-MM-DD HH:mm');
2368
+ } else {
2369
+ var _item$_productOrigin18;
2370
+ resource.startTime = currentStartTime;
2371
+ resource.endTime = dayjs(currentStartTime).add(((_item$_productOrigin18 = item._productOrigin) === null || _item$_productOrigin18 === void 0 || (_item$_productOrigin18 = _item$_productOrigin18.duration) === null || _item$_productOrigin18 === void 0 ? void 0 : _item$_productOrigin18.value) || 10, 'minutes').format('YYYY-MM-DD HH:mm');
2372
+ }
2373
+ // delete resource.times;
2328
2374
  });
2329
- _this11.store.cart.updateItem({
2375
+ _this12.store.cart.updateItem({
2330
2376
  _id: item._id,
2331
2377
  resources: newResources
2332
2378
  });
@@ -2409,12 +2455,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2409
2455
  }
2410
2456
  }, {
2411
2457
  key: "getTimeslotBySchedule",
2412
- value: function getTimeslotBySchedule(_ref12) {
2458
+ value: function getTimeslotBySchedule(_ref9) {
2413
2459
  var _this$store$currentPr2, _targetProductData$pr;
2414
- var date = _ref12.date,
2415
- scheduleIds = _ref12.scheduleIds,
2416
- resources = _ref12.resources,
2417
- product = _ref12.product;
2460
+ var date = _ref9.date,
2461
+ scheduleIds = _ref9.scheduleIds,
2462
+ resources = _ref9.resources,
2463
+ product = _ref9.product;
2418
2464
  var targetProduct = this.store.currentProduct;
2419
2465
  // 如果外面传递了product 优先用外面的
2420
2466
  var targetProductData = product || (targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.getData());
@@ -2532,19 +2578,19 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2532
2578
  }
2533
2579
  }, {
2534
2580
  key: "addProductToCart",
2535
- value: function addProductToCart(_ref13) {
2536
- var _this12 = this;
2537
- var product = _ref13.product,
2538
- date = _ref13.date,
2539
- account = _ref13.account;
2540
- var _ref14 = product || {},
2541
- bundle = _ref14.bundle,
2542
- options = _ref14.options,
2543
- origin = _ref14.origin,
2544
- product_variant_id = _ref14.product_variant_id,
2545
- rowKey = _ref14.rowKey,
2546
- _ref14$quantity = _ref14.quantity,
2547
- quantity = _ref14$quantity === void 0 ? 1 : _ref14$quantity;
2581
+ value: function addProductToCart(_ref10) {
2582
+ var _this13 = this;
2583
+ var product = _ref10.product,
2584
+ date = _ref10.date,
2585
+ account = _ref10.account;
2586
+ var _ref11 = product || {},
2587
+ bundle = _ref11.bundle,
2588
+ options = _ref11.options,
2589
+ origin = _ref11.origin,
2590
+ product_variant_id = _ref11.product_variant_id,
2591
+ rowKey = _ref11.rowKey,
2592
+ _ref11$quantity = _ref11.quantity,
2593
+ quantity = _ref11$quantity === void 0 ? 1 : _ref11$quantity;
2548
2594
  var productData = _objectSpread(_objectSpread({}, origin), {}, {
2549
2595
  product_variant_id: product_variant_id
2550
2596
  });
@@ -2588,7 +2634,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2588
2634
  });
2589
2635
  if (cartItemsByDate.length) {
2590
2636
  cartItemsByDate.forEach(function (n) {
2591
- _this12.store.cart.removeItem(n._id);
2637
+ _this13.store.cart.removeItem(n._id);
2592
2638
  });
2593
2639
  }
2594
2640
  }
@@ -2652,7 +2698,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2652
2698
  }, {
2653
2699
  key: "getResourcesByCartItemAndCode",
2654
2700
  value: function getResourcesByCartItemAndCode(cartItemId, resourceCode) {
2655
- var _cartItem$_productOri11, _cartItem$_productOri12;
2701
+ var _cartItem$_productOri13, _cartItem$_productOri14;
2656
2702
  var dateRange = this.store.date.getDateRange();
2657
2703
  var resources = [];
2658
2704
  if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
@@ -2676,7 +2722,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2676
2722
  if (!cartItem) return [];
2677
2723
  var selectedResources = [];
2678
2724
  var formatCapacity = formatDefaultCapacitys({
2679
- capacity: (_cartItem$_productOri11 = cartItem._productOrigin) === null || _cartItem$_productOri11 === void 0 ? void 0 : _cartItem$_productOri11.capacity,
2725
+ capacity: (_cartItem$_productOri13 = cartItem._productOrigin) === null || _cartItem$_productOri13 === void 0 ? void 0 : _cartItem$_productOri13.capacity,
2680
2726
  product_bundle: cartItem._origin.product.product_bundle
2681
2727
  });
2682
2728
  cartItem._origin.metadata.capacity = formatCapacity;
@@ -2688,7 +2734,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2688
2734
  } else {
2689
2735
  selectedResources = getOthersCartSelectedResources(cartItems, cartItem._id, resourcesMap);
2690
2736
  }
2691
- var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri12 = cartItem._productOrigin) === null || _cartItem$_productOri12 === void 0 || (_cartItem$_productOri12 = _cartItem$_productOri12.product_resource) === null || _cartItem$_productOri12 === void 0 ? void 0 : _cartItem$_productOri12.resources) || [], selectedResources, currentCapacity);
2737
+ var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri14 = cartItem._productOrigin) === null || _cartItem$_productOri14 === void 0 || (_cartItem$_productOri14 = _cartItem$_productOri14.product_resource) === null || _cartItem$_productOri14 === void 0 ? void 0 : _cartItem$_productOri14.resources) || [], selectedResources, currentCapacity);
2692
2738
  var targetResource = productResources.find(function (resource) {
2693
2739
  return resource.code === resourceCode;
2694
2740
  });
@@ -2711,7 +2757,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2711
2757
  });
2712
2758
  if (mTimes.length === 0) return false;
2713
2759
  var canUseArr = mTimes.map(function (item) {
2714
- var _cartItem$_productOri13;
2760
+ var _cartItem$_productOri15;
2715
2761
  var res = getIsUsableByTimeItem({
2716
2762
  timeSlice: {
2717
2763
  start_time: startTime.format('HH:mm'),
@@ -2723,7 +2769,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2723
2769
  resource: m,
2724
2770
  currentCount: currentCapacity || 0,
2725
2771
  resourcesUseableMap: resourcesUseableMap,
2726
- cut_off_time: (_cartItem$_productOri13 = cartItem._productOrigin) === null || _cartItem$_productOri13 === void 0 ? void 0 : _cartItem$_productOri13.cut_off_time
2772
+ cut_off_time: (_cartItem$_productOri15 = cartItem._productOrigin) === null || _cartItem$_productOri15 === void 0 ? void 0 : _cartItem$_productOri15.cut_off_time
2727
2773
  });
2728
2774
  if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
2729
2775
  resourcesUseableMap[m.id] = res.usable;
@@ -2737,12 +2783,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2737
2783
  });
2738
2784
  } else {
2739
2785
  targetResource.renderList = targetResource.renderList.filter(function (n) {
2740
- var _cartItem$_productOri14;
2786
+ var _cartItem$_productOri16;
2741
2787
  var recordCount = n.capacity || 0;
2742
2788
  if (n.onlyComputed) return false;
2743
2789
  var timeSlots = getTimeSlicesByResource({
2744
2790
  resource: n,
2745
- duration: ((_cartItem$_productOri14 = cartItem._productOrigin) === null || _cartItem$_productOri14 === void 0 || (_cartItem$_productOri14 = _cartItem$_productOri14.duration) === null || _cartItem$_productOri14 === void 0 ? void 0 : _cartItem$_productOri14.value) || 0,
2791
+ duration: ((_cartItem$_productOri16 = cartItem._productOrigin) === null || _cartItem$_productOri16 === void 0 || (_cartItem$_productOri16 = _cartItem$_productOri16.duration) === null || _cartItem$_productOri16 === void 0 ? void 0 : _cartItem$_productOri16.value) || 10,
2746
2792
  split: 10,
2747
2793
  currentDate: dateRange[0].date
2748
2794
  });
@@ -2760,12 +2806,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2760
2806
  }, {
2761
2807
  key: "getTimeslotsScheduleByDateRange",
2762
2808
  value: (function () {
2763
- var _getTimeslotsScheduleByDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(_ref15) {
2809
+ var _getTimeslotsScheduleByDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(_ref12) {
2764
2810
  var startDate, endDate, scheduleIds, resources, dates, currentDate, end, results, _i, _dates, date;
2765
2811
  return _regeneratorRuntime().wrap(function _callee28$(_context29) {
2766
2812
  while (1) switch (_context29.prev = _context29.next) {
2767
2813
  case 0:
2768
- startDate = _ref15.startDate, endDate = _ref15.endDate, scheduleIds = _ref15.scheduleIds, resources = _ref15.resources;
2814
+ startDate = _ref12.startDate, endDate = _ref12.endDate, scheduleIds = _ref12.scheduleIds, resources = _ref12.resources;
2769
2815
  console.log('appoimentBooking-session-date-getTimeslotsScheduleByDateRange', {
2770
2816
  startDate: startDate,
2771
2817
  endDate: endDate,
@@ -2811,7 +2857,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2811
2857
  endDate,
2812
2858
  type,
2813
2859
  tempProducts,
2814
- _ref16,
2860
+ _ref13,
2815
2861
  resourceIds,
2816
2862
  rules,
2817
2863
  resourcesMap,
@@ -2837,7 +2883,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2837
2883
  })];
2838
2884
  }
2839
2885
  // 在这里需要把能收集到的数据都收集上来,拼装好给 date 模块去查询
2840
- _ref16 = getAvailableProductResources(tempProducts) || {}, resourceIds = _ref16.resourceIds, rules = _ref16.rules, resourcesMap = _ref16.resourcesMap;
2886
+ _ref13 = getAvailableProductResources(tempProducts) || {}, resourceIds = _ref13.resourceIds, rules = _ref13.rules, resourcesMap = _ref13.resourcesMap;
2841
2887
  this.otherParams.currentResourcesMap = resourcesMap;
2842
2888
  _context30.next = 10;
2843
2889
  return this.store.date.getResourceDates({
@@ -79,7 +79,7 @@ export declare const formatResources: ({ booking, resources, }: {
79
79
  * @return {*}
80
80
  * @Author: zhiwei.Wang
81
81
  */
82
- export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate, capacity, resourcesUseableMap, cut_off_time, }: {
82
+ export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate, capacity, resourcesUseableMap, cut_off_time, hasFlexibleDuration, operating_day_boundary }: {
83
83
  resource: ResourceItem;
84
84
  duration: number;
85
85
  split: number;
@@ -96,6 +96,8 @@ export declare const getTimeSlicesByResource: ({ resource, duration, split, curr
96
96
  unit: number;
97
97
  } | undefined;
98
98
  } | undefined;
99
+ hasFlexibleDuration?: boolean | undefined;
100
+ operating_day_boundary?: string | undefined;
99
101
  }) => TimeSliceItem[];
100
102
  /**
101
103
  * @title: 获取时间切片列表的交集
@@ -133,7 +135,7 @@ export declare const mergeSubResourcesTimeSlices: (resources: ResourceItem[], re
133
135
  * @return {*}
134
136
  * @Author: zhiwei.Wang
135
137
  */
136
- export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split, capacity, resourcesUseableMap, cut_off_time, }: {
138
+ export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split, capacity, resourcesUseableMap, cut_off_time, hasFlexibleDuration, operating_day_boundary }: {
137
139
  resourceIds: number[];
138
140
  resourcesMap: any;
139
141
  duration: number;
@@ -151,6 +153,8 @@ export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, dur
151
153
  unit: number;
152
154
  } | undefined;
153
155
  } | undefined;
156
+ hasFlexibleDuration?: boolean | undefined;
157
+ operating_day_boundary?: string | undefined;
154
158
  }) => any[];
155
159
  /**
156
160
  * @title: 获取其他人的已选资源
@@ -415,7 +415,9 @@ export var getTimeSlicesByResource = function getTimeSlicesByResource(_ref5) {
415
415
  capacity = _ref5.capacity,
416
416
  _ref5$resourcesUseabl = _ref5.resourcesUseableMap,
417
417
  resourcesUseableMap = _ref5$resourcesUseabl === void 0 ? {} : _ref5$resourcesUseabl,
418
- cut_off_time = _ref5.cut_off_time;
418
+ cut_off_time = _ref5.cut_off_time,
419
+ hasFlexibleDuration = _ref5.hasFlexibleDuration,
420
+ operating_day_boundary = _ref5.operating_day_boundary;
419
421
  var times = resource.times;
420
422
 
421
423
  // 存储所有时间切片
@@ -424,7 +426,7 @@ export var getTimeSlicesByResource = function getTimeSlicesByResource(_ref5) {
424
426
  // 处理每个时间范围
425
427
  times.forEach(function (time) {
426
428
  // 创建今天的日期字符串,用于构建完整的日期时间
427
- var today = dayjs(currentDate).format('YYYY-MM-DD');
429
+ // const today = dayjs(currentDate).format('YYYY-MM-DD');
428
430
 
429
431
  // 解析开始和结束时间
430
432
  var startTime = dayjs("".concat(time.start_at));
@@ -460,6 +462,10 @@ export var getTimeSlicesByResource = function getTimeSlicesByResource(_ref5) {
460
462
  resourcesUseableMap[resource.id] = _status.usable;
461
463
  }
462
464
  if (_status.usable) {
465
+ // 如果有hasFlexibleDuration,且timeSlice.start_at 大于等于operating_day_boundary,则不添加时间切片
466
+ if (hasFlexibleDuration && operating_day_boundary && timeSlice.start_time >= operating_day_boundary) {
467
+ break;
468
+ }
463
469
  // 添加时间切片 09:00 ~ 10:00 09:20 ~ 10:20 09:00 ~ 10:00 09:20 ~ 10:20 11:00 ~ 12:00 11:20 ~ 12:20
464
470
  timeSlices.push(_objectSpread(_objectSpread({}, timeSlice), {}, {
465
471
  // 这里需要补充这个时间段内是否可预约
@@ -565,7 +571,9 @@ export var getTimeSlicesByResources = function getTimeSlicesByResources(_ref6) {
565
571
  split = _ref6.split,
566
572
  capacity = _ref6.capacity,
567
573
  resourcesUseableMap = _ref6.resourcesUseableMap,
568
- cut_off_time = _ref6.cut_off_time;
574
+ cut_off_time = _ref6.cut_off_time,
575
+ hasFlexibleDuration = _ref6.hasFlexibleDuration,
576
+ operating_day_boundary = _ref6.operating_day_boundary;
569
577
  // 获取资源列表
570
578
  var resources = getResourcesByIds(resourcesMap, resourceIds);
571
579
  mergeSubResourcesTimeSlices(resources, resourcesMap);
@@ -588,7 +596,9 @@ export var getTimeSlicesByResources = function getTimeSlicesByResources(_ref6) {
588
596
  currentDate: currentDate,
589
597
  capacity: capacity,
590
598
  resourcesUseableMap: resourcesUseableMap,
591
- cut_off_time: cut_off_time
599
+ cut_off_time: cut_off_time,
600
+ hasFlexibleDuration: hasFlexibleDuration,
601
+ operating_day_boundary: operating_day_boundary
592
602
  }));
593
603
  }, []);
594
604
 
@@ -20,4 +20,5 @@ export declare class DateModule extends BaseModule implements Module, DateModule
20
20
  getResourceAvailableTimeList(params: IGetAvailableTimeListParams): Promise<ITime[]>;
21
21
  clearDateRange(): void;
22
22
  storeChange(): void;
23
+ getResourcesListByDate(date: string): any[] | undefined;
23
24
  }
@@ -125,6 +125,12 @@ var DateModule = class extends import_BaseModule.BaseModule {
125
125
  });
126
126
  }
127
127
  }
128
+ getResourcesListByDate(date) {
129
+ var _a;
130
+ const dateList = this.store.dateList;
131
+ const resourcesList = (_a = dateList.find((item) => item.date === date)) == null ? void 0 : _a.resource;
132
+ return resourcesList;
133
+ }
128
134
  };
129
135
  // Annotate the CommonJS export names for ESM import in node:
130
136
  0 && (module.exports = {
@@ -69,6 +69,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
69
69
  if (!this.request) {
70
70
  throw new Error("bookingByStep解决方案需要 request 插件支持");
71
71
  }
72
+ if (!this.shopStore) {
73
+ throw new Error("SummaryModule 需要 shopStore 插件支持");
74
+ }
72
75
  let targetCacheData = {};
73
76
  this.cacheId = (_a = this.otherParams) == null ? void 0 : _a.cacheId;
74
77
  if ((_b = this.otherParams) == null ? void 0 : _b.cacheId) {
@@ -821,7 +824,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
821
824
  const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
822
825
  const arr = [];
823
826
  cartItems.forEach((cartItem) => {
824
- var _a, _b, _c;
827
+ var _a, _b, _c, _d, _e, _f, _g, _h;
825
828
  let selectedResources = [];
826
829
  const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
827
830
  capacity: (_a = cartItem._productOrigin) == null ? void 0 : _a.capacity,
@@ -858,9 +861,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
858
861
  const resourcesUseableMap = {};
859
862
  productResources.forEach((n) => {
860
863
  n.renderList = n.renderList.sort((a, b) => {
861
- var _a2, _b2, _c2, _d;
864
+ var _a2, _b2, _c2, _d2;
862
865
  const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
863
- const bIsCombined = ((_d = (_c2 = b.metadata) == null ? void 0 : _c2.combined_resource) == null ? void 0 : _d.status) === 1;
866
+ const bIsCombined = ((_d2 = (_c2 = b.metadata) == null ? void 0 : _c2.combined_resource) == null ? void 0 : _d2.status) === 1;
864
867
  if (aIsCombined && !bIsCombined)
865
868
  return 1;
866
869
  if (!aIsCombined && bIsCombined)
@@ -900,17 +903,22 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
900
903
  });
901
904
  });
902
905
  } else {
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;
903
908
  productResources.forEach((item) => {
904
909
  item.renderList = item.renderList.filter((n) => {
905
- var _a2, _b2;
910
+ var _a2, _b2, _c2;
906
911
  const recordCount = n.capacity || 0;
907
912
  if (n.onlyComputed)
908
913
  return false;
909
914
  const timeSlots = (0, import_resources.getTimeSlicesByResource)({
910
915
  resource: n,
911
- duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 0,
916
+ duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10,
912
917
  split: 10,
913
- currentDate: dateRange[0].date
918
+ currentDate: dateRange[0].date,
919
+ hasFlexibleDuration,
920
+ cut_off_time: (_c2 = cartItem._productOrigin) == null ? void 0 : _c2.cut_off_time,
921
+ operating_day_boundary
914
922
  });
915
923
  return recordCount >= currentCapacity && timeSlots.length > 0;
916
924
  });
@@ -1037,7 +1045,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1037
1045
  return false;
1038
1046
  const timeSlots = (0, import_resources.getTimeSlicesByResource)({
1039
1047
  resource: n,
1040
- duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 0,
1048
+ duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10,
1041
1049
  split: 10,
1042
1050
  currentDate: dateRange[0].date
1043
1051
  });
@@ -1155,7 +1163,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1155
1163
  }
1156
1164
  let duration = accountCartItems.reduce((acc, n) => {
1157
1165
  var _a2, _b2;
1158
- return acc + (((_b2 = (_a2 = n._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) ?? 0);
1166
+ return acc + (((_b2 = (_a2 = n._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10);
1159
1167
  }, 0);
1160
1168
  let AllResources = [];
1161
1169
  if (dateRange == null ? void 0 : dateRange.length) {
@@ -1287,7 +1295,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1287
1295
  const selectForCartResources = (cartItems2) => {
1288
1296
  let recordTimeSlots = (0, import_lodash_es.cloneDeep)(timeSlots);
1289
1297
  cartItems2.forEach((item, index) => {
1290
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
1298
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
1291
1299
  const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
1292
1300
  capacity: (_a2 = item._productOrigin) == null ? void 0 : _a2.capacity,
1293
1301
  product_bundle: item._origin.product.product_bundle
@@ -1308,12 +1316,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1308
1316
  const resourceBookingType = (currentResourceConfig == null ? void 0 : currentResourceConfig.type) || "single";
1309
1317
  if (index !== 0 && recordTimeSlots && resourceBookingType === "single" && ((_e = item._productOrigin) == null ? void 0 : _e.duration)) {
1310
1318
  let start_at = (0, import_dayjs.default)(recordTimeSlots.end_time).add(
1311
- ((_g = (_f = item._productOrigin) == null ? void 0 : _f.duration) == null ? void 0 : _g.value) ?? 0,
1312
- ((_i = (_h = item._productOrigin) == null ? void 0 : _h.duration) == null ? void 0 : _i.type) ?? "minutes"
1319
+ ((_g = (_f = item._productOrigin) == null ? void 0 : _f.duration) == null ? void 0 : _g.value) || 10,
1320
+ "minutes"
1313
1321
  );
1314
1322
  let end_at = start_at.add(
1315
- ((_k = (_j = item._productOrigin) == null ? void 0 : _j.duration) == null ? void 0 : _k.value) ?? 0,
1316
- ((_m = (_l = item._productOrigin) == null ? void 0 : _l.duration) == null ? void 0 : _m.type) ?? "minutes"
1323
+ ((_i = (_h = item._productOrigin) == null ? void 0 : _h.duration) == null ? void 0 : _i.value) || 10,
1324
+ "minutes"
1317
1325
  );
1318
1326
  recordTimeSlots = {
1319
1327
  start_time: start_at.format("HH:mm"),
@@ -1366,7 +1374,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1366
1374
  const allCartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
1367
1375
  let selectedResources = [];
1368
1376
  const resources2 = (0, import_lodash_es.cloneDeep)(
1369
- ((_o = (_n = item._productOrigin) == null ? void 0 : _n.product_resource) == null ? void 0 : _o.resources) || []
1377
+ ((_k = (_j = item._productOrigin) == null ? void 0 : _j.product_resource) == null ? void 0 : _k.resources) || []
1370
1378
  );
1371
1379
  const currentResourcesRenderList = [];
1372
1380
  resources2.forEach((n) => {
@@ -1377,7 +1385,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1377
1385
  const recordCount = (m.capacity || 0) - (selectResourcesMap[m.id] || 0);
1378
1386
  const timeSlots2 = (0, import_resources.getTimeSlicesByResource)({
1379
1387
  resource: m,
1380
- duration: ((_a4 = item == null ? void 0 : item.duration) == null ? void 0 : _a4.value) || 0,
1388
+ duration: ((_a4 = item == null ? void 0 : item.duration) == null ? void 0 : _a4.value) || 10,
1381
1389
  split: 10,
1382
1390
  currentDate: dateRange[0].date
1383
1391
  });
@@ -1414,11 +1422,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1414
1422
  return recordCount >= currentCapacity;
1415
1423
  });
1416
1424
  });
1417
- const targetRenderList = (_p = productResources.find(
1425
+ const targetRenderList = (_l = productResources.find(
1418
1426
  (n) => n.code === resources_code
1419
- )) == null ? void 0 : _p.renderList;
1427
+ )) == null ? void 0 : _l.renderList;
1420
1428
  if (targetRenderList && targetRenderList.length > 0) {
1421
- if ((_q = item._origin.resources) == null ? void 0 : _q.some(
1429
+ if ((_m = item._origin.resources) == null ? void 0 : _m.some(
1422
1430
  (n) => n.form_id === targetRenderList[0].form_id
1423
1431
  )) {
1424
1432
  return;
@@ -1464,7 +1472,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1464
1472
  }
1465
1473
  // 从购物车中获取已经分配好第一步资源的所有时间片
1466
1474
  getTimeSlotByAllResources(resources_code) {
1467
- var _a, _b, _c, _d, _e, _f;
1475
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
1468
1476
  let dateRange = this.store.date.getDateRange();
1469
1477
  const resources = [];
1470
1478
  const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
@@ -1474,7 +1482,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1474
1482
  let maxCutOffTime = void 0;
1475
1483
  let maxCutOffTimeValue = (0, import_dayjs.default)();
1476
1484
  cartItems.forEach((item) => {
1477
- var _a2, _b2, _c2, _d2, _e2, _f2, _g, _h, _i;
1485
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2;
1478
1486
  (_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.forEach((n) => {
1479
1487
  if (n.code === resources_code) {
1480
1488
  resources.push(...n.renderList || []);
@@ -1484,10 +1492,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1484
1492
  if (item.resource_id) {
1485
1493
  resourceIds.push(item.resource_id);
1486
1494
  }
1487
- resourcesTypeId = (_g = (_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(
1495
+ 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(
1488
1496
  (n) => n.code === resources_code
1489
- )) == null ? void 0 : _g.id;
1490
- if (((_h = item._productOrigin) == null ? void 0 : _h.cut_off_time) && ((_i = item._productOrigin) == null ? void 0 : _i.cut_off_time.type) === "advance") {
1497
+ )) == null ? void 0 : _g2.id;
1498
+ if (((_h2 = item._productOrigin) == null ? void 0 : _h2.cut_off_time) && ((_i2 = item._productOrigin) == null ? void 0 : _i2.cut_off_time.type) === "advance") {
1491
1499
  const currentCutOffTime = (0, import_dayjs.default)().add(
1492
1500
  item._productOrigin.cut_off_time.unit,
1493
1501
  item._productOrigin.cut_off_time.unit_type
@@ -1513,10 +1521,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1513
1521
  cartItems2.forEach((item) => {
1514
1522
  var _a2, _b2, _c2, _d2, _e2, _f2;
1515
1523
  if (isSingleResource) {
1516
- accountDuration += ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) ?? 0;
1524
+ accountDuration += ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10;
1517
1525
  } else {
1518
- if (accountDuration < (((_d2 = (_c2 = item._productOrigin) == null ? void 0 : _c2.duration) == null ? void 0 : _d2.value) ?? 0)) {
1519
- accountDuration = ((_f2 = (_e2 = item._productOrigin) == null ? void 0 : _e2.duration) == null ? void 0 : _f2.value) ?? 0;
1526
+ if (accountDuration < (((_d2 = (_c2 = item._productOrigin) == null ? void 0 : _c2.duration) == null ? void 0 : _d2.value) || 10)) {
1527
+ accountDuration = ((_f2 = (_e2 = item._productOrigin) == null ? void 0 : _e2.duration) == null ? void 0 : _f2.value) || 10;
1520
1528
  }
1521
1529
  }
1522
1530
  });
@@ -1552,6 +1560,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1552
1560
  ];
1553
1561
  }
1554
1562
  const resourcesUseableMap = {};
1563
+ const hasFlexibleDuration = cartItems.some((item) => {
1564
+ var _a2, _b2;
1565
+ return ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.type) === "flexible";
1566
+ });
1567
+ 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;
1555
1568
  const timeSlots = (0, import_resources.getTimeSlicesByResources)({
1556
1569
  resourceIds,
1557
1570
  resourcesMap,
@@ -1559,13 +1572,17 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1559
1572
  currentDate: dateRange[0].date,
1560
1573
  split: 10,
1561
1574
  resourcesUseableMap,
1562
- cut_off_time: maxCutOffTime
1575
+ cut_off_time: maxCutOffTime,
1576
+ hasFlexibleDuration,
1577
+ operating_day_boundary
1563
1578
  });
1564
1579
  return timeSlots;
1565
1580
  }
1566
- // 提交时间切片,绑定到对应购物车的商品上,更新购物车
1581
+ // 提交时间切片,绑定到对应购物车的商品上,更新购物车---只有 duration 商品
1567
1582
  submitTimeSlot(timeSlots) {
1583
+ var _a, _b, _c;
1568
1584
  const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
1585
+ const allResources = this.store.date.getResourcesListByDate(timeSlots.start_at.format("YYYY-MM-DD"));
1569
1586
  const itemsByAccount = cartItems.reduce(
1570
1587
  (acc, item) => {
1571
1588
  const holderId = item.holder_id;
@@ -1577,25 +1594,46 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1577
1594
  },
1578
1595
  {}
1579
1596
  );
1597
+ 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;
1580
1598
  Object.values(itemsByAccount).forEach((accountItems) => {
1581
1599
  let currentStartTime = timeSlots.start_at.format("YYYY-MM-DD HH:mm");
1582
1600
  accountItems.forEach((item, index) => {
1583
- var _a;
1601
+ var _a2;
1584
1602
  const newResources = (0, import_lodash_es.cloneDeep)(item._origin.resources);
1585
1603
  newResources.forEach((resource) => {
1586
- var _a2, _b, _c, _d;
1587
- resource.startTime = currentStartTime;
1588
- resource.endTime = (0, import_dayjs.default)(currentStartTime).add(
1589
- ((_b = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b.value) ?? 0,
1590
- ((_d = (_c = item._productOrigin) == null ? void 0 : _c.duration) == null ? void 0 : _d.type) ?? "minutes"
1591
- ).format("YYYY-MM-DD HH:mm");
1592
- delete resource.times;
1604
+ var _a3, _b2, _c2, _d, _e;
1605
+ if (((_b2 = (_a3 = item._productOrigin) == null ? void 0 : _a3.duration) == null ? void 0 : _b2.type) === "flexible") {
1606
+ item.duration = {
1607
+ type: "minutes",
1608
+ value: 10
1609
+ };
1610
+ resource.startTime = timeSlots.start_at.format("YYYY-MM-DD HH:mm");
1611
+ const targetResourceTimes = (_c2 = allResources == null ? void 0 : allResources.find((n) => n.id === resource.id)) == null ? void 0 : _c2.times;
1612
+ const resourcesEndTime = targetResourceTimes.reduce((acc, curr) => {
1613
+ return (0, import_dayjs.default)(curr.end_at).isBefore((0, import_dayjs.default)(acc.end_at)) ? curr : acc;
1614
+ }, targetResourceTimes[0]);
1615
+ const endTime = (0, import_dayjs.default)(resourcesEndTime.end_at).isBefore((0, import_dayjs.default)(operating_day_boundary)) ? resourcesEndTime.end_at : operating_day_boundary;
1616
+ let formattedEndTime;
1617
+ if (typeof endTime === "string" && endTime.includes(":") && !endTime.includes(" ") && !endTime.includes("T")) {
1618
+ const currentDate = timeSlots.start_at.format("YYYY-MM-DD");
1619
+ formattedEndTime = (0, import_dayjs.default)(`${currentDate} ${endTime}`);
1620
+ } else {
1621
+ formattedEndTime = (0, import_dayjs.default)(endTime);
1622
+ }
1623
+ resource.endTime = formattedEndTime.format("YYYY-MM-DD HH:mm");
1624
+ } else {
1625
+ resource.startTime = currentStartTime;
1626
+ resource.endTime = (0, import_dayjs.default)(currentStartTime).add(
1627
+ ((_e = (_d = item._productOrigin) == null ? void 0 : _d.duration) == null ? void 0 : _e.value) || 10,
1628
+ "minutes"
1629
+ ).format("YYYY-MM-DD HH:mm");
1630
+ }
1593
1631
  });
1594
1632
  this.store.cart.updateItem({
1595
1633
  _id: item._id,
1596
1634
  resources: newResources
1597
1635
  });
1598
- if (index < accountItems.length - 1 && ((_a = newResources == null ? void 0 : newResources[0]) == null ? void 0 : _a.resourceType) === "single") {
1636
+ if (index < accountItems.length - 1 && ((_a2 = newResources == null ? void 0 : newResources[0]) == null ? void 0 : _a2.resourceType) === "single") {
1599
1637
  currentStartTime = newResources[0].endTime;
1600
1638
  }
1601
1639
  });
@@ -1940,7 +1978,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1940
1978
  return false;
1941
1979
  const timeSlots = (0, import_resources.getTimeSlicesByResource)({
1942
1980
  resource: n,
1943
- duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 0,
1981
+ duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10,
1944
1982
  split: 10,
1945
1983
  currentDate: dateRange[0].date
1946
1984
  });
@@ -79,7 +79,7 @@ export declare const formatResources: ({ booking, resources, }: {
79
79
  * @return {*}
80
80
  * @Author: zhiwei.Wang
81
81
  */
82
- export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate, capacity, resourcesUseableMap, cut_off_time, }: {
82
+ export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate, capacity, resourcesUseableMap, cut_off_time, hasFlexibleDuration, operating_day_boundary }: {
83
83
  resource: ResourceItem;
84
84
  duration: number;
85
85
  split: number;
@@ -96,6 +96,8 @@ export declare const getTimeSlicesByResource: ({ resource, duration, split, curr
96
96
  unit: number;
97
97
  } | undefined;
98
98
  } | undefined;
99
+ hasFlexibleDuration?: boolean | undefined;
100
+ operating_day_boundary?: string | undefined;
99
101
  }) => TimeSliceItem[];
100
102
  /**
101
103
  * @title: 获取时间切片列表的交集
@@ -133,7 +135,7 @@ export declare const mergeSubResourcesTimeSlices: (resources: ResourceItem[], re
133
135
  * @return {*}
134
136
  * @Author: zhiwei.Wang
135
137
  */
136
- export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split, capacity, resourcesUseableMap, cut_off_time, }: {
138
+ export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split, capacity, resourcesUseableMap, cut_off_time, hasFlexibleDuration, operating_day_boundary }: {
137
139
  resourceIds: number[];
138
140
  resourcesMap: any;
139
141
  duration: number;
@@ -151,6 +153,8 @@ export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, dur
151
153
  unit: number;
152
154
  } | undefined;
153
155
  } | undefined;
156
+ hasFlexibleDuration?: boolean | undefined;
157
+ operating_day_boundary?: string | undefined;
154
158
  }) => any[];
155
159
  /**
156
160
  * @title: 获取其他人的已选资源
@@ -333,12 +333,13 @@ var getTimeSlicesByResource = ({
333
333
  currentDate = (0, import_dayjs.default)(),
334
334
  capacity,
335
335
  resourcesUseableMap = {},
336
- cut_off_time
336
+ cut_off_time,
337
+ hasFlexibleDuration,
338
+ operating_day_boundary
337
339
  }) => {
338
340
  const { times } = resource;
339
341
  const timeSlices = [];
340
342
  times.forEach((time) => {
341
- const today = (0, import_dayjs.default)(currentDate).format("YYYY-MM-DD");
342
343
  const startTime = (0, import_dayjs.default)(`${time.start_at}`);
343
344
  const endTime = (0, import_dayjs.default)(`${time.end_at}`);
344
345
  let currentStart = startTime;
@@ -365,6 +366,9 @@ var getTimeSlicesByResource = ({
365
366
  resourcesUseableMap[resource.id] = _status.usable;
366
367
  }
367
368
  if (_status.usable) {
369
+ if (hasFlexibleDuration && operating_day_boundary && timeSlice.start_time >= operating_day_boundary) {
370
+ break;
371
+ }
368
372
  timeSlices.push({
369
373
  ...timeSlice,
370
374
  // 这里需要补充这个时间段内是否可预约
@@ -422,7 +426,9 @@ var getTimeSlicesByResources = ({
422
426
  split,
423
427
  capacity,
424
428
  resourcesUseableMap,
425
- cut_off_time
429
+ cut_off_time,
430
+ hasFlexibleDuration,
431
+ operating_day_boundary
426
432
  }) => {
427
433
  let resources = getResourcesByIds(resourcesMap, resourceIds);
428
434
  mergeSubResourcesTimeSlices(resources, resourcesMap);
@@ -446,7 +452,9 @@ var getTimeSlicesByResources = ({
446
452
  currentDate,
447
453
  capacity,
448
454
  resourcesUseableMap,
449
- cut_off_time
455
+ cut_off_time,
456
+ hasFlexibleDuration,
457
+ operating_day_boundary
450
458
  })
451
459
  );
452
460
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.127",
4
+ "version": "0.0.128",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",