@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
|
@@ -68,12 +68,12 @@ var formatDefaultCapacitys = ({
|
|
|
68
68
|
}
|
|
69
69
|
return [{ id: 0, value: 1, name: "" }];
|
|
70
70
|
};
|
|
71
|
-
var getSumCapacity = ({ capacity }) => {
|
|
71
|
+
var getSumCapacity = ({ capacity, num = 1 }) => {
|
|
72
72
|
let sum = 0;
|
|
73
73
|
for (let item of capacity || []) {
|
|
74
74
|
sum += item.value;
|
|
75
75
|
}
|
|
76
|
-
return sum;
|
|
76
|
+
return sum * num;
|
|
77
77
|
};
|
|
78
78
|
function getCapacityInfoByCartItem(targetCartItem) {
|
|
79
79
|
var _a;
|
|
@@ -81,7 +81,7 @@ function getCapacityInfoByCartItem(targetCartItem) {
|
|
|
81
81
|
capacity: (_a = targetCartItem._productOrigin) == null ? void 0 : _a.capacity,
|
|
82
82
|
product_bundle: targetCartItem._origin.product.product_bundle
|
|
83
83
|
});
|
|
84
|
-
const currentCapacity = getSumCapacity({ capacity: formatCapacity });
|
|
84
|
+
const currentCapacity = getSumCapacity({ capacity: formatCapacity, num: (targetCartItem == null ? void 0 : targetCartItem.num) || 1 });
|
|
85
85
|
return {
|
|
86
86
|
formatCapacity,
|
|
87
87
|
currentCapacity
|
|
@@ -182,13 +182,22 @@ function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, allResourc
|
|
|
182
182
|
const productResourceIds = getResourcesIdsByProduct(cartItem._productOrigin);
|
|
183
183
|
const { currentCapacity } = getCapacityInfoByCartItem(cartItem);
|
|
184
184
|
Object.keys(resourceTypeMap).forEach((formId) => {
|
|
185
|
+
var _a2, _b2, _c, _d;
|
|
185
186
|
const resourcesInType = resourceTypeMap[formId];
|
|
186
187
|
const resourceIdsInType = resourcesInType.map((r) => r.id);
|
|
188
|
+
const selectType = (_d = (_c = (_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c.find((r) => {
|
|
189
|
+
var _a3;
|
|
190
|
+
return ((_a3 = r.id) == null ? void 0 : _a3.toString()) === formId;
|
|
191
|
+
})) == null ? void 0 : _d.type;
|
|
187
192
|
const needsThisResourceType = productResourceIds.some(
|
|
188
193
|
(id) => resourceIdsInType.includes(id)
|
|
189
194
|
);
|
|
190
195
|
if (needsThisResourceType) {
|
|
191
|
-
|
|
196
|
+
if (selectType === "single") {
|
|
197
|
+
requiredCapacityByType[formId] = (requiredCapacityByType[formId] || 0) + ((cartItem == null ? void 0 : cartItem.num) || 1);
|
|
198
|
+
} else {
|
|
199
|
+
requiredCapacityByType[formId] = (requiredCapacityByType[formId] || 0) + currentCapacity;
|
|
200
|
+
}
|
|
192
201
|
}
|
|
193
202
|
});
|
|
194
203
|
});
|
|
@@ -229,13 +238,18 @@ function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, allResourc
|
|
|
229
238
|
console.log(`capacity.ts - 资源类型 ${formId} 多个预约检查: 总容量 ${totalAvailableCapacity}, 需求 ${requiredCapacity}`);
|
|
230
239
|
if (totalAvailableCapacity < requiredCapacity) {
|
|
231
240
|
console.log(`资源类型 ${formId} 容量不足: 需要 ${requiredCapacity}, 可用 ${totalAvailableCapacity}`);
|
|
232
|
-
return
|
|
241
|
+
return {
|
|
242
|
+
success: false,
|
|
243
|
+
required: requiredCapacity,
|
|
244
|
+
available: totalAvailableCapacity
|
|
245
|
+
};
|
|
233
246
|
}
|
|
234
247
|
} else {
|
|
235
248
|
let availableResourceCount = 0;
|
|
236
249
|
resourcesInType.forEach((resource) => {
|
|
237
250
|
const availableTimes = resource.times.filter((time) => {
|
|
238
|
-
|
|
251
|
+
var _a2;
|
|
252
|
+
return !(0, import_dayjs.default)(time.start_at).isAfter((0, import_dayjs.default)(timeSlotStart), "minute") && !(0, import_dayjs.default)(time.end_at).isBefore((0, import_dayjs.default)(timeSlotEnd), "minute") || (0, import_dayjs.default)(time.start_at).isBefore((0, import_dayjs.default)(timeSlotEnd), "minute") && (0, import_dayjs.default)(time.end_at).isAfter((0, import_dayjs.default)(timeSlotStart), "minute") && ((_a2 = time.event_list) == null ? void 0 : _a2.length) === 0;
|
|
239
253
|
});
|
|
240
254
|
if (availableTimes.length > 0) {
|
|
241
255
|
availableResourceCount++;
|
|
@@ -244,11 +258,19 @@ function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, allResourc
|
|
|
244
258
|
console.log(`capacity.ts - 资源类型 ${formId} 单个预约检查: 可用资源数 ${availableResourceCount}, 需求 ${requiredCapacity}`);
|
|
245
259
|
if (availableResourceCount < requiredCapacity) {
|
|
246
260
|
console.log(`资源类型 ${formId} 数量不足: 需要 ${requiredCapacity}, 可用 ${availableResourceCount}`);
|
|
247
|
-
return
|
|
261
|
+
return {
|
|
262
|
+
success: false,
|
|
263
|
+
required: requiredCapacity,
|
|
264
|
+
available: availableResourceCount
|
|
265
|
+
};
|
|
248
266
|
}
|
|
249
267
|
}
|
|
250
268
|
}
|
|
251
|
-
return
|
|
269
|
+
return {
|
|
270
|
+
success: true,
|
|
271
|
+
required: 0,
|
|
272
|
+
available: 0
|
|
273
|
+
};
|
|
252
274
|
}
|
|
253
275
|
// Annotate the CommonJS export names for ESM import in node:
|
|
254
276
|
0 && (module.exports = {
|
|
@@ -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: 根据时间切片、资源、当前预约量判断时间切片是否可用
|
|
@@ -43,6 +43,7 @@ __export(resources_exports, {
|
|
|
43
43
|
getTimeSlicesByResource: () => getTimeSlicesByResource,
|
|
44
44
|
getTimeSlicesByResources: () => getTimeSlicesByResources,
|
|
45
45
|
getTimesIntersection: () => getTimesIntersection,
|
|
46
|
+
isConflict: () => isConflict,
|
|
46
47
|
mergeSubResourcesTimeSlices: () => mergeSubResourcesTimeSlices,
|
|
47
48
|
sortCombinedResources: () => sortCombinedResources
|
|
48
49
|
});
|
|
@@ -636,6 +637,7 @@ function checkTwoResourcesIntersection(resource1, resource2) {
|
|
|
636
637
|
getTimeSlicesByResource,
|
|
637
638
|
getTimeSlicesByResources,
|
|
638
639
|
getTimesIntersection,
|
|
640
|
+
isConflict,
|
|
639
641
|
mergeSubResourcesTimeSlices,
|
|
640
642
|
sortCombinedResources
|
|
641
643
|
});
|
|
@@ -122,6 +122,12 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
122
122
|
throw error;
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* 初始化外设扫码结果监听
|
|
127
|
+
*/
|
|
128
|
+
initPeripheralsListener() {
|
|
129
|
+
this.scan.initPeripheralsListener();
|
|
130
|
+
}
|
|
125
131
|
/**
|
|
126
132
|
* 获取商品列表(不加载到模块中)
|
|
127
133
|
* @returns 商品列表
|