@pisell/pisellos 3.0.38 → 3.0.40
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/Cart/types.d.ts +3 -1
- package/dist/modules/Cart/utils/cartProduct.js +3 -2
- package/dist/modules/Date/index.d.ts +1 -0
- package/dist/modules/Date/index.js +10 -0
- package/dist/modules/Summary/utils.js +2 -2
- package/dist/solution/BookingByStep/index.d.ts +2 -1
- package/dist/solution/BookingByStep/index.js +163 -104
- package/dist/solution/BookingByStep/utils/resources.d.ts +12 -2
- package/dist/solution/BookingByStep/utils/resources.js +15 -4
- package/lib/modules/Cart/types.d.ts +3 -1
- package/lib/modules/Cart/utils/cartProduct.js +2 -2
- package/lib/modules/Date/index.d.ts +1 -0
- package/lib/modules/Date/index.js +6 -0
- package/lib/modules/Summary/utils.js +2 -2
- package/lib/solution/BookingByStep/index.d.ts +2 -1
- package/lib/solution/BookingByStep/index.js +92 -45
- package/lib/solution/BookingByStep/utils/resources.d.ts +12 -2
- package/lib/solution/BookingByStep/utils/resources.js +13 -4
- package/package.json +1 -1
|
@@ -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
|
}
|
|
@@ -209,11 +215,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
209
215
|
key: "loadProducts",
|
|
210
216
|
value: function () {
|
|
211
217
|
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref) {
|
|
212
|
-
var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, userPlugin, customer_id, _userPlugin$get, productsData;
|
|
218
|
+
var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, schedule_date, userPlugin, customer_id, _userPlugin$get, productsData;
|
|
213
219
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
214
220
|
while (1) switch (_context2.prev = _context2.next) {
|
|
215
221
|
case 0:
|
|
216
|
-
_ref$category_ids = _ref.category_ids, category_ids = _ref$category_ids === void 0 ? [] : _ref$category_ids, _ref$product_ids = _ref.product_ids, product_ids = _ref$product_ids === void 0 ? [] : _ref$product_ids, _ref$collection = _ref.collection, collection = _ref$collection === void 0 ? [] : _ref$collection;
|
|
222
|
+
_ref$category_ids = _ref.category_ids, category_ids = _ref$category_ids === void 0 ? [] : _ref$category_ids, _ref$product_ids = _ref.product_ids, product_ids = _ref$product_ids === void 0 ? [] : _ref$product_ids, _ref$collection = _ref.collection, collection = _ref$collection === void 0 ? [] : _ref$collection, schedule_date = _ref.schedule_date;
|
|
217
223
|
// // 如果 schedule_ids 为空,则需要尝试从 schedule 模块里获取
|
|
218
224
|
// if (!schedule_ids?.length) {
|
|
219
225
|
// const schedule_ids_data = this.store.schedule
|
|
@@ -247,9 +253,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
247
253
|
category_ids: category_ids,
|
|
248
254
|
ids: product_ids,
|
|
249
255
|
collection: collection,
|
|
250
|
-
front_end_cache_id: this.cacheId
|
|
256
|
+
front_end_cache_id: this.cacheId,
|
|
251
257
|
// client_schedule_ids: schedule_ids,
|
|
252
|
-
|
|
258
|
+
schedule_date: schedule_date
|
|
253
259
|
}, {
|
|
254
260
|
useCache: true
|
|
255
261
|
});
|
|
@@ -318,8 +324,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
318
324
|
return this.loadProducts({
|
|
319
325
|
// schedule_ids: scheduleIds,
|
|
320
326
|
product_ids: allProductIds,
|
|
321
|
-
category_ids: category_ids
|
|
322
|
-
|
|
327
|
+
category_ids: category_ids,
|
|
328
|
+
schedule_date: date
|
|
323
329
|
});
|
|
324
330
|
case 9:
|
|
325
331
|
return _context3.abrupt("return", _context3.sent);
|
|
@@ -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 ? void 0 : _this9$shopStore$get.operating_day_boundary;
|
|
1562
1572
|
productResources.forEach(function (item) {
|
|
1563
1573
|
// 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
|
|
1564
1574
|
// 同时,在这一步尝试去拉一下时间片,基于商品的时长,看每个资源是否还有空余时间能对这个商品做服务,如果没有则过滤
|
|
1565
1575
|
item.renderList = item.renderList.filter(function (n) {
|
|
1566
|
-
var _cartItem$
|
|
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$
|
|
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$
|
|
1631
|
+
var _cartItem$_productOri7, _cartItem$_productOri8;
|
|
1619
1632
|
var selectedResources = [];
|
|
1620
1633
|
var formatCapacity = formatDefaultCapacitys({
|
|
1621
|
-
capacity: (_cartItem$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
1826
|
-
return acc + ((
|
|
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$
|
|
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) || [];
|
|
@@ -1907,15 +1909,20 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1907
1909
|
var hasOverlap = !dayjs(item.time.start_at).isAfter(dayjs(timeSlots.start_at)) && !dayjs(item.time.end_at).isBefore(dayjs(timeSlots.end_at));
|
|
1908
1910
|
return hasOverlap ? sum + item.pax : sum;
|
|
1909
1911
|
}, 0);
|
|
1912
|
+
|
|
1913
|
+
// 如果资源是单个预约,并且有 totalCapacity,则认为在当前 timeSlots 资源已经被选择过,就不可用了
|
|
1914
|
+
if (n.resourceType === 'single' && totalCapacity > 0) {
|
|
1915
|
+
return 0; // continue
|
|
1916
|
+
}
|
|
1910
1917
|
var canUseTime = mTimes.find(function (item) {
|
|
1911
|
-
var _cartItem$
|
|
1918
|
+
var _cartItem$_productOri12;
|
|
1912
1919
|
var res = getIsUsableByTimeItem({
|
|
1913
1920
|
timeSlice: timeSlots,
|
|
1914
1921
|
time: item,
|
|
1915
1922
|
resource: n,
|
|
1916
1923
|
currentCount: totalCapacity + (capacity || 0),
|
|
1917
1924
|
resourcesUseableMap: resourcesUseableMap,
|
|
1918
|
-
cut_off_time: (_cartItem$
|
|
1925
|
+
cut_off_time: (_cartItem$_productOri12 = cartItem._productOrigin) === null || _cartItem$_productOri12 === void 0 ? void 0 : _cartItem$_productOri12.cut_off_time
|
|
1919
1926
|
});
|
|
1920
1927
|
// 如果只是因为子资源容量不够,而不是子资源被预约导致没时间片,不应该标记子资源为不可用,从而影响组合资源的情况
|
|
1921
1928
|
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[n.id]) !== false && res.reason !== 'capacityOnly') {
|
|
@@ -1978,7 +1985,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1978
1985
|
key: "autoSelectAllProductResources",
|
|
1979
1986
|
value: function autoSelectAllProductResources(resources_code, timeSlots) {
|
|
1980
1987
|
var _dateRange$4,
|
|
1981
|
-
|
|
1988
|
+
_this10 = this;
|
|
1982
1989
|
var dateRange = this.store.date.getDateRange();
|
|
1983
1990
|
var resources = [];
|
|
1984
1991
|
if (dateRange !== null && dateRange !== void 0 && (_dateRange$4 = dateRange[0]) !== null && _dateRange$4 !== void 0 && _dateRange$4.date) {
|
|
@@ -1997,11 +2004,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1997
2004
|
// timeSlots 传进来的只是用户选中的时间片,但是实际上需要根据多个商品时间进行累加
|
|
1998
2005
|
// 假设 timeSlots.start_time 是15:40 duration 是 30min
|
|
1999
2006
|
// 第一个商品分配完以后,第二个商品分配的start_time应该是第一个商品的 end_time ,然后 end_time 应该是 start_time+duration
|
|
2000
|
-
|
|
2001
|
-
cartItems.
|
|
2007
|
+
// 判断购物车里是否有 flexible 类型的商品,如果有则不累加时间
|
|
2008
|
+
var hasFlexibleProduct = cartItems.some(function (item) {
|
|
2002
2009
|
var _item$_productOrigin3;
|
|
2010
|
+
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';
|
|
2011
|
+
});
|
|
2012
|
+
cartItems.forEach(function (item, index) {
|
|
2013
|
+
var _item$_productOrigin4;
|
|
2003
2014
|
var formatCapacity = formatDefaultCapacitys({
|
|
2004
|
-
capacity: (_item$
|
|
2015
|
+
capacity: (_item$_productOrigin4 = item._productOrigin) === null || _item$_productOrigin4 === void 0 ? void 0 : _item$_productOrigin4.capacity,
|
|
2005
2016
|
product_bundle: item._origin.product.product_bundle
|
|
2006
2017
|
});
|
|
2007
2018
|
var currentCapacity = getSumCapacity({
|
|
@@ -2017,17 +2028,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2017
2028
|
};
|
|
2018
2029
|
}
|
|
2019
2030
|
if (recordTimeSlots) {
|
|
2020
|
-
var _item$
|
|
2031
|
+
var _item$_productOrigin5, _item$_productOrigin6;
|
|
2021
2032
|
// 同一账号下,如果当前商品不是第一个,则需要根据上一个商品的 end_time 和 duration 计算出当前商品的 start_time 和 end_time
|
|
2022
2033
|
// 前提:当前资源是单个预约才需要这么做
|
|
2023
|
-
var currentResourceConfig = (_item$
|
|
2034
|
+
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
2035
|
return n.code === resources_code;
|
|
2025
2036
|
});
|
|
2026
2037
|
// 只有 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((
|
|
2038
|
+
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) {
|
|
2039
|
+
var _item$_productOrigin7, _item$_productOrigin8;
|
|
2040
|
+
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');
|
|
2041
|
+
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
2042
|
recordTimeSlots = {
|
|
2032
2043
|
start_time: start_at.format('HH:mm'),
|
|
2033
2044
|
end_time: end_at.format('HH:mm'),
|
|
@@ -2036,7 +2047,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2036
2047
|
};
|
|
2037
2048
|
}
|
|
2038
2049
|
// 如果传递了 timeSlots,代表是第二种资源,则直接拿 timeSlots 去匹配
|
|
2039
|
-
var res =
|
|
2050
|
+
var res = _this10.autoSelectAccountResources({
|
|
2040
2051
|
cartItem: item,
|
|
2041
2052
|
holder_id: item.holder_id,
|
|
2042
2053
|
resources_code: resources_code,
|
|
@@ -2062,7 +2073,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2062
2073
|
}
|
|
2063
2074
|
res.selectedResource.capacity = currentCapacity;
|
|
2064
2075
|
checkSubResourcesCapacity(res.selectedResource);
|
|
2065
|
-
|
|
2076
|
+
_this10.store.cart.updateItem({
|
|
2066
2077
|
_id: item._id,
|
|
2067
2078
|
// 这里要做去重,避免出现同样类型的资源被塞进同一个商品
|
|
2068
2079
|
resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
|
|
@@ -2075,12 +2086,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2075
2086
|
errorList.push(item._id);
|
|
2076
2087
|
}
|
|
2077
2088
|
} else {
|
|
2078
|
-
var _item$
|
|
2089
|
+
var _item$_productOrigin9, _productResources$fin;
|
|
2079
2090
|
// 这里必须每次循环重新读,避免前一次循环操作了购物车,导致数据变更
|
|
2080
|
-
var allCartItems = cloneDeep(
|
|
2091
|
+
var allCartItems = cloneDeep(_this10.store.cart.getItems());
|
|
2081
2092
|
// 如果没有传递 timeSlots,代表是第一种资源,则直接拿商品的 duration,到资源列表里找一个公共可用的
|
|
2082
2093
|
var selectedResources = [];
|
|
2083
|
-
var _resources = cloneDeep(((_item$
|
|
2094
|
+
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
2095
|
var currentResourcesRenderList = [];
|
|
2085
2096
|
_resources.forEach(function (n) {
|
|
2086
2097
|
var _n$renderList;
|
|
@@ -2092,7 +2103,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2092
2103
|
var recordCount = (m.capacity || 0) - (selectResourcesMap[m.id] || 0);
|
|
2093
2104
|
var timeSlots = getTimeSlicesByResource({
|
|
2094
2105
|
resource: m,
|
|
2095
|
-
duration: (item === null || item === void 0 || (_item$duration = item.duration) === null || _item$duration === void 0 ? void 0 : _item$duration.value) ||
|
|
2106
|
+
duration: (item === null || item === void 0 || (_item$duration = item.duration) === null || _item$duration === void 0 ? void 0 : _item$duration.value) || 10,
|
|
2096
2107
|
split: 10,
|
|
2097
2108
|
currentDate: dateRange[0].date
|
|
2098
2109
|
});
|
|
@@ -2141,7 +2152,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2141
2152
|
} else {
|
|
2142
2153
|
selectResourcesMap[targetResource.id] += currentCapacity;
|
|
2143
2154
|
}
|
|
2144
|
-
|
|
2155
|
+
_this10.store.cart.updateItem({
|
|
2145
2156
|
_id: item._id,
|
|
2146
2157
|
resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
|
|
2147
2158
|
return existingRes.resourceType !== targetRenderList[0].resourceType;
|
|
@@ -2161,7 +2172,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2161
2172
|
// 如果购物车里没有 holderid数据,证明不按 holder 类流程预约走,给所有购物车一次性分派即可,不做账号下资源互斥逻辑
|
|
2162
2173
|
if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
|
|
2163
2174
|
accountList.forEach(function (account) {
|
|
2164
|
-
var cartItems =
|
|
2175
|
+
var cartItems = _this10.store.cart.getCartByAccount(account.getId());
|
|
2165
2176
|
selectForCartResources(cartItems);
|
|
2166
2177
|
});
|
|
2167
2178
|
} else {
|
|
@@ -2176,9 +2187,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2176
2187
|
key: "getTimeSlotByAllResources",
|
|
2177
2188
|
value: function getTimeSlotByAllResources(resources_code) {
|
|
2178
2189
|
var _dateRange,
|
|
2179
|
-
|
|
2190
|
+
_this11 = this,
|
|
2180
2191
|
_cartItems$,
|
|
2181
|
-
_cartItems$2
|
|
2192
|
+
_cartItems$2,
|
|
2193
|
+
_this$shopStore$get;
|
|
2182
2194
|
var dateRange = this.store.date.getDateRange();
|
|
2183
2195
|
// 取出购物车中所有一已选择的第一步资源
|
|
2184
2196
|
var resources = [];
|
|
@@ -2194,8 +2206,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2194
2206
|
var maxCutOffTime = undefined;
|
|
2195
2207
|
var maxCutOffTimeValue = dayjs();
|
|
2196
2208
|
cartItems.forEach(function (item) {
|
|
2197
|
-
var _item$
|
|
2198
|
-
(_item$
|
|
2209
|
+
var _item$_productOrigin10, _item$_productOrigin11, _item$_productOrigin12, _item$_productOrigin13;
|
|
2210
|
+
(_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
2211
|
// TODO: 少了个 status 的判断
|
|
2200
2212
|
if (n.code === resources_code) {
|
|
2201
2213
|
resources.push.apply(resources, _toConsumableArray(n.renderList || []));
|
|
@@ -2208,10 +2220,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2208
2220
|
if (item.resource_id) {
|
|
2209
2221
|
resourceIds.push(item.resource_id);
|
|
2210
2222
|
}
|
|
2211
|
-
resourcesTypeId = item === null || item === void 0 || (_item$
|
|
2223
|
+
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
2224
|
return n.code === resources_code;
|
|
2213
|
-
})) === null || _item$
|
|
2214
|
-
if ((_item$
|
|
2225
|
+
})) === null || _item$_productOrigin11 === void 0 ? void 0 : _item$_productOrigin11.id;
|
|
2226
|
+
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
2227
|
var currentCutOffTime = dayjs().add(item._productOrigin.cut_off_time.unit, item._productOrigin.cut_off_time.unit_type);
|
|
2216
2228
|
if (currentCutOffTime.isAfter(maxCutOffTimeValue, 'minute')) {
|
|
2217
2229
|
maxCutOffTimeValue = currentCutOffTime;
|
|
@@ -2239,13 +2251,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2239
2251
|
cartItems.forEach(function (item) {
|
|
2240
2252
|
// 单个预约累加账号 多个预约取最大值
|
|
2241
2253
|
if (isSingleResource) {
|
|
2242
|
-
var _item$
|
|
2243
|
-
accountDuration += (
|
|
2254
|
+
var _item$_productOrigin14;
|
|
2255
|
+
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
2256
|
} else {
|
|
2245
|
-
var _item$
|
|
2246
|
-
if (accountDuration < ((
|
|
2247
|
-
var _item$
|
|
2248
|
-
accountDuration = (
|
|
2257
|
+
var _item$_productOrigin15;
|
|
2258
|
+
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)) {
|
|
2259
|
+
var _item$_productOrigin16;
|
|
2260
|
+
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
2261
|
}
|
|
2250
2262
|
}
|
|
2251
2263
|
});
|
|
@@ -2255,7 +2267,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2255
2267
|
};
|
|
2256
2268
|
if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
|
|
2257
2269
|
accountList.forEach(function (account) {
|
|
2258
|
-
var cartItems =
|
|
2270
|
+
var cartItems = _this11.store.cart.getCartByAccount(account.getId());
|
|
2259
2271
|
checkDuration(cartItems);
|
|
2260
2272
|
});
|
|
2261
2273
|
} else {
|
|
@@ -2281,6 +2293,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2281
2293
|
}];
|
|
2282
2294
|
}
|
|
2283
2295
|
var resourcesUseableMap = {};
|
|
2296
|
+
var hasFlexibleDuration = cartItems.some(function (item) {
|
|
2297
|
+
var _item$_productOrigin17;
|
|
2298
|
+
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';
|
|
2299
|
+
});
|
|
2300
|
+
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
2301
|
var timeSlots = getTimeSlicesByResources({
|
|
2285
2302
|
resourceIds: resourceIds,
|
|
2286
2303
|
resourcesMap: resourcesMap,
|
|
@@ -2288,21 +2305,27 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2288
2305
|
currentDate: dateRange[0].date,
|
|
2289
2306
|
split: 10,
|
|
2290
2307
|
resourcesUseableMap: resourcesUseableMap,
|
|
2291
|
-
cut_off_time: maxCutOffTime
|
|
2308
|
+
cut_off_time: maxCutOffTime,
|
|
2309
|
+
hasFlexibleDuration: hasFlexibleDuration,
|
|
2310
|
+
operating_day_boundary: operating_day_boundary
|
|
2292
2311
|
});
|
|
2293
2312
|
return timeSlots;
|
|
2294
2313
|
}
|
|
2295
2314
|
|
|
2296
|
-
//
|
|
2315
|
+
// 提交时间切片,绑定到对应购物车的商品上,更新购物车---只有 duration 商品
|
|
2297
2316
|
}, {
|
|
2298
2317
|
key: "submitTimeSlot",
|
|
2299
2318
|
value: function submitTimeSlot(timeSlots) {
|
|
2300
|
-
var
|
|
2319
|
+
var _this$shopStore$get2,
|
|
2320
|
+
_this12 = this;
|
|
2301
2321
|
// 以账号为维度处理数据。购物车里每一项的 startTime应该是前一个商品的 endTime,如果是第一个商品则用 timeSlots.start_at
|
|
2302
2322
|
var cartItems = this.store.cart.getItems().filter(function (n) {
|
|
2303
2323
|
return !isNormalProduct(n._productOrigin);
|
|
2304
2324
|
});
|
|
2305
2325
|
|
|
2326
|
+
// 取出所有资源列表
|
|
2327
|
+
var allResources = this.store.date.getResourcesListByDate(timeSlots.start_at.format('YYYY-MM-DD'));
|
|
2328
|
+
|
|
2306
2329
|
// 按账号分组
|
|
2307
2330
|
var itemsByAccount = cartItems.reduce(function (acc, item) {
|
|
2308
2331
|
var holderId = item.holder_id;
|
|
@@ -2313,6 +2336,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2313
2336
|
return acc;
|
|
2314
2337
|
}, {});
|
|
2315
2338
|
|
|
2339
|
+
// 店铺营业结束时间
|
|
2340
|
+
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;
|
|
2341
|
+
|
|
2316
2342
|
// 处理每个账号的商品
|
|
2317
2343
|
Object.values(itemsByAccount).forEach(function (accountItems) {
|
|
2318
2344
|
var currentStartTime = timeSlots.start_at.format('YYYY-MM-DD HH:mm');
|
|
@@ -2320,12 +2346,45 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2320
2346
|
var _newResources$;
|
|
2321
2347
|
var newResources = cloneDeep(item._origin.resources);
|
|
2322
2348
|
newResources.forEach(function (resource) {
|
|
2323
|
-
var _item$
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2349
|
+
var _item$_productOrigin18;
|
|
2350
|
+
// 如果商品配置的是灵活时长,开始时间设置为提交的时间,结束时间从资源的可用最晚时间和店铺营业结束时间里取一个最早的
|
|
2351
|
+
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') {
|
|
2352
|
+
var _allResources$find;
|
|
2353
|
+
item.duration = {
|
|
2354
|
+
type: 'minutes',
|
|
2355
|
+
value: 10
|
|
2356
|
+
};
|
|
2357
|
+
resource.startTime = timeSlots.start_at.format('YYYY-MM-DD HH:mm');
|
|
2358
|
+
// 找到resource.times里最早的end_at
|
|
2359
|
+
var targetResourceTimes = allResources === null || allResources === void 0 || (_allResources$find = allResources.find(function (n) {
|
|
2360
|
+
return n.id === resource.id;
|
|
2361
|
+
})) === null || _allResources$find === void 0 ? void 0 : _allResources$find.times;
|
|
2362
|
+
var resourcesEndTime = targetResourceTimes.reduce(function (acc, curr) {
|
|
2363
|
+
return dayjs(curr.end_at).isBefore(dayjs(acc.end_at)) ? curr : acc;
|
|
2364
|
+
}, targetResourceTimes[0]);
|
|
2365
|
+
|
|
2366
|
+
// 将 operating_day_boundary 转换为与 resourcesEndTime.end_at 相同日期的完整日期时间
|
|
2367
|
+
var resourceDate = dayjs(resourcesEndTime.end_at).format('YYYY-MM-DD');
|
|
2368
|
+
var operatingBoundaryDateTime = "".concat(resourceDate, " ").concat(operating_day_boundary.type === 'start_time' ? "23:59" : operating_day_boundary.time);
|
|
2369
|
+
var endTime = dayjs(resourcesEndTime.end_at).isBefore(dayjs(operatingBoundaryDateTime)) ? resourcesEndTime.end_at : operatingBoundaryDateTime;
|
|
2370
|
+
// 修复:如果 endTime 只是时间格式(如 "17:00"),需要加上日期
|
|
2371
|
+
var formattedEndTime;
|
|
2372
|
+
if (typeof endTime === 'string' && endTime.includes(':') && !endTime.includes(' ') && !endTime.includes('T')) {
|
|
2373
|
+
// 如果是纯时间格式,与当前日期合并
|
|
2374
|
+
var currentDate = timeSlots.start_at.format('YYYY-MM-DD');
|
|
2375
|
+
formattedEndTime = dayjs("".concat(currentDate, " ").concat(endTime));
|
|
2376
|
+
} else {
|
|
2377
|
+
formattedEndTime = dayjs(endTime);
|
|
2378
|
+
}
|
|
2379
|
+
resource.endTime = formattedEndTime.format('YYYY-MM-DD HH:mm');
|
|
2380
|
+
} else {
|
|
2381
|
+
var _item$_productOrigin19;
|
|
2382
|
+
resource.startTime = currentStartTime;
|
|
2383
|
+
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');
|
|
2384
|
+
}
|
|
2385
|
+
// delete resource.times;
|
|
2327
2386
|
});
|
|
2328
|
-
|
|
2387
|
+
_this12.store.cart.updateItem({
|
|
2329
2388
|
_id: item._id,
|
|
2330
2389
|
resources: newResources
|
|
2331
2390
|
});
|
|
@@ -2408,12 +2467,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2408
2467
|
}
|
|
2409
2468
|
}, {
|
|
2410
2469
|
key: "getTimeslotBySchedule",
|
|
2411
|
-
value: function getTimeslotBySchedule(
|
|
2470
|
+
value: function getTimeslotBySchedule(_ref9) {
|
|
2412
2471
|
var _this$store$currentPr2, _targetProductData$pr;
|
|
2413
|
-
var date =
|
|
2414
|
-
scheduleIds =
|
|
2415
|
-
resources =
|
|
2416
|
-
product =
|
|
2472
|
+
var date = _ref9.date,
|
|
2473
|
+
scheduleIds = _ref9.scheduleIds,
|
|
2474
|
+
resources = _ref9.resources,
|
|
2475
|
+
product = _ref9.product;
|
|
2417
2476
|
var targetProduct = this.store.currentProduct;
|
|
2418
2477
|
// 如果外面传递了product 优先用外面的
|
|
2419
2478
|
var targetProductData = product || (targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.getData());
|
|
@@ -2531,19 +2590,19 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2531
2590
|
}
|
|
2532
2591
|
}, {
|
|
2533
2592
|
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 =
|
|
2593
|
+
value: function addProductToCart(_ref10) {
|
|
2594
|
+
var _this13 = this;
|
|
2595
|
+
var product = _ref10.product,
|
|
2596
|
+
date = _ref10.date,
|
|
2597
|
+
account = _ref10.account;
|
|
2598
|
+
var _ref11 = product || {},
|
|
2599
|
+
bundle = _ref11.bundle,
|
|
2600
|
+
options = _ref11.options,
|
|
2601
|
+
origin = _ref11.origin,
|
|
2602
|
+
product_variant_id = _ref11.product_variant_id,
|
|
2603
|
+
rowKey = _ref11.rowKey,
|
|
2604
|
+
_ref11$quantity = _ref11.quantity,
|
|
2605
|
+
quantity = _ref11$quantity === void 0 ? 1 : _ref11$quantity;
|
|
2547
2606
|
var productData = _objectSpread(_objectSpread({}, origin), {}, {
|
|
2548
2607
|
product_variant_id: product_variant_id
|
|
2549
2608
|
});
|
|
@@ -2587,7 +2646,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2587
2646
|
});
|
|
2588
2647
|
if (cartItemsByDate.length) {
|
|
2589
2648
|
cartItemsByDate.forEach(function (n) {
|
|
2590
|
-
|
|
2649
|
+
_this13.store.cart.removeItem(n._id);
|
|
2591
2650
|
});
|
|
2592
2651
|
}
|
|
2593
2652
|
}
|
|
@@ -2651,7 +2710,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2651
2710
|
}, {
|
|
2652
2711
|
key: "getResourcesByCartItemAndCode",
|
|
2653
2712
|
value: function getResourcesByCartItemAndCode(cartItemId, resourceCode) {
|
|
2654
|
-
var _cartItem$
|
|
2713
|
+
var _cartItem$_productOri13, _cartItem$_productOri14;
|
|
2655
2714
|
var dateRange = this.store.date.getDateRange();
|
|
2656
2715
|
var resources = [];
|
|
2657
2716
|
if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
|
|
@@ -2675,7 +2734,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2675
2734
|
if (!cartItem) return [];
|
|
2676
2735
|
var selectedResources = [];
|
|
2677
2736
|
var formatCapacity = formatDefaultCapacitys({
|
|
2678
|
-
capacity: (_cartItem$
|
|
2737
|
+
capacity: (_cartItem$_productOri13 = cartItem._productOrigin) === null || _cartItem$_productOri13 === void 0 ? void 0 : _cartItem$_productOri13.capacity,
|
|
2679
2738
|
product_bundle: cartItem._origin.product.product_bundle
|
|
2680
2739
|
});
|
|
2681
2740
|
cartItem._origin.metadata.capacity = formatCapacity;
|
|
@@ -2687,7 +2746,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2687
2746
|
} else {
|
|
2688
2747
|
selectedResources = getOthersCartSelectedResources(cartItems, cartItem._id, resourcesMap);
|
|
2689
2748
|
}
|
|
2690
|
-
var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$
|
|
2749
|
+
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
2750
|
var targetResource = productResources.find(function (resource) {
|
|
2692
2751
|
return resource.code === resourceCode;
|
|
2693
2752
|
});
|
|
@@ -2710,7 +2769,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2710
2769
|
});
|
|
2711
2770
|
if (mTimes.length === 0) return false;
|
|
2712
2771
|
var canUseArr = mTimes.map(function (item) {
|
|
2713
|
-
var _cartItem$
|
|
2772
|
+
var _cartItem$_productOri15;
|
|
2714
2773
|
var res = getIsUsableByTimeItem({
|
|
2715
2774
|
timeSlice: {
|
|
2716
2775
|
start_time: startTime.format('HH:mm'),
|
|
@@ -2722,7 +2781,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2722
2781
|
resource: m,
|
|
2723
2782
|
currentCount: currentCapacity || 0,
|
|
2724
2783
|
resourcesUseableMap: resourcesUseableMap,
|
|
2725
|
-
cut_off_time: (_cartItem$
|
|
2784
|
+
cut_off_time: (_cartItem$_productOri15 = cartItem._productOrigin) === null || _cartItem$_productOri15 === void 0 ? void 0 : _cartItem$_productOri15.cut_off_time
|
|
2726
2785
|
});
|
|
2727
2786
|
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
|
|
2728
2787
|
resourcesUseableMap[m.id] = res.usable;
|
|
@@ -2736,12 +2795,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2736
2795
|
});
|
|
2737
2796
|
} else {
|
|
2738
2797
|
targetResource.renderList = targetResource.renderList.filter(function (n) {
|
|
2739
|
-
var _cartItem$
|
|
2798
|
+
var _cartItem$_productOri16;
|
|
2740
2799
|
var recordCount = n.capacity || 0;
|
|
2741
2800
|
if (n.onlyComputed) return false;
|
|
2742
2801
|
var timeSlots = getTimeSlicesByResource({
|
|
2743
2802
|
resource: n,
|
|
2744
|
-
duration: ((_cartItem$
|
|
2803
|
+
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
2804
|
split: 10,
|
|
2746
2805
|
currentDate: dateRange[0].date
|
|
2747
2806
|
});
|
|
@@ -2759,12 +2818,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2759
2818
|
}, {
|
|
2760
2819
|
key: "getTimeslotsScheduleByDateRange",
|
|
2761
2820
|
value: (function () {
|
|
2762
|
-
var _getTimeslotsScheduleByDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(
|
|
2821
|
+
var _getTimeslotsScheduleByDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(_ref12) {
|
|
2763
2822
|
var startDate, endDate, scheduleIds, resources, dates, currentDate, end, results, _i, _dates, date;
|
|
2764
2823
|
return _regeneratorRuntime().wrap(function _callee28$(_context29) {
|
|
2765
2824
|
while (1) switch (_context29.prev = _context29.next) {
|
|
2766
2825
|
case 0:
|
|
2767
|
-
startDate =
|
|
2826
|
+
startDate = _ref12.startDate, endDate = _ref12.endDate, scheduleIds = _ref12.scheduleIds, resources = _ref12.resources;
|
|
2768
2827
|
console.log('appoimentBooking-session-date-getTimeslotsScheduleByDateRange', {
|
|
2769
2828
|
startDate: startDate,
|
|
2770
2829
|
endDate: endDate,
|
|
@@ -2810,7 +2869,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2810
2869
|
endDate,
|
|
2811
2870
|
type,
|
|
2812
2871
|
tempProducts,
|
|
2813
|
-
|
|
2872
|
+
_ref13,
|
|
2814
2873
|
resourceIds,
|
|
2815
2874
|
rules,
|
|
2816
2875
|
resourcesMap,
|
|
@@ -2836,7 +2895,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2836
2895
|
})];
|
|
2837
2896
|
}
|
|
2838
2897
|
// 在这里需要把能收集到的数据都收集上来,拼装好给 date 模块去查询
|
|
2839
|
-
|
|
2898
|
+
_ref13 = getAvailableProductResources(tempProducts) || {}, resourceIds = _ref13.resourceIds, rules = _ref13.rules, resourcesMap = _ref13.resourcesMap;
|
|
2840
2899
|
this.otherParams.currentResourcesMap = resourcesMap;
|
|
2841
2900
|
_context30.next = 10;
|
|
2842
2901
|
return this.store.date.getResourceDates({
|