@pisell/pisellos 0.0.292 → 0.0.293
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/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/modules/Product/index.d.ts +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
|
@@ -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
|
}
|
|
@@ -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';
|
|
@@ -2601,12 +2601,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2601
2601
|
});
|
|
2602
2602
|
// 这里为什么要设置个 map,因为有可能日程有重叠,所以要把重叠的 event_list 去除
|
|
2603
2603
|
var mSet = new Map();
|
|
2604
|
-
|
|
2605
|
-
//
|
|
2606
|
-
|
|
2607
|
-
|
|
2604
|
+
n.event_list.forEach(function (m) {
|
|
2605
|
+
// 需要确认 m 的时间段是否和 item 的时间段有交集
|
|
2606
|
+
if (isConflict({
|
|
2607
|
+
start_at: m.start_at,
|
|
2608
|
+
end_at: m.end_at
|
|
2609
|
+
}, {
|
|
2610
|
+
start_at: dayjs(item.start),
|
|
2611
|
+
end_at: dayjs(item.end)
|
|
2612
|
+
})) {
|
|
2608
2613
|
mSet.set(m.id, m.pax || 1);
|
|
2609
|
-
}
|
|
2614
|
+
}
|
|
2610
2615
|
});
|
|
2611
2616
|
acc += Array.from(mSet.values()).reduce(function (acc, curr) {
|
|
2612
2617
|
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);
|
|
@@ -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
|
}
|
|
@@ -1829,10 +1829,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1829
1829
|
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");
|
|
1830
1830
|
});
|
|
1831
1831
|
const mSet = /* @__PURE__ */ new Map();
|
|
1832
|
-
|
|
1833
|
-
|
|
1832
|
+
n.event_list.forEach((m) => {
|
|
1833
|
+
if ((0, import_resources.isConflict)(
|
|
1834
|
+
{ start_at: m.start_at, end_at: m.end_at },
|
|
1835
|
+
{ start_at: (0, import_dayjs.default)(item.start), end_at: (0, import_dayjs.default)(item.end) }
|
|
1836
|
+
)) {
|
|
1834
1837
|
mSet.set(m.id, m.pax || 1);
|
|
1835
|
-
}
|
|
1838
|
+
}
|
|
1836
1839
|
});
|
|
1837
1840
|
acc += Array.from(mSet.values()).reduce((acc2, curr2) => acc2 + curr2, 0);
|
|
1838
1841
|
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
|
});
|