@pisell/pisellos 0.0.309 → 0.0.311
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.
|
@@ -128,7 +128,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
128
128
|
case 0:
|
|
129
129
|
startTime = Date.now();
|
|
130
130
|
walletParams = this.generateWalletParams(businessData);
|
|
131
|
-
if (!(Number((businessData === null || businessData === void 0 || (_businessData$amountI = businessData.amountInfo) === null || _businessData$amountI === void 0 ? void 0 : _businessData$amountI.totalAmount) || 0) < 0 || Number((businessData === null || businessData === void 0 || (_businessData$amountI2 = businessData.amountInfo) === null || _businessData$amountI2 === void 0 ? void 0 : _businessData$amountI2.subTotal) || 0) < 0
|
|
131
|
+
if (!(Number((businessData === null || businessData === void 0 || (_businessData$amountI = businessData.amountInfo) === null || _businessData$amountI === void 0 ? void 0 : _businessData$amountI.totalAmount) || 0) < 0 || Number((businessData === null || businessData === void 0 || (_businessData$amountI2 = businessData.amountInfo) === null || _businessData$amountI2 === void 0 ? void 0 : _businessData$amountI2.subTotal) || 0) < 0)) {
|
|
132
132
|
_context.next = 4;
|
|
133
133
|
break;
|
|
134
134
|
}
|
|
@@ -826,12 +826,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
826
826
|
case 45:
|
|
827
827
|
created = _context10.sent;
|
|
828
828
|
this.store.currentOrder = created;
|
|
829
|
-
_context10.next = 49;
|
|
830
|
-
return this.updateStateAmountToRemaining();
|
|
831
|
-
case 49:
|
|
832
829
|
this.initWalletData();
|
|
833
830
|
return _context10.abrupt("return", created);
|
|
834
|
-
case
|
|
831
|
+
case 49:
|
|
835
832
|
case "end":
|
|
836
833
|
return _context10.stop();
|
|
837
834
|
}
|
|
@@ -3271,6 +3268,25 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3271
3268
|
reason: '手动设置和计算值均为0'
|
|
3272
3269
|
});
|
|
3273
3270
|
}
|
|
3271
|
+
// 如果此时是普通支付状态,并且要同步的支付项里一个定金支付的都没有,则 is_deposit 和 deposit_amount 都置为 0
|
|
3272
|
+
if (this.store.currentOrder.is_deposit === 0 && processedPaymentItems.every(function (item) {
|
|
3273
|
+
return item.order_payment_type !== 'deposit';
|
|
3274
|
+
})) {
|
|
3275
|
+
finalDepositAmount = '0.00';
|
|
3276
|
+
this.store.currentOrder.is_deposit = 0;
|
|
3277
|
+
}
|
|
3278
|
+
// 如果此时是普通支付,并且有普通支付项进来了,则提交给后端的 deposit_amount 只能是支付项里已经支付的order_payment_type = deposit 的金额
|
|
3279
|
+
if (this.store.currentOrder.is_deposit === 0 && processedPaymentItems.some(function (item) {
|
|
3280
|
+
return item.order_payment_type === 'deposit';
|
|
3281
|
+
})) {
|
|
3282
|
+
finalDepositAmount = processedPaymentItems.filter(function (item) {
|
|
3283
|
+
return item.status !== 'voided' && item.order_payment_type === 'deposit';
|
|
3284
|
+
}).reduce(function (sum, item) {
|
|
3285
|
+
var amt = new Decimal(item.amount || '0');
|
|
3286
|
+
var rounding = new Decimal(item.rounding_amount || '0').abs();
|
|
3287
|
+
return sum.plus(amt).plus(rounding);
|
|
3288
|
+
}, new Decimal(0)).toFixed(2);
|
|
3289
|
+
}
|
|
3274
3290
|
this.logInfo('定金金额确定结果', {
|
|
3275
3291
|
depositPaymentItemsCount: processedPaymentItems.length,
|
|
3276
3292
|
depositPaymentItems: processedPaymentItems.map(function (item) {
|
|
@@ -3338,7 +3354,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3338
3354
|
|
|
3339
3355
|
// 发送下单接口请求开始事件
|
|
3340
3356
|
startTime = Date.now();
|
|
3341
|
-
_context36.next =
|
|
3357
|
+
_context36.next = 26;
|
|
3342
3358
|
return this.core.effects.emit(CheckoutHooks.OnOrderSubmitStart, {
|
|
3343
3359
|
orderUuid: this.store.currentOrder.uuid,
|
|
3344
3360
|
operation: isUpdateOperation ? 'update' : 'create',
|
|
@@ -3346,9 +3362,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3346
3362
|
paymentItemCount: paymentItems.length,
|
|
3347
3363
|
timestamp: startTime
|
|
3348
3364
|
});
|
|
3349
|
-
case
|
|
3365
|
+
case 26:
|
|
3350
3366
|
submitSuccess = false;
|
|
3351
|
-
_context36.prev =
|
|
3367
|
+
_context36.prev = 27;
|
|
3352
3368
|
// 记录接口调用参数
|
|
3353
3369
|
this.logInfo('Calling backend checkout API', _objectSpread({
|
|
3354
3370
|
url: '/order/checkout',
|
|
@@ -3356,23 +3372,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3356
3372
|
}, orderParams));
|
|
3357
3373
|
|
|
3358
3374
|
// 调用 Order 模块的专用 createOrderByCheckout 方法
|
|
3359
|
-
_context36.next =
|
|
3375
|
+
_context36.next = 31;
|
|
3360
3376
|
return this.order.createOrderByCheckout(orderParams);
|
|
3361
|
-
case
|
|
3377
|
+
case 31:
|
|
3362
3378
|
checkoutResponse = _context36.sent;
|
|
3363
3379
|
submitSuccess = true;
|
|
3364
3380
|
this.logInfo('下单接口调用成功', checkoutResponse);
|
|
3365
|
-
_context36.next =
|
|
3381
|
+
_context36.next = 44;
|
|
3366
3382
|
break;
|
|
3367
|
-
case
|
|
3368
|
-
_context36.prev =
|
|
3369
|
-
_context36.t1 = _context36["catch"](
|
|
3383
|
+
case 36:
|
|
3384
|
+
_context36.prev = 36;
|
|
3385
|
+
_context36.t1 = _context36["catch"](27);
|
|
3370
3386
|
submitSuccess = false;
|
|
3371
3387
|
submitError = _context36.t1 instanceof Error ? _context36.t1.message : String(_context36.t1);
|
|
3372
3388
|
this.logError('下单接口调用失败:', submitError);
|
|
3373
3389
|
|
|
3374
3390
|
// 发送订单同步失败事件(网络错误或请求失败)
|
|
3375
|
-
_context36.next =
|
|
3391
|
+
_context36.next = 43;
|
|
3376
3392
|
return this.core.effects.emit(CheckoutHooks.OnOrderSyncFailed, {
|
|
3377
3393
|
orderUuid: this.store.currentOrder.uuid,
|
|
3378
3394
|
operation: isUpdateOperation ? 'update' : 'create',
|
|
@@ -3382,11 +3398,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3382
3398
|
duration: Date.now() - startTime,
|
|
3383
3399
|
timestamp: Date.now()
|
|
3384
3400
|
});
|
|
3385
|
-
case
|
|
3401
|
+
case 43:
|
|
3386
3402
|
throw _context36.t1;
|
|
3387
|
-
case
|
|
3388
|
-
_context36.prev =
|
|
3389
|
-
_context36.next =
|
|
3403
|
+
case 44:
|
|
3404
|
+
_context36.prev = 44;
|
|
3405
|
+
_context36.next = 47;
|
|
3390
3406
|
return this.core.effects.emit(CheckoutHooks.OnOrderSubmitEnd, {
|
|
3391
3407
|
success: submitSuccess,
|
|
3392
3408
|
orderUuid: this.store.currentOrder.uuid,
|
|
@@ -3397,18 +3413,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3397
3413
|
duration: Date.now() - startTime,
|
|
3398
3414
|
timestamp: Date.now()
|
|
3399
3415
|
});
|
|
3400
|
-
case
|
|
3401
|
-
return _context36.finish(
|
|
3402
|
-
case
|
|
3416
|
+
case 47:
|
|
3417
|
+
return _context36.finish(44);
|
|
3418
|
+
case 48:
|
|
3403
3419
|
// 检查响应状态是否为成功状态
|
|
3404
3420
|
responseStatus = (_checkoutResponse3 = checkoutResponse) === null || _checkoutResponse3 === void 0 ? void 0 : _checkoutResponse3.status;
|
|
3405
3421
|
isSuccessResponse = responseStatus === true || responseStatus === 200 || responseStatus === 'success' || responseStatus === 1 && ((_checkoutResponse4 = checkoutResponse) === null || _checkoutResponse4 === void 0 ? void 0 : _checkoutResponse4.code) === 200;
|
|
3406
3422
|
if (isSuccessResponse) {
|
|
3407
|
-
_context36.next =
|
|
3423
|
+
_context36.next = 55;
|
|
3408
3424
|
break;
|
|
3409
3425
|
}
|
|
3410
3426
|
errorMessage = ((_checkoutResponse5 = checkoutResponse) === null || _checkoutResponse5 === void 0 ? void 0 : _checkoutResponse5.message) || '订单同步失败,后端返回非成功状态'; // 发送订单同步失败事件
|
|
3411
|
-
_context36.next =
|
|
3427
|
+
_context36.next = 54;
|
|
3412
3428
|
return this.core.effects.emit(CheckoutHooks.OnOrderSyncFailed, {
|
|
3413
3429
|
orderUuid: this.store.currentOrder.uuid,
|
|
3414
3430
|
operation: isUpdateOperation ? 'update' : 'create',
|
|
@@ -3419,18 +3435,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3419
3435
|
duration: Date.now() - startTime,
|
|
3420
3436
|
timestamp: Date.now()
|
|
3421
3437
|
});
|
|
3422
|
-
case
|
|
3438
|
+
case 54:
|
|
3423
3439
|
throw new Error(errorMessage);
|
|
3424
|
-
case
|
|
3440
|
+
case 55:
|
|
3425
3441
|
if (!isUpdateOperation) {
|
|
3426
|
-
_context36.next =
|
|
3442
|
+
_context36.next = 59;
|
|
3427
3443
|
break;
|
|
3428
3444
|
}
|
|
3429
3445
|
// 更新操作:使用现有的订单ID
|
|
3430
3446
|
realOrderId = currentOrderId;
|
|
3431
|
-
_context36.next =
|
|
3447
|
+
_context36.next = 78;
|
|
3432
3448
|
break;
|
|
3433
|
-
case
|
|
3449
|
+
case 59:
|
|
3434
3450
|
// 创建操作:从响应中提取新的订单ID
|
|
3435
3451
|
extractedOrderId = (_checkoutResponse6 = checkoutResponse) === null || _checkoutResponse6 === void 0 || (_checkoutResponse6 = _checkoutResponse6.data) === null || _checkoutResponse6 === void 0 ? void 0 : _checkoutResponse6.order_id; // 如果data.order_id不存在,尝试直接从根级获取
|
|
3436
3452
|
if (!extractedOrderId) {
|
|
@@ -3452,10 +3468,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3452
3468
|
oldOrderId: this.store.currentOrder.order_id,
|
|
3453
3469
|
newOrderId: realOrderId
|
|
3454
3470
|
});
|
|
3455
|
-
_context36.prev =
|
|
3456
|
-
_context36.next =
|
|
3471
|
+
_context36.prev = 65;
|
|
3472
|
+
_context36.next = 68;
|
|
3457
3473
|
return this.payment.replaceOrderIdByUuidAsync(this.store.currentOrder.uuid, realOrderId);
|
|
3458
|
-
case
|
|
3474
|
+
case 68:
|
|
3459
3475
|
updatedOrder = _context36.sent;
|
|
3460
3476
|
this.logInfo('Payment模块替换订单ID结果:', {
|
|
3461
3477
|
wasSuccessful: !!updatedOrder,
|
|
@@ -3482,66 +3498,66 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3482
3498
|
目标ID: realOrderId
|
|
3483
3499
|
});
|
|
3484
3500
|
}
|
|
3485
|
-
_context36.next =
|
|
3501
|
+
_context36.next = 78;
|
|
3486
3502
|
break;
|
|
3487
|
-
case
|
|
3488
|
-
_context36.prev =
|
|
3489
|
-
_context36.t2 = _context36["catch"](
|
|
3503
|
+
case 73:
|
|
3504
|
+
_context36.prev = 73;
|
|
3505
|
+
_context36.t2 = _context36["catch"](65);
|
|
3490
3506
|
this.logError('调用Payment模块替换订单ID时发生错误:', _context36.t2);
|
|
3491
3507
|
|
|
3492
3508
|
// 发生错误时也进行手动替换
|
|
3493
3509
|
this.store.currentOrder.order_id = realOrderId;
|
|
3494
3510
|
this.logInfo('错误恢复:手动设置订单ID:', realOrderId);
|
|
3495
|
-
case
|
|
3496
|
-
_context36.prev =
|
|
3511
|
+
case 78:
|
|
3512
|
+
_context36.prev = 78;
|
|
3497
3513
|
syncedPaymentUuids = processedPaymentItems.filter(function (item) {
|
|
3498
3514
|
return item.status !== 'voided';
|
|
3499
3515
|
}).map(function (item) {
|
|
3500
3516
|
return item.uuid;
|
|
3501
3517
|
}).filter(Boolean);
|
|
3502
3518
|
_iterator3 = _createForOfIteratorHelper(syncedPaymentUuids);
|
|
3503
|
-
_context36.prev =
|
|
3519
|
+
_context36.prev = 81;
|
|
3504
3520
|
_iterator3.s();
|
|
3505
|
-
case
|
|
3521
|
+
case 83:
|
|
3506
3522
|
if ((_step3 = _iterator3.n()).done) {
|
|
3507
|
-
_context36.next =
|
|
3523
|
+
_context36.next = 89;
|
|
3508
3524
|
break;
|
|
3509
3525
|
}
|
|
3510
3526
|
paymentUuid = _step3.value;
|
|
3511
|
-
_context36.next =
|
|
3527
|
+
_context36.next = 87;
|
|
3512
3528
|
return this.payment.updatePaymentAsync(this.store.currentOrder.uuid, paymentUuid, {
|
|
3513
3529
|
isSynced: true,
|
|
3514
3530
|
syncError: undefined
|
|
3515
3531
|
});
|
|
3516
|
-
case 85:
|
|
3517
|
-
_context36.next = 81;
|
|
3518
|
-
break;
|
|
3519
3532
|
case 87:
|
|
3520
|
-
_context36.next =
|
|
3533
|
+
_context36.next = 83;
|
|
3521
3534
|
break;
|
|
3522
3535
|
case 89:
|
|
3523
|
-
_context36.
|
|
3524
|
-
|
|
3536
|
+
_context36.next = 94;
|
|
3537
|
+
break;
|
|
3538
|
+
case 91:
|
|
3539
|
+
_context36.prev = 91;
|
|
3540
|
+
_context36.t3 = _context36["catch"](81);
|
|
3525
3541
|
_iterator3.e(_context36.t3);
|
|
3526
|
-
case
|
|
3527
|
-
_context36.prev =
|
|
3542
|
+
case 94:
|
|
3543
|
+
_context36.prev = 94;
|
|
3528
3544
|
_iterator3.f();
|
|
3529
|
-
return _context36.finish(
|
|
3530
|
-
case 95:
|
|
3531
|
-
_context36.next = 100;
|
|
3532
|
-
break;
|
|
3545
|
+
return _context36.finish(94);
|
|
3533
3546
|
case 97:
|
|
3534
|
-
_context36.
|
|
3535
|
-
|
|
3547
|
+
_context36.next = 102;
|
|
3548
|
+
break;
|
|
3549
|
+
case 99:
|
|
3550
|
+
_context36.prev = 99;
|
|
3551
|
+
_context36.t4 = _context36["catch"](78);
|
|
3536
3552
|
this.logWarning('标记支付项已同步失败(不阻塞主流程)', {
|
|
3537
3553
|
error: _context36.t4
|
|
3538
3554
|
});
|
|
3539
|
-
case
|
|
3555
|
+
case 102:
|
|
3540
3556
|
// 标记订单已同步
|
|
3541
3557
|
this.store.isOrderSynced = true;
|
|
3542
3558
|
|
|
3543
3559
|
// 触发订单同步完成事件
|
|
3544
|
-
_context36.next =
|
|
3560
|
+
_context36.next = 105;
|
|
3545
3561
|
return this.core.effects.emit(CheckoutHooks.OnOrderSynced, {
|
|
3546
3562
|
orderUuid: this.store.currentOrder.uuid,
|
|
3547
3563
|
realOrderId: realOrderId,
|
|
@@ -3550,18 +3566,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3550
3566
|
isManual: isManual,
|
|
3551
3567
|
response: checkoutResponse
|
|
3552
3568
|
});
|
|
3553
|
-
case
|
|
3569
|
+
case 105:
|
|
3554
3570
|
return _context36.abrupt("return", {
|
|
3555
3571
|
success: true,
|
|
3556
3572
|
orderId: realOrderId,
|
|
3557
3573
|
orderUuid: this.store.currentOrder.uuid,
|
|
3558
3574
|
response: checkoutResponse
|
|
3559
3575
|
});
|
|
3560
|
-
case
|
|
3576
|
+
case 106:
|
|
3561
3577
|
case "end":
|
|
3562
3578
|
return _context36.stop();
|
|
3563
3579
|
}
|
|
3564
|
-
}, _callee36, this, [[
|
|
3580
|
+
}, _callee36, this, [[27, 36, 44, 48], [65, 73], [78, 99], [81, 91, 94, 97]]);
|
|
3565
3581
|
}));
|
|
3566
3582
|
function syncOrderToBackendWithReturn() {
|
|
3567
3583
|
return _syncOrderToBackendWithReturn.apply(this, arguments);
|
|
@@ -99,7 +99,7 @@ var WalletPassPaymentImpl = class {
|
|
|
99
99
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
100
100
|
const startTime = Date.now();
|
|
101
101
|
const walletParams = this.generateWalletParams(businessData);
|
|
102
|
-
if (Number(((_a = businessData == null ? void 0 : businessData.amountInfo) == null ? void 0 : _a.totalAmount) || 0) < 0 || Number(((_b = businessData == null ? void 0 : businessData.amountInfo) == null ? void 0 : _b.subTotal) || 0) < 0
|
|
102
|
+
if (Number(((_a = businessData == null ? void 0 : businessData.amountInfo) == null ? void 0 : _a.totalAmount) || 0) < 0 || Number(((_b = businessData == null ? void 0 : businessData.amountInfo) == null ? void 0 : _b.subTotal) || 0) < 0) {
|
|
103
103
|
return {
|
|
104
104
|
walletRecommendList: [],
|
|
105
105
|
userIdentificationCodes: []
|
|
@@ -556,7 +556,6 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
556
556
|
}
|
|
557
557
|
});
|
|
558
558
|
this.store.currentOrder = created;
|
|
559
|
-
await this.updateStateAmountToRemaining();
|
|
560
559
|
this.initWalletData();
|
|
561
560
|
return created;
|
|
562
561
|
}
|
|
@@ -2025,6 +2024,17 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2025
2024
|
reason: "手动设置和计算值均为0"
|
|
2026
2025
|
});
|
|
2027
2026
|
}
|
|
2027
|
+
if (this.store.currentOrder.is_deposit === 0 && processedPaymentItems.every((item) => item.order_payment_type !== "deposit")) {
|
|
2028
|
+
finalDepositAmount = "0.00";
|
|
2029
|
+
this.store.currentOrder.is_deposit = 0;
|
|
2030
|
+
}
|
|
2031
|
+
if (this.store.currentOrder.is_deposit === 0 && processedPaymentItems.some((item) => item.order_payment_type === "deposit")) {
|
|
2032
|
+
finalDepositAmount = processedPaymentItems.filter((item) => item.status !== "voided" && item.order_payment_type === "deposit").reduce((sum, item) => {
|
|
2033
|
+
const amt = new import_decimal.default(item.amount || "0");
|
|
2034
|
+
const rounding = new import_decimal.default(item.rounding_amount || "0").abs();
|
|
2035
|
+
return sum.plus(amt).plus(rounding);
|
|
2036
|
+
}, new import_decimal.default(0)).toFixed(2);
|
|
2037
|
+
}
|
|
2028
2038
|
this.logInfo("定金金额确定结果", {
|
|
2029
2039
|
depositPaymentItemsCount: processedPaymentItems.length,
|
|
2030
2040
|
depositPaymentItems: processedPaymentItems.map((item) => ({
|