@pisell/pisellos 0.0.231 → 0.0.233

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.
@@ -276,17 +276,59 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
276
276
  if (!this.store.currentOrder) {
277
277
  return [];
278
278
  }
279
+ var getDiscountListAmount = function getDiscountListAmount(list) {
280
+ return list.reduce(function (pre, item) {
281
+ return pre + (item.amount || 0);
282
+ }, 0);
283
+ };
279
284
  var productList = (_this$store$currentOr = this.store.currentOrder.order_info) === null || _this$store$currentOr === void 0 ? void 0 : _this$store$currentOr.original_order_data.bookings.map(function (item) {
280
285
  return {
281
286
  product_id: item.product.product_id,
282
287
  product_variant_id: item.product.product_variant_id,
283
288
  quantity: item.product.num,
284
- selling_price: item.product.price - (item.product.discount_amount || 0)
289
+ selling_price: item.product.price - (item.product.discount_amount || 0) - getDiscountListAmount(item.product.discount_list)
285
290
  };
286
291
  });
287
292
  return productList;
288
293
  }
289
-
294
+ }, {
295
+ key: "initWalletData",
296
+ value: function () {
297
+ var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(params) {
298
+ var _this$store$currentOr2, _this$store$currentCu;
299
+ var amountInfo, walletBusinessData;
300
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
301
+ while (1) switch (_context6.prev = _context6.next) {
302
+ case 0:
303
+ amountInfo = (_this$store$currentOr2 = this.store.currentOrder) === null || _this$store$currentOr2 === void 0 || (_this$store$currentOr2 = _this$store$currentOr2.order_info) === null || _this$store$currentOr2 === void 0 ? void 0 : _this$store$currentOr2.amount_breakdown;
304
+ if (amountInfo) {
305
+ _context6.next = 3;
306
+ break;
307
+ }
308
+ return _context6.abrupt("return");
309
+ case 3:
310
+ // 准备钱包初始化的业务数据
311
+ walletBusinessData = _objectSpread({
312
+ customer_id: (_this$store$currentCu = this.store.currentCustomer) !== null && _this$store$currentCu !== void 0 && _this$store$currentCu.customer_id ? Number(this.store.currentCustomer.customer_id) : undefined,
313
+ amountInfo: {
314
+ totalAmount: amountInfo.totalAmount,
315
+ subTotal: amountInfo.subTotal
316
+ },
317
+ products: this.getProductListByOrder()
318
+ }, params);
319
+ _context6.next = 6;
320
+ return this.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
321
+ case 6:
322
+ case "end":
323
+ return _context6.stop();
324
+ }
325
+ }, _callee6, this);
326
+ }));
327
+ function initWalletData(_x8) {
328
+ return _initWalletData.apply(this, arguments);
329
+ }
330
+ return initWalletData;
331
+ }()
290
332
  /**
291
333
  * 创建本地订单 (前端模拟下单流程)
292
334
  *
@@ -297,21 +339,21 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
297
339
  }, {
298
340
  key: "createLocalOrderAsync",
299
341
  value: (function () {
300
- var _createLocalOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(params) {
301
- var _params$totalInfo, _params$totalInfo2, _this$store$currentCu, validation, localOrderId, amountInfo, customerInfo, paymentOrder, walletBusinessData, walletData;
302
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
303
- while (1) switch (_context6.prev = _context6.next) {
342
+ var _createLocalOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(params) {
343
+ var _params$totalInfo, _params$totalInfo2, validation, localOrderId, amountInfo, customerInfo, paymentOrder;
344
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
345
+ while (1) switch (_context7.prev = _context7.next) {
304
346
  case 0:
305
- _context6.prev = 0;
306
- _context6.next = 3;
347
+ _context7.prev = 0;
348
+ _context7.next = 3;
307
349
  return this.setStatus(CheckoutStatus.CreatingOrder);
308
350
  case 3:
309
- _context6.next = 5;
351
+ _context7.next = 5;
310
352
  return this.validateLocalOrderData(params.orderData);
311
353
  case 5:
312
- validation = _context6.sent;
354
+ validation = _context7.sent;
313
355
  if (validation.valid) {
314
- _context6.next = 8;
356
+ _context7.next = 8;
315
357
  break;
316
358
  }
317
359
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, "\u8BA2\u5355\u6570\u636E\u9A8C\u8BC1\u5931\u8D25: ".concat(validation.errors.join(', ')));
@@ -345,7 +387,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
345
387
  }
346
388
 
347
389
  // 创建支付订单对象
348
- _context6.next = 20;
390
+ _context7.next = 20;
349
391
  return this.payment.createPaymentOrderAsync({
350
392
  order_id: localOrderId,
351
393
  total_amount: amountInfo.totalAmount,
@@ -363,46 +405,33 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
363
405
  }
364
406
  });
365
407
  case 20:
366
- paymentOrder = _context6.sent;
408
+ paymentOrder = _context7.sent;
367
409
  this.store.currentOrder = paymentOrder;
368
-
369
- // 准备钱包初始化的业务数据
370
- walletBusinessData = {
371
- customer_id: (_this$store$currentCu = this.store.currentCustomer) !== null && _this$store$currentCu !== void 0 && _this$store$currentCu.customer_id ? Number(this.store.currentCustomer.customer_id) : undefined,
372
- amountInfo: {
373
- totalAmount: amountInfo.totalAmount,
374
- subTotal: amountInfo.subTotal
375
- },
376
- products: this.getProductListByOrder()
377
- }; // 调用WalletPass模块的业务数据初始化函数
378
- _context6.next = 25;
379
- return this.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
380
- case 25:
381
- walletData = _context6.sent;
382
- console.log(walletData.walletRecommendList, 'walletRecommendList');
383
- console.log(walletData.userIdentificationCodes, 'userIdentificationCodes');
384
- _context6.next = 30;
410
+ _context7.next = 24;
411
+ return this.initWalletData();
412
+ case 24:
413
+ _context7.next = 26;
385
414
  return this.setStatus(CheckoutStatus.OrderCreated);
386
- case 30:
387
- _context6.next = 32;
415
+ case 26:
416
+ _context7.next = 28;
388
417
  return this.setStep(CheckoutStep.PaymentMethod);
389
- case 32:
418
+ case 28:
390
419
  if (!params.autoPayment) {
391
- _context6.next = 35;
420
+ _context7.next = 31;
392
421
  break;
393
422
  }
394
- _context6.next = 35;
423
+ _context7.next = 31;
395
424
  return this.setStep(CheckoutStep.PaymentProcessing);
396
- case 35:
397
- _context6.next = 37;
425
+ case 31:
426
+ _context7.next = 33;
398
427
  return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
399
428
  order: paymentOrder,
400
429
  timestamp: Date.now()
401
430
  });
402
- case 37:
403
- _context6.next = 39;
431
+ case 33:
432
+ _context7.next = 35;
404
433
  return this.updateStateAmountToRemaining();
405
- case 39:
434
+ case 35:
406
435
  console.log('[Checkout] 本地订单创建成功:', {
407
436
  localOrderId: localOrderId,
408
437
  uuid: paymentOrder.uuid,
@@ -411,27 +440,27 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
411
440
  taxAmount: amountInfo.taxAmount,
412
441
  stateAmount: this.store.stateAmount
413
442
  });
414
- return _context6.abrupt("return", paymentOrder);
443
+ return _context7.abrupt("return", paymentOrder);
444
+ case 39:
445
+ _context7.prev = 39;
446
+ _context7.t0 = _context7["catch"](0);
447
+ _context7.next = 43;
448
+ return this.handleError(_context7.t0, CheckoutErrorType.OrderCreationFailed);
415
449
  case 43:
416
- _context6.prev = 43;
417
- _context6.t0 = _context6["catch"](0);
418
- _context6.next = 47;
419
- return this.handleError(_context6.t0, CheckoutErrorType.OrderCreationFailed);
420
- case 47:
421
- _context6.next = 49;
450
+ _context7.next = 45;
422
451
  return this.core.effects.emit(CheckoutHooks.OnOrderCreationFailed, {
423
452
  error: this.store.lastError,
424
453
  timestamp: Date.now()
425
454
  });
426
- case 49:
427
- throw _context6.t0;
428
- case 50:
455
+ case 45:
456
+ throw _context7.t0;
457
+ case 46:
429
458
  case "end":
430
- return _context6.stop();
459
+ return _context7.stop();
431
460
  }
432
- }, _callee6, this, [[0, 43]]);
461
+ }, _callee7, this, [[0, 39]]);
433
462
  }));
434
- function createLocalOrderAsync(_x8) {
463
+ function createLocalOrderAsync(_x9) {
435
464
  return _createLocalOrderAsync.apply(this, arguments);
436
465
  }
437
466
  return createLocalOrderAsync;
@@ -445,7 +474,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
445
474
  }, {
446
475
  key: "placeOrderAsync",
447
476
  value: (function () {
448
- var _placeOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
477
+ var _placeOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
449
478
  var params,
450
479
  _data,
451
480
  orderData,
@@ -453,26 +482,26 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
453
482
  realOrderId,
454
483
  updatedOrder,
455
484
  errorMessage,
456
- _args7 = arguments;
457
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
458
- while (1) switch (_context7.prev = _context7.next) {
485
+ _args8 = arguments;
486
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
487
+ while (1) switch (_context8.prev = _context8.next) {
459
488
  case 0:
460
- params = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : {};
461
- _context7.prev = 1;
489
+ params = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : {};
490
+ _context8.prev = 1;
462
491
  if (this.store.localOrderData) {
463
- _context7.next = 4;
492
+ _context8.next = 4;
464
493
  break;
465
494
  }
466
495
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, '没有找到本地订单数据,请先调用 createLocalOrderAsync 创建虚拟订单');
467
496
  case 4:
468
497
  if (this.store.currentOrder) {
469
- _context7.next = 6;
498
+ _context8.next = 6;
470
499
  break;
471
500
  }
472
501
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, '没有找到当前订单,请先创建虚拟订单');
473
502
  case 6:
474
503
  console.log('[Checkout] 开始手动下单流程...');
475
- _context7.next = 9;
504
+ _context8.next = 9;
476
505
  return this.setStatus(CheckoutStatus.CreatingOrder);
477
506
  case 9:
478
507
  // 准备订单数据,使用 Order 模块期望的格式
@@ -481,18 +510,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
481
510
  type: this.store.localOrderData.type,
482
511
  platform: this.store.localOrderData.platform
483
512
  }; // 调用 Order 模块提交订单
484
- _context7.next = 12;
513
+ _context8.next = 12;
485
514
  return this.order.submitOrder({
486
515
  url: params.url,
487
516
  // 可选的自定义 URL
488
517
  query: orderData
489
518
  });
490
519
  case 12:
491
- orderResponse = _context7.sent;
520
+ orderResponse = _context8.sent;
492
521
  // 提取真实订单ID(假设返回格式包含 order_id)
493
522
  realOrderId = (orderResponse === null || orderResponse === void 0 || (_data = orderResponse.data) === null || _data === void 0 ? void 0 : _data.order_id) || (orderResponse === null || orderResponse === void 0 ? void 0 : orderResponse.order_id);
494
523
  if (realOrderId) {
495
- _context7.next = 16;
524
+ _context8.next = 16;
496
525
  break;
497
526
  }
498
527
  throw createCheckoutError(CheckoutErrorType.OrderCreationFailed, '订单创建成功但未返回订单ID');
@@ -501,15 +530,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
501
530
 
502
531
  // 如果设置了自动替换订单ID,则替换虚拟订单ID
503
532
  if (!(params.autoReplaceOrderId !== false)) {
504
- _context7.next = 23;
533
+ _context8.next = 23;
505
534
  break;
506
535
  }
507
536
  // 默认为 true
508
537
  console.log('[Checkout] 自动替换虚拟订单ID为真实订单ID...');
509
- _context7.next = 21;
538
+ _context8.next = 21;
510
539
  return this.replaceLocalOrderIdAsync(realOrderId);
511
540
  case 21:
512
- updatedOrder = _context7.sent;
541
+ updatedOrder = _context8.sent;
513
542
  if (updatedOrder) {
514
543
  console.log('[Checkout] 订单ID替换成功:', {
515
544
  oldId: this.store.currentOrder.order_id,
@@ -517,10 +546,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
517
546
  });
518
547
  }
519
548
  case 23:
520
- _context7.next = 25;
549
+ _context8.next = 25;
521
550
  return this.setStatus(CheckoutStatus.OrderCreated);
522
551
  case 25:
523
- _context7.next = 27;
552
+ _context8.next = 27;
524
553
  return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
525
554
  order: this.store.currentOrder,
526
555
  timestamp: Date.now()
@@ -529,33 +558,33 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
529
558
  // 标记订单已同步
530
559
  this.store.isOrderSynced = true;
531
560
  console.log('[Checkout] 手动下单流程完成');
532
- return _context7.abrupt("return", {
561
+ return _context8.abrupt("return", {
533
562
  success: true,
534
563
  orderId: realOrderId
535
564
  });
536
565
  case 32:
537
- _context7.prev = 32;
538
- _context7.t0 = _context7["catch"](1);
566
+ _context8.prev = 32;
567
+ _context8.t0 = _context8["catch"](1);
539
568
  // 处理 CheckoutError 对象
540
569
  errorMessage = '下单失败';
541
- if (_context7.t0 && _typeof(_context7.t0) === 'object' && 'message' in _context7.t0) {
542
- errorMessage = _context7.t0.message;
543
- } else if (_context7.t0 instanceof Error) {
544
- errorMessage = _context7.t0.message;
570
+ if (_context8.t0 && _typeof(_context8.t0) === 'object' && 'message' in _context8.t0) {
571
+ errorMessage = _context8.t0.message;
572
+ } else if (_context8.t0 instanceof Error) {
573
+ errorMessage = _context8.t0.message;
545
574
  }
546
575
  console.error('[Checkout] 手动下单失败:', errorMessage);
547
- _context7.next = 39;
548
- return this.handleError(_context7.t0, CheckoutErrorType.OrderCreationFailed);
576
+ _context8.next = 39;
577
+ return this.handleError(_context8.t0, CheckoutErrorType.OrderCreationFailed);
549
578
  case 39:
550
- return _context7.abrupt("return", {
579
+ return _context8.abrupt("return", {
551
580
  success: false,
552
581
  error: errorMessage
553
582
  });
554
583
  case 40:
555
584
  case "end":
556
- return _context7.stop();
585
+ return _context8.stop();
557
586
  }
558
- }, _callee7, this, [[1, 32]]);
587
+ }, _callee8, this, [[1, 32]]);
559
588
  }));
560
589
  function placeOrderAsync() {
561
590
  return _placeOrderAsync.apply(this, arguments);
@@ -569,13 +598,13 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
569
598
  }, {
570
599
  key: "createOrderAsync",
571
600
  value: (function () {
572
- var _createOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params) {
601
+ var _createOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
573
602
  var _data2, checkResult, orderResponse, paymentOrder;
574
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
575
- while (1) switch (_context8.prev = _context8.next) {
603
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
604
+ while (1) switch (_context9.prev = _context9.next) {
576
605
  case 0:
577
- _context8.prev = 0;
578
- _context8.next = 3;
606
+ _context9.prev = 0;
607
+ _context9.next = 3;
579
608
  return this.setStatus(CheckoutStatus.CreatingOrder);
580
609
  case 3:
581
610
  // 验证购物车数据
@@ -584,12 +613,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
584
613
  type: 'account' // 默认使用 account 类型
585
614
  });
586
615
  if (checkResult) {
587
- _context8.next = 6;
616
+ _context9.next = 6;
588
617
  break;
589
618
  }
590
619
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, '购物车数据验证失败,请检查商品信息');
591
620
  case 6:
592
- _context8.next = 8;
621
+ _context9.next = 8;
593
622
  return this.order.submitOrder({
594
623
  query: {
595
624
  cartItems: params.cartItems,
@@ -598,23 +627,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
598
627
  }
599
628
  });
600
629
  case 8:
601
- orderResponse = _context8.sent;
602
- _context8.next = 11;
630
+ orderResponse = _context9.sent;
631
+ _context9.next = 11;
603
632
  return this.payment.createPaymentOrderAsync({
604
633
  order_id: (orderResponse === null || orderResponse === void 0 || (_data2 = orderResponse.data) === null || _data2 === void 0 ? void 0 : _data2.order_id) || "order_".concat(Date.now()),
605
634
  total_amount: this.calculateTotalAmount(params.cartItems),
606
635
  order_info: orderResponse === null || orderResponse === void 0 ? void 0 : orderResponse.data
607
636
  });
608
637
  case 11:
609
- paymentOrder = _context8.sent;
638
+ paymentOrder = _context9.sent;
610
639
  this.store.currentOrder = paymentOrder;
611
- _context8.next = 15;
640
+ _context9.next = 15;
612
641
  return this.setStatus(CheckoutStatus.OrderCreated);
613
642
  case 15:
614
- _context8.next = 17;
643
+ _context9.next = 17;
615
644
  return this.setStep(CheckoutStep.PaymentMethod);
616
645
  case 17:
617
- _context8.next = 19;
646
+ _context9.next = 19;
618
647
  return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
619
648
  order: paymentOrder,
620
649
  timestamp: Date.now()
@@ -624,31 +653,31 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
624
653
  this.store.isOrderSynced = true;
625
654
 
626
655
  // 自动设置 stateAmount 为剩余未支付金额
627
- _context8.next = 22;
656
+ _context9.next = 22;
628
657
  return this.updateStateAmountToRemaining();
629
658
  case 22:
630
659
  console.log('[Checkout] 订单创建成功:', paymentOrder.id);
631
- return _context8.abrupt("return", paymentOrder);
660
+ return _context9.abrupt("return", paymentOrder);
632
661
  case 26:
633
- _context8.prev = 26;
634
- _context8.t0 = _context8["catch"](0);
635
- _context8.next = 30;
636
- return this.handleError(_context8.t0, CheckoutErrorType.OrderCreationFailed);
662
+ _context9.prev = 26;
663
+ _context9.t0 = _context9["catch"](0);
664
+ _context9.next = 30;
665
+ return this.handleError(_context9.t0, CheckoutErrorType.OrderCreationFailed);
637
666
  case 30:
638
- _context8.next = 32;
667
+ _context9.next = 32;
639
668
  return this.core.effects.emit(CheckoutHooks.OnOrderCreationFailed, {
640
669
  error: this.store.lastError,
641
670
  timestamp: Date.now()
642
671
  });
643
672
  case 32:
644
- throw _context8.t0;
673
+ throw _context9.t0;
645
674
  case 33:
646
675
  case "end":
647
- return _context8.stop();
676
+ return _context9.stop();
648
677
  }
649
- }, _callee8, this, [[0, 26]]);
678
+ }, _callee9, this, [[0, 26]]);
650
679
  }));
651
- function createOrderAsync(_x9) {
680
+ function createOrderAsync(_x10) {
652
681
  return _createOrderAsync.apply(this, arguments);
653
682
  }
654
683
  return createOrderAsync;
@@ -660,22 +689,22 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
660
689
  }, {
661
690
  key: "processPaymentAsync",
662
691
  value: (function () {
663
- var _processPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
692
+ var _processPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
664
693
  var paymentMethod, paymentItem, result;
665
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
666
- while (1) switch (_context9.prev = _context9.next) {
694
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
695
+ while (1) switch (_context10.prev = _context10.next) {
667
696
  case 0:
668
- _context9.prev = 0;
697
+ _context10.prev = 0;
669
698
  if (this.store.currentOrder) {
670
- _context9.next = 3;
699
+ _context10.next = 3;
671
700
  break;
672
701
  }
673
702
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, '未找到当前订单,请先创建订单');
674
703
  case 3:
675
- _context9.next = 5;
704
+ _context10.next = 5;
676
705
  return this.setStatus(CheckoutStatus.ProcessingPayment);
677
706
  case 5:
678
- _context9.next = 7;
707
+ _context10.next = 7;
679
708
  return this.setStep(CheckoutStep.PaymentProcessing);
680
709
  case 7:
681
710
  // 查找支付方式
@@ -683,7 +712,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
683
712
  return method.code === params.paymentMethodCode;
684
713
  });
685
714
  if (paymentMethod) {
686
- _context9.next = 10;
715
+ _context10.next = 10;
687
716
  break;
688
717
  }
689
718
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, "\u672A\u627E\u5230\u652F\u4ED8\u65B9\u5F0F: ".concat(params.paymentMethodCode));
@@ -696,14 +725,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
696
725
  amount: String(params.amount),
697
726
  id: paymentMethod.id
698
727
  }; // 添加支付项到订单
699
- _context9.next = 13;
728
+ _context10.next = 13;
700
729
  return this.payment.addPaymentItemAsync(this.store.currentOrder.uuid, paymentItem);
701
730
  case 13:
702
- _context9.next = 15;
731
+ _context10.next = 15;
703
732
  return this.payment.submitPayAsync(this.store.currentOrder.uuid);
704
733
  case 15:
705
- result = _context9.sent;
706
- _context9.next = 18;
734
+ result = _context10.sent;
735
+ _context10.next = 18;
707
736
  return this.core.effects.emit(CheckoutHooks.OnPaymentStarted, {
708
737
  orderUuid: this.store.currentOrder.uuid,
709
738
  paymentMethodCode: params.paymentMethodCode,
@@ -712,42 +741,42 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
712
741
  });
713
742
  case 18:
714
743
  if (!(result.status === 'success')) {
715
- _context9.next = 27;
744
+ _context10.next = 27;
716
745
  break;
717
746
  }
718
- _context9.next = 21;
747
+ _context10.next = 21;
719
748
  return this.setStatus(CheckoutStatus.PaymentCompleted);
720
749
  case 21:
721
- _context9.next = 23;
750
+ _context10.next = 23;
722
751
  return this.updateStateAmountToRemaining();
723
752
  case 23:
724
- _context9.next = 25;
753
+ _context10.next = 25;
725
754
  return this.handlePaymentSuccess({
726
755
  orderUuid: this.store.currentOrder.uuid,
727
756
  timestamp: Date.now()
728
757
  });
729
758
  case 25:
730
- _context9.next = 28;
759
+ _context10.next = 28;
731
760
  break;
732
761
  case 27:
733
762
  throw createCheckoutError(CheckoutErrorType.PaymentFailed, '支付处理失败,请重试');
734
763
  case 28:
735
- _context9.next = 35;
764
+ _context10.next = 35;
736
765
  break;
737
766
  case 30:
738
- _context9.prev = 30;
739
- _context9.t0 = _context9["catch"](0);
740
- _context9.next = 34;
741
- return this.handleError(_context9.t0, CheckoutErrorType.PaymentFailed);
767
+ _context10.prev = 30;
768
+ _context10.t0 = _context10["catch"](0);
769
+ _context10.next = 34;
770
+ return this.handleError(_context10.t0, CheckoutErrorType.PaymentFailed);
742
771
  case 34:
743
- throw _context9.t0;
772
+ throw _context10.t0;
744
773
  case 35:
745
774
  case "end":
746
- return _context9.stop();
775
+ return _context10.stop();
747
776
  }
748
- }, _callee9, this, [[0, 30]]);
777
+ }, _callee10, this, [[0, 30]]);
749
778
  }));
750
- function processPaymentAsync(_x10) {
779
+ function processPaymentAsync(_x11) {
751
780
  return _processPaymentAsync.apply(this, arguments);
752
781
  }
753
782
  return processPaymentAsync;
@@ -759,61 +788,61 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
759
788
  }, {
760
789
  key: "completeCheckoutAsync",
761
790
  value: (function () {
762
- var _completeCheckoutAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
791
+ var _completeCheckoutAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
763
792
  var order;
764
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
765
- while (1) switch (_context10.prev = _context10.next) {
793
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
794
+ while (1) switch (_context11.prev = _context11.next) {
766
795
  case 0:
767
- _context10.prev = 0;
796
+ _context11.prev = 0;
768
797
  if (this.store.currentOrder) {
769
- _context10.next = 3;
798
+ _context11.next = 3;
770
799
  break;
771
800
  }
772
801
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, '未找到当前订单');
773
802
  case 3:
774
- _context10.next = 5;
803
+ _context11.next = 5;
775
804
  return this.payment.getPaymentOrderByUuidAsync(this.store.currentOrder.uuid);
776
805
  case 5:
777
- order = _context10.sent;
806
+ order = _context11.sent;
778
807
  if (!(!order || order.payment_status !== PaymentStatus.Finished)) {
779
- _context10.next = 8;
808
+ _context11.next = 8;
780
809
  break;
781
810
  }
782
811
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, '订单支付未完成,无法完成结账');
783
812
  case 8:
784
813
  // 清理钱包模块的所有缓存数据
785
814
  this.payment.wallet.clearAllCache();
786
- _context10.next = 11;
815
+ _context11.next = 11;
787
816
  return this.setStatus(CheckoutStatus.Completed);
788
817
  case 11:
789
- _context10.next = 13;
818
+ _context11.next = 13;
790
819
  return this.setStep(CheckoutStep.Complete);
791
820
  case 13:
792
- _context10.next = 15;
821
+ _context11.next = 15;
793
822
  return this.core.effects.emit(CheckoutHooks.OnCheckoutCompleted, {
794
823
  orderId: order.id,
795
824
  timestamp: Date.now()
796
825
  });
797
826
  case 15:
798
827
  console.log('[Checkout] 结账流程完成:', order.id);
799
- return _context10.abrupt("return", {
828
+ return _context11.abrupt("return", {
800
829
  success: true,
801
830
  orderId: String(order.id)
802
831
  });
803
832
  case 19:
804
- _context10.prev = 19;
805
- _context10.t0 = _context10["catch"](0);
806
- _context10.next = 23;
807
- return this.handleError(_context10.t0, CheckoutErrorType.UnknownError);
833
+ _context11.prev = 19;
834
+ _context11.t0 = _context11["catch"](0);
835
+ _context11.next = 23;
836
+ return this.handleError(_context11.t0, CheckoutErrorType.UnknownError);
808
837
  case 23:
809
- return _context10.abrupt("return", {
838
+ return _context11.abrupt("return", {
810
839
  success: false
811
840
  });
812
841
  case 24:
813
842
  case "end":
814
- return _context10.stop();
843
+ return _context11.stop();
815
844
  }
816
- }, _callee10, this, [[0, 19]]);
845
+ }, _callee11, this, [[0, 19]]);
817
846
  }));
818
847
  function completeCheckoutAsync() {
819
848
  return _completeCheckoutAsync.apply(this, arguments);
@@ -827,16 +856,16 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
827
856
  }, {
828
857
  key: "cancelCheckoutAsync",
829
858
  value: (function () {
830
- var _cancelCheckoutAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
831
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
832
- while (1) switch (_context11.prev = _context11.next) {
859
+ var _cancelCheckoutAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
860
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
861
+ while (1) switch (_context12.prev = _context12.next) {
833
862
  case 0:
834
- _context11.prev = 0;
863
+ _context12.prev = 0;
835
864
  if (!this.store.currentOrder) {
836
- _context11.next = 5;
865
+ _context12.next = 5;
837
866
  break;
838
867
  }
839
- _context11.next = 4;
868
+ _context12.next = 4;
840
869
  return this.payment.deletePaymentOrderAsync(this.store.currentOrder.uuid);
841
870
  case 4:
842
871
  this.store.currentOrder = undefined;
@@ -849,28 +878,28 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
849
878
  this.store.stateAmount = '0.00';
850
879
  this.store.isOrderSynced = false;
851
880
  this.store.currentCustomer = undefined;
852
- _context11.next = 14;
881
+ _context12.next = 14;
853
882
  return this.setStatus(CheckoutStatus.Cancelled);
854
883
  case 14:
855
- _context11.next = 16;
884
+ _context12.next = 16;
856
885
  return this.core.effects.emit(CheckoutHooks.OnCheckoutCancelled, {
857
886
  timestamp: Date.now()
858
887
  });
859
888
  case 16:
860
889
  console.log('[Checkout] 结账流程已取消');
861
- _context11.next = 24;
890
+ _context12.next = 24;
862
891
  break;
863
892
  case 19:
864
- _context11.prev = 19;
865
- _context11.t0 = _context11["catch"](0);
866
- console.error('[Checkout] 取消结账失败:', _context11.t0);
867
- _context11.next = 24;
868
- return this.handleError(_context11.t0, CheckoutErrorType.UnknownError);
893
+ _context12.prev = 19;
894
+ _context12.t0 = _context12["catch"](0);
895
+ console.error('[Checkout] 取消结账失败:', _context12.t0);
896
+ _context12.next = 24;
897
+ return this.handleError(_context12.t0, CheckoutErrorType.UnknownError);
869
898
  case 24:
870
899
  case "end":
871
- return _context11.stop();
900
+ return _context12.stop();
872
901
  }
873
- }, _callee11, this, [[0, 19]]);
902
+ }, _callee12, this, [[0, 19]]);
874
903
  }));
875
904
  function cancelCheckoutAsync() {
876
905
  return _cancelCheckoutAsync.apply(this, arguments);
@@ -899,28 +928,28 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
899
928
  }, {
900
929
  key: "getCheckoutSummaryAsync",
901
930
  value: (function () {
902
- var _getCheckoutSummaryAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
903
- var _this$store$currentOr2, _this$store$currentOr3;
931
+ var _getCheckoutSummaryAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
932
+ var _this$store$currentOr3, _this$store$currentOr4;
904
933
  var totalAmount, paidAmount, remainingAmount;
905
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
906
- while (1) switch (_context12.prev = _context12.next) {
934
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
935
+ while (1) switch (_context13.prev = _context13.next) {
907
936
  case 0:
908
- totalAmount = ((_this$store$currentOr2 = this.store.currentOrder) === null || _this$store$currentOr2 === void 0 ? void 0 : _this$store$currentOr2.total_amount) || '0.00';
937
+ totalAmount = ((_this$store$currentOr3 = this.store.currentOrder) === null || _this$store$currentOr3 === void 0 ? void 0 : _this$store$currentOr3.total_amount) || '0.00';
909
938
  paidAmount = this.calculatePaidAmount();
910
939
  remainingAmount = this.calculateRemainingAmount();
911
- return _context12.abrupt("return", {
940
+ return _context13.abrupt("return", {
912
941
  order: this.store.currentOrder,
913
942
  totalAmount: totalAmount,
914
943
  paidAmount: paidAmount,
915
944
  remainingAmount: remainingAmount,
916
- paymentStatus: ((_this$store$currentOr3 = this.store.currentOrder) === null || _this$store$currentOr3 === void 0 ? void 0 : _this$store$currentOr3.payment_status) || PaymentStatus.Processing,
945
+ paymentStatus: ((_this$store$currentOr4 = this.store.currentOrder) === null || _this$store$currentOr4 === void 0 ? void 0 : _this$store$currentOr4.payment_status) || PaymentStatus.Processing,
917
946
  availablePaymentMethods: this.store.paymentMethods
918
947
  });
919
948
  case 4:
920
949
  case "end":
921
- return _context12.stop();
950
+ return _context13.stop();
922
951
  }
923
- }, _callee12, this);
952
+ }, _callee13, this);
924
953
  }));
925
954
  function getCheckoutSummaryAsync() {
926
955
  return _getCheckoutSummaryAsync.apply(this, arguments);
@@ -934,24 +963,24 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
934
963
  }, {
935
964
  key: "getAvailablePaymentMethodsAsync",
936
965
  value: (function () {
937
- var _getAvailablePaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
938
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
939
- while (1) switch (_context13.prev = _context13.next) {
966
+ var _getAvailablePaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
967
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
968
+ while (1) switch (_context14.prev = _context14.next) {
940
969
  case 0:
941
970
  if (!(this.store.paymentMethods.length === 0)) {
942
- _context13.next = 4;
971
+ _context14.next = 4;
943
972
  break;
944
973
  }
945
974
  console.log('[Checkout] 支付方式缓存为空,重新加载...');
946
- _context13.next = 4;
975
+ _context14.next = 4;
947
976
  return this.preloadPaymentMethods();
948
977
  case 4:
949
- return _context13.abrupt("return", this.store.paymentMethods);
978
+ return _context14.abrupt("return", this.store.paymentMethods);
950
979
  case 5:
951
980
  case "end":
952
- return _context13.stop();
981
+ return _context14.stop();
953
982
  }
954
- }, _callee13, this);
983
+ }, _callee14, this);
955
984
  }));
956
985
  function getAvailablePaymentMethodsAsync() {
957
986
  return _getAvailablePaymentMethodsAsync.apply(this, arguments);
@@ -967,32 +996,42 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
967
996
  }, {
968
997
  key: "refreshPaymentMethodsAsync",
969
998
  value: (function () {
970
- var _refreshPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
971
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
972
- while (1) switch (_context14.prev = _context14.next) {
999
+ var _refreshPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
1000
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1001
+ while (1) switch (_context15.prev = _context15.next) {
973
1002
  case 0:
974
1003
  console.log('[Checkout] 强制刷新支付方式缓存...');
975
- _context14.next = 3;
1004
+ _context15.next = 3;
976
1005
  return this.preloadPaymentMethods();
977
1006
  case 3:
978
- return _context14.abrupt("return", this.store.paymentMethods);
1007
+ return _context15.abrupt("return", this.store.paymentMethods);
979
1008
  case 4:
980
1009
  case "end":
981
- return _context14.stop();
1010
+ return _context15.stop();
982
1011
  }
983
- }, _callee14, this);
1012
+ }, _callee15, this);
984
1013
  }));
985
1014
  function refreshPaymentMethodsAsync() {
986
1015
  return _refreshPaymentMethodsAsync.apply(this, arguments);
987
1016
  }
988
1017
  return refreshPaymentMethodsAsync;
989
1018
  }()
1019
+ /**
1020
+ * 获取订单原始数据
1021
+ */
1022
+ )
1023
+ }, {
1024
+ key: "getOrderOriginalData",
1025
+ value: function getOrderOriginalData() {
1026
+ var _this$store$currentOr5;
1027
+ return (_this$store$currentOr5 = this.store.currentOrder) === null || _this$store$currentOr5 === void 0 ? void 0 : _this$store$currentOr5.order_info;
1028
+ }
1029
+
990
1030
  /**
991
1031
  * 获取当前订单基础信息
992
1032
  *
993
1033
  * 返回当前订单的基础信息,包括订单状态、金额、支付状态等
994
1034
  */
995
- )
996
1035
  }, {
997
1036
  key: "getCurrentOrderInfo",
998
1037
  value: function getCurrentOrderInfo() {
@@ -1051,19 +1090,19 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1051
1090
  }, {
1052
1091
  key: "getCurrentOrderPaymentItemsAsync",
1053
1092
  value: (function () {
1054
- var _getCurrentOrderPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
1093
+ var _getCurrentOrderPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
1055
1094
  var _currentOrder2, paymentItems;
1056
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1057
- while (1) switch (_context15.prev = _context15.next) {
1095
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1096
+ while (1) switch (_context16.prev = _context16.next) {
1058
1097
  case 0:
1059
- _context15.prev = 0;
1098
+ _context16.prev = 0;
1060
1099
  _currentOrder2 = this.store.currentOrder;
1061
1100
  if (_currentOrder2) {
1062
- _context15.next = 5;
1101
+ _context16.next = 5;
1063
1102
  break;
1064
1103
  }
1065
1104
  console.log('[Checkout] 当前没有活跃订单,无法获取支付项');
1066
- return _context15.abrupt("return", []);
1105
+ return _context16.abrupt("return", []);
1067
1106
  case 5:
1068
1107
  console.log('[Checkout] 获取当前订单支付项:', {
1069
1108
  orderUuid: _currentOrder2.uuid,
@@ -1071,10 +1110,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1071
1110
  });
1072
1111
 
1073
1112
  // 调用Payment模块获取支付项
1074
- _context15.next = 8;
1113
+ _context16.next = 8;
1075
1114
  return this.payment.getPaymentItemsAsync(_currentOrder2.uuid);
1076
1115
  case 8:
1077
- paymentItems = _context15.sent;
1116
+ paymentItems = _context16.sent;
1078
1117
  console.log('[Checkout] 成功获取支付项:', {
1079
1118
  orderUuid: _currentOrder2.uuid,
1080
1119
  paymentItemCount: paymentItems.length,
@@ -1099,17 +1138,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1099
1138
  };
1100
1139
  })
1101
1140
  });
1102
- return _context15.abrupt("return", paymentItems);
1141
+ return _context16.abrupt("return", paymentItems);
1103
1142
  case 13:
1104
- _context15.prev = 13;
1105
- _context15.t0 = _context15["catch"](0);
1106
- console.error('[Checkout] 获取当前订单支付项失败:', _context15.t0);
1107
- return _context15.abrupt("return", []);
1143
+ _context16.prev = 13;
1144
+ _context16.t0 = _context16["catch"](0);
1145
+ console.error('[Checkout] 获取当前订单支付项失败:', _context16.t0);
1146
+ return _context16.abrupt("return", []);
1108
1147
  case 17:
1109
1148
  case "end":
1110
- return _context15.stop();
1149
+ return _context16.stop();
1111
1150
  }
1112
- }, _callee15, this, [[0, 13]]);
1151
+ }, _callee16, this, [[0, 13]]);
1113
1152
  }));
1114
1153
  function getCurrentOrderPaymentItemsAsync() {
1115
1154
  return _getCurrentOrderPaymentItemsAsync.apply(this, arguments);
@@ -1123,10 +1162,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1123
1162
  }, {
1124
1163
  key: "validateCheckoutAsync",
1125
1164
  value: (function () {
1126
- var _validateCheckoutAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
1165
+ var _validateCheckoutAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1127
1166
  var errors;
1128
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1129
- while (1) switch (_context16.prev = _context16.next) {
1167
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1168
+ while (1) switch (_context17.prev = _context17.next) {
1130
1169
  case 0:
1131
1170
  errors = []; // 验证购物车
1132
1171
  if (!this.store.cartItems || this.store.cartItems.length === 0) {
@@ -1142,15 +1181,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1142
1181
  if (this.store.status === CheckoutStatus.Error) {
1143
1182
  errors.push('结账流程存在错误');
1144
1183
  }
1145
- return _context16.abrupt("return", {
1184
+ return _context17.abrupt("return", {
1146
1185
  valid: errors.length === 0,
1147
1186
  errors: errors
1148
1187
  });
1149
1188
  case 5:
1150
1189
  case "end":
1151
- return _context16.stop();
1190
+ return _context17.stop();
1152
1191
  }
1153
- }, _callee16, this);
1192
+ }, _callee17, this);
1154
1193
  }));
1155
1194
  function validateCheckoutAsync() {
1156
1195
  return _validateCheckoutAsync.apply(this, arguments);
@@ -1164,44 +1203,44 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1164
1203
  }, {
1165
1204
  key: "retryFailedOperationAsync",
1166
1205
  value: (function () {
1167
- var _retryFailedOperationAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1168
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1169
- while (1) switch (_context17.prev = _context17.next) {
1206
+ var _retryFailedOperationAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
1207
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1208
+ while (1) switch (_context18.prev = _context18.next) {
1170
1209
  case 0:
1171
- _context17.prev = 0;
1210
+ _context18.prev = 0;
1172
1211
  if (!(this.store.status === CheckoutStatus.Error && this.store.lastError)) {
1173
- _context17.next = 10;
1212
+ _context18.next = 10;
1174
1213
  break;
1175
1214
  }
1176
- _context17.t0 = this.store.lastError.type;
1177
- _context17.next = _context17.t0 === CheckoutErrorType.OrderCreationFailed ? 5 : 9;
1215
+ _context18.t0 = this.store.lastError.type;
1216
+ _context18.next = _context18.t0 === CheckoutErrorType.OrderCreationFailed ? 5 : 9;
1178
1217
  break;
1179
1218
  case 5:
1180
1219
  if (!(this.store.cartItems.length > 0)) {
1181
- _context17.next = 8;
1220
+ _context18.next = 8;
1182
1221
  break;
1183
1222
  }
1184
- _context17.next = 8;
1223
+ _context18.next = 8;
1185
1224
  return this.createOrderAsync({
1186
1225
  cartItems: this.store.cartItems
1187
1226
  });
1188
1227
  case 8:
1189
- return _context17.abrupt("break", 10);
1228
+ return _context18.abrupt("break", 10);
1190
1229
  case 9:
1191
1230
  console.warn('[Checkout] 无法重试此类型的错误:', this.store.lastError.type);
1192
1231
  case 10:
1193
- _context17.next = 16;
1232
+ _context18.next = 16;
1194
1233
  break;
1195
1234
  case 12:
1196
- _context17.prev = 12;
1197
- _context17.t1 = _context17["catch"](0);
1198
- _context17.next = 16;
1199
- return this.handleError(_context17.t1, CheckoutErrorType.UnknownError);
1235
+ _context18.prev = 12;
1236
+ _context18.t1 = _context18["catch"](0);
1237
+ _context18.next = 16;
1238
+ return this.handleError(_context18.t1, CheckoutErrorType.UnknownError);
1200
1239
  case 16:
1201
1240
  case "end":
1202
- return _context17.stop();
1241
+ return _context18.stop();
1203
1242
  }
1204
- }, _callee17, this, [[0, 12]]);
1243
+ }, _callee18, this, [[0, 12]]);
1205
1244
  }));
1206
1245
  function retryFailedOperationAsync() {
1207
1246
  return _retryFailedOperationAsync.apply(this, arguments);
@@ -1253,32 +1292,32 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1253
1292
  }, {
1254
1293
  key: "replaceLocalOrderIdAsync",
1255
1294
  value: (function () {
1256
- var _replaceLocalOrderIdAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(newOrderId) {
1295
+ var _replaceLocalOrderIdAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(newOrderId) {
1257
1296
  var updatedOrder;
1258
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1259
- while (1) switch (_context18.prev = _context18.next) {
1297
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1298
+ while (1) switch (_context19.prev = _context19.next) {
1260
1299
  case 0:
1261
- _context18.prev = 0;
1300
+ _context19.prev = 0;
1262
1301
  if (this.store.currentOrder) {
1263
- _context18.next = 4;
1302
+ _context19.next = 4;
1264
1303
  break;
1265
1304
  }
1266
1305
  console.warn('[Checkout] 没有当前订单,无法替换订单ID');
1267
- return _context18.abrupt("return", null);
1306
+ return _context19.abrupt("return", null);
1268
1307
  case 4:
1269
- _context18.next = 6;
1308
+ _context19.next = 6;
1270
1309
  return this.payment.replaceOrderIdByUuidAsync(this.store.currentOrder.uuid, newOrderId);
1271
1310
  case 6:
1272
- updatedOrder = _context18.sent;
1311
+ updatedOrder = _context19.sent;
1273
1312
  if (!updatedOrder) {
1274
- _context18.next = 15;
1313
+ _context19.next = 15;
1275
1314
  break;
1276
1315
  }
1277
1316
  // 更新当前订单引用
1278
1317
  this.store.currentOrder = updatedOrder;
1279
1318
 
1280
1319
  // 触发订单更新事件
1281
- _context18.next = 11;
1320
+ _context19.next = 11;
1282
1321
  return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
1283
1322
  order: updatedOrder,
1284
1323
  timestamp: Date.now()
@@ -1293,25 +1332,25 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1293
1332
  this.store.isOrderSynced = true;
1294
1333
 
1295
1334
  // 订单ID替换后更新 stateAmount
1296
- _context18.next = 15;
1335
+ _context19.next = 15;
1297
1336
  return this.updateStateAmountToRemaining();
1298
1337
  case 15:
1299
- return _context18.abrupt("return", updatedOrder);
1338
+ return _context19.abrupt("return", updatedOrder);
1300
1339
  case 18:
1301
- _context18.prev = 18;
1302
- _context18.t0 = _context18["catch"](0);
1303
- console.error('[Checkout] 替换订单ID失败:', _context18.t0);
1304
- _context18.next = 23;
1305
- return this.handleError(_context18.t0, CheckoutErrorType.UnknownError);
1340
+ _context19.prev = 18;
1341
+ _context19.t0 = _context19["catch"](0);
1342
+ console.error('[Checkout] 替换订单ID失败:', _context19.t0);
1343
+ _context19.next = 23;
1344
+ return this.handleError(_context19.t0, CheckoutErrorType.UnknownError);
1306
1345
  case 23:
1307
- return _context18.abrupt("return", null);
1346
+ return _context19.abrupt("return", null);
1308
1347
  case 24:
1309
1348
  case "end":
1310
- return _context18.stop();
1349
+ return _context19.stop();
1311
1350
  }
1312
- }, _callee18, this, [[0, 18]]);
1351
+ }, _callee19, this, [[0, 18]]);
1313
1352
  }));
1314
- function replaceLocalOrderIdAsync(_x11) {
1353
+ function replaceLocalOrderIdAsync(_x12) {
1315
1354
  return _replaceLocalOrderIdAsync.apply(this, arguments);
1316
1355
  }
1317
1356
  return replaceLocalOrderIdAsync;
@@ -1327,16 +1366,16 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1327
1366
  }, {
1328
1367
  key: "setStateAmountAsync",
1329
1368
  value: (function () {
1330
- var _setStateAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(amount) {
1369
+ var _setStateAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(amount) {
1331
1370
  var numAmount, oldAmount, formattedAmount, errorMessage;
1332
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1333
- while (1) switch (_context19.prev = _context19.next) {
1371
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1372
+ while (1) switch (_context20.prev = _context20.next) {
1334
1373
  case 0:
1335
- _context19.prev = 0;
1374
+ _context20.prev = 0;
1336
1375
  // 验证金额格式
1337
1376
  numAmount = parseFloat(amount);
1338
1377
  if (!(isNaN(numAmount) || numAmount < 0)) {
1339
- _context19.next = 4;
1378
+ _context20.next = 4;
1340
1379
  break;
1341
1380
  }
1342
1381
  throw new Error("\u65E0\u6548\u7684\u652F\u4ED8\u91D1\u989D: ".concat(amount));
@@ -1344,16 +1383,16 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1344
1383
  oldAmount = this.store.stateAmount;
1345
1384
  formattedAmount = numAmount.toFixed(2); // 如果金额没有变化,直接返回
1346
1385
  if (!(oldAmount === formattedAmount)) {
1347
- _context19.next = 8;
1386
+ _context20.next = 8;
1348
1387
  break;
1349
1388
  }
1350
- return _context19.abrupt("return");
1389
+ return _context20.abrupt("return");
1351
1390
  case 8:
1352
1391
  // 更新状态
1353
1392
  this.store.stateAmount = formattedAmount;
1354
1393
 
1355
1394
  // 触发金额变更事件
1356
- _context19.next = 11;
1395
+ _context20.next = 11;
1357
1396
  return this.core.effects.emit(CheckoutHooks.OnStateAmountChanged, {
1358
1397
  oldAmount: oldAmount,
1359
1398
  newAmount: formattedAmount,
@@ -1364,24 +1403,24 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1364
1403
  oldAmount: oldAmount,
1365
1404
  newAmount: formattedAmount
1366
1405
  });
1367
- _context19.next = 21;
1406
+ _context20.next = 21;
1368
1407
  break;
1369
1408
  case 14:
1370
- _context19.prev = 14;
1371
- _context19.t0 = _context19["catch"](0);
1372
- errorMessage = _context19.t0 instanceof Error ? _context19.t0.message : '设置支付金额失败';
1409
+ _context20.prev = 14;
1410
+ _context20.t0 = _context20["catch"](0);
1411
+ errorMessage = _context20.t0 instanceof Error ? _context20.t0.message : '设置支付金额失败';
1373
1412
  console.error('[Checkout] 设置自定义支付金额失败:', errorMessage);
1374
- _context19.next = 20;
1413
+ _context20.next = 20;
1375
1414
  return this.handleError(new Error(errorMessage), CheckoutErrorType.ValidationFailed);
1376
1415
  case 20:
1377
- throw _context19.t0;
1416
+ throw _context20.t0;
1378
1417
  case 21:
1379
1418
  case "end":
1380
- return _context19.stop();
1419
+ return _context20.stop();
1381
1420
  }
1382
- }, _callee19, this, [[0, 14]]);
1421
+ }, _callee20, this, [[0, 14]]);
1383
1422
  }));
1384
- function setStateAmountAsync(_x12) {
1423
+ function setStateAmountAsync(_x13) {
1385
1424
  return _setStateAmountAsync.apply(this, arguments);
1386
1425
  }
1387
1426
  return setStateAmountAsync;
@@ -1406,17 +1445,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1406
1445
  }, {
1407
1446
  key: "refreshStateAmountAsync",
1408
1447
  value: (function () {
1409
- var _refreshStateAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
1410
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1411
- while (1) switch (_context20.prev = _context20.next) {
1448
+ var _refreshStateAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
1449
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1450
+ while (1) switch (_context21.prev = _context21.next) {
1412
1451
  case 0:
1413
- _context20.next = 2;
1452
+ _context21.next = 2;
1414
1453
  return this.updateStateAmountToRemaining();
1415
1454
  case 2:
1416
1455
  case "end":
1417
- return _context20.stop();
1456
+ return _context21.stop();
1418
1457
  }
1419
- }, _callee20, this);
1458
+ }, _callee21, this);
1420
1459
  }));
1421
1460
  function refreshStateAmountAsync() {
1422
1461
  return _refreshStateAmountAsync.apply(this, arguments);
@@ -1480,19 +1519,19 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1480
1519
  }, {
1481
1520
  key: "getPaymentMethodsAsync",
1482
1521
  value: (function () {
1483
- var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
1484
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1485
- while (1) switch (_context21.prev = _context21.next) {
1522
+ var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
1523
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1524
+ while (1) switch (_context22.prev = _context22.next) {
1486
1525
  case 0:
1487
- _context21.next = 2;
1526
+ _context22.next = 2;
1488
1527
  return this.payment.getPayMethodListAsync();
1489
1528
  case 2:
1490
- return _context21.abrupt("return", _context21.sent);
1529
+ return _context22.abrupt("return", _context22.sent);
1491
1530
  case 3:
1492
1531
  case "end":
1493
- return _context21.stop();
1532
+ return _context22.stop();
1494
1533
  }
1495
- }, _callee21, this);
1534
+ }, _callee22, this);
1496
1535
  }));
1497
1536
  function getPaymentMethodsAsync() {
1498
1537
  return _getPaymentMethodsAsync.apply(this, arguments);
@@ -1511,14 +1550,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1511
1550
  }, {
1512
1551
  key: "addPaymentItemAsync",
1513
1552
  value: (function () {
1514
- var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(paymentItem) {
1553
+ var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(paymentItem) {
1515
1554
  var currentOrderId, isCurrentOrderReal, updatedOrder, needsOrderSync;
1516
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1517
- while (1) switch (_context22.prev = _context22.next) {
1555
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1556
+ while (1) switch (_context23.prev = _context23.next) {
1518
1557
  case 0:
1519
- _context22.prev = 0;
1558
+ _context23.prev = 0;
1520
1559
  if (this.store.currentOrder) {
1521
- _context22.next = 3;
1560
+ _context23.next = 3;
1522
1561
  break;
1523
1562
  }
1524
1563
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, '未找到当前订单,无法添加支付项');
@@ -1535,7 +1574,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1535
1574
  });
1536
1575
 
1537
1576
  // 添加支付项到订单
1538
- _context22.next = 6;
1577
+ _context23.next = 6;
1539
1578
  return this.payment.addPaymentItemAsync(this.store.currentOrder.uuid, paymentItem);
1540
1579
  case 6:
1541
1580
  console.log('[Checkout] 支付项添加成功');
@@ -1547,10 +1586,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1547
1586
  当前订单ID: currentOrderId,
1548
1587
  是否为真实ID: isCurrentOrderReal
1549
1588
  });
1550
- _context22.next = 12;
1589
+ _context23.next = 12;
1551
1590
  return this.payment.getPaymentOrderByUuidAsync(this.store.currentOrder.uuid);
1552
1591
  case 12:
1553
- updatedOrder = _context22.sent;
1592
+ updatedOrder = _context23.sent;
1554
1593
  if (updatedOrder) {
1555
1594
  // 如果当前订单ID是真实ID,但获取到的订单ID是虚拟ID,需要保护真实ID
1556
1595
  if (isCurrentOrderReal && this.isVirtualOrderId(updatedOrder.order_id)) {
@@ -1579,7 +1618,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1579
1618
  isOrderSynced: this.store.isOrderSynced
1580
1619
  });
1581
1620
  if (!needsOrderSync) {
1582
- _context22.next = 21;
1621
+ _context23.next = 21;
1583
1622
  break;
1584
1623
  }
1585
1624
  console.log('[Checkout] 检测到非现金/自定义支付,开始同步订单到后端...', {
@@ -1588,7 +1627,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1588
1627
  订单同步状态: this.store.isOrderSynced,
1589
1628
  订单UUID: this.store.currentOrder.uuid
1590
1629
  });
1591
- _context22.next = 20;
1630
+ _context23.next = 20;
1592
1631
  return this.syncOrderToBackend();
1593
1632
  case 20:
1594
1633
  console.log('[Checkout] addPaymentItemAsync 中的同步完成:', {
@@ -1597,10 +1636,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1597
1636
  订单同步状态: this.store.isOrderSynced
1598
1637
  });
1599
1638
  case 21:
1600
- _context22.next = 23;
1639
+ _context23.next = 23;
1601
1640
  return this.updateStateAmountToRemaining();
1602
1641
  case 23:
1603
- _context22.next = 25;
1642
+ _context23.next = 25;
1604
1643
  return this.core.effects.emit(CheckoutHooks.OnPaymentStarted, {
1605
1644
  orderUuid: this.store.currentOrder.uuid,
1606
1645
  paymentMethodCode: paymentItem.code,
@@ -1608,23 +1647,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1608
1647
  timestamp: Date.now()
1609
1648
  });
1610
1649
  case 25:
1611
- _context22.next = 33;
1650
+ _context23.next = 33;
1612
1651
  break;
1613
1652
  case 27:
1614
- _context22.prev = 27;
1615
- _context22.t0 = _context22["catch"](0);
1616
- console.error('[Checkout] 添加支付项失败:', _context22.t0);
1617
- _context22.next = 32;
1618
- return this.handleError(_context22.t0, CheckoutErrorType.PaymentFailed);
1653
+ _context23.prev = 27;
1654
+ _context23.t0 = _context23["catch"](0);
1655
+ console.error('[Checkout] 添加支付项失败:', _context23.t0);
1656
+ _context23.next = 32;
1657
+ return this.handleError(_context23.t0, CheckoutErrorType.PaymentFailed);
1619
1658
  case 32:
1620
- throw _context22.t0;
1659
+ throw _context23.t0;
1621
1660
  case 33:
1622
1661
  case "end":
1623
- return _context22.stop();
1662
+ return _context23.stop();
1624
1663
  }
1625
- }, _callee22, this, [[0, 27]]);
1664
+ }, _callee23, this, [[0, 27]]);
1626
1665
  }));
1627
- function addPaymentItemAsync(_x13) {
1666
+ function addPaymentItemAsync(_x14) {
1628
1667
  return _addPaymentItemAsync.apply(this, arguments);
1629
1668
  }
1630
1669
  return addPaymentItemAsync;
@@ -1642,14 +1681,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1642
1681
  }, {
1643
1682
  key: "deletePaymentItemAsync",
1644
1683
  value: (function () {
1645
- var _deletePaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(paymentUuid) {
1684
+ var _deletePaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(paymentUuid) {
1646
1685
  var paymentItem, currentOrderId, isCurrentOrderReal, updatedOrder;
1647
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1648
- while (1) switch (_context23.prev = _context23.next) {
1686
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1687
+ while (1) switch (_context24.prev = _context24.next) {
1649
1688
  case 0:
1650
- _context23.prev = 0;
1689
+ _context24.prev = 0;
1651
1690
  if (this.store.currentOrder) {
1652
- _context23.next = 3;
1691
+ _context24.next = 3;
1653
1692
  break;
1654
1693
  }
1655
1694
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, '当前没有活跃订单,无法删除支付项');
@@ -1664,7 +1703,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1664
1703
  return p.uuid === paymentUuid;
1665
1704
  });
1666
1705
  if (paymentItem) {
1667
- _context23.next = 7;
1706
+ _context24.next = 7;
1668
1707
  break;
1669
1708
  }
1670
1709
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, "\u652F\u4ED8\u9879\u4E0D\u5B58\u5728: ".concat(paymentUuid));
@@ -1677,7 +1716,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1677
1716
  });
1678
1717
 
1679
1718
  // 调用 Payment 模块删除支付项
1680
- _context23.next = 10;
1719
+ _context24.next = 10;
1681
1720
  return this.payment.deletePaymentAsync(this.store.currentOrder.uuid, paymentUuid);
1682
1721
  case 10:
1683
1722
  console.log('[Checkout] Payment模块删除完成');
@@ -1685,10 +1724,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1685
1724
  // 重新从Payment模块获取最新的订单数据,确保支付项同步
1686
1725
  currentOrderId = this.store.currentOrder.order_id; // 保存当前的订单ID
1687
1726
  isCurrentOrderReal = currentOrderId && !this.isVirtualOrderId(currentOrderId);
1688
- _context23.next = 15;
1727
+ _context24.next = 15;
1689
1728
  return this.payment.getPaymentOrderByUuidAsync(this.store.currentOrder.uuid);
1690
1729
  case 15:
1691
- updatedOrder = _context23.sent;
1730
+ updatedOrder = _context24.sent;
1692
1731
  if (updatedOrder) {
1693
1732
  // 如果当前订单ID是真实ID,但获取到的订单ID是虚拟ID,需要保护真实ID
1694
1733
  if (isCurrentOrderReal && this.isVirtualOrderId(updatedOrder.order_id)) {
@@ -1703,10 +1742,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1703
1742
  }
1704
1743
 
1705
1744
  // 更新 stateAmount 为剩余未支付金额
1706
- _context23.next = 19;
1745
+ _context24.next = 19;
1707
1746
  return this.updateStateAmountToRemaining();
1708
1747
  case 19:
1709
- _context23.next = 21;
1748
+ _context24.next = 21;
1710
1749
  return this.core.effects.emit(CheckoutHooks.OnPaymentStarted, {
1711
1750
  orderUuid: this.store.currentOrder.uuid,
1712
1751
  paymentMethodCode: paymentItem.code,
@@ -1716,23 +1755,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1716
1755
  });
1717
1756
  case 21:
1718
1757
  console.log('[Checkout] 支付项删除成功');
1719
- _context23.next = 30;
1758
+ _context24.next = 30;
1720
1759
  break;
1721
1760
  case 24:
1722
- _context23.prev = 24;
1723
- _context23.t0 = _context23["catch"](0);
1724
- console.error('[Checkout] 删除支付项失败:', _context23.t0);
1725
- _context23.next = 29;
1726
- return this.handleError(_context23.t0, CheckoutErrorType.PaymentFailed);
1761
+ _context24.prev = 24;
1762
+ _context24.t0 = _context24["catch"](0);
1763
+ console.error('[Checkout] 删除支付项失败:', _context24.t0);
1764
+ _context24.next = 29;
1765
+ return this.handleError(_context24.t0, CheckoutErrorType.PaymentFailed);
1727
1766
  case 29:
1728
- throw _context23.t0;
1767
+ throw _context24.t0;
1729
1768
  case 30:
1730
1769
  case "end":
1731
- return _context23.stop();
1770
+ return _context24.stop();
1732
1771
  }
1733
- }, _callee23, this, [[0, 24]]);
1772
+ }, _callee24, this, [[0, 24]]);
1734
1773
  }));
1735
- function deletePaymentItemAsync(_x14) {
1774
+ function deletePaymentItemAsync(_x15) {
1736
1775
  return _deletePaymentItemAsync.apply(this, arguments);
1737
1776
  }
1738
1777
  return deletePaymentItemAsync;
@@ -1751,14 +1790,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1751
1790
  }, {
1752
1791
  key: "updateVoucherPaymentItemsAsync",
1753
1792
  value: (function () {
1754
- var _updateVoucherPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(voucherPaymentItems) {
1793
+ var _updateVoucherPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(voucherPaymentItems) {
1755
1794
  var _iterator, _step, item, currentOrderId, isCurrentOrderReal, updatedOrder, voucherItems;
1756
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1757
- while (1) switch (_context24.prev = _context24.next) {
1795
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1796
+ while (1) switch (_context25.prev = _context25.next) {
1758
1797
  case 0:
1759
- _context24.prev = 0;
1798
+ _context25.prev = 0;
1760
1799
  if (this.store.currentOrder) {
1761
- _context24.next = 3;
1800
+ _context25.next = 3;
1762
1801
  break;
1763
1802
  }
1764
1803
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, '当前没有活跃订单,无法更新代金券支付项');
@@ -1771,35 +1810,35 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1771
1810
 
1772
1811
  // 验证所有支付项都包含 voucher_id
1773
1812
  _iterator = _createForOfIteratorHelper(voucherPaymentItems);
1774
- _context24.prev = 5;
1813
+ _context25.prev = 5;
1775
1814
  _iterator.s();
1776
1815
  case 7:
1777
1816
  if ((_step = _iterator.n()).done) {
1778
- _context24.next = 13;
1817
+ _context25.next = 13;
1779
1818
  break;
1780
1819
  }
1781
1820
  item = _step.value;
1782
1821
  if (item.voucher_id) {
1783
- _context24.next = 11;
1822
+ _context25.next = 11;
1784
1823
  break;
1785
1824
  }
1786
1825
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, "\u4EE3\u91D1\u5238\u652F\u4ED8\u9879\u7F3A\u5C11 voucher_id: ".concat(JSON.stringify(item)));
1787
1826
  case 11:
1788
- _context24.next = 7;
1827
+ _context25.next = 7;
1789
1828
  break;
1790
1829
  case 13:
1791
- _context24.next = 18;
1830
+ _context25.next = 18;
1792
1831
  break;
1793
1832
  case 15:
1794
- _context24.prev = 15;
1795
- _context24.t0 = _context24["catch"](5);
1796
- _iterator.e(_context24.t0);
1833
+ _context25.prev = 15;
1834
+ _context25.t0 = _context25["catch"](5);
1835
+ _iterator.e(_context25.t0);
1797
1836
  case 18:
1798
- _context24.prev = 18;
1837
+ _context25.prev = 18;
1799
1838
  _iterator.f();
1800
- return _context24.finish(18);
1839
+ return _context25.finish(18);
1801
1840
  case 21:
1802
- _context24.next = 23;
1841
+ _context25.next = 23;
1803
1842
  return this.payment.updateVoucherPaymentItemsAsync(this.store.currentOrder.uuid, voucherPaymentItems);
1804
1843
  case 23:
1805
1844
  console.log('[Checkout] Payment模块批量更新完成');
@@ -1807,10 +1846,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1807
1846
  // 重新从Payment模块获取最新的订单数据,确保支付项同步
1808
1847
  currentOrderId = this.store.currentOrder.order_id; // 保存当前的订单ID
1809
1848
  isCurrentOrderReal = currentOrderId && !this.isVirtualOrderId(currentOrderId);
1810
- _context24.next = 28;
1849
+ _context25.next = 28;
1811
1850
  return this.payment.getPaymentOrderByUuidAsync(this.store.currentOrder.uuid);
1812
1851
  case 28:
1813
- updatedOrder = _context24.sent;
1852
+ updatedOrder = _context25.sent;
1814
1853
  if (updatedOrder) {
1815
1854
  // 如果当前订单ID是真实ID,但获取到的订单ID是虚拟ID,需要保护真实ID
1816
1855
  if (isCurrentOrderReal && this.isVirtualOrderId(updatedOrder.order_id)) {
@@ -1841,10 +1880,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1841
1880
  }
1842
1881
 
1843
1882
  // 更新 stateAmount 为剩余未支付金额
1844
- _context24.next = 32;
1883
+ _context25.next = 32;
1845
1884
  return this.updateStateAmountToRemaining();
1846
1885
  case 32:
1847
- _context24.next = 34;
1886
+ _context25.next = 34;
1848
1887
  return this.core.effects.emit(CheckoutHooks.OnPaymentStarted, {
1849
1888
  orderUuid: this.store.currentOrder.uuid,
1850
1889
  paymentMethodCode: 'VOUCHER_BATCH',
@@ -1855,23 +1894,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1855
1894
  });
1856
1895
  case 34:
1857
1896
  console.log('[Checkout] 代金券支付项批量更新成功');
1858
- _context24.next = 43;
1897
+ _context25.next = 43;
1859
1898
  break;
1860
1899
  case 37:
1861
- _context24.prev = 37;
1862
- _context24.t1 = _context24["catch"](0);
1863
- console.error('[Checkout] 批量更新代金券支付项失败:', _context24.t1);
1864
- _context24.next = 42;
1865
- return this.handleError(_context24.t1, CheckoutErrorType.PaymentFailed);
1900
+ _context25.prev = 37;
1901
+ _context25.t1 = _context25["catch"](0);
1902
+ console.error('[Checkout] 批量更新代金券支付项失败:', _context25.t1);
1903
+ _context25.next = 42;
1904
+ return this.handleError(_context25.t1, CheckoutErrorType.PaymentFailed);
1866
1905
  case 42:
1867
- throw _context24.t1;
1906
+ throw _context25.t1;
1868
1907
  case 43:
1869
1908
  case "end":
1870
- return _context24.stop();
1909
+ return _context25.stop();
1871
1910
  }
1872
- }, _callee24, this, [[0, 37], [5, 15, 18, 21]]);
1911
+ }, _callee25, this, [[0, 37], [5, 15, 18, 21]]);
1873
1912
  }));
1874
- function updateVoucherPaymentItemsAsync(_x15) {
1913
+ function updateVoucherPaymentItemsAsync(_x16) {
1875
1914
  return _updateVoucherPaymentItemsAsync.apply(this, arguments);
1876
1915
  }
1877
1916
  return updateVoucherPaymentItemsAsync;
@@ -1888,20 +1927,20 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1888
1927
  }, {
1889
1928
  key: "updateOrderDepositStatusAsync",
1890
1929
  value: (function () {
1891
- var _updateOrderDepositStatusAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(isDeposit) {
1930
+ var _updateOrderDepositStatusAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(isDeposit) {
1892
1931
  var newDepositValue, oldDepositValue, updateParams;
1893
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1894
- while (1) switch (_context25.prev = _context25.next) {
1932
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
1933
+ while (1) switch (_context26.prev = _context26.next) {
1895
1934
  case 0:
1896
- _context25.prev = 0;
1935
+ _context26.prev = 0;
1897
1936
  if (!(isDeposit !== 0 && isDeposit !== 1)) {
1898
- _context25.next = 3;
1937
+ _context26.next = 3;
1899
1938
  break;
1900
1939
  }
1901
1940
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, 'isDeposit 参数只能是 0(全款订单)或 1(定金订单)');
1902
1941
  case 3:
1903
1942
  if (this.store.currentOrder) {
1904
- _context25.next = 5;
1943
+ _context26.next = 5;
1905
1944
  break;
1906
1945
  }
1907
1946
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, '未找到当前订单,无法修改定金状态');
@@ -1909,11 +1948,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1909
1948
  newDepositValue = isDeposit;
1910
1949
  oldDepositValue = this.store.currentOrder.is_deposit; // 如果状态没有变化,直接返回
1911
1950
  if (!(oldDepositValue === newDepositValue)) {
1912
- _context25.next = 10;
1951
+ _context26.next = 10;
1913
1952
  break;
1914
1953
  }
1915
1954
  console.log('[Checkout] 定金状态无变化,跳过更新');
1916
- return _context25.abrupt("return");
1955
+ return _context26.abrupt("return");
1917
1956
  case 10:
1918
1957
  console.log('[Checkout] 更新订单定金状态:', {
1919
1958
  orderUuid: this.store.currentOrder.uuid,
@@ -1932,7 +1971,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1932
1971
  }
1933
1972
 
1934
1973
  // 调用 Payment 模块更新订单
1935
- _context25.next = 15;
1974
+ _context26.next = 15;
1936
1975
  return this.payment.updateOrderAsync(this.store.currentOrder.uuid, updateParams);
1937
1976
  case 15:
1938
1977
  // 更新本地缓存的订单对象
@@ -1944,7 +1983,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1944
1983
  }
1945
1984
 
1946
1985
  // 触发订单更新事件
1947
- _context25.next = 19;
1986
+ _context26.next = 19;
1948
1987
  return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
1949
1988
  order: this.store.currentOrder,
1950
1989
  timestamp: Date.now()
@@ -1954,23 +1993,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1954
1993
  isDeposit: newDepositValue,
1955
1994
  depositAmount: this.store.currentOrder.deposit_amount
1956
1995
  });
1957
- _context25.next = 28;
1996
+ _context26.next = 28;
1958
1997
  break;
1959
1998
  case 22:
1960
- _context25.prev = 22;
1961
- _context25.t0 = _context25["catch"](0);
1962
- console.error('[Checkout] 更新订单定金状态失败:', _context25.t0);
1963
- _context25.next = 27;
1964
- return this.handleError(_context25.t0, CheckoutErrorType.ValidationFailed);
1999
+ _context26.prev = 22;
2000
+ _context26.t0 = _context26["catch"](0);
2001
+ console.error('[Checkout] 更新订单定金状态失败:', _context26.t0);
2002
+ _context26.next = 27;
2003
+ return this.handleError(_context26.t0, CheckoutErrorType.ValidationFailed);
1965
2004
  case 27:
1966
- throw _context25.t0;
2005
+ throw _context26.t0;
1967
2006
  case 28:
1968
2007
  case "end":
1969
- return _context25.stop();
2008
+ return _context26.stop();
1970
2009
  }
1971
- }, _callee25, this, [[0, 22]]);
2010
+ }, _callee26, this, [[0, 22]]);
1972
2011
  }));
1973
- function updateOrderDepositStatusAsync(_x16) {
2012
+ function updateOrderDepositStatusAsync(_x17) {
1974
2013
  return _updateOrderDepositStatusAsync.apply(this, arguments);
1975
2014
  }
1976
2015
  return updateOrderDepositStatusAsync;
@@ -1987,13 +2026,13 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1987
2026
  }, {
1988
2027
  key: "updateOrderCustomerAsync",
1989
2028
  value: (function () {
1990
- var _updateOrderCustomerAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(customer) {
1991
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
1992
- while (1) switch (_context26.prev = _context26.next) {
2029
+ var _updateOrderCustomerAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(customer) {
2030
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2031
+ while (1) switch (_context27.prev = _context27.next) {
1993
2032
  case 0:
1994
- _context26.prev = 0;
2033
+ _context27.prev = 0;
1995
2034
  if (this.store.currentOrder) {
1996
- _context26.next = 3;
2035
+ _context27.next = 3;
1997
2036
  break;
1998
2037
  }
1999
2038
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, '未找到当前订单,无法更新客户信息');
@@ -2016,23 +2055,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2016
2055
  this.store.localOrderData.customer_name = customer.customer_name;
2017
2056
  }
2018
2057
  console.log('[Checkout] 订单客户信息更新成功:', this.store.currentCustomer);
2019
- _context26.next = 15;
2058
+ _context27.next = 15;
2020
2059
  break;
2021
2060
  case 9:
2022
- _context26.prev = 9;
2023
- _context26.t0 = _context26["catch"](0);
2024
- console.error('[Checkout] 更新订单客户信息失败:', _context26.t0);
2025
- _context26.next = 14;
2026
- return this.handleError(_context26.t0, CheckoutErrorType.ValidationFailed);
2061
+ _context27.prev = 9;
2062
+ _context27.t0 = _context27["catch"](0);
2063
+ console.error('[Checkout] 更新订单客户信息失败:', _context27.t0);
2064
+ _context27.next = 14;
2065
+ return this.handleError(_context27.t0, CheckoutErrorType.ValidationFailed);
2027
2066
  case 14:
2028
- throw _context26.t0;
2067
+ throw _context27.t0;
2029
2068
  case 15:
2030
2069
  case "end":
2031
- return _context26.stop();
2070
+ return _context27.stop();
2032
2071
  }
2033
- }, _callee26, this, [[0, 9]]);
2072
+ }, _callee27, this, [[0, 9]]);
2034
2073
  }));
2035
- function updateOrderCustomerAsync(_x17) {
2074
+ function updateOrderCustomerAsync(_x18) {
2036
2075
  return _updateOrderCustomerAsync.apply(this, arguments);
2037
2076
  }
2038
2077
  return updateOrderCustomerAsync;
@@ -2058,7 +2097,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2058
2097
  key: "needsManualSync",
2059
2098
  value: function needsManualSync() {
2060
2099
  try {
2061
- var _this$store$currentOr4;
2100
+ var _this$store$currentOr6;
2062
2101
  // 检查基础条件
2063
2102
  if (!this.store.currentOrder || this.store.isOrderSynced) {
2064
2103
  return false;
@@ -2079,7 +2118,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2079
2118
  orderUuid: this.store.currentOrder.uuid,
2080
2119
  isOrderSynced: this.store.isOrderSynced,
2081
2120
  remainingAmount: remainingAmount,
2082
- hasPayments: ((_this$store$currentOr4 = this.store.currentOrder.payment) === null || _this$store$currentOr4 === void 0 ? void 0 : _this$store$currentOr4.length) > 0,
2121
+ hasPayments: ((_this$store$currentOr6 = this.store.currentOrder.payment) === null || _this$store$currentOr6 === void 0 ? void 0 : _this$store$currentOr6.length) > 0,
2083
2122
  allPaymentsHaveVoucherId: allPaymentsHaveVoucherId,
2084
2123
  needsManualSync: allPaymentsHaveVoucherId
2085
2124
  });
@@ -2098,17 +2137,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2098
2137
  }, {
2099
2138
  key: "manualSyncOrderAsync",
2100
2139
  value: (function () {
2101
- var _manualSyncOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
2102
- var orderUuid, oldOrderId, realOrderId, finalOrderId, finalIsVirtual, _this$store$currentOr5, errorMessage;
2103
- return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2104
- while (1) switch (_context27.prev = _context27.next) {
2140
+ var _manualSyncOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
2141
+ var orderUuid, oldOrderId, realOrderId, finalOrderId, finalIsVirtual, _this$store$currentOr7, errorMessage;
2142
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2143
+ while (1) switch (_context28.prev = _context28.next) {
2105
2144
  case 0:
2106
- _context27.prev = 0;
2145
+ _context28.prev = 0;
2107
2146
  if (this.store.currentOrder) {
2108
- _context27.next = 3;
2147
+ _context28.next = 3;
2109
2148
  break;
2110
2149
  }
2111
- return _context27.abrupt("return", {
2150
+ return _context28.abrupt("return", {
2112
2151
  success: false,
2113
2152
  message: '当前没有活跃订单,无法同步'
2114
2153
  });
@@ -2126,10 +2165,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2126
2165
  });
2127
2166
 
2128
2167
  // 强制同步订单到后端,并获取真实订单ID
2129
- _context27.next = 9;
2168
+ _context28.next = 9;
2130
2169
  return this.syncOrderToBackendWithReturn(true);
2131
2170
  case 9:
2132
- realOrderId = _context27.sent;
2171
+ realOrderId = _context28.sent;
2133
2172
  console.log('[Checkout] 手动同步订单完成:', {
2134
2173
  orderUuid: orderUuid,
2135
2174
  oldOrderId: oldOrderId,
@@ -2153,7 +2192,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2153
2192
  if (realOrderId !== finalOrderId) {
2154
2193
  console.error('[Checkout] 严重警告:返回的订单ID与存储的订单ID不一致!');
2155
2194
  }
2156
- return _context27.abrupt("return", {
2195
+ return _context28.abrupt("return", {
2157
2196
  success: true,
2158
2197
  message: '订单同步成功',
2159
2198
  orderId: realOrderId,
@@ -2161,20 +2200,20 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2161
2200
  orderUuid: orderUuid
2162
2201
  });
2163
2202
  case 19:
2164
- _context27.prev = 19;
2165
- _context27.t0 = _context27["catch"](0);
2166
- console.error('[Checkout] 手动同步订单失败:', _context27.t0);
2167
- errorMessage = _context27.t0 instanceof Error ? _context27.t0.message : '同步失败';
2168
- return _context27.abrupt("return", {
2203
+ _context28.prev = 19;
2204
+ _context28.t0 = _context28["catch"](0);
2205
+ console.error('[Checkout] 手动同步订单失败:', _context28.t0);
2206
+ errorMessage = _context28.t0 instanceof Error ? _context28.t0.message : '同步失败';
2207
+ return _context28.abrupt("return", {
2169
2208
  success: false,
2170
2209
  message: "\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(errorMessage),
2171
- orderUuid: (_this$store$currentOr5 = this.store.currentOrder) === null || _this$store$currentOr5 === void 0 ? void 0 : _this$store$currentOr5.uuid
2210
+ orderUuid: (_this$store$currentOr7 = this.store.currentOrder) === null || _this$store$currentOr7 === void 0 ? void 0 : _this$store$currentOr7.uuid
2172
2211
  });
2173
2212
  case 24:
2174
2213
  case "end":
2175
- return _context27.stop();
2214
+ return _context28.stop();
2176
2215
  }
2177
- }, _callee27, this, [[0, 19]]);
2216
+ }, _callee28, this, [[0, 19]]);
2178
2217
  }));
2179
2218
  function manualSyncOrderAsync() {
2180
2219
  return _manualSyncOrderAsync.apply(this, arguments);
@@ -2220,17 +2259,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2220
2259
  }, {
2221
2260
  key: "saveForLaterPaymentAsync",
2222
2261
  value: (function () {
2223
- var _saveForLaterPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
2224
- var orderUuid, currentOrderId, allPaymentItems, filteredPaymentItems, voucherItems, realOrderId, finalOrderId, _this$store$currentOr6, errorMessage;
2225
- return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2226
- while (1) switch (_context28.prev = _context28.next) {
2262
+ var _saveForLaterPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
2263
+ var orderUuid, currentOrderId, allPaymentItems, filteredPaymentItems, voucherItems, realOrderId, finalOrderId, _this$store$currentOr8, errorMessage;
2264
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2265
+ while (1) switch (_context29.prev = _context29.next) {
2227
2266
  case 0:
2228
- _context28.prev = 0;
2267
+ _context29.prev = 0;
2229
2268
  if (this.store.currentOrder) {
2230
- _context28.next = 3;
2269
+ _context29.next = 3;
2231
2270
  break;
2232
2271
  }
2233
- return _context28.abrupt("return", {
2272
+ return _context29.abrupt("return", {
2234
2273
  success: false,
2235
2274
  message: '当前没有活跃订单,无法保存'
2236
2275
  });
@@ -2244,10 +2283,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2244
2283
  });
2245
2284
 
2246
2285
  // 获取当前订单的所有支付项
2247
- _context28.next = 8;
2286
+ _context29.next = 8;
2248
2287
  return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid);
2249
2288
  case 8:
2250
- allPaymentItems = _context28.sent;
2289
+ allPaymentItems = _context29.sent;
2251
2290
  // 过滤掉带有 voucher_id 的支付项(代金券类支付项)
2252
2291
  filteredPaymentItems = allPaymentItems.filter(function (payment) {
2253
2292
  return !payment.voucher_id || payment.voucher_id.trim() === '';
@@ -2277,10 +2316,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2277
2316
  });
2278
2317
 
2279
2318
  // 调用同步方法,传入过滤后的支付项
2280
- _context28.next = 14;
2319
+ _context29.next = 14;
2281
2320
  return this.syncOrderToBackendWithReturn(false, filteredPaymentItems);
2282
2321
  case 14:
2283
- realOrderId = _context28.sent;
2322
+ realOrderId = _context29.sent;
2284
2323
  console.log('[Checkout] 保存订单完成:', {
2285
2324
  orderUuid: orderUuid,
2286
2325
  oldOrderId: currentOrderId,
@@ -2297,27 +2336,27 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2297
2336
  是否一致: realOrderId === finalOrderId,
2298
2337
  同步状态: this.store.isOrderSynced
2299
2338
  });
2300
- return _context28.abrupt("return", {
2339
+ return _context29.abrupt("return", {
2301
2340
  success: true,
2302
2341
  message: '订单保存成功,可稍后继续支付',
2303
2342
  orderId: realOrderId,
2304
2343
  orderUuid: orderUuid
2305
2344
  });
2306
2345
  case 21:
2307
- _context28.prev = 21;
2308
- _context28.t0 = _context28["catch"](0);
2309
- console.error('[Checkout] 保存订单失败:', _context28.t0);
2310
- errorMessage = _context28.t0 instanceof Error ? _context28.t0.message : '保存失败';
2311
- return _context28.abrupt("return", {
2346
+ _context29.prev = 21;
2347
+ _context29.t0 = _context29["catch"](0);
2348
+ console.error('[Checkout] 保存订单失败:', _context29.t0);
2349
+ errorMessage = _context29.t0 instanceof Error ? _context29.t0.message : '保存失败';
2350
+ return _context29.abrupt("return", {
2312
2351
  success: false,
2313
2352
  message: "\u8BA2\u5355\u4FDD\u5B58\u5931\u8D25: ".concat(errorMessage),
2314
- orderUuid: (_this$store$currentOr6 = this.store.currentOrder) === null || _this$store$currentOr6 === void 0 ? void 0 : _this$store$currentOr6.uuid
2353
+ orderUuid: (_this$store$currentOr8 = this.store.currentOrder) === null || _this$store$currentOr8 === void 0 ? void 0 : _this$store$currentOr8.uuid
2315
2354
  });
2316
2355
  case 26:
2317
2356
  case "end":
2318
- return _context28.stop();
2357
+ return _context29.stop();
2319
2358
  }
2320
- }, _callee28, this, [[0, 21]]);
2359
+ }, _callee29, this, [[0, 21]]);
2321
2360
  }));
2322
2361
  function saveForLaterPaymentAsync() {
2323
2362
  return _saveForLaterPaymentAsync.apply(this, arguments);
@@ -2361,15 +2400,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2361
2400
  }, {
2362
2401
  key: "updateShopDiscountAsync",
2363
2402
  value: (function () {
2364
- var _updateShopDiscountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(discountAmount) {
2365
- var _this$store$currentOr7, _this$store$currentOr8, oldDiscount, shopDiscountItem, updatedAmountInfo;
2366
- return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2367
- while (1) switch (_context29.prev = _context29.next) {
2403
+ var _updateShopDiscountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(discountAmount) {
2404
+ var _this$store$currentOr9, _this$store$currentOr10, oldDiscount, shopDiscountItem, updatedAmountInfo;
2405
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2406
+ while (1) switch (_context30.prev = _context30.next) {
2368
2407
  case 0:
2369
- _context29.prev = 0;
2408
+ _context30.prev = 0;
2370
2409
  oldDiscount = this.getShopDiscount();
2371
2410
  console.log('[Checkout] 更新商店折扣:', {
2372
- orderUuid: (_this$store$currentOr7 = this.store.currentOrder) === null || _this$store$currentOr7 === void 0 ? void 0 : _this$store$currentOr7.uuid,
2411
+ orderUuid: (_this$store$currentOr9 = this.store.currentOrder) === null || _this$store$currentOr9 === void 0 ? void 0 : _this$store$currentOr9.uuid,
2373
2412
  oldDiscount: oldDiscount,
2374
2413
  newDiscount: discountAmount
2375
2414
  });
@@ -2414,12 +2453,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2414
2453
  }
2415
2454
 
2416
2455
  // 4. 更新 stateAmount 为剩余未支付金额
2417
- _context29.next = 8;
2456
+ _context30.next = 8;
2418
2457
  return this.updateStateAmountToRemaining();
2419
2458
  case 8:
2420
- _context29.next = 10;
2459
+ _context30.next = 10;
2421
2460
  return this.core.effects.emit(CheckoutHooks.OnShopDiscountChanged, {
2422
- orderUuid: (_this$store$currentOr8 = this.store.currentOrder) === null || _this$store$currentOr8 === void 0 ? void 0 : _this$store$currentOr8.uuid,
2461
+ orderUuid: (_this$store$currentOr10 = this.store.currentOrder) === null || _this$store$currentOr10 === void 0 ? void 0 : _this$store$currentOr10.uuid,
2423
2462
  oldDiscount: oldDiscount,
2424
2463
  newDiscount: discountAmount,
2425
2464
  timestamp: Date.now()
@@ -2429,23 +2468,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2429
2468
  oldDiscount: oldDiscount,
2430
2469
  newDiscount: discountAmount
2431
2470
  });
2432
- _context29.next = 19;
2471
+ _context30.next = 19;
2433
2472
  break;
2434
2473
  case 13:
2435
- _context29.prev = 13;
2436
- _context29.t0 = _context29["catch"](0);
2437
- console.error('[Checkout] 更新商店折扣失败:', _context29.t0);
2438
- _context29.next = 18;
2439
- return this.handleError(_context29.t0, CheckoutErrorType.ValidationFailed);
2474
+ _context30.prev = 13;
2475
+ _context30.t0 = _context30["catch"](0);
2476
+ console.error('[Checkout] 更新商店折扣失败:', _context30.t0);
2477
+ _context30.next = 18;
2478
+ return this.handleError(_context30.t0, CheckoutErrorType.ValidationFailed);
2440
2479
  case 18:
2441
- throw _context29.t0;
2480
+ throw _context30.t0;
2442
2481
  case 19:
2443
2482
  case "end":
2444
- return _context29.stop();
2483
+ return _context30.stop();
2445
2484
  }
2446
- }, _callee29, this, [[0, 13]]);
2485
+ }, _callee30, this, [[0, 13]]);
2447
2486
  }));
2448
- function updateShopDiscountAsync(_x18) {
2487
+ function updateShopDiscountAsync(_x19) {
2449
2488
  return _updateShopDiscountAsync.apply(this, arguments);
2450
2489
  }
2451
2490
  return updateShopDiscountAsync;
@@ -2459,20 +2498,20 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2459
2498
  }, {
2460
2499
  key: "updateOrderNoteAsync",
2461
2500
  value: (function () {
2462
- var _updateOrderNoteAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(note) {
2463
- var _this$store$currentOr9, _this$store$currentOr10, oldNote, orderInPayment;
2464
- return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2465
- while (1) switch (_context30.prev = _context30.next) {
2501
+ var _updateOrderNoteAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(note) {
2502
+ var _this$store$currentOr11, _this$store$currentOr12, oldNote, orderInPayment;
2503
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2504
+ while (1) switch (_context31.prev = _context31.next) {
2466
2505
  case 0:
2467
- _context30.prev = 0;
2506
+ _context31.prev = 0;
2468
2507
  if (this.store.localOrderData) {
2469
- _context30.next = 3;
2508
+ _context31.next = 3;
2470
2509
  break;
2471
2510
  }
2472
2511
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, '没有本地订单数据,无法更新备注');
2473
2512
  case 3:
2474
2513
  console.log('[Checkout] 更新订单备注:', {
2475
- orderUuid: (_this$store$currentOr9 = this.store.currentOrder) === null || _this$store$currentOr9 === void 0 ? void 0 : _this$store$currentOr9.uuid,
2514
+ orderUuid: (_this$store$currentOr11 = this.store.currentOrder) === null || _this$store$currentOr11 === void 0 ? void 0 : _this$store$currentOr11.uuid,
2476
2515
  oldNote: this.store.localOrderData.shop_note,
2477
2516
  newNote: note
2478
2517
  });
@@ -2483,29 +2522,29 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2483
2522
 
2484
2523
  // 如果有当前订单,也同步到Payment模块中的订单数据
2485
2524
  if (!this.store.currentOrder) {
2486
- _context30.next = 17;
2525
+ _context31.next = 17;
2487
2526
  break;
2488
2527
  }
2489
- _context30.prev = 7;
2490
- _context30.next = 10;
2528
+ _context31.prev = 7;
2529
+ _context31.next = 10;
2491
2530
  return this.payment.getPaymentOrderByUuidAsync(this.store.currentOrder.uuid);
2492
2531
  case 10:
2493
- orderInPayment = _context30.sent;
2532
+ orderInPayment = _context31.sent;
2494
2533
  if (orderInPayment && orderInPayment.note !== undefined) {
2495
2534
  // 使用Payment模块的更新方法(如果有的话)
2496
2535
  // 这里可能需要根据Payment模块的实际API来调整
2497
2536
  console.log('[Checkout] 同步备注到Payment模块的订单数据中');
2498
2537
  }
2499
- _context30.next = 17;
2538
+ _context31.next = 17;
2500
2539
  break;
2501
2540
  case 14:
2502
- _context30.prev = 14;
2503
- _context30.t0 = _context30["catch"](7);
2504
- console.warn('[Checkout] 同步备注到Payment模块失败,但本地更新成功:', _context30.t0);
2541
+ _context31.prev = 14;
2542
+ _context31.t0 = _context31["catch"](7);
2543
+ console.warn('[Checkout] 同步备注到Payment模块失败,但本地更新成功:', _context31.t0);
2505
2544
  case 17:
2506
- _context30.next = 19;
2545
+ _context31.next = 19;
2507
2546
  return this.core.effects.emit(CheckoutHooks.OnOrderNoteChanged, {
2508
- orderUuid: (_this$store$currentOr10 = this.store.currentOrder) === null || _this$store$currentOr10 === void 0 ? void 0 : _this$store$currentOr10.uuid,
2547
+ orderUuid: (_this$store$currentOr12 = this.store.currentOrder) === null || _this$store$currentOr12 === void 0 ? void 0 : _this$store$currentOr12.uuid,
2509
2548
  oldNote: oldNote,
2510
2549
  newNote: note,
2511
2550
  timestamp: Date.now()
@@ -2515,23 +2554,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2515
2554
  oldNote: oldNote,
2516
2555
  newNote: note
2517
2556
  });
2518
- _context30.next = 28;
2557
+ _context31.next = 28;
2519
2558
  break;
2520
2559
  case 22:
2521
- _context30.prev = 22;
2522
- _context30.t1 = _context30["catch"](0);
2523
- console.error('[Checkout] 更新订单备注失败:', _context30.t1);
2524
- _context30.next = 27;
2525
- return this.handleError(_context30.t1, CheckoutErrorType.ValidationFailed);
2560
+ _context31.prev = 22;
2561
+ _context31.t1 = _context31["catch"](0);
2562
+ console.error('[Checkout] 更新订单备注失败:', _context31.t1);
2563
+ _context31.next = 27;
2564
+ return this.handleError(_context31.t1, CheckoutErrorType.ValidationFailed);
2526
2565
  case 27:
2527
- throw _context30.t1;
2566
+ throw _context31.t1;
2528
2567
  case 28:
2529
2568
  case "end":
2530
- return _context30.stop();
2569
+ return _context31.stop();
2531
2570
  }
2532
- }, _callee30, this, [[0, 22], [7, 14]]);
2571
+ }, _callee31, this, [[0, 22], [7, 14]]);
2533
2572
  }));
2534
- function updateOrderNoteAsync(_x19) {
2573
+ function updateOrderNoteAsync(_x20) {
2535
2574
  return _updateOrderNoteAsync.apply(this, arguments);
2536
2575
  }
2537
2576
  return updateOrderNoteAsync;
@@ -2543,14 +2582,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2543
2582
  }, {
2544
2583
  key: "setStatus",
2545
2584
  value: (function () {
2546
- var _setStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(status) {
2585
+ var _setStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(status) {
2547
2586
  var oldStatus;
2548
- return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2549
- while (1) switch (_context31.prev = _context31.next) {
2587
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2588
+ while (1) switch (_context32.prev = _context32.next) {
2550
2589
  case 0:
2551
2590
  oldStatus = this.store.status;
2552
2591
  this.store.status = status;
2553
- _context31.next = 4;
2592
+ _context32.next = 4;
2554
2593
  return this.core.effects.emit(CheckoutHooks.OnStatusChanged, {
2555
2594
  oldStatus: oldStatus,
2556
2595
  newStatus: status,
@@ -2558,11 +2597,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2558
2597
  });
2559
2598
  case 4:
2560
2599
  case "end":
2561
- return _context31.stop();
2600
+ return _context32.stop();
2562
2601
  }
2563
- }, _callee31, this);
2602
+ }, _callee32, this);
2564
2603
  }));
2565
- function setStatus(_x20) {
2604
+ function setStatus(_x21) {
2566
2605
  return _setStatus.apply(this, arguments);
2567
2606
  }
2568
2607
  return setStatus;
@@ -2574,14 +2613,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2574
2613
  }, {
2575
2614
  key: "setStep",
2576
2615
  value: (function () {
2577
- var _setStep = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(step) {
2616
+ var _setStep = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(step) {
2578
2617
  var oldStep;
2579
- return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2580
- while (1) switch (_context32.prev = _context32.next) {
2618
+ return _regeneratorRuntime().wrap(function _callee33$(_context33) {
2619
+ while (1) switch (_context33.prev = _context33.next) {
2581
2620
  case 0:
2582
2621
  oldStep = this.store.step;
2583
2622
  this.store.step = step;
2584
- _context32.next = 4;
2623
+ _context33.next = 4;
2585
2624
  return this.core.effects.emit(CheckoutHooks.OnStepChanged, {
2586
2625
  oldStep: oldStep,
2587
2626
  newStep: step,
@@ -2589,11 +2628,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2589
2628
  });
2590
2629
  case 4:
2591
2630
  case "end":
2592
- return _context32.stop();
2631
+ return _context33.stop();
2593
2632
  }
2594
- }, _callee32, this);
2633
+ }, _callee33, this);
2595
2634
  }));
2596
- function setStep(_x21) {
2635
+ function setStep(_x22) {
2597
2636
  return _setStep.apply(this, arguments);
2598
2637
  }
2599
2638
  return setStep;
@@ -2605,17 +2644,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2605
2644
  }, {
2606
2645
  key: "handleError",
2607
2646
  value: (function () {
2608
- var _handleError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(error, type) {
2647
+ var _handleError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(error, type) {
2609
2648
  var checkoutError;
2610
- return _regeneratorRuntime().wrap(function _callee33$(_context33) {
2611
- while (1) switch (_context33.prev = _context33.next) {
2649
+ return _regeneratorRuntime().wrap(function _callee34$(_context34) {
2650
+ while (1) switch (_context34.prev = _context34.next) {
2612
2651
  case 0:
2613
2652
  checkoutError = error instanceof Error && 'type' in error ? error : createCheckoutError(type, error.message, error);
2614
2653
  this.store.lastError = checkoutError;
2615
- _context33.next = 4;
2654
+ _context34.next = 4;
2616
2655
  return this.setStatus(CheckoutStatus.Error);
2617
2656
  case 4:
2618
- _context33.next = 6;
2657
+ _context34.next = 6;
2619
2658
  return this.core.effects.emit(CheckoutHooks.OnError, {
2620
2659
  error: checkoutError,
2621
2660
  context: {
@@ -2628,11 +2667,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2628
2667
  console.error('[Checkout] 错误:', checkoutError);
2629
2668
  case 7:
2630
2669
  case "end":
2631
- return _context33.stop();
2670
+ return _context34.stop();
2632
2671
  }
2633
- }, _callee33, this);
2672
+ }, _callee34, this);
2634
2673
  }));
2635
- function handleError(_x22, _x23) {
2674
+ function handleError(_x23, _x24) {
2636
2675
  return _handleError.apply(this, arguments);
2637
2676
  }
2638
2677
  return handleError;
@@ -2644,34 +2683,34 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2644
2683
  }, {
2645
2684
  key: "handlePaymentSuccess",
2646
2685
  value: (function () {
2647
- var _handlePaymentSuccess = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(data) {
2648
- var _this$store$currentOr11;
2649
- return _regeneratorRuntime().wrap(function _callee34$(_context34) {
2650
- while (1) switch (_context34.prev = _context34.next) {
2686
+ var _handlePaymentSuccess = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(data) {
2687
+ var _this$store$currentOr13;
2688
+ return _regeneratorRuntime().wrap(function _callee35$(_context35) {
2689
+ while (1) switch (_context35.prev = _context35.next) {
2651
2690
  case 0:
2652
- _context34.next = 2;
2691
+ _context35.next = 2;
2653
2692
  return this.setStatus(CheckoutStatus.PaymentCompleted);
2654
2693
  case 2:
2655
- _context34.next = 4;
2694
+ _context35.next = 4;
2656
2695
  return this.updateStateAmountToRemaining();
2657
2696
  case 4:
2658
- _context34.next = 6;
2697
+ _context35.next = 6;
2659
2698
  return this.core.effects.emit(CheckoutHooks.OnPaymentSuccess, {
2660
2699
  orderUuid: data.orderUuid,
2661
2700
  paymentMethodCode: '',
2662
- amount: ((_this$store$currentOr11 = this.store.currentOrder) === null || _this$store$currentOr11 === void 0 ? void 0 : _this$store$currentOr11.total_amount) || '0',
2701
+ amount: ((_this$store$currentOr13 = this.store.currentOrder) === null || _this$store$currentOr13 === void 0 ? void 0 : _this$store$currentOr13.total_amount) || '0',
2663
2702
  timestamp: data.timestamp
2664
2703
  });
2665
2704
  case 6:
2666
- _context34.next = 8;
2705
+ _context35.next = 8;
2667
2706
  return this.completeCheckoutAsync();
2668
2707
  case 8:
2669
2708
  case "end":
2670
- return _context34.stop();
2709
+ return _context35.stop();
2671
2710
  }
2672
- }, _callee34, this);
2711
+ }, _callee35, this);
2673
2712
  }));
2674
- function handlePaymentSuccess(_x24) {
2713
+ function handlePaymentSuccess(_x25) {
2675
2714
  return _handlePaymentSuccess.apply(this, arguments);
2676
2715
  }
2677
2716
  return handlePaymentSuccess;
@@ -2683,30 +2722,30 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2683
2722
  }, {
2684
2723
  key: "handlePaymentError",
2685
2724
  value: (function () {
2686
- var _handlePaymentError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(data) {
2687
- var _this$store$currentOr12;
2725
+ var _handlePaymentError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(data) {
2726
+ var _this$store$currentOr14;
2688
2727
  var error;
2689
- return _regeneratorRuntime().wrap(function _callee35$(_context35) {
2690
- while (1) switch (_context35.prev = _context35.next) {
2728
+ return _regeneratorRuntime().wrap(function _callee36$(_context36) {
2729
+ while (1) switch (_context36.prev = _context36.next) {
2691
2730
  case 0:
2692
2731
  error = createCheckoutError(CheckoutErrorType.PaymentFailed, data.error || '支付同步失败');
2693
- _context35.next = 3;
2732
+ _context36.next = 3;
2694
2733
  return this.handleError(error instanceof Error ? error : new Error(String(error)), CheckoutErrorType.PaymentFailed);
2695
2734
  case 3:
2696
- _context35.next = 5;
2735
+ _context36.next = 5;
2697
2736
  return this.core.effects.emit(CheckoutHooks.OnPaymentFailed, {
2698
2737
  orderUuid: data.orderUuid,
2699
2738
  paymentMethodCode: '',
2700
- amount: ((_this$store$currentOr12 = this.store.currentOrder) === null || _this$store$currentOr12 === void 0 ? void 0 : _this$store$currentOr12.total_amount) || '0',
2739
+ amount: ((_this$store$currentOr14 = this.store.currentOrder) === null || _this$store$currentOr14 === void 0 ? void 0 : _this$store$currentOr14.total_amount) || '0',
2701
2740
  timestamp: data.timestamp
2702
2741
  });
2703
2742
  case 5:
2704
2743
  case "end":
2705
- return _context35.stop();
2744
+ return _context36.stop();
2706
2745
  }
2707
- }, _callee35, this);
2746
+ }, _callee36, this);
2708
2747
  }));
2709
- function handlePaymentError(_x25) {
2748
+ function handlePaymentError(_x26) {
2710
2749
  return _handlePaymentError.apply(this, arguments);
2711
2750
  }
2712
2751
  return handlePaymentError;
@@ -2718,18 +2757,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2718
2757
  }, {
2719
2758
  key: "validateCheckoutParams",
2720
2759
  value: (function () {
2721
- var _validateCheckoutParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
2722
- return _regeneratorRuntime().wrap(function _callee36$(_context36) {
2723
- while (1) switch (_context36.prev = _context36.next) {
2760
+ var _validateCheckoutParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
2761
+ return _regeneratorRuntime().wrap(function _callee37$(_context37) {
2762
+ while (1) switch (_context37.prev = _context37.next) {
2724
2763
  case 0:
2725
- return _context36.abrupt("return", validateCheckoutData(params));
2764
+ return _context37.abrupt("return", validateCheckoutData(params));
2726
2765
  case 1:
2727
2766
  case "end":
2728
- return _context36.stop();
2767
+ return _context37.stop();
2729
2768
  }
2730
- }, _callee36);
2769
+ }, _callee37);
2731
2770
  }));
2732
- function validateCheckoutParams(_x26) {
2771
+ function validateCheckoutParams(_x27) {
2733
2772
  return _validateCheckoutParams.apply(this, arguments);
2734
2773
  }
2735
2774
  return validateCheckoutParams;
@@ -2741,10 +2780,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2741
2780
  }, {
2742
2781
  key: "validateLocalOrderData",
2743
2782
  value: (function () {
2744
- var _validateLocalOrderData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(orderData) {
2783
+ var _validateLocalOrderData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(orderData) {
2745
2784
  var errors;
2746
- return _regeneratorRuntime().wrap(function _callee37$(_context37) {
2747
- while (1) switch (_context37.prev = _context37.next) {
2785
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
2786
+ while (1) switch (_context38.prev = _context38.next) {
2748
2787
  case 0:
2749
2788
  errors = []; // 验证基本字段
2750
2789
  if (!orderData.type) {
@@ -2771,17 +2810,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2771
2810
  }
2772
2811
  });
2773
2812
  }
2774
- return _context37.abrupt("return", {
2813
+ return _context38.abrupt("return", {
2775
2814
  valid: errors.length === 0,
2776
2815
  errors: errors
2777
2816
  });
2778
2817
  case 6:
2779
2818
  case "end":
2780
- return _context37.stop();
2819
+ return _context38.stop();
2781
2820
  }
2782
- }, _callee37);
2821
+ }, _callee38);
2783
2822
  }));
2784
- function validateLocalOrderData(_x27) {
2823
+ function validateLocalOrderData(_x28) {
2785
2824
  return _validateLocalOrderData.apply(this, arguments);
2786
2825
  }
2787
2826
  return validateLocalOrderData;
@@ -2879,31 +2918,31 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2879
2918
  }, {
2880
2919
  key: "preloadPaymentMethods",
2881
2920
  value: (function () {
2882
- var _preloadPaymentMethods = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
2921
+ var _preloadPaymentMethods = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
2883
2922
  var methods;
2884
- return _regeneratorRuntime().wrap(function _callee38$(_context38) {
2885
- while (1) switch (_context38.prev = _context38.next) {
2923
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
2924
+ while (1) switch (_context39.prev = _context39.next) {
2886
2925
  case 0:
2887
- _context38.prev = 0;
2926
+ _context39.prev = 0;
2888
2927
  console.log('[Checkout] 预加载支付方式...');
2889
- _context38.next = 4;
2928
+ _context39.next = 4;
2890
2929
  return this.payment.getPayMethodListAsync();
2891
2930
  case 4:
2892
- methods = _context38.sent;
2931
+ methods = _context39.sent;
2893
2932
  this.store.paymentMethods = methods;
2894
2933
  console.log("[Checkout] \u9884\u52A0\u8F7D\u5B8C\u6210\uFF0C\u5171 ".concat(methods.length, " \u79CD\u652F\u4ED8\u65B9\u5F0F"));
2895
- _context38.next = 13;
2934
+ _context39.next = 13;
2896
2935
  break;
2897
2936
  case 9:
2898
- _context38.prev = 9;
2899
- _context38.t0 = _context38["catch"](0);
2900
- console.error('[Checkout] 预加载支付方式失败:', _context38.t0);
2937
+ _context39.prev = 9;
2938
+ _context39.t0 = _context39["catch"](0);
2939
+ console.error('[Checkout] 预加载支付方式失败:', _context39.t0);
2901
2940
  this.store.paymentMethods = [];
2902
2941
  case 13:
2903
2942
  case "end":
2904
- return _context38.stop();
2943
+ return _context39.stop();
2905
2944
  }
2906
- }, _callee38, this, [[0, 9]]);
2945
+ }, _callee39, this, [[0, 9]]);
2907
2946
  }));
2908
2947
  function preloadPaymentMethods() {
2909
2948
  return _preloadPaymentMethods.apply(this, arguments);
@@ -2990,30 +3029,30 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2990
3029
  }, {
2991
3030
  key: "updateStateAmountToRemaining",
2992
3031
  value: (function () {
2993
- var _updateStateAmountToRemaining = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
2994
- var _this$store$currentOr13, remainingAmount, currentStateAmount;
2995
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
2996
- while (1) switch (_context39.prev = _context39.next) {
3032
+ var _updateStateAmountToRemaining = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40() {
3033
+ var _this$store$currentOr15, remainingAmount, currentStateAmount;
3034
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3035
+ while (1) switch (_context40.prev = _context40.next) {
2997
3036
  case 0:
2998
- _context39.prev = 0;
3037
+ _context40.prev = 0;
2999
3038
  remainingAmount = this.calculateRemainingAmount();
3000
3039
  currentStateAmount = this.store.stateAmount;
3001
3040
  console.log('[Checkout] updateStateAmountToRemaining: 状态检查:', {
3002
3041
  calculatedRemainingAmount: remainingAmount,
3003
3042
  currentStateAmount: currentStateAmount,
3004
3043
  needsUpdate: remainingAmount !== currentStateAmount,
3005
- orderUuid: (_this$store$currentOr13 = this.store.currentOrder) === null || _this$store$currentOr13 === void 0 ? void 0 : _this$store$currentOr13.uuid
3044
+ orderUuid: (_this$store$currentOr15 = this.store.currentOrder) === null || _this$store$currentOr15 === void 0 ? void 0 : _this$store$currentOr15.uuid
3006
3045
  });
3007
3046
 
3008
3047
  // 只有当剩余金额与当前 stateAmount 不同时才更新
3009
3048
  if (!(remainingAmount !== currentStateAmount)) {
3010
- _context39.next = 11;
3049
+ _context40.next = 11;
3011
3050
  break;
3012
3051
  }
3013
3052
  this.store.stateAmount = remainingAmount;
3014
3053
 
3015
3054
  // 发出 stateAmount 变更事件
3016
- _context39.next = 8;
3055
+ _context40.next = 8;
3017
3056
  return this.core.effects.emit(CheckoutHooks.OnStateAmountChanged, {
3018
3057
  oldAmount: currentStateAmount,
3019
3058
  newAmount: remainingAmount,
@@ -3024,7 +3063,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3024
3063
  oldAmount: currentStateAmount,
3025
3064
  newAmount: remainingAmount
3026
3065
  });
3027
- _context39.next = 12;
3066
+ _context40.next = 12;
3028
3067
  break;
3029
3068
  case 11:
3030
3069
  console.log('[Checkout] stateAmount 无需更新,当前值已是最新:', {
@@ -3032,20 +3071,20 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3032
3071
  remainingAmount: remainingAmount
3033
3072
  });
3034
3073
  case 12:
3035
- _context39.next = 14;
3074
+ _context40.next = 14;
3036
3075
  return this.checkOrderPaymentCompletion();
3037
3076
  case 14:
3038
- _context39.next = 19;
3077
+ _context40.next = 19;
3039
3078
  break;
3040
3079
  case 16:
3041
- _context39.prev = 16;
3042
- _context39.t0 = _context39["catch"](0);
3043
- console.error('[Checkout] 更新 stateAmount 为剩余金额失败:', _context39.t0);
3080
+ _context40.prev = 16;
3081
+ _context40.t0 = _context40["catch"](0);
3082
+ console.error('[Checkout] 更新 stateAmount 为剩余金额失败:', _context40.t0);
3044
3083
  case 19:
3045
3084
  case "end":
3046
- return _context39.stop();
3085
+ return _context40.stop();
3047
3086
  }
3048
- }, _callee39, this, [[0, 16]]);
3087
+ }, _callee40, this, [[0, 16]]);
3049
3088
  }));
3050
3089
  function updateStateAmountToRemaining() {
3051
3090
  return _updateStateAmountToRemaining.apply(this, arguments);
@@ -3061,22 +3100,22 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3061
3100
  }, {
3062
3101
  key: "checkOrderPaymentCompletion",
3063
3102
  value: (function () {
3064
- var _checkOrderPaymentCompletion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40() {
3065
- var remainingAmount, remainingValue, _this$store$currentOr14, _this$store$currentOr15, totalAmount, paidAmount, allPaymentsHaveVoucherId;
3066
- return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3067
- while (1) switch (_context40.prev = _context40.next) {
3103
+ var _checkOrderPaymentCompletion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41() {
3104
+ var remainingAmount, remainingValue, _this$store$currentOr16, _this$store$currentOr17, totalAmount, paidAmount, allPaymentsHaveVoucherId;
3105
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3106
+ while (1) switch (_context41.prev = _context41.next) {
3068
3107
  case 0:
3069
- _context40.prev = 0;
3108
+ _context41.prev = 0;
3070
3109
  if (this.store.currentOrder) {
3071
- _context40.next = 3;
3110
+ _context41.next = 3;
3072
3111
  break;
3073
3112
  }
3074
- return _context40.abrupt("return");
3113
+ return _context41.abrupt("return");
3075
3114
  case 3:
3076
3115
  remainingAmount = this.calculateRemainingAmount();
3077
3116
  remainingValue = parseFloat(remainingAmount); // 当剩余金额小于等于0时,认为订单已完成支付
3078
3117
  if (!(remainingValue <= 0)) {
3079
- _context40.next = 21;
3118
+ _context41.next = 21;
3080
3119
  break;
3081
3120
  }
3082
3121
  totalAmount = this.store.currentOrder.total_amount;
@@ -3095,9 +3134,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3095
3134
  return item.status !== 'voided' && item.voucher_id;
3096
3135
  });
3097
3136
  console.log('[Checkout] 支付项voucher_id检查:', {
3098
- paymentCount: ((_this$store$currentOr14 = this.store.currentOrder.payment) === null || _this$store$currentOr14 === void 0 ? void 0 : _this$store$currentOr14.length) || 0,
3137
+ paymentCount: ((_this$store$currentOr16 = this.store.currentOrder.payment) === null || _this$store$currentOr16 === void 0 ? void 0 : _this$store$currentOr16.length) || 0,
3099
3138
  allHaveVoucherId: allPaymentsHaveVoucherId,
3100
- paymentItems: (_this$store$currentOr15 = this.store.currentOrder.payment) === null || _this$store$currentOr15 === void 0 ? void 0 : _this$store$currentOr15.map(function (p) {
3139
+ paymentItems: (_this$store$currentOr17 = this.store.currentOrder.payment) === null || _this$store$currentOr17 === void 0 ? void 0 : _this$store$currentOr17.map(function (p) {
3101
3140
  return {
3102
3141
  uuid: p.uuid,
3103
3142
  code: p.code,
@@ -3110,22 +3149,22 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3110
3149
 
3111
3150
  // 如果支付完成但订单未同步,需要判断是否同步
3112
3151
  if (this.store.isOrderSynced) {
3113
- _context40.next = 19;
3152
+ _context41.next = 19;
3114
3153
  break;
3115
3154
  }
3116
3155
  if (!allPaymentsHaveVoucherId) {
3117
- _context40.next = 16;
3156
+ _context41.next = 16;
3118
3157
  break;
3119
3158
  }
3120
3159
  console.log('[Checkout] 所有支付项均为代金券类型,跳过订单同步');
3121
- _context40.next = 19;
3160
+ _context41.next = 19;
3122
3161
  break;
3123
3162
  case 16:
3124
3163
  console.log('[Checkout] 支付完成但订单未同步,开始同步订单到后端...');
3125
- _context40.next = 19;
3164
+ _context41.next = 19;
3126
3165
  return this.syncOrderToBackend();
3127
3166
  case 19:
3128
- _context40.next = 21;
3167
+ _context41.next = 21;
3129
3168
  return this.core.effects.emit(CheckoutHooks.OnOrderPaymentCompleted, {
3130
3169
  orderUuid: this.store.currentOrder.uuid,
3131
3170
  orderId: this.store.currentOrder.order_id,
@@ -3135,17 +3174,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3135
3174
  timestamp: Date.now()
3136
3175
  });
3137
3176
  case 21:
3138
- _context40.next = 26;
3177
+ _context41.next = 26;
3139
3178
  break;
3140
3179
  case 23:
3141
- _context40.prev = 23;
3142
- _context40.t0 = _context40["catch"](0);
3143
- console.error('[Checkout] 检查订单支付完成状态失败:', _context40.t0);
3180
+ _context41.prev = 23;
3181
+ _context41.t0 = _context41["catch"](0);
3182
+ console.error('[Checkout] 检查订单支付完成状态失败:', _context41.t0);
3144
3183
  case 26:
3145
3184
  case "end":
3146
- return _context40.stop();
3185
+ return _context41.stop();
3147
3186
  }
3148
- }, _callee40, this, [[0, 23]]);
3187
+ }, _callee41, this, [[0, 23]]);
3149
3188
  }));
3150
3189
  function checkOrderPaymentCompletion() {
3151
3190
  return _checkOrderPaymentCompletion.apply(this, arguments);
@@ -3217,8 +3256,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3217
3256
  }, {
3218
3257
  key: "syncOrderToBackendWithReturn",
3219
3258
  value: (function () {
3220
- var _syncOrderToBackendWithReturn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41() {
3221
- var _this$store$currentCu2, _this$store$currentOr16, _this$store$currentOr17;
3259
+ var _syncOrderToBackendWithReturn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42() {
3260
+ var _this$store$currentCu2, _this$store$currentOr18, _this$store$currentOr19;
3222
3261
  var isManual,
3223
3262
  customPaymentItems,
3224
3263
  syncType,
@@ -3237,14 +3276,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3237
3276
  beforeManualUpdate,
3238
3277
  finalOrderId,
3239
3278
  finalIsVirtual,
3240
- _args41 = arguments;
3241
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3242
- while (1) switch (_context41.prev = _context41.next) {
3279
+ _args42 = arguments;
3280
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3281
+ while (1) switch (_context42.prev = _context42.next) {
3243
3282
  case 0:
3244
- isManual = _args41.length > 0 && _args41[0] !== undefined ? _args41[0] : false;
3245
- customPaymentItems = _args41.length > 1 ? _args41[1] : undefined;
3283
+ isManual = _args42.length > 0 && _args42[0] !== undefined ? _args42[0] : false;
3284
+ customPaymentItems = _args42.length > 1 ? _args42[1] : undefined;
3246
3285
  if (!(!this.store.localOrderData || !this.store.currentOrder)) {
3247
- _context41.next = 4;
3286
+ _context42.next = 4;
3248
3287
  break;
3249
3288
  }
3250
3289
  throw new Error('缺少必要的订单数据,无法同步到后端');
@@ -3285,17 +3324,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3285
3324
  });
3286
3325
 
3287
3326
  // 获取当前订单的支付项
3288
- _context41.t0 = customPaymentItems;
3289
- if (_context41.t0) {
3290
- _context41.next = 18;
3327
+ _context42.t0 = customPaymentItems;
3328
+ if (_context42.t0) {
3329
+ _context42.next = 18;
3291
3330
  break;
3292
3331
  }
3293
- _context41.next = 17;
3332
+ _context42.next = 17;
3294
3333
  return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid);
3295
3334
  case 17:
3296
- _context41.t0 = _context41.sent;
3335
+ _context42.t0 = _context42.sent;
3297
3336
  case 18:
3298
- paymentItems = _context41.t0;
3337
+ paymentItems = _context42.t0;
3299
3338
  console.log('[Checkout] 获取到支付项:', {
3300
3339
  count: paymentItems.length,
3301
3340
  isCustomFiltered: !!customPaymentItems,
@@ -3336,8 +3375,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3336
3375
  currency_code: this.otherParams.currency_code,
3337
3376
  currency_symbol: this.otherParams.currency_symbol,
3338
3377
  currency_format: this.otherParams.currency_format,
3339
- is_deposit: ((_this$store$currentOr16 = this.store.currentOrder) === null || _this$store$currentOr16 === void 0 ? void 0 : _this$store$currentOr16.is_deposit) || 0,
3340
- deposit_amount: ((_this$store$currentOr17 = this.store.currentOrder) === null || _this$store$currentOr17 === void 0 ? void 0 : _this$store$currentOr17.deposit_amount) || '0.00',
3378
+ is_deposit: ((_this$store$currentOr18 = this.store.currentOrder) === null || _this$store$currentOr18 === void 0 ? void 0 : _this$store$currentOr18.is_deposit) || 0,
3379
+ deposit_amount: ((_this$store$currentOr19 = this.store.currentOrder) === null || _this$store$currentOr19 === void 0 ? void 0 : _this$store$currentOr19.deposit_amount) || '0.00',
3341
3380
  // surcharge_fee: this.otherParams.surcharge_fee,
3342
3381
  // surcharges: ,
3343
3382
  note: this.store.localOrderData.shop_note
@@ -3367,10 +3406,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3367
3406
  }
3368
3407
 
3369
3408
  // 调用 Order 模块的专用 createOrderByCheckout 方法
3370
- _context41.next = 24;
3409
+ _context42.next = 24;
3371
3410
  return this.order.createOrderByCheckout(orderParams);
3372
3411
  case 24:
3373
- checkoutResponse = _context41.sent;
3412
+ checkoutResponse = _context42.sent;
3374
3413
  console.log('[Checkout] 后端返回的响应数据:', {
3375
3414
  status: checkoutResponse === null || checkoutResponse === void 0 ? void 0 : checkoutResponse.status,
3376
3415
  code: checkoutResponse === null || checkoutResponse === void 0 ? void 0 : checkoutResponse.code,
@@ -3378,13 +3417,13 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3378
3417
  data: checkoutResponse === null || checkoutResponse === void 0 ? void 0 : checkoutResponse.data
3379
3418
  });
3380
3419
  if (!isUpdateOperation) {
3381
- _context41.next = 31;
3420
+ _context42.next = 31;
3382
3421
  break;
3383
3422
  }
3384
3423
  // 更新操作:使用现有的订单ID
3385
3424
  realOrderId = currentOrderId;
3386
3425
  console.log("[Checkout] \u8BA2\u5355\u66F4\u65B0\u6210\u529F\uFF0C\u8BA2\u5355ID: ".concat(realOrderId));
3387
- _context41.next = 52;
3426
+ _context42.next = 52;
3388
3427
  break;
3389
3428
  case 31:
3390
3429
  // 创建操作:从响应中提取新的订单ID
@@ -3398,7 +3437,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3398
3437
  extractedOrderId = String(extractedOrderId);
3399
3438
  }
3400
3439
  if (extractedOrderId) {
3401
- _context41.next = 36;
3440
+ _context42.next = 36;
3402
3441
  break;
3403
3442
  }
3404
3443
  throw new Error('后端返回的订单信息中未包含订单ID');
@@ -3412,11 +3451,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3412
3451
  oldOrderId: this.store.currentOrder.order_id,
3413
3452
  newOrderId: realOrderId
3414
3453
  });
3415
- _context41.prev = 39;
3416
- _context41.next = 42;
3454
+ _context42.prev = 39;
3455
+ _context42.next = 42;
3417
3456
  return this.payment.replaceOrderIdByUuidAsync(this.store.currentOrder.uuid, realOrderId);
3418
3457
  case 42:
3419
- updatedOrder = _context41.sent;
3458
+ updatedOrder = _context42.sent;
3420
3459
  console.log('[Checkout] Payment模块替换订单ID结果:', {
3421
3460
  wasSuccessful: !!updatedOrder,
3422
3461
  returnedOrderId: updatedOrder === null || updatedOrder === void 0 ? void 0 : updatedOrder.order_id,
@@ -3442,12 +3481,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3442
3481
  目标ID: realOrderId
3443
3482
  });
3444
3483
  }
3445
- _context41.next = 52;
3484
+ _context42.next = 52;
3446
3485
  break;
3447
3486
  case 47:
3448
- _context41.prev = 47;
3449
- _context41.t1 = _context41["catch"](39);
3450
- console.error('[Checkout] 调用Payment模块替换订单ID时发生错误:', _context41.t1);
3487
+ _context42.prev = 47;
3488
+ _context42.t1 = _context42["catch"](39);
3489
+ console.error('[Checkout] 调用Payment模块替换订单ID时发生错误:', _context42.t1);
3451
3490
 
3452
3491
  // 发生错误时也进行手动替换
3453
3492
  this.store.currentOrder.order_id = realOrderId;
@@ -3457,13 +3496,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3457
3496
  this.store.isOrderSynced = true;
3458
3497
 
3459
3498
  // 触发订单同步完成事件
3460
- _context41.next = 55;
3499
+ _context42.next = 55;
3461
3500
  return this.core.effects.emit(CheckoutHooks.OnOrderSynced, {
3462
3501
  orderUuid: this.store.currentOrder.uuid,
3463
3502
  realOrderId: realOrderId,
3464
3503
  virtualOrderId: this.store.currentOrder.order_id,
3465
3504
  timestamp: Date.now(),
3466
- isManual: isManual
3505
+ isManual: isManual,
3506
+ response: checkoutResponse
3467
3507
  });
3468
3508
  case 55:
3469
3509
  // 验证最终状态
@@ -3482,12 +3522,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3482
3522
  }
3483
3523
 
3484
3524
  // 返回真实订单ID
3485
- return _context41.abrupt("return", realOrderId);
3525
+ return _context42.abrupt("return", realOrderId);
3486
3526
  case 60:
3487
3527
  case "end":
3488
- return _context41.stop();
3528
+ return _context42.stop();
3489
3529
  }
3490
- }, _callee41, this, [[39, 47]]);
3530
+ }, _callee42, this, [[39, 47]]);
3491
3531
  }));
3492
3532
  function syncOrderToBackendWithReturn() {
3493
3533
  return _syncOrderToBackendWithReturn.apply(this, arguments);
@@ -3497,27 +3537,27 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3497
3537
  }, {
3498
3538
  key: "syncOrderToBackend",
3499
3539
  value: function () {
3500
- var _syncOrderToBackend = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42() {
3501
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3502
- while (1) switch (_context42.prev = _context42.next) {
3540
+ var _syncOrderToBackend = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43() {
3541
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3542
+ while (1) switch (_context43.prev = _context43.next) {
3503
3543
  case 0:
3504
- _context42.prev = 0;
3505
- _context42.next = 3;
3544
+ _context43.prev = 0;
3545
+ _context43.next = 3;
3506
3546
  return this.syncOrderToBackendWithReturn(false);
3507
3547
  case 3:
3508
- _context42.next = 10;
3548
+ _context43.next = 10;
3509
3549
  break;
3510
3550
  case 5:
3511
- _context42.prev = 5;
3512
- _context42.t0 = _context42["catch"](0);
3513
- console.error('[Checkout] 同步订单到后端失败:', _context42.t0);
3514
- _context42.next = 10;
3515
- return this.handleError(new Error("\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(_context42.t0 instanceof Error ? _context42.t0.message : String(_context42.t0))), CheckoutErrorType.OrderCreationFailed);
3551
+ _context43.prev = 5;
3552
+ _context43.t0 = _context43["catch"](0);
3553
+ console.error('[Checkout] 同步订单到后端失败:', _context43.t0);
3554
+ _context43.next = 10;
3555
+ return this.handleError(new Error("\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(_context43.t0 instanceof Error ? _context43.t0.message : String(_context43.t0))), CheckoutErrorType.OrderCreationFailed);
3516
3556
  case 10:
3517
3557
  case "end":
3518
- return _context42.stop();
3558
+ return _context43.stop();
3519
3559
  }
3520
- }, _callee42, this, [[0, 5]]);
3560
+ }, _callee43, this, [[0, 5]]);
3521
3561
  }));
3522
3562
  function syncOrderToBackend() {
3523
3563
  return _syncOrderToBackend.apply(this, arguments);
@@ -3557,15 +3597,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3557
3597
  }, {
3558
3598
  key: "setOtherParams",
3559
3599
  value: function () {
3560
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
3600
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(params) {
3561
3601
  var _ref3,
3562
3602
  _ref3$cover,
3563
3603
  cover,
3564
- _args43 = arguments;
3565
- return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3566
- while (1) switch (_context43.prev = _context43.next) {
3604
+ _args44 = arguments;
3605
+ return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3606
+ while (1) switch (_context44.prev = _context44.next) {
3567
3607
  case 0:
3568
- _ref3 = _args43.length > 1 && _args43[1] !== undefined ? _args43[1] : {}, _ref3$cover = _ref3.cover, cover = _ref3$cover === void 0 ? false : _ref3$cover;
3608
+ _ref3 = _args44.length > 1 && _args44[1] !== undefined ? _args44[1] : {}, _ref3$cover = _ref3.cover, cover = _ref3$cover === void 0 ? false : _ref3$cover;
3569
3609
  if (cover) {
3570
3610
  this.otherParams = params;
3571
3611
  } else {
@@ -3573,22 +3613,137 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3573
3613
  }
3574
3614
  case 2:
3575
3615
  case "end":
3576
- return _context43.stop();
3616
+ return _context44.stop();
3577
3617
  }
3578
- }, _callee43, this);
3618
+ }, _callee44, this);
3579
3619
  }));
3580
- function setOtherParams(_x28) {
3620
+ function setOtherParams(_x29) {
3581
3621
  return _setOtherParams.apply(this, arguments);
3582
3622
  }
3583
3623
  return setOtherParams;
3584
3624
  }()
3625
+ /**
3626
+ * 通过订单ID编辑订单备注
3627
+ *
3628
+ * 用于修改已同步到后端的订单备注,通常在支付成功后的弹窗中使用
3629
+ *
3630
+ * @param orderId 后端订单ID
3631
+ * @param note 新的订单备注
3632
+ * @returns 修改结果
3633
+ */
3634
+ }, {
3635
+ key: "editOrderNoteByOrderIdAsync",
3636
+ value: (function () {
3637
+ var _editOrderNoteByOrderIdAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(orderId, note) {
3638
+ var response, previousNote, errorMessage, _errorMessage;
3639
+ return _regeneratorRuntime().wrap(function _callee45$(_context45) {
3640
+ while (1) switch (_context45.prev = _context45.next) {
3641
+ case 0:
3642
+ _context45.prev = 0;
3643
+ console.log('[Checkout] 开始编辑订单备注:', {
3644
+ orderId: orderId,
3645
+ note: note,
3646
+ noteLength: note.length
3647
+ });
3648
+
3649
+ // 参数验证
3650
+ if (orderId) {
3651
+ _context45.next = 4;
3652
+ break;
3653
+ }
3654
+ return _context45.abrupt("return", {
3655
+ success: false,
3656
+ message: '订单ID不能为空',
3657
+ orderId: orderId
3658
+ });
3659
+ case 4:
3660
+ _context45.next = 6;
3661
+ return this.request.put("/shop/order/order/".concat(orderId, "/note"), {
3662
+ note: note
3663
+ });
3664
+ case 6:
3665
+ response = _context45.sent;
3666
+ console.log('[Checkout] 订单备注编辑响应:', {
3667
+ orderId: orderId,
3668
+ status: response.status,
3669
+ message: response.message,
3670
+ response: response
3671
+ });
3672
+
3673
+ // 检查响应状态
3674
+ if (!(response.status === true || response.status === 200)) {
3675
+ _context45.next = 19;
3676
+ break;
3677
+ }
3678
+ console.log("[Checkout] \u8BA2\u5355 ".concat(orderId, " \u5907\u6CE8\u4FEE\u6539\u6210\u529F"));
3679
+
3680
+ // 如果当前订单就是被修改的订单,同时更新本地状态
3681
+ if (!(this.store.currentOrder && (String(this.store.currentOrder.order_id) === String(orderId) || String(this.store.currentOrder.id) === String(orderId)))) {
3682
+ _context45.next = 16;
3683
+ break;
3684
+ }
3685
+ console.log('[Checkout] 更新本地订单备注状态');
3686
+
3687
+ // 获取修改前的备注用于事件
3688
+ previousNote = this.getOrderNote(); // 更新本地订单数据中的备注
3689
+ if (this.store.localOrderData) {
3690
+ this.store.localOrderData.shop_note = note;
3691
+ }
3692
+
3693
+ // 触发订单备注变更事件
3694
+ _context45.next = 16;
3695
+ return this.core.effects.emit(CheckoutHooks.OnOrderNoteChanged, {
3696
+ orderUuid: this.store.currentOrder.uuid,
3697
+ oldNote: previousNote,
3698
+ newNote: note,
3699
+ timestamp: Date.now()
3700
+ });
3701
+ case 16:
3702
+ return _context45.abrupt("return", {
3703
+ success: true,
3704
+ message: response.message || '订单备注修改成功',
3705
+ orderId: orderId
3706
+ });
3707
+ case 19:
3708
+ // API返回失败状态
3709
+ errorMessage = response.message || '订单备注修改失败';
3710
+ console.error("[Checkout] \u8BA2\u5355 ".concat(orderId, " \u5907\u6CE8\u4FEE\u6539\u5931\u8D25:"), errorMessage);
3711
+ return _context45.abrupt("return", {
3712
+ success: false,
3713
+ message: errorMessage,
3714
+ orderId: orderId
3715
+ });
3716
+ case 22:
3717
+ _context45.next = 29;
3718
+ break;
3719
+ case 24:
3720
+ _context45.prev = 24;
3721
+ _context45.t0 = _context45["catch"](0);
3722
+ console.error('[Checkout] 编辑订单备注失败:', _context45.t0);
3723
+ _errorMessage = _context45.t0 instanceof Error ? _context45.t0.message : '网络错误或服务器异常';
3724
+ return _context45.abrupt("return", {
3725
+ success: false,
3726
+ message: "\u7F16\u8F91\u8BA2\u5355\u5907\u6CE8\u5931\u8D25: ".concat(_errorMessage),
3727
+ orderId: orderId
3728
+ });
3729
+ case 29:
3730
+ case "end":
3731
+ return _context45.stop();
3732
+ }
3733
+ }, _callee45, this, [[0, 24]]);
3734
+ }));
3735
+ function editOrderNoteByOrderIdAsync(_x30, _x31) {
3736
+ return _editOrderNoteByOrderIdAsync.apply(this, arguments);
3737
+ }
3738
+ return editOrderNoteByOrderIdAsync;
3739
+ }())
3585
3740
  }, {
3586
3741
  key: "destroy",
3587
3742
  value: function () {
3588
- var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
3743
+ var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
3589
3744
  var _this$order, _this$order$destroy, _this$payment, _this$payment$destroy;
3590
- return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3591
- while (1) switch (_context44.prev = _context44.next) {
3745
+ return _regeneratorRuntime().wrap(function _callee46$(_context46) {
3746
+ while (1) switch (_context46.prev = _context46.next) {
3592
3747
  case 0:
3593
3748
  // 清理钱包模块的所有缓存数据
3594
3749
  this.payment.wallet.clearAllCache();
@@ -3597,10 +3752,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3597
3752
  this.core.effects.offByModuleDestroy(this.name);
3598
3753
 
3599
3754
  // 销毁子模块
3600
- _context44.next = 4;
3755
+ _context46.next = 4;
3601
3756
  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);
3602
3757
  case 4:
3603
- _context44.next = 6;
3758
+ _context46.next = 6;
3604
3759
  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);
3605
3760
  case 6:
3606
3761
  // 取消注册模块
@@ -3608,9 +3763,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3608
3763
  console.log('[Checkout] 已销毁');
3609
3764
  case 8:
3610
3765
  case "end":
3611
- return _context44.stop();
3766
+ return _context46.stop();
3612
3767
  }
3613
- }, _callee44, this);
3768
+ }, _callee46, this);
3614
3769
  }));
3615
3770
  function destroy() {
3616
3771
  return _destroy.apply(this, arguments);