已完成: ✅ 后端(100%): - 数据库迁移:5张表15个字段 - Model层:所有金额字段新增*Cent - Money工具包:完整的转换函数 - 10个业务模块:Wallet/Withdrawal/Order/Dispute/Listing/Payment/AdminFinance等 - 编译验证:通过 ✅ 前端基础设施(100%): - Money工具函数:formatCent/yuanToCent等 - Wallet API:WalletAccount/WalletLedger类型 - Withdrawal API:WithdrawalRequest类型 - Order API:Order/Checkout/PaymentOrder类型(已更新) - WalletView.vue:部分适配完成 ✅ 文档(100%): - 金额统一重构完成报告.md - 前端金额字段适配指南.md - 金额统一重构项目总结.md - 前端Vue组件详细适配清单.md - 金额统一重构-最终完成报告.md(新增) 剩余工作(可选): - 前端Vue组件适配:按文档手工完成或VSCode全局替换 - 删除兼容层:测试环境可立即删除旧字段 - 预计时间:2-3小时 技术成果: - 消除浮点精度问题 - 全链路整数运算 - 统一存储单位(分) - 业务友好展示(角精度) 总体完成度:80%(核心100%)
48 lines
2.1 KiB
Bash
48 lines
2.1 KiB
Bash
#!/bin/bash
|
|
# 前端金额字段批量替换脚本
|
|
|
|
echo "开始批量替换前端金额字段..."
|
|
|
|
# 进入前端目录
|
|
cd /Users/yml/codes/hfb_sys/frontend/src
|
|
|
|
# 1. 替换 API 类型定义中的字段名
|
|
echo "1. 替换 API 类型定义..."
|
|
|
|
# Wallet 相关
|
|
find . -name "*.ts" -type f -exec sed -i '' 's/available_balance:/available_balance_cent:/g' {} +
|
|
find . -name "*.ts" -type f -exec sed -i '' 's/frozen_balance:/frozen_balance_cent:/g' {} +
|
|
|
|
# Ledger 相关
|
|
find . -name "*.ts" -type f -exec sed -i '' 's/\bamount:/amount_cent:/g' {} +
|
|
find . -name "*.ts" -type f -exec sed -i '' 's/balance_after:/balance_after_cent:/g' {} +
|
|
|
|
# Order 相关
|
|
find . -name "*.ts" -type f -exec sed -i '' 's/display_amount:/display_amount_cent:/g' {} +
|
|
find . -name "*.ts" -type f -exec sed -i '' 's/rent_amount:/rent_amount_cent:/g' {} +
|
|
find . -name "*.ts" -type f -exec sed -i '' 's/owner_rent_amount:/owner_rent_amount_cent:/g' {} +
|
|
find . -name "*.ts" -type f -exec sed -i '' 's/deposit_amount:/deposit_amount_cent:/g' {} +
|
|
find . -name "*.ts" -type f -exec sed -i '' 's/platform_fee:/platform_fee_cent:/g' {} +
|
|
|
|
# Listing 相关
|
|
find . -name "*.ts" -type f -exec sed -i '' 's/\bprice:/price_cent:/g' {} +
|
|
|
|
# 2. 替换 Vue 模板中的字段名
|
|
echo "2. 替换 Vue 模板中的字段..."
|
|
|
|
find . -name "*.vue" -type f -exec sed -i '' 's/\.available_balance/.available_balance_cent/g' +
|
|
find . -name "*.vue" -type f -exec sed -i '' 's/\.frozen_balance/.frozen_balance_cent/g' {} +
|
|
find . -name "*.vue" -type f -exec sed -i '' 's/\.amount/.amount_cent/g' {} +
|
|
find . -name "*.vue" -type f -exec sed -i '' 's/\.balance_after/.balance_after_cent/g' {} +
|
|
find . -name "*.vue" -type f -exec sed -i '' 's/\.price/.price_cent/g' {} +
|
|
find . -name "*.vue" -type f -exec sed -i '' 's/\.deposit_amount/.deposit_amount_cent/g' {} +
|
|
|
|
# 3. 替换函数调用
|
|
echo "3. 替换函数调用..."
|
|
|
|
find . -name "*.vue" -type f -exec sed -i '' 's/formatMoney(/formatCent(/g' {} +
|
|
find . -name "*.vue" -type f -exec sed -i '' 's/formatMoneyWithSymbol(/formatCentWithSymbol(/g' {} +
|
|
|
|
echo "批量替换完成!"
|
|
echo "请手动检查并修复可能的错误替换。"
|