@pisell/pisellos 0.0.407 → 0.0.408
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.
|
@@ -2376,7 +2376,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2376
2376
|
key: "saveForLaterPaymentAsync",
|
|
2377
2377
|
value: (function () {
|
|
2378
2378
|
var _saveForLaterPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
2379
|
-
var orderUuid, currentOrderId, allPaymentItems, syncResult, _this$store$currentOr19, errorMessage;
|
|
2379
|
+
var orderUuid, currentOrderId, allPaymentItems, orderPaymentStatus, syncResult, _this$store$currentOr19, errorMessage;
|
|
2380
2380
|
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
2381
2381
|
while (1) switch (_context23.prev = _context23.next) {
|
|
2382
2382
|
case 0:
|
|
@@ -2403,9 +2403,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2403
2403
|
return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid);
|
|
2404
2404
|
case 8:
|
|
2405
2405
|
allPaymentItems = _context23.sent;
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2406
|
+
// 保存并稍后支付的订单状态需要特殊处理
|
|
2407
|
+
// 如果当前订单已经有支付项了,则标记为partially_paid 否则标记为 payment_processing
|
|
2408
|
+
orderPaymentStatus = allPaymentItems.filter(function (item) {
|
|
2409
|
+
return item.status !== 'voided';
|
|
2410
|
+
}).length > 0 ? 'partially_paid' : 'payment_processing'; // 调用同步方法,传入过滤后的支付项
|
|
2411
|
+
_context23.next = 12;
|
|
2412
|
+
return this.syncOrderToBackendWithReturn(true, allPaymentItems, orderPaymentStatus);
|
|
2413
|
+
case 12:
|
|
2409
2414
|
syncResult = _context23.sent;
|
|
2410
2415
|
this.logInfo('保存订单完成:', {
|
|
2411
2416
|
orderUuid: orderUuid,
|
|
@@ -2422,8 +2427,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2422
2427
|
orderUuid: orderUuid,
|
|
2423
2428
|
response: syncResult.response
|
|
2424
2429
|
});
|
|
2425
|
-
case
|
|
2426
|
-
_context23.prev =
|
|
2430
|
+
case 17:
|
|
2431
|
+
_context23.prev = 17;
|
|
2427
2432
|
_context23.t0 = _context23["catch"](0);
|
|
2428
2433
|
this.logError('保存订单失败:', _context23.t0);
|
|
2429
2434
|
errorMessage = _context23.t0 instanceof Error ? _context23.t0.message : '保存失败';
|
|
@@ -2432,11 +2437,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2432
2437
|
message: "\u8BA2\u5355\u4FDD\u5B58\u5931\u8D25: ".concat(errorMessage),
|
|
2433
2438
|
orderUuid: (_this$store$currentOr19 = this.store.currentOrder) === null || _this$store$currentOr19 === void 0 ? void 0 : _this$store$currentOr19.uuid
|
|
2434
2439
|
});
|
|
2435
|
-
case
|
|
2440
|
+
case 22:
|
|
2436
2441
|
case "end":
|
|
2437
2442
|
return _context23.stop();
|
|
2438
2443
|
}
|
|
2439
|
-
}, _callee23, this, [[0,
|
|
2444
|
+
}, _callee23, this, [[0, 17]]);
|
|
2440
2445
|
}));
|
|
2441
2446
|
function saveForLaterPaymentAsync() {
|
|
2442
2447
|
return _saveForLaterPaymentAsync.apply(this, arguments);
|
|
@@ -3752,6 +3757,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3752
3757
|
_checkoutResponse4;
|
|
3753
3758
|
var isManual,
|
|
3754
3759
|
customPaymentItems,
|
|
3760
|
+
paymentStatus,
|
|
3755
3761
|
currentOrderId,
|
|
3756
3762
|
isUpdateOperation,
|
|
3757
3763
|
paymentItems,
|
|
@@ -3759,6 +3765,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3759
3765
|
finalDepositAmount,
|
|
3760
3766
|
manualDepositAmount,
|
|
3761
3767
|
manualDepositValue,
|
|
3768
|
+
orderPaymentStatus,
|
|
3769
|
+
totalPaidAmount,
|
|
3762
3770
|
orderParams,
|
|
3763
3771
|
startTime,
|
|
3764
3772
|
checkoutResponse,
|
|
@@ -3786,12 +3794,13 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3786
3794
|
case 0:
|
|
3787
3795
|
isManual = _args39.length > 0 && _args39[0] !== undefined ? _args39[0] : false;
|
|
3788
3796
|
customPaymentItems = _args39.length > 1 ? _args39[1] : undefined;
|
|
3797
|
+
paymentStatus = _args39.length > 2 ? _args39[2] : undefined;
|
|
3789
3798
|
if (!(!this.store.localOrderData || !this.store.currentOrder)) {
|
|
3790
|
-
_context39.next =
|
|
3799
|
+
_context39.next = 5;
|
|
3791
3800
|
break;
|
|
3792
3801
|
}
|
|
3793
3802
|
throw new Error('缺少必要的订单数据,无法同步到后端');
|
|
3794
|
-
case
|
|
3803
|
+
case 5:
|
|
3795
3804
|
this.logInfo('syncOrderToBackendWithReturn called', {
|
|
3796
3805
|
isManual: isManual
|
|
3797
3806
|
});
|
|
@@ -3808,14 +3817,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3808
3817
|
// 获取当前订单的支付项
|
|
3809
3818
|
_context39.t0 = customPaymentItems;
|
|
3810
3819
|
if (_context39.t0) {
|
|
3811
|
-
_context39.next =
|
|
3820
|
+
_context39.next = 14;
|
|
3812
3821
|
break;
|
|
3813
3822
|
}
|
|
3814
|
-
_context39.next =
|
|
3823
|
+
_context39.next = 13;
|
|
3815
3824
|
return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid);
|
|
3816
|
-
case 12:
|
|
3817
|
-
_context39.t0 = _context39.sent;
|
|
3818
3825
|
case 13:
|
|
3826
|
+
_context39.t0 = _context39.sent;
|
|
3827
|
+
case 14:
|
|
3819
3828
|
paymentItems = _context39.t0;
|
|
3820
3829
|
// 处理支付项数据,确保包含完整的 metadata
|
|
3821
3830
|
processedPaymentItems = paymentItems.map(function (item) {
|
|
@@ -3890,8 +3899,33 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3890
3899
|
isDeposit: ((_this$store$currentOr25 = this.store.currentOrder) === null || _this$store$currentOr25 === void 0 ? void 0 : _this$store$currentOr25.is_deposit) || 0
|
|
3891
3900
|
});
|
|
3892
3901
|
|
|
3902
|
+
// 计算订单状态,优先读取外面传递的,如果没有则根据订单支付数据来
|
|
3903
|
+
// paid 已全额付款
|
|
3904
|
+
// partially_paid 部分付款
|
|
3905
|
+
// unpaid 未支付(弃单状态)
|
|
3906
|
+
// payment_processing 待支付
|
|
3907
|
+
orderPaymentStatus = paymentStatus;
|
|
3908
|
+
if (!orderPaymentStatus) {
|
|
3909
|
+
// 判断当前支付项里的数据是否已经满足订单的金额
|
|
3910
|
+
totalPaidAmount = processedPaymentItems.filter(function (item) {
|
|
3911
|
+
return item.status !== 'voided';
|
|
3912
|
+
}).reduce(function (sum, item) {
|
|
3913
|
+
var amt = new Decimal(item.amount || '0');
|
|
3914
|
+
var rounding = new Decimal(item.rounding_amount || '0');
|
|
3915
|
+
return sum.plus(amt).sub(rounding);
|
|
3916
|
+
}, new Decimal(0));
|
|
3917
|
+
if (totalPaidAmount.gte(new Decimal(this.store.currentOrder.total_amount))) {
|
|
3918
|
+
orderPaymentStatus = 'paid';
|
|
3919
|
+
} else if (totalPaidAmount.gt(0)) {
|
|
3920
|
+
orderPaymentStatus = 'partially_paid';
|
|
3921
|
+
} else {
|
|
3922
|
+
orderPaymentStatus = 'unpaid';
|
|
3923
|
+
}
|
|
3924
|
+
}
|
|
3925
|
+
|
|
3893
3926
|
// 构造订单参数,直接使用 localOrderData 中已处理好的数据
|
|
3894
3927
|
orderParams = _objectSpread(_objectSpread({}, this.store.localOrderData), {}, {
|
|
3928
|
+
payment_status: orderPaymentStatus,
|
|
3895
3929
|
type: this.store.localOrderData.type,
|
|
3896
3930
|
platform: this.store.localOrderData.platform,
|
|
3897
3931
|
payments: processedPaymentItems,
|
|
@@ -3940,7 +3974,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3940
3974
|
|
|
3941
3975
|
// 发送下单接口请求开始事件
|
|
3942
3976
|
startTime = Date.now();
|
|
3943
|
-
_context39.next =
|
|
3977
|
+
_context39.next = 30;
|
|
3944
3978
|
return this.core.effects.emit("".concat(this.name, ":onOrderSubmitStart"), {
|
|
3945
3979
|
orderUuid: this.store.currentOrder.uuid,
|
|
3946
3980
|
operation: isUpdateOperation ? 'update' : 'create',
|
|
@@ -3948,9 +3982,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3948
3982
|
paymentItemCount: paymentItems.length,
|
|
3949
3983
|
timestamp: startTime
|
|
3950
3984
|
});
|
|
3951
|
-
case
|
|
3985
|
+
case 30:
|
|
3952
3986
|
submitSuccess = false;
|
|
3953
|
-
_context39.prev =
|
|
3987
|
+
_context39.prev = 31;
|
|
3954
3988
|
// 记录接口调用参数
|
|
3955
3989
|
this.logInfo('Calling backend checkout API', _objectSpread({
|
|
3956
3990
|
url: '/order/checkout',
|
|
@@ -3958,23 +3992,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3958
3992
|
}, orderParams));
|
|
3959
3993
|
|
|
3960
3994
|
// 调用 Order 模块的专用 createOrderByCheckout 方法
|
|
3961
|
-
_context39.next =
|
|
3995
|
+
_context39.next = 35;
|
|
3962
3996
|
return this.order.createOrderByCheckout(orderParams);
|
|
3963
|
-
case
|
|
3997
|
+
case 35:
|
|
3964
3998
|
checkoutResponse = _context39.sent;
|
|
3965
3999
|
submitSuccess = true;
|
|
3966
4000
|
this.logInfo('下单接口调用成功', checkoutResponse);
|
|
3967
|
-
_context39.next =
|
|
4001
|
+
_context39.next = 48;
|
|
3968
4002
|
break;
|
|
3969
|
-
case
|
|
3970
|
-
_context39.prev =
|
|
3971
|
-
_context39.t1 = _context39["catch"](
|
|
4003
|
+
case 40:
|
|
4004
|
+
_context39.prev = 40;
|
|
4005
|
+
_context39.t1 = _context39["catch"](31);
|
|
3972
4006
|
submitSuccess = false;
|
|
3973
4007
|
submitError = _context39.t1 instanceof Error ? _context39.t1.message : String(_context39.t1);
|
|
3974
4008
|
this.logError('下单接口调用失败:', submitError);
|
|
3975
4009
|
|
|
3976
4010
|
// 发送订单同步失败事件(网络错误或请求失败)
|
|
3977
|
-
_context39.next =
|
|
4011
|
+
_context39.next = 47;
|
|
3978
4012
|
return this.core.effects.emit("".concat(this.name, ":onOrderSyncFailed"), {
|
|
3979
4013
|
orderUuid: this.store.currentOrder.uuid,
|
|
3980
4014
|
operation: isUpdateOperation ? 'update' : 'create',
|
|
@@ -3984,11 +4018,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3984
4018
|
duration: Date.now() - startTime,
|
|
3985
4019
|
timestamp: Date.now()
|
|
3986
4020
|
});
|
|
3987
|
-
case
|
|
4021
|
+
case 47:
|
|
3988
4022
|
throw _context39.t1;
|
|
3989
|
-
case
|
|
3990
|
-
_context39.prev =
|
|
3991
|
-
_context39.next =
|
|
4023
|
+
case 48:
|
|
4024
|
+
_context39.prev = 48;
|
|
4025
|
+
_context39.next = 51;
|
|
3992
4026
|
return this.core.effects.emit("".concat(this.name, ":onOrderSubmitEnd"), {
|
|
3993
4027
|
success: submitSuccess,
|
|
3994
4028
|
orderUuid: this.store.currentOrder.uuid,
|
|
@@ -3999,18 +4033,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3999
4033
|
duration: Date.now() - startTime,
|
|
4000
4034
|
timestamp: Date.now()
|
|
4001
4035
|
});
|
|
4002
|
-
case
|
|
4003
|
-
return _context39.finish(
|
|
4004
|
-
case
|
|
4036
|
+
case 51:
|
|
4037
|
+
return _context39.finish(48);
|
|
4038
|
+
case 52:
|
|
4005
4039
|
// 检查响应状态是否为成功状态
|
|
4006
4040
|
responseStatus = (_checkoutResponse3 = checkoutResponse) === null || _checkoutResponse3 === void 0 ? void 0 : _checkoutResponse3.status;
|
|
4007
4041
|
isSuccessResponse = responseStatus === true || responseStatus === 200 || responseStatus === 'success' || responseStatus === 1 && ((_checkoutResponse4 = checkoutResponse) === null || _checkoutResponse4 === void 0 ? void 0 : _checkoutResponse4.code) === 200;
|
|
4008
4042
|
if (isSuccessResponse) {
|
|
4009
|
-
_context39.next =
|
|
4043
|
+
_context39.next = 59;
|
|
4010
4044
|
break;
|
|
4011
4045
|
}
|
|
4012
4046
|
errorMessage = ((_checkoutResponse5 = checkoutResponse) === null || _checkoutResponse5 === void 0 ? void 0 : _checkoutResponse5.message) || '订单同步失败,后端返回非成功状态'; // 发送订单同步失败事件
|
|
4013
|
-
_context39.next =
|
|
4047
|
+
_context39.next = 58;
|
|
4014
4048
|
return this.core.effects.emit("".concat(this.name, ":onOrderSyncFailed"), {
|
|
4015
4049
|
orderUuid: this.store.currentOrder.uuid,
|
|
4016
4050
|
operation: isUpdateOperation ? 'update' : 'create',
|
|
@@ -4021,18 +4055,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4021
4055
|
duration: Date.now() - startTime,
|
|
4022
4056
|
timestamp: Date.now()
|
|
4023
4057
|
});
|
|
4024
|
-
case
|
|
4058
|
+
case 58:
|
|
4025
4059
|
throw new Error(errorMessage);
|
|
4026
|
-
case
|
|
4060
|
+
case 59:
|
|
4027
4061
|
if (!isUpdateOperation) {
|
|
4028
|
-
_context39.next =
|
|
4062
|
+
_context39.next = 63;
|
|
4029
4063
|
break;
|
|
4030
4064
|
}
|
|
4031
4065
|
// 更新操作:使用现有的订单ID
|
|
4032
4066
|
realOrderId = currentOrderId;
|
|
4033
|
-
_context39.next =
|
|
4067
|
+
_context39.next = 82;
|
|
4034
4068
|
break;
|
|
4035
|
-
case
|
|
4069
|
+
case 63:
|
|
4036
4070
|
// 创建操作:从响应中提取新的订单ID
|
|
4037
4071
|
extractedOrderId = (_checkoutResponse6 = checkoutResponse) === null || _checkoutResponse6 === void 0 || (_checkoutResponse6 = _checkoutResponse6.data) === null || _checkoutResponse6 === void 0 ? void 0 : _checkoutResponse6.order_id; // 如果data.order_id不存在,尝试直接从根级获取
|
|
4038
4072
|
if (!extractedOrderId) {
|
|
@@ -4054,10 +4088,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4054
4088
|
oldOrderId: this.store.currentOrder.order_id,
|
|
4055
4089
|
newOrderId: realOrderId
|
|
4056
4090
|
});
|
|
4057
|
-
_context39.prev =
|
|
4058
|
-
_context39.next =
|
|
4091
|
+
_context39.prev = 69;
|
|
4092
|
+
_context39.next = 72;
|
|
4059
4093
|
return this.payment.replaceOrderIdByUuidAsync(this.store.currentOrder.uuid, realOrderId);
|
|
4060
|
-
case
|
|
4094
|
+
case 72:
|
|
4061
4095
|
updatedOrder = _context39.sent;
|
|
4062
4096
|
this.logInfo('Payment模块替换订单ID结果:', {
|
|
4063
4097
|
wasSuccessful: !!updatedOrder,
|
|
@@ -4084,61 +4118,61 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4084
4118
|
目标ID: realOrderId
|
|
4085
4119
|
});
|
|
4086
4120
|
}
|
|
4087
|
-
_context39.next =
|
|
4121
|
+
_context39.next = 82;
|
|
4088
4122
|
break;
|
|
4089
|
-
case
|
|
4090
|
-
_context39.prev =
|
|
4091
|
-
_context39.t2 = _context39["catch"](
|
|
4123
|
+
case 77:
|
|
4124
|
+
_context39.prev = 77;
|
|
4125
|
+
_context39.t2 = _context39["catch"](69);
|
|
4092
4126
|
this.logError('调用Payment模块替换订单ID时发生错误:', _context39.t2);
|
|
4093
4127
|
|
|
4094
4128
|
// 发生错误时也进行手动替换
|
|
4095
4129
|
this.store.currentOrder.order_id = realOrderId;
|
|
4096
4130
|
this.logInfo('错误恢复:手动设置订单ID:', realOrderId);
|
|
4097
|
-
case
|
|
4098
|
-
_context39.prev =
|
|
4131
|
+
case 82:
|
|
4132
|
+
_context39.prev = 82;
|
|
4099
4133
|
syncedPaymentUuids = processedPaymentItems.filter(function (item) {
|
|
4100
4134
|
return item.status !== 'voided';
|
|
4101
4135
|
}).map(function (item) {
|
|
4102
4136
|
return item.uuid;
|
|
4103
4137
|
}).filter(Boolean);
|
|
4104
4138
|
_iterator3 = _createForOfIteratorHelper(syncedPaymentUuids);
|
|
4105
|
-
_context39.prev =
|
|
4139
|
+
_context39.prev = 85;
|
|
4106
4140
|
_iterator3.s();
|
|
4107
|
-
case
|
|
4141
|
+
case 87:
|
|
4108
4142
|
if ((_step3 = _iterator3.n()).done) {
|
|
4109
|
-
_context39.next =
|
|
4143
|
+
_context39.next = 93;
|
|
4110
4144
|
break;
|
|
4111
4145
|
}
|
|
4112
4146
|
paymentUuid = _step3.value;
|
|
4113
|
-
_context39.next =
|
|
4147
|
+
_context39.next = 91;
|
|
4114
4148
|
return this.payment.updatePaymentAsync(this.store.currentOrder.uuid, paymentUuid, {
|
|
4115
4149
|
isSynced: true,
|
|
4116
4150
|
syncError: undefined
|
|
4117
4151
|
});
|
|
4118
|
-
case
|
|
4119
|
-
_context39.next =
|
|
4152
|
+
case 91:
|
|
4153
|
+
_context39.next = 87;
|
|
4120
4154
|
break;
|
|
4121
|
-
case
|
|
4122
|
-
_context39.next =
|
|
4155
|
+
case 93:
|
|
4156
|
+
_context39.next = 98;
|
|
4123
4157
|
break;
|
|
4124
|
-
case 92:
|
|
4125
|
-
_context39.prev = 92;
|
|
4126
|
-
_context39.t3 = _context39["catch"](82);
|
|
4127
|
-
_iterator3.e(_context39.t3);
|
|
4128
4158
|
case 95:
|
|
4129
4159
|
_context39.prev = 95;
|
|
4130
|
-
|
|
4131
|
-
|
|
4160
|
+
_context39.t3 = _context39["catch"](85);
|
|
4161
|
+
_iterator3.e(_context39.t3);
|
|
4132
4162
|
case 98:
|
|
4133
|
-
_context39.
|
|
4163
|
+
_context39.prev = 98;
|
|
4164
|
+
_iterator3.f();
|
|
4165
|
+
return _context39.finish(98);
|
|
4166
|
+
case 101:
|
|
4167
|
+
_context39.next = 106;
|
|
4134
4168
|
break;
|
|
4135
|
-
case
|
|
4136
|
-
_context39.prev =
|
|
4137
|
-
_context39.t4 = _context39["catch"](
|
|
4169
|
+
case 103:
|
|
4170
|
+
_context39.prev = 103;
|
|
4171
|
+
_context39.t4 = _context39["catch"](82);
|
|
4138
4172
|
this.logWarning('标记支付项已同步失败(不阻塞主流程)', {
|
|
4139
4173
|
error: _context39.t4
|
|
4140
4174
|
});
|
|
4141
|
-
case
|
|
4175
|
+
case 106:
|
|
4142
4176
|
// 标记订单已同步
|
|
4143
4177
|
this.store.isOrderSynced = true;
|
|
4144
4178
|
|
|
@@ -4146,7 +4180,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4146
4180
|
this.clearCalculationCache();
|
|
4147
4181
|
|
|
4148
4182
|
// 触发订单同步完成事件
|
|
4149
|
-
_context39.next =
|
|
4183
|
+
_context39.next = 110;
|
|
4150
4184
|
return this.core.effects.emit("".concat(this.name, ":onOrderSynced"), {
|
|
4151
4185
|
orderUuid: this.store.currentOrder.uuid,
|
|
4152
4186
|
realOrderId: realOrderId,
|
|
@@ -4155,18 +4189,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4155
4189
|
isManual: isManual,
|
|
4156
4190
|
response: checkoutResponse
|
|
4157
4191
|
});
|
|
4158
|
-
case
|
|
4192
|
+
case 110:
|
|
4159
4193
|
return _context39.abrupt("return", {
|
|
4160
4194
|
success: true,
|
|
4161
4195
|
orderId: realOrderId,
|
|
4162
4196
|
orderUuid: this.store.currentOrder.uuid,
|
|
4163
4197
|
response: checkoutResponse
|
|
4164
4198
|
});
|
|
4165
|
-
case
|
|
4199
|
+
case 111:
|
|
4166
4200
|
case "end":
|
|
4167
4201
|
return _context39.stop();
|
|
4168
4202
|
}
|
|
4169
|
-
}, _callee39, this, [[
|
|
4203
|
+
}, _callee39, this, [[31, 40, 48, 52], [69, 77], [82, 103], [85, 95, 98, 101]]);
|
|
4170
4204
|
}));
|
|
4171
4205
|
function syncOrderToBackendWithReturn() {
|
|
4172
4206
|
return _syncOrderToBackendWithReturn.apply(this, arguments);
|
|
@@ -1623,9 +1623,11 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1623
1623
|
const allPaymentItems = await this.payment.getPaymentItemsAsync(
|
|
1624
1624
|
this.store.currentOrder.uuid
|
|
1625
1625
|
);
|
|
1626
|
+
const orderPaymentStatus = allPaymentItems.filter((item) => item.status !== "voided").length > 0 ? "partially_paid" : "payment_processing";
|
|
1626
1627
|
const syncResult = await this.syncOrderToBackendWithReturn(
|
|
1627
1628
|
true,
|
|
1628
|
-
allPaymentItems
|
|
1629
|
+
allPaymentItems,
|
|
1630
|
+
orderPaymentStatus
|
|
1629
1631
|
);
|
|
1630
1632
|
this.logInfo("保存订单完成:", {
|
|
1631
1633
|
orderUuid,
|
|
@@ -2356,7 +2358,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2356
2358
|
* @param customPaymentItems 自定义支付项列表,如果提供则使用此列表而不是从数据库获取
|
|
2357
2359
|
* @returns 包含订单ID、UUID和完整后端响应的对象
|
|
2358
2360
|
*/
|
|
2359
|
-
async syncOrderToBackendWithReturn(isManual = false, customPaymentItems) {
|
|
2361
|
+
async syncOrderToBackendWithReturn(isManual = false, customPaymentItems, paymentStatus) {
|
|
2360
2362
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2361
2363
|
if (!this.store.localOrderData || !this.store.currentOrder) {
|
|
2362
2364
|
throw new Error("缺少必要的订单数据,无法同步到后端");
|
|
@@ -2431,8 +2433,24 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2431
2433
|
finalDepositAmount,
|
|
2432
2434
|
isDeposit: ((_b = this.store.currentOrder) == null ? void 0 : _b.is_deposit) || 0
|
|
2433
2435
|
});
|
|
2436
|
+
let orderPaymentStatus = paymentStatus;
|
|
2437
|
+
if (!orderPaymentStatus) {
|
|
2438
|
+
const totalPaidAmount = processedPaymentItems.filter((item) => item.status !== "voided").reduce((sum, item) => {
|
|
2439
|
+
const amt = new import_decimal.default(item.amount || "0");
|
|
2440
|
+
const rounding = new import_decimal.default(item.rounding_amount || "0");
|
|
2441
|
+
return sum.plus(amt).sub(rounding);
|
|
2442
|
+
}, new import_decimal.default(0));
|
|
2443
|
+
if (totalPaidAmount.gte(new import_decimal.default(this.store.currentOrder.total_amount))) {
|
|
2444
|
+
orderPaymentStatus = "paid";
|
|
2445
|
+
} else if (totalPaidAmount.gt(0)) {
|
|
2446
|
+
orderPaymentStatus = "partially_paid";
|
|
2447
|
+
} else {
|
|
2448
|
+
orderPaymentStatus = "unpaid";
|
|
2449
|
+
}
|
|
2450
|
+
}
|
|
2434
2451
|
const orderParams = {
|
|
2435
2452
|
...this.store.localOrderData,
|
|
2453
|
+
payment_status: orderPaymentStatus,
|
|
2436
2454
|
type: this.store.localOrderData.type,
|
|
2437
2455
|
platform: this.store.localOrderData.platform,
|
|
2438
2456
|
payments: processedPaymentItems,
|