@pisell/pisellos 0.0.254 → 0.0.255

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.
@@ -62,6 +62,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
62
62
  key: "initialize",
63
63
  value: function () {
64
64
  var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
65
+ var appPlugin, app;
65
66
  return _regeneratorRuntime().wrap(function _callee$(_context) {
66
67
  while (1) switch (_context.prev = _context.next) {
67
68
  case 0:
@@ -77,7 +78,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
77
78
  throw new Error('Checkout 解决方案需要 request 插件支持');
78
79
  case 5:
79
80
  // 获取 logger 实例
80
- this.logger = core.getPlugin('logger');
81
+ appPlugin = core.getPlugin('app');
82
+ if (appPlugin) {
83
+ _context.next = 8;
84
+ break;
85
+ }
86
+ throw new Error('Checkout 解决方案需要 app 插件支持');
87
+ case 8:
88
+ app = appPlugin.getApp();
89
+ this.logger = app.logger;
81
90
 
82
91
  // 初始化模块
83
92
  this.order = new OrderModule();
@@ -97,25 +106,25 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
97
106
  };
98
107
 
99
108
  // 注册并初始化子模块
100
- _context.next = 11;
109
+ _context.next = 15;
101
110
  return this.initializeSubModules(core, options);
102
- case 11:
103
- _context.next = 13;
111
+ case 15:
112
+ _context.next = 17;
104
113
  return this.preloadPaymentMethods();
105
- case 13:
106
- _context.next = 15;
114
+ case 17:
115
+ _context.next = 19;
107
116
  return this.cleanupExpiredOrdersAsync();
108
- case 15:
117
+ case 19:
109
118
  // 设置状态为就绪
110
119
  this.setStatus(CheckoutStatus.Ready);
111
120
  console.log('[Checkout] 初始化完成');
112
- _context.next = 19;
121
+ _context.next = 23;
113
122
  return this.core.effects.emit(CheckoutHooks.OnCheckoutInitialized, {
114
123
  timestamp: Date.now()
115
124
  });
116
- case 19:
125
+ case 23:
117
126
  this.logInfo('CheckoutModule initialized successfully');
118
- case 20:
127
+ case 24:
119
128
  case "end":
120
129
  return _context.stop();
121
130
  }
@@ -1522,37 +1531,42 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1522
1531
  }
1523
1532
  return _context22.abrupt("return");
1524
1533
  case 8:
1534
+ this.logger.info('[Checkout] 设置自定义支付金额:', {
1535
+ oldAmount: oldAmount,
1536
+ newAmount: formattedAmount
1537
+ });
1538
+
1525
1539
  // 更新状态
1526
1540
  this.store.stateAmount = formattedAmount;
1527
1541
 
1528
1542
  // 触发金额变更事件
1529
- _context22.next = 11;
1543
+ _context22.next = 12;
1530
1544
  return this.core.effects.emit(CheckoutHooks.OnStateAmountChanged, {
1531
1545
  oldAmount: oldAmount,
1532
1546
  newAmount: formattedAmount,
1533
1547
  timestamp: Date.now()
1534
1548
  });
1535
- case 11:
1549
+ case 12:
1536
1550
  console.log('[Checkout] 自定义支付金额已更新:', {
1537
1551
  oldAmount: oldAmount,
1538
1552
  newAmount: formattedAmount
1539
1553
  });
1540
- _context22.next = 21;
1554
+ _context22.next = 22;
1541
1555
  break;
1542
- case 14:
1543
- _context22.prev = 14;
1556
+ case 15:
1557
+ _context22.prev = 15;
1544
1558
  _context22.t0 = _context22["catch"](0);
1545
1559
  errorMessage = _context22.t0 instanceof Error ? _context22.t0.message : '设置支付金额失败';
1546
1560
  console.error('[Checkout] 设置自定义支付金额失败:', errorMessage);
1547
- _context22.next = 20;
1561
+ _context22.next = 21;
1548
1562
  return this.handleError(new Error(errorMessage), CheckoutErrorType.ValidationFailed);
1549
- case 20:
1550
- throw _context22.t0;
1551
1563
  case 21:
1564
+ throw _context22.t0;
1565
+ case 22:
1552
1566
  case "end":
1553
1567
  return _context22.stop();
1554
1568
  }
1555
- }, _callee22, this, [[0, 14]]);
1569
+ }, _callee22, this, [[0, 15]]);
1556
1570
  }));
1557
1571
  function setStateAmountAsync(_x15) {
1558
1572
  return _setStateAmountAsync.apply(this, arguments);
@@ -1720,7 +1734,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1720
1734
  value: (function () {
1721
1735
  var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(paymentItem) {
1722
1736
  var _this$store$currentOr9, _this$store$currentOr10;
1723
- var _paymentItem$type, _paymentItem$code, orderPaymentType, metadata, paymentItemWithType, isEftposPayment, syncResult;
1737
+ var _paymentItemWithType$, _paymentItemWithType$2, _paymentItem$type, _paymentItem$code, orderPaymentType, processedPaymentItem, metadata, paymentItemWithType, isEftposPayment, syncResult;
1724
1738
  return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1725
1739
  while (1) switch (_context25.prev = _context25.next) {
1726
1740
  case 0:
@@ -1744,12 +1758,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1744
1758
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, '未找到当前订单,无法添加支付项');
1745
1759
  case 4:
1746
1760
  // 根据当前订单的定金状态设置订单支付类型
1747
- orderPaymentType = this.store.currentOrder.is_deposit === 1 ? 'deposit' : 'normal'; // 从 otherParams 获取 metadata 字段
1748
- metadata = _objectSpread(_objectSpread({}, paymentItem.metadata), {}, {
1761
+ orderPaymentType = this.store.currentOrder.is_deposit === 1 ? 'deposit' : 'normal'; // 处理现金支付的找零逻辑
1762
+ _context25.next = 7;
1763
+ return this.processCashPaymentItem(paymentItem);
1764
+ case 7:
1765
+ processedPaymentItem = _context25.sent;
1766
+ // 从 otherParams 获取 metadata 字段
1767
+ metadata = _objectSpread(_objectSpread({}, processedPaymentItem.metadata), {}, {
1749
1768
  rounding_rule: this.otherParams.order_rounding_setting,
1750
1769
  shop_wallet_pass_id: this.otherParams.shop_wallet_pass_id
1751
1770
  }); // 设置支付项的订单支付类型和 metadata
1752
- paymentItemWithType = _objectSpread(_objectSpread({}, paymentItem), {}, {
1771
+ paymentItemWithType = _objectSpread(_objectSpread({}, processedPaymentItem), {}, {
1753
1772
  order_payment_type: orderPaymentType,
1754
1773
  metadata: metadata
1755
1774
  });
@@ -1767,13 +1786,19 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1767
1786
  metadata: paymentItemWithType.metadata
1768
1787
  },
1769
1788
  orderDepositStatus: this.store.currentOrder.is_deposit,
1770
- calculatedOrderPaymentType: orderPaymentType
1789
+ calculatedOrderPaymentType: orderPaymentType,
1790
+ // 现金支付找零详情
1791
+ isCashPayment: this.isCashPayment(paymentItem.code, paymentItem.type),
1792
+ originalAmount: paymentItem.amount,
1793
+ processedAmount: paymentItemWithType.amount,
1794
+ actualPaidAmount: (_paymentItemWithType$ = paymentItemWithType.metadata) === null || _paymentItemWithType$ === void 0 ? void 0 : _paymentItemWithType$.actual_paid_amount,
1795
+ changeGivenAmount: (_paymentItemWithType$2 = paymentItemWithType.metadata) === null || _paymentItemWithType$2 === void 0 ? void 0 : _paymentItemWithType$2.change_given_amount
1771
1796
  });
1772
1797
 
1773
1798
  // 添加支付项到订单
1774
- _context25.next = 10;
1799
+ _context25.next = 13;
1775
1800
  return this.payment.addPaymentItemAsync(this.store.currentOrder.uuid, paymentItemWithType);
1776
- case 10:
1801
+ case 13:
1777
1802
  console.log('[Checkout] 支付项添加成功');
1778
1803
 
1779
1804
  // 检查是否是 EFTPOS 支付,如果是则立即同步订单
@@ -1785,56 +1810,56 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1785
1810
  currentOrderSynced: this.store.isOrderSynced
1786
1811
  });
1787
1812
  if (!isEftposPayment) {
1788
- _context25.next = 27;
1813
+ _context25.next = 30;
1789
1814
  break;
1790
1815
  }
1791
1816
  console.log('[Checkout] 检测到 EFTPOS 支付,立即同步订单到后端...');
1792
- _context25.prev = 15;
1793
- _context25.next = 18;
1817
+ _context25.prev = 18;
1818
+ _context25.next = 21;
1794
1819
  return this.syncOrderToBackendWithReturn(true);
1795
- case 18:
1820
+ case 21:
1796
1821
  syncResult = _context25.sent;
1797
1822
  console.log('[Checkout] EFTPOS 支付后订单同步完成 (已标记为手动同步):', {
1798
1823
  订单ID: syncResult.orderId,
1799
1824
  是否已同步: this.store.isOrderSynced,
1800
1825
  后端响应: syncResult.response
1801
1826
  });
1802
- _context25.next = 27;
1827
+ _context25.next = 30;
1803
1828
  break;
1804
- case 22:
1805
- _context25.prev = 22;
1806
- _context25.t0 = _context25["catch"](15);
1829
+ case 25:
1830
+ _context25.prev = 25;
1831
+ _context25.t0 = _context25["catch"](18);
1807
1832
  console.error('[Checkout] EFTPOS 支付后订单同步失败:', _context25.t0);
1808
1833
  // 不抛出错误,避免影响支付流程,但记录错误
1809
- _context25.next = 27;
1834
+ _context25.next = 30;
1810
1835
  return this.handleError(new Error("EFTPOS \u652F\u4ED8\u540E\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(_context25.t0 instanceof Error ? _context25.t0.message : String(_context25.t0))), CheckoutErrorType.OrderCreationFailed);
1811
- case 27:
1812
- _context25.next = 29;
1836
+ case 30:
1837
+ _context25.next = 32;
1813
1838
  return this.updateStateAmountToRemaining();
1814
- case 29:
1815
- _context25.next = 31;
1839
+ case 32:
1840
+ _context25.next = 34;
1816
1841
  return this.core.effects.emit(CheckoutHooks.OnPaymentStarted, {
1817
1842
  orderUuid: this.store.currentOrder.uuid,
1818
1843
  paymentMethodCode: paymentItem.code,
1819
1844
  amount: String(paymentItem.amount),
1820
1845
  timestamp: Date.now()
1821
1846
  });
1822
- case 31:
1823
- _context25.next = 39;
1847
+ case 34:
1848
+ _context25.next = 42;
1824
1849
  break;
1825
- case 33:
1826
- _context25.prev = 33;
1850
+ case 36:
1851
+ _context25.prev = 36;
1827
1852
  _context25.t1 = _context25["catch"](1);
1828
1853
  console.error('[Checkout] 添加支付项失败:', _context25.t1);
1829
- _context25.next = 38;
1854
+ _context25.next = 41;
1830
1855
  return this.handleError(_context25.t1, CheckoutErrorType.PaymentFailed);
1831
- case 38:
1856
+ case 41:
1832
1857
  throw _context25.t1;
1833
- case 39:
1858
+ case 42:
1834
1859
  case "end":
1835
1860
  return _context25.stop();
1836
1861
  }
1837
- }, _callee25, this, [[1, 33], [15, 22]]);
1862
+ }, _callee25, this, [[1, 36], [18, 25]]);
1838
1863
  }));
1839
1864
  function addPaymentItemAsync(_x16) {
1840
1865
  return _addPaymentItemAsync.apply(this, arguments);
@@ -3062,37 +3087,143 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3062
3087
  return validateCheckoutData(params);
3063
3088
  }
3064
3089
 
3090
+ /**
3091
+ * 处理现金支付项的找零逻辑
3092
+ *
3093
+ * @param paymentItem 原始支付项
3094
+ * @returns 处理后的支付项(包含找零信息)
3095
+ */
3096
+ }, {
3097
+ key: "processCashPaymentItem",
3098
+ value: (function () {
3099
+ var _processCashPaymentItem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(paymentItem) {
3100
+ var isCashPayment, remainingAmountStr, remainingAmount, cashAmount, changeAmount, processedPaymentItem;
3101
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3102
+ while (1) switch (_context39.prev = _context39.next) {
3103
+ case 0:
3104
+ // 检查是否是现金支付
3105
+ isCashPayment = this.isCashPayment(paymentItem.code, paymentItem.type);
3106
+ if (isCashPayment) {
3107
+ _context39.next = 3;
3108
+ break;
3109
+ }
3110
+ return _context39.abrupt("return", paymentItem);
3111
+ case 3:
3112
+ _context39.prev = 3;
3113
+ _context39.next = 6;
3114
+ return this.calculateRemainingAmountAsync();
3115
+ case 6:
3116
+ remainingAmountStr = _context39.sent;
3117
+ remainingAmount = parseFloat(remainingAmountStr);
3118
+ cashAmount = parseFloat(String(paymentItem.amount));
3119
+ console.log('[Checkout] 现金支付处理:', {
3120
+ cashAmount: cashAmount,
3121
+ remainingAmount: remainingAmount,
3122
+ needsChange: cashAmount > remainingAmount
3123
+ });
3124
+
3125
+ // 如果现金金额小于等于剩余待付金额,无需找零
3126
+ if (!(cashAmount <= remainingAmount)) {
3127
+ _context39.next = 12;
3128
+ break;
3129
+ }
3130
+ return _context39.abrupt("return", paymentItem);
3131
+ case 12:
3132
+ // 计算找零金额
3133
+ changeAmount = cashAmount - remainingAmount;
3134
+ console.log('[Checkout] 现金支付需要找零:', {
3135
+ actualPaidAmount: cashAmount,
3136
+ chargedAmount: remainingAmount,
3137
+ changeGivenAmount: changeAmount
3138
+ });
3139
+
3140
+ // 创建包含找零信息的支付项
3141
+ processedPaymentItem = _objectSpread(_objectSpread({}, paymentItem), {}, {
3142
+ amount: remainingAmount,
3143
+ // 将 amount 设置为剩余待付金额
3144
+ metadata: _objectSpread(_objectSpread({}, paymentItem.metadata), {}, {
3145
+ actual_paid_amount: cashAmount,
3146
+ // 实付金额
3147
+ change_given_amount: changeAmount // 找零金额
3148
+ })
3149
+ });
3150
+ this.logInfo('Cash payment with change processed', {
3151
+ originalAmount: cashAmount,
3152
+ chargedAmount: remainingAmount,
3153
+ changeAmount: changeAmount,
3154
+ paymentCode: paymentItem.code,
3155
+ paymentType: paymentItem.type
3156
+ });
3157
+ return _context39.abrupt("return", processedPaymentItem);
3158
+ case 19:
3159
+ _context39.prev = 19;
3160
+ _context39.t0 = _context39["catch"](3);
3161
+ console.error('[Checkout] 处理现金支付项时出错:', _context39.t0);
3162
+ // 出错时返回原始支付项,避免中断支付流程
3163
+ return _context39.abrupt("return", paymentItem);
3164
+ case 23:
3165
+ case "end":
3166
+ return _context39.stop();
3167
+ }
3168
+ }, _callee39, this, [[3, 19]]);
3169
+ }));
3170
+ function processCashPaymentItem(_x28) {
3171
+ return _processCashPaymentItem.apply(this, arguments);
3172
+ }
3173
+ return processCashPaymentItem;
3174
+ }()
3175
+ /**
3176
+ * 判断是否为现金支付
3177
+ *
3178
+ * @param paymentCode 支付代码
3179
+ * @param paymentType 支付类型
3180
+ * @returns 是否为现金支付
3181
+ */
3182
+ )
3183
+ }, {
3184
+ key: "isCashPayment",
3185
+ value: function isCashPayment(paymentCode, paymentType) {
3186
+ var codeUpper = (paymentCode === null || paymentCode === void 0 ? void 0 : paymentCode.toUpperCase()) || '';
3187
+ var typeUpper = (paymentType === null || paymentType === void 0 ? void 0 : paymentType.toUpperCase()) || '';
3188
+
3189
+ // 现金支付识别规则
3190
+ var cashIdentifiers = ['CASH', 'CASHMANUAL', 'MANUAL'];
3191
+ return cashIdentifiers.some(function (identifier) {
3192
+ return codeUpper.includes(identifier) || typeUpper.includes(identifier);
3193
+ });
3194
+ }
3195
+
3065
3196
  /**
3066
3197
  * 预加载支付方式(在初始化时调用)
3067
3198
  */
3068
3199
  }, {
3069
3200
  key: "preloadPaymentMethods",
3070
3201
  value: (function () {
3071
- var _preloadPaymentMethods = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
3202
+ var _preloadPaymentMethods = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40() {
3072
3203
  var methods;
3073
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3074
- while (1) switch (_context39.prev = _context39.next) {
3204
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3205
+ while (1) switch (_context40.prev = _context40.next) {
3075
3206
  case 0:
3076
- _context39.prev = 0;
3207
+ _context40.prev = 0;
3077
3208
  console.log('[Checkout] 预加载支付方式...');
3078
- _context39.next = 4;
3209
+ _context40.next = 4;
3079
3210
  return this.payment.getPayMethodListAsync();
3080
3211
  case 4:
3081
- methods = _context39.sent;
3212
+ methods = _context40.sent;
3082
3213
  this.store.paymentMethods = methods;
3083
3214
  console.log("[Checkout] \u9884\u52A0\u8F7D\u5B8C\u6210\uFF0C\u5171 ".concat(methods.length, " \u79CD\u652F\u4ED8\u65B9\u5F0F"));
3084
- _context39.next = 13;
3215
+ _context40.next = 13;
3085
3216
  break;
3086
3217
  case 9:
3087
- _context39.prev = 9;
3088
- _context39.t0 = _context39["catch"](0);
3089
- console.error('[Checkout] 预加载支付方式失败:', _context39.t0);
3218
+ _context40.prev = 9;
3219
+ _context40.t0 = _context40["catch"](0);
3220
+ console.error('[Checkout] 预加载支付方式失败:', _context40.t0);
3090
3221
  this.store.paymentMethods = [];
3091
3222
  case 13:
3092
3223
  case "end":
3093
- return _context39.stop();
3224
+ return _context40.stop();
3094
3225
  }
3095
- }, _callee39, this, [[0, 9]]);
3226
+ }, _callee40, this, [[0, 9]]);
3096
3227
  }));
3097
3228
  function preloadPaymentMethods() {
3098
3229
  return _preloadPaymentMethods.apply(this, arguments);
@@ -3108,59 +3239,59 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3108
3239
  }, {
3109
3240
  key: "cleanupExpiredOrdersAsync",
3110
3241
  value: (function () {
3111
- var _cleanupExpiredOrdersAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40() {
3242
+ var _cleanupExpiredOrdersAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41() {
3112
3243
  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;
3113
- return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3114
- while (1) switch (_context40.prev = _context40.next) {
3244
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3245
+ while (1) switch (_context41.prev = _context41.next) {
3115
3246
  case 0:
3116
- _context40.prev = 0;
3247
+ _context41.prev = 0;
3117
3248
  // 检查是否启用了清理功能
3118
3249
  cleanupConfig = this.otherParams.orderDataCleanup || {};
3119
3250
  isCleanupEnabled = cleanupConfig.enabled !== false; // 默认启用
3120
3251
  retentionDays = cleanupConfig.retentionDays || 7; // 默认保留7天
3121
3252
  maxOrdersToDelete = cleanupConfig.maxOrdersToDelete || 100; // 默认最多删除100个订单
3122
3253
  if (isCleanupEnabled) {
3123
- _context40.next = 8;
3254
+ _context41.next = 8;
3124
3255
  break;
3125
3256
  }
3126
3257
  console.log('[Checkout] 订单数据清理功能已禁用');
3127
- return _context40.abrupt("return");
3258
+ return _context41.abrupt("return");
3128
3259
  case 8:
3129
3260
  console.log("[Checkout] \u5F00\u59CB\u6E05\u7406\u8FC7\u671F\u8BA2\u5355\u6570\u636E\uFF08\u4FDD\u7559 ".concat(retentionDays, " \u5929\u5185\u7684\u6570\u636E\uFF09..."));
3130
3261
 
3131
3262
  // 获取所有订单
3132
- _context40.next = 11;
3263
+ _context41.next = 11;
3133
3264
  return this.payment.getOrderListAsync();
3134
3265
  case 11:
3135
- allOrders = _context40.sent;
3266
+ allOrders = _context41.sent;
3136
3267
  if (!(!allOrders || allOrders.length === 0)) {
3137
- _context40.next = 15;
3268
+ _context41.next = 15;
3138
3269
  break;
3139
3270
  }
3140
3271
  console.log('[Checkout] 没有找到需要清理的订单数据');
3141
- return _context40.abrupt("return");
3272
+ return _context41.abrupt("return");
3142
3273
  case 15:
3143
3274
  thresholdDate = new Date();
3144
3275
  thresholdDate.setDate(thresholdDate.getDate() - retentionDays);
3145
3276
  deletedCount = 0;
3146
3277
  ordersToDelete = [];
3147
3278
  _iterator = _createForOfIteratorHelper(allOrders);
3148
- _context40.prev = 20;
3279
+ _context41.prev = 20;
3149
3280
  _iterator.s();
3150
3281
  case 22:
3151
3282
  if ((_step = _iterator.n()).done) {
3152
- _context40.next = 41;
3283
+ _context41.next = 41;
3153
3284
  break;
3154
3285
  }
3155
3286
  order = _step.value;
3156
- _context40.prev = 24;
3287
+ _context41.prev = 24;
3157
3288
  // 检查订单是否已同步(订单ID不是虚拟ID)
3158
3289
  isSynced = order.order_id && !isVirtualOrderId(order.order_id);
3159
3290
  if (isSynced) {
3160
- _context40.next = 28;
3291
+ _context41.next = 28;
3161
3292
  break;
3162
3293
  }
3163
- return _context40.abrupt("continue", 39);
3294
+ return _context41.abrupt("continue", 39);
3164
3295
  case 28:
3165
3296
  // 检查创建时间
3166
3297
  orderCreatedAt = null; // 尝试从 order_info.created_at 获取创建时间
@@ -3174,10 +3305,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3174
3305
 
3175
3306
  // 如果无法获取创建时间,跳过此订单
3176
3307
  if (!(!orderCreatedAt || isNaN(orderCreatedAt.getTime()))) {
3177
- _context40.next = 32;
3308
+ _context41.next = 32;
3178
3309
  break;
3179
3310
  }
3180
- return _context40.abrupt("continue", 39);
3311
+ return _context41.abrupt("continue", 39);
3181
3312
  case 32:
3182
3313
  // 检查是否超过指定天数
3183
3314
  if (orderCreatedAt < thresholdDate) {
@@ -3188,27 +3319,27 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3188
3319
  daysSinceCreated: Math.floor((Date.now() - orderCreatedAt.getTime()) / (1000 * 60 * 60 * 24))
3189
3320
  });
3190
3321
  }
3191
- _context40.next = 39;
3322
+ _context41.next = 39;
3192
3323
  break;
3193
3324
  case 35:
3194
- _context40.prev = 35;
3195
- _context40.t0 = _context40["catch"](24);
3196
- console.warn("[Checkout] \u5904\u7406\u8BA2\u5355 ".concat(order.uuid, " \u65F6\u51FA\u9519:"), _context40.t0);
3197
- return _context40.abrupt("continue", 39);
3325
+ _context41.prev = 35;
3326
+ _context41.t0 = _context41["catch"](24);
3327
+ console.warn("[Checkout] \u5904\u7406\u8BA2\u5355 ".concat(order.uuid, " \u65F6\u51FA\u9519:"), _context41.t0);
3328
+ return _context41.abrupt("continue", 39);
3198
3329
  case 39:
3199
- _context40.next = 22;
3330
+ _context41.next = 22;
3200
3331
  break;
3201
3332
  case 41:
3202
- _context40.next = 46;
3333
+ _context41.next = 46;
3203
3334
  break;
3204
3335
  case 43:
3205
- _context40.prev = 43;
3206
- _context40.t1 = _context40["catch"](20);
3207
- _iterator.e(_context40.t1);
3336
+ _context41.prev = 43;
3337
+ _context41.t1 = _context41["catch"](20);
3338
+ _iterator.e(_context41.t1);
3208
3339
  case 46:
3209
- _context40.prev = 46;
3340
+ _context41.prev = 46;
3210
3341
  _iterator.f();
3211
- return _context40.finish(46);
3342
+ return _context41.finish(46);
3212
3343
  case 49:
3213
3344
  // 按创建时间排序(最老的先删除)并限制删除数量
3214
3345
  ordersToDelete.sort(function (a, b) {
@@ -3216,40 +3347,40 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3216
3347
  });
3217
3348
  actualOrdersToDelete = ordersToDelete.slice(0, maxOrdersToDelete); // 删除符合条件的订单
3218
3349
  _iterator2 = _createForOfIteratorHelper(actualOrdersToDelete);
3219
- _context40.prev = 52;
3350
+ _context41.prev = 52;
3220
3351
  _iterator2.s();
3221
3352
  case 54:
3222
3353
  if ((_step2 = _iterator2.n()).done) {
3223
- _context40.next = 68;
3354
+ _context41.next = 68;
3224
3355
  break;
3225
3356
  }
3226
3357
  orderInfo = _step2.value;
3227
- _context40.prev = 56;
3228
- _context40.next = 59;
3358
+ _context41.prev = 56;
3359
+ _context41.next = 59;
3229
3360
  return this.payment.deletePaymentOrderAsync(orderInfo.uuid);
3230
3361
  case 59:
3231
3362
  deletedCount++;
3232
3363
  console.log("[Checkout] \u5DF2\u5220\u9664\u8FC7\u671F\u8BA2\u5355: ".concat(orderInfo.orderId, " (").concat(orderInfo.daysSinceCreated, " \u5929\u524D\u521B\u5EFA)"));
3233
- _context40.next = 66;
3364
+ _context41.next = 66;
3234
3365
  break;
3235
3366
  case 63:
3236
- _context40.prev = 63;
3237
- _context40.t2 = _context40["catch"](56);
3238
- console.error("[Checkout] \u5220\u9664\u8BA2\u5355 ".concat(orderInfo.uuid, " \u5931\u8D25:"), _context40.t2);
3367
+ _context41.prev = 63;
3368
+ _context41.t2 = _context41["catch"](56);
3369
+ console.error("[Checkout] \u5220\u9664\u8BA2\u5355 ".concat(orderInfo.uuid, " \u5931\u8D25:"), _context41.t2);
3239
3370
  case 66:
3240
- _context40.next = 54;
3371
+ _context41.next = 54;
3241
3372
  break;
3242
3373
  case 68:
3243
- _context40.next = 73;
3374
+ _context41.next = 73;
3244
3375
  break;
3245
3376
  case 70:
3246
- _context40.prev = 70;
3247
- _context40.t3 = _context40["catch"](52);
3248
- _iterator2.e(_context40.t3);
3377
+ _context41.prev = 70;
3378
+ _context41.t3 = _context41["catch"](52);
3379
+ _iterator2.e(_context41.t3);
3249
3380
  case 73:
3250
- _context40.prev = 73;
3381
+ _context41.prev = 73;
3251
3382
  _iterator2.f();
3252
- return _context40.finish(73);
3383
+ return _context41.finish(73);
3253
3384
  case 76:
3254
3385
  summary = {
3255
3386
  totalOrders: allOrders.length,
@@ -3267,21 +3398,21 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3267
3398
  } else {
3268
3399
  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"));
3269
3400
  }
3270
- _context40.next = 86;
3401
+ _context41.next = 86;
3271
3402
  break;
3272
3403
  case 81:
3273
- _context40.prev = 81;
3274
- _context40.t4 = _context40["catch"](0);
3275
- errorMessage = _context40.t4 instanceof Error ? _context40.t4.message : String(_context40.t4);
3276
- console.error('[Checkout] 清理过期订单数据失败:', _context40.t4);
3404
+ _context41.prev = 81;
3405
+ _context41.t4 = _context41["catch"](0);
3406
+ errorMessage = _context41.t4 instanceof Error ? _context41.t4.message : String(_context41.t4);
3407
+ console.error('[Checkout] 清理过期订单数据失败:', _context41.t4);
3277
3408
  this.logError('Expired orders cleanup failed', {
3278
3409
  error: errorMessage
3279
3410
  });
3280
3411
  case 86:
3281
3412
  case "end":
3282
- return _context40.stop();
3413
+ return _context41.stop();
3283
3414
  }
3284
- }, _callee40, this, [[0, 81], [20, 43, 46, 49], [24, 35], [52, 70, 73, 76], [56, 63]]);
3415
+ }, _callee41, this, [[0, 81], [20, 43, 46, 49], [24, 35], [52, 70, 73, 76], [56, 63]]);
3285
3416
  }));
3286
3417
  function cleanupExpiredOrdersAsync() {
3287
3418
  return _cleanupExpiredOrdersAsync.apply(this, arguments);
@@ -3295,24 +3426,24 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3295
3426
  }, {
3296
3427
  key: "calculatePaidAmountAsync",
3297
3428
  value: (function () {
3298
- var _calculatePaidAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41() {
3429
+ var _calculatePaidAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42() {
3299
3430
  var payments, paidAmount, result;
3300
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3301
- while (1) switch (_context41.prev = _context41.next) {
3431
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3432
+ while (1) switch (_context42.prev = _context42.next) {
3302
3433
  case 0:
3303
3434
  if (this.store.currentOrder) {
3304
- _context41.next = 3;
3435
+ _context42.next = 3;
3305
3436
  break;
3306
3437
  }
3307
3438
  console.log('[Checkout] calculatePaidAmountAsync: 没有当前订单');
3308
- return _context41.abrupt("return", '0.00');
3439
+ return _context42.abrupt("return", '0.00');
3309
3440
  case 3:
3310
- _context41.prev = 3;
3311
- _context41.next = 6;
3441
+ _context42.prev = 3;
3442
+ _context42.next = 6;
3312
3443
  return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid, false // 不包括已撤销的支付项
3313
3444
  );
3314
3445
  case 6:
3315
- payments = _context41.sent;
3446
+ payments = _context42.sent;
3316
3447
  console.log('[Checkout] calculatePaidAmountAsync: 支付项详情:', {
3317
3448
  paymentCount: payments.length,
3318
3449
  payments: payments.map(function (p) {
@@ -3346,17 +3477,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3346
3477
  }, 0);
3347
3478
  result = paidAmount.toFixed(2);
3348
3479
  console.log('[Checkout] calculatePaidAmountAsync: 计算结果 =', result);
3349
- return _context41.abrupt("return", result);
3480
+ return _context42.abrupt("return", result);
3350
3481
  case 14:
3351
- _context41.prev = 14;
3352
- _context41.t0 = _context41["catch"](3);
3353
- console.error('[Checkout] calculatePaidAmountAsync 失败:', _context41.t0);
3354
- return _context41.abrupt("return", '0.00');
3482
+ _context42.prev = 14;
3483
+ _context42.t0 = _context42["catch"](3);
3484
+ console.error('[Checkout] calculatePaidAmountAsync 失败:', _context42.t0);
3485
+ return _context42.abrupt("return", '0.00');
3355
3486
  case 18:
3356
3487
  case "end":
3357
- return _context41.stop();
3488
+ return _context42.stop();
3358
3489
  }
3359
- }, _callee41, this, [[3, 14]]);
3490
+ }, _callee42, this, [[3, 14]]);
3360
3491
  }));
3361
3492
  function calculatePaidAmountAsync() {
3362
3493
  return _calculatePaidAmountAsync.apply(this, arguments);
@@ -3370,25 +3501,25 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3370
3501
  }, {
3371
3502
  key: "calculateRemainingAmountAsync",
3372
3503
  value: (function () {
3373
- var _calculateRemainingAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42() {
3504
+ var _calculateRemainingAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43() {
3374
3505
  var totalAmount, paidAmount, remainingAmount, result;
3375
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3376
- while (1) switch (_context42.prev = _context42.next) {
3506
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3507
+ while (1) switch (_context43.prev = _context43.next) {
3377
3508
  case 0:
3378
3509
  if (this.store.currentOrder) {
3379
- _context42.next = 3;
3510
+ _context43.next = 3;
3380
3511
  break;
3381
3512
  }
3382
3513
  console.log('[Checkout] calculateRemainingAmountAsync: 没有当前订单');
3383
- return _context42.abrupt("return", '0.00');
3514
+ return _context43.abrupt("return", '0.00');
3384
3515
  case 3:
3385
3516
  totalAmount = parseFloat(this.store.currentOrder.total_amount || '0');
3386
- _context42.t0 = parseFloat;
3387
- _context42.next = 7;
3517
+ _context43.t0 = parseFloat;
3518
+ _context43.next = 7;
3388
3519
  return this.calculatePaidAmountAsync();
3389
3520
  case 7:
3390
- _context42.t1 = _context42.sent;
3391
- paidAmount = (0, _context42.t0)(_context42.t1);
3521
+ _context43.t1 = _context43.sent;
3522
+ paidAmount = (0, _context43.t0)(_context43.t1);
3392
3523
  remainingAmount = totalAmount - paidAmount;
3393
3524
  result = Math.max(0, remainingAmount).toFixed(2);
3394
3525
  console.log('[Checkout] calculateRemainingAmountAsync: 计算详情:', {
@@ -3399,12 +3530,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3399
3530
  finalResult: result,
3400
3531
  说明: '已支付金额包含抹零计算(amount + |rounding_amount|)'
3401
3532
  });
3402
- return _context42.abrupt("return", result);
3533
+ return _context43.abrupt("return", result);
3403
3534
  case 13:
3404
3535
  case "end":
3405
- return _context42.stop();
3536
+ return _context43.stop();
3406
3537
  }
3407
- }, _callee42, this);
3538
+ }, _callee43, this);
3408
3539
  }));
3409
3540
  function calculateRemainingAmountAsync() {
3410
3541
  return _calculateRemainingAmountAsync.apply(this, arguments);
@@ -3418,16 +3549,16 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3418
3549
  }, {
3419
3550
  key: "updateBalanceDueAmount",
3420
3551
  value: (function () {
3421
- var _updateBalanceDueAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43() {
3552
+ var _updateBalanceDueAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
3422
3553
  var _this$store$currentOr24, remainingAmount, currentBalanceDueAmount;
3423
- return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3424
- while (1) switch (_context43.prev = _context43.next) {
3554
+ return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3555
+ while (1) switch (_context44.prev = _context44.next) {
3425
3556
  case 0:
3426
- _context43.prev = 0;
3427
- _context43.next = 3;
3557
+ _context44.prev = 0;
3558
+ _context44.next = 3;
3428
3559
  return this.calculateRemainingAmountAsync();
3429
3560
  case 3:
3430
- remainingAmount = _context43.sent;
3561
+ remainingAmount = _context44.sent;
3431
3562
  currentBalanceDueAmount = this.store.balanceDueAmount;
3432
3563
  console.log('[Checkout] updateBalanceDueAmount: 状态检查:', {
3433
3564
  calculatedRemainingAmount: remainingAmount,
@@ -3438,13 +3569,13 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3438
3569
 
3439
3570
  // 只有当剩余金额与当前 balanceDueAmount 不同时才更新
3440
3571
  if (!(remainingAmount !== currentBalanceDueAmount)) {
3441
- _context43.next = 13;
3572
+ _context44.next = 13;
3442
3573
  break;
3443
3574
  }
3444
3575
  this.store.balanceDueAmount = remainingAmount;
3445
3576
 
3446
3577
  // 发出 balanceDueAmount 变更事件
3447
- _context43.next = 10;
3578
+ _context44.next = 10;
3448
3579
  return this.core.effects.emit(CheckoutHooks.OnBalanceDueAmountChanged, {
3449
3580
  oldAmount: currentBalanceDueAmount,
3450
3581
  newAmount: remainingAmount,
@@ -3455,7 +3586,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3455
3586
  oldAmount: currentBalanceDueAmount,
3456
3587
  newAmount: remainingAmount
3457
3588
  });
3458
- _context43.next = 14;
3589
+ _context44.next = 14;
3459
3590
  break;
3460
3591
  case 13:
3461
3592
  console.log('[Checkout] balanceDueAmount 无需更新,当前值已是最新:', {
@@ -3463,17 +3594,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3463
3594
  remainingAmount: remainingAmount
3464
3595
  });
3465
3596
  case 14:
3466
- _context43.next = 19;
3597
+ _context44.next = 19;
3467
3598
  break;
3468
3599
  case 16:
3469
- _context43.prev = 16;
3470
- _context43.t0 = _context43["catch"](0);
3471
- console.error('[Checkout] 更新 balanceDueAmount 失败:', _context43.t0);
3600
+ _context44.prev = 16;
3601
+ _context44.t0 = _context44["catch"](0);
3602
+ console.error('[Checkout] 更新 balanceDueAmount 失败:', _context44.t0);
3472
3603
  case 19:
3473
3604
  case "end":
3474
- return _context43.stop();
3605
+ return _context44.stop();
3475
3606
  }
3476
- }, _callee43, this, [[0, 16]]);
3607
+ }, _callee44, this, [[0, 16]]);
3477
3608
  }));
3478
3609
  function updateBalanceDueAmount() {
3479
3610
  return _updateBalanceDueAmount.apply(this, arguments);
@@ -3487,16 +3618,16 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3487
3618
  }, {
3488
3619
  key: "updateStateAmountToRemaining",
3489
3620
  value: (function () {
3490
- var _updateStateAmountToRemaining = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
3621
+ var _updateStateAmountToRemaining = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45() {
3491
3622
  var _this$store$currentOr25, remainingAmount, currentStateAmount;
3492
- return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3493
- while (1) switch (_context44.prev = _context44.next) {
3623
+ return _regeneratorRuntime().wrap(function _callee45$(_context45) {
3624
+ while (1) switch (_context45.prev = _context45.next) {
3494
3625
  case 0:
3495
- _context44.prev = 0;
3496
- _context44.next = 3;
3626
+ _context45.prev = 0;
3627
+ _context45.next = 3;
3497
3628
  return this.calculateRemainingAmountAsync();
3498
3629
  case 3:
3499
- remainingAmount = _context44.sent;
3630
+ remainingAmount = _context45.sent;
3500
3631
  currentStateAmount = this.store.stateAmount;
3501
3632
  console.log('[Checkout] updateStateAmountToRemaining: 状态检查:', {
3502
3633
  calculatedRemainingAmount: remainingAmount,
@@ -3527,23 +3658,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3527
3658
  }
3528
3659
 
3529
3660
  // 同步更新系统内部的 balanceDueAmount
3530
- _context44.next = 9;
3661
+ _context45.next = 9;
3531
3662
  return this.updateBalanceDueAmount();
3532
3663
  case 9:
3533
- _context44.next = 11;
3664
+ _context45.next = 11;
3534
3665
  return this.checkOrderPaymentCompletion();
3535
3666
  case 11:
3536
- _context44.next = 16;
3667
+ _context45.next = 16;
3537
3668
  break;
3538
3669
  case 13:
3539
- _context44.prev = 13;
3540
- _context44.t0 = _context44["catch"](0);
3541
- console.error('[Checkout] 更新 stateAmount 为剩余金额失败:', _context44.t0);
3670
+ _context45.prev = 13;
3671
+ _context45.t0 = _context45["catch"](0);
3672
+ console.error('[Checkout] 更新 stateAmount 为剩余金额失败:', _context45.t0);
3542
3673
  case 16:
3543
3674
  case "end":
3544
- return _context44.stop();
3675
+ return _context45.stop();
3545
3676
  }
3546
- }, _callee44, this, [[0, 13]]);
3677
+ }, _callee45, this, [[0, 13]]);
3547
3678
  }));
3548
3679
  function updateStateAmountToRemaining() {
3549
3680
  return _updateStateAmountToRemaining.apply(this, arguments);
@@ -3559,32 +3690,32 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3559
3690
  }, {
3560
3691
  key: "checkOrderPaymentCompletion",
3561
3692
  value: (function () {
3562
- var _checkOrderPaymentCompletion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45() {
3693
+ var _checkOrderPaymentCompletion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
3563
3694
  var remainingAmount, remainingValue, totalAmount, paidAmount, currentPayments, hasPaymentItems, allPaymentsHaveVoucherId, shouldAutoSync;
3564
- return _regeneratorRuntime().wrap(function _callee45$(_context45) {
3565
- while (1) switch (_context45.prev = _context45.next) {
3695
+ return _regeneratorRuntime().wrap(function _callee46$(_context46) {
3696
+ while (1) switch (_context46.prev = _context46.next) {
3566
3697
  case 0:
3567
- _context45.prev = 0;
3698
+ _context46.prev = 0;
3568
3699
  if (this.store.currentOrder) {
3569
- _context45.next = 3;
3700
+ _context46.next = 3;
3570
3701
  break;
3571
3702
  }
3572
- return _context45.abrupt("return");
3703
+ return _context46.abrupt("return");
3573
3704
  case 3:
3574
- _context45.next = 5;
3705
+ _context46.next = 5;
3575
3706
  return this.calculateRemainingAmountAsync();
3576
3707
  case 5:
3577
- remainingAmount = _context45.sent;
3708
+ remainingAmount = _context46.sent;
3578
3709
  remainingValue = parseFloat(remainingAmount); // 当剩余金额小于等于0时,认为订单已完成支付
3579
3710
  if (!(remainingValue <= 0)) {
3580
- _context45.next = 29;
3711
+ _context46.next = 29;
3581
3712
  break;
3582
3713
  }
3583
3714
  totalAmount = this.store.currentOrder.total_amount;
3584
- _context45.next = 11;
3715
+ _context46.next = 11;
3585
3716
  return this.calculatePaidAmountAsync();
3586
3717
  case 11:
3587
- paidAmount = _context45.sent;
3718
+ paidAmount = _context46.sent;
3588
3719
  console.log('[Checkout] 检测到订单支付完成:', {
3589
3720
  orderUuid: this.store.currentOrder.uuid,
3590
3721
  orderId: this.store.currentOrder.order_id,
@@ -3595,11 +3726,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3595
3726
  });
3596
3727
 
3597
3728
  // 从 Payment 模块获取最新支付项,检查自动同步条件
3598
- _context45.next = 15;
3729
+ _context46.next = 15;
3599
3730
  return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid, false // 不包括已撤销的支付项
3600
3731
  );
3601
3732
  case 15:
3602
- currentPayments = _context45.sent;
3733
+ currentPayments = _context46.sent;
3603
3734
  // 检查自动同步条件:
3604
3735
  // 1. 待付金额为 0 ✓ (已在上面检查)
3605
3736
  // 2. 需要有支付项
@@ -3633,14 +3764,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3633
3764
  })
3634
3765
  });
3635
3766
  if (!shouldAutoSync) {
3636
- _context45.next = 26;
3767
+ _context46.next = 26;
3637
3768
  break;
3638
3769
  }
3639
3770
  console.log('[Checkout] 满足自动同步条件,开始同步订单到后端...');
3640
- _context45.next = 24;
3771
+ _context46.next = 24;
3641
3772
  return this.syncOrderToBackend();
3642
3773
  case 24:
3643
- _context45.next = 27;
3774
+ _context46.next = 27;
3644
3775
  break;
3645
3776
  case 26:
3646
3777
  if (!hasPaymentItems) {
@@ -3649,7 +3780,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3649
3780
  console.log('[Checkout] 所有支付项均为代金券类型,跳过订单同步');
3650
3781
  }
3651
3782
  case 27:
3652
- _context45.next = 29;
3783
+ _context46.next = 29;
3653
3784
  return this.core.effects.emit(CheckoutHooks.OnOrderPaymentCompleted, {
3654
3785
  orderUuid: this.store.currentOrder.uuid,
3655
3786
  orderId: this.store.currentOrder.order_id,
@@ -3659,17 +3790,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3659
3790
  timestamp: Date.now()
3660
3791
  });
3661
3792
  case 29:
3662
- _context45.next = 34;
3793
+ _context46.next = 34;
3663
3794
  break;
3664
3795
  case 31:
3665
- _context45.prev = 31;
3666
- _context45.t0 = _context45["catch"](0);
3667
- console.error('[Checkout] 检查订单支付完成状态失败:', _context45.t0);
3796
+ _context46.prev = 31;
3797
+ _context46.t0 = _context46["catch"](0);
3798
+ console.error('[Checkout] 检查订单支付完成状态失败:', _context46.t0);
3668
3799
  case 34:
3669
3800
  case "end":
3670
- return _context45.stop();
3801
+ return _context46.stop();
3671
3802
  }
3672
- }, _callee45, this, [[0, 31]]);
3803
+ }, _callee46, this, [[0, 31]]);
3673
3804
  }));
3674
3805
  function checkOrderPaymentCompletion() {
3675
3806
  return _checkOrderPaymentCompletion.apply(this, arguments);
@@ -3692,7 +3823,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3692
3823
  }, {
3693
3824
  key: "syncOrderToBackendWithReturn",
3694
3825
  value: (function () {
3695
- var _syncOrderToBackendWithReturn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
3826
+ var _syncOrderToBackendWithReturn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47() {
3696
3827
  var _this$store$currentCu2,
3697
3828
  _this4 = this,
3698
3829
  _processedPaymentItem,
@@ -3740,14 +3871,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3740
3871
  beforeManualUpdate,
3741
3872
  finalOrderId,
3742
3873
  finalIsVirtual,
3743
- _args46 = arguments;
3744
- return _regeneratorRuntime().wrap(function _callee46$(_context46) {
3745
- while (1) switch (_context46.prev = _context46.next) {
3874
+ _args47 = arguments;
3875
+ return _regeneratorRuntime().wrap(function _callee47$(_context47) {
3876
+ while (1) switch (_context47.prev = _context47.next) {
3746
3877
  case 0:
3747
- isManual = _args46.length > 0 && _args46[0] !== undefined ? _args46[0] : false;
3748
- customPaymentItems = _args46.length > 1 ? _args46[1] : undefined;
3878
+ isManual = _args47.length > 0 && _args47[0] !== undefined ? _args47[0] : false;
3879
+ customPaymentItems = _args47.length > 1 ? _args47[1] : undefined;
3749
3880
  if (!(!this.store.localOrderData || !this.store.currentOrder)) {
3750
- _context46.next = 4;
3881
+ _context47.next = 4;
3751
3882
  break;
3752
3883
  }
3753
3884
  throw new Error('缺少必要的订单数据,无法同步到后端');
@@ -3800,17 +3931,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3800
3931
  });
3801
3932
 
3802
3933
  // 获取当前订单的支付项
3803
- _context46.t0 = customPaymentItems;
3804
- if (_context46.t0) {
3805
- _context46.next = 19;
3934
+ _context47.t0 = customPaymentItems;
3935
+ if (_context47.t0) {
3936
+ _context47.next = 19;
3806
3937
  break;
3807
3938
  }
3808
- _context46.next = 18;
3939
+ _context47.next = 18;
3809
3940
  return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid);
3810
3941
  case 18:
3811
- _context46.t0 = _context46.sent;
3942
+ _context47.t0 = _context47.sent;
3812
3943
  case 19:
3813
- paymentItems = _context46.t0;
3944
+ paymentItems = _context47.t0;
3814
3945
  console.log('[Checkout] 获取到支付项:', {
3815
3946
  count: paymentItems.length,
3816
3947
  isCustomFiltered: !!customPaymentItems,
@@ -3849,10 +3980,16 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3849
3980
  processedCount: processedPaymentItems.length,
3850
3981
  sampleMetadata: (_processedPaymentItem = processedPaymentItems[0]) === null || _processedPaymentItem === void 0 ? void 0 : _processedPaymentItem.metadata,
3851
3982
  allPaymentItems: processedPaymentItems.map(function (p) {
3983
+ var _p$metadata2, _p$metadata3;
3852
3984
  return {
3853
3985
  code: p.code,
3854
3986
  amount: p.amount,
3855
- metadata: p.metadata
3987
+ voucherId: p.voucher_id,
3988
+ orderPaymentType: p.order_payment_type,
3989
+ metadata: p.metadata,
3990
+ // 现金支付找零信息
3991
+ actualPaidAmount: (_p$metadata2 = p.metadata) === null || _p$metadata2 === void 0 ? void 0 : _p$metadata2.actual_paid_amount,
3992
+ changeGivenAmount: (_p$metadata3 = p.metadata) === null || _p$metadata3 === void 0 ? void 0 : _p$metadata3.change_given_amount
3856
3993
  };
3857
3994
  })
3858
3995
  });
@@ -3909,7 +4046,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3909
4046
 
3910
4047
  // 发送下单接口请求开始事件
3911
4048
  startTime = Date.now();
3912
- _context46.next = 28;
4049
+ _context47.next = 28;
3913
4050
  return this.core.effects.emit(CheckoutHooks.OnOrderSubmitStart, {
3914
4051
  orderUuid: this.store.currentOrder.uuid,
3915
4052
  operation: isUpdateOperation ? 'update' : 'create',
@@ -3919,7 +4056,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3919
4056
  });
3920
4057
  case 28:
3921
4058
  submitSuccess = false;
3922
- _context46.prev = 29;
4059
+ _context47.prev = 29;
3923
4060
  // 记录接口调用参数
3924
4061
  this.logInfo('Calling backend checkout API', {
3925
4062
  url: '/order/checkout',
@@ -3944,23 +4081,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3944
4081
  });
3945
4082
 
3946
4083
  // 调用 Order 模块的专用 createOrderByCheckout 方法
3947
- _context46.next = 33;
4084
+ _context47.next = 33;
3948
4085
  return this.order.createOrderByCheckout(orderParams);
3949
4086
  case 33:
3950
- checkoutResponse = _context46.sent;
4087
+ checkoutResponse = _context47.sent;
3951
4088
  submitSuccess = true;
3952
4089
  console.log('[Checkout] 下单接口调用成功');
3953
- _context46.next = 45;
4090
+ _context47.next = 45;
3954
4091
  break;
3955
4092
  case 38:
3956
- _context46.prev = 38;
3957
- _context46.t1 = _context46["catch"](29);
4093
+ _context47.prev = 38;
4094
+ _context47.t1 = _context47["catch"](29);
3958
4095
  submitSuccess = false;
3959
- submitError = _context46.t1 instanceof Error ? _context46.t1.message : String(_context46.t1);
4096
+ submitError = _context47.t1 instanceof Error ? _context47.t1.message : String(_context47.t1);
3960
4097
  // console.error('[Checkout] 下单接口调用失败:', submitError);
3961
4098
 
3962
4099
  // 发送订单同步失败事件(网络错误或请求失败)
3963
- _context46.next = 44;
4100
+ _context47.next = 44;
3964
4101
  return this.core.effects.emit(CheckoutHooks.OnOrderSyncFailed, {
3965
4102
  orderUuid: this.store.currentOrder.uuid,
3966
4103
  operation: isUpdateOperation ? 'update' : 'create',
@@ -3971,10 +4108,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3971
4108
  timestamp: Date.now()
3972
4109
  });
3973
4110
  case 44:
3974
- throw _context46.t1;
4111
+ throw _context47.t1;
3975
4112
  case 45:
3976
- _context46.prev = 45;
3977
- _context46.next = 48;
4113
+ _context47.prev = 45;
4114
+ _context47.next = 48;
3978
4115
  return this.core.effects.emit(CheckoutHooks.OnOrderSubmitEnd, {
3979
4116
  success: submitSuccess,
3980
4117
  orderUuid: this.store.currentOrder.uuid,
@@ -3986,7 +4123,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3986
4123
  timestamp: Date.now()
3987
4124
  });
3988
4125
  case 48:
3989
- return _context46.finish(45);
4126
+ return _context47.finish(45);
3990
4127
  case 49:
3991
4128
  console.log('[Checkout] 后端返回的响应数据:', {
3992
4129
  status: (_checkoutResponse3 = checkoutResponse) === null || _checkoutResponse3 === void 0 ? void 0 : _checkoutResponse3.status,
@@ -3999,7 +4136,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3999
4136
  responseStatus = (_checkoutResponse7 = checkoutResponse) === null || _checkoutResponse7 === void 0 ? void 0 : _checkoutResponse7.status;
4000
4137
  isSuccessResponse = responseStatus === true || responseStatus === 200 || responseStatus === 'success' || responseStatus === 1 && ((_checkoutResponse8 = checkoutResponse) === null || _checkoutResponse8 === void 0 ? void 0 : _checkoutResponse8.code) === 200;
4001
4138
  if (isSuccessResponse) {
4002
- _context46.next = 58;
4139
+ _context47.next = 58;
4003
4140
  break;
4004
4141
  }
4005
4142
  errorMessage = ((_checkoutResponse9 = checkoutResponse) === null || _checkoutResponse9 === void 0 ? void 0 : _checkoutResponse9.message) || '订单同步失败,后端返回非成功状态';
@@ -4012,7 +4149,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4012
4149
  });
4013
4150
 
4014
4151
  // 发送订单同步失败事件
4015
- _context46.next = 57;
4152
+ _context47.next = 57;
4016
4153
  return this.core.effects.emit(CheckoutHooks.OnOrderSyncFailed, {
4017
4154
  orderUuid: this.store.currentOrder.uuid,
4018
4155
  operation: isUpdateOperation ? 'update' : 'create',
@@ -4028,13 +4165,13 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4028
4165
  case 58:
4029
4166
  console.log('[Checkout] 响应状态检查通过,开始处理订单数据');
4030
4167
  if (!isUpdateOperation) {
4031
- _context46.next = 64;
4168
+ _context47.next = 64;
4032
4169
  break;
4033
4170
  }
4034
4171
  // 更新操作:使用现有的订单ID
4035
4172
  realOrderId = currentOrderId;
4036
4173
  console.log("[Checkout] \u8BA2\u5355\u66F4\u65B0\u6210\u529F\uFF0C\u8BA2\u5355ID: ".concat(realOrderId));
4037
- _context46.next = 85;
4174
+ _context47.next = 85;
4038
4175
  break;
4039
4176
  case 64:
4040
4177
  // 创建操作:从响应中提取新的订单ID
@@ -4048,7 +4185,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4048
4185
  extractedOrderId = String(extractedOrderId);
4049
4186
  }
4050
4187
  if (extractedOrderId) {
4051
- _context46.next = 69;
4188
+ _context47.next = 69;
4052
4189
  break;
4053
4190
  }
4054
4191
  throw new Error('后端返回的订单信息中未包含订单ID');
@@ -4062,11 +4199,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4062
4199
  oldOrderId: this.store.currentOrder.order_id,
4063
4200
  newOrderId: realOrderId
4064
4201
  });
4065
- _context46.prev = 72;
4066
- _context46.next = 75;
4202
+ _context47.prev = 72;
4203
+ _context47.next = 75;
4067
4204
  return this.payment.replaceOrderIdByUuidAsync(this.store.currentOrder.uuid, realOrderId);
4068
4205
  case 75:
4069
- updatedOrder = _context46.sent;
4206
+ updatedOrder = _context47.sent;
4070
4207
  console.log('[Checkout] Payment模块替换订单ID结果:', {
4071
4208
  wasSuccessful: !!updatedOrder,
4072
4209
  returnedOrderId: updatedOrder === null || updatedOrder === void 0 ? void 0 : updatedOrder.order_id,
@@ -4092,12 +4229,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4092
4229
  目标ID: realOrderId
4093
4230
  });
4094
4231
  }
4095
- _context46.next = 85;
4232
+ _context47.next = 85;
4096
4233
  break;
4097
4234
  case 80:
4098
- _context46.prev = 80;
4099
- _context46.t2 = _context46["catch"](72);
4100
- console.error('[Checkout] 调用Payment模块替换订单ID时发生错误:', _context46.t2);
4235
+ _context47.prev = 80;
4236
+ _context47.t2 = _context47["catch"](72);
4237
+ console.error('[Checkout] 调用Payment模块替换订单ID时发生错误:', _context47.t2);
4101
4238
 
4102
4239
  // 发生错误时也进行手动替换
4103
4240
  this.store.currentOrder.order_id = realOrderId;
@@ -4107,7 +4244,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4107
4244
  this.store.isOrderSynced = true;
4108
4245
 
4109
4246
  // 触发订单同步完成事件
4110
- _context46.next = 88;
4247
+ _context47.next = 88;
4111
4248
  return this.core.effects.emit(CheckoutHooks.OnOrderSynced, {
4112
4249
  orderUuid: this.store.currentOrder.uuid,
4113
4250
  realOrderId: realOrderId,
@@ -4133,7 +4270,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4133
4270
  }
4134
4271
 
4135
4272
  // 返回同步结果
4136
- return _context46.abrupt("return", {
4273
+ return _context47.abrupt("return", {
4137
4274
  success: true,
4138
4275
  message: "\u8BA2\u5355".concat(operation, "\u6210\u529F"),
4139
4276
  orderId: realOrderId,
@@ -4142,9 +4279,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4142
4279
  });
4143
4280
  case 93:
4144
4281
  case "end":
4145
- return _context46.stop();
4282
+ return _context47.stop();
4146
4283
  }
4147
- }, _callee46, this, [[29, 38, 45, 49], [72, 80]]);
4284
+ }, _callee47, this, [[29, 38, 45, 49], [72, 80]]);
4148
4285
  }));
4149
4286
  function syncOrderToBackendWithReturn() {
4150
4287
  return _syncOrderToBackendWithReturn.apply(this, arguments);
@@ -4154,30 +4291,30 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4154
4291
  }, {
4155
4292
  key: "syncOrderToBackend",
4156
4293
  value: function () {
4157
- var _syncOrderToBackend = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47() {
4294
+ var _syncOrderToBackend = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48() {
4158
4295
  var syncResult;
4159
- return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4160
- while (1) switch (_context47.prev = _context47.next) {
4296
+ return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4297
+ while (1) switch (_context48.prev = _context48.next) {
4161
4298
  case 0:
4162
- _context47.prev = 0;
4163
- _context47.next = 3;
4299
+ _context48.prev = 0;
4300
+ _context48.next = 3;
4164
4301
  return this.syncOrderToBackendWithReturn(false);
4165
4302
  case 3:
4166
- syncResult = _context47.sent;
4303
+ syncResult = _context48.sent;
4167
4304
  console.log('[Checkout] 自动同步订单完成:', syncResult);
4168
- _context47.next = 12;
4305
+ _context48.next = 12;
4169
4306
  break;
4170
4307
  case 7:
4171
- _context47.prev = 7;
4172
- _context47.t0 = _context47["catch"](0);
4173
- console.error('[Checkout] 同步订单到后端失败:', _context47.t0);
4174
- _context47.next = 12;
4175
- return this.handleError(new Error("\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(_context47.t0 instanceof Error ? _context47.t0.message : String(_context47.t0))), CheckoutErrorType.OrderCreationFailed);
4308
+ _context48.prev = 7;
4309
+ _context48.t0 = _context48["catch"](0);
4310
+ console.error('[Checkout] 同步订单到后端失败:', _context48.t0);
4311
+ _context48.next = 12;
4312
+ return this.handleError(new Error("\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(_context48.t0 instanceof Error ? _context48.t0.message : String(_context48.t0))), CheckoutErrorType.OrderCreationFailed);
4176
4313
  case 12:
4177
4314
  case "end":
4178
- return _context47.stop();
4315
+ return _context48.stop();
4179
4316
  }
4180
- }, _callee47, this, [[0, 7]]);
4317
+ }, _callee48, this, [[0, 7]]);
4181
4318
  }));
4182
4319
  function syncOrderToBackend() {
4183
4320
  return _syncOrderToBackend.apply(this, arguments);
@@ -4217,15 +4354,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4217
4354
  }, {
4218
4355
  key: "setOtherParams",
4219
4356
  value: function () {
4220
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(params) {
4357
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(params) {
4221
4358
  var _ref5,
4222
4359
  _ref5$cover,
4223
4360
  cover,
4224
- _args48 = arguments;
4225
- return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4226
- while (1) switch (_context48.prev = _context48.next) {
4361
+ _args49 = arguments;
4362
+ return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4363
+ while (1) switch (_context49.prev = _context49.next) {
4227
4364
  case 0:
4228
- _ref5 = _args48.length > 1 && _args48[1] !== undefined ? _args48[1] : {}, _ref5$cover = _ref5.cover, cover = _ref5$cover === void 0 ? false : _ref5$cover;
4365
+ _ref5 = _args49.length > 1 && _args49[1] !== undefined ? _args49[1] : {}, _ref5$cover = _ref5.cover, cover = _ref5$cover === void 0 ? false : _ref5$cover;
4229
4366
  if (cover) {
4230
4367
  this.otherParams = params;
4231
4368
  } else {
@@ -4233,11 +4370,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4233
4370
  }
4234
4371
  case 2:
4235
4372
  case "end":
4236
- return _context48.stop();
4373
+ return _context49.stop();
4237
4374
  }
4238
- }, _callee48, this);
4375
+ }, _callee49, this);
4239
4376
  }));
4240
- function setOtherParams(_x28) {
4377
+ function setOtherParams(_x29) {
4241
4378
  return _setOtherParams.apply(this, arguments);
4242
4379
  }
4243
4380
  return setOtherParams;
@@ -4254,10 +4391,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4254
4391
  }, {
4255
4392
  key: "editOrderNoteByOrderIdAsync",
4256
4393
  value: (function () {
4257
- var _editOrderNoteByOrderIdAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(orderId, note) {
4394
+ var _editOrderNoteByOrderIdAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(orderId, note) {
4258
4395
  var response, previousNote, errorMessage, _errorMessage;
4259
- return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4260
- while (1) switch (_context49.prev = _context49.next) {
4396
+ return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4397
+ while (1) switch (_context50.prev = _context50.next) {
4261
4398
  case 0:
4262
4399
  this.logInfo('editOrderNoteByOrderIdAsync called', {
4263
4400
  orderId: orderId,
@@ -4265,7 +4402,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4265
4402
  noteLength: note.length,
4266
4403
  isCurrentOrder: this.store.currentOrder && (String(this.store.currentOrder.order_id) === String(orderId) || String(this.store.currentOrder.id) === String(orderId))
4267
4404
  });
4268
- _context49.prev = 1;
4405
+ _context50.prev = 1;
4269
4406
  console.log('[Checkout] 开始编辑订单备注:', {
4270
4407
  orderId: orderId,
4271
4408
  note: note,
@@ -4274,10 +4411,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4274
4411
 
4275
4412
  // 参数验证
4276
4413
  if (orderId) {
4277
- _context49.next = 5;
4414
+ _context50.next = 5;
4278
4415
  break;
4279
4416
  }
4280
- return _context49.abrupt("return", {
4417
+ return _context50.abrupt("return", {
4281
4418
  success: false,
4282
4419
  message: '订单ID不能为空',
4283
4420
  orderId: orderId
@@ -4293,12 +4430,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4293
4430
  });
4294
4431
 
4295
4432
  // 调用后端API修改订单备注
4296
- _context49.next = 8;
4433
+ _context50.next = 8;
4297
4434
  return this.request.put("/order/order/".concat(orderId, "/note"), {
4298
4435
  note: note
4299
4436
  });
4300
4437
  case 8:
4301
- response = _context49.sent;
4438
+ response = _context50.sent;
4302
4439
  console.log('[Checkout] 订单备注编辑响应:', {
4303
4440
  orderId: orderId,
4304
4441
  status: response.status,
@@ -4308,14 +4445,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4308
4445
 
4309
4446
  // 检查响应状态
4310
4447
  if (!(response.status === true || response.status === 200)) {
4311
- _context49.next = 21;
4448
+ _context50.next = 21;
4312
4449
  break;
4313
4450
  }
4314
4451
  console.log("[Checkout] \u8BA2\u5355 ".concat(orderId, " \u5907\u6CE8\u4FEE\u6539\u6210\u529F"));
4315
4452
 
4316
4453
  // 如果当前订单就是被修改的订单,同时更新本地状态
4317
4454
  if (!(this.store.currentOrder && (String(this.store.currentOrder.order_id) === String(orderId) || String(this.store.currentOrder.id) === String(orderId)))) {
4318
- _context49.next = 18;
4455
+ _context50.next = 18;
4319
4456
  break;
4320
4457
  }
4321
4458
  console.log('[Checkout] 更新本地订单备注状态');
@@ -4327,7 +4464,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4327
4464
  }
4328
4465
 
4329
4466
  // 触发订单备注变更事件
4330
- _context49.next = 18;
4467
+ _context50.next = 18;
4331
4468
  return this.core.effects.emit(CheckoutHooks.OnOrderNoteChanged, {
4332
4469
  orderUuid: this.store.currentOrder.uuid,
4333
4470
  oldNote: previousNote,
@@ -4335,7 +4472,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4335
4472
  timestamp: Date.now()
4336
4473
  });
4337
4474
  case 18:
4338
- return _context49.abrupt("return", {
4475
+ return _context50.abrupt("return", {
4339
4476
  success: true,
4340
4477
  message: response.message || '订单备注修改成功',
4341
4478
  orderId: orderId
@@ -4344,31 +4481,31 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4344
4481
  // API返回失败状态
4345
4482
  errorMessage = response.message || '订单备注修改失败';
4346
4483
  console.error("[Checkout] \u8BA2\u5355 ".concat(orderId, " \u5907\u6CE8\u4FEE\u6539\u5931\u8D25:"), errorMessage);
4347
- return _context49.abrupt("return", {
4484
+ return _context50.abrupt("return", {
4348
4485
  success: false,
4349
4486
  message: errorMessage,
4350
4487
  orderId: orderId
4351
4488
  });
4352
4489
  case 24:
4353
- _context49.next = 31;
4490
+ _context50.next = 31;
4354
4491
  break;
4355
4492
  case 26:
4356
- _context49.prev = 26;
4357
- _context49.t0 = _context49["catch"](1);
4358
- console.error('[Checkout] 编辑订单备注失败:', _context49.t0);
4359
- _errorMessage = _context49.t0 instanceof Error ? _context49.t0.message : '网络错误或服务器异常';
4360
- return _context49.abrupt("return", {
4493
+ _context50.prev = 26;
4494
+ _context50.t0 = _context50["catch"](1);
4495
+ console.error('[Checkout] 编辑订单备注失败:', _context50.t0);
4496
+ _errorMessage = _context50.t0 instanceof Error ? _context50.t0.message : '网络错误或服务器异常';
4497
+ return _context50.abrupt("return", {
4361
4498
  success: false,
4362
4499
  message: "\u7F16\u8F91\u8BA2\u5355\u5907\u6CE8\u5931\u8D25: ".concat(_errorMessage),
4363
4500
  orderId: orderId
4364
4501
  });
4365
4502
  case 31:
4366
4503
  case "end":
4367
- return _context49.stop();
4504
+ return _context50.stop();
4368
4505
  }
4369
- }, _callee49, this, [[1, 26]]);
4506
+ }, _callee50, this, [[1, 26]]);
4370
4507
  }));
4371
- function editOrderNoteByOrderIdAsync(_x29, _x30) {
4508
+ function editOrderNoteByOrderIdAsync(_x30, _x31) {
4372
4509
  return _editOrderNoteByOrderIdAsync.apply(this, arguments);
4373
4510
  }
4374
4511
  return editOrderNoteByOrderIdAsync;
@@ -4385,11 +4522,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4385
4522
  }, {
4386
4523
  key: "sendCustomerPayLinkAsync",
4387
4524
  value: (function () {
4388
- var _sendCustomerPayLinkAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(params) {
4525
+ var _sendCustomerPayLinkAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
4389
4526
  var _params$order_ids, _params$emails;
4390
4527
  var emailRegex, invalidEmails, requestBody, response, errorMessage, _errorMessage2;
4391
- return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4392
- while (1) switch (_context50.prev = _context50.next) {
4528
+ return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4529
+ while (1) switch (_context51.prev = _context51.next) {
4393
4530
  case 0:
4394
4531
  this.logInfo('sendCustomerPayLinkAsync called', {
4395
4532
  orderIds: params.order_ids,
@@ -4398,7 +4535,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4398
4535
  emailsCount: ((_params$emails = params.emails) === null || _params$emails === void 0 ? void 0 : _params$emails.length) || 0,
4399
4536
  notifyAction: params.notify_action || 'order_payment_reminder'
4400
4537
  });
4401
- _context50.prev = 1;
4538
+ _context51.prev = 1;
4402
4539
  console.log('[Checkout] 开始发送客户支付链接邮件:', {
4403
4540
  orderIds: params.order_ids,
4404
4541
  emails: params.emails,
@@ -4407,19 +4544,19 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4407
4544
 
4408
4545
  // 参数验证
4409
4546
  if (!(!params.order_ids || params.order_ids.length === 0)) {
4410
- _context50.next = 5;
4547
+ _context51.next = 5;
4411
4548
  break;
4412
4549
  }
4413
- return _context50.abrupt("return", {
4550
+ return _context51.abrupt("return", {
4414
4551
  success: false,
4415
4552
  message: '订单ID列表不能为空'
4416
4553
  });
4417
4554
  case 5:
4418
4555
  if (!(!params.emails || params.emails.length === 0)) {
4419
- _context50.next = 7;
4556
+ _context51.next = 7;
4420
4557
  break;
4421
4558
  }
4422
- return _context50.abrupt("return", {
4559
+ return _context51.abrupt("return", {
4423
4560
  success: false,
4424
4561
  message: '邮箱地址列表不能为空'
4425
4562
  });
@@ -4430,10 +4567,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4430
4567
  return !emailRegex.test(email);
4431
4568
  });
4432
4569
  if (!(invalidEmails.length > 0)) {
4433
- _context50.next = 11;
4570
+ _context51.next = 11;
4434
4571
  break;
4435
4572
  }
4436
- return _context50.abrupt("return", {
4573
+ return _context51.abrupt("return", {
4437
4574
  success: false,
4438
4575
  message: "\u90AE\u7BB1\u683C\u5F0F\u65E0\u6548: ".concat(invalidEmails.join(', '))
4439
4576
  });
@@ -4457,10 +4594,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4457
4594
  });
4458
4595
 
4459
4596
  // 调用后端API发送邮件
4460
- _context50.next = 16;
4597
+ _context51.next = 16;
4461
4598
  return this.request.post('/order/batch-email', requestBody);
4462
4599
  case 16:
4463
- response = _context50.sent;
4600
+ response = _context51.sent;
4464
4601
  console.log('[Checkout] 支付链接邮件发送响应:', {
4465
4602
  status: response.status,
4466
4603
  message: response.message,
@@ -4470,11 +4607,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4470
4607
 
4471
4608
  // 检查响应状态
4472
4609
  if (!(response.status === true || response.status === 200)) {
4473
- _context50.next = 23;
4610
+ _context51.next = 23;
4474
4611
  break;
4475
4612
  }
4476
4613
  console.log('[Checkout] 支付链接邮件发送成功');
4477
- return _context50.abrupt("return", {
4614
+ return _context51.abrupt("return", {
4478
4615
  success: true,
4479
4616
  message: response.message || '支付链接邮件发送成功'
4480
4617
  });
@@ -4482,29 +4619,29 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4482
4619
  // API返回失败状态
4483
4620
  errorMessage = response.message || '支付链接邮件发送失败';
4484
4621
  console.error('[Checkout] 支付链接邮件发送失败:', errorMessage);
4485
- return _context50.abrupt("return", {
4622
+ return _context51.abrupt("return", {
4486
4623
  success: false,
4487
4624
  message: errorMessage
4488
4625
  });
4489
4626
  case 26:
4490
- _context50.next = 33;
4627
+ _context51.next = 33;
4491
4628
  break;
4492
4629
  case 28:
4493
- _context50.prev = 28;
4494
- _context50.t0 = _context50["catch"](1);
4495
- console.error('[Checkout] 发送客户支付链接邮件失败:', _context50.t0);
4496
- _errorMessage2 = _context50.t0 instanceof Error ? _context50.t0.message : '网络错误或服务器异常';
4497
- return _context50.abrupt("return", {
4630
+ _context51.prev = 28;
4631
+ _context51.t0 = _context51["catch"](1);
4632
+ console.error('[Checkout] 发送客户支付链接邮件失败:', _context51.t0);
4633
+ _errorMessage2 = _context51.t0 instanceof Error ? _context51.t0.message : '网络错误或服务器异常';
4634
+ return _context51.abrupt("return", {
4498
4635
  success: false,
4499
4636
  message: "\u53D1\u9001\u652F\u4ED8\u94FE\u63A5\u90AE\u4EF6\u5931\u8D25: ".concat(_errorMessage2)
4500
4637
  });
4501
4638
  case 33:
4502
4639
  case "end":
4503
- return _context50.stop();
4640
+ return _context51.stop();
4504
4641
  }
4505
- }, _callee50, this, [[1, 28]]);
4642
+ }, _callee51, this, [[1, 28]]);
4506
4643
  }));
4507
- function sendCustomerPayLinkAsync(_x31) {
4644
+ function sendCustomerPayLinkAsync(_x32) {
4508
4645
  return _sendCustomerPayLinkAsync.apply(this, arguments);
4509
4646
  }
4510
4647
  return sendCustomerPayLinkAsync;
@@ -4519,25 +4656,25 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4519
4656
  }, {
4520
4657
  key: "roundAmountAsync",
4521
4658
  value: (function () {
4522
- var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(amount) {
4659
+ var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(amount) {
4523
4660
  var _this$otherParams$ord, _this$otherParams$ord2;
4524
4661
  var result;
4525
- return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4526
- while (1) switch (_context51.prev = _context51.next) {
4662
+ return _regeneratorRuntime().wrap(function _callee52$(_context52) {
4663
+ while (1) switch (_context52.prev = _context52.next) {
4527
4664
  case 0:
4528
- _context51.next = 2;
4665
+ _context52.next = 2;
4529
4666
  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);
4530
4667
  case 2:
4531
- result = _context51.sent;
4668
+ result = _context52.sent;
4532
4669
  console.log("[Checkout] \u91D1\u989D\u820D\u5165\u5B8C\u6210 - \u539F\u59CB: ".concat(result.originalAmount, ", \u820D\u5165\u540E: ").concat(result.roundedAmount, ", \u5DEE\u989D: ").concat(result.roundingDifference));
4533
- return _context51.abrupt("return", result);
4670
+ return _context52.abrupt("return", result);
4534
4671
  case 5:
4535
4672
  case "end":
4536
- return _context51.stop();
4673
+ return _context52.stop();
4537
4674
  }
4538
- }, _callee51, this);
4675
+ }, _callee52, this);
4539
4676
  }));
4540
- function roundAmountAsync(_x32) {
4677
+ function roundAmountAsync(_x33) {
4541
4678
  return _roundAmountAsync.apply(this, arguments);
4542
4679
  }
4543
4680
  return roundAmountAsync;
@@ -4545,10 +4682,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4545
4682
  }, {
4546
4683
  key: "destroy",
4547
4684
  value: function () {
4548
- var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52() {
4685
+ var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53() {
4549
4686
  var _this$order, _this$order$destroy, _this$payment, _this$payment$destroy;
4550
- return _regeneratorRuntime().wrap(function _callee52$(_context52) {
4551
- while (1) switch (_context52.prev = _context52.next) {
4687
+ return _regeneratorRuntime().wrap(function _callee53$(_context53) {
4688
+ while (1) switch (_context53.prev = _context53.next) {
4552
4689
  case 0:
4553
4690
  // 清理钱包模块的所有缓存数据
4554
4691
  this.payment.wallet.clearAllCache();
@@ -4557,10 +4694,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4557
4694
  this.core.effects.offByModuleDestroy(this.name);
4558
4695
 
4559
4696
  // 销毁子模块
4560
- _context52.next = 4;
4697
+ _context53.next = 4;
4561
4698
  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);
4562
4699
  case 4:
4563
- _context52.next = 6;
4700
+ _context53.next = 6;
4564
4701
  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);
4565
4702
  case 6:
4566
4703
  // 取消注册模块
@@ -4568,9 +4705,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4568
4705
  console.log('[Checkout] 已销毁');
4569
4706
  case 8:
4570
4707
  case "end":
4571
- return _context52.stop();
4708
+ return _context53.stop();
4572
4709
  }
4573
- }, _callee52, this);
4710
+ }, _callee53, this);
4574
4711
  }));
4575
4712
  function destroy() {
4576
4713
  return _destroy.apply(this, arguments);
@@ -4585,12 +4722,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4585
4722
  }, {
4586
4723
  key: "resetStoreStateAsync",
4587
4724
  value: (function () {
4588
- var _resetStoreStateAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53() {
4725
+ var _resetStoreStateAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54() {
4589
4726
  var prevOrderInfo;
4590
- return _regeneratorRuntime().wrap(function _callee53$(_context53) {
4591
- while (1) switch (_context53.prev = _context53.next) {
4727
+ return _regeneratorRuntime().wrap(function _callee54$(_context54) {
4728
+ while (1) switch (_context54.prev = _context54.next) {
4592
4729
  case 0:
4593
- _context53.prev = 0;
4730
+ _context54.prev = 0;
4594
4731
  prevOrderInfo = this.store.currentOrder ? {
4595
4732
  uuid: this.store.currentOrder.uuid,
4596
4733
  orderId: this.store.currentOrder.order_id
@@ -4622,26 +4759,26 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4622
4759
 
4623
4760
  // 触发订单清理事件(如果之前有订单)
4624
4761
  if (!prevOrderInfo) {
4625
- _context53.next = 19;
4762
+ _context54.next = 19;
4626
4763
  break;
4627
4764
  }
4628
- _context53.next = 19;
4765
+ _context54.next = 19;
4629
4766
  return this.core.effects.emit(CheckoutHooks.OnOrderCleared, {
4630
4767
  previousOrder: prevOrderInfo,
4631
4768
  timestamp: Date.now()
4632
4769
  });
4633
4770
  case 19:
4634
- _context53.next = 24;
4771
+ _context54.next = 24;
4635
4772
  break;
4636
4773
  case 21:
4637
- _context53.prev = 21;
4638
- _context53.t0 = _context53["catch"](0);
4639
- console.error('[Checkout] 重置 store 状态失败:', _context53.t0);
4774
+ _context54.prev = 21;
4775
+ _context54.t0 = _context54["catch"](0);
4776
+ console.error('[Checkout] 重置 store 状态失败:', _context54.t0);
4640
4777
  case 24:
4641
4778
  case "end":
4642
- return _context53.stop();
4779
+ return _context54.stop();
4643
4780
  }
4644
- }, _callee53, this, [[0, 21]]);
4781
+ }, _callee54, this, [[0, 21]]);
4645
4782
  }));
4646
4783
  function resetStoreStateAsync() {
4647
4784
  return _resetStoreStateAsync.apply(this, arguments);
@@ -4659,37 +4796,37 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4659
4796
  }, {
4660
4797
  key: "clearCompletedOrderAsync",
4661
4798
  value: (function () {
4662
- var _clearCompletedOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54() {
4799
+ var _clearCompletedOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55() {
4663
4800
  var prevOrderInfo;
4664
- return _regeneratorRuntime().wrap(function _callee54$(_context54) {
4665
- while (1) switch (_context54.prev = _context54.next) {
4801
+ return _regeneratorRuntime().wrap(function _callee55$(_context55) {
4802
+ while (1) switch (_context55.prev = _context55.next) {
4666
4803
  case 0:
4667
- _context54.prev = 0;
4804
+ _context55.prev = 0;
4668
4805
  prevOrderInfo = this.store.currentOrder ? {
4669
4806
  uuid: this.store.currentOrder.uuid,
4670
4807
  orderId: this.store.currentOrder.order_id
4671
4808
  } : null;
4672
- _context54.next = 4;
4809
+ _context55.next = 4;
4673
4810
  return this.resetStoreStateAsync();
4674
4811
  case 4:
4675
- return _context54.abrupt("return", {
4812
+ return _context55.abrupt("return", {
4676
4813
  success: true,
4677
4814
  message: prevOrderInfo ? '订单状态已成功清理' : '没有需要清理的订单状态',
4678
4815
  clearedOrder: prevOrderInfo
4679
4816
  });
4680
4817
  case 7:
4681
- _context54.prev = 7;
4682
- _context54.t0 = _context54["catch"](0);
4683
- console.error('[Checkout] 手动清理订单状态失败:', _context54.t0);
4684
- return _context54.abrupt("return", {
4818
+ _context55.prev = 7;
4819
+ _context55.t0 = _context55["catch"](0);
4820
+ console.error('[Checkout] 手动清理订单状态失败:', _context55.t0);
4821
+ return _context55.abrupt("return", {
4685
4822
  success: false,
4686
- message: _context54.t0 instanceof Error ? _context54.t0.message : '清理失败'
4823
+ message: _context55.t0 instanceof Error ? _context55.t0.message : '清理失败'
4687
4824
  });
4688
4825
  case 11:
4689
4826
  case "end":
4690
- return _context54.stop();
4827
+ return _context55.stop();
4691
4828
  }
4692
- }, _callee54, this, [[0, 7]]);
4829
+ }, _callee55, this, [[0, 7]]);
4693
4830
  }));
4694
4831
  function clearCompletedOrderAsync() {
4695
4832
  return _clearCompletedOrderAsync.apply(this, arguments);