@pisell/pisellos 2.0.30 → 2.0.31
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.
|
@@ -210,7 +210,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
210
210
|
}): void;
|
|
211
211
|
setOtherData(key: string, value: any): void;
|
|
212
212
|
getOtherData(key: string): any;
|
|
213
|
-
getProductTypeById(id: number): Promise<"
|
|
213
|
+
getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
|
|
214
214
|
/**
|
|
215
215
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
216
216
|
*
|
|
@@ -2802,7 +2802,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2802
2802
|
var _getAvailableDateForSessionOptimize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
|
|
2803
2803
|
var _this$store$currentPr3, _this$store$currentPr4, _this$store$currentPr5, _tempProducts, _this$store$currentPr6;
|
|
2804
2804
|
var params,
|
|
2805
|
-
cache,
|
|
2806
2805
|
startDate,
|
|
2807
2806
|
endDate,
|
|
2808
2807
|
tempProducts,
|
|
@@ -2810,6 +2809,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2810
2809
|
filteredSchedule,
|
|
2811
2810
|
tempResourceIds,
|
|
2812
2811
|
res,
|
|
2812
|
+
cache,
|
|
2813
2813
|
dates,
|
|
2814
2814
|
currentDate,
|
|
2815
2815
|
firstAvailableDate,
|
|
@@ -2822,21 +2822,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2822
2822
|
while (1) switch (_context32.prev = _context32.next) {
|
|
2823
2823
|
case 0:
|
|
2824
2824
|
params = _args32.length > 0 && _args32[0] !== undefined ? _args32[0] : {};
|
|
2825
|
-
// 先去读缓存结果,因为正常 UI 调用的是 7 天,而下面我会直接计算 30 天(最少也是 14 天),所以先去读缓存结果,如果缓存结果存在,则直接返回
|
|
2826
|
-
cache = (_this$store$currentPr3 = this.store.currentProduct) === null || _this$store$currentPr3 === void 0 ? void 0 : _this$store$currentPr3.getOtherParams()['timeSlotBySchedule'];
|
|
2827
|
-
if (!cache) {
|
|
2828
|
-
_context32.next = 5;
|
|
2829
|
-
break;
|
|
2830
|
-
}
|
|
2831
|
-
if (!(dayjs(params.startDate).isSameOrAfter(dayjs(cache.startDate), 'day') && dayjs(params.endDate).isSameOrBefore(dayjs(cache.endDate), 'day'))) {
|
|
2832
|
-
_context32.next = 5;
|
|
2833
|
-
break;
|
|
2834
|
-
}
|
|
2835
|
-
return _context32.abrupt("return", {
|
|
2836
|
-
dateList: cache.dateList,
|
|
2837
|
-
firstAvailableDate: cache.firstAvailableDate
|
|
2838
|
-
});
|
|
2839
|
-
case 5:
|
|
2840
2825
|
// 开始日期如果小于今天,直接以今天当做开始日期
|
|
2841
2826
|
startDate = params.startDate, endDate = params.endDate; // 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天 且 endDate 小于或等于今天,需要把 startDate 置为今天
|
|
2842
2827
|
if (dayjs(startDate).isBefore(dayjs(), 'day') && (dayjs(endDate).isAfter(dayjs(), 'day') || dayjs(endDate).isSame(dayjs(), 'day'))) {
|
|
@@ -2845,11 +2830,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2845
2830
|
// 不管前端传什么 endDate 默认查一个月的,以今天为开始日期。用于找到一个月内最近可用的日期
|
|
2846
2831
|
endDate = dayjs().add(1, 'month').format('YYYY-MM-DD');
|
|
2847
2832
|
// 如果当前打开了某个的商品详情弹窗,则应该默认用这个商品
|
|
2848
|
-
tempProducts = (_this$store$
|
|
2849
|
-
schedule = (_this$store$
|
|
2833
|
+
tempProducts = (_this$store$currentPr3 = this.store.currentProduct) === null || _this$store$currentPr3 === void 0 ? void 0 : _this$store$currentPr3.getData();
|
|
2834
|
+
schedule = (_this$store$currentPr4 = this.store.currentProduct) === null || _this$store$currentPr4 === void 0 ? void 0 : _this$store$currentPr4.getOtherParams()['schedule'];
|
|
2850
2835
|
filteredSchedule = filterScheduleByDateRange(schedule, startDate || '', endDate || ''); // 1.后端返回的数据,确定资源在每一天的可用和使用情况
|
|
2851
2836
|
tempResourceIds = getResourcesIdsByProduct(tempProducts);
|
|
2852
|
-
_context32.next =
|
|
2837
|
+
_context32.next = 10;
|
|
2853
2838
|
return this.store.date.fetchResourceDates({
|
|
2854
2839
|
query: {
|
|
2855
2840
|
start_date: startDate || '',
|
|
@@ -2857,8 +2842,24 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2857
2842
|
resource_ids: tempResourceIds
|
|
2858
2843
|
}
|
|
2859
2844
|
});
|
|
2860
|
-
case
|
|
2845
|
+
case 10:
|
|
2861
2846
|
res = _context32.sent;
|
|
2847
|
+
// 先去读缓存结果,因为正常 UI 调用的是 7 天,而下面我会直接计算 30 天(最少也是 14 天),所以先去读缓存结果,如果缓存结果存在,则直接返回
|
|
2848
|
+
// TODO 优化关于为什么要放在接口后,因为在获取时间切片的时候还需要读一次接口数据,其实可以直接从这个结果里拿了,需要优化
|
|
2849
|
+
cache = (_this$store$currentPr5 = this.store.currentProduct) === null || _this$store$currentPr5 === void 0 ? void 0 : _this$store$currentPr5.getOtherParams()['timeSlotBySchedule'];
|
|
2850
|
+
if (!cache) {
|
|
2851
|
+
_context32.next = 15;
|
|
2852
|
+
break;
|
|
2853
|
+
}
|
|
2854
|
+
if (!(dayjs(params.startDate).isSameOrAfter(dayjs(cache.startDate), 'day') && dayjs(params.endDate).isSameOrBefore(dayjs(cache.endDate), 'day'))) {
|
|
2855
|
+
_context32.next = 15;
|
|
2856
|
+
break;
|
|
2857
|
+
}
|
|
2858
|
+
return _context32.abrupt("return", {
|
|
2859
|
+
dateList: cache.dateList,
|
|
2860
|
+
firstAvailableDate: cache.firstAvailableDate
|
|
2861
|
+
});
|
|
2862
|
+
case 15:
|
|
2862
2863
|
// 2. 商品 schedule 数据,确定日程在每一天的时间片
|
|
2863
2864
|
// 3. 把后端返回的和 schedule 的数据进行合并,确定每一天的可用和使用情况
|
|
2864
2865
|
dates = [];
|
|
@@ -210,7 +210,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
210
210
|
}): void;
|
|
211
211
|
setOtherData(key: string, value: any): void;
|
|
212
212
|
getOtherData(key: string): any;
|
|
213
|
-
getProductTypeById(id: number): Promise<"
|
|
213
|
+
getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
|
|
214
214
|
/**
|
|
215
215
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
216
216
|
*
|
|
@@ -1986,23 +1986,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1986
1986
|
}
|
|
1987
1987
|
async getAvailableDateForSessionOptimize(params = {}) {
|
|
1988
1988
|
var _a, _b, _c, _d, _e, _f;
|
|
1989
|
-
const cache = (_a = this.store.currentProduct) == null ? void 0 : _a.getOtherParams()["timeSlotBySchedule"];
|
|
1990
|
-
if (cache) {
|
|
1991
|
-
if ((0, import_dayjs.default)(params.startDate).isSameOrAfter((0, import_dayjs.default)(cache.startDate), "day") && (0, import_dayjs.default)(params.endDate).isSameOrBefore((0, import_dayjs.default)(cache.endDate), "day")) {
|
|
1992
|
-
return {
|
|
1993
|
-
dateList: cache.dateList,
|
|
1994
|
-
firstAvailableDate: cache.firstAvailableDate
|
|
1995
|
-
};
|
|
1996
|
-
}
|
|
1997
|
-
}
|
|
1998
1989
|
let { startDate, endDate } = params;
|
|
1999
1990
|
if ((0, import_dayjs.default)(startDate).isBefore((0, import_dayjs.default)(), "day") && ((0, import_dayjs.default)(endDate).isAfter((0, import_dayjs.default)(), "day") || (0, import_dayjs.default)(endDate).isSame((0, import_dayjs.default)(), "day"))) {
|
|
2000
1991
|
startDate = (0, import_dayjs.default)().format("YYYY-MM-DD");
|
|
2001
1992
|
}
|
|
2002
1993
|
endDate = (0, import_dayjs.default)().add(1, "month").format("YYYY-MM-DD");
|
|
2003
1994
|
let tempProducts;
|
|
2004
|
-
tempProducts = (
|
|
2005
|
-
const schedule = (
|
|
1995
|
+
tempProducts = (_a = this.store.currentProduct) == null ? void 0 : _a.getData();
|
|
1996
|
+
const schedule = (_b = this.store.currentProduct) == null ? void 0 : _b.getOtherParams()["schedule"];
|
|
2006
1997
|
const filteredSchedule = (0, import_resources.filterScheduleByDateRange)(
|
|
2007
1998
|
schedule,
|
|
2008
1999
|
startDate || "",
|
|
@@ -2016,6 +2007,15 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2016
2007
|
resource_ids: tempResourceIds
|
|
2017
2008
|
}
|
|
2018
2009
|
});
|
|
2010
|
+
const cache = (_c = this.store.currentProduct) == null ? void 0 : _c.getOtherParams()["timeSlotBySchedule"];
|
|
2011
|
+
if (cache) {
|
|
2012
|
+
if ((0, import_dayjs.default)(params.startDate).isSameOrAfter((0, import_dayjs.default)(cache.startDate), "day") && (0, import_dayjs.default)(params.endDate).isSameOrBefore((0, import_dayjs.default)(cache.endDate), "day")) {
|
|
2013
|
+
return {
|
|
2014
|
+
dateList: cache.dateList,
|
|
2015
|
+
firstAvailableDate: cache.firstAvailableDate
|
|
2016
|
+
};
|
|
2017
|
+
}
|
|
2018
|
+
}
|
|
2019
2019
|
let dates = [];
|
|
2020
2020
|
let currentDate = (0, import_dayjs.default)(startDate);
|
|
2021
2021
|
let firstAvailableDate = "";
|