From fa7b45ec2faca45fc3a30733fcf93d7016539e4b Mon Sep 17 00:00:00 2001 From: hailin Date: Wed, 7 Jan 2026 03:01:52 -0800 Subject: [PATCH] =?UTF-8?q?fix(wallet-service,=20admin-web):=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E7=B3=BB=E7=BB=9F=E8=B4=A6=E6=88=B7=E5=88=92=E8=BD=AC?= =?UTF-8?q?=E9=87=91=E9=A2=9D=E7=B1=BB=E5=9E=8B=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - wallet-service: 支持 amount 为字符串或数字类型,添加类型转换 - admin-web: 改进错误处理,正确提取 Axios 错误消息 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../src/api/controllers/system-withdrawal.controller.ts | 9 ++++++--- .../src/app/(dashboard)/system-transfer/page.tsx | 7 +++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/backend/services/wallet-service/src/api/controllers/system-withdrawal.controller.ts b/backend/services/wallet-service/src/api/controllers/system-withdrawal.controller.ts index 809957f3..86281cb6 100644 --- a/backend/services/wallet-service/src/api/controllers/system-withdrawal.controller.ts +++ b/backend/services/wallet-service/src/api/controllers/system-withdrawal.controller.ts @@ -28,7 +28,7 @@ import { SystemWithdrawalApplicationService } from '@/application/services'; class SystemWithdrawalRequestDTO { fromAccountSequence: string; toAccountSequence: string; - amount: number; + amount: number | string; // 支持字符串或数字 memo?: string; operatorId: string; operatorName?: string; @@ -106,7 +106,10 @@ export class SystemWithdrawalController { if (!dto.toAccountSequence) { 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'); } if (!dto.operatorId) { @@ -116,7 +119,7 @@ export class SystemWithdrawalController { const result = await this.systemWithdrawalService.requestSystemWithdrawal({ fromAccountSequence: dto.fromAccountSequence, toAccountSequence: dto.toAccountSequence, - amount: dto.amount, + amount: amount, memo: dto.memo, operatorId: dto.operatorId, operatorName: dto.operatorName, diff --git a/frontend/admin-web/src/app/(dashboard)/system-transfer/page.tsx b/frontend/admin-web/src/app/(dashboard)/system-transfer/page.tsx index ce498cdb..070e6ea3 100644 --- a/frontend/admin-web/src/app/(dashboard)/system-transfer/page.tsx +++ b/frontend/admin-web/src/app/(dashboard)/system-transfer/page.tsx @@ -117,8 +117,11 @@ export default function SystemTransferPage() { setFormErrors({}); // 切换到订单列表查看 setActiveTab('orders'); - } catch (err) { - toast.error((err as Error).message || '划转失败'); + } catch (err: unknown) { + // 从 Axios 错误中提取消息 + const axiosError = err as { response?: { data?: { message?: string } }; message?: string }; + const errorMessage = axiosError.response?.data?.message || axiosError.message || '划转失败'; + toast.error(errorMessage); } };