@pisell/pisellos 2.1.72 → 2.1.73
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.
|
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
326
326
|
count: number;
|
|
327
327
|
left: number;
|
|
328
328
|
summaryCount: number;
|
|
329
|
-
status:
|
|
329
|
+
status: "lots_of_space" | "filling_up_fast" | "sold_out";
|
|
330
330
|
}[];
|
|
331
331
|
/**
|
|
332
332
|
* 找到多个资源的公共可用时间段
|
|
@@ -391,9 +391,3 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
391
391
|
*/
|
|
392
392
|
getContactInfo(params: any): Promise<any>;
|
|
393
393
|
}
|
|
394
|
-
interface TimeStatusMap {
|
|
395
|
-
lots_of_space: true;
|
|
396
|
-
filling_up_fast: true;
|
|
397
|
-
sold_out: true;
|
|
398
|
-
}
|
|
399
|
-
export {};
|
|
@@ -2691,7 +2691,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2691
2691
|
value: function getTimeslotBySchedule(_ref11) {
|
|
2692
2692
|
var _this$store$currentPr2,
|
|
2693
2693
|
_targetProductData$pr,
|
|
2694
|
-
_targetProductData$pr2,
|
|
2695
2694
|
_this15 = this;
|
|
2696
2695
|
var date = _ref11.date,
|
|
2697
2696
|
scheduleIds = _ref11.scheduleIds,
|
|
@@ -2730,29 +2729,35 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2730
2729
|
if (!aIsCombined && bIsCombined) return -1;
|
|
2731
2730
|
return 0;
|
|
2732
2731
|
});
|
|
2733
|
-
|
|
2734
|
-
// 找到当前商品下第一个启用的资源id
|
|
2735
|
-
var firstEnabledResourceId = targetProductData === null || targetProductData === void 0 || (_targetProductData$pr = targetProductData.product_resource) === null || _targetProductData$pr === void 0 || (_targetProductData$pr = _targetProductData$pr.resources) === null || _targetProductData$pr === void 0 || (_targetProductData$pr = _targetProductData$pr.find(function (n) {
|
|
2732
|
+
var enabledResourceTypeConfigs = (targetProductData === null || targetProductData === void 0 || (_targetProductData$pr = targetProductData.product_resource) === null || _targetProductData$pr === void 0 || (_targetProductData$pr = _targetProductData$pr.resources) === null || _targetProductData$pr === void 0 ? void 0 : _targetProductData$pr.filter(function (n) {
|
|
2736
2733
|
return n.status === 1;
|
|
2737
|
-
}))
|
|
2738
|
-
var
|
|
2739
|
-
return n.
|
|
2740
|
-
});
|
|
2741
|
-
|
|
2734
|
+
})) || [];
|
|
2735
|
+
var resourceTypeConfigById = new Map(enabledResourceTypeConfigs.map(function (n) {
|
|
2736
|
+
return [n.id, n];
|
|
2737
|
+
}));
|
|
2738
|
+
|
|
2742
2739
|
// 计算每个日程切片下日程可用的资源的容量总和
|
|
2743
2740
|
var formatScheduleTimeSlots = scheduleTimeSlots.map(function (item) {
|
|
2744
2741
|
// 用来计算资源的可使用情况,针对单个schedule 时间片
|
|
2745
2742
|
var resourcesUseableMap = {};
|
|
2746
|
-
var
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2743
|
+
var statsByResourceType = {};
|
|
2744
|
+
enabledResourceTypeConfigs.forEach(function (cfg) {
|
|
2745
|
+
statsByResourceType[cfg.id] = {
|
|
2746
|
+
count: 0,
|
|
2747
|
+
left: 0,
|
|
2748
|
+
summaryCount: 0,
|
|
2749
|
+
summaryConfigCount: 0
|
|
2750
|
+
};
|
|
2751
|
+
});
|
|
2752
|
+
|
|
2750
2753
|
// 遍历所有资源
|
|
2751
2754
|
allProductResources === null || allProductResources === void 0 || allProductResources.forEach(function (m) {
|
|
2755
|
+
var currentResourceTypeConfig = resourceTypeConfigById.get(m.form_id);
|
|
2756
|
+
if (!currentResourceTypeConfig) return;
|
|
2757
|
+
|
|
2752
2758
|
// 遍历所有资源的上工时间片
|
|
2753
|
-
var
|
|
2754
|
-
var
|
|
2755
|
-
var currentResourcesTimeSlotCanUsedArr = [];
|
|
2759
|
+
var currentResourceMaxRemainingCapacity = 0;
|
|
2760
|
+
var isAllTimeSlicesUsable = true;
|
|
2756
2761
|
// m.times 需要做个过滤,假设 timeSlice.start_at 是 09:30 timeSlice.end_at 是 11:30
|
|
2757
2762
|
// time 是 time.start_at = 2025-05-26 10:30, time.end_at = 2025-05-26 12:30
|
|
2758
2763
|
// 需要判断 time 的开始结束时间 是否包含timeSlice的开始结束时间
|
|
@@ -2769,6 +2774,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2769
2774
|
if (mTimes.length === 0) {
|
|
2770
2775
|
return;
|
|
2771
2776
|
}
|
|
2777
|
+
|
|
2778
|
+
// 统计该资源类型在这个时间片的“配置容量”(无占用),只统计上工的资源
|
|
2779
|
+
if (!m.onlyComputed) {
|
|
2780
|
+
var _currentStats = statsByResourceType[m.form_id] || {
|
|
2781
|
+
count: 0,
|
|
2782
|
+
left: 0,
|
|
2783
|
+
summaryCount: 0,
|
|
2784
|
+
summaryConfigCount: 0
|
|
2785
|
+
};
|
|
2786
|
+
if (currentResourceTypeConfig.type === 'multiple') _currentStats.summaryConfigCount += m.capacity;else _currentStats.summaryConfigCount += 1;
|
|
2787
|
+
statsByResourceType[m.form_id] = _currentStats;
|
|
2788
|
+
}
|
|
2772
2789
|
mTimes.forEach(function (childTiem) {
|
|
2773
2790
|
// 挨个去匹配某个工作时间段结合当前日程时间,资源能不能用,有多少容量能用
|
|
2774
2791
|
var res = getIsUsableByTimeItem({
|
|
@@ -2787,40 +2804,41 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2787
2804
|
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
|
|
2788
2805
|
resourcesUseableMap[m.id] = res.usable;
|
|
2789
2806
|
}
|
|
2790
|
-
if (res.usable
|
|
2791
|
-
|
|
2807
|
+
if (!res.usable) isAllTimeSlicesUsable = false;
|
|
2808
|
+
if (res.usable && !m.onlyComputed) {
|
|
2809
|
+
if (res.remainingCapacity > currentResourceMaxRemainingCapacity) currentResourceMaxRemainingCapacity = res.remainingCapacity;
|
|
2792
2810
|
}
|
|
2793
|
-
if (res.usable && !m.onlyComputed && res.remainingCapacity >= currentResourcesSummaryCount) {
|
|
2794
|
-
currentResourcesSummaryCount = res.remainingCapacity;
|
|
2795
|
-
}
|
|
2796
|
-
currentResourcesTimeSlotCanUsedArr.push(res.usable);
|
|
2797
2811
|
});
|
|
2798
|
-
if (
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
}
|
|
2806
|
-
|
|
2807
|
-
if (
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
}
|
|
2815
|
-
if (!m.onlyComputed) {
|
|
2816
|
-
bookingLeft += 1;
|
|
2817
|
-
summaryCount += currentResourcesSummaryCount;
|
|
2818
|
-
}
|
|
2812
|
+
if (!isAllTimeSlicesUsable) return;
|
|
2813
|
+
if (m.onlyComputed) return;
|
|
2814
|
+
var currentStats = statsByResourceType[m.form_id] || {
|
|
2815
|
+
count: 0,
|
|
2816
|
+
left: 0,
|
|
2817
|
+
summaryCount: 0,
|
|
2818
|
+
summaryConfigCount: 0
|
|
2819
|
+
};
|
|
2820
|
+
currentStats.left += 1;
|
|
2821
|
+
if (currentResourceTypeConfig.type === 'multiple') {
|
|
2822
|
+
currentStats.summaryCount += currentResourceMaxRemainingCapacity;
|
|
2823
|
+
if (currentResourceMaxRemainingCapacity > currentStats.count) currentStats.count = currentResourceMaxRemainingCapacity;
|
|
2824
|
+
} else {
|
|
2825
|
+
// 单个预约:一个资源只计 1,不关心剩余容量
|
|
2826
|
+
currentStats.summaryCount += 1;
|
|
2827
|
+
if (currentStats.count < 1) currentStats.count = 1;
|
|
2819
2828
|
}
|
|
2829
|
+
statsByResourceType[m.form_id] = currentStats;
|
|
2820
2830
|
});
|
|
2821
2831
|
// 容量检测
|
|
2822
2832
|
var cartItems = _this15.store.cart.getItems();
|
|
2823
2833
|
productResources.forEach(function (n) {
|
|
2834
|
+
var currentResourceTypeConfig = resourceTypeConfigById.get(n.id);
|
|
2835
|
+
if (!currentResourceTypeConfig) return;
|
|
2836
|
+
var currentStats = statsByResourceType[n.id] || {
|
|
2837
|
+
count: 0,
|
|
2838
|
+
left: 0,
|
|
2839
|
+
summaryCount: 0
|
|
2840
|
+
};
|
|
2841
|
+
|
|
2824
2842
|
// 单个预约检测规则:
|
|
2825
2843
|
// 1、跟我一样的商品同一时间在购物车里不可以超过我最少的那种资源的关联的资源个数
|
|
2826
2844
|
// 2、跟我不一样的商品,只需要跟我当前商品有同一种类型的资源的同一时间的,她配置了几个资源的个数+我配置了几个资源的个数,然后购物车里有几个这样的商品,对应的资源做一个去重,不超过这个去重以后的总数
|
|
@@ -2831,10 +2849,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2831
2849
|
var _m$_productOrigin, _targetProductData$id;
|
|
2832
2850
|
return ((_m$_productOrigin = m._productOrigin) === null || _m$_productOrigin === void 0 || (_m$_productOrigin = _m$_productOrigin.id) === null || _m$_productOrigin === void 0 ? void 0 : _m$_productOrigin.toString()) === (targetProductData === null || targetProductData === void 0 || (_targetProductData$id = targetProductData.id) === null || _targetProductData$id === void 0 ? void 0 : _targetProductData$id.toString()) && "".concat(m.start_date, " ").concat(m.start_time) === item.start && "".concat(m.start_date, " ").concat(m.end_time) === item.end;
|
|
2833
2851
|
});
|
|
2834
|
-
if (sameCartItems.length > 0 && sameCartItems.length >= currentResourcesSet.size || sameCartItems.length >
|
|
2835
|
-
|
|
2836
|
-
count = 0;
|
|
2837
|
-
summaryCount = 0;
|
|
2852
|
+
if (sameCartItems.length > 0 && sameCartItems.length >= currentResourcesSet.size || sameCartItems.length > currentStats.left) {
|
|
2853
|
+
currentStats.left = 0;
|
|
2854
|
+
currentStats.count = 0;
|
|
2855
|
+
currentStats.summaryCount = 0;
|
|
2838
2856
|
}
|
|
2839
2857
|
// 规则 2
|
|
2840
2858
|
var otherCartItems = cartItems.filter(function (m) {
|
|
@@ -2871,9 +2889,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2871
2889
|
}
|
|
2872
2890
|
});
|
|
2873
2891
|
if (currentResourcesSet.size > 0 && otherCartItems.length + sameCartItems.length >= currentResourcesSet.size) {
|
|
2874
|
-
|
|
2875
|
-
count = 0;
|
|
2876
|
-
summaryCount = 0;
|
|
2892
|
+
currentStats.left = 0;
|
|
2893
|
+
currentStats.count = 0;
|
|
2894
|
+
currentStats.summaryCount = 0;
|
|
2877
2895
|
}
|
|
2878
2896
|
} else {
|
|
2879
2897
|
// 多个预约的检测规则:
|
|
@@ -2889,9 +2907,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2889
2907
|
return !curr.onlyComputed ? acc + curr.capacity || 0 : acc;
|
|
2890
2908
|
}, 0);
|
|
2891
2909
|
if (sameCartNeedCapacity >= currentProductResourcesCapacity) {
|
|
2892
|
-
|
|
2893
|
-
count = 0;
|
|
2894
|
-
summaryCount = 0;
|
|
2910
|
+
currentStats.left = 0;
|
|
2911
|
+
currentStats.count = 0;
|
|
2912
|
+
currentStats.summaryCount = 0;
|
|
2895
2913
|
}
|
|
2896
2914
|
// 规则2、不管是不是跟我一样的商品,只需要跟我当前商品有同一种类型的资源的同一时间的,把所有购物车的 capacity 之和 和 所有当前类型资源的 capacity 之和比较,如果超过了resourcesCapacity,则不可用
|
|
2897
2915
|
// const otherCartItems = cartItems.filter((m) => m._productOrigin?.id?.toString() !== targetProductData?.id?.toString() && m.start_time === item.start && m.end_time === item.end);
|
|
@@ -2953,45 +2971,61 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2953
2971
|
}, 0);
|
|
2954
2972
|
// 如果已使用容量超过了当前类型资源的容量,则不可用
|
|
2955
2973
|
if (otherCartNeedCapacity + usedCapacity >= currentTypeResourcesCapacity) {
|
|
2956
|
-
|
|
2957
|
-
count = 0;
|
|
2958
|
-
summaryCount = 0;
|
|
2974
|
+
currentStats.left = 0;
|
|
2975
|
+
currentStats.count = 0;
|
|
2976
|
+
currentStats.summaryCount = 0;
|
|
2959
2977
|
}
|
|
2960
2978
|
}
|
|
2979
|
+
statsByResourceType[n.id] = currentStats;
|
|
2961
2980
|
});
|
|
2962
2981
|
var startDayJs = dayjs(item.start);
|
|
2963
2982
|
var endDayJs = dayjs(item.end);
|
|
2964
2983
|
|
|
2965
|
-
//
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
if (
|
|
2977
|
-
|
|
2978
|
-
|
|
2984
|
+
// 选择“瓶颈资源类型”:multiple 取 summaryCount 最小,single 取 left 最小
|
|
2985
|
+
var bottleneckResourceTypeId;
|
|
2986
|
+
var bottleneckValue = Infinity;
|
|
2987
|
+
enabledResourceTypeConfigs.forEach(function (cfg) {
|
|
2988
|
+
var stats = statsByResourceType[cfg.id] || {
|
|
2989
|
+
count: 0,
|
|
2990
|
+
left: 0,
|
|
2991
|
+
summaryCount: 0,
|
|
2992
|
+
summaryConfigCount: 0
|
|
2993
|
+
};
|
|
2994
|
+
var value = cfg.type === 'multiple' ? stats.summaryCount : stats.left;
|
|
2995
|
+
if (value < bottleneckValue) {
|
|
2996
|
+
bottleneckValue = value;
|
|
2997
|
+
bottleneckResourceTypeId = cfg.id;
|
|
2979
2998
|
}
|
|
2999
|
+
});
|
|
3000
|
+
var bottleneckStats = bottleneckResourceTypeId !== undefined ? statsByResourceType[bottleneckResourceTypeId] || {
|
|
3001
|
+
count: 0,
|
|
3002
|
+
left: 0,
|
|
3003
|
+
summaryCount: 0,
|
|
3004
|
+
summaryConfigCount: 0
|
|
3005
|
+
} : {
|
|
3006
|
+
count: 0,
|
|
3007
|
+
left: 0,
|
|
3008
|
+
summaryCount: 0,
|
|
3009
|
+
summaryConfigCount: 0
|
|
3010
|
+
};
|
|
3011
|
+
var bottleneckConfig = bottleneckResourceTypeId !== undefined ? resourceTypeConfigById.get(bottleneckResourceTypeId) : undefined;
|
|
3012
|
+
var status = 'sold_out';
|
|
3013
|
+
if (bottleneckStats.left === 0) status = 'sold_out';else if (!bottleneckConfig || bottleneckStats.summaryConfigCount === 0) status = 'sold_out';else if (bottleneckConfig.type === 'multiple') {
|
|
3014
|
+
var usageRatio = bottleneckStats.summaryCount / bottleneckStats.summaryConfigCount;
|
|
3015
|
+
if (usageRatio > 0.5) status = 'lots_of_space';else if (bottleneckStats.summaryCount > 0) status = 'filling_up_fast';else status = 'sold_out';
|
|
2980
3016
|
} else {
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
if (_usageRatio > 0.5) timeStatus = 'lots_of_space';else if (count > 0) timeStatus = 'filling_up_fast';else timeStatus = 'sold_out';
|
|
2984
|
-
}
|
|
3017
|
+
var _usageRatio = bottleneckStats.left / bottleneckStats.summaryConfigCount;
|
|
3018
|
+
if (_usageRatio > 0.5) status = 'lots_of_space';else if (bottleneckStats.count > 0) status = 'filling_up_fast';else status = 'sold_out';
|
|
2985
3019
|
}
|
|
2986
3020
|
return {
|
|
2987
3021
|
start_time: startDayJs.format('HH:mm'),
|
|
2988
3022
|
end_time: endDayJs.format('HH:mm'),
|
|
2989
3023
|
start_at: startDayJs,
|
|
2990
3024
|
end_at: endDayJs,
|
|
2991
|
-
count: count,
|
|
2992
|
-
left:
|
|
2993
|
-
summaryCount: summaryCount,
|
|
2994
|
-
status:
|
|
3025
|
+
count: bottleneckStats.count,
|
|
3026
|
+
left: bottleneckStats.left,
|
|
3027
|
+
summaryCount: bottleneckStats.summaryCount,
|
|
3028
|
+
status: status
|
|
2995
3029
|
};
|
|
2996
3030
|
});
|
|
2997
3031
|
return formatScheduleTimeSlots;
|
|
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
326
326
|
count: number;
|
|
327
327
|
left: number;
|
|
328
328
|
summaryCount: number;
|
|
329
|
-
status:
|
|
329
|
+
status: "lots_of_space" | "filling_up_fast" | "sold_out";
|
|
330
330
|
}[];
|
|
331
331
|
/**
|
|
332
332
|
* 找到多个资源的公共可用时间段
|
|
@@ -391,9 +391,3 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
391
391
|
*/
|
|
392
392
|
getContactInfo(params: any): Promise<any>;
|
|
393
393
|
}
|
|
394
|
-
interface TimeStatusMap {
|
|
395
|
-
lots_of_space: true;
|
|
396
|
-
filling_up_fast: true;
|
|
397
|
-
sold_out: true;
|
|
398
|
-
}
|
|
399
|
-
export {};
|
|
@@ -1880,7 +1880,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1880
1880
|
resources,
|
|
1881
1881
|
product
|
|
1882
1882
|
}) {
|
|
1883
|
-
var _a, _b, _c, _d
|
|
1883
|
+
var _a, _b, _c, _d;
|
|
1884
1884
|
const targetProduct = this.store.currentProduct;
|
|
1885
1885
|
const targetProductData = product || targetProduct;
|
|
1886
1886
|
let targetSchedules = [];
|
|
@@ -1923,29 +1923,48 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1923
1923
|
return -1;
|
|
1924
1924
|
return 0;
|
|
1925
1925
|
});
|
|
1926
|
-
const
|
|
1926
|
+
const enabledResourceTypeConfigs = ((_d = (_c = targetProductData == null ? void 0 : targetProductData.product_resource) == null ? void 0 : _c.resources) == null ? void 0 : _d.filter(
|
|
1927
1927
|
(n) => n.status === 1
|
|
1928
|
-
))
|
|
1929
|
-
const
|
|
1930
|
-
(n) => n.
|
|
1928
|
+
)) || [];
|
|
1929
|
+
const resourceTypeConfigById = new Map(
|
|
1930
|
+
enabledResourceTypeConfigs.map((n) => [n.id, n])
|
|
1931
1931
|
);
|
|
1932
|
-
const isMultipleBooking = (firstEnabledResourceConfig == null ? void 0 : firstEnabledResourceConfig.type) === "multiple";
|
|
1933
1932
|
const formatScheduleTimeSlots = scheduleTimeSlots.map((item) => {
|
|
1934
1933
|
const resourcesUseableMap = {};
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1934
|
+
const statsByResourceType = {};
|
|
1935
|
+
enabledResourceTypeConfigs.forEach((cfg) => {
|
|
1936
|
+
statsByResourceType[cfg.id] = {
|
|
1937
|
+
count: 0,
|
|
1938
|
+
left: 0,
|
|
1939
|
+
summaryCount: 0,
|
|
1940
|
+
summaryConfigCount: 0
|
|
1941
|
+
};
|
|
1942
|
+
});
|
|
1939
1943
|
allProductResources == null ? void 0 : allProductResources.forEach((m) => {
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1944
|
+
const currentResourceTypeConfig = resourceTypeConfigById.get(m.form_id);
|
|
1945
|
+
if (!currentResourceTypeConfig)
|
|
1946
|
+
return;
|
|
1947
|
+
let currentResourceMaxRemainingCapacity = 0;
|
|
1948
|
+
let isAllTimeSlicesUsable = true;
|
|
1943
1949
|
const mTimes = m.times.filter((n) => {
|
|
1944
1950
|
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") || m.onlyComputed && (0, import_dayjs.default)(n.start_at).isBefore((0, import_dayjs.default)(item.end), "minute") && (0, import_dayjs.default)(n.end_at).isAfter((0, import_dayjs.default)(item.start), "minute");
|
|
1945
1951
|
});
|
|
1946
1952
|
if (mTimes.length === 0) {
|
|
1947
1953
|
return;
|
|
1948
1954
|
}
|
|
1955
|
+
if (!m.onlyComputed) {
|
|
1956
|
+
const currentStats2 = statsByResourceType[m.form_id] || {
|
|
1957
|
+
count: 0,
|
|
1958
|
+
left: 0,
|
|
1959
|
+
summaryCount: 0,
|
|
1960
|
+
summaryConfigCount: 0
|
|
1961
|
+
};
|
|
1962
|
+
if (currentResourceTypeConfig.type === "multiple")
|
|
1963
|
+
currentStats2.summaryConfigCount += m.capacity;
|
|
1964
|
+
else
|
|
1965
|
+
currentStats2.summaryConfigCount += 1;
|
|
1966
|
+
statsByResourceType[m.form_id] = currentStats2;
|
|
1967
|
+
}
|
|
1949
1968
|
mTimes.forEach((childTiem) => {
|
|
1950
1969
|
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
1951
1970
|
timeSlice: {
|
|
@@ -1963,52 +1982,61 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1963
1982
|
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== "capacityOnly") {
|
|
1964
1983
|
resourcesUseableMap[m.id] = res.usable;
|
|
1965
1984
|
}
|
|
1966
|
-
if (res.usable
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1985
|
+
if (!res.usable)
|
|
1986
|
+
isAllTimeSlicesUsable = false;
|
|
1987
|
+
if (res.usable && !m.onlyComputed) {
|
|
1988
|
+
if (res.remainingCapacity > currentResourceMaxRemainingCapacity)
|
|
1989
|
+
currentResourceMaxRemainingCapacity = res.remainingCapacity;
|
|
1971
1990
|
}
|
|
1972
|
-
currentResourcesTimeSlotCanUsedArr.push(res.usable);
|
|
1973
1991
|
});
|
|
1974
|
-
if (
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
+
if (!isAllTimeSlicesUsable)
|
|
1993
|
+
return;
|
|
1994
|
+
if (m.onlyComputed)
|
|
1995
|
+
return;
|
|
1996
|
+
const currentStats = statsByResourceType[m.form_id] || {
|
|
1997
|
+
count: 0,
|
|
1998
|
+
left: 0,
|
|
1999
|
+
summaryCount: 0,
|
|
2000
|
+
summaryConfigCount: 0
|
|
2001
|
+
};
|
|
2002
|
+
currentStats.left += 1;
|
|
2003
|
+
if (currentResourceTypeConfig.type === "multiple") {
|
|
2004
|
+
currentStats.summaryCount += currentResourceMaxRemainingCapacity;
|
|
2005
|
+
if (currentResourceMaxRemainingCapacity > currentStats.count)
|
|
2006
|
+
currentStats.count = currentResourceMaxRemainingCapacity;
|
|
2007
|
+
} else {
|
|
2008
|
+
currentStats.summaryCount += 1;
|
|
2009
|
+
if (currentStats.count < 1)
|
|
2010
|
+
currentStats.count = 1;
|
|
1992
2011
|
}
|
|
2012
|
+
statsByResourceType[m.form_id] = currentStats;
|
|
1993
2013
|
});
|
|
1994
2014
|
const cartItems2 = this.store.cart.getItems();
|
|
1995
2015
|
productResources.forEach((n) => {
|
|
2016
|
+
const currentResourceTypeConfig = resourceTypeConfigById.get(n.id);
|
|
2017
|
+
if (!currentResourceTypeConfig)
|
|
2018
|
+
return;
|
|
2019
|
+
const currentStats = statsByResourceType[n.id] || {
|
|
2020
|
+
count: 0,
|
|
2021
|
+
left: 0,
|
|
2022
|
+
summaryCount: 0
|
|
2023
|
+
};
|
|
1996
2024
|
if (n.type === "single") {
|
|
1997
2025
|
const currentResourcesSet = /* @__PURE__ */ new Set([...n.optional_resource, ...n.default_resource]);
|
|
1998
2026
|
const sameCartItems = cartItems2.filter((m) => {
|
|
1999
2027
|
var _a2, _b2, _c2;
|
|
2000
2028
|
return ((_b2 = (_a2 = m._productOrigin) == null ? void 0 : _a2.id) == null ? void 0 : _b2.toString()) === ((_c2 = targetProductData == null ? void 0 : targetProductData.id) == null ? void 0 : _c2.toString()) && `${m.start_date} ${m.start_time}` === item.start && `${m.start_date} ${m.end_time}` === item.end;
|
|
2001
2029
|
});
|
|
2002
|
-
if (sameCartItems.length > 0 && sameCartItems.length >= currentResourcesSet.size || sameCartItems.length >
|
|
2003
|
-
|
|
2004
|
-
count = 0;
|
|
2005
|
-
summaryCount = 0;
|
|
2030
|
+
if (sameCartItems.length > 0 && sameCartItems.length >= currentResourcesSet.size || sameCartItems.length > currentStats.left) {
|
|
2031
|
+
currentStats.left = 0;
|
|
2032
|
+
currentStats.count = 0;
|
|
2033
|
+
currentStats.summaryCount = 0;
|
|
2006
2034
|
}
|
|
2007
2035
|
let otherCartItems = cartItems2.filter(
|
|
2008
2036
|
(m) => {
|
|
2009
|
-
var _a2, _b2, _c2, _d2,
|
|
2037
|
+
var _a2, _b2, _c2, _d2, _e, _f;
|
|
2010
2038
|
const isTimeMatch = ((_b2 = (_a2 = m._productOrigin) == null ? void 0 : _a2.id) == null ? void 0 : _b2.toString()) !== ((_c2 = targetProductData == null ? void 0 : targetProductData.id) == null ? void 0 : _c2.toString()) && `${m.start_date} ${m.start_time}` === item.start && `${m.start_date} ${m.end_time}` === item.end;
|
|
2011
|
-
const isResourceMatch = (
|
|
2039
|
+
const isResourceMatch = (_f = (_e = (_d2 = m._productOrigin) == null ? void 0 : _d2.product_resource) == null ? void 0 : _e.resources) == null ? void 0 : _f.find((m2) => m2.type === n.type && m2.status === 1);
|
|
2012
2040
|
return isTimeMatch && isResourceMatch;
|
|
2013
2041
|
}
|
|
2014
2042
|
);
|
|
@@ -2030,9 +2058,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2030
2058
|
}
|
|
2031
2059
|
});
|
|
2032
2060
|
if (currentResourcesSet.size > 0 && otherCartItems.length + sameCartItems.length >= currentResourcesSet.size) {
|
|
2033
|
-
|
|
2034
|
-
count = 0;
|
|
2035
|
-
summaryCount = 0;
|
|
2061
|
+
currentStats.left = 0;
|
|
2062
|
+
currentStats.count = 0;
|
|
2063
|
+
currentStats.summaryCount = 0;
|
|
2036
2064
|
}
|
|
2037
2065
|
} else {
|
|
2038
2066
|
const sameCartItems = cartItems2.filter((m) => {
|
|
@@ -2042,9 +2070,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2042
2070
|
const sameCartNeedCapacity = sameCartItems.reduce((acc, curr) => acc + (0, import_capacity.getCapacityInfoByCartItem)(curr).currentCapacity, 0);
|
|
2043
2071
|
const currentProductResourcesCapacity = n.renderList.reduce((acc, curr) => !curr.onlyComputed ? acc + curr.capacity || 0 : acc, 0);
|
|
2044
2072
|
if (sameCartNeedCapacity >= currentProductResourcesCapacity) {
|
|
2045
|
-
|
|
2046
|
-
count = 0;
|
|
2047
|
-
summaryCount = 0;
|
|
2073
|
+
currentStats.left = 0;
|
|
2074
|
+
currentStats.count = 0;
|
|
2075
|
+
currentStats.summaryCount = 0;
|
|
2048
2076
|
}
|
|
2049
2077
|
const otherSameTimesCartItems = cartItems2.filter((m) => `${m.start_date} ${m.start_time}` === item.start && `${m.start_date} ${m.end_time}` === item.end);
|
|
2050
2078
|
const otherCartNeedCapacity = otherSameTimesCartItems.reduce((acc, curr) => acc + (0, import_capacity.getCapacityInfoByCartItem)(curr).currentCapacity, 0);
|
|
@@ -2087,51 +2115,68 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2087
2115
|
return acc;
|
|
2088
2116
|
}, 0);
|
|
2089
2117
|
if (otherCartNeedCapacity + usedCapacity >= currentTypeResourcesCapacity) {
|
|
2090
|
-
|
|
2091
|
-
count = 0;
|
|
2092
|
-
summaryCount = 0;
|
|
2118
|
+
currentStats.left = 0;
|
|
2119
|
+
currentStats.count = 0;
|
|
2120
|
+
currentStats.summaryCount = 0;
|
|
2093
2121
|
}
|
|
2094
2122
|
}
|
|
2123
|
+
statsByResourceType[n.id] = currentStats;
|
|
2095
2124
|
});
|
|
2096
2125
|
const startDayJs = (0, import_dayjs.default)(item.start);
|
|
2097
2126
|
const endDayJs = (0, import_dayjs.default)(item.end);
|
|
2098
|
-
let
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
timeStatus = "sold_out";
|
|
2127
|
+
let bottleneckResourceTypeId;
|
|
2128
|
+
let bottleneckValue = Infinity;
|
|
2129
|
+
enabledResourceTypeConfigs.forEach((cfg) => {
|
|
2130
|
+
const stats = statsByResourceType[cfg.id] || {
|
|
2131
|
+
count: 0,
|
|
2132
|
+
left: 0,
|
|
2133
|
+
summaryCount: 0,
|
|
2134
|
+
summaryConfigCount: 0
|
|
2135
|
+
};
|
|
2136
|
+
const value = cfg.type === "multiple" ? stats.summaryCount : stats.left;
|
|
2137
|
+
if (value < bottleneckValue) {
|
|
2138
|
+
bottleneckValue = value;
|
|
2139
|
+
bottleneckResourceTypeId = cfg.id;
|
|
2112
2140
|
}
|
|
2141
|
+
});
|
|
2142
|
+
const bottleneckStats = bottleneckResourceTypeId !== void 0 ? statsByResourceType[bottleneckResourceTypeId] || {
|
|
2143
|
+
count: 0,
|
|
2144
|
+
left: 0,
|
|
2145
|
+
summaryCount: 0,
|
|
2146
|
+
summaryConfigCount: 0
|
|
2147
|
+
} : { count: 0, left: 0, summaryCount: 0, summaryConfigCount: 0 };
|
|
2148
|
+
const bottleneckConfig = bottleneckResourceTypeId !== void 0 ? resourceTypeConfigById.get(bottleneckResourceTypeId) : void 0;
|
|
2149
|
+
let status = "sold_out";
|
|
2150
|
+
if (bottleneckStats.left === 0)
|
|
2151
|
+
status = "sold_out";
|
|
2152
|
+
else if (!bottleneckConfig || bottleneckStats.summaryConfigCount === 0)
|
|
2153
|
+
status = "sold_out";
|
|
2154
|
+
else if (bottleneckConfig.type === "multiple") {
|
|
2155
|
+
const usageRatio = bottleneckStats.summaryCount / bottleneckStats.summaryConfigCount;
|
|
2156
|
+
if (usageRatio > 0.5)
|
|
2157
|
+
status = "lots_of_space";
|
|
2158
|
+
else if (bottleneckStats.summaryCount > 0)
|
|
2159
|
+
status = "filling_up_fast";
|
|
2160
|
+
else
|
|
2161
|
+
status = "sold_out";
|
|
2113
2162
|
} else {
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
timeStatus = "filling_up_fast";
|
|
2122
|
-
else
|
|
2123
|
-
timeStatus = "sold_out";
|
|
2124
|
-
}
|
|
2163
|
+
const usageRatio = bottleneckStats.left / bottleneckStats.summaryConfigCount;
|
|
2164
|
+
if (usageRatio > 0.5)
|
|
2165
|
+
status = "lots_of_space";
|
|
2166
|
+
else if (bottleneckStats.count > 0)
|
|
2167
|
+
status = "filling_up_fast";
|
|
2168
|
+
else
|
|
2169
|
+
status = "sold_out";
|
|
2125
2170
|
}
|
|
2126
2171
|
return {
|
|
2127
2172
|
start_time: startDayJs.format("HH:mm"),
|
|
2128
2173
|
end_time: endDayJs.format("HH:mm"),
|
|
2129
2174
|
start_at: startDayJs,
|
|
2130
2175
|
end_at: endDayJs,
|
|
2131
|
-
count,
|
|
2132
|
-
left:
|
|
2133
|
-
summaryCount,
|
|
2134
|
-
status
|
|
2176
|
+
count: bottleneckStats.count,
|
|
2177
|
+
left: bottleneckStats.left,
|
|
2178
|
+
summaryCount: bottleneckStats.summaryCount,
|
|
2179
|
+
status
|
|
2135
2180
|
};
|
|
2136
2181
|
});
|
|
2137
2182
|
return formatScheduleTimeSlots;
|