@pisell/pisellos 0.0.99 → 0.0.101
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/solution/BookingByStep/index.d.ts +9 -0
- package/dist/solution/BookingByStep/index.js +132 -11
- package/dist/solution/BookingByStep/utils/resources.d.ts +22 -2
- package/dist/solution/BookingByStep/utils/resources.js +8 -4
- package/lib/solution/BookingByStep/index.d.ts +9 -0
- package/lib/solution/BookingByStep/index.js +137 -3
- package/lib/solution/BookingByStep/utils/resources.d.ts +22 -2
- package/lib/solution/BookingByStep/utils/resources.js +8 -4
- package/package.json +1 -1
|
@@ -209,4 +209,13 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
209
209
|
setOtherData(key: string, value: any): void;
|
|
210
210
|
getOtherData(key: string): any;
|
|
211
211
|
getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
|
|
212
|
+
/**
|
|
213
|
+
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
214
|
+
*
|
|
215
|
+
* @param {string} cartItemId
|
|
216
|
+
* @param {string} resourceCode
|
|
217
|
+
* @return {*}
|
|
218
|
+
* @memberof BookingByStepImpl
|
|
219
|
+
*/
|
|
220
|
+
getResourcesByCartItemAndCode(cartItemId: string, resourceCode: string): any;
|
|
212
221
|
}
|
|
@@ -2067,9 +2067,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2067
2067
|
var resourceIds = [];
|
|
2068
2068
|
var resourcesTypeId = undefined;
|
|
2069
2069
|
var isSingleResource = false;
|
|
2070
|
+
|
|
2071
|
+
// 找出购物车里最大的 cut_off_time
|
|
2072
|
+
var maxCutOffTime = undefined;
|
|
2073
|
+
var maxCutOffTimeValue = dayjs();
|
|
2070
2074
|
cartItems.forEach(function (item) {
|
|
2071
|
-
var _item$_productOrigin11, _item$_productOrigin12;
|
|
2075
|
+
var _item$_productOrigin11, _item$_productOrigin12, _item$_productOrigin13, _item$_productOrigin14;
|
|
2072
2076
|
(_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.forEach(function (n) {
|
|
2077
|
+
// TODO: 少了个 status 的判断
|
|
2073
2078
|
if (n.code === resources_code) {
|
|
2074
2079
|
resources.push.apply(resources, _toConsumableArray(n.renderList || []));
|
|
2075
2080
|
isSingleResource = n.type === 'single';
|
|
@@ -2084,6 +2089,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2084
2089
|
resourcesTypeId = item === null || item === void 0 || (_item$_productOrigin12 = item._productOrigin) === null || _item$_productOrigin12 === void 0 || (_item$_productOrigin12 = _item$_productOrigin12.product_resource) === null || _item$_productOrigin12 === void 0 || (_item$_productOrigin12 = _item$_productOrigin12.resources) === null || _item$_productOrigin12 === void 0 || (_item$_productOrigin12 = _item$_productOrigin12.find(function (n) {
|
|
2085
2090
|
return n.code === resources_code;
|
|
2086
2091
|
})) === null || _item$_productOrigin12 === void 0 ? void 0 : _item$_productOrigin12.id;
|
|
2092
|
+
if ((_item$_productOrigin13 = item._productOrigin) !== null && _item$_productOrigin13 !== void 0 && _item$_productOrigin13.cut_off_time && ((_item$_productOrigin14 = item._productOrigin) === null || _item$_productOrigin14 === void 0 ? void 0 : _item$_productOrigin14.cut_off_time.type) === 'advance') {
|
|
2093
|
+
var currentCutOffTime = dayjs().add(item._productOrigin.cut_off_time.unit, item._productOrigin.cut_off_time.unit_type);
|
|
2094
|
+
if (currentCutOffTime.isAfter(maxCutOffTimeValue, 'minute')) {
|
|
2095
|
+
maxCutOffTimeValue = currentCutOffTime;
|
|
2096
|
+
maxCutOffTime = item._productOrigin.cut_off_time;
|
|
2097
|
+
}
|
|
2098
|
+
}
|
|
2087
2099
|
});
|
|
2088
2100
|
// 保险起见,在这里如果 dateRange 里也有 resources 的话,也 push 进去
|
|
2089
2101
|
if ((_dateRange = dateRange) !== null && _dateRange !== void 0 && (_dateRange = _dateRange[0]) !== null && _dateRange !== void 0 && (_dateRange = _dateRange.resource) !== null && _dateRange !== void 0 && _dateRange.length) {
|
|
@@ -2105,13 +2117,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2105
2117
|
cartItems.forEach(function (item) {
|
|
2106
2118
|
// 单个预约累加账号 多个预约取最大值
|
|
2107
2119
|
if (isSingleResource) {
|
|
2108
|
-
var _item$_productOrigin$3, _item$
|
|
2109
|
-
accountDuration += (_item$_productOrigin$3 = (_item$
|
|
2120
|
+
var _item$_productOrigin$3, _item$_productOrigin15;
|
|
2121
|
+
accountDuration += (_item$_productOrigin$3 = (_item$_productOrigin15 = item._productOrigin) === null || _item$_productOrigin15 === void 0 || (_item$_productOrigin15 = _item$_productOrigin15.duration) === null || _item$_productOrigin15 === void 0 ? void 0 : _item$_productOrigin15.value) !== null && _item$_productOrigin$3 !== void 0 ? _item$_productOrigin$3 : 0;
|
|
2110
2122
|
} else {
|
|
2111
|
-
var _item$_productOrigin$4, _item$
|
|
2112
|
-
if (accountDuration < ((_item$_productOrigin$4 = (_item$
|
|
2113
|
-
var _item$_productOrigin$5, _item$
|
|
2114
|
-
accountDuration = (_item$_productOrigin$5 = (_item$
|
|
2123
|
+
var _item$_productOrigin$4, _item$_productOrigin16;
|
|
2124
|
+
if (accountDuration < ((_item$_productOrigin$4 = (_item$_productOrigin16 = item._productOrigin) === null || _item$_productOrigin16 === void 0 || (_item$_productOrigin16 = _item$_productOrigin16.duration) === null || _item$_productOrigin16 === void 0 ? void 0 : _item$_productOrigin16.value) !== null && _item$_productOrigin$4 !== void 0 ? _item$_productOrigin$4 : 0)) {
|
|
2125
|
+
var _item$_productOrigin$5, _item$_productOrigin17;
|
|
2126
|
+
accountDuration = (_item$_productOrigin$5 = (_item$_productOrigin17 = item._productOrigin) === null || _item$_productOrigin17 === void 0 || (_item$_productOrigin17 = _item$_productOrigin17.duration) === null || _item$_productOrigin17 === void 0 ? void 0 : _item$_productOrigin17.value) !== null && _item$_productOrigin$5 !== void 0 ? _item$_productOrigin$5 : 0;
|
|
2115
2127
|
}
|
|
2116
2128
|
}
|
|
2117
2129
|
});
|
|
@@ -2153,7 +2165,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2153
2165
|
duration: duration,
|
|
2154
2166
|
currentDate: dateRange[0].date,
|
|
2155
2167
|
split: 10,
|
|
2156
|
-
resourcesUseableMap: resourcesUseableMap
|
|
2168
|
+
resourcesUseableMap: resourcesUseableMap,
|
|
2169
|
+
cut_off_time: maxCutOffTime
|
|
2157
2170
|
});
|
|
2158
2171
|
return timeSlots;
|
|
2159
2172
|
}
|
|
@@ -2183,9 +2196,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2183
2196
|
var _newResources$;
|
|
2184
2197
|
var newResources = cloneDeep(item._origin.resources);
|
|
2185
2198
|
newResources.forEach(function (resource) {
|
|
2186
|
-
var _item$_productOrigin$6, _item$
|
|
2199
|
+
var _item$_productOrigin$6, _item$_productOrigin18, _ref11, _item$_productOrigin19;
|
|
2187
2200
|
resource.startTime = currentStartTime;
|
|
2188
|
-
resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$6 = (_item$
|
|
2201
|
+
resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$6 = (_item$_productOrigin18 = item._productOrigin) === null || _item$_productOrigin18 === void 0 || (_item$_productOrigin18 = _item$_productOrigin18.duration) === null || _item$_productOrigin18 === void 0 ? void 0 : _item$_productOrigin18.value) !== null && _item$_productOrigin$6 !== void 0 ? _item$_productOrigin$6 : 0, (_ref11 = (_item$_productOrigin19 = item._productOrigin) === null || _item$_productOrigin19 === void 0 || (_item$_productOrigin19 = _item$_productOrigin19.duration) === null || _item$_productOrigin19 === void 0 ? void 0 : _item$_productOrigin19.type) !== null && _ref11 !== void 0 ? _ref11 : 'minutes').format('YYYY-MM-DD HH:mm');
|
|
2189
2202
|
delete resource.times;
|
|
2190
2203
|
});
|
|
2191
2204
|
_this11.store.cart.updateItem({
|
|
@@ -2326,7 +2339,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2326
2339
|
// time 是 time.start_at = 2025-05-26 10:30, time.end_at = 2025-05-26 12:30
|
|
2327
2340
|
// 需要判断 time 的开始结束时间 是否包含timeSlice的开始结束时间
|
|
2328
2341
|
var mTimes = m.times.filter(function (n) {
|
|
2329
|
-
return !dayjs(n.start_at).isAfter(dayjs(item.start)) && !dayjs(n.end_at).isBefore(dayjs(item.end));
|
|
2342
|
+
return !dayjs(n.start_at).isAfter(dayjs(item.start), 'minute') && !dayjs(n.end_at).isBefore(dayjs(item.end), 'minute');
|
|
2330
2343
|
});
|
|
2331
2344
|
// 如果在这个区间的时间一个都没有,可以直接认为这个资源不可用
|
|
2332
2345
|
if (mTimes.length === 0) {
|
|
@@ -2463,6 +2476,114 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2463
2476
|
}
|
|
2464
2477
|
return getProductTypeById;
|
|
2465
2478
|
}()
|
|
2479
|
+
/**
|
|
2480
|
+
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
2481
|
+
*
|
|
2482
|
+
* @param {string} cartItemId
|
|
2483
|
+
* @param {string} resourceCode
|
|
2484
|
+
* @return {*}
|
|
2485
|
+
* @memberof BookingByStepImpl
|
|
2486
|
+
*/
|
|
2487
|
+
}, {
|
|
2488
|
+
key: "getResourcesByCartItemAndCode",
|
|
2489
|
+
value: function getResourcesByCartItemAndCode(cartItemId, resourceCode) {
|
|
2490
|
+
var _cartItem$_productOri11, _cartItem$_productOri12;
|
|
2491
|
+
var dateRange = this.store.date.getDateRange();
|
|
2492
|
+
var resources = [];
|
|
2493
|
+
if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
|
|
2494
|
+
dateRange.forEach(function (n) {
|
|
2495
|
+
if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
|
|
2496
|
+
});
|
|
2497
|
+
}
|
|
2498
|
+
if (!resources.length) {
|
|
2499
|
+
var dateList = this.store.date.getDateList();
|
|
2500
|
+
dateList.forEach(function (n) {
|
|
2501
|
+
if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
|
|
2502
|
+
});
|
|
2503
|
+
}
|
|
2504
|
+
var resourcesMap = getResourcesMap(cloneDeep(resources));
|
|
2505
|
+
var cartItems = this.store.cart.getItems();
|
|
2506
|
+
var cartItem = cartItems.find(function (item) {
|
|
2507
|
+
return item._id === cartItemId;
|
|
2508
|
+
});
|
|
2509
|
+
if (!cartItem) return [];
|
|
2510
|
+
var selectedResources = [];
|
|
2511
|
+
var formatCapacity = formatDefaultCapacitys({
|
|
2512
|
+
capacity: (_cartItem$_productOri11 = cartItem._productOrigin) === null || _cartItem$_productOri11 === void 0 ? void 0 : _cartItem$_productOri11.capacity,
|
|
2513
|
+
product_bundle: cartItem._origin.product.product_bundle
|
|
2514
|
+
});
|
|
2515
|
+
cartItem._origin.metadata.capacity = formatCapacity;
|
|
2516
|
+
var currentCapacity = getSumCapacity({
|
|
2517
|
+
capacity: formatCapacity
|
|
2518
|
+
});
|
|
2519
|
+
if (cartItem.holder_id) {
|
|
2520
|
+
selectedResources = getOthersSelectedResources(cartItems, cartItem.holder_id, resourcesMap);
|
|
2521
|
+
} else {
|
|
2522
|
+
selectedResources = getOthersCartSelectedResources(cartItems, cartItem._id, resourcesMap);
|
|
2523
|
+
}
|
|
2524
|
+
var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri12 = cartItem._productOrigin) === null || _cartItem$_productOri12 === void 0 || (_cartItem$_productOri12 = _cartItem$_productOri12.product_resource) === null || _cartItem$_productOri12 === void 0 ? void 0 : _cartItem$_productOri12.resources) || [], selectedResources, currentCapacity);
|
|
2525
|
+
var targetResource = productResources.find(function (resource) {
|
|
2526
|
+
return resource.code === resourceCode;
|
|
2527
|
+
});
|
|
2528
|
+
if (!targetResource) return [];
|
|
2529
|
+
if (cartItem._origin.start_time) {
|
|
2530
|
+
var startTime = dayjs("".concat(cartItem._origin.start_date, " ").concat(cartItem._origin.start_time));
|
|
2531
|
+
var endTime = dayjs("".concat(cartItem._origin.end_date, " ").concat(cartItem._origin.end_time));
|
|
2532
|
+
var resourcesUseableMap = {};
|
|
2533
|
+
targetResource.renderList = targetResource.renderList.sort(function (a, b) {
|
|
2534
|
+
var _a$metadata5, _b$metadata5;
|
|
2535
|
+
var aIsCombined = ((_a$metadata5 = a.metadata) === null || _a$metadata5 === void 0 || (_a$metadata5 = _a$metadata5.combined_resource) === null || _a$metadata5 === void 0 ? void 0 : _a$metadata5.status) === 1;
|
|
2536
|
+
var bIsCombined = ((_b$metadata5 = b.metadata) === null || _b$metadata5 === void 0 || (_b$metadata5 = _b$metadata5.combined_resource) === null || _b$metadata5 === void 0 ? void 0 : _b$metadata5.status) === 1;
|
|
2537
|
+
if (aIsCombined && !bIsCombined) return 1;
|
|
2538
|
+
if (!aIsCombined && bIsCombined) return -1;
|
|
2539
|
+
return 0;
|
|
2540
|
+
});
|
|
2541
|
+
targetResource.renderList = targetResource.renderList.filter(function (m) {
|
|
2542
|
+
var mTimes = m.times.filter(function (n) {
|
|
2543
|
+
return !dayjs(n.start_at).isAfter(dayjs(startTime)) && !dayjs(n.end_at).isBefore(dayjs(endTime));
|
|
2544
|
+
});
|
|
2545
|
+
if (mTimes.length === 0) return false;
|
|
2546
|
+
var canUseArr = mTimes.map(function (item) {
|
|
2547
|
+
var _cartItem$_productOri13;
|
|
2548
|
+
var res = getIsUsableByTimeItem({
|
|
2549
|
+
timeSlice: {
|
|
2550
|
+
start_time: startTime.format('HH:mm'),
|
|
2551
|
+
end_time: endTime.format('HH:mm'),
|
|
2552
|
+
start_at: startTime,
|
|
2553
|
+
end_at: endTime
|
|
2554
|
+
},
|
|
2555
|
+
time: item,
|
|
2556
|
+
resource: m,
|
|
2557
|
+
currentCount: currentCapacity || 0,
|
|
2558
|
+
resourcesUseableMap: resourcesUseableMap,
|
|
2559
|
+
cut_off_time: (_cartItem$_productOri13 = cartItem._productOrigin) === null || _cartItem$_productOri13 === void 0 ? void 0 : _cartItem$_productOri13.cut_off_time
|
|
2560
|
+
});
|
|
2561
|
+
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
|
|
2562
|
+
resourcesUseableMap[m.id] = res.usable;
|
|
2563
|
+
}
|
|
2564
|
+
return res.usable;
|
|
2565
|
+
});
|
|
2566
|
+
if (m.onlyComputed) return false;
|
|
2567
|
+
return !canUseArr.some(function (n) {
|
|
2568
|
+
return n === false;
|
|
2569
|
+
});
|
|
2570
|
+
});
|
|
2571
|
+
} else {
|
|
2572
|
+
targetResource.renderList = targetResource.renderList.filter(function (n) {
|
|
2573
|
+
var _cartItem$_productOri14;
|
|
2574
|
+
var recordCount = n.capacity || 0;
|
|
2575
|
+
if (n.onlyComputed) return false;
|
|
2576
|
+
var timeSlots = getTimeSlicesByResource({
|
|
2577
|
+
resource: n,
|
|
2578
|
+
duration: ((_cartItem$_productOri14 = cartItem._productOrigin) === null || _cartItem$_productOri14 === void 0 || (_cartItem$_productOri14 = _cartItem$_productOri14.duration) === null || _cartItem$_productOri14 === void 0 ? void 0 : _cartItem$_productOri14.value) || 0,
|
|
2579
|
+
split: 10,
|
|
2580
|
+
currentDate: dateRange[0].date
|
|
2581
|
+
});
|
|
2582
|
+
return recordCount >= currentCapacity && timeSlots.length > 0;
|
|
2583
|
+
});
|
|
2584
|
+
}
|
|
2585
|
+
return targetResource.renderList;
|
|
2586
|
+
}
|
|
2466
2587
|
}]);
|
|
2467
2588
|
return BookingByStepImpl;
|
|
2468
2589
|
}(BaseModule);
|
|
@@ -79,13 +79,23 @@ export declare const formatResources: ({ booking, resources, }: {
|
|
|
79
79
|
* @return {*}
|
|
80
80
|
* @Author: zhiwei.Wang
|
|
81
81
|
*/
|
|
82
|
-
export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate, capacity, resourcesUseableMap, }: {
|
|
82
|
+
export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate, capacity, resourcesUseableMap, cut_off_time }: {
|
|
83
83
|
resource: ResourceItem;
|
|
84
84
|
duration: number;
|
|
85
85
|
split: number;
|
|
86
86
|
currentDate: DateType | string;
|
|
87
87
|
capacity?: number | undefined;
|
|
88
88
|
resourcesUseableMap?: Record<string, boolean> | undefined;
|
|
89
|
+
cut_off_time?: {
|
|
90
|
+
future_day: number;
|
|
91
|
+
unit: number;
|
|
92
|
+
unit_type: string;
|
|
93
|
+
type: string;
|
|
94
|
+
ongoing?: {
|
|
95
|
+
type: string;
|
|
96
|
+
unit: number;
|
|
97
|
+
} | undefined;
|
|
98
|
+
} | undefined;
|
|
89
99
|
}) => TimeSliceItem[];
|
|
90
100
|
/**
|
|
91
101
|
* @title: 获取时间切片列表的交集
|
|
@@ -123,7 +133,7 @@ export declare const mergeSubResourcesTimeSlices: (resources: ResourceItem[], re
|
|
|
123
133
|
* @return {*}
|
|
124
134
|
* @Author: zhiwei.Wang
|
|
125
135
|
*/
|
|
126
|
-
export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split, capacity, resourcesUseableMap, }: {
|
|
136
|
+
export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split, capacity, resourcesUseableMap, cut_off_time }: {
|
|
127
137
|
resourceIds: number[];
|
|
128
138
|
resourcesMap: any;
|
|
129
139
|
duration: number;
|
|
@@ -131,6 +141,16 @@ export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, dur
|
|
|
131
141
|
split: number;
|
|
132
142
|
capacity?: number | undefined;
|
|
133
143
|
resourcesUseableMap: Record<string, boolean>;
|
|
144
|
+
cut_off_time?: {
|
|
145
|
+
future_day: number;
|
|
146
|
+
unit: number;
|
|
147
|
+
unit_type: string;
|
|
148
|
+
type: string;
|
|
149
|
+
ongoing?: {
|
|
150
|
+
type: string;
|
|
151
|
+
unit: number;
|
|
152
|
+
} | undefined;
|
|
153
|
+
} | undefined;
|
|
134
154
|
}) => any[];
|
|
135
155
|
/**
|
|
136
156
|
* @title: 获取其他人的已选资源
|
|
@@ -414,7 +414,8 @@ export var getTimeSlicesByResource = function getTimeSlicesByResource(_ref5) {
|
|
|
414
414
|
currentDate = _ref5$currentDate === void 0 ? dayjs() : _ref5$currentDate,
|
|
415
415
|
capacity = _ref5.capacity,
|
|
416
416
|
_ref5$resourcesUseabl = _ref5.resourcesUseableMap,
|
|
417
|
-
resourcesUseableMap = _ref5$resourcesUseabl === void 0 ? {} : _ref5$resourcesUseabl
|
|
417
|
+
resourcesUseableMap = _ref5$resourcesUseabl === void 0 ? {} : _ref5$resourcesUseabl,
|
|
418
|
+
cut_off_time = _ref5.cut_off_time;
|
|
418
419
|
var times = resource.times;
|
|
419
420
|
|
|
420
421
|
// 存储所有时间切片
|
|
@@ -452,7 +453,8 @@ export var getTimeSlicesByResource = function getTimeSlicesByResource(_ref5) {
|
|
|
452
453
|
time: time,
|
|
453
454
|
resource: resource,
|
|
454
455
|
currentCount: capacity || 1,
|
|
455
|
-
resourcesUseableMap: resourcesUseableMap
|
|
456
|
+
resourcesUseableMap: resourcesUseableMap,
|
|
457
|
+
cut_off_time: cut_off_time
|
|
456
458
|
});
|
|
457
459
|
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[resource.id]) !== false) {
|
|
458
460
|
resourcesUseableMap[resource.id] = _status.usable;
|
|
@@ -562,7 +564,8 @@ export var getTimeSlicesByResources = function getTimeSlicesByResources(_ref6) {
|
|
|
562
564
|
currentDate = _ref6.currentDate,
|
|
563
565
|
split = _ref6.split,
|
|
564
566
|
capacity = _ref6.capacity,
|
|
565
|
-
resourcesUseableMap = _ref6.resourcesUseableMap
|
|
567
|
+
resourcesUseableMap = _ref6.resourcesUseableMap,
|
|
568
|
+
cut_off_time = _ref6.cut_off_time;
|
|
566
569
|
// 获取资源列表
|
|
567
570
|
var resources = getResourcesByIds(resourcesMap, resourceIds);
|
|
568
571
|
mergeSubResourcesTimeSlices(resources, resourcesMap);
|
|
@@ -584,7 +587,8 @@ export var getTimeSlicesByResources = function getTimeSlicesByResources(_ref6) {
|
|
|
584
587
|
split: split,
|
|
585
588
|
currentDate: currentDate,
|
|
586
589
|
capacity: capacity,
|
|
587
|
-
resourcesUseableMap: resourcesUseableMap
|
|
590
|
+
resourcesUseableMap: resourcesUseableMap,
|
|
591
|
+
cut_off_time: cut_off_time
|
|
588
592
|
}));
|
|
589
593
|
}, []);
|
|
590
594
|
|
|
@@ -209,4 +209,13 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
209
209
|
setOtherData(key: string, value: any): void;
|
|
210
210
|
getOtherData(key: string): any;
|
|
211
211
|
getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
|
|
212
|
+
/**
|
|
213
|
+
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
214
|
+
*
|
|
215
|
+
* @param {string} cartItemId
|
|
216
|
+
* @param {string} resourceCode
|
|
217
|
+
* @return {*}
|
|
218
|
+
* @memberof BookingByStepImpl
|
|
219
|
+
*/
|
|
220
|
+
getResourcesByCartItemAndCode(cartItemId: string, resourceCode: string): any;
|
|
212
221
|
}
|
|
@@ -1370,8 +1370,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1370
1370
|
const resourceIds = [];
|
|
1371
1371
|
let resourcesTypeId = void 0;
|
|
1372
1372
|
let isSingleResource = false;
|
|
1373
|
+
let maxCutOffTime = void 0;
|
|
1374
|
+
let maxCutOffTimeValue = (0, import_dayjs.default)();
|
|
1373
1375
|
cartItems.forEach((item) => {
|
|
1374
|
-
var _a2, _b2, _c2, _d2, _e2, _f2, _g;
|
|
1376
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g, _h, _i;
|
|
1375
1377
|
(_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.forEach((n) => {
|
|
1376
1378
|
if (n.code === resources_code) {
|
|
1377
1379
|
resources.push(...n.renderList || []);
|
|
@@ -1384,6 +1386,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1384
1386
|
resourcesTypeId = (_g = (_f2 = (_e2 = (_d2 = item == null ? void 0 : item._productOrigin) == null ? void 0 : _d2.product_resource) == null ? void 0 : _e2.resources) == null ? void 0 : _f2.find(
|
|
1385
1387
|
(n) => n.code === resources_code
|
|
1386
1388
|
)) == null ? void 0 : _g.id;
|
|
1389
|
+
if (((_h = item._productOrigin) == null ? void 0 : _h.cut_off_time) && ((_i = item._productOrigin) == null ? void 0 : _i.cut_off_time.type) === "advance") {
|
|
1390
|
+
const currentCutOffTime = (0, import_dayjs.default)().add(item._productOrigin.cut_off_time.unit, item._productOrigin.cut_off_time.unit_type);
|
|
1391
|
+
if (currentCutOffTime.isAfter(maxCutOffTimeValue, "minute")) {
|
|
1392
|
+
maxCutOffTimeValue = currentCutOffTime;
|
|
1393
|
+
maxCutOffTime = item._productOrigin.cut_off_time;
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1387
1396
|
});
|
|
1388
1397
|
if ((_b = (_a = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _a.resource) == null ? void 0 : _b.length) {
|
|
1389
1398
|
dateRange[0].resource.forEach((n) => {
|
|
@@ -1445,7 +1454,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1445
1454
|
duration,
|
|
1446
1455
|
currentDate: dateRange[0].date,
|
|
1447
1456
|
split: 10,
|
|
1448
|
-
resourcesUseableMap
|
|
1457
|
+
resourcesUseableMap,
|
|
1458
|
+
cut_off_time: maxCutOffTime
|
|
1449
1459
|
});
|
|
1450
1460
|
return timeSlots;
|
|
1451
1461
|
}
|
|
@@ -1588,7 +1598,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1588
1598
|
let currentResourcesCount = 0;
|
|
1589
1599
|
const currentResourcesTimeSlotCanUsedArr = [];
|
|
1590
1600
|
const mTimes = m.times.filter((n) => {
|
|
1591
|
-
return !(0, import_dayjs.default)(n.start_at).isAfter((0, import_dayjs.default)(item.start)) && !(0, import_dayjs.default)(n.end_at).isBefore((0, import_dayjs.default)(item.end));
|
|
1601
|
+
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");
|
|
1592
1602
|
});
|
|
1593
1603
|
if (mTimes.length === 0) {
|
|
1594
1604
|
return;
|
|
@@ -1682,6 +1692,130 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1682
1692
|
}
|
|
1683
1693
|
return "normal";
|
|
1684
1694
|
}
|
|
1695
|
+
/**
|
|
1696
|
+
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
1697
|
+
*
|
|
1698
|
+
* @param {string} cartItemId
|
|
1699
|
+
* @param {string} resourceCode
|
|
1700
|
+
* @return {*}
|
|
1701
|
+
* @memberof BookingByStepImpl
|
|
1702
|
+
*/
|
|
1703
|
+
getResourcesByCartItemAndCode(cartItemId, resourceCode) {
|
|
1704
|
+
var _a, _b, _c;
|
|
1705
|
+
const dateRange = this.store.date.getDateRange();
|
|
1706
|
+
const resources = [];
|
|
1707
|
+
if (dateRange == null ? void 0 : dateRange.length) {
|
|
1708
|
+
dateRange.forEach((n) => {
|
|
1709
|
+
if (n.resource)
|
|
1710
|
+
resources.push(...n.resource);
|
|
1711
|
+
});
|
|
1712
|
+
}
|
|
1713
|
+
if (!resources.length) {
|
|
1714
|
+
const dateList = this.store.date.getDateList();
|
|
1715
|
+
dateList.forEach((n) => {
|
|
1716
|
+
if (n.resource)
|
|
1717
|
+
resources.push(...n.resource);
|
|
1718
|
+
});
|
|
1719
|
+
}
|
|
1720
|
+
const resourcesMap = (0, import_utils.getResourcesMap)((0, import_lodash_es.cloneDeep)(resources));
|
|
1721
|
+
const cartItems = this.store.cart.getItems();
|
|
1722
|
+
const cartItem = cartItems.find((item) => item._id === cartItemId);
|
|
1723
|
+
if (!cartItem)
|
|
1724
|
+
return [];
|
|
1725
|
+
let selectedResources = [];
|
|
1726
|
+
const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
|
|
1727
|
+
capacity: (_a = cartItem._productOrigin) == null ? void 0 : _a.capacity,
|
|
1728
|
+
product_bundle: cartItem._origin.product.product_bundle
|
|
1729
|
+
});
|
|
1730
|
+
cartItem._origin.metadata.capacity = formatCapacity;
|
|
1731
|
+
const currentCapacity = (0, import_resources.getSumCapacity)({ capacity: formatCapacity });
|
|
1732
|
+
if (cartItem.holder_id) {
|
|
1733
|
+
selectedResources = (0, import_resources.getOthersSelectedResources)(
|
|
1734
|
+
cartItems,
|
|
1735
|
+
cartItem.holder_id,
|
|
1736
|
+
resourcesMap
|
|
1737
|
+
);
|
|
1738
|
+
} else {
|
|
1739
|
+
selectedResources = (0, import_resources.getOthersCartSelectedResources)(
|
|
1740
|
+
cartItems,
|
|
1741
|
+
cartItem._id,
|
|
1742
|
+
resourcesMap
|
|
1743
|
+
);
|
|
1744
|
+
}
|
|
1745
|
+
const productResources = (0, import_resources.getResourcesByProduct)(
|
|
1746
|
+
resourcesMap,
|
|
1747
|
+
((_c = (_b = cartItem._productOrigin) == null ? void 0 : _b.product_resource) == null ? void 0 : _c.resources) || [],
|
|
1748
|
+
selectedResources,
|
|
1749
|
+
currentCapacity
|
|
1750
|
+
);
|
|
1751
|
+
const targetResource = productResources.find((resource) => resource.code === resourceCode);
|
|
1752
|
+
if (!targetResource)
|
|
1753
|
+
return [];
|
|
1754
|
+
if (cartItem._origin.start_time) {
|
|
1755
|
+
const startTime = (0, import_dayjs.default)(
|
|
1756
|
+
`${cartItem._origin.start_date} ${cartItem._origin.start_time}`
|
|
1757
|
+
);
|
|
1758
|
+
const endTime = (0, import_dayjs.default)(
|
|
1759
|
+
`${cartItem._origin.end_date} ${cartItem._origin.end_time}`
|
|
1760
|
+
);
|
|
1761
|
+
const resourcesUseableMap = {};
|
|
1762
|
+
targetResource.renderList = targetResource.renderList.sort((a, b) => {
|
|
1763
|
+
var _a2, _b2, _c2, _d;
|
|
1764
|
+
const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
|
|
1765
|
+
const bIsCombined = ((_d = (_c2 = b.metadata) == null ? void 0 : _c2.combined_resource) == null ? void 0 : _d.status) === 1;
|
|
1766
|
+
if (aIsCombined && !bIsCombined)
|
|
1767
|
+
return 1;
|
|
1768
|
+
if (!aIsCombined && bIsCombined)
|
|
1769
|
+
return -1;
|
|
1770
|
+
return 0;
|
|
1771
|
+
});
|
|
1772
|
+
targetResource.renderList = targetResource.renderList.filter((m) => {
|
|
1773
|
+
const mTimes = m.times.filter((n) => {
|
|
1774
|
+
return !(0, import_dayjs.default)(n.start_at).isAfter((0, import_dayjs.default)(startTime)) && !(0, import_dayjs.default)(n.end_at).isBefore((0, import_dayjs.default)(endTime));
|
|
1775
|
+
});
|
|
1776
|
+
if (mTimes.length === 0)
|
|
1777
|
+
return false;
|
|
1778
|
+
const canUseArr = mTimes.map((item) => {
|
|
1779
|
+
var _a2;
|
|
1780
|
+
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
1781
|
+
timeSlice: {
|
|
1782
|
+
start_time: startTime.format("HH:mm"),
|
|
1783
|
+
end_time: endTime.format("HH:mm"),
|
|
1784
|
+
start_at: startTime,
|
|
1785
|
+
end_at: endTime
|
|
1786
|
+
},
|
|
1787
|
+
time: item,
|
|
1788
|
+
resource: m,
|
|
1789
|
+
currentCount: currentCapacity || 0,
|
|
1790
|
+
resourcesUseableMap,
|
|
1791
|
+
cut_off_time: (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.cut_off_time
|
|
1792
|
+
});
|
|
1793
|
+
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== "capacityOnly") {
|
|
1794
|
+
resourcesUseableMap[m.id] = res.usable;
|
|
1795
|
+
}
|
|
1796
|
+
return res.usable;
|
|
1797
|
+
});
|
|
1798
|
+
if (m.onlyComputed)
|
|
1799
|
+
return false;
|
|
1800
|
+
return !canUseArr.some((n) => n === false);
|
|
1801
|
+
});
|
|
1802
|
+
} else {
|
|
1803
|
+
targetResource.renderList = targetResource.renderList.filter((n) => {
|
|
1804
|
+
var _a2, _b2;
|
|
1805
|
+
const recordCount = n.capacity || 0;
|
|
1806
|
+
if (n.onlyComputed)
|
|
1807
|
+
return false;
|
|
1808
|
+
const timeSlots = (0, import_resources.getTimeSlicesByResource)({
|
|
1809
|
+
resource: n,
|
|
1810
|
+
duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 0,
|
|
1811
|
+
split: 10,
|
|
1812
|
+
currentDate: dateRange[0].date
|
|
1813
|
+
});
|
|
1814
|
+
return recordCount >= currentCapacity && timeSlots.length > 0;
|
|
1815
|
+
});
|
|
1816
|
+
}
|
|
1817
|
+
return targetResource.renderList;
|
|
1818
|
+
}
|
|
1685
1819
|
};
|
|
1686
1820
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1687
1821
|
0 && (module.exports = {
|
|
@@ -79,13 +79,23 @@ export declare const formatResources: ({ booking, resources, }: {
|
|
|
79
79
|
* @return {*}
|
|
80
80
|
* @Author: zhiwei.Wang
|
|
81
81
|
*/
|
|
82
|
-
export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate, capacity, resourcesUseableMap, }: {
|
|
82
|
+
export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate, capacity, resourcesUseableMap, cut_off_time }: {
|
|
83
83
|
resource: ResourceItem;
|
|
84
84
|
duration: number;
|
|
85
85
|
split: number;
|
|
86
86
|
currentDate: DateType | string;
|
|
87
87
|
capacity?: number | undefined;
|
|
88
88
|
resourcesUseableMap?: Record<string, boolean> | undefined;
|
|
89
|
+
cut_off_time?: {
|
|
90
|
+
future_day: number;
|
|
91
|
+
unit: number;
|
|
92
|
+
unit_type: string;
|
|
93
|
+
type: string;
|
|
94
|
+
ongoing?: {
|
|
95
|
+
type: string;
|
|
96
|
+
unit: number;
|
|
97
|
+
} | undefined;
|
|
98
|
+
} | undefined;
|
|
89
99
|
}) => TimeSliceItem[];
|
|
90
100
|
/**
|
|
91
101
|
* @title: 获取时间切片列表的交集
|
|
@@ -123,7 +133,7 @@ export declare const mergeSubResourcesTimeSlices: (resources: ResourceItem[], re
|
|
|
123
133
|
* @return {*}
|
|
124
134
|
* @Author: zhiwei.Wang
|
|
125
135
|
*/
|
|
126
|
-
export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split, capacity, resourcesUseableMap, }: {
|
|
136
|
+
export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split, capacity, resourcesUseableMap, cut_off_time }: {
|
|
127
137
|
resourceIds: number[];
|
|
128
138
|
resourcesMap: any;
|
|
129
139
|
duration: number;
|
|
@@ -131,6 +141,16 @@ export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, dur
|
|
|
131
141
|
split: number;
|
|
132
142
|
capacity?: number | undefined;
|
|
133
143
|
resourcesUseableMap: Record<string, boolean>;
|
|
144
|
+
cut_off_time?: {
|
|
145
|
+
future_day: number;
|
|
146
|
+
unit: number;
|
|
147
|
+
unit_type: string;
|
|
148
|
+
type: string;
|
|
149
|
+
ongoing?: {
|
|
150
|
+
type: string;
|
|
151
|
+
unit: number;
|
|
152
|
+
} | undefined;
|
|
153
|
+
} | undefined;
|
|
134
154
|
}) => any[];
|
|
135
155
|
/**
|
|
136
156
|
* @title: 获取其他人的已选资源
|
|
@@ -328,7 +328,8 @@ var getTimeSlicesByResource = ({
|
|
|
328
328
|
split = 10,
|
|
329
329
|
currentDate = (0, import_dayjs.default)(),
|
|
330
330
|
capacity,
|
|
331
|
-
resourcesUseableMap = {}
|
|
331
|
+
resourcesUseableMap = {},
|
|
332
|
+
cut_off_time
|
|
332
333
|
}) => {
|
|
333
334
|
const { times } = resource;
|
|
334
335
|
const timeSlices = [];
|
|
@@ -353,7 +354,8 @@ var getTimeSlicesByResource = ({
|
|
|
353
354
|
time,
|
|
354
355
|
resource,
|
|
355
356
|
currentCount: capacity || 1,
|
|
356
|
-
resourcesUseableMap
|
|
357
|
+
resourcesUseableMap,
|
|
358
|
+
cut_off_time
|
|
357
359
|
});
|
|
358
360
|
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[resource.id]) !== false) {
|
|
359
361
|
resourcesUseableMap[resource.id] = _status.usable;
|
|
@@ -415,7 +417,8 @@ var getTimeSlicesByResources = ({
|
|
|
415
417
|
currentDate,
|
|
416
418
|
split,
|
|
417
419
|
capacity,
|
|
418
|
-
resourcesUseableMap
|
|
420
|
+
resourcesUseableMap,
|
|
421
|
+
cut_off_time
|
|
419
422
|
}) => {
|
|
420
423
|
let resources = getResourcesByIds(resourcesMap, resourceIds);
|
|
421
424
|
mergeSubResourcesTimeSlices(resources, resourcesMap);
|
|
@@ -438,7 +441,8 @@ var getTimeSlicesByResources = ({
|
|
|
438
441
|
split,
|
|
439
442
|
currentDate,
|
|
440
443
|
capacity,
|
|
441
|
-
resourcesUseableMap
|
|
444
|
+
resourcesUseableMap,
|
|
445
|
+
cut_off_time
|
|
442
446
|
})
|
|
443
447
|
);
|
|
444
448
|
},
|