fix(wallet-service, admin-web): 修复系统账户划转金额类型问题
- wallet-service: 支持 amount 为字符串或数字类型,添加类型转换 - admin-web: 改进错误处理,正确提取 Axios 错误消息 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
1b237778ee
commit
fa7b45ec2f
|
|
@ -28,7 +28,7 @@ import { SystemWithdrawalApplicationService } from '@/application/services';
|
||||||
class SystemWithdrawalRequestDTO {
|
class SystemWithdrawalRequestDTO {
|
||||||
fromAccountSequence: string;
|
fromAccountSequence: string;
|
||||||
toAccountSequence: string;
|
toAccountSequence: string;
|
||||||
amount: number;
|
amount: number | string; // 支持字符串或数字
|
||||||
memo?: string;
|
memo?: string;
|
||||||
operatorId: string;
|
operatorId: string;
|
||||||
operatorName?: string;
|
operatorName?: string;
|
||||||
|
|
@ -106,7 +106,10 @@ export class SystemWithdrawalController {
|
||||||
if (!dto.toAccountSequence) {
|
if (!dto.toAccountSequence) {
|
||||||
throw new BadRequestException('接收账户不能为空');
|
throw new BadRequestException('接收账户不能为空');
|
||||||
}
|
}
|
||||||
if (!dto.amount || dto.amount <= 0) {
|
|
||||||
|
// 将 amount 转换为数字(前端可能传入字符串)
|
||||||
|
const amount = typeof dto.amount === 'string' ? parseFloat(dto.amount) : dto.amount;
|
||||||
|
if (!amount || isNaN(amount) || amount <= 0) {
|
||||||
throw new BadRequestException('转出金额必须大于0');
|
throw new BadRequestException('转出金额必须大于0');
|
||||||
}
|
}
|
||||||
if (!dto.operatorId) {
|
if (!dto.operatorId) {
|
||||||
|
|
@ -116,7 +119,7 @@ export class SystemWithdrawalController {
|
||||||
const result = await this.systemWithdrawalService.requestSystemWithdrawal({
|
const result = await this.systemWithdrawalService.requestSystemWithdrawal({
|
||||||
fromAccountSequence: dto.fromAccountSequence,
|
fromAccountSequence: dto.fromAccountSequence,
|
||||||
toAccountSequence: dto.toAccountSequence,
|
toAccountSequence: dto.toAccountSequence,
|
||||||
amount: dto.amount,
|
amount: amount,
|
||||||
memo: dto.memo,
|
memo: dto.memo,
|
||||||
operatorId: dto.operatorId,
|
operatorId: dto.operatorId,
|
||||||
operatorName: dto.operatorName,
|
operatorName: dto.operatorName,
|
||||||
|
|
|
||||||
|
|
@ -117,8 +117,11 @@ export default function SystemTransferPage() {
|
||||||
setFormErrors({});
|
setFormErrors({});
|
||||||
// 切换到订单列表查看
|
// 切换到订单列表查看
|
||||||
setActiveTab('orders');
|
setActiveTab('orders');
|
||||||
} catch (err) {
|
} catch (err: unknown) {
|
||||||
toast.error((err as Error).message || '划转失败');
|
// 从 Axios 错误中提取消息
|
||||||
|
const axiosError = err as { response?: { data?: { message?: string } }; message?: string };
|
||||||
|
const errorMessage = axiosError.response?.data?.message || axiosError.message || '划转失败';
|
||||||
|
toast.error(errorMessage);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue