@pisell/pisellos 0.0.260 → 0.0.261
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.
|
@@ -1030,7 +1030,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1030
1030
|
key: "addPaymentItemAsync",
|
|
1031
1031
|
value: (function () {
|
|
1032
1032
|
var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(paymentItem) {
|
|
1033
|
-
var
|
|
1033
|
+
var orderPaymentType, processedPaymentItem, metadata, paymentItemWithType, remainingAmount, _paymentItem$type, _paymentItem$code, isEftposPayment, syncResult;
|
|
1034
1034
|
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1035
1035
|
while (1) switch (_context15.prev = _context15.next) {
|
|
1036
1036
|
case 0:
|
|
@@ -1062,6 +1062,19 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1062
1062
|
case 12:
|
|
1063
1063
|
this.logInfo('支付项添加成功');
|
|
1064
1064
|
|
|
1065
|
+
// 支付项添加后,更新 stateAmount 为剩余未支付金额
|
|
1066
|
+
_context15.next = 15;
|
|
1067
|
+
return this.updateStateAmountToRemaining();
|
|
1068
|
+
case 15:
|
|
1069
|
+
_context15.next = 17;
|
|
1070
|
+
return this.calculateRemainingAmountAsync();
|
|
1071
|
+
case 17:
|
|
1072
|
+
remainingAmount = _context15.sent;
|
|
1073
|
+
if (!(Number(remainingAmount) > 0)) {
|
|
1074
|
+
_context15.next = 36;
|
|
1075
|
+
break;
|
|
1076
|
+
}
|
|
1077
|
+
this.logInfo('订单金额还有待付的,同步 EFTPOS 支付');
|
|
1065
1078
|
// 检查是否是 EFTPOS 支付,如果是则立即同步订单
|
|
1066
1079
|
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'));
|
|
1067
1080
|
this.logInfo('EFTPOS 支付检查:', {
|
|
@@ -1071,34 +1084,31 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1071
1084
|
currentOrderSynced: this.store.isOrderSynced
|
|
1072
1085
|
});
|
|
1073
1086
|
if (!isEftposPayment) {
|
|
1074
|
-
_context15.next =
|
|
1087
|
+
_context15.next = 36;
|
|
1075
1088
|
break;
|
|
1076
1089
|
}
|
|
1077
1090
|
this.logInfo('检测到 EFTPOS 支付,立即同步订单到后端...');
|
|
1078
|
-
_context15.prev =
|
|
1079
|
-
_context15.next =
|
|
1091
|
+
_context15.prev = 24;
|
|
1092
|
+
_context15.next = 27;
|
|
1080
1093
|
return this.syncOrderToBackendWithReturn(true);
|
|
1081
|
-
case
|
|
1094
|
+
case 27:
|
|
1082
1095
|
syncResult = _context15.sent;
|
|
1083
1096
|
this.logInfo('EFTPOS 支付后订单同步完成 (已标记为手动同步):', {
|
|
1084
1097
|
orderId: syncResult.orderId,
|
|
1085
1098
|
isOrderSynced: this.store.isOrderSynced,
|
|
1086
1099
|
backendResponse: syncResult.response
|
|
1087
1100
|
});
|
|
1088
|
-
_context15.next =
|
|
1101
|
+
_context15.next = 36;
|
|
1089
1102
|
break;
|
|
1090
|
-
case
|
|
1091
|
-
_context15.prev =
|
|
1092
|
-
_context15.t0 = _context15["catch"](
|
|
1103
|
+
case 31:
|
|
1104
|
+
_context15.prev = 31;
|
|
1105
|
+
_context15.t0 = _context15["catch"](24);
|
|
1093
1106
|
this.logError('EFTPOS 支付后订单同步失败:', _context15.t0);
|
|
1094
1107
|
// 不抛出错误,避免影响支付流程,但记录错误
|
|
1095
|
-
_context15.next =
|
|
1108
|
+
_context15.next = 36;
|
|
1096
1109
|
return this.handleError(new Error("EFTPOS \u652F\u4ED8\u540E\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(_context15.t0 instanceof Error ? _context15.t0.message : String(_context15.t0))), CheckoutErrorType.OrderCreationFailed);
|
|
1097
|
-
case
|
|
1098
|
-
_context15.next =
|
|
1099
|
-
return this.updateStateAmountToRemaining();
|
|
1100
|
-
case 31:
|
|
1101
|
-
_context15.next = 33;
|
|
1110
|
+
case 36:
|
|
1111
|
+
_context15.next = 38;
|
|
1102
1112
|
return this.core.effects.emit(CheckoutHooks.OnPaymentItemAdded, {
|
|
1103
1113
|
orderUuid: this.store.currentOrder.uuid,
|
|
1104
1114
|
paymentMethodCode: paymentItem.code,
|
|
@@ -1106,22 +1116,22 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1106
1116
|
amount: String(paymentItem.amount),
|
|
1107
1117
|
timestamp: Date.now()
|
|
1108
1118
|
});
|
|
1109
|
-
case
|
|
1110
|
-
_context15.next =
|
|
1119
|
+
case 38:
|
|
1120
|
+
_context15.next = 46;
|
|
1111
1121
|
break;
|
|
1112
|
-
case
|
|
1113
|
-
_context15.prev =
|
|
1122
|
+
case 40:
|
|
1123
|
+
_context15.prev = 40;
|
|
1114
1124
|
_context15.t1 = _context15["catch"](1);
|
|
1115
1125
|
this.logError('添加支付项失败:', _context15.t1);
|
|
1116
|
-
_context15.next =
|
|
1126
|
+
_context15.next = 45;
|
|
1117
1127
|
return this.handleError(_context15.t1, CheckoutErrorType.PaymentFailed);
|
|
1118
|
-
case
|
|
1128
|
+
case 45:
|
|
1119
1129
|
throw _context15.t1;
|
|
1120
|
-
case
|
|
1130
|
+
case 46:
|
|
1121
1131
|
case "end":
|
|
1122
1132
|
return _context15.stop();
|
|
1123
1133
|
}
|
|
1124
|
-
}, _callee15, this, [[1,
|
|
1134
|
+
}, _callee15, this, [[1, 40], [24, 31]]);
|
|
1125
1135
|
}));
|
|
1126
1136
|
function addPaymentItemAsync(_x14) {
|
|
1127
1137
|
return _addPaymentItemAsync.apply(this, arguments);
|
|
@@ -638,33 +638,37 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
638
638
|
paymentItemWithType
|
|
639
639
|
);
|
|
640
640
|
this.logInfo("支付项添加成功");
|
|
641
|
-
|
|
642
|
-
this.
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
isEftposPayment
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
)
|
|
663
|
-
|
|
664
|
-
|
|
641
|
+
await this.updateStateAmountToRemaining();
|
|
642
|
+
const remainingAmount = await this.calculateRemainingAmountAsync();
|
|
643
|
+
if (Number(remainingAmount) > 0) {
|
|
644
|
+
this.logInfo("订单金额还有待付的,同步 EFTPOS 支付");
|
|
645
|
+
const isEftposPayment = ((_a = paymentItem.type) == null ? void 0 : _a.toLowerCase()) === "eftpos" || ((_b = paymentItem.code) == null ? void 0 : _b.toUpperCase().includes("EFTPOS"));
|
|
646
|
+
this.logInfo("EFTPOS 支付检查:", {
|
|
647
|
+
paymentCode: paymentItem.code,
|
|
648
|
+
paymentType: paymentItem.type,
|
|
649
|
+
isEftposPayment,
|
|
650
|
+
currentOrderSynced: this.store.isOrderSynced
|
|
651
|
+
});
|
|
652
|
+
if (isEftposPayment) {
|
|
653
|
+
this.logInfo("检测到 EFTPOS 支付,立即同步订单到后端...");
|
|
654
|
+
try {
|
|
655
|
+
const syncResult = await this.syncOrderToBackendWithReturn(true);
|
|
656
|
+
this.logInfo("EFTPOS 支付后订单同步完成 (已标记为手动同步):", {
|
|
657
|
+
orderId: syncResult.orderId,
|
|
658
|
+
isOrderSynced: this.store.isOrderSynced,
|
|
659
|
+
backendResponse: syncResult.response
|
|
660
|
+
});
|
|
661
|
+
} catch (error) {
|
|
662
|
+
this.logError("EFTPOS 支付后订单同步失败:", error);
|
|
663
|
+
await this.handleError(
|
|
664
|
+
new Error(
|
|
665
|
+
`EFTPOS 支付后订单同步失败: ${error instanceof Error ? error.message : String(error)}`
|
|
666
|
+
),
|
|
667
|
+
import_types.CheckoutErrorType.OrderCreationFailed
|
|
668
|
+
);
|
|
669
|
+
}
|
|
665
670
|
}
|
|
666
671
|
}
|
|
667
|
-
await this.updateStateAmountToRemaining();
|
|
668
672
|
await this.core.effects.emit(import_types.CheckoutHooks.OnPaymentItemAdded, {
|
|
669
673
|
orderUuid: this.store.currentOrder.uuid,
|
|
670
674
|
paymentMethodCode: paymentItem.code,
|