@pisell/pisellos 3.0.39 → 3.0.41
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.
- package/dist/modules/Date/index.d.ts +1 -0
- package/dist/modules/Date/index.js +10 -0
- package/dist/solution/BookingByStep/index.js +164 -106
- package/dist/solution/BookingByStep/utils/resources.d.ts +12 -2
- package/dist/solution/BookingByStep/utils/resources.js +15 -4
- package/lib/modules/Date/index.d.ts +1 -0
- package/lib/modules/Date/index.js +6 -0
- package/lib/solution/BookingByStep/index.js +89 -41
- package/lib/solution/BookingByStep/utils/resources.d.ts +12 -2
- package/lib/solution/BookingByStep/utils/resources.js +13 -4
- package/package.json +1 -1
|
@@ -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
|
|
129
|
+
case 18:
|
|
124
130
|
case "end":
|
|
125
131
|
return _context.stop();
|
|
126
132
|
}
|
|
@@ -273,7 +279,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
273
279
|
value: function () {
|
|
274
280
|
var _loadProductByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref2) {
|
|
275
281
|
var _schedule$product_ids;
|
|
276
|
-
var date, _ref2$product_ids, product_ids, _ref2$category_ids, category_ids, scheduleList, schedule, otherProductsIds, allProductIds;
|
|
282
|
+
var date, _ref2$product_ids, product_ids, _ref2$category_ids, category_ids, scheduleList, newProductIds, schedule, otherProductsIds, allProductIds;
|
|
277
283
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
278
284
|
while (1) switch (_context3.prev = _context3.next) {
|
|
279
285
|
case 0:
|
|
@@ -290,11 +296,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
290
296
|
week: '',
|
|
291
297
|
weekNum: 0
|
|
292
298
|
}]);
|
|
293
|
-
// const scheduleIds = scheduleList
|
|
299
|
+
newProductIds = []; // const scheduleIds = scheduleList
|
|
294
300
|
// .filter((n) => n.date === date)
|
|
295
301
|
// .flatMap((n) => n.schedule_id)
|
|
296
302
|
// .filter((n) => n !== null && n !== undefined);
|
|
297
|
-
|
|
298
303
|
// 如果外面没传 product_ids,尝试从对应 schedule 里拿 product_ids
|
|
299
304
|
// if (!product_ids?.length) {
|
|
300
305
|
// const schedule = scheduleList.find((n) => n.date === date);
|
|
@@ -307,23 +312,23 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
307
312
|
return n.date === date;
|
|
308
313
|
});
|
|
309
314
|
if (schedule && (_schedule$product_ids = schedule.product_ids) !== null && _schedule$product_ids !== void 0 && _schedule$product_ids.length) {
|
|
310
|
-
|
|
315
|
+
newProductIds = schedule.product_ids;
|
|
311
316
|
}
|
|
312
317
|
// 尝试去拿schedule 里的 other_product_ids 和 product_ids 拼在一起去重
|
|
313
318
|
otherProductsIds = this.store.schedule.getOtherProductsIds() || [];
|
|
314
|
-
allProductIds = [].concat(_toConsumableArray(
|
|
319
|
+
allProductIds = [].concat(_toConsumableArray(newProductIds), _toConsumableArray(otherProductsIds)).filter(function (n, index, self) {
|
|
315
320
|
return self.indexOf(n) === index;
|
|
316
321
|
});
|
|
317
|
-
_context3.next =
|
|
322
|
+
_context3.next = 10;
|
|
318
323
|
return this.loadProducts({
|
|
319
324
|
// schedule_ids: scheduleIds,
|
|
320
325
|
product_ids: allProductIds,
|
|
321
326
|
category_ids: category_ids,
|
|
322
327
|
schedule_date: date
|
|
323
328
|
});
|
|
324
|
-
case 9:
|
|
325
|
-
return _context3.abrupt("return", _context3.sent);
|
|
326
329
|
case 10:
|
|
330
|
+
return _context3.abrupt("return", _context3.sent);
|
|
331
|
+
case 11:
|
|
327
332
|
case "end":
|
|
328
333
|
return _context3.stop();
|
|
329
334
|
}
|
|
@@ -1468,6 +1473,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1468
1473
|
}, {
|
|
1469
1474
|
key: "getResourcesList",
|
|
1470
1475
|
value: function getResourcesList() {
|
|
1476
|
+
var _this9 = this;
|
|
1471
1477
|
var dateRange = this.store.date.getDateRange();
|
|
1472
1478
|
var resources = [];
|
|
1473
1479
|
if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
|
|
@@ -1559,19 +1565,25 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1559
1565
|
});
|
|
1560
1566
|
});
|
|
1561
1567
|
} else {
|
|
1568
|
+
var _cartItem$_productOri4, _this9$shopStore$get;
|
|
1569
|
+
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';
|
|
1570
|
+
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;
|
|
1562
1571
|
productResources.forEach(function (item) {
|
|
1563
1572
|
// 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
|
|
1564
1573
|
// 同时,在这一步尝试去拉一下时间片,基于商品的时长,看每个资源是否还有空余时间能对这个商品做服务,如果没有则过滤
|
|
1565
1574
|
item.renderList = item.renderList.filter(function (n) {
|
|
1566
|
-
var _cartItem$
|
|
1575
|
+
var _cartItem$_productOri5, _cartItem$_productOri6;
|
|
1567
1576
|
var recordCount = n.capacity || 0;
|
|
1568
1577
|
if (n.onlyComputed) return false;
|
|
1569
1578
|
// 查一下这个资源基于商品的可用时间片
|
|
1570
1579
|
var timeSlots = getTimeSlicesByResource({
|
|
1571
1580
|
resource: n,
|
|
1572
|
-
duration: ((_cartItem$
|
|
1581
|
+
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
1582
|
split: 10,
|
|
1574
|
-
currentDate: dateRange[0].date
|
|
1583
|
+
currentDate: dateRange[0].date,
|
|
1584
|
+
hasFlexibleDuration: hasFlexibleDuration,
|
|
1585
|
+
cut_off_time: (_cartItem$_productOri6 = cartItem._productOrigin) === null || _cartItem$_productOri6 === void 0 ? void 0 : _cartItem$_productOri6.cut_off_time,
|
|
1586
|
+
operating_day_boundary: operating_day_boundary
|
|
1575
1587
|
});
|
|
1576
1588
|
return recordCount >= currentCapacity && timeSlots.length > 0;
|
|
1577
1589
|
});
|
|
@@ -1615,10 +1627,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1615
1627
|
});
|
|
1616
1628
|
var arr = [];
|
|
1617
1629
|
cartItems.forEach(function (cartItem) {
|
|
1618
|
-
var _cartItem$
|
|
1630
|
+
var _cartItem$_productOri7, _cartItem$_productOri8;
|
|
1619
1631
|
var selectedResources = [];
|
|
1620
1632
|
var formatCapacity = formatDefaultCapacitys({
|
|
1621
|
-
capacity: (_cartItem$
|
|
1633
|
+
capacity: (_cartItem$_productOri7 = cartItem._productOrigin) === null || _cartItem$_productOri7 === void 0 ? void 0 : _cartItem$_productOri7.capacity,
|
|
1622
1634
|
product_bundle: cartItem._origin.product.product_bundle
|
|
1623
1635
|
});
|
|
1624
1636
|
cartItem._origin.metadata.capacity = formatCapacity;
|
|
@@ -1630,7 +1642,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1630
1642
|
} else {
|
|
1631
1643
|
selectedResources = getOthersCartSelectedResources(cartItems, cartItem._id, resourcesMap);
|
|
1632
1644
|
}
|
|
1633
|
-
var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$
|
|
1645
|
+
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
1646
|
// 如果购物车里已经有了时间片,则需要按照时间片过滤
|
|
1635
1647
|
if (cartItem._origin.start_time) {
|
|
1636
1648
|
var startTime = dayjs("".concat(cartItem._origin.start_date, " ").concat(cartItem._origin.start_time));
|
|
@@ -1658,7 +1670,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1658
1670
|
return false;
|
|
1659
1671
|
}
|
|
1660
1672
|
var canUseArr = mTimes.map(function (item) {
|
|
1661
|
-
var _cartItem$
|
|
1673
|
+
var _cartItem$_productOri9;
|
|
1662
1674
|
var res = getIsUsableByTimeItem({
|
|
1663
1675
|
timeSlice: {
|
|
1664
1676
|
start_time: startTime.format('HH:mm'),
|
|
@@ -1670,7 +1682,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1670
1682
|
resource: m,
|
|
1671
1683
|
currentCount: currentCapacity || 0,
|
|
1672
1684
|
resourcesUseableMap: resourcesUseableMap,
|
|
1673
|
-
cut_off_time: (_cartItem$
|
|
1685
|
+
cut_off_time: (_cartItem$_productOri9 = cartItem._productOrigin) === null || _cartItem$_productOri9 === void 0 ? void 0 : _cartItem$_productOri9.cut_off_time
|
|
1674
1686
|
});
|
|
1675
1687
|
// 如果仅仅是因为子资源容量不够,不应该标记子资源是被占用的情况
|
|
1676
1688
|
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
|
|
@@ -1690,13 +1702,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1690
1702
|
// 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
|
|
1691
1703
|
// 同时,在这一步尝试去拉一下时间片,基于商品的时长,看每个资源是否还有空余时间能对这个商品做服务,如果没有则过滤
|
|
1692
1704
|
item.renderList = item.renderList.filter(function (n) {
|
|
1693
|
-
var _cartItem$
|
|
1705
|
+
var _cartItem$_productOri10;
|
|
1694
1706
|
var recordCount = n.capacity || 0;
|
|
1695
1707
|
if (n.onlyComputed) return false;
|
|
1696
1708
|
// 查一下这个资源基于商品的可用时间片
|
|
1697
1709
|
var timeSlots = getTimeSlicesByResource({
|
|
1698
1710
|
resource: n,
|
|
1699
|
-
duration: ((_cartItem$
|
|
1711
|
+
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
1712
|
split: 10,
|
|
1701
1713
|
currentDate: dateRange[0].date
|
|
1702
1714
|
});
|
|
@@ -1800,7 +1812,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1800
1812
|
}, {
|
|
1801
1813
|
key: "autoSelectAccountResources",
|
|
1802
1814
|
value: function autoSelectAccountResources(_ref8) {
|
|
1803
|
-
var _cartItem$
|
|
1815
|
+
var _cartItem$_productOri11, _allProductResources$;
|
|
1804
1816
|
var cartItem = _ref8.cartItem,
|
|
1805
1817
|
holder_id = _ref8.holder_id,
|
|
1806
1818
|
resources_code = _ref8.resources_code,
|
|
@@ -1822,20 +1834,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1822
1834
|
}
|
|
1823
1835
|
// duration=所有商品时间的集合
|
|
1824
1836
|
var duration = accountCartItems.reduce(function (acc, n) {
|
|
1825
|
-
var _n$
|
|
1826
|
-
return acc + ((
|
|
1837
|
+
var _n$_productOrigin2;
|
|
1838
|
+
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
1839
|
}, 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
1840
|
var AllResources = [];
|
|
1840
1841
|
if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
|
|
1841
1842
|
dateRange.forEach(function (n) {
|
|
@@ -1852,7 +1853,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1852
1853
|
var resourcesMap = getResourcesMap(cloneDeep(AllResources));
|
|
1853
1854
|
var allCartItems = cloneDeep(this.store.cart.getItems());
|
|
1854
1855
|
var selectedResources = getOthersSelectedResources(allCartItems, holder_id, resourcesMap);
|
|
1855
|
-
var allProductResources = getResourcesByProduct(resourcesMap, ((_cartItem$
|
|
1856
|
+
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
1857
|
var resources = ((_allProductResources$ = allProductResources.find(function (n) {
|
|
1857
1858
|
return n.code === resources_code;
|
|
1858
1859
|
})) === null || _allProductResources$ === void 0 ? void 0 : _allProductResources$.renderList) || [];
|
|
@@ -1907,15 +1908,20 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1907
1908
|
var hasOverlap = !dayjs(item.time.start_at).isAfter(dayjs(timeSlots.start_at)) && !dayjs(item.time.end_at).isBefore(dayjs(timeSlots.end_at));
|
|
1908
1909
|
return hasOverlap ? sum + item.pax : sum;
|
|
1909
1910
|
}, 0);
|
|
1911
|
+
|
|
1912
|
+
// 如果资源是单个预约,并且有 totalCapacity,则认为在当前 timeSlots 资源已经被选择过,就不可用了
|
|
1913
|
+
if (n.resourceType === 'single' && totalCapacity > 0) {
|
|
1914
|
+
return 0; // continue
|
|
1915
|
+
}
|
|
1910
1916
|
var canUseTime = mTimes.find(function (item) {
|
|
1911
|
-
var _cartItem$
|
|
1917
|
+
var _cartItem$_productOri12;
|
|
1912
1918
|
var res = getIsUsableByTimeItem({
|
|
1913
1919
|
timeSlice: timeSlots,
|
|
1914
1920
|
time: item,
|
|
1915
1921
|
resource: n,
|
|
1916
1922
|
currentCount: totalCapacity + (capacity || 0),
|
|
1917
1923
|
resourcesUseableMap: resourcesUseableMap,
|
|
1918
|
-
cut_off_time: (_cartItem$
|
|
1924
|
+
cut_off_time: (_cartItem$_productOri12 = cartItem._productOrigin) === null || _cartItem$_productOri12 === void 0 ? void 0 : _cartItem$_productOri12.cut_off_time
|
|
1919
1925
|
});
|
|
1920
1926
|
// 如果只是因为子资源容量不够,而不是子资源被预约导致没时间片,不应该标记子资源为不可用,从而影响组合资源的情况
|
|
1921
1927
|
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[n.id]) !== false && res.reason !== 'capacityOnly') {
|
|
@@ -1978,7 +1984,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1978
1984
|
key: "autoSelectAllProductResources",
|
|
1979
1985
|
value: function autoSelectAllProductResources(resources_code, timeSlots) {
|
|
1980
1986
|
var _dateRange$4,
|
|
1981
|
-
|
|
1987
|
+
_this10 = this;
|
|
1982
1988
|
var dateRange = this.store.date.getDateRange();
|
|
1983
1989
|
var resources = [];
|
|
1984
1990
|
if (dateRange !== null && dateRange !== void 0 && (_dateRange$4 = dateRange[0]) !== null && _dateRange$4 !== void 0 && _dateRange$4.date) {
|
|
@@ -1997,11 +2003,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1997
2003
|
// timeSlots 传进来的只是用户选中的时间片,但是实际上需要根据多个商品时间进行累加
|
|
1998
2004
|
// 假设 timeSlots.start_time 是15:40 duration 是 30min
|
|
1999
2005
|
// 第一个商品分配完以后,第二个商品分配的start_time应该是第一个商品的 end_time ,然后 end_time 应该是 start_time+duration
|
|
2000
|
-
|
|
2001
|
-
cartItems.
|
|
2006
|
+
// 判断购物车里是否有 flexible 类型的商品,如果有则不累加时间
|
|
2007
|
+
var hasFlexibleProduct = cartItems.some(function (item) {
|
|
2002
2008
|
var _item$_productOrigin3;
|
|
2009
|
+
return ((_item$_productOrigin3 = item._productOrigin) === null || _item$_productOrigin3 === void 0 || (_item$_productOrigin3 = _item$_productOrigin3.duration) === null || _item$_productOrigin3 === void 0 ? void 0 : _item$_productOrigin3.type) === 'flexible';
|
|
2010
|
+
});
|
|
2011
|
+
cartItems.forEach(function (item, index) {
|
|
2012
|
+
var _item$_productOrigin4;
|
|
2003
2013
|
var formatCapacity = formatDefaultCapacitys({
|
|
2004
|
-
capacity: (_item$
|
|
2014
|
+
capacity: (_item$_productOrigin4 = item._productOrigin) === null || _item$_productOrigin4 === void 0 ? void 0 : _item$_productOrigin4.capacity,
|
|
2005
2015
|
product_bundle: item._origin.product.product_bundle
|
|
2006
2016
|
});
|
|
2007
2017
|
var currentCapacity = getSumCapacity({
|
|
@@ -2017,17 +2027,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2017
2027
|
};
|
|
2018
2028
|
}
|
|
2019
2029
|
if (recordTimeSlots) {
|
|
2020
|
-
var _item$
|
|
2030
|
+
var _item$_productOrigin5, _item$_productOrigin6;
|
|
2021
2031
|
// 同一账号下,如果当前商品不是第一个,则需要根据上一个商品的 end_time 和 duration 计算出当前商品的 start_time 和 end_time
|
|
2022
2032
|
// 前提:当前资源是单个预约才需要这么做
|
|
2023
|
-
var currentResourceConfig = (_item$
|
|
2033
|
+
var currentResourceConfig = (_item$_productOrigin5 = item._productOrigin) === null || _item$_productOrigin5 === void 0 || (_item$_productOrigin5 = _item$_productOrigin5.product_resource) === null || _item$_productOrigin5 === void 0 || (_item$_productOrigin5 = _item$_productOrigin5.resources) === null || _item$_productOrigin5 === void 0 ? void 0 : _item$_productOrigin5.find(function (n) {
|
|
2024
2034
|
return n.code === resources_code;
|
|
2025
2035
|
});
|
|
2026
2036
|
// 只有 duration 类商品需要这个操作
|
|
2027
|
-
if (index !== 0 && recordTimeSlots && (currentResourceConfig === null || currentResourceConfig === void 0 ? void 0 : currentResourceConfig.type) === 'single' && (_item$
|
|
2028
|
-
var _item$
|
|
2029
|
-
var start_at = dayjs(recordTimeSlots.end_time).add((
|
|
2030
|
-
var end_at = start_at.add((
|
|
2037
|
+
if (index !== 0 && recordTimeSlots && (currentResourceConfig === null || currentResourceConfig === void 0 ? void 0 : currentResourceConfig.type) === 'single' && (_item$_productOrigin6 = item._productOrigin) !== null && _item$_productOrigin6 !== void 0 && _item$_productOrigin6.duration && !hasFlexibleProduct) {
|
|
2038
|
+
var _item$_productOrigin7, _item$_productOrigin8;
|
|
2039
|
+
var start_at = dayjs(recordTimeSlots.end_time).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');
|
|
2040
|
+
var end_at = start_at.add(((_item$_productOrigin8 = item._productOrigin) === null || _item$_productOrigin8 === void 0 || (_item$_productOrigin8 = _item$_productOrigin8.duration) === null || _item$_productOrigin8 === void 0 ? void 0 : _item$_productOrigin8.value) || 10, 'minutes');
|
|
2031
2041
|
recordTimeSlots = {
|
|
2032
2042
|
start_time: start_at.format('HH:mm'),
|
|
2033
2043
|
end_time: end_at.format('HH:mm'),
|
|
@@ -2036,7 +2046,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2036
2046
|
};
|
|
2037
2047
|
}
|
|
2038
2048
|
// 如果传递了 timeSlots,代表是第二种资源,则直接拿 timeSlots 去匹配
|
|
2039
|
-
var res =
|
|
2049
|
+
var res = _this10.autoSelectAccountResources({
|
|
2040
2050
|
cartItem: item,
|
|
2041
2051
|
holder_id: item.holder_id,
|
|
2042
2052
|
resources_code: resources_code,
|
|
@@ -2062,7 +2072,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2062
2072
|
}
|
|
2063
2073
|
res.selectedResource.capacity = currentCapacity;
|
|
2064
2074
|
checkSubResourcesCapacity(res.selectedResource);
|
|
2065
|
-
|
|
2075
|
+
_this10.store.cart.updateItem({
|
|
2066
2076
|
_id: item._id,
|
|
2067
2077
|
// 这里要做去重,避免出现同样类型的资源被塞进同一个商品
|
|
2068
2078
|
resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
|
|
@@ -2075,12 +2085,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2075
2085
|
errorList.push(item._id);
|
|
2076
2086
|
}
|
|
2077
2087
|
} else {
|
|
2078
|
-
var _item$
|
|
2088
|
+
var _item$_productOrigin9, _productResources$fin;
|
|
2079
2089
|
// 这里必须每次循环重新读,避免前一次循环操作了购物车,导致数据变更
|
|
2080
|
-
var allCartItems = cloneDeep(
|
|
2090
|
+
var allCartItems = cloneDeep(_this10.store.cart.getItems());
|
|
2081
2091
|
// 如果没有传递 timeSlots,代表是第一种资源,则直接拿商品的 duration,到资源列表里找一个公共可用的
|
|
2082
2092
|
var selectedResources = [];
|
|
2083
|
-
var _resources = cloneDeep(((_item$
|
|
2093
|
+
var _resources = cloneDeep(((_item$_productOrigin9 = item._productOrigin) === null || _item$_productOrigin9 === void 0 || (_item$_productOrigin9 = _item$_productOrigin9.product_resource) === null || _item$_productOrigin9 === void 0 ? void 0 : _item$_productOrigin9.resources) || []);
|
|
2084
2094
|
var currentResourcesRenderList = [];
|
|
2085
2095
|
_resources.forEach(function (n) {
|
|
2086
2096
|
var _n$renderList;
|
|
@@ -2092,7 +2102,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2092
2102
|
var recordCount = (m.capacity || 0) - (selectResourcesMap[m.id] || 0);
|
|
2093
2103
|
var timeSlots = getTimeSlicesByResource({
|
|
2094
2104
|
resource: m,
|
|
2095
|
-
duration: (item === null || item === void 0 || (_item$duration = item.duration) === null || _item$duration === void 0 ? void 0 : _item$duration.value) ||
|
|
2105
|
+
duration: (item === null || item === void 0 || (_item$duration = item.duration) === null || _item$duration === void 0 ? void 0 : _item$duration.value) || 10,
|
|
2096
2106
|
split: 10,
|
|
2097
2107
|
currentDate: dateRange[0].date
|
|
2098
2108
|
});
|
|
@@ -2141,7 +2151,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2141
2151
|
} else {
|
|
2142
2152
|
selectResourcesMap[targetResource.id] += currentCapacity;
|
|
2143
2153
|
}
|
|
2144
|
-
|
|
2154
|
+
_this10.store.cart.updateItem({
|
|
2145
2155
|
_id: item._id,
|
|
2146
2156
|
resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
|
|
2147
2157
|
return existingRes.resourceType !== targetRenderList[0].resourceType;
|
|
@@ -2161,7 +2171,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2161
2171
|
// 如果购物车里没有 holderid数据,证明不按 holder 类流程预约走,给所有购物车一次性分派即可,不做账号下资源互斥逻辑
|
|
2162
2172
|
if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
|
|
2163
2173
|
accountList.forEach(function (account) {
|
|
2164
|
-
var cartItems =
|
|
2174
|
+
var cartItems = _this10.store.cart.getCartByAccount(account.getId());
|
|
2165
2175
|
selectForCartResources(cartItems);
|
|
2166
2176
|
});
|
|
2167
2177
|
} else {
|
|
@@ -2176,9 +2186,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2176
2186
|
key: "getTimeSlotByAllResources",
|
|
2177
2187
|
value: function getTimeSlotByAllResources(resources_code) {
|
|
2178
2188
|
var _dateRange,
|
|
2179
|
-
|
|
2189
|
+
_this11 = this,
|
|
2180
2190
|
_cartItems$,
|
|
2181
|
-
_cartItems$2
|
|
2191
|
+
_cartItems$2,
|
|
2192
|
+
_this$shopStore$get;
|
|
2182
2193
|
var dateRange = this.store.date.getDateRange();
|
|
2183
2194
|
// 取出购物车中所有一已选择的第一步资源
|
|
2184
2195
|
var resources = [];
|
|
@@ -2194,8 +2205,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2194
2205
|
var maxCutOffTime = undefined;
|
|
2195
2206
|
var maxCutOffTimeValue = dayjs();
|
|
2196
2207
|
cartItems.forEach(function (item) {
|
|
2197
|
-
var _item$
|
|
2198
|
-
(_item$
|
|
2208
|
+
var _item$_productOrigin10, _item$_productOrigin11, _item$_productOrigin12, _item$_productOrigin13;
|
|
2209
|
+
(_item$_productOrigin10 = item._productOrigin) === null || _item$_productOrigin10 === void 0 || (_item$_productOrigin10 = _item$_productOrigin10.product_resource) === null || _item$_productOrigin10 === void 0 || (_item$_productOrigin10 = _item$_productOrigin10.resources) === null || _item$_productOrigin10 === void 0 || _item$_productOrigin10.forEach(function (n) {
|
|
2199
2210
|
// TODO: 少了个 status 的判断
|
|
2200
2211
|
if (n.code === resources_code) {
|
|
2201
2212
|
resources.push.apply(resources, _toConsumableArray(n.renderList || []));
|
|
@@ -2208,10 +2219,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2208
2219
|
if (item.resource_id) {
|
|
2209
2220
|
resourceIds.push(item.resource_id);
|
|
2210
2221
|
}
|
|
2211
|
-
resourcesTypeId = item === null || item === void 0 || (_item$
|
|
2222
|
+
resourcesTypeId = item === null || item === void 0 || (_item$_productOrigin11 = item._productOrigin) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.product_resource) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.resources) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.find(function (n) {
|
|
2212
2223
|
return n.code === resources_code;
|
|
2213
|
-
})) === null || _item$
|
|
2214
|
-
if ((_item$
|
|
2224
|
+
})) === null || _item$_productOrigin11 === void 0 ? void 0 : _item$_productOrigin11.id;
|
|
2225
|
+
if ((_item$_productOrigin12 = item._productOrigin) !== null && _item$_productOrigin12 !== void 0 && _item$_productOrigin12.cut_off_time && ((_item$_productOrigin13 = item._productOrigin) === null || _item$_productOrigin13 === void 0 ? void 0 : _item$_productOrigin13.cut_off_time.type) === 'advance') {
|
|
2215
2226
|
var currentCutOffTime = dayjs().add(item._productOrigin.cut_off_time.unit, item._productOrigin.cut_off_time.unit_type);
|
|
2216
2227
|
if (currentCutOffTime.isAfter(maxCutOffTimeValue, 'minute')) {
|
|
2217
2228
|
maxCutOffTimeValue = currentCutOffTime;
|
|
@@ -2239,13 +2250,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2239
2250
|
cartItems.forEach(function (item) {
|
|
2240
2251
|
// 单个预约累加账号 多个预约取最大值
|
|
2241
2252
|
if (isSingleResource) {
|
|
2242
|
-
var _item$
|
|
2243
|
-
accountDuration += (
|
|
2253
|
+
var _item$_productOrigin14;
|
|
2254
|
+
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;
|
|
2244
2255
|
} else {
|
|
2245
|
-
var _item$
|
|
2246
|
-
if (accountDuration < ((
|
|
2247
|
-
var _item$
|
|
2248
|
-
accountDuration = (
|
|
2256
|
+
var _item$_productOrigin15;
|
|
2257
|
+
if (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)) {
|
|
2258
|
+
var _item$_productOrigin16;
|
|
2259
|
+
accountDuration = ((_item$_productOrigin16 = item._productOrigin) === null || _item$_productOrigin16 === void 0 || (_item$_productOrigin16 = _item$_productOrigin16.duration) === null || _item$_productOrigin16 === void 0 ? void 0 : _item$_productOrigin16.value) || 10;
|
|
2249
2260
|
}
|
|
2250
2261
|
}
|
|
2251
2262
|
});
|
|
@@ -2255,7 +2266,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2255
2266
|
};
|
|
2256
2267
|
if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
|
|
2257
2268
|
accountList.forEach(function (account) {
|
|
2258
|
-
var cartItems =
|
|
2269
|
+
var cartItems = _this11.store.cart.getCartByAccount(account.getId());
|
|
2259
2270
|
checkDuration(cartItems);
|
|
2260
2271
|
});
|
|
2261
2272
|
} else {
|
|
@@ -2281,6 +2292,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2281
2292
|
}];
|
|
2282
2293
|
}
|
|
2283
2294
|
var resourcesUseableMap = {};
|
|
2295
|
+
var hasFlexibleDuration = cartItems.some(function (item) {
|
|
2296
|
+
var _item$_productOrigin17;
|
|
2297
|
+
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';
|
|
2298
|
+
});
|
|
2299
|
+
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;
|
|
2284
2300
|
var timeSlots = getTimeSlicesByResources({
|
|
2285
2301
|
resourceIds: resourceIds,
|
|
2286
2302
|
resourcesMap: resourcesMap,
|
|
@@ -2288,21 +2304,27 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2288
2304
|
currentDate: dateRange[0].date,
|
|
2289
2305
|
split: 10,
|
|
2290
2306
|
resourcesUseableMap: resourcesUseableMap,
|
|
2291
|
-
cut_off_time: maxCutOffTime
|
|
2307
|
+
cut_off_time: maxCutOffTime,
|
|
2308
|
+
hasFlexibleDuration: hasFlexibleDuration,
|
|
2309
|
+
operating_day_boundary: operating_day_boundary
|
|
2292
2310
|
});
|
|
2293
2311
|
return timeSlots;
|
|
2294
2312
|
}
|
|
2295
2313
|
|
|
2296
|
-
//
|
|
2314
|
+
// 提交时间切片,绑定到对应购物车的商品上,更新购物车---只有 duration 商品
|
|
2297
2315
|
}, {
|
|
2298
2316
|
key: "submitTimeSlot",
|
|
2299
2317
|
value: function submitTimeSlot(timeSlots) {
|
|
2300
|
-
var
|
|
2318
|
+
var _this$shopStore$get2,
|
|
2319
|
+
_this12 = this;
|
|
2301
2320
|
// 以账号为维度处理数据。购物车里每一项的 startTime应该是前一个商品的 endTime,如果是第一个商品则用 timeSlots.start_at
|
|
2302
2321
|
var cartItems = this.store.cart.getItems().filter(function (n) {
|
|
2303
2322
|
return !isNormalProduct(n._productOrigin);
|
|
2304
2323
|
});
|
|
2305
2324
|
|
|
2325
|
+
// 取出所有资源列表
|
|
2326
|
+
var allResources = this.store.date.getResourcesListByDate(timeSlots.start_at.format('YYYY-MM-DD'));
|
|
2327
|
+
|
|
2306
2328
|
// 按账号分组
|
|
2307
2329
|
var itemsByAccount = cartItems.reduce(function (acc, item) {
|
|
2308
2330
|
var holderId = item.holder_id;
|
|
@@ -2313,6 +2335,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2313
2335
|
return acc;
|
|
2314
2336
|
}, {});
|
|
2315
2337
|
|
|
2338
|
+
// 店铺营业结束时间
|
|
2339
|
+
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;
|
|
2340
|
+
|
|
2316
2341
|
// 处理每个账号的商品
|
|
2317
2342
|
Object.values(itemsByAccount).forEach(function (accountItems) {
|
|
2318
2343
|
var currentStartTime = timeSlots.start_at.format('YYYY-MM-DD HH:mm');
|
|
@@ -2320,12 +2345,45 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2320
2345
|
var _newResources$;
|
|
2321
2346
|
var newResources = cloneDeep(item._origin.resources);
|
|
2322
2347
|
newResources.forEach(function (resource) {
|
|
2323
|
-
var _item$
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2348
|
+
var _item$_productOrigin18;
|
|
2349
|
+
// 如果商品配置的是灵活时长,开始时间设置为提交的时间,结束时间从资源的可用最晚时间和店铺营业结束时间里取一个最早的
|
|
2350
|
+
if (((_item$_productOrigin18 = item._productOrigin) === null || _item$_productOrigin18 === void 0 || (_item$_productOrigin18 = _item$_productOrigin18.duration) === null || _item$_productOrigin18 === void 0 ? void 0 : _item$_productOrigin18.type) === 'flexible') {
|
|
2351
|
+
var _allResources$find;
|
|
2352
|
+
item.duration = {
|
|
2353
|
+
type: 'minutes',
|
|
2354
|
+
value: 10
|
|
2355
|
+
};
|
|
2356
|
+
resource.startTime = timeSlots.start_at.format('YYYY-MM-DD HH:mm');
|
|
2357
|
+
// 找到resource.times里最早的end_at
|
|
2358
|
+
var targetResourceTimes = allResources === null || allResources === void 0 || (_allResources$find = allResources.find(function (n) {
|
|
2359
|
+
return n.id === resource.id;
|
|
2360
|
+
})) === null || _allResources$find === void 0 ? void 0 : _allResources$find.times;
|
|
2361
|
+
var resourcesEndTime = targetResourceTimes.reduce(function (acc, curr) {
|
|
2362
|
+
return dayjs(curr.end_at).isBefore(dayjs(acc.end_at)) ? curr : acc;
|
|
2363
|
+
}, targetResourceTimes[0]);
|
|
2364
|
+
|
|
2365
|
+
// 将 operating_day_boundary 转换为与 resourcesEndTime.end_at 相同日期的完整日期时间
|
|
2366
|
+
var resourceDate = dayjs(resourcesEndTime.end_at).format('YYYY-MM-DD');
|
|
2367
|
+
var operatingBoundaryDateTime = "".concat(resourceDate, " ").concat(operating_day_boundary.type === 'start_time' ? "23:59" : operating_day_boundary.time);
|
|
2368
|
+
var endTime = dayjs(resourcesEndTime.end_at).isBefore(dayjs(operatingBoundaryDateTime)) ? resourcesEndTime.end_at : operatingBoundaryDateTime;
|
|
2369
|
+
// 修复:如果 endTime 只是时间格式(如 "17:00"),需要加上日期
|
|
2370
|
+
var formattedEndTime;
|
|
2371
|
+
if (typeof endTime === 'string' && endTime.includes(':') && !endTime.includes(' ') && !endTime.includes('T')) {
|
|
2372
|
+
// 如果是纯时间格式,与当前日期合并
|
|
2373
|
+
var currentDate = timeSlots.start_at.format('YYYY-MM-DD');
|
|
2374
|
+
formattedEndTime = dayjs("".concat(currentDate, " ").concat(endTime));
|
|
2375
|
+
} else {
|
|
2376
|
+
formattedEndTime = dayjs(endTime);
|
|
2377
|
+
}
|
|
2378
|
+
resource.endTime = formattedEndTime.format('YYYY-MM-DD HH:mm');
|
|
2379
|
+
} else {
|
|
2380
|
+
var _item$_productOrigin19;
|
|
2381
|
+
resource.startTime = currentStartTime;
|
|
2382
|
+
resource.endTime = dayjs(currentStartTime).add(((_item$_productOrigin19 = item._productOrigin) === null || _item$_productOrigin19 === void 0 || (_item$_productOrigin19 = _item$_productOrigin19.duration) === null || _item$_productOrigin19 === void 0 ? void 0 : _item$_productOrigin19.value) || 10, 'minutes').format('YYYY-MM-DD HH:mm');
|
|
2383
|
+
}
|
|
2384
|
+
// delete resource.times;
|
|
2327
2385
|
});
|
|
2328
|
-
|
|
2386
|
+
_this12.store.cart.updateItem({
|
|
2329
2387
|
_id: item._id,
|
|
2330
2388
|
resources: newResources
|
|
2331
2389
|
});
|
|
@@ -2408,12 +2466,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2408
2466
|
}
|
|
2409
2467
|
}, {
|
|
2410
2468
|
key: "getTimeslotBySchedule",
|
|
2411
|
-
value: function getTimeslotBySchedule(
|
|
2469
|
+
value: function getTimeslotBySchedule(_ref9) {
|
|
2412
2470
|
var _this$store$currentPr2, _targetProductData$pr;
|
|
2413
|
-
var date =
|
|
2414
|
-
scheduleIds =
|
|
2415
|
-
resources =
|
|
2416
|
-
product =
|
|
2471
|
+
var date = _ref9.date,
|
|
2472
|
+
scheduleIds = _ref9.scheduleIds,
|
|
2473
|
+
resources = _ref9.resources,
|
|
2474
|
+
product = _ref9.product;
|
|
2417
2475
|
var targetProduct = this.store.currentProduct;
|
|
2418
2476
|
// 如果外面传递了product 优先用外面的
|
|
2419
2477
|
var targetProductData = product || (targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.getData());
|
|
@@ -2531,19 +2589,19 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2531
2589
|
}
|
|
2532
2590
|
}, {
|
|
2533
2591
|
key: "addProductToCart",
|
|
2534
|
-
value: function addProductToCart(
|
|
2535
|
-
var
|
|
2536
|
-
var product =
|
|
2537
|
-
date =
|
|
2538
|
-
account =
|
|
2539
|
-
var
|
|
2540
|
-
bundle =
|
|
2541
|
-
options =
|
|
2542
|
-
origin =
|
|
2543
|
-
product_variant_id =
|
|
2544
|
-
rowKey =
|
|
2545
|
-
|
|
2546
|
-
quantity =
|
|
2592
|
+
value: function addProductToCart(_ref10) {
|
|
2593
|
+
var _this13 = this;
|
|
2594
|
+
var product = _ref10.product,
|
|
2595
|
+
date = _ref10.date,
|
|
2596
|
+
account = _ref10.account;
|
|
2597
|
+
var _ref11 = product || {},
|
|
2598
|
+
bundle = _ref11.bundle,
|
|
2599
|
+
options = _ref11.options,
|
|
2600
|
+
origin = _ref11.origin,
|
|
2601
|
+
product_variant_id = _ref11.product_variant_id,
|
|
2602
|
+
rowKey = _ref11.rowKey,
|
|
2603
|
+
_ref11$quantity = _ref11.quantity,
|
|
2604
|
+
quantity = _ref11$quantity === void 0 ? 1 : _ref11$quantity;
|
|
2547
2605
|
var productData = _objectSpread(_objectSpread({}, origin), {}, {
|
|
2548
2606
|
product_variant_id: product_variant_id
|
|
2549
2607
|
});
|
|
@@ -2587,7 +2645,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2587
2645
|
});
|
|
2588
2646
|
if (cartItemsByDate.length) {
|
|
2589
2647
|
cartItemsByDate.forEach(function (n) {
|
|
2590
|
-
|
|
2648
|
+
_this13.store.cart.removeItem(n._id);
|
|
2591
2649
|
});
|
|
2592
2650
|
}
|
|
2593
2651
|
}
|
|
@@ -2651,7 +2709,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2651
2709
|
}, {
|
|
2652
2710
|
key: "getResourcesByCartItemAndCode",
|
|
2653
2711
|
value: function getResourcesByCartItemAndCode(cartItemId, resourceCode) {
|
|
2654
|
-
var _cartItem$
|
|
2712
|
+
var _cartItem$_productOri13, _cartItem$_productOri14;
|
|
2655
2713
|
var dateRange = this.store.date.getDateRange();
|
|
2656
2714
|
var resources = [];
|
|
2657
2715
|
if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
|
|
@@ -2675,7 +2733,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2675
2733
|
if (!cartItem) return [];
|
|
2676
2734
|
var selectedResources = [];
|
|
2677
2735
|
var formatCapacity = formatDefaultCapacitys({
|
|
2678
|
-
capacity: (_cartItem$
|
|
2736
|
+
capacity: (_cartItem$_productOri13 = cartItem._productOrigin) === null || _cartItem$_productOri13 === void 0 ? void 0 : _cartItem$_productOri13.capacity,
|
|
2679
2737
|
product_bundle: cartItem._origin.product.product_bundle
|
|
2680
2738
|
});
|
|
2681
2739
|
cartItem._origin.metadata.capacity = formatCapacity;
|
|
@@ -2687,7 +2745,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2687
2745
|
} else {
|
|
2688
2746
|
selectedResources = getOthersCartSelectedResources(cartItems, cartItem._id, resourcesMap);
|
|
2689
2747
|
}
|
|
2690
|
-
var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$
|
|
2748
|
+
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);
|
|
2691
2749
|
var targetResource = productResources.find(function (resource) {
|
|
2692
2750
|
return resource.code === resourceCode;
|
|
2693
2751
|
});
|
|
@@ -2710,7 +2768,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2710
2768
|
});
|
|
2711
2769
|
if (mTimes.length === 0) return false;
|
|
2712
2770
|
var canUseArr = mTimes.map(function (item) {
|
|
2713
|
-
var _cartItem$
|
|
2771
|
+
var _cartItem$_productOri15;
|
|
2714
2772
|
var res = getIsUsableByTimeItem({
|
|
2715
2773
|
timeSlice: {
|
|
2716
2774
|
start_time: startTime.format('HH:mm'),
|
|
@@ -2722,7 +2780,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2722
2780
|
resource: m,
|
|
2723
2781
|
currentCount: currentCapacity || 0,
|
|
2724
2782
|
resourcesUseableMap: resourcesUseableMap,
|
|
2725
|
-
cut_off_time: (_cartItem$
|
|
2783
|
+
cut_off_time: (_cartItem$_productOri15 = cartItem._productOrigin) === null || _cartItem$_productOri15 === void 0 ? void 0 : _cartItem$_productOri15.cut_off_time
|
|
2726
2784
|
});
|
|
2727
2785
|
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
|
|
2728
2786
|
resourcesUseableMap[m.id] = res.usable;
|
|
@@ -2736,12 +2794,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2736
2794
|
});
|
|
2737
2795
|
} else {
|
|
2738
2796
|
targetResource.renderList = targetResource.renderList.filter(function (n) {
|
|
2739
|
-
var _cartItem$
|
|
2797
|
+
var _cartItem$_productOri16;
|
|
2740
2798
|
var recordCount = n.capacity || 0;
|
|
2741
2799
|
if (n.onlyComputed) return false;
|
|
2742
2800
|
var timeSlots = getTimeSlicesByResource({
|
|
2743
2801
|
resource: n,
|
|
2744
|
-
duration: ((_cartItem$
|
|
2802
|
+
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,
|
|
2745
2803
|
split: 10,
|
|
2746
2804
|
currentDate: dateRange[0].date
|
|
2747
2805
|
});
|
|
@@ -2759,12 +2817,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2759
2817
|
}, {
|
|
2760
2818
|
key: "getTimeslotsScheduleByDateRange",
|
|
2761
2819
|
value: (function () {
|
|
2762
|
-
var _getTimeslotsScheduleByDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(
|
|
2820
|
+
var _getTimeslotsScheduleByDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(_ref12) {
|
|
2763
2821
|
var startDate, endDate, scheduleIds, resources, dates, currentDate, end, results, _i, _dates, date;
|
|
2764
2822
|
return _regeneratorRuntime().wrap(function _callee28$(_context29) {
|
|
2765
2823
|
while (1) switch (_context29.prev = _context29.next) {
|
|
2766
2824
|
case 0:
|
|
2767
|
-
startDate =
|
|
2825
|
+
startDate = _ref12.startDate, endDate = _ref12.endDate, scheduleIds = _ref12.scheduleIds, resources = _ref12.resources;
|
|
2768
2826
|
console.log('appoimentBooking-session-date-getTimeslotsScheduleByDateRange', {
|
|
2769
2827
|
startDate: startDate,
|
|
2770
2828
|
endDate: endDate,
|
|
@@ -2810,7 +2868,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2810
2868
|
endDate,
|
|
2811
2869
|
type,
|
|
2812
2870
|
tempProducts,
|
|
2813
|
-
|
|
2871
|
+
_ref13,
|
|
2814
2872
|
resourceIds,
|
|
2815
2873
|
rules,
|
|
2816
2874
|
resourcesMap,
|
|
@@ -2836,7 +2894,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2836
2894
|
})];
|
|
2837
2895
|
}
|
|
2838
2896
|
// 在这里需要把能收集到的数据都收集上来,拼装好给 date 模块去查询
|
|
2839
|
-
|
|
2897
|
+
_ref13 = getAvailableProductResources(tempProducts) || {}, resourceIds = _ref13.resourceIds, rules = _ref13.rules, resourcesMap = _ref13.resourcesMap;
|
|
2840
2898
|
this.otherParams.currentResourcesMap = resourcesMap;
|
|
2841
2899
|
_context30.next = 10;
|
|
2842
2900
|
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,11 @@ 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?: {
|
|
101
|
+
type: string;
|
|
102
|
+
time: string;
|
|
103
|
+
} | undefined;
|
|
99
104
|
}) => TimeSliceItem[];
|
|
100
105
|
/**
|
|
101
106
|
* @title: 获取时间切片列表的交集
|
|
@@ -133,7 +138,7 @@ export declare const mergeSubResourcesTimeSlices: (resources: ResourceItem[], re
|
|
|
133
138
|
* @return {*}
|
|
134
139
|
* @Author: zhiwei.Wang
|
|
135
140
|
*/
|
|
136
|
-
export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split, capacity, resourcesUseableMap, cut_off_time, }: {
|
|
141
|
+
export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split, capacity, resourcesUseableMap, cut_off_time, hasFlexibleDuration, operating_day_boundary }: {
|
|
137
142
|
resourceIds: number[];
|
|
138
143
|
resourcesMap: any;
|
|
139
144
|
duration: number;
|
|
@@ -151,6 +156,11 @@ export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, dur
|
|
|
151
156
|
unit: number;
|
|
152
157
|
} | undefined;
|
|
153
158
|
} | undefined;
|
|
159
|
+
hasFlexibleDuration?: boolean | undefined;
|
|
160
|
+
operating_day_boundary?: {
|
|
161
|
+
type: string;
|
|
162
|
+
time: string;
|
|
163
|
+
} | undefined;
|
|
154
164
|
}) => any[];
|
|
155
165
|
/**
|
|
156
166
|
* @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
|
-
|
|
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,11 @@ 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
|
+
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")) {
|
|
468
|
+
break;
|
|
469
|
+
}
|
|
463
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
|
|
464
471
|
timeSlices.push(_objectSpread(_objectSpread({}, timeSlice), {}, {
|
|
465
472
|
// 这里需要补充这个时间段内是否可预约
|
|
@@ -565,7 +572,9 @@ export var getTimeSlicesByResources = function getTimeSlicesByResources(_ref6) {
|
|
|
565
572
|
split = _ref6.split,
|
|
566
573
|
capacity = _ref6.capacity,
|
|
567
574
|
resourcesUseableMap = _ref6.resourcesUseableMap,
|
|
568
|
-
cut_off_time = _ref6.cut_off_time
|
|
575
|
+
cut_off_time = _ref6.cut_off_time,
|
|
576
|
+
hasFlexibleDuration = _ref6.hasFlexibleDuration,
|
|
577
|
+
operating_day_boundary = _ref6.operating_day_boundary;
|
|
569
578
|
// 获取资源列表
|
|
570
579
|
var resources = getResourcesByIds(resourcesMap, resourceIds);
|
|
571
580
|
mergeSubResourcesTimeSlices(resources, resourcesMap);
|
|
@@ -588,7 +597,9 @@ export var getTimeSlicesByResources = function getTimeSlicesByResources(_ref6) {
|
|
|
588
597
|
currentDate: currentDate,
|
|
589
598
|
capacity: capacity,
|
|
590
599
|
resourcesUseableMap: resourcesUseableMap,
|
|
591
|
-
cut_off_time: cut_off_time
|
|
600
|
+
cut_off_time: cut_off_time,
|
|
601
|
+
hasFlexibleDuration: hasFlexibleDuration,
|
|
602
|
+
operating_day_boundary: operating_day_boundary
|
|
592
603
|
}));
|
|
593
604
|
}, []);
|
|
594
605
|
|
|
@@ -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) {
|
|
@@ -216,12 +219,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
216
219
|
{ date, status: "available", week: "", weekNum: 0 },
|
|
217
220
|
{ date, status: "available", week: "", weekNum: 0 }
|
|
218
221
|
]);
|
|
222
|
+
let newProductIds = [];
|
|
219
223
|
const schedule = scheduleList.find((n) => n.date === date);
|
|
220
224
|
if (schedule && ((_a = schedule.product_ids) == null ? void 0 : _a.length)) {
|
|
221
|
-
|
|
225
|
+
newProductIds = schedule.product_ids;
|
|
222
226
|
}
|
|
223
227
|
const otherProductsIds = this.store.schedule.getOtherProductsIds() || [];
|
|
224
|
-
const allProductIds = [...
|
|
228
|
+
const allProductIds = [...newProductIds, ...otherProductsIds].filter(
|
|
225
229
|
(n, index, self) => self.indexOf(n) === index
|
|
226
230
|
);
|
|
227
231
|
return await this.loadProducts({
|
|
@@ -821,7 +825,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
821
825
|
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
|
|
822
826
|
const arr = [];
|
|
823
827
|
cartItems.forEach((cartItem) => {
|
|
824
|
-
var _a, _b, _c;
|
|
828
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
825
829
|
let selectedResources = [];
|
|
826
830
|
const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
|
|
827
831
|
capacity: (_a = cartItem._productOrigin) == null ? void 0 : _a.capacity,
|
|
@@ -858,9 +862,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
858
862
|
const resourcesUseableMap = {};
|
|
859
863
|
productResources.forEach((n) => {
|
|
860
864
|
n.renderList = n.renderList.sort((a, b) => {
|
|
861
|
-
var _a2, _b2, _c2,
|
|
865
|
+
var _a2, _b2, _c2, _d2;
|
|
862
866
|
const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
|
|
863
|
-
const bIsCombined = ((
|
|
867
|
+
const bIsCombined = ((_d2 = (_c2 = b.metadata) == null ? void 0 : _c2.combined_resource) == null ? void 0 : _d2.status) === 1;
|
|
864
868
|
if (aIsCombined && !bIsCombined)
|
|
865
869
|
return 1;
|
|
866
870
|
if (!aIsCombined && bIsCombined)
|
|
@@ -900,17 +904,22 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
900
904
|
});
|
|
901
905
|
});
|
|
902
906
|
} else {
|
|
907
|
+
const hasFlexibleDuration = ((_e = (_d = cartItem._productOrigin) == null ? void 0 : _d.duration) == null ? void 0 : _e.type) === "flexible";
|
|
908
|
+
const operating_day_boundary = (_g = (_f = this.shopStore.get("core")) == null ? void 0 : _f.core) == null ? void 0 : _g.operating_day_boundary;
|
|
903
909
|
productResources.forEach((item) => {
|
|
904
910
|
item.renderList = item.renderList.filter((n) => {
|
|
905
|
-
var _a2, _b2;
|
|
911
|
+
var _a2, _b2, _c2;
|
|
906
912
|
const recordCount = n.capacity || 0;
|
|
907
913
|
if (n.onlyComputed)
|
|
908
914
|
return false;
|
|
909
915
|
const timeSlots = (0, import_resources.getTimeSlicesByResource)({
|
|
910
916
|
resource: n,
|
|
911
|
-
duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) ||
|
|
917
|
+
duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10,
|
|
912
918
|
split: 10,
|
|
913
|
-
currentDate: dateRange[0].date
|
|
919
|
+
currentDate: dateRange[0].date,
|
|
920
|
+
hasFlexibleDuration,
|
|
921
|
+
cut_off_time: (_c2 = cartItem._productOrigin) == null ? void 0 : _c2.cut_off_time,
|
|
922
|
+
operating_day_boundary
|
|
914
923
|
});
|
|
915
924
|
return recordCount >= currentCapacity && timeSlots.length > 0;
|
|
916
925
|
});
|
|
@@ -1037,7 +1046,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1037
1046
|
return false;
|
|
1038
1047
|
const timeSlots = (0, import_resources.getTimeSlicesByResource)({
|
|
1039
1048
|
resource: n,
|
|
1040
|
-
duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) ||
|
|
1049
|
+
duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10,
|
|
1041
1050
|
split: 10,
|
|
1042
1051
|
currentDate: dateRange[0].date
|
|
1043
1052
|
});
|
|
@@ -1155,7 +1164,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1155
1164
|
}
|
|
1156
1165
|
let duration = accountCartItems.reduce((acc, n) => {
|
|
1157
1166
|
var _a2, _b2;
|
|
1158
|
-
return acc + (((_b2 = (_a2 = n._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value)
|
|
1167
|
+
return acc + (((_b2 = (_a2 = n._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10);
|
|
1159
1168
|
}, 0);
|
|
1160
1169
|
let AllResources = [];
|
|
1161
1170
|
if (dateRange == null ? void 0 : dateRange.length) {
|
|
@@ -1219,6 +1228,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1219
1228
|
},
|
|
1220
1229
|
0
|
|
1221
1230
|
);
|
|
1231
|
+
if (n.resourceType === "single" && totalCapacity > 0) {
|
|
1232
|
+
continue;
|
|
1233
|
+
}
|
|
1222
1234
|
const canUseTime = mTimes.find((item) => {
|
|
1223
1235
|
var _a2;
|
|
1224
1236
|
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
@@ -1286,8 +1298,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1286
1298
|
const accountList = this.store.accountList.getAccounts();
|
|
1287
1299
|
const selectForCartResources = (cartItems2) => {
|
|
1288
1300
|
let recordTimeSlots = (0, import_lodash_es.cloneDeep)(timeSlots);
|
|
1301
|
+
const hasFlexibleProduct = cartItems2.some((item) => {
|
|
1302
|
+
var _a2, _b;
|
|
1303
|
+
return ((_b = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b.type) === "flexible";
|
|
1304
|
+
});
|
|
1289
1305
|
cartItems2.forEach((item, index) => {
|
|
1290
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m
|
|
1306
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
1291
1307
|
const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
|
|
1292
1308
|
capacity: (_a2 = item._productOrigin) == null ? void 0 : _a2.capacity,
|
|
1293
1309
|
product_bundle: item._origin.product.product_bundle
|
|
@@ -1305,14 +1321,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1305
1321
|
const currentResourceConfig = (_d = (_c = (_b = item._productOrigin) == null ? void 0 : _b.product_resource) == null ? void 0 : _c.resources) == null ? void 0 : _d.find(
|
|
1306
1322
|
(n) => n.code === resources_code
|
|
1307
1323
|
);
|
|
1308
|
-
if (index !== 0 && recordTimeSlots && (currentResourceConfig == null ? void 0 : currentResourceConfig.type) === "single" && ((_e = item._productOrigin) == null ? void 0 : _e.duration)) {
|
|
1324
|
+
if (index !== 0 && recordTimeSlots && (currentResourceConfig == null ? void 0 : currentResourceConfig.type) === "single" && ((_e = item._productOrigin) == null ? void 0 : _e.duration) && !hasFlexibleProduct) {
|
|
1309
1325
|
let start_at = (0, import_dayjs.default)(recordTimeSlots.end_time).add(
|
|
1310
|
-
((_g = (_f = item._productOrigin) == null ? void 0 : _f.duration) == null ? void 0 : _g.value)
|
|
1311
|
-
|
|
1326
|
+
((_g = (_f = item._productOrigin) == null ? void 0 : _f.duration) == null ? void 0 : _g.value) || 10,
|
|
1327
|
+
"minutes"
|
|
1312
1328
|
);
|
|
1313
1329
|
let end_at = start_at.add(
|
|
1314
|
-
((
|
|
1315
|
-
|
|
1330
|
+
((_i = (_h = item._productOrigin) == null ? void 0 : _h.duration) == null ? void 0 : _i.value) || 10,
|
|
1331
|
+
"minutes"
|
|
1316
1332
|
);
|
|
1317
1333
|
recordTimeSlots = {
|
|
1318
1334
|
start_time: start_at.format("HH:mm"),
|
|
@@ -1365,7 +1381,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1365
1381
|
const allCartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
1366
1382
|
let selectedResources = [];
|
|
1367
1383
|
const resources2 = (0, import_lodash_es.cloneDeep)(
|
|
1368
|
-
((
|
|
1384
|
+
((_k = (_j = item._productOrigin) == null ? void 0 : _j.product_resource) == null ? void 0 : _k.resources) || []
|
|
1369
1385
|
);
|
|
1370
1386
|
const currentResourcesRenderList = [];
|
|
1371
1387
|
resources2.forEach((n) => {
|
|
@@ -1376,7 +1392,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1376
1392
|
const recordCount = (m.capacity || 0) - (selectResourcesMap[m.id] || 0);
|
|
1377
1393
|
const timeSlots2 = (0, import_resources.getTimeSlicesByResource)({
|
|
1378
1394
|
resource: m,
|
|
1379
|
-
duration: ((_a4 = item == null ? void 0 : item.duration) == null ? void 0 : _a4.value) ||
|
|
1395
|
+
duration: ((_a4 = item == null ? void 0 : item.duration) == null ? void 0 : _a4.value) || 10,
|
|
1380
1396
|
split: 10,
|
|
1381
1397
|
currentDate: dateRange[0].date
|
|
1382
1398
|
});
|
|
@@ -1413,11 +1429,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1413
1429
|
return recordCount >= currentCapacity;
|
|
1414
1430
|
});
|
|
1415
1431
|
});
|
|
1416
|
-
const targetRenderList = (
|
|
1432
|
+
const targetRenderList = (_l = productResources.find(
|
|
1417
1433
|
(n) => n.code === resources_code
|
|
1418
|
-
)) == null ? void 0 :
|
|
1434
|
+
)) == null ? void 0 : _l.renderList;
|
|
1419
1435
|
if (targetRenderList && targetRenderList.length > 0) {
|
|
1420
|
-
if ((
|
|
1436
|
+
if ((_m = item._origin.resources) == null ? void 0 : _m.some(
|
|
1421
1437
|
(n) => n.form_id === targetRenderList[0].form_id
|
|
1422
1438
|
)) {
|
|
1423
1439
|
return;
|
|
@@ -1463,7 +1479,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1463
1479
|
}
|
|
1464
1480
|
// 从购物车中获取已经分配好第一步资源的所有时间片
|
|
1465
1481
|
getTimeSlotByAllResources(resources_code) {
|
|
1466
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1482
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1467
1483
|
let dateRange = this.store.date.getDateRange();
|
|
1468
1484
|
const resources = [];
|
|
1469
1485
|
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
|
|
@@ -1473,7 +1489,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1473
1489
|
let maxCutOffTime = void 0;
|
|
1474
1490
|
let maxCutOffTimeValue = (0, import_dayjs.default)();
|
|
1475
1491
|
cartItems.forEach((item) => {
|
|
1476
|
-
var _a2, _b2, _c2, _d2, _e2, _f2,
|
|
1492
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i;
|
|
1477
1493
|
(_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.forEach((n) => {
|
|
1478
1494
|
if (n.code === resources_code) {
|
|
1479
1495
|
resources.push(...n.renderList || []);
|
|
@@ -1483,10 +1499,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1483
1499
|
if (item.resource_id) {
|
|
1484
1500
|
resourceIds.push(item.resource_id);
|
|
1485
1501
|
}
|
|
1486
|
-
resourcesTypeId = (
|
|
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(
|
|
1487
1503
|
(n) => n.code === resources_code
|
|
1488
|
-
)) == null ? void 0 :
|
|
1489
|
-
if (((
|
|
1504
|
+
)) == null ? void 0 : _g2.id;
|
|
1505
|
+
if (((_h2 = item._productOrigin) == null ? void 0 : _h2.cut_off_time) && ((_i = item._productOrigin) == null ? void 0 : _i.cut_off_time.type) === "advance") {
|
|
1490
1506
|
const currentCutOffTime = (0, import_dayjs.default)().add(
|
|
1491
1507
|
item._productOrigin.cut_off_time.unit,
|
|
1492
1508
|
item._productOrigin.cut_off_time.unit_type
|
|
@@ -1512,10 +1528,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1512
1528
|
cartItems2.forEach((item) => {
|
|
1513
1529
|
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
1514
1530
|
if (isSingleResource) {
|
|
1515
|
-
accountDuration += ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value)
|
|
1531
|
+
accountDuration += ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10;
|
|
1516
1532
|
} else {
|
|
1517
|
-
if (accountDuration < (((_d2 = (_c2 = item._productOrigin) == null ? void 0 : _c2.duration) == null ? void 0 : _d2.value)
|
|
1518
|
-
accountDuration = ((_f2 = (_e2 = item._productOrigin) == null ? void 0 : _e2.duration) == null ? void 0 : _f2.value)
|
|
1533
|
+
if (accountDuration < (((_d2 = (_c2 = item._productOrigin) == null ? void 0 : _c2.duration) == null ? void 0 : _d2.value) || 10)) {
|
|
1534
|
+
accountDuration = ((_f2 = (_e2 = item._productOrigin) == null ? void 0 : _e2.duration) == null ? void 0 : _f2.value) || 10;
|
|
1519
1535
|
}
|
|
1520
1536
|
}
|
|
1521
1537
|
});
|
|
@@ -1551,6 +1567,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1551
1567
|
];
|
|
1552
1568
|
}
|
|
1553
1569
|
const resourcesUseableMap = {};
|
|
1570
|
+
const hasFlexibleDuration = cartItems.some((item) => {
|
|
1571
|
+
var _a2, _b2;
|
|
1572
|
+
return ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.type) === "flexible";
|
|
1573
|
+
});
|
|
1574
|
+
const operating_day_boundary = (_h = (_g = this.shopStore.get("core")) == null ? void 0 : _g.core) == null ? void 0 : _h.operating_day_boundary;
|
|
1554
1575
|
const timeSlots = (0, import_resources.getTimeSlicesByResources)({
|
|
1555
1576
|
resourceIds,
|
|
1556
1577
|
resourcesMap,
|
|
@@ -1558,13 +1579,17 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1558
1579
|
currentDate: dateRange[0].date,
|
|
1559
1580
|
split: 10,
|
|
1560
1581
|
resourcesUseableMap,
|
|
1561
|
-
cut_off_time: maxCutOffTime
|
|
1582
|
+
cut_off_time: maxCutOffTime,
|
|
1583
|
+
hasFlexibleDuration,
|
|
1584
|
+
operating_day_boundary
|
|
1562
1585
|
});
|
|
1563
1586
|
return timeSlots;
|
|
1564
1587
|
}
|
|
1565
|
-
//
|
|
1588
|
+
// 提交时间切片,绑定到对应购物车的商品上,更新购物车---只有 duration 商品
|
|
1566
1589
|
submitTimeSlot(timeSlots) {
|
|
1590
|
+
var _a, _b;
|
|
1567
1591
|
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
|
|
1592
|
+
const allResources = this.store.date.getResourcesListByDate(timeSlots.start_at.format("YYYY-MM-DD"));
|
|
1568
1593
|
const itemsByAccount = cartItems.reduce(
|
|
1569
1594
|
(acc, item) => {
|
|
1570
1595
|
const holderId = item.holder_id;
|
|
@@ -1576,25 +1601,48 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1576
1601
|
},
|
|
1577
1602
|
{}
|
|
1578
1603
|
);
|
|
1604
|
+
const operating_day_boundary = (_b = (_a = this.shopStore.get("core")) == null ? void 0 : _a.core) == null ? void 0 : _b.operating_day_boundary;
|
|
1579
1605
|
Object.values(itemsByAccount).forEach((accountItems) => {
|
|
1580
1606
|
let currentStartTime = timeSlots.start_at.format("YYYY-MM-DD HH:mm");
|
|
1581
1607
|
accountItems.forEach((item, index) => {
|
|
1582
|
-
var
|
|
1608
|
+
var _a2;
|
|
1583
1609
|
const newResources = (0, import_lodash_es.cloneDeep)(item._origin.resources);
|
|
1584
1610
|
newResources.forEach((resource) => {
|
|
1585
|
-
var
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1611
|
+
var _a3, _b2, _c, _d, _e;
|
|
1612
|
+
if (((_b2 = (_a3 = item._productOrigin) == null ? void 0 : _a3.duration) == null ? void 0 : _b2.type) === "flexible") {
|
|
1613
|
+
item.duration = {
|
|
1614
|
+
type: "minutes",
|
|
1615
|
+
value: 10
|
|
1616
|
+
};
|
|
1617
|
+
resource.startTime = timeSlots.start_at.format("YYYY-MM-DD HH:mm");
|
|
1618
|
+
const targetResourceTimes = (_c = allResources == null ? void 0 : allResources.find((n) => n.id === resource.id)) == null ? void 0 : _c.times;
|
|
1619
|
+
const resourcesEndTime = targetResourceTimes.reduce((acc, curr) => {
|
|
1620
|
+
return (0, import_dayjs.default)(curr.end_at).isBefore((0, import_dayjs.default)(acc.end_at)) ? curr : acc;
|
|
1621
|
+
}, targetResourceTimes[0]);
|
|
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;
|
|
1625
|
+
let formattedEndTime;
|
|
1626
|
+
if (typeof endTime === "string" && endTime.includes(":") && !endTime.includes(" ") && !endTime.includes("T")) {
|
|
1627
|
+
const currentDate = timeSlots.start_at.format("YYYY-MM-DD");
|
|
1628
|
+
formattedEndTime = (0, import_dayjs.default)(`${currentDate} ${endTime}`);
|
|
1629
|
+
} else {
|
|
1630
|
+
formattedEndTime = (0, import_dayjs.default)(endTime);
|
|
1631
|
+
}
|
|
1632
|
+
resource.endTime = formattedEndTime.format("YYYY-MM-DD HH:mm");
|
|
1633
|
+
} else {
|
|
1634
|
+
resource.startTime = currentStartTime;
|
|
1635
|
+
resource.endTime = (0, import_dayjs.default)(currentStartTime).add(
|
|
1636
|
+
((_e = (_d = item._productOrigin) == null ? void 0 : _d.duration) == null ? void 0 : _e.value) || 10,
|
|
1637
|
+
"minutes"
|
|
1638
|
+
).format("YYYY-MM-DD HH:mm");
|
|
1639
|
+
}
|
|
1592
1640
|
});
|
|
1593
1641
|
this.store.cart.updateItem({
|
|
1594
1642
|
_id: item._id,
|
|
1595
1643
|
resources: newResources
|
|
1596
1644
|
});
|
|
1597
|
-
if (index < accountItems.length - 1 && ((
|
|
1645
|
+
if (index < accountItems.length - 1 && ((_a2 = newResources == null ? void 0 : newResources[0]) == null ? void 0 : _a2.resourceType) === "single") {
|
|
1598
1646
|
currentStartTime = newResources[0].endTime;
|
|
1599
1647
|
}
|
|
1600
1648
|
});
|
|
@@ -1939,7 +1987,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1939
1987
|
return false;
|
|
1940
1988
|
const timeSlots = (0, import_resources.getTimeSlicesByResource)({
|
|
1941
1989
|
resource: n,
|
|
1942
|
-
duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) ||
|
|
1990
|
+
duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10,
|
|
1943
1991
|
split: 10,
|
|
1944
1992
|
currentDate: dateRange[0].date
|
|
1945
1993
|
});
|
|
@@ -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,11 @@ 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?: {
|
|
101
|
+
type: string;
|
|
102
|
+
time: string;
|
|
103
|
+
} | undefined;
|
|
99
104
|
}) => TimeSliceItem[];
|
|
100
105
|
/**
|
|
101
106
|
* @title: 获取时间切片列表的交集
|
|
@@ -133,7 +138,7 @@ export declare const mergeSubResourcesTimeSlices: (resources: ResourceItem[], re
|
|
|
133
138
|
* @return {*}
|
|
134
139
|
* @Author: zhiwei.Wang
|
|
135
140
|
*/
|
|
136
|
-
export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split, capacity, resourcesUseableMap, cut_off_time, }: {
|
|
141
|
+
export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split, capacity, resourcesUseableMap, cut_off_time, hasFlexibleDuration, operating_day_boundary }: {
|
|
137
142
|
resourceIds: number[];
|
|
138
143
|
resourcesMap: any;
|
|
139
144
|
duration: number;
|
|
@@ -151,6 +156,11 @@ export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, dur
|
|
|
151
156
|
unit: number;
|
|
152
157
|
} | undefined;
|
|
153
158
|
} | undefined;
|
|
159
|
+
hasFlexibleDuration?: boolean | undefined;
|
|
160
|
+
operating_day_boundary?: {
|
|
161
|
+
type: string;
|
|
162
|
+
time: string;
|
|
163
|
+
} | undefined;
|
|
154
164
|
}) => any[];
|
|
155
165
|
/**
|
|
156
166
|
* @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,10 @@ var getTimeSlicesByResource = ({
|
|
|
365
366
|
resourcesUseableMap[resource.id] = _status.usable;
|
|
366
367
|
}
|
|
367
368
|
if (_status.usable) {
|
|
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")) {
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
368
373
|
timeSlices.push({
|
|
369
374
|
...timeSlice,
|
|
370
375
|
// 这里需要补充这个时间段内是否可预约
|
|
@@ -422,7 +427,9 @@ var getTimeSlicesByResources = ({
|
|
|
422
427
|
split,
|
|
423
428
|
capacity,
|
|
424
429
|
resourcesUseableMap,
|
|
425
|
-
cut_off_time
|
|
430
|
+
cut_off_time,
|
|
431
|
+
hasFlexibleDuration,
|
|
432
|
+
operating_day_boundary
|
|
426
433
|
}) => {
|
|
427
434
|
let resources = getResourcesByIds(resourcesMap, resourceIds);
|
|
428
435
|
mergeSubResourcesTimeSlices(resources, resourcesMap);
|
|
@@ -446,7 +453,9 @@ var getTimeSlicesByResources = ({
|
|
|
446
453
|
currentDate,
|
|
447
454
|
capacity,
|
|
448
455
|
resourcesUseableMap,
|
|
449
|
-
cut_off_time
|
|
456
|
+
cut_off_time,
|
|
457
|
+
hasFlexibleDuration,
|
|
458
|
+
operating_day_boundary
|
|
450
459
|
})
|
|
451
460
|
);
|
|
452
461
|
},
|