@pisell/pisellos 1.0.70 → 1.0.71
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/Product/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +2 -1
- package/dist/solution/BookingByStep/index.d.ts +16 -0
- package/dist/solution/BookingByStep/index.js +499 -24
- package/dist/solution/BookingByStep/utils/capacity.d.ts +7 -2
- package/dist/solution/BookingByStep/utils/capacity.js +39 -12
- package/dist/solution/BookingByStep/utils/resources.d.ts +15 -0
- package/dist/solution/BookingByStep/utils/resources.js +1 -1
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +2 -1
- package/lib/solution/BookingByStep/index.d.ts +16 -0
- package/lib/solution/BookingByStep/index.js +336 -41
- package/lib/solution/BookingByStep/utils/capacity.d.ts +7 -2
- package/lib/solution/BookingByStep/utils/capacity.js +30 -8
- package/lib/solution/BookingByStep/utils/resources.d.ts +15 -0
- package/lib/solution/BookingByStep/utils/resources.js +2 -0
- package/lib/solution/BookingTicket/index.js +6 -0
- package/package.json +1 -1
|
@@ -15,8 +15,9 @@ export declare const formatDefaultCapacitys: ({ capacity, product_bundle, }: any
|
|
|
15
15
|
* @return {*}
|
|
16
16
|
* @Author: zhiwei.Wang
|
|
17
17
|
*/
|
|
18
|
-
export declare const getSumCapacity: ({ capacity }: {
|
|
18
|
+
export declare const getSumCapacity: ({ capacity, num }: {
|
|
19
19
|
capacity: CapacityItem[];
|
|
20
|
+
num: number;
|
|
20
21
|
}) => number;
|
|
21
22
|
/**
|
|
22
23
|
* 给定购物车数据,返回对应的 capacity 信息和套餐 capacity
|
|
@@ -67,4 +68,8 @@ export declare function getResourcesIdsByProduct(product: any): number[];
|
|
|
67
68
|
/**
|
|
68
69
|
* 检查特定时间段的容量是否足够
|
|
69
70
|
*/
|
|
70
|
-
export declare function checkTimeSlotCapacity(timeSlotStart: string, timeSlotEnd: string, cartItems: CartItem[], allResources: ResourceItem[]):
|
|
71
|
+
export declare function checkTimeSlotCapacity(timeSlotStart: string, timeSlotEnd: string, cartItems: CartItem[], allResources: ResourceItem[]): {
|
|
72
|
+
success: boolean;
|
|
73
|
+
required: number;
|
|
74
|
+
available: number;
|
|
75
|
+
};
|
|
@@ -60,7 +60,9 @@ export var formatDefaultCapacitys = function formatDefaultCapacitys(_ref) {
|
|
|
60
60
|
* @Author: zhiwei.Wang
|
|
61
61
|
*/
|
|
62
62
|
export var getSumCapacity = function getSumCapacity(_ref2) {
|
|
63
|
-
var capacity = _ref2.capacity
|
|
63
|
+
var capacity = _ref2.capacity,
|
|
64
|
+
_ref2$num = _ref2.num,
|
|
65
|
+
num = _ref2$num === void 0 ? 1 : _ref2$num;
|
|
64
66
|
var sum = 0;
|
|
65
67
|
var _iterator = _createForOfIteratorHelper(capacity || []),
|
|
66
68
|
_step;
|
|
@@ -74,7 +76,7 @@ export var getSumCapacity = function getSumCapacity(_ref2) {
|
|
|
74
76
|
} finally {
|
|
75
77
|
_iterator.f();
|
|
76
78
|
}
|
|
77
|
-
return sum;
|
|
79
|
+
return sum * num;
|
|
78
80
|
};
|
|
79
81
|
|
|
80
82
|
/**
|
|
@@ -91,7 +93,8 @@ export function getCapacityInfoByCartItem(targetCartItem) {
|
|
|
91
93
|
product_bundle: targetCartItem._origin.product.product_bundle
|
|
92
94
|
});
|
|
93
95
|
var currentCapacity = getSumCapacity({
|
|
94
|
-
capacity: formatCapacity
|
|
96
|
+
capacity: formatCapacity,
|
|
97
|
+
num: (targetCartItem === null || targetCartItem === void 0 ? void 0 : targetCartItem.num) || 1
|
|
95
98
|
});
|
|
96
99
|
return {
|
|
97
100
|
formatCapacity: formatCapacity,
|
|
@@ -245,17 +248,28 @@ export function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, all
|
|
|
245
248
|
var _getCapacityInfoByCar2 = getCapacityInfoByCartItem(cartItem),
|
|
246
249
|
currentCapacity = _getCapacityInfoByCar2.currentCapacity;
|
|
247
250
|
Object.keys(resourceTypeMap).forEach(function (formId) {
|
|
251
|
+
var _cartItem$_productOri;
|
|
248
252
|
var resourcesInType = resourceTypeMap[formId];
|
|
249
253
|
var resourceIdsInType = resourcesInType.map(function (r) {
|
|
250
254
|
return r.id;
|
|
251
255
|
});
|
|
256
|
+
var selectType = (_cartItem$_productOri = cartItem._productOrigin) === null || _cartItem$_productOri === void 0 || (_cartItem$_productOri = _cartItem$_productOri.product_resource) === null || _cartItem$_productOri === void 0 || (_cartItem$_productOri = _cartItem$_productOri.resources) === null || _cartItem$_productOri === void 0 || (_cartItem$_productOri = _cartItem$_productOri.find(function (r) {
|
|
257
|
+
var _r$id;
|
|
258
|
+
return ((_r$id = r.id) === null || _r$id === void 0 ? void 0 : _r$id.toString()) === formId;
|
|
259
|
+
})) === null || _cartItem$_productOri === void 0 ? void 0 : _cartItem$_productOri.type;
|
|
252
260
|
|
|
253
261
|
// 检查该商品是否需要这种类型的资源
|
|
254
262
|
var needsThisResourceType = productResourceIds.some(function (id) {
|
|
255
263
|
return resourceIdsInType.includes(id);
|
|
256
264
|
});
|
|
257
265
|
if (needsThisResourceType) {
|
|
258
|
-
|
|
266
|
+
// 需要判断是单个预约还是多个预约,如果是单个预约,不用加 capacity,只用+1
|
|
267
|
+
if (selectType === 'single') {
|
|
268
|
+
requiredCapacityByType[formId] = (requiredCapacityByType[formId] || 0) + ((cartItem === null || cartItem === void 0 ? void 0 : cartItem.num) || 1);
|
|
269
|
+
} else {
|
|
270
|
+
requiredCapacityByType[formId] = (requiredCapacityByType[formId] || 0) + currentCapacity;
|
|
271
|
+
}
|
|
272
|
+
// requiredCapacityByType[formId] = (requiredCapacityByType[formId] || 0) + currentCapacity;
|
|
259
273
|
}
|
|
260
274
|
});
|
|
261
275
|
});
|
|
@@ -275,12 +289,12 @@ export function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, all
|
|
|
275
289
|
_step2;
|
|
276
290
|
try {
|
|
277
291
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
278
|
-
var _cartItem$
|
|
292
|
+
var _cartItem$_productOri2;
|
|
279
293
|
var cartItem = _step2.value;
|
|
280
|
-
if ((_cartItem$
|
|
294
|
+
if ((_cartItem$_productOri2 = cartItem._productOrigin) !== null && _cartItem$_productOri2 !== void 0 && (_cartItem$_productOri2 = _cartItem$_productOri2.product_resource) !== null && _cartItem$_productOri2 !== void 0 && _cartItem$_productOri2.resources) {
|
|
281
295
|
resourceTypeConfig = cartItem._productOrigin.product_resource.resources.find(function (r) {
|
|
282
|
-
var _r$
|
|
283
|
-
return ((_r$
|
|
296
|
+
var _r$id2;
|
|
297
|
+
return ((_r$id2 = r.id) === null || _r$id2 === void 0 ? void 0 : _r$id2.toString()) === formId && r.status === 1;
|
|
284
298
|
});
|
|
285
299
|
if (resourceTypeConfig) break;
|
|
286
300
|
}
|
|
@@ -316,7 +330,11 @@ export function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, all
|
|
|
316
330
|
if (totalAvailableCapacity < requiredCapacity) {
|
|
317
331
|
console.log("\u8D44\u6E90\u7C7B\u578B ".concat(formId, " \u5BB9\u91CF\u4E0D\u8DB3: \u9700\u8981 ").concat(requiredCapacity, ", \u53EF\u7528 ").concat(totalAvailableCapacity));
|
|
318
332
|
return {
|
|
319
|
-
v:
|
|
333
|
+
v: {
|
|
334
|
+
success: false,
|
|
335
|
+
required: requiredCapacity,
|
|
336
|
+
available: totalAvailableCapacity
|
|
337
|
+
}
|
|
320
338
|
};
|
|
321
339
|
}
|
|
322
340
|
} else {
|
|
@@ -325,7 +343,8 @@ export function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, all
|
|
|
325
343
|
resourcesInType.forEach(function (resource) {
|
|
326
344
|
// 过滤出在时间段内的资源时间片
|
|
327
345
|
var availableTimes = resource.times.filter(function (time) {
|
|
328
|
-
|
|
346
|
+
var _time$event_list;
|
|
347
|
+
return !dayjs(time.start_at).isAfter(dayjs(timeSlotStart), 'minute') && !dayjs(time.end_at).isBefore(dayjs(timeSlotEnd), 'minute') || dayjs(time.start_at).isBefore(dayjs(timeSlotEnd), 'minute') && dayjs(time.end_at).isAfter(dayjs(timeSlotStart), 'minute') && ((_time$event_list = time.event_list) === null || _time$event_list === void 0 ? void 0 : _time$event_list.length) === 0;
|
|
329
348
|
});
|
|
330
349
|
if (availableTimes.length > 0) {
|
|
331
350
|
availableResourceCount++;
|
|
@@ -335,7 +354,11 @@ export function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, all
|
|
|
335
354
|
if (availableResourceCount < requiredCapacity) {
|
|
336
355
|
console.log("\u8D44\u6E90\u7C7B\u578B ".concat(formId, " \u6570\u91CF\u4E0D\u8DB3: \u9700\u8981 ").concat(requiredCapacity, ", \u53EF\u7528 ").concat(availableResourceCount));
|
|
337
356
|
return {
|
|
338
|
-
v:
|
|
357
|
+
v: {
|
|
358
|
+
success: false,
|
|
359
|
+
required: requiredCapacity,
|
|
360
|
+
available: availableResourceCount
|
|
361
|
+
}
|
|
339
362
|
};
|
|
340
363
|
}
|
|
341
364
|
}
|
|
@@ -346,5 +369,9 @@ export function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, all
|
|
|
346
369
|
if (_ret === 0) continue;
|
|
347
370
|
if (_ret) return _ret.v;
|
|
348
371
|
}
|
|
349
|
-
return
|
|
372
|
+
return {
|
|
373
|
+
success: true,
|
|
374
|
+
required: 0,
|
|
375
|
+
available: 0
|
|
376
|
+
};
|
|
350
377
|
}
|
|
@@ -20,6 +20,21 @@ export interface ResourceItem {
|
|
|
20
20
|
interface BookingItem {
|
|
21
21
|
[key: string]: any;
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* @title: 判断两个时间段是否有重叠
|
|
25
|
+
* @description:
|
|
26
|
+
* @param {object} event
|
|
27
|
+
* @param {object} current
|
|
28
|
+
* @return {*}
|
|
29
|
+
* @Author: zhiwei.Wang
|
|
30
|
+
*/
|
|
31
|
+
export declare const isConflict: (event: {
|
|
32
|
+
start_at: DateType;
|
|
33
|
+
end_at: DateType;
|
|
34
|
+
}, current: {
|
|
35
|
+
start_at: DateType;
|
|
36
|
+
end_at?: DateType;
|
|
37
|
+
}) => boolean;
|
|
23
38
|
/**
|
|
24
39
|
* @title: 获取时间切片是否可用
|
|
25
40
|
* @description: 根据时间切片、资源、当前预约量判断时间切片是否可用
|
|
@@ -42,7 +42,7 @@ var getUseableEventCount = function getUseableEventCount(eventList, current) {
|
|
|
42
42
|
* @return {*}
|
|
43
43
|
* @Author: zhiwei.Wang
|
|
44
44
|
*/
|
|
45
|
-
var isConflict = function isConflict(event, current) {
|
|
45
|
+
export var isConflict = function isConflict(event, current) {
|
|
46
46
|
var eventStart = dayjs(event.start_at);
|
|
47
47
|
var eventEnd = dayjs(event.end_at);
|
|
48
48
|
var currentStart = dayjs(current.start_at);
|
|
@@ -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(): "duration" | "session" | "normal";
|
|
53
53
|
}
|
|
@@ -97,7 +97,8 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
97
97
|
schedule_date,
|
|
98
98
|
with_schedule,
|
|
99
99
|
schedule_datetime,
|
|
100
|
-
application_code: (_b = this.otherParams) == null ? void 0 : _b.channel
|
|
100
|
+
application_code: (_b = this.otherParams) == null ? void 0 : _b.channel,
|
|
101
|
+
is_eject: 1
|
|
101
102
|
},
|
|
102
103
|
{ useCache: true }
|
|
103
104
|
);
|
|
@@ -324,6 +324,22 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
324
324
|
success: boolean;
|
|
325
325
|
minAvailableCount: number;
|
|
326
326
|
};
|
|
327
|
+
/**
|
|
328
|
+
* 将 ProductData 转换为 CartItem,但不添加到购物车
|
|
329
|
+
* 参考 addProductToCart 方法的实现
|
|
330
|
+
*/
|
|
331
|
+
private convertProductToCartItem;
|
|
332
|
+
checkMaxDurationCapacityForDetailNums({ product, date, account, }: {
|
|
333
|
+
product: ProductData;
|
|
334
|
+
date?: {
|
|
335
|
+
startTime: string;
|
|
336
|
+
endTime: string;
|
|
337
|
+
} | null;
|
|
338
|
+
account?: Account | null;
|
|
339
|
+
}): {
|
|
340
|
+
success: boolean;
|
|
341
|
+
minAvailableCount: number;
|
|
342
|
+
};
|
|
327
343
|
setOtherData(key: string, value: any): void;
|
|
328
344
|
getOtherData(key: string): any;
|
|
329
345
|
getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
|