@pisell/pisellos 2.1.21 → 2.1.22
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.js +11 -6
- package/dist/solution/BookingByStep/utils/resources.d.ts +15 -0
- package/dist/solution/BookingByStep/utils/resources.js +1 -1
- package/lib/solution/BookingByStep/index.js +6 -3
- package/lib/solution/BookingByStep/utils/resources.d.ts +15 -0
- package/lib/solution/BookingByStep/utils/resources.js +2 -0
- package/package.json +1 -1
|
@@ -31,7 +31,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
31
31
|
import { BaseModule } from "../../modules/BaseModule";
|
|
32
32
|
import { BookingByStepHooks, createModule } from "./types";
|
|
33
33
|
import { getAvailableProductResources } from "./utils/products";
|
|
34
|
-
import { getResourcesByProduct, getTimeSlicesByResource, getTimeSlicesByResources, getIsUsableByTimeItem, getOthersSelectedResources, getOthersCartSelectedResources, filterScheduleByDateRange, checkSessionProductLeadTime, sortCombinedResources, filterResourcesByFormItem, checkTwoResourcesIntersection } from "./utils/resources";
|
|
34
|
+
import { getResourcesByProduct, getTimeSlicesByResource, getTimeSlicesByResources, getIsUsableByTimeItem, getOthersSelectedResources, getOthersCartSelectedResources, filterScheduleByDateRange, checkSessionProductLeadTime, sortCombinedResources, filterResourcesByFormItem, checkTwoResourcesIntersection, isConflict } from "./utils/resources";
|
|
35
35
|
import dayjs from 'dayjs';
|
|
36
36
|
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
|
|
37
37
|
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
|
|
@@ -2598,12 +2598,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2598
2598
|
});
|
|
2599
2599
|
// 这里为什么要设置个 map,因为有可能日程有重叠,所以要把重叠的 event_list 去除
|
|
2600
2600
|
var mSet = new Map();
|
|
2601
|
-
|
|
2602
|
-
//
|
|
2603
|
-
|
|
2604
|
-
|
|
2601
|
+
n.event_list.forEach(function (m) {
|
|
2602
|
+
// 需要确认 m 的时间段是否和 item 的时间段有交集
|
|
2603
|
+
if (isConflict({
|
|
2604
|
+
start_at: m.start_at,
|
|
2605
|
+
end_at: m.end_at
|
|
2606
|
+
}, {
|
|
2607
|
+
start_at: dayjs(item.start),
|
|
2608
|
+
end_at: dayjs(item.end)
|
|
2609
|
+
})) {
|
|
2605
2610
|
mSet.set(m.id, m.pax || 1);
|
|
2606
|
-
}
|
|
2611
|
+
}
|
|
2607
2612
|
});
|
|
2608
2613
|
acc += Array.from(mSet.values()).reduce(function (acc, curr) {
|
|
2609
2614
|
return acc + curr;
|
|
@@ -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);
|
|
@@ -1826,10 +1826,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1826
1826
|
return !(0, import_dayjs.default)(n2.start_at).isAfter((0, import_dayjs.default)(item.start), "minute") && !(0, import_dayjs.default)(n2.end_at).isBefore((0, import_dayjs.default)(item.end), "minute") || (0, import_dayjs.default)(n2.start_at).isBefore((0, import_dayjs.default)(item.end), "minute") && (0, import_dayjs.default)(n2.end_at).isAfter((0, import_dayjs.default)(item.start), "minute");
|
|
1827
1827
|
});
|
|
1828
1828
|
const mSet = /* @__PURE__ */ new Map();
|
|
1829
|
-
|
|
1830
|
-
|
|
1829
|
+
n.event_list.forEach((m) => {
|
|
1830
|
+
if ((0, import_resources.isConflict)(
|
|
1831
|
+
{ start_at: m.start_at, end_at: m.end_at },
|
|
1832
|
+
{ start_at: (0, import_dayjs.default)(item.start), end_at: (0, import_dayjs.default)(item.end) }
|
|
1833
|
+
)) {
|
|
1831
1834
|
mSet.set(m.id, m.pax || 1);
|
|
1832
|
-
}
|
|
1835
|
+
}
|
|
1833
1836
|
});
|
|
1834
1837
|
acc += Array.from(mSet.values()).reduce((acc2, curr2) => acc2 + curr2, 0);
|
|
1835
1838
|
return acc;
|
|
@@ -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
|
});
|