@pisell/pisellos 0.0.127 → 0.0.129
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/modules/Discount/index.d.ts +1 -0
- package/dist/modules/Discount/index.js +15 -7
- package/dist/modules/Rules/index.js +48 -19
- package/dist/solution/BookingByStep/index.js +168 -111
- package/dist/solution/BookingByStep/utils/resources.d.ts +6 -2
- package/dist/solution/BookingByStep/utils/resources.js +14 -4
- package/dist/solution/ShopDiscount/index.js +9 -9
- package/lib/modules/Date/index.d.ts +1 -0
- package/lib/modules/Date/index.js +6 -0
- package/lib/modules/Discount/index.d.ts +1 -0
- package/lib/modules/Discount/index.js +18 -6
- package/lib/modules/Rules/index.js +48 -17
- package/lib/solution/BookingByStep/index.js +88 -42
- package/lib/solution/BookingByStep/utils/resources.d.ts +6 -2
- package/lib/solution/BookingByStep/utils/resources.js +12 -4
- package/lib/solution/ShopDiscount/index.js +7 -5
- 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
|
}
|
|
@@ -1468,6 +1474,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1468
1474
|
}, {
|
|
1469
1475
|
key: "getResourcesList",
|
|
1470
1476
|
value: function getResourcesList() {
|
|
1477
|
+
var _this9 = this;
|
|
1471
1478
|
var dateRange = this.store.date.getDateRange();
|
|
1472
1479
|
var resources = [];
|
|
1473
1480
|
if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
|
|
@@ -1559,19 +1566,25 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1559
1566
|
});
|
|
1560
1567
|
});
|
|
1561
1568
|
} else {
|
|
1569
|
+
var _cartItem$_productOri4, _this9$shopStore$get;
|
|
1570
|
+
var hasFlexibleDuration = ((_cartItem$_productOri4 = cartItem._productOrigin) === null || _cartItem$_productOri4 === void 0 || (_cartItem$_productOri4 = _cartItem$_productOri4.duration) === null || _cartItem$_productOri4 === void 0 ? void 0 : _cartItem$_productOri4.type) === 'flexible';
|
|
1571
|
+
var operating_day_boundary = (_this9$shopStore$get = _this9.shopStore.get('core')) === null || _this9$shopStore$get === void 0 || (_this9$shopStore$get = _this9$shopStore$get.core) === null || _this9$shopStore$get === void 0 || (_this9$shopStore$get = _this9$shopStore$get.operating_day_boundary) === null || _this9$shopStore$get === void 0 ? void 0 : _this9$shopStore$get.time;
|
|
1562
1572
|
productResources.forEach(function (item) {
|
|
1563
1573
|
// 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
|
|
1564
1574
|
// 同时,在这一步尝试去拉一下时间片,基于商品的时长,看每个资源是否还有空余时间能对这个商品做服务,如果没有则过滤
|
|
1565
1575
|
item.renderList = item.renderList.filter(function (n) {
|
|
1566
|
-
var _cartItem$
|
|
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) || [];
|
|
@@ -1908,14 +1910,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1908
1910
|
return hasOverlap ? sum + item.pax : sum;
|
|
1909
1911
|
}, 0);
|
|
1910
1912
|
var canUseTime = mTimes.find(function (item) {
|
|
1911
|
-
var _cartItem$
|
|
1913
|
+
var _cartItem$_productOri12;
|
|
1912
1914
|
var res = getIsUsableByTimeItem({
|
|
1913
1915
|
timeSlice: timeSlots,
|
|
1914
1916
|
time: item,
|
|
1915
1917
|
resource: n,
|
|
1916
1918
|
currentCount: totalCapacity + (capacity || 0),
|
|
1917
1919
|
resourcesUseableMap: resourcesUseableMap,
|
|
1918
|
-
cut_off_time: (_cartItem$
|
|
1920
|
+
cut_off_time: (_cartItem$_productOri12 = cartItem._productOrigin) === null || _cartItem$_productOri12 === void 0 ? void 0 : _cartItem$_productOri12.cut_off_time
|
|
1919
1921
|
});
|
|
1920
1922
|
// 如果只是因为子资源容量不够,而不是子资源被预约导致没时间片,不应该标记子资源为不可用,从而影响组合资源的情况
|
|
1921
1923
|
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[n.id]) !== false && res.reason !== 'capacityOnly') {
|
|
@@ -1978,7 +1980,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1978
1980
|
key: "autoSelectAllProductResources",
|
|
1979
1981
|
value: function autoSelectAllProductResources(resources_code, timeSlots) {
|
|
1980
1982
|
var _dateRange$4,
|
|
1981
|
-
|
|
1983
|
+
_this10 = this;
|
|
1982
1984
|
var dateRange = this.store.date.getDateRange();
|
|
1983
1985
|
var resources = [];
|
|
1984
1986
|
if (dateRange !== null && dateRange !== void 0 && (_dateRange$4 = dateRange[0]) !== null && _dateRange$4 !== void 0 && _dateRange$4.date) {
|
|
@@ -2026,9 +2028,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2026
2028
|
var resourceBookingType = (currentResourceConfig === null || currentResourceConfig === void 0 ? void 0 : currentResourceConfig.type) || 'single';
|
|
2027
2029
|
// 只有 duration 类商品需要这个操作
|
|
2028
2030
|
if (index !== 0 && recordTimeSlots && resourceBookingType === 'single' && (_item$_productOrigin5 = item._productOrigin) !== null && _item$_productOrigin5 !== void 0 && _item$_productOrigin5.duration) {
|
|
2029
|
-
var _item$
|
|
2030
|
-
var start_at = dayjs(recordTimeSlots.end_time).add((
|
|
2031
|
-
var end_at = start_at.add((
|
|
2031
|
+
var _item$_productOrigin6, _item$_productOrigin7;
|
|
2032
|
+
var start_at = dayjs(recordTimeSlots.end_time).add(((_item$_productOrigin6 = item._productOrigin) === null || _item$_productOrigin6 === void 0 || (_item$_productOrigin6 = _item$_productOrigin6.duration) === null || _item$_productOrigin6 === void 0 ? void 0 : _item$_productOrigin6.value) || 10, 'minutes');
|
|
2033
|
+
var end_at = start_at.add(((_item$_productOrigin7 = item._productOrigin) === null || _item$_productOrigin7 === void 0 || (_item$_productOrigin7 = _item$_productOrigin7.duration) === null || _item$_productOrigin7 === void 0 ? void 0 : _item$_productOrigin7.value) || 10, 'minutes');
|
|
2032
2034
|
recordTimeSlots = {
|
|
2033
2035
|
start_time: start_at.format('HH:mm'),
|
|
2034
2036
|
end_time: end_at.format('HH:mm'),
|
|
@@ -2037,7 +2039,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2037
2039
|
};
|
|
2038
2040
|
}
|
|
2039
2041
|
// 如果传递了 timeSlots,代表是第二种资源,则直接拿 timeSlots 去匹配
|
|
2040
|
-
var res =
|
|
2042
|
+
var res = _this10.autoSelectAccountResources({
|
|
2041
2043
|
cartItem: item,
|
|
2042
2044
|
holder_id: item.holder_id,
|
|
2043
2045
|
resources_code: resources_code,
|
|
@@ -2063,7 +2065,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2063
2065
|
}
|
|
2064
2066
|
res.selectedResource.capacity = currentCapacity;
|
|
2065
2067
|
checkSubResourcesCapacity(res.selectedResource);
|
|
2066
|
-
|
|
2068
|
+
_this10.store.cart.updateItem({
|
|
2067
2069
|
_id: item._id,
|
|
2068
2070
|
// 这里要做去重,避免出现同样类型的资源被塞进同一个商品
|
|
2069
2071
|
resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
|
|
@@ -2076,12 +2078,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2076
2078
|
errorList.push(item._id);
|
|
2077
2079
|
}
|
|
2078
2080
|
} else {
|
|
2079
|
-
var _item$
|
|
2081
|
+
var _item$_productOrigin8, _productResources$fin;
|
|
2080
2082
|
// 这里必须每次循环重新读,避免前一次循环操作了购物车,导致数据变更
|
|
2081
|
-
var allCartItems = cloneDeep(
|
|
2083
|
+
var allCartItems = cloneDeep(_this10.store.cart.getItems());
|
|
2082
2084
|
// 如果没有传递 timeSlots,代表是第一种资源,则直接拿商品的 duration,到资源列表里找一个公共可用的
|
|
2083
2085
|
var selectedResources = [];
|
|
2084
|
-
var _resources = cloneDeep(((_item$
|
|
2086
|
+
var _resources = cloneDeep(((_item$_productOrigin8 = item._productOrigin) === null || _item$_productOrigin8 === void 0 || (_item$_productOrigin8 = _item$_productOrigin8.product_resource) === null || _item$_productOrigin8 === void 0 ? void 0 : _item$_productOrigin8.resources) || []);
|
|
2085
2087
|
var currentResourcesRenderList = [];
|
|
2086
2088
|
_resources.forEach(function (n) {
|
|
2087
2089
|
var _n$renderList;
|
|
@@ -2093,7 +2095,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2093
2095
|
var recordCount = (m.capacity || 0) - (selectResourcesMap[m.id] || 0);
|
|
2094
2096
|
var timeSlots = getTimeSlicesByResource({
|
|
2095
2097
|
resource: m,
|
|
2096
|
-
duration: (item === null || item === void 0 || (_item$duration = item.duration) === null || _item$duration === void 0 ? void 0 : _item$duration.value) ||
|
|
2098
|
+
duration: (item === null || item === void 0 || (_item$duration = item.duration) === null || _item$duration === void 0 ? void 0 : _item$duration.value) || 10,
|
|
2097
2099
|
split: 10,
|
|
2098
2100
|
currentDate: dateRange[0].date
|
|
2099
2101
|
});
|
|
@@ -2142,7 +2144,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2142
2144
|
} else {
|
|
2143
2145
|
selectResourcesMap[targetResource.id] += currentCapacity;
|
|
2144
2146
|
}
|
|
2145
|
-
|
|
2147
|
+
_this10.store.cart.updateItem({
|
|
2146
2148
|
_id: item._id,
|
|
2147
2149
|
resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
|
|
2148
2150
|
return existingRes.resourceType !== targetRenderList[0].resourceType;
|
|
@@ -2162,7 +2164,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2162
2164
|
// 如果购物车里没有 holderid数据,证明不按 holder 类流程预约走,给所有购物车一次性分派即可,不做账号下资源互斥逻辑
|
|
2163
2165
|
if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
|
|
2164
2166
|
accountList.forEach(function (account) {
|
|
2165
|
-
var cartItems =
|
|
2167
|
+
var cartItems = _this10.store.cart.getCartByAccount(account.getId());
|
|
2166
2168
|
selectForCartResources(cartItems);
|
|
2167
2169
|
});
|
|
2168
2170
|
} else {
|
|
@@ -2177,9 +2179,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2177
2179
|
key: "getTimeSlotByAllResources",
|
|
2178
2180
|
value: function getTimeSlotByAllResources(resources_code) {
|
|
2179
2181
|
var _dateRange,
|
|
2180
|
-
|
|
2182
|
+
_this11 = this,
|
|
2181
2183
|
_cartItems$,
|
|
2182
|
-
_cartItems$2
|
|
2184
|
+
_cartItems$2,
|
|
2185
|
+
_this$shopStore$get;
|
|
2183
2186
|
var dateRange = this.store.date.getDateRange();
|
|
2184
2187
|
// 取出购物车中所有一已选择的第一步资源
|
|
2185
2188
|
var resources = [];
|
|
@@ -2195,8 +2198,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2195
2198
|
var maxCutOffTime = undefined;
|
|
2196
2199
|
var maxCutOffTimeValue = dayjs();
|
|
2197
2200
|
cartItems.forEach(function (item) {
|
|
2198
|
-
var _item$
|
|
2199
|
-
(_item$
|
|
2201
|
+
var _item$_productOrigin9, _item$_productOrigin10, _item$_productOrigin11, _item$_productOrigin12;
|
|
2202
|
+
(_item$_productOrigin9 = item._productOrigin) === null || _item$_productOrigin9 === void 0 || (_item$_productOrigin9 = _item$_productOrigin9.product_resource) === null || _item$_productOrigin9 === void 0 || (_item$_productOrigin9 = _item$_productOrigin9.resources) === null || _item$_productOrigin9 === void 0 || _item$_productOrigin9.forEach(function (n) {
|
|
2200
2203
|
// TODO: 少了个 status 的判断
|
|
2201
2204
|
if (n.code === resources_code) {
|
|
2202
2205
|
resources.push.apply(resources, _toConsumableArray(n.renderList || []));
|
|
@@ -2209,10 +2212,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2209
2212
|
if (item.resource_id) {
|
|
2210
2213
|
resourceIds.push(item.resource_id);
|
|
2211
2214
|
}
|
|
2212
|
-
resourcesTypeId = item === null || item === void 0 || (_item$
|
|
2215
|
+
resourcesTypeId = item === null || item === void 0 || (_item$_productOrigin10 = item._productOrigin) === null || _item$_productOrigin10 === void 0 || (_item$_productOrigin10 = _item$_productOrigin10.product_resource) === null || _item$_productOrigin10 === void 0 || (_item$_productOrigin10 = _item$_productOrigin10.resources) === null || _item$_productOrigin10 === void 0 || (_item$_productOrigin10 = _item$_productOrigin10.find(function (n) {
|
|
2213
2216
|
return n.code === resources_code;
|
|
2214
|
-
})) === null || _item$
|
|
2215
|
-
if ((_item$
|
|
2217
|
+
})) === null || _item$_productOrigin10 === void 0 ? void 0 : _item$_productOrigin10.id;
|
|
2218
|
+
if ((_item$_productOrigin11 = item._productOrigin) !== null && _item$_productOrigin11 !== void 0 && _item$_productOrigin11.cut_off_time && ((_item$_productOrigin12 = item._productOrigin) === null || _item$_productOrigin12 === void 0 ? void 0 : _item$_productOrigin12.cut_off_time.type) === 'advance') {
|
|
2216
2219
|
var currentCutOffTime = dayjs().add(item._productOrigin.cut_off_time.unit, item._productOrigin.cut_off_time.unit_type);
|
|
2217
2220
|
if (currentCutOffTime.isAfter(maxCutOffTimeValue, 'minute')) {
|
|
2218
2221
|
maxCutOffTimeValue = currentCutOffTime;
|
|
@@ -2240,13 +2243,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2240
2243
|
cartItems.forEach(function (item) {
|
|
2241
2244
|
// 单个预约累加账号 多个预约取最大值
|
|
2242
2245
|
if (isSingleResource) {
|
|
2243
|
-
var _item$
|
|
2244
|
-
accountDuration += (
|
|
2246
|
+
var _item$_productOrigin13;
|
|
2247
|
+
accountDuration += ((_item$_productOrigin13 = item._productOrigin) === null || _item$_productOrigin13 === void 0 || (_item$_productOrigin13 = _item$_productOrigin13.duration) === null || _item$_productOrigin13 === void 0 ? void 0 : _item$_productOrigin13.value) || 10;
|
|
2245
2248
|
} else {
|
|
2246
|
-
var _item$
|
|
2247
|
-
if (accountDuration < ((
|
|
2248
|
-
var _item$
|
|
2249
|
-
accountDuration = (
|
|
2249
|
+
var _item$_productOrigin14;
|
|
2250
|
+
if (accountDuration < (((_item$_productOrigin14 = item._productOrigin) === null || _item$_productOrigin14 === void 0 || (_item$_productOrigin14 = _item$_productOrigin14.duration) === null || _item$_productOrigin14 === void 0 ? void 0 : _item$_productOrigin14.value) || 10)) {
|
|
2251
|
+
var _item$_productOrigin15;
|
|
2252
|
+
accountDuration = ((_item$_productOrigin15 = item._productOrigin) === null || _item$_productOrigin15 === void 0 || (_item$_productOrigin15 = _item$_productOrigin15.duration) === null || _item$_productOrigin15 === void 0 ? void 0 : _item$_productOrigin15.value) || 10;
|
|
2250
2253
|
}
|
|
2251
2254
|
}
|
|
2252
2255
|
});
|
|
@@ -2256,7 +2259,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2256
2259
|
};
|
|
2257
2260
|
if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
|
|
2258
2261
|
accountList.forEach(function (account) {
|
|
2259
|
-
var cartItems =
|
|
2262
|
+
var cartItems = _this11.store.cart.getCartByAccount(account.getId());
|
|
2260
2263
|
checkDuration(cartItems);
|
|
2261
2264
|
});
|
|
2262
2265
|
} else {
|
|
@@ -2282,6 +2285,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2282
2285
|
}];
|
|
2283
2286
|
}
|
|
2284
2287
|
var resourcesUseableMap = {};
|
|
2288
|
+
var hasFlexibleDuration = cartItems.some(function (item) {
|
|
2289
|
+
var _item$_productOrigin16;
|
|
2290
|
+
return ((_item$_productOrigin16 = item._productOrigin) === null || _item$_productOrigin16 === void 0 || (_item$_productOrigin16 = _item$_productOrigin16.duration) === null || _item$_productOrigin16 === void 0 ? void 0 : _item$_productOrigin16.type) === 'flexible';
|
|
2291
|
+
});
|
|
2292
|
+
var operating_day_boundary = (_this$shopStore$get = this.shopStore.get('core')) === null || _this$shopStore$get === void 0 || (_this$shopStore$get = _this$shopStore$get.core) === null || _this$shopStore$get === void 0 || (_this$shopStore$get = _this$shopStore$get.operating_day_boundary) === null || _this$shopStore$get === void 0 ? void 0 : _this$shopStore$get.time;
|
|
2285
2293
|
var timeSlots = getTimeSlicesByResources({
|
|
2286
2294
|
resourceIds: resourceIds,
|
|
2287
2295
|
resourcesMap: resourcesMap,
|
|
@@ -2289,21 +2297,27 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2289
2297
|
currentDate: dateRange[0].date,
|
|
2290
2298
|
split: 10,
|
|
2291
2299
|
resourcesUseableMap: resourcesUseableMap,
|
|
2292
|
-
cut_off_time: maxCutOffTime
|
|
2300
|
+
cut_off_time: maxCutOffTime,
|
|
2301
|
+
hasFlexibleDuration: hasFlexibleDuration,
|
|
2302
|
+
operating_day_boundary: operating_day_boundary
|
|
2293
2303
|
});
|
|
2294
2304
|
return timeSlots;
|
|
2295
2305
|
}
|
|
2296
2306
|
|
|
2297
|
-
//
|
|
2307
|
+
// 提交时间切片,绑定到对应购物车的商品上,更新购物车---只有 duration 商品
|
|
2298
2308
|
}, {
|
|
2299
2309
|
key: "submitTimeSlot",
|
|
2300
2310
|
value: function submitTimeSlot(timeSlots) {
|
|
2301
|
-
var
|
|
2311
|
+
var _this$shopStore$get2,
|
|
2312
|
+
_this12 = this;
|
|
2302
2313
|
// 以账号为维度处理数据。购物车里每一项的 startTime应该是前一个商品的 endTime,如果是第一个商品则用 timeSlots.start_at
|
|
2303
2314
|
var cartItems = this.store.cart.getItems().filter(function (n) {
|
|
2304
2315
|
return !isNormalProduct(n._productOrigin);
|
|
2305
2316
|
});
|
|
2306
2317
|
|
|
2318
|
+
// 取出所有资源列表
|
|
2319
|
+
var allResources = this.store.date.getResourcesListByDate(timeSlots.start_at.format('YYYY-MM-DD'));
|
|
2320
|
+
|
|
2307
2321
|
// 按账号分组
|
|
2308
2322
|
var itemsByAccount = cartItems.reduce(function (acc, item) {
|
|
2309
2323
|
var holderId = item.holder_id;
|
|
@@ -2314,6 +2328,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2314
2328
|
return acc;
|
|
2315
2329
|
}, {});
|
|
2316
2330
|
|
|
2331
|
+
// 店铺营业结束时间
|
|
2332
|
+
var operating_day_boundary = (_this$shopStore$get2 = this.shopStore.get('core')) === null || _this$shopStore$get2 === void 0 || (_this$shopStore$get2 = _this$shopStore$get2.core) === null || _this$shopStore$get2 === void 0 || (_this$shopStore$get2 = _this$shopStore$get2.operating_day_boundary) === null || _this$shopStore$get2 === void 0 ? void 0 : _this$shopStore$get2.time;
|
|
2333
|
+
|
|
2317
2334
|
// 处理每个账号的商品
|
|
2318
2335
|
Object.values(itemsByAccount).forEach(function (accountItems) {
|
|
2319
2336
|
var currentStartTime = timeSlots.start_at.format('YYYY-MM-DD HH:mm');
|
|
@@ -2321,12 +2338,41 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2321
2338
|
var _newResources$;
|
|
2322
2339
|
var newResources = cloneDeep(item._origin.resources);
|
|
2323
2340
|
newResources.forEach(function (resource) {
|
|
2324
|
-
var _item$
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2341
|
+
var _item$_productOrigin17;
|
|
2342
|
+
// 如果商品配置的是灵活时长,开始时间设置为提交的时间,结束时间从资源的可用最晚时间和店铺营业结束时间里取一个最早的
|
|
2343
|
+
if (((_item$_productOrigin17 = item._productOrigin) === null || _item$_productOrigin17 === void 0 || (_item$_productOrigin17 = _item$_productOrigin17.duration) === null || _item$_productOrigin17 === void 0 ? void 0 : _item$_productOrigin17.type) === 'flexible') {
|
|
2344
|
+
var _allResources$find;
|
|
2345
|
+
item.duration = {
|
|
2346
|
+
type: 'minutes',
|
|
2347
|
+
value: 10
|
|
2348
|
+
};
|
|
2349
|
+
resource.startTime = timeSlots.start_at.format('YYYY-MM-DD HH:mm');
|
|
2350
|
+
// 找到resource.times里最早的end_at
|
|
2351
|
+
var targetResourceTimes = allResources === null || allResources === void 0 || (_allResources$find = allResources.find(function (n) {
|
|
2352
|
+
return n.id === resource.id;
|
|
2353
|
+
})) === null || _allResources$find === void 0 ? void 0 : _allResources$find.times;
|
|
2354
|
+
var resourcesEndTime = targetResourceTimes.reduce(function (acc, curr) {
|
|
2355
|
+
return dayjs(curr.end_at).isBefore(dayjs(acc.end_at)) ? curr : acc;
|
|
2356
|
+
}, targetResourceTimes[0]);
|
|
2357
|
+
var endTime = dayjs(resourcesEndTime.end_at).isBefore(dayjs(operating_day_boundary)) ? resourcesEndTime.end_at : operating_day_boundary;
|
|
2358
|
+
// 修复:如果 endTime 只是时间格式(如 "17:00"),需要加上日期
|
|
2359
|
+
var formattedEndTime;
|
|
2360
|
+
if (typeof endTime === 'string' && endTime.includes(':') && !endTime.includes(' ') && !endTime.includes('T')) {
|
|
2361
|
+
// 如果是纯时间格式,与当前日期合并
|
|
2362
|
+
var currentDate = timeSlots.start_at.format('YYYY-MM-DD');
|
|
2363
|
+
formattedEndTime = dayjs("".concat(currentDate, " ").concat(endTime));
|
|
2364
|
+
} else {
|
|
2365
|
+
formattedEndTime = dayjs(endTime);
|
|
2366
|
+
}
|
|
2367
|
+
resource.endTime = formattedEndTime.format('YYYY-MM-DD HH:mm');
|
|
2368
|
+
} else {
|
|
2369
|
+
var _item$_productOrigin18;
|
|
2370
|
+
resource.startTime = currentStartTime;
|
|
2371
|
+
resource.endTime = dayjs(currentStartTime).add(((_item$_productOrigin18 = item._productOrigin) === null || _item$_productOrigin18 === void 0 || (_item$_productOrigin18 = _item$_productOrigin18.duration) === null || _item$_productOrigin18 === void 0 ? void 0 : _item$_productOrigin18.value) || 10, 'minutes').format('YYYY-MM-DD HH:mm');
|
|
2372
|
+
}
|
|
2373
|
+
// delete resource.times;
|
|
2328
2374
|
});
|
|
2329
|
-
|
|
2375
|
+
_this12.store.cart.updateItem({
|
|
2330
2376
|
_id: item._id,
|
|
2331
2377
|
resources: newResources
|
|
2332
2378
|
});
|
|
@@ -2409,12 +2455,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2409
2455
|
}
|
|
2410
2456
|
}, {
|
|
2411
2457
|
key: "getTimeslotBySchedule",
|
|
2412
|
-
value: function getTimeslotBySchedule(
|
|
2458
|
+
value: function getTimeslotBySchedule(_ref9) {
|
|
2413
2459
|
var _this$store$currentPr2, _targetProductData$pr;
|
|
2414
|
-
var date =
|
|
2415
|
-
scheduleIds =
|
|
2416
|
-
resources =
|
|
2417
|
-
product =
|
|
2460
|
+
var date = _ref9.date,
|
|
2461
|
+
scheduleIds = _ref9.scheduleIds,
|
|
2462
|
+
resources = _ref9.resources,
|
|
2463
|
+
product = _ref9.product;
|
|
2418
2464
|
var targetProduct = this.store.currentProduct;
|
|
2419
2465
|
// 如果外面传递了product 优先用外面的
|
|
2420
2466
|
var targetProductData = product || (targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.getData());
|
|
@@ -2532,21 +2578,22 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2532
2578
|
}
|
|
2533
2579
|
}, {
|
|
2534
2580
|
key: "addProductToCart",
|
|
2535
|
-
value: function addProductToCart(
|
|
2536
|
-
var
|
|
2537
|
-
var product =
|
|
2538
|
-
date =
|
|
2539
|
-
account =
|
|
2540
|
-
var
|
|
2541
|
-
bundle =
|
|
2542
|
-
options =
|
|
2543
|
-
origin =
|
|
2544
|
-
product_variant_id =
|
|
2545
|
-
rowKey =
|
|
2546
|
-
|
|
2547
|
-
quantity =
|
|
2581
|
+
value: function addProductToCart(_ref10) {
|
|
2582
|
+
var _this13 = this;
|
|
2583
|
+
var product = _ref10.product,
|
|
2584
|
+
date = _ref10.date,
|
|
2585
|
+
account = _ref10.account;
|
|
2586
|
+
var _ref11 = product || {},
|
|
2587
|
+
bundle = _ref11.bundle,
|
|
2588
|
+
options = _ref11.options,
|
|
2589
|
+
origin = _ref11.origin,
|
|
2590
|
+
product_variant_id = _ref11.product_variant_id,
|
|
2591
|
+
rowKey = _ref11.rowKey,
|
|
2592
|
+
_ref11$quantity = _ref11.quantity,
|
|
2593
|
+
quantity = _ref11$quantity === void 0 ? 1 : _ref11$quantity;
|
|
2548
2594
|
var productData = _objectSpread(_objectSpread({}, origin), {}, {
|
|
2549
|
-
product_variant_id: product_variant_id
|
|
2595
|
+
product_variant_id: product_variant_id,
|
|
2596
|
+
rowKey: rowKey
|
|
2550
2597
|
});
|
|
2551
2598
|
if (!account) {
|
|
2552
2599
|
var activeAccount = this.getActiveAccount();
|
|
@@ -2565,7 +2612,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2565
2612
|
_id: targetCartItem._id,
|
|
2566
2613
|
product: _objectSpread(_objectSpread({}, targetCartItem._productOrigin), {}, {
|
|
2567
2614
|
quantity: (targetCartItem.num || 1) + quantity
|
|
2568
|
-
})
|
|
2615
|
+
}),
|
|
2616
|
+
bundle: targetCartItem._bundleOrigin,
|
|
2617
|
+
options: targetCartItem._optionsOrigin,
|
|
2618
|
+
quantity: (targetCartItem.num || 1) + quantity
|
|
2569
2619
|
});
|
|
2570
2620
|
return;
|
|
2571
2621
|
}
|
|
@@ -2588,7 +2638,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2588
2638
|
});
|
|
2589
2639
|
if (cartItemsByDate.length) {
|
|
2590
2640
|
cartItemsByDate.forEach(function (n) {
|
|
2591
|
-
|
|
2641
|
+
_this13.store.cart.removeItem(n._id);
|
|
2592
2642
|
});
|
|
2593
2643
|
}
|
|
2594
2644
|
}
|
|
@@ -2652,7 +2702,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2652
2702
|
}, {
|
|
2653
2703
|
key: "getResourcesByCartItemAndCode",
|
|
2654
2704
|
value: function getResourcesByCartItemAndCode(cartItemId, resourceCode) {
|
|
2655
|
-
var _cartItem$
|
|
2705
|
+
var _cartItem$_productOri13, _cartItem$_productOri14;
|
|
2656
2706
|
var dateRange = this.store.date.getDateRange();
|
|
2657
2707
|
var resources = [];
|
|
2658
2708
|
if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
|
|
@@ -2676,7 +2726,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2676
2726
|
if (!cartItem) return [];
|
|
2677
2727
|
var selectedResources = [];
|
|
2678
2728
|
var formatCapacity = formatDefaultCapacitys({
|
|
2679
|
-
capacity: (_cartItem$
|
|
2729
|
+
capacity: (_cartItem$_productOri13 = cartItem._productOrigin) === null || _cartItem$_productOri13 === void 0 ? void 0 : _cartItem$_productOri13.capacity,
|
|
2680
2730
|
product_bundle: cartItem._origin.product.product_bundle
|
|
2681
2731
|
});
|
|
2682
2732
|
cartItem._origin.metadata.capacity = formatCapacity;
|
|
@@ -2688,7 +2738,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2688
2738
|
} else {
|
|
2689
2739
|
selectedResources = getOthersCartSelectedResources(cartItems, cartItem._id, resourcesMap);
|
|
2690
2740
|
}
|
|
2691
|
-
var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$
|
|
2741
|
+
var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri14 = cartItem._productOrigin) === null || _cartItem$_productOri14 === void 0 || (_cartItem$_productOri14 = _cartItem$_productOri14.product_resource) === null || _cartItem$_productOri14 === void 0 ? void 0 : _cartItem$_productOri14.resources) || [], selectedResources, currentCapacity);
|
|
2692
2742
|
var targetResource = productResources.find(function (resource) {
|
|
2693
2743
|
return resource.code === resourceCode;
|
|
2694
2744
|
});
|
|
@@ -2711,7 +2761,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2711
2761
|
});
|
|
2712
2762
|
if (mTimes.length === 0) return false;
|
|
2713
2763
|
var canUseArr = mTimes.map(function (item) {
|
|
2714
|
-
var _cartItem$
|
|
2764
|
+
var _cartItem$_productOri15;
|
|
2715
2765
|
var res = getIsUsableByTimeItem({
|
|
2716
2766
|
timeSlice: {
|
|
2717
2767
|
start_time: startTime.format('HH:mm'),
|
|
@@ -2723,7 +2773,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2723
2773
|
resource: m,
|
|
2724
2774
|
currentCount: currentCapacity || 0,
|
|
2725
2775
|
resourcesUseableMap: resourcesUseableMap,
|
|
2726
|
-
cut_off_time: (_cartItem$
|
|
2776
|
+
cut_off_time: (_cartItem$_productOri15 = cartItem._productOrigin) === null || _cartItem$_productOri15 === void 0 ? void 0 : _cartItem$_productOri15.cut_off_time
|
|
2727
2777
|
});
|
|
2728
2778
|
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
|
|
2729
2779
|
resourcesUseableMap[m.id] = res.usable;
|
|
@@ -2737,12 +2787,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2737
2787
|
});
|
|
2738
2788
|
} else {
|
|
2739
2789
|
targetResource.renderList = targetResource.renderList.filter(function (n) {
|
|
2740
|
-
var _cartItem$
|
|
2790
|
+
var _cartItem$_productOri16;
|
|
2741
2791
|
var recordCount = n.capacity || 0;
|
|
2742
2792
|
if (n.onlyComputed) return false;
|
|
2743
2793
|
var timeSlots = getTimeSlicesByResource({
|
|
2744
2794
|
resource: n,
|
|
2745
|
-
duration: ((_cartItem$
|
|
2795
|
+
duration: ((_cartItem$_productOri16 = cartItem._productOrigin) === null || _cartItem$_productOri16 === void 0 || (_cartItem$_productOri16 = _cartItem$_productOri16.duration) === null || _cartItem$_productOri16 === void 0 ? void 0 : _cartItem$_productOri16.value) || 10,
|
|
2746
2796
|
split: 10,
|
|
2747
2797
|
currentDate: dateRange[0].date
|
|
2748
2798
|
});
|
|
@@ -2760,12 +2810,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2760
2810
|
}, {
|
|
2761
2811
|
key: "getTimeslotsScheduleByDateRange",
|
|
2762
2812
|
value: (function () {
|
|
2763
|
-
var _getTimeslotsScheduleByDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(
|
|
2813
|
+
var _getTimeslotsScheduleByDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(_ref12) {
|
|
2764
2814
|
var startDate, endDate, scheduleIds, resources, dates, currentDate, end, results, _i, _dates, date;
|
|
2765
2815
|
return _regeneratorRuntime().wrap(function _callee28$(_context29) {
|
|
2766
2816
|
while (1) switch (_context29.prev = _context29.next) {
|
|
2767
2817
|
case 0:
|
|
2768
|
-
startDate =
|
|
2818
|
+
startDate = _ref12.startDate, endDate = _ref12.endDate, scheduleIds = _ref12.scheduleIds, resources = _ref12.resources;
|
|
2769
2819
|
console.log('appoimentBooking-session-date-getTimeslotsScheduleByDateRange', {
|
|
2770
2820
|
startDate: startDate,
|
|
2771
2821
|
endDate: endDate,
|
|
@@ -2811,7 +2861,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2811
2861
|
endDate,
|
|
2812
2862
|
type,
|
|
2813
2863
|
tempProducts,
|
|
2814
|
-
|
|
2864
|
+
_ref13,
|
|
2815
2865
|
resourceIds,
|
|
2816
2866
|
rules,
|
|
2817
2867
|
resourcesMap,
|
|
@@ -2837,7 +2887,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2837
2887
|
})];
|
|
2838
2888
|
}
|
|
2839
2889
|
// 在这里需要把能收集到的数据都收集上来,拼装好给 date 模块去查询
|
|
2840
|
-
|
|
2890
|
+
_ref13 = getAvailableProductResources(tempProducts) || {}, resourceIds = _ref13.resourceIds, rules = _ref13.rules, resourcesMap = _ref13.resourcesMap;
|
|
2841
2891
|
this.otherParams.currentResourcesMap = resourcesMap;
|
|
2842
2892
|
_context30.next = 10;
|
|
2843
2893
|
return this.store.date.getResourceDates({
|
|
@@ -2903,6 +2953,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2903
2953
|
startDate,
|
|
2904
2954
|
endDate,
|
|
2905
2955
|
endDateAfterMonth,
|
|
2956
|
+
tempEndDate,
|
|
2906
2957
|
tempProducts,
|
|
2907
2958
|
schedule,
|
|
2908
2959
|
filteredSchedule,
|
|
@@ -2930,17 +2981,23 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2930
2981
|
// 优化策略:
|
|
2931
2982
|
// 在 endDate 添加完一个月以后,如果 endDate 还小于 startDate + 7 天,则还需要 endDate+7 天
|
|
2932
2983
|
endDateAfterMonth = dayjs().add(1, 'month').format('YYYY-MM-DD');
|
|
2984
|
+
tempEndDate = endDateAfterMonth;
|
|
2933
2985
|
if (dayjs(startDate).add(7, 'day').isAfter(dayjs(endDateAfterMonth), 'day')) {
|
|
2934
|
-
|
|
2986
|
+
tempEndDate = dayjs(startDate).add(7, 'day').format('YYYY-MM-DD');
|
|
2935
2987
|
} else {
|
|
2936
|
-
|
|
2988
|
+
tempEndDate = endDateAfterMonth;
|
|
2937
2989
|
}
|
|
2990
|
+
// 如果这么算出来的 tempEndDate 还小于 endDate,则需要把 endDate 置为 tempEndDate
|
|
2991
|
+
if (dayjs(tempEndDate).isBefore(dayjs(endDate), 'day')) {
|
|
2992
|
+
tempEndDate = endDate || '';
|
|
2993
|
+
}
|
|
2994
|
+
endDate = tempEndDate;
|
|
2938
2995
|
// 如果当前打开了某个的商品详情弹窗,则应该默认用这个商品
|
|
2939
2996
|
tempProducts = (_this$store$currentPr3 = this.store.currentProduct) === null || _this$store$currentPr3 === void 0 ? void 0 : _this$store$currentPr3.getData();
|
|
2940
2997
|
schedule = (_this$store$currentPr4 = this.store.currentProduct) === null || _this$store$currentPr4 === void 0 ? void 0 : _this$store$currentPr4.getOtherParams()['schedule'];
|
|
2941
2998
|
filteredSchedule = filterScheduleByDateRange(schedule, startDate || '', endDate || ''); // 1.后端返回的数据,确定资源在每一天的可用和使用情况
|
|
2942
2999
|
tempResourceIds = getResourcesIdsByProduct(tempProducts);
|
|
2943
|
-
_context32.next =
|
|
3000
|
+
_context32.next = 14;
|
|
2944
3001
|
return this.store.date.fetchResourceDates({
|
|
2945
3002
|
query: {
|
|
2946
3003
|
start_date: startDate || '',
|
|
@@ -2948,17 +3005,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2948
3005
|
resource_ids: tempResourceIds
|
|
2949
3006
|
}
|
|
2950
3007
|
});
|
|
2951
|
-
case
|
|
3008
|
+
case 14:
|
|
2952
3009
|
res = _context32.sent;
|
|
2953
3010
|
// 先去读缓存结果,因为正常 UI 调用的是 7 天,而下面我会直接计算 30 天(最少也是 14 天),所以先去读缓存结果,如果缓存结果存在,则直接返回
|
|
2954
3011
|
// TODO 优化关于为什么要放在接口后,因为在获取时间切片的时候还需要读一次接口数据,其实可以直接从这个结果里拿了,需要优化
|
|
2955
3012
|
cache = (_this$store$currentPr5 = this.store.currentProduct) === null || _this$store$currentPr5 === void 0 ? void 0 : _this$store$currentPr5.getOtherParams()['timeSlotBySchedule'];
|
|
2956
3013
|
if (!cache) {
|
|
2957
|
-
_context32.next =
|
|
3014
|
+
_context32.next = 20;
|
|
2958
3015
|
break;
|
|
2959
3016
|
}
|
|
2960
3017
|
if (!(dayjs(params.startDate).isSameOrAfter(dayjs(cache.startDate), 'day') && dayjs(params.endDate).isSameOrBefore(dayjs(cache.endDate), 'day'))) {
|
|
2961
|
-
_context32.next =
|
|
3018
|
+
_context32.next = 20;
|
|
2962
3019
|
break;
|
|
2963
3020
|
}
|
|
2964
3021
|
this.store.date.setDateList(cache.dateList);
|
|
@@ -2966,7 +3023,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2966
3023
|
dateList: cache.dateList,
|
|
2967
3024
|
firstAvailableDate: cache.firstAvailableDate
|
|
2968
3025
|
});
|
|
2969
|
-
case
|
|
3026
|
+
case 20:
|
|
2970
3027
|
// 2. 商品 schedule 数据,确定日程在每一天的时间片
|
|
2971
3028
|
// 3. 把后端返回的和 schedule 的数据进行合并,确定每一天的可用和使用情况
|
|
2972
3029
|
dates = [];
|
|
@@ -3093,22 +3150,22 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3093
3150
|
}
|
|
3094
3151
|
}, _loop3);
|
|
3095
3152
|
});
|
|
3096
|
-
case
|
|
3153
|
+
case 28:
|
|
3097
3154
|
if (!(dayjs(currentDate).isBefore(dayjs(endDate), 'day') || dayjs(currentDate).isSame(dayjs(endDate), 'day'))) {
|
|
3098
|
-
_context32.next =
|
|
3155
|
+
_context32.next = 34;
|
|
3099
3156
|
break;
|
|
3100
3157
|
}
|
|
3101
|
-
return _context32.delegateYield(_loop3(), "t0",
|
|
3102
|
-
case
|
|
3158
|
+
return _context32.delegateYield(_loop3(), "t0", 30);
|
|
3159
|
+
case 30:
|
|
3103
3160
|
if (!_context32.t0) {
|
|
3104
|
-
_context32.next =
|
|
3161
|
+
_context32.next = 32;
|
|
3105
3162
|
break;
|
|
3106
3163
|
}
|
|
3107
|
-
return _context32.abrupt("break",
|
|
3108
|
-
case
|
|
3109
|
-
_context32.next =
|
|
3164
|
+
return _context32.abrupt("break", 34);
|
|
3165
|
+
case 32:
|
|
3166
|
+
_context32.next = 28;
|
|
3110
3167
|
break;
|
|
3111
|
-
case
|
|
3168
|
+
case 34:
|
|
3112
3169
|
// 最终把资源数据也加到日期内
|
|
3113
3170
|
dates = handleAvailableDateByResource(res.data, dates);
|
|
3114
3171
|
this.store.date.setDateList(dates);
|
|
@@ -3124,7 +3181,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3124
3181
|
dateList: dates,
|
|
3125
3182
|
firstAvailableDate: firstAvailableDate
|
|
3126
3183
|
});
|
|
3127
|
-
case
|
|
3184
|
+
case 38:
|
|
3128
3185
|
case "end":
|
|
3129
3186
|
return _context32.stop();
|
|
3130
3187
|
}
|