@pisell/pisellos 0.0.416 → 0.0.418
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/types.d.ts +3 -1
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.d.ts +9 -2
- package/dist/solution/BookingByStep/index.js +94 -16
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/lib/modules/Date/types.d.ts +3 -1
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.d.ts +9 -2
- package/lib/solution/BookingByStep/index.js +108 -29
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -20,7 +20,9 @@ export interface ITime {
|
|
|
20
20
|
date: string;
|
|
21
21
|
week: string;
|
|
22
22
|
weekNum: number;
|
|
23
|
-
status: 'unavailable' | 'available';
|
|
23
|
+
status: 'unavailable' | 'available' | 'lots_of_space' | 'filling_up_fast' | 'sold_out';
|
|
24
|
+
summaryCount?: number;
|
|
25
|
+
availableCount?: number;
|
|
24
26
|
resource?: any[];
|
|
25
27
|
color?: string[];
|
|
26
28
|
}
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
|
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
311
|
date: string;
|
|
312
312
|
status: string;
|
|
313
313
|
week: string;
|
|
314
|
-
weekNum: 0 |
|
|
314
|
+
weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -330,6 +330,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
330
330
|
count: number;
|
|
331
331
|
left: number;
|
|
332
332
|
summaryCount: number;
|
|
333
|
+
status: keyof TimeStatusMap;
|
|
333
334
|
}[];
|
|
334
335
|
/**
|
|
335
336
|
* 找到多个资源的公共可用时间段
|
|
@@ -357,7 +358,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
357
358
|
};
|
|
358
359
|
setOtherData(key: string, value: any): void;
|
|
359
360
|
getOtherData(key: string): any;
|
|
360
|
-
getProductTypeById(id: number): Promise<"
|
|
361
|
+
getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
|
|
361
362
|
/**
|
|
362
363
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
363
364
|
*
|
|
@@ -394,3 +395,9 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
394
395
|
*/
|
|
395
396
|
getContactInfo(params: any): Promise<any>;
|
|
396
397
|
}
|
|
398
|
+
interface TimeStatusMap {
|
|
399
|
+
lots_of_space: true;
|
|
400
|
+
filling_up_fast: true;
|
|
401
|
+
sold_out: true;
|
|
402
|
+
}
|
|
403
|
+
export {};
|
|
@@ -2674,6 +2674,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2674
2674
|
value: function getTimeslotBySchedule(_ref11) {
|
|
2675
2675
|
var _this$store$currentPr2,
|
|
2676
2676
|
_targetProductData$pr,
|
|
2677
|
+
_targetProductData$pr2,
|
|
2677
2678
|
_this15 = this;
|
|
2678
2679
|
var date = _ref11.date,
|
|
2679
2680
|
scheduleIds = _ref11.scheduleIds,
|
|
@@ -2717,7 +2718,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2717
2718
|
var firstEnabledResourceId = targetProductData === null || targetProductData === void 0 || (_targetProductData$pr = targetProductData.product_resource) === null || _targetProductData$pr === void 0 || (_targetProductData$pr = _targetProductData$pr.resources) === null || _targetProductData$pr === void 0 || (_targetProductData$pr = _targetProductData$pr.find(function (n) {
|
|
2718
2719
|
return n.status === 1;
|
|
2719
2720
|
})) === null || _targetProductData$pr === void 0 ? void 0 : _targetProductData$pr.id;
|
|
2720
|
-
|
|
2721
|
+
var firstEnabledResourceConfig = targetProductData === null || targetProductData === void 0 || (_targetProductData$pr2 = targetProductData.product_resource) === null || _targetProductData$pr2 === void 0 || (_targetProductData$pr2 = _targetProductData$pr2.resources) === null || _targetProductData$pr2 === void 0 ? void 0 : _targetProductData$pr2.find(function (n) {
|
|
2722
|
+
return n.status === 1 && n.id === firstEnabledResourceId;
|
|
2723
|
+
});
|
|
2724
|
+
var isMultipleBooking = (firstEnabledResourceConfig === null || firstEnabledResourceConfig === void 0 ? void 0 : firstEnabledResourceConfig.type) === 'multiple';
|
|
2721
2725
|
// 计算每个日程切片下日程可用的资源的容量总和
|
|
2722
2726
|
var formatScheduleTimeSlots = scheduleTimeSlots.map(function (item) {
|
|
2723
2727
|
// 用来计算资源的可使用情况,针对单个schedule 时间片
|
|
@@ -2725,6 +2729,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2725
2729
|
var count = 0;
|
|
2726
2730
|
var bookingLeft = 0;
|
|
2727
2731
|
var summaryCount = 0;
|
|
2732
|
+
var summaryConfigCount = 0;
|
|
2728
2733
|
// 遍历所有资源
|
|
2729
2734
|
allProductResources === null || allProductResources === void 0 || allProductResources.forEach(function (m) {
|
|
2730
2735
|
// 遍历所有资源的上工时间片
|
|
@@ -2772,6 +2777,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2772
2777
|
}
|
|
2773
2778
|
currentResourcesTimeSlotCanUsedArr.push(res.usable);
|
|
2774
2779
|
});
|
|
2780
|
+
if (m.form_id === firstEnabledResourceId) {
|
|
2781
|
+
// 确认当前资源是单个预约还是多个预约,单个预约则只需要计数,多个预约才添加容量
|
|
2782
|
+
if (isMultipleBooking) {
|
|
2783
|
+
summaryConfigCount += m.capacity;
|
|
2784
|
+
} else {
|
|
2785
|
+
summaryConfigCount += 1;
|
|
2786
|
+
}
|
|
2787
|
+
}
|
|
2775
2788
|
// 在已经选定时间的情况下,只要canUseTime如果有一个 false 那就不可用
|
|
2776
2789
|
if (!currentResourcesTimeSlotCanUsedArr.some(function (n) {
|
|
2777
2790
|
return n === false;
|
|
@@ -2930,6 +2943,28 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2930
2943
|
});
|
|
2931
2944
|
var startDayJs = dayjs(item.start);
|
|
2932
2945
|
var endDayJs = dayjs(item.end);
|
|
2946
|
+
|
|
2947
|
+
// 状态
|
|
2948
|
+
// 如果是isMultipleBooking
|
|
2949
|
+
// lots_of_space: summaryCount / summaryConfigCount > 0.5
|
|
2950
|
+
// filling_up_fast: summaryCount / summaryConfigCount <= 0.5 && summaryCount > 0
|
|
2951
|
+
// sold_out: bookingLeft = 0
|
|
2952
|
+
// 如果不是isMultipleBooking
|
|
2953
|
+
// lots_of_space: bookingLeft / summaryConfigCount > 0.5
|
|
2954
|
+
// filling_up_fast: bookingLeft / summaryConfigCount <= 0.5 && count > 0
|
|
2955
|
+
// sold_out: bookingLeft = 0
|
|
2956
|
+
var timeStatus = 'sold_out';
|
|
2957
|
+
if (bookingLeft === 0) timeStatus = 'sold_out';else if (isMultipleBooking) {
|
|
2958
|
+
if (summaryConfigCount === 0) timeStatus = 'sold_out';else {
|
|
2959
|
+
var usageRatio = summaryCount / summaryConfigCount;
|
|
2960
|
+
if (usageRatio > 0.5) timeStatus = 'lots_of_space';else if (summaryCount > 0) timeStatus = 'filling_up_fast';else timeStatus = 'sold_out';
|
|
2961
|
+
}
|
|
2962
|
+
} else {
|
|
2963
|
+
if (summaryConfigCount === 0) timeStatus = 'sold_out';else {
|
|
2964
|
+
var _usageRatio = bookingLeft / summaryConfigCount;
|
|
2965
|
+
if (_usageRatio > 0.5) timeStatus = 'lots_of_space';else if (count > 0) timeStatus = 'filling_up_fast';else timeStatus = 'sold_out';
|
|
2966
|
+
}
|
|
2967
|
+
}
|
|
2933
2968
|
return {
|
|
2934
2969
|
start_time: startDayJs.format('HH:mm'),
|
|
2935
2970
|
end_time: endDayJs.format('HH:mm'),
|
|
@@ -2937,7 +2972,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2937
2972
|
end_at: endDayJs,
|
|
2938
2973
|
count: count,
|
|
2939
2974
|
left: bookingLeft,
|
|
2940
|
-
summaryCount: summaryCount
|
|
2975
|
+
summaryCount: summaryCount,
|
|
2976
|
+
status: timeStatus
|
|
2941
2977
|
};
|
|
2942
2978
|
});
|
|
2943
2979
|
return formatScheduleTimeSlots;
|
|
@@ -4122,12 +4158,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4122
4158
|
});
|
|
4123
4159
|
targetSchedules = this.store.schedule.getScheduleListByIds(tempProducts['schedule.ids']);
|
|
4124
4160
|
_loop8 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop8() {
|
|
4125
|
-
var currentDateStr, status, _checkSessionProductL, latestStartDate, earliestEndDate, scheduleByDate, minTimeMaxTime, scheduleTimeSlots, timesSlotCanUse;
|
|
4161
|
+
var currentDateStr, status, summaryCount, availableCount, _checkSessionProductL, latestStartDate, earliestEndDate, scheduleByDate, minTimeMaxTime, scheduleTimeSlots, timesSlotCanUse, dateStatus, usageRatio;
|
|
4126
4162
|
return _regeneratorRuntime().wrap(function _loop8$(_context29) {
|
|
4127
4163
|
while (1) switch (_context29.prev = _context29.next) {
|
|
4128
4164
|
case 0:
|
|
4129
4165
|
currentDateStr = currentDate.format('YYYY-MM-DD');
|
|
4130
|
-
status = 'available';
|
|
4166
|
+
status = 'available';
|
|
4167
|
+
summaryCount = 0;
|
|
4168
|
+
availableCount = 0; // 1. 检查商品的提前量等情况是否满足
|
|
4131
4169
|
_checkSessionProductL = checkSessionProductLeadTime(tempProducts), latestStartDate = _checkSessionProductL.latestStartDate, earliestEndDate = _checkSessionProductL.earliestEndDate;
|
|
4132
4170
|
if (latestStartDate || earliestEndDate) {
|
|
4133
4171
|
// 如果时间在最早开始时间之前,则设置为不可用
|
|
@@ -4153,17 +4191,25 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4153
4191
|
if (status === 'available') {
|
|
4154
4192
|
minTimeMaxTime = calcMinTimeMaxTimeBySchedules(targetSchedules, {}, currentDateStr);
|
|
4155
4193
|
scheduleTimeSlots = getAllSortedDateRanges(minTimeMaxTime); // 同一天内多个时间片下 只要有一个可用则视为可用
|
|
4156
|
-
timesSlotCanUse =
|
|
4194
|
+
timesSlotCanUse = false;
|
|
4195
|
+
scheduleTimeSlots.forEach(function (item) {
|
|
4157
4196
|
// 用来计算资源的可使用情况,针对单个schedule 时间片
|
|
4158
4197
|
var resourcesUseableMap = {};
|
|
4159
4198
|
// 遍历产品下启用的资源
|
|
4160
4199
|
// 必须要保证每种类型的资源都至少有一个能够在对应时间点被选择
|
|
4161
|
-
|
|
4200
|
+
// 求出第一个资源的剩余量和总量
|
|
4201
|
+
// 剩余量=每个资源在每个时间片内剩余之和
|
|
4202
|
+
// 总量=每个资源在每个时间片内资源总量之和
|
|
4203
|
+
var isAllResourceTypesUseable = true;
|
|
4204
|
+
openResources.forEach(function (resource) {
|
|
4205
|
+
// if (!isAllResourceTypesUseable) return;
|
|
4206
|
+
|
|
4162
4207
|
// 获取当前资源类型的资源列表
|
|
4163
4208
|
var currentResourcesList = allProductResources.filter(function (n) {
|
|
4164
4209
|
return n.form_id === resource.resource_type_id;
|
|
4165
4210
|
});
|
|
4166
|
-
|
|
4211
|
+
var isAnyResourceUseableInType = false;
|
|
4212
|
+
currentResourcesList === null || currentResourcesList === void 0 || currentResourcesList.forEach(function (m) {
|
|
4167
4213
|
// 遍历所有资源的上工时间片
|
|
4168
4214
|
// m.times 需要做个过滤,假设 timeSlice.start_at 是 09:30 timeSlice.end_at 是 11:30
|
|
4169
4215
|
// time 是 time.start_at = 2025-05-26 10:30, time.end_at = 2025-05-26 12:30
|
|
@@ -4171,12 +4217,20 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4171
4217
|
var mTimes = m.times.filter(function (n) {
|
|
4172
4218
|
return !dayjs(n.start_at).isAfter(dayjs(item.start), 'minute') && !dayjs(n.end_at).isBefore(dayjs(item.end), 'minute');
|
|
4173
4219
|
});
|
|
4220
|
+
|
|
4174
4221
|
// 如果在这个区间的时间一个都没有,可以直接认为这个资源不可用
|
|
4175
|
-
if (mTimes.length === 0)
|
|
4176
|
-
|
|
4222
|
+
if (mTimes.length === 0) return;
|
|
4223
|
+
// 如果资源可用则把他的容量纳入总计
|
|
4224
|
+
if (resource.type === 'multiple') {
|
|
4225
|
+
summaryCount += m.capacity;
|
|
4226
|
+
} else {
|
|
4227
|
+
summaryCount += 1;
|
|
4177
4228
|
}
|
|
4178
|
-
var
|
|
4229
|
+
var isAnyTimeSliceUseable = false;
|
|
4230
|
+
mTimes.forEach(function (childTiem) {
|
|
4179
4231
|
var _tempProducts3;
|
|
4232
|
+
if (isAnyTimeSliceUseable) return;
|
|
4233
|
+
|
|
4180
4234
|
// 挨个去匹配某个工作时间段结合当前日程时间,资源能不能用,有多少容量能用
|
|
4181
4235
|
var res = getIsUsableByTimeItem({
|
|
4182
4236
|
timeSlice: {
|
|
@@ -4194,11 +4248,21 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4194
4248
|
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
|
|
4195
4249
|
resourcesUseableMap[m.id] = res.usable;
|
|
4196
4250
|
}
|
|
4197
|
-
|
|
4251
|
+
if (res.usable && !m.onlyComputed) {
|
|
4252
|
+
isAnyTimeSliceUseable = true;
|
|
4253
|
+
if (resource.type === 'multiple') {
|
|
4254
|
+
availableCount += m.capacity;
|
|
4255
|
+
} else {
|
|
4256
|
+
availableCount += 1;
|
|
4257
|
+
}
|
|
4258
|
+
}
|
|
4259
|
+
;
|
|
4198
4260
|
});
|
|
4199
|
-
|
|
4261
|
+
if (isAnyTimeSliceUseable) isAnyResourceUseableInType = true;
|
|
4200
4262
|
});
|
|
4263
|
+
if (!isAnyResourceUseableInType) isAllResourceTypesUseable = false;
|
|
4201
4264
|
});
|
|
4265
|
+
if (isAllResourceTypesUseable) timesSlotCanUse = true;
|
|
4202
4266
|
});
|
|
4203
4267
|
if (!timesSlotCanUse) {
|
|
4204
4268
|
status = 'unavailable';
|
|
@@ -4207,22 +4271,36 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4207
4271
|
firstAvailableDate = currentDateStr;
|
|
4208
4272
|
}
|
|
4209
4273
|
}
|
|
4274
|
+
// 状态: lots_of_space: availableCount / summaryCount > 0.5
|
|
4275
|
+
// filling_up_fast: availableCount / summaryCount <= 0.5 && availableCount > 0
|
|
4276
|
+
// sold_out: summaryCount = 0
|
|
4277
|
+
// unavailable: summaryCount > 0 && availableCount = 0
|
|
4278
|
+
|
|
4279
|
+
if (status === 'unavailable') {
|
|
4280
|
+
// dateStatus = 'unavailable'
|
|
4281
|
+
if (summaryCount === 0) dateStatus = 'sold_out';else dateStatus = 'unavailable';
|
|
4282
|
+
} else {
|
|
4283
|
+
usageRatio = availableCount / summaryCount;
|
|
4284
|
+
if (usageRatio > 0.5) dateStatus = 'lots_of_space';else dateStatus = 'filling_up_fast';
|
|
4285
|
+
}
|
|
4210
4286
|
dates.push({
|
|
4211
4287
|
date: dayjs(currentDate).format('YYYY-MM-DD'),
|
|
4212
4288
|
week: dayjs(currentDate).format('ddd'),
|
|
4213
4289
|
weekNum: dayjs(currentDate).day(),
|
|
4214
|
-
|
|
4290
|
+
summaryCount: summaryCount,
|
|
4291
|
+
availableCount: availableCount,
|
|
4292
|
+
status: dateStatus
|
|
4215
4293
|
});
|
|
4216
4294
|
|
|
4217
4295
|
// 如果 firstAvailableDate 距离 startDate 大于 14 天了,则后面就不需要再找了,也是一种性能保护
|
|
4218
4296
|
if (!(firstAvailableDate && dayjs(currentDate).diff(dayjs(startDate), 'day') > 31)) {
|
|
4219
|
-
_context29.next =
|
|
4297
|
+
_context29.next = 12;
|
|
4220
4298
|
break;
|
|
4221
4299
|
}
|
|
4222
4300
|
return _context29.abrupt("return", 1);
|
|
4223
|
-
case
|
|
4301
|
+
case 12:
|
|
4224
4302
|
currentDate = dayjs(currentDate).add(1, 'day');
|
|
4225
|
-
case
|
|
4303
|
+
case 13:
|
|
4226
4304
|
case "end":
|
|
4227
4305
|
return _context29.stop();
|
|
4228
4306
|
}
|
|
@@ -123,7 +123,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
123
123
|
* 获取当前的客户搜索条件
|
|
124
124
|
* @returns 当前搜索条件
|
|
125
125
|
*/
|
|
126
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
126
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
127
127
|
/**
|
|
128
128
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
129
129
|
* @returns 客户状态
|
|
@@ -20,7 +20,9 @@ export interface ITime {
|
|
|
20
20
|
date: string;
|
|
21
21
|
week: string;
|
|
22
22
|
weekNum: number;
|
|
23
|
-
status: 'unavailable' | 'available';
|
|
23
|
+
status: 'unavailable' | 'available' | 'lots_of_space' | 'filling_up_fast' | 'sold_out';
|
|
24
|
+
summaryCount?: number;
|
|
25
|
+
availableCount?: number;
|
|
24
26
|
resource?: any[];
|
|
25
27
|
color?: string[];
|
|
26
28
|
}
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
|
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
311
|
date: string;
|
|
312
312
|
status: string;
|
|
313
313
|
week: string;
|
|
314
|
-
weekNum: 0 |
|
|
314
|
+
weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -330,6 +330,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
330
330
|
count: number;
|
|
331
331
|
left: number;
|
|
332
332
|
summaryCount: number;
|
|
333
|
+
status: keyof TimeStatusMap;
|
|
333
334
|
}[];
|
|
334
335
|
/**
|
|
335
336
|
* 找到多个资源的公共可用时间段
|
|
@@ -357,7 +358,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
357
358
|
};
|
|
358
359
|
setOtherData(key: string, value: any): void;
|
|
359
360
|
getOtherData(key: string): any;
|
|
360
|
-
getProductTypeById(id: number): Promise<"
|
|
361
|
+
getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
|
|
361
362
|
/**
|
|
362
363
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
363
364
|
*
|
|
@@ -394,3 +395,9 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
394
395
|
*/
|
|
395
396
|
getContactInfo(params: any): Promise<any>;
|
|
396
397
|
}
|
|
398
|
+
interface TimeStatusMap {
|
|
399
|
+
lots_of_space: true;
|
|
400
|
+
filling_up_fast: true;
|
|
401
|
+
sold_out: true;
|
|
402
|
+
}
|
|
403
|
+
export {};
|
|
@@ -1865,7 +1865,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1865
1865
|
resources,
|
|
1866
1866
|
product
|
|
1867
1867
|
}) {
|
|
1868
|
-
var _a, _b, _c, _d, _e;
|
|
1868
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1869
1869
|
const targetProduct = this.store.currentProduct;
|
|
1870
1870
|
const targetProductData = product || targetProduct;
|
|
1871
1871
|
let targetSchedules = [];
|
|
@@ -1911,11 +1911,16 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1911
1911
|
const firstEnabledResourceId = (_e = (_d = (_c = targetProductData == null ? void 0 : targetProductData.product_resource) == null ? void 0 : _c.resources) == null ? void 0 : _d.find(
|
|
1912
1912
|
(n) => n.status === 1
|
|
1913
1913
|
)) == null ? void 0 : _e.id;
|
|
1914
|
+
const firstEnabledResourceConfig = (_g = (_f = targetProductData == null ? void 0 : targetProductData.product_resource) == null ? void 0 : _f.resources) == null ? void 0 : _g.find(
|
|
1915
|
+
(n) => n.status === 1 && n.id === firstEnabledResourceId
|
|
1916
|
+
);
|
|
1917
|
+
const isMultipleBooking = (firstEnabledResourceConfig == null ? void 0 : firstEnabledResourceConfig.type) === "multiple";
|
|
1914
1918
|
const formatScheduleTimeSlots = scheduleTimeSlots.map((item) => {
|
|
1915
1919
|
const resourcesUseableMap = {};
|
|
1916
1920
|
let count = 0;
|
|
1917
1921
|
let bookingLeft = 0;
|
|
1918
1922
|
let summaryCount = 0;
|
|
1923
|
+
let summaryConfigCount = 0;
|
|
1919
1924
|
allProductResources == null ? void 0 : allProductResources.forEach((m) => {
|
|
1920
1925
|
let currentResourcesCount = 0;
|
|
1921
1926
|
let currentResourcesSummaryCount = 0;
|
|
@@ -1951,6 +1956,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1951
1956
|
}
|
|
1952
1957
|
currentResourcesTimeSlotCanUsedArr.push(res.usable);
|
|
1953
1958
|
});
|
|
1959
|
+
if (m.form_id === firstEnabledResourceId) {
|
|
1960
|
+
if (isMultipleBooking) {
|
|
1961
|
+
summaryConfigCount += m.capacity;
|
|
1962
|
+
} else {
|
|
1963
|
+
summaryConfigCount += 1;
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1954
1966
|
if (!currentResourcesTimeSlotCanUsedArr.some(
|
|
1955
1967
|
(n) => n === false
|
|
1956
1968
|
) && // 只统计第一种资源的容量和 left
|
|
@@ -1979,9 +1991,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1979
1991
|
}
|
|
1980
1992
|
let otherCartItems = cartItems2.filter(
|
|
1981
1993
|
(m) => {
|
|
1982
|
-
var _a2, _b2, _c2, _d2, _e2,
|
|
1994
|
+
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
1983
1995
|
const isTimeMatch = ((_b2 = (_a2 = m._productOrigin) == null ? void 0 : _a2.id) == null ? void 0 : _b2.toString()) !== ((_c2 = targetProductData == null ? void 0 : targetProductData.id) == null ? void 0 : _c2.toString()) && `${m.start_date} ${m.start_time}` === item.start && `${m.start_date} ${m.end_time}` === item.end;
|
|
1984
|
-
const isResourceMatch = (
|
|
1996
|
+
const isResourceMatch = (_f2 = (_e2 = (_d2 = m._productOrigin) == null ? void 0 : _d2.product_resource) == null ? void 0 : _e2.resources) == null ? void 0 : _f2.find((m2) => m2.type === n.type && m2.status === 1);
|
|
1985
1997
|
return isTimeMatch && isResourceMatch;
|
|
1986
1998
|
}
|
|
1987
1999
|
);
|
|
@@ -2068,6 +2080,34 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2068
2080
|
});
|
|
2069
2081
|
const startDayJs = (0, import_dayjs.default)(item.start);
|
|
2070
2082
|
const endDayJs = (0, import_dayjs.default)(item.end);
|
|
2083
|
+
let timeStatus = "sold_out";
|
|
2084
|
+
if (bookingLeft === 0)
|
|
2085
|
+
timeStatus = "sold_out";
|
|
2086
|
+
else if (isMultipleBooking) {
|
|
2087
|
+
if (summaryConfigCount === 0)
|
|
2088
|
+
timeStatus = "sold_out";
|
|
2089
|
+
else {
|
|
2090
|
+
const usageRatio = summaryCount / summaryConfigCount;
|
|
2091
|
+
if (usageRatio > 0.5)
|
|
2092
|
+
timeStatus = "lots_of_space";
|
|
2093
|
+
else if (summaryCount > 0)
|
|
2094
|
+
timeStatus = "filling_up_fast";
|
|
2095
|
+
else
|
|
2096
|
+
timeStatus = "sold_out";
|
|
2097
|
+
}
|
|
2098
|
+
} else {
|
|
2099
|
+
if (summaryConfigCount === 0)
|
|
2100
|
+
timeStatus = "sold_out";
|
|
2101
|
+
else {
|
|
2102
|
+
const usageRatio = bookingLeft / summaryConfigCount;
|
|
2103
|
+
if (usageRatio > 0.5)
|
|
2104
|
+
timeStatus = "lots_of_space";
|
|
2105
|
+
else if (count > 0)
|
|
2106
|
+
timeStatus = "filling_up_fast";
|
|
2107
|
+
else
|
|
2108
|
+
timeStatus = "sold_out";
|
|
2109
|
+
}
|
|
2110
|
+
}
|
|
2071
2111
|
return {
|
|
2072
2112
|
start_time: startDayJs.format("HH:mm"),
|
|
2073
2113
|
end_time: endDayJs.format("HH:mm"),
|
|
@@ -2075,7 +2115,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2075
2115
|
end_at: endDayJs,
|
|
2076
2116
|
count,
|
|
2077
2117
|
left: bookingLeft,
|
|
2078
|
-
summaryCount
|
|
2118
|
+
summaryCount,
|
|
2119
|
+
status: timeStatus
|
|
2079
2120
|
};
|
|
2080
2121
|
});
|
|
2081
2122
|
return formatScheduleTimeSlots;
|
|
@@ -2846,6 +2887,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2846
2887
|
while ((0, import_dayjs.default)(currentDate).isBefore((0, import_dayjs.default)(endDate), "day") || (0, import_dayjs.default)(currentDate).isSame((0, import_dayjs.default)(endDate), "day")) {
|
|
2847
2888
|
const currentDateStr = currentDate.format("YYYY-MM-DD");
|
|
2848
2889
|
let status = "available";
|
|
2890
|
+
let summaryCount = 0;
|
|
2891
|
+
let availableCount = 0;
|
|
2849
2892
|
const { latestStartDate, earliestEndDate } = (0, import_resources.checkSessionProductLeadTime)(tempProducts);
|
|
2850
2893
|
if (latestStartDate || earliestEndDate) {
|
|
2851
2894
|
if (latestStartDate && (0, import_dayjs.default)(currentDate).isBefore(latestStartDate, "day")) {
|
|
@@ -2870,43 +2913,64 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2870
2913
|
currentDateStr
|
|
2871
2914
|
);
|
|
2872
2915
|
const scheduleTimeSlots = (0, import_utils3.getAllSortedDateRanges)(minTimeMaxTime);
|
|
2873
|
-
|
|
2916
|
+
let timesSlotCanUse = false;
|
|
2917
|
+
scheduleTimeSlots.forEach((item) => {
|
|
2874
2918
|
const resourcesUseableMap = {};
|
|
2875
|
-
|
|
2919
|
+
let isAllResourceTypesUseable = true;
|
|
2920
|
+
openResources.forEach((resource) => {
|
|
2876
2921
|
const currentResourcesList = allProductResources.filter(
|
|
2877
2922
|
(n) => n.form_id === resource.resource_type_id
|
|
2878
2923
|
);
|
|
2879
|
-
|
|
2924
|
+
let isAnyResourceUseableInType = false;
|
|
2925
|
+
currentResourcesList == null ? void 0 : currentResourcesList.forEach((m) => {
|
|
2880
2926
|
const mTimes = m.times.filter((n) => {
|
|
2881
2927
|
return !(0, import_dayjs.default)(n.start_at).isAfter((0, import_dayjs.default)(item.start), "minute") && !(0, import_dayjs.default)(n.end_at).isBefore((0, import_dayjs.default)(item.end), "minute");
|
|
2882
2928
|
});
|
|
2883
|
-
if (mTimes.length === 0)
|
|
2929
|
+
if (mTimes.length === 0)
|
|
2884
2930
|
return;
|
|
2931
|
+
if (resource.type === "multiple") {
|
|
2932
|
+
summaryCount += m.capacity;
|
|
2933
|
+
} else {
|
|
2934
|
+
summaryCount += 1;
|
|
2885
2935
|
}
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2936
|
+
let isAnyTimeSliceUseable = false;
|
|
2937
|
+
mTimes.forEach((childTiem) => {
|
|
2938
|
+
if (isAnyTimeSliceUseable)
|
|
2939
|
+
return;
|
|
2940
|
+
const res2 = (0, import_resources.getIsUsableByTimeItem)({
|
|
2941
|
+
timeSlice: {
|
|
2942
|
+
start_time: item.start,
|
|
2943
|
+
end_time: item.end,
|
|
2944
|
+
start_at: (0, import_dayjs.default)(item.start),
|
|
2945
|
+
end_at: (0, import_dayjs.default)(item.end)
|
|
2946
|
+
},
|
|
2947
|
+
time: childTiem,
|
|
2948
|
+
resource: m,
|
|
2949
|
+
currentCount: 1,
|
|
2950
|
+
resourcesUseableMap,
|
|
2951
|
+
cut_off_time: tempProducts == null ? void 0 : tempProducts.cut_off_time
|
|
2952
|
+
});
|
|
2953
|
+
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false && res2.reason !== "capacityOnly") {
|
|
2954
|
+
resourcesUseableMap[m.id] = res2.usable;
|
|
2955
|
+
}
|
|
2956
|
+
if (res2.usable && !m.onlyComputed) {
|
|
2957
|
+
isAnyTimeSliceUseable = true;
|
|
2958
|
+
if (resource.type === "multiple") {
|
|
2959
|
+
availableCount += m.capacity;
|
|
2960
|
+
} else {
|
|
2961
|
+
availableCount += 1;
|
|
2903
2962
|
}
|
|
2904
|
-
return res2.usable && !m.onlyComputed;
|
|
2905
2963
|
}
|
|
2906
|
-
|
|
2907
|
-
|
|
2964
|
+
;
|
|
2965
|
+
});
|
|
2966
|
+
if (isAnyTimeSliceUseable)
|
|
2967
|
+
isAnyResourceUseableInType = true;
|
|
2908
2968
|
});
|
|
2969
|
+
if (!isAnyResourceUseableInType)
|
|
2970
|
+
isAllResourceTypesUseable = false;
|
|
2909
2971
|
});
|
|
2972
|
+
if (isAllResourceTypesUseable)
|
|
2973
|
+
timesSlotCanUse = true;
|
|
2910
2974
|
});
|
|
2911
2975
|
if (!timesSlotCanUse) {
|
|
2912
2976
|
status = "unavailable";
|
|
@@ -2915,11 +2979,26 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2915
2979
|
firstAvailableDate = currentDateStr;
|
|
2916
2980
|
}
|
|
2917
2981
|
}
|
|
2982
|
+
let dateStatus;
|
|
2983
|
+
if (status === "unavailable") {
|
|
2984
|
+
if (summaryCount === 0)
|
|
2985
|
+
dateStatus = "sold_out";
|
|
2986
|
+
else
|
|
2987
|
+
dateStatus = "unavailable";
|
|
2988
|
+
} else {
|
|
2989
|
+
const usageRatio = availableCount / summaryCount;
|
|
2990
|
+
if (usageRatio > 0.5)
|
|
2991
|
+
dateStatus = "lots_of_space";
|
|
2992
|
+
else
|
|
2993
|
+
dateStatus = "filling_up_fast";
|
|
2994
|
+
}
|
|
2918
2995
|
dates.push({
|
|
2919
2996
|
date: (0, import_dayjs.default)(currentDate).format("YYYY-MM-DD"),
|
|
2920
2997
|
week: (0, import_dayjs.default)(currentDate).format("ddd"),
|
|
2921
2998
|
weekNum: (0, import_dayjs.default)(currentDate).day(),
|
|
2922
|
-
|
|
2999
|
+
summaryCount,
|
|
3000
|
+
availableCount,
|
|
3001
|
+
status: dateStatus
|
|
2923
3002
|
});
|
|
2924
3003
|
if (firstAvailableDate && (0, import_dayjs.default)(currentDate).diff((0, import_dayjs.default)(startDate), "day") > 31) {
|
|
2925
3004
|
break;
|
|
@@ -123,7 +123,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
123
123
|
* 获取当前的客户搜索条件
|
|
124
124
|
* @returns 当前搜索条件
|
|
125
125
|
*/
|
|
126
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
126
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
127
127
|
/**
|
|
128
128
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
129
129
|
* @returns 客户状态
|