fix(admin-service): 修复钱包金额显示被除以10^8的问题
- decimalToString 改用 toString() 替代 toFixed(8) - Prisma Decimal 的 toFixed 会导致精度错误 - 删除调试日志代码 🤖 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
7176bbd5c2
commit
475acf71cc
|
|
@ -490,11 +490,16 @@ export class UserDetailQueryRepositoryImpl implements IUserDetailQueryRepository
|
|||
|
||||
/**
|
||||
* 将 Decimal 转为字符串,保留合理精度
|
||||
* 数据库存的是实际金额,直接格式化为最多 8 位小数
|
||||
* 使用 toString() 避免 Prisma Decimal 的 toFixed 精度问题
|
||||
*/
|
||||
private decimalToString(decimal: Decimal | null | undefined): string {
|
||||
if (!decimal) return '0';
|
||||
// 直接转字符串,去掉尾部多余的 0
|
||||
return decimal.toFixed(8).replace(/\.?0+$/, '');
|
||||
// 使用 toString() 获取原始值,去掉尾部多余的 0
|
||||
const str = decimal.toString();
|
||||
// 如果有小数点,去掉尾部的 0
|
||||
if (str.includes('.')) {
|
||||
return str.replace(/\.?0+$/, '');
|
||||
}
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue