@pisell/pisellos 0.0.243 → 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.
@@ -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
@@ -269,41 +270,39 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
269
270
  _context7.next = 3;
270
271
  return this.setStatus(CheckoutStatus.Initializing);
271
272
  case 3:
272
- _context7.next = 5;
273
- return this.validateCheckoutParams(params);
274
- case 5:
275
- validation = _context7.sent;
273
+ // 验证参数
274
+ validation = this.validateCheckoutParams(params);
276
275
  if (validation.valid) {
277
- _context7.next = 8;
276
+ _context7.next = 6;
278
277
  break;
279
278
  }
280
279
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, "\u53C2\u6570\u9A8C\u8BC1\u5931\u8D25: ".concat(validation.errors.join(', ')));
281
- case 8:
280
+ case 6:
282
281
  // 保存购物车数据
283
282
  this.store.cartItems = params.cartItems;
284
283
 
285
284
  // 设置为就绪状态
286
- _context7.next = 11;
285
+ _context7.next = 9;
287
286
  return this.setStatus(CheckoutStatus.Ready);
288
- case 11:
289
- _context7.next = 13;
287
+ case 9:
288
+ _context7.next = 11;
290
289
  return this.setStep(CheckoutStep.OrderConfirmation);
291
- case 13:
290
+ case 11:
292
291
  console.log('[Checkout] 结账流程初始化完成');
293
- _context7.next = 21;
292
+ _context7.next = 19;
294
293
  break;
295
- case 16:
296
- _context7.prev = 16;
294
+ case 14:
295
+ _context7.prev = 14;
297
296
  _context7.t0 = _context7["catch"](0);
298
- _context7.next = 20;
297
+ _context7.next = 18;
299
298
  return this.handleError(_context7.t0, CheckoutErrorType.UnknownError);
300
- case 20:
299
+ case 18:
301
300
  throw _context7.t0;
302
- case 21:
301
+ case 19:
303
302
  case "end":
304
303
  return _context7.stop();
305
304
  }
306
- }, _callee7, this, [[0, 16]]);
305
+ }, _callee7, this, [[0, 14]]);
307
306
  }));
308
307
  function initializeCheckoutAsync(_x9) {
309
308
  return _initializeCheckoutAsync.apply(this, arguments);
@@ -400,16 +399,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
400
399
  _context9.next = 5;
401
400
  return this.setStatus(CheckoutStatus.CreatingOrder);
402
401
  case 5:
403
- _context9.next = 7;
404
- return this.validateLocalOrderData(params.orderData);
405
- case 7:
406
- validation = _context9.sent;
402
+ // 验证订单数据
403
+ validation = this.validateLocalOrderData(params.orderData);
407
404
  if (validation.valid) {
408
- _context9.next = 10;
405
+ _context9.next = 8;
409
406
  break;
410
407
  }
411
408
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, "\u8BA2\u5355\u6570\u636E\u9A8C\u8BC1\u5931\u8D25: ".concat(validation.errors.join(', ')));
412
- case 10:
409
+ case 8:
413
410
  // 生成本地虚拟订单ID (后续可以被真实订单ID替换)
414
411
  localOrderId = this.generateLocalOrderId(); // 从购物车小计数据中提取金额信息
415
412
  amountInfo = this.extractAmountFromCartSummary(params.cartSummary); // TODO: 外面传的是 pos ,但是现在 后端只有 shop 和 kiosk
@@ -440,7 +437,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
440
437
  }
441
438
 
442
439
  // 创建支付订单对象
443
- _context9.next = 23;
440
+ _context9.next = 21;
444
441
  return this.payment.createPaymentOrderAsync({
445
442
  order_id: localOrderId,
446
443
  total_amount: amountInfo.totalAmount,
@@ -457,34 +454,32 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
457
454
  amount_breakdown: amountInfo
458
455
  }
459
456
  });
460
- case 23:
457
+ case 21:
461
458
  paymentOrder = _context9.sent;
462
459
  this.store.currentOrder = paymentOrder;
463
- _context9.next = 27;
464
- return this.initWalletData();
465
- case 27:
466
- _context9.next = 29;
460
+ this.initWalletData();
461
+ _context9.next = 26;
467
462
  return this.setStatus(CheckoutStatus.OrderCreated);
468
- case 29:
469
- _context9.next = 31;
463
+ case 26:
464
+ _context9.next = 28;
470
465
  return this.setStep(CheckoutStep.PaymentMethod);
471
- case 31:
466
+ case 28:
472
467
  if (!params.autoPayment) {
473
- _context9.next = 34;
468
+ _context9.next = 31;
474
469
  break;
475
470
  }
476
- _context9.next = 34;
471
+ _context9.next = 31;
477
472
  return this.setStep(CheckoutStep.PaymentProcessing);
478
- case 34:
479
- _context9.next = 36;
480
- return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
473
+ case 31:
474
+ this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
481
475
  order: paymentOrder,
482
476
  timestamp: Date.now()
483
477
  });
484
- case 36:
485
- _context9.next = 38;
478
+
479
+ // 自动设置 stateAmount 为剩余未支付金额
480
+ _context9.next = 34;
486
481
  return this.updateStateAmountToRemaining();
487
- case 38:
482
+ case 34:
488
483
  console.log('[Checkout] 本地订单创建成功:', {
489
484
  localOrderId: localOrderId,
490
485
  uuid: paymentOrder.uuid,
@@ -494,24 +489,22 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
494
489
  stateAmount: this.store.stateAmount
495
490
  });
496
491
  return _context9.abrupt("return", paymentOrder);
497
- case 42:
498
- _context9.prev = 42;
492
+ case 38:
493
+ _context9.prev = 38;
499
494
  _context9.t0 = _context9["catch"](0);
500
- _context9.next = 46;
495
+ _context9.next = 42;
501
496
  return this.handleError(_context9.t0, CheckoutErrorType.OrderCreationFailed);
502
- case 46:
503
- _context9.next = 48;
504
- return this.core.effects.emit(CheckoutHooks.OnOrderCreationFailed, {
497
+ case 42:
498
+ this.core.effects.emit(CheckoutHooks.OnOrderCreationFailed, {
505
499
  error: this.store.lastError,
506
500
  timestamp: Date.now()
507
501
  });
508
- case 48:
509
502
  throw _context9.t0;
510
- case 49:
503
+ case 44:
511
504
  case "end":
512
505
  return _context9.stop();
513
506
  }
514
- }, _callee9, this, [[0, 42]]);
507
+ }, _callee9, this, [[0, 38]]);
515
508
  }));
516
509
  function createLocalOrderAsync(_x11) {
517
510
  return _createLocalOrderAsync.apply(this, arguments);
@@ -934,30 +927,31 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
934
927
  this.payment.wallet.clearAllCache();
935
928
  this.store.cartItems = [];
936
929
  this.store.stateAmount = '0.00';
930
+ this.store.balanceDueAmount = '0.00';
937
931
  this.store.isOrderSynced = false;
938
932
  this.store.currentCustomer = undefined;
939
- _context14.next = 14;
933
+ _context14.next = 15;
940
934
  return this.setStatus(CheckoutStatus.Cancelled);
941
- case 14:
942
- _context14.next = 16;
935
+ case 15:
936
+ _context14.next = 17;
943
937
  return this.core.effects.emit(CheckoutHooks.OnCheckoutCancelled, {
944
938
  timestamp: Date.now()
945
939
  });
946
- case 16:
940
+ case 17:
947
941
  console.log('[Checkout] 结账流程已取消');
948
- _context14.next = 24;
942
+ _context14.next = 25;
949
943
  break;
950
- case 19:
951
- _context14.prev = 19;
944
+ case 20:
945
+ _context14.prev = 20;
952
946
  _context14.t0 = _context14["catch"](0);
953
947
  console.error('[Checkout] 取消结账失败:', _context14.t0);
954
- _context14.next = 24;
948
+ _context14.next = 25;
955
949
  return this.handleError(_context14.t0, CheckoutErrorType.UnknownError);
956
- case 24:
950
+ case 25:
957
951
  case "end":
958
952
  return _context14.stop();
959
953
  }
960
- }, _callee14, this, [[0, 19]]);
954
+ }, _callee14, this, [[0, 20]]);
961
955
  }));
962
956
  function cancelCheckoutAsync() {
963
957
  return _cancelCheckoutAsync.apply(this, arguments);
@@ -1507,6 +1501,19 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1507
1501
  return this.store.stateAmount;
1508
1502
  }
1509
1503
 
1504
+ /**
1505
+ * 获取系统计算的待付金额(只读)
1506
+ *
1507
+ * 此方法返回系统内部计算的实际待付金额,不允许外部修改
1508
+ *
1509
+ * @returns 当前系统计算的待付金额
1510
+ */
1511
+ }, {
1512
+ key: "getBalanceDueAmount",
1513
+ value: function getBalanceDueAmount() {
1514
+ return this.store.balanceDueAmount;
1515
+ }
1516
+
1510
1517
  /**
1511
1518
  * 刷新 stateAmount 为当前剩余未支付金额
1512
1519
  *
@@ -2458,6 +2465,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2458
2465
  this.store.currentOrder = undefined; // 释放 currentOrder
2459
2466
  this.store.localOrderData = undefined;
2460
2467
  this.store.stateAmount = '0.00';
2468
+ this.store.balanceDueAmount = '0.00';
2461
2469
  this.store.isOrderSynced = false;
2462
2470
  this.store.currentCustomer = undefined;
2463
2471
 
@@ -2466,7 +2474,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2466
2474
  console.log('[Checkout] 订单状态清理完成,currentOrder已释放');
2467
2475
 
2468
2476
  // 触发订单取消事件
2469
- _context32.next = 32;
2477
+ _context32.next = 33;
2470
2478
  return this.core.effects.emit(CheckoutHooks.OnOrderCancelled, {
2471
2479
  orderUuid: currentOrderUuid,
2472
2480
  orderId: currentOrderId,
@@ -2475,7 +2483,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2475
2483
  // 只有未同步订单可以被取消
2476
2484
  timestamp: Date.now()
2477
2485
  });
2478
- case 32:
2486
+ case 33:
2479
2487
  console.log('[Checkout] 本地订单取消完成:', {
2480
2488
  orderUuid: currentOrderUuid,
2481
2489
  orderId: currentOrderId,
@@ -2486,8 +2494,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2486
2494
  message: '本地订单已成功取消',
2487
2495
  orderId: currentOrderId
2488
2496
  });
2489
- case 36:
2490
- _context32.prev = 36;
2497
+ case 37:
2498
+ _context32.prev = 37;
2491
2499
  _context32.t1 = _context32["catch"](0);
2492
2500
  console.error('[Checkout] 取消本地订单失败:', _context32.t1);
2493
2501
  errorMessage = _context32.t1 instanceof Error ? _context32.t1.message : '未知错误';
@@ -2495,11 +2503,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2495
2503
  success: false,
2496
2504
  message: "\u53D6\u6D88\u8BA2\u5355\u5931\u8D25: ".concat(errorMessage)
2497
2505
  });
2498
- case 41:
2506
+ case 42:
2499
2507
  case "end":
2500
2508
  return _context32.stop();
2501
2509
  }
2502
- }, _callee32, this, [[0, 36], [12, 19]]);
2510
+ }, _callee32, this, [[0, 37], [12, 19]]);
2503
2511
  }));
2504
2512
  function cancelCurrentOrderAsync(_x21) {
2505
2513
  return _cancelCurrentOrderAsync.apply(this, arguments);
@@ -3013,80 +3021,53 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3013
3021
  )
3014
3022
  }, {
3015
3023
  key: "validateCheckoutParams",
3016
- value: (function () {
3017
- var _validateCheckoutParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
3018
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3019
- while (1) switch (_context41.prev = _context41.next) {
3020
- case 0:
3021
- return _context41.abrupt("return", validateCheckoutData(params));
3022
- case 1:
3023
- case "end":
3024
- return _context41.stop();
3025
- }
3026
- }, _callee41);
3027
- }));
3028
- function validateCheckoutParams(_x30) {
3029
- return _validateCheckoutParams.apply(this, arguments);
3030
- }
3031
- return validateCheckoutParams;
3032
- }()
3024
+ value: function validateCheckoutParams(params) {
3025
+ return validateCheckoutData(params);
3026
+ }
3027
+
3033
3028
  /**
3034
3029
  * 验证本地订单数据
3035
3030
  */
3036
- )
3037
3031
  }, {
3038
3032
  key: "validateLocalOrderData",
3039
- value: (function () {
3040
- var _validateLocalOrderData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(orderData) {
3041
- var _orderData$relation_p;
3042
- var errors;
3043
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3044
- while (1) switch (_context42.prev = _context42.next) {
3045
- case 0:
3046
- errors = []; // 验证基本字段
3047
- if (!orderData.type) {
3048
- errors.push('订单类型不能为空');
3049
- }
3050
- if (!orderData.platform) {
3051
- errors.push('平台信息不能为空');
3052
- }
3053
- 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)) {
3054
- errors.push('预订信息不能为空');
3055
- }
3033
+ value: function validateLocalOrderData(orderData) {
3034
+ var _orderData$relation_p;
3035
+ var errors = [];
3056
3036
 
3057
- // 验证预订信息
3058
- if (orderData.bookings) {
3059
- orderData.bookings.forEach(function (booking, index) {
3060
- if (!booking.product || !booking.product.product_id) {
3061
- errors.push("\u9884\u8BA2\u9879 ".concat(index + 1, " \u7F3A\u5C11\u5546\u54C1\u4FE1\u606F"));
3062
- }
3063
- if (!booking.start_date) {
3064
- errors.push("\u9884\u8BA2\u9879 ".concat(index + 1, " \u7F3A\u5C11\u5F00\u59CB\u65E5\u671F"));
3065
- }
3066
- if (!booking.start_time) {
3067
- errors.push("\u9884\u8BA2\u9879 ".concat(index + 1, " \u7F3A\u5C11\u5F00\u59CB\u65F6\u95F4"));
3068
- }
3069
- });
3070
- }
3071
- return _context42.abrupt("return", {
3072
- valid: errors.length === 0,
3073
- errors: errors
3074
- });
3075
- case 6:
3076
- case "end":
3077
- 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"));
3078
3053
  }
3079
- }, _callee42);
3080
- }));
3081
- function validateLocalOrderData(_x31) {
3082
- return _validateLocalOrderData.apply(this, arguments);
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
+ });
3083
3061
  }
3084
- return validateLocalOrderData;
3085
- }()
3062
+ return {
3063
+ valid: errors.length === 0,
3064
+ errors: errors
3065
+ };
3066
+ }
3067
+
3086
3068
  /**
3087
3069
  * 生成本地订单ID
3088
3070
  */
3089
- )
3090
3071
  }, {
3091
3072
  key: "generateLocalOrderId",
3092
3073
  value: function generateLocalOrderId() {
@@ -3176,31 +3157,31 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3176
3157
  }, {
3177
3158
  key: "preloadPaymentMethods",
3178
3159
  value: (function () {
3179
- var _preloadPaymentMethods = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43() {
3160
+ var _preloadPaymentMethods = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41() {
3180
3161
  var methods;
3181
- return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3182
- while (1) switch (_context43.prev = _context43.next) {
3162
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3163
+ while (1) switch (_context41.prev = _context41.next) {
3183
3164
  case 0:
3184
- _context43.prev = 0;
3165
+ _context41.prev = 0;
3185
3166
  console.log('[Checkout] 预加载支付方式...');
3186
- _context43.next = 4;
3167
+ _context41.next = 4;
3187
3168
  return this.payment.getPayMethodListAsync();
3188
3169
  case 4:
3189
- methods = _context43.sent;
3170
+ methods = _context41.sent;
3190
3171
  this.store.paymentMethods = methods;
3191
3172
  console.log("[Checkout] \u9884\u52A0\u8F7D\u5B8C\u6210\uFF0C\u5171 ".concat(methods.length, " \u79CD\u652F\u4ED8\u65B9\u5F0F"));
3192
- _context43.next = 13;
3173
+ _context41.next = 13;
3193
3174
  break;
3194
3175
  case 9:
3195
- _context43.prev = 9;
3196
- _context43.t0 = _context43["catch"](0);
3197
- console.error('[Checkout] 预加载支付方式失败:', _context43.t0);
3176
+ _context41.prev = 9;
3177
+ _context41.t0 = _context41["catch"](0);
3178
+ console.error('[Checkout] 预加载支付方式失败:', _context41.t0);
3198
3179
  this.store.paymentMethods = [];
3199
3180
  case 13:
3200
3181
  case "end":
3201
- return _context43.stop();
3182
+ return _context41.stop();
3202
3183
  }
3203
- }, _callee43, this, [[0, 9]]);
3184
+ }, _callee41, this, [[0, 9]]);
3204
3185
  }));
3205
3186
  function preloadPaymentMethods() {
3206
3187
  return _preloadPaymentMethods.apply(this, arguments);
@@ -3228,24 +3209,24 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3228
3209
  }, {
3229
3210
  key: "calculatePaidAmountAsync",
3230
3211
  value: (function () {
3231
- var _calculatePaidAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
3212
+ var _calculatePaidAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42() {
3232
3213
  var payments, paidAmount, result;
3233
- return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3234
- while (1) switch (_context44.prev = _context44.next) {
3214
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3215
+ while (1) switch (_context42.prev = _context42.next) {
3235
3216
  case 0:
3236
3217
  if (this.store.currentOrder) {
3237
- _context44.next = 3;
3218
+ _context42.next = 3;
3238
3219
  break;
3239
3220
  }
3240
3221
  console.log('[Checkout] calculatePaidAmountAsync: 没有当前订单');
3241
- return _context44.abrupt("return", '0.00');
3222
+ return _context42.abrupt("return", '0.00');
3242
3223
  case 3:
3243
- _context44.prev = 3;
3244
- _context44.next = 6;
3224
+ _context42.prev = 3;
3225
+ _context42.next = 6;
3245
3226
  return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid, false // 不包括已撤销的支付项
3246
3227
  );
3247
3228
  case 6:
3248
- payments = _context44.sent;
3229
+ payments = _context42.sent;
3249
3230
  console.log('[Checkout] calculatePaidAmountAsync: 支付项详情:', {
3250
3231
  paymentCount: payments.length,
3251
3232
  payments: payments.map(function (p) {
@@ -3267,17 +3248,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3267
3248
  }, 0);
3268
3249
  result = paidAmount.toFixed(2);
3269
3250
  console.log('[Checkout] calculatePaidAmountAsync: 计算结果 =', result);
3270
- return _context44.abrupt("return", result);
3251
+ return _context42.abrupt("return", result);
3271
3252
  case 14:
3272
- _context44.prev = 14;
3273
- _context44.t0 = _context44["catch"](3);
3274
- console.error('[Checkout] calculatePaidAmountAsync 失败:', _context44.t0);
3275
- return _context44.abrupt("return", '0.00');
3253
+ _context42.prev = 14;
3254
+ _context42.t0 = _context42["catch"](3);
3255
+ console.error('[Checkout] calculatePaidAmountAsync 失败:', _context42.t0);
3256
+ return _context42.abrupt("return", '0.00');
3276
3257
  case 18:
3277
3258
  case "end":
3278
- return _context44.stop();
3259
+ return _context42.stop();
3279
3260
  }
3280
- }, _callee44, this, [[3, 14]]);
3261
+ }, _callee42, this, [[3, 14]]);
3281
3262
  }));
3282
3263
  function calculatePaidAmountAsync() {
3283
3264
  return _calculatePaidAmountAsync.apply(this, arguments);
@@ -3291,25 +3272,25 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3291
3272
  }, {
3292
3273
  key: "calculateRemainingAmountAsync",
3293
3274
  value: (function () {
3294
- var _calculateRemainingAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45() {
3275
+ var _calculateRemainingAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43() {
3295
3276
  var totalAmount, paidAmount, remainingAmount, result;
3296
- return _regeneratorRuntime().wrap(function _callee45$(_context45) {
3297
- while (1) switch (_context45.prev = _context45.next) {
3277
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3278
+ while (1) switch (_context43.prev = _context43.next) {
3298
3279
  case 0:
3299
3280
  if (this.store.currentOrder) {
3300
- _context45.next = 3;
3281
+ _context43.next = 3;
3301
3282
  break;
3302
3283
  }
3303
3284
  console.log('[Checkout] calculateRemainingAmountAsync: 没有当前订单');
3304
- return _context45.abrupt("return", '0.00');
3285
+ return _context43.abrupt("return", '0.00');
3305
3286
  case 3:
3306
3287
  totalAmount = parseFloat(this.store.currentOrder.total_amount || '0');
3307
- _context45.t0 = parseFloat;
3308
- _context45.next = 7;
3288
+ _context43.t0 = parseFloat;
3289
+ _context43.next = 7;
3309
3290
  return this.calculatePaidAmountAsync();
3310
3291
  case 7:
3311
- _context45.t1 = _context45.sent;
3312
- paidAmount = (0, _context45.t0)(_context45.t1);
3292
+ _context43.t1 = _context43.sent;
3293
+ paidAmount = (0, _context43.t0)(_context43.t1);
3313
3294
  remainingAmount = totalAmount - paidAmount;
3314
3295
  result = Math.max(0, remainingAmount).toFixed(2);
3315
3296
  console.log('[Checkout] calculateRemainingAmountAsync: 计算详情:', {
@@ -3319,18 +3300,87 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3319
3300
  calculatedRemaining: remainingAmount.toFixed(2),
3320
3301
  finalResult: result
3321
3302
  });
3322
- return _context45.abrupt("return", result);
3303
+ return _context43.abrupt("return", result);
3323
3304
  case 13:
3324
3305
  case "end":
3325
- return _context45.stop();
3306
+ return _context43.stop();
3326
3307
  }
3327
- }, _callee45, this);
3308
+ }, _callee43, this);
3328
3309
  }));
3329
3310
  function calculateRemainingAmountAsync() {
3330
3311
  return _calculateRemainingAmountAsync.apply(this, arguments);
3331
3312
  }
3332
3313
  return calculateRemainingAmountAsync;
3333
3314
  }()
3315
+ /**
3316
+ * 更新 balanceDueAmount 为当前剩余未支付金额(系统内部计算)
3317
+ */
3318
+ )
3319
+ }, {
3320
+ key: "updateBalanceDueAmount",
3321
+ value: (function () {
3322
+ var _updateBalanceDueAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
3323
+ var _this$store$currentOr17, remainingAmount, currentBalanceDueAmount;
3324
+ return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3325
+ while (1) switch (_context44.prev = _context44.next) {
3326
+ case 0:
3327
+ _context44.prev = 0;
3328
+ _context44.next = 3;
3329
+ return this.calculateRemainingAmountAsync();
3330
+ case 3:
3331
+ remainingAmount = _context44.sent;
3332
+ currentBalanceDueAmount = this.store.balanceDueAmount;
3333
+ console.log('[Checkout] updateBalanceDueAmount: 状态检查:', {
3334
+ calculatedRemainingAmount: remainingAmount,
3335
+ currentBalanceDueAmount: currentBalanceDueAmount,
3336
+ needsUpdate: remainingAmount !== currentBalanceDueAmount,
3337
+ orderUuid: (_this$store$currentOr17 = this.store.currentOrder) === null || _this$store$currentOr17 === void 0 ? void 0 : _this$store$currentOr17.uuid
3338
+ });
3339
+
3340
+ // 只有当剩余金额与当前 balanceDueAmount 不同时才更新
3341
+ if (!(remainingAmount !== currentBalanceDueAmount)) {
3342
+ _context44.next = 13;
3343
+ break;
3344
+ }
3345
+ this.store.balanceDueAmount = remainingAmount;
3346
+
3347
+ // 发出 balanceDueAmount 变更事件
3348
+ _context44.next = 10;
3349
+ return this.core.effects.emit(CheckoutHooks.OnBalanceDueAmountChanged, {
3350
+ oldAmount: currentBalanceDueAmount,
3351
+ newAmount: remainingAmount,
3352
+ timestamp: Date.now()
3353
+ });
3354
+ case 10:
3355
+ console.log('[Checkout] balanceDueAmount 已自动更新:', {
3356
+ oldAmount: currentBalanceDueAmount,
3357
+ newAmount: remainingAmount
3358
+ });
3359
+ _context44.next = 14;
3360
+ break;
3361
+ case 13:
3362
+ console.log('[Checkout] balanceDueAmount 无需更新,当前值已是最新:', {
3363
+ balanceDueAmount: currentBalanceDueAmount,
3364
+ remainingAmount: remainingAmount
3365
+ });
3366
+ case 14:
3367
+ _context44.next = 19;
3368
+ break;
3369
+ case 16:
3370
+ _context44.prev = 16;
3371
+ _context44.t0 = _context44["catch"](0);
3372
+ console.error('[Checkout] 更新 balanceDueAmount 失败:', _context44.t0);
3373
+ case 19:
3374
+ case "end":
3375
+ return _context44.stop();
3376
+ }
3377
+ }, _callee44, this, [[0, 16]]);
3378
+ }));
3379
+ function updateBalanceDueAmount() {
3380
+ return _updateBalanceDueAmount.apply(this, arguments);
3381
+ }
3382
+ return updateBalanceDueAmount;
3383
+ }()
3334
3384
  /**
3335
3385
  * 更新 stateAmount 为当前剩余未支付金额
3336
3386
  */
@@ -3338,33 +3388,33 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3338
3388
  }, {
3339
3389
  key: "updateStateAmountToRemaining",
3340
3390
  value: (function () {
3341
- var _updateStateAmountToRemaining = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
3342
- var _this$store$currentOr17, remainingAmount, currentStateAmount;
3343
- return _regeneratorRuntime().wrap(function _callee46$(_context46) {
3344
- while (1) switch (_context46.prev = _context46.next) {
3391
+ var _updateStateAmountToRemaining = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45() {
3392
+ var _this$store$currentOr18, remainingAmount, currentStateAmount;
3393
+ return _regeneratorRuntime().wrap(function _callee45$(_context45) {
3394
+ while (1) switch (_context45.prev = _context45.next) {
3345
3395
  case 0:
3346
- _context46.prev = 0;
3347
- _context46.next = 3;
3396
+ _context45.prev = 0;
3397
+ _context45.next = 3;
3348
3398
  return this.calculateRemainingAmountAsync();
3349
3399
  case 3:
3350
- remainingAmount = _context46.sent;
3400
+ remainingAmount = _context45.sent;
3351
3401
  currentStateAmount = this.store.stateAmount;
3352
3402
  console.log('[Checkout] updateStateAmountToRemaining: 状态检查:', {
3353
3403
  calculatedRemainingAmount: remainingAmount,
3354
3404
  currentStateAmount: currentStateAmount,
3355
3405
  needsUpdate: remainingAmount !== currentStateAmount,
3356
- orderUuid: (_this$store$currentOr17 = this.store.currentOrder) === null || _this$store$currentOr17 === void 0 ? void 0 : _this$store$currentOr17.uuid
3406
+ orderUuid: (_this$store$currentOr18 = this.store.currentOrder) === null || _this$store$currentOr18 === void 0 ? void 0 : _this$store$currentOr18.uuid
3357
3407
  });
3358
3408
 
3359
3409
  // 只有当剩余金额与当前 stateAmount 不同时才更新
3360
3410
  if (!(remainingAmount !== currentStateAmount)) {
3361
- _context46.next = 13;
3411
+ _context45.next = 13;
3362
3412
  break;
3363
3413
  }
3364
3414
  this.store.stateAmount = remainingAmount;
3365
3415
 
3366
3416
  // 发出 stateAmount 变更事件
3367
- _context46.next = 10;
3417
+ _context45.next = 10;
3368
3418
  return this.core.effects.emit(CheckoutHooks.OnStateAmountChanged, {
3369
3419
  oldAmount: currentStateAmount,
3370
3420
  newAmount: remainingAmount,
@@ -3375,7 +3425,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3375
3425
  oldAmount: currentStateAmount,
3376
3426
  newAmount: remainingAmount
3377
3427
  });
3378
- _context46.next = 14;
3428
+ _context45.next = 14;
3379
3429
  break;
3380
3430
  case 13:
3381
3431
  console.log('[Checkout] stateAmount 无需更新,当前值已是最新:', {
@@ -3383,20 +3433,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3383
3433
  remainingAmount: remainingAmount
3384
3434
  });
3385
3435
  case 14:
3386
- _context46.next = 16;
3387
- return this.checkOrderPaymentCompletion();
3436
+ _context45.next = 16;
3437
+ return this.updateBalanceDueAmount();
3388
3438
  case 16:
3389
- _context46.next = 21;
3390
- break;
3439
+ _context45.next = 18;
3440
+ return this.checkOrderPaymentCompletion();
3391
3441
  case 18:
3392
- _context46.prev = 18;
3393
- _context46.t0 = _context46["catch"](0);
3394
- console.error('[Checkout] 更新 stateAmount 为剩余金额失败:', _context46.t0);
3395
- case 21:
3442
+ _context45.next = 23;
3443
+ break;
3444
+ case 20:
3445
+ _context45.prev = 20;
3446
+ _context45.t0 = _context45["catch"](0);
3447
+ console.error('[Checkout] 更新 stateAmount 为剩余金额失败:', _context45.t0);
3448
+ case 23:
3396
3449
  case "end":
3397
- return _context46.stop();
3450
+ return _context45.stop();
3398
3451
  }
3399
- }, _callee46, this, [[0, 18]]);
3452
+ }, _callee45, this, [[0, 20]]);
3400
3453
  }));
3401
3454
  function updateStateAmountToRemaining() {
3402
3455
  return _updateStateAmountToRemaining.apply(this, arguments);
@@ -3412,32 +3465,32 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3412
3465
  }, {
3413
3466
  key: "checkOrderPaymentCompletion",
3414
3467
  value: (function () {
3415
- var _checkOrderPaymentCompletion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47() {
3468
+ var _checkOrderPaymentCompletion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
3416
3469
  var remainingAmount, remainingValue, totalAmount, paidAmount, currentPayments, hasPaymentItems, allPaymentsHaveVoucherId, shouldAutoSync;
3417
- return _regeneratorRuntime().wrap(function _callee47$(_context47) {
3418
- while (1) switch (_context47.prev = _context47.next) {
3470
+ return _regeneratorRuntime().wrap(function _callee46$(_context46) {
3471
+ while (1) switch (_context46.prev = _context46.next) {
3419
3472
  case 0:
3420
- _context47.prev = 0;
3473
+ _context46.prev = 0;
3421
3474
  if (this.store.currentOrder) {
3422
- _context47.next = 3;
3475
+ _context46.next = 3;
3423
3476
  break;
3424
3477
  }
3425
- return _context47.abrupt("return");
3478
+ return _context46.abrupt("return");
3426
3479
  case 3:
3427
- _context47.next = 5;
3480
+ _context46.next = 5;
3428
3481
  return this.calculateRemainingAmountAsync();
3429
3482
  case 5:
3430
- remainingAmount = _context47.sent;
3483
+ remainingAmount = _context46.sent;
3431
3484
  remainingValue = parseFloat(remainingAmount); // 当剩余金额小于等于0时,认为订单已完成支付
3432
3485
  if (!(remainingValue <= 0)) {
3433
- _context47.next = 29;
3486
+ _context46.next = 29;
3434
3487
  break;
3435
3488
  }
3436
3489
  totalAmount = this.store.currentOrder.total_amount;
3437
- _context47.next = 11;
3490
+ _context46.next = 11;
3438
3491
  return this.calculatePaidAmountAsync();
3439
3492
  case 11:
3440
- paidAmount = _context47.sent;
3493
+ paidAmount = _context46.sent;
3441
3494
  console.log('[Checkout] 检测到订单支付完成:', {
3442
3495
  orderUuid: this.store.currentOrder.uuid,
3443
3496
  orderId: this.store.currentOrder.order_id,
@@ -3448,11 +3501,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3448
3501
  });
3449
3502
 
3450
3503
  // 从 Payment 模块获取最新支付项,检查自动同步条件
3451
- _context47.next = 15;
3504
+ _context46.next = 15;
3452
3505
  return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid, false // 不包括已撤销的支付项
3453
3506
  );
3454
3507
  case 15:
3455
- currentPayments = _context47.sent;
3508
+ currentPayments = _context46.sent;
3456
3509
  // 检查自动同步条件:
3457
3510
  // 1. 待付金额为 0 ✓ (已在上面检查)
3458
3511
  // 2. 需要有支付项
@@ -3484,14 +3537,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3484
3537
  })
3485
3538
  });
3486
3539
  if (!shouldAutoSync) {
3487
- _context47.next = 26;
3540
+ _context46.next = 26;
3488
3541
  break;
3489
3542
  }
3490
3543
  console.log('[Checkout] 满足自动同步条件,开始同步订单到后端...');
3491
- _context47.next = 24;
3544
+ _context46.next = 24;
3492
3545
  return this.syncOrderToBackend();
3493
3546
  case 24:
3494
- _context47.next = 27;
3547
+ _context46.next = 27;
3495
3548
  break;
3496
3549
  case 26:
3497
3550
  if (!hasPaymentItems) {
@@ -3500,7 +3553,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3500
3553
  console.log('[Checkout] 所有支付项均为代金券类型,跳过订单同步');
3501
3554
  }
3502
3555
  case 27:
3503
- _context47.next = 29;
3556
+ _context46.next = 29;
3504
3557
  return this.core.effects.emit(CheckoutHooks.OnOrderPaymentCompleted, {
3505
3558
  orderUuid: this.store.currentOrder.uuid,
3506
3559
  orderId: this.store.currentOrder.order_id,
@@ -3510,17 +3563,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3510
3563
  timestamp: Date.now()
3511
3564
  });
3512
3565
  case 29:
3513
- _context47.next = 34;
3566
+ _context46.next = 34;
3514
3567
  break;
3515
3568
  case 31:
3516
- _context47.prev = 31;
3517
- _context47.t0 = _context47["catch"](0);
3518
- console.error('[Checkout] 检查订单支付完成状态失败:', _context47.t0);
3569
+ _context46.prev = 31;
3570
+ _context46.t0 = _context46["catch"](0);
3571
+ console.error('[Checkout] 检查订单支付完成状态失败:', _context46.t0);
3519
3572
  case 34:
3520
3573
  case "end":
3521
- return _context47.stop();
3574
+ return _context46.stop();
3522
3575
  }
3523
- }, _callee47, this, [[0, 31]]);
3576
+ }, _callee46, this, [[0, 31]]);
3524
3577
  }));
3525
3578
  function checkOrderPaymentCompletion() {
3526
3579
  return _checkOrderPaymentCompletion.apply(this, arguments);
@@ -3592,8 +3645,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3592
3645
  }, {
3593
3646
  key: "syncOrderToBackendWithReturn",
3594
3647
  value: (function () {
3595
- var _syncOrderToBackendWithReturn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48() {
3596
- var _this$store$currentCu2, _this$store$currentOr18, _this$store$currentOr19, _checkoutResponse3, _checkoutResponse4, _checkoutResponse5, _checkoutResponse6;
3648
+ var _syncOrderToBackendWithReturn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47() {
3649
+ var _this$store$currentCu2, _this$store$currentOr19, _this$store$currentOr20, _checkoutResponse3, _checkoutResponse4, _checkoutResponse5, _checkoutResponse6, _checkoutResponse7, _checkoutResponse8;
3597
3650
  var isManual,
3598
3651
  customPaymentItems,
3599
3652
  syncType,
@@ -3610,22 +3663,28 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3610
3663
  submitError,
3611
3664
  _checkoutResponse,
3612
3665
  _checkoutResponse2,
3666
+ responseStatus,
3667
+ isSuccessResponse,
3668
+ _checkoutResponse9,
3669
+ _checkoutResponse10,
3670
+ _checkoutResponse11,
3671
+ errorMessage,
3613
3672
  realOrderId,
3614
- _checkoutResponse7,
3673
+ _checkoutResponse12,
3615
3674
  extractedOrderId,
3616
- _checkoutResponse8,
3675
+ _checkoutResponse13,
3617
3676
  updatedOrder,
3618
3677
  beforeManualUpdate,
3619
3678
  finalOrderId,
3620
3679
  finalIsVirtual,
3621
- _args48 = arguments;
3622
- return _regeneratorRuntime().wrap(function _callee48$(_context48) {
3623
- while (1) switch (_context48.prev = _context48.next) {
3680
+ _args47 = arguments;
3681
+ return _regeneratorRuntime().wrap(function _callee47$(_context47) {
3682
+ while (1) switch (_context47.prev = _context47.next) {
3624
3683
  case 0:
3625
- isManual = _args48.length > 0 && _args48[0] !== undefined ? _args48[0] : false;
3626
- customPaymentItems = _args48.length > 1 ? _args48[1] : undefined;
3684
+ isManual = _args47.length > 0 && _args47[0] !== undefined ? _args47[0] : false;
3685
+ customPaymentItems = _args47.length > 1 ? _args47[1] : undefined;
3627
3686
  if (!(!this.store.localOrderData || !this.store.currentOrder)) {
3628
- _context48.next = 4;
3687
+ _context47.next = 4;
3629
3688
  break;
3630
3689
  }
3631
3690
  throw new Error('缺少必要的订单数据,无法同步到后端');
@@ -3666,17 +3725,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3666
3725
  });
3667
3726
 
3668
3727
  // 获取当前订单的支付项
3669
- _context48.t0 = customPaymentItems;
3670
- if (_context48.t0) {
3671
- _context48.next = 18;
3728
+ _context47.t0 = customPaymentItems;
3729
+ if (_context47.t0) {
3730
+ _context47.next = 18;
3672
3731
  break;
3673
3732
  }
3674
- _context48.next = 17;
3733
+ _context47.next = 17;
3675
3734
  return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid);
3676
3735
  case 17:
3677
- _context48.t0 = _context48.sent;
3736
+ _context47.t0 = _context47.sent;
3678
3737
  case 18:
3679
- paymentItems = _context48.t0;
3738
+ paymentItems = _context47.t0;
3680
3739
  console.log('[Checkout] 获取到支付项:', {
3681
3740
  count: paymentItems.length,
3682
3741
  isCustomFiltered: !!customPaymentItems,
@@ -3717,8 +3776,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3717
3776
  currency_code: this.otherParams.currency_code,
3718
3777
  currency_symbol: this.otherParams.currency_symbol,
3719
3778
  currency_format: this.otherParams.currency_format,
3720
- is_deposit: ((_this$store$currentOr18 = this.store.currentOrder) === null || _this$store$currentOr18 === void 0 ? void 0 : _this$store$currentOr18.is_deposit) || 0,
3721
- deposit_amount: ((_this$store$currentOr19 = this.store.currentOrder) === null || _this$store$currentOr19 === void 0 ? void 0 : _this$store$currentOr19.deposit_amount) || '0.00',
3779
+ is_deposit: ((_this$store$currentOr19 = this.store.currentOrder) === null || _this$store$currentOr19 === void 0 ? void 0 : _this$store$currentOr19.is_deposit) || 0,
3780
+ deposit_amount: ((_this$store$currentOr20 = this.store.currentOrder) === null || _this$store$currentOr20 === void 0 ? void 0 : _this$store$currentOr20.deposit_amount) || '0.00',
3722
3781
  // surcharge_fee: this.otherParams.surcharge_fee,
3723
3782
  // surcharges: ,
3724
3783
  note: this.store.localOrderData.shop_note
@@ -3749,7 +3808,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3749
3808
 
3750
3809
  // 发送下单接口请求开始事件
3751
3810
  startTime = Date.now();
3752
- _context48.next = 25;
3811
+ _context47.next = 25;
3753
3812
  return this.core.effects.emit(CheckoutHooks.OnOrderSubmitStart, {
3754
3813
  orderUuid: this.store.currentOrder.uuid,
3755
3814
  operation: isUpdateOperation ? 'update' : 'create',
@@ -3759,25 +3818,38 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3759
3818
  });
3760
3819
  case 25:
3761
3820
  submitSuccess = false;
3762
- _context48.prev = 26;
3763
- _context48.next = 29;
3821
+ _context47.prev = 26;
3822
+ _context47.next = 29;
3764
3823
  return this.order.createOrderByCheckout(orderParams);
3765
3824
  case 29:
3766
- checkoutResponse = _context48.sent;
3825
+ checkoutResponse = _context47.sent;
3767
3826
  submitSuccess = true;
3768
3827
  console.log('[Checkout] 下单接口调用成功');
3769
- _context48.next = 40;
3828
+ _context47.next = 41;
3770
3829
  break;
3771
3830
  case 34:
3772
- _context48.prev = 34;
3773
- _context48.t1 = _context48["catch"](26);
3831
+ _context47.prev = 34;
3832
+ _context47.t1 = _context47["catch"](26);
3774
3833
  submitSuccess = false;
3775
- submitError = _context48.t1 instanceof Error ? _context48.t1.message : String(_context48.t1);
3776
- console.error('[Checkout] 下单接口调用失败:', submitError);
3777
- throw _context48.t1;
3834
+ submitError = _context47.t1 instanceof Error ? _context47.t1.message : String(_context47.t1);
3835
+ // console.error('[Checkout] 下单接口调用失败:', submitError);
3836
+
3837
+ // 发送订单同步失败事件(网络错误或请求失败)
3838
+ _context47.next = 40;
3839
+ return this.core.effects.emit(CheckoutHooks.OnOrderSyncFailed, {
3840
+ orderUuid: this.store.currentOrder.uuid,
3841
+ operation: isUpdateOperation ? 'update' : 'create',
3842
+ isManual: isManual,
3843
+ error: submitError,
3844
+ errorType: 'network_error',
3845
+ duration: Date.now() - startTime,
3846
+ timestamp: Date.now()
3847
+ });
3778
3848
  case 40:
3779
- _context48.prev = 40;
3780
- _context48.next = 43;
3849
+ throw _context47.t1;
3850
+ case 41:
3851
+ _context47.prev = 41;
3852
+ _context47.next = 44;
3781
3853
  return this.core.effects.emit(CheckoutHooks.OnOrderSubmitEnd, {
3782
3854
  success: submitSuccess,
3783
3855
  orderUuid: this.store.currentOrder.uuid,
@@ -3788,29 +3860,62 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3788
3860
  duration: Date.now() - startTime,
3789
3861
  timestamp: Date.now()
3790
3862
  });
3791
- case 43:
3792
- return _context48.finish(40);
3793
3863
  case 44:
3864
+ return _context47.finish(41);
3865
+ case 45:
3794
3866
  console.log('[Checkout] 后端返回的响应数据:', {
3795
3867
  status: (_checkoutResponse3 = checkoutResponse) === null || _checkoutResponse3 === void 0 ? void 0 : _checkoutResponse3.status,
3796
3868
  code: (_checkoutResponse4 = checkoutResponse) === null || _checkoutResponse4 === void 0 ? void 0 : _checkoutResponse4.code,
3797
3869
  message: (_checkoutResponse5 = checkoutResponse) === null || _checkoutResponse5 === void 0 ? void 0 : _checkoutResponse5.message,
3798
3870
  data: (_checkoutResponse6 = checkoutResponse) === null || _checkoutResponse6 === void 0 ? void 0 : _checkoutResponse6.data
3799
3871
  });
3872
+
3873
+ // 检查响应状态是否为成功状态
3874
+ responseStatus = (_checkoutResponse7 = checkoutResponse) === null || _checkoutResponse7 === void 0 ? void 0 : _checkoutResponse7.status;
3875
+ isSuccessResponse = responseStatus === true || responseStatus === 200 || responseStatus === 'success' || responseStatus === 1 && ((_checkoutResponse8 = checkoutResponse) === null || _checkoutResponse8 === void 0 ? void 0 : _checkoutResponse8.code) === 200;
3876
+ if (isSuccessResponse) {
3877
+ _context47.next = 54;
3878
+ break;
3879
+ }
3880
+ errorMessage = ((_checkoutResponse9 = checkoutResponse) === null || _checkoutResponse9 === void 0 ? void 0 : _checkoutResponse9.message) || '订单同步失败,后端返回非成功状态';
3881
+ console.error('[Checkout] 订单同步失败,响应状态检查未通过:', {
3882
+ expectedSuccess: true,
3883
+ actualStatus: responseStatus,
3884
+ code: (_checkoutResponse10 = checkoutResponse) === null || _checkoutResponse10 === void 0 ? void 0 : _checkoutResponse10.code,
3885
+ message: (_checkoutResponse11 = checkoutResponse) === null || _checkoutResponse11 === void 0 ? void 0 : _checkoutResponse11.message,
3886
+ errorMessage: errorMessage
3887
+ });
3888
+
3889
+ // 发送订单同步失败事件
3890
+ _context47.next = 53;
3891
+ return this.core.effects.emit(CheckoutHooks.OnOrderSyncFailed, {
3892
+ orderUuid: this.store.currentOrder.uuid,
3893
+ operation: isUpdateOperation ? 'update' : 'create',
3894
+ isManual: isManual,
3895
+ error: errorMessage,
3896
+ errorType: 'api_error',
3897
+ response: checkoutResponse,
3898
+ duration: Date.now() - startTime,
3899
+ timestamp: Date.now()
3900
+ });
3901
+ case 53:
3902
+ throw new Error(errorMessage);
3903
+ case 54:
3904
+ console.log('[Checkout] 响应状态检查通过,开始处理订单数据');
3800
3905
  if (!isUpdateOperation) {
3801
- _context48.next = 50;
3906
+ _context47.next = 60;
3802
3907
  break;
3803
3908
  }
3804
3909
  // 更新操作:使用现有的订单ID
3805
3910
  realOrderId = currentOrderId;
3806
3911
  console.log("[Checkout] \u8BA2\u5355\u66F4\u65B0\u6210\u529F\uFF0C\u8BA2\u5355ID: ".concat(realOrderId));
3807
- _context48.next = 71;
3912
+ _context47.next = 81;
3808
3913
  break;
3809
- case 50:
3914
+ case 60:
3810
3915
  // 创建操作:从响应中提取新的订单ID
3811
- extractedOrderId = (_checkoutResponse7 = checkoutResponse) === null || _checkoutResponse7 === void 0 || (_checkoutResponse7 = _checkoutResponse7.data) === null || _checkoutResponse7 === void 0 ? void 0 : _checkoutResponse7.order_id; // 如果data.order_id不存在,尝试直接从根级获取
3916
+ extractedOrderId = (_checkoutResponse12 = checkoutResponse) === null || _checkoutResponse12 === void 0 || (_checkoutResponse12 = _checkoutResponse12.data) === null || _checkoutResponse12 === void 0 ? void 0 : _checkoutResponse12.order_id; // 如果data.order_id不存在,尝试直接从根级获取
3812
3917
  if (!extractedOrderId) {
3813
- extractedOrderId = (_checkoutResponse8 = checkoutResponse) === null || _checkoutResponse8 === void 0 ? void 0 : _checkoutResponse8.order_id;
3918
+ extractedOrderId = (_checkoutResponse13 = checkoutResponse) === null || _checkoutResponse13 === void 0 ? void 0 : _checkoutResponse13.order_id;
3814
3919
  }
3815
3920
 
3816
3921
  // 确保转换为字符串类型
@@ -3818,11 +3923,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3818
3923
  extractedOrderId = String(extractedOrderId);
3819
3924
  }
3820
3925
  if (extractedOrderId) {
3821
- _context48.next = 55;
3926
+ _context47.next = 65;
3822
3927
  break;
3823
3928
  }
3824
3929
  throw new Error('后端返回的订单信息中未包含订单ID');
3825
- case 55:
3930
+ case 65:
3826
3931
  realOrderId = extractedOrderId;
3827
3932
  console.log('[Checkout] 订单创建成功,真实订单ID:', realOrderId);
3828
3933
 
@@ -3832,11 +3937,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3832
3937
  oldOrderId: this.store.currentOrder.order_id,
3833
3938
  newOrderId: realOrderId
3834
3939
  });
3835
- _context48.prev = 58;
3836
- _context48.next = 61;
3940
+ _context47.prev = 68;
3941
+ _context47.next = 71;
3837
3942
  return this.payment.replaceOrderIdByUuidAsync(this.store.currentOrder.uuid, realOrderId);
3838
- case 61:
3839
- updatedOrder = _context48.sent;
3943
+ case 71:
3944
+ updatedOrder = _context47.sent;
3840
3945
  console.log('[Checkout] Payment模块替换订单ID结果:', {
3841
3946
  wasSuccessful: !!updatedOrder,
3842
3947
  returnedOrderId: updatedOrder === null || updatedOrder === void 0 ? void 0 : updatedOrder.order_id,
@@ -3862,22 +3967,22 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3862
3967
  目标ID: realOrderId
3863
3968
  });
3864
3969
  }
3865
- _context48.next = 71;
3970
+ _context47.next = 81;
3866
3971
  break;
3867
- case 66:
3868
- _context48.prev = 66;
3869
- _context48.t2 = _context48["catch"](58);
3870
- console.error('[Checkout] 调用Payment模块替换订单ID时发生错误:', _context48.t2);
3972
+ case 76:
3973
+ _context47.prev = 76;
3974
+ _context47.t2 = _context47["catch"](68);
3975
+ console.error('[Checkout] 调用Payment模块替换订单ID时发生错误:', _context47.t2);
3871
3976
 
3872
3977
  // 发生错误时也进行手动替换
3873
3978
  this.store.currentOrder.order_id = realOrderId;
3874
3979
  console.log('[Checkout] 错误恢复:手动设置订单ID:', realOrderId);
3875
- case 71:
3980
+ case 81:
3876
3981
  // 标记订单已同步
3877
3982
  this.store.isOrderSynced = true;
3878
3983
 
3879
3984
  // 触发订单同步完成事件
3880
- _context48.next = 74;
3985
+ _context47.next = 84;
3881
3986
  return this.core.effects.emit(CheckoutHooks.OnOrderSynced, {
3882
3987
  orderUuid: this.store.currentOrder.uuid,
3883
3988
  realOrderId: realOrderId,
@@ -3886,7 +3991,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3886
3991
  isManual: isManual,
3887
3992
  response: checkoutResponse
3888
3993
  });
3889
- case 74:
3994
+ case 84:
3890
3995
  // 验证最终状态
3891
3996
  finalOrderId = this.store.currentOrder.order_id;
3892
3997
  finalIsVirtual = this.isVirtualOrderId(finalOrderId || '');
@@ -3903,12 +4008,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3903
4008
  }
3904
4009
 
3905
4010
  // 返回真实订单ID
3906
- return _context48.abrupt("return", realOrderId);
3907
- case 79:
4011
+ return _context47.abrupt("return", realOrderId);
4012
+ case 89:
3908
4013
  case "end":
3909
- return _context48.stop();
4014
+ return _context47.stop();
3910
4015
  }
3911
- }, _callee48, this, [[26, 34, 40, 44], [58, 66]]);
4016
+ }, _callee47, this, [[26, 34, 41, 45], [68, 76]]);
3912
4017
  }));
3913
4018
  function syncOrderToBackendWithReturn() {
3914
4019
  return _syncOrderToBackendWithReturn.apply(this, arguments);
@@ -3918,27 +4023,27 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3918
4023
  }, {
3919
4024
  key: "syncOrderToBackend",
3920
4025
  value: function () {
3921
- var _syncOrderToBackend = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49() {
3922
- return _regeneratorRuntime().wrap(function _callee49$(_context49) {
3923
- while (1) switch (_context49.prev = _context49.next) {
4026
+ var _syncOrderToBackend = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48() {
4027
+ return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4028
+ while (1) switch (_context48.prev = _context48.next) {
3924
4029
  case 0:
3925
- _context49.prev = 0;
3926
- _context49.next = 3;
4030
+ _context48.prev = 0;
4031
+ _context48.next = 3;
3927
4032
  return this.syncOrderToBackendWithReturn(false);
3928
4033
  case 3:
3929
- _context49.next = 10;
4034
+ _context48.next = 10;
3930
4035
  break;
3931
4036
  case 5:
3932
- _context49.prev = 5;
3933
- _context49.t0 = _context49["catch"](0);
3934
- console.error('[Checkout] 同步订单到后端失败:', _context49.t0);
3935
- _context49.next = 10;
3936
- return this.handleError(new Error("\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(_context49.t0 instanceof Error ? _context49.t0.message : String(_context49.t0))), CheckoutErrorType.OrderCreationFailed);
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);
3937
4042
  case 10:
3938
4043
  case "end":
3939
- return _context49.stop();
4044
+ return _context48.stop();
3940
4045
  }
3941
- }, _callee49, this, [[0, 5]]);
4046
+ }, _callee48, this, [[0, 5]]);
3942
4047
  }));
3943
4048
  function syncOrderToBackend() {
3944
4049
  return _syncOrderToBackend.apply(this, arguments);
@@ -3978,15 +4083,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3978
4083
  }, {
3979
4084
  key: "setOtherParams",
3980
4085
  value: function () {
3981
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(params) {
4086
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(params) {
3982
4087
  var _ref5,
3983
4088
  _ref5$cover,
3984
4089
  cover,
3985
- _args50 = arguments;
3986
- return _regeneratorRuntime().wrap(function _callee50$(_context50) {
3987
- while (1) switch (_context50.prev = _context50.next) {
4090
+ _args49 = arguments;
4091
+ return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4092
+ while (1) switch (_context49.prev = _context49.next) {
3988
4093
  case 0:
3989
- _ref5 = _args50.length > 1 && _args50[1] !== undefined ? _args50[1] : {}, _ref5$cover = _ref5.cover, cover = _ref5$cover === void 0 ? false : _ref5$cover;
4094
+ _ref5 = _args49.length > 1 && _args49[1] !== undefined ? _args49[1] : {}, _ref5$cover = _ref5.cover, cover = _ref5$cover === void 0 ? false : _ref5$cover;
3990
4095
  if (cover) {
3991
4096
  this.otherParams = params;
3992
4097
  } else {
@@ -3994,11 +4099,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3994
4099
  }
3995
4100
  case 2:
3996
4101
  case "end":
3997
- return _context50.stop();
4102
+ return _context49.stop();
3998
4103
  }
3999
- }, _callee50, this);
4104
+ }, _callee49, this);
4000
4105
  }));
4001
- function setOtherParams(_x32) {
4106
+ function setOtherParams(_x30) {
4002
4107
  return _setOtherParams.apply(this, arguments);
4003
4108
  }
4004
4109
  return setOtherParams;
@@ -4015,12 +4120,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4015
4120
  }, {
4016
4121
  key: "editOrderNoteByOrderIdAsync",
4017
4122
  value: (function () {
4018
- var _editOrderNoteByOrderIdAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(orderId, note) {
4123
+ var _editOrderNoteByOrderIdAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(orderId, note) {
4019
4124
  var response, previousNote, errorMessage, _errorMessage;
4020
- return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4021
- while (1) switch (_context51.prev = _context51.next) {
4125
+ return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4126
+ while (1) switch (_context50.prev = _context50.next) {
4022
4127
  case 0:
4023
- _context51.prev = 0;
4128
+ _context50.prev = 0;
4024
4129
  console.log('[Checkout] 开始编辑订单备注:', {
4025
4130
  orderId: orderId,
4026
4131
  note: note,
@@ -4029,21 +4134,21 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4029
4134
 
4030
4135
  // 参数验证
4031
4136
  if (orderId) {
4032
- _context51.next = 4;
4137
+ _context50.next = 4;
4033
4138
  break;
4034
4139
  }
4035
- return _context51.abrupt("return", {
4140
+ return _context50.abrupt("return", {
4036
4141
  success: false,
4037
4142
  message: '订单ID不能为空',
4038
4143
  orderId: orderId
4039
4144
  });
4040
4145
  case 4:
4041
- _context51.next = 6;
4146
+ _context50.next = 6;
4042
4147
  return this.request.put("/order/order/".concat(orderId, "/note"), {
4043
4148
  note: note
4044
4149
  });
4045
4150
  case 6:
4046
- response = _context51.sent;
4151
+ response = _context50.sent;
4047
4152
  console.log('[Checkout] 订单备注编辑响应:', {
4048
4153
  orderId: orderId,
4049
4154
  status: response.status,
@@ -4053,14 +4158,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4053
4158
 
4054
4159
  // 检查响应状态
4055
4160
  if (!(response.status === true || response.status === 200)) {
4056
- _context51.next = 19;
4161
+ _context50.next = 19;
4057
4162
  break;
4058
4163
  }
4059
4164
  console.log("[Checkout] \u8BA2\u5355 ".concat(orderId, " \u5907\u6CE8\u4FEE\u6539\u6210\u529F"));
4060
4165
 
4061
4166
  // 如果当前订单就是被修改的订单,同时更新本地状态
4062
4167
  if (!(this.store.currentOrder && (String(this.store.currentOrder.order_id) === String(orderId) || String(this.store.currentOrder.id) === String(orderId)))) {
4063
- _context51.next = 16;
4168
+ _context50.next = 16;
4064
4169
  break;
4065
4170
  }
4066
4171
  console.log('[Checkout] 更新本地订单备注状态');
@@ -4072,7 +4177,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4072
4177
  }
4073
4178
 
4074
4179
  // 触发订单备注变更事件
4075
- _context51.next = 16;
4180
+ _context50.next = 16;
4076
4181
  return this.core.effects.emit(CheckoutHooks.OnOrderNoteChanged, {
4077
4182
  orderUuid: this.store.currentOrder.uuid,
4078
4183
  oldNote: previousNote,
@@ -4080,7 +4185,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4080
4185
  timestamp: Date.now()
4081
4186
  });
4082
4187
  case 16:
4083
- return _context51.abrupt("return", {
4188
+ return _context50.abrupt("return", {
4084
4189
  success: true,
4085
4190
  message: response.message || '订单备注修改成功',
4086
4191
  orderId: orderId
@@ -4089,31 +4194,31 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4089
4194
  // API返回失败状态
4090
4195
  errorMessage = response.message || '订单备注修改失败';
4091
4196
  console.error("[Checkout] \u8BA2\u5355 ".concat(orderId, " \u5907\u6CE8\u4FEE\u6539\u5931\u8D25:"), errorMessage);
4092
- return _context51.abrupt("return", {
4197
+ return _context50.abrupt("return", {
4093
4198
  success: false,
4094
4199
  message: errorMessage,
4095
4200
  orderId: orderId
4096
4201
  });
4097
4202
  case 22:
4098
- _context51.next = 29;
4203
+ _context50.next = 29;
4099
4204
  break;
4100
4205
  case 24:
4101
- _context51.prev = 24;
4102
- _context51.t0 = _context51["catch"](0);
4103
- console.error('[Checkout] 编辑订单备注失败:', _context51.t0);
4104
- _errorMessage = _context51.t0 instanceof Error ? _context51.t0.message : '网络错误或服务器异常';
4105
- return _context51.abrupt("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", {
4106
4211
  success: false,
4107
4212
  message: "\u7F16\u8F91\u8BA2\u5355\u5907\u6CE8\u5931\u8D25: ".concat(_errorMessage),
4108
4213
  orderId: orderId
4109
4214
  });
4110
4215
  case 29:
4111
4216
  case "end":
4112
- return _context51.stop();
4217
+ return _context50.stop();
4113
4218
  }
4114
- }, _callee51, this, [[0, 24]]);
4219
+ }, _callee50, this, [[0, 24]]);
4115
4220
  }));
4116
- function editOrderNoteByOrderIdAsync(_x33, _x34) {
4221
+ function editOrderNoteByOrderIdAsync(_x31, _x32) {
4117
4222
  return _editOrderNoteByOrderIdAsync.apply(this, arguments);
4118
4223
  }
4119
4224
  return editOrderNoteByOrderIdAsync;
@@ -4130,12 +4235,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4130
4235
  }, {
4131
4236
  key: "sendCustomerPayLinkAsync",
4132
4237
  value: (function () {
4133
- var _sendCustomerPayLinkAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(params) {
4238
+ var _sendCustomerPayLinkAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
4134
4239
  var emailRegex, invalidEmails, requestBody, response, errorMessage, _errorMessage2;
4135
- return _regeneratorRuntime().wrap(function _callee52$(_context52) {
4136
- while (1) switch (_context52.prev = _context52.next) {
4240
+ return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4241
+ while (1) switch (_context51.prev = _context51.next) {
4137
4242
  case 0:
4138
- _context52.prev = 0;
4243
+ _context51.prev = 0;
4139
4244
  console.log('[Checkout] 开始发送客户支付链接邮件:', {
4140
4245
  orderIds: params.order_ids,
4141
4246
  emails: params.emails,
@@ -4144,19 +4249,19 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4144
4249
 
4145
4250
  // 参数验证
4146
4251
  if (!(!params.order_ids || params.order_ids.length === 0)) {
4147
- _context52.next = 4;
4252
+ _context51.next = 4;
4148
4253
  break;
4149
4254
  }
4150
- return _context52.abrupt("return", {
4255
+ return _context51.abrupt("return", {
4151
4256
  success: false,
4152
4257
  message: '订单ID列表不能为空'
4153
4258
  });
4154
4259
  case 4:
4155
4260
  if (!(!params.emails || params.emails.length === 0)) {
4156
- _context52.next = 6;
4261
+ _context51.next = 6;
4157
4262
  break;
4158
4263
  }
4159
- return _context52.abrupt("return", {
4264
+ return _context51.abrupt("return", {
4160
4265
  success: false,
4161
4266
  message: '邮箱地址列表不能为空'
4162
4267
  });
@@ -4167,10 +4272,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4167
4272
  return !emailRegex.test(email);
4168
4273
  });
4169
4274
  if (!(invalidEmails.length > 0)) {
4170
- _context52.next = 10;
4275
+ _context51.next = 10;
4171
4276
  break;
4172
4277
  }
4173
- return _context52.abrupt("return", {
4278
+ return _context51.abrupt("return", {
4174
4279
  success: false,
4175
4280
  message: "\u90AE\u7BB1\u683C\u5F0F\u65E0\u6548: ".concat(invalidEmails.join(', '))
4176
4281
  });
@@ -4184,10 +4289,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4184
4289
  console.log('[Checkout] 发送支付链接邮件请求参数:', requestBody);
4185
4290
 
4186
4291
  // 调用后端API发送邮件
4187
- _context52.next = 14;
4292
+ _context51.next = 14;
4188
4293
  return this.request.post('/order/batch-email', requestBody);
4189
4294
  case 14:
4190
- response = _context52.sent;
4295
+ response = _context51.sent;
4191
4296
  console.log('[Checkout] 支付链接邮件发送响应:', {
4192
4297
  status: response.status,
4193
4298
  message: response.message,
@@ -4197,11 +4302,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4197
4302
 
4198
4303
  // 检查响应状态
4199
4304
  if (!(response.status === true || response.status === 200)) {
4200
- _context52.next = 21;
4305
+ _context51.next = 21;
4201
4306
  break;
4202
4307
  }
4203
4308
  console.log('[Checkout] 支付链接邮件发送成功');
4204
- return _context52.abrupt("return", {
4309
+ return _context51.abrupt("return", {
4205
4310
  success: true,
4206
4311
  message: response.message || '支付链接邮件发送成功'
4207
4312
  });
@@ -4209,29 +4314,29 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4209
4314
  // API返回失败状态
4210
4315
  errorMessage = response.message || '支付链接邮件发送失败';
4211
4316
  console.error('[Checkout] 支付链接邮件发送失败:', errorMessage);
4212
- return _context52.abrupt("return", {
4317
+ return _context51.abrupt("return", {
4213
4318
  success: false,
4214
4319
  message: errorMessage
4215
4320
  });
4216
4321
  case 24:
4217
- _context52.next = 31;
4322
+ _context51.next = 31;
4218
4323
  break;
4219
4324
  case 26:
4220
- _context52.prev = 26;
4221
- _context52.t0 = _context52["catch"](0);
4222
- console.error('[Checkout] 发送客户支付链接邮件失败:', _context52.t0);
4223
- _errorMessage2 = _context52.t0 instanceof Error ? _context52.t0.message : '网络错误或服务器异常';
4224
- return _context52.abrupt("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", {
4225
4330
  success: false,
4226
4331
  message: "\u53D1\u9001\u652F\u4ED8\u94FE\u63A5\u90AE\u4EF6\u5931\u8D25: ".concat(_errorMessage2)
4227
4332
  });
4228
4333
  case 31:
4229
4334
  case "end":
4230
- return _context52.stop();
4335
+ return _context51.stop();
4231
4336
  }
4232
- }, _callee52, this, [[0, 26]]);
4337
+ }, _callee51, this, [[0, 26]]);
4233
4338
  }));
4234
- function sendCustomerPayLinkAsync(_x35) {
4339
+ function sendCustomerPayLinkAsync(_x33) {
4235
4340
  return _sendCustomerPayLinkAsync.apply(this, arguments);
4236
4341
  }
4237
4342
  return sendCustomerPayLinkAsync;
@@ -4246,25 +4351,25 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4246
4351
  }, {
4247
4352
  key: "roundAmountAsync",
4248
4353
  value: (function () {
4249
- var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(amount) {
4354
+ var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(amount) {
4250
4355
  var _this$otherParams$ord, _this$otherParams$ord2;
4251
4356
  var result;
4252
- return _regeneratorRuntime().wrap(function _callee53$(_context53) {
4253
- while (1) switch (_context53.prev = _context53.next) {
4357
+ return _regeneratorRuntime().wrap(function _callee52$(_context52) {
4358
+ while (1) switch (_context52.prev = _context52.next) {
4254
4359
  case 0:
4255
- _context53.next = 2;
4360
+ _context52.next = 2;
4256
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);
4257
4362
  case 2:
4258
- result = _context53.sent;
4363
+ result = _context52.sent;
4259
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));
4260
- return _context53.abrupt("return", result);
4365
+ return _context52.abrupt("return", result);
4261
4366
  case 5:
4262
4367
  case "end":
4263
- return _context53.stop();
4368
+ return _context52.stop();
4264
4369
  }
4265
- }, _callee53, this);
4370
+ }, _callee52, this);
4266
4371
  }));
4267
- function roundAmountAsync(_x36) {
4372
+ function roundAmountAsync(_x34) {
4268
4373
  return _roundAmountAsync.apply(this, arguments);
4269
4374
  }
4270
4375
  return roundAmountAsync;
@@ -4272,10 +4377,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4272
4377
  }, {
4273
4378
  key: "destroy",
4274
4379
  value: function () {
4275
- var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54() {
4380
+ var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53() {
4276
4381
  var _this$order, _this$order$destroy, _this$payment, _this$payment$destroy;
4277
- return _regeneratorRuntime().wrap(function _callee54$(_context54) {
4278
- while (1) switch (_context54.prev = _context54.next) {
4382
+ return _regeneratorRuntime().wrap(function _callee53$(_context53) {
4383
+ while (1) switch (_context53.prev = _context53.next) {
4279
4384
  case 0:
4280
4385
  // 清理钱包模块的所有缓存数据
4281
4386
  this.payment.wallet.clearAllCache();
@@ -4284,10 +4389,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4284
4389
  this.core.effects.offByModuleDestroy(this.name);
4285
4390
 
4286
4391
  // 销毁子模块
4287
- _context54.next = 4;
4392
+ _context53.next = 4;
4288
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);
4289
4394
  case 4:
4290
- _context54.next = 6;
4395
+ _context53.next = 6;
4291
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);
4292
4397
  case 6:
4293
4398
  // 取消注册模块
@@ -4295,9 +4400,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4295
4400
  console.log('[Checkout] 已销毁');
4296
4401
  case 8:
4297
4402
  case "end":
4298
- return _context54.stop();
4403
+ return _context53.stop();
4299
4404
  }
4300
- }, _callee54, this);
4405
+ }, _callee53, this);
4301
4406
  }));
4302
4407
  function destroy() {
4303
4408
  return _destroy.apply(this, arguments);
@@ -4312,12 +4417,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4312
4417
  }, {
4313
4418
  key: "resetStoreStateAsync",
4314
4419
  value: (function () {
4315
- var _resetStoreStateAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55() {
4420
+ var _resetStoreStateAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54() {
4316
4421
  var prevOrderInfo;
4317
- return _regeneratorRuntime().wrap(function _callee55$(_context55) {
4318
- while (1) switch (_context55.prev = _context55.next) {
4422
+ return _regeneratorRuntime().wrap(function _callee54$(_context54) {
4423
+ while (1) switch (_context54.prev = _context54.next) {
4319
4424
  case 0:
4320
- _context55.prev = 0;
4425
+ _context54.prev = 0;
4321
4426
  prevOrderInfo = this.store.currentOrder ? {
4322
4427
  uuid: this.store.currentOrder.uuid,
4323
4428
  orderId: this.store.currentOrder.order_id
@@ -4329,6 +4434,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4329
4434
  this.store.localOrderData = undefined;
4330
4435
  this.store.cartSummary = undefined;
4331
4436
  this.store.stateAmount = '0.00';
4437
+ this.store.balanceDueAmount = '0.00';
4332
4438
  this.store.isOrderSynced = false;
4333
4439
  this.store.currentCustomer = undefined;
4334
4440
  this.store.lastError = undefined;
@@ -4342,36 +4448,36 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4342
4448
  // 注意:故意保留 this.store.paymentMethods,因为支付方式数据不易变更,保留在内存中提高性能
4343
4449
 
4344
4450
  // 重置状态和步骤为初始状态
4345
- _context55.next = 14;
4451
+ _context54.next = 15;
4346
4452
  return this.setStatus(CheckoutStatus.Ready);
4347
- case 14:
4348
- _context55.next = 16;
4453
+ case 15:
4454
+ _context54.next = 17;
4349
4455
  return this.setStep(CheckoutStep.OrderConfirmation);
4350
- case 16:
4456
+ case 17:
4351
4457
  console.log('[Checkout] Store 状态重置完成');
4352
4458
 
4353
4459
  // 触发订单清理事件(如果之前有订单)
4354
4460
  if (!prevOrderInfo) {
4355
- _context55.next = 20;
4461
+ _context54.next = 21;
4356
4462
  break;
4357
4463
  }
4358
- _context55.next = 20;
4464
+ _context54.next = 21;
4359
4465
  return this.core.effects.emit(CheckoutHooks.OnOrderCleared, {
4360
4466
  previousOrder: prevOrderInfo,
4361
4467
  timestamp: Date.now()
4362
4468
  });
4363
- case 20:
4364
- _context55.next = 25;
4469
+ case 21:
4470
+ _context54.next = 26;
4365
4471
  break;
4366
- case 22:
4367
- _context55.prev = 22;
4368
- _context55.t0 = _context55["catch"](0);
4369
- console.error('[Checkout] 重置 store 状态失败:', _context55.t0);
4370
- case 25:
4472
+ case 23:
4473
+ _context54.prev = 23;
4474
+ _context54.t0 = _context54["catch"](0);
4475
+ console.error('[Checkout] 重置 store 状态失败:', _context54.t0);
4476
+ case 26:
4371
4477
  case "end":
4372
- return _context55.stop();
4478
+ return _context54.stop();
4373
4479
  }
4374
- }, _callee55, this, [[0, 22]]);
4480
+ }, _callee54, this, [[0, 23]]);
4375
4481
  }));
4376
4482
  function resetStoreStateAsync() {
4377
4483
  return _resetStoreStateAsync.apply(this, arguments);
@@ -4389,37 +4495,37 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4389
4495
  }, {
4390
4496
  key: "clearCompletedOrderAsync",
4391
4497
  value: (function () {
4392
- var _clearCompletedOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56() {
4498
+ var _clearCompletedOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55() {
4393
4499
  var prevOrderInfo;
4394
- return _regeneratorRuntime().wrap(function _callee56$(_context56) {
4395
- while (1) switch (_context56.prev = _context56.next) {
4500
+ return _regeneratorRuntime().wrap(function _callee55$(_context55) {
4501
+ while (1) switch (_context55.prev = _context55.next) {
4396
4502
  case 0:
4397
- _context56.prev = 0;
4503
+ _context55.prev = 0;
4398
4504
  prevOrderInfo = this.store.currentOrder ? {
4399
4505
  uuid: this.store.currentOrder.uuid,
4400
4506
  orderId: this.store.currentOrder.order_id
4401
4507
  } : null;
4402
- _context56.next = 4;
4508
+ _context55.next = 4;
4403
4509
  return this.resetStoreStateAsync();
4404
4510
  case 4:
4405
- return _context56.abrupt("return", {
4511
+ return _context55.abrupt("return", {
4406
4512
  success: true,
4407
4513
  message: prevOrderInfo ? '订单状态已成功清理' : '没有需要清理的订单状态',
4408
4514
  clearedOrder: prevOrderInfo
4409
4515
  });
4410
4516
  case 7:
4411
- _context56.prev = 7;
4412
- _context56.t0 = _context56["catch"](0);
4413
- console.error('[Checkout] 手动清理订单状态失败:', _context56.t0);
4414
- return _context56.abrupt("return", {
4517
+ _context55.prev = 7;
4518
+ _context55.t0 = _context55["catch"](0);
4519
+ console.error('[Checkout] 手动清理订单状态失败:', _context55.t0);
4520
+ return _context55.abrupt("return", {
4415
4521
  success: false,
4416
- message: _context56.t0 instanceof Error ? _context56.t0.message : '清理失败'
4522
+ message: _context55.t0 instanceof Error ? _context55.t0.message : '清理失败'
4417
4523
  });
4418
4524
  case 11:
4419
4525
  case "end":
4420
- return _context56.stop();
4526
+ return _context55.stop();
4421
4527
  }
4422
- }, _callee56, this, [[0, 7]]);
4528
+ }, _callee55, this, [[0, 7]]);
4423
4529
  }));
4424
4530
  function clearCompletedOrderAsync() {
4425
4531
  return _clearCompletedOrderAsync.apply(this, arguments);