@pisell/pisellos 2.2.35 → 2.2.37

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.
@@ -1502,24 +1502,59 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1502
1502
  }, {
1503
1503
  key: "addPaymentItemAsync",
1504
1504
  value: (function () {
1505
- var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(paymentItem) {
1506
- var orderPaymentType, processedPaymentItem, metadata, paymentItemWithType, remainingAmount, _paymentItem$type, _paymentItem$code, isEftposPayment, isCash, isCustomePayment, syncResult;
1505
+ var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(paymentItem, orderUuid) {
1506
+ var _paymentItem$type, _paymentItem$code;
1507
+ var isEftposPayment, shouldRepairFromIndexDb, _this$store$currentOr12, orderPaymentType, processedPaymentItem, metadata, paymentItemWithType, remainingAmount, _paymentItem$type2, _paymentItem$code2, _isEftposPayment, isCash, isCustomePayment, syncResult;
1507
1508
  return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1508
1509
  while (1) switch (_context16.prev = _context16.next) {
1509
1510
  case 0:
1510
- this.logInfo('addPaymentItemAsync called', paymentItem);
1511
- _context16.prev = 1;
1511
+ this.logInfo('addPaymentItemAsync called', {
1512
+ paymentItem: paymentItem,
1513
+ orderUuid: orderUuid
1514
+ });
1515
+ isEftposPayment = ((_paymentItem$type = paymentItem.type) === null || _paymentItem$type === void 0 ? void 0 : _paymentItem$type.toLowerCase()) === 'eftpos' || ((_paymentItem$code = paymentItem.code) === null || _paymentItem$code === void 0 ? void 0 : _paymentItem$code.toUpperCase().includes('EFTPOS'));
1516
+ shouldRepairFromIndexDb = !!orderUuid && isEftposPayment && (!this.store.currentOrder || this.store.currentOrder.uuid !== orderUuid);
1517
+ if (!shouldRepairFromIndexDb) {
1518
+ _context16.next = 14;
1519
+ break;
1520
+ }
1521
+ this.logError('EFTPOS push payment repair triggered', {
1522
+ orderUuid: orderUuid,
1523
+ currentOrderUuid: (_this$store$currentOr12 = this.store.currentOrder) === null || _this$store$currentOr12 === void 0 ? void 0 : _this$store$currentOr12.uuid,
1524
+ paymentCode: paymentItem.code,
1525
+ paymentType: paymentItem.type
1526
+ });
1527
+ _context16.prev = 5;
1528
+ _context16.next = 8;
1529
+ return this.repairEftposPaymentFromIndexDbAsync({
1530
+ orderUuid: orderUuid,
1531
+ paymentItem: paymentItem
1532
+ });
1533
+ case 8:
1534
+ _context16.next = 13;
1535
+ break;
1536
+ case 10:
1537
+ _context16.prev = 10;
1538
+ _context16.t0 = _context16["catch"](5);
1539
+ this.logError('EFTPOS push payment repair failed', {
1540
+ orderUuid: orderUuid,
1541
+ error: _context16.t0 instanceof Error ? _context16.t0.message : String(_context16.t0)
1542
+ });
1543
+ case 13:
1544
+ return _context16.abrupt("return");
1545
+ case 14:
1546
+ _context16.prev = 14;
1512
1547
  if (this.store.currentOrder) {
1513
- _context16.next = 4;
1548
+ _context16.next = 17;
1514
1549
  break;
1515
1550
  }
1516
1551
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, '未找到当前订单,无法添加支付项');
1517
- case 4:
1552
+ case 17:
1518
1553
  // 根据当前订单的定金状态设置订单支付类型
1519
1554
  orderPaymentType = this.store.currentOrder.is_deposit === 1 ? 'deposit' : 'normal'; // 处理现金支付的找零逻辑
1520
- _context16.next = 7;
1555
+ _context16.next = 20;
1521
1556
  return this.processCashPaymentItem(paymentItem);
1522
- case 7:
1557
+ case 20:
1523
1558
  processedPaymentItem = _context16.sent;
1524
1559
  // 从 otherParams 获取 metadata 字段
1525
1560
  metadata = _objectSpread(_objectSpread({}, processedPaymentItem.metadata), {}, {
@@ -1530,62 +1565,62 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1530
1565
  order_payment_type: orderPaymentType,
1531
1566
  metadata: metadata
1532
1567
  }); // 添加支付项到订单
1533
- _context16.next = 12;
1568
+ _context16.next = 25;
1534
1569
  return this.payment.addPaymentItemAsync(this.store.currentOrder.uuid, paymentItemWithType);
1535
- case 12:
1570
+ case 25:
1536
1571
  this.logInfo('支付项添加成功');
1537
1572
 
1538
1573
  // 🚀 清除计算缓存,确保获取最新数据
1539
1574
  this.clearCalculationCache();
1540
1575
 
1541
1576
  // 支付项添加后,更新 stateAmount 为剩余未支付金额
1542
- _context16.next = 16;
1577
+ _context16.next = 29;
1543
1578
  return this.updateStateAmountToRemaining();
1544
- case 16:
1545
- _context16.next = 18;
1579
+ case 29:
1580
+ _context16.next = 31;
1546
1581
  return this.calculateRemainingAmountAsync();
1547
- case 18:
1582
+ case 31:
1548
1583
  remainingAmount = _context16.sent;
1549
1584
  if (!(Number(remainingAmount) > 0)) {
1550
- _context16.next = 39;
1585
+ _context16.next = 52;
1551
1586
  break;
1552
1587
  }
1553
1588
  this.logInfo('订单金额还有待付的,同步 EFTPOS 支付');
1554
1589
  // 检查是否是 EFTPOS 支付,如果是则立即同步订单
1555
- isEftposPayment = ((_paymentItem$type = paymentItem.type) === null || _paymentItem$type === void 0 ? void 0 : _paymentItem$type.toLowerCase()) === 'eftpos' || ((_paymentItem$code = paymentItem.code) === null || _paymentItem$code === void 0 ? void 0 : _paymentItem$code.toUpperCase().includes('EFTPOS'));
1590
+ _isEftposPayment = ((_paymentItem$type2 = paymentItem.type) === null || _paymentItem$type2 === void 0 ? void 0 : _paymentItem$type2.toLowerCase()) === 'eftpos' || ((_paymentItem$code2 = paymentItem.code) === null || _paymentItem$code2 === void 0 ? void 0 : _paymentItem$code2.toUpperCase().includes('EFTPOS'));
1556
1591
  isCash = isCashPayment(paymentItem);
1557
1592
  isCustomePayment = paymentItem.type === 'custom';
1558
1593
  this.logInfo('EFTPOS 支付检查:', {
1559
1594
  paymentCode: paymentItem.code,
1560
1595
  paymentType: paymentItem.type,
1561
- isEftposPayment: isEftposPayment,
1596
+ isEftposPayment: _isEftposPayment,
1562
1597
  currentOrderSynced: this.store.isOrderSynced
1563
1598
  });
1564
- if (!(isEftposPayment || isCash || isCustomePayment)) {
1565
- _context16.next = 39;
1599
+ if (!(_isEftposPayment || isCash || isCustomePayment)) {
1600
+ _context16.next = 52;
1566
1601
  break;
1567
1602
  }
1568
1603
  this.logInfo('检测到 EFTPOS 支付,立即同步订单到后端...');
1569
- _context16.prev = 27;
1570
- _context16.next = 30;
1604
+ _context16.prev = 40;
1605
+ _context16.next = 43;
1571
1606
  return this.syncOrderToBackendWithReturn(true);
1572
- case 30:
1607
+ case 43:
1573
1608
  syncResult = _context16.sent;
1574
1609
  this.logInfo('EFTPOS 支付后订单同步完成 (已标记为手动同步):', {
1575
1610
  orderId: syncResult.orderId,
1576
1611
  isOrderSynced: this.store.isOrderSynced,
1577
1612
  backendResponse: syncResult.response
1578
1613
  });
1579
- _context16.next = 39;
1614
+ _context16.next = 52;
1580
1615
  break;
1581
- case 34:
1582
- _context16.prev = 34;
1583
- _context16.t0 = _context16["catch"](27);
1584
- this.logError('EFTPOS 支付后订单同步失败:', _context16.t0);
1616
+ case 47:
1617
+ _context16.prev = 47;
1618
+ _context16.t1 = _context16["catch"](40);
1619
+ this.logError('EFTPOS 支付后订单同步失败:', _context16.t1);
1585
1620
  // 不抛出错误,避免影响支付流程,但记录错误
1586
- _context16.next = 39;
1587
- return this.handleError(new Error("EFTPOS \u652F\u4ED8\u540E\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(_context16.t0 instanceof Error ? _context16.t0.message : String(_context16.t0))), CheckoutErrorType.OrderCreationFailed);
1588
- case 39:
1621
+ _context16.next = 52;
1622
+ return this.handleError(new Error("EFTPOS \u652F\u4ED8\u540E\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(_context16.t1 instanceof Error ? _context16.t1.message : String(_context16.t1))), CheckoutErrorType.OrderCreationFailed);
1623
+ case 52:
1589
1624
  // 触发支付项添加事件(可以复用支付开始事件)
1590
1625
  this.core.effects.emit("".concat(this.name, ":onPaymentItemAdded"), {
1591
1626
  orderUuid: this.store.currentOrder.uuid,
@@ -1594,23 +1629,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1594
1629
  amount: String(paymentItem.amount),
1595
1630
  timestamp: Date.now()
1596
1631
  });
1597
- _context16.next = 48;
1632
+ _context16.next = 61;
1598
1633
  break;
1599
- case 42:
1600
- _context16.prev = 42;
1601
- _context16.t1 = _context16["catch"](1);
1602
- this.logError('添加支付项失败:', _context16.t1);
1603
- _context16.next = 47;
1604
- return this.handleError(_context16.t1, CheckoutErrorType.PaymentFailed);
1605
- case 47:
1606
- throw _context16.t1;
1607
- case 48:
1634
+ case 55:
1635
+ _context16.prev = 55;
1636
+ _context16.t2 = _context16["catch"](14);
1637
+ this.logError('添加支付项失败:', _context16.t2);
1638
+ _context16.next = 60;
1639
+ return this.handleError(_context16.t2, CheckoutErrorType.PaymentFailed);
1640
+ case 60:
1641
+ throw _context16.t2;
1642
+ case 61:
1608
1643
  case "end":
1609
1644
  return _context16.stop();
1610
1645
  }
1611
- }, _callee16, this, [[1, 42], [27, 34]]);
1646
+ }, _callee16, this, [[5, 10], [14, 55], [40, 47]]);
1612
1647
  }));
1613
- function addPaymentItemAsync(_x15) {
1648
+ function addPaymentItemAsync(_x15, _x16) {
1614
1649
  return _addPaymentItemAsync.apply(this, arguments);
1615
1650
  }
1616
1651
  return addPaymentItemAsync;
@@ -1724,7 +1759,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1724
1759
  }
1725
1760
  }, _callee17, this, [[0, 27]]);
1726
1761
  }));
1727
- function deletePaymentItemAsync(_x16) {
1762
+ function deletePaymentItemAsync(_x17) {
1728
1763
  return _deletePaymentItemAsync.apply(this, arguments);
1729
1764
  }
1730
1765
  return deletePaymentItemAsync;
@@ -1881,7 +1916,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1881
1916
  }
1882
1917
  }, _callee18, this, [[0, 40]]);
1883
1918
  }));
1884
- function updateVoucherPaymentItemsAsync(_x17) {
1919
+ function updateVoucherPaymentItemsAsync(_x18) {
1885
1920
  return _updateVoucherPaymentItemsAsync.apply(this, arguments);
1886
1921
  }
1887
1922
  return updateVoucherPaymentItemsAsync;
@@ -1985,7 +2020,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1985
2020
  }
1986
2021
  }, _callee19, this, [[0, 24]]);
1987
2022
  }));
1988
- function updateOrderDepositStatusAsync(_x18) {
2023
+ function updateOrderDepositStatusAsync(_x19) {
1989
2024
  return _updateOrderDepositStatusAsync.apply(this, arguments);
1990
2025
  }
1991
2026
  return updateOrderDepositStatusAsync;
@@ -2004,7 +2039,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2004
2039
  key: "setDepositAmountAsync",
2005
2040
  value: (function () {
2006
2041
  var _setDepositAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(depositAmount) {
2007
- var _this$store$currentOr12, _this$store$currentOr13;
2042
+ var _this$store$currentOr13, _this$store$currentOr14;
2008
2043
  var depositValue, formattedDepositAmount, oldDepositAmount, updateParams;
2009
2044
  return _regeneratorRuntime().wrap(function _callee20$(_context20) {
2010
2045
  while (1) switch (_context20.prev = _context20.next) {
@@ -2012,8 +2047,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2012
2047
  this.logInfo('setDepositAmountAsync called', {
2013
2048
  depositAmount: depositAmount,
2014
2049
  hasCurrentOrder: !!this.store.currentOrder,
2015
- currentOrderId: (_this$store$currentOr12 = this.store.currentOrder) === null || _this$store$currentOr12 === void 0 ? void 0 : _this$store$currentOr12.order_id,
2016
- currentTotalAmount: (_this$store$currentOr13 = this.store.currentOrder) === null || _this$store$currentOr13 === void 0 ? void 0 : _this$store$currentOr13.total_amount
2050
+ currentOrderId: (_this$store$currentOr13 = this.store.currentOrder) === null || _this$store$currentOr13 === void 0 ? void 0 : _this$store$currentOr13.order_id,
2051
+ currentTotalAmount: (_this$store$currentOr14 = this.store.currentOrder) === null || _this$store$currentOr14 === void 0 ? void 0 : _this$store$currentOr14.total_amount
2017
2052
  });
2018
2053
  _context20.prev = 1;
2019
2054
  // 验证定金金额格式
@@ -2118,7 +2153,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2118
2153
  }
2119
2154
  }, _callee20, this, [[1, 26]]);
2120
2155
  }));
2121
- function setDepositAmountAsync(_x19) {
2156
+ function setDepositAmountAsync(_x20) {
2122
2157
  return _setDepositAmountAsync.apply(this, arguments);
2123
2158
  }
2124
2159
  return setDepositAmountAsync;
@@ -2133,17 +2168,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2133
2168
  key: "manualSyncOrderAsync",
2134
2169
  value: (function () {
2135
2170
  var _manualSyncOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
2136
- var _this$store$currentOr14, _this$store$currentOr15, _this$store$currentOr16;
2137
- var _this$store$currentOr17, orderUuid, oldOrderId, syncResult, finalOrderId, finalIsVirtual, newRes, _this$store$currentOr18, errorMessage;
2171
+ var _this$store$currentOr15, _this$store$currentOr16, _this$store$currentOr17;
2172
+ var _this$store$currentOr18, orderUuid, oldOrderId, syncResult, finalOrderId, finalIsVirtual, newRes, _this$store$currentOr19, errorMessage;
2138
2173
  return _regeneratorRuntime().wrap(function _callee21$(_context21) {
2139
2174
  while (1) switch (_context21.prev = _context21.next) {
2140
2175
  case 0:
2141
2176
  console.log('manualSyncOrderAsync called');
2142
2177
  this.logInfo('manualSyncOrderAsync called', {
2143
2178
  hasCurrentOrder: !!this.store.currentOrder,
2144
- currentOrderId: (_this$store$currentOr14 = this.store.currentOrder) === null || _this$store$currentOr14 === void 0 ? void 0 : _this$store$currentOr14.order_id,
2145
- orderUuid: (_this$store$currentOr15 = this.store.currentOrder) === null || _this$store$currentOr15 === void 0 ? void 0 : _this$store$currentOr15.uuid,
2146
- totalAmount: (_this$store$currentOr16 = this.store.currentOrder) === null || _this$store$currentOr16 === void 0 ? void 0 : _this$store$currentOr16.total_amount,
2179
+ currentOrderId: (_this$store$currentOr15 = this.store.currentOrder) === null || _this$store$currentOr15 === void 0 ? void 0 : _this$store$currentOr15.order_id,
2180
+ orderUuid: (_this$store$currentOr16 = this.store.currentOrder) === null || _this$store$currentOr16 === void 0 ? void 0 : _this$store$currentOr16.uuid,
2181
+ totalAmount: (_this$store$currentOr17 = this.store.currentOrder) === null || _this$store$currentOr17 === void 0 ? void 0 : _this$store$currentOr17.total_amount,
2147
2182
  isOrderSynced: this.store.isOrderSynced,
2148
2183
  isVirtualOrderId: this.store.currentOrder ? isVirtualOrderId(this.store.currentOrder.order_id) : false
2149
2184
  });
@@ -2203,7 +2238,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2203
2238
  this.logError('[Checkout] 严重警告:返回的订单ID与存储的订单ID不一致!');
2204
2239
  }
2205
2240
  newRes = _objectSpread(_objectSpread({}, syncResult), {}, {
2206
- is_deposit: ((_this$store$currentOr17 = this.store.currentOrder) === null || _this$store$currentOr17 === void 0 ? void 0 : _this$store$currentOr17.is_deposit) || 0
2241
+ is_deposit: ((_this$store$currentOr18 = this.store.currentOrder) === null || _this$store$currentOr18 === void 0 ? void 0 : _this$store$currentOr18.is_deposit) || 0
2207
2242
  });
2208
2243
  _context21.next = 30;
2209
2244
  return this.updateStateAmountToRemaining(false);
@@ -2217,7 +2252,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2217
2252
  return _context21.abrupt("return", {
2218
2253
  success: false,
2219
2254
  message: "\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(errorMessage),
2220
- orderUuid: (_this$store$currentOr18 = this.store.currentOrder) === null || _this$store$currentOr18 === void 0 ? void 0 : _this$store$currentOr18.uuid
2255
+ orderUuid: (_this$store$currentOr19 = this.store.currentOrder) === null || _this$store$currentOr19 === void 0 ? void 0 : _this$store$currentOr19.uuid
2221
2256
  });
2222
2257
  case 38:
2223
2258
  case "end":
@@ -2294,15 +2329,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2294
2329
  key: "cancelCurrentOrderAsync",
2295
2330
  value: (function () {
2296
2331
  var _cancelCurrentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(cancelReason) {
2297
- var _this$store$currentOr19, _this$store$currentOr20, currentOrderUuid, currentOrderId, isOrderSynced, errorMessage;
2332
+ var _this$store$currentOr20, _this$store$currentOr21, currentOrderUuid, currentOrderId, isOrderSynced, errorMessage;
2298
2333
  return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2299
2334
  while (1) switch (_context22.prev = _context22.next) {
2300
2335
  case 0:
2301
2336
  _context22.prev = 0;
2302
2337
  this.logInfo('开始取消当前本地订单:', {
2303
2338
  hasCurrentOrder: !!this.store.currentOrder,
2304
- orderUuid: (_this$store$currentOr19 = this.store.currentOrder) === null || _this$store$currentOr19 === void 0 ? void 0 : _this$store$currentOr19.uuid,
2305
- orderId: (_this$store$currentOr20 = this.store.currentOrder) === null || _this$store$currentOr20 === void 0 ? void 0 : _this$store$currentOr20.order_id,
2339
+ orderUuid: (_this$store$currentOr20 = this.store.currentOrder) === null || _this$store$currentOr20 === void 0 ? void 0 : _this$store$currentOr20.uuid,
2340
+ orderId: (_this$store$currentOr21 = this.store.currentOrder) === null || _this$store$currentOr21 === void 0 ? void 0 : _this$store$currentOr21.order_id,
2306
2341
  isOrderSynced: this.store.isOrderSynced,
2307
2342
  cancelReason: cancelReason
2308
2343
  });
@@ -2336,17 +2371,19 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2336
2371
  });
2337
2372
  case 11:
2338
2373
  _context22.prev = 11;
2339
- this.logInfo('删除本地订单数据');
2374
+ this.logInfo('标记本地订单为已删除');
2340
2375
  _context22.next = 15;
2341
- return this.payment.deletePaymentOrderAsync(currentOrderUuid);
2376
+ return this.payment.updateOrderAsync(currentOrderUuid, {
2377
+ payment_status: PaymentStatus.Voided
2378
+ });
2342
2379
  case 15:
2343
- this.logInfo('本地订单数据删除成功');
2380
+ this.logInfo('本地订单删除标记成功');
2344
2381
  _context22.next = 21;
2345
2382
  break;
2346
2383
  case 18:
2347
2384
  _context22.prev = 18;
2348
2385
  _context22.t0 = _context22["catch"](11);
2349
- this.logWarning('删除本地订单数据失败,但继续执行:', _context22.t0);
2386
+ this.logWarning('标记本地订单删除失败,但继续执行:', _context22.t0);
2350
2387
  case 21:
2351
2388
  // 清理订单相关状态,确保正确释放 currentOrder
2352
2389
  this.logInfo('清理订单相关状态');
@@ -2397,7 +2434,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2397
2434
  }
2398
2435
  }, _callee22, this, [[0, 36], [11, 18]]);
2399
2436
  }));
2400
- function cancelCurrentOrderAsync(_x20) {
2437
+ function cancelCurrentOrderAsync(_x21) {
2401
2438
  return _cancelCurrentOrderAsync.apply(this, arguments);
2402
2439
  }
2403
2440
  return cancelCurrentOrderAsync;
@@ -2413,7 +2450,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2413
2450
  key: "saveForLaterPaymentAsync",
2414
2451
  value: (function () {
2415
2452
  var _saveForLaterPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
2416
- var orderUuid, currentOrderId, allPaymentItems, orderPaymentStatus, syncResult, _this$store$currentOr21, errorMessage;
2453
+ var orderUuid, currentOrderId, allPaymentItems, orderPaymentStatus, syncResult, _this$store$currentOr22, errorMessage;
2417
2454
  return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2418
2455
  while (1) switch (_context23.prev = _context23.next) {
2419
2456
  case 0:
@@ -2472,7 +2509,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2472
2509
  return _context23.abrupt("return", {
2473
2510
  success: false,
2474
2511
  message: "\u8BA2\u5355\u4FDD\u5B58\u5931\u8D25: ".concat(errorMessage),
2475
- orderUuid: (_this$store$currentOr21 = this.store.currentOrder) === null || _this$store$currentOr21 === void 0 ? void 0 : _this$store$currentOr21.uuid
2512
+ orderUuid: (_this$store$currentOr22 = this.store.currentOrder) === null || _this$store$currentOr22 === void 0 ? void 0 : _this$store$currentOr22.uuid
2476
2513
  });
2477
2514
  case 22:
2478
2515
  case "end":
@@ -2495,7 +2532,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2495
2532
  key: "updateOrderNoteAsync",
2496
2533
  value: (function () {
2497
2534
  var _updateOrderNoteAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(note) {
2498
- var _this$store$currentOr22, _this$store$currentOr23, oldNote, orderInPayment;
2535
+ var _this$store$currentOr23, _this$store$currentOr24, oldNote, orderInPayment;
2499
2536
  return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2500
2537
  while (1) switch (_context24.prev = _context24.next) {
2501
2538
  case 0:
@@ -2507,7 +2544,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2507
2544
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, '没有本地订单数据,无法更新备注');
2508
2545
  case 3:
2509
2546
  console.log('[Checkout] 更新订单备注:', {
2510
- orderUuid: (_this$store$currentOr22 = this.store.currentOrder) === null || _this$store$currentOr22 === void 0 ? void 0 : _this$store$currentOr22.uuid,
2547
+ orderUuid: (_this$store$currentOr23 = this.store.currentOrder) === null || _this$store$currentOr23 === void 0 ? void 0 : _this$store$currentOr23.uuid,
2511
2548
  oldNote: this.store.localOrderData.shop_note,
2512
2549
  newNote: note
2513
2550
  });
@@ -2540,7 +2577,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2540
2577
  case 17:
2541
2578
  _context24.next = 19;
2542
2579
  return this.core.effects.emit("".concat(this.name, ":onOrderNoteChanged"), {
2543
- orderUuid: (_this$store$currentOr23 = this.store.currentOrder) === null || _this$store$currentOr23 === void 0 ? void 0 : _this$store$currentOr23.uuid,
2580
+ orderUuid: (_this$store$currentOr24 = this.store.currentOrder) === null || _this$store$currentOr24 === void 0 ? void 0 : _this$store$currentOr24.uuid,
2544
2581
  oldNote: oldNote,
2545
2582
  newNote: note,
2546
2583
  timestamp: Date.now()
@@ -2566,7 +2603,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2566
2603
  }
2567
2604
  }, _callee24, this, [[0, 22], [7, 14]]);
2568
2605
  }));
2569
- function updateOrderNoteAsync(_x21) {
2606
+ function updateOrderNoteAsync(_x22) {
2570
2607
  return _updateOrderNoteAsync.apply(this, arguments);
2571
2608
  }
2572
2609
  return updateOrderNoteAsync;
@@ -2599,7 +2636,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2599
2636
  }
2600
2637
  }, _callee25, this);
2601
2638
  }));
2602
- function handleError(_x22, _x23) {
2639
+ function handleError(_x23, _x24) {
2603
2640
  return _handleError.apply(this, arguments);
2604
2641
  }
2605
2642
  return handleError;
@@ -2612,7 +2649,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2612
2649
  key: "handlePaymentSuccess",
2613
2650
  value: (function () {
2614
2651
  var _handlePaymentSuccess = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(data) {
2615
- var _this$store$currentOr24;
2652
+ var _this$store$currentOr25;
2616
2653
  return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2617
2654
  while (1) switch (_context26.prev = _context26.next) {
2618
2655
  case 0:
@@ -2623,7 +2660,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2623
2660
  return this.core.effects.emit("".concat(this.name, ":onPaymentSuccess"), {
2624
2661
  orderUuid: data.orderUuid,
2625
2662
  paymentMethodCode: '',
2626
- amount: ((_this$store$currentOr24 = this.store.currentOrder) === null || _this$store$currentOr24 === void 0 ? void 0 : _this$store$currentOr24.total_amount) || '0',
2663
+ amount: ((_this$store$currentOr25 = this.store.currentOrder) === null || _this$store$currentOr25 === void 0 ? void 0 : _this$store$currentOr25.total_amount) || '0',
2627
2664
  timestamp: data.timestamp
2628
2665
  });
2629
2666
  case 4:
@@ -2635,7 +2672,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2635
2672
  }
2636
2673
  }, _callee26, this);
2637
2674
  }));
2638
- function handlePaymentSuccess(_x24) {
2675
+ function handlePaymentSuccess(_x25) {
2639
2676
  return _handlePaymentSuccess.apply(this, arguments);
2640
2677
  }
2641
2678
  return handlePaymentSuccess;
@@ -2648,7 +2685,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2648
2685
  key: "handlePaymentError",
2649
2686
  value: (function () {
2650
2687
  var _handlePaymentError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(data) {
2651
- var _this$store$currentOr25;
2688
+ var _this$store$currentOr26;
2652
2689
  var error;
2653
2690
  return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2654
2691
  while (1) switch (_context27.prev = _context27.next) {
@@ -2661,7 +2698,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2661
2698
  return this.core.effects.emit("".concat(this.name, ":onPaymentFailed"), {
2662
2699
  orderUuid: data.orderUuid,
2663
2700
  paymentMethodCode: '',
2664
- amount: ((_this$store$currentOr25 = this.store.currentOrder) === null || _this$store$currentOr25 === void 0 ? void 0 : _this$store$currentOr25.total_amount) || '0',
2701
+ amount: ((_this$store$currentOr26 = this.store.currentOrder) === null || _this$store$currentOr26 === void 0 ? void 0 : _this$store$currentOr26.total_amount) || '0',
2665
2702
  timestamp: data.timestamp
2666
2703
  });
2667
2704
  case 5:
@@ -2670,7 +2707,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2670
2707
  }
2671
2708
  }, _callee27, this);
2672
2709
  }));
2673
- function handlePaymentError(_x25) {
2710
+ function handlePaymentError(_x26) {
2674
2711
  return _handlePaymentError.apply(this, arguments);
2675
2712
  }
2676
2713
  return handlePaymentError;
@@ -2771,7 +2808,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2771
2808
  }
2772
2809
  }, _callee28, this, [[3, 23]]);
2773
2810
  }));
2774
- function processCashPaymentItem(_x26) {
2811
+ function processCashPaymentItem(_x27) {
2775
2812
  return _processCashPaymentItem.apply(this, arguments);
2776
2813
  }
2777
2814
  return processCashPaymentItem;
@@ -3637,7 +3674,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3637
3674
  }
3638
3675
  }, _callee37, this, [[0, 23]]);
3639
3676
  }));
3640
- function checkOrderPaymentCompletionOptimized(_x27, _x28) {
3677
+ function checkOrderPaymentCompletionOptimized(_x28, _x29) {
3641
3678
  return _checkOrderPaymentCompletionOptimized.apply(this, arguments);
3642
3679
  }
3643
3680
  return checkOrderPaymentCompletionOptimized;
@@ -3770,6 +3807,374 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3770
3807
  return _checkOrderPaymentCompletion.apply(this, arguments);
3771
3808
  }
3772
3809
  return checkOrderPaymentCompletion;
3810
+ }())
3811
+ }, {
3812
+ key: "repairEftposPaymentFromIndexDbAsync",
3813
+ value: function () {
3814
+ var _repairEftposPaymentFromIndexDbAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
3815
+ var orderUuid, paymentItem, order, orderPaymentType, processedPaymentItem, metadata, paymentItemWithType;
3816
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3817
+ while (1) switch (_context39.prev = _context39.next) {
3818
+ case 0:
3819
+ orderUuid = params.orderUuid, paymentItem = params.paymentItem;
3820
+ _context39.next = 3;
3821
+ return this.payment.getPaymentOrderByUuidAsync(orderUuid);
3822
+ case 3:
3823
+ order = _context39.sent;
3824
+ if (order) {
3825
+ _context39.next = 7;
3826
+ break;
3827
+ }
3828
+ this.logError('EFTPOS repair failed: order not found in IndexDB', {
3829
+ orderUuid: orderUuid,
3830
+ paymentItem: paymentItem
3831
+ });
3832
+ return _context39.abrupt("return");
3833
+ case 7:
3834
+ orderPaymentType = order.is_deposit === 1 ? 'deposit' : 'normal';
3835
+ _context39.next = 10;
3836
+ return this.processCashPaymentItem(paymentItem);
3837
+ case 10:
3838
+ processedPaymentItem = _context39.sent;
3839
+ metadata = _objectSpread(_objectSpread({}, processedPaymentItem.metadata), {}, {
3840
+ rounding_rule: this.otherParams.order_rounding_setting,
3841
+ shop_wallet_pass_id: this.otherParams.shop_wallet_pass_id
3842
+ });
3843
+ paymentItemWithType = _objectSpread(_objectSpread({}, processedPaymentItem), {}, {
3844
+ order_payment_type: orderPaymentType,
3845
+ metadata: metadata
3846
+ });
3847
+ _context39.next = 15;
3848
+ return this.payment.addPaymentItemAsync(orderUuid, paymentItemWithType);
3849
+ case 15:
3850
+ _context39.next = 17;
3851
+ return this.syncOrderToBackendFromIndexDbAsync({
3852
+ orderUuid: orderUuid
3853
+ });
3854
+ case 17:
3855
+ case "end":
3856
+ return _context39.stop();
3857
+ }
3858
+ }, _callee39, this);
3859
+ }));
3860
+ function repairEftposPaymentFromIndexDbAsync(_x30) {
3861
+ return _repairEftposPaymentFromIndexDbAsync.apply(this, arguments);
3862
+ }
3863
+ return repairEftposPaymentFromIndexDbAsync;
3864
+ }()
3865
+ }, {
3866
+ key: "syncOrderToBackendFromIndexDbAsync",
3867
+ value: function () {
3868
+ var _syncOrderToBackendFromIndexDbAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
3869
+ var _paymentOrder$order_i,
3870
+ _paymentOrder$order_i2,
3871
+ _this6 = this,
3872
+ _this$otherParams,
3873
+ _localOrderData$booki,
3874
+ _localOrderData$relat,
3875
+ _checkoutResponse4,
3876
+ _checkoutResponse5,
3877
+ _checkoutResponse9;
3878
+ var orderUuid, paymentOrder, localOrderData, paymentItems, processedPaymentItems, finalDepositAmount, manualDepositAmount, manualDepositValue, orderPaymentStatus, totalPaidAmount, orderParams, currentOrderId, isUpdateOperation, startTime, checkoutResponse, submitSuccess, submitError, _checkoutResponse, _checkoutResponse2, _checkoutResponse3, responseStatus, isSuccessResponse, _checkoutResponse6, errorMessage, realOrderId, _checkoutResponse7, extractedOrderId, _checkoutResponse8, syncedPaymentUuids, _iterator3, _step3, paymentUuid, latestPaymentStatus;
3879
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3880
+ while (1) switch (_context40.prev = _context40.next) {
3881
+ case 0:
3882
+ orderUuid = params.orderUuid;
3883
+ _context40.next = 3;
3884
+ return this.payment.getPaymentOrderByUuidAsync(orderUuid);
3885
+ case 3:
3886
+ paymentOrder = _context40.sent;
3887
+ if (paymentOrder) {
3888
+ _context40.next = 7;
3889
+ break;
3890
+ }
3891
+ this.logError('EFTPOS repair sync failed: missing payment order', {
3892
+ orderUuid: orderUuid
3893
+ });
3894
+ return _context40.abrupt("return", {
3895
+ success: false
3896
+ });
3897
+ case 7:
3898
+ localOrderData = ((_paymentOrder$order_i = paymentOrder.order_info) === null || _paymentOrder$order_i === void 0 ? void 0 : _paymentOrder$order_i.original_order_data) || ((_paymentOrder$order_i2 = paymentOrder.order_info) === null || _paymentOrder$order_i2 === void 0 ? void 0 : _paymentOrder$order_i2.order_data);
3899
+ if (localOrderData) {
3900
+ _context40.next = 11;
3901
+ break;
3902
+ }
3903
+ this.logError('EFTPOS repair sync failed: missing local order data', {
3904
+ orderUuid: orderUuid,
3905
+ orderInfoKeys: Object.keys(paymentOrder.order_info || {})
3906
+ });
3907
+ return _context40.abrupt("return", {
3908
+ success: false
3909
+ });
3910
+ case 11:
3911
+ _context40.next = 13;
3912
+ return this.payment.getPaymentItemsAsync(orderUuid);
3913
+ case 13:
3914
+ paymentItems = _context40.sent;
3915
+ processedPaymentItems = paymentItems.map(function (item) {
3916
+ var _item$metadata, _item$metadata2;
3917
+ return _objectSpread(_objectSpread({}, item), {}, {
3918
+ metadata: _objectSpread(_objectSpread({}, item.metadata), {}, {
3919
+ rounding_rule: ((_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.rounding_rule) || _this6.otherParams.order_rounding_setting,
3920
+ shop_wallet_pass_id: ((_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.shop_wallet_pass_id) || _this6.otherParams.shop_wallet_pass_id
3921
+ })
3922
+ });
3923
+ });
3924
+ manualDepositAmount = paymentOrder.deposit_amount || '0.00';
3925
+ manualDepositValue = new Decimal(manualDepositAmount);
3926
+ if (manualDepositValue.gt(0)) {
3927
+ finalDepositAmount = manualDepositAmount;
3928
+ } else {
3929
+ finalDepositAmount = '0.00';
3930
+ }
3931
+ if (paymentOrder.is_deposit === 0 && processedPaymentItems.every(function (item) {
3932
+ return item.order_payment_type !== 'deposit';
3933
+ })) {
3934
+ finalDepositAmount = '0.00';
3935
+ }
3936
+ if (paymentOrder.is_deposit === 0 && processedPaymentItems.some(function (item) {
3937
+ return item.order_payment_type === 'deposit';
3938
+ })) {
3939
+ finalDepositAmount = processedPaymentItems.filter(function (item) {
3940
+ return item.status !== 'voided' && item.order_payment_type === 'deposit';
3941
+ }).reduce(function (sum, item) {
3942
+ var amountValue = new Decimal(item.amount || '0');
3943
+ var roundingValue = new Decimal(item.rounding_amount || '0');
3944
+ return sum.plus(amountValue).sub(roundingValue);
3945
+ }, new Decimal(0)).toFixed(2);
3946
+ }
3947
+ if (paymentOrder.is_deposit === 1 && new Decimal(finalDepositAmount).gte(new Decimal(paymentOrder.total_amount))) {
3948
+ finalDepositAmount = processedPaymentItems.filter(function (item) {
3949
+ return item.status !== 'voided' && item.order_payment_type === 'deposit';
3950
+ }).reduce(function (sum, item) {
3951
+ var amountValue = new Decimal(item.amount || '0');
3952
+ var roundingValue = new Decimal(item.rounding_amount || '0');
3953
+ return sum.plus(amountValue).sub(roundingValue);
3954
+ }, new Decimal(0)).toFixed(2);
3955
+ }
3956
+ totalPaidAmount = processedPaymentItems.filter(function (item) {
3957
+ return item.status !== 'voided';
3958
+ }).reduce(function (sum, item) {
3959
+ var amountValue = new Decimal(item.amount || '0');
3960
+ var roundingValue = new Decimal(item.rounding_amount || '0');
3961
+ return sum.plus(amountValue).sub(roundingValue);
3962
+ }, new Decimal(0));
3963
+ if (totalPaidAmount.gte(new Decimal(paymentOrder.total_amount))) {
3964
+ orderPaymentStatus = 'paid';
3965
+ } else if (totalPaidAmount.gt(0)) {
3966
+ orderPaymentStatus = 'partially_paid';
3967
+ } else {
3968
+ orderPaymentStatus = 'unpaid';
3969
+ }
3970
+ orderParams = _objectSpread(_objectSpread({}, localOrderData), {}, {
3971
+ payment_status: orderPaymentStatus,
3972
+ type: localOrderData.type,
3973
+ platform: localOrderData.platform,
3974
+ payments: processedPaymentItems,
3975
+ customer_id: localOrderData.customer_id,
3976
+ is_price_include_tax: this.otherParams.is_price_include_tax,
3977
+ tax_title: this.otherParams.tax_title,
3978
+ tax_rate: this.otherParams.tax_rate,
3979
+ tax_country_code: this.otherParams.tax_country_code,
3980
+ currency_code: this.otherParams.currency_code,
3981
+ currency_symbol: this.otherParams.currency_symbol,
3982
+ currency_format: this.otherParams.currency_format,
3983
+ business_code: ((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.business_code) || undefined,
3984
+ is_deposit: (paymentOrder.is_deposit || Number(finalDepositAmount) > 0 ? 1 : 0) || 0,
3985
+ deposit_amount: finalDepositAmount,
3986
+ product_tax_fee: localOrderData.tax_fee,
3987
+ note: localOrderData.shop_note,
3988
+ bookings: (_localOrderData$booki = localOrderData.bookings) === null || _localOrderData$booki === void 0 ? void 0 : _localOrderData$booki.map(function (item) {
3989
+ return _objectSpread(_objectSpread({}, item), {}, {
3990
+ product: _objectSpread(_objectSpread({}, item.product), {}, {
3991
+ custom_deposit_data: undefined
3992
+ }),
3993
+ deposit: undefined
3994
+ });
3995
+ }),
3996
+ relation_products: (_localOrderData$relat = localOrderData.relation_products) === null || _localOrderData$relat === void 0 ? void 0 : _localOrderData$relat.map(function (item) {
3997
+ return _objectSpread(_objectSpread({}, item), {}, {
3998
+ custom_deposit_data: undefined,
3999
+ deposit: undefined
4000
+ });
4001
+ })
4002
+ });
4003
+ currentOrderId = paymentOrder.order_id;
4004
+ isUpdateOperation = currentOrderId && !isVirtualOrderId(currentOrderId);
4005
+ if (isUpdateOperation) {
4006
+ orderParams.order_id = currentOrderId;
4007
+ }
4008
+ this.logError('EFTPOS repair sync start', {
4009
+ orderUuid: orderUuid,
4010
+ orderId: currentOrderId,
4011
+ isUpdateOperation: isUpdateOperation,
4012
+ paymentItemCount: processedPaymentItems.length
4013
+ });
4014
+
4015
+ // 发送下单接口请求开始事件
4016
+ startTime = Date.now();
4017
+ _context40.next = 31;
4018
+ return this.core.effects.emit("".concat(this.name, ":onOrderSubmitStart"), {
4019
+ orderUuid: orderUuid,
4020
+ operation: isUpdateOperation ? 'update' : 'create',
4021
+ isManual: false,
4022
+ paymentItemCount: processedPaymentItems.length,
4023
+ timestamp: startTime
4024
+ });
4025
+ case 31:
4026
+ submitSuccess = false;
4027
+ _context40.prev = 32;
4028
+ this.logError('EFTPOS repair calling backend checkout API', _objectSpread({
4029
+ url: '/order/checkout',
4030
+ isManual: true
4031
+ }, orderParams));
4032
+ _context40.next = 36;
4033
+ return this.order.createOrderByCheckout(orderParams);
4034
+ case 36:
4035
+ checkoutResponse = _context40.sent;
4036
+ submitSuccess = true;
4037
+ _context40.next = 45;
4038
+ break;
4039
+ case 40:
4040
+ _context40.prev = 40;
4041
+ _context40.t0 = _context40["catch"](32);
4042
+ this.logError('EFTPOS repair checkout API failed', {
4043
+ orderUuid: orderUuid,
4044
+ error: _context40.t0 instanceof Error ? _context40.t0.message : String(_context40.t0)
4045
+ });
4046
+ submitError = _context40.t0 instanceof Error ? _context40.t0.message : String(_context40.t0);
4047
+ throw _context40.t0;
4048
+ case 45:
4049
+ _context40.prev = 45;
4050
+ this.logError('EFTPOS repair sync end', {
4051
+ orderUuid: orderUuid,
4052
+ orderId: currentOrderId,
4053
+ responseStatus: (_checkoutResponse = checkoutResponse) === null || _checkoutResponse === void 0 ? void 0 : _checkoutResponse.status
4054
+ });
4055
+ this.core.effects.emit("".concat(this.name, ":onOrderSubmitEnd"), {
4056
+ success: submitSuccess,
4057
+ orderUuid: orderUuid,
4058
+ operation: isUpdateOperation ? 'update' : 'create',
4059
+ isManual: false,
4060
+ orderId: submitSuccess ? ((_checkoutResponse2 = checkoutResponse) === null || _checkoutResponse2 === void 0 || (_checkoutResponse2 = _checkoutResponse2.data) === null || _checkoutResponse2 === void 0 ? void 0 : _checkoutResponse2.order_id) || ((_checkoutResponse3 = checkoutResponse) === null || _checkoutResponse3 === void 0 ? void 0 : _checkoutResponse3.order_id) : undefined,
4061
+ error: submitError,
4062
+ duration: Date.now() - startTime,
4063
+ timestamp: Date.now()
4064
+ });
4065
+ return _context40.finish(45);
4066
+ case 49:
4067
+ responseStatus = (_checkoutResponse4 = checkoutResponse) === null || _checkoutResponse4 === void 0 ? void 0 : _checkoutResponse4.status;
4068
+ isSuccessResponse = responseStatus === true || responseStatus === 200 || responseStatus === 'success' || responseStatus === 1 && ((_checkoutResponse5 = checkoutResponse) === null || _checkoutResponse5 === void 0 ? void 0 : _checkoutResponse5.code) === 200;
4069
+ if (isSuccessResponse) {
4070
+ _context40.next = 55;
4071
+ break;
4072
+ }
4073
+ errorMessage = ((_checkoutResponse6 = checkoutResponse) === null || _checkoutResponse6 === void 0 ? void 0 : _checkoutResponse6.message) || '订单同步失败,后端返回非成功状态';
4074
+ this.logError('EFTPOS repair sync failed: api error', {
4075
+ orderUuid: orderUuid,
4076
+ errorMessage: errorMessage,
4077
+ response: checkoutResponse
4078
+ });
4079
+ return _context40.abrupt("return", {
4080
+ success: false,
4081
+ response: checkoutResponse
4082
+ });
4083
+ case 55:
4084
+ realOrderId = currentOrderId;
4085
+ if (isUpdateOperation) {
4086
+ _context40.next = 67;
4087
+ break;
4088
+ }
4089
+ extractedOrderId = (_checkoutResponse7 = checkoutResponse) === null || _checkoutResponse7 === void 0 || (_checkoutResponse7 = _checkoutResponse7.data) === null || _checkoutResponse7 === void 0 ? void 0 : _checkoutResponse7.order_id;
4090
+ if (!extractedOrderId) {
4091
+ extractedOrderId = (_checkoutResponse8 = checkoutResponse) === null || _checkoutResponse8 === void 0 ? void 0 : _checkoutResponse8.order_id;
4092
+ }
4093
+ if (extractedOrderId !== undefined && extractedOrderId !== null) {
4094
+ extractedOrderId = String(extractedOrderId);
4095
+ }
4096
+ realOrderId = extractedOrderId;
4097
+ if (!realOrderId) {
4098
+ _context40.next = 66;
4099
+ break;
4100
+ }
4101
+ _context40.next = 64;
4102
+ return this.payment.replaceOrderIdByUuidAsync(orderUuid, realOrderId);
4103
+ case 64:
4104
+ _context40.next = 67;
4105
+ break;
4106
+ case 66:
4107
+ this.logError('EFTPOS repair missing order_id in response', {
4108
+ orderUuid: orderUuid,
4109
+ response: checkoutResponse
4110
+ });
4111
+ case 67:
4112
+ syncedPaymentUuids = processedPaymentItems.filter(function (item) {
4113
+ return item.status !== 'voided';
4114
+ }).map(function (item) {
4115
+ return item.uuid;
4116
+ }).filter(Boolean);
4117
+ _iterator3 = _createForOfIteratorHelper(syncedPaymentUuids);
4118
+ _context40.prev = 69;
4119
+ _iterator3.s();
4120
+ case 71:
4121
+ if ((_step3 = _iterator3.n()).done) {
4122
+ _context40.next = 77;
4123
+ break;
4124
+ }
4125
+ paymentUuid = _step3.value;
4126
+ _context40.next = 75;
4127
+ return this.payment.updatePaymentAsync(orderUuid, paymentUuid, {
4128
+ isSynced: true,
4129
+ syncError: undefined
4130
+ });
4131
+ case 75:
4132
+ _context40.next = 71;
4133
+ break;
4134
+ case 77:
4135
+ _context40.next = 82;
4136
+ break;
4137
+ case 79:
4138
+ _context40.prev = 79;
4139
+ _context40.t1 = _context40["catch"](69);
4140
+ _iterator3.e(_context40.t1);
4141
+ case 82:
4142
+ _context40.prev = 82;
4143
+ _iterator3.f();
4144
+ return _context40.finish(82);
4145
+ case 85:
4146
+ latestPaymentStatus = ((_checkoutResponse9 = checkoutResponse) === null || _checkoutResponse9 === void 0 || (_checkoutResponse9 = _checkoutResponse9.data) === null || _checkoutResponse9 === void 0 ? void 0 : _checkoutResponse9.payment_status) || orderPaymentStatus;
4147
+ _context40.next = 88;
4148
+ return this.payment.updateOrderAsync(orderUuid, {
4149
+ payment_status: latestPaymentStatus
4150
+ });
4151
+ case 88:
4152
+ _context40.next = 90;
4153
+ return this.core.effects.emit("".concat(this.name, ":onOrderSynced"), {
4154
+ orderUuid: orderUuid,
4155
+ realOrderId: realOrderId,
4156
+ virtualOrderId: orderUuid,
4157
+ timestamp: Date.now(),
4158
+ isManual: false,
4159
+ response: checkoutResponse,
4160
+ isFormRepair: true
4161
+ });
4162
+ case 90:
4163
+ return _context40.abrupt("return", {
4164
+ success: true,
4165
+ orderId: realOrderId,
4166
+ response: checkoutResponse
4167
+ });
4168
+ case 91:
4169
+ case "end":
4170
+ return _context40.stop();
4171
+ }
4172
+ }, _callee40, this, [[32, 40, 45, 49], [69, 79, 82, 85]]);
4173
+ }));
4174
+ function syncOrderToBackendFromIndexDbAsync(_x31) {
4175
+ return _syncOrderToBackendFromIndexDbAsync.apply(this, arguments);
4176
+ }
4177
+ return syncOrderToBackendFromIndexDbAsync;
3773
4178
  }()
3774
4179
  /**
3775
4180
  * 同步订单到后端并返回真实订单ID
@@ -3778,12 +4183,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3778
4183
  * @param customPaymentItems 自定义支付项列表,如果提供则使用此列表而不是从数据库获取
3779
4184
  * @returns 包含订单ID、UUID和完整后端响应的对象
3780
4185
  */
3781
- )
3782
4186
  }, {
3783
4187
  key: "syncOrderToBackendWithReturn",
3784
4188
  value: (function () {
3785
- var _syncOrderToBackendWithReturn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
3786
- var _this6 = this;
4189
+ var _syncOrderToBackendWithReturn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41() {
4190
+ var _this7 = this;
3787
4191
  var isManual,
3788
4192
  customPaymentItems,
3789
4193
  paymentStatus,
@@ -3792,15 +4196,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3792
4196
  resolveInFlight,
3793
4197
  rejectInFlight,
3794
4198
  inFlightPromise,
3795
- _this$store$currentOr26,
3796
4199
  _this$store$currentOr27,
3797
- _this$store$currentCu2,
3798
- _this$otherParams,
3799
4200
  _this$store$currentOr28,
4201
+ _this$store$currentCu2,
4202
+ _this$otherParams2,
4203
+ _this$store$currentOr29,
3800
4204
  _this$store$localOrde,
3801
4205
  _this$store$localOrde2,
3802
- _checkoutResponse3,
3803
- _checkoutResponse4,
4206
+ _checkoutResponse12,
4207
+ _checkoutResponse13,
3804
4208
  currentOrderId,
3805
4209
  isUpdateOperation,
3806
4210
  paymentItems,
@@ -3815,49 +4219,49 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3815
4219
  checkoutResponse,
3816
4220
  submitSuccess,
3817
4221
  submitError,
3818
- _checkoutResponse,
3819
- _checkoutResponse2,
4222
+ _checkoutResponse10,
4223
+ _checkoutResponse11,
3820
4224
  responseStatus,
3821
4225
  isSuccessResponse,
3822
- _checkoutResponse5,
4226
+ _checkoutResponse14,
3823
4227
  errorMessage,
3824
4228
  realOrderId,
3825
- _checkoutResponse6,
4229
+ _checkoutResponse15,
3826
4230
  extractedOrderId,
3827
- _checkoutResponse7,
4231
+ _checkoutResponse16,
3828
4232
  latestPaymentStatus,
3829
4233
  previousOrder,
3830
4234
  updatedOrder,
3831
4235
  beforeManualUpdate,
3832
4236
  syncedPaymentUuids,
3833
- _iterator3,
3834
- _step3,
4237
+ _iterator4,
4238
+ _step4,
3835
4239
  paymentUuid,
3836
4240
  result,
3837
4241
  currentInFlight,
3838
- _args39 = arguments;
3839
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3840
- while (1) switch (_context39.prev = _context39.next) {
4242
+ _args41 = arguments;
4243
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
4244
+ while (1) switch (_context41.prev = _context41.next) {
3841
4245
  case 0:
3842
- isManual = _args39.length > 0 && _args39[0] !== undefined ? _args39[0] : false;
3843
- customPaymentItems = _args39.length > 1 ? _args39[1] : undefined;
3844
- paymentStatus = _args39.length > 2 ? _args39[2] : undefined;
4246
+ isManual = _args41.length > 0 && _args41[0] !== undefined ? _args41[0] : false;
4247
+ customPaymentItems = _args41.length > 1 ? _args41[1] : undefined;
4248
+ paymentStatus = _args41.length > 2 ? _args41[2] : undefined;
3845
4249
  if (!(!this.store.localOrderData || !this.store.currentOrder)) {
3846
- _context39.next = 5;
4250
+ _context41.next = 5;
3847
4251
  break;
3848
4252
  }
3849
4253
  throw new Error('缺少必要的订单数据,无法同步到后端');
3850
4254
  case 5:
3851
4255
  orderLockKey = this.store.currentOrder.uuid || this.store.currentOrder.order_id;
3852
4256
  if (orderLockKey) {
3853
- _context39.next = 8;
4257
+ _context41.next = 8;
3854
4258
  break;
3855
4259
  }
3856
4260
  throw new Error('缺少订单标识,无法同步到后端');
3857
4261
  case 8:
3858
4262
  existingInFlight = this.syncOrderToBackendInFlightByOrderKey.get(orderLockKey);
3859
4263
  if (!existingInFlight) {
3860
- _context39.next = 14;
4264
+ _context41.next = 14;
3861
4265
  break;
3862
4266
  }
3863
4267
  this.logInfo('syncOrderToBackendWithReturn 触发锁:当前订单正在同步中,将等待当前同步结束', {
@@ -3867,17 +4271,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3867
4271
  isManual: isManual,
3868
4272
  hasCustomPaymentItems: !!customPaymentItems
3869
4273
  });
3870
- _context39.next = 13;
4274
+ _context41.next = 13;
3871
4275
  return existingInFlight;
3872
4276
  case 13:
3873
- return _context39.abrupt("return", _context39.sent);
4277
+ return _context41.abrupt("return", _context41.sent);
3874
4278
  case 14:
3875
4279
  inFlightPromise = new Promise(function (resolve, reject) {
3876
4280
  resolveInFlight = resolve;
3877
4281
  rejectInFlight = reject;
3878
4282
  });
3879
4283
  this.syncOrderToBackendInFlightByOrderKey.set(orderLockKey, inFlightPromise);
3880
- _context39.prev = 16;
4284
+ _context41.prev = 16;
3881
4285
  this.logInfo('syncOrderToBackendWithReturn called', {
3882
4286
  isManual: isManual
3883
4287
  });
@@ -3892,28 +4296,28 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3892
4296
  });
3893
4297
 
3894
4298
  // 获取当前订单的支付项
3895
- _context39.t0 = customPaymentItems;
3896
- if (_context39.t0) {
3897
- _context39.next = 26;
4299
+ _context41.t0 = customPaymentItems;
4300
+ if (_context41.t0) {
4301
+ _context41.next = 26;
3898
4302
  break;
3899
4303
  }
3900
- _context39.next = 25;
4304
+ _context41.next = 25;
3901
4305
  return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid);
3902
4306
  case 25:
3903
- _context39.t0 = _context39.sent;
4307
+ _context41.t0 = _context41.sent;
3904
4308
  case 26:
3905
- paymentItems = _context39.t0;
4309
+ paymentItems = _context41.t0;
3906
4310
  // 处理支付项数据,确保包含完整的 metadata
3907
4311
  processedPaymentItems = paymentItems.map(function (item) {
3908
- var _item$metadata, _item$metadata2;
4312
+ var _item$metadata3, _item$metadata4;
3909
4313
  return _objectSpread(_objectSpread({}, item), {}, {
3910
4314
  metadata: _objectSpread(_objectSpread({}, item.metadata), {}, {
3911
- rounding_rule: ((_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.rounding_rule) || _this6.otherParams.order_rounding_setting,
3912
- shop_wallet_pass_id: ((_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.shop_wallet_pass_id) || _this6.otherParams.shop_wallet_pass_id
4315
+ rounding_rule: ((_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.rounding_rule) || _this7.otherParams.order_rounding_setting,
4316
+ shop_wallet_pass_id: ((_item$metadata4 = item.metadata) === null || _item$metadata4 === void 0 ? void 0 : _item$metadata4.shop_wallet_pass_id) || _this7.otherParams.shop_wallet_pass_id
3913
4317
  })
3914
4318
  });
3915
4319
  }); // 确定最终的定金金额:优先使用手动设置的值,否则从支付项中计算
3916
- manualDepositAmount = ((_this$store$currentOr26 = this.store.currentOrder) === null || _this$store$currentOr26 === void 0 ? void 0 : _this$store$currentOr26.deposit_amount) || '0.00'; // 优先级逻辑:手动设置的定金金额 > 从支付项计算的金额
4320
+ manualDepositAmount = ((_this$store$currentOr27 = this.store.currentOrder) === null || _this$store$currentOr27 === void 0 ? void 0 : _this$store$currentOr27.deposit_amount) || '0.00'; // 优先级逻辑:手动设置的定金金额 > 从支付项计算的金额
3917
4321
  manualDepositValue = new Decimal(manualDepositAmount);
3918
4322
  if (manualDepositValue.gt(0)) {
3919
4323
  // 如果手动设置了定金金额且大于0,使用手动设置的值
@@ -3973,7 +4377,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3973
4377
  }),
3974
4378
  manualDepositAmount: manualDepositAmount,
3975
4379
  finalDepositAmount: finalDepositAmount,
3976
- isDeposit: ((_this$store$currentOr27 = this.store.currentOrder) === null || _this$store$currentOr27 === void 0 ? void 0 : _this$store$currentOr27.is_deposit) || 0
4380
+ isDeposit: ((_this$store$currentOr28 = this.store.currentOrder) === null || _this$store$currentOr28 === void 0 ? void 0 : _this$store$currentOr28.is_deposit) || 0
3977
4381
  });
3978
4382
 
3979
4383
  // 计算订单状态,优先读取外面传递的,如果没有则根据订单支付数据来
@@ -4020,8 +4424,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4020
4424
  currency_code: this.otherParams.currency_code,
4021
4425
  currency_symbol: this.otherParams.currency_symbol,
4022
4426
  currency_format: this.otherParams.currency_format,
4023
- business_code: ((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.business_code) || undefined,
4024
- is_deposit: ((_this$store$currentOr28 = this.store.currentOrder) !== null && _this$store$currentOr28 !== void 0 && _this$store$currentOr28.is_deposit || Number(finalDepositAmount) > 0 ? 1 : 0) || 0,
4427
+ business_code: ((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.business_code) || undefined,
4428
+ is_deposit: ((_this$store$currentOr29 = this.store.currentOrder) !== null && _this$store$currentOr29 !== void 0 && _this$store$currentOr29.is_deposit || Number(finalDepositAmount) > 0 ? 1 : 0) || 0,
4025
4429
  deposit_amount: finalDepositAmount,
4026
4430
  // 使用最终确定的定金金额(手动设置优先)
4027
4431
  product_tax_fee: this.store.localOrderData.tax_fee,
@@ -4052,7 +4456,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4052
4456
 
4053
4457
  // 发送下单接口请求开始事件
4054
4458
  startTime = Date.now();
4055
- _context39.next = 42;
4459
+ _context41.next = 42;
4056
4460
  return this.core.effects.emit("".concat(this.name, ":onOrderSubmitStart"), {
4057
4461
  orderUuid: this.store.currentOrder.uuid,
4058
4462
  operation: isUpdateOperation ? 'update' : 'create',
@@ -4062,7 +4466,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4062
4466
  });
4063
4467
  case 42:
4064
4468
  submitSuccess = false;
4065
- _context39.prev = 43;
4469
+ _context41.prev = 43;
4066
4470
  // 记录接口调用参数
4067
4471
  this.logInfo('Calling backend checkout API', _objectSpread({
4068
4472
  url: '/order/checkout',
@@ -4070,24 +4474,24 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4070
4474
  }, orderParams));
4071
4475
 
4072
4476
  // 调用 Order 模块的专用 createOrderByCheckout 方法
4073
- _context39.next = 47;
4477
+ _context41.next = 47;
4074
4478
  return this.order.createOrderByCheckout(orderParams);
4075
4479
  case 47:
4076
- checkoutResponse = _context39.sent;
4480
+ checkoutResponse = _context41.sent;
4077
4481
  submitSuccess = true;
4078
4482
  this.store.currentOrder.payment_status = checkoutResponse.data.payment_status;
4079
4483
  this.logInfo('下单接口调用成功', checkoutResponse);
4080
- _context39.next = 61;
4484
+ _context41.next = 61;
4081
4485
  break;
4082
4486
  case 53:
4083
- _context39.prev = 53;
4084
- _context39.t1 = _context39["catch"](43);
4487
+ _context41.prev = 53;
4488
+ _context41.t1 = _context41["catch"](43);
4085
4489
  submitSuccess = false;
4086
- submitError = _context39.t1 instanceof Error ? _context39.t1.message : String(_context39.t1);
4490
+ submitError = _context41.t1 instanceof Error ? _context41.t1.message : String(_context41.t1);
4087
4491
  this.logError('下单接口调用失败:', submitError);
4088
4492
 
4089
4493
  // 发送订单同步失败事件(网络错误或请求失败)
4090
- _context39.next = 60;
4494
+ _context41.next = 60;
4091
4495
  return this.core.effects.emit("".concat(this.name, ":onOrderSyncFailed"), {
4092
4496
  orderUuid: this.store.currentOrder.uuid,
4093
4497
  operation: isUpdateOperation ? 'update' : 'create',
@@ -4098,32 +4502,32 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4098
4502
  timestamp: Date.now()
4099
4503
  });
4100
4504
  case 60:
4101
- throw _context39.t1;
4505
+ throw _context41.t1;
4102
4506
  case 61:
4103
- _context39.prev = 61;
4104
- _context39.next = 64;
4507
+ _context41.prev = 61;
4508
+ _context41.next = 64;
4105
4509
  return this.core.effects.emit("".concat(this.name, ":onOrderSubmitEnd"), {
4106
4510
  success: submitSuccess,
4107
4511
  orderUuid: this.store.currentOrder.uuid,
4108
4512
  operation: isUpdateOperation ? 'update' : 'create',
4109
4513
  isManual: isManual,
4110
- orderId: submitSuccess ? ((_checkoutResponse = checkoutResponse) === null || _checkoutResponse === void 0 || (_checkoutResponse = _checkoutResponse.data) === null || _checkoutResponse === void 0 ? void 0 : _checkoutResponse.order_id) || ((_checkoutResponse2 = checkoutResponse) === null || _checkoutResponse2 === void 0 ? void 0 : _checkoutResponse2.order_id) : undefined,
4514
+ orderId: submitSuccess ? ((_checkoutResponse10 = checkoutResponse) === null || _checkoutResponse10 === void 0 || (_checkoutResponse10 = _checkoutResponse10.data) === null || _checkoutResponse10 === void 0 ? void 0 : _checkoutResponse10.order_id) || ((_checkoutResponse11 = checkoutResponse) === null || _checkoutResponse11 === void 0 ? void 0 : _checkoutResponse11.order_id) : undefined,
4111
4515
  error: submitError,
4112
4516
  duration: Date.now() - startTime,
4113
4517
  timestamp: Date.now()
4114
4518
  });
4115
4519
  case 64:
4116
- return _context39.finish(61);
4520
+ return _context41.finish(61);
4117
4521
  case 65:
4118
4522
  // 检查响应状态是否为成功状态
4119
- responseStatus = (_checkoutResponse3 = checkoutResponse) === null || _checkoutResponse3 === void 0 ? void 0 : _checkoutResponse3.status;
4120
- isSuccessResponse = responseStatus === true || responseStatus === 200 || responseStatus === 'success' || responseStatus === 1 && ((_checkoutResponse4 = checkoutResponse) === null || _checkoutResponse4 === void 0 ? void 0 : _checkoutResponse4.code) === 200;
4523
+ responseStatus = (_checkoutResponse12 = checkoutResponse) === null || _checkoutResponse12 === void 0 ? void 0 : _checkoutResponse12.status;
4524
+ isSuccessResponse = responseStatus === true || responseStatus === 200 || responseStatus === 'success' || responseStatus === 1 && ((_checkoutResponse13 = checkoutResponse) === null || _checkoutResponse13 === void 0 ? void 0 : _checkoutResponse13.code) === 200;
4121
4525
  if (isSuccessResponse) {
4122
- _context39.next = 72;
4526
+ _context41.next = 72;
4123
4527
  break;
4124
4528
  }
4125
- errorMessage = ((_checkoutResponse5 = checkoutResponse) === null || _checkoutResponse5 === void 0 ? void 0 : _checkoutResponse5.message) || '订单同步失败,后端返回非成功状态'; // 发送订单同步失败事件
4126
- _context39.next = 71;
4529
+ errorMessage = ((_checkoutResponse14 = checkoutResponse) === null || _checkoutResponse14 === void 0 ? void 0 : _checkoutResponse14.message) || '订单同步失败,后端返回非成功状态'; // 发送订单同步失败事件
4530
+ _context41.next = 71;
4127
4531
  return this.core.effects.emit("".concat(this.name, ":onOrderSyncFailed"), {
4128
4532
  orderUuid: this.store.currentOrder.uuid,
4129
4533
  operation: isUpdateOperation ? 'update' : 'create',
@@ -4138,18 +4542,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4138
4542
  throw new Error(errorMessage);
4139
4543
  case 72:
4140
4544
  if (!isUpdateOperation) {
4141
- _context39.next = 76;
4545
+ _context41.next = 76;
4142
4546
  break;
4143
4547
  }
4144
4548
  // 更新操作:使用现有的订单ID
4145
4549
  realOrderId = currentOrderId;
4146
- _context39.next = 109;
4550
+ _context41.next = 109;
4147
4551
  break;
4148
4552
  case 76:
4149
4553
  // 创建操作:从响应中提取新的订单ID
4150
- extractedOrderId = (_checkoutResponse6 = checkoutResponse) === null || _checkoutResponse6 === void 0 || (_checkoutResponse6 = _checkoutResponse6.data) === null || _checkoutResponse6 === void 0 ? void 0 : _checkoutResponse6.order_id; // 如果data.order_id不存在,尝试直接从根级获取
4554
+ extractedOrderId = (_checkoutResponse15 = checkoutResponse) === null || _checkoutResponse15 === void 0 || (_checkoutResponse15 = _checkoutResponse15.data) === null || _checkoutResponse15 === void 0 ? void 0 : _checkoutResponse15.order_id; // 如果data.order_id不存在,尝试直接从根级获取
4151
4555
  if (!extractedOrderId) {
4152
- extractedOrderId = (_checkoutResponse7 = checkoutResponse) === null || _checkoutResponse7 === void 0 ? void 0 : _checkoutResponse7.order_id;
4556
+ extractedOrderId = (_checkoutResponse16 = checkoutResponse) === null || _checkoutResponse16 === void 0 ? void 0 : _checkoutResponse16.order_id;
4153
4557
  }
4154
4558
 
4155
4559
  // 确保转换为字符串类型
@@ -4167,20 +4571,20 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4167
4571
  oldOrderId: this.store.currentOrder.order_id,
4168
4572
  newOrderId: realOrderId
4169
4573
  });
4170
- _context39.prev = 82;
4574
+ _context41.prev = 82;
4171
4575
  latestPaymentStatus = this.store.currentOrder.payment_status;
4172
4576
  previousOrder = this.store.currentOrder;
4173
- _context39.next = 87;
4577
+ _context41.next = 87;
4174
4578
  return this.payment.replaceOrderIdByUuidAsync(previousOrder.uuid, realOrderId);
4175
4579
  case 87:
4176
- updatedOrder = _context39.sent;
4580
+ updatedOrder = _context41.sent;
4177
4581
  this.logInfo('Payment模块替换订单ID结果:', {
4178
4582
  wasSuccessful: !!updatedOrder,
4179
4583
  returnedOrderId: updatedOrder === null || updatedOrder === void 0 ? void 0 : updatedOrder.order_id,
4180
4584
  expectedOrderId: realOrderId
4181
4585
  });
4182
4586
  if (!updatedOrder) {
4183
- _context39.next = 98;
4587
+ _context41.next = 98;
4184
4588
  break;
4185
4589
  }
4186
4590
  this.logInfo('Payment模块返回的更新后订单:', {
@@ -4196,16 +4600,16 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4196
4600
 
4197
4601
  // 同步更新 Payment 模块 DB,避免后续读取 DB 时又拿回旧状态
4198
4602
  if (!latestPaymentStatus) {
4199
- _context39.next = 95;
4603
+ _context41.next = 95;
4200
4604
  break;
4201
4605
  }
4202
- _context39.next = 95;
4606
+ _context41.next = 95;
4203
4607
  return this.payment.updateOrderAsync(previousOrder.uuid, {
4204
4608
  payment_status: latestPaymentStatus
4205
4609
  });
4206
4610
  case 95:
4207
4611
  this.logInfo('[Checkout] 订单ID替换成功,当前订单ID:', this.store.currentOrder.order_id);
4208
- _context39.next = 102;
4612
+ _context41.next = 102;
4209
4613
  break;
4210
4614
  case 98:
4211
4615
  this.logError('[Checkout] Payment模块返回空订单,订单ID替换失败,开始手动替换');
@@ -4219,59 +4623,59 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4219
4623
  目标ID: realOrderId
4220
4624
  });
4221
4625
  case 102:
4222
- _context39.next = 109;
4626
+ _context41.next = 109;
4223
4627
  break;
4224
4628
  case 104:
4225
- _context39.prev = 104;
4226
- _context39.t2 = _context39["catch"](82);
4227
- this.logError('调用Payment模块替换订单ID时发生错误:', _context39.t2);
4629
+ _context41.prev = 104;
4630
+ _context41.t2 = _context41["catch"](82);
4631
+ this.logError('调用Payment模块替换订单ID时发生错误:', _context41.t2);
4228
4632
 
4229
4633
  // 发生错误时也进行手动替换
4230
4634
  this.store.currentOrder.order_id = realOrderId;
4231
4635
  this.logInfo('错误恢复:手动设置订单ID:', realOrderId);
4232
4636
  case 109:
4233
- _context39.prev = 109;
4637
+ _context41.prev = 109;
4234
4638
  syncedPaymentUuids = processedPaymentItems.filter(function (item) {
4235
4639
  return item.status !== 'voided';
4236
4640
  }).map(function (item) {
4237
4641
  return item.uuid;
4238
4642
  }).filter(Boolean);
4239
- _iterator3 = _createForOfIteratorHelper(syncedPaymentUuids);
4240
- _context39.prev = 112;
4241
- _iterator3.s();
4643
+ _iterator4 = _createForOfIteratorHelper(syncedPaymentUuids);
4644
+ _context41.prev = 112;
4645
+ _iterator4.s();
4242
4646
  case 114:
4243
- if ((_step3 = _iterator3.n()).done) {
4244
- _context39.next = 120;
4647
+ if ((_step4 = _iterator4.n()).done) {
4648
+ _context41.next = 120;
4245
4649
  break;
4246
4650
  }
4247
- paymentUuid = _step3.value;
4248
- _context39.next = 118;
4651
+ paymentUuid = _step4.value;
4652
+ _context41.next = 118;
4249
4653
  return this.payment.updatePaymentAsync(this.store.currentOrder.uuid, paymentUuid, {
4250
4654
  isSynced: true,
4251
4655
  syncError: undefined
4252
4656
  });
4253
4657
  case 118:
4254
- _context39.next = 114;
4658
+ _context41.next = 114;
4255
4659
  break;
4256
4660
  case 120:
4257
- _context39.next = 125;
4661
+ _context41.next = 125;
4258
4662
  break;
4259
4663
  case 122:
4260
- _context39.prev = 122;
4261
- _context39.t3 = _context39["catch"](112);
4262
- _iterator3.e(_context39.t3);
4664
+ _context41.prev = 122;
4665
+ _context41.t3 = _context41["catch"](112);
4666
+ _iterator4.e(_context41.t3);
4263
4667
  case 125:
4264
- _context39.prev = 125;
4265
- _iterator3.f();
4266
- return _context39.finish(125);
4668
+ _context41.prev = 125;
4669
+ _iterator4.f();
4670
+ return _context41.finish(125);
4267
4671
  case 128:
4268
- _context39.next = 133;
4672
+ _context41.next = 133;
4269
4673
  break;
4270
4674
  case 130:
4271
- _context39.prev = 130;
4272
- _context39.t4 = _context39["catch"](109);
4675
+ _context41.prev = 130;
4676
+ _context41.t4 = _context41["catch"](109);
4273
4677
  this.logWarning('标记支付项已同步失败(不阻塞主流程)', {
4274
- error: _context39.t4
4678
+ error: _context41.t4
4275
4679
  });
4276
4680
  case 133:
4277
4681
  // 标记订单已同步
@@ -4281,7 +4685,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4281
4685
  this.clearCalculationCache();
4282
4686
 
4283
4687
  // 触发订单同步完成事件
4284
- _context39.next = 137;
4688
+ _context41.next = 137;
4285
4689
  return this.core.effects.emit("".concat(this.name, ":onOrderSynced"), {
4286
4690
  orderUuid: this.store.currentOrder.uuid,
4287
4691
  realOrderId: realOrderId,
@@ -4299,24 +4703,24 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4299
4703
  response: checkoutResponse
4300
4704
  };
4301
4705
  resolveInFlight(result);
4302
- return _context39.abrupt("return", result);
4706
+ return _context41.abrupt("return", result);
4303
4707
  case 142:
4304
- _context39.prev = 142;
4305
- _context39.t5 = _context39["catch"](16);
4306
- rejectInFlight(_context39.t5);
4307
- throw _context39.t5;
4708
+ _context41.prev = 142;
4709
+ _context41.t5 = _context41["catch"](16);
4710
+ rejectInFlight(_context41.t5);
4711
+ throw _context41.t5;
4308
4712
  case 146:
4309
- _context39.prev = 146;
4713
+ _context41.prev = 146;
4310
4714
  currentInFlight = this.syncOrderToBackendInFlightByOrderKey.get(orderLockKey);
4311
4715
  if (currentInFlight === inFlightPromise) {
4312
4716
  this.syncOrderToBackendInFlightByOrderKey.delete(orderLockKey);
4313
4717
  }
4314
- return _context39.finish(146);
4718
+ return _context41.finish(146);
4315
4719
  case 150:
4316
4720
  case "end":
4317
- return _context39.stop();
4721
+ return _context41.stop();
4318
4722
  }
4319
- }, _callee39, this, [[16, 142, 146, 150], [43, 53, 61, 65], [82, 104], [109, 130], [112, 122, 125, 128]]);
4723
+ }, _callee41, this, [[16, 142, 146, 150], [43, 53, 61, 65], [82, 104], [109, 130], [112, 122, 125, 128]]);
4320
4724
  }));
4321
4725
  function syncOrderToBackendWithReturn() {
4322
4726
  return _syncOrderToBackendWithReturn.apply(this, arguments);
@@ -4326,15 +4730,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4326
4730
  }, {
4327
4731
  key: "setOtherParams",
4328
4732
  value: function () {
4329
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
4733
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
4330
4734
  var _ref5,
4331
4735
  _ref5$cover,
4332
4736
  cover,
4333
- _args40 = arguments;
4334
- return _regeneratorRuntime().wrap(function _callee40$(_context40) {
4335
- while (1) switch (_context40.prev = _context40.next) {
4737
+ _args42 = arguments;
4738
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
4739
+ while (1) switch (_context42.prev = _context42.next) {
4336
4740
  case 0:
4337
- _ref5 = _args40.length > 1 && _args40[1] !== undefined ? _args40[1] : {}, _ref5$cover = _ref5.cover, cover = _ref5$cover === void 0 ? false : _ref5$cover;
4741
+ _ref5 = _args42.length > 1 && _args42[1] !== undefined ? _args42[1] : {}, _ref5$cover = _ref5.cover, cover = _ref5$cover === void 0 ? false : _ref5$cover;
4338
4742
  if (cover) {
4339
4743
  this.otherParams = params;
4340
4744
  } else {
@@ -4342,11 +4746,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4342
4746
  }
4343
4747
  case 2:
4344
4748
  case "end":
4345
- return _context40.stop();
4749
+ return _context42.stop();
4346
4750
  }
4347
- }, _callee40, this);
4751
+ }, _callee42, this);
4348
4752
  }));
4349
- function setOtherParams(_x29) {
4753
+ function setOtherParams(_x32) {
4350
4754
  return _setOtherParams.apply(this, arguments);
4351
4755
  }
4352
4756
  return setOtherParams;
@@ -4363,22 +4767,22 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4363
4767
  }, {
4364
4768
  key: "editOrderNoteByOrderIdAsync",
4365
4769
  value: (function () {
4366
- var _editOrderNoteByOrderIdAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(orderId, note) {
4770
+ var _editOrderNoteByOrderIdAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(orderId, note) {
4367
4771
  var response, previousNote, errorMessage, _errorMessage;
4368
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
4369
- while (1) switch (_context41.prev = _context41.next) {
4772
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
4773
+ while (1) switch (_context43.prev = _context43.next) {
4370
4774
  case 0:
4371
4775
  this.logInfo('editOrderNoteByOrderIdAsync called', {
4372
4776
  orderId: orderId,
4373
4777
  note: note,
4374
4778
  noteLength: note.length
4375
4779
  });
4376
- _context41.prev = 1;
4780
+ _context43.prev = 1;
4377
4781
  if (orderId) {
4378
- _context41.next = 4;
4782
+ _context43.next = 4;
4379
4783
  break;
4380
4784
  }
4381
- return _context41.abrupt("return", {
4785
+ return _context43.abrupt("return", {
4382
4786
  success: false,
4383
4787
  message: '订单ID不能为空',
4384
4788
  orderId: orderId
@@ -4394,12 +4798,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4394
4798
  });
4395
4799
 
4396
4800
  // 调用后端API修改订单备注
4397
- _context41.next = 7;
4801
+ _context43.next = 7;
4398
4802
  return this.request.put("/order/order/".concat(orderId, "/note"), {
4399
4803
  note: note
4400
4804
  });
4401
4805
  case 7:
4402
- response = _context41.sent;
4806
+ response = _context43.sent;
4403
4807
  this.logInfo('订单备注编辑响应:', {
4404
4808
  orderId: orderId,
4405
4809
  status: response.status,
@@ -4409,11 +4813,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4409
4813
 
4410
4814
  // 检查响应状态
4411
4815
  if (!(response.status === true || response.status === 200)) {
4412
- _context41.next = 18;
4816
+ _context43.next = 18;
4413
4817
  break;
4414
4818
  }
4415
4819
  if (!(this.store.currentOrder && (String(this.store.currentOrder.order_id) === String(orderId) || String(this.store.currentOrder.id) === String(orderId)))) {
4416
- _context41.next = 15;
4820
+ _context43.next = 15;
4417
4821
  break;
4418
4822
  }
4419
4823
  // 获取修改前的备注用于事件
@@ -4423,7 +4827,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4423
4827
  }
4424
4828
 
4425
4829
  // 触发订单备注变更事件
4426
- _context41.next = 15;
4830
+ _context43.next = 15;
4427
4831
  return this.core.effects.emit("".concat(this.name, ":onOrderNoteChanged"), {
4428
4832
  orderUuid: this.store.currentOrder.uuid,
4429
4833
  oldNote: previousNote,
@@ -4431,7 +4835,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4431
4835
  timestamp: Date.now()
4432
4836
  });
4433
4837
  case 15:
4434
- return _context41.abrupt("return", {
4838
+ return _context43.abrupt("return", {
4435
4839
  success: true,
4436
4840
  message: response.message || '订单备注修改成功',
4437
4841
  orderId: orderId
@@ -4440,31 +4844,31 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4440
4844
  // API返回失败状态
4441
4845
  errorMessage = response.message || '订单备注修改失败';
4442
4846
  this.logError("\u8BA2\u5355 ".concat(orderId, " \u5907\u6CE8\u4FEE\u6539\u5931\u8D25:"), errorMessage);
4443
- return _context41.abrupt("return", {
4847
+ return _context43.abrupt("return", {
4444
4848
  success: false,
4445
4849
  message: errorMessage,
4446
4850
  orderId: orderId
4447
4851
  });
4448
4852
  case 21:
4449
- _context41.next = 28;
4853
+ _context43.next = 28;
4450
4854
  break;
4451
4855
  case 23:
4452
- _context41.prev = 23;
4453
- _context41.t0 = _context41["catch"](1);
4454
- this.logError('编辑订单备注失败:', _context41.t0);
4455
- _errorMessage = _context41.t0 instanceof Error ? _context41.t0.message : '网络错误或服务器异常';
4456
- return _context41.abrupt("return", {
4856
+ _context43.prev = 23;
4857
+ _context43.t0 = _context43["catch"](1);
4858
+ this.logError('编辑订单备注失败:', _context43.t0);
4859
+ _errorMessage = _context43.t0 instanceof Error ? _context43.t0.message : '网络错误或服务器异常';
4860
+ return _context43.abrupt("return", {
4457
4861
  success: false,
4458
4862
  message: "\u7F16\u8F91\u8BA2\u5355\u5907\u6CE8\u5931\u8D25: ".concat(_errorMessage),
4459
4863
  orderId: orderId
4460
4864
  });
4461
4865
  case 28:
4462
4866
  case "end":
4463
- return _context41.stop();
4867
+ return _context43.stop();
4464
4868
  }
4465
- }, _callee41, this, [[1, 23]]);
4869
+ }, _callee43, this, [[1, 23]]);
4466
4870
  }));
4467
- function editOrderNoteByOrderIdAsync(_x30, _x31) {
4871
+ function editOrderNoteByOrderIdAsync(_x33, _x34) {
4468
4872
  return _editOrderNoteByOrderIdAsync.apply(this, arguments);
4469
4873
  }
4470
4874
  return editOrderNoteByOrderIdAsync;
@@ -4481,11 +4885,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4481
4885
  }, {
4482
4886
  key: "sendCustomerPayLinkAsync",
4483
4887
  value: (function () {
4484
- var _sendCustomerPayLinkAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
4888
+ var _sendCustomerPayLinkAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(params) {
4485
4889
  var _params$order_ids, _params$emails;
4486
4890
  var emailRegex, invalidEmails, requestBody, response, errorMessage, _errorMessage2;
4487
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
4488
- while (1) switch (_context42.prev = _context42.next) {
4891
+ return _regeneratorRuntime().wrap(function _callee44$(_context44) {
4892
+ while (1) switch (_context44.prev = _context44.next) {
4489
4893
  case 0:
4490
4894
  this.logInfo('sendCustomerPayLinkAsync called', {
4491
4895
  orderIds: params.order_ids,
@@ -4494,21 +4898,21 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4494
4898
  emailsCount: ((_params$emails = params.emails) === null || _params$emails === void 0 ? void 0 : _params$emails.length) || 0,
4495
4899
  notifyAction: params.notify_action || 'order_payment_reminder'
4496
4900
  });
4497
- _context42.prev = 1;
4901
+ _context44.prev = 1;
4498
4902
  if (!(!params.order_ids || params.order_ids.length === 0)) {
4499
- _context42.next = 4;
4903
+ _context44.next = 4;
4500
4904
  break;
4501
4905
  }
4502
- return _context42.abrupt("return", {
4906
+ return _context44.abrupt("return", {
4503
4907
  success: false,
4504
4908
  message: '订单ID列表不能为空'
4505
4909
  });
4506
4910
  case 4:
4507
4911
  if (!(!params.emails || params.emails.length === 0)) {
4508
- _context42.next = 6;
4912
+ _context44.next = 6;
4509
4913
  break;
4510
4914
  }
4511
- return _context42.abrupt("return", {
4915
+ return _context44.abrupt("return", {
4512
4916
  success: false,
4513
4917
  message: '邮箱地址列表不能为空'
4514
4918
  });
@@ -4519,10 +4923,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4519
4923
  return !emailRegex.test(email);
4520
4924
  });
4521
4925
  if (!(invalidEmails.length > 0)) {
4522
- _context42.next = 10;
4926
+ _context44.next = 10;
4523
4927
  break;
4524
4928
  }
4525
- return _context42.abrupt("return", {
4929
+ return _context44.abrupt("return", {
4526
4930
  success: false,
4527
4931
  message: "\u90AE\u7BB1\u683C\u5F0F\u65E0\u6548: ".concat(invalidEmails.join(', '))
4528
4932
  });
@@ -4538,10 +4942,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4538
4942
  }, requestBody));
4539
4943
 
4540
4944
  // 调用后端API发送邮件
4541
- _context42.next = 14;
4945
+ _context44.next = 14;
4542
4946
  return this.request.post('/order/batch-email', requestBody);
4543
4947
  case 14:
4544
- response = _context42.sent;
4948
+ response = _context44.sent;
4545
4949
  this.logInfo('支付链接邮件发送响应:', {
4546
4950
  status: response.status,
4547
4951
  message: response.message,
@@ -4551,10 +4955,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4551
4955
 
4552
4956
  // 检查响应状态
4553
4957
  if (!(response.status === true || response.status === 200)) {
4554
- _context42.next = 20;
4958
+ _context44.next = 20;
4555
4959
  break;
4556
4960
  }
4557
- return _context42.abrupt("return", {
4961
+ return _context44.abrupt("return", {
4558
4962
  success: true,
4559
4963
  message: response.message || '支付链接邮件发送成功'
4560
4964
  });
@@ -4562,29 +4966,29 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4562
4966
  // API返回失败状态
4563
4967
  errorMessage = response.message || '支付链接邮件发送失败';
4564
4968
  console.error('[Checkout] 支付链接邮件发送失败:', errorMessage);
4565
- return _context42.abrupt("return", {
4969
+ return _context44.abrupt("return", {
4566
4970
  success: false,
4567
4971
  message: errorMessage
4568
4972
  });
4569
4973
  case 23:
4570
- _context42.next = 30;
4974
+ _context44.next = 30;
4571
4975
  break;
4572
4976
  case 25:
4573
- _context42.prev = 25;
4574
- _context42.t0 = _context42["catch"](1);
4575
- this.logError('发送客户支付链接邮件失败:', _context42.t0);
4576
- _errorMessage2 = _context42.t0 instanceof Error ? _context42.t0.message : '网络错误或服务器异常';
4577
- return _context42.abrupt("return", {
4977
+ _context44.prev = 25;
4978
+ _context44.t0 = _context44["catch"](1);
4979
+ this.logError('发送客户支付链接邮件失败:', _context44.t0);
4980
+ _errorMessage2 = _context44.t0 instanceof Error ? _context44.t0.message : '网络错误或服务器异常';
4981
+ return _context44.abrupt("return", {
4578
4982
  success: false,
4579
4983
  message: "\u53D1\u9001\u652F\u4ED8\u94FE\u63A5\u90AE\u4EF6\u5931\u8D25: ".concat(_errorMessage2)
4580
4984
  });
4581
4985
  case 30:
4582
4986
  case "end":
4583
- return _context42.stop();
4987
+ return _context44.stop();
4584
4988
  }
4585
- }, _callee42, this, [[1, 25]]);
4989
+ }, _callee44, this, [[1, 25]]);
4586
4990
  }));
4587
- function sendCustomerPayLinkAsync(_x32) {
4991
+ function sendCustomerPayLinkAsync(_x35) {
4588
4992
  return _sendCustomerPayLinkAsync.apply(this, arguments);
4589
4993
  }
4590
4994
  return sendCustomerPayLinkAsync;
@@ -4599,38 +5003,38 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4599
5003
  }, {
4600
5004
  key: "roundAmountAsync",
4601
5005
  value: (function () {
4602
- var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(amount) {
5006
+ var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(amount) {
4603
5007
  var _cashManualPayment$me, _this$otherParams$ord, _this$otherParams$ord2;
4604
5008
  var cashManualPayment, result;
4605
- return _regeneratorRuntime().wrap(function _callee43$(_context43) {
4606
- while (1) switch (_context43.prev = _context43.next) {
5009
+ return _regeneratorRuntime().wrap(function _callee45$(_context45) {
5010
+ while (1) switch (_context45.prev = _context45.next) {
4607
5011
  case 0:
4608
5012
  // 检查 CASHMANUAL 的支付项是否开启了舍入,如果没开直接返回 amount
4609
5013
  cashManualPayment = this.store.paymentMethods.find(function (p) {
4610
5014
  return p.code === 'CASHMANUAL';
4611
5015
  });
4612
5016
  if (cashManualPayment !== null && cashManualPayment !== void 0 && (_cashManualPayment$me = cashManualPayment.metadata) !== null && _cashManualPayment$me !== void 0 && _cashManualPayment$me.order_rounding_switch) {
4613
- _context43.next = 3;
5017
+ _context45.next = 3;
4614
5018
  break;
4615
5019
  }
4616
- return _context43.abrupt("return", {
5020
+ return _context45.abrupt("return", {
4617
5021
  originalAmount: amount.toString(),
4618
5022
  roundedAmount: amount.toString(),
4619
5023
  roundingDifference: '0.00'
4620
5024
  });
4621
5025
  case 3:
4622
- _context43.next = 5;
5026
+ _context45.next = 5;
4623
5027
  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);
4624
5028
  case 5:
4625
- result = _context43.sent;
4626
- return _context43.abrupt("return", result);
5029
+ result = _context45.sent;
5030
+ return _context45.abrupt("return", result);
4627
5031
  case 7:
4628
5032
  case "end":
4629
- return _context43.stop();
5033
+ return _context45.stop();
4630
5034
  }
4631
- }, _callee43, this);
5035
+ }, _callee45, this);
4632
5036
  }));
4633
- function roundAmountAsync(_x33) {
5037
+ function roundAmountAsync(_x36) {
4634
5038
  return _roundAmountAsync.apply(this, arguments);
4635
5039
  }
4636
5040
  return roundAmountAsync;
@@ -4638,10 +5042,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4638
5042
  }, {
4639
5043
  key: "destroy",
4640
5044
  value: function () {
4641
- var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
5045
+ var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
4642
5046
  var _this$order, _this$order$destroy, _this$payment, _this$payment$destroy;
4643
- return _regeneratorRuntime().wrap(function _callee44$(_context44) {
4644
- while (1) switch (_context44.prev = _context44.next) {
5047
+ return _regeneratorRuntime().wrap(function _callee46$(_context46) {
5048
+ while (1) switch (_context46.prev = _context46.next) {
4645
5049
  case 0:
4646
5050
  // 清理钱包模块的所有缓存数据
4647
5051
  this.payment.wallet.clearAllCache();
@@ -4650,10 +5054,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4650
5054
  this.core.effects.offByModuleDestroy(this.name);
4651
5055
 
4652
5056
  // 销毁子模块
4653
- _context44.next = 4;
5057
+ _context46.next = 4;
4654
5058
  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);
4655
5059
  case 4:
4656
- _context44.next = 6;
5060
+ _context46.next = 6;
4657
5061
  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);
4658
5062
  case 6:
4659
5063
  // 取消注册模块
@@ -4661,9 +5065,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4661
5065
  console.log('[Checkout] 已销毁');
4662
5066
  case 8:
4663
5067
  case "end":
4664
- return _context44.stop();
5068
+ return _context46.stop();
4665
5069
  }
4666
- }, _callee44, this);
5070
+ }, _callee46, this);
4667
5071
  }));
4668
5072
  function destroy() {
4669
5073
  return _destroy.apply(this, arguments);
@@ -4680,7 +5084,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4680
5084
  }, {
4681
5085
  key: "resetStoreState",
4682
5086
  value: function resetStoreState() {
4683
- var _this7 = this;
5087
+ var _this8 = this;
4684
5088
  try {
4685
5089
  var prevOrderInfo = this.store.currentOrder ? {
4686
5090
  uuid: this.store.currentOrder.uuid,
@@ -4715,7 +5119,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4715
5119
  // 使用 setTimeout 确保事件处理不会阻塞状态重置
4716
5120
  if (prevOrderInfo) {
4717
5121
  setTimeout(function () {
4718
- _this7.core.effects.emit("".concat(_this7.name, ":onOrderCleared"), {
5122
+ _this8.core.effects.emit("".concat(_this8.name, ":onOrderCleared"), {
4719
5123
  previousOrder: prevOrderInfo,
4720
5124
  timestamp: Date.now()
4721
5125
  });