@pisell/pisellos 0.0.312 → 0.0.313
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.
|
@@ -3291,6 +3291,16 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3291
3291
|
return sum.plus(amt).plus(rounding);
|
|
3292
3292
|
}, new Decimal(0)).toFixed(2);
|
|
3293
3293
|
}
|
|
3294
|
+
// 如果当前是定金支付,并且定金额度已经大于等于了订单总计,则 finalDepositAmount 为实际付出去的定金金额
|
|
3295
|
+
if (this.store.currentOrder.is_deposit === 1 && new Decimal(finalDepositAmount).gte(new Decimal(this.store.currentOrder.total_amount))) {
|
|
3296
|
+
finalDepositAmount = processedPaymentItems.filter(function (item) {
|
|
3297
|
+
return item.status !== 'voided' && item.order_payment_type === 'deposit';
|
|
3298
|
+
}).reduce(function (sum, item) {
|
|
3299
|
+
var amt = new Decimal(item.amount || '0');
|
|
3300
|
+
var rounding = new Decimal(item.rounding_amount || '0').abs();
|
|
3301
|
+
return sum.plus(amt).plus(rounding);
|
|
3302
|
+
}, new Decimal(0)).toFixed(2);
|
|
3303
|
+
}
|
|
3294
3304
|
this.logInfo('定金金额确定结果', {
|
|
3295
3305
|
depositPaymentItemsCount: processedPaymentItems.length,
|
|
3296
3306
|
depositPaymentItems: processedPaymentItems.map(function (item) {
|
|
@@ -3358,7 +3368,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3358
3368
|
|
|
3359
3369
|
// 发送下单接口请求开始事件
|
|
3360
3370
|
startTime = Date.now();
|
|
3361
|
-
_context36.next =
|
|
3371
|
+
_context36.next = 27;
|
|
3362
3372
|
return this.core.effects.emit(CheckoutHooks.OnOrderSubmitStart, {
|
|
3363
3373
|
orderUuid: this.store.currentOrder.uuid,
|
|
3364
3374
|
operation: isUpdateOperation ? 'update' : 'create',
|
|
@@ -3366,9 +3376,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3366
3376
|
paymentItemCount: paymentItems.length,
|
|
3367
3377
|
timestamp: startTime
|
|
3368
3378
|
});
|
|
3369
|
-
case
|
|
3379
|
+
case 27:
|
|
3370
3380
|
submitSuccess = false;
|
|
3371
|
-
_context36.prev =
|
|
3381
|
+
_context36.prev = 28;
|
|
3372
3382
|
// 记录接口调用参数
|
|
3373
3383
|
this.logInfo('Calling backend checkout API', _objectSpread({
|
|
3374
3384
|
url: '/order/checkout',
|
|
@@ -3376,23 +3386,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3376
3386
|
}, orderParams));
|
|
3377
3387
|
|
|
3378
3388
|
// 调用 Order 模块的专用 createOrderByCheckout 方法
|
|
3379
|
-
_context36.next =
|
|
3389
|
+
_context36.next = 32;
|
|
3380
3390
|
return this.order.createOrderByCheckout(orderParams);
|
|
3381
|
-
case
|
|
3391
|
+
case 32:
|
|
3382
3392
|
checkoutResponse = _context36.sent;
|
|
3383
3393
|
submitSuccess = true;
|
|
3384
3394
|
this.logInfo('下单接口调用成功', checkoutResponse);
|
|
3385
|
-
_context36.next =
|
|
3395
|
+
_context36.next = 45;
|
|
3386
3396
|
break;
|
|
3387
|
-
case
|
|
3388
|
-
_context36.prev =
|
|
3389
|
-
_context36.t1 = _context36["catch"](
|
|
3397
|
+
case 37:
|
|
3398
|
+
_context36.prev = 37;
|
|
3399
|
+
_context36.t1 = _context36["catch"](28);
|
|
3390
3400
|
submitSuccess = false;
|
|
3391
3401
|
submitError = _context36.t1 instanceof Error ? _context36.t1.message : String(_context36.t1);
|
|
3392
3402
|
this.logError('下单接口调用失败:', submitError);
|
|
3393
3403
|
|
|
3394
3404
|
// 发送订单同步失败事件(网络错误或请求失败)
|
|
3395
|
-
_context36.next =
|
|
3405
|
+
_context36.next = 44;
|
|
3396
3406
|
return this.core.effects.emit(CheckoutHooks.OnOrderSyncFailed, {
|
|
3397
3407
|
orderUuid: this.store.currentOrder.uuid,
|
|
3398
3408
|
operation: isUpdateOperation ? 'update' : 'create',
|
|
@@ -3402,11 +3412,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3402
3412
|
duration: Date.now() - startTime,
|
|
3403
3413
|
timestamp: Date.now()
|
|
3404
3414
|
});
|
|
3405
|
-
case 43:
|
|
3406
|
-
throw _context36.t1;
|
|
3407
3415
|
case 44:
|
|
3408
|
-
_context36.
|
|
3409
|
-
|
|
3416
|
+
throw _context36.t1;
|
|
3417
|
+
case 45:
|
|
3418
|
+
_context36.prev = 45;
|
|
3419
|
+
_context36.next = 48;
|
|
3410
3420
|
return this.core.effects.emit(CheckoutHooks.OnOrderSubmitEnd, {
|
|
3411
3421
|
success: submitSuccess,
|
|
3412
3422
|
orderUuid: this.store.currentOrder.uuid,
|
|
@@ -3417,18 +3427,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3417
3427
|
duration: Date.now() - startTime,
|
|
3418
3428
|
timestamp: Date.now()
|
|
3419
3429
|
});
|
|
3420
|
-
case 47:
|
|
3421
|
-
return _context36.finish(44);
|
|
3422
3430
|
case 48:
|
|
3431
|
+
return _context36.finish(45);
|
|
3432
|
+
case 49:
|
|
3423
3433
|
// 检查响应状态是否为成功状态
|
|
3424
3434
|
responseStatus = (_checkoutResponse3 = checkoutResponse) === null || _checkoutResponse3 === void 0 ? void 0 : _checkoutResponse3.status;
|
|
3425
3435
|
isSuccessResponse = responseStatus === true || responseStatus === 200 || responseStatus === 'success' || responseStatus === 1 && ((_checkoutResponse4 = checkoutResponse) === null || _checkoutResponse4 === void 0 ? void 0 : _checkoutResponse4.code) === 200;
|
|
3426
3436
|
if (isSuccessResponse) {
|
|
3427
|
-
_context36.next =
|
|
3437
|
+
_context36.next = 56;
|
|
3428
3438
|
break;
|
|
3429
3439
|
}
|
|
3430
3440
|
errorMessage = ((_checkoutResponse5 = checkoutResponse) === null || _checkoutResponse5 === void 0 ? void 0 : _checkoutResponse5.message) || '订单同步失败,后端返回非成功状态'; // 发送订单同步失败事件
|
|
3431
|
-
_context36.next =
|
|
3441
|
+
_context36.next = 55;
|
|
3432
3442
|
return this.core.effects.emit(CheckoutHooks.OnOrderSyncFailed, {
|
|
3433
3443
|
orderUuid: this.store.currentOrder.uuid,
|
|
3434
3444
|
operation: isUpdateOperation ? 'update' : 'create',
|
|
@@ -3439,18 +3449,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3439
3449
|
duration: Date.now() - startTime,
|
|
3440
3450
|
timestamp: Date.now()
|
|
3441
3451
|
});
|
|
3442
|
-
case 54:
|
|
3443
|
-
throw new Error(errorMessage);
|
|
3444
3452
|
case 55:
|
|
3453
|
+
throw new Error(errorMessage);
|
|
3454
|
+
case 56:
|
|
3445
3455
|
if (!isUpdateOperation) {
|
|
3446
|
-
_context36.next =
|
|
3456
|
+
_context36.next = 60;
|
|
3447
3457
|
break;
|
|
3448
3458
|
}
|
|
3449
3459
|
// 更新操作:使用现有的订单ID
|
|
3450
3460
|
realOrderId = currentOrderId;
|
|
3451
|
-
_context36.next =
|
|
3461
|
+
_context36.next = 79;
|
|
3452
3462
|
break;
|
|
3453
|
-
case
|
|
3463
|
+
case 60:
|
|
3454
3464
|
// 创建操作:从响应中提取新的订单ID
|
|
3455
3465
|
extractedOrderId = (_checkoutResponse6 = checkoutResponse) === null || _checkoutResponse6 === void 0 || (_checkoutResponse6 = _checkoutResponse6.data) === null || _checkoutResponse6 === void 0 ? void 0 : _checkoutResponse6.order_id; // 如果data.order_id不存在,尝试直接从根级获取
|
|
3456
3466
|
if (!extractedOrderId) {
|
|
@@ -3472,10 +3482,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3472
3482
|
oldOrderId: this.store.currentOrder.order_id,
|
|
3473
3483
|
newOrderId: realOrderId
|
|
3474
3484
|
});
|
|
3475
|
-
_context36.prev =
|
|
3476
|
-
_context36.next =
|
|
3485
|
+
_context36.prev = 66;
|
|
3486
|
+
_context36.next = 69;
|
|
3477
3487
|
return this.payment.replaceOrderIdByUuidAsync(this.store.currentOrder.uuid, realOrderId);
|
|
3478
|
-
case
|
|
3488
|
+
case 69:
|
|
3479
3489
|
updatedOrder = _context36.sent;
|
|
3480
3490
|
this.logInfo('Payment模块替换订单ID结果:', {
|
|
3481
3491
|
wasSuccessful: !!updatedOrder,
|
|
@@ -3502,66 +3512,66 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3502
3512
|
目标ID: realOrderId
|
|
3503
3513
|
});
|
|
3504
3514
|
}
|
|
3505
|
-
_context36.next =
|
|
3515
|
+
_context36.next = 79;
|
|
3506
3516
|
break;
|
|
3507
|
-
case
|
|
3508
|
-
_context36.prev =
|
|
3509
|
-
_context36.t2 = _context36["catch"](
|
|
3517
|
+
case 74:
|
|
3518
|
+
_context36.prev = 74;
|
|
3519
|
+
_context36.t2 = _context36["catch"](66);
|
|
3510
3520
|
this.logError('调用Payment模块替换订单ID时发生错误:', _context36.t2);
|
|
3511
3521
|
|
|
3512
3522
|
// 发生错误时也进行手动替换
|
|
3513
3523
|
this.store.currentOrder.order_id = realOrderId;
|
|
3514
3524
|
this.logInfo('错误恢复:手动设置订单ID:', realOrderId);
|
|
3515
|
-
case
|
|
3516
|
-
_context36.prev =
|
|
3525
|
+
case 79:
|
|
3526
|
+
_context36.prev = 79;
|
|
3517
3527
|
syncedPaymentUuids = processedPaymentItems.filter(function (item) {
|
|
3518
3528
|
return item.status !== 'voided';
|
|
3519
3529
|
}).map(function (item) {
|
|
3520
3530
|
return item.uuid;
|
|
3521
3531
|
}).filter(Boolean);
|
|
3522
3532
|
_iterator3 = _createForOfIteratorHelper(syncedPaymentUuids);
|
|
3523
|
-
_context36.prev =
|
|
3533
|
+
_context36.prev = 82;
|
|
3524
3534
|
_iterator3.s();
|
|
3525
|
-
case
|
|
3535
|
+
case 84:
|
|
3526
3536
|
if ((_step3 = _iterator3.n()).done) {
|
|
3527
|
-
_context36.next =
|
|
3537
|
+
_context36.next = 90;
|
|
3528
3538
|
break;
|
|
3529
3539
|
}
|
|
3530
3540
|
paymentUuid = _step3.value;
|
|
3531
|
-
_context36.next =
|
|
3541
|
+
_context36.next = 88;
|
|
3532
3542
|
return this.payment.updatePaymentAsync(this.store.currentOrder.uuid, paymentUuid, {
|
|
3533
3543
|
isSynced: true,
|
|
3534
3544
|
syncError: undefined
|
|
3535
3545
|
});
|
|
3536
|
-
case
|
|
3537
|
-
_context36.next =
|
|
3546
|
+
case 88:
|
|
3547
|
+
_context36.next = 84;
|
|
3538
3548
|
break;
|
|
3539
|
-
case
|
|
3540
|
-
_context36.next =
|
|
3549
|
+
case 90:
|
|
3550
|
+
_context36.next = 95;
|
|
3541
3551
|
break;
|
|
3542
|
-
case
|
|
3543
|
-
_context36.prev =
|
|
3544
|
-
_context36.t3 = _context36["catch"](
|
|
3552
|
+
case 92:
|
|
3553
|
+
_context36.prev = 92;
|
|
3554
|
+
_context36.t3 = _context36["catch"](82);
|
|
3545
3555
|
_iterator3.e(_context36.t3);
|
|
3546
|
-
case
|
|
3547
|
-
_context36.prev =
|
|
3556
|
+
case 95:
|
|
3557
|
+
_context36.prev = 95;
|
|
3548
3558
|
_iterator3.f();
|
|
3549
|
-
return _context36.finish(
|
|
3550
|
-
case
|
|
3551
|
-
_context36.next =
|
|
3559
|
+
return _context36.finish(95);
|
|
3560
|
+
case 98:
|
|
3561
|
+
_context36.next = 103;
|
|
3552
3562
|
break;
|
|
3553
|
-
case
|
|
3554
|
-
_context36.prev =
|
|
3555
|
-
_context36.t4 = _context36["catch"](
|
|
3563
|
+
case 100:
|
|
3564
|
+
_context36.prev = 100;
|
|
3565
|
+
_context36.t4 = _context36["catch"](79);
|
|
3556
3566
|
this.logWarning('标记支付项已同步失败(不阻塞主流程)', {
|
|
3557
3567
|
error: _context36.t4
|
|
3558
3568
|
});
|
|
3559
|
-
case
|
|
3569
|
+
case 103:
|
|
3560
3570
|
// 标记订单已同步
|
|
3561
3571
|
this.store.isOrderSynced = true;
|
|
3562
3572
|
|
|
3563
3573
|
// 触发订单同步完成事件
|
|
3564
|
-
_context36.next =
|
|
3574
|
+
_context36.next = 106;
|
|
3565
3575
|
return this.core.effects.emit(CheckoutHooks.OnOrderSynced, {
|
|
3566
3576
|
orderUuid: this.store.currentOrder.uuid,
|
|
3567
3577
|
realOrderId: realOrderId,
|
|
@@ -3570,18 +3580,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3570
3580
|
isManual: isManual,
|
|
3571
3581
|
response: checkoutResponse
|
|
3572
3582
|
});
|
|
3573
|
-
case
|
|
3583
|
+
case 106:
|
|
3574
3584
|
return _context36.abrupt("return", {
|
|
3575
3585
|
success: true,
|
|
3576
3586
|
orderId: realOrderId,
|
|
3577
3587
|
orderUuid: this.store.currentOrder.uuid,
|
|
3578
3588
|
response: checkoutResponse
|
|
3579
3589
|
});
|
|
3580
|
-
case
|
|
3590
|
+
case 107:
|
|
3581
3591
|
case "end":
|
|
3582
3592
|
return _context36.stop();
|
|
3583
3593
|
}
|
|
3584
|
-
}, _callee36, this, [[
|
|
3594
|
+
}, _callee36, this, [[28, 37, 45, 49], [66, 74], [79, 100], [82, 92, 95, 98]]);
|
|
3585
3595
|
}));
|
|
3586
3596
|
function syncOrderToBackendWithReturn() {
|
|
3587
3597
|
return _syncOrderToBackendWithReturn.apply(this, arguments);
|
|
@@ -2039,6 +2039,13 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2039
2039
|
return sum.plus(amt).plus(rounding);
|
|
2040
2040
|
}, new import_decimal.default(0)).toFixed(2);
|
|
2041
2041
|
}
|
|
2042
|
+
if (this.store.currentOrder.is_deposit === 1 && new import_decimal.default(finalDepositAmount).gte(new import_decimal.default(this.store.currentOrder.total_amount))) {
|
|
2043
|
+
finalDepositAmount = processedPaymentItems.filter((item) => item.status !== "voided" && item.order_payment_type === "deposit").reduce((sum, item) => {
|
|
2044
|
+
const amt = new import_decimal.default(item.amount || "0");
|
|
2045
|
+
const rounding = new import_decimal.default(item.rounding_amount || "0").abs();
|
|
2046
|
+
return sum.plus(amt).plus(rounding);
|
|
2047
|
+
}, new import_decimal.default(0)).toFixed(2);
|
|
2048
|
+
}
|
|
2042
2049
|
this.logInfo("定金金额确定结果", {
|
|
2043
2050
|
depositPaymentItemsCount: processedPaymentItems.length,
|
|
2044
2051
|
depositPaymentItems: processedPaymentItems.map((item) => ({
|