@pisell/pisellos 2.1.72 → 2.1.74
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/Order/index.d.ts +1 -0
- package/dist/modules/Order/index.js +2 -1
- package/dist/modules/Order/types.d.ts +1 -0
- package/dist/solution/BookingByStep/index.d.ts +1 -7
- package/dist/solution/BookingByStep/index.js +114 -78
- package/dist/solution/BookingByStep/utils/capacity.js +17 -1
- package/lib/modules/Order/index.d.ts +1 -0
- package/lib/modules/Order/index.js +1 -0
- package/lib/modules/Order/types.d.ts +1 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -7
- package/lib/solution/BookingByStep/index.js +130 -83
- package/lib/solution/BookingByStep/utils/capacity.js +20 -1
- package/package.json +1 -1
|
@@ -33,6 +33,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
33
33
|
is_deposit: number;
|
|
34
34
|
relation_products: any[];
|
|
35
35
|
relation_forms: any[];
|
|
36
|
+
business_code: string | undefined;
|
|
36
37
|
};
|
|
37
38
|
checkBeforeSubmitOrder(params: {
|
|
38
39
|
cartItems: CartItem[];
|
|
@@ -133,7 +133,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
133
133
|
schedule_date: '',
|
|
134
134
|
is_deposit: 0,
|
|
135
135
|
relation_products: [],
|
|
136
|
-
relation_forms: []
|
|
136
|
+
relation_forms: [],
|
|
137
|
+
business_code: params === null || params === void 0 ? void 0 : params.business_code
|
|
137
138
|
}, (params === null || params === void 0 ? void 0 : params.extraData) || {});
|
|
138
139
|
var is_deposit = 0; // 是否存在定金,0 不存在,1 存在
|
|
139
140
|
if (params.cartItems.length > 0) {
|
|
@@ -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 {};
|
|
@@ -978,6 +978,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
978
978
|
key: "submitOrder",
|
|
979
979
|
value: function () {
|
|
980
980
|
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(extraData) {
|
|
981
|
+
var _this$otherParams4;
|
|
981
982
|
var cartItems, newCartItems, type;
|
|
982
983
|
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
983
984
|
while (1) switch (_context19.prev = _context19.next) {
|
|
@@ -1015,6 +1016,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1015
1016
|
cartItems: newCartItems,
|
|
1016
1017
|
type: type,
|
|
1017
1018
|
platform: this.platform,
|
|
1019
|
+
business_code: (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.business_code,
|
|
1018
1020
|
extraData: extraData
|
|
1019
1021
|
}
|
|
1020
1022
|
}));
|
|
@@ -2691,7 +2693,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2691
2693
|
value: function getTimeslotBySchedule(_ref11) {
|
|
2692
2694
|
var _this$store$currentPr2,
|
|
2693
2695
|
_targetProductData$pr,
|
|
2694
|
-
_targetProductData$pr2,
|
|
2695
2696
|
_this15 = this;
|
|
2696
2697
|
var date = _ref11.date,
|
|
2697
2698
|
scheduleIds = _ref11.scheduleIds,
|
|
@@ -2730,29 +2731,35 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2730
2731
|
if (!aIsCombined && bIsCombined) return -1;
|
|
2731
2732
|
return 0;
|
|
2732
2733
|
});
|
|
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) {
|
|
2734
|
+
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
2735
|
return n.status === 1;
|
|
2737
|
-
}))
|
|
2738
|
-
var
|
|
2739
|
-
return n.
|
|
2740
|
-
});
|
|
2741
|
-
|
|
2736
|
+
})) || [];
|
|
2737
|
+
var resourceTypeConfigById = new Map(enabledResourceTypeConfigs.map(function (n) {
|
|
2738
|
+
return [n.id, n];
|
|
2739
|
+
}));
|
|
2740
|
+
|
|
2742
2741
|
// 计算每个日程切片下日程可用的资源的容量总和
|
|
2743
2742
|
var formatScheduleTimeSlots = scheduleTimeSlots.map(function (item) {
|
|
2744
2743
|
// 用来计算资源的可使用情况,针对单个schedule 时间片
|
|
2745
2744
|
var resourcesUseableMap = {};
|
|
2746
|
-
var
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2745
|
+
var statsByResourceType = {};
|
|
2746
|
+
enabledResourceTypeConfigs.forEach(function (cfg) {
|
|
2747
|
+
statsByResourceType[cfg.id] = {
|
|
2748
|
+
count: 0,
|
|
2749
|
+
left: 0,
|
|
2750
|
+
summaryCount: 0,
|
|
2751
|
+
summaryConfigCount: 0
|
|
2752
|
+
};
|
|
2753
|
+
});
|
|
2754
|
+
|
|
2750
2755
|
// 遍历所有资源
|
|
2751
2756
|
allProductResources === null || allProductResources === void 0 || allProductResources.forEach(function (m) {
|
|
2757
|
+
var currentResourceTypeConfig = resourceTypeConfigById.get(m.form_id);
|
|
2758
|
+
if (!currentResourceTypeConfig) return;
|
|
2759
|
+
|
|
2752
2760
|
// 遍历所有资源的上工时间片
|
|
2753
|
-
var
|
|
2754
|
-
var
|
|
2755
|
-
var currentResourcesTimeSlotCanUsedArr = [];
|
|
2761
|
+
var currentResourceMaxRemainingCapacity = 0;
|
|
2762
|
+
var isAllTimeSlicesUsable = true;
|
|
2756
2763
|
// m.times 需要做个过滤,假设 timeSlice.start_at 是 09:30 timeSlice.end_at 是 11:30
|
|
2757
2764
|
// time 是 time.start_at = 2025-05-26 10:30, time.end_at = 2025-05-26 12:30
|
|
2758
2765
|
// 需要判断 time 的开始结束时间 是否包含timeSlice的开始结束时间
|
|
@@ -2769,6 +2776,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2769
2776
|
if (mTimes.length === 0) {
|
|
2770
2777
|
return;
|
|
2771
2778
|
}
|
|
2779
|
+
|
|
2780
|
+
// 统计该资源类型在这个时间片的“配置容量”(无占用),只统计上工的资源
|
|
2781
|
+
if (!m.onlyComputed) {
|
|
2782
|
+
var _currentStats = statsByResourceType[m.form_id] || {
|
|
2783
|
+
count: 0,
|
|
2784
|
+
left: 0,
|
|
2785
|
+
summaryCount: 0,
|
|
2786
|
+
summaryConfigCount: 0
|
|
2787
|
+
};
|
|
2788
|
+
if (currentResourceTypeConfig.type === 'multiple') _currentStats.summaryConfigCount += m.capacity;else _currentStats.summaryConfigCount += 1;
|
|
2789
|
+
statsByResourceType[m.form_id] = _currentStats;
|
|
2790
|
+
}
|
|
2772
2791
|
mTimes.forEach(function (childTiem) {
|
|
2773
2792
|
// 挨个去匹配某个工作时间段结合当前日程时间,资源能不能用,有多少容量能用
|
|
2774
2793
|
var res = getIsUsableByTimeItem({
|
|
@@ -2787,40 +2806,41 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2787
2806
|
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
|
|
2788
2807
|
resourcesUseableMap[m.id] = res.usable;
|
|
2789
2808
|
}
|
|
2790
|
-
if (res.usable
|
|
2791
|
-
|
|
2809
|
+
if (!res.usable) isAllTimeSlicesUsable = false;
|
|
2810
|
+
if (res.usable && !m.onlyComputed) {
|
|
2811
|
+
if (res.remainingCapacity > currentResourceMaxRemainingCapacity) currentResourceMaxRemainingCapacity = res.remainingCapacity;
|
|
2792
2812
|
}
|
|
2793
|
-
if (res.usable && !m.onlyComputed && res.remainingCapacity >= currentResourcesSummaryCount) {
|
|
2794
|
-
currentResourcesSummaryCount = res.remainingCapacity;
|
|
2795
|
-
}
|
|
2796
|
-
currentResourcesTimeSlotCanUsedArr.push(res.usable);
|
|
2797
2813
|
});
|
|
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
|
-
}
|
|
2814
|
+
if (!isAllTimeSlicesUsable) return;
|
|
2815
|
+
if (m.onlyComputed) return;
|
|
2816
|
+
var currentStats = statsByResourceType[m.form_id] || {
|
|
2817
|
+
count: 0,
|
|
2818
|
+
left: 0,
|
|
2819
|
+
summaryCount: 0,
|
|
2820
|
+
summaryConfigCount: 0
|
|
2821
|
+
};
|
|
2822
|
+
currentStats.left += 1;
|
|
2823
|
+
if (currentResourceTypeConfig.type === 'multiple') {
|
|
2824
|
+
currentStats.summaryCount += currentResourceMaxRemainingCapacity;
|
|
2825
|
+
if (currentResourceMaxRemainingCapacity > currentStats.count) currentStats.count = currentResourceMaxRemainingCapacity;
|
|
2826
|
+
} else {
|
|
2827
|
+
// 单个预约:一个资源只计 1,不关心剩余容量
|
|
2828
|
+
currentStats.summaryCount += 1;
|
|
2829
|
+
if (currentStats.count < 1) currentStats.count = 1;
|
|
2819
2830
|
}
|
|
2831
|
+
statsByResourceType[m.form_id] = currentStats;
|
|
2820
2832
|
});
|
|
2821
2833
|
// 容量检测
|
|
2822
2834
|
var cartItems = _this15.store.cart.getItems();
|
|
2823
2835
|
productResources.forEach(function (n) {
|
|
2836
|
+
var currentResourceTypeConfig = resourceTypeConfigById.get(n.id);
|
|
2837
|
+
if (!currentResourceTypeConfig) return;
|
|
2838
|
+
var currentStats = statsByResourceType[n.id] || {
|
|
2839
|
+
count: 0,
|
|
2840
|
+
left: 0,
|
|
2841
|
+
summaryCount: 0
|
|
2842
|
+
};
|
|
2843
|
+
|
|
2824
2844
|
// 单个预约检测规则:
|
|
2825
2845
|
// 1、跟我一样的商品同一时间在购物车里不可以超过我最少的那种资源的关联的资源个数
|
|
2826
2846
|
// 2、跟我不一样的商品,只需要跟我当前商品有同一种类型的资源的同一时间的,她配置了几个资源的个数+我配置了几个资源的个数,然后购物车里有几个这样的商品,对应的资源做一个去重,不超过这个去重以后的总数
|
|
@@ -2831,10 +2851,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2831
2851
|
var _m$_productOrigin, _targetProductData$id;
|
|
2832
2852
|
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
2853
|
});
|
|
2834
|
-
if (sameCartItems.length > 0 && sameCartItems.length >= currentResourcesSet.size || sameCartItems.length >
|
|
2835
|
-
|
|
2836
|
-
count = 0;
|
|
2837
|
-
summaryCount = 0;
|
|
2854
|
+
if (sameCartItems.length > 0 && sameCartItems.length >= currentResourcesSet.size || sameCartItems.length > currentStats.left) {
|
|
2855
|
+
currentStats.left = 0;
|
|
2856
|
+
currentStats.count = 0;
|
|
2857
|
+
currentStats.summaryCount = 0;
|
|
2838
2858
|
}
|
|
2839
2859
|
// 规则 2
|
|
2840
2860
|
var otherCartItems = cartItems.filter(function (m) {
|
|
@@ -2871,9 +2891,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2871
2891
|
}
|
|
2872
2892
|
});
|
|
2873
2893
|
if (currentResourcesSet.size > 0 && otherCartItems.length + sameCartItems.length >= currentResourcesSet.size) {
|
|
2874
|
-
|
|
2875
|
-
count = 0;
|
|
2876
|
-
summaryCount = 0;
|
|
2894
|
+
currentStats.left = 0;
|
|
2895
|
+
currentStats.count = 0;
|
|
2896
|
+
currentStats.summaryCount = 0;
|
|
2877
2897
|
}
|
|
2878
2898
|
} else {
|
|
2879
2899
|
// 多个预约的检测规则:
|
|
@@ -2889,9 +2909,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2889
2909
|
return !curr.onlyComputed ? acc + curr.capacity || 0 : acc;
|
|
2890
2910
|
}, 0);
|
|
2891
2911
|
if (sameCartNeedCapacity >= currentProductResourcesCapacity) {
|
|
2892
|
-
|
|
2893
|
-
count = 0;
|
|
2894
|
-
summaryCount = 0;
|
|
2912
|
+
currentStats.left = 0;
|
|
2913
|
+
currentStats.count = 0;
|
|
2914
|
+
currentStats.summaryCount = 0;
|
|
2895
2915
|
}
|
|
2896
2916
|
// 规则2、不管是不是跟我一样的商品,只需要跟我当前商品有同一种类型的资源的同一时间的,把所有购物车的 capacity 之和 和 所有当前类型资源的 capacity 之和比较,如果超过了resourcesCapacity,则不可用
|
|
2897
2917
|
// const otherCartItems = cartItems.filter((m) => m._productOrigin?.id?.toString() !== targetProductData?.id?.toString() && m.start_time === item.start && m.end_time === item.end);
|
|
@@ -2953,45 +2973,61 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2953
2973
|
}, 0);
|
|
2954
2974
|
// 如果已使用容量超过了当前类型资源的容量,则不可用
|
|
2955
2975
|
if (otherCartNeedCapacity + usedCapacity >= currentTypeResourcesCapacity) {
|
|
2956
|
-
|
|
2957
|
-
count = 0;
|
|
2958
|
-
summaryCount = 0;
|
|
2976
|
+
currentStats.left = 0;
|
|
2977
|
+
currentStats.count = 0;
|
|
2978
|
+
currentStats.summaryCount = 0;
|
|
2959
2979
|
}
|
|
2960
2980
|
}
|
|
2981
|
+
statsByResourceType[n.id] = currentStats;
|
|
2961
2982
|
});
|
|
2962
2983
|
var startDayJs = dayjs(item.start);
|
|
2963
2984
|
var endDayJs = dayjs(item.end);
|
|
2964
2985
|
|
|
2965
|
-
//
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
if (
|
|
2977
|
-
|
|
2978
|
-
|
|
2986
|
+
// 选择“瓶颈资源类型”:multiple 取 summaryCount 最小,single 取 left 最小
|
|
2987
|
+
var bottleneckResourceTypeId;
|
|
2988
|
+
var bottleneckValue = Infinity;
|
|
2989
|
+
enabledResourceTypeConfigs.forEach(function (cfg) {
|
|
2990
|
+
var stats = statsByResourceType[cfg.id] || {
|
|
2991
|
+
count: 0,
|
|
2992
|
+
left: 0,
|
|
2993
|
+
summaryCount: 0,
|
|
2994
|
+
summaryConfigCount: 0
|
|
2995
|
+
};
|
|
2996
|
+
var value = cfg.type === 'multiple' ? stats.summaryCount : stats.left;
|
|
2997
|
+
if (value < bottleneckValue) {
|
|
2998
|
+
bottleneckValue = value;
|
|
2999
|
+
bottleneckResourceTypeId = cfg.id;
|
|
2979
3000
|
}
|
|
3001
|
+
});
|
|
3002
|
+
var bottleneckStats = bottleneckResourceTypeId !== undefined ? statsByResourceType[bottleneckResourceTypeId] || {
|
|
3003
|
+
count: 0,
|
|
3004
|
+
left: 0,
|
|
3005
|
+
summaryCount: 0,
|
|
3006
|
+
summaryConfigCount: 0
|
|
3007
|
+
} : {
|
|
3008
|
+
count: 0,
|
|
3009
|
+
left: 0,
|
|
3010
|
+
summaryCount: 0,
|
|
3011
|
+
summaryConfigCount: 0
|
|
3012
|
+
};
|
|
3013
|
+
var bottleneckConfig = bottleneckResourceTypeId !== undefined ? resourceTypeConfigById.get(bottleneckResourceTypeId) : undefined;
|
|
3014
|
+
var status = 'sold_out';
|
|
3015
|
+
if (bottleneckStats.left === 0) status = 'sold_out';else if (!bottleneckConfig || bottleneckStats.summaryConfigCount === 0) status = 'sold_out';else if (bottleneckConfig.type === 'multiple') {
|
|
3016
|
+
var usageRatio = bottleneckStats.summaryCount / bottleneckStats.summaryConfigCount;
|
|
3017
|
+
if (usageRatio > 0.5) status = 'lots_of_space';else if (bottleneckStats.summaryCount > 0) status = 'filling_up_fast';else status = 'sold_out';
|
|
2980
3018
|
} 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
|
-
}
|
|
3019
|
+
var _usageRatio = bottleneckStats.left / bottleneckStats.summaryConfigCount;
|
|
3020
|
+
if (_usageRatio > 0.5) status = 'lots_of_space';else if (bottleneckStats.count > 0) status = 'filling_up_fast';else status = 'sold_out';
|
|
2985
3021
|
}
|
|
2986
3022
|
return {
|
|
2987
3023
|
start_time: startDayJs.format('HH:mm'),
|
|
2988
3024
|
end_time: endDayJs.format('HH:mm'),
|
|
2989
3025
|
start_at: startDayJs,
|
|
2990
3026
|
end_at: endDayJs,
|
|
2991
|
-
count: count,
|
|
2992
|
-
left:
|
|
2993
|
-
summaryCount: summaryCount,
|
|
2994
|
-
status:
|
|
3027
|
+
count: bottleneckStats.count,
|
|
3028
|
+
left: bottleneckStats.left,
|
|
3029
|
+
summaryCount: bottleneckStats.summaryCount,
|
|
3030
|
+
status: status
|
|
2995
3031
|
};
|
|
2996
3032
|
});
|
|
2997
3033
|
return formatScheduleTimeSlots;
|
|
@@ -23,11 +23,27 @@ export var formatDefaultCapacitys = function formatDefaultCapacitys(_ref) {
|
|
|
23
23
|
product_bundle = _ref.product_bundle;
|
|
24
24
|
if ((capacity === null || capacity === void 0 ? void 0 : capacity.type) === 'package') {
|
|
25
25
|
return (product_bundle || []).map(function (d) {
|
|
26
|
+
var _window;
|
|
26
27
|
var id = d.bundle_product_id;
|
|
27
28
|
var variantId = d.bundle_variant_id;
|
|
28
29
|
var item = ((capacity === null || capacity === void 0 ? void 0 : capacity.package) || []).find(function (item) {
|
|
29
|
-
return item.product_id
|
|
30
|
+
return item.product_id == id || item.product_id == variantId;
|
|
30
31
|
});
|
|
32
|
+
if (!item && (_window = window) !== null && _window !== void 0 && _window.sendWarningLog) {
|
|
33
|
+
window.sendWarningLog({
|
|
34
|
+
title: '未找到套餐 capacity 配置',
|
|
35
|
+
content: [{
|
|
36
|
+
key: 'product_id',
|
|
37
|
+
value: id
|
|
38
|
+
}, {
|
|
39
|
+
key: 'variant_id',
|
|
40
|
+
value: variantId
|
|
41
|
+
}, {
|
|
42
|
+
key: 'package',
|
|
43
|
+
value: JSON.stringify((capacity === null || capacity === void 0 ? void 0 : capacity.package) || [])
|
|
44
|
+
}]
|
|
45
|
+
});
|
|
46
|
+
}
|
|
31
47
|
return {
|
|
32
48
|
id: id,
|
|
33
49
|
value: item ? d.num || 0 : 0,
|
|
@@ -33,6 +33,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
33
33
|
is_deposit: number;
|
|
34
34
|
relation_products: any[];
|
|
35
35
|
relation_forms: any[];
|
|
36
|
+
business_code: string | undefined;
|
|
36
37
|
};
|
|
37
38
|
checkBeforeSubmitOrder(params: {
|
|
38
39
|
cartItems: CartItem[];
|
|
@@ -105,6 +105,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
105
105
|
is_deposit: 0,
|
|
106
106
|
relation_products: [],
|
|
107
107
|
relation_forms: [],
|
|
108
|
+
business_code: params == null ? void 0 : params.business_code,
|
|
108
109
|
...(params == null ? void 0 : params.extraData) || {}
|
|
109
110
|
};
|
|
110
111
|
let is_deposit = 0;
|
|
@@ -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 {};
|
|
@@ -512,10 +512,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
512
512
|
}
|
|
513
513
|
// 购物车提交订单
|
|
514
514
|
async submitOrder(extraData) {
|
|
515
|
+
var _a;
|
|
515
516
|
const cartItems = this.store.cart.getItems();
|
|
516
517
|
const newCartItems = (0, import_lodash_es.cloneDeep)(cartItems);
|
|
517
518
|
newCartItems.forEach((item) => {
|
|
518
|
-
var
|
|
519
|
+
var _a2;
|
|
519
520
|
if (item._origin.resources && item._origin.resources.length) {
|
|
520
521
|
item._origin.resources = item._origin.resources.map((n) => {
|
|
521
522
|
const newResourcesItem = (0, import_lodash_es.cloneDeep)(n);
|
|
@@ -525,7 +526,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
525
526
|
return { ...newResourcesItem };
|
|
526
527
|
});
|
|
527
528
|
const { currentCapacity, formatCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(item);
|
|
528
|
-
if (!((
|
|
529
|
+
if (!((_a2 = item._origin) == null ? void 0 : _a2.metadata)) {
|
|
529
530
|
item._origin.metadata = {};
|
|
530
531
|
}
|
|
531
532
|
item._origin.metadata.capacity = formatCapacity;
|
|
@@ -543,6 +544,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
543
544
|
cartItems: newCartItems,
|
|
544
545
|
type,
|
|
545
546
|
platform: this.platform,
|
|
547
|
+
business_code: (_a = this.otherParams) == null ? void 0 : _a.business_code,
|
|
546
548
|
extraData
|
|
547
549
|
}
|
|
548
550
|
});
|
|
@@ -1880,7 +1882,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1880
1882
|
resources,
|
|
1881
1883
|
product
|
|
1882
1884
|
}) {
|
|
1883
|
-
var _a, _b, _c, _d
|
|
1885
|
+
var _a, _b, _c, _d;
|
|
1884
1886
|
const targetProduct = this.store.currentProduct;
|
|
1885
1887
|
const targetProductData = product || targetProduct;
|
|
1886
1888
|
let targetSchedules = [];
|
|
@@ -1923,29 +1925,48 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1923
1925
|
return -1;
|
|
1924
1926
|
return 0;
|
|
1925
1927
|
});
|
|
1926
|
-
const
|
|
1928
|
+
const enabledResourceTypeConfigs = ((_d = (_c = targetProductData == null ? void 0 : targetProductData.product_resource) == null ? void 0 : _c.resources) == null ? void 0 : _d.filter(
|
|
1927
1929
|
(n) => n.status === 1
|
|
1928
|
-
))
|
|
1929
|
-
const
|
|
1930
|
-
(n) => n.
|
|
1930
|
+
)) || [];
|
|
1931
|
+
const resourceTypeConfigById = new Map(
|
|
1932
|
+
enabledResourceTypeConfigs.map((n) => [n.id, n])
|
|
1931
1933
|
);
|
|
1932
|
-
const isMultipleBooking = (firstEnabledResourceConfig == null ? void 0 : firstEnabledResourceConfig.type) === "multiple";
|
|
1933
1934
|
const formatScheduleTimeSlots = scheduleTimeSlots.map((item) => {
|
|
1934
1935
|
const resourcesUseableMap = {};
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1936
|
+
const statsByResourceType = {};
|
|
1937
|
+
enabledResourceTypeConfigs.forEach((cfg) => {
|
|
1938
|
+
statsByResourceType[cfg.id] = {
|
|
1939
|
+
count: 0,
|
|
1940
|
+
left: 0,
|
|
1941
|
+
summaryCount: 0,
|
|
1942
|
+
summaryConfigCount: 0
|
|
1943
|
+
};
|
|
1944
|
+
});
|
|
1939
1945
|
allProductResources == null ? void 0 : allProductResources.forEach((m) => {
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1946
|
+
const currentResourceTypeConfig = resourceTypeConfigById.get(m.form_id);
|
|
1947
|
+
if (!currentResourceTypeConfig)
|
|
1948
|
+
return;
|
|
1949
|
+
let currentResourceMaxRemainingCapacity = 0;
|
|
1950
|
+
let isAllTimeSlicesUsable = true;
|
|
1943
1951
|
const mTimes = m.times.filter((n) => {
|
|
1944
1952
|
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
1953
|
});
|
|
1946
1954
|
if (mTimes.length === 0) {
|
|
1947
1955
|
return;
|
|
1948
1956
|
}
|
|
1957
|
+
if (!m.onlyComputed) {
|
|
1958
|
+
const currentStats2 = statsByResourceType[m.form_id] || {
|
|
1959
|
+
count: 0,
|
|
1960
|
+
left: 0,
|
|
1961
|
+
summaryCount: 0,
|
|
1962
|
+
summaryConfigCount: 0
|
|
1963
|
+
};
|
|
1964
|
+
if (currentResourceTypeConfig.type === "multiple")
|
|
1965
|
+
currentStats2.summaryConfigCount += m.capacity;
|
|
1966
|
+
else
|
|
1967
|
+
currentStats2.summaryConfigCount += 1;
|
|
1968
|
+
statsByResourceType[m.form_id] = currentStats2;
|
|
1969
|
+
}
|
|
1949
1970
|
mTimes.forEach((childTiem) => {
|
|
1950
1971
|
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
1951
1972
|
timeSlice: {
|
|
@@ -1963,52 +1984,61 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1963
1984
|
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== "capacityOnly") {
|
|
1964
1985
|
resourcesUseableMap[m.id] = res.usable;
|
|
1965
1986
|
}
|
|
1966
|
-
if (res.usable
|
|
1967
|
-
|
|
1987
|
+
if (!res.usable)
|
|
1988
|
+
isAllTimeSlicesUsable = false;
|
|
1989
|
+
if (res.usable && !m.onlyComputed) {
|
|
1990
|
+
if (res.remainingCapacity > currentResourceMaxRemainingCapacity)
|
|
1991
|
+
currentResourceMaxRemainingCapacity = res.remainingCapacity;
|
|
1968
1992
|
}
|
|
1969
|
-
if (res.usable && !m.onlyComputed && res.remainingCapacity >= currentResourcesSummaryCount) {
|
|
1970
|
-
currentResourcesSummaryCount = res.remainingCapacity;
|
|
1971
|
-
}
|
|
1972
|
-
currentResourcesTimeSlotCanUsedArr.push(res.usable);
|
|
1973
1993
|
});
|
|
1974
|
-
if (
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1994
|
+
if (!isAllTimeSlicesUsable)
|
|
1995
|
+
return;
|
|
1996
|
+
if (m.onlyComputed)
|
|
1997
|
+
return;
|
|
1998
|
+
const currentStats = statsByResourceType[m.form_id] || {
|
|
1999
|
+
count: 0,
|
|
2000
|
+
left: 0,
|
|
2001
|
+
summaryCount: 0,
|
|
2002
|
+
summaryConfigCount: 0
|
|
2003
|
+
};
|
|
2004
|
+
currentStats.left += 1;
|
|
2005
|
+
if (currentResourceTypeConfig.type === "multiple") {
|
|
2006
|
+
currentStats.summaryCount += currentResourceMaxRemainingCapacity;
|
|
2007
|
+
if (currentResourceMaxRemainingCapacity > currentStats.count)
|
|
2008
|
+
currentStats.count = currentResourceMaxRemainingCapacity;
|
|
2009
|
+
} else {
|
|
2010
|
+
currentStats.summaryCount += 1;
|
|
2011
|
+
if (currentStats.count < 1)
|
|
2012
|
+
currentStats.count = 1;
|
|
1992
2013
|
}
|
|
2014
|
+
statsByResourceType[m.form_id] = currentStats;
|
|
1993
2015
|
});
|
|
1994
2016
|
const cartItems2 = this.store.cart.getItems();
|
|
1995
2017
|
productResources.forEach((n) => {
|
|
2018
|
+
const currentResourceTypeConfig = resourceTypeConfigById.get(n.id);
|
|
2019
|
+
if (!currentResourceTypeConfig)
|
|
2020
|
+
return;
|
|
2021
|
+
const currentStats = statsByResourceType[n.id] || {
|
|
2022
|
+
count: 0,
|
|
2023
|
+
left: 0,
|
|
2024
|
+
summaryCount: 0
|
|
2025
|
+
};
|
|
1996
2026
|
if (n.type === "single") {
|
|
1997
2027
|
const currentResourcesSet = /* @__PURE__ */ new Set([...n.optional_resource, ...n.default_resource]);
|
|
1998
2028
|
const sameCartItems = cartItems2.filter((m) => {
|
|
1999
2029
|
var _a2, _b2, _c2;
|
|
2000
2030
|
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
2031
|
});
|
|
2002
|
-
if (sameCartItems.length > 0 && sameCartItems.length >= currentResourcesSet.size || sameCartItems.length >
|
|
2003
|
-
|
|
2004
|
-
count = 0;
|
|
2005
|
-
summaryCount = 0;
|
|
2032
|
+
if (sameCartItems.length > 0 && sameCartItems.length >= currentResourcesSet.size || sameCartItems.length > currentStats.left) {
|
|
2033
|
+
currentStats.left = 0;
|
|
2034
|
+
currentStats.count = 0;
|
|
2035
|
+
currentStats.summaryCount = 0;
|
|
2006
2036
|
}
|
|
2007
2037
|
let otherCartItems = cartItems2.filter(
|
|
2008
2038
|
(m) => {
|
|
2009
|
-
var _a2, _b2, _c2, _d2,
|
|
2039
|
+
var _a2, _b2, _c2, _d2, _e, _f;
|
|
2010
2040
|
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 = (
|
|
2041
|
+
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
2042
|
return isTimeMatch && isResourceMatch;
|
|
2013
2043
|
}
|
|
2014
2044
|
);
|
|
@@ -2030,9 +2060,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2030
2060
|
}
|
|
2031
2061
|
});
|
|
2032
2062
|
if (currentResourcesSet.size > 0 && otherCartItems.length + sameCartItems.length >= currentResourcesSet.size) {
|
|
2033
|
-
|
|
2034
|
-
count = 0;
|
|
2035
|
-
summaryCount = 0;
|
|
2063
|
+
currentStats.left = 0;
|
|
2064
|
+
currentStats.count = 0;
|
|
2065
|
+
currentStats.summaryCount = 0;
|
|
2036
2066
|
}
|
|
2037
2067
|
} else {
|
|
2038
2068
|
const sameCartItems = cartItems2.filter((m) => {
|
|
@@ -2042,9 +2072,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2042
2072
|
const sameCartNeedCapacity = sameCartItems.reduce((acc, curr) => acc + (0, import_capacity.getCapacityInfoByCartItem)(curr).currentCapacity, 0);
|
|
2043
2073
|
const currentProductResourcesCapacity = n.renderList.reduce((acc, curr) => !curr.onlyComputed ? acc + curr.capacity || 0 : acc, 0);
|
|
2044
2074
|
if (sameCartNeedCapacity >= currentProductResourcesCapacity) {
|
|
2045
|
-
|
|
2046
|
-
count = 0;
|
|
2047
|
-
summaryCount = 0;
|
|
2075
|
+
currentStats.left = 0;
|
|
2076
|
+
currentStats.count = 0;
|
|
2077
|
+
currentStats.summaryCount = 0;
|
|
2048
2078
|
}
|
|
2049
2079
|
const otherSameTimesCartItems = cartItems2.filter((m) => `${m.start_date} ${m.start_time}` === item.start && `${m.start_date} ${m.end_time}` === item.end);
|
|
2050
2080
|
const otherCartNeedCapacity = otherSameTimesCartItems.reduce((acc, curr) => acc + (0, import_capacity.getCapacityInfoByCartItem)(curr).currentCapacity, 0);
|
|
@@ -2087,51 +2117,68 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2087
2117
|
return acc;
|
|
2088
2118
|
}, 0);
|
|
2089
2119
|
if (otherCartNeedCapacity + usedCapacity >= currentTypeResourcesCapacity) {
|
|
2090
|
-
|
|
2091
|
-
count = 0;
|
|
2092
|
-
summaryCount = 0;
|
|
2120
|
+
currentStats.left = 0;
|
|
2121
|
+
currentStats.count = 0;
|
|
2122
|
+
currentStats.summaryCount = 0;
|
|
2093
2123
|
}
|
|
2094
2124
|
}
|
|
2125
|
+
statsByResourceType[n.id] = currentStats;
|
|
2095
2126
|
});
|
|
2096
2127
|
const startDayJs = (0, import_dayjs.default)(item.start);
|
|
2097
2128
|
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";
|
|
2129
|
+
let bottleneckResourceTypeId;
|
|
2130
|
+
let bottleneckValue = Infinity;
|
|
2131
|
+
enabledResourceTypeConfigs.forEach((cfg) => {
|
|
2132
|
+
const stats = statsByResourceType[cfg.id] || {
|
|
2133
|
+
count: 0,
|
|
2134
|
+
left: 0,
|
|
2135
|
+
summaryCount: 0,
|
|
2136
|
+
summaryConfigCount: 0
|
|
2137
|
+
};
|
|
2138
|
+
const value = cfg.type === "multiple" ? stats.summaryCount : stats.left;
|
|
2139
|
+
if (value < bottleneckValue) {
|
|
2140
|
+
bottleneckValue = value;
|
|
2141
|
+
bottleneckResourceTypeId = cfg.id;
|
|
2112
2142
|
}
|
|
2143
|
+
});
|
|
2144
|
+
const bottleneckStats = bottleneckResourceTypeId !== void 0 ? statsByResourceType[bottleneckResourceTypeId] || {
|
|
2145
|
+
count: 0,
|
|
2146
|
+
left: 0,
|
|
2147
|
+
summaryCount: 0,
|
|
2148
|
+
summaryConfigCount: 0
|
|
2149
|
+
} : { count: 0, left: 0, summaryCount: 0, summaryConfigCount: 0 };
|
|
2150
|
+
const bottleneckConfig = bottleneckResourceTypeId !== void 0 ? resourceTypeConfigById.get(bottleneckResourceTypeId) : void 0;
|
|
2151
|
+
let status = "sold_out";
|
|
2152
|
+
if (bottleneckStats.left === 0)
|
|
2153
|
+
status = "sold_out";
|
|
2154
|
+
else if (!bottleneckConfig || bottleneckStats.summaryConfigCount === 0)
|
|
2155
|
+
status = "sold_out";
|
|
2156
|
+
else if (bottleneckConfig.type === "multiple") {
|
|
2157
|
+
const usageRatio = bottleneckStats.summaryCount / bottleneckStats.summaryConfigCount;
|
|
2158
|
+
if (usageRatio > 0.5)
|
|
2159
|
+
status = "lots_of_space";
|
|
2160
|
+
else if (bottleneckStats.summaryCount > 0)
|
|
2161
|
+
status = "filling_up_fast";
|
|
2162
|
+
else
|
|
2163
|
+
status = "sold_out";
|
|
2113
2164
|
} else {
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
timeStatus = "filling_up_fast";
|
|
2122
|
-
else
|
|
2123
|
-
timeStatus = "sold_out";
|
|
2124
|
-
}
|
|
2165
|
+
const usageRatio = bottleneckStats.left / bottleneckStats.summaryConfigCount;
|
|
2166
|
+
if (usageRatio > 0.5)
|
|
2167
|
+
status = "lots_of_space";
|
|
2168
|
+
else if (bottleneckStats.count > 0)
|
|
2169
|
+
status = "filling_up_fast";
|
|
2170
|
+
else
|
|
2171
|
+
status = "sold_out";
|
|
2125
2172
|
}
|
|
2126
2173
|
return {
|
|
2127
2174
|
start_time: startDayJs.format("HH:mm"),
|
|
2128
2175
|
end_time: endDayJs.format("HH:mm"),
|
|
2129
2176
|
start_at: startDayJs,
|
|
2130
2177
|
end_at: endDayJs,
|
|
2131
|
-
count,
|
|
2132
|
-
left:
|
|
2133
|
-
summaryCount,
|
|
2134
|
-
status
|
|
2178
|
+
count: bottleneckStats.count,
|
|
2179
|
+
left: bottleneckStats.left,
|
|
2180
|
+
summaryCount: bottleneckStats.summaryCount,
|
|
2181
|
+
status
|
|
2135
2182
|
};
|
|
2136
2183
|
});
|
|
2137
2184
|
return formatScheduleTimeSlots;
|
|
@@ -49,8 +49,27 @@ var formatDefaultCapacitys = ({
|
|
|
49
49
|
const id = d.bundle_product_id;
|
|
50
50
|
const variantId = d.bundle_variant_id;
|
|
51
51
|
const item = ((capacity == null ? void 0 : capacity.package) || []).find(
|
|
52
|
-
(item2) => item2.product_id
|
|
52
|
+
(item2) => item2.product_id == id || item2.product_id == variantId
|
|
53
53
|
);
|
|
54
|
+
if (!item && (window == null ? void 0 : window.sendWarningLog)) {
|
|
55
|
+
window.sendWarningLog({
|
|
56
|
+
title: "未找到套餐 capacity 配置",
|
|
57
|
+
content: [
|
|
58
|
+
{
|
|
59
|
+
key: "product_id",
|
|
60
|
+
value: id
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
key: "variant_id",
|
|
64
|
+
value: variantId
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
key: "package",
|
|
68
|
+
value: JSON.stringify((capacity == null ? void 0 : capacity.package) || [])
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
});
|
|
72
|
+
}
|
|
54
73
|
return {
|
|
55
74
|
id,
|
|
56
75
|
value: item ? d.num || 0 : 0,
|