@pisell/pisellos 0.0.242 → 0.0.244
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/solution/Checkout/index.d.ts +12 -0
- package/dist/solution/Checkout/index.js +392 -250
- package/dist/solution/Checkout/types.d.ts +39 -0
- package/dist/solution/Checkout/types.js +2 -0
- package/lib/solution/Checkout/index.d.ts +12 -0
- package/lib/solution/Checkout/index.js +87 -4
- package/lib/solution/Checkout/types.d.ts +39 -0
- package/lib/solution/Checkout/types.js +2 -0
- package/package.json +1 -1
|
@@ -85,6 +85,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
85
85
|
cartItems: [],
|
|
86
86
|
paymentMethods: [],
|
|
87
87
|
stateAmount: '0.00',
|
|
88
|
+
balanceDueAmount: '0.00',
|
|
88
89
|
cartSummary: undefined,
|
|
89
90
|
isOrderSynced: false,
|
|
90
91
|
currentCustomer: undefined
|
|
@@ -389,7 +390,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
389
390
|
key: "createLocalOrderAsync",
|
|
390
391
|
value: (function () {
|
|
391
392
|
var _createLocalOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
|
|
392
|
-
var _params$totalInfo, _params$totalInfo2, validation, localOrderId, amountInfo, customerInfo, paymentOrder;
|
|
393
|
+
var _params$totalInfo, _params$totalInfo2, _params$totalInfo3, validation, localOrderId, amountInfo, customerInfo, paymentOrder;
|
|
393
394
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
394
395
|
while (1) switch (_context9.prev = _context9.next) {
|
|
395
396
|
case 0:
|
|
@@ -416,10 +417,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
416
417
|
params.orderData.platform = 'pos';
|
|
417
418
|
// 补充 created_at 时间 (YYYY-MM-DD hh:mm:ss 格式)
|
|
418
419
|
params.orderData.created_at = this.formatDateTime(new Date());
|
|
419
|
-
//
|
|
420
|
-
params.orderData.surcharge_fee = (_params$totalInfo = params.totalInfo) === null || _params$totalInfo === void 0 || (_params$totalInfo = _params$totalInfo.total) === null || _params$totalInfo === void 0 ? void 0 : _params$totalInfo.
|
|
420
|
+
// 补充附加费信息
|
|
421
|
+
params.orderData.surcharge_fee = (_params$totalInfo = params.totalInfo) === null || _params$totalInfo === void 0 || (_params$totalInfo = _params$totalInfo.total) === null || _params$totalInfo === void 0 ? void 0 : _params$totalInfo.otherAmount;
|
|
422
|
+
params.orderData.surcharges = (_params$totalInfo2 = params.totalInfo) === null || _params$totalInfo2 === void 0 || (_params$totalInfo2 = _params$totalInfo2.total) === null || _params$totalInfo2 === void 0 ? void 0 : _params$totalInfo2.surcharge;
|
|
421
423
|
// 补充订单折扣信息
|
|
422
|
-
params.orderData.shop_discount = (_params$
|
|
424
|
+
params.orderData.shop_discount = (_params$totalInfo3 = params.totalInfo) === null || _params$totalInfo3 === void 0 || (_params$totalInfo3 = _params$totalInfo3.total) === null || _params$totalInfo3 === void 0 ? void 0 : _params$totalInfo3.shopDiscount;
|
|
423
425
|
|
|
424
426
|
// 保存原始订单数据和小计数据到状态中
|
|
425
427
|
this.store.localOrderData = params.orderData;
|
|
@@ -439,7 +441,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
439
441
|
}
|
|
440
442
|
|
|
441
443
|
// 创建支付订单对象
|
|
442
|
-
_context9.next =
|
|
444
|
+
_context9.next = 23;
|
|
443
445
|
return this.payment.createPaymentOrderAsync({
|
|
444
446
|
order_id: localOrderId,
|
|
445
447
|
total_amount: amountInfo.totalAmount,
|
|
@@ -456,34 +458,34 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
456
458
|
amount_breakdown: amountInfo
|
|
457
459
|
}
|
|
458
460
|
});
|
|
459
|
-
case
|
|
461
|
+
case 23:
|
|
460
462
|
paymentOrder = _context9.sent;
|
|
461
463
|
this.store.currentOrder = paymentOrder;
|
|
462
|
-
_context9.next =
|
|
464
|
+
_context9.next = 27;
|
|
463
465
|
return this.initWalletData();
|
|
464
|
-
case
|
|
465
|
-
_context9.next =
|
|
466
|
+
case 27:
|
|
467
|
+
_context9.next = 29;
|
|
466
468
|
return this.setStatus(CheckoutStatus.OrderCreated);
|
|
467
|
-
case
|
|
468
|
-
_context9.next =
|
|
469
|
+
case 29:
|
|
470
|
+
_context9.next = 31;
|
|
469
471
|
return this.setStep(CheckoutStep.PaymentMethod);
|
|
470
|
-
case
|
|
472
|
+
case 31:
|
|
471
473
|
if (!params.autoPayment) {
|
|
472
|
-
_context9.next =
|
|
474
|
+
_context9.next = 34;
|
|
473
475
|
break;
|
|
474
476
|
}
|
|
475
|
-
_context9.next =
|
|
477
|
+
_context9.next = 34;
|
|
476
478
|
return this.setStep(CheckoutStep.PaymentProcessing);
|
|
477
|
-
case
|
|
478
|
-
_context9.next =
|
|
479
|
+
case 34:
|
|
480
|
+
_context9.next = 36;
|
|
479
481
|
return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
|
|
480
482
|
order: paymentOrder,
|
|
481
483
|
timestamp: Date.now()
|
|
482
484
|
});
|
|
483
|
-
case
|
|
484
|
-
_context9.next =
|
|
485
|
+
case 36:
|
|
486
|
+
_context9.next = 38;
|
|
485
487
|
return this.updateStateAmountToRemaining();
|
|
486
|
-
case
|
|
488
|
+
case 38:
|
|
487
489
|
console.log('[Checkout] 本地订单创建成功:', {
|
|
488
490
|
localOrderId: localOrderId,
|
|
489
491
|
uuid: paymentOrder.uuid,
|
|
@@ -493,24 +495,24 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
493
495
|
stateAmount: this.store.stateAmount
|
|
494
496
|
});
|
|
495
497
|
return _context9.abrupt("return", paymentOrder);
|
|
496
|
-
case
|
|
497
|
-
_context9.prev =
|
|
498
|
+
case 42:
|
|
499
|
+
_context9.prev = 42;
|
|
498
500
|
_context9.t0 = _context9["catch"](0);
|
|
499
|
-
_context9.next =
|
|
501
|
+
_context9.next = 46;
|
|
500
502
|
return this.handleError(_context9.t0, CheckoutErrorType.OrderCreationFailed);
|
|
501
|
-
case
|
|
502
|
-
_context9.next =
|
|
503
|
+
case 46:
|
|
504
|
+
_context9.next = 48;
|
|
503
505
|
return this.core.effects.emit(CheckoutHooks.OnOrderCreationFailed, {
|
|
504
506
|
error: this.store.lastError,
|
|
505
507
|
timestamp: Date.now()
|
|
506
508
|
});
|
|
507
|
-
case 47:
|
|
508
|
-
throw _context9.t0;
|
|
509
509
|
case 48:
|
|
510
|
+
throw _context9.t0;
|
|
511
|
+
case 49:
|
|
510
512
|
case "end":
|
|
511
513
|
return _context9.stop();
|
|
512
514
|
}
|
|
513
|
-
}, _callee9, this, [[0,
|
|
515
|
+
}, _callee9, this, [[0, 42]]);
|
|
514
516
|
}));
|
|
515
517
|
function createLocalOrderAsync(_x11) {
|
|
516
518
|
return _createLocalOrderAsync.apply(this, arguments);
|
|
@@ -933,30 +935,31 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
933
935
|
this.payment.wallet.clearAllCache();
|
|
934
936
|
this.store.cartItems = [];
|
|
935
937
|
this.store.stateAmount = '0.00';
|
|
938
|
+
this.store.balanceDueAmount = '0.00';
|
|
936
939
|
this.store.isOrderSynced = false;
|
|
937
940
|
this.store.currentCustomer = undefined;
|
|
938
|
-
_context14.next =
|
|
941
|
+
_context14.next = 15;
|
|
939
942
|
return this.setStatus(CheckoutStatus.Cancelled);
|
|
940
|
-
case
|
|
941
|
-
_context14.next =
|
|
943
|
+
case 15:
|
|
944
|
+
_context14.next = 17;
|
|
942
945
|
return this.core.effects.emit(CheckoutHooks.OnCheckoutCancelled, {
|
|
943
946
|
timestamp: Date.now()
|
|
944
947
|
});
|
|
945
|
-
case
|
|
948
|
+
case 17:
|
|
946
949
|
console.log('[Checkout] 结账流程已取消');
|
|
947
|
-
_context14.next =
|
|
950
|
+
_context14.next = 25;
|
|
948
951
|
break;
|
|
949
|
-
case
|
|
950
|
-
_context14.prev =
|
|
952
|
+
case 20:
|
|
953
|
+
_context14.prev = 20;
|
|
951
954
|
_context14.t0 = _context14["catch"](0);
|
|
952
955
|
console.error('[Checkout] 取消结账失败:', _context14.t0);
|
|
953
|
-
_context14.next =
|
|
956
|
+
_context14.next = 25;
|
|
954
957
|
return this.handleError(_context14.t0, CheckoutErrorType.UnknownError);
|
|
955
|
-
case
|
|
958
|
+
case 25:
|
|
956
959
|
case "end":
|
|
957
960
|
return _context14.stop();
|
|
958
961
|
}
|
|
959
|
-
}, _callee14, this, [[0,
|
|
962
|
+
}, _callee14, this, [[0, 20]]);
|
|
960
963
|
}));
|
|
961
964
|
function cancelCheckoutAsync() {
|
|
962
965
|
return _cancelCheckoutAsync.apply(this, arguments);
|
|
@@ -1506,6 +1509,19 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1506
1509
|
return this.store.stateAmount;
|
|
1507
1510
|
}
|
|
1508
1511
|
|
|
1512
|
+
/**
|
|
1513
|
+
* 获取系统计算的待付金额(只读)
|
|
1514
|
+
*
|
|
1515
|
+
* 此方法返回系统内部计算的实际待付金额,不允许外部修改
|
|
1516
|
+
*
|
|
1517
|
+
* @returns 当前系统计算的待付金额
|
|
1518
|
+
*/
|
|
1519
|
+
}, {
|
|
1520
|
+
key: "getBalanceDueAmount",
|
|
1521
|
+
value: function getBalanceDueAmount() {
|
|
1522
|
+
return this.store.balanceDueAmount;
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1509
1525
|
/**
|
|
1510
1526
|
* 刷新 stateAmount 为当前剩余未支付金额
|
|
1511
1527
|
*
|
|
@@ -2457,6 +2473,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2457
2473
|
this.store.currentOrder = undefined; // 释放 currentOrder
|
|
2458
2474
|
this.store.localOrderData = undefined;
|
|
2459
2475
|
this.store.stateAmount = '0.00';
|
|
2476
|
+
this.store.balanceDueAmount = '0.00';
|
|
2460
2477
|
this.store.isOrderSynced = false;
|
|
2461
2478
|
this.store.currentCustomer = undefined;
|
|
2462
2479
|
|
|
@@ -2465,7 +2482,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2465
2482
|
console.log('[Checkout] 订单状态清理完成,currentOrder已释放');
|
|
2466
2483
|
|
|
2467
2484
|
// 触发订单取消事件
|
|
2468
|
-
_context32.next =
|
|
2485
|
+
_context32.next = 33;
|
|
2469
2486
|
return this.core.effects.emit(CheckoutHooks.OnOrderCancelled, {
|
|
2470
2487
|
orderUuid: currentOrderUuid,
|
|
2471
2488
|
orderId: currentOrderId,
|
|
@@ -2474,7 +2491,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2474
2491
|
// 只有未同步订单可以被取消
|
|
2475
2492
|
timestamp: Date.now()
|
|
2476
2493
|
});
|
|
2477
|
-
case
|
|
2494
|
+
case 33:
|
|
2478
2495
|
console.log('[Checkout] 本地订单取消完成:', {
|
|
2479
2496
|
orderUuid: currentOrderUuid,
|
|
2480
2497
|
orderId: currentOrderId,
|
|
@@ -2485,8 +2502,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2485
2502
|
message: '本地订单已成功取消',
|
|
2486
2503
|
orderId: currentOrderId
|
|
2487
2504
|
});
|
|
2488
|
-
case
|
|
2489
|
-
_context32.prev =
|
|
2505
|
+
case 37:
|
|
2506
|
+
_context32.prev = 37;
|
|
2490
2507
|
_context32.t1 = _context32["catch"](0);
|
|
2491
2508
|
console.error('[Checkout] 取消本地订单失败:', _context32.t1);
|
|
2492
2509
|
errorMessage = _context32.t1 instanceof Error ? _context32.t1.message : '未知错误';
|
|
@@ -2494,11 +2511,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2494
2511
|
success: false,
|
|
2495
2512
|
message: "\u53D6\u6D88\u8BA2\u5355\u5931\u8D25: ".concat(errorMessage)
|
|
2496
2513
|
});
|
|
2497
|
-
case
|
|
2514
|
+
case 42:
|
|
2498
2515
|
case "end":
|
|
2499
2516
|
return _context32.stop();
|
|
2500
2517
|
}
|
|
2501
|
-
}, _callee32, this, [[0,
|
|
2518
|
+
}, _callee32, this, [[0, 37], [12, 19]]);
|
|
2502
2519
|
}));
|
|
2503
2520
|
function cancelCurrentOrderAsync(_x21) {
|
|
2504
2521
|
return _cancelCurrentOrderAsync.apply(this, arguments);
|
|
@@ -3331,14 +3348,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3331
3348
|
return calculateRemainingAmountAsync;
|
|
3332
3349
|
}()
|
|
3333
3350
|
/**
|
|
3334
|
-
* 更新
|
|
3351
|
+
* 更新 balanceDueAmount 为当前剩余未支付金额(系统内部计算)
|
|
3335
3352
|
*/
|
|
3336
3353
|
)
|
|
3337
3354
|
}, {
|
|
3338
|
-
key: "
|
|
3355
|
+
key: "updateBalanceDueAmount",
|
|
3339
3356
|
value: (function () {
|
|
3340
|
-
var
|
|
3341
|
-
var _this$store$currentOr17, remainingAmount,
|
|
3357
|
+
var _updateBalanceDueAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
|
|
3358
|
+
var _this$store$currentOr17, remainingAmount, currentBalanceDueAmount;
|
|
3342
3359
|
return _regeneratorRuntime().wrap(function _callee46$(_context46) {
|
|
3343
3360
|
while (1) switch (_context46.prev = _context46.next) {
|
|
3344
3361
|
case 0:
|
|
@@ -3347,23 +3364,92 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3347
3364
|
return this.calculateRemainingAmountAsync();
|
|
3348
3365
|
case 3:
|
|
3349
3366
|
remainingAmount = _context46.sent;
|
|
3367
|
+
currentBalanceDueAmount = this.store.balanceDueAmount;
|
|
3368
|
+
console.log('[Checkout] updateBalanceDueAmount: 状态检查:', {
|
|
3369
|
+
calculatedRemainingAmount: remainingAmount,
|
|
3370
|
+
currentBalanceDueAmount: currentBalanceDueAmount,
|
|
3371
|
+
needsUpdate: remainingAmount !== currentBalanceDueAmount,
|
|
3372
|
+
orderUuid: (_this$store$currentOr17 = this.store.currentOrder) === null || _this$store$currentOr17 === void 0 ? void 0 : _this$store$currentOr17.uuid
|
|
3373
|
+
});
|
|
3374
|
+
|
|
3375
|
+
// 只有当剩余金额与当前 balanceDueAmount 不同时才更新
|
|
3376
|
+
if (!(remainingAmount !== currentBalanceDueAmount)) {
|
|
3377
|
+
_context46.next = 13;
|
|
3378
|
+
break;
|
|
3379
|
+
}
|
|
3380
|
+
this.store.balanceDueAmount = remainingAmount;
|
|
3381
|
+
|
|
3382
|
+
// 发出 balanceDueAmount 变更事件
|
|
3383
|
+
_context46.next = 10;
|
|
3384
|
+
return this.core.effects.emit(CheckoutHooks.OnBalanceDueAmountChanged, {
|
|
3385
|
+
oldAmount: currentBalanceDueAmount,
|
|
3386
|
+
newAmount: remainingAmount,
|
|
3387
|
+
timestamp: Date.now()
|
|
3388
|
+
});
|
|
3389
|
+
case 10:
|
|
3390
|
+
console.log('[Checkout] balanceDueAmount 已自动更新:', {
|
|
3391
|
+
oldAmount: currentBalanceDueAmount,
|
|
3392
|
+
newAmount: remainingAmount
|
|
3393
|
+
});
|
|
3394
|
+
_context46.next = 14;
|
|
3395
|
+
break;
|
|
3396
|
+
case 13:
|
|
3397
|
+
console.log('[Checkout] balanceDueAmount 无需更新,当前值已是最新:', {
|
|
3398
|
+
balanceDueAmount: currentBalanceDueAmount,
|
|
3399
|
+
remainingAmount: remainingAmount
|
|
3400
|
+
});
|
|
3401
|
+
case 14:
|
|
3402
|
+
_context46.next = 19;
|
|
3403
|
+
break;
|
|
3404
|
+
case 16:
|
|
3405
|
+
_context46.prev = 16;
|
|
3406
|
+
_context46.t0 = _context46["catch"](0);
|
|
3407
|
+
console.error('[Checkout] 更新 balanceDueAmount 失败:', _context46.t0);
|
|
3408
|
+
case 19:
|
|
3409
|
+
case "end":
|
|
3410
|
+
return _context46.stop();
|
|
3411
|
+
}
|
|
3412
|
+
}, _callee46, this, [[0, 16]]);
|
|
3413
|
+
}));
|
|
3414
|
+
function updateBalanceDueAmount() {
|
|
3415
|
+
return _updateBalanceDueAmount.apply(this, arguments);
|
|
3416
|
+
}
|
|
3417
|
+
return updateBalanceDueAmount;
|
|
3418
|
+
}()
|
|
3419
|
+
/**
|
|
3420
|
+
* 更新 stateAmount 为当前剩余未支付金额
|
|
3421
|
+
*/
|
|
3422
|
+
)
|
|
3423
|
+
}, {
|
|
3424
|
+
key: "updateStateAmountToRemaining",
|
|
3425
|
+
value: (function () {
|
|
3426
|
+
var _updateStateAmountToRemaining = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47() {
|
|
3427
|
+
var _this$store$currentOr18, remainingAmount, currentStateAmount;
|
|
3428
|
+
return _regeneratorRuntime().wrap(function _callee47$(_context47) {
|
|
3429
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
3430
|
+
case 0:
|
|
3431
|
+
_context47.prev = 0;
|
|
3432
|
+
_context47.next = 3;
|
|
3433
|
+
return this.calculateRemainingAmountAsync();
|
|
3434
|
+
case 3:
|
|
3435
|
+
remainingAmount = _context47.sent;
|
|
3350
3436
|
currentStateAmount = this.store.stateAmount;
|
|
3351
3437
|
console.log('[Checkout] updateStateAmountToRemaining: 状态检查:', {
|
|
3352
3438
|
calculatedRemainingAmount: remainingAmount,
|
|
3353
3439
|
currentStateAmount: currentStateAmount,
|
|
3354
3440
|
needsUpdate: remainingAmount !== currentStateAmount,
|
|
3355
|
-
orderUuid: (_this$store$
|
|
3441
|
+
orderUuid: (_this$store$currentOr18 = this.store.currentOrder) === null || _this$store$currentOr18 === void 0 ? void 0 : _this$store$currentOr18.uuid
|
|
3356
3442
|
});
|
|
3357
3443
|
|
|
3358
3444
|
// 只有当剩余金额与当前 stateAmount 不同时才更新
|
|
3359
3445
|
if (!(remainingAmount !== currentStateAmount)) {
|
|
3360
|
-
|
|
3446
|
+
_context47.next = 13;
|
|
3361
3447
|
break;
|
|
3362
3448
|
}
|
|
3363
3449
|
this.store.stateAmount = remainingAmount;
|
|
3364
3450
|
|
|
3365
3451
|
// 发出 stateAmount 变更事件
|
|
3366
|
-
|
|
3452
|
+
_context47.next = 10;
|
|
3367
3453
|
return this.core.effects.emit(CheckoutHooks.OnStateAmountChanged, {
|
|
3368
3454
|
oldAmount: currentStateAmount,
|
|
3369
3455
|
newAmount: remainingAmount,
|
|
@@ -3374,7 +3460,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3374
3460
|
oldAmount: currentStateAmount,
|
|
3375
3461
|
newAmount: remainingAmount
|
|
3376
3462
|
});
|
|
3377
|
-
|
|
3463
|
+
_context47.next = 14;
|
|
3378
3464
|
break;
|
|
3379
3465
|
case 13:
|
|
3380
3466
|
console.log('[Checkout] stateAmount 无需更新,当前值已是最新:', {
|
|
@@ -3382,20 +3468,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3382
3468
|
remainingAmount: remainingAmount
|
|
3383
3469
|
});
|
|
3384
3470
|
case 14:
|
|
3385
|
-
|
|
3386
|
-
return this.
|
|
3471
|
+
_context47.next = 16;
|
|
3472
|
+
return this.updateBalanceDueAmount();
|
|
3387
3473
|
case 16:
|
|
3388
|
-
|
|
3389
|
-
|
|
3474
|
+
_context47.next = 18;
|
|
3475
|
+
return this.checkOrderPaymentCompletion();
|
|
3390
3476
|
case 18:
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3477
|
+
_context47.next = 23;
|
|
3478
|
+
break;
|
|
3479
|
+
case 20:
|
|
3480
|
+
_context47.prev = 20;
|
|
3481
|
+
_context47.t0 = _context47["catch"](0);
|
|
3482
|
+
console.error('[Checkout] 更新 stateAmount 为剩余金额失败:', _context47.t0);
|
|
3483
|
+
case 23:
|
|
3395
3484
|
case "end":
|
|
3396
|
-
return
|
|
3485
|
+
return _context47.stop();
|
|
3397
3486
|
}
|
|
3398
|
-
},
|
|
3487
|
+
}, _callee47, this, [[0, 20]]);
|
|
3399
3488
|
}));
|
|
3400
3489
|
function updateStateAmountToRemaining() {
|
|
3401
3490
|
return _updateStateAmountToRemaining.apply(this, arguments);
|
|
@@ -3411,32 +3500,32 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3411
3500
|
}, {
|
|
3412
3501
|
key: "checkOrderPaymentCompletion",
|
|
3413
3502
|
value: (function () {
|
|
3414
|
-
var _checkOrderPaymentCompletion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3503
|
+
var _checkOrderPaymentCompletion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48() {
|
|
3415
3504
|
var remainingAmount, remainingValue, totalAmount, paidAmount, currentPayments, hasPaymentItems, allPaymentsHaveVoucherId, shouldAutoSync;
|
|
3416
|
-
return _regeneratorRuntime().wrap(function
|
|
3417
|
-
while (1) switch (
|
|
3505
|
+
return _regeneratorRuntime().wrap(function _callee48$(_context48) {
|
|
3506
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
3418
3507
|
case 0:
|
|
3419
|
-
|
|
3508
|
+
_context48.prev = 0;
|
|
3420
3509
|
if (this.store.currentOrder) {
|
|
3421
|
-
|
|
3510
|
+
_context48.next = 3;
|
|
3422
3511
|
break;
|
|
3423
3512
|
}
|
|
3424
|
-
return
|
|
3513
|
+
return _context48.abrupt("return");
|
|
3425
3514
|
case 3:
|
|
3426
|
-
|
|
3515
|
+
_context48.next = 5;
|
|
3427
3516
|
return this.calculateRemainingAmountAsync();
|
|
3428
3517
|
case 5:
|
|
3429
|
-
remainingAmount =
|
|
3518
|
+
remainingAmount = _context48.sent;
|
|
3430
3519
|
remainingValue = parseFloat(remainingAmount); // 当剩余金额小于等于0时,认为订单已完成支付
|
|
3431
3520
|
if (!(remainingValue <= 0)) {
|
|
3432
|
-
|
|
3521
|
+
_context48.next = 29;
|
|
3433
3522
|
break;
|
|
3434
3523
|
}
|
|
3435
3524
|
totalAmount = this.store.currentOrder.total_amount;
|
|
3436
|
-
|
|
3525
|
+
_context48.next = 11;
|
|
3437
3526
|
return this.calculatePaidAmountAsync();
|
|
3438
3527
|
case 11:
|
|
3439
|
-
paidAmount =
|
|
3528
|
+
paidAmount = _context48.sent;
|
|
3440
3529
|
console.log('[Checkout] 检测到订单支付完成:', {
|
|
3441
3530
|
orderUuid: this.store.currentOrder.uuid,
|
|
3442
3531
|
orderId: this.store.currentOrder.order_id,
|
|
@@ -3447,11 +3536,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3447
3536
|
});
|
|
3448
3537
|
|
|
3449
3538
|
// 从 Payment 模块获取最新支付项,检查自动同步条件
|
|
3450
|
-
|
|
3539
|
+
_context48.next = 15;
|
|
3451
3540
|
return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid, false // 不包括已撤销的支付项
|
|
3452
3541
|
);
|
|
3453
3542
|
case 15:
|
|
3454
|
-
currentPayments =
|
|
3543
|
+
currentPayments = _context48.sent;
|
|
3455
3544
|
// 检查自动同步条件:
|
|
3456
3545
|
// 1. 待付金额为 0 ✓ (已在上面检查)
|
|
3457
3546
|
// 2. 需要有支付项
|
|
@@ -3483,14 +3572,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3483
3572
|
})
|
|
3484
3573
|
});
|
|
3485
3574
|
if (!shouldAutoSync) {
|
|
3486
|
-
|
|
3575
|
+
_context48.next = 26;
|
|
3487
3576
|
break;
|
|
3488
3577
|
}
|
|
3489
3578
|
console.log('[Checkout] 满足自动同步条件,开始同步订单到后端...');
|
|
3490
|
-
|
|
3579
|
+
_context48.next = 24;
|
|
3491
3580
|
return this.syncOrderToBackend();
|
|
3492
3581
|
case 24:
|
|
3493
|
-
|
|
3582
|
+
_context48.next = 27;
|
|
3494
3583
|
break;
|
|
3495
3584
|
case 26:
|
|
3496
3585
|
if (!hasPaymentItems) {
|
|
@@ -3499,7 +3588,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3499
3588
|
console.log('[Checkout] 所有支付项均为代金券类型,跳过订单同步');
|
|
3500
3589
|
}
|
|
3501
3590
|
case 27:
|
|
3502
|
-
|
|
3591
|
+
_context48.next = 29;
|
|
3503
3592
|
return this.core.effects.emit(CheckoutHooks.OnOrderPaymentCompleted, {
|
|
3504
3593
|
orderUuid: this.store.currentOrder.uuid,
|
|
3505
3594
|
orderId: this.store.currentOrder.order_id,
|
|
@@ -3509,17 +3598,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3509
3598
|
timestamp: Date.now()
|
|
3510
3599
|
});
|
|
3511
3600
|
case 29:
|
|
3512
|
-
|
|
3601
|
+
_context48.next = 34;
|
|
3513
3602
|
break;
|
|
3514
3603
|
case 31:
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
console.error('[Checkout] 检查订单支付完成状态失败:',
|
|
3604
|
+
_context48.prev = 31;
|
|
3605
|
+
_context48.t0 = _context48["catch"](0);
|
|
3606
|
+
console.error('[Checkout] 检查订单支付完成状态失败:', _context48.t0);
|
|
3518
3607
|
case 34:
|
|
3519
3608
|
case "end":
|
|
3520
|
-
return
|
|
3609
|
+
return _context48.stop();
|
|
3521
3610
|
}
|
|
3522
|
-
},
|
|
3611
|
+
}, _callee48, this, [[0, 31]]);
|
|
3523
3612
|
}));
|
|
3524
3613
|
function checkOrderPaymentCompletion() {
|
|
3525
3614
|
return _checkOrderPaymentCompletion.apply(this, arguments);
|
|
@@ -3591,8 +3680,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3591
3680
|
}, {
|
|
3592
3681
|
key: "syncOrderToBackendWithReturn",
|
|
3593
3682
|
value: (function () {
|
|
3594
|
-
var _syncOrderToBackendWithReturn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3595
|
-
var _this$store$currentCu2, _this$store$
|
|
3683
|
+
var _syncOrderToBackendWithReturn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49() {
|
|
3684
|
+
var _this$store$currentCu2, _this$store$currentOr19, _this$store$currentOr20, _checkoutResponse3, _checkoutResponse4, _checkoutResponse5, _checkoutResponse6, _checkoutResponse7, _checkoutResponse8;
|
|
3596
3685
|
var isManual,
|
|
3597
3686
|
customPaymentItems,
|
|
3598
3687
|
syncType,
|
|
@@ -3609,22 +3698,28 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3609
3698
|
submitError,
|
|
3610
3699
|
_checkoutResponse,
|
|
3611
3700
|
_checkoutResponse2,
|
|
3701
|
+
responseStatus,
|
|
3702
|
+
isSuccessResponse,
|
|
3703
|
+
_checkoutResponse9,
|
|
3704
|
+
_checkoutResponse10,
|
|
3705
|
+
_checkoutResponse11,
|
|
3706
|
+
errorMessage,
|
|
3612
3707
|
realOrderId,
|
|
3613
|
-
|
|
3708
|
+
_checkoutResponse12,
|
|
3614
3709
|
extractedOrderId,
|
|
3615
|
-
|
|
3710
|
+
_checkoutResponse13,
|
|
3616
3711
|
updatedOrder,
|
|
3617
3712
|
beforeManualUpdate,
|
|
3618
3713
|
finalOrderId,
|
|
3619
3714
|
finalIsVirtual,
|
|
3620
|
-
|
|
3621
|
-
return _regeneratorRuntime().wrap(function
|
|
3622
|
-
while (1) switch (
|
|
3715
|
+
_args49 = arguments;
|
|
3716
|
+
return _regeneratorRuntime().wrap(function _callee49$(_context49) {
|
|
3717
|
+
while (1) switch (_context49.prev = _context49.next) {
|
|
3623
3718
|
case 0:
|
|
3624
|
-
isManual =
|
|
3625
|
-
customPaymentItems =
|
|
3719
|
+
isManual = _args49.length > 0 && _args49[0] !== undefined ? _args49[0] : false;
|
|
3720
|
+
customPaymentItems = _args49.length > 1 ? _args49[1] : undefined;
|
|
3626
3721
|
if (!(!this.store.localOrderData || !this.store.currentOrder)) {
|
|
3627
|
-
|
|
3722
|
+
_context49.next = 4;
|
|
3628
3723
|
break;
|
|
3629
3724
|
}
|
|
3630
3725
|
throw new Error('缺少必要的订单数据,无法同步到后端');
|
|
@@ -3665,17 +3760,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3665
3760
|
});
|
|
3666
3761
|
|
|
3667
3762
|
// 获取当前订单的支付项
|
|
3668
|
-
|
|
3669
|
-
if (
|
|
3670
|
-
|
|
3763
|
+
_context49.t0 = customPaymentItems;
|
|
3764
|
+
if (_context49.t0) {
|
|
3765
|
+
_context49.next = 18;
|
|
3671
3766
|
break;
|
|
3672
3767
|
}
|
|
3673
|
-
|
|
3768
|
+
_context49.next = 17;
|
|
3674
3769
|
return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid);
|
|
3675
3770
|
case 17:
|
|
3676
|
-
|
|
3771
|
+
_context49.t0 = _context49.sent;
|
|
3677
3772
|
case 18:
|
|
3678
|
-
paymentItems =
|
|
3773
|
+
paymentItems = _context49.t0;
|
|
3679
3774
|
console.log('[Checkout] 获取到支付项:', {
|
|
3680
3775
|
count: paymentItems.length,
|
|
3681
3776
|
isCustomFiltered: !!customPaymentItems,
|
|
@@ -3716,8 +3811,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3716
3811
|
currency_code: this.otherParams.currency_code,
|
|
3717
3812
|
currency_symbol: this.otherParams.currency_symbol,
|
|
3718
3813
|
currency_format: this.otherParams.currency_format,
|
|
3719
|
-
is_deposit: ((_this$store$
|
|
3720
|
-
deposit_amount: ((_this$store$
|
|
3814
|
+
is_deposit: ((_this$store$currentOr19 = this.store.currentOrder) === null || _this$store$currentOr19 === void 0 ? void 0 : _this$store$currentOr19.is_deposit) || 0,
|
|
3815
|
+
deposit_amount: ((_this$store$currentOr20 = this.store.currentOrder) === null || _this$store$currentOr20 === void 0 ? void 0 : _this$store$currentOr20.deposit_amount) || '0.00',
|
|
3721
3816
|
// surcharge_fee: this.otherParams.surcharge_fee,
|
|
3722
3817
|
// surcharges: ,
|
|
3723
3818
|
note: this.store.localOrderData.shop_note
|
|
@@ -3748,7 +3843,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3748
3843
|
|
|
3749
3844
|
// 发送下单接口请求开始事件
|
|
3750
3845
|
startTime = Date.now();
|
|
3751
|
-
|
|
3846
|
+
_context49.next = 25;
|
|
3752
3847
|
return this.core.effects.emit(CheckoutHooks.OnOrderSubmitStart, {
|
|
3753
3848
|
orderUuid: this.store.currentOrder.uuid,
|
|
3754
3849
|
operation: isUpdateOperation ? 'update' : 'create',
|
|
@@ -3758,25 +3853,38 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3758
3853
|
});
|
|
3759
3854
|
case 25:
|
|
3760
3855
|
submitSuccess = false;
|
|
3761
|
-
|
|
3762
|
-
|
|
3856
|
+
_context49.prev = 26;
|
|
3857
|
+
_context49.next = 29;
|
|
3763
3858
|
return this.order.createOrderByCheckout(orderParams);
|
|
3764
3859
|
case 29:
|
|
3765
|
-
checkoutResponse =
|
|
3860
|
+
checkoutResponse = _context49.sent;
|
|
3766
3861
|
submitSuccess = true;
|
|
3767
3862
|
console.log('[Checkout] 下单接口调用成功');
|
|
3768
|
-
|
|
3863
|
+
_context49.next = 41;
|
|
3769
3864
|
break;
|
|
3770
3865
|
case 34:
|
|
3771
|
-
|
|
3772
|
-
|
|
3866
|
+
_context49.prev = 34;
|
|
3867
|
+
_context49.t1 = _context49["catch"](26);
|
|
3773
3868
|
submitSuccess = false;
|
|
3774
|
-
submitError =
|
|
3775
|
-
console.error('[Checkout] 下单接口调用失败:', submitError);
|
|
3776
|
-
|
|
3869
|
+
submitError = _context49.t1 instanceof Error ? _context49.t1.message : String(_context49.t1);
|
|
3870
|
+
// console.error('[Checkout] 下单接口调用失败:', submitError);
|
|
3871
|
+
|
|
3872
|
+
// 发送订单同步失败事件(网络错误或请求失败)
|
|
3873
|
+
_context49.next = 40;
|
|
3874
|
+
return this.core.effects.emit(CheckoutHooks.OnOrderSyncFailed, {
|
|
3875
|
+
orderUuid: this.store.currentOrder.uuid,
|
|
3876
|
+
operation: isUpdateOperation ? 'update' : 'create',
|
|
3877
|
+
isManual: isManual,
|
|
3878
|
+
error: submitError,
|
|
3879
|
+
errorType: 'network_error',
|
|
3880
|
+
duration: Date.now() - startTime,
|
|
3881
|
+
timestamp: Date.now()
|
|
3882
|
+
});
|
|
3777
3883
|
case 40:
|
|
3778
|
-
|
|
3779
|
-
|
|
3884
|
+
throw _context49.t1;
|
|
3885
|
+
case 41:
|
|
3886
|
+
_context49.prev = 41;
|
|
3887
|
+
_context49.next = 44;
|
|
3780
3888
|
return this.core.effects.emit(CheckoutHooks.OnOrderSubmitEnd, {
|
|
3781
3889
|
success: submitSuccess,
|
|
3782
3890
|
orderUuid: this.store.currentOrder.uuid,
|
|
@@ -3787,29 +3895,62 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3787
3895
|
duration: Date.now() - startTime,
|
|
3788
3896
|
timestamp: Date.now()
|
|
3789
3897
|
});
|
|
3790
|
-
case 43:
|
|
3791
|
-
return _context48.finish(40);
|
|
3792
3898
|
case 44:
|
|
3899
|
+
return _context49.finish(41);
|
|
3900
|
+
case 45:
|
|
3793
3901
|
console.log('[Checkout] 后端返回的响应数据:', {
|
|
3794
3902
|
status: (_checkoutResponse3 = checkoutResponse) === null || _checkoutResponse3 === void 0 ? void 0 : _checkoutResponse3.status,
|
|
3795
3903
|
code: (_checkoutResponse4 = checkoutResponse) === null || _checkoutResponse4 === void 0 ? void 0 : _checkoutResponse4.code,
|
|
3796
3904
|
message: (_checkoutResponse5 = checkoutResponse) === null || _checkoutResponse5 === void 0 ? void 0 : _checkoutResponse5.message,
|
|
3797
3905
|
data: (_checkoutResponse6 = checkoutResponse) === null || _checkoutResponse6 === void 0 ? void 0 : _checkoutResponse6.data
|
|
3798
3906
|
});
|
|
3907
|
+
|
|
3908
|
+
// 检查响应状态是否为成功状态
|
|
3909
|
+
responseStatus = (_checkoutResponse7 = checkoutResponse) === null || _checkoutResponse7 === void 0 ? void 0 : _checkoutResponse7.status;
|
|
3910
|
+
isSuccessResponse = responseStatus === true || responseStatus === 200 || responseStatus === 'success' || responseStatus === 1 && ((_checkoutResponse8 = checkoutResponse) === null || _checkoutResponse8 === void 0 ? void 0 : _checkoutResponse8.code) === 200;
|
|
3911
|
+
if (isSuccessResponse) {
|
|
3912
|
+
_context49.next = 54;
|
|
3913
|
+
break;
|
|
3914
|
+
}
|
|
3915
|
+
errorMessage = ((_checkoutResponse9 = checkoutResponse) === null || _checkoutResponse9 === void 0 ? void 0 : _checkoutResponse9.message) || '订单同步失败,后端返回非成功状态';
|
|
3916
|
+
console.error('[Checkout] 订单同步失败,响应状态检查未通过:', {
|
|
3917
|
+
expectedSuccess: true,
|
|
3918
|
+
actualStatus: responseStatus,
|
|
3919
|
+
code: (_checkoutResponse10 = checkoutResponse) === null || _checkoutResponse10 === void 0 ? void 0 : _checkoutResponse10.code,
|
|
3920
|
+
message: (_checkoutResponse11 = checkoutResponse) === null || _checkoutResponse11 === void 0 ? void 0 : _checkoutResponse11.message,
|
|
3921
|
+
errorMessage: errorMessage
|
|
3922
|
+
});
|
|
3923
|
+
|
|
3924
|
+
// 发送订单同步失败事件
|
|
3925
|
+
_context49.next = 53;
|
|
3926
|
+
return this.core.effects.emit(CheckoutHooks.OnOrderSyncFailed, {
|
|
3927
|
+
orderUuid: this.store.currentOrder.uuid,
|
|
3928
|
+
operation: isUpdateOperation ? 'update' : 'create',
|
|
3929
|
+
isManual: isManual,
|
|
3930
|
+
error: errorMessage,
|
|
3931
|
+
errorType: 'api_error',
|
|
3932
|
+
response: checkoutResponse,
|
|
3933
|
+
duration: Date.now() - startTime,
|
|
3934
|
+
timestamp: Date.now()
|
|
3935
|
+
});
|
|
3936
|
+
case 53:
|
|
3937
|
+
throw new Error(errorMessage);
|
|
3938
|
+
case 54:
|
|
3939
|
+
console.log('[Checkout] 响应状态检查通过,开始处理订单数据');
|
|
3799
3940
|
if (!isUpdateOperation) {
|
|
3800
|
-
|
|
3941
|
+
_context49.next = 60;
|
|
3801
3942
|
break;
|
|
3802
3943
|
}
|
|
3803
3944
|
// 更新操作:使用现有的订单ID
|
|
3804
3945
|
realOrderId = currentOrderId;
|
|
3805
3946
|
console.log("[Checkout] \u8BA2\u5355\u66F4\u65B0\u6210\u529F\uFF0C\u8BA2\u5355ID: ".concat(realOrderId));
|
|
3806
|
-
|
|
3947
|
+
_context49.next = 81;
|
|
3807
3948
|
break;
|
|
3808
|
-
case
|
|
3949
|
+
case 60:
|
|
3809
3950
|
// 创建操作:从响应中提取新的订单ID
|
|
3810
|
-
extractedOrderId = (
|
|
3951
|
+
extractedOrderId = (_checkoutResponse12 = checkoutResponse) === null || _checkoutResponse12 === void 0 || (_checkoutResponse12 = _checkoutResponse12.data) === null || _checkoutResponse12 === void 0 ? void 0 : _checkoutResponse12.order_id; // 如果data.order_id不存在,尝试直接从根级获取
|
|
3811
3952
|
if (!extractedOrderId) {
|
|
3812
|
-
extractedOrderId = (
|
|
3953
|
+
extractedOrderId = (_checkoutResponse13 = checkoutResponse) === null || _checkoutResponse13 === void 0 ? void 0 : _checkoutResponse13.order_id;
|
|
3813
3954
|
}
|
|
3814
3955
|
|
|
3815
3956
|
// 确保转换为字符串类型
|
|
@@ -3817,11 +3958,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3817
3958
|
extractedOrderId = String(extractedOrderId);
|
|
3818
3959
|
}
|
|
3819
3960
|
if (extractedOrderId) {
|
|
3820
|
-
|
|
3961
|
+
_context49.next = 65;
|
|
3821
3962
|
break;
|
|
3822
3963
|
}
|
|
3823
3964
|
throw new Error('后端返回的订单信息中未包含订单ID');
|
|
3824
|
-
case
|
|
3965
|
+
case 65:
|
|
3825
3966
|
realOrderId = extractedOrderId;
|
|
3826
3967
|
console.log('[Checkout] 订单创建成功,真实订单ID:', realOrderId);
|
|
3827
3968
|
|
|
@@ -3831,11 +3972,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3831
3972
|
oldOrderId: this.store.currentOrder.order_id,
|
|
3832
3973
|
newOrderId: realOrderId
|
|
3833
3974
|
});
|
|
3834
|
-
|
|
3835
|
-
|
|
3975
|
+
_context49.prev = 68;
|
|
3976
|
+
_context49.next = 71;
|
|
3836
3977
|
return this.payment.replaceOrderIdByUuidAsync(this.store.currentOrder.uuid, realOrderId);
|
|
3837
|
-
case
|
|
3838
|
-
updatedOrder =
|
|
3978
|
+
case 71:
|
|
3979
|
+
updatedOrder = _context49.sent;
|
|
3839
3980
|
console.log('[Checkout] Payment模块替换订单ID结果:', {
|
|
3840
3981
|
wasSuccessful: !!updatedOrder,
|
|
3841
3982
|
returnedOrderId: updatedOrder === null || updatedOrder === void 0 ? void 0 : updatedOrder.order_id,
|
|
@@ -3861,22 +4002,22 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3861
4002
|
目标ID: realOrderId
|
|
3862
4003
|
});
|
|
3863
4004
|
}
|
|
3864
|
-
|
|
4005
|
+
_context49.next = 81;
|
|
3865
4006
|
break;
|
|
3866
|
-
case
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
console.error('[Checkout] 调用Payment模块替换订单ID时发生错误:',
|
|
4007
|
+
case 76:
|
|
4008
|
+
_context49.prev = 76;
|
|
4009
|
+
_context49.t2 = _context49["catch"](68);
|
|
4010
|
+
console.error('[Checkout] 调用Payment模块替换订单ID时发生错误:', _context49.t2);
|
|
3870
4011
|
|
|
3871
4012
|
// 发生错误时也进行手动替换
|
|
3872
4013
|
this.store.currentOrder.order_id = realOrderId;
|
|
3873
4014
|
console.log('[Checkout] 错误恢复:手动设置订单ID:', realOrderId);
|
|
3874
|
-
case
|
|
4015
|
+
case 81:
|
|
3875
4016
|
// 标记订单已同步
|
|
3876
4017
|
this.store.isOrderSynced = true;
|
|
3877
4018
|
|
|
3878
4019
|
// 触发订单同步完成事件
|
|
3879
|
-
|
|
4020
|
+
_context49.next = 84;
|
|
3880
4021
|
return this.core.effects.emit(CheckoutHooks.OnOrderSynced, {
|
|
3881
4022
|
orderUuid: this.store.currentOrder.uuid,
|
|
3882
4023
|
realOrderId: realOrderId,
|
|
@@ -3885,7 +4026,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3885
4026
|
isManual: isManual,
|
|
3886
4027
|
response: checkoutResponse
|
|
3887
4028
|
});
|
|
3888
|
-
case
|
|
4029
|
+
case 84:
|
|
3889
4030
|
// 验证最终状态
|
|
3890
4031
|
finalOrderId = this.store.currentOrder.order_id;
|
|
3891
4032
|
finalIsVirtual = this.isVirtualOrderId(finalOrderId || '');
|
|
@@ -3902,12 +4043,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3902
4043
|
}
|
|
3903
4044
|
|
|
3904
4045
|
// 返回真实订单ID
|
|
3905
|
-
return
|
|
3906
|
-
case
|
|
4046
|
+
return _context49.abrupt("return", realOrderId);
|
|
4047
|
+
case 89:
|
|
3907
4048
|
case "end":
|
|
3908
|
-
return
|
|
4049
|
+
return _context49.stop();
|
|
3909
4050
|
}
|
|
3910
|
-
},
|
|
4051
|
+
}, _callee49, this, [[26, 34, 41, 45], [68, 76]]);
|
|
3911
4052
|
}));
|
|
3912
4053
|
function syncOrderToBackendWithReturn() {
|
|
3913
4054
|
return _syncOrderToBackendWithReturn.apply(this, arguments);
|
|
@@ -3917,27 +4058,27 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3917
4058
|
}, {
|
|
3918
4059
|
key: "syncOrderToBackend",
|
|
3919
4060
|
value: function () {
|
|
3920
|
-
var _syncOrderToBackend = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3921
|
-
return _regeneratorRuntime().wrap(function
|
|
3922
|
-
while (1) switch (
|
|
4061
|
+
var _syncOrderToBackend = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50() {
|
|
4062
|
+
return _regeneratorRuntime().wrap(function _callee50$(_context50) {
|
|
4063
|
+
while (1) switch (_context50.prev = _context50.next) {
|
|
3923
4064
|
case 0:
|
|
3924
|
-
|
|
3925
|
-
|
|
4065
|
+
_context50.prev = 0;
|
|
4066
|
+
_context50.next = 3;
|
|
3926
4067
|
return this.syncOrderToBackendWithReturn(false);
|
|
3927
4068
|
case 3:
|
|
3928
|
-
|
|
4069
|
+
_context50.next = 10;
|
|
3929
4070
|
break;
|
|
3930
4071
|
case 5:
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
console.error('[Checkout] 同步订单到后端失败:',
|
|
3934
|
-
|
|
3935
|
-
return this.handleError(new Error("\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(
|
|
4072
|
+
_context50.prev = 5;
|
|
4073
|
+
_context50.t0 = _context50["catch"](0);
|
|
4074
|
+
console.error('[Checkout] 同步订单到后端失败:', _context50.t0);
|
|
4075
|
+
_context50.next = 10;
|
|
4076
|
+
return this.handleError(new Error("\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(_context50.t0 instanceof Error ? _context50.t0.message : String(_context50.t0))), CheckoutErrorType.OrderCreationFailed);
|
|
3936
4077
|
case 10:
|
|
3937
4078
|
case "end":
|
|
3938
|
-
return
|
|
4079
|
+
return _context50.stop();
|
|
3939
4080
|
}
|
|
3940
|
-
},
|
|
4081
|
+
}, _callee50, this, [[0, 5]]);
|
|
3941
4082
|
}));
|
|
3942
4083
|
function syncOrderToBackend() {
|
|
3943
4084
|
return _syncOrderToBackend.apply(this, arguments);
|
|
@@ -3977,15 +4118,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3977
4118
|
}, {
|
|
3978
4119
|
key: "setOtherParams",
|
|
3979
4120
|
value: function () {
|
|
3980
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4121
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
|
|
3981
4122
|
var _ref5,
|
|
3982
4123
|
_ref5$cover,
|
|
3983
4124
|
cover,
|
|
3984
|
-
|
|
3985
|
-
return _regeneratorRuntime().wrap(function
|
|
3986
|
-
while (1) switch (
|
|
4125
|
+
_args51 = arguments;
|
|
4126
|
+
return _regeneratorRuntime().wrap(function _callee51$(_context51) {
|
|
4127
|
+
while (1) switch (_context51.prev = _context51.next) {
|
|
3987
4128
|
case 0:
|
|
3988
|
-
_ref5 =
|
|
4129
|
+
_ref5 = _args51.length > 1 && _args51[1] !== undefined ? _args51[1] : {}, _ref5$cover = _ref5.cover, cover = _ref5$cover === void 0 ? false : _ref5$cover;
|
|
3989
4130
|
if (cover) {
|
|
3990
4131
|
this.otherParams = params;
|
|
3991
4132
|
} else {
|
|
@@ -3993,9 +4134,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3993
4134
|
}
|
|
3994
4135
|
case 2:
|
|
3995
4136
|
case "end":
|
|
3996
|
-
return
|
|
4137
|
+
return _context51.stop();
|
|
3997
4138
|
}
|
|
3998
|
-
},
|
|
4139
|
+
}, _callee51, this);
|
|
3999
4140
|
}));
|
|
4000
4141
|
function setOtherParams(_x32) {
|
|
4001
4142
|
return _setOtherParams.apply(this, arguments);
|
|
@@ -4014,12 +4155,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4014
4155
|
}, {
|
|
4015
4156
|
key: "editOrderNoteByOrderIdAsync",
|
|
4016
4157
|
value: (function () {
|
|
4017
|
-
var _editOrderNoteByOrderIdAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4158
|
+
var _editOrderNoteByOrderIdAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(orderId, note) {
|
|
4018
4159
|
var response, previousNote, errorMessage, _errorMessage;
|
|
4019
|
-
return _regeneratorRuntime().wrap(function
|
|
4020
|
-
while (1) switch (
|
|
4160
|
+
return _regeneratorRuntime().wrap(function _callee52$(_context52) {
|
|
4161
|
+
while (1) switch (_context52.prev = _context52.next) {
|
|
4021
4162
|
case 0:
|
|
4022
|
-
|
|
4163
|
+
_context52.prev = 0;
|
|
4023
4164
|
console.log('[Checkout] 开始编辑订单备注:', {
|
|
4024
4165
|
orderId: orderId,
|
|
4025
4166
|
note: note,
|
|
@@ -4028,21 +4169,21 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4028
4169
|
|
|
4029
4170
|
// 参数验证
|
|
4030
4171
|
if (orderId) {
|
|
4031
|
-
|
|
4172
|
+
_context52.next = 4;
|
|
4032
4173
|
break;
|
|
4033
4174
|
}
|
|
4034
|
-
return
|
|
4175
|
+
return _context52.abrupt("return", {
|
|
4035
4176
|
success: false,
|
|
4036
4177
|
message: '订单ID不能为空',
|
|
4037
4178
|
orderId: orderId
|
|
4038
4179
|
});
|
|
4039
4180
|
case 4:
|
|
4040
|
-
|
|
4181
|
+
_context52.next = 6;
|
|
4041
4182
|
return this.request.put("/order/order/".concat(orderId, "/note"), {
|
|
4042
4183
|
note: note
|
|
4043
4184
|
});
|
|
4044
4185
|
case 6:
|
|
4045
|
-
response =
|
|
4186
|
+
response = _context52.sent;
|
|
4046
4187
|
console.log('[Checkout] 订单备注编辑响应:', {
|
|
4047
4188
|
orderId: orderId,
|
|
4048
4189
|
status: response.status,
|
|
@@ -4052,14 +4193,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4052
4193
|
|
|
4053
4194
|
// 检查响应状态
|
|
4054
4195
|
if (!(response.status === true || response.status === 200)) {
|
|
4055
|
-
|
|
4196
|
+
_context52.next = 19;
|
|
4056
4197
|
break;
|
|
4057
4198
|
}
|
|
4058
4199
|
console.log("[Checkout] \u8BA2\u5355 ".concat(orderId, " \u5907\u6CE8\u4FEE\u6539\u6210\u529F"));
|
|
4059
4200
|
|
|
4060
4201
|
// 如果当前订单就是被修改的订单,同时更新本地状态
|
|
4061
4202
|
if (!(this.store.currentOrder && (String(this.store.currentOrder.order_id) === String(orderId) || String(this.store.currentOrder.id) === String(orderId)))) {
|
|
4062
|
-
|
|
4203
|
+
_context52.next = 16;
|
|
4063
4204
|
break;
|
|
4064
4205
|
}
|
|
4065
4206
|
console.log('[Checkout] 更新本地订单备注状态');
|
|
@@ -4071,7 +4212,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4071
4212
|
}
|
|
4072
4213
|
|
|
4073
4214
|
// 触发订单备注变更事件
|
|
4074
|
-
|
|
4215
|
+
_context52.next = 16;
|
|
4075
4216
|
return this.core.effects.emit(CheckoutHooks.OnOrderNoteChanged, {
|
|
4076
4217
|
orderUuid: this.store.currentOrder.uuid,
|
|
4077
4218
|
oldNote: previousNote,
|
|
@@ -4079,7 +4220,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4079
4220
|
timestamp: Date.now()
|
|
4080
4221
|
});
|
|
4081
4222
|
case 16:
|
|
4082
|
-
return
|
|
4223
|
+
return _context52.abrupt("return", {
|
|
4083
4224
|
success: true,
|
|
4084
4225
|
message: response.message || '订单备注修改成功',
|
|
4085
4226
|
orderId: orderId
|
|
@@ -4088,29 +4229,29 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4088
4229
|
// API返回失败状态
|
|
4089
4230
|
errorMessage = response.message || '订单备注修改失败';
|
|
4090
4231
|
console.error("[Checkout] \u8BA2\u5355 ".concat(orderId, " \u5907\u6CE8\u4FEE\u6539\u5931\u8D25:"), errorMessage);
|
|
4091
|
-
return
|
|
4232
|
+
return _context52.abrupt("return", {
|
|
4092
4233
|
success: false,
|
|
4093
4234
|
message: errorMessage,
|
|
4094
4235
|
orderId: orderId
|
|
4095
4236
|
});
|
|
4096
4237
|
case 22:
|
|
4097
|
-
|
|
4238
|
+
_context52.next = 29;
|
|
4098
4239
|
break;
|
|
4099
4240
|
case 24:
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
console.error('[Checkout] 编辑订单备注失败:',
|
|
4103
|
-
_errorMessage =
|
|
4104
|
-
return
|
|
4241
|
+
_context52.prev = 24;
|
|
4242
|
+
_context52.t0 = _context52["catch"](0);
|
|
4243
|
+
console.error('[Checkout] 编辑订单备注失败:', _context52.t0);
|
|
4244
|
+
_errorMessage = _context52.t0 instanceof Error ? _context52.t0.message : '网络错误或服务器异常';
|
|
4245
|
+
return _context52.abrupt("return", {
|
|
4105
4246
|
success: false,
|
|
4106
4247
|
message: "\u7F16\u8F91\u8BA2\u5355\u5907\u6CE8\u5931\u8D25: ".concat(_errorMessage),
|
|
4107
4248
|
orderId: orderId
|
|
4108
4249
|
});
|
|
4109
4250
|
case 29:
|
|
4110
4251
|
case "end":
|
|
4111
|
-
return
|
|
4252
|
+
return _context52.stop();
|
|
4112
4253
|
}
|
|
4113
|
-
},
|
|
4254
|
+
}, _callee52, this, [[0, 24]]);
|
|
4114
4255
|
}));
|
|
4115
4256
|
function editOrderNoteByOrderIdAsync(_x33, _x34) {
|
|
4116
4257
|
return _editOrderNoteByOrderIdAsync.apply(this, arguments);
|
|
@@ -4129,12 +4270,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4129
4270
|
}, {
|
|
4130
4271
|
key: "sendCustomerPayLinkAsync",
|
|
4131
4272
|
value: (function () {
|
|
4132
|
-
var _sendCustomerPayLinkAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4273
|
+
var _sendCustomerPayLinkAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(params) {
|
|
4133
4274
|
var emailRegex, invalidEmails, requestBody, response, errorMessage, _errorMessage2;
|
|
4134
|
-
return _regeneratorRuntime().wrap(function
|
|
4135
|
-
while (1) switch (
|
|
4275
|
+
return _regeneratorRuntime().wrap(function _callee53$(_context53) {
|
|
4276
|
+
while (1) switch (_context53.prev = _context53.next) {
|
|
4136
4277
|
case 0:
|
|
4137
|
-
|
|
4278
|
+
_context53.prev = 0;
|
|
4138
4279
|
console.log('[Checkout] 开始发送客户支付链接邮件:', {
|
|
4139
4280
|
orderIds: params.order_ids,
|
|
4140
4281
|
emails: params.emails,
|
|
@@ -4143,19 +4284,19 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4143
4284
|
|
|
4144
4285
|
// 参数验证
|
|
4145
4286
|
if (!(!params.order_ids || params.order_ids.length === 0)) {
|
|
4146
|
-
|
|
4287
|
+
_context53.next = 4;
|
|
4147
4288
|
break;
|
|
4148
4289
|
}
|
|
4149
|
-
return
|
|
4290
|
+
return _context53.abrupt("return", {
|
|
4150
4291
|
success: false,
|
|
4151
4292
|
message: '订单ID列表不能为空'
|
|
4152
4293
|
});
|
|
4153
4294
|
case 4:
|
|
4154
4295
|
if (!(!params.emails || params.emails.length === 0)) {
|
|
4155
|
-
|
|
4296
|
+
_context53.next = 6;
|
|
4156
4297
|
break;
|
|
4157
4298
|
}
|
|
4158
|
-
return
|
|
4299
|
+
return _context53.abrupt("return", {
|
|
4159
4300
|
success: false,
|
|
4160
4301
|
message: '邮箱地址列表不能为空'
|
|
4161
4302
|
});
|
|
@@ -4166,10 +4307,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4166
4307
|
return !emailRegex.test(email);
|
|
4167
4308
|
});
|
|
4168
4309
|
if (!(invalidEmails.length > 0)) {
|
|
4169
|
-
|
|
4310
|
+
_context53.next = 10;
|
|
4170
4311
|
break;
|
|
4171
4312
|
}
|
|
4172
|
-
return
|
|
4313
|
+
return _context53.abrupt("return", {
|
|
4173
4314
|
success: false,
|
|
4174
4315
|
message: "\u90AE\u7BB1\u683C\u5F0F\u65E0\u6548: ".concat(invalidEmails.join(', '))
|
|
4175
4316
|
});
|
|
@@ -4183,10 +4324,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4183
4324
|
console.log('[Checkout] 发送支付链接邮件请求参数:', requestBody);
|
|
4184
4325
|
|
|
4185
4326
|
// 调用后端API发送邮件
|
|
4186
|
-
|
|
4327
|
+
_context53.next = 14;
|
|
4187
4328
|
return this.request.post('/order/batch-email', requestBody);
|
|
4188
4329
|
case 14:
|
|
4189
|
-
response =
|
|
4330
|
+
response = _context53.sent;
|
|
4190
4331
|
console.log('[Checkout] 支付链接邮件发送响应:', {
|
|
4191
4332
|
status: response.status,
|
|
4192
4333
|
message: response.message,
|
|
@@ -4196,11 +4337,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4196
4337
|
|
|
4197
4338
|
// 检查响应状态
|
|
4198
4339
|
if (!(response.status === true || response.status === 200)) {
|
|
4199
|
-
|
|
4340
|
+
_context53.next = 21;
|
|
4200
4341
|
break;
|
|
4201
4342
|
}
|
|
4202
4343
|
console.log('[Checkout] 支付链接邮件发送成功');
|
|
4203
|
-
return
|
|
4344
|
+
return _context53.abrupt("return", {
|
|
4204
4345
|
success: true,
|
|
4205
4346
|
message: response.message || '支付链接邮件发送成功'
|
|
4206
4347
|
});
|
|
@@ -4208,27 +4349,27 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4208
4349
|
// API返回失败状态
|
|
4209
4350
|
errorMessage = response.message || '支付链接邮件发送失败';
|
|
4210
4351
|
console.error('[Checkout] 支付链接邮件发送失败:', errorMessage);
|
|
4211
|
-
return
|
|
4352
|
+
return _context53.abrupt("return", {
|
|
4212
4353
|
success: false,
|
|
4213
4354
|
message: errorMessage
|
|
4214
4355
|
});
|
|
4215
4356
|
case 24:
|
|
4216
|
-
|
|
4357
|
+
_context53.next = 31;
|
|
4217
4358
|
break;
|
|
4218
4359
|
case 26:
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
console.error('[Checkout] 发送客户支付链接邮件失败:',
|
|
4222
|
-
_errorMessage2 =
|
|
4223
|
-
return
|
|
4360
|
+
_context53.prev = 26;
|
|
4361
|
+
_context53.t0 = _context53["catch"](0);
|
|
4362
|
+
console.error('[Checkout] 发送客户支付链接邮件失败:', _context53.t0);
|
|
4363
|
+
_errorMessage2 = _context53.t0 instanceof Error ? _context53.t0.message : '网络错误或服务器异常';
|
|
4364
|
+
return _context53.abrupt("return", {
|
|
4224
4365
|
success: false,
|
|
4225
4366
|
message: "\u53D1\u9001\u652F\u4ED8\u94FE\u63A5\u90AE\u4EF6\u5931\u8D25: ".concat(_errorMessage2)
|
|
4226
4367
|
});
|
|
4227
4368
|
case 31:
|
|
4228
4369
|
case "end":
|
|
4229
|
-
return
|
|
4370
|
+
return _context53.stop();
|
|
4230
4371
|
}
|
|
4231
|
-
},
|
|
4372
|
+
}, _callee53, this, [[0, 26]]);
|
|
4232
4373
|
}));
|
|
4233
4374
|
function sendCustomerPayLinkAsync(_x35) {
|
|
4234
4375
|
return _sendCustomerPayLinkAsync.apply(this, arguments);
|
|
@@ -4245,23 +4386,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4245
4386
|
}, {
|
|
4246
4387
|
key: "roundAmountAsync",
|
|
4247
4388
|
value: (function () {
|
|
4248
|
-
var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4389
|
+
var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(amount) {
|
|
4249
4390
|
var _this$otherParams$ord, _this$otherParams$ord2;
|
|
4250
4391
|
var result;
|
|
4251
|
-
return _regeneratorRuntime().wrap(function
|
|
4252
|
-
while (1) switch (
|
|
4392
|
+
return _regeneratorRuntime().wrap(function _callee54$(_context54) {
|
|
4393
|
+
while (1) switch (_context54.prev = _context54.next) {
|
|
4253
4394
|
case 0:
|
|
4254
|
-
|
|
4395
|
+
_context54.next = 2;
|
|
4255
4396
|
return this.payment.roundAmountAsync(amount, (_this$otherParams$ord = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord === void 0 ? void 0 : _this$otherParams$ord.interval, (_this$otherParams$ord2 = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord2 === void 0 ? void 0 : _this$otherParams$ord2.type);
|
|
4256
4397
|
case 2:
|
|
4257
|
-
result =
|
|
4398
|
+
result = _context54.sent;
|
|
4258
4399
|
console.log("[Checkout] \u91D1\u989D\u820D\u5165\u5B8C\u6210 - \u539F\u59CB: ".concat(result.originalAmount, ", \u820D\u5165\u540E: ").concat(result.roundedAmount, ", \u5DEE\u989D: ").concat(result.roundingDifference));
|
|
4259
|
-
return
|
|
4400
|
+
return _context54.abrupt("return", result);
|
|
4260
4401
|
case 5:
|
|
4261
4402
|
case "end":
|
|
4262
|
-
return
|
|
4403
|
+
return _context54.stop();
|
|
4263
4404
|
}
|
|
4264
|
-
},
|
|
4405
|
+
}, _callee54, this);
|
|
4265
4406
|
}));
|
|
4266
4407
|
function roundAmountAsync(_x36) {
|
|
4267
4408
|
return _roundAmountAsync.apply(this, arguments);
|
|
@@ -4271,10 +4412,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4271
4412
|
}, {
|
|
4272
4413
|
key: "destroy",
|
|
4273
4414
|
value: function () {
|
|
4274
|
-
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4415
|
+
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55() {
|
|
4275
4416
|
var _this$order, _this$order$destroy, _this$payment, _this$payment$destroy;
|
|
4276
|
-
return _regeneratorRuntime().wrap(function
|
|
4277
|
-
while (1) switch (
|
|
4417
|
+
return _regeneratorRuntime().wrap(function _callee55$(_context55) {
|
|
4418
|
+
while (1) switch (_context55.prev = _context55.next) {
|
|
4278
4419
|
case 0:
|
|
4279
4420
|
// 清理钱包模块的所有缓存数据
|
|
4280
4421
|
this.payment.wallet.clearAllCache();
|
|
@@ -4283,10 +4424,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4283
4424
|
this.core.effects.offByModuleDestroy(this.name);
|
|
4284
4425
|
|
|
4285
4426
|
// 销毁子模块
|
|
4286
|
-
|
|
4427
|
+
_context55.next = 4;
|
|
4287
4428
|
return (_this$order = this.order) === null || _this$order === void 0 || (_this$order$destroy = _this$order.destroy) === null || _this$order$destroy === void 0 ? void 0 : _this$order$destroy.call(_this$order);
|
|
4288
4429
|
case 4:
|
|
4289
|
-
|
|
4430
|
+
_context55.next = 6;
|
|
4290
4431
|
return (_this$payment = this.payment) === null || _this$payment === void 0 || (_this$payment$destroy = _this$payment.destroy) === null || _this$payment$destroy === void 0 ? void 0 : _this$payment$destroy.call(_this$payment);
|
|
4291
4432
|
case 6:
|
|
4292
4433
|
// 取消注册模块
|
|
@@ -4294,9 +4435,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4294
4435
|
console.log('[Checkout] 已销毁');
|
|
4295
4436
|
case 8:
|
|
4296
4437
|
case "end":
|
|
4297
|
-
return
|
|
4438
|
+
return _context55.stop();
|
|
4298
4439
|
}
|
|
4299
|
-
},
|
|
4440
|
+
}, _callee55, this);
|
|
4300
4441
|
}));
|
|
4301
4442
|
function destroy() {
|
|
4302
4443
|
return _destroy.apply(this, arguments);
|
|
@@ -4311,12 +4452,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4311
4452
|
}, {
|
|
4312
4453
|
key: "resetStoreStateAsync",
|
|
4313
4454
|
value: (function () {
|
|
4314
|
-
var _resetStoreStateAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4455
|
+
var _resetStoreStateAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56() {
|
|
4315
4456
|
var prevOrderInfo;
|
|
4316
|
-
return _regeneratorRuntime().wrap(function
|
|
4317
|
-
while (1) switch (
|
|
4457
|
+
return _regeneratorRuntime().wrap(function _callee56$(_context56) {
|
|
4458
|
+
while (1) switch (_context56.prev = _context56.next) {
|
|
4318
4459
|
case 0:
|
|
4319
|
-
|
|
4460
|
+
_context56.prev = 0;
|
|
4320
4461
|
prevOrderInfo = this.store.currentOrder ? {
|
|
4321
4462
|
uuid: this.store.currentOrder.uuid,
|
|
4322
4463
|
orderId: this.store.currentOrder.order_id
|
|
@@ -4328,6 +4469,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4328
4469
|
this.store.localOrderData = undefined;
|
|
4329
4470
|
this.store.cartSummary = undefined;
|
|
4330
4471
|
this.store.stateAmount = '0.00';
|
|
4472
|
+
this.store.balanceDueAmount = '0.00';
|
|
4331
4473
|
this.store.isOrderSynced = false;
|
|
4332
4474
|
this.store.currentCustomer = undefined;
|
|
4333
4475
|
this.store.lastError = undefined;
|
|
@@ -4341,36 +4483,36 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4341
4483
|
// 注意:故意保留 this.store.paymentMethods,因为支付方式数据不易变更,保留在内存中提高性能
|
|
4342
4484
|
|
|
4343
4485
|
// 重置状态和步骤为初始状态
|
|
4344
|
-
|
|
4486
|
+
_context56.next = 15;
|
|
4345
4487
|
return this.setStatus(CheckoutStatus.Ready);
|
|
4346
|
-
case
|
|
4347
|
-
|
|
4488
|
+
case 15:
|
|
4489
|
+
_context56.next = 17;
|
|
4348
4490
|
return this.setStep(CheckoutStep.OrderConfirmation);
|
|
4349
|
-
case
|
|
4491
|
+
case 17:
|
|
4350
4492
|
console.log('[Checkout] Store 状态重置完成');
|
|
4351
4493
|
|
|
4352
4494
|
// 触发订单清理事件(如果之前有订单)
|
|
4353
4495
|
if (!prevOrderInfo) {
|
|
4354
|
-
|
|
4496
|
+
_context56.next = 21;
|
|
4355
4497
|
break;
|
|
4356
4498
|
}
|
|
4357
|
-
|
|
4499
|
+
_context56.next = 21;
|
|
4358
4500
|
return this.core.effects.emit(CheckoutHooks.OnOrderCleared, {
|
|
4359
4501
|
previousOrder: prevOrderInfo,
|
|
4360
4502
|
timestamp: Date.now()
|
|
4361
4503
|
});
|
|
4362
|
-
case
|
|
4363
|
-
|
|
4504
|
+
case 21:
|
|
4505
|
+
_context56.next = 26;
|
|
4364
4506
|
break;
|
|
4365
|
-
case
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
console.error('[Checkout] 重置 store 状态失败:',
|
|
4369
|
-
case
|
|
4507
|
+
case 23:
|
|
4508
|
+
_context56.prev = 23;
|
|
4509
|
+
_context56.t0 = _context56["catch"](0);
|
|
4510
|
+
console.error('[Checkout] 重置 store 状态失败:', _context56.t0);
|
|
4511
|
+
case 26:
|
|
4370
4512
|
case "end":
|
|
4371
|
-
return
|
|
4513
|
+
return _context56.stop();
|
|
4372
4514
|
}
|
|
4373
|
-
},
|
|
4515
|
+
}, _callee56, this, [[0, 23]]);
|
|
4374
4516
|
}));
|
|
4375
4517
|
function resetStoreStateAsync() {
|
|
4376
4518
|
return _resetStoreStateAsync.apply(this, arguments);
|
|
@@ -4388,37 +4530,37 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4388
4530
|
}, {
|
|
4389
4531
|
key: "clearCompletedOrderAsync",
|
|
4390
4532
|
value: (function () {
|
|
4391
|
-
var _clearCompletedOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4533
|
+
var _clearCompletedOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57() {
|
|
4392
4534
|
var prevOrderInfo;
|
|
4393
|
-
return _regeneratorRuntime().wrap(function
|
|
4394
|
-
while (1) switch (
|
|
4535
|
+
return _regeneratorRuntime().wrap(function _callee57$(_context57) {
|
|
4536
|
+
while (1) switch (_context57.prev = _context57.next) {
|
|
4395
4537
|
case 0:
|
|
4396
|
-
|
|
4538
|
+
_context57.prev = 0;
|
|
4397
4539
|
prevOrderInfo = this.store.currentOrder ? {
|
|
4398
4540
|
uuid: this.store.currentOrder.uuid,
|
|
4399
4541
|
orderId: this.store.currentOrder.order_id
|
|
4400
4542
|
} : null;
|
|
4401
|
-
|
|
4543
|
+
_context57.next = 4;
|
|
4402
4544
|
return this.resetStoreStateAsync();
|
|
4403
4545
|
case 4:
|
|
4404
|
-
return
|
|
4546
|
+
return _context57.abrupt("return", {
|
|
4405
4547
|
success: true,
|
|
4406
4548
|
message: prevOrderInfo ? '订单状态已成功清理' : '没有需要清理的订单状态',
|
|
4407
4549
|
clearedOrder: prevOrderInfo
|
|
4408
4550
|
});
|
|
4409
4551
|
case 7:
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
console.error('[Checkout] 手动清理订单状态失败:',
|
|
4413
|
-
return
|
|
4552
|
+
_context57.prev = 7;
|
|
4553
|
+
_context57.t0 = _context57["catch"](0);
|
|
4554
|
+
console.error('[Checkout] 手动清理订单状态失败:', _context57.t0);
|
|
4555
|
+
return _context57.abrupt("return", {
|
|
4414
4556
|
success: false,
|
|
4415
|
-
message:
|
|
4557
|
+
message: _context57.t0 instanceof Error ? _context57.t0.message : '清理失败'
|
|
4416
4558
|
});
|
|
4417
4559
|
case 11:
|
|
4418
4560
|
case "end":
|
|
4419
|
-
return
|
|
4561
|
+
return _context57.stop();
|
|
4420
4562
|
}
|
|
4421
|
-
},
|
|
4563
|
+
}, _callee57, this, [[0, 7]]);
|
|
4422
4564
|
}));
|
|
4423
4565
|
function clearCompletedOrderAsync() {
|
|
4424
4566
|
return _clearCompletedOrderAsync.apply(this, arguments);
|