@pisell/pisellos 0.0.244 → 0.0.246

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
- _context7.next = 5;
274
- return this.validateCheckoutParams(params);
275
- case 5:
276
- validation = _context7.sent;
273
+ // 验证参数
274
+ validation = this.validateCheckoutParams(params);
277
275
  if (validation.valid) {
278
- _context7.next = 8;
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 8:
280
+ case 6:
283
281
  // 保存购物车数据
284
282
  this.store.cartItems = params.cartItems;
285
283
 
286
284
  // 设置为就绪状态
287
- _context7.next = 11;
285
+ _context7.next = 9;
288
286
  return this.setStatus(CheckoutStatus.Ready);
289
- case 11:
290
- _context7.next = 13;
287
+ case 9:
288
+ _context7.next = 11;
291
289
  return this.setStep(CheckoutStep.OrderConfirmation);
292
- case 13:
290
+ case 11:
293
291
  console.log('[Checkout] 结账流程初始化完成');
294
- _context7.next = 21;
292
+ _context7.next = 19;
295
293
  break;
296
- case 16:
297
- _context7.prev = 16;
294
+ case 14:
295
+ _context7.prev = 14;
298
296
  _context7.t0 = _context7["catch"](0);
299
- _context7.next = 20;
297
+ _context7.next = 18;
300
298
  return this.handleError(_context7.t0, CheckoutErrorType.UnknownError);
301
- case 20:
299
+ case 18:
302
300
  throw _context7.t0;
303
- case 21:
301
+ case 19:
304
302
  case "end":
305
303
  return _context7.stop();
306
304
  }
307
- }, _callee7, this, [[0, 16]]);
305
+ }, _callee7, this, [[0, 14]]);
308
306
  }));
309
307
  function initializeCheckoutAsync(_x9) {
310
308
  return _initializeCheckoutAsync.apply(this, arguments);
@@ -345,7 +343,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
345
343
  key: "initWalletData",
346
344
  value: function () {
347
345
  var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params) {
348
- var _this$store$currentOr3, _this$store$currentCu;
346
+ var _this$store$currentOr3, _this$store$currentCu, _this$store$currentOr4;
349
347
  var amountInfo, walletBusinessData;
350
348
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
351
349
  while (1) switch (_context8.prev = _context8.next) {
@@ -369,6 +367,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
369
367
  _context8.next = 6;
370
368
  return this.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
371
369
  case 6:
370
+ _context8.next = 8;
371
+ return this.core.effects.emit(CheckoutHooks.OnWalletDataInitialized, {
372
+ orderUuid: (_this$store$currentOr4 = this.store.currentOrder) === null || _this$store$currentOr4 === void 0 ? void 0 : _this$store$currentOr4.uuid,
373
+ customerId: walletBusinessData.customer_id,
374
+ walletBusinessData: {
375
+ customer_id: walletBusinessData.customer_id,
376
+ amountInfo: walletBusinessData.amountInfo,
377
+ order_wait_pay_amount: params === null || params === void 0 ? void 0 : params.order_wait_pay_amount
378
+ },
379
+ timestamp: Date.now()
380
+ });
381
+ case 8:
372
382
  case "end":
373
383
  return _context8.stop();
374
384
  }
@@ -401,16 +411,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
401
411
  _context9.next = 5;
402
412
  return this.setStatus(CheckoutStatus.CreatingOrder);
403
413
  case 5:
404
- _context9.next = 7;
405
- return this.validateLocalOrderData(params.orderData);
406
- case 7:
407
- validation = _context9.sent;
414
+ // 验证订单数据
415
+ validation = this.validateLocalOrderData(params.orderData);
408
416
  if (validation.valid) {
409
- _context9.next = 10;
417
+ _context9.next = 8;
410
418
  break;
411
419
  }
412
420
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, "\u8BA2\u5355\u6570\u636E\u9A8C\u8BC1\u5931\u8D25: ".concat(validation.errors.join(', ')));
413
- case 10:
421
+ case 8:
414
422
  // 生成本地虚拟订单ID (后续可以被真实订单ID替换)
415
423
  localOrderId = this.generateLocalOrderId(); // 从购物车小计数据中提取金额信息
416
424
  amountInfo = this.extractAmountFromCartSummary(params.cartSummary); // TODO: 外面传的是 pos ,但是现在 后端只有 shop 和 kiosk
@@ -441,7 +449,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
441
449
  }
442
450
 
443
451
  // 创建支付订单对象
444
- _context9.next = 23;
452
+ _context9.next = 21;
445
453
  return this.payment.createPaymentOrderAsync({
446
454
  order_id: localOrderId,
447
455
  total_amount: amountInfo.totalAmount,
@@ -458,34 +466,32 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
458
466
  amount_breakdown: amountInfo
459
467
  }
460
468
  });
461
- case 23:
469
+ case 21:
462
470
  paymentOrder = _context9.sent;
463
471
  this.store.currentOrder = paymentOrder;
464
- _context9.next = 27;
465
- return this.initWalletData();
466
- case 27:
467
- _context9.next = 29;
472
+ this.initWalletData();
473
+ _context9.next = 26;
468
474
  return this.setStatus(CheckoutStatus.OrderCreated);
469
- case 29:
470
- _context9.next = 31;
475
+ case 26:
476
+ _context9.next = 28;
471
477
  return this.setStep(CheckoutStep.PaymentMethod);
472
- case 31:
478
+ case 28:
473
479
  if (!params.autoPayment) {
474
- _context9.next = 34;
480
+ _context9.next = 31;
475
481
  break;
476
482
  }
477
- _context9.next = 34;
483
+ _context9.next = 31;
478
484
  return this.setStep(CheckoutStep.PaymentProcessing);
479
- case 34:
480
- _context9.next = 36;
481
- return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
485
+ case 31:
486
+ this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
482
487
  order: paymentOrder,
483
488
  timestamp: Date.now()
484
489
  });
485
- case 36:
486
- _context9.next = 38;
490
+
491
+ // 自动设置 stateAmount 为剩余未支付金额
492
+ _context9.next = 34;
487
493
  return this.updateStateAmountToRemaining();
488
- case 38:
494
+ case 34:
489
495
  console.log('[Checkout] 本地订单创建成功:', {
490
496
  localOrderId: localOrderId,
491
497
  uuid: paymentOrder.uuid,
@@ -495,24 +501,22 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
495
501
  stateAmount: this.store.stateAmount
496
502
  });
497
503
  return _context9.abrupt("return", paymentOrder);
498
- case 42:
499
- _context9.prev = 42;
504
+ case 38:
505
+ _context9.prev = 38;
500
506
  _context9.t0 = _context9["catch"](0);
501
- _context9.next = 46;
507
+ _context9.next = 42;
502
508
  return this.handleError(_context9.t0, CheckoutErrorType.OrderCreationFailed);
503
- case 46:
504
- _context9.next = 48;
505
- return this.core.effects.emit(CheckoutHooks.OnOrderCreationFailed, {
509
+ case 42:
510
+ this.core.effects.emit(CheckoutHooks.OnOrderCreationFailed, {
506
511
  error: this.store.lastError,
507
512
  timestamp: Date.now()
508
513
  });
509
- case 48:
510
514
  throw _context9.t0;
511
- case 49:
515
+ case 44:
512
516
  case "end":
513
517
  return _context9.stop();
514
518
  }
515
- }, _callee9, this, [[0, 42]]);
519
+ }, _callee9, this, [[0, 38]]);
516
520
  }));
517
521
  function createLocalOrderAsync(_x11) {
518
522
  return _createLocalOrderAsync.apply(this, arguments);
@@ -989,12 +993,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
989
993
  key: "getCheckoutSummaryAsync",
990
994
  value: (function () {
991
995
  var _getCheckoutSummaryAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
992
- var _this$store$currentOr4, _this$store$currentOr5;
996
+ var _this$store$currentOr5, _this$store$currentOr6;
993
997
  var totalAmount, paidAmount, remainingAmount;
994
998
  return _regeneratorRuntime().wrap(function _callee15$(_context15) {
995
999
  while (1) switch (_context15.prev = _context15.next) {
996
1000
  case 0:
997
- totalAmount = ((_this$store$currentOr4 = this.store.currentOrder) === null || _this$store$currentOr4 === void 0 ? void 0 : _this$store$currentOr4.total_amount) || '0.00';
1001
+ totalAmount = ((_this$store$currentOr5 = this.store.currentOrder) === null || _this$store$currentOr5 === void 0 ? void 0 : _this$store$currentOr5.total_amount) || '0.00';
998
1002
  _context15.next = 3;
999
1003
  return this.calculatePaidAmountAsync();
1000
1004
  case 3:
@@ -1008,7 +1012,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1008
1012
  totalAmount: totalAmount,
1009
1013
  paidAmount: paidAmount,
1010
1014
  remainingAmount: remainingAmount,
1011
- paymentStatus: ((_this$store$currentOr5 = this.store.currentOrder) === null || _this$store$currentOr5 === void 0 ? void 0 : _this$store$currentOr5.payment_status) || PaymentStatus.Processing,
1015
+ paymentStatus: ((_this$store$currentOr6 = this.store.currentOrder) === null || _this$store$currentOr6 === void 0 ? void 0 : _this$store$currentOr6.payment_status) || PaymentStatus.Processing,
1012
1016
  availablePaymentMethods: this.store.paymentMethods
1013
1017
  });
1014
1018
  case 8:
@@ -1095,8 +1099,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1095
1099
  }, {
1096
1100
  key: "getOrderOriginalData",
1097
1101
  value: function getOrderOriginalData() {
1098
- var _this$store$currentOr6;
1099
- return (_this$store$currentOr6 = this.store.currentOrder) === null || _this$store$currentOr6 === void 0 ? void 0 : _this$store$currentOr6.order_info;
1102
+ var _this$store$currentOr7;
1103
+ return (_this$store$currentOr7 = this.store.currentOrder) === null || _this$store$currentOr7 === void 0 ? void 0 : _this$store$currentOr7.order_info;
1100
1104
  }
1101
1105
 
1102
1106
  /**
@@ -2258,7 +2262,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2258
2262
  key: "manualSyncOrderAsync",
2259
2263
  value: (function () {
2260
2264
  var _manualSyncOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
2261
- var orderUuid, oldOrderId, realOrderId, finalOrderId, finalIsVirtual, _this$store$currentOr7, errorMessage;
2265
+ var orderUuid, oldOrderId, realOrderId, finalOrderId, finalIsVirtual, _this$store$currentOr8, errorMessage;
2262
2266
  return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2263
2267
  while (1) switch (_context31.prev = _context31.next) {
2264
2268
  case 0:
@@ -2334,7 +2338,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2334
2338
  return _context31.abrupt("return", {
2335
2339
  success: false,
2336
2340
  message: "\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(errorMessage),
2337
- orderUuid: (_this$store$currentOr7 = this.store.currentOrder) === null || _this$store$currentOr7 === void 0 ? void 0 : _this$store$currentOr7.uuid
2341
+ orderUuid: (_this$store$currentOr8 = this.store.currentOrder) === null || _this$store$currentOr8 === void 0 ? void 0 : _this$store$currentOr8.uuid
2338
2342
  });
2339
2343
  case 32:
2340
2344
  case "end":
@@ -2411,15 +2415,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2411
2415
  key: "cancelCurrentOrderAsync",
2412
2416
  value: (function () {
2413
2417
  var _cancelCurrentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(cancelReason) {
2414
- var _this$store$currentOr8, _this$store$currentOr9, currentOrderUuid, currentOrderId, isOrderSynced, errorMessage;
2418
+ var _this$store$currentOr9, _this$store$currentOr10, currentOrderUuid, currentOrderId, isOrderSynced, errorMessage;
2415
2419
  return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2416
2420
  while (1) switch (_context32.prev = _context32.next) {
2417
2421
  case 0:
2418
2422
  _context32.prev = 0;
2419
2423
  console.log('[Checkout] 开始取消当前本地订单:', {
2420
2424
  hasCurrentOrder: !!this.store.currentOrder,
2421
- orderUuid: (_this$store$currentOr8 = this.store.currentOrder) === null || _this$store$currentOr8 === void 0 ? void 0 : _this$store$currentOr8.uuid,
2422
- orderId: (_this$store$currentOr9 = this.store.currentOrder) === null || _this$store$currentOr9 === void 0 ? void 0 : _this$store$currentOr9.order_id,
2425
+ orderUuid: (_this$store$currentOr9 = this.store.currentOrder) === null || _this$store$currentOr9 === void 0 ? void 0 : _this$store$currentOr9.uuid,
2426
+ orderId: (_this$store$currentOr10 = this.store.currentOrder) === null || _this$store$currentOr10 === void 0 ? void 0 : _this$store$currentOr10.order_id,
2423
2427
  isOrderSynced: this.store.isOrderSynced,
2424
2428
  cancelReason: cancelReason
2425
2429
  });
@@ -2533,7 +2537,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2533
2537
  key: "saveForLaterPaymentAsync",
2534
2538
  value: (function () {
2535
2539
  var _saveForLaterPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
2536
- var orderUuid, currentOrderId, allPaymentItems, filteredPaymentItems, voucherItems, realOrderId, finalOrderId, _this$store$currentOr10, errorMessage;
2540
+ var orderUuid, currentOrderId, allPaymentItems, filteredPaymentItems, voucherItems, realOrderId, finalOrderId, _this$store$currentOr11, errorMessage;
2537
2541
  return _regeneratorRuntime().wrap(function _callee33$(_context33) {
2538
2542
  while (1) switch (_context33.prev = _context33.next) {
2539
2543
  case 0:
@@ -2623,7 +2627,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2623
2627
  return _context33.abrupt("return", {
2624
2628
  success: false,
2625
2629
  message: "\u8BA2\u5355\u4FDD\u5B58\u5931\u8D25: ".concat(errorMessage),
2626
- orderUuid: (_this$store$currentOr10 = this.store.currentOrder) === null || _this$store$currentOr10 === void 0 ? void 0 : _this$store$currentOr10.uuid
2630
+ orderUuid: (_this$store$currentOr11 = this.store.currentOrder) === null || _this$store$currentOr11 === void 0 ? void 0 : _this$store$currentOr11.uuid
2627
2631
  });
2628
2632
  case 26:
2629
2633
  case "end":
@@ -2674,14 +2678,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2674
2678
  key: "updateShopDiscountAsync",
2675
2679
  value: (function () {
2676
2680
  var _updateShopDiscountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(discountAmount) {
2677
- var _this$store$currentOr11, _this$store$currentOr12, oldDiscount, shopDiscountItem, updatedAmountInfo;
2681
+ var _this$store$currentOr12, _this$store$currentOr13, oldDiscount, shopDiscountItem, updatedAmountInfo;
2678
2682
  return _regeneratorRuntime().wrap(function _callee34$(_context34) {
2679
2683
  while (1) switch (_context34.prev = _context34.next) {
2680
2684
  case 0:
2681
2685
  _context34.prev = 0;
2682
2686
  oldDiscount = this.getShopDiscount();
2683
2687
  console.log('[Checkout] 更新商店折扣:', {
2684
- orderUuid: (_this$store$currentOr11 = this.store.currentOrder) === null || _this$store$currentOr11 === void 0 ? void 0 : _this$store$currentOr11.uuid,
2688
+ orderUuid: (_this$store$currentOr12 = this.store.currentOrder) === null || _this$store$currentOr12 === void 0 ? void 0 : _this$store$currentOr12.uuid,
2685
2689
  oldDiscount: oldDiscount,
2686
2690
  newDiscount: discountAmount
2687
2691
  });
@@ -2731,7 +2735,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2731
2735
  case 8:
2732
2736
  _context34.next = 10;
2733
2737
  return this.core.effects.emit(CheckoutHooks.OnShopDiscountChanged, {
2734
- orderUuid: (_this$store$currentOr12 = this.store.currentOrder) === null || _this$store$currentOr12 === void 0 ? void 0 : _this$store$currentOr12.uuid,
2738
+ orderUuid: (_this$store$currentOr13 = this.store.currentOrder) === null || _this$store$currentOr13 === void 0 ? void 0 : _this$store$currentOr13.uuid,
2735
2739
  oldDiscount: oldDiscount,
2736
2740
  newDiscount: discountAmount,
2737
2741
  timestamp: Date.now()
@@ -2772,7 +2776,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2772
2776
  key: "updateOrderNoteAsync",
2773
2777
  value: (function () {
2774
2778
  var _updateOrderNoteAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(note) {
2775
- var _this$store$currentOr13, _this$store$currentOr14, oldNote, orderInPayment;
2779
+ var _this$store$currentOr14, _this$store$currentOr15, oldNote, orderInPayment;
2776
2780
  return _regeneratorRuntime().wrap(function _callee35$(_context35) {
2777
2781
  while (1) switch (_context35.prev = _context35.next) {
2778
2782
  case 0:
@@ -2784,7 +2788,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2784
2788
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, '没有本地订单数据,无法更新备注');
2785
2789
  case 3:
2786
2790
  console.log('[Checkout] 更新订单备注:', {
2787
- orderUuid: (_this$store$currentOr13 = this.store.currentOrder) === null || _this$store$currentOr13 === void 0 ? void 0 : _this$store$currentOr13.uuid,
2791
+ orderUuid: (_this$store$currentOr14 = this.store.currentOrder) === null || _this$store$currentOr14 === void 0 ? void 0 : _this$store$currentOr14.uuid,
2788
2792
  oldNote: this.store.localOrderData.shop_note,
2789
2793
  newNote: note
2790
2794
  });
@@ -2817,7 +2821,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2817
2821
  case 17:
2818
2822
  _context35.next = 19;
2819
2823
  return this.core.effects.emit(CheckoutHooks.OnOrderNoteChanged, {
2820
- orderUuid: (_this$store$currentOr14 = this.store.currentOrder) === null || _this$store$currentOr14 === void 0 ? void 0 : _this$store$currentOr14.uuid,
2824
+ orderUuid: (_this$store$currentOr15 = this.store.currentOrder) === null || _this$store$currentOr15 === void 0 ? void 0 : _this$store$currentOr15.uuid,
2821
2825
  oldNote: oldNote,
2822
2826
  newNote: note,
2823
2827
  timestamp: Date.now()
@@ -2957,7 +2961,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2957
2961
  key: "handlePaymentSuccess",
2958
2962
  value: (function () {
2959
2963
  var _handlePaymentSuccess = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(data) {
2960
- var _this$store$currentOr15;
2964
+ var _this$store$currentOr16;
2961
2965
  return _regeneratorRuntime().wrap(function _callee39$(_context39) {
2962
2966
  while (1) switch (_context39.prev = _context39.next) {
2963
2967
  case 0:
@@ -2971,7 +2975,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2971
2975
  return this.core.effects.emit(CheckoutHooks.OnPaymentSuccess, {
2972
2976
  orderUuid: data.orderUuid,
2973
2977
  paymentMethodCode: '',
2974
- amount: ((_this$store$currentOr15 = this.store.currentOrder) === null || _this$store$currentOr15 === void 0 ? void 0 : _this$store$currentOr15.total_amount) || '0',
2978
+ amount: ((_this$store$currentOr16 = this.store.currentOrder) === null || _this$store$currentOr16 === void 0 ? void 0 : _this$store$currentOr16.total_amount) || '0',
2975
2979
  timestamp: data.timestamp
2976
2980
  });
2977
2981
  case 6:
@@ -2996,7 +3000,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2996
3000
  key: "handlePaymentError",
2997
3001
  value: (function () {
2998
3002
  var _handlePaymentError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(data) {
2999
- var _this$store$currentOr16;
3003
+ var _this$store$currentOr17;
3000
3004
  var error;
3001
3005
  return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3002
3006
  while (1) switch (_context40.prev = _context40.next) {
@@ -3009,7 +3013,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3009
3013
  return this.core.effects.emit(CheckoutHooks.OnPaymentFailed, {
3010
3014
  orderUuid: data.orderUuid,
3011
3015
  paymentMethodCode: '',
3012
- amount: ((_this$store$currentOr16 = this.store.currentOrder) === null || _this$store$currentOr16 === void 0 ? void 0 : _this$store$currentOr16.total_amount) || '0',
3016
+ amount: ((_this$store$currentOr17 = this.store.currentOrder) === null || _this$store$currentOr17 === void 0 ? void 0 : _this$store$currentOr17.total_amount) || '0',
3013
3017
  timestamp: data.timestamp
3014
3018
  });
3015
3019
  case 5:
@@ -3029,80 +3033,53 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3029
3033
  )
3030
3034
  }, {
3031
3035
  key: "validateCheckoutParams",
3032
- value: (function () {
3033
- var _validateCheckoutParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
3034
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3035
- while (1) switch (_context41.prev = _context41.next) {
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
- }()
3036
+ value: function validateCheckoutParams(params) {
3037
+ return validateCheckoutData(params);
3038
+ }
3039
+
3049
3040
  /**
3050
3041
  * 验证本地订单数据
3051
3042
  */
3052
- )
3053
3043
  }, {
3054
3044
  key: "validateLocalOrderData",
3055
- value: (function () {
3056
- var _validateLocalOrderData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(orderData) {
3057
- var _orderData$relation_p;
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
- }
3045
+ value: function validateLocalOrderData(orderData) {
3046
+ var _orderData$relation_p;
3047
+ var errors = [];
3072
3048
 
3073
- // 验证预订信息
3074
- if (orderData.bookings) {
3075
- orderData.bookings.forEach(function (booking, index) {
3076
- if (!booking.product || !booking.product.product_id) {
3077
- errors.push("\u9884\u8BA2\u9879 ".concat(index + 1, " \u7F3A\u5C11\u5546\u54C1\u4FE1\u606F"));
3078
- }
3079
- if (!booking.start_date) {
3080
- errors.push("\u9884\u8BA2\u9879 ".concat(index + 1, " \u7F3A\u5C11\u5F00\u59CB\u65E5\u671F"));
3081
- }
3082
- if (!booking.start_time) {
3083
- errors.push("\u9884\u8BA2\u9879 ".concat(index + 1, " \u7F3A\u5C11\u5F00\u59CB\u65F6\u95F4"));
3084
- }
3085
- });
3086
- }
3087
- return _context42.abrupt("return", {
3088
- valid: errors.length === 0,
3089
- errors: errors
3090
- });
3091
- case 6:
3092
- case "end":
3093
- return _context42.stop();
3049
+ // 验证基本字段
3050
+ if (!orderData.type) {
3051
+ errors.push('订单类型不能为空');
3052
+ }
3053
+ if (!orderData.platform) {
3054
+ errors.push('平台信息不能为空');
3055
+ }
3056
+ 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)) {
3057
+ errors.push('预订信息不能为空');
3058
+ }
3059
+
3060
+ // 验证预订信息
3061
+ if (orderData.bookings) {
3062
+ orderData.bookings.forEach(function (booking, index) {
3063
+ if (!booking.product || !booking.product.product_id) {
3064
+ errors.push("\u9884\u8BA2\u9879 ".concat(index + 1, " \u7F3A\u5C11\u5546\u54C1\u4FE1\u606F"));
3094
3065
  }
3095
- }, _callee42);
3096
- }));
3097
- function validateLocalOrderData(_x31) {
3098
- return _validateLocalOrderData.apply(this, arguments);
3066
+ if (!booking.start_date) {
3067
+ errors.push("\u9884\u8BA2\u9879 ".concat(index + 1, " \u7F3A\u5C11\u5F00\u59CB\u65E5\u671F"));
3068
+ }
3069
+ if (!booking.start_time) {
3070
+ errors.push("\u9884\u8BA2\u9879 ".concat(index + 1, " \u7F3A\u5C11\u5F00\u59CB\u65F6\u95F4"));
3071
+ }
3072
+ });
3099
3073
  }
3100
- return validateLocalOrderData;
3101
- }()
3074
+ return {
3075
+ valid: errors.length === 0,
3076
+ errors: errors
3077
+ };
3078
+ }
3079
+
3102
3080
  /**
3103
3081
  * 生成本地订单ID
3104
3082
  */
3105
- )
3106
3083
  }, {
3107
3084
  key: "generateLocalOrderId",
3108
3085
  value: function generateLocalOrderId() {
@@ -3192,31 +3169,31 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3192
3169
  }, {
3193
3170
  key: "preloadPaymentMethods",
3194
3171
  value: (function () {
3195
- var _preloadPaymentMethods = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43() {
3172
+ var _preloadPaymentMethods = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41() {
3196
3173
  var methods;
3197
- return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3198
- while (1) switch (_context43.prev = _context43.next) {
3174
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3175
+ while (1) switch (_context41.prev = _context41.next) {
3199
3176
  case 0:
3200
- _context43.prev = 0;
3177
+ _context41.prev = 0;
3201
3178
  console.log('[Checkout] 预加载支付方式...');
3202
- _context43.next = 4;
3179
+ _context41.next = 4;
3203
3180
  return this.payment.getPayMethodListAsync();
3204
3181
  case 4:
3205
- methods = _context43.sent;
3182
+ methods = _context41.sent;
3206
3183
  this.store.paymentMethods = methods;
3207
3184
  console.log("[Checkout] \u9884\u52A0\u8F7D\u5B8C\u6210\uFF0C\u5171 ".concat(methods.length, " \u79CD\u652F\u4ED8\u65B9\u5F0F"));
3208
- _context43.next = 13;
3185
+ _context41.next = 13;
3209
3186
  break;
3210
3187
  case 9:
3211
- _context43.prev = 9;
3212
- _context43.t0 = _context43["catch"](0);
3213
- console.error('[Checkout] 预加载支付方式失败:', _context43.t0);
3188
+ _context41.prev = 9;
3189
+ _context41.t0 = _context41["catch"](0);
3190
+ console.error('[Checkout] 预加载支付方式失败:', _context41.t0);
3214
3191
  this.store.paymentMethods = [];
3215
3192
  case 13:
3216
3193
  case "end":
3217
- return _context43.stop();
3194
+ return _context41.stop();
3218
3195
  }
3219
- }, _callee43, this, [[0, 9]]);
3196
+ }, _callee41, this, [[0, 9]]);
3220
3197
  }));
3221
3198
  function preloadPaymentMethods() {
3222
3199
  return _preloadPaymentMethods.apply(this, arguments);
@@ -3244,24 +3221,24 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3244
3221
  }, {
3245
3222
  key: "calculatePaidAmountAsync",
3246
3223
  value: (function () {
3247
- var _calculatePaidAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
3224
+ var _calculatePaidAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42() {
3248
3225
  var payments, paidAmount, result;
3249
- return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3250
- while (1) switch (_context44.prev = _context44.next) {
3226
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3227
+ while (1) switch (_context42.prev = _context42.next) {
3251
3228
  case 0:
3252
3229
  if (this.store.currentOrder) {
3253
- _context44.next = 3;
3230
+ _context42.next = 3;
3254
3231
  break;
3255
3232
  }
3256
3233
  console.log('[Checkout] calculatePaidAmountAsync: 没有当前订单');
3257
- return _context44.abrupt("return", '0.00');
3234
+ return _context42.abrupt("return", '0.00');
3258
3235
  case 3:
3259
- _context44.prev = 3;
3260
- _context44.next = 6;
3236
+ _context42.prev = 3;
3237
+ _context42.next = 6;
3261
3238
  return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid, false // 不包括已撤销的支付项
3262
3239
  );
3263
3240
  case 6:
3264
- payments = _context44.sent;
3241
+ payments = _context42.sent;
3265
3242
  console.log('[Checkout] calculatePaidAmountAsync: 支付项详情:', {
3266
3243
  paymentCount: payments.length,
3267
3244
  payments: payments.map(function (p) {
@@ -3283,17 +3260,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3283
3260
  }, 0);
3284
3261
  result = paidAmount.toFixed(2);
3285
3262
  console.log('[Checkout] calculatePaidAmountAsync: 计算结果 =', result);
3286
- return _context44.abrupt("return", result);
3263
+ return _context42.abrupt("return", result);
3287
3264
  case 14:
3288
- _context44.prev = 14;
3289
- _context44.t0 = _context44["catch"](3);
3290
- console.error('[Checkout] calculatePaidAmountAsync 失败:', _context44.t0);
3291
- return _context44.abrupt("return", '0.00');
3265
+ _context42.prev = 14;
3266
+ _context42.t0 = _context42["catch"](3);
3267
+ console.error('[Checkout] calculatePaidAmountAsync 失败:', _context42.t0);
3268
+ return _context42.abrupt("return", '0.00');
3292
3269
  case 18:
3293
3270
  case "end":
3294
- return _context44.stop();
3271
+ return _context42.stop();
3295
3272
  }
3296
- }, _callee44, this, [[3, 14]]);
3273
+ }, _callee42, this, [[3, 14]]);
3297
3274
  }));
3298
3275
  function calculatePaidAmountAsync() {
3299
3276
  return _calculatePaidAmountAsync.apply(this, arguments);
@@ -3307,25 +3284,25 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3307
3284
  }, {
3308
3285
  key: "calculateRemainingAmountAsync",
3309
3286
  value: (function () {
3310
- var _calculateRemainingAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45() {
3287
+ var _calculateRemainingAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43() {
3311
3288
  var totalAmount, paidAmount, remainingAmount, result;
3312
- return _regeneratorRuntime().wrap(function _callee45$(_context45) {
3313
- while (1) switch (_context45.prev = _context45.next) {
3289
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3290
+ while (1) switch (_context43.prev = _context43.next) {
3314
3291
  case 0:
3315
3292
  if (this.store.currentOrder) {
3316
- _context45.next = 3;
3293
+ _context43.next = 3;
3317
3294
  break;
3318
3295
  }
3319
3296
  console.log('[Checkout] calculateRemainingAmountAsync: 没有当前订单');
3320
- return _context45.abrupt("return", '0.00');
3297
+ return _context43.abrupt("return", '0.00');
3321
3298
  case 3:
3322
3299
  totalAmount = parseFloat(this.store.currentOrder.total_amount || '0');
3323
- _context45.t0 = parseFloat;
3324
- _context45.next = 7;
3300
+ _context43.t0 = parseFloat;
3301
+ _context43.next = 7;
3325
3302
  return this.calculatePaidAmountAsync();
3326
3303
  case 7:
3327
- _context45.t1 = _context45.sent;
3328
- paidAmount = (0, _context45.t0)(_context45.t1);
3304
+ _context43.t1 = _context43.sent;
3305
+ paidAmount = (0, _context43.t0)(_context43.t1);
3329
3306
  remainingAmount = totalAmount - paidAmount;
3330
3307
  result = Math.max(0, remainingAmount).toFixed(2);
3331
3308
  console.log('[Checkout] calculateRemainingAmountAsync: 计算详情:', {
@@ -3335,12 +3312,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3335
3312
  calculatedRemaining: remainingAmount.toFixed(2),
3336
3313
  finalResult: result
3337
3314
  });
3338
- return _context45.abrupt("return", result);
3315
+ return _context43.abrupt("return", result);
3339
3316
  case 13:
3340
3317
  case "end":
3341
- return _context45.stop();
3318
+ return _context43.stop();
3342
3319
  }
3343
- }, _callee45, this);
3320
+ }, _callee43, this);
3344
3321
  }));
3345
3322
  function calculateRemainingAmountAsync() {
3346
3323
  return _calculateRemainingAmountAsync.apply(this, arguments);
@@ -3354,33 +3331,33 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3354
3331
  }, {
3355
3332
  key: "updateBalanceDueAmount",
3356
3333
  value: (function () {
3357
- var _updateBalanceDueAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
3358
- var _this$store$currentOr17, remainingAmount, currentBalanceDueAmount;
3359
- return _regeneratorRuntime().wrap(function _callee46$(_context46) {
3360
- while (1) switch (_context46.prev = _context46.next) {
3334
+ var _updateBalanceDueAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
3335
+ var _this$store$currentOr18, remainingAmount, currentBalanceDueAmount;
3336
+ return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3337
+ while (1) switch (_context44.prev = _context44.next) {
3361
3338
  case 0:
3362
- _context46.prev = 0;
3363
- _context46.next = 3;
3339
+ _context44.prev = 0;
3340
+ _context44.next = 3;
3364
3341
  return this.calculateRemainingAmountAsync();
3365
3342
  case 3:
3366
- remainingAmount = _context46.sent;
3343
+ remainingAmount = _context44.sent;
3367
3344
  currentBalanceDueAmount = this.store.balanceDueAmount;
3368
3345
  console.log('[Checkout] updateBalanceDueAmount: 状态检查:', {
3369
3346
  calculatedRemainingAmount: remainingAmount,
3370
3347
  currentBalanceDueAmount: currentBalanceDueAmount,
3371
3348
  needsUpdate: remainingAmount !== currentBalanceDueAmount,
3372
- orderUuid: (_this$store$currentOr17 = this.store.currentOrder) === null || _this$store$currentOr17 === void 0 ? void 0 : _this$store$currentOr17.uuid
3349
+ orderUuid: (_this$store$currentOr18 = this.store.currentOrder) === null || _this$store$currentOr18 === void 0 ? void 0 : _this$store$currentOr18.uuid
3373
3350
  });
3374
3351
 
3375
3352
  // 只有当剩余金额与当前 balanceDueAmount 不同时才更新
3376
3353
  if (!(remainingAmount !== currentBalanceDueAmount)) {
3377
- _context46.next = 13;
3354
+ _context44.next = 13;
3378
3355
  break;
3379
3356
  }
3380
3357
  this.store.balanceDueAmount = remainingAmount;
3381
3358
 
3382
3359
  // 发出 balanceDueAmount 变更事件
3383
- _context46.next = 10;
3360
+ _context44.next = 10;
3384
3361
  return this.core.effects.emit(CheckoutHooks.OnBalanceDueAmountChanged, {
3385
3362
  oldAmount: currentBalanceDueAmount,
3386
3363
  newAmount: remainingAmount,
@@ -3391,7 +3368,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3391
3368
  oldAmount: currentBalanceDueAmount,
3392
3369
  newAmount: remainingAmount
3393
3370
  });
3394
- _context46.next = 14;
3371
+ _context44.next = 14;
3395
3372
  break;
3396
3373
  case 13:
3397
3374
  console.log('[Checkout] balanceDueAmount 无需更新,当前值已是最新:', {
@@ -3399,17 +3376,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3399
3376
  remainingAmount: remainingAmount
3400
3377
  });
3401
3378
  case 14:
3402
- _context46.next = 19;
3379
+ _context44.next = 19;
3403
3380
  break;
3404
3381
  case 16:
3405
- _context46.prev = 16;
3406
- _context46.t0 = _context46["catch"](0);
3407
- console.error('[Checkout] 更新 balanceDueAmount 失败:', _context46.t0);
3382
+ _context44.prev = 16;
3383
+ _context44.t0 = _context44["catch"](0);
3384
+ console.error('[Checkout] 更新 balanceDueAmount 失败:', _context44.t0);
3408
3385
  case 19:
3409
3386
  case "end":
3410
- return _context46.stop();
3387
+ return _context44.stop();
3411
3388
  }
3412
- }, _callee46, this, [[0, 16]]);
3389
+ }, _callee44, this, [[0, 16]]);
3413
3390
  }));
3414
3391
  function updateBalanceDueAmount() {
3415
3392
  return _updateBalanceDueAmount.apply(this, arguments);
@@ -3423,33 +3400,33 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3423
3400
  }, {
3424
3401
  key: "updateStateAmountToRemaining",
3425
3402
  value: (function () {
3426
- var _updateStateAmountToRemaining = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47() {
3427
- var _this$store$currentOr18, remainingAmount, currentStateAmount;
3428
- return _regeneratorRuntime().wrap(function _callee47$(_context47) {
3429
- while (1) switch (_context47.prev = _context47.next) {
3403
+ var _updateStateAmountToRemaining = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45() {
3404
+ var _this$store$currentOr19, remainingAmount, currentStateAmount;
3405
+ return _regeneratorRuntime().wrap(function _callee45$(_context45) {
3406
+ while (1) switch (_context45.prev = _context45.next) {
3430
3407
  case 0:
3431
- _context47.prev = 0;
3432
- _context47.next = 3;
3408
+ _context45.prev = 0;
3409
+ _context45.next = 3;
3433
3410
  return this.calculateRemainingAmountAsync();
3434
3411
  case 3:
3435
- remainingAmount = _context47.sent;
3412
+ remainingAmount = _context45.sent;
3436
3413
  currentStateAmount = this.store.stateAmount;
3437
3414
  console.log('[Checkout] updateStateAmountToRemaining: 状态检查:', {
3438
3415
  calculatedRemainingAmount: remainingAmount,
3439
3416
  currentStateAmount: currentStateAmount,
3440
3417
  needsUpdate: remainingAmount !== currentStateAmount,
3441
- orderUuid: (_this$store$currentOr18 = this.store.currentOrder) === null || _this$store$currentOr18 === void 0 ? void 0 : _this$store$currentOr18.uuid
3418
+ orderUuid: (_this$store$currentOr19 = this.store.currentOrder) === null || _this$store$currentOr19 === void 0 ? void 0 : _this$store$currentOr19.uuid
3442
3419
  });
3443
3420
 
3444
3421
  // 只有当剩余金额与当前 stateAmount 不同时才更新
3445
3422
  if (!(remainingAmount !== currentStateAmount)) {
3446
- _context47.next = 13;
3423
+ _context45.next = 13;
3447
3424
  break;
3448
3425
  }
3449
3426
  this.store.stateAmount = remainingAmount;
3450
3427
 
3451
3428
  // 发出 stateAmount 变更事件
3452
- _context47.next = 10;
3429
+ _context45.next = 10;
3453
3430
  return this.core.effects.emit(CheckoutHooks.OnStateAmountChanged, {
3454
3431
  oldAmount: currentStateAmount,
3455
3432
  newAmount: remainingAmount,
@@ -3460,7 +3437,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3460
3437
  oldAmount: currentStateAmount,
3461
3438
  newAmount: remainingAmount
3462
3439
  });
3463
- _context47.next = 14;
3440
+ _context45.next = 14;
3464
3441
  break;
3465
3442
  case 13:
3466
3443
  console.log('[Checkout] stateAmount 无需更新,当前值已是最新:', {
@@ -3468,23 +3445,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3468
3445
  remainingAmount: remainingAmount
3469
3446
  });
3470
3447
  case 14:
3471
- _context47.next = 16;
3448
+ _context45.next = 16;
3472
3449
  return this.updateBalanceDueAmount();
3473
3450
  case 16:
3474
- _context47.next = 18;
3451
+ _context45.next = 18;
3475
3452
  return this.checkOrderPaymentCompletion();
3476
3453
  case 18:
3477
- _context47.next = 23;
3454
+ _context45.next = 23;
3478
3455
  break;
3479
3456
  case 20:
3480
- _context47.prev = 20;
3481
- _context47.t0 = _context47["catch"](0);
3482
- console.error('[Checkout] 更新 stateAmount 为剩余金额失败:', _context47.t0);
3457
+ _context45.prev = 20;
3458
+ _context45.t0 = _context45["catch"](0);
3459
+ console.error('[Checkout] 更新 stateAmount 为剩余金额失败:', _context45.t0);
3483
3460
  case 23:
3484
3461
  case "end":
3485
- return _context47.stop();
3462
+ return _context45.stop();
3486
3463
  }
3487
- }, _callee47, this, [[0, 20]]);
3464
+ }, _callee45, this, [[0, 20]]);
3488
3465
  }));
3489
3466
  function updateStateAmountToRemaining() {
3490
3467
  return _updateStateAmountToRemaining.apply(this, arguments);
@@ -3500,32 +3477,32 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3500
3477
  }, {
3501
3478
  key: "checkOrderPaymentCompletion",
3502
3479
  value: (function () {
3503
- var _checkOrderPaymentCompletion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48() {
3480
+ var _checkOrderPaymentCompletion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
3504
3481
  var remainingAmount, remainingValue, totalAmount, paidAmount, currentPayments, hasPaymentItems, allPaymentsHaveVoucherId, shouldAutoSync;
3505
- return _regeneratorRuntime().wrap(function _callee48$(_context48) {
3506
- while (1) switch (_context48.prev = _context48.next) {
3482
+ return _regeneratorRuntime().wrap(function _callee46$(_context46) {
3483
+ while (1) switch (_context46.prev = _context46.next) {
3507
3484
  case 0:
3508
- _context48.prev = 0;
3485
+ _context46.prev = 0;
3509
3486
  if (this.store.currentOrder) {
3510
- _context48.next = 3;
3487
+ _context46.next = 3;
3511
3488
  break;
3512
3489
  }
3513
- return _context48.abrupt("return");
3490
+ return _context46.abrupt("return");
3514
3491
  case 3:
3515
- _context48.next = 5;
3492
+ _context46.next = 5;
3516
3493
  return this.calculateRemainingAmountAsync();
3517
3494
  case 5:
3518
- remainingAmount = _context48.sent;
3495
+ remainingAmount = _context46.sent;
3519
3496
  remainingValue = parseFloat(remainingAmount); // 当剩余金额小于等于0时,认为订单已完成支付
3520
3497
  if (!(remainingValue <= 0)) {
3521
- _context48.next = 29;
3498
+ _context46.next = 29;
3522
3499
  break;
3523
3500
  }
3524
3501
  totalAmount = this.store.currentOrder.total_amount;
3525
- _context48.next = 11;
3502
+ _context46.next = 11;
3526
3503
  return this.calculatePaidAmountAsync();
3527
3504
  case 11:
3528
- paidAmount = _context48.sent;
3505
+ paidAmount = _context46.sent;
3529
3506
  console.log('[Checkout] 检测到订单支付完成:', {
3530
3507
  orderUuid: this.store.currentOrder.uuid,
3531
3508
  orderId: this.store.currentOrder.order_id,
@@ -3536,11 +3513,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3536
3513
  });
3537
3514
 
3538
3515
  // 从 Payment 模块获取最新支付项,检查自动同步条件
3539
- _context48.next = 15;
3516
+ _context46.next = 15;
3540
3517
  return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid, false // 不包括已撤销的支付项
3541
3518
  );
3542
3519
  case 15:
3543
- currentPayments = _context48.sent;
3520
+ currentPayments = _context46.sent;
3544
3521
  // 检查自动同步条件:
3545
3522
  // 1. 待付金额为 0 ✓ (已在上面检查)
3546
3523
  // 2. 需要有支付项
@@ -3572,14 +3549,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3572
3549
  })
3573
3550
  });
3574
3551
  if (!shouldAutoSync) {
3575
- _context48.next = 26;
3552
+ _context46.next = 26;
3576
3553
  break;
3577
3554
  }
3578
3555
  console.log('[Checkout] 满足自动同步条件,开始同步订单到后端...');
3579
- _context48.next = 24;
3556
+ _context46.next = 24;
3580
3557
  return this.syncOrderToBackend();
3581
3558
  case 24:
3582
- _context48.next = 27;
3559
+ _context46.next = 27;
3583
3560
  break;
3584
3561
  case 26:
3585
3562
  if (!hasPaymentItems) {
@@ -3588,7 +3565,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3588
3565
  console.log('[Checkout] 所有支付项均为代金券类型,跳过订单同步');
3589
3566
  }
3590
3567
  case 27:
3591
- _context48.next = 29;
3568
+ _context46.next = 29;
3592
3569
  return this.core.effects.emit(CheckoutHooks.OnOrderPaymentCompleted, {
3593
3570
  orderUuid: this.store.currentOrder.uuid,
3594
3571
  orderId: this.store.currentOrder.order_id,
@@ -3598,17 +3575,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3598
3575
  timestamp: Date.now()
3599
3576
  });
3600
3577
  case 29:
3601
- _context48.next = 34;
3578
+ _context46.next = 34;
3602
3579
  break;
3603
3580
  case 31:
3604
- _context48.prev = 31;
3605
- _context48.t0 = _context48["catch"](0);
3606
- console.error('[Checkout] 检查订单支付完成状态失败:', _context48.t0);
3581
+ _context46.prev = 31;
3582
+ _context46.t0 = _context46["catch"](0);
3583
+ console.error('[Checkout] 检查订单支付完成状态失败:', _context46.t0);
3607
3584
  case 34:
3608
3585
  case "end":
3609
- return _context48.stop();
3586
+ return _context46.stop();
3610
3587
  }
3611
- }, _callee48, this, [[0, 31]]);
3588
+ }, _callee46, this, [[0, 31]]);
3612
3589
  }));
3613
3590
  function checkOrderPaymentCompletion() {
3614
3591
  return _checkOrderPaymentCompletion.apply(this, arguments);
@@ -3680,8 +3657,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3680
3657
  }, {
3681
3658
  key: "syncOrderToBackendWithReturn",
3682
3659
  value: (function () {
3683
- var _syncOrderToBackendWithReturn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49() {
3684
- var _this$store$currentCu2, _this$store$currentOr19, _this$store$currentOr20, _checkoutResponse3, _checkoutResponse4, _checkoutResponse5, _checkoutResponse6, _checkoutResponse7, _checkoutResponse8;
3660
+ var _syncOrderToBackendWithReturn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47() {
3661
+ var _this$store$currentCu2, _this$store$currentOr20, _this$store$currentOr21, _checkoutResponse3, _checkoutResponse4, _checkoutResponse5, _checkoutResponse6, _checkoutResponse7, _checkoutResponse8;
3685
3662
  var isManual,
3686
3663
  customPaymentItems,
3687
3664
  syncType,
@@ -3712,14 +3689,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3712
3689
  beforeManualUpdate,
3713
3690
  finalOrderId,
3714
3691
  finalIsVirtual,
3715
- _args49 = arguments;
3716
- return _regeneratorRuntime().wrap(function _callee49$(_context49) {
3717
- while (1) switch (_context49.prev = _context49.next) {
3692
+ _args47 = arguments;
3693
+ return _regeneratorRuntime().wrap(function _callee47$(_context47) {
3694
+ while (1) switch (_context47.prev = _context47.next) {
3718
3695
  case 0:
3719
- isManual = _args49.length > 0 && _args49[0] !== undefined ? _args49[0] : false;
3720
- customPaymentItems = _args49.length > 1 ? _args49[1] : undefined;
3696
+ isManual = _args47.length > 0 && _args47[0] !== undefined ? _args47[0] : false;
3697
+ customPaymentItems = _args47.length > 1 ? _args47[1] : undefined;
3721
3698
  if (!(!this.store.localOrderData || !this.store.currentOrder)) {
3722
- _context49.next = 4;
3699
+ _context47.next = 4;
3723
3700
  break;
3724
3701
  }
3725
3702
  throw new Error('缺少必要的订单数据,无法同步到后端');
@@ -3760,17 +3737,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3760
3737
  });
3761
3738
 
3762
3739
  // 获取当前订单的支付项
3763
- _context49.t0 = customPaymentItems;
3764
- if (_context49.t0) {
3765
- _context49.next = 18;
3740
+ _context47.t0 = customPaymentItems;
3741
+ if (_context47.t0) {
3742
+ _context47.next = 18;
3766
3743
  break;
3767
3744
  }
3768
- _context49.next = 17;
3745
+ _context47.next = 17;
3769
3746
  return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid);
3770
3747
  case 17:
3771
- _context49.t0 = _context49.sent;
3748
+ _context47.t0 = _context47.sent;
3772
3749
  case 18:
3773
- paymentItems = _context49.t0;
3750
+ paymentItems = _context47.t0;
3774
3751
  console.log('[Checkout] 获取到支付项:', {
3775
3752
  count: paymentItems.length,
3776
3753
  isCustomFiltered: !!customPaymentItems,
@@ -3811,8 +3788,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3811
3788
  currency_code: this.otherParams.currency_code,
3812
3789
  currency_symbol: this.otherParams.currency_symbol,
3813
3790
  currency_format: this.otherParams.currency_format,
3814
- is_deposit: ((_this$store$currentOr19 = this.store.currentOrder) === null || _this$store$currentOr19 === void 0 ? void 0 : _this$store$currentOr19.is_deposit) || 0,
3815
- deposit_amount: ((_this$store$currentOr20 = this.store.currentOrder) === null || _this$store$currentOr20 === void 0 ? void 0 : _this$store$currentOr20.deposit_amount) || '0.00',
3791
+ is_deposit: ((_this$store$currentOr20 = this.store.currentOrder) === null || _this$store$currentOr20 === void 0 ? void 0 : _this$store$currentOr20.is_deposit) || 0,
3792
+ deposit_amount: ((_this$store$currentOr21 = this.store.currentOrder) === null || _this$store$currentOr21 === void 0 ? void 0 : _this$store$currentOr21.deposit_amount) || '0.00',
3816
3793
  // surcharge_fee: this.otherParams.surcharge_fee,
3817
3794
  // surcharges: ,
3818
3795
  note: this.store.localOrderData.shop_note
@@ -3843,7 +3820,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3843
3820
 
3844
3821
  // 发送下单接口请求开始事件
3845
3822
  startTime = Date.now();
3846
- _context49.next = 25;
3823
+ _context47.next = 25;
3847
3824
  return this.core.effects.emit(CheckoutHooks.OnOrderSubmitStart, {
3848
3825
  orderUuid: this.store.currentOrder.uuid,
3849
3826
  operation: isUpdateOperation ? 'update' : 'create',
@@ -3853,24 +3830,24 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3853
3830
  });
3854
3831
  case 25:
3855
3832
  submitSuccess = false;
3856
- _context49.prev = 26;
3857
- _context49.next = 29;
3833
+ _context47.prev = 26;
3834
+ _context47.next = 29;
3858
3835
  return this.order.createOrderByCheckout(orderParams);
3859
3836
  case 29:
3860
- checkoutResponse = _context49.sent;
3837
+ checkoutResponse = _context47.sent;
3861
3838
  submitSuccess = true;
3862
3839
  console.log('[Checkout] 下单接口调用成功');
3863
- _context49.next = 41;
3840
+ _context47.next = 41;
3864
3841
  break;
3865
3842
  case 34:
3866
- _context49.prev = 34;
3867
- _context49.t1 = _context49["catch"](26);
3843
+ _context47.prev = 34;
3844
+ _context47.t1 = _context47["catch"](26);
3868
3845
  submitSuccess = false;
3869
- submitError = _context49.t1 instanceof Error ? _context49.t1.message : String(_context49.t1);
3846
+ submitError = _context47.t1 instanceof Error ? _context47.t1.message : String(_context47.t1);
3870
3847
  // console.error('[Checkout] 下单接口调用失败:', submitError);
3871
3848
 
3872
3849
  // 发送订单同步失败事件(网络错误或请求失败)
3873
- _context49.next = 40;
3850
+ _context47.next = 40;
3874
3851
  return this.core.effects.emit(CheckoutHooks.OnOrderSyncFailed, {
3875
3852
  orderUuid: this.store.currentOrder.uuid,
3876
3853
  operation: isUpdateOperation ? 'update' : 'create',
@@ -3881,10 +3858,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3881
3858
  timestamp: Date.now()
3882
3859
  });
3883
3860
  case 40:
3884
- throw _context49.t1;
3861
+ throw _context47.t1;
3885
3862
  case 41:
3886
- _context49.prev = 41;
3887
- _context49.next = 44;
3863
+ _context47.prev = 41;
3864
+ _context47.next = 44;
3888
3865
  return this.core.effects.emit(CheckoutHooks.OnOrderSubmitEnd, {
3889
3866
  success: submitSuccess,
3890
3867
  orderUuid: this.store.currentOrder.uuid,
@@ -3896,7 +3873,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3896
3873
  timestamp: Date.now()
3897
3874
  });
3898
3875
  case 44:
3899
- return _context49.finish(41);
3876
+ return _context47.finish(41);
3900
3877
  case 45:
3901
3878
  console.log('[Checkout] 后端返回的响应数据:', {
3902
3879
  status: (_checkoutResponse3 = checkoutResponse) === null || _checkoutResponse3 === void 0 ? void 0 : _checkoutResponse3.status,
@@ -3909,7 +3886,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3909
3886
  responseStatus = (_checkoutResponse7 = checkoutResponse) === null || _checkoutResponse7 === void 0 ? void 0 : _checkoutResponse7.status;
3910
3887
  isSuccessResponse = responseStatus === true || responseStatus === 200 || responseStatus === 'success' || responseStatus === 1 && ((_checkoutResponse8 = checkoutResponse) === null || _checkoutResponse8 === void 0 ? void 0 : _checkoutResponse8.code) === 200;
3911
3888
  if (isSuccessResponse) {
3912
- _context49.next = 54;
3889
+ _context47.next = 54;
3913
3890
  break;
3914
3891
  }
3915
3892
  errorMessage = ((_checkoutResponse9 = checkoutResponse) === null || _checkoutResponse9 === void 0 ? void 0 : _checkoutResponse9.message) || '订单同步失败,后端返回非成功状态';
@@ -3922,7 +3899,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3922
3899
  });
3923
3900
 
3924
3901
  // 发送订单同步失败事件
3925
- _context49.next = 53;
3902
+ _context47.next = 53;
3926
3903
  return this.core.effects.emit(CheckoutHooks.OnOrderSyncFailed, {
3927
3904
  orderUuid: this.store.currentOrder.uuid,
3928
3905
  operation: isUpdateOperation ? 'update' : 'create',
@@ -3938,13 +3915,13 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3938
3915
  case 54:
3939
3916
  console.log('[Checkout] 响应状态检查通过,开始处理订单数据');
3940
3917
  if (!isUpdateOperation) {
3941
- _context49.next = 60;
3918
+ _context47.next = 60;
3942
3919
  break;
3943
3920
  }
3944
3921
  // 更新操作:使用现有的订单ID
3945
3922
  realOrderId = currentOrderId;
3946
3923
  console.log("[Checkout] \u8BA2\u5355\u66F4\u65B0\u6210\u529F\uFF0C\u8BA2\u5355ID: ".concat(realOrderId));
3947
- _context49.next = 81;
3924
+ _context47.next = 81;
3948
3925
  break;
3949
3926
  case 60:
3950
3927
  // 创建操作:从响应中提取新的订单ID
@@ -3958,7 +3935,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3958
3935
  extractedOrderId = String(extractedOrderId);
3959
3936
  }
3960
3937
  if (extractedOrderId) {
3961
- _context49.next = 65;
3938
+ _context47.next = 65;
3962
3939
  break;
3963
3940
  }
3964
3941
  throw new Error('后端返回的订单信息中未包含订单ID');
@@ -3972,11 +3949,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3972
3949
  oldOrderId: this.store.currentOrder.order_id,
3973
3950
  newOrderId: realOrderId
3974
3951
  });
3975
- _context49.prev = 68;
3976
- _context49.next = 71;
3952
+ _context47.prev = 68;
3953
+ _context47.next = 71;
3977
3954
  return this.payment.replaceOrderIdByUuidAsync(this.store.currentOrder.uuid, realOrderId);
3978
3955
  case 71:
3979
- updatedOrder = _context49.sent;
3956
+ updatedOrder = _context47.sent;
3980
3957
  console.log('[Checkout] Payment模块替换订单ID结果:', {
3981
3958
  wasSuccessful: !!updatedOrder,
3982
3959
  returnedOrderId: updatedOrder === null || updatedOrder === void 0 ? void 0 : updatedOrder.order_id,
@@ -4002,12 +3979,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4002
3979
  目标ID: realOrderId
4003
3980
  });
4004
3981
  }
4005
- _context49.next = 81;
3982
+ _context47.next = 81;
4006
3983
  break;
4007
3984
  case 76:
4008
- _context49.prev = 76;
4009
- _context49.t2 = _context49["catch"](68);
4010
- console.error('[Checkout] 调用Payment模块替换订单ID时发生错误:', _context49.t2);
3985
+ _context47.prev = 76;
3986
+ _context47.t2 = _context47["catch"](68);
3987
+ console.error('[Checkout] 调用Payment模块替换订单ID时发生错误:', _context47.t2);
4011
3988
 
4012
3989
  // 发生错误时也进行手动替换
4013
3990
  this.store.currentOrder.order_id = realOrderId;
@@ -4017,7 +3994,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4017
3994
  this.store.isOrderSynced = true;
4018
3995
 
4019
3996
  // 触发订单同步完成事件
4020
- _context49.next = 84;
3997
+ _context47.next = 84;
4021
3998
  return this.core.effects.emit(CheckoutHooks.OnOrderSynced, {
4022
3999
  orderUuid: this.store.currentOrder.uuid,
4023
4000
  realOrderId: realOrderId,
@@ -4043,12 +4020,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4043
4020
  }
4044
4021
 
4045
4022
  // 返回真实订单ID
4046
- return _context49.abrupt("return", realOrderId);
4023
+ return _context47.abrupt("return", realOrderId);
4047
4024
  case 89:
4048
4025
  case "end":
4049
- return _context49.stop();
4026
+ return _context47.stop();
4050
4027
  }
4051
- }, _callee49, this, [[26, 34, 41, 45], [68, 76]]);
4028
+ }, _callee47, this, [[26, 34, 41, 45], [68, 76]]);
4052
4029
  }));
4053
4030
  function syncOrderToBackendWithReturn() {
4054
4031
  return _syncOrderToBackendWithReturn.apply(this, arguments);
@@ -4058,27 +4035,27 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4058
4035
  }, {
4059
4036
  key: "syncOrderToBackend",
4060
4037
  value: function () {
4061
- var _syncOrderToBackend = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50() {
4062
- return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4063
- while (1) switch (_context50.prev = _context50.next) {
4038
+ var _syncOrderToBackend = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48() {
4039
+ return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4040
+ while (1) switch (_context48.prev = _context48.next) {
4064
4041
  case 0:
4065
- _context50.prev = 0;
4066
- _context50.next = 3;
4042
+ _context48.prev = 0;
4043
+ _context48.next = 3;
4067
4044
  return this.syncOrderToBackendWithReturn(false);
4068
4045
  case 3:
4069
- _context50.next = 10;
4046
+ _context48.next = 10;
4070
4047
  break;
4071
4048
  case 5:
4072
- _context50.prev = 5;
4073
- _context50.t0 = _context50["catch"](0);
4074
- console.error('[Checkout] 同步订单到后端失败:', _context50.t0);
4075
- _context50.next = 10;
4076
- return this.handleError(new Error("\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(_context50.t0 instanceof Error ? _context50.t0.message : String(_context50.t0))), CheckoutErrorType.OrderCreationFailed);
4049
+ _context48.prev = 5;
4050
+ _context48.t0 = _context48["catch"](0);
4051
+ console.error('[Checkout] 同步订单到后端失败:', _context48.t0);
4052
+ _context48.next = 10;
4053
+ 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
4054
  case 10:
4078
4055
  case "end":
4079
- return _context50.stop();
4056
+ return _context48.stop();
4080
4057
  }
4081
- }, _callee50, this, [[0, 5]]);
4058
+ }, _callee48, this, [[0, 5]]);
4082
4059
  }));
4083
4060
  function syncOrderToBackend() {
4084
4061
  return _syncOrderToBackend.apply(this, arguments);
@@ -4118,15 +4095,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4118
4095
  }, {
4119
4096
  key: "setOtherParams",
4120
4097
  value: function () {
4121
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
4098
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(params) {
4122
4099
  var _ref5,
4123
4100
  _ref5$cover,
4124
4101
  cover,
4125
- _args51 = arguments;
4126
- return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4127
- while (1) switch (_context51.prev = _context51.next) {
4102
+ _args49 = arguments;
4103
+ return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4104
+ while (1) switch (_context49.prev = _context49.next) {
4128
4105
  case 0:
4129
- _ref5 = _args51.length > 1 && _args51[1] !== undefined ? _args51[1] : {}, _ref5$cover = _ref5.cover, cover = _ref5$cover === void 0 ? false : _ref5$cover;
4106
+ _ref5 = _args49.length > 1 && _args49[1] !== undefined ? _args49[1] : {}, _ref5$cover = _ref5.cover, cover = _ref5$cover === void 0 ? false : _ref5$cover;
4130
4107
  if (cover) {
4131
4108
  this.otherParams = params;
4132
4109
  } else {
@@ -4134,11 +4111,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4134
4111
  }
4135
4112
  case 2:
4136
4113
  case "end":
4137
- return _context51.stop();
4114
+ return _context49.stop();
4138
4115
  }
4139
- }, _callee51, this);
4116
+ }, _callee49, this);
4140
4117
  }));
4141
- function setOtherParams(_x32) {
4118
+ function setOtherParams(_x30) {
4142
4119
  return _setOtherParams.apply(this, arguments);
4143
4120
  }
4144
4121
  return setOtherParams;
@@ -4155,12 +4132,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4155
4132
  }, {
4156
4133
  key: "editOrderNoteByOrderIdAsync",
4157
4134
  value: (function () {
4158
- var _editOrderNoteByOrderIdAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(orderId, note) {
4135
+ var _editOrderNoteByOrderIdAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(orderId, note) {
4159
4136
  var response, previousNote, errorMessage, _errorMessage;
4160
- return _regeneratorRuntime().wrap(function _callee52$(_context52) {
4161
- while (1) switch (_context52.prev = _context52.next) {
4137
+ return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4138
+ while (1) switch (_context50.prev = _context50.next) {
4162
4139
  case 0:
4163
- _context52.prev = 0;
4140
+ _context50.prev = 0;
4164
4141
  console.log('[Checkout] 开始编辑订单备注:', {
4165
4142
  orderId: orderId,
4166
4143
  note: note,
@@ -4169,21 +4146,21 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4169
4146
 
4170
4147
  // 参数验证
4171
4148
  if (orderId) {
4172
- _context52.next = 4;
4149
+ _context50.next = 4;
4173
4150
  break;
4174
4151
  }
4175
- return _context52.abrupt("return", {
4152
+ return _context50.abrupt("return", {
4176
4153
  success: false,
4177
4154
  message: '订单ID不能为空',
4178
4155
  orderId: orderId
4179
4156
  });
4180
4157
  case 4:
4181
- _context52.next = 6;
4158
+ _context50.next = 6;
4182
4159
  return this.request.put("/order/order/".concat(orderId, "/note"), {
4183
4160
  note: note
4184
4161
  });
4185
4162
  case 6:
4186
- response = _context52.sent;
4163
+ response = _context50.sent;
4187
4164
  console.log('[Checkout] 订单备注编辑响应:', {
4188
4165
  orderId: orderId,
4189
4166
  status: response.status,
@@ -4193,14 +4170,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4193
4170
 
4194
4171
  // 检查响应状态
4195
4172
  if (!(response.status === true || response.status === 200)) {
4196
- _context52.next = 19;
4173
+ _context50.next = 19;
4197
4174
  break;
4198
4175
  }
4199
4176
  console.log("[Checkout] \u8BA2\u5355 ".concat(orderId, " \u5907\u6CE8\u4FEE\u6539\u6210\u529F"));
4200
4177
 
4201
4178
  // 如果当前订单就是被修改的订单,同时更新本地状态
4202
4179
  if (!(this.store.currentOrder && (String(this.store.currentOrder.order_id) === String(orderId) || String(this.store.currentOrder.id) === String(orderId)))) {
4203
- _context52.next = 16;
4180
+ _context50.next = 16;
4204
4181
  break;
4205
4182
  }
4206
4183
  console.log('[Checkout] 更新本地订单备注状态');
@@ -4212,7 +4189,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4212
4189
  }
4213
4190
 
4214
4191
  // 触发订单备注变更事件
4215
- _context52.next = 16;
4192
+ _context50.next = 16;
4216
4193
  return this.core.effects.emit(CheckoutHooks.OnOrderNoteChanged, {
4217
4194
  orderUuid: this.store.currentOrder.uuid,
4218
4195
  oldNote: previousNote,
@@ -4220,7 +4197,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4220
4197
  timestamp: Date.now()
4221
4198
  });
4222
4199
  case 16:
4223
- return _context52.abrupt("return", {
4200
+ return _context50.abrupt("return", {
4224
4201
  success: true,
4225
4202
  message: response.message || '订单备注修改成功',
4226
4203
  orderId: orderId
@@ -4229,31 +4206,31 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4229
4206
  // API返回失败状态
4230
4207
  errorMessage = response.message || '订单备注修改失败';
4231
4208
  console.error("[Checkout] \u8BA2\u5355 ".concat(orderId, " \u5907\u6CE8\u4FEE\u6539\u5931\u8D25:"), errorMessage);
4232
- return _context52.abrupt("return", {
4209
+ return _context50.abrupt("return", {
4233
4210
  success: false,
4234
4211
  message: errorMessage,
4235
4212
  orderId: orderId
4236
4213
  });
4237
4214
  case 22:
4238
- _context52.next = 29;
4215
+ _context50.next = 29;
4239
4216
  break;
4240
4217
  case 24:
4241
- _context52.prev = 24;
4242
- _context52.t0 = _context52["catch"](0);
4243
- console.error('[Checkout] 编辑订单备注失败:', _context52.t0);
4244
- _errorMessage = _context52.t0 instanceof Error ? _context52.t0.message : '网络错误或服务器异常';
4245
- return _context52.abrupt("return", {
4218
+ _context50.prev = 24;
4219
+ _context50.t0 = _context50["catch"](0);
4220
+ console.error('[Checkout] 编辑订单备注失败:', _context50.t0);
4221
+ _errorMessage = _context50.t0 instanceof Error ? _context50.t0.message : '网络错误或服务器异常';
4222
+ return _context50.abrupt("return", {
4246
4223
  success: false,
4247
4224
  message: "\u7F16\u8F91\u8BA2\u5355\u5907\u6CE8\u5931\u8D25: ".concat(_errorMessage),
4248
4225
  orderId: orderId
4249
4226
  });
4250
4227
  case 29:
4251
4228
  case "end":
4252
- return _context52.stop();
4229
+ return _context50.stop();
4253
4230
  }
4254
- }, _callee52, this, [[0, 24]]);
4231
+ }, _callee50, this, [[0, 24]]);
4255
4232
  }));
4256
- function editOrderNoteByOrderIdAsync(_x33, _x34) {
4233
+ function editOrderNoteByOrderIdAsync(_x31, _x32) {
4257
4234
  return _editOrderNoteByOrderIdAsync.apply(this, arguments);
4258
4235
  }
4259
4236
  return editOrderNoteByOrderIdAsync;
@@ -4270,12 +4247,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4270
4247
  }, {
4271
4248
  key: "sendCustomerPayLinkAsync",
4272
4249
  value: (function () {
4273
- var _sendCustomerPayLinkAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(params) {
4250
+ var _sendCustomerPayLinkAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
4274
4251
  var emailRegex, invalidEmails, requestBody, response, errorMessage, _errorMessage2;
4275
- return _regeneratorRuntime().wrap(function _callee53$(_context53) {
4276
- while (1) switch (_context53.prev = _context53.next) {
4252
+ return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4253
+ while (1) switch (_context51.prev = _context51.next) {
4277
4254
  case 0:
4278
- _context53.prev = 0;
4255
+ _context51.prev = 0;
4279
4256
  console.log('[Checkout] 开始发送客户支付链接邮件:', {
4280
4257
  orderIds: params.order_ids,
4281
4258
  emails: params.emails,
@@ -4284,19 +4261,19 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4284
4261
 
4285
4262
  // 参数验证
4286
4263
  if (!(!params.order_ids || params.order_ids.length === 0)) {
4287
- _context53.next = 4;
4264
+ _context51.next = 4;
4288
4265
  break;
4289
4266
  }
4290
- return _context53.abrupt("return", {
4267
+ return _context51.abrupt("return", {
4291
4268
  success: false,
4292
4269
  message: '订单ID列表不能为空'
4293
4270
  });
4294
4271
  case 4:
4295
4272
  if (!(!params.emails || params.emails.length === 0)) {
4296
- _context53.next = 6;
4273
+ _context51.next = 6;
4297
4274
  break;
4298
4275
  }
4299
- return _context53.abrupt("return", {
4276
+ return _context51.abrupt("return", {
4300
4277
  success: false,
4301
4278
  message: '邮箱地址列表不能为空'
4302
4279
  });
@@ -4307,10 +4284,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4307
4284
  return !emailRegex.test(email);
4308
4285
  });
4309
4286
  if (!(invalidEmails.length > 0)) {
4310
- _context53.next = 10;
4287
+ _context51.next = 10;
4311
4288
  break;
4312
4289
  }
4313
- return _context53.abrupt("return", {
4290
+ return _context51.abrupt("return", {
4314
4291
  success: false,
4315
4292
  message: "\u90AE\u7BB1\u683C\u5F0F\u65E0\u6548: ".concat(invalidEmails.join(', '))
4316
4293
  });
@@ -4324,10 +4301,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4324
4301
  console.log('[Checkout] 发送支付链接邮件请求参数:', requestBody);
4325
4302
 
4326
4303
  // 调用后端API发送邮件
4327
- _context53.next = 14;
4304
+ _context51.next = 14;
4328
4305
  return this.request.post('/order/batch-email', requestBody);
4329
4306
  case 14:
4330
- response = _context53.sent;
4307
+ response = _context51.sent;
4331
4308
  console.log('[Checkout] 支付链接邮件发送响应:', {
4332
4309
  status: response.status,
4333
4310
  message: response.message,
@@ -4337,11 +4314,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4337
4314
 
4338
4315
  // 检查响应状态
4339
4316
  if (!(response.status === true || response.status === 200)) {
4340
- _context53.next = 21;
4317
+ _context51.next = 21;
4341
4318
  break;
4342
4319
  }
4343
4320
  console.log('[Checkout] 支付链接邮件发送成功');
4344
- return _context53.abrupt("return", {
4321
+ return _context51.abrupt("return", {
4345
4322
  success: true,
4346
4323
  message: response.message || '支付链接邮件发送成功'
4347
4324
  });
@@ -4349,29 +4326,29 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4349
4326
  // API返回失败状态
4350
4327
  errorMessage = response.message || '支付链接邮件发送失败';
4351
4328
  console.error('[Checkout] 支付链接邮件发送失败:', errorMessage);
4352
- return _context53.abrupt("return", {
4329
+ return _context51.abrupt("return", {
4353
4330
  success: false,
4354
4331
  message: errorMessage
4355
4332
  });
4356
4333
  case 24:
4357
- _context53.next = 31;
4334
+ _context51.next = 31;
4358
4335
  break;
4359
4336
  case 26:
4360
- _context53.prev = 26;
4361
- _context53.t0 = _context53["catch"](0);
4362
- console.error('[Checkout] 发送客户支付链接邮件失败:', _context53.t0);
4363
- _errorMessage2 = _context53.t0 instanceof Error ? _context53.t0.message : '网络错误或服务器异常';
4364
- return _context53.abrupt("return", {
4337
+ _context51.prev = 26;
4338
+ _context51.t0 = _context51["catch"](0);
4339
+ console.error('[Checkout] 发送客户支付链接邮件失败:', _context51.t0);
4340
+ _errorMessage2 = _context51.t0 instanceof Error ? _context51.t0.message : '网络错误或服务器异常';
4341
+ return _context51.abrupt("return", {
4365
4342
  success: false,
4366
4343
  message: "\u53D1\u9001\u652F\u4ED8\u94FE\u63A5\u90AE\u4EF6\u5931\u8D25: ".concat(_errorMessage2)
4367
4344
  });
4368
4345
  case 31:
4369
4346
  case "end":
4370
- return _context53.stop();
4347
+ return _context51.stop();
4371
4348
  }
4372
- }, _callee53, this, [[0, 26]]);
4349
+ }, _callee51, this, [[0, 26]]);
4373
4350
  }));
4374
- function sendCustomerPayLinkAsync(_x35) {
4351
+ function sendCustomerPayLinkAsync(_x33) {
4375
4352
  return _sendCustomerPayLinkAsync.apply(this, arguments);
4376
4353
  }
4377
4354
  return sendCustomerPayLinkAsync;
@@ -4386,25 +4363,25 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4386
4363
  }, {
4387
4364
  key: "roundAmountAsync",
4388
4365
  value: (function () {
4389
- var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(amount) {
4366
+ var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(amount) {
4390
4367
  var _this$otherParams$ord, _this$otherParams$ord2;
4391
4368
  var result;
4392
- return _regeneratorRuntime().wrap(function _callee54$(_context54) {
4393
- while (1) switch (_context54.prev = _context54.next) {
4369
+ return _regeneratorRuntime().wrap(function _callee52$(_context52) {
4370
+ while (1) switch (_context52.prev = _context52.next) {
4394
4371
  case 0:
4395
- _context54.next = 2;
4372
+ _context52.next = 2;
4396
4373
  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
4374
  case 2:
4398
- result = _context54.sent;
4375
+ result = _context52.sent;
4399
4376
  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 _context54.abrupt("return", result);
4377
+ return _context52.abrupt("return", result);
4401
4378
  case 5:
4402
4379
  case "end":
4403
- return _context54.stop();
4380
+ return _context52.stop();
4404
4381
  }
4405
- }, _callee54, this);
4382
+ }, _callee52, this);
4406
4383
  }));
4407
- function roundAmountAsync(_x36) {
4384
+ function roundAmountAsync(_x34) {
4408
4385
  return _roundAmountAsync.apply(this, arguments);
4409
4386
  }
4410
4387
  return roundAmountAsync;
@@ -4412,10 +4389,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4412
4389
  }, {
4413
4390
  key: "destroy",
4414
4391
  value: function () {
4415
- var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55() {
4392
+ var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53() {
4416
4393
  var _this$order, _this$order$destroy, _this$payment, _this$payment$destroy;
4417
- return _regeneratorRuntime().wrap(function _callee55$(_context55) {
4418
- while (1) switch (_context55.prev = _context55.next) {
4394
+ return _regeneratorRuntime().wrap(function _callee53$(_context53) {
4395
+ while (1) switch (_context53.prev = _context53.next) {
4419
4396
  case 0:
4420
4397
  // 清理钱包模块的所有缓存数据
4421
4398
  this.payment.wallet.clearAllCache();
@@ -4424,10 +4401,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4424
4401
  this.core.effects.offByModuleDestroy(this.name);
4425
4402
 
4426
4403
  // 销毁子模块
4427
- _context55.next = 4;
4404
+ _context53.next = 4;
4428
4405
  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
4406
  case 4:
4430
- _context55.next = 6;
4407
+ _context53.next = 6;
4431
4408
  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
4409
  case 6:
4433
4410
  // 取消注册模块
@@ -4435,9 +4412,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4435
4412
  console.log('[Checkout] 已销毁');
4436
4413
  case 8:
4437
4414
  case "end":
4438
- return _context55.stop();
4415
+ return _context53.stop();
4439
4416
  }
4440
- }, _callee55, this);
4417
+ }, _callee53, this);
4441
4418
  }));
4442
4419
  function destroy() {
4443
4420
  return _destroy.apply(this, arguments);
@@ -4452,12 +4429,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4452
4429
  }, {
4453
4430
  key: "resetStoreStateAsync",
4454
4431
  value: (function () {
4455
- var _resetStoreStateAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56() {
4432
+ var _resetStoreStateAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54() {
4456
4433
  var prevOrderInfo;
4457
- return _regeneratorRuntime().wrap(function _callee56$(_context56) {
4458
- while (1) switch (_context56.prev = _context56.next) {
4434
+ return _regeneratorRuntime().wrap(function _callee54$(_context54) {
4435
+ while (1) switch (_context54.prev = _context54.next) {
4459
4436
  case 0:
4460
- _context56.prev = 0;
4437
+ _context54.prev = 0;
4461
4438
  prevOrderInfo = this.store.currentOrder ? {
4462
4439
  uuid: this.store.currentOrder.uuid,
4463
4440
  orderId: this.store.currentOrder.order_id
@@ -4483,36 +4460,36 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4483
4460
  // 注意:故意保留 this.store.paymentMethods,因为支付方式数据不易变更,保留在内存中提高性能
4484
4461
 
4485
4462
  // 重置状态和步骤为初始状态
4486
- _context56.next = 15;
4463
+ _context54.next = 15;
4487
4464
  return this.setStatus(CheckoutStatus.Ready);
4488
4465
  case 15:
4489
- _context56.next = 17;
4466
+ _context54.next = 17;
4490
4467
  return this.setStep(CheckoutStep.OrderConfirmation);
4491
4468
  case 17:
4492
4469
  console.log('[Checkout] Store 状态重置完成');
4493
4470
 
4494
4471
  // 触发订单清理事件(如果之前有订单)
4495
4472
  if (!prevOrderInfo) {
4496
- _context56.next = 21;
4473
+ _context54.next = 21;
4497
4474
  break;
4498
4475
  }
4499
- _context56.next = 21;
4476
+ _context54.next = 21;
4500
4477
  return this.core.effects.emit(CheckoutHooks.OnOrderCleared, {
4501
4478
  previousOrder: prevOrderInfo,
4502
4479
  timestamp: Date.now()
4503
4480
  });
4504
4481
  case 21:
4505
- _context56.next = 26;
4482
+ _context54.next = 26;
4506
4483
  break;
4507
4484
  case 23:
4508
- _context56.prev = 23;
4509
- _context56.t0 = _context56["catch"](0);
4510
- console.error('[Checkout] 重置 store 状态失败:', _context56.t0);
4485
+ _context54.prev = 23;
4486
+ _context54.t0 = _context54["catch"](0);
4487
+ console.error('[Checkout] 重置 store 状态失败:', _context54.t0);
4511
4488
  case 26:
4512
4489
  case "end":
4513
- return _context56.stop();
4490
+ return _context54.stop();
4514
4491
  }
4515
- }, _callee56, this, [[0, 23]]);
4492
+ }, _callee54, this, [[0, 23]]);
4516
4493
  }));
4517
4494
  function resetStoreStateAsync() {
4518
4495
  return _resetStoreStateAsync.apply(this, arguments);
@@ -4530,37 +4507,37 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4530
4507
  }, {
4531
4508
  key: "clearCompletedOrderAsync",
4532
4509
  value: (function () {
4533
- var _clearCompletedOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57() {
4510
+ var _clearCompletedOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55() {
4534
4511
  var prevOrderInfo;
4535
- return _regeneratorRuntime().wrap(function _callee57$(_context57) {
4536
- while (1) switch (_context57.prev = _context57.next) {
4512
+ return _regeneratorRuntime().wrap(function _callee55$(_context55) {
4513
+ while (1) switch (_context55.prev = _context55.next) {
4537
4514
  case 0:
4538
- _context57.prev = 0;
4515
+ _context55.prev = 0;
4539
4516
  prevOrderInfo = this.store.currentOrder ? {
4540
4517
  uuid: this.store.currentOrder.uuid,
4541
4518
  orderId: this.store.currentOrder.order_id
4542
4519
  } : null;
4543
- _context57.next = 4;
4520
+ _context55.next = 4;
4544
4521
  return this.resetStoreStateAsync();
4545
4522
  case 4:
4546
- return _context57.abrupt("return", {
4523
+ return _context55.abrupt("return", {
4547
4524
  success: true,
4548
4525
  message: prevOrderInfo ? '订单状态已成功清理' : '没有需要清理的订单状态',
4549
4526
  clearedOrder: prevOrderInfo
4550
4527
  });
4551
4528
  case 7:
4552
- _context57.prev = 7;
4553
- _context57.t0 = _context57["catch"](0);
4554
- console.error('[Checkout] 手动清理订单状态失败:', _context57.t0);
4555
- return _context57.abrupt("return", {
4529
+ _context55.prev = 7;
4530
+ _context55.t0 = _context55["catch"](0);
4531
+ console.error('[Checkout] 手动清理订单状态失败:', _context55.t0);
4532
+ return _context55.abrupt("return", {
4556
4533
  success: false,
4557
- message: _context57.t0 instanceof Error ? _context57.t0.message : '清理失败'
4534
+ message: _context55.t0 instanceof Error ? _context55.t0.message : '清理失败'
4558
4535
  });
4559
4536
  case 11:
4560
4537
  case "end":
4561
- return _context57.stop();
4538
+ return _context55.stop();
4562
4539
  }
4563
- }, _callee57, this, [[0, 7]]);
4540
+ }, _callee55, this, [[0, 7]]);
4564
4541
  }));
4565
4542
  function clearCompletedOrderAsync() {
4566
4543
  return _clearCompletedOrderAsync.apply(this, arguments);