@pisell/pisellos 0.0.244 → 0.0.245
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.
|
@@ -270,41 +270,39 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
270
270
|
_context7.next = 3;
|
|
271
271
|
return this.setStatus(CheckoutStatus.Initializing);
|
|
272
272
|
case 3:
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
case 5:
|
|
276
|
-
validation = _context7.sent;
|
|
273
|
+
// 验证参数
|
|
274
|
+
validation = this.validateCheckoutParams(params);
|
|
277
275
|
if (validation.valid) {
|
|
278
|
-
_context7.next =
|
|
276
|
+
_context7.next = 6;
|
|
279
277
|
break;
|
|
280
278
|
}
|
|
281
279
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, "\u53C2\u6570\u9A8C\u8BC1\u5931\u8D25: ".concat(validation.errors.join(', ')));
|
|
282
|
-
case
|
|
280
|
+
case 6:
|
|
283
281
|
// 保存购物车数据
|
|
284
282
|
this.store.cartItems = params.cartItems;
|
|
285
283
|
|
|
286
284
|
// 设置为就绪状态
|
|
287
|
-
_context7.next =
|
|
285
|
+
_context7.next = 9;
|
|
288
286
|
return this.setStatus(CheckoutStatus.Ready);
|
|
289
|
-
case
|
|
290
|
-
_context7.next =
|
|
287
|
+
case 9:
|
|
288
|
+
_context7.next = 11;
|
|
291
289
|
return this.setStep(CheckoutStep.OrderConfirmation);
|
|
292
|
-
case
|
|
290
|
+
case 11:
|
|
293
291
|
console.log('[Checkout] 结账流程初始化完成');
|
|
294
|
-
_context7.next =
|
|
292
|
+
_context7.next = 19;
|
|
295
293
|
break;
|
|
296
|
-
case
|
|
297
|
-
_context7.prev =
|
|
294
|
+
case 14:
|
|
295
|
+
_context7.prev = 14;
|
|
298
296
|
_context7.t0 = _context7["catch"](0);
|
|
299
|
-
_context7.next =
|
|
297
|
+
_context7.next = 18;
|
|
300
298
|
return this.handleError(_context7.t0, CheckoutErrorType.UnknownError);
|
|
301
|
-
case
|
|
299
|
+
case 18:
|
|
302
300
|
throw _context7.t0;
|
|
303
|
-
case
|
|
301
|
+
case 19:
|
|
304
302
|
case "end":
|
|
305
303
|
return _context7.stop();
|
|
306
304
|
}
|
|
307
|
-
}, _callee7, this, [[0,
|
|
305
|
+
}, _callee7, this, [[0, 14]]);
|
|
308
306
|
}));
|
|
309
307
|
function initializeCheckoutAsync(_x9) {
|
|
310
308
|
return _initializeCheckoutAsync.apply(this, arguments);
|
|
@@ -401,16 +399,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
401
399
|
_context9.next = 5;
|
|
402
400
|
return this.setStatus(CheckoutStatus.CreatingOrder);
|
|
403
401
|
case 5:
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
case 7:
|
|
407
|
-
validation = _context9.sent;
|
|
402
|
+
// 验证订单数据
|
|
403
|
+
validation = this.validateLocalOrderData(params.orderData);
|
|
408
404
|
if (validation.valid) {
|
|
409
|
-
_context9.next =
|
|
405
|
+
_context9.next = 8;
|
|
410
406
|
break;
|
|
411
407
|
}
|
|
412
408
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, "\u8BA2\u5355\u6570\u636E\u9A8C\u8BC1\u5931\u8D25: ".concat(validation.errors.join(', ')));
|
|
413
|
-
case
|
|
409
|
+
case 8:
|
|
414
410
|
// 生成本地虚拟订单ID (后续可以被真实订单ID替换)
|
|
415
411
|
localOrderId = this.generateLocalOrderId(); // 从购物车小计数据中提取金额信息
|
|
416
412
|
amountInfo = this.extractAmountFromCartSummary(params.cartSummary); // TODO: 外面传的是 pos ,但是现在 后端只有 shop 和 kiosk
|
|
@@ -441,7 +437,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
441
437
|
}
|
|
442
438
|
|
|
443
439
|
// 创建支付订单对象
|
|
444
|
-
_context9.next =
|
|
440
|
+
_context9.next = 21;
|
|
445
441
|
return this.payment.createPaymentOrderAsync({
|
|
446
442
|
order_id: localOrderId,
|
|
447
443
|
total_amount: amountInfo.totalAmount,
|
|
@@ -458,34 +454,32 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
458
454
|
amount_breakdown: amountInfo
|
|
459
455
|
}
|
|
460
456
|
});
|
|
461
|
-
case
|
|
457
|
+
case 21:
|
|
462
458
|
paymentOrder = _context9.sent;
|
|
463
459
|
this.store.currentOrder = paymentOrder;
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
case 27:
|
|
467
|
-
_context9.next = 29;
|
|
460
|
+
this.initWalletData();
|
|
461
|
+
_context9.next = 26;
|
|
468
462
|
return this.setStatus(CheckoutStatus.OrderCreated);
|
|
469
|
-
case
|
|
470
|
-
_context9.next =
|
|
463
|
+
case 26:
|
|
464
|
+
_context9.next = 28;
|
|
471
465
|
return this.setStep(CheckoutStep.PaymentMethod);
|
|
472
|
-
case
|
|
466
|
+
case 28:
|
|
473
467
|
if (!params.autoPayment) {
|
|
474
|
-
_context9.next =
|
|
468
|
+
_context9.next = 31;
|
|
475
469
|
break;
|
|
476
470
|
}
|
|
477
|
-
_context9.next =
|
|
471
|
+
_context9.next = 31;
|
|
478
472
|
return this.setStep(CheckoutStep.PaymentProcessing);
|
|
479
|
-
case
|
|
480
|
-
|
|
481
|
-
return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
|
|
473
|
+
case 31:
|
|
474
|
+
this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
|
|
482
475
|
order: paymentOrder,
|
|
483
476
|
timestamp: Date.now()
|
|
484
477
|
});
|
|
485
|
-
|
|
486
|
-
|
|
478
|
+
|
|
479
|
+
// 自动设置 stateAmount 为剩余未支付金额
|
|
480
|
+
_context9.next = 34;
|
|
487
481
|
return this.updateStateAmountToRemaining();
|
|
488
|
-
case
|
|
482
|
+
case 34:
|
|
489
483
|
console.log('[Checkout] 本地订单创建成功:', {
|
|
490
484
|
localOrderId: localOrderId,
|
|
491
485
|
uuid: paymentOrder.uuid,
|
|
@@ -495,24 +489,22 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
495
489
|
stateAmount: this.store.stateAmount
|
|
496
490
|
});
|
|
497
491
|
return _context9.abrupt("return", paymentOrder);
|
|
498
|
-
case
|
|
499
|
-
_context9.prev =
|
|
492
|
+
case 38:
|
|
493
|
+
_context9.prev = 38;
|
|
500
494
|
_context9.t0 = _context9["catch"](0);
|
|
501
|
-
_context9.next =
|
|
495
|
+
_context9.next = 42;
|
|
502
496
|
return this.handleError(_context9.t0, CheckoutErrorType.OrderCreationFailed);
|
|
503
|
-
case
|
|
504
|
-
|
|
505
|
-
return this.core.effects.emit(CheckoutHooks.OnOrderCreationFailed, {
|
|
497
|
+
case 42:
|
|
498
|
+
this.core.effects.emit(CheckoutHooks.OnOrderCreationFailed, {
|
|
506
499
|
error: this.store.lastError,
|
|
507
500
|
timestamp: Date.now()
|
|
508
501
|
});
|
|
509
|
-
case 48:
|
|
510
502
|
throw _context9.t0;
|
|
511
|
-
case
|
|
503
|
+
case 44:
|
|
512
504
|
case "end":
|
|
513
505
|
return _context9.stop();
|
|
514
506
|
}
|
|
515
|
-
}, _callee9, this, [[0,
|
|
507
|
+
}, _callee9, this, [[0, 38]]);
|
|
516
508
|
}));
|
|
517
509
|
function createLocalOrderAsync(_x11) {
|
|
518
510
|
return _createLocalOrderAsync.apply(this, arguments);
|
|
@@ -3029,80 +3021,53 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3029
3021
|
)
|
|
3030
3022
|
}, {
|
|
3031
3023
|
key: "validateCheckoutParams",
|
|
3032
|
-
value:
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
case 0:
|
|
3037
|
-
return _context41.abrupt("return", validateCheckoutData(params));
|
|
3038
|
-
case 1:
|
|
3039
|
-
case "end":
|
|
3040
|
-
return _context41.stop();
|
|
3041
|
-
}
|
|
3042
|
-
}, _callee41);
|
|
3043
|
-
}));
|
|
3044
|
-
function validateCheckoutParams(_x30) {
|
|
3045
|
-
return _validateCheckoutParams.apply(this, arguments);
|
|
3046
|
-
}
|
|
3047
|
-
return validateCheckoutParams;
|
|
3048
|
-
}()
|
|
3024
|
+
value: function validateCheckoutParams(params) {
|
|
3025
|
+
return validateCheckoutData(params);
|
|
3026
|
+
}
|
|
3027
|
+
|
|
3049
3028
|
/**
|
|
3050
3029
|
* 验证本地订单数据
|
|
3051
3030
|
*/
|
|
3052
|
-
)
|
|
3053
3031
|
}, {
|
|
3054
3032
|
key: "validateLocalOrderData",
|
|
3055
|
-
value:
|
|
3056
|
-
var
|
|
3057
|
-
|
|
3058
|
-
var errors;
|
|
3059
|
-
return _regeneratorRuntime().wrap(function _callee42$(_context42) {
|
|
3060
|
-
while (1) switch (_context42.prev = _context42.next) {
|
|
3061
|
-
case 0:
|
|
3062
|
-
errors = []; // 验证基本字段
|
|
3063
|
-
if (!orderData.type) {
|
|
3064
|
-
errors.push('订单类型不能为空');
|
|
3065
|
-
}
|
|
3066
|
-
if (!orderData.platform) {
|
|
3067
|
-
errors.push('平台信息不能为空');
|
|
3068
|
-
}
|
|
3069
|
-
if ((!orderData.bookings || orderData.bookings.length === 0) && !(orderData !== null && orderData !== void 0 && (_orderData$relation_p = orderData.relation_products) !== null && _orderData$relation_p !== void 0 && _orderData$relation_p.length)) {
|
|
3070
|
-
errors.push('预订信息不能为空');
|
|
3071
|
-
}
|
|
3033
|
+
value: function validateLocalOrderData(orderData) {
|
|
3034
|
+
var _orderData$relation_p;
|
|
3035
|
+
var errors = [];
|
|
3072
3036
|
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
errors: errors
|
|
3090
|
-
});
|
|
3091
|
-
case 6:
|
|
3092
|
-
case "end":
|
|
3093
|
-
return _context42.stop();
|
|
3037
|
+
// 验证基本字段
|
|
3038
|
+
if (!orderData.type) {
|
|
3039
|
+
errors.push('订单类型不能为空');
|
|
3040
|
+
}
|
|
3041
|
+
if (!orderData.platform) {
|
|
3042
|
+
errors.push('平台信息不能为空');
|
|
3043
|
+
}
|
|
3044
|
+
if ((!orderData.bookings || orderData.bookings.length === 0) && !(orderData !== null && orderData !== void 0 && (_orderData$relation_p = orderData.relation_products) !== null && _orderData$relation_p !== void 0 && _orderData$relation_p.length)) {
|
|
3045
|
+
errors.push('预订信息不能为空');
|
|
3046
|
+
}
|
|
3047
|
+
|
|
3048
|
+
// 验证预订信息
|
|
3049
|
+
if (orderData.bookings) {
|
|
3050
|
+
orderData.bookings.forEach(function (booking, index) {
|
|
3051
|
+
if (!booking.product || !booking.product.product_id) {
|
|
3052
|
+
errors.push("\u9884\u8BA2\u9879 ".concat(index + 1, " \u7F3A\u5C11\u5546\u54C1\u4FE1\u606F"));
|
|
3094
3053
|
}
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3054
|
+
if (!booking.start_date) {
|
|
3055
|
+
errors.push("\u9884\u8BA2\u9879 ".concat(index + 1, " \u7F3A\u5C11\u5F00\u59CB\u65E5\u671F"));
|
|
3056
|
+
}
|
|
3057
|
+
if (!booking.start_time) {
|
|
3058
|
+
errors.push("\u9884\u8BA2\u9879 ".concat(index + 1, " \u7F3A\u5C11\u5F00\u59CB\u65F6\u95F4"));
|
|
3059
|
+
}
|
|
3060
|
+
});
|
|
3099
3061
|
}
|
|
3100
|
-
return
|
|
3101
|
-
|
|
3062
|
+
return {
|
|
3063
|
+
valid: errors.length === 0,
|
|
3064
|
+
errors: errors
|
|
3065
|
+
};
|
|
3066
|
+
}
|
|
3067
|
+
|
|
3102
3068
|
/**
|
|
3103
3069
|
* 生成本地订单ID
|
|
3104
3070
|
*/
|
|
3105
|
-
)
|
|
3106
3071
|
}, {
|
|
3107
3072
|
key: "generateLocalOrderId",
|
|
3108
3073
|
value: function generateLocalOrderId() {
|
|
@@ -3192,31 +3157,31 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3192
3157
|
}, {
|
|
3193
3158
|
key: "preloadPaymentMethods",
|
|
3194
3159
|
value: (function () {
|
|
3195
|
-
var _preloadPaymentMethods = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3160
|
+
var _preloadPaymentMethods = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41() {
|
|
3196
3161
|
var methods;
|
|
3197
|
-
return _regeneratorRuntime().wrap(function
|
|
3198
|
-
while (1) switch (
|
|
3162
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context41) {
|
|
3163
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
3199
3164
|
case 0:
|
|
3200
|
-
|
|
3165
|
+
_context41.prev = 0;
|
|
3201
3166
|
console.log('[Checkout] 预加载支付方式...');
|
|
3202
|
-
|
|
3167
|
+
_context41.next = 4;
|
|
3203
3168
|
return this.payment.getPayMethodListAsync();
|
|
3204
3169
|
case 4:
|
|
3205
|
-
methods =
|
|
3170
|
+
methods = _context41.sent;
|
|
3206
3171
|
this.store.paymentMethods = methods;
|
|
3207
3172
|
console.log("[Checkout] \u9884\u52A0\u8F7D\u5B8C\u6210\uFF0C\u5171 ".concat(methods.length, " \u79CD\u652F\u4ED8\u65B9\u5F0F"));
|
|
3208
|
-
|
|
3173
|
+
_context41.next = 13;
|
|
3209
3174
|
break;
|
|
3210
3175
|
case 9:
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
console.error('[Checkout] 预加载支付方式失败:',
|
|
3176
|
+
_context41.prev = 9;
|
|
3177
|
+
_context41.t0 = _context41["catch"](0);
|
|
3178
|
+
console.error('[Checkout] 预加载支付方式失败:', _context41.t0);
|
|
3214
3179
|
this.store.paymentMethods = [];
|
|
3215
3180
|
case 13:
|
|
3216
3181
|
case "end":
|
|
3217
|
-
return
|
|
3182
|
+
return _context41.stop();
|
|
3218
3183
|
}
|
|
3219
|
-
},
|
|
3184
|
+
}, _callee41, this, [[0, 9]]);
|
|
3220
3185
|
}));
|
|
3221
3186
|
function preloadPaymentMethods() {
|
|
3222
3187
|
return _preloadPaymentMethods.apply(this, arguments);
|
|
@@ -3244,24 +3209,24 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3244
3209
|
}, {
|
|
3245
3210
|
key: "calculatePaidAmountAsync",
|
|
3246
3211
|
value: (function () {
|
|
3247
|
-
var _calculatePaidAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3212
|
+
var _calculatePaidAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42() {
|
|
3248
3213
|
var payments, paidAmount, result;
|
|
3249
|
-
return _regeneratorRuntime().wrap(function
|
|
3250
|
-
while (1) switch (
|
|
3214
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context42) {
|
|
3215
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
3251
3216
|
case 0:
|
|
3252
3217
|
if (this.store.currentOrder) {
|
|
3253
|
-
|
|
3218
|
+
_context42.next = 3;
|
|
3254
3219
|
break;
|
|
3255
3220
|
}
|
|
3256
3221
|
console.log('[Checkout] calculatePaidAmountAsync: 没有当前订单');
|
|
3257
|
-
return
|
|
3222
|
+
return _context42.abrupt("return", '0.00');
|
|
3258
3223
|
case 3:
|
|
3259
|
-
|
|
3260
|
-
|
|
3224
|
+
_context42.prev = 3;
|
|
3225
|
+
_context42.next = 6;
|
|
3261
3226
|
return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid, false // 不包括已撤销的支付项
|
|
3262
3227
|
);
|
|
3263
3228
|
case 6:
|
|
3264
|
-
payments =
|
|
3229
|
+
payments = _context42.sent;
|
|
3265
3230
|
console.log('[Checkout] calculatePaidAmountAsync: 支付项详情:', {
|
|
3266
3231
|
paymentCount: payments.length,
|
|
3267
3232
|
payments: payments.map(function (p) {
|
|
@@ -3283,17 +3248,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3283
3248
|
}, 0);
|
|
3284
3249
|
result = paidAmount.toFixed(2);
|
|
3285
3250
|
console.log('[Checkout] calculatePaidAmountAsync: 计算结果 =', result);
|
|
3286
|
-
return
|
|
3251
|
+
return _context42.abrupt("return", result);
|
|
3287
3252
|
case 14:
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
console.error('[Checkout] calculatePaidAmountAsync 失败:',
|
|
3291
|
-
return
|
|
3253
|
+
_context42.prev = 14;
|
|
3254
|
+
_context42.t0 = _context42["catch"](3);
|
|
3255
|
+
console.error('[Checkout] calculatePaidAmountAsync 失败:', _context42.t0);
|
|
3256
|
+
return _context42.abrupt("return", '0.00');
|
|
3292
3257
|
case 18:
|
|
3293
3258
|
case "end":
|
|
3294
|
-
return
|
|
3259
|
+
return _context42.stop();
|
|
3295
3260
|
}
|
|
3296
|
-
},
|
|
3261
|
+
}, _callee42, this, [[3, 14]]);
|
|
3297
3262
|
}));
|
|
3298
3263
|
function calculatePaidAmountAsync() {
|
|
3299
3264
|
return _calculatePaidAmountAsync.apply(this, arguments);
|
|
@@ -3307,25 +3272,25 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3307
3272
|
}, {
|
|
3308
3273
|
key: "calculateRemainingAmountAsync",
|
|
3309
3274
|
value: (function () {
|
|
3310
|
-
var _calculateRemainingAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3275
|
+
var _calculateRemainingAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43() {
|
|
3311
3276
|
var totalAmount, paidAmount, remainingAmount, result;
|
|
3312
|
-
return _regeneratorRuntime().wrap(function
|
|
3313
|
-
while (1) switch (
|
|
3277
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context43) {
|
|
3278
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
3314
3279
|
case 0:
|
|
3315
3280
|
if (this.store.currentOrder) {
|
|
3316
|
-
|
|
3281
|
+
_context43.next = 3;
|
|
3317
3282
|
break;
|
|
3318
3283
|
}
|
|
3319
3284
|
console.log('[Checkout] calculateRemainingAmountAsync: 没有当前订单');
|
|
3320
|
-
return
|
|
3285
|
+
return _context43.abrupt("return", '0.00');
|
|
3321
3286
|
case 3:
|
|
3322
3287
|
totalAmount = parseFloat(this.store.currentOrder.total_amount || '0');
|
|
3323
|
-
|
|
3324
|
-
|
|
3288
|
+
_context43.t0 = parseFloat;
|
|
3289
|
+
_context43.next = 7;
|
|
3325
3290
|
return this.calculatePaidAmountAsync();
|
|
3326
3291
|
case 7:
|
|
3327
|
-
|
|
3328
|
-
paidAmount = (0,
|
|
3292
|
+
_context43.t1 = _context43.sent;
|
|
3293
|
+
paidAmount = (0, _context43.t0)(_context43.t1);
|
|
3329
3294
|
remainingAmount = totalAmount - paidAmount;
|
|
3330
3295
|
result = Math.max(0, remainingAmount).toFixed(2);
|
|
3331
3296
|
console.log('[Checkout] calculateRemainingAmountAsync: 计算详情:', {
|
|
@@ -3335,12 +3300,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3335
3300
|
calculatedRemaining: remainingAmount.toFixed(2),
|
|
3336
3301
|
finalResult: result
|
|
3337
3302
|
});
|
|
3338
|
-
return
|
|
3303
|
+
return _context43.abrupt("return", result);
|
|
3339
3304
|
case 13:
|
|
3340
3305
|
case "end":
|
|
3341
|
-
return
|
|
3306
|
+
return _context43.stop();
|
|
3342
3307
|
}
|
|
3343
|
-
},
|
|
3308
|
+
}, _callee43, this);
|
|
3344
3309
|
}));
|
|
3345
3310
|
function calculateRemainingAmountAsync() {
|
|
3346
3311
|
return _calculateRemainingAmountAsync.apply(this, arguments);
|
|
@@ -3354,16 +3319,16 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3354
3319
|
}, {
|
|
3355
3320
|
key: "updateBalanceDueAmount",
|
|
3356
3321
|
value: (function () {
|
|
3357
|
-
var _updateBalanceDueAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3322
|
+
var _updateBalanceDueAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
|
|
3358
3323
|
var _this$store$currentOr17, remainingAmount, currentBalanceDueAmount;
|
|
3359
|
-
return _regeneratorRuntime().wrap(function
|
|
3360
|
-
while (1) switch (
|
|
3324
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context44) {
|
|
3325
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
3361
3326
|
case 0:
|
|
3362
|
-
|
|
3363
|
-
|
|
3327
|
+
_context44.prev = 0;
|
|
3328
|
+
_context44.next = 3;
|
|
3364
3329
|
return this.calculateRemainingAmountAsync();
|
|
3365
3330
|
case 3:
|
|
3366
|
-
remainingAmount =
|
|
3331
|
+
remainingAmount = _context44.sent;
|
|
3367
3332
|
currentBalanceDueAmount = this.store.balanceDueAmount;
|
|
3368
3333
|
console.log('[Checkout] updateBalanceDueAmount: 状态检查:', {
|
|
3369
3334
|
calculatedRemainingAmount: remainingAmount,
|
|
@@ -3374,13 +3339,13 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3374
3339
|
|
|
3375
3340
|
// 只有当剩余金额与当前 balanceDueAmount 不同时才更新
|
|
3376
3341
|
if (!(remainingAmount !== currentBalanceDueAmount)) {
|
|
3377
|
-
|
|
3342
|
+
_context44.next = 13;
|
|
3378
3343
|
break;
|
|
3379
3344
|
}
|
|
3380
3345
|
this.store.balanceDueAmount = remainingAmount;
|
|
3381
3346
|
|
|
3382
3347
|
// 发出 balanceDueAmount 变更事件
|
|
3383
|
-
|
|
3348
|
+
_context44.next = 10;
|
|
3384
3349
|
return this.core.effects.emit(CheckoutHooks.OnBalanceDueAmountChanged, {
|
|
3385
3350
|
oldAmount: currentBalanceDueAmount,
|
|
3386
3351
|
newAmount: remainingAmount,
|
|
@@ -3391,7 +3356,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3391
3356
|
oldAmount: currentBalanceDueAmount,
|
|
3392
3357
|
newAmount: remainingAmount
|
|
3393
3358
|
});
|
|
3394
|
-
|
|
3359
|
+
_context44.next = 14;
|
|
3395
3360
|
break;
|
|
3396
3361
|
case 13:
|
|
3397
3362
|
console.log('[Checkout] balanceDueAmount 无需更新,当前值已是最新:', {
|
|
@@ -3399,17 +3364,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3399
3364
|
remainingAmount: remainingAmount
|
|
3400
3365
|
});
|
|
3401
3366
|
case 14:
|
|
3402
|
-
|
|
3367
|
+
_context44.next = 19;
|
|
3403
3368
|
break;
|
|
3404
3369
|
case 16:
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
console.error('[Checkout] 更新 balanceDueAmount 失败:',
|
|
3370
|
+
_context44.prev = 16;
|
|
3371
|
+
_context44.t0 = _context44["catch"](0);
|
|
3372
|
+
console.error('[Checkout] 更新 balanceDueAmount 失败:', _context44.t0);
|
|
3408
3373
|
case 19:
|
|
3409
3374
|
case "end":
|
|
3410
|
-
return
|
|
3375
|
+
return _context44.stop();
|
|
3411
3376
|
}
|
|
3412
|
-
},
|
|
3377
|
+
}, _callee44, this, [[0, 16]]);
|
|
3413
3378
|
}));
|
|
3414
3379
|
function updateBalanceDueAmount() {
|
|
3415
3380
|
return _updateBalanceDueAmount.apply(this, arguments);
|
|
@@ -3423,16 +3388,16 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3423
3388
|
}, {
|
|
3424
3389
|
key: "updateStateAmountToRemaining",
|
|
3425
3390
|
value: (function () {
|
|
3426
|
-
var _updateStateAmountToRemaining = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3391
|
+
var _updateStateAmountToRemaining = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45() {
|
|
3427
3392
|
var _this$store$currentOr18, remainingAmount, currentStateAmount;
|
|
3428
|
-
return _regeneratorRuntime().wrap(function
|
|
3429
|
-
while (1) switch (
|
|
3393
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context45) {
|
|
3394
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
3430
3395
|
case 0:
|
|
3431
|
-
|
|
3432
|
-
|
|
3396
|
+
_context45.prev = 0;
|
|
3397
|
+
_context45.next = 3;
|
|
3433
3398
|
return this.calculateRemainingAmountAsync();
|
|
3434
3399
|
case 3:
|
|
3435
|
-
remainingAmount =
|
|
3400
|
+
remainingAmount = _context45.sent;
|
|
3436
3401
|
currentStateAmount = this.store.stateAmount;
|
|
3437
3402
|
console.log('[Checkout] updateStateAmountToRemaining: 状态检查:', {
|
|
3438
3403
|
calculatedRemainingAmount: remainingAmount,
|
|
@@ -3443,13 +3408,13 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3443
3408
|
|
|
3444
3409
|
// 只有当剩余金额与当前 stateAmount 不同时才更新
|
|
3445
3410
|
if (!(remainingAmount !== currentStateAmount)) {
|
|
3446
|
-
|
|
3411
|
+
_context45.next = 13;
|
|
3447
3412
|
break;
|
|
3448
3413
|
}
|
|
3449
3414
|
this.store.stateAmount = remainingAmount;
|
|
3450
3415
|
|
|
3451
3416
|
// 发出 stateAmount 变更事件
|
|
3452
|
-
|
|
3417
|
+
_context45.next = 10;
|
|
3453
3418
|
return this.core.effects.emit(CheckoutHooks.OnStateAmountChanged, {
|
|
3454
3419
|
oldAmount: currentStateAmount,
|
|
3455
3420
|
newAmount: remainingAmount,
|
|
@@ -3460,7 +3425,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3460
3425
|
oldAmount: currentStateAmount,
|
|
3461
3426
|
newAmount: remainingAmount
|
|
3462
3427
|
});
|
|
3463
|
-
|
|
3428
|
+
_context45.next = 14;
|
|
3464
3429
|
break;
|
|
3465
3430
|
case 13:
|
|
3466
3431
|
console.log('[Checkout] stateAmount 无需更新,当前值已是最新:', {
|
|
@@ -3468,23 +3433,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3468
3433
|
remainingAmount: remainingAmount
|
|
3469
3434
|
});
|
|
3470
3435
|
case 14:
|
|
3471
|
-
|
|
3436
|
+
_context45.next = 16;
|
|
3472
3437
|
return this.updateBalanceDueAmount();
|
|
3473
3438
|
case 16:
|
|
3474
|
-
|
|
3439
|
+
_context45.next = 18;
|
|
3475
3440
|
return this.checkOrderPaymentCompletion();
|
|
3476
3441
|
case 18:
|
|
3477
|
-
|
|
3442
|
+
_context45.next = 23;
|
|
3478
3443
|
break;
|
|
3479
3444
|
case 20:
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
console.error('[Checkout] 更新 stateAmount 为剩余金额失败:',
|
|
3445
|
+
_context45.prev = 20;
|
|
3446
|
+
_context45.t0 = _context45["catch"](0);
|
|
3447
|
+
console.error('[Checkout] 更新 stateAmount 为剩余金额失败:', _context45.t0);
|
|
3483
3448
|
case 23:
|
|
3484
3449
|
case "end":
|
|
3485
|
-
return
|
|
3450
|
+
return _context45.stop();
|
|
3486
3451
|
}
|
|
3487
|
-
},
|
|
3452
|
+
}, _callee45, this, [[0, 20]]);
|
|
3488
3453
|
}));
|
|
3489
3454
|
function updateStateAmountToRemaining() {
|
|
3490
3455
|
return _updateStateAmountToRemaining.apply(this, arguments);
|
|
@@ -3500,32 +3465,32 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3500
3465
|
}, {
|
|
3501
3466
|
key: "checkOrderPaymentCompletion",
|
|
3502
3467
|
value: (function () {
|
|
3503
|
-
var _checkOrderPaymentCompletion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3468
|
+
var _checkOrderPaymentCompletion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
|
|
3504
3469
|
var remainingAmount, remainingValue, totalAmount, paidAmount, currentPayments, hasPaymentItems, allPaymentsHaveVoucherId, shouldAutoSync;
|
|
3505
|
-
return _regeneratorRuntime().wrap(function
|
|
3506
|
-
while (1) switch (
|
|
3470
|
+
return _regeneratorRuntime().wrap(function _callee46$(_context46) {
|
|
3471
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
3507
3472
|
case 0:
|
|
3508
|
-
|
|
3473
|
+
_context46.prev = 0;
|
|
3509
3474
|
if (this.store.currentOrder) {
|
|
3510
|
-
|
|
3475
|
+
_context46.next = 3;
|
|
3511
3476
|
break;
|
|
3512
3477
|
}
|
|
3513
|
-
return
|
|
3478
|
+
return _context46.abrupt("return");
|
|
3514
3479
|
case 3:
|
|
3515
|
-
|
|
3480
|
+
_context46.next = 5;
|
|
3516
3481
|
return this.calculateRemainingAmountAsync();
|
|
3517
3482
|
case 5:
|
|
3518
|
-
remainingAmount =
|
|
3483
|
+
remainingAmount = _context46.sent;
|
|
3519
3484
|
remainingValue = parseFloat(remainingAmount); // 当剩余金额小于等于0时,认为订单已完成支付
|
|
3520
3485
|
if (!(remainingValue <= 0)) {
|
|
3521
|
-
|
|
3486
|
+
_context46.next = 29;
|
|
3522
3487
|
break;
|
|
3523
3488
|
}
|
|
3524
3489
|
totalAmount = this.store.currentOrder.total_amount;
|
|
3525
|
-
|
|
3490
|
+
_context46.next = 11;
|
|
3526
3491
|
return this.calculatePaidAmountAsync();
|
|
3527
3492
|
case 11:
|
|
3528
|
-
paidAmount =
|
|
3493
|
+
paidAmount = _context46.sent;
|
|
3529
3494
|
console.log('[Checkout] 检测到订单支付完成:', {
|
|
3530
3495
|
orderUuid: this.store.currentOrder.uuid,
|
|
3531
3496
|
orderId: this.store.currentOrder.order_id,
|
|
@@ -3536,11 +3501,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3536
3501
|
});
|
|
3537
3502
|
|
|
3538
3503
|
// 从 Payment 模块获取最新支付项,检查自动同步条件
|
|
3539
|
-
|
|
3504
|
+
_context46.next = 15;
|
|
3540
3505
|
return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid, false // 不包括已撤销的支付项
|
|
3541
3506
|
);
|
|
3542
3507
|
case 15:
|
|
3543
|
-
currentPayments =
|
|
3508
|
+
currentPayments = _context46.sent;
|
|
3544
3509
|
// 检查自动同步条件:
|
|
3545
3510
|
// 1. 待付金额为 0 ✓ (已在上面检查)
|
|
3546
3511
|
// 2. 需要有支付项
|
|
@@ -3572,14 +3537,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3572
3537
|
})
|
|
3573
3538
|
});
|
|
3574
3539
|
if (!shouldAutoSync) {
|
|
3575
|
-
|
|
3540
|
+
_context46.next = 26;
|
|
3576
3541
|
break;
|
|
3577
3542
|
}
|
|
3578
3543
|
console.log('[Checkout] 满足自动同步条件,开始同步订单到后端...');
|
|
3579
|
-
|
|
3544
|
+
_context46.next = 24;
|
|
3580
3545
|
return this.syncOrderToBackend();
|
|
3581
3546
|
case 24:
|
|
3582
|
-
|
|
3547
|
+
_context46.next = 27;
|
|
3583
3548
|
break;
|
|
3584
3549
|
case 26:
|
|
3585
3550
|
if (!hasPaymentItems) {
|
|
@@ -3588,7 +3553,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3588
3553
|
console.log('[Checkout] 所有支付项均为代金券类型,跳过订单同步');
|
|
3589
3554
|
}
|
|
3590
3555
|
case 27:
|
|
3591
|
-
|
|
3556
|
+
_context46.next = 29;
|
|
3592
3557
|
return this.core.effects.emit(CheckoutHooks.OnOrderPaymentCompleted, {
|
|
3593
3558
|
orderUuid: this.store.currentOrder.uuid,
|
|
3594
3559
|
orderId: this.store.currentOrder.order_id,
|
|
@@ -3598,17 +3563,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3598
3563
|
timestamp: Date.now()
|
|
3599
3564
|
});
|
|
3600
3565
|
case 29:
|
|
3601
|
-
|
|
3566
|
+
_context46.next = 34;
|
|
3602
3567
|
break;
|
|
3603
3568
|
case 31:
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
console.error('[Checkout] 检查订单支付完成状态失败:',
|
|
3569
|
+
_context46.prev = 31;
|
|
3570
|
+
_context46.t0 = _context46["catch"](0);
|
|
3571
|
+
console.error('[Checkout] 检查订单支付完成状态失败:', _context46.t0);
|
|
3607
3572
|
case 34:
|
|
3608
3573
|
case "end":
|
|
3609
|
-
return
|
|
3574
|
+
return _context46.stop();
|
|
3610
3575
|
}
|
|
3611
|
-
},
|
|
3576
|
+
}, _callee46, this, [[0, 31]]);
|
|
3612
3577
|
}));
|
|
3613
3578
|
function checkOrderPaymentCompletion() {
|
|
3614
3579
|
return _checkOrderPaymentCompletion.apply(this, arguments);
|
|
@@ -3680,7 +3645,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3680
3645
|
}, {
|
|
3681
3646
|
key: "syncOrderToBackendWithReturn",
|
|
3682
3647
|
value: (function () {
|
|
3683
|
-
var _syncOrderToBackendWithReturn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3648
|
+
var _syncOrderToBackendWithReturn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47() {
|
|
3684
3649
|
var _this$store$currentCu2, _this$store$currentOr19, _this$store$currentOr20, _checkoutResponse3, _checkoutResponse4, _checkoutResponse5, _checkoutResponse6, _checkoutResponse7, _checkoutResponse8;
|
|
3685
3650
|
var isManual,
|
|
3686
3651
|
customPaymentItems,
|
|
@@ -3712,14 +3677,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3712
3677
|
beforeManualUpdate,
|
|
3713
3678
|
finalOrderId,
|
|
3714
3679
|
finalIsVirtual,
|
|
3715
|
-
|
|
3716
|
-
return _regeneratorRuntime().wrap(function
|
|
3717
|
-
while (1) switch (
|
|
3680
|
+
_args47 = arguments;
|
|
3681
|
+
return _regeneratorRuntime().wrap(function _callee47$(_context47) {
|
|
3682
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
3718
3683
|
case 0:
|
|
3719
|
-
isManual =
|
|
3720
|
-
customPaymentItems =
|
|
3684
|
+
isManual = _args47.length > 0 && _args47[0] !== undefined ? _args47[0] : false;
|
|
3685
|
+
customPaymentItems = _args47.length > 1 ? _args47[1] : undefined;
|
|
3721
3686
|
if (!(!this.store.localOrderData || !this.store.currentOrder)) {
|
|
3722
|
-
|
|
3687
|
+
_context47.next = 4;
|
|
3723
3688
|
break;
|
|
3724
3689
|
}
|
|
3725
3690
|
throw new Error('缺少必要的订单数据,无法同步到后端');
|
|
@@ -3760,17 +3725,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3760
3725
|
});
|
|
3761
3726
|
|
|
3762
3727
|
// 获取当前订单的支付项
|
|
3763
|
-
|
|
3764
|
-
if (
|
|
3765
|
-
|
|
3728
|
+
_context47.t0 = customPaymentItems;
|
|
3729
|
+
if (_context47.t0) {
|
|
3730
|
+
_context47.next = 18;
|
|
3766
3731
|
break;
|
|
3767
3732
|
}
|
|
3768
|
-
|
|
3733
|
+
_context47.next = 17;
|
|
3769
3734
|
return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid);
|
|
3770
3735
|
case 17:
|
|
3771
|
-
|
|
3736
|
+
_context47.t0 = _context47.sent;
|
|
3772
3737
|
case 18:
|
|
3773
|
-
paymentItems =
|
|
3738
|
+
paymentItems = _context47.t0;
|
|
3774
3739
|
console.log('[Checkout] 获取到支付项:', {
|
|
3775
3740
|
count: paymentItems.length,
|
|
3776
3741
|
isCustomFiltered: !!customPaymentItems,
|
|
@@ -3843,7 +3808,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3843
3808
|
|
|
3844
3809
|
// 发送下单接口请求开始事件
|
|
3845
3810
|
startTime = Date.now();
|
|
3846
|
-
|
|
3811
|
+
_context47.next = 25;
|
|
3847
3812
|
return this.core.effects.emit(CheckoutHooks.OnOrderSubmitStart, {
|
|
3848
3813
|
orderUuid: this.store.currentOrder.uuid,
|
|
3849
3814
|
operation: isUpdateOperation ? 'update' : 'create',
|
|
@@ -3853,24 +3818,24 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3853
3818
|
});
|
|
3854
3819
|
case 25:
|
|
3855
3820
|
submitSuccess = false;
|
|
3856
|
-
|
|
3857
|
-
|
|
3821
|
+
_context47.prev = 26;
|
|
3822
|
+
_context47.next = 29;
|
|
3858
3823
|
return this.order.createOrderByCheckout(orderParams);
|
|
3859
3824
|
case 29:
|
|
3860
|
-
checkoutResponse =
|
|
3825
|
+
checkoutResponse = _context47.sent;
|
|
3861
3826
|
submitSuccess = true;
|
|
3862
3827
|
console.log('[Checkout] 下单接口调用成功');
|
|
3863
|
-
|
|
3828
|
+
_context47.next = 41;
|
|
3864
3829
|
break;
|
|
3865
3830
|
case 34:
|
|
3866
|
-
|
|
3867
|
-
|
|
3831
|
+
_context47.prev = 34;
|
|
3832
|
+
_context47.t1 = _context47["catch"](26);
|
|
3868
3833
|
submitSuccess = false;
|
|
3869
|
-
submitError =
|
|
3834
|
+
submitError = _context47.t1 instanceof Error ? _context47.t1.message : String(_context47.t1);
|
|
3870
3835
|
// console.error('[Checkout] 下单接口调用失败:', submitError);
|
|
3871
3836
|
|
|
3872
3837
|
// 发送订单同步失败事件(网络错误或请求失败)
|
|
3873
|
-
|
|
3838
|
+
_context47.next = 40;
|
|
3874
3839
|
return this.core.effects.emit(CheckoutHooks.OnOrderSyncFailed, {
|
|
3875
3840
|
orderUuid: this.store.currentOrder.uuid,
|
|
3876
3841
|
operation: isUpdateOperation ? 'update' : 'create',
|
|
@@ -3881,10 +3846,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3881
3846
|
timestamp: Date.now()
|
|
3882
3847
|
});
|
|
3883
3848
|
case 40:
|
|
3884
|
-
throw
|
|
3849
|
+
throw _context47.t1;
|
|
3885
3850
|
case 41:
|
|
3886
|
-
|
|
3887
|
-
|
|
3851
|
+
_context47.prev = 41;
|
|
3852
|
+
_context47.next = 44;
|
|
3888
3853
|
return this.core.effects.emit(CheckoutHooks.OnOrderSubmitEnd, {
|
|
3889
3854
|
success: submitSuccess,
|
|
3890
3855
|
orderUuid: this.store.currentOrder.uuid,
|
|
@@ -3896,7 +3861,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3896
3861
|
timestamp: Date.now()
|
|
3897
3862
|
});
|
|
3898
3863
|
case 44:
|
|
3899
|
-
return
|
|
3864
|
+
return _context47.finish(41);
|
|
3900
3865
|
case 45:
|
|
3901
3866
|
console.log('[Checkout] 后端返回的响应数据:', {
|
|
3902
3867
|
status: (_checkoutResponse3 = checkoutResponse) === null || _checkoutResponse3 === void 0 ? void 0 : _checkoutResponse3.status,
|
|
@@ -3909,7 +3874,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3909
3874
|
responseStatus = (_checkoutResponse7 = checkoutResponse) === null || _checkoutResponse7 === void 0 ? void 0 : _checkoutResponse7.status;
|
|
3910
3875
|
isSuccessResponse = responseStatus === true || responseStatus === 200 || responseStatus === 'success' || responseStatus === 1 && ((_checkoutResponse8 = checkoutResponse) === null || _checkoutResponse8 === void 0 ? void 0 : _checkoutResponse8.code) === 200;
|
|
3911
3876
|
if (isSuccessResponse) {
|
|
3912
|
-
|
|
3877
|
+
_context47.next = 54;
|
|
3913
3878
|
break;
|
|
3914
3879
|
}
|
|
3915
3880
|
errorMessage = ((_checkoutResponse9 = checkoutResponse) === null || _checkoutResponse9 === void 0 ? void 0 : _checkoutResponse9.message) || '订单同步失败,后端返回非成功状态';
|
|
@@ -3922,7 +3887,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3922
3887
|
});
|
|
3923
3888
|
|
|
3924
3889
|
// 发送订单同步失败事件
|
|
3925
|
-
|
|
3890
|
+
_context47.next = 53;
|
|
3926
3891
|
return this.core.effects.emit(CheckoutHooks.OnOrderSyncFailed, {
|
|
3927
3892
|
orderUuid: this.store.currentOrder.uuid,
|
|
3928
3893
|
operation: isUpdateOperation ? 'update' : 'create',
|
|
@@ -3938,13 +3903,13 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3938
3903
|
case 54:
|
|
3939
3904
|
console.log('[Checkout] 响应状态检查通过,开始处理订单数据');
|
|
3940
3905
|
if (!isUpdateOperation) {
|
|
3941
|
-
|
|
3906
|
+
_context47.next = 60;
|
|
3942
3907
|
break;
|
|
3943
3908
|
}
|
|
3944
3909
|
// 更新操作:使用现有的订单ID
|
|
3945
3910
|
realOrderId = currentOrderId;
|
|
3946
3911
|
console.log("[Checkout] \u8BA2\u5355\u66F4\u65B0\u6210\u529F\uFF0C\u8BA2\u5355ID: ".concat(realOrderId));
|
|
3947
|
-
|
|
3912
|
+
_context47.next = 81;
|
|
3948
3913
|
break;
|
|
3949
3914
|
case 60:
|
|
3950
3915
|
// 创建操作:从响应中提取新的订单ID
|
|
@@ -3958,7 +3923,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3958
3923
|
extractedOrderId = String(extractedOrderId);
|
|
3959
3924
|
}
|
|
3960
3925
|
if (extractedOrderId) {
|
|
3961
|
-
|
|
3926
|
+
_context47.next = 65;
|
|
3962
3927
|
break;
|
|
3963
3928
|
}
|
|
3964
3929
|
throw new Error('后端返回的订单信息中未包含订单ID');
|
|
@@ -3972,11 +3937,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3972
3937
|
oldOrderId: this.store.currentOrder.order_id,
|
|
3973
3938
|
newOrderId: realOrderId
|
|
3974
3939
|
});
|
|
3975
|
-
|
|
3976
|
-
|
|
3940
|
+
_context47.prev = 68;
|
|
3941
|
+
_context47.next = 71;
|
|
3977
3942
|
return this.payment.replaceOrderIdByUuidAsync(this.store.currentOrder.uuid, realOrderId);
|
|
3978
3943
|
case 71:
|
|
3979
|
-
updatedOrder =
|
|
3944
|
+
updatedOrder = _context47.sent;
|
|
3980
3945
|
console.log('[Checkout] Payment模块替换订单ID结果:', {
|
|
3981
3946
|
wasSuccessful: !!updatedOrder,
|
|
3982
3947
|
returnedOrderId: updatedOrder === null || updatedOrder === void 0 ? void 0 : updatedOrder.order_id,
|
|
@@ -4002,12 +3967,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4002
3967
|
目标ID: realOrderId
|
|
4003
3968
|
});
|
|
4004
3969
|
}
|
|
4005
|
-
|
|
3970
|
+
_context47.next = 81;
|
|
4006
3971
|
break;
|
|
4007
3972
|
case 76:
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
console.error('[Checkout] 调用Payment模块替换订单ID时发生错误:',
|
|
3973
|
+
_context47.prev = 76;
|
|
3974
|
+
_context47.t2 = _context47["catch"](68);
|
|
3975
|
+
console.error('[Checkout] 调用Payment模块替换订单ID时发生错误:', _context47.t2);
|
|
4011
3976
|
|
|
4012
3977
|
// 发生错误时也进行手动替换
|
|
4013
3978
|
this.store.currentOrder.order_id = realOrderId;
|
|
@@ -4017,7 +3982,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4017
3982
|
this.store.isOrderSynced = true;
|
|
4018
3983
|
|
|
4019
3984
|
// 触发订单同步完成事件
|
|
4020
|
-
|
|
3985
|
+
_context47.next = 84;
|
|
4021
3986
|
return this.core.effects.emit(CheckoutHooks.OnOrderSynced, {
|
|
4022
3987
|
orderUuid: this.store.currentOrder.uuid,
|
|
4023
3988
|
realOrderId: realOrderId,
|
|
@@ -4043,12 +4008,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4043
4008
|
}
|
|
4044
4009
|
|
|
4045
4010
|
// 返回真实订单ID
|
|
4046
|
-
return
|
|
4011
|
+
return _context47.abrupt("return", realOrderId);
|
|
4047
4012
|
case 89:
|
|
4048
4013
|
case "end":
|
|
4049
|
-
return
|
|
4014
|
+
return _context47.stop();
|
|
4050
4015
|
}
|
|
4051
|
-
},
|
|
4016
|
+
}, _callee47, this, [[26, 34, 41, 45], [68, 76]]);
|
|
4052
4017
|
}));
|
|
4053
4018
|
function syncOrderToBackendWithReturn() {
|
|
4054
4019
|
return _syncOrderToBackendWithReturn.apply(this, arguments);
|
|
@@ -4058,27 +4023,27 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4058
4023
|
}, {
|
|
4059
4024
|
key: "syncOrderToBackend",
|
|
4060
4025
|
value: function () {
|
|
4061
|
-
var _syncOrderToBackend = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4062
|
-
return _regeneratorRuntime().wrap(function
|
|
4063
|
-
while (1) switch (
|
|
4026
|
+
var _syncOrderToBackend = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48() {
|
|
4027
|
+
return _regeneratorRuntime().wrap(function _callee48$(_context48) {
|
|
4028
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
4064
4029
|
case 0:
|
|
4065
|
-
|
|
4066
|
-
|
|
4030
|
+
_context48.prev = 0;
|
|
4031
|
+
_context48.next = 3;
|
|
4067
4032
|
return this.syncOrderToBackendWithReturn(false);
|
|
4068
4033
|
case 3:
|
|
4069
|
-
|
|
4034
|
+
_context48.next = 10;
|
|
4070
4035
|
break;
|
|
4071
4036
|
case 5:
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
console.error('[Checkout] 同步订单到后端失败:',
|
|
4075
|
-
|
|
4076
|
-
return this.handleError(new Error("\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(
|
|
4037
|
+
_context48.prev = 5;
|
|
4038
|
+
_context48.t0 = _context48["catch"](0);
|
|
4039
|
+
console.error('[Checkout] 同步订单到后端失败:', _context48.t0);
|
|
4040
|
+
_context48.next = 10;
|
|
4041
|
+
return this.handleError(new Error("\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(_context48.t0 instanceof Error ? _context48.t0.message : String(_context48.t0))), CheckoutErrorType.OrderCreationFailed);
|
|
4077
4042
|
case 10:
|
|
4078
4043
|
case "end":
|
|
4079
|
-
return
|
|
4044
|
+
return _context48.stop();
|
|
4080
4045
|
}
|
|
4081
|
-
},
|
|
4046
|
+
}, _callee48, this, [[0, 5]]);
|
|
4082
4047
|
}));
|
|
4083
4048
|
function syncOrderToBackend() {
|
|
4084
4049
|
return _syncOrderToBackend.apply(this, arguments);
|
|
@@ -4118,15 +4083,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4118
4083
|
}, {
|
|
4119
4084
|
key: "setOtherParams",
|
|
4120
4085
|
value: function () {
|
|
4121
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4086
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(params) {
|
|
4122
4087
|
var _ref5,
|
|
4123
4088
|
_ref5$cover,
|
|
4124
4089
|
cover,
|
|
4125
|
-
|
|
4126
|
-
return _regeneratorRuntime().wrap(function
|
|
4127
|
-
while (1) switch (
|
|
4090
|
+
_args49 = arguments;
|
|
4091
|
+
return _regeneratorRuntime().wrap(function _callee49$(_context49) {
|
|
4092
|
+
while (1) switch (_context49.prev = _context49.next) {
|
|
4128
4093
|
case 0:
|
|
4129
|
-
_ref5 =
|
|
4094
|
+
_ref5 = _args49.length > 1 && _args49[1] !== undefined ? _args49[1] : {}, _ref5$cover = _ref5.cover, cover = _ref5$cover === void 0 ? false : _ref5$cover;
|
|
4130
4095
|
if (cover) {
|
|
4131
4096
|
this.otherParams = params;
|
|
4132
4097
|
} else {
|
|
@@ -4134,11 +4099,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4134
4099
|
}
|
|
4135
4100
|
case 2:
|
|
4136
4101
|
case "end":
|
|
4137
|
-
return
|
|
4102
|
+
return _context49.stop();
|
|
4138
4103
|
}
|
|
4139
|
-
},
|
|
4104
|
+
}, _callee49, this);
|
|
4140
4105
|
}));
|
|
4141
|
-
function setOtherParams(
|
|
4106
|
+
function setOtherParams(_x30) {
|
|
4142
4107
|
return _setOtherParams.apply(this, arguments);
|
|
4143
4108
|
}
|
|
4144
4109
|
return setOtherParams;
|
|
@@ -4155,12 +4120,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4155
4120
|
}, {
|
|
4156
4121
|
key: "editOrderNoteByOrderIdAsync",
|
|
4157
4122
|
value: (function () {
|
|
4158
|
-
var _editOrderNoteByOrderIdAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4123
|
+
var _editOrderNoteByOrderIdAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(orderId, note) {
|
|
4159
4124
|
var response, previousNote, errorMessage, _errorMessage;
|
|
4160
|
-
return _regeneratorRuntime().wrap(function
|
|
4161
|
-
while (1) switch (
|
|
4125
|
+
return _regeneratorRuntime().wrap(function _callee50$(_context50) {
|
|
4126
|
+
while (1) switch (_context50.prev = _context50.next) {
|
|
4162
4127
|
case 0:
|
|
4163
|
-
|
|
4128
|
+
_context50.prev = 0;
|
|
4164
4129
|
console.log('[Checkout] 开始编辑订单备注:', {
|
|
4165
4130
|
orderId: orderId,
|
|
4166
4131
|
note: note,
|
|
@@ -4169,21 +4134,21 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4169
4134
|
|
|
4170
4135
|
// 参数验证
|
|
4171
4136
|
if (orderId) {
|
|
4172
|
-
|
|
4137
|
+
_context50.next = 4;
|
|
4173
4138
|
break;
|
|
4174
4139
|
}
|
|
4175
|
-
return
|
|
4140
|
+
return _context50.abrupt("return", {
|
|
4176
4141
|
success: false,
|
|
4177
4142
|
message: '订单ID不能为空',
|
|
4178
4143
|
orderId: orderId
|
|
4179
4144
|
});
|
|
4180
4145
|
case 4:
|
|
4181
|
-
|
|
4146
|
+
_context50.next = 6;
|
|
4182
4147
|
return this.request.put("/order/order/".concat(orderId, "/note"), {
|
|
4183
4148
|
note: note
|
|
4184
4149
|
});
|
|
4185
4150
|
case 6:
|
|
4186
|
-
response =
|
|
4151
|
+
response = _context50.sent;
|
|
4187
4152
|
console.log('[Checkout] 订单备注编辑响应:', {
|
|
4188
4153
|
orderId: orderId,
|
|
4189
4154
|
status: response.status,
|
|
@@ -4193,14 +4158,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4193
4158
|
|
|
4194
4159
|
// 检查响应状态
|
|
4195
4160
|
if (!(response.status === true || response.status === 200)) {
|
|
4196
|
-
|
|
4161
|
+
_context50.next = 19;
|
|
4197
4162
|
break;
|
|
4198
4163
|
}
|
|
4199
4164
|
console.log("[Checkout] \u8BA2\u5355 ".concat(orderId, " \u5907\u6CE8\u4FEE\u6539\u6210\u529F"));
|
|
4200
4165
|
|
|
4201
4166
|
// 如果当前订单就是被修改的订单,同时更新本地状态
|
|
4202
4167
|
if (!(this.store.currentOrder && (String(this.store.currentOrder.order_id) === String(orderId) || String(this.store.currentOrder.id) === String(orderId)))) {
|
|
4203
|
-
|
|
4168
|
+
_context50.next = 16;
|
|
4204
4169
|
break;
|
|
4205
4170
|
}
|
|
4206
4171
|
console.log('[Checkout] 更新本地订单备注状态');
|
|
@@ -4212,7 +4177,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4212
4177
|
}
|
|
4213
4178
|
|
|
4214
4179
|
// 触发订单备注变更事件
|
|
4215
|
-
|
|
4180
|
+
_context50.next = 16;
|
|
4216
4181
|
return this.core.effects.emit(CheckoutHooks.OnOrderNoteChanged, {
|
|
4217
4182
|
orderUuid: this.store.currentOrder.uuid,
|
|
4218
4183
|
oldNote: previousNote,
|
|
@@ -4220,7 +4185,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4220
4185
|
timestamp: Date.now()
|
|
4221
4186
|
});
|
|
4222
4187
|
case 16:
|
|
4223
|
-
return
|
|
4188
|
+
return _context50.abrupt("return", {
|
|
4224
4189
|
success: true,
|
|
4225
4190
|
message: response.message || '订单备注修改成功',
|
|
4226
4191
|
orderId: orderId
|
|
@@ -4229,31 +4194,31 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4229
4194
|
// API返回失败状态
|
|
4230
4195
|
errorMessage = response.message || '订单备注修改失败';
|
|
4231
4196
|
console.error("[Checkout] \u8BA2\u5355 ".concat(orderId, " \u5907\u6CE8\u4FEE\u6539\u5931\u8D25:"), errorMessage);
|
|
4232
|
-
return
|
|
4197
|
+
return _context50.abrupt("return", {
|
|
4233
4198
|
success: false,
|
|
4234
4199
|
message: errorMessage,
|
|
4235
4200
|
orderId: orderId
|
|
4236
4201
|
});
|
|
4237
4202
|
case 22:
|
|
4238
|
-
|
|
4203
|
+
_context50.next = 29;
|
|
4239
4204
|
break;
|
|
4240
4205
|
case 24:
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
console.error('[Checkout] 编辑订单备注失败:',
|
|
4244
|
-
_errorMessage =
|
|
4245
|
-
return
|
|
4206
|
+
_context50.prev = 24;
|
|
4207
|
+
_context50.t0 = _context50["catch"](0);
|
|
4208
|
+
console.error('[Checkout] 编辑订单备注失败:', _context50.t0);
|
|
4209
|
+
_errorMessage = _context50.t0 instanceof Error ? _context50.t0.message : '网络错误或服务器异常';
|
|
4210
|
+
return _context50.abrupt("return", {
|
|
4246
4211
|
success: false,
|
|
4247
4212
|
message: "\u7F16\u8F91\u8BA2\u5355\u5907\u6CE8\u5931\u8D25: ".concat(_errorMessage),
|
|
4248
4213
|
orderId: orderId
|
|
4249
4214
|
});
|
|
4250
4215
|
case 29:
|
|
4251
4216
|
case "end":
|
|
4252
|
-
return
|
|
4217
|
+
return _context50.stop();
|
|
4253
4218
|
}
|
|
4254
|
-
},
|
|
4219
|
+
}, _callee50, this, [[0, 24]]);
|
|
4255
4220
|
}));
|
|
4256
|
-
function editOrderNoteByOrderIdAsync(
|
|
4221
|
+
function editOrderNoteByOrderIdAsync(_x31, _x32) {
|
|
4257
4222
|
return _editOrderNoteByOrderIdAsync.apply(this, arguments);
|
|
4258
4223
|
}
|
|
4259
4224
|
return editOrderNoteByOrderIdAsync;
|
|
@@ -4270,12 +4235,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4270
4235
|
}, {
|
|
4271
4236
|
key: "sendCustomerPayLinkAsync",
|
|
4272
4237
|
value: (function () {
|
|
4273
|
-
var _sendCustomerPayLinkAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4238
|
+
var _sendCustomerPayLinkAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
|
|
4274
4239
|
var emailRegex, invalidEmails, requestBody, response, errorMessage, _errorMessage2;
|
|
4275
|
-
return _regeneratorRuntime().wrap(function
|
|
4276
|
-
while (1) switch (
|
|
4240
|
+
return _regeneratorRuntime().wrap(function _callee51$(_context51) {
|
|
4241
|
+
while (1) switch (_context51.prev = _context51.next) {
|
|
4277
4242
|
case 0:
|
|
4278
|
-
|
|
4243
|
+
_context51.prev = 0;
|
|
4279
4244
|
console.log('[Checkout] 开始发送客户支付链接邮件:', {
|
|
4280
4245
|
orderIds: params.order_ids,
|
|
4281
4246
|
emails: params.emails,
|
|
@@ -4284,19 +4249,19 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4284
4249
|
|
|
4285
4250
|
// 参数验证
|
|
4286
4251
|
if (!(!params.order_ids || params.order_ids.length === 0)) {
|
|
4287
|
-
|
|
4252
|
+
_context51.next = 4;
|
|
4288
4253
|
break;
|
|
4289
4254
|
}
|
|
4290
|
-
return
|
|
4255
|
+
return _context51.abrupt("return", {
|
|
4291
4256
|
success: false,
|
|
4292
4257
|
message: '订单ID列表不能为空'
|
|
4293
4258
|
});
|
|
4294
4259
|
case 4:
|
|
4295
4260
|
if (!(!params.emails || params.emails.length === 0)) {
|
|
4296
|
-
|
|
4261
|
+
_context51.next = 6;
|
|
4297
4262
|
break;
|
|
4298
4263
|
}
|
|
4299
|
-
return
|
|
4264
|
+
return _context51.abrupt("return", {
|
|
4300
4265
|
success: false,
|
|
4301
4266
|
message: '邮箱地址列表不能为空'
|
|
4302
4267
|
});
|
|
@@ -4307,10 +4272,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4307
4272
|
return !emailRegex.test(email);
|
|
4308
4273
|
});
|
|
4309
4274
|
if (!(invalidEmails.length > 0)) {
|
|
4310
|
-
|
|
4275
|
+
_context51.next = 10;
|
|
4311
4276
|
break;
|
|
4312
4277
|
}
|
|
4313
|
-
return
|
|
4278
|
+
return _context51.abrupt("return", {
|
|
4314
4279
|
success: false,
|
|
4315
4280
|
message: "\u90AE\u7BB1\u683C\u5F0F\u65E0\u6548: ".concat(invalidEmails.join(', '))
|
|
4316
4281
|
});
|
|
@@ -4324,10 +4289,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4324
4289
|
console.log('[Checkout] 发送支付链接邮件请求参数:', requestBody);
|
|
4325
4290
|
|
|
4326
4291
|
// 调用后端API发送邮件
|
|
4327
|
-
|
|
4292
|
+
_context51.next = 14;
|
|
4328
4293
|
return this.request.post('/order/batch-email', requestBody);
|
|
4329
4294
|
case 14:
|
|
4330
|
-
response =
|
|
4295
|
+
response = _context51.sent;
|
|
4331
4296
|
console.log('[Checkout] 支付链接邮件发送响应:', {
|
|
4332
4297
|
status: response.status,
|
|
4333
4298
|
message: response.message,
|
|
@@ -4337,11 +4302,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4337
4302
|
|
|
4338
4303
|
// 检查响应状态
|
|
4339
4304
|
if (!(response.status === true || response.status === 200)) {
|
|
4340
|
-
|
|
4305
|
+
_context51.next = 21;
|
|
4341
4306
|
break;
|
|
4342
4307
|
}
|
|
4343
4308
|
console.log('[Checkout] 支付链接邮件发送成功');
|
|
4344
|
-
return
|
|
4309
|
+
return _context51.abrupt("return", {
|
|
4345
4310
|
success: true,
|
|
4346
4311
|
message: response.message || '支付链接邮件发送成功'
|
|
4347
4312
|
});
|
|
@@ -4349,29 +4314,29 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4349
4314
|
// API返回失败状态
|
|
4350
4315
|
errorMessage = response.message || '支付链接邮件发送失败';
|
|
4351
4316
|
console.error('[Checkout] 支付链接邮件发送失败:', errorMessage);
|
|
4352
|
-
return
|
|
4317
|
+
return _context51.abrupt("return", {
|
|
4353
4318
|
success: false,
|
|
4354
4319
|
message: errorMessage
|
|
4355
4320
|
});
|
|
4356
4321
|
case 24:
|
|
4357
|
-
|
|
4322
|
+
_context51.next = 31;
|
|
4358
4323
|
break;
|
|
4359
4324
|
case 26:
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
console.error('[Checkout] 发送客户支付链接邮件失败:',
|
|
4363
|
-
_errorMessage2 =
|
|
4364
|
-
return
|
|
4325
|
+
_context51.prev = 26;
|
|
4326
|
+
_context51.t0 = _context51["catch"](0);
|
|
4327
|
+
console.error('[Checkout] 发送客户支付链接邮件失败:', _context51.t0);
|
|
4328
|
+
_errorMessage2 = _context51.t0 instanceof Error ? _context51.t0.message : '网络错误或服务器异常';
|
|
4329
|
+
return _context51.abrupt("return", {
|
|
4365
4330
|
success: false,
|
|
4366
4331
|
message: "\u53D1\u9001\u652F\u4ED8\u94FE\u63A5\u90AE\u4EF6\u5931\u8D25: ".concat(_errorMessage2)
|
|
4367
4332
|
});
|
|
4368
4333
|
case 31:
|
|
4369
4334
|
case "end":
|
|
4370
|
-
return
|
|
4335
|
+
return _context51.stop();
|
|
4371
4336
|
}
|
|
4372
|
-
},
|
|
4337
|
+
}, _callee51, this, [[0, 26]]);
|
|
4373
4338
|
}));
|
|
4374
|
-
function sendCustomerPayLinkAsync(
|
|
4339
|
+
function sendCustomerPayLinkAsync(_x33) {
|
|
4375
4340
|
return _sendCustomerPayLinkAsync.apply(this, arguments);
|
|
4376
4341
|
}
|
|
4377
4342
|
return sendCustomerPayLinkAsync;
|
|
@@ -4386,25 +4351,25 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4386
4351
|
}, {
|
|
4387
4352
|
key: "roundAmountAsync",
|
|
4388
4353
|
value: (function () {
|
|
4389
|
-
var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4354
|
+
var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(amount) {
|
|
4390
4355
|
var _this$otherParams$ord, _this$otherParams$ord2;
|
|
4391
4356
|
var result;
|
|
4392
|
-
return _regeneratorRuntime().wrap(function
|
|
4393
|
-
while (1) switch (
|
|
4357
|
+
return _regeneratorRuntime().wrap(function _callee52$(_context52) {
|
|
4358
|
+
while (1) switch (_context52.prev = _context52.next) {
|
|
4394
4359
|
case 0:
|
|
4395
|
-
|
|
4360
|
+
_context52.next = 2;
|
|
4396
4361
|
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);
|
|
4397
4362
|
case 2:
|
|
4398
|
-
result =
|
|
4363
|
+
result = _context52.sent;
|
|
4399
4364
|
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));
|
|
4400
|
-
return
|
|
4365
|
+
return _context52.abrupt("return", result);
|
|
4401
4366
|
case 5:
|
|
4402
4367
|
case "end":
|
|
4403
|
-
return
|
|
4368
|
+
return _context52.stop();
|
|
4404
4369
|
}
|
|
4405
|
-
},
|
|
4370
|
+
}, _callee52, this);
|
|
4406
4371
|
}));
|
|
4407
|
-
function roundAmountAsync(
|
|
4372
|
+
function roundAmountAsync(_x34) {
|
|
4408
4373
|
return _roundAmountAsync.apply(this, arguments);
|
|
4409
4374
|
}
|
|
4410
4375
|
return roundAmountAsync;
|
|
@@ -4412,10 +4377,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4412
4377
|
}, {
|
|
4413
4378
|
key: "destroy",
|
|
4414
4379
|
value: function () {
|
|
4415
|
-
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4380
|
+
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53() {
|
|
4416
4381
|
var _this$order, _this$order$destroy, _this$payment, _this$payment$destroy;
|
|
4417
|
-
return _regeneratorRuntime().wrap(function
|
|
4418
|
-
while (1) switch (
|
|
4382
|
+
return _regeneratorRuntime().wrap(function _callee53$(_context53) {
|
|
4383
|
+
while (1) switch (_context53.prev = _context53.next) {
|
|
4419
4384
|
case 0:
|
|
4420
4385
|
// 清理钱包模块的所有缓存数据
|
|
4421
4386
|
this.payment.wallet.clearAllCache();
|
|
@@ -4424,10 +4389,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4424
4389
|
this.core.effects.offByModuleDestroy(this.name);
|
|
4425
4390
|
|
|
4426
4391
|
// 销毁子模块
|
|
4427
|
-
|
|
4392
|
+
_context53.next = 4;
|
|
4428
4393
|
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);
|
|
4429
4394
|
case 4:
|
|
4430
|
-
|
|
4395
|
+
_context53.next = 6;
|
|
4431
4396
|
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);
|
|
4432
4397
|
case 6:
|
|
4433
4398
|
// 取消注册模块
|
|
@@ -4435,9 +4400,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4435
4400
|
console.log('[Checkout] 已销毁');
|
|
4436
4401
|
case 8:
|
|
4437
4402
|
case "end":
|
|
4438
|
-
return
|
|
4403
|
+
return _context53.stop();
|
|
4439
4404
|
}
|
|
4440
|
-
},
|
|
4405
|
+
}, _callee53, this);
|
|
4441
4406
|
}));
|
|
4442
4407
|
function destroy() {
|
|
4443
4408
|
return _destroy.apply(this, arguments);
|
|
@@ -4452,12 +4417,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4452
4417
|
}, {
|
|
4453
4418
|
key: "resetStoreStateAsync",
|
|
4454
4419
|
value: (function () {
|
|
4455
|
-
var _resetStoreStateAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4420
|
+
var _resetStoreStateAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54() {
|
|
4456
4421
|
var prevOrderInfo;
|
|
4457
|
-
return _regeneratorRuntime().wrap(function
|
|
4458
|
-
while (1) switch (
|
|
4422
|
+
return _regeneratorRuntime().wrap(function _callee54$(_context54) {
|
|
4423
|
+
while (1) switch (_context54.prev = _context54.next) {
|
|
4459
4424
|
case 0:
|
|
4460
|
-
|
|
4425
|
+
_context54.prev = 0;
|
|
4461
4426
|
prevOrderInfo = this.store.currentOrder ? {
|
|
4462
4427
|
uuid: this.store.currentOrder.uuid,
|
|
4463
4428
|
orderId: this.store.currentOrder.order_id
|
|
@@ -4483,36 +4448,36 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4483
4448
|
// 注意:故意保留 this.store.paymentMethods,因为支付方式数据不易变更,保留在内存中提高性能
|
|
4484
4449
|
|
|
4485
4450
|
// 重置状态和步骤为初始状态
|
|
4486
|
-
|
|
4451
|
+
_context54.next = 15;
|
|
4487
4452
|
return this.setStatus(CheckoutStatus.Ready);
|
|
4488
4453
|
case 15:
|
|
4489
|
-
|
|
4454
|
+
_context54.next = 17;
|
|
4490
4455
|
return this.setStep(CheckoutStep.OrderConfirmation);
|
|
4491
4456
|
case 17:
|
|
4492
4457
|
console.log('[Checkout] Store 状态重置完成');
|
|
4493
4458
|
|
|
4494
4459
|
// 触发订单清理事件(如果之前有订单)
|
|
4495
4460
|
if (!prevOrderInfo) {
|
|
4496
|
-
|
|
4461
|
+
_context54.next = 21;
|
|
4497
4462
|
break;
|
|
4498
4463
|
}
|
|
4499
|
-
|
|
4464
|
+
_context54.next = 21;
|
|
4500
4465
|
return this.core.effects.emit(CheckoutHooks.OnOrderCleared, {
|
|
4501
4466
|
previousOrder: prevOrderInfo,
|
|
4502
4467
|
timestamp: Date.now()
|
|
4503
4468
|
});
|
|
4504
4469
|
case 21:
|
|
4505
|
-
|
|
4470
|
+
_context54.next = 26;
|
|
4506
4471
|
break;
|
|
4507
4472
|
case 23:
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
console.error('[Checkout] 重置 store 状态失败:',
|
|
4473
|
+
_context54.prev = 23;
|
|
4474
|
+
_context54.t0 = _context54["catch"](0);
|
|
4475
|
+
console.error('[Checkout] 重置 store 状态失败:', _context54.t0);
|
|
4511
4476
|
case 26:
|
|
4512
4477
|
case "end":
|
|
4513
|
-
return
|
|
4478
|
+
return _context54.stop();
|
|
4514
4479
|
}
|
|
4515
|
-
},
|
|
4480
|
+
}, _callee54, this, [[0, 23]]);
|
|
4516
4481
|
}));
|
|
4517
4482
|
function resetStoreStateAsync() {
|
|
4518
4483
|
return _resetStoreStateAsync.apply(this, arguments);
|
|
@@ -4530,37 +4495,37 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4530
4495
|
}, {
|
|
4531
4496
|
key: "clearCompletedOrderAsync",
|
|
4532
4497
|
value: (function () {
|
|
4533
|
-
var _clearCompletedOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4498
|
+
var _clearCompletedOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55() {
|
|
4534
4499
|
var prevOrderInfo;
|
|
4535
|
-
return _regeneratorRuntime().wrap(function
|
|
4536
|
-
while (1) switch (
|
|
4500
|
+
return _regeneratorRuntime().wrap(function _callee55$(_context55) {
|
|
4501
|
+
while (1) switch (_context55.prev = _context55.next) {
|
|
4537
4502
|
case 0:
|
|
4538
|
-
|
|
4503
|
+
_context55.prev = 0;
|
|
4539
4504
|
prevOrderInfo = this.store.currentOrder ? {
|
|
4540
4505
|
uuid: this.store.currentOrder.uuid,
|
|
4541
4506
|
orderId: this.store.currentOrder.order_id
|
|
4542
4507
|
} : null;
|
|
4543
|
-
|
|
4508
|
+
_context55.next = 4;
|
|
4544
4509
|
return this.resetStoreStateAsync();
|
|
4545
4510
|
case 4:
|
|
4546
|
-
return
|
|
4511
|
+
return _context55.abrupt("return", {
|
|
4547
4512
|
success: true,
|
|
4548
4513
|
message: prevOrderInfo ? '订单状态已成功清理' : '没有需要清理的订单状态',
|
|
4549
4514
|
clearedOrder: prevOrderInfo
|
|
4550
4515
|
});
|
|
4551
4516
|
case 7:
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
console.error('[Checkout] 手动清理订单状态失败:',
|
|
4555
|
-
return
|
|
4517
|
+
_context55.prev = 7;
|
|
4518
|
+
_context55.t0 = _context55["catch"](0);
|
|
4519
|
+
console.error('[Checkout] 手动清理订单状态失败:', _context55.t0);
|
|
4520
|
+
return _context55.abrupt("return", {
|
|
4556
4521
|
success: false,
|
|
4557
|
-
message:
|
|
4522
|
+
message: _context55.t0 instanceof Error ? _context55.t0.message : '清理失败'
|
|
4558
4523
|
});
|
|
4559
4524
|
case 11:
|
|
4560
4525
|
case "end":
|
|
4561
|
-
return
|
|
4526
|
+
return _context55.stop();
|
|
4562
4527
|
}
|
|
4563
|
-
},
|
|
4528
|
+
}, _callee55, this, [[0, 7]]);
|
|
4564
4529
|
}));
|
|
4565
4530
|
function clearCompletedOrderAsync() {
|
|
4566
4531
|
return _clearCompletedOrderAsync.apply(this, arguments);
|