@pisell/pisellos 2.1.11 → 2.1.13

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.
@@ -1466,6 +1466,143 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1466
1466
  }
1467
1467
  return updateOrderDepositStatusAsync;
1468
1468
  }()
1469
+ /**
1470
+ * 手动设置当前订单的定金金额
1471
+ *
1472
+ * 允许手动设置订单的定金金额,通常用于用户自定义定金支付场景
1473
+ *
1474
+ * @param depositAmount 定金金额,必须是有效的数字字符串,且不能超过订单总额
1475
+ * @throws 当前没有活跃订单时抛出错误
1476
+ * @throws 定金金额格式无效或超过订单总额时抛出错误
1477
+ */
1478
+ )
1479
+ }, {
1480
+ key: "setDepositAmountAsync",
1481
+ value: (function () {
1482
+ var _setDepositAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(depositAmount) {
1483
+ var _this$store$currentOr6, _this$store$currentOr7;
1484
+ var depositValue, totalAmount, formattedDepositAmount, oldDepositAmount, updateParams;
1485
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1486
+ while (1) switch (_context19.prev = _context19.next) {
1487
+ case 0:
1488
+ this.logInfo('setDepositAmountAsync called', {
1489
+ depositAmount: depositAmount,
1490
+ hasCurrentOrder: !!this.store.currentOrder,
1491
+ currentOrderId: (_this$store$currentOr6 = this.store.currentOrder) === null || _this$store$currentOr6 === void 0 ? void 0 : _this$store$currentOr6.order_id,
1492
+ currentTotalAmount: (_this$store$currentOr7 = this.store.currentOrder) === null || _this$store$currentOr7 === void 0 ? void 0 : _this$store$currentOr7.total_amount
1493
+ });
1494
+ _context19.prev = 1;
1495
+ // 验证定金金额格式
1496
+ depositValue = new Decimal(depositAmount);
1497
+ if (!(depositValue.isNaN() || depositValue.lt(0))) {
1498
+ _context19.next = 5;
1499
+ break;
1500
+ }
1501
+ throw createCheckoutError(CheckoutErrorType.ValidationFailed, "\u65E0\u6548\u7684\u5B9A\u91D1\u91D1\u989D\u683C\u5F0F: ".concat(depositAmount));
1502
+ case 5:
1503
+ if (this.store.currentOrder) {
1504
+ _context19.next = 7;
1505
+ break;
1506
+ }
1507
+ throw createCheckoutError(CheckoutErrorType.ValidationFailed, '未找到当前订单,无法设置定金金额');
1508
+ case 7:
1509
+ // 使用 Decimal.js 进行安全比较,检查定金金额是否超过订单总额
1510
+ totalAmount = new Decimal(this.store.currentOrder.total_amount || '0');
1511
+ if (!depositValue.gt(totalAmount)) {
1512
+ _context19.next = 10;
1513
+ break;
1514
+ }
1515
+ throw createCheckoutError(CheckoutErrorType.ValidationFailed, "\u5B9A\u91D1\u91D1\u989D ".concat(depositAmount, " \u4E0D\u80FD\u8D85\u8FC7\u8BA2\u5355\u603B\u989D ").concat(totalAmount.toFixed(2)));
1516
+ case 10:
1517
+ formattedDepositAmount = depositValue.toFixed(2);
1518
+ oldDepositAmount = this.store.currentOrder.deposit_amount || '0.00'; // 如果定金金额没有变化,直接返回
1519
+ if (!(formattedDepositAmount === oldDepositAmount)) {
1520
+ _context19.next = 15;
1521
+ break;
1522
+ }
1523
+ this.logInfo('定金金额无变化,跳过更新:', {
1524
+ currentAmount: oldDepositAmount,
1525
+ newAmount: formattedDepositAmount
1526
+ });
1527
+ return _context19.abrupt("return");
1528
+ case 15:
1529
+ this.logInfo('开始设置订单定金金额:', {
1530
+ orderUuid: this.store.currentOrder.uuid,
1531
+ orderId: this.store.currentOrder.order_id,
1532
+ oldDepositAmount: oldDepositAmount,
1533
+ newDepositAmount: formattedDepositAmount,
1534
+ totalAmount: totalAmount.toFixed(2)
1535
+ });
1536
+
1537
+ // 准备更新参数
1538
+ updateParams = {
1539
+ deposit_amount: formattedDepositAmount
1540
+ }; // 如果设置的定金金额大于0,自动将订单标记为定金订单
1541
+ if (depositValue.gt(0) && this.store.currentOrder.is_deposit !== 1) {
1542
+ updateParams.is_deposit = 1;
1543
+ this.logInfo('定金金额大于0,自动设置为定金订单');
1544
+ }
1545
+ // 如果设置的定金金额为0,可以考虑将订单标记为全款订单
1546
+ else if (depositValue.eq(0) && this.store.currentOrder.is_deposit === 1) {
1547
+ updateParams.is_deposit = 0;
1548
+ this.logInfo('定金金额为0,自动设置为全款订单');
1549
+ }
1550
+
1551
+ // 调用 Payment 模块更新订单
1552
+ _context19.next = 20;
1553
+ return this.payment.updateOrderAsync(this.store.currentOrder.uuid, updateParams);
1554
+ case 20:
1555
+ // 更新本地缓存的订单对象
1556
+ this.store.currentOrder = _objectSpread(_objectSpread({}, this.store.currentOrder), updateParams);
1557
+
1558
+ // 同时更新本地订单数据(如果存在)
1559
+ if (this.store.localOrderData) {
1560
+ // 注意:本地订单数据中没有deposit_amount字段,但如果需要可以在这里添加
1561
+ if ('deposit_amount' in this.store.localOrderData) {
1562
+ this.store.localOrderData.deposit_amount = formattedDepositAmount;
1563
+ }
1564
+ // 同步更新 is_deposit 状态(如果有变化)
1565
+ if (updateParams.is_deposit !== undefined) {
1566
+ this.store.localOrderData.is_deposit = updateParams.is_deposit;
1567
+ }
1568
+ }
1569
+
1570
+ // 触发订单更新事件
1571
+ _context19.next = 24;
1572
+ return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
1573
+ order: this.store.currentOrder,
1574
+ timestamp: Date.now()
1575
+ });
1576
+ case 24:
1577
+ this.logInfo('订单定金金额设置成功:', {
1578
+ orderUuid: this.store.currentOrder.uuid,
1579
+ orderId: this.store.currentOrder.order_id,
1580
+ oldDepositAmount: oldDepositAmount,
1581
+ newDepositAmount: formattedDepositAmount,
1582
+ isDeposit: this.store.currentOrder.is_deposit,
1583
+ totalAmount: this.store.currentOrder.total_amount
1584
+ });
1585
+ _context19.next = 33;
1586
+ break;
1587
+ case 27:
1588
+ _context19.prev = 27;
1589
+ _context19.t0 = _context19["catch"](1);
1590
+ this.logError('设置订单定金金额失败:', _context19.t0);
1591
+ _context19.next = 32;
1592
+ return this.handleError(_context19.t0, CheckoutErrorType.ValidationFailed);
1593
+ case 32:
1594
+ throw _context19.t0;
1595
+ case 33:
1596
+ case "end":
1597
+ return _context19.stop();
1598
+ }
1599
+ }, _callee19, this, [[1, 27]]);
1600
+ }));
1601
+ function setDepositAmountAsync(_x18) {
1602
+ return _setDepositAmountAsync.apply(this, arguments);
1603
+ }
1604
+ return setDepositAmountAsync;
1605
+ }()
1469
1606
  /**
1470
1607
  * 手动同步订单到后端
1471
1608
  *
@@ -1475,26 +1612,26 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1475
1612
  }, {
1476
1613
  key: "manualSyncOrderAsync",
1477
1614
  value: (function () {
1478
- var _manualSyncOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
1479
- var _this$store$currentOr6, _this$store$currentOr7, _this$store$currentOr8;
1480
- var orderUuid, oldOrderId, syncResult, finalOrderId, finalIsVirtual, _this$store$currentOr9, errorMessage;
1481
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1482
- while (1) switch (_context19.prev = _context19.next) {
1615
+ var _manualSyncOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
1616
+ var _this$store$currentOr8, _this$store$currentOr9, _this$store$currentOr10;
1617
+ var orderUuid, oldOrderId, syncResult, finalOrderId, finalIsVirtual, _this$store$currentOr11, errorMessage;
1618
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1619
+ while (1) switch (_context20.prev = _context20.next) {
1483
1620
  case 0:
1484
1621
  this.logInfo('manualSyncOrderAsync called', {
1485
1622
  hasCurrentOrder: !!this.store.currentOrder,
1486
- currentOrderId: (_this$store$currentOr6 = this.store.currentOrder) === null || _this$store$currentOr6 === void 0 ? void 0 : _this$store$currentOr6.order_id,
1487
- orderUuid: (_this$store$currentOr7 = this.store.currentOrder) === null || _this$store$currentOr7 === void 0 ? void 0 : _this$store$currentOr7.uuid,
1488
- totalAmount: (_this$store$currentOr8 = this.store.currentOrder) === null || _this$store$currentOr8 === void 0 ? void 0 : _this$store$currentOr8.total_amount,
1623
+ currentOrderId: (_this$store$currentOr8 = this.store.currentOrder) === null || _this$store$currentOr8 === void 0 ? void 0 : _this$store$currentOr8.order_id,
1624
+ orderUuid: (_this$store$currentOr9 = this.store.currentOrder) === null || _this$store$currentOr9 === void 0 ? void 0 : _this$store$currentOr9.uuid,
1625
+ totalAmount: (_this$store$currentOr10 = this.store.currentOrder) === null || _this$store$currentOr10 === void 0 ? void 0 : _this$store$currentOr10.total_amount,
1489
1626
  isOrderSynced: this.store.isOrderSynced,
1490
1627
  isVirtualOrderId: this.store.currentOrder ? isVirtualOrderId(this.store.currentOrder.order_id) : false
1491
1628
  });
1492
- _context19.prev = 1;
1629
+ _context20.prev = 1;
1493
1630
  if (this.store.currentOrder) {
1494
- _context19.next = 4;
1631
+ _context20.next = 4;
1495
1632
  break;
1496
1633
  }
1497
- return _context19.abrupt("return", {
1634
+ return _context20.abrupt("return", {
1498
1635
  success: false,
1499
1636
  message: '当前没有活跃订单,无法同步'
1500
1637
  });
@@ -1504,25 +1641,25 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1504
1641
  if (this.store.isOrderSynced) {
1505
1642
  this.logInfo('订单已同步过,将执行更新操作');
1506
1643
  }
1507
- _context19.t0 = this;
1508
- _context19.t1 = orderUuid;
1509
- _context19.t2 = oldOrderId;
1510
- _context19.t3 = this.store.currentOrder.total_amount;
1511
- _context19.next = 13;
1644
+ _context20.t0 = this;
1645
+ _context20.t1 = orderUuid;
1646
+ _context20.t2 = oldOrderId;
1647
+ _context20.t3 = this.store.currentOrder.total_amount;
1648
+ _context20.next = 13;
1512
1649
  return this.calculateRemainingAmountAsync();
1513
1650
  case 13:
1514
- _context19.t4 = _context19.sent;
1515
- _context19.t5 = {
1516
- orderUuid: _context19.t1,
1517
- orderId: _context19.t2,
1518
- totalAmount: _context19.t3,
1519
- remainingAmount: _context19.t4
1651
+ _context20.t4 = _context20.sent;
1652
+ _context20.t5 = {
1653
+ orderUuid: _context20.t1,
1654
+ orderId: _context20.t2,
1655
+ totalAmount: _context20.t3,
1656
+ remainingAmount: _context20.t4
1520
1657
  };
1521
- _context19.t0.logInfo.call(_context19.t0, '开始手动同步订单到后端:', _context19.t5);
1522
- _context19.next = 18;
1658
+ _context20.t0.logInfo.call(_context20.t0, '开始手动同步订单到后端:', _context20.t5);
1659
+ _context20.next = 18;
1523
1660
  return this.syncOrderToBackendWithReturn(true);
1524
1661
  case 18:
1525
- syncResult = _context19.sent;
1662
+ syncResult = _context20.sent;
1526
1663
  this.logInfo('手动同步订单完成:', {
1527
1664
  orderUuid: orderUuid,
1528
1665
  syncResult: syncResult,
@@ -1540,22 +1677,22 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1540
1677
  if (syncResult.orderId !== finalOrderId) {
1541
1678
  this.logError('[Checkout] 严重警告:返回的订单ID与存储的订单ID不一致!');
1542
1679
  }
1543
- return _context19.abrupt("return", syncResult);
1680
+ return _context20.abrupt("return", syncResult);
1544
1681
  case 27:
1545
- _context19.prev = 27;
1546
- _context19.t6 = _context19["catch"](1);
1547
- this.logError('手动同步订单失败:', _context19.t6);
1548
- errorMessage = _context19.t6 instanceof Error ? _context19.t6.message : '同步失败';
1549
- return _context19.abrupt("return", {
1682
+ _context20.prev = 27;
1683
+ _context20.t6 = _context20["catch"](1);
1684
+ this.logError('手动同步订单失败:', _context20.t6);
1685
+ errorMessage = _context20.t6 instanceof Error ? _context20.t6.message : '同步失败';
1686
+ return _context20.abrupt("return", {
1550
1687
  success: false,
1551
1688
  message: "\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(errorMessage),
1552
- orderUuid: (_this$store$currentOr9 = this.store.currentOrder) === null || _this$store$currentOr9 === void 0 ? void 0 : _this$store$currentOr9.uuid
1689
+ orderUuid: (_this$store$currentOr11 = this.store.currentOrder) === null || _this$store$currentOr11 === void 0 ? void 0 : _this$store$currentOr11.uuid
1553
1690
  });
1554
1691
  case 32:
1555
1692
  case "end":
1556
- return _context19.stop();
1693
+ return _context20.stop();
1557
1694
  }
1558
- }, _callee19, this, [[1, 27]]);
1695
+ }, _callee20, this, [[1, 27]]);
1559
1696
  }));
1560
1697
  function manualSyncOrderAsync() {
1561
1698
  return _manualSyncOrderAsync.apply(this, arguments);
@@ -1625,27 +1762,27 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1625
1762
  }, {
1626
1763
  key: "cancelCurrentOrderAsync",
1627
1764
  value: (function () {
1628
- var _cancelCurrentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(cancelReason) {
1629
- var _this$store$currentOr10, _this$store$currentOr11, currentOrderUuid, currentOrderId, isOrderSynced, errorMessage;
1630
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1631
- while (1) switch (_context20.prev = _context20.next) {
1765
+ var _cancelCurrentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(cancelReason) {
1766
+ var _this$store$currentOr12, _this$store$currentOr13, currentOrderUuid, currentOrderId, isOrderSynced, errorMessage;
1767
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1768
+ while (1) switch (_context21.prev = _context21.next) {
1632
1769
  case 0:
1633
- _context20.prev = 0;
1770
+ _context21.prev = 0;
1634
1771
  this.logInfo('开始取消当前本地订单:', {
1635
1772
  hasCurrentOrder: !!this.store.currentOrder,
1636
- orderUuid: (_this$store$currentOr10 = this.store.currentOrder) === null || _this$store$currentOr10 === void 0 ? void 0 : _this$store$currentOr10.uuid,
1637
- orderId: (_this$store$currentOr11 = this.store.currentOrder) === null || _this$store$currentOr11 === void 0 ? void 0 : _this$store$currentOr11.order_id,
1773
+ orderUuid: (_this$store$currentOr12 = this.store.currentOrder) === null || _this$store$currentOr12 === void 0 ? void 0 : _this$store$currentOr12.uuid,
1774
+ orderId: (_this$store$currentOr13 = this.store.currentOrder) === null || _this$store$currentOr13 === void 0 ? void 0 : _this$store$currentOr13.order_id,
1638
1775
  isOrderSynced: this.store.isOrderSynced,
1639
1776
  cancelReason: cancelReason
1640
1777
  });
1641
1778
 
1642
1779
  // 检查是否有当前订单
1643
1780
  if (this.store.currentOrder) {
1644
- _context20.next = 5;
1781
+ _context21.next = 5;
1645
1782
  break;
1646
1783
  }
1647
1784
  this.logInfo('没有当前订单,无需取消');
1648
- return _context20.abrupt("return", {
1785
+ return _context21.abrupt("return", {
1649
1786
  success: false,
1650
1787
  message: '没有当前订单可取消'
1651
1788
  });
@@ -1654,31 +1791,31 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1654
1791
  currentOrderId = this.store.currentOrder.order_id;
1655
1792
  isOrderSynced = this.store.isOrderSynced; // 检查订单是否已同步,已同步的订单不能取消
1656
1793
  if (!isOrderSynced) {
1657
- _context20.next = 11;
1794
+ _context21.next = 11;
1658
1795
  break;
1659
1796
  }
1660
1797
  this.logInfo('订单已同步到后端,不能取消:', {
1661
1798
  orderId: currentOrderId,
1662
1799
  orderUuid: currentOrderUuid
1663
1800
  });
1664
- return _context20.abrupt("return", {
1801
+ return _context21.abrupt("return", {
1665
1802
  success: false,
1666
1803
  message: '订单已同步到后端,无法取消',
1667
1804
  orderId: currentOrderId
1668
1805
  });
1669
1806
  case 11:
1670
- _context20.prev = 11;
1807
+ _context21.prev = 11;
1671
1808
  this.logInfo('删除本地订单数据');
1672
- _context20.next = 15;
1809
+ _context21.next = 15;
1673
1810
  return this.payment.deletePaymentOrderAsync(currentOrderUuid);
1674
1811
  case 15:
1675
1812
  this.logInfo('本地订单数据删除成功');
1676
- _context20.next = 21;
1813
+ _context21.next = 21;
1677
1814
  break;
1678
1815
  case 18:
1679
- _context20.prev = 18;
1680
- _context20.t0 = _context20["catch"](11);
1681
- this.logWarning('删除本地订单数据失败,但继续执行:', _context20.t0);
1816
+ _context21.prev = 18;
1817
+ _context21.t0 = _context21["catch"](11);
1818
+ this.logWarning('删除本地订单数据失败,但继续执行:', _context21.t0);
1682
1819
  case 21:
1683
1820
  // 清理订单相关状态,确保正确释放 currentOrder
1684
1821
  this.logInfo('清理订单相关状态');
@@ -1694,7 +1831,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1694
1831
  this.logInfo('订单状态清理完成,currentOrder已释放');
1695
1832
 
1696
1833
  // 触发订单取消事件
1697
- _context20.next = 32;
1834
+ _context21.next = 32;
1698
1835
  return this.core.effects.emit(CheckoutHooks.OnOrderCancelled, {
1699
1836
  orderUuid: currentOrderUuid,
1700
1837
  orderId: currentOrderId,
@@ -1709,27 +1846,27 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1709
1846
  orderId: currentOrderId,
1710
1847
  cancelReason: cancelReason
1711
1848
  });
1712
- return _context20.abrupt("return", {
1849
+ return _context21.abrupt("return", {
1713
1850
  success: true,
1714
1851
  message: '本地订单已成功取消',
1715
1852
  orderId: currentOrderId
1716
1853
  });
1717
1854
  case 36:
1718
- _context20.prev = 36;
1719
- _context20.t1 = _context20["catch"](0);
1720
- this.logError('取消本地订单失败:', _context20.t1);
1721
- errorMessage = _context20.t1 instanceof Error ? _context20.t1.message : '未知错误';
1722
- return _context20.abrupt("return", {
1855
+ _context21.prev = 36;
1856
+ _context21.t1 = _context21["catch"](0);
1857
+ this.logError('取消本地订单失败:', _context21.t1);
1858
+ errorMessage = _context21.t1 instanceof Error ? _context21.t1.message : '未知错误';
1859
+ return _context21.abrupt("return", {
1723
1860
  success: false,
1724
1861
  message: "\u53D6\u6D88\u8BA2\u5355\u5931\u8D25: ".concat(errorMessage)
1725
1862
  });
1726
1863
  case 41:
1727
1864
  case "end":
1728
- return _context20.stop();
1865
+ return _context21.stop();
1729
1866
  }
1730
- }, _callee20, this, [[0, 36], [11, 18]]);
1867
+ }, _callee21, this, [[0, 36], [11, 18]]);
1731
1868
  }));
1732
- function cancelCurrentOrderAsync(_x18) {
1869
+ function cancelCurrentOrderAsync(_x19) {
1733
1870
  return _cancelCurrentOrderAsync.apply(this, arguments);
1734
1871
  }
1735
1872
  return cancelCurrentOrderAsync;
@@ -1744,17 +1881,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1744
1881
  }, {
1745
1882
  key: "saveForLaterPaymentAsync",
1746
1883
  value: (function () {
1747
- var _saveForLaterPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
1748
- var orderUuid, currentOrderId, allPaymentItems, syncResult, _this$store$currentOr12, errorMessage;
1749
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1750
- while (1) switch (_context21.prev = _context21.next) {
1884
+ var _saveForLaterPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
1885
+ var orderUuid, currentOrderId, allPaymentItems, syncResult, _this$store$currentOr14, errorMessage;
1886
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1887
+ while (1) switch (_context22.prev = _context22.next) {
1751
1888
  case 0:
1752
- _context21.prev = 0;
1889
+ _context22.prev = 0;
1753
1890
  if (this.store.currentOrder) {
1754
- _context21.next = 3;
1891
+ _context22.next = 3;
1755
1892
  break;
1756
1893
  }
1757
- return _context21.abrupt("return", {
1894
+ return _context22.abrupt("return", {
1758
1895
  success: false,
1759
1896
  message: '当前没有活跃订单,无法保存'
1760
1897
  });
@@ -1768,14 +1905,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1768
1905
  });
1769
1906
 
1770
1907
  // 获取当前订单的所有支付项
1771
- _context21.next = 8;
1908
+ _context22.next = 8;
1772
1909
  return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid);
1773
1910
  case 8:
1774
- allPaymentItems = _context21.sent;
1775
- _context21.next = 11;
1911
+ allPaymentItems = _context22.sent;
1912
+ _context22.next = 11;
1776
1913
  return this.syncOrderToBackendWithReturn(true, allPaymentItems);
1777
1914
  case 11:
1778
- syncResult = _context21.sent;
1915
+ syncResult = _context22.sent;
1779
1916
  this.logInfo('保存订单完成:', {
1780
1917
  orderUuid: orderUuid,
1781
1918
  oldOrderId: currentOrderId,
@@ -1784,7 +1921,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1784
1921
  isOrderSynced: this.store.isOrderSynced,
1785
1922
  filteredPaymentsCount: allPaymentItems.length
1786
1923
  });
1787
- return _context21.abrupt("return", {
1924
+ return _context22.abrupt("return", {
1788
1925
  success: true,
1789
1926
  message: '订单保存成功,可稍后继续支付',
1790
1927
  orderId: syncResult.orderId,
@@ -1792,20 +1929,20 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1792
1929
  response: syncResult.response
1793
1930
  });
1794
1931
  case 16:
1795
- _context21.prev = 16;
1796
- _context21.t0 = _context21["catch"](0);
1797
- this.logError('保存订单失败:', _context21.t0);
1798
- errorMessage = _context21.t0 instanceof Error ? _context21.t0.message : '保存失败';
1799
- return _context21.abrupt("return", {
1932
+ _context22.prev = 16;
1933
+ _context22.t0 = _context22["catch"](0);
1934
+ this.logError('保存订单失败:', _context22.t0);
1935
+ errorMessage = _context22.t0 instanceof Error ? _context22.t0.message : '保存失败';
1936
+ return _context22.abrupt("return", {
1800
1937
  success: false,
1801
1938
  message: "\u8BA2\u5355\u4FDD\u5B58\u5931\u8D25: ".concat(errorMessage),
1802
- orderUuid: (_this$store$currentOr12 = this.store.currentOrder) === null || _this$store$currentOr12 === void 0 ? void 0 : _this$store$currentOr12.uuid
1939
+ orderUuid: (_this$store$currentOr14 = this.store.currentOrder) === null || _this$store$currentOr14 === void 0 ? void 0 : _this$store$currentOr14.uuid
1803
1940
  });
1804
1941
  case 21:
1805
1942
  case "end":
1806
- return _context21.stop();
1943
+ return _context22.stop();
1807
1944
  }
1808
- }, _callee21, this, [[0, 16]]);
1945
+ }, _callee22, this, [[0, 16]]);
1809
1946
  }));
1810
1947
  function saveForLaterPaymentAsync() {
1811
1948
  return _saveForLaterPaymentAsync.apply(this, arguments);
@@ -1821,20 +1958,20 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1821
1958
  }, {
1822
1959
  key: "updateOrderNoteAsync",
1823
1960
  value: (function () {
1824
- var _updateOrderNoteAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(note) {
1825
- var _this$store$currentOr13, _this$store$currentOr14, oldNote, orderInPayment;
1826
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1827
- while (1) switch (_context22.prev = _context22.next) {
1961
+ var _updateOrderNoteAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(note) {
1962
+ var _this$store$currentOr15, _this$store$currentOr16, oldNote, orderInPayment;
1963
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1964
+ while (1) switch (_context23.prev = _context23.next) {
1828
1965
  case 0:
1829
- _context22.prev = 0;
1966
+ _context23.prev = 0;
1830
1967
  if (this.store.localOrderData) {
1831
- _context22.next = 3;
1968
+ _context23.next = 3;
1832
1969
  break;
1833
1970
  }
1834
1971
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, '没有本地订单数据,无法更新备注');
1835
1972
  case 3:
1836
1973
  console.log('[Checkout] 更新订单备注:', {
1837
- orderUuid: (_this$store$currentOr13 = this.store.currentOrder) === null || _this$store$currentOr13 === void 0 ? void 0 : _this$store$currentOr13.uuid,
1974
+ orderUuid: (_this$store$currentOr15 = this.store.currentOrder) === null || _this$store$currentOr15 === void 0 ? void 0 : _this$store$currentOr15.uuid,
1838
1975
  oldNote: this.store.localOrderData.shop_note,
1839
1976
  newNote: note
1840
1977
  });
@@ -1845,29 +1982,29 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1845
1982
 
1846
1983
  // 如果有当前订单,也同步到Payment模块中的订单数据
1847
1984
  if (!this.store.currentOrder) {
1848
- _context22.next = 17;
1985
+ _context23.next = 17;
1849
1986
  break;
1850
1987
  }
1851
- _context22.prev = 7;
1852
- _context22.next = 10;
1988
+ _context23.prev = 7;
1989
+ _context23.next = 10;
1853
1990
  return this.payment.getPaymentOrderByUuidAsync(this.store.currentOrder.uuid);
1854
1991
  case 10:
1855
- orderInPayment = _context22.sent;
1992
+ orderInPayment = _context23.sent;
1856
1993
  if (orderInPayment && orderInPayment.note !== undefined) {
1857
1994
  // 使用Payment模块的更新方法(如果有的话)
1858
1995
  // 这里可能需要根据Payment模块的实际API来调整
1859
1996
  console.log('[Checkout] 同步备注到Payment模块的订单数据中');
1860
1997
  }
1861
- _context22.next = 17;
1998
+ _context23.next = 17;
1862
1999
  break;
1863
2000
  case 14:
1864
- _context22.prev = 14;
1865
- _context22.t0 = _context22["catch"](7);
1866
- console.warn('[Checkout] 同步备注到Payment模块失败,但本地更新成功:', _context22.t0);
2001
+ _context23.prev = 14;
2002
+ _context23.t0 = _context23["catch"](7);
2003
+ console.warn('[Checkout] 同步备注到Payment模块失败,但本地更新成功:', _context23.t0);
1867
2004
  case 17:
1868
- _context22.next = 19;
2005
+ _context23.next = 19;
1869
2006
  return this.core.effects.emit(CheckoutHooks.OnOrderNoteChanged, {
1870
- orderUuid: (_this$store$currentOr14 = this.store.currentOrder) === null || _this$store$currentOr14 === void 0 ? void 0 : _this$store$currentOr14.uuid,
2007
+ orderUuid: (_this$store$currentOr16 = this.store.currentOrder) === null || _this$store$currentOr16 === void 0 ? void 0 : _this$store$currentOr16.uuid,
1871
2008
  oldNote: oldNote,
1872
2009
  newNote: note,
1873
2010
  timestamp: Date.now()
@@ -1877,23 +2014,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1877
2014
  oldNote: oldNote,
1878
2015
  newNote: note
1879
2016
  });
1880
- _context22.next = 28;
2017
+ _context23.next = 28;
1881
2018
  break;
1882
2019
  case 22:
1883
- _context22.prev = 22;
1884
- _context22.t1 = _context22["catch"](0);
1885
- console.error('[Checkout] 更新订单备注失败:', _context22.t1);
1886
- _context22.next = 27;
1887
- return this.handleError(_context22.t1, CheckoutErrorType.ValidationFailed);
2020
+ _context23.prev = 22;
2021
+ _context23.t1 = _context23["catch"](0);
2022
+ console.error('[Checkout] 更新订单备注失败:', _context23.t1);
2023
+ _context23.next = 27;
2024
+ return this.handleError(_context23.t1, CheckoutErrorType.ValidationFailed);
1888
2025
  case 27:
1889
- throw _context22.t1;
2026
+ throw _context23.t1;
1890
2027
  case 28:
1891
2028
  case "end":
1892
- return _context22.stop();
2029
+ return _context23.stop();
1893
2030
  }
1894
- }, _callee22, this, [[0, 22], [7, 14]]);
2031
+ }, _callee23, this, [[0, 22], [7, 14]]);
1895
2032
  }));
1896
- function updateOrderNoteAsync(_x19) {
2033
+ function updateOrderNoteAsync(_x20) {
1897
2034
  return _updateOrderNoteAsync.apply(this, arguments);
1898
2035
  }
1899
2036
  return updateOrderNoteAsync;
@@ -1905,14 +2042,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1905
2042
  }, {
1906
2043
  key: "handleError",
1907
2044
  value: (function () {
1908
- var _handleError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(error, type) {
2045
+ var _handleError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(error, type) {
1909
2046
  var checkoutError;
1910
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1911
- while (1) switch (_context23.prev = _context23.next) {
2047
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2048
+ while (1) switch (_context24.prev = _context24.next) {
1912
2049
  case 0:
1913
2050
  checkoutError = error instanceof Error && 'type' in error ? error : createCheckoutError(type, error.message, error);
1914
2051
  this.store.lastError = checkoutError;
1915
- _context23.next = 4;
2052
+ _context24.next = 4;
1916
2053
  return this.core.effects.emit(CheckoutHooks.OnError, {
1917
2054
  error: checkoutError,
1918
2055
  context: {},
@@ -1922,11 +2059,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1922
2059
  console.error('[Checkout] 错误:', checkoutError);
1923
2060
  case 5:
1924
2061
  case "end":
1925
- return _context23.stop();
2062
+ return _context24.stop();
1926
2063
  }
1927
- }, _callee23, this);
2064
+ }, _callee24, this);
1928
2065
  }));
1929
- function handleError(_x20, _x21) {
2066
+ function handleError(_x21, _x22) {
1930
2067
  return _handleError.apply(this, arguments);
1931
2068
  }
1932
2069
  return handleError;
@@ -1938,31 +2075,31 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1938
2075
  }, {
1939
2076
  key: "handlePaymentSuccess",
1940
2077
  value: (function () {
1941
- var _handlePaymentSuccess = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(data) {
1942
- var _this$store$currentOr15;
1943
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1944
- while (1) switch (_context24.prev = _context24.next) {
2078
+ var _handlePaymentSuccess = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(data) {
2079
+ var _this$store$currentOr17;
2080
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2081
+ while (1) switch (_context25.prev = _context25.next) {
1945
2082
  case 0:
1946
- _context24.next = 2;
2083
+ _context25.next = 2;
1947
2084
  return this.updateStateAmountToRemaining();
1948
2085
  case 2:
1949
- _context24.next = 4;
2086
+ _context25.next = 4;
1950
2087
  return this.core.effects.emit(CheckoutHooks.OnPaymentSuccess, {
1951
2088
  orderUuid: data.orderUuid,
1952
2089
  paymentMethodCode: '',
1953
- amount: ((_this$store$currentOr15 = this.store.currentOrder) === null || _this$store$currentOr15 === void 0 ? void 0 : _this$store$currentOr15.total_amount) || '0',
2090
+ amount: ((_this$store$currentOr17 = this.store.currentOrder) === null || _this$store$currentOr17 === void 0 ? void 0 : _this$store$currentOr17.total_amount) || '0',
1954
2091
  timestamp: data.timestamp
1955
2092
  });
1956
2093
  case 4:
1957
- _context24.next = 6;
2094
+ _context25.next = 6;
1958
2095
  return this.completeCheckoutAsync();
1959
2096
  case 6:
1960
2097
  case "end":
1961
- return _context24.stop();
2098
+ return _context25.stop();
1962
2099
  }
1963
- }, _callee24, this);
2100
+ }, _callee25, this);
1964
2101
  }));
1965
- function handlePaymentSuccess(_x22) {
2102
+ function handlePaymentSuccess(_x23) {
1966
2103
  return _handlePaymentSuccess.apply(this, arguments);
1967
2104
  }
1968
2105
  return handlePaymentSuccess;
@@ -1974,30 +2111,30 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1974
2111
  }, {
1975
2112
  key: "handlePaymentError",
1976
2113
  value: (function () {
1977
- var _handlePaymentError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(data) {
1978
- var _this$store$currentOr16;
2114
+ var _handlePaymentError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(data) {
2115
+ var _this$store$currentOr18;
1979
2116
  var error;
1980
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1981
- while (1) switch (_context25.prev = _context25.next) {
2117
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2118
+ while (1) switch (_context26.prev = _context26.next) {
1982
2119
  case 0:
1983
2120
  error = createCheckoutError(CheckoutErrorType.PaymentFailed, data.error || '支付同步失败');
1984
- _context25.next = 3;
2121
+ _context26.next = 3;
1985
2122
  return this.handleError(error instanceof Error ? error : new Error(String(error)), CheckoutErrorType.PaymentFailed);
1986
2123
  case 3:
1987
- _context25.next = 5;
2124
+ _context26.next = 5;
1988
2125
  return this.core.effects.emit(CheckoutHooks.OnPaymentFailed, {
1989
2126
  orderUuid: data.orderUuid,
1990
2127
  paymentMethodCode: '',
1991
- amount: ((_this$store$currentOr16 = this.store.currentOrder) === null || _this$store$currentOr16 === void 0 ? void 0 : _this$store$currentOr16.total_amount) || '0',
2128
+ amount: ((_this$store$currentOr18 = this.store.currentOrder) === null || _this$store$currentOr18 === void 0 ? void 0 : _this$store$currentOr18.total_amount) || '0',
1992
2129
  timestamp: data.timestamp
1993
2130
  });
1994
2131
  case 5:
1995
2132
  case "end":
1996
- return _context25.stop();
2133
+ return _context26.stop();
1997
2134
  }
1998
- }, _callee25, this);
2135
+ }, _callee26, this);
1999
2136
  }));
2000
- function handlePaymentError(_x23) {
2137
+ function handlePaymentError(_x24) {
2001
2138
  return _handlePaymentError.apply(this, arguments);
2002
2139
  }
2003
2140
  return handlePaymentError;
@@ -2021,43 +2158,43 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2021
2158
  }, {
2022
2159
  key: "processCashPaymentItem",
2023
2160
  value: (function () {
2024
- var _processCashPaymentItem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(paymentItem) {
2161
+ var _processCashPaymentItem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(paymentItem) {
2025
2162
  var cashPayment, remainingAmountStr, remainingAmount, cashAmount, changeAmount, processedPaymentItem;
2026
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2027
- while (1) switch (_context26.prev = _context26.next) {
2163
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2164
+ while (1) switch (_context27.prev = _context27.next) {
2028
2165
  case 0:
2029
2166
  // 检查是否是现金支付
2030
2167
  cashPayment = isCashPayment(paymentItem.code, paymentItem.type);
2031
2168
  if (cashPayment) {
2032
- _context26.next = 3;
2169
+ _context27.next = 3;
2033
2170
  break;
2034
2171
  }
2035
- return _context26.abrupt("return", paymentItem);
2172
+ return _context27.abrupt("return", paymentItem);
2036
2173
  case 3:
2037
- _context26.prev = 3;
2038
- _context26.next = 6;
2174
+ _context27.prev = 3;
2175
+ _context27.next = 6;
2039
2176
  return this.calculateRemainingAmountAsync();
2040
2177
  case 6:
2041
- remainingAmountStr = _context26.sent;
2178
+ remainingAmountStr = _context27.sent;
2042
2179
  remainingAmount = new Decimal(remainingAmountStr);
2043
2180
  cashAmount = new Decimal(String(paymentItem.amount)); // 如果现金金额小于等于剩余待付金额,无需找零
2044
2181
  if (!cashAmount.lte(remainingAmount)) {
2045
- _context26.next = 11;
2182
+ _context27.next = 11;
2046
2183
  break;
2047
2184
  }
2048
- return _context26.abrupt("return", paymentItem);
2185
+ return _context27.abrupt("return", paymentItem);
2049
2186
  case 11:
2050
2187
  // 使用 Decimal.js 安全计算找零金额
2051
2188
  changeAmount = cashAmount.sub(remainingAmount); // 如果还有 rounding_amount 的配置,要判断是否和 changeAmount 相等
2052
2189
  if (!(Number(paymentItem.rounding_amount) > 0)) {
2053
- _context26.next = 18;
2190
+ _context27.next = 18;
2054
2191
  break;
2055
2192
  }
2056
2193
  if (!(Number(paymentItem.rounding_amount) === changeAmount.toNumber())) {
2057
- _context26.next = 17;
2194
+ _context27.next = 17;
2058
2195
  break;
2059
2196
  }
2060
- return _context26.abrupt("return", paymentItem);
2197
+ return _context27.abrupt("return", paymentItem);
2061
2198
  case 17:
2062
2199
  // 如果不等于,则remainingAmount需要加上 rounding_amount,避免这里被改为未舍入金额
2063
2200
  remainingAmount = remainingAmount.add(new Decimal(paymentItem.rounding_amount || '0'));
@@ -2085,20 +2222,20 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2085
2222
  changeAmountPrecise: changeAmount.toString()
2086
2223
  }
2087
2224
  });
2088
- return _context26.abrupt("return", processedPaymentItem);
2225
+ return _context27.abrupt("return", processedPaymentItem);
2089
2226
  case 23:
2090
- _context26.prev = 23;
2091
- _context26.t0 = _context26["catch"](3);
2092
- this.logError('处理现金支付项时出错:', _context26.t0);
2227
+ _context27.prev = 23;
2228
+ _context27.t0 = _context27["catch"](3);
2229
+ this.logError('处理现金支付项时出错:', _context27.t0);
2093
2230
  // 出错时返回原始支付项,避免中断支付流程
2094
- return _context26.abrupt("return", paymentItem);
2231
+ return _context27.abrupt("return", paymentItem);
2095
2232
  case 27:
2096
2233
  case "end":
2097
- return _context26.stop();
2234
+ return _context27.stop();
2098
2235
  }
2099
- }, _callee26, this, [[3, 23]]);
2236
+ }, _callee27, this, [[3, 23]]);
2100
2237
  }));
2101
- function processCashPaymentItem(_x24) {
2238
+ function processCashPaymentItem(_x25) {
2102
2239
  return _processCashPaymentItem.apply(this, arguments);
2103
2240
  }
2104
2241
  return processCashPaymentItem;
@@ -2110,31 +2247,31 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2110
2247
  }, {
2111
2248
  key: "preloadPaymentMethods",
2112
2249
  value: (function () {
2113
- var _preloadPaymentMethods = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
2250
+ var _preloadPaymentMethods = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
2114
2251
  var methods;
2115
- return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2116
- while (1) switch (_context27.prev = _context27.next) {
2252
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2253
+ while (1) switch (_context28.prev = _context28.next) {
2117
2254
  case 0:
2118
- _context27.prev = 0;
2255
+ _context28.prev = 0;
2119
2256
  console.log('[Checkout] 预加载支付方式...');
2120
- _context27.next = 4;
2257
+ _context28.next = 4;
2121
2258
  return this.payment.getPayMethodListAsync();
2122
2259
  case 4:
2123
- methods = _context27.sent;
2260
+ methods = _context28.sent;
2124
2261
  this.store.paymentMethods = methods;
2125
2262
  console.log("[Checkout] \u9884\u52A0\u8F7D\u5B8C\u6210\uFF0C\u5171 ".concat(methods.length, " \u79CD\u652F\u4ED8\u65B9\u5F0F"));
2126
- _context27.next = 13;
2263
+ _context28.next = 13;
2127
2264
  break;
2128
2265
  case 9:
2129
- _context27.prev = 9;
2130
- _context27.t0 = _context27["catch"](0);
2131
- console.error('[Checkout] 预加载支付方式失败:', _context27.t0);
2266
+ _context28.prev = 9;
2267
+ _context28.t0 = _context28["catch"](0);
2268
+ console.error('[Checkout] 预加载支付方式失败:', _context28.t0);
2132
2269
  this.store.paymentMethods = [];
2133
2270
  case 13:
2134
2271
  case "end":
2135
- return _context27.stop();
2272
+ return _context28.stop();
2136
2273
  }
2137
- }, _callee27, this, [[0, 9]]);
2274
+ }, _callee28, this, [[0, 9]]);
2138
2275
  }));
2139
2276
  function preloadPaymentMethods() {
2140
2277
  return _preloadPaymentMethods.apply(this, arguments);
@@ -2150,59 +2287,59 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2150
2287
  }, {
2151
2288
  key: "cleanupExpiredOrdersAsync",
2152
2289
  value: (function () {
2153
- var _cleanupExpiredOrdersAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
2290
+ var _cleanupExpiredOrdersAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
2154
2291
  var cleanupConfig, isCleanupEnabled, retentionDays, maxOrdersToDelete, allOrders, thresholdDate, deletedCount, ordersToDelete, _iterator, _step, order, _order$order_info, _order$order_info2, isSynced, orderCreatedAt, actualOrdersToDelete, _iterator2, _step2, orderInfo, summary, errorMessage;
2155
- return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2156
- while (1) switch (_context28.prev = _context28.next) {
2292
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2293
+ while (1) switch (_context29.prev = _context29.next) {
2157
2294
  case 0:
2158
- _context28.prev = 0;
2295
+ _context29.prev = 0;
2159
2296
  // 检查是否启用了清理功能
2160
2297
  cleanupConfig = this.otherParams.orderDataCleanup || {};
2161
2298
  isCleanupEnabled = cleanupConfig.enabled !== false; // 默认启用
2162
2299
  retentionDays = cleanupConfig.retentionDays || 7; // 默认保留7天
2163
2300
  maxOrdersToDelete = cleanupConfig.maxOrdersToDelete || 100; // 默认最多删除100个订单
2164
2301
  if (isCleanupEnabled) {
2165
- _context28.next = 8;
2302
+ _context29.next = 8;
2166
2303
  break;
2167
2304
  }
2168
2305
  console.log('[Checkout] 订单数据清理功能已禁用');
2169
- return _context28.abrupt("return");
2306
+ return _context29.abrupt("return");
2170
2307
  case 8:
2171
2308
  console.log("[Checkout] \u5F00\u59CB\u6E05\u7406\u8FC7\u671F\u8BA2\u5355\u6570\u636E\uFF08\u4FDD\u7559 ".concat(retentionDays, " \u5929\u5185\u7684\u6570\u636E\uFF09..."));
2172
2309
 
2173
2310
  // 获取所有订单
2174
- _context28.next = 11;
2311
+ _context29.next = 11;
2175
2312
  return this.payment.getOrderListAsync();
2176
2313
  case 11:
2177
- allOrders = _context28.sent;
2314
+ allOrders = _context29.sent;
2178
2315
  if (!(!allOrders || allOrders.length === 0)) {
2179
- _context28.next = 15;
2316
+ _context29.next = 15;
2180
2317
  break;
2181
2318
  }
2182
2319
  console.log('[Checkout] 没有找到需要清理的订单数据');
2183
- return _context28.abrupt("return");
2320
+ return _context29.abrupt("return");
2184
2321
  case 15:
2185
2322
  thresholdDate = new Date();
2186
2323
  thresholdDate.setDate(thresholdDate.getDate() - retentionDays);
2187
2324
  deletedCount = 0;
2188
2325
  ordersToDelete = [];
2189
2326
  _iterator = _createForOfIteratorHelper(allOrders);
2190
- _context28.prev = 20;
2327
+ _context29.prev = 20;
2191
2328
  _iterator.s();
2192
2329
  case 22:
2193
2330
  if ((_step = _iterator.n()).done) {
2194
- _context28.next = 41;
2331
+ _context29.next = 41;
2195
2332
  break;
2196
2333
  }
2197
2334
  order = _step.value;
2198
- _context28.prev = 24;
2335
+ _context29.prev = 24;
2199
2336
  // 检查订单是否已同步(订单ID不是虚拟ID)
2200
2337
  isSynced = order.order_id && !isVirtualOrderId(order.order_id);
2201
2338
  if (isSynced) {
2202
- _context28.next = 28;
2339
+ _context29.next = 28;
2203
2340
  break;
2204
2341
  }
2205
- return _context28.abrupt("continue", 39);
2342
+ return _context29.abrupt("continue", 39);
2206
2343
  case 28:
2207
2344
  // 检查创建时间
2208
2345
  orderCreatedAt = null; // 尝试从 order_info.created_at 获取创建时间
@@ -2216,10 +2353,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2216
2353
 
2217
2354
  // 如果无法获取创建时间,跳过此订单
2218
2355
  if (!(!orderCreatedAt || isNaN(orderCreatedAt.getTime()))) {
2219
- _context28.next = 32;
2356
+ _context29.next = 32;
2220
2357
  break;
2221
2358
  }
2222
- return _context28.abrupt("continue", 39);
2359
+ return _context29.abrupt("continue", 39);
2223
2360
  case 32:
2224
2361
  // 检查是否超过指定天数
2225
2362
  if (orderCreatedAt < thresholdDate) {
@@ -2230,27 +2367,27 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2230
2367
  daysSinceCreated: Math.floor((Date.now() - orderCreatedAt.getTime()) / (1000 * 60 * 60 * 24))
2231
2368
  });
2232
2369
  }
2233
- _context28.next = 39;
2370
+ _context29.next = 39;
2234
2371
  break;
2235
2372
  case 35:
2236
- _context28.prev = 35;
2237
- _context28.t0 = _context28["catch"](24);
2238
- console.warn("[Checkout] \u5904\u7406\u8BA2\u5355 ".concat(order.uuid, " \u65F6\u51FA\u9519:"), _context28.t0);
2239
- return _context28.abrupt("continue", 39);
2373
+ _context29.prev = 35;
2374
+ _context29.t0 = _context29["catch"](24);
2375
+ console.warn("[Checkout] \u5904\u7406\u8BA2\u5355 ".concat(order.uuid, " \u65F6\u51FA\u9519:"), _context29.t0);
2376
+ return _context29.abrupt("continue", 39);
2240
2377
  case 39:
2241
- _context28.next = 22;
2378
+ _context29.next = 22;
2242
2379
  break;
2243
2380
  case 41:
2244
- _context28.next = 46;
2381
+ _context29.next = 46;
2245
2382
  break;
2246
2383
  case 43:
2247
- _context28.prev = 43;
2248
- _context28.t1 = _context28["catch"](20);
2249
- _iterator.e(_context28.t1);
2384
+ _context29.prev = 43;
2385
+ _context29.t1 = _context29["catch"](20);
2386
+ _iterator.e(_context29.t1);
2250
2387
  case 46:
2251
- _context28.prev = 46;
2388
+ _context29.prev = 46;
2252
2389
  _iterator.f();
2253
- return _context28.finish(46);
2390
+ return _context29.finish(46);
2254
2391
  case 49:
2255
2392
  // 按创建时间排序(最老的先删除)并限制删除数量
2256
2393
  ordersToDelete.sort(function (a, b) {
@@ -2258,40 +2395,40 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2258
2395
  });
2259
2396
  actualOrdersToDelete = ordersToDelete.slice(0, maxOrdersToDelete); // 删除符合条件的订单
2260
2397
  _iterator2 = _createForOfIteratorHelper(actualOrdersToDelete);
2261
- _context28.prev = 52;
2398
+ _context29.prev = 52;
2262
2399
  _iterator2.s();
2263
2400
  case 54:
2264
2401
  if ((_step2 = _iterator2.n()).done) {
2265
- _context28.next = 68;
2402
+ _context29.next = 68;
2266
2403
  break;
2267
2404
  }
2268
2405
  orderInfo = _step2.value;
2269
- _context28.prev = 56;
2270
- _context28.next = 59;
2406
+ _context29.prev = 56;
2407
+ _context29.next = 59;
2271
2408
  return this.payment.deletePaymentOrderAsync(orderInfo.uuid);
2272
2409
  case 59:
2273
2410
  deletedCount++;
2274
2411
  console.log("[Checkout] \u5DF2\u5220\u9664\u8FC7\u671F\u8BA2\u5355: ".concat(orderInfo.orderId, " (").concat(orderInfo.daysSinceCreated, " \u5929\u524D\u521B\u5EFA)"));
2275
- _context28.next = 66;
2412
+ _context29.next = 66;
2276
2413
  break;
2277
2414
  case 63:
2278
- _context28.prev = 63;
2279
- _context28.t2 = _context28["catch"](56);
2280
- console.error("[Checkout] \u5220\u9664\u8BA2\u5355 ".concat(orderInfo.uuid, " \u5931\u8D25:"), _context28.t2);
2415
+ _context29.prev = 63;
2416
+ _context29.t2 = _context29["catch"](56);
2417
+ console.error("[Checkout] \u5220\u9664\u8BA2\u5355 ".concat(orderInfo.uuid, " \u5931\u8D25:"), _context29.t2);
2281
2418
  case 66:
2282
- _context28.next = 54;
2419
+ _context29.next = 54;
2283
2420
  break;
2284
2421
  case 68:
2285
- _context28.next = 73;
2422
+ _context29.next = 73;
2286
2423
  break;
2287
2424
  case 70:
2288
- _context28.prev = 70;
2289
- _context28.t3 = _context28["catch"](52);
2290
- _iterator2.e(_context28.t3);
2425
+ _context29.prev = 70;
2426
+ _context29.t3 = _context29["catch"](52);
2427
+ _iterator2.e(_context29.t3);
2291
2428
  case 73:
2292
- _context28.prev = 73;
2429
+ _context29.prev = 73;
2293
2430
  _iterator2.f();
2294
- return _context28.finish(73);
2431
+ return _context29.finish(73);
2295
2432
  case 76:
2296
2433
  summary = {
2297
2434
  totalOrders: allOrders.length,
@@ -2309,21 +2446,21 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2309
2446
  } else {
2310
2447
  console.log("[Checkout] \u8FC7\u671F\u8BA2\u5355\u6E05\u7406\u5B8C\u6210: \u603B\u8BA1 ".concat(allOrders.length, " \u4E2A\u8BA2\u5355\uFF0C\u5220\u9664\u4E86 ").concat(deletedCount, " \u4E2A\u8FC7\u671F\u5DF2\u540C\u6B65\u8BA2\u5355"));
2311
2448
  }
2312
- _context28.next = 86;
2449
+ _context29.next = 86;
2313
2450
  break;
2314
2451
  case 81:
2315
- _context28.prev = 81;
2316
- _context28.t4 = _context28["catch"](0);
2317
- errorMessage = _context28.t4 instanceof Error ? _context28.t4.message : String(_context28.t4);
2318
- console.error('[Checkout] 清理过期订单数据失败:', _context28.t4);
2452
+ _context29.prev = 81;
2453
+ _context29.t4 = _context29["catch"](0);
2454
+ errorMessage = _context29.t4 instanceof Error ? _context29.t4.message : String(_context29.t4);
2455
+ console.error('[Checkout] 清理过期订单数据失败:', _context29.t4);
2319
2456
  this.logError('Expired orders cleanup failed', {
2320
2457
  error: errorMessage
2321
2458
  });
2322
2459
  case 86:
2323
2460
  case "end":
2324
- return _context28.stop();
2461
+ return _context29.stop();
2325
2462
  }
2326
- }, _callee28, this, [[0, 81], [20, 43, 46, 49], [24, 35], [52, 70, 73, 76], [56, 63]]);
2463
+ }, _callee29, this, [[0, 81], [20, 43, 46, 49], [24, 35], [52, 70, 73, 76], [56, 63]]);
2327
2464
  }));
2328
2465
  function cleanupExpiredOrdersAsync() {
2329
2466
  return _cleanupExpiredOrdersAsync.apply(this, arguments);
@@ -2337,24 +2474,24 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2337
2474
  }, {
2338
2475
  key: "calculatePaidAmountAsync",
2339
2476
  value: (function () {
2340
- var _calculatePaidAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
2477
+ var _calculatePaidAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
2341
2478
  var payments, paidAmount, result;
2342
- return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2343
- while (1) switch (_context29.prev = _context29.next) {
2479
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2480
+ while (1) switch (_context30.prev = _context30.next) {
2344
2481
  case 0:
2345
2482
  if (this.store.currentOrder) {
2346
- _context29.next = 3;
2483
+ _context30.next = 3;
2347
2484
  break;
2348
2485
  }
2349
2486
  this.logWarning('[Checkout] calculatePaidAmountAsync: 没有当前订单');
2350
- return _context29.abrupt("return", '0.00');
2487
+ return _context30.abrupt("return", '0.00');
2351
2488
  case 3:
2352
- _context29.prev = 3;
2353
- _context29.next = 6;
2489
+ _context30.prev = 3;
2490
+ _context30.next = 6;
2354
2491
  return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid, false // 不包括已撤销的支付项
2355
2492
  );
2356
2493
  case 6:
2357
- payments = _context29.sent;
2494
+ payments = _context30.sent;
2358
2495
  // 使用 Decimal.js 进行安全的金额计算
2359
2496
  paidAmount = payments.filter(function (payment) {
2360
2497
  return payment.status !== 'voided';
@@ -2383,17 +2520,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2383
2520
  }, new Decimal(0));
2384
2521
  result = paidAmount.toFixed(2);
2385
2522
  this.logInfo('calculatePaidAmountAsync: 计算结果 =', result);
2386
- return _context29.abrupt("return", result);
2523
+ return _context30.abrupt("return", result);
2387
2524
  case 13:
2388
- _context29.prev = 13;
2389
- _context29.t0 = _context29["catch"](3);
2390
- this.logError('calculatePaidAmountAsync 失败:', _context29.t0);
2391
- return _context29.abrupt("return", '0.00');
2525
+ _context30.prev = 13;
2526
+ _context30.t0 = _context30["catch"](3);
2527
+ this.logError('calculatePaidAmountAsync 失败:', _context30.t0);
2528
+ return _context30.abrupt("return", '0.00');
2392
2529
  case 17:
2393
2530
  case "end":
2394
- return _context29.stop();
2531
+ return _context30.stop();
2395
2532
  }
2396
- }, _callee29, this, [[3, 13]]);
2533
+ }, _callee30, this, [[3, 13]]);
2397
2534
  }));
2398
2535
  function calculatePaidAmountAsync() {
2399
2536
  return _calculatePaidAmountAsync.apply(this, arguments);
@@ -2407,34 +2544,34 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2407
2544
  }, {
2408
2545
  key: "calculateRemainingAmountAsync",
2409
2546
  value: (function () {
2410
- var _calculateRemainingAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
2547
+ var _calculateRemainingAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
2411
2548
  var totalAmount, paidAmountStr, paidAmount, remainingAmount, result;
2412
- return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2413
- while (1) switch (_context30.prev = _context30.next) {
2549
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2550
+ while (1) switch (_context31.prev = _context31.next) {
2414
2551
  case 0:
2415
2552
  if (this.store.currentOrder) {
2416
- _context30.next = 3;
2553
+ _context31.next = 3;
2417
2554
  break;
2418
2555
  }
2419
2556
  this.logWarning('calculateRemainingAmountAsync: 没有当前订单');
2420
- return _context30.abrupt("return", '0.00');
2557
+ return _context31.abrupt("return", '0.00');
2421
2558
  case 3:
2422
2559
  // 使用 Decimal.js 进行安全的金额计算
2423
2560
  totalAmount = new Decimal(this.store.currentOrder.total_amount || '0');
2424
- _context30.next = 6;
2561
+ _context31.next = 6;
2425
2562
  return this.calculatePaidAmountAsync();
2426
2563
  case 6:
2427
- paidAmountStr = _context30.sent;
2564
+ paidAmountStr = _context31.sent;
2428
2565
  paidAmount = new Decimal(paidAmountStr);
2429
2566
  remainingAmount = totalAmount.sub(paidAmount); // 确保剩余金额不为负数
2430
2567
  result = Decimal.max(0, remainingAmount).toFixed(2);
2431
2568
  this.logInfo('calculateRemainingAmountAsync: 计算=', result);
2432
- return _context30.abrupt("return", result);
2569
+ return _context31.abrupt("return", result);
2433
2570
  case 12:
2434
2571
  case "end":
2435
- return _context30.stop();
2572
+ return _context31.stop();
2436
2573
  }
2437
- }, _callee30, this);
2574
+ }, _callee31, this);
2438
2575
  }));
2439
2576
  function calculateRemainingAmountAsync() {
2440
2577
  return _calculateRemainingAmountAsync.apply(this, arguments);
@@ -2448,25 +2585,25 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2448
2585
  }, {
2449
2586
  key: "updateBalanceDueAmount",
2450
2587
  value: (function () {
2451
- var _updateBalanceDueAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
2588
+ var _updateBalanceDueAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
2452
2589
  var remainingAmount, currentBalanceDueAmount;
2453
- return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2454
- while (1) switch (_context31.prev = _context31.next) {
2590
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2591
+ while (1) switch (_context32.prev = _context32.next) {
2455
2592
  case 0:
2456
- _context31.prev = 0;
2457
- _context31.next = 3;
2593
+ _context32.prev = 0;
2594
+ _context32.next = 3;
2458
2595
  return this.calculateRemainingAmountAsync();
2459
2596
  case 3:
2460
- remainingAmount = _context31.sent;
2597
+ remainingAmount = _context32.sent;
2461
2598
  currentBalanceDueAmount = this.store.balanceDueAmount; // 只有当剩余金额与当前 balanceDueAmount 不同时才更新
2462
2599
  if (!(remainingAmount !== currentBalanceDueAmount)) {
2463
- _context31.next = 12;
2600
+ _context32.next = 12;
2464
2601
  break;
2465
2602
  }
2466
2603
  this.store.balanceDueAmount = remainingAmount;
2467
2604
 
2468
2605
  // 发出 balanceDueAmount 变更事件
2469
- _context31.next = 9;
2606
+ _context32.next = 9;
2470
2607
  return this.core.effects.emit(CheckoutHooks.OnBalanceDueAmountChanged, {
2471
2608
  oldAmount: currentBalanceDueAmount,
2472
2609
  newAmount: remainingAmount,
@@ -2477,7 +2614,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2477
2614
  oldAmount: currentBalanceDueAmount,
2478
2615
  newAmount: remainingAmount
2479
2616
  });
2480
- _context31.next = 13;
2617
+ _context32.next = 13;
2481
2618
  break;
2482
2619
  case 12:
2483
2620
  this.logInfo('balanceDueAmount 无需更新,当前值已是最新:', {
@@ -2485,17 +2622,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2485
2622
  remainingAmount: remainingAmount
2486
2623
  });
2487
2624
  case 13:
2488
- _context31.next = 18;
2625
+ _context32.next = 18;
2489
2626
  break;
2490
2627
  case 15:
2491
- _context31.prev = 15;
2492
- _context31.t0 = _context31["catch"](0);
2493
- this.logError('更新 balanceDueAmount 失败:', _context31.t0);
2628
+ _context32.prev = 15;
2629
+ _context32.t0 = _context32["catch"](0);
2630
+ this.logError('更新 balanceDueAmount 失败:', _context32.t0);
2494
2631
  case 18:
2495
2632
  case "end":
2496
- return _context31.stop();
2633
+ return _context32.stop();
2497
2634
  }
2498
- }, _callee31, this, [[0, 15]]);
2635
+ }, _callee32, this, [[0, 15]]);
2499
2636
  }));
2500
2637
  function updateBalanceDueAmount() {
2501
2638
  return _updateBalanceDueAmount.apply(this, arguments);
@@ -2509,16 +2646,16 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2509
2646
  }, {
2510
2647
  key: "updateStateAmountToRemaining",
2511
2648
  value: (function () {
2512
- var _updateStateAmountToRemaining = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
2649
+ var _updateStateAmountToRemaining = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
2513
2650
  var remainingAmount, currentStateAmount;
2514
- return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2515
- while (1) switch (_context32.prev = _context32.next) {
2651
+ return _regeneratorRuntime().wrap(function _callee33$(_context33) {
2652
+ while (1) switch (_context33.prev = _context33.next) {
2516
2653
  case 0:
2517
- _context32.prev = 0;
2518
- _context32.next = 3;
2654
+ _context33.prev = 0;
2655
+ _context33.next = 3;
2519
2656
  return this.calculateRemainingAmountAsync();
2520
2657
  case 3:
2521
- remainingAmount = _context32.sent;
2658
+ remainingAmount = _context33.sent;
2522
2659
  currentStateAmount = this.store.stateAmount; // 只有当剩余金额与当前 stateAmount 不同时才更新
2523
2660
  if (remainingAmount !== currentStateAmount) {
2524
2661
  this.store.stateAmount = remainingAmount;
@@ -2541,23 +2678,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2541
2678
  }
2542
2679
 
2543
2680
  // 同步更新系统内部的 balanceDueAmount
2544
- _context32.next = 8;
2681
+ _context33.next = 8;
2545
2682
  return this.updateBalanceDueAmount();
2546
2683
  case 8:
2547
- _context32.next = 10;
2684
+ _context33.next = 10;
2548
2685
  return this.checkOrderPaymentCompletion();
2549
2686
  case 10:
2550
- _context32.next = 15;
2687
+ _context33.next = 15;
2551
2688
  break;
2552
2689
  case 12:
2553
- _context32.prev = 12;
2554
- _context32.t0 = _context32["catch"](0);
2555
- this.logError('更新 stateAmount 为剩余金额失败:', _context32.t0);
2690
+ _context33.prev = 12;
2691
+ _context33.t0 = _context33["catch"](0);
2692
+ this.logError('更新 stateAmount 为剩余金额失败:', _context33.t0);
2556
2693
  case 15:
2557
2694
  case "end":
2558
- return _context32.stop();
2695
+ return _context33.stop();
2559
2696
  }
2560
- }, _callee32, this, [[0, 12]]);
2697
+ }, _callee33, this, [[0, 12]]);
2561
2698
  }));
2562
2699
  function updateStateAmountToRemaining() {
2563
2700
  return _updateStateAmountToRemaining.apply(this, arguments);
@@ -2573,32 +2710,32 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2573
2710
  }, {
2574
2711
  key: "checkOrderPaymentCompletion",
2575
2712
  value: (function () {
2576
- var _checkOrderPaymentCompletion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
2713
+ var _checkOrderPaymentCompletion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
2577
2714
  var remainingAmount, remainingValue, totalAmount, paidAmount, currentPayments, hasPaymentItems, allPaymentsHaveVoucherId, shouldAutoSync;
2578
- return _regeneratorRuntime().wrap(function _callee33$(_context33) {
2579
- while (1) switch (_context33.prev = _context33.next) {
2715
+ return _regeneratorRuntime().wrap(function _callee34$(_context34) {
2716
+ while (1) switch (_context34.prev = _context34.next) {
2580
2717
  case 0:
2581
- _context33.prev = 0;
2718
+ _context34.prev = 0;
2582
2719
  if (this.store.currentOrder) {
2583
- _context33.next = 3;
2720
+ _context34.next = 3;
2584
2721
  break;
2585
2722
  }
2586
- return _context33.abrupt("return");
2723
+ return _context34.abrupt("return");
2587
2724
  case 3:
2588
- _context33.next = 5;
2725
+ _context34.next = 5;
2589
2726
  return this.calculateRemainingAmountAsync();
2590
2727
  case 5:
2591
- remainingAmount = _context33.sent;
2728
+ remainingAmount = _context34.sent;
2592
2729
  remainingValue = new Decimal(remainingAmount); // 当剩余金额小于等于0时,认为订单已完成支付
2593
2730
  if (!remainingValue.lte(0)) {
2594
- _context33.next = 29;
2731
+ _context34.next = 29;
2595
2732
  break;
2596
2733
  }
2597
2734
  totalAmount = this.store.currentOrder.total_amount;
2598
- _context33.next = 11;
2735
+ _context34.next = 11;
2599
2736
  return this.calculatePaidAmountAsync();
2600
2737
  case 11:
2601
- paidAmount = _context33.sent;
2738
+ paidAmount = _context34.sent;
2602
2739
  this.logInfo('检测到订单支付完成:', {
2603
2740
  orderUuid: this.store.currentOrder.uuid,
2604
2741
  orderId: this.store.currentOrder.order_id,
@@ -2609,11 +2746,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2609
2746
  });
2610
2747
 
2611
2748
  // 从 Payment 模块获取最新支付项,检查自动同步条件
2612
- _context33.next = 15;
2749
+ _context34.next = 15;
2613
2750
  return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid, false // 不包括已撤销的支付项
2614
2751
  );
2615
2752
  case 15:
2616
- currentPayments = _context33.sent;
2753
+ currentPayments = _context34.sent;
2617
2754
  // 检查自动同步条件:
2618
2755
  // 1. 待付金额为 0 ✓ (已在上面检查)
2619
2756
  // 2. 需要有支付项
@@ -2647,14 +2784,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2647
2784
  })
2648
2785
  });
2649
2786
  if (!shouldAutoSync) {
2650
- _context33.next = 26;
2787
+ _context34.next = 26;
2651
2788
  break;
2652
2789
  }
2653
2790
  this.logInfo('满足自动同步条件,开始同步订单到后端...');
2654
- _context33.next = 24;
2791
+ _context34.next = 24;
2655
2792
  return this.syncOrderToBackendWithReturn(false);
2656
2793
  case 24:
2657
- _context33.next = 27;
2794
+ _context34.next = 27;
2658
2795
  break;
2659
2796
  case 26:
2660
2797
  if (!hasPaymentItems) {
@@ -2663,7 +2800,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2663
2800
  this.logInfo('所有支付项均为代金券类型,跳过订单同步');
2664
2801
  }
2665
2802
  case 27:
2666
- _context33.next = 29;
2803
+ _context34.next = 29;
2667
2804
  return this.core.effects.emit(CheckoutHooks.OnOrderPaymentCompleted, {
2668
2805
  orderUuid: this.store.currentOrder.uuid,
2669
2806
  orderId: this.store.currentOrder.order_id,
@@ -2673,17 +2810,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2673
2810
  timestamp: Date.now()
2674
2811
  });
2675
2812
  case 29:
2676
- _context33.next = 34;
2813
+ _context34.next = 34;
2677
2814
  break;
2678
2815
  case 31:
2679
- _context33.prev = 31;
2680
- _context33.t0 = _context33["catch"](0);
2681
- this.logError('检查订单支付完成状态失败:', _context33.t0);
2816
+ _context34.prev = 31;
2817
+ _context34.t0 = _context34["catch"](0);
2818
+ this.logError('检查订单支付完成状态失败:', _context34.t0);
2682
2819
  case 34:
2683
2820
  case "end":
2684
- return _context33.stop();
2821
+ return _context34.stop();
2685
2822
  }
2686
- }, _callee33, this, [[0, 31]]);
2823
+ }, _callee34, this, [[0, 31]]);
2687
2824
  }));
2688
2825
  function checkOrderPaymentCompletion() {
2689
2826
  return _checkOrderPaymentCompletion.apply(this, arguments);
@@ -2701,11 +2838,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2701
2838
  }, {
2702
2839
  key: "syncOrderToBackendWithReturn",
2703
2840
  value: (function () {
2704
- var _syncOrderToBackendWithReturn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
2841
+ var _syncOrderToBackendWithReturn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {
2705
2842
  var _this4 = this,
2706
- _this$store$currentOr17,
2843
+ _this$store$currentOr19,
2844
+ _this$store$currentOr20,
2707
2845
  _this$store$currentCu2,
2708
- _this$store$currentOr18,
2846
+ _this$store$currentOr21,
2709
2847
  _checkoutResponse3,
2710
2848
  _checkoutResponse4;
2711
2849
  var isManual,
@@ -2714,8 +2852,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2714
2852
  isUpdateOperation,
2715
2853
  paymentItems,
2716
2854
  processedPaymentItems,
2855
+ finalDepositAmount,
2856
+ manualDepositAmount,
2717
2857
  depositPaymentItems,
2718
2858
  calculatedDepositAmount,
2859
+ manualDepositValue,
2860
+ calculatedDepositValue,
2719
2861
  orderParams,
2720
2862
  startTime,
2721
2863
  checkoutResponse,
@@ -2733,14 +2875,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2733
2875
  _checkoutResponse7,
2734
2876
  updatedOrder,
2735
2877
  beforeManualUpdate,
2736
- _args34 = arguments;
2737
- return _regeneratorRuntime().wrap(function _callee34$(_context34) {
2738
- while (1) switch (_context34.prev = _context34.next) {
2878
+ _args35 = arguments;
2879
+ return _regeneratorRuntime().wrap(function _callee35$(_context35) {
2880
+ while (1) switch (_context35.prev = _context35.next) {
2739
2881
  case 0:
2740
- isManual = _args34.length > 0 && _args34[0] !== undefined ? _args34[0] : false;
2741
- customPaymentItems = _args34.length > 1 ? _args34[1] : undefined;
2882
+ isManual = _args35.length > 0 && _args35[0] !== undefined ? _args35[0] : false;
2883
+ customPaymentItems = _args35.length > 1 ? _args35[1] : undefined;
2742
2884
  if (!(!this.store.localOrderData || !this.store.currentOrder)) {
2743
- _context34.next = 4;
2885
+ _context35.next = 4;
2744
2886
  break;
2745
2887
  }
2746
2888
  throw new Error('缺少必要的订单数据,无法同步到后端');
@@ -2759,17 +2901,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2759
2901
  });
2760
2902
 
2761
2903
  // 获取当前订单的支付项
2762
- _context34.t0 = customPaymentItems;
2763
- if (_context34.t0) {
2764
- _context34.next = 13;
2904
+ _context35.t0 = customPaymentItems;
2905
+ if (_context35.t0) {
2906
+ _context35.next = 13;
2765
2907
  break;
2766
2908
  }
2767
- _context34.next = 12;
2909
+ _context35.next = 12;
2768
2910
  return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid);
2769
2911
  case 12:
2770
- _context34.t0 = _context34.sent;
2912
+ _context35.t0 = _context35.sent;
2771
2913
  case 13:
2772
- paymentItems = _context34.t0;
2914
+ paymentItems = _context35.t0;
2773
2915
  // 处理支付项数据,确保包含完整的 metadata
2774
2916
  processedPaymentItems = paymentItems.map(function (item) {
2775
2917
  var _item$metadata, _item$metadata2;
@@ -2779,7 +2921,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2779
2921
  shop_wallet_pass_id: ((_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.shop_wallet_pass_id) || _this4.otherParams.shop_wallet_pass_id
2780
2922
  })
2781
2923
  });
2782
- }); // 计算定金支付项的总金额(order_payment_type="deposit")
2924
+ }); // 确定最终的定金金额:优先使用手动设置的值,否则从支付项中计算
2925
+ manualDepositAmount = ((_this$store$currentOr19 = this.store.currentOrder) === null || _this$store$currentOr19 === void 0 ? void 0 : _this$store$currentOr19.deposit_amount) || '0.00'; // 计算定金支付项的总金额(order_payment_type="deposit")
2783
2926
  depositPaymentItems = processedPaymentItems.filter(function (item) {
2784
2927
  return item.order_payment_type === 'deposit' && item.status !== 'voided';
2785
2928
  });
@@ -2789,8 +2932,35 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2789
2932
  // 包含抹零计算的有效支付金额
2790
2933
  var effectiveAmount = amount.add(roundingAmount.abs());
2791
2934
  return sum.add(effectiveAmount);
2792
- }, new Decimal(0)).toFixed(2);
2793
- this.logInfo('计算定金支付项总金额', {
2935
+ }, new Decimal(0)).toFixed(2); // 优先级逻辑:手动设置的定金金额 > 从支付项计算的金额
2936
+ manualDepositValue = new Decimal(manualDepositAmount);
2937
+ calculatedDepositValue = new Decimal(calculatedDepositAmount);
2938
+ if (manualDepositValue.gt(0)) {
2939
+ // 如果手动设置了定金金额且大于0,使用手动设置的值
2940
+ finalDepositAmount = manualDepositAmount;
2941
+ this.logInfo('使用手动设置的定金金额', {
2942
+ manualDepositAmount: manualDepositAmount,
2943
+ calculatedDepositAmount: calculatedDepositAmount,
2944
+ reason: '用户通过setDepositAmountAsync手动设置了定金金额'
2945
+ });
2946
+ } else if (calculatedDepositValue.gt(0)) {
2947
+ // 如果没有手动设置但有定金类型的支付项,使用计算值
2948
+ finalDepositAmount = calculatedDepositAmount;
2949
+ this.logInfo('使用从支付项计算的定金金额', {
2950
+ manualDepositAmount: manualDepositAmount,
2951
+ calculatedDepositAmount: calculatedDepositAmount,
2952
+ reason: '未手动设置定金金额,从定金类型支付项计算得出'
2953
+ });
2954
+ } else {
2955
+ // 都为0,使用0
2956
+ finalDepositAmount = '0.00';
2957
+ this.logInfo('定金金额为0', {
2958
+ manualDepositAmount: manualDepositAmount,
2959
+ calculatedDepositAmount: calculatedDepositAmount,
2960
+ reason: '手动设置和计算值均为0'
2961
+ });
2962
+ }
2963
+ this.logInfo('定金金额确定结果', {
2794
2964
  depositPaymentItemsCount: depositPaymentItems.length,
2795
2965
  depositPaymentItems: depositPaymentItems.map(function (item) {
2796
2966
  return {
@@ -2802,8 +2972,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2802
2972
  status: item.status
2803
2973
  };
2804
2974
  }),
2975
+ manualDepositAmount: manualDepositAmount,
2805
2976
  calculatedDepositAmount: calculatedDepositAmount,
2806
- originalDepositAmount: ((_this$store$currentOr17 = this.store.currentOrder) === null || _this$store$currentOr17 === void 0 ? void 0 : _this$store$currentOr17.deposit_amount) || '0.00'
2977
+ finalDepositAmount: finalDepositAmount,
2978
+ isDeposit: ((_this$store$currentOr20 = this.store.currentOrder) === null || _this$store$currentOr20 === void 0 ? void 0 : _this$store$currentOr20.is_deposit) || 0
2807
2979
  });
2808
2980
 
2809
2981
  // 构造订单参数,直接使用 localOrderData 中已处理好的数据
@@ -2825,9 +2997,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2825
2997
  currency_code: this.otherParams.currency_code,
2826
2998
  currency_symbol: this.otherParams.currency_symbol,
2827
2999
  currency_format: this.otherParams.currency_format,
2828
- is_deposit: ((_this$store$currentOr18 = this.store.currentOrder) === null || _this$store$currentOr18 === void 0 ? void 0 : _this$store$currentOr18.is_deposit) || 0,
2829
- deposit_amount: calculatedDepositAmount,
2830
- // 使用从支付项中计算出的定金金额
3000
+ is_deposit: ((_this$store$currentOr21 = this.store.currentOrder) === null || _this$store$currentOr21 === void 0 ? void 0 : _this$store$currentOr21.is_deposit) || 0,
3001
+ deposit_amount: finalDepositAmount,
3002
+ // 使用最终确定的定金金额(手动设置优先)
2831
3003
  product_tax_fee: this.store.localOrderData.tax_fee,
2832
3004
  note: this.store.localOrderData.shop_note
2833
3005
  }); // 如果是更新操作,需要在参数中包含真实的订单ID
@@ -2842,7 +3014,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2842
3014
 
2843
3015
  // 发送下单接口请求开始事件
2844
3016
  startTime = Date.now();
2845
- _context34.next = 23;
3017
+ _context35.next = 27;
2846
3018
  return this.core.effects.emit(CheckoutHooks.OnOrderSubmitStart, {
2847
3019
  orderUuid: this.store.currentOrder.uuid,
2848
3020
  operation: isUpdateOperation ? 'update' : 'create',
@@ -2850,9 +3022,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2850
3022
  paymentItemCount: paymentItems.length,
2851
3023
  timestamp: startTime
2852
3024
  });
2853
- case 23:
3025
+ case 27:
2854
3026
  submitSuccess = false;
2855
- _context34.prev = 24;
3027
+ _context35.prev = 28;
2856
3028
  // 记录接口调用参数
2857
3029
  this.logInfo('Calling backend checkout API', _objectSpread({
2858
3030
  url: '/order/checkout',
@@ -2860,23 +3032,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2860
3032
  }, orderParams));
2861
3033
 
2862
3034
  // 调用 Order 模块的专用 createOrderByCheckout 方法
2863
- _context34.next = 28;
3035
+ _context35.next = 32;
2864
3036
  return this.order.createOrderByCheckout(orderParams);
2865
- case 28:
2866
- checkoutResponse = _context34.sent;
3037
+ case 32:
3038
+ checkoutResponse = _context35.sent;
2867
3039
  submitSuccess = true;
2868
3040
  this.logInfo('下单接口调用成功', checkoutResponse);
2869
- _context34.next = 41;
3041
+ _context35.next = 45;
2870
3042
  break;
2871
- case 33:
2872
- _context34.prev = 33;
2873
- _context34.t1 = _context34["catch"](24);
3043
+ case 37:
3044
+ _context35.prev = 37;
3045
+ _context35.t1 = _context35["catch"](28);
2874
3046
  submitSuccess = false;
2875
- submitError = _context34.t1 instanceof Error ? _context34.t1.message : String(_context34.t1);
3047
+ submitError = _context35.t1 instanceof Error ? _context35.t1.message : String(_context35.t1);
2876
3048
  this.logError('下单接口调用失败:', submitError);
2877
3049
 
2878
3050
  // 发送订单同步失败事件(网络错误或请求失败)
2879
- _context34.next = 40;
3051
+ _context35.next = 44;
2880
3052
  return this.core.effects.emit(CheckoutHooks.OnOrderSyncFailed, {
2881
3053
  orderUuid: this.store.currentOrder.uuid,
2882
3054
  operation: isUpdateOperation ? 'update' : 'create',
@@ -2886,11 +3058,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2886
3058
  duration: Date.now() - startTime,
2887
3059
  timestamp: Date.now()
2888
3060
  });
2889
- case 40:
2890
- throw _context34.t1;
2891
- case 41:
2892
- _context34.prev = 41;
2893
- _context34.next = 44;
3061
+ case 44:
3062
+ throw _context35.t1;
3063
+ case 45:
3064
+ _context35.prev = 45;
3065
+ _context35.next = 48;
2894
3066
  return this.core.effects.emit(CheckoutHooks.OnOrderSubmitEnd, {
2895
3067
  success: submitSuccess,
2896
3068
  orderUuid: this.store.currentOrder.uuid,
@@ -2901,18 +3073,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2901
3073
  duration: Date.now() - startTime,
2902
3074
  timestamp: Date.now()
2903
3075
  });
2904
- case 44:
2905
- return _context34.finish(41);
2906
- case 45:
3076
+ case 48:
3077
+ return _context35.finish(45);
3078
+ case 49:
2907
3079
  // 检查响应状态是否为成功状态
2908
3080
  responseStatus = (_checkoutResponse3 = checkoutResponse) === null || _checkoutResponse3 === void 0 ? void 0 : _checkoutResponse3.status;
2909
3081
  isSuccessResponse = responseStatus === true || responseStatus === 200 || responseStatus === 'success' || responseStatus === 1 && ((_checkoutResponse4 = checkoutResponse) === null || _checkoutResponse4 === void 0 ? void 0 : _checkoutResponse4.code) === 200;
2910
3082
  if (isSuccessResponse) {
2911
- _context34.next = 52;
3083
+ _context35.next = 56;
2912
3084
  break;
2913
3085
  }
2914
3086
  errorMessage = ((_checkoutResponse5 = checkoutResponse) === null || _checkoutResponse5 === void 0 ? void 0 : _checkoutResponse5.message) || '订单同步失败,后端返回非成功状态'; // 发送订单同步失败事件
2915
- _context34.next = 51;
3087
+ _context35.next = 55;
2916
3088
  return this.core.effects.emit(CheckoutHooks.OnOrderSyncFailed, {
2917
3089
  orderUuid: this.store.currentOrder.uuid,
2918
3090
  operation: isUpdateOperation ? 'update' : 'create',
@@ -2923,18 +3095,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2923
3095
  duration: Date.now() - startTime,
2924
3096
  timestamp: Date.now()
2925
3097
  });
2926
- case 51:
3098
+ case 55:
2927
3099
  throw new Error(errorMessage);
2928
- case 52:
3100
+ case 56:
2929
3101
  if (!isUpdateOperation) {
2930
- _context34.next = 56;
3102
+ _context35.next = 60;
2931
3103
  break;
2932
3104
  }
2933
3105
  // 更新操作:使用现有的订单ID
2934
3106
  realOrderId = currentOrderId;
2935
- _context34.next = 75;
3107
+ _context35.next = 79;
2936
3108
  break;
2937
- case 56:
3109
+ case 60:
2938
3110
  // 创建操作:从响应中提取新的订单ID
2939
3111
  extractedOrderId = (_checkoutResponse6 = checkoutResponse) === null || _checkoutResponse6 === void 0 || (_checkoutResponse6 = _checkoutResponse6.data) === null || _checkoutResponse6 === void 0 ? void 0 : _checkoutResponse6.order_id; // 如果data.order_id不存在,尝试直接从根级获取
2940
3112
  if (!extractedOrderId) {
@@ -2956,11 +3128,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2956
3128
  oldOrderId: this.store.currentOrder.order_id,
2957
3129
  newOrderId: realOrderId
2958
3130
  });
2959
- _context34.prev = 62;
2960
- _context34.next = 65;
3131
+ _context35.prev = 66;
3132
+ _context35.next = 69;
2961
3133
  return this.payment.replaceOrderIdByUuidAsync(this.store.currentOrder.uuid, realOrderId);
2962
- case 65:
2963
- updatedOrder = _context34.sent;
3134
+ case 69:
3135
+ updatedOrder = _context35.sent;
2964
3136
  this.logInfo('Payment模块替换订单ID结果:', {
2965
3137
  wasSuccessful: !!updatedOrder,
2966
3138
  returnedOrderId: updatedOrder === null || updatedOrder === void 0 ? void 0 : updatedOrder.order_id,
@@ -2986,22 +3158,22 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2986
3158
  目标ID: realOrderId
2987
3159
  });
2988
3160
  }
2989
- _context34.next = 75;
3161
+ _context35.next = 79;
2990
3162
  break;
2991
- case 70:
2992
- _context34.prev = 70;
2993
- _context34.t2 = _context34["catch"](62);
2994
- this.logError('调用Payment模块替换订单ID时发生错误:', _context34.t2);
3163
+ case 74:
3164
+ _context35.prev = 74;
3165
+ _context35.t2 = _context35["catch"](66);
3166
+ this.logError('调用Payment模块替换订单ID时发生错误:', _context35.t2);
2995
3167
 
2996
3168
  // 发生错误时也进行手动替换
2997
3169
  this.store.currentOrder.order_id = realOrderId;
2998
3170
  this.logInfo('错误恢复:手动设置订单ID:', realOrderId);
2999
- case 75:
3171
+ case 79:
3000
3172
  // 标记订单已同步
3001
3173
  this.store.isOrderSynced = true;
3002
3174
 
3003
3175
  // 触发订单同步完成事件
3004
- _context34.next = 78;
3176
+ _context35.next = 82;
3005
3177
  return this.core.effects.emit(CheckoutHooks.OnOrderSynced, {
3006
3178
  orderUuid: this.store.currentOrder.uuid,
3007
3179
  realOrderId: realOrderId,
@@ -3010,18 +3182,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3010
3182
  isManual: isManual,
3011
3183
  response: checkoutResponse
3012
3184
  });
3013
- case 78:
3014
- return _context34.abrupt("return", {
3185
+ case 82:
3186
+ return _context35.abrupt("return", {
3015
3187
  success: true,
3016
3188
  orderId: realOrderId,
3017
3189
  orderUuid: this.store.currentOrder.uuid,
3018
3190
  response: checkoutResponse
3019
3191
  });
3020
- case 79:
3192
+ case 83:
3021
3193
  case "end":
3022
- return _context34.stop();
3194
+ return _context35.stop();
3023
3195
  }
3024
- }, _callee34, this, [[24, 33, 41, 45], [62, 70]]);
3196
+ }, _callee35, this, [[28, 37, 45, 49], [66, 74]]);
3025
3197
  }));
3026
3198
  function syncOrderToBackendWithReturn() {
3027
3199
  return _syncOrderToBackendWithReturn.apply(this, arguments);
@@ -3031,15 +3203,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3031
3203
  }, {
3032
3204
  key: "setOtherParams",
3033
3205
  value: function () {
3034
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
3206
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
3035
3207
  var _ref5,
3036
3208
  _ref5$cover,
3037
3209
  cover,
3038
- _args35 = arguments;
3039
- return _regeneratorRuntime().wrap(function _callee35$(_context35) {
3040
- while (1) switch (_context35.prev = _context35.next) {
3210
+ _args36 = arguments;
3211
+ return _regeneratorRuntime().wrap(function _callee36$(_context36) {
3212
+ while (1) switch (_context36.prev = _context36.next) {
3041
3213
  case 0:
3042
- _ref5 = _args35.length > 1 && _args35[1] !== undefined ? _args35[1] : {}, _ref5$cover = _ref5.cover, cover = _ref5$cover === void 0 ? false : _ref5$cover;
3214
+ _ref5 = _args36.length > 1 && _args36[1] !== undefined ? _args36[1] : {}, _ref5$cover = _ref5.cover, cover = _ref5$cover === void 0 ? false : _ref5$cover;
3043
3215
  if (cover) {
3044
3216
  this.otherParams = params;
3045
3217
  } else {
@@ -3047,11 +3219,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3047
3219
  }
3048
3220
  case 2:
3049
3221
  case "end":
3050
- return _context35.stop();
3222
+ return _context36.stop();
3051
3223
  }
3052
- }, _callee35, this);
3224
+ }, _callee36, this);
3053
3225
  }));
3054
- function setOtherParams(_x25) {
3226
+ function setOtherParams(_x26) {
3055
3227
  return _setOtherParams.apply(this, arguments);
3056
3228
  }
3057
3229
  return setOtherParams;
@@ -3068,22 +3240,22 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3068
3240
  }, {
3069
3241
  key: "editOrderNoteByOrderIdAsync",
3070
3242
  value: (function () {
3071
- var _editOrderNoteByOrderIdAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(orderId, note) {
3243
+ var _editOrderNoteByOrderIdAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(orderId, note) {
3072
3244
  var response, previousNote, errorMessage, _errorMessage;
3073
- return _regeneratorRuntime().wrap(function _callee36$(_context36) {
3074
- while (1) switch (_context36.prev = _context36.next) {
3245
+ return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3246
+ while (1) switch (_context37.prev = _context37.next) {
3075
3247
  case 0:
3076
3248
  this.logInfo('editOrderNoteByOrderIdAsync called', {
3077
3249
  orderId: orderId,
3078
3250
  note: note,
3079
3251
  noteLength: note.length
3080
3252
  });
3081
- _context36.prev = 1;
3253
+ _context37.prev = 1;
3082
3254
  if (orderId) {
3083
- _context36.next = 4;
3255
+ _context37.next = 4;
3084
3256
  break;
3085
3257
  }
3086
- return _context36.abrupt("return", {
3258
+ return _context37.abrupt("return", {
3087
3259
  success: false,
3088
3260
  message: '订单ID不能为空',
3089
3261
  orderId: orderId
@@ -3099,12 +3271,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3099
3271
  });
3100
3272
 
3101
3273
  // 调用后端API修改订单备注
3102
- _context36.next = 7;
3274
+ _context37.next = 7;
3103
3275
  return this.request.put("/order/order/".concat(orderId, "/note"), {
3104
3276
  note: note
3105
3277
  });
3106
3278
  case 7:
3107
- response = _context36.sent;
3279
+ response = _context37.sent;
3108
3280
  this.logInfo('订单备注编辑响应:', {
3109
3281
  orderId: orderId,
3110
3282
  status: response.status,
@@ -3114,11 +3286,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3114
3286
 
3115
3287
  // 检查响应状态
3116
3288
  if (!(response.status === true || response.status === 200)) {
3117
- _context36.next = 18;
3289
+ _context37.next = 18;
3118
3290
  break;
3119
3291
  }
3120
3292
  if (!(this.store.currentOrder && (String(this.store.currentOrder.order_id) === String(orderId) || String(this.store.currentOrder.id) === String(orderId)))) {
3121
- _context36.next = 15;
3293
+ _context37.next = 15;
3122
3294
  break;
3123
3295
  }
3124
3296
  // 获取修改前的备注用于事件
@@ -3128,7 +3300,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3128
3300
  }
3129
3301
 
3130
3302
  // 触发订单备注变更事件
3131
- _context36.next = 15;
3303
+ _context37.next = 15;
3132
3304
  return this.core.effects.emit(CheckoutHooks.OnOrderNoteChanged, {
3133
3305
  orderUuid: this.store.currentOrder.uuid,
3134
3306
  oldNote: previousNote,
@@ -3136,7 +3308,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3136
3308
  timestamp: Date.now()
3137
3309
  });
3138
3310
  case 15:
3139
- return _context36.abrupt("return", {
3311
+ return _context37.abrupt("return", {
3140
3312
  success: true,
3141
3313
  message: response.message || '订单备注修改成功',
3142
3314
  orderId: orderId
@@ -3145,31 +3317,31 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3145
3317
  // API返回失败状态
3146
3318
  errorMessage = response.message || '订单备注修改失败';
3147
3319
  this.logError("\u8BA2\u5355 ".concat(orderId, " \u5907\u6CE8\u4FEE\u6539\u5931\u8D25:"), errorMessage);
3148
- return _context36.abrupt("return", {
3320
+ return _context37.abrupt("return", {
3149
3321
  success: false,
3150
3322
  message: errorMessage,
3151
3323
  orderId: orderId
3152
3324
  });
3153
3325
  case 21:
3154
- _context36.next = 28;
3326
+ _context37.next = 28;
3155
3327
  break;
3156
3328
  case 23:
3157
- _context36.prev = 23;
3158
- _context36.t0 = _context36["catch"](1);
3159
- this.logError('编辑订单备注失败:', _context36.t0);
3160
- _errorMessage = _context36.t0 instanceof Error ? _context36.t0.message : '网络错误或服务器异常';
3161
- return _context36.abrupt("return", {
3329
+ _context37.prev = 23;
3330
+ _context37.t0 = _context37["catch"](1);
3331
+ this.logError('编辑订单备注失败:', _context37.t0);
3332
+ _errorMessage = _context37.t0 instanceof Error ? _context37.t0.message : '网络错误或服务器异常';
3333
+ return _context37.abrupt("return", {
3162
3334
  success: false,
3163
3335
  message: "\u7F16\u8F91\u8BA2\u5355\u5907\u6CE8\u5931\u8D25: ".concat(_errorMessage),
3164
3336
  orderId: orderId
3165
3337
  });
3166
3338
  case 28:
3167
3339
  case "end":
3168
- return _context36.stop();
3340
+ return _context37.stop();
3169
3341
  }
3170
- }, _callee36, this, [[1, 23]]);
3342
+ }, _callee37, this, [[1, 23]]);
3171
3343
  }));
3172
- function editOrderNoteByOrderIdAsync(_x26, _x27) {
3344
+ function editOrderNoteByOrderIdAsync(_x27, _x28) {
3173
3345
  return _editOrderNoteByOrderIdAsync.apply(this, arguments);
3174
3346
  }
3175
3347
  return editOrderNoteByOrderIdAsync;
@@ -3186,11 +3358,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3186
3358
  }, {
3187
3359
  key: "sendCustomerPayLinkAsync",
3188
3360
  value: (function () {
3189
- var _sendCustomerPayLinkAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
3361
+ var _sendCustomerPayLinkAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
3190
3362
  var _params$order_ids, _params$emails;
3191
3363
  var emailRegex, invalidEmails, requestBody, response, errorMessage, _errorMessage2;
3192
- return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3193
- while (1) switch (_context37.prev = _context37.next) {
3364
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3365
+ while (1) switch (_context38.prev = _context38.next) {
3194
3366
  case 0:
3195
3367
  this.logInfo('sendCustomerPayLinkAsync called', {
3196
3368
  orderIds: params.order_ids,
@@ -3199,21 +3371,21 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3199
3371
  emailsCount: ((_params$emails = params.emails) === null || _params$emails === void 0 ? void 0 : _params$emails.length) || 0,
3200
3372
  notifyAction: params.notify_action || 'order_payment_reminder'
3201
3373
  });
3202
- _context37.prev = 1;
3374
+ _context38.prev = 1;
3203
3375
  if (!(!params.order_ids || params.order_ids.length === 0)) {
3204
- _context37.next = 4;
3376
+ _context38.next = 4;
3205
3377
  break;
3206
3378
  }
3207
- return _context37.abrupt("return", {
3379
+ return _context38.abrupt("return", {
3208
3380
  success: false,
3209
3381
  message: '订单ID列表不能为空'
3210
3382
  });
3211
3383
  case 4:
3212
3384
  if (!(!params.emails || params.emails.length === 0)) {
3213
- _context37.next = 6;
3385
+ _context38.next = 6;
3214
3386
  break;
3215
3387
  }
3216
- return _context37.abrupt("return", {
3388
+ return _context38.abrupt("return", {
3217
3389
  success: false,
3218
3390
  message: '邮箱地址列表不能为空'
3219
3391
  });
@@ -3224,10 +3396,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3224
3396
  return !emailRegex.test(email);
3225
3397
  });
3226
3398
  if (!(invalidEmails.length > 0)) {
3227
- _context37.next = 10;
3399
+ _context38.next = 10;
3228
3400
  break;
3229
3401
  }
3230
- return _context37.abrupt("return", {
3402
+ return _context38.abrupt("return", {
3231
3403
  success: false,
3232
3404
  message: "\u90AE\u7BB1\u683C\u5F0F\u65E0\u6548: ".concat(invalidEmails.join(', '))
3233
3405
  });
@@ -3243,10 +3415,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3243
3415
  }, requestBody));
3244
3416
 
3245
3417
  // 调用后端API发送邮件
3246
- _context37.next = 14;
3418
+ _context38.next = 14;
3247
3419
  return this.request.post('/order/batch-email', requestBody);
3248
3420
  case 14:
3249
- response = _context37.sent;
3421
+ response = _context38.sent;
3250
3422
  this.logInfo('支付链接邮件发送响应:', {
3251
3423
  status: response.status,
3252
3424
  message: response.message,
@@ -3256,10 +3428,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3256
3428
 
3257
3429
  // 检查响应状态
3258
3430
  if (!(response.status === true || response.status === 200)) {
3259
- _context37.next = 20;
3431
+ _context38.next = 20;
3260
3432
  break;
3261
3433
  }
3262
- return _context37.abrupt("return", {
3434
+ return _context38.abrupt("return", {
3263
3435
  success: true,
3264
3436
  message: response.message || '支付链接邮件发送成功'
3265
3437
  });
@@ -3267,29 +3439,29 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3267
3439
  // API返回失败状态
3268
3440
  errorMessage = response.message || '支付链接邮件发送失败';
3269
3441
  console.error('[Checkout] 支付链接邮件发送失败:', errorMessage);
3270
- return _context37.abrupt("return", {
3442
+ return _context38.abrupt("return", {
3271
3443
  success: false,
3272
3444
  message: errorMessage
3273
3445
  });
3274
3446
  case 23:
3275
- _context37.next = 30;
3447
+ _context38.next = 30;
3276
3448
  break;
3277
3449
  case 25:
3278
- _context37.prev = 25;
3279
- _context37.t0 = _context37["catch"](1);
3280
- this.logError('发送客户支付链接邮件失败:', _context37.t0);
3281
- _errorMessage2 = _context37.t0 instanceof Error ? _context37.t0.message : '网络错误或服务器异常';
3282
- return _context37.abrupt("return", {
3450
+ _context38.prev = 25;
3451
+ _context38.t0 = _context38["catch"](1);
3452
+ this.logError('发送客户支付链接邮件失败:', _context38.t0);
3453
+ _errorMessage2 = _context38.t0 instanceof Error ? _context38.t0.message : '网络错误或服务器异常';
3454
+ return _context38.abrupt("return", {
3283
3455
  success: false,
3284
3456
  message: "\u53D1\u9001\u652F\u4ED8\u94FE\u63A5\u90AE\u4EF6\u5931\u8D25: ".concat(_errorMessage2)
3285
3457
  });
3286
3458
  case 30:
3287
3459
  case "end":
3288
- return _context37.stop();
3460
+ return _context38.stop();
3289
3461
  }
3290
- }, _callee37, this, [[1, 25]]);
3462
+ }, _callee38, this, [[1, 25]]);
3291
3463
  }));
3292
- function sendCustomerPayLinkAsync(_x28) {
3464
+ function sendCustomerPayLinkAsync(_x29) {
3293
3465
  return _sendCustomerPayLinkAsync.apply(this, arguments);
3294
3466
  }
3295
3467
  return sendCustomerPayLinkAsync;
@@ -3304,24 +3476,24 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3304
3476
  }, {
3305
3477
  key: "roundAmountAsync",
3306
3478
  value: (function () {
3307
- var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(amount) {
3479
+ var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(amount) {
3308
3480
  var _this$otherParams$ord, _this$otherParams$ord2;
3309
3481
  var result;
3310
- return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3311
- while (1) switch (_context38.prev = _context38.next) {
3482
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3483
+ while (1) switch (_context39.prev = _context39.next) {
3312
3484
  case 0:
3313
- _context38.next = 2;
3485
+ _context39.next = 2;
3314
3486
  return this.payment.roundAmountAsync(amount, (_this$otherParams$ord = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord === void 0 ? void 0 : _this$otherParams$ord.interval, (_this$otherParams$ord2 = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord2 === void 0 ? void 0 : _this$otherParams$ord2.type);
3315
3487
  case 2:
3316
- result = _context38.sent;
3317
- return _context38.abrupt("return", result);
3488
+ result = _context39.sent;
3489
+ return _context39.abrupt("return", result);
3318
3490
  case 4:
3319
3491
  case "end":
3320
- return _context38.stop();
3492
+ return _context39.stop();
3321
3493
  }
3322
- }, _callee38, this);
3494
+ }, _callee39, this);
3323
3495
  }));
3324
- function roundAmountAsync(_x29) {
3496
+ function roundAmountAsync(_x30) {
3325
3497
  return _roundAmountAsync.apply(this, arguments);
3326
3498
  }
3327
3499
  return roundAmountAsync;
@@ -3329,10 +3501,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3329
3501
  }, {
3330
3502
  key: "destroy",
3331
3503
  value: function () {
3332
- var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
3504
+ var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40() {
3333
3505
  var _this$order, _this$order$destroy, _this$payment, _this$payment$destroy;
3334
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3335
- while (1) switch (_context39.prev = _context39.next) {
3506
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3507
+ while (1) switch (_context40.prev = _context40.next) {
3336
3508
  case 0:
3337
3509
  // 清理钱包模块的所有缓存数据
3338
3510
  this.payment.wallet.clearAllCache();
@@ -3341,10 +3513,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3341
3513
  this.core.effects.offByModuleDestroy(this.name);
3342
3514
 
3343
3515
  // 销毁子模块
3344
- _context39.next = 4;
3516
+ _context40.next = 4;
3345
3517
  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);
3346
3518
  case 4:
3347
- _context39.next = 6;
3519
+ _context40.next = 6;
3348
3520
  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);
3349
3521
  case 6:
3350
3522
  // 取消注册模块
@@ -3352,9 +3524,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3352
3524
  console.log('[Checkout] 已销毁');
3353
3525
  case 8:
3354
3526
  case "end":
3355
- return _context39.stop();
3527
+ return _context40.stop();
3356
3528
  }
3357
- }, _callee39, this);
3529
+ }, _callee40, this);
3358
3530
  }));
3359
3531
  function destroy() {
3360
3532
  return _destroy.apply(this, arguments);
@@ -3369,12 +3541,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3369
3541
  }, {
3370
3542
  key: "resetStoreStateAsync",
3371
3543
  value: (function () {
3372
- var _resetStoreStateAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40() {
3544
+ var _resetStoreStateAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41() {
3373
3545
  var prevOrderInfo;
3374
- return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3375
- while (1) switch (_context40.prev = _context40.next) {
3546
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3547
+ while (1) switch (_context41.prev = _context41.next) {
3376
3548
  case 0:
3377
- _context40.prev = 0;
3549
+ _context41.prev = 0;
3378
3550
  prevOrderInfo = this.store.currentOrder ? {
3379
3551
  uuid: this.store.currentOrder.uuid,
3380
3552
  orderId: this.store.currentOrder.order_id
@@ -3403,26 +3575,26 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3403
3575
 
3404
3576
  // 触发订单清理事件(如果之前有订单)
3405
3577
  if (!prevOrderInfo) {
3406
- _context40.next = 17;
3578
+ _context41.next = 17;
3407
3579
  break;
3408
3580
  }
3409
- _context40.next = 17;
3581
+ _context41.next = 17;
3410
3582
  return this.core.effects.emit(CheckoutHooks.OnOrderCleared, {
3411
3583
  previousOrder: prevOrderInfo,
3412
3584
  timestamp: Date.now()
3413
3585
  });
3414
3586
  case 17:
3415
- _context40.next = 22;
3587
+ _context41.next = 22;
3416
3588
  break;
3417
3589
  case 19:
3418
- _context40.prev = 19;
3419
- _context40.t0 = _context40["catch"](0);
3420
- console.error('[Checkout] 重置 store 状态失败:', _context40.t0);
3590
+ _context41.prev = 19;
3591
+ _context41.t0 = _context41["catch"](0);
3592
+ console.error('[Checkout] 重置 store 状态失败:', _context41.t0);
3421
3593
  case 22:
3422
3594
  case "end":
3423
- return _context40.stop();
3595
+ return _context41.stop();
3424
3596
  }
3425
- }, _callee40, this, [[0, 19]]);
3597
+ }, _callee41, this, [[0, 19]]);
3426
3598
  }));
3427
3599
  function resetStoreStateAsync() {
3428
3600
  return _resetStoreStateAsync.apply(this, arguments);