@pisell/pisellos 2.1.29 → 2.1.31
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/Payment/index.js +56 -46
- package/dist/modules/ProductList/index.js +3 -2
- package/dist/solution/BookingByStep/index.d.ts +17 -1
- package/dist/solution/BookingByStep/index.js +466 -21
- package/dist/solution/BookingByStep/utils/capacity.d.ts +7 -2
- package/dist/solution/BookingByStep/utils/capacity.js +24 -8
- package/dist/solution/Checkout/index.d.ts +46 -1
- package/dist/solution/Checkout/index.js +823 -503
- package/lib/modules/Payment/index.js +28 -41
- package/lib/modules/ProductList/index.js +3 -2
- package/lib/solution/BookingByStep/index.d.ts +17 -1
- package/lib/solution/BookingByStep/index.js +311 -39
- package/lib/solution/BookingByStep/utils/capacity.d.ts +7 -2
- package/lib/solution/BookingByStep/utils/capacity.js +21 -8
- package/lib/solution/Checkout/index.d.ts +46 -1
- package/lib/solution/Checkout/index.js +263 -66
- package/package.json +1 -1
|
@@ -68,12 +68,12 @@ var formatDefaultCapacitys = ({
|
|
|
68
68
|
}
|
|
69
69
|
return [{ id: 0, value: 1, name: "" }];
|
|
70
70
|
};
|
|
71
|
-
var getSumCapacity = ({ capacity }) => {
|
|
71
|
+
var getSumCapacity = ({ capacity, num = 1 }) => {
|
|
72
72
|
let sum = 0;
|
|
73
73
|
for (let item of capacity || []) {
|
|
74
74
|
sum += item.value;
|
|
75
75
|
}
|
|
76
|
-
return sum;
|
|
76
|
+
return sum * num;
|
|
77
77
|
};
|
|
78
78
|
function getCapacityInfoByCartItem(targetCartItem) {
|
|
79
79
|
var _a;
|
|
@@ -81,7 +81,7 @@ function getCapacityInfoByCartItem(targetCartItem) {
|
|
|
81
81
|
capacity: (_a = targetCartItem._productOrigin) == null ? void 0 : _a.capacity,
|
|
82
82
|
product_bundle: targetCartItem._origin.product.product_bundle
|
|
83
83
|
});
|
|
84
|
-
const currentCapacity = getSumCapacity({ capacity: formatCapacity });
|
|
84
|
+
const currentCapacity = getSumCapacity({ capacity: formatCapacity, num: (targetCartItem == null ? void 0 : targetCartItem.num) || 1 });
|
|
85
85
|
return {
|
|
86
86
|
formatCapacity,
|
|
87
87
|
currentCapacity
|
|
@@ -194,7 +194,7 @@ function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, allResourc
|
|
|
194
194
|
);
|
|
195
195
|
if (needsThisResourceType) {
|
|
196
196
|
if (selectType === "single") {
|
|
197
|
-
requiredCapacityByType[formId] = (requiredCapacityByType[formId] || 0) + 1;
|
|
197
|
+
requiredCapacityByType[formId] = (requiredCapacityByType[formId] || 0) + ((cartItem == null ? void 0 : cartItem.num) || 1);
|
|
198
198
|
} else {
|
|
199
199
|
requiredCapacityByType[formId] = (requiredCapacityByType[formId] || 0) + currentCapacity;
|
|
200
200
|
}
|
|
@@ -238,13 +238,18 @@ function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, allResourc
|
|
|
238
238
|
console.log(`capacity.ts - 资源类型 ${formId} 多个预约检查: 总容量 ${totalAvailableCapacity}, 需求 ${requiredCapacity}`);
|
|
239
239
|
if (totalAvailableCapacity < requiredCapacity) {
|
|
240
240
|
console.log(`资源类型 ${formId} 容量不足: 需要 ${requiredCapacity}, 可用 ${totalAvailableCapacity}`);
|
|
241
|
-
return
|
|
241
|
+
return {
|
|
242
|
+
success: false,
|
|
243
|
+
required: requiredCapacity,
|
|
244
|
+
available: totalAvailableCapacity
|
|
245
|
+
};
|
|
242
246
|
}
|
|
243
247
|
} else {
|
|
244
248
|
let availableResourceCount = 0;
|
|
245
249
|
resourcesInType.forEach((resource) => {
|
|
246
250
|
const availableTimes = resource.times.filter((time) => {
|
|
247
|
-
|
|
251
|
+
var _a2;
|
|
252
|
+
return !(0, import_dayjs.default)(time.start_at).isAfter((0, import_dayjs.default)(timeSlotStart), "minute") && !(0, import_dayjs.default)(time.end_at).isBefore((0, import_dayjs.default)(timeSlotEnd), "minute") || (0, import_dayjs.default)(time.start_at).isBefore((0, import_dayjs.default)(timeSlotEnd), "minute") && (0, import_dayjs.default)(time.end_at).isAfter((0, import_dayjs.default)(timeSlotStart), "minute") && ((_a2 = time.event_list) == null ? void 0 : _a2.length) === 0;
|
|
248
253
|
});
|
|
249
254
|
if (availableTimes.length > 0) {
|
|
250
255
|
availableResourceCount++;
|
|
@@ -253,11 +258,19 @@ function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, allResourc
|
|
|
253
258
|
console.log(`capacity.ts - 资源类型 ${formId} 单个预约检查: 可用资源数 ${availableResourceCount}, 需求 ${requiredCapacity}`);
|
|
254
259
|
if (availableResourceCount < requiredCapacity) {
|
|
255
260
|
console.log(`资源类型 ${formId} 数量不足: 需要 ${requiredCapacity}, 可用 ${availableResourceCount}`);
|
|
256
|
-
return
|
|
261
|
+
return {
|
|
262
|
+
success: false,
|
|
263
|
+
required: requiredCapacity,
|
|
264
|
+
available: availableResourceCount
|
|
265
|
+
};
|
|
257
266
|
}
|
|
258
267
|
}
|
|
259
268
|
}
|
|
260
|
-
return
|
|
269
|
+
return {
|
|
270
|
+
success: true,
|
|
271
|
+
required: 0,
|
|
272
|
+
available: 0
|
|
273
|
+
};
|
|
261
274
|
}
|
|
262
275
|
// Annotate the CommonJS export names for ESM import in node:
|
|
263
276
|
0 && (module.exports = {
|
|
@@ -19,6 +19,7 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
|
|
|
19
19
|
private store;
|
|
20
20
|
private otherParams;
|
|
21
21
|
private logger;
|
|
22
|
+
private calculationCache;
|
|
22
23
|
order: OrderModule;
|
|
23
24
|
payment: PaymentModule;
|
|
24
25
|
constructor(name?: string, version?: string);
|
|
@@ -302,16 +303,46 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
|
|
|
302
303
|
* 删除本地 IndexDB 中超过指定天数且已同步到后端的订单数据
|
|
303
304
|
*/
|
|
304
305
|
private cleanupExpiredOrdersAsync;
|
|
306
|
+
/**
|
|
307
|
+
* 清除计算缓存
|
|
308
|
+
*/
|
|
309
|
+
private clearCalculationCache;
|
|
310
|
+
/**
|
|
311
|
+
* 批量获取订单数据(用于性能优化)
|
|
312
|
+
* 一次性获取所有需要的数据,避免重复查询
|
|
313
|
+
*/
|
|
314
|
+
private fetchOrderDataBatch;
|
|
315
|
+
/**
|
|
316
|
+
* 从支付项数组计算已支付金额(纯计算,不查询数据库)
|
|
317
|
+
*/
|
|
318
|
+
private calculatePaidAmountFromItems;
|
|
305
319
|
/**
|
|
306
320
|
* 计算已支付金额(从 Payment 模块获取最新数据)
|
|
321
|
+
*
|
|
322
|
+
* 注意:此方法保持独立性,可以单独调用。
|
|
323
|
+
* 在 updateStateAmountToRemaining 等批量操作中会使用缓存优化。
|
|
307
324
|
*/
|
|
308
325
|
private calculatePaidAmountAsync;
|
|
326
|
+
/**
|
|
327
|
+
* 从订单和支付项计算剩余金额(纯计算,不查询数据库)
|
|
328
|
+
*/
|
|
329
|
+
private calculateRemainingAmountFromData;
|
|
330
|
+
/**
|
|
331
|
+
* 从订单和支付项计算剩余总金额(纯计算,排除定金)
|
|
332
|
+
*/
|
|
333
|
+
private calculateRemainingTotalAmountFromData;
|
|
309
334
|
/**
|
|
310
335
|
* 计算剩余未支付金额(从 Payment 模块获取最新数据)
|
|
336
|
+
*
|
|
337
|
+
* 注意:此方法保持独立性,可以单独调用。
|
|
338
|
+
* 在 updateStateAmountToRemaining 等批量操作中会使用缓存优化。
|
|
311
339
|
*/
|
|
312
340
|
private calculateRemainingAmountAsync;
|
|
313
341
|
/**
|
|
314
342
|
* 计算剩余未支付金额(排除定金计算,始终使用订单总金额)
|
|
343
|
+
*
|
|
344
|
+
* 注意:此方法保持独立性,可以单独调用。
|
|
345
|
+
* 在 updateStateAmountToRemaining 等批量操作中会使用缓存优化。
|
|
315
346
|
*/
|
|
316
347
|
private calculateRemainingTotalAmountAsync;
|
|
317
348
|
/**
|
|
@@ -320,12 +351,24 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
|
|
|
320
351
|
private updateBalanceDueAmount;
|
|
321
352
|
/**
|
|
322
353
|
* 更新 stateAmount 为当前剩余未支付金额
|
|
354
|
+
*
|
|
355
|
+
* 优化版本:批量获取数据,避免重复查询数据库
|
|
323
356
|
*/
|
|
324
357
|
private updateStateAmountToRemaining;
|
|
358
|
+
/**
|
|
359
|
+
* 检查订单支付是否完成(优化版,复用已获取的数据)
|
|
360
|
+
*
|
|
361
|
+
* @param paymentItems 已获取的支付项数据
|
|
362
|
+
* @param remainingAmount 已计算的剩余金额
|
|
363
|
+
*/
|
|
364
|
+
private checkOrderPaymentCompletionOptimized;
|
|
325
365
|
/**
|
|
326
366
|
* 检查订单支付是否完成
|
|
327
367
|
*
|
|
328
368
|
* 当剩余待付款金额 <= 0 时,触发订单支付完成事件
|
|
369
|
+
*
|
|
370
|
+
* 注意:此方法保持独立性,可以单独调用。
|
|
371
|
+
* 在 updateStateAmountToRemaining 中会使用优化版本。
|
|
329
372
|
*/
|
|
330
373
|
private checkOrderPaymentCompletion;
|
|
331
374
|
/**
|
|
@@ -381,6 +424,8 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
|
|
|
381
424
|
* 重置 store 状态
|
|
382
425
|
*
|
|
383
426
|
* 在创建新订单前调用,确保状态完全干净
|
|
427
|
+
*
|
|
428
|
+
* 🚀 性能优化:改为同步方法,事件发射不阻塞主流程
|
|
384
429
|
*/
|
|
385
|
-
private
|
|
430
|
+
private resetStoreState;
|
|
386
431
|
}
|