@pisell/pisellos 2.1.19 → 2.1.20
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.
|
@@ -245,17 +245,28 @@ export function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, all
|
|
|
245
245
|
var _getCapacityInfoByCar2 = getCapacityInfoByCartItem(cartItem),
|
|
246
246
|
currentCapacity = _getCapacityInfoByCar2.currentCapacity;
|
|
247
247
|
Object.keys(resourceTypeMap).forEach(function (formId) {
|
|
248
|
+
var _cartItem$_productOri;
|
|
248
249
|
var resourcesInType = resourceTypeMap[formId];
|
|
249
250
|
var resourceIdsInType = resourcesInType.map(function (r) {
|
|
250
251
|
return r.id;
|
|
251
252
|
});
|
|
253
|
+
var selectType = (_cartItem$_productOri = cartItem._productOrigin) === null || _cartItem$_productOri === void 0 || (_cartItem$_productOri = _cartItem$_productOri.product_resource) === null || _cartItem$_productOri === void 0 || (_cartItem$_productOri = _cartItem$_productOri.resources) === null || _cartItem$_productOri === void 0 || (_cartItem$_productOri = _cartItem$_productOri.find(function (r) {
|
|
254
|
+
var _r$id;
|
|
255
|
+
return ((_r$id = r.id) === null || _r$id === void 0 ? void 0 : _r$id.toString()) === formId;
|
|
256
|
+
})) === null || _cartItem$_productOri === void 0 ? void 0 : _cartItem$_productOri.type;
|
|
252
257
|
|
|
253
258
|
// 检查该商品是否需要这种类型的资源
|
|
254
259
|
var needsThisResourceType = productResourceIds.some(function (id) {
|
|
255
260
|
return resourceIdsInType.includes(id);
|
|
256
261
|
});
|
|
257
262
|
if (needsThisResourceType) {
|
|
258
|
-
|
|
263
|
+
// 需要判断是单个预约还是多个预约,如果是单个预约,不用加 capacity,只用+1
|
|
264
|
+
if (selectType === 'single') {
|
|
265
|
+
requiredCapacityByType[formId] = (requiredCapacityByType[formId] || 0) + 1;
|
|
266
|
+
} else {
|
|
267
|
+
requiredCapacityByType[formId] = (requiredCapacityByType[formId] || 0) + currentCapacity;
|
|
268
|
+
}
|
|
269
|
+
// requiredCapacityByType[formId] = (requiredCapacityByType[formId] || 0) + currentCapacity;
|
|
259
270
|
}
|
|
260
271
|
});
|
|
261
272
|
});
|
|
@@ -275,12 +286,12 @@ export function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, all
|
|
|
275
286
|
_step2;
|
|
276
287
|
try {
|
|
277
288
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
278
|
-
var _cartItem$
|
|
289
|
+
var _cartItem$_productOri2;
|
|
279
290
|
var cartItem = _step2.value;
|
|
280
|
-
if ((_cartItem$
|
|
291
|
+
if ((_cartItem$_productOri2 = cartItem._productOrigin) !== null && _cartItem$_productOri2 !== void 0 && (_cartItem$_productOri2 = _cartItem$_productOri2.product_resource) !== null && _cartItem$_productOri2 !== void 0 && _cartItem$_productOri2.resources) {
|
|
281
292
|
resourceTypeConfig = cartItem._productOrigin.product_resource.resources.find(function (r) {
|
|
282
|
-
var _r$
|
|
283
|
-
return ((_r$
|
|
293
|
+
var _r$id2;
|
|
294
|
+
return ((_r$id2 = r.id) === null || _r$id2 === void 0 ? void 0 : _r$id2.toString()) === formId && r.status === 1;
|
|
284
295
|
});
|
|
285
296
|
if (resourceTypeConfig) break;
|
|
286
297
|
}
|
|
@@ -182,13 +182,22 @@ function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, allResourc
|
|
|
182
182
|
const productResourceIds = getResourcesIdsByProduct(cartItem._productOrigin);
|
|
183
183
|
const { currentCapacity } = getCapacityInfoByCartItem(cartItem);
|
|
184
184
|
Object.keys(resourceTypeMap).forEach((formId) => {
|
|
185
|
+
var _a2, _b2, _c, _d;
|
|
185
186
|
const resourcesInType = resourceTypeMap[formId];
|
|
186
187
|
const resourceIdsInType = resourcesInType.map((r) => r.id);
|
|
188
|
+
const selectType = (_d = (_c = (_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c.find((r) => {
|
|
189
|
+
var _a3;
|
|
190
|
+
return ((_a3 = r.id) == null ? void 0 : _a3.toString()) === formId;
|
|
191
|
+
})) == null ? void 0 : _d.type;
|
|
187
192
|
const needsThisResourceType = productResourceIds.some(
|
|
188
193
|
(id) => resourceIdsInType.includes(id)
|
|
189
194
|
);
|
|
190
195
|
if (needsThisResourceType) {
|
|
191
|
-
|
|
196
|
+
if (selectType === "single") {
|
|
197
|
+
requiredCapacityByType[formId] = (requiredCapacityByType[formId] || 0) + 1;
|
|
198
|
+
} else {
|
|
199
|
+
requiredCapacityByType[formId] = (requiredCapacityByType[formId] || 0) + currentCapacity;
|
|
200
|
+
}
|
|
192
201
|
}
|
|
193
202
|
});
|
|
194
203
|
});
|