@pisell/pisellos 0.0.56 → 0.0.57
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.
|
@@ -1783,8 +1783,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1783
1783
|
currentCount: 1
|
|
1784
1784
|
});
|
|
1785
1785
|
// 如果资源可用,且是独占资源,remainingCapacity 始终为 1
|
|
1786
|
-
if (res.usable) {
|
|
1787
|
-
count
|
|
1786
|
+
if (res.usable && res.remainingCapacity >= count) {
|
|
1787
|
+
count = res.remainingCapacity;
|
|
1788
1788
|
}
|
|
1789
1789
|
});
|
|
1790
1790
|
});
|
|
@@ -126,24 +126,24 @@ var checkCapacity = function checkCapacity(_ref) {
|
|
|
126
126
|
});
|
|
127
127
|
});
|
|
128
128
|
|
|
129
|
+
// 减去重叠的总量
|
|
130
|
+
var conflictCount = getUseableEventCount(conflict, resource.capacity);
|
|
131
|
+
|
|
129
132
|
// 同一时间段内只能进行一个预约,无论容量是否已满。
|
|
130
133
|
if (resource.resourceType === 'single') {
|
|
131
134
|
// 0代表着不重叠,则满足条件
|
|
132
135
|
if (conflict.length === 0) {
|
|
133
136
|
return {
|
|
134
137
|
status: true,
|
|
135
|
-
capacity:
|
|
138
|
+
capacity: conflictCount
|
|
136
139
|
};
|
|
137
140
|
} else {
|
|
138
141
|
return {
|
|
139
142
|
status: false,
|
|
140
|
-
capacity:
|
|
143
|
+
capacity: conflictCount
|
|
141
144
|
};
|
|
142
145
|
}
|
|
143
146
|
} else {
|
|
144
|
-
// 减去重叠的总量
|
|
145
|
-
var conflictCount = getUseableEventCount(conflict, resource.capacity);
|
|
146
|
-
|
|
147
147
|
// 当前预约量 <= 总剩余容量
|
|
148
148
|
if (currentCount <= conflictCount) {
|
|
149
149
|
return {
|
|
@@ -533,7 +533,6 @@ export var getOthersCartSelectedResources = function getOthersCartSelectedResour
|
|
|
533
533
|
if (d._id !== cartItemId) {
|
|
534
534
|
var _d$_origin2;
|
|
535
535
|
if ((_d$_origin2 = d._origin) !== null && _d$_origin2 !== void 0 && _d$_origin2.resources) {
|
|
536
|
-
debugger;
|
|
537
536
|
d._origin.resources.forEach(function (n) {
|
|
538
537
|
// 如果是组合资源,还需要检查组合资源里子资源是否被占用过
|
|
539
538
|
if (n.metadata.combined_resource && n.metadata.combined_resource.status === 1) {
|
|
@@ -643,13 +642,19 @@ export var getSumCapacity = function getSumCapacity(_ref7) {
|
|
|
643
642
|
*/
|
|
644
643
|
export var checkSubResourcesCapacity = function checkSubResourcesCapacity(resource) {
|
|
645
644
|
if (resource.children && resource.children.length) {
|
|
646
|
-
var countCapacity = resource.capacity;
|
|
647
|
-
resource.children.forEach(function (child) {
|
|
645
|
+
var countCapacity = resource.capacity; // 100
|
|
646
|
+
resource.children.forEach(function (child, index) {
|
|
647
|
+
if (index === resource.children.length - 1) {
|
|
648
|
+
// 如果是最后一个资源,直接拿剩余未分配完的容量去占用
|
|
649
|
+
// 哪怕这个东西会超过资源本身的 capacity也得让他占,PRD 里有写
|
|
650
|
+
child.capacity = countCapacity;
|
|
651
|
+
return;
|
|
652
|
+
}
|
|
648
653
|
if (child.capacity <= countCapacity) {
|
|
649
|
-
countCapacity -= child.capacity;
|
|
654
|
+
countCapacity -= child.capacity; // 100 - = 90
|
|
650
655
|
} else {
|
|
651
|
-
child.capacity = countCapacity;
|
|
652
|
-
countCapacity = 0;
|
|
656
|
+
child.capacity = countCapacity; // 10
|
|
657
|
+
countCapacity = 0; // 0
|
|
653
658
|
}
|
|
654
659
|
});
|
|
655
660
|
}
|
|
@@ -1145,8 +1145,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1145
1145
|
resource: m,
|
|
1146
1146
|
currentCount: 1
|
|
1147
1147
|
});
|
|
1148
|
-
if (res.usable) {
|
|
1149
|
-
count
|
|
1148
|
+
if (res.usable && res.remainingCapacity >= count) {
|
|
1149
|
+
count = res.remainingCapacity;
|
|
1150
1150
|
}
|
|
1151
1151
|
});
|
|
1152
1152
|
});
|
|
@@ -93,20 +93,20 @@ var checkCapacity = ({
|
|
|
93
93
|
{ start_at: timeSlice.start_at, end_at: timeSlice.end_at }
|
|
94
94
|
);
|
|
95
95
|
});
|
|
96
|
+
let conflictCount = getUseableEventCount(conflict, resource.capacity);
|
|
96
97
|
if (resource.resourceType === "single") {
|
|
97
98
|
if (conflict.length === 0) {
|
|
98
99
|
return {
|
|
99
100
|
status: true,
|
|
100
|
-
capacity:
|
|
101
|
+
capacity: conflictCount
|
|
101
102
|
};
|
|
102
103
|
} else {
|
|
103
104
|
return {
|
|
104
105
|
status: false,
|
|
105
|
-
capacity:
|
|
106
|
+
capacity: conflictCount
|
|
106
107
|
};
|
|
107
108
|
}
|
|
108
109
|
} else {
|
|
109
|
-
let conflictCount = getUseableEventCount(conflict, resource.capacity);
|
|
110
110
|
if (currentCount <= conflictCount) {
|
|
111
111
|
return {
|
|
112
112
|
status: true,
|
|
@@ -385,7 +385,6 @@ var getOthersCartSelectedResources = (cartItems, cartItemId, resourcesMap) => {
|
|
|
385
385
|
var _a;
|
|
386
386
|
if (d._id !== cartItemId) {
|
|
387
387
|
if ((_a = d._origin) == null ? void 0 : _a.resources) {
|
|
388
|
-
debugger;
|
|
389
388
|
d._origin.resources.forEach((n) => {
|
|
390
389
|
if (n.metadata.combined_resource && n.metadata.combined_resource.status === 1) {
|
|
391
390
|
if (n.metadata.combined_resource.resource_ids.some(
|
|
@@ -453,7 +452,11 @@ var getSumCapacity = ({ capacity }) => {
|
|
|
453
452
|
var checkSubResourcesCapacity = (resource) => {
|
|
454
453
|
if (resource.children && resource.children.length) {
|
|
455
454
|
let countCapacity = resource.capacity;
|
|
456
|
-
resource.children.forEach((child) => {
|
|
455
|
+
resource.children.forEach((child, index) => {
|
|
456
|
+
if (index === resource.children.length - 1) {
|
|
457
|
+
child.capacity = countCapacity;
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
457
460
|
if (child.capacity <= countCapacity) {
|
|
458
461
|
countCapacity -= child.capacity;
|
|
459
462
|
} else {
|