@pisell/pisellos 0.0.438 → 0.0.440
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.
- package/dist/modules/Discount/index.d.ts +1 -0
- package/dist/modules/Discount/index.js +2 -1
- package/dist/modules/Payment/types.d.ts +3 -1
- package/dist/modules/Payment/types.js +1 -0
- package/dist/modules/Summary/index.js +4 -5
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/Checkout/index.d.ts +3 -1
- package/dist/solution/Checkout/index.js +612 -244
- package/dist/solution/Checkout/types.d.ts +1 -1
- package/dist/solution/ShopDiscount/index.js +2 -1
- package/lib/modules/Discount/index.d.ts +1 -0
- package/lib/modules/Discount/index.js +2 -1
- package/lib/modules/Payment/types.d.ts +3 -1
- package/lib/modules/Payment/types.js +1 -0
- package/lib/modules/Summary/index.js +2 -3
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/Checkout/index.d.ts +3 -1
- package/lib/solution/Checkout/index.js +249 -10
- package/lib/solution/Checkout/types.d.ts +1 -1
- package/lib/solution/ShopDiscount/index.js +2 -1
- package/package.json +1 -1
|
@@ -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
|
|
1505
|
+
var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(paymentItem, orderUuid) {
|
|
1506
|
+
var _paymentItem$type, _paymentItem$code;
|
|
1507
|
+
var isEftposPayment, shouldRepairFromIndexDb, _this$store$currentOr10, orderPaymentType, processedPaymentItem, metadata, paymentItemWithType, remainingAmount, _paymentItem$type2, _paymentItem$code2, _isEftposPayment, _isCashPayment, 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',
|
|
1511
|
-
|
|
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$currentOr10 = this.store.currentOrder) === null || _this$store$currentOr10 === void 0 ? void 0 : _this$store$currentOr10.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 =
|
|
1548
|
+
_context16.next = 17;
|
|
1514
1549
|
break;
|
|
1515
1550
|
}
|
|
1516
1551
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '未找到当前订单,无法添加支付项');
|
|
1517
|
-
case
|
|
1552
|
+
case 17:
|
|
1518
1553
|
// 根据当前订单的定金状态设置订单支付类型
|
|
1519
1554
|
orderPaymentType = this.store.currentOrder.is_deposit === 1 ? 'deposit' : 'normal'; // 处理现金支付的找零逻辑
|
|
1520
|
-
_context16.next =
|
|
1555
|
+
_context16.next = 20;
|
|
1521
1556
|
return this.processCashPaymentItem(paymentItem);
|
|
1522
|
-
case
|
|
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 =
|
|
1568
|
+
_context16.next = 25;
|
|
1534
1569
|
return this.payment.addPaymentItemAsync(this.store.currentOrder.uuid, paymentItemWithType);
|
|
1535
|
-
case
|
|
1570
|
+
case 25:
|
|
1536
1571
|
this.logInfo('支付项添加成功');
|
|
1537
1572
|
|
|
1538
1573
|
// 🚀 清除计算缓存,确保获取最新数据
|
|
1539
1574
|
this.clearCalculationCache();
|
|
1540
1575
|
|
|
1541
1576
|
// 支付项添加后,更新 stateAmount 为剩余未支付金额
|
|
1542
|
-
_context16.next =
|
|
1577
|
+
_context16.next = 29;
|
|
1543
1578
|
return this.updateStateAmountToRemaining();
|
|
1544
|
-
case
|
|
1545
|
-
_context16.next =
|
|
1579
|
+
case 29:
|
|
1580
|
+
_context16.next = 31;
|
|
1546
1581
|
return this.calculateRemainingAmountAsync();
|
|
1547
|
-
case
|
|
1582
|
+
case 31:
|
|
1548
1583
|
remainingAmount = _context16.sent;
|
|
1549
1584
|
if (!(Number(remainingAmount) > 0)) {
|
|
1550
|
-
_context16.next =
|
|
1585
|
+
_context16.next = 52;
|
|
1551
1586
|
break;
|
|
1552
1587
|
}
|
|
1553
1588
|
this.logInfo('订单金额还有待付的,同步 EFTPOS 支付');
|
|
1554
1589
|
// 检查是否是 EFTPOS 支付,如果是则立即同步订单
|
|
1555
|
-
|
|
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
|
_isCashPayment = paymentItem.code === 'CASHMANUAL';
|
|
1557
1592
|
isCustomePayment = paymentItem.type === 'custom';
|
|
1558
1593
|
this.logInfo('EFTPOS 支付检查:', {
|
|
1559
1594
|
paymentCode: paymentItem.code,
|
|
1560
1595
|
paymentType: paymentItem.type,
|
|
1561
|
-
isEftposPayment:
|
|
1596
|
+
isEftposPayment: _isEftposPayment,
|
|
1562
1597
|
currentOrderSynced: this.store.isOrderSynced
|
|
1563
1598
|
});
|
|
1564
|
-
if (!(
|
|
1565
|
-
_context16.next =
|
|
1599
|
+
if (!(_isEftposPayment || _isCashPayment || isCustomePayment)) {
|
|
1600
|
+
_context16.next = 52;
|
|
1566
1601
|
break;
|
|
1567
1602
|
}
|
|
1568
1603
|
this.logInfo('检测到 EFTPOS 支付,立即同步订单到后端...');
|
|
1569
|
-
_context16.prev =
|
|
1570
|
-
_context16.next =
|
|
1604
|
+
_context16.prev = 40;
|
|
1605
|
+
_context16.next = 43;
|
|
1571
1606
|
return this.syncOrderToBackendWithReturn(true);
|
|
1572
|
-
case
|
|
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 =
|
|
1614
|
+
_context16.next = 52;
|
|
1580
1615
|
break;
|
|
1581
|
-
case
|
|
1582
|
-
_context16.prev =
|
|
1583
|
-
_context16.
|
|
1584
|
-
this.logError('EFTPOS 支付后订单同步失败:', _context16.
|
|
1616
|
+
case 47:
|
|
1617
|
+
_context16.prev = 47;
|
|
1618
|
+
_context16.t1 = _context16["catch"](40);
|
|
1619
|
+
this.logError('EFTPOS 支付后订单同步失败:', _context16.t1);
|
|
1585
1620
|
// 不抛出错误,避免影响支付流程,但记录错误
|
|
1586
|
-
_context16.next =
|
|
1587
|
-
return this.handleError(new Error("EFTPOS \u652F\u4ED8\u540E\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(_context16.
|
|
1588
|
-
case
|
|
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 =
|
|
1632
|
+
_context16.next = 61;
|
|
1598
1633
|
break;
|
|
1599
|
-
case
|
|
1600
|
-
_context16.prev =
|
|
1601
|
-
_context16.
|
|
1602
|
-
this.logError('添加支付项失败:', _context16.
|
|
1603
|
-
_context16.next =
|
|
1604
|
-
return this.handleError(_context16.
|
|
1605
|
-
case
|
|
1606
|
-
throw _context16.
|
|
1607
|
-
case
|
|
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, [[
|
|
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(
|
|
1762
|
+
function deletePaymentItemAsync(_x17) {
|
|
1728
1763
|
return _deletePaymentItemAsync.apply(this, arguments);
|
|
1729
1764
|
}
|
|
1730
1765
|
return deletePaymentItemAsync;
|
|
@@ -1860,7 +1895,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1860
1895
|
}
|
|
1861
1896
|
}, _callee18, this, [[0, 34]]);
|
|
1862
1897
|
}));
|
|
1863
|
-
function updateVoucherPaymentItemsAsync(
|
|
1898
|
+
function updateVoucherPaymentItemsAsync(_x18) {
|
|
1864
1899
|
return _updateVoucherPaymentItemsAsync.apply(this, arguments);
|
|
1865
1900
|
}
|
|
1866
1901
|
return updateVoucherPaymentItemsAsync;
|
|
@@ -1964,7 +1999,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1964
1999
|
}
|
|
1965
2000
|
}, _callee19, this, [[0, 24]]);
|
|
1966
2001
|
}));
|
|
1967
|
-
function updateOrderDepositStatusAsync(
|
|
2002
|
+
function updateOrderDepositStatusAsync(_x19) {
|
|
1968
2003
|
return _updateOrderDepositStatusAsync.apply(this, arguments);
|
|
1969
2004
|
}
|
|
1970
2005
|
return updateOrderDepositStatusAsync;
|
|
@@ -1983,7 +2018,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1983
2018
|
key: "setDepositAmountAsync",
|
|
1984
2019
|
value: (function () {
|
|
1985
2020
|
var _setDepositAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(depositAmount) {
|
|
1986
|
-
var _this$store$
|
|
2021
|
+
var _this$store$currentOr11, _this$store$currentOr12;
|
|
1987
2022
|
var depositValue, formattedDepositAmount, oldDepositAmount, updateParams;
|
|
1988
2023
|
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1989
2024
|
while (1) switch (_context20.prev = _context20.next) {
|
|
@@ -1991,8 +2026,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1991
2026
|
this.logInfo('setDepositAmountAsync called', {
|
|
1992
2027
|
depositAmount: depositAmount,
|
|
1993
2028
|
hasCurrentOrder: !!this.store.currentOrder,
|
|
1994
|
-
currentOrderId: (_this$store$
|
|
1995
|
-
currentTotalAmount: (_this$store$
|
|
2029
|
+
currentOrderId: (_this$store$currentOr11 = this.store.currentOrder) === null || _this$store$currentOr11 === void 0 ? void 0 : _this$store$currentOr11.order_id,
|
|
2030
|
+
currentTotalAmount: (_this$store$currentOr12 = this.store.currentOrder) === null || _this$store$currentOr12 === void 0 ? void 0 : _this$store$currentOr12.total_amount
|
|
1996
2031
|
});
|
|
1997
2032
|
_context20.prev = 1;
|
|
1998
2033
|
// 验证定金金额格式
|
|
@@ -2097,7 +2132,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2097
2132
|
}
|
|
2098
2133
|
}, _callee20, this, [[1, 26]]);
|
|
2099
2134
|
}));
|
|
2100
|
-
function setDepositAmountAsync(
|
|
2135
|
+
function setDepositAmountAsync(_x20) {
|
|
2101
2136
|
return _setDepositAmountAsync.apply(this, arguments);
|
|
2102
2137
|
}
|
|
2103
2138
|
return setDepositAmountAsync;
|
|
@@ -2112,17 +2147,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2112
2147
|
key: "manualSyncOrderAsync",
|
|
2113
2148
|
value: (function () {
|
|
2114
2149
|
var _manualSyncOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
2115
|
-
var _this$store$
|
|
2116
|
-
var _this$store$
|
|
2150
|
+
var _this$store$currentOr13, _this$store$currentOr14, _this$store$currentOr15;
|
|
2151
|
+
var _this$store$currentOr16, orderUuid, oldOrderId, syncResult, finalOrderId, finalIsVirtual, newRes, _this$store$currentOr17, errorMessage;
|
|
2117
2152
|
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
2118
2153
|
while (1) switch (_context21.prev = _context21.next) {
|
|
2119
2154
|
case 0:
|
|
2120
2155
|
console.log('manualSyncOrderAsync called');
|
|
2121
2156
|
this.logInfo('manualSyncOrderAsync called', {
|
|
2122
2157
|
hasCurrentOrder: !!this.store.currentOrder,
|
|
2123
|
-
currentOrderId: (_this$store$
|
|
2124
|
-
orderUuid: (_this$store$
|
|
2125
|
-
totalAmount: (_this$store$
|
|
2158
|
+
currentOrderId: (_this$store$currentOr13 = this.store.currentOrder) === null || _this$store$currentOr13 === void 0 ? void 0 : _this$store$currentOr13.order_id,
|
|
2159
|
+
orderUuid: (_this$store$currentOr14 = this.store.currentOrder) === null || _this$store$currentOr14 === void 0 ? void 0 : _this$store$currentOr14.uuid,
|
|
2160
|
+
totalAmount: (_this$store$currentOr15 = this.store.currentOrder) === null || _this$store$currentOr15 === void 0 ? void 0 : _this$store$currentOr15.total_amount,
|
|
2126
2161
|
isOrderSynced: this.store.isOrderSynced,
|
|
2127
2162
|
isVirtualOrderId: this.store.currentOrder ? isVirtualOrderId(this.store.currentOrder.order_id) : false
|
|
2128
2163
|
});
|
|
@@ -2182,7 +2217,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2182
2217
|
this.logError('[Checkout] 严重警告:返回的订单ID与存储的订单ID不一致!');
|
|
2183
2218
|
}
|
|
2184
2219
|
newRes = _objectSpread(_objectSpread({}, syncResult), {}, {
|
|
2185
|
-
is_deposit: ((_this$store$
|
|
2220
|
+
is_deposit: ((_this$store$currentOr16 = this.store.currentOrder) === null || _this$store$currentOr16 === void 0 ? void 0 : _this$store$currentOr16.is_deposit) || 0
|
|
2186
2221
|
});
|
|
2187
2222
|
_context21.next = 30;
|
|
2188
2223
|
return this.updateStateAmountToRemaining(false);
|
|
@@ -2196,7 +2231,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2196
2231
|
return _context21.abrupt("return", {
|
|
2197
2232
|
success: false,
|
|
2198
2233
|
message: "\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(errorMessage),
|
|
2199
|
-
orderUuid: (_this$store$
|
|
2234
|
+
orderUuid: (_this$store$currentOr17 = this.store.currentOrder) === null || _this$store$currentOr17 === void 0 ? void 0 : _this$store$currentOr17.uuid
|
|
2200
2235
|
});
|
|
2201
2236
|
case 38:
|
|
2202
2237
|
case "end":
|
|
@@ -2273,15 +2308,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2273
2308
|
key: "cancelCurrentOrderAsync",
|
|
2274
2309
|
value: (function () {
|
|
2275
2310
|
var _cancelCurrentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(cancelReason) {
|
|
2276
|
-
var _this$store$
|
|
2311
|
+
var _this$store$currentOr18, _this$store$currentOr19, currentOrderUuid, currentOrderId, isOrderSynced, errorMessage;
|
|
2277
2312
|
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
2278
2313
|
while (1) switch (_context22.prev = _context22.next) {
|
|
2279
2314
|
case 0:
|
|
2280
2315
|
_context22.prev = 0;
|
|
2281
2316
|
this.logInfo('开始取消当前本地订单:', {
|
|
2282
2317
|
hasCurrentOrder: !!this.store.currentOrder,
|
|
2283
|
-
orderUuid: (_this$store$
|
|
2284
|
-
orderId: (_this$store$
|
|
2318
|
+
orderUuid: (_this$store$currentOr18 = this.store.currentOrder) === null || _this$store$currentOr18 === void 0 ? void 0 : _this$store$currentOr18.uuid,
|
|
2319
|
+
orderId: (_this$store$currentOr19 = this.store.currentOrder) === null || _this$store$currentOr19 === void 0 ? void 0 : _this$store$currentOr19.order_id,
|
|
2285
2320
|
isOrderSynced: this.store.isOrderSynced,
|
|
2286
2321
|
cancelReason: cancelReason
|
|
2287
2322
|
});
|
|
@@ -2315,17 +2350,19 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2315
2350
|
});
|
|
2316
2351
|
case 11:
|
|
2317
2352
|
_context22.prev = 11;
|
|
2318
|
-
this.logInfo('
|
|
2353
|
+
this.logInfo('标记本地订单为已删除');
|
|
2319
2354
|
_context22.next = 15;
|
|
2320
|
-
return this.payment.
|
|
2355
|
+
return this.payment.updateOrderAsync(currentOrderUuid, {
|
|
2356
|
+
payment_status: PaymentStatus.Voided
|
|
2357
|
+
});
|
|
2321
2358
|
case 15:
|
|
2322
|
-
this.logInfo('
|
|
2359
|
+
this.logInfo('本地订单删除标记成功');
|
|
2323
2360
|
_context22.next = 21;
|
|
2324
2361
|
break;
|
|
2325
2362
|
case 18:
|
|
2326
2363
|
_context22.prev = 18;
|
|
2327
2364
|
_context22.t0 = _context22["catch"](11);
|
|
2328
|
-
this.logWarning('
|
|
2365
|
+
this.logWarning('标记本地订单删除失败,但继续执行:', _context22.t0);
|
|
2329
2366
|
case 21:
|
|
2330
2367
|
// 清理订单相关状态,确保正确释放 currentOrder
|
|
2331
2368
|
this.logInfo('清理订单相关状态');
|
|
@@ -2376,7 +2413,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2376
2413
|
}
|
|
2377
2414
|
}, _callee22, this, [[0, 36], [11, 18]]);
|
|
2378
2415
|
}));
|
|
2379
|
-
function cancelCurrentOrderAsync(
|
|
2416
|
+
function cancelCurrentOrderAsync(_x21) {
|
|
2380
2417
|
return _cancelCurrentOrderAsync.apply(this, arguments);
|
|
2381
2418
|
}
|
|
2382
2419
|
return cancelCurrentOrderAsync;
|
|
@@ -2392,7 +2429,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2392
2429
|
key: "saveForLaterPaymentAsync",
|
|
2393
2430
|
value: (function () {
|
|
2394
2431
|
var _saveForLaterPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
2395
|
-
var orderUuid, currentOrderId, allPaymentItems, orderPaymentStatus, syncResult, _this$store$
|
|
2432
|
+
var orderUuid, currentOrderId, allPaymentItems, orderPaymentStatus, syncResult, _this$store$currentOr20, errorMessage;
|
|
2396
2433
|
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
2397
2434
|
while (1) switch (_context23.prev = _context23.next) {
|
|
2398
2435
|
case 0:
|
|
@@ -2451,7 +2488,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2451
2488
|
return _context23.abrupt("return", {
|
|
2452
2489
|
success: false,
|
|
2453
2490
|
message: "\u8BA2\u5355\u4FDD\u5B58\u5931\u8D25: ".concat(errorMessage),
|
|
2454
|
-
orderUuid: (_this$store$
|
|
2491
|
+
orderUuid: (_this$store$currentOr20 = this.store.currentOrder) === null || _this$store$currentOr20 === void 0 ? void 0 : _this$store$currentOr20.uuid
|
|
2455
2492
|
});
|
|
2456
2493
|
case 22:
|
|
2457
2494
|
case "end":
|
|
@@ -2474,7 +2511,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2474
2511
|
key: "updateOrderNoteAsync",
|
|
2475
2512
|
value: (function () {
|
|
2476
2513
|
var _updateOrderNoteAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(note) {
|
|
2477
|
-
var _this$store$
|
|
2514
|
+
var _this$store$currentOr21, _this$store$currentOr22, oldNote, orderInPayment;
|
|
2478
2515
|
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
2479
2516
|
while (1) switch (_context24.prev = _context24.next) {
|
|
2480
2517
|
case 0:
|
|
@@ -2486,7 +2523,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2486
2523
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '没有本地订单数据,无法更新备注');
|
|
2487
2524
|
case 3:
|
|
2488
2525
|
console.log('[Checkout] 更新订单备注:', {
|
|
2489
|
-
orderUuid: (_this$store$
|
|
2526
|
+
orderUuid: (_this$store$currentOr21 = this.store.currentOrder) === null || _this$store$currentOr21 === void 0 ? void 0 : _this$store$currentOr21.uuid,
|
|
2490
2527
|
oldNote: this.store.localOrderData.shop_note,
|
|
2491
2528
|
newNote: note
|
|
2492
2529
|
});
|
|
@@ -2519,7 +2556,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2519
2556
|
case 17:
|
|
2520
2557
|
_context24.next = 19;
|
|
2521
2558
|
return this.core.effects.emit("".concat(this.name, ":onOrderNoteChanged"), {
|
|
2522
|
-
orderUuid: (_this$store$
|
|
2559
|
+
orderUuid: (_this$store$currentOr22 = this.store.currentOrder) === null || _this$store$currentOr22 === void 0 ? void 0 : _this$store$currentOr22.uuid,
|
|
2523
2560
|
oldNote: oldNote,
|
|
2524
2561
|
newNote: note,
|
|
2525
2562
|
timestamp: Date.now()
|
|
@@ -2545,7 +2582,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2545
2582
|
}
|
|
2546
2583
|
}, _callee24, this, [[0, 22], [7, 14]]);
|
|
2547
2584
|
}));
|
|
2548
|
-
function updateOrderNoteAsync(
|
|
2585
|
+
function updateOrderNoteAsync(_x22) {
|
|
2549
2586
|
return _updateOrderNoteAsync.apply(this, arguments);
|
|
2550
2587
|
}
|
|
2551
2588
|
return updateOrderNoteAsync;
|
|
@@ -2578,7 +2615,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2578
2615
|
}
|
|
2579
2616
|
}, _callee25, this);
|
|
2580
2617
|
}));
|
|
2581
|
-
function handleError(
|
|
2618
|
+
function handleError(_x23, _x24) {
|
|
2582
2619
|
return _handleError.apply(this, arguments);
|
|
2583
2620
|
}
|
|
2584
2621
|
return handleError;
|
|
@@ -2591,7 +2628,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2591
2628
|
key: "handlePaymentSuccess",
|
|
2592
2629
|
value: (function () {
|
|
2593
2630
|
var _handlePaymentSuccess = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(data) {
|
|
2594
|
-
var _this$store$
|
|
2631
|
+
var _this$store$currentOr23;
|
|
2595
2632
|
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
2596
2633
|
while (1) switch (_context26.prev = _context26.next) {
|
|
2597
2634
|
case 0:
|
|
@@ -2602,7 +2639,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2602
2639
|
return this.core.effects.emit("".concat(this.name, ":onPaymentSuccess"), {
|
|
2603
2640
|
orderUuid: data.orderUuid,
|
|
2604
2641
|
paymentMethodCode: '',
|
|
2605
|
-
amount: ((_this$store$
|
|
2642
|
+
amount: ((_this$store$currentOr23 = this.store.currentOrder) === null || _this$store$currentOr23 === void 0 ? void 0 : _this$store$currentOr23.total_amount) || '0',
|
|
2606
2643
|
timestamp: data.timestamp
|
|
2607
2644
|
});
|
|
2608
2645
|
case 4:
|
|
@@ -2614,7 +2651,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2614
2651
|
}
|
|
2615
2652
|
}, _callee26, this);
|
|
2616
2653
|
}));
|
|
2617
|
-
function handlePaymentSuccess(
|
|
2654
|
+
function handlePaymentSuccess(_x25) {
|
|
2618
2655
|
return _handlePaymentSuccess.apply(this, arguments);
|
|
2619
2656
|
}
|
|
2620
2657
|
return handlePaymentSuccess;
|
|
@@ -2627,7 +2664,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2627
2664
|
key: "handlePaymentError",
|
|
2628
2665
|
value: (function () {
|
|
2629
2666
|
var _handlePaymentError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(data) {
|
|
2630
|
-
var _this$store$
|
|
2667
|
+
var _this$store$currentOr24;
|
|
2631
2668
|
var error;
|
|
2632
2669
|
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
2633
2670
|
while (1) switch (_context27.prev = _context27.next) {
|
|
@@ -2640,7 +2677,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2640
2677
|
return this.core.effects.emit("".concat(this.name, ":onPaymentFailed"), {
|
|
2641
2678
|
orderUuid: data.orderUuid,
|
|
2642
2679
|
paymentMethodCode: '',
|
|
2643
|
-
amount: ((_this$store$
|
|
2680
|
+
amount: ((_this$store$currentOr24 = this.store.currentOrder) === null || _this$store$currentOr24 === void 0 ? void 0 : _this$store$currentOr24.total_amount) || '0',
|
|
2644
2681
|
timestamp: data.timestamp
|
|
2645
2682
|
});
|
|
2646
2683
|
case 5:
|
|
@@ -2649,7 +2686,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2649
2686
|
}
|
|
2650
2687
|
}, _callee27, this);
|
|
2651
2688
|
}));
|
|
2652
|
-
function handlePaymentError(
|
|
2689
|
+
function handlePaymentError(_x26) {
|
|
2653
2690
|
return _handlePaymentError.apply(this, arguments);
|
|
2654
2691
|
}
|
|
2655
2692
|
return handlePaymentError;
|
|
@@ -2750,7 +2787,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2750
2787
|
}
|
|
2751
2788
|
}, _callee28, this, [[3, 23]]);
|
|
2752
2789
|
}));
|
|
2753
|
-
function processCashPaymentItem(
|
|
2790
|
+
function processCashPaymentItem(_x27) {
|
|
2754
2791
|
return _processCashPaymentItem.apply(this, arguments);
|
|
2755
2792
|
}
|
|
2756
2793
|
return processCashPaymentItem;
|
|
@@ -3616,7 +3653,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3616
3653
|
}
|
|
3617
3654
|
}, _callee37, this, [[0, 23]]);
|
|
3618
3655
|
}));
|
|
3619
|
-
function checkOrderPaymentCompletionOptimized(
|
|
3656
|
+
function checkOrderPaymentCompletionOptimized(_x28, _x29) {
|
|
3620
3657
|
return _checkOrderPaymentCompletionOptimized.apply(this, arguments);
|
|
3621
3658
|
}
|
|
3622
3659
|
return checkOrderPaymentCompletionOptimized;
|
|
@@ -3749,6 +3786,338 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3749
3786
|
return _checkOrderPaymentCompletion.apply(this, arguments);
|
|
3750
3787
|
}
|
|
3751
3788
|
return checkOrderPaymentCompletion;
|
|
3789
|
+
}())
|
|
3790
|
+
}, {
|
|
3791
|
+
key: "repairEftposPaymentFromIndexDbAsync",
|
|
3792
|
+
value: function () {
|
|
3793
|
+
var _repairEftposPaymentFromIndexDbAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
|
|
3794
|
+
var orderUuid, paymentItem, order, orderPaymentType, processedPaymentItem, metadata, paymentItemWithType;
|
|
3795
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
3796
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
3797
|
+
case 0:
|
|
3798
|
+
orderUuid = params.orderUuid, paymentItem = params.paymentItem;
|
|
3799
|
+
_context39.next = 3;
|
|
3800
|
+
return this.payment.getPaymentOrderByUuidAsync(orderUuid);
|
|
3801
|
+
case 3:
|
|
3802
|
+
order = _context39.sent;
|
|
3803
|
+
if (order) {
|
|
3804
|
+
_context39.next = 7;
|
|
3805
|
+
break;
|
|
3806
|
+
}
|
|
3807
|
+
this.logError('EFTPOS repair failed: order not found in IndexDB', {
|
|
3808
|
+
orderUuid: orderUuid,
|
|
3809
|
+
paymentItem: paymentItem
|
|
3810
|
+
});
|
|
3811
|
+
return _context39.abrupt("return");
|
|
3812
|
+
case 7:
|
|
3813
|
+
orderPaymentType = order.is_deposit === 1 ? 'deposit' : 'normal';
|
|
3814
|
+
_context39.next = 10;
|
|
3815
|
+
return this.processCashPaymentItem(paymentItem);
|
|
3816
|
+
case 10:
|
|
3817
|
+
processedPaymentItem = _context39.sent;
|
|
3818
|
+
metadata = _objectSpread(_objectSpread({}, processedPaymentItem.metadata), {}, {
|
|
3819
|
+
rounding_rule: this.otherParams.order_rounding_setting,
|
|
3820
|
+
shop_wallet_pass_id: this.otherParams.shop_wallet_pass_id
|
|
3821
|
+
});
|
|
3822
|
+
paymentItemWithType = _objectSpread(_objectSpread({}, processedPaymentItem), {}, {
|
|
3823
|
+
order_payment_type: orderPaymentType,
|
|
3824
|
+
metadata: metadata
|
|
3825
|
+
});
|
|
3826
|
+
_context39.next = 15;
|
|
3827
|
+
return this.payment.addPaymentItemAsync(orderUuid, paymentItemWithType);
|
|
3828
|
+
case 15:
|
|
3829
|
+
_context39.next = 17;
|
|
3830
|
+
return this.syncOrderToBackendFromIndexDbAsync({
|
|
3831
|
+
orderUuid: orderUuid
|
|
3832
|
+
});
|
|
3833
|
+
case 17:
|
|
3834
|
+
case "end":
|
|
3835
|
+
return _context39.stop();
|
|
3836
|
+
}
|
|
3837
|
+
}, _callee39, this);
|
|
3838
|
+
}));
|
|
3839
|
+
function repairEftposPaymentFromIndexDbAsync(_x30) {
|
|
3840
|
+
return _repairEftposPaymentFromIndexDbAsync.apply(this, arguments);
|
|
3841
|
+
}
|
|
3842
|
+
return repairEftposPaymentFromIndexDbAsync;
|
|
3843
|
+
}()
|
|
3844
|
+
}, {
|
|
3845
|
+
key: "syncOrderToBackendFromIndexDbAsync",
|
|
3846
|
+
value: function () {
|
|
3847
|
+
var _syncOrderToBackendFromIndexDbAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
|
|
3848
|
+
var _paymentOrder$order_i,
|
|
3849
|
+
_paymentOrder$order_i2,
|
|
3850
|
+
_this6 = this,
|
|
3851
|
+
_this$otherParams,
|
|
3852
|
+
_localOrderData$booki,
|
|
3853
|
+
_localOrderData$relat,
|
|
3854
|
+
_checkoutResponse2,
|
|
3855
|
+
_checkoutResponse3,
|
|
3856
|
+
_checkoutResponse7;
|
|
3857
|
+
var orderUuid, paymentOrder, localOrderData, paymentItems, processedPaymentItems, finalDepositAmount, manualDepositAmount, manualDepositValue, orderPaymentStatus, totalPaidAmount, orderParams, currentOrderId, isUpdateOperation, checkoutResponse, _checkoutResponse, responseStatus, isSuccessResponse, _checkoutResponse4, errorMessage, realOrderId, _checkoutResponse5, extractedOrderId, _checkoutResponse6, syncedPaymentUuids, _iterator3, _step3, paymentUuid, latestPaymentStatus;
|
|
3858
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
3859
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
3860
|
+
case 0:
|
|
3861
|
+
orderUuid = params.orderUuid;
|
|
3862
|
+
_context40.next = 3;
|
|
3863
|
+
return this.payment.getPaymentOrderByUuidAsync(orderUuid);
|
|
3864
|
+
case 3:
|
|
3865
|
+
paymentOrder = _context40.sent;
|
|
3866
|
+
if (paymentOrder) {
|
|
3867
|
+
_context40.next = 7;
|
|
3868
|
+
break;
|
|
3869
|
+
}
|
|
3870
|
+
this.logError('EFTPOS repair sync failed: missing payment order', {
|
|
3871
|
+
orderUuid: orderUuid
|
|
3872
|
+
});
|
|
3873
|
+
return _context40.abrupt("return", {
|
|
3874
|
+
success: false
|
|
3875
|
+
});
|
|
3876
|
+
case 7:
|
|
3877
|
+
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);
|
|
3878
|
+
if (localOrderData) {
|
|
3879
|
+
_context40.next = 11;
|
|
3880
|
+
break;
|
|
3881
|
+
}
|
|
3882
|
+
this.logError('EFTPOS repair sync failed: missing local order data', {
|
|
3883
|
+
orderUuid: orderUuid,
|
|
3884
|
+
orderInfoKeys: Object.keys(paymentOrder.order_info || {})
|
|
3885
|
+
});
|
|
3886
|
+
return _context40.abrupt("return", {
|
|
3887
|
+
success: false
|
|
3888
|
+
});
|
|
3889
|
+
case 11:
|
|
3890
|
+
_context40.next = 13;
|
|
3891
|
+
return this.payment.getPaymentItemsAsync(orderUuid);
|
|
3892
|
+
case 13:
|
|
3893
|
+
paymentItems = _context40.sent;
|
|
3894
|
+
processedPaymentItems = paymentItems.map(function (item) {
|
|
3895
|
+
var _item$metadata, _item$metadata2;
|
|
3896
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
3897
|
+
metadata: _objectSpread(_objectSpread({}, item.metadata), {}, {
|
|
3898
|
+
rounding_rule: ((_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.rounding_rule) || _this6.otherParams.order_rounding_setting,
|
|
3899
|
+
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
|
|
3900
|
+
})
|
|
3901
|
+
});
|
|
3902
|
+
});
|
|
3903
|
+
manualDepositAmount = paymentOrder.deposit_amount || '0.00';
|
|
3904
|
+
manualDepositValue = new Decimal(manualDepositAmount);
|
|
3905
|
+
if (manualDepositValue.gt(0)) {
|
|
3906
|
+
finalDepositAmount = manualDepositAmount;
|
|
3907
|
+
} else {
|
|
3908
|
+
finalDepositAmount = '0.00';
|
|
3909
|
+
}
|
|
3910
|
+
if (paymentOrder.is_deposit === 0 && processedPaymentItems.every(function (item) {
|
|
3911
|
+
return item.order_payment_type !== 'deposit';
|
|
3912
|
+
})) {
|
|
3913
|
+
finalDepositAmount = '0.00';
|
|
3914
|
+
}
|
|
3915
|
+
if (paymentOrder.is_deposit === 0 && processedPaymentItems.some(function (item) {
|
|
3916
|
+
return item.order_payment_type === 'deposit';
|
|
3917
|
+
})) {
|
|
3918
|
+
finalDepositAmount = processedPaymentItems.filter(function (item) {
|
|
3919
|
+
return item.status !== 'voided' && item.order_payment_type === 'deposit';
|
|
3920
|
+
}).reduce(function (sum, item) {
|
|
3921
|
+
var amountValue = new Decimal(item.amount || '0');
|
|
3922
|
+
var roundingValue = new Decimal(item.rounding_amount || '0');
|
|
3923
|
+
return sum.plus(amountValue).sub(roundingValue);
|
|
3924
|
+
}, new Decimal(0)).toFixed(2);
|
|
3925
|
+
}
|
|
3926
|
+
if (paymentOrder.is_deposit === 1 && new Decimal(finalDepositAmount).gte(new Decimal(paymentOrder.total_amount))) {
|
|
3927
|
+
finalDepositAmount = processedPaymentItems.filter(function (item) {
|
|
3928
|
+
return item.status !== 'voided' && item.order_payment_type === 'deposit';
|
|
3929
|
+
}).reduce(function (sum, item) {
|
|
3930
|
+
var amountValue = new Decimal(item.amount || '0');
|
|
3931
|
+
var roundingValue = new Decimal(item.rounding_amount || '0');
|
|
3932
|
+
return sum.plus(amountValue).sub(roundingValue);
|
|
3933
|
+
}, new Decimal(0)).toFixed(2);
|
|
3934
|
+
}
|
|
3935
|
+
totalPaidAmount = processedPaymentItems.filter(function (item) {
|
|
3936
|
+
return item.status !== 'voided';
|
|
3937
|
+
}).reduce(function (sum, item) {
|
|
3938
|
+
var amountValue = new Decimal(item.amount || '0');
|
|
3939
|
+
var roundingValue = new Decimal(item.rounding_amount || '0');
|
|
3940
|
+
return sum.plus(amountValue).sub(roundingValue);
|
|
3941
|
+
}, new Decimal(0));
|
|
3942
|
+
if (totalPaidAmount.gte(new Decimal(paymentOrder.total_amount))) {
|
|
3943
|
+
orderPaymentStatus = 'paid';
|
|
3944
|
+
} else if (totalPaidAmount.gt(0)) {
|
|
3945
|
+
orderPaymentStatus = 'partially_paid';
|
|
3946
|
+
} else {
|
|
3947
|
+
orderPaymentStatus = 'unpaid';
|
|
3948
|
+
}
|
|
3949
|
+
orderParams = _objectSpread(_objectSpread({}, localOrderData), {}, {
|
|
3950
|
+
payment_status: orderPaymentStatus,
|
|
3951
|
+
type: localOrderData.type,
|
|
3952
|
+
platform: localOrderData.platform,
|
|
3953
|
+
payments: processedPaymentItems,
|
|
3954
|
+
customer_id: localOrderData.customer_id,
|
|
3955
|
+
is_price_include_tax: this.otherParams.is_price_include_tax,
|
|
3956
|
+
tax_title: this.otherParams.tax_title,
|
|
3957
|
+
tax_rate: this.otherParams.tax_rate,
|
|
3958
|
+
tax_country_code: this.otherParams.tax_country_code,
|
|
3959
|
+
currency_code: this.otherParams.currency_code,
|
|
3960
|
+
currency_symbol: this.otherParams.currency_symbol,
|
|
3961
|
+
currency_format: this.otherParams.currency_format,
|
|
3962
|
+
business_code: ((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.business_code) || undefined,
|
|
3963
|
+
is_deposit: (paymentOrder.is_deposit || Number(finalDepositAmount) > 0 ? 1 : 0) || 0,
|
|
3964
|
+
deposit_amount: finalDepositAmount,
|
|
3965
|
+
product_tax_fee: localOrderData.tax_fee,
|
|
3966
|
+
note: localOrderData.shop_note,
|
|
3967
|
+
bookings: (_localOrderData$booki = localOrderData.bookings) === null || _localOrderData$booki === void 0 ? void 0 : _localOrderData$booki.map(function (item) {
|
|
3968
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
3969
|
+
product: _objectSpread(_objectSpread({}, item.product), {}, {
|
|
3970
|
+
custom_deposit_data: undefined
|
|
3971
|
+
}),
|
|
3972
|
+
deposit: undefined
|
|
3973
|
+
});
|
|
3974
|
+
}),
|
|
3975
|
+
relation_products: (_localOrderData$relat = localOrderData.relation_products) === null || _localOrderData$relat === void 0 ? void 0 : _localOrderData$relat.map(function (item) {
|
|
3976
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
3977
|
+
custom_deposit_data: undefined,
|
|
3978
|
+
deposit: undefined
|
|
3979
|
+
});
|
|
3980
|
+
})
|
|
3981
|
+
});
|
|
3982
|
+
currentOrderId = paymentOrder.order_id;
|
|
3983
|
+
isUpdateOperation = currentOrderId && !isVirtualOrderId(currentOrderId);
|
|
3984
|
+
if (isUpdateOperation) {
|
|
3985
|
+
orderParams.order_id = currentOrderId;
|
|
3986
|
+
}
|
|
3987
|
+
this.logError('EFTPOS repair sync start', {
|
|
3988
|
+
orderUuid: orderUuid,
|
|
3989
|
+
orderId: currentOrderId,
|
|
3990
|
+
isUpdateOperation: isUpdateOperation,
|
|
3991
|
+
paymentItemCount: processedPaymentItems.length
|
|
3992
|
+
});
|
|
3993
|
+
_context40.prev = 28;
|
|
3994
|
+
this.logError('EFTPOS repair calling backend checkout API', _objectSpread({
|
|
3995
|
+
url: '/order/checkout',
|
|
3996
|
+
isManual: true
|
|
3997
|
+
}, orderParams));
|
|
3998
|
+
_context40.next = 32;
|
|
3999
|
+
return this.order.createOrderByCheckout(orderParams);
|
|
4000
|
+
case 32:
|
|
4001
|
+
checkoutResponse = _context40.sent;
|
|
4002
|
+
_context40.next = 39;
|
|
4003
|
+
break;
|
|
4004
|
+
case 35:
|
|
4005
|
+
_context40.prev = 35;
|
|
4006
|
+
_context40.t0 = _context40["catch"](28);
|
|
4007
|
+
this.logError('EFTPOS repair checkout API failed', {
|
|
4008
|
+
orderUuid: orderUuid,
|
|
4009
|
+
error: _context40.t0 instanceof Error ? _context40.t0.message : String(_context40.t0)
|
|
4010
|
+
});
|
|
4011
|
+
throw _context40.t0;
|
|
4012
|
+
case 39:
|
|
4013
|
+
_context40.prev = 39;
|
|
4014
|
+
this.logError('EFTPOS repair sync end', {
|
|
4015
|
+
orderUuid: orderUuid,
|
|
4016
|
+
orderId: currentOrderId,
|
|
4017
|
+
responseStatus: (_checkoutResponse = checkoutResponse) === null || _checkoutResponse === void 0 ? void 0 : _checkoutResponse.status
|
|
4018
|
+
});
|
|
4019
|
+
return _context40.finish(39);
|
|
4020
|
+
case 42:
|
|
4021
|
+
responseStatus = (_checkoutResponse2 = checkoutResponse) === null || _checkoutResponse2 === void 0 ? void 0 : _checkoutResponse2.status;
|
|
4022
|
+
isSuccessResponse = responseStatus === true || responseStatus === 200 || responseStatus === 'success' || responseStatus === 1 && ((_checkoutResponse3 = checkoutResponse) === null || _checkoutResponse3 === void 0 ? void 0 : _checkoutResponse3.code) === 200;
|
|
4023
|
+
if (isSuccessResponse) {
|
|
4024
|
+
_context40.next = 48;
|
|
4025
|
+
break;
|
|
4026
|
+
}
|
|
4027
|
+
errorMessage = ((_checkoutResponse4 = checkoutResponse) === null || _checkoutResponse4 === void 0 ? void 0 : _checkoutResponse4.message) || '订单同步失败,后端返回非成功状态';
|
|
4028
|
+
this.logError('EFTPOS repair sync failed: api error', {
|
|
4029
|
+
orderUuid: orderUuid,
|
|
4030
|
+
errorMessage: errorMessage,
|
|
4031
|
+
response: checkoutResponse
|
|
4032
|
+
});
|
|
4033
|
+
return _context40.abrupt("return", {
|
|
4034
|
+
success: false,
|
|
4035
|
+
response: checkoutResponse
|
|
4036
|
+
});
|
|
4037
|
+
case 48:
|
|
4038
|
+
realOrderId = currentOrderId;
|
|
4039
|
+
if (isUpdateOperation) {
|
|
4040
|
+
_context40.next = 60;
|
|
4041
|
+
break;
|
|
4042
|
+
}
|
|
4043
|
+
extractedOrderId = (_checkoutResponse5 = checkoutResponse) === null || _checkoutResponse5 === void 0 || (_checkoutResponse5 = _checkoutResponse5.data) === null || _checkoutResponse5 === void 0 ? void 0 : _checkoutResponse5.order_id;
|
|
4044
|
+
if (!extractedOrderId) {
|
|
4045
|
+
extractedOrderId = (_checkoutResponse6 = checkoutResponse) === null || _checkoutResponse6 === void 0 ? void 0 : _checkoutResponse6.order_id;
|
|
4046
|
+
}
|
|
4047
|
+
if (extractedOrderId !== undefined && extractedOrderId !== null) {
|
|
4048
|
+
extractedOrderId = String(extractedOrderId);
|
|
4049
|
+
}
|
|
4050
|
+
realOrderId = extractedOrderId;
|
|
4051
|
+
if (!realOrderId) {
|
|
4052
|
+
_context40.next = 59;
|
|
4053
|
+
break;
|
|
4054
|
+
}
|
|
4055
|
+
_context40.next = 57;
|
|
4056
|
+
return this.payment.replaceOrderIdByUuidAsync(orderUuid, realOrderId);
|
|
4057
|
+
case 57:
|
|
4058
|
+
_context40.next = 60;
|
|
4059
|
+
break;
|
|
4060
|
+
case 59:
|
|
4061
|
+
this.logError('EFTPOS repair missing order_id in response', {
|
|
4062
|
+
orderUuid: orderUuid,
|
|
4063
|
+
response: checkoutResponse
|
|
4064
|
+
});
|
|
4065
|
+
case 60:
|
|
4066
|
+
syncedPaymentUuids = processedPaymentItems.filter(function (item) {
|
|
4067
|
+
return item.status !== 'voided';
|
|
4068
|
+
}).map(function (item) {
|
|
4069
|
+
return item.uuid;
|
|
4070
|
+
}).filter(Boolean);
|
|
4071
|
+
_iterator3 = _createForOfIteratorHelper(syncedPaymentUuids);
|
|
4072
|
+
_context40.prev = 62;
|
|
4073
|
+
_iterator3.s();
|
|
4074
|
+
case 64:
|
|
4075
|
+
if ((_step3 = _iterator3.n()).done) {
|
|
4076
|
+
_context40.next = 70;
|
|
4077
|
+
break;
|
|
4078
|
+
}
|
|
4079
|
+
paymentUuid = _step3.value;
|
|
4080
|
+
_context40.next = 68;
|
|
4081
|
+
return this.payment.updatePaymentAsync(orderUuid, paymentUuid, {
|
|
4082
|
+
isSynced: true,
|
|
4083
|
+
syncError: undefined
|
|
4084
|
+
});
|
|
4085
|
+
case 68:
|
|
4086
|
+
_context40.next = 64;
|
|
4087
|
+
break;
|
|
4088
|
+
case 70:
|
|
4089
|
+
_context40.next = 75;
|
|
4090
|
+
break;
|
|
4091
|
+
case 72:
|
|
4092
|
+
_context40.prev = 72;
|
|
4093
|
+
_context40.t1 = _context40["catch"](62);
|
|
4094
|
+
_iterator3.e(_context40.t1);
|
|
4095
|
+
case 75:
|
|
4096
|
+
_context40.prev = 75;
|
|
4097
|
+
_iterator3.f();
|
|
4098
|
+
return _context40.finish(75);
|
|
4099
|
+
case 78:
|
|
4100
|
+
latestPaymentStatus = ((_checkoutResponse7 = checkoutResponse) === null || _checkoutResponse7 === void 0 || (_checkoutResponse7 = _checkoutResponse7.data) === null || _checkoutResponse7 === void 0 ? void 0 : _checkoutResponse7.payment_status) || orderPaymentStatus;
|
|
4101
|
+
_context40.next = 81;
|
|
4102
|
+
return this.payment.updateOrderAsync(orderUuid, {
|
|
4103
|
+
payment_status: latestPaymentStatus
|
|
4104
|
+
});
|
|
4105
|
+
case 81:
|
|
4106
|
+
return _context40.abrupt("return", {
|
|
4107
|
+
success: true,
|
|
4108
|
+
orderId: realOrderId,
|
|
4109
|
+
response: checkoutResponse
|
|
4110
|
+
});
|
|
4111
|
+
case 82:
|
|
4112
|
+
case "end":
|
|
4113
|
+
return _context40.stop();
|
|
4114
|
+
}
|
|
4115
|
+
}, _callee40, this, [[28, 35, 39, 42], [62, 72, 75, 78]]);
|
|
4116
|
+
}));
|
|
4117
|
+
function syncOrderToBackendFromIndexDbAsync(_x31) {
|
|
4118
|
+
return _syncOrderToBackendFromIndexDbAsync.apply(this, arguments);
|
|
4119
|
+
}
|
|
4120
|
+
return syncOrderToBackendFromIndexDbAsync;
|
|
3752
4121
|
}()
|
|
3753
4122
|
/**
|
|
3754
4123
|
* 同步订单到后端并返回真实订单ID
|
|
@@ -3757,20 +4126,19 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3757
4126
|
* @param customPaymentItems 自定义支付项列表,如果提供则使用此列表而不是从数据库获取
|
|
3758
4127
|
* @returns 包含订单ID、UUID和完整后端响应的对象
|
|
3759
4128
|
*/
|
|
3760
|
-
)
|
|
3761
4129
|
}, {
|
|
3762
4130
|
key: "syncOrderToBackendWithReturn",
|
|
3763
4131
|
value: (function () {
|
|
3764
|
-
var _syncOrderToBackendWithReturn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3765
|
-
var
|
|
3766
|
-
_this$store$currentOr24,
|
|
4132
|
+
var _syncOrderToBackendWithReturn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41() {
|
|
4133
|
+
var _this7 = this,
|
|
3767
4134
|
_this$store$currentOr25,
|
|
3768
|
-
_this$store$currentCu2,
|
|
3769
4135
|
_this$store$currentOr26,
|
|
4136
|
+
_this$store$currentCu2,
|
|
4137
|
+
_this$store$currentOr27,
|
|
3770
4138
|
_this$store$localOrde,
|
|
3771
4139
|
_this$store$localOrde2,
|
|
3772
|
-
|
|
3773
|
-
|
|
4140
|
+
_checkoutResponse10,
|
|
4141
|
+
_checkoutResponse11;
|
|
3774
4142
|
var isManual,
|
|
3775
4143
|
customPaymentItems,
|
|
3776
4144
|
paymentStatus,
|
|
@@ -3788,33 +4156,33 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3788
4156
|
checkoutResponse,
|
|
3789
4157
|
submitSuccess,
|
|
3790
4158
|
submitError,
|
|
3791
|
-
|
|
3792
|
-
|
|
4159
|
+
_checkoutResponse8,
|
|
4160
|
+
_checkoutResponse9,
|
|
3793
4161
|
responseStatus,
|
|
3794
4162
|
isSuccessResponse,
|
|
3795
|
-
|
|
4163
|
+
_checkoutResponse12,
|
|
3796
4164
|
errorMessage,
|
|
3797
4165
|
realOrderId,
|
|
3798
|
-
|
|
4166
|
+
_checkoutResponse13,
|
|
3799
4167
|
extractedOrderId,
|
|
3800
|
-
|
|
4168
|
+
_checkoutResponse14,
|
|
3801
4169
|
latestPaymentStatus,
|
|
3802
4170
|
previousOrder,
|
|
3803
4171
|
updatedOrder,
|
|
3804
4172
|
beforeManualUpdate,
|
|
3805
4173
|
syncedPaymentUuids,
|
|
3806
|
-
|
|
3807
|
-
|
|
4174
|
+
_iterator4,
|
|
4175
|
+
_step4,
|
|
3808
4176
|
paymentUuid,
|
|
3809
|
-
|
|
3810
|
-
return _regeneratorRuntime().wrap(function
|
|
3811
|
-
while (1) switch (
|
|
4177
|
+
_args41 = arguments;
|
|
4178
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context41) {
|
|
4179
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
3812
4180
|
case 0:
|
|
3813
|
-
isManual =
|
|
3814
|
-
customPaymentItems =
|
|
3815
|
-
paymentStatus =
|
|
4181
|
+
isManual = _args41.length > 0 && _args41[0] !== undefined ? _args41[0] : false;
|
|
4182
|
+
customPaymentItems = _args41.length > 1 ? _args41[1] : undefined;
|
|
4183
|
+
paymentStatus = _args41.length > 2 ? _args41[2] : undefined;
|
|
3816
4184
|
if (!(!this.store.localOrderData || !this.store.currentOrder)) {
|
|
3817
|
-
|
|
4185
|
+
_context41.next = 5;
|
|
3818
4186
|
break;
|
|
3819
4187
|
}
|
|
3820
4188
|
throw new Error('缺少必要的订单数据,无法同步到后端');
|
|
@@ -3833,28 +4201,28 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3833
4201
|
});
|
|
3834
4202
|
|
|
3835
4203
|
// 获取当前订单的支付项
|
|
3836
|
-
|
|
3837
|
-
if (
|
|
3838
|
-
|
|
4204
|
+
_context41.t0 = customPaymentItems;
|
|
4205
|
+
if (_context41.t0) {
|
|
4206
|
+
_context41.next = 14;
|
|
3839
4207
|
break;
|
|
3840
4208
|
}
|
|
3841
|
-
|
|
4209
|
+
_context41.next = 13;
|
|
3842
4210
|
return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid);
|
|
3843
4211
|
case 13:
|
|
3844
|
-
|
|
4212
|
+
_context41.t0 = _context41.sent;
|
|
3845
4213
|
case 14:
|
|
3846
|
-
paymentItems =
|
|
4214
|
+
paymentItems = _context41.t0;
|
|
3847
4215
|
// 处理支付项数据,确保包含完整的 metadata
|
|
3848
4216
|
processedPaymentItems = paymentItems.map(function (item) {
|
|
3849
|
-
var _item$
|
|
4217
|
+
var _item$metadata3, _item$metadata4;
|
|
3850
4218
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
3851
4219
|
metadata: _objectSpread(_objectSpread({}, item.metadata), {}, {
|
|
3852
|
-
rounding_rule: ((_item$
|
|
3853
|
-
shop_wallet_pass_id: ((_item$
|
|
4220
|
+
rounding_rule: ((_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.rounding_rule) || _this7.otherParams.order_rounding_setting,
|
|
4221
|
+
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
|
|
3854
4222
|
})
|
|
3855
4223
|
});
|
|
3856
4224
|
}); // 确定最终的定金金额:优先使用手动设置的值,否则从支付项中计算
|
|
3857
|
-
manualDepositAmount = ((_this$store$
|
|
4225
|
+
manualDepositAmount = ((_this$store$currentOr25 = this.store.currentOrder) === null || _this$store$currentOr25 === void 0 ? void 0 : _this$store$currentOr25.deposit_amount) || '0.00'; // 优先级逻辑:手动设置的定金金额 > 从支付项计算的金额
|
|
3858
4226
|
manualDepositValue = new Decimal(manualDepositAmount);
|
|
3859
4227
|
if (manualDepositValue.gt(0)) {
|
|
3860
4228
|
// 如果手动设置了定金金额且大于0,使用手动设置的值
|
|
@@ -3914,7 +4282,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3914
4282
|
}),
|
|
3915
4283
|
manualDepositAmount: manualDepositAmount,
|
|
3916
4284
|
finalDepositAmount: finalDepositAmount,
|
|
3917
|
-
isDeposit: ((_this$store$
|
|
4285
|
+
isDeposit: ((_this$store$currentOr26 = this.store.currentOrder) === null || _this$store$currentOr26 === void 0 ? void 0 : _this$store$currentOr26.is_deposit) || 0
|
|
3918
4286
|
});
|
|
3919
4287
|
|
|
3920
4288
|
// 计算订单状态,优先读取外面传递的,如果没有则根据订单支付数据来
|
|
@@ -3961,7 +4329,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3961
4329
|
currency_code: this.otherParams.currency_code,
|
|
3962
4330
|
currency_symbol: this.otherParams.currency_symbol,
|
|
3963
4331
|
currency_format: this.otherParams.currency_format,
|
|
3964
|
-
is_deposit: ((_this$store$
|
|
4332
|
+
is_deposit: ((_this$store$currentOr27 = this.store.currentOrder) !== null && _this$store$currentOr27 !== void 0 && _this$store$currentOr27.is_deposit || Number(finalDepositAmount) > 0 ? 1 : 0) || 0,
|
|
3965
4333
|
deposit_amount: finalDepositAmount,
|
|
3966
4334
|
// 使用最终确定的定金金额(手动设置优先)
|
|
3967
4335
|
product_tax_fee: this.store.localOrderData.tax_fee,
|
|
@@ -3992,7 +4360,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3992
4360
|
|
|
3993
4361
|
// 发送下单接口请求开始事件
|
|
3994
4362
|
startTime = Date.now();
|
|
3995
|
-
|
|
4363
|
+
_context41.next = 30;
|
|
3996
4364
|
return this.core.effects.emit("".concat(this.name, ":onOrderSubmitStart"), {
|
|
3997
4365
|
orderUuid: this.store.currentOrder.uuid,
|
|
3998
4366
|
operation: isUpdateOperation ? 'update' : 'create',
|
|
@@ -4002,7 +4370,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4002
4370
|
});
|
|
4003
4371
|
case 30:
|
|
4004
4372
|
submitSuccess = false;
|
|
4005
|
-
|
|
4373
|
+
_context41.prev = 31;
|
|
4006
4374
|
// 记录接口调用参数
|
|
4007
4375
|
this.logInfo('Calling backend checkout API', _objectSpread({
|
|
4008
4376
|
url: '/order/checkout',
|
|
@@ -4010,24 +4378,24 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4010
4378
|
}, orderParams));
|
|
4011
4379
|
|
|
4012
4380
|
// 调用 Order 模块的专用 createOrderByCheckout 方法
|
|
4013
|
-
|
|
4381
|
+
_context41.next = 35;
|
|
4014
4382
|
return this.order.createOrderByCheckout(orderParams);
|
|
4015
4383
|
case 35:
|
|
4016
|
-
checkoutResponse =
|
|
4384
|
+
checkoutResponse = _context41.sent;
|
|
4017
4385
|
submitSuccess = true;
|
|
4018
4386
|
this.store.currentOrder.payment_status = checkoutResponse.data.payment_status;
|
|
4019
4387
|
this.logInfo('下单接口调用成功', checkoutResponse);
|
|
4020
|
-
|
|
4388
|
+
_context41.next = 49;
|
|
4021
4389
|
break;
|
|
4022
4390
|
case 41:
|
|
4023
|
-
|
|
4024
|
-
|
|
4391
|
+
_context41.prev = 41;
|
|
4392
|
+
_context41.t1 = _context41["catch"](31);
|
|
4025
4393
|
submitSuccess = false;
|
|
4026
|
-
submitError =
|
|
4394
|
+
submitError = _context41.t1 instanceof Error ? _context41.t1.message : String(_context41.t1);
|
|
4027
4395
|
this.logError('下单接口调用失败:', submitError);
|
|
4028
4396
|
|
|
4029
4397
|
// 发送订单同步失败事件(网络错误或请求失败)
|
|
4030
|
-
|
|
4398
|
+
_context41.next = 48;
|
|
4031
4399
|
return this.core.effects.emit("".concat(this.name, ":onOrderSyncFailed"), {
|
|
4032
4400
|
orderUuid: this.store.currentOrder.uuid,
|
|
4033
4401
|
operation: isUpdateOperation ? 'update' : 'create',
|
|
@@ -4038,32 +4406,32 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4038
4406
|
timestamp: Date.now()
|
|
4039
4407
|
});
|
|
4040
4408
|
case 48:
|
|
4041
|
-
throw
|
|
4409
|
+
throw _context41.t1;
|
|
4042
4410
|
case 49:
|
|
4043
|
-
|
|
4044
|
-
|
|
4411
|
+
_context41.prev = 49;
|
|
4412
|
+
_context41.next = 52;
|
|
4045
4413
|
return this.core.effects.emit("".concat(this.name, ":onOrderSubmitEnd"), {
|
|
4046
4414
|
success: submitSuccess,
|
|
4047
4415
|
orderUuid: this.store.currentOrder.uuid,
|
|
4048
4416
|
operation: isUpdateOperation ? 'update' : 'create',
|
|
4049
4417
|
isManual: isManual,
|
|
4050
|
-
orderId: submitSuccess ? ((
|
|
4418
|
+
orderId: submitSuccess ? ((_checkoutResponse8 = checkoutResponse) === null || _checkoutResponse8 === void 0 || (_checkoutResponse8 = _checkoutResponse8.data) === null || _checkoutResponse8 === void 0 ? void 0 : _checkoutResponse8.order_id) || ((_checkoutResponse9 = checkoutResponse) === null || _checkoutResponse9 === void 0 ? void 0 : _checkoutResponse9.order_id) : undefined,
|
|
4051
4419
|
error: submitError,
|
|
4052
4420
|
duration: Date.now() - startTime,
|
|
4053
4421
|
timestamp: Date.now()
|
|
4054
4422
|
});
|
|
4055
4423
|
case 52:
|
|
4056
|
-
return
|
|
4424
|
+
return _context41.finish(49);
|
|
4057
4425
|
case 53:
|
|
4058
4426
|
// 检查响应状态是否为成功状态
|
|
4059
|
-
responseStatus = (
|
|
4060
|
-
isSuccessResponse = responseStatus === true || responseStatus === 200 || responseStatus === 'success' || responseStatus === 1 && ((
|
|
4427
|
+
responseStatus = (_checkoutResponse10 = checkoutResponse) === null || _checkoutResponse10 === void 0 ? void 0 : _checkoutResponse10.status;
|
|
4428
|
+
isSuccessResponse = responseStatus === true || responseStatus === 200 || responseStatus === 'success' || responseStatus === 1 && ((_checkoutResponse11 = checkoutResponse) === null || _checkoutResponse11 === void 0 ? void 0 : _checkoutResponse11.code) === 200;
|
|
4061
4429
|
if (isSuccessResponse) {
|
|
4062
|
-
|
|
4430
|
+
_context41.next = 60;
|
|
4063
4431
|
break;
|
|
4064
4432
|
}
|
|
4065
|
-
errorMessage = ((
|
|
4066
|
-
|
|
4433
|
+
errorMessage = ((_checkoutResponse12 = checkoutResponse) === null || _checkoutResponse12 === void 0 ? void 0 : _checkoutResponse12.message) || '订单同步失败,后端返回非成功状态'; // 发送订单同步失败事件
|
|
4434
|
+
_context41.next = 59;
|
|
4067
4435
|
return this.core.effects.emit("".concat(this.name, ":onOrderSyncFailed"), {
|
|
4068
4436
|
orderUuid: this.store.currentOrder.uuid,
|
|
4069
4437
|
operation: isUpdateOperation ? 'update' : 'create',
|
|
@@ -4078,18 +4446,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4078
4446
|
throw new Error(errorMessage);
|
|
4079
4447
|
case 60:
|
|
4080
4448
|
if (!isUpdateOperation) {
|
|
4081
|
-
|
|
4449
|
+
_context41.next = 64;
|
|
4082
4450
|
break;
|
|
4083
4451
|
}
|
|
4084
4452
|
// 更新操作:使用现有的订单ID
|
|
4085
4453
|
realOrderId = currentOrderId;
|
|
4086
|
-
|
|
4454
|
+
_context41.next = 97;
|
|
4087
4455
|
break;
|
|
4088
4456
|
case 64:
|
|
4089
4457
|
// 创建操作:从响应中提取新的订单ID
|
|
4090
|
-
extractedOrderId = (
|
|
4458
|
+
extractedOrderId = (_checkoutResponse13 = checkoutResponse) === null || _checkoutResponse13 === void 0 || (_checkoutResponse13 = _checkoutResponse13.data) === null || _checkoutResponse13 === void 0 ? void 0 : _checkoutResponse13.order_id; // 如果data.order_id不存在,尝试直接从根级获取
|
|
4091
4459
|
if (!extractedOrderId) {
|
|
4092
|
-
extractedOrderId = (
|
|
4460
|
+
extractedOrderId = (_checkoutResponse14 = checkoutResponse) === null || _checkoutResponse14 === void 0 ? void 0 : _checkoutResponse14.order_id;
|
|
4093
4461
|
}
|
|
4094
4462
|
|
|
4095
4463
|
// 确保转换为字符串类型
|
|
@@ -4107,20 +4475,20 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4107
4475
|
oldOrderId: this.store.currentOrder.order_id,
|
|
4108
4476
|
newOrderId: realOrderId
|
|
4109
4477
|
});
|
|
4110
|
-
|
|
4478
|
+
_context41.prev = 70;
|
|
4111
4479
|
latestPaymentStatus = this.store.currentOrder.payment_status;
|
|
4112
4480
|
previousOrder = this.store.currentOrder;
|
|
4113
|
-
|
|
4481
|
+
_context41.next = 75;
|
|
4114
4482
|
return this.payment.replaceOrderIdByUuidAsync(previousOrder.uuid, realOrderId);
|
|
4115
4483
|
case 75:
|
|
4116
|
-
updatedOrder =
|
|
4484
|
+
updatedOrder = _context41.sent;
|
|
4117
4485
|
this.logInfo('Payment模块替换订单ID结果:', {
|
|
4118
4486
|
wasSuccessful: !!updatedOrder,
|
|
4119
4487
|
returnedOrderId: updatedOrder === null || updatedOrder === void 0 ? void 0 : updatedOrder.order_id,
|
|
4120
4488
|
expectedOrderId: realOrderId
|
|
4121
4489
|
});
|
|
4122
4490
|
if (!updatedOrder) {
|
|
4123
|
-
|
|
4491
|
+
_context41.next = 86;
|
|
4124
4492
|
break;
|
|
4125
4493
|
}
|
|
4126
4494
|
this.logInfo('Payment模块返回的更新后订单:', {
|
|
@@ -4136,16 +4504,16 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4136
4504
|
|
|
4137
4505
|
// 同步更新 Payment 模块 DB,避免后续读取 DB 时又拿回旧状态
|
|
4138
4506
|
if (!latestPaymentStatus) {
|
|
4139
|
-
|
|
4507
|
+
_context41.next = 83;
|
|
4140
4508
|
break;
|
|
4141
4509
|
}
|
|
4142
|
-
|
|
4510
|
+
_context41.next = 83;
|
|
4143
4511
|
return this.payment.updateOrderAsync(previousOrder.uuid, {
|
|
4144
4512
|
payment_status: latestPaymentStatus
|
|
4145
4513
|
});
|
|
4146
4514
|
case 83:
|
|
4147
4515
|
this.logInfo('[Checkout] 订单ID替换成功,当前订单ID:', this.store.currentOrder.order_id);
|
|
4148
|
-
|
|
4516
|
+
_context41.next = 90;
|
|
4149
4517
|
break;
|
|
4150
4518
|
case 86:
|
|
4151
4519
|
this.logError('[Checkout] Payment模块返回空订单,订单ID替换失败,开始手动替换');
|
|
@@ -4159,59 +4527,59 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4159
4527
|
目标ID: realOrderId
|
|
4160
4528
|
});
|
|
4161
4529
|
case 90:
|
|
4162
|
-
|
|
4530
|
+
_context41.next = 97;
|
|
4163
4531
|
break;
|
|
4164
4532
|
case 92:
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
this.logError('调用Payment模块替换订单ID时发生错误:',
|
|
4533
|
+
_context41.prev = 92;
|
|
4534
|
+
_context41.t2 = _context41["catch"](70);
|
|
4535
|
+
this.logError('调用Payment模块替换订单ID时发生错误:', _context41.t2);
|
|
4168
4536
|
|
|
4169
4537
|
// 发生错误时也进行手动替换
|
|
4170
4538
|
this.store.currentOrder.order_id = realOrderId;
|
|
4171
4539
|
this.logInfo('错误恢复:手动设置订单ID:', realOrderId);
|
|
4172
4540
|
case 97:
|
|
4173
|
-
|
|
4541
|
+
_context41.prev = 97;
|
|
4174
4542
|
syncedPaymentUuids = processedPaymentItems.filter(function (item) {
|
|
4175
4543
|
return item.status !== 'voided';
|
|
4176
4544
|
}).map(function (item) {
|
|
4177
4545
|
return item.uuid;
|
|
4178
4546
|
}).filter(Boolean);
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4547
|
+
_iterator4 = _createForOfIteratorHelper(syncedPaymentUuids);
|
|
4548
|
+
_context41.prev = 100;
|
|
4549
|
+
_iterator4.s();
|
|
4182
4550
|
case 102:
|
|
4183
|
-
if ((
|
|
4184
|
-
|
|
4551
|
+
if ((_step4 = _iterator4.n()).done) {
|
|
4552
|
+
_context41.next = 108;
|
|
4185
4553
|
break;
|
|
4186
4554
|
}
|
|
4187
|
-
paymentUuid =
|
|
4188
|
-
|
|
4555
|
+
paymentUuid = _step4.value;
|
|
4556
|
+
_context41.next = 106;
|
|
4189
4557
|
return this.payment.updatePaymentAsync(this.store.currentOrder.uuid, paymentUuid, {
|
|
4190
4558
|
isSynced: true,
|
|
4191
4559
|
syncError: undefined
|
|
4192
4560
|
});
|
|
4193
4561
|
case 106:
|
|
4194
|
-
|
|
4562
|
+
_context41.next = 102;
|
|
4195
4563
|
break;
|
|
4196
4564
|
case 108:
|
|
4197
|
-
|
|
4565
|
+
_context41.next = 113;
|
|
4198
4566
|
break;
|
|
4199
4567
|
case 110:
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4568
|
+
_context41.prev = 110;
|
|
4569
|
+
_context41.t3 = _context41["catch"](100);
|
|
4570
|
+
_iterator4.e(_context41.t3);
|
|
4203
4571
|
case 113:
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
return
|
|
4572
|
+
_context41.prev = 113;
|
|
4573
|
+
_iterator4.f();
|
|
4574
|
+
return _context41.finish(113);
|
|
4207
4575
|
case 116:
|
|
4208
|
-
|
|
4576
|
+
_context41.next = 121;
|
|
4209
4577
|
break;
|
|
4210
4578
|
case 118:
|
|
4211
|
-
|
|
4212
|
-
|
|
4579
|
+
_context41.prev = 118;
|
|
4580
|
+
_context41.t4 = _context41["catch"](97);
|
|
4213
4581
|
this.logWarning('标记支付项已同步失败(不阻塞主流程)', {
|
|
4214
|
-
error:
|
|
4582
|
+
error: _context41.t4
|
|
4215
4583
|
});
|
|
4216
4584
|
case 121:
|
|
4217
4585
|
// 标记订单已同步
|
|
@@ -4221,7 +4589,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4221
4589
|
this.clearCalculationCache();
|
|
4222
4590
|
|
|
4223
4591
|
// 触发订单同步完成事件
|
|
4224
|
-
|
|
4592
|
+
_context41.next = 125;
|
|
4225
4593
|
return this.core.effects.emit("".concat(this.name, ":onOrderSynced"), {
|
|
4226
4594
|
orderUuid: this.store.currentOrder.uuid,
|
|
4227
4595
|
realOrderId: realOrderId,
|
|
@@ -4231,7 +4599,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4231
4599
|
response: checkoutResponse
|
|
4232
4600
|
});
|
|
4233
4601
|
case 125:
|
|
4234
|
-
return
|
|
4602
|
+
return _context41.abrupt("return", {
|
|
4235
4603
|
success: true,
|
|
4236
4604
|
orderId: realOrderId,
|
|
4237
4605
|
orderUuid: this.store.currentOrder.uuid,
|
|
@@ -4239,9 +4607,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4239
4607
|
});
|
|
4240
4608
|
case 126:
|
|
4241
4609
|
case "end":
|
|
4242
|
-
return
|
|
4610
|
+
return _context41.stop();
|
|
4243
4611
|
}
|
|
4244
|
-
},
|
|
4612
|
+
}, _callee41, this, [[31, 41, 49, 53], [70, 92], [97, 118], [100, 110, 113, 116]]);
|
|
4245
4613
|
}));
|
|
4246
4614
|
function syncOrderToBackendWithReturn() {
|
|
4247
4615
|
return _syncOrderToBackendWithReturn.apply(this, arguments);
|
|
@@ -4251,15 +4619,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4251
4619
|
}, {
|
|
4252
4620
|
key: "setOtherParams",
|
|
4253
4621
|
value: function () {
|
|
4254
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4622
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
|
|
4255
4623
|
var _ref5,
|
|
4256
4624
|
_ref5$cover,
|
|
4257
4625
|
cover,
|
|
4258
|
-
|
|
4259
|
-
return _regeneratorRuntime().wrap(function
|
|
4260
|
-
while (1) switch (
|
|
4626
|
+
_args42 = arguments;
|
|
4627
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context42) {
|
|
4628
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
4261
4629
|
case 0:
|
|
4262
|
-
_ref5 =
|
|
4630
|
+
_ref5 = _args42.length > 1 && _args42[1] !== undefined ? _args42[1] : {}, _ref5$cover = _ref5.cover, cover = _ref5$cover === void 0 ? false : _ref5$cover;
|
|
4263
4631
|
if (cover) {
|
|
4264
4632
|
this.otherParams = params;
|
|
4265
4633
|
} else {
|
|
@@ -4267,11 +4635,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4267
4635
|
}
|
|
4268
4636
|
case 2:
|
|
4269
4637
|
case "end":
|
|
4270
|
-
return
|
|
4638
|
+
return _context42.stop();
|
|
4271
4639
|
}
|
|
4272
|
-
},
|
|
4640
|
+
}, _callee42, this);
|
|
4273
4641
|
}));
|
|
4274
|
-
function setOtherParams(
|
|
4642
|
+
function setOtherParams(_x32) {
|
|
4275
4643
|
return _setOtherParams.apply(this, arguments);
|
|
4276
4644
|
}
|
|
4277
4645
|
return setOtherParams;
|
|
@@ -4288,22 +4656,22 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4288
4656
|
}, {
|
|
4289
4657
|
key: "editOrderNoteByOrderIdAsync",
|
|
4290
4658
|
value: (function () {
|
|
4291
|
-
var _editOrderNoteByOrderIdAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4659
|
+
var _editOrderNoteByOrderIdAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(orderId, note) {
|
|
4292
4660
|
var response, previousNote, errorMessage, _errorMessage;
|
|
4293
|
-
return _regeneratorRuntime().wrap(function
|
|
4294
|
-
while (1) switch (
|
|
4661
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context43) {
|
|
4662
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
4295
4663
|
case 0:
|
|
4296
4664
|
this.logInfo('editOrderNoteByOrderIdAsync called', {
|
|
4297
4665
|
orderId: orderId,
|
|
4298
4666
|
note: note,
|
|
4299
4667
|
noteLength: note.length
|
|
4300
4668
|
});
|
|
4301
|
-
|
|
4669
|
+
_context43.prev = 1;
|
|
4302
4670
|
if (orderId) {
|
|
4303
|
-
|
|
4671
|
+
_context43.next = 4;
|
|
4304
4672
|
break;
|
|
4305
4673
|
}
|
|
4306
|
-
return
|
|
4674
|
+
return _context43.abrupt("return", {
|
|
4307
4675
|
success: false,
|
|
4308
4676
|
message: '订单ID不能为空',
|
|
4309
4677
|
orderId: orderId
|
|
@@ -4319,12 +4687,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4319
4687
|
});
|
|
4320
4688
|
|
|
4321
4689
|
// 调用后端API修改订单备注
|
|
4322
|
-
|
|
4690
|
+
_context43.next = 7;
|
|
4323
4691
|
return this.request.put("/order/order/".concat(orderId, "/note"), {
|
|
4324
4692
|
note: note
|
|
4325
4693
|
});
|
|
4326
4694
|
case 7:
|
|
4327
|
-
response =
|
|
4695
|
+
response = _context43.sent;
|
|
4328
4696
|
this.logInfo('订单备注编辑响应:', {
|
|
4329
4697
|
orderId: orderId,
|
|
4330
4698
|
status: response.status,
|
|
@@ -4334,11 +4702,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4334
4702
|
|
|
4335
4703
|
// 检查响应状态
|
|
4336
4704
|
if (!(response.status === true || response.status === 200)) {
|
|
4337
|
-
|
|
4705
|
+
_context43.next = 18;
|
|
4338
4706
|
break;
|
|
4339
4707
|
}
|
|
4340
4708
|
if (!(this.store.currentOrder && (String(this.store.currentOrder.order_id) === String(orderId) || String(this.store.currentOrder.id) === String(orderId)))) {
|
|
4341
|
-
|
|
4709
|
+
_context43.next = 15;
|
|
4342
4710
|
break;
|
|
4343
4711
|
}
|
|
4344
4712
|
// 获取修改前的备注用于事件
|
|
@@ -4348,7 +4716,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4348
4716
|
}
|
|
4349
4717
|
|
|
4350
4718
|
// 触发订单备注变更事件
|
|
4351
|
-
|
|
4719
|
+
_context43.next = 15;
|
|
4352
4720
|
return this.core.effects.emit("".concat(this.name, ":onOrderNoteChanged"), {
|
|
4353
4721
|
orderUuid: this.store.currentOrder.uuid,
|
|
4354
4722
|
oldNote: previousNote,
|
|
@@ -4356,7 +4724,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4356
4724
|
timestamp: Date.now()
|
|
4357
4725
|
});
|
|
4358
4726
|
case 15:
|
|
4359
|
-
return
|
|
4727
|
+
return _context43.abrupt("return", {
|
|
4360
4728
|
success: true,
|
|
4361
4729
|
message: response.message || '订单备注修改成功',
|
|
4362
4730
|
orderId: orderId
|
|
@@ -4365,31 +4733,31 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4365
4733
|
// API返回失败状态
|
|
4366
4734
|
errorMessage = response.message || '订单备注修改失败';
|
|
4367
4735
|
this.logError("\u8BA2\u5355 ".concat(orderId, " \u5907\u6CE8\u4FEE\u6539\u5931\u8D25:"), errorMessage);
|
|
4368
|
-
return
|
|
4736
|
+
return _context43.abrupt("return", {
|
|
4369
4737
|
success: false,
|
|
4370
4738
|
message: errorMessage,
|
|
4371
4739
|
orderId: orderId
|
|
4372
4740
|
});
|
|
4373
4741
|
case 21:
|
|
4374
|
-
|
|
4742
|
+
_context43.next = 28;
|
|
4375
4743
|
break;
|
|
4376
4744
|
case 23:
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
this.logError('编辑订单备注失败:',
|
|
4380
|
-
_errorMessage =
|
|
4381
|
-
return
|
|
4745
|
+
_context43.prev = 23;
|
|
4746
|
+
_context43.t0 = _context43["catch"](1);
|
|
4747
|
+
this.logError('编辑订单备注失败:', _context43.t0);
|
|
4748
|
+
_errorMessage = _context43.t0 instanceof Error ? _context43.t0.message : '网络错误或服务器异常';
|
|
4749
|
+
return _context43.abrupt("return", {
|
|
4382
4750
|
success: false,
|
|
4383
4751
|
message: "\u7F16\u8F91\u8BA2\u5355\u5907\u6CE8\u5931\u8D25: ".concat(_errorMessage),
|
|
4384
4752
|
orderId: orderId
|
|
4385
4753
|
});
|
|
4386
4754
|
case 28:
|
|
4387
4755
|
case "end":
|
|
4388
|
-
return
|
|
4756
|
+
return _context43.stop();
|
|
4389
4757
|
}
|
|
4390
|
-
},
|
|
4758
|
+
}, _callee43, this, [[1, 23]]);
|
|
4391
4759
|
}));
|
|
4392
|
-
function editOrderNoteByOrderIdAsync(
|
|
4760
|
+
function editOrderNoteByOrderIdAsync(_x33, _x34) {
|
|
4393
4761
|
return _editOrderNoteByOrderIdAsync.apply(this, arguments);
|
|
4394
4762
|
}
|
|
4395
4763
|
return editOrderNoteByOrderIdAsync;
|
|
@@ -4406,11 +4774,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4406
4774
|
}, {
|
|
4407
4775
|
key: "sendCustomerPayLinkAsync",
|
|
4408
4776
|
value: (function () {
|
|
4409
|
-
var _sendCustomerPayLinkAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4777
|
+
var _sendCustomerPayLinkAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(params) {
|
|
4410
4778
|
var _params$order_ids, _params$emails;
|
|
4411
4779
|
var emailRegex, invalidEmails, requestBody, response, errorMessage, _errorMessage2;
|
|
4412
|
-
return _regeneratorRuntime().wrap(function
|
|
4413
|
-
while (1) switch (
|
|
4780
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context44) {
|
|
4781
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
4414
4782
|
case 0:
|
|
4415
4783
|
this.logInfo('sendCustomerPayLinkAsync called', {
|
|
4416
4784
|
orderIds: params.order_ids,
|
|
@@ -4419,21 +4787,21 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4419
4787
|
emailsCount: ((_params$emails = params.emails) === null || _params$emails === void 0 ? void 0 : _params$emails.length) || 0,
|
|
4420
4788
|
notifyAction: params.notify_action || 'order_payment_reminder'
|
|
4421
4789
|
});
|
|
4422
|
-
|
|
4790
|
+
_context44.prev = 1;
|
|
4423
4791
|
if (!(!params.order_ids || params.order_ids.length === 0)) {
|
|
4424
|
-
|
|
4792
|
+
_context44.next = 4;
|
|
4425
4793
|
break;
|
|
4426
4794
|
}
|
|
4427
|
-
return
|
|
4795
|
+
return _context44.abrupt("return", {
|
|
4428
4796
|
success: false,
|
|
4429
4797
|
message: '订单ID列表不能为空'
|
|
4430
4798
|
});
|
|
4431
4799
|
case 4:
|
|
4432
4800
|
if (!(!params.emails || params.emails.length === 0)) {
|
|
4433
|
-
|
|
4801
|
+
_context44.next = 6;
|
|
4434
4802
|
break;
|
|
4435
4803
|
}
|
|
4436
|
-
return
|
|
4804
|
+
return _context44.abrupt("return", {
|
|
4437
4805
|
success: false,
|
|
4438
4806
|
message: '邮箱地址列表不能为空'
|
|
4439
4807
|
});
|
|
@@ -4444,10 +4812,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4444
4812
|
return !emailRegex.test(email);
|
|
4445
4813
|
});
|
|
4446
4814
|
if (!(invalidEmails.length > 0)) {
|
|
4447
|
-
|
|
4815
|
+
_context44.next = 10;
|
|
4448
4816
|
break;
|
|
4449
4817
|
}
|
|
4450
|
-
return
|
|
4818
|
+
return _context44.abrupt("return", {
|
|
4451
4819
|
success: false,
|
|
4452
4820
|
message: "\u90AE\u7BB1\u683C\u5F0F\u65E0\u6548: ".concat(invalidEmails.join(', '))
|
|
4453
4821
|
});
|
|
@@ -4463,10 +4831,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4463
4831
|
}, requestBody));
|
|
4464
4832
|
|
|
4465
4833
|
// 调用后端API发送邮件
|
|
4466
|
-
|
|
4834
|
+
_context44.next = 14;
|
|
4467
4835
|
return this.request.post('/order/batch-email', requestBody);
|
|
4468
4836
|
case 14:
|
|
4469
|
-
response =
|
|
4837
|
+
response = _context44.sent;
|
|
4470
4838
|
this.logInfo('支付链接邮件发送响应:', {
|
|
4471
4839
|
status: response.status,
|
|
4472
4840
|
message: response.message,
|
|
@@ -4476,10 +4844,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4476
4844
|
|
|
4477
4845
|
// 检查响应状态
|
|
4478
4846
|
if (!(response.status === true || response.status === 200)) {
|
|
4479
|
-
|
|
4847
|
+
_context44.next = 20;
|
|
4480
4848
|
break;
|
|
4481
4849
|
}
|
|
4482
|
-
return
|
|
4850
|
+
return _context44.abrupt("return", {
|
|
4483
4851
|
success: true,
|
|
4484
4852
|
message: response.message || '支付链接邮件发送成功'
|
|
4485
4853
|
});
|
|
@@ -4487,29 +4855,29 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4487
4855
|
// API返回失败状态
|
|
4488
4856
|
errorMessage = response.message || '支付链接邮件发送失败';
|
|
4489
4857
|
console.error('[Checkout] 支付链接邮件发送失败:', errorMessage);
|
|
4490
|
-
return
|
|
4858
|
+
return _context44.abrupt("return", {
|
|
4491
4859
|
success: false,
|
|
4492
4860
|
message: errorMessage
|
|
4493
4861
|
});
|
|
4494
4862
|
case 23:
|
|
4495
|
-
|
|
4863
|
+
_context44.next = 30;
|
|
4496
4864
|
break;
|
|
4497
4865
|
case 25:
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
this.logError('发送客户支付链接邮件失败:',
|
|
4501
|
-
_errorMessage2 =
|
|
4502
|
-
return
|
|
4866
|
+
_context44.prev = 25;
|
|
4867
|
+
_context44.t0 = _context44["catch"](1);
|
|
4868
|
+
this.logError('发送客户支付链接邮件失败:', _context44.t0);
|
|
4869
|
+
_errorMessage2 = _context44.t0 instanceof Error ? _context44.t0.message : '网络错误或服务器异常';
|
|
4870
|
+
return _context44.abrupt("return", {
|
|
4503
4871
|
success: false,
|
|
4504
4872
|
message: "\u53D1\u9001\u652F\u4ED8\u94FE\u63A5\u90AE\u4EF6\u5931\u8D25: ".concat(_errorMessage2)
|
|
4505
4873
|
});
|
|
4506
4874
|
case 30:
|
|
4507
4875
|
case "end":
|
|
4508
|
-
return
|
|
4876
|
+
return _context44.stop();
|
|
4509
4877
|
}
|
|
4510
|
-
},
|
|
4878
|
+
}, _callee44, this, [[1, 25]]);
|
|
4511
4879
|
}));
|
|
4512
|
-
function sendCustomerPayLinkAsync(
|
|
4880
|
+
function sendCustomerPayLinkAsync(_x35) {
|
|
4513
4881
|
return _sendCustomerPayLinkAsync.apply(this, arguments);
|
|
4514
4882
|
}
|
|
4515
4883
|
return sendCustomerPayLinkAsync;
|
|
@@ -4524,38 +4892,38 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4524
4892
|
}, {
|
|
4525
4893
|
key: "roundAmountAsync",
|
|
4526
4894
|
value: (function () {
|
|
4527
|
-
var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4895
|
+
var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(amount) {
|
|
4528
4896
|
var _cashManualPayment$me, _this$otherParams$ord, _this$otherParams$ord2;
|
|
4529
4897
|
var cashManualPayment, result;
|
|
4530
|
-
return _regeneratorRuntime().wrap(function
|
|
4531
|
-
while (1) switch (
|
|
4898
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context45) {
|
|
4899
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
4532
4900
|
case 0:
|
|
4533
4901
|
// 检查 CASHMANUAL 的支付项是否开启了舍入,如果没开直接返回 amount
|
|
4534
4902
|
cashManualPayment = this.store.paymentMethods.find(function (p) {
|
|
4535
4903
|
return p.code === 'CASHMANUAL';
|
|
4536
4904
|
});
|
|
4537
4905
|
if (cashManualPayment !== null && cashManualPayment !== void 0 && (_cashManualPayment$me = cashManualPayment.metadata) !== null && _cashManualPayment$me !== void 0 && _cashManualPayment$me.order_rounding_switch) {
|
|
4538
|
-
|
|
4906
|
+
_context45.next = 3;
|
|
4539
4907
|
break;
|
|
4540
4908
|
}
|
|
4541
|
-
return
|
|
4909
|
+
return _context45.abrupt("return", {
|
|
4542
4910
|
originalAmount: amount.toString(),
|
|
4543
4911
|
roundedAmount: amount.toString(),
|
|
4544
4912
|
roundingDifference: '0.00'
|
|
4545
4913
|
});
|
|
4546
4914
|
case 3:
|
|
4547
|
-
|
|
4915
|
+
_context45.next = 5;
|
|
4548
4916
|
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);
|
|
4549
4917
|
case 5:
|
|
4550
|
-
result =
|
|
4551
|
-
return
|
|
4918
|
+
result = _context45.sent;
|
|
4919
|
+
return _context45.abrupt("return", result);
|
|
4552
4920
|
case 7:
|
|
4553
4921
|
case "end":
|
|
4554
|
-
return
|
|
4922
|
+
return _context45.stop();
|
|
4555
4923
|
}
|
|
4556
|
-
},
|
|
4924
|
+
}, _callee45, this);
|
|
4557
4925
|
}));
|
|
4558
|
-
function roundAmountAsync(
|
|
4926
|
+
function roundAmountAsync(_x36) {
|
|
4559
4927
|
return _roundAmountAsync.apply(this, arguments);
|
|
4560
4928
|
}
|
|
4561
4929
|
return roundAmountAsync;
|
|
@@ -4563,10 +4931,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4563
4931
|
}, {
|
|
4564
4932
|
key: "destroy",
|
|
4565
4933
|
value: function () {
|
|
4566
|
-
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4934
|
+
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
|
|
4567
4935
|
var _this$order, _this$order$destroy, _this$payment, _this$payment$destroy;
|
|
4568
|
-
return _regeneratorRuntime().wrap(function
|
|
4569
|
-
while (1) switch (
|
|
4936
|
+
return _regeneratorRuntime().wrap(function _callee46$(_context46) {
|
|
4937
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
4570
4938
|
case 0:
|
|
4571
4939
|
// 清理钱包模块的所有缓存数据
|
|
4572
4940
|
this.payment.wallet.clearAllCache();
|
|
@@ -4575,10 +4943,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4575
4943
|
this.core.effects.offByModuleDestroy(this.name);
|
|
4576
4944
|
|
|
4577
4945
|
// 销毁子模块
|
|
4578
|
-
|
|
4946
|
+
_context46.next = 4;
|
|
4579
4947
|
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);
|
|
4580
4948
|
case 4:
|
|
4581
|
-
|
|
4949
|
+
_context46.next = 6;
|
|
4582
4950
|
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);
|
|
4583
4951
|
case 6:
|
|
4584
4952
|
// 取消注册模块
|
|
@@ -4586,9 +4954,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4586
4954
|
console.log('[Checkout] 已销毁');
|
|
4587
4955
|
case 8:
|
|
4588
4956
|
case "end":
|
|
4589
|
-
return
|
|
4957
|
+
return _context46.stop();
|
|
4590
4958
|
}
|
|
4591
|
-
},
|
|
4959
|
+
}, _callee46, this);
|
|
4592
4960
|
}));
|
|
4593
4961
|
function destroy() {
|
|
4594
4962
|
return _destroy.apply(this, arguments);
|
|
@@ -4605,7 +4973,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4605
4973
|
}, {
|
|
4606
4974
|
key: "resetStoreState",
|
|
4607
4975
|
value: function resetStoreState() {
|
|
4608
|
-
var
|
|
4976
|
+
var _this8 = this;
|
|
4609
4977
|
try {
|
|
4610
4978
|
var prevOrderInfo = this.store.currentOrder ? {
|
|
4611
4979
|
uuid: this.store.currentOrder.uuid,
|
|
@@ -4640,7 +5008,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4640
5008
|
// 使用 setTimeout 确保事件处理不会阻塞状态重置
|
|
4641
5009
|
if (prevOrderInfo) {
|
|
4642
5010
|
setTimeout(function () {
|
|
4643
|
-
|
|
5011
|
+
_this8.core.effects.emit("".concat(_this8.name, ":onOrderCleared"), {
|
|
4644
5012
|
previousOrder: prevOrderInfo,
|
|
4645
5013
|
timestamp: Date.now()
|
|
4646
5014
|
});
|