Wallet与Withdrawal模块:完成分字段重构

核心改造:
1. Wallet模块DTO层全部改为*Cent int64字段
2. Wallet.Entry结构从Amount float64改为AmountCent int64
3. Repository层applyEntry函数使用整数加减,无需浮点运算
4. Withdrawal模块DTO/Request全部改为*Cent字段
5. 所有wallet.AppendEntries调用点改为AmountCent
6. 提现手续费计算改为分单位

技术细节:
- 删除了roundWalletMoney函数(不再需要)
- toAccountDTO/toLedgerDTO使用*Cent字段
- 最小提现金额:10元=1000分
- 最大提现金额:5000元=500000分
- 编译验证通过 

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
yml
2026-06-09 13:44:20 +08:00
co-authored by Claude Opus 4.8
parent e2780ffb86
commit 01909ee7e5
6 changed files with 142 additions and 147 deletions
+21 -21
View File
@@ -6,22 +6,22 @@ import (
// 用户端 DTO
type WithdrawalDTO struct {
ID uint64 `json:"id"`
WithdrawNo string `json:"withdraw_no"`
UserID uint64 `json:"user_id"`
Amount float64 `json:"amount"`
Fee float64 `json:"fee"`
ActualAmount float64 `json:"actual_amount"`
AccountType string `json:"account_type"`
AccountName string `json:"account_name"`
AccountNo string `json:"account_no"` // 脱敏
BankName string `json:"bank_name"`
Status string `json:"status"`
ReviewRemark string `json:"review_remark"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ReviewedAt *time.Time `json:"reviewed_at"`
PaidAt *time.Time `json:"paid_at"`
ID uint64 `json:"id"`
WithdrawNo string `json:"withdraw_no"`
UserID uint64 `json:"user_id"`
AmountCent int64 `json:"amount_cent"`
FeeCent int64 `json:"fee_cent"`
ActualAmountCent int64 `json:"actual_amount_cent"`
AccountType string `json:"account_type"`
AccountName string `json:"account_name"`
AccountNo string `json:"account_no"` // 脱敏
BankName string `json:"bank_name"`
Status string `json:"status"`
ReviewRemark string `json:"review_remark"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ReviewedAt *time.Time `json:"reviewed_at"`
PaidAt *time.Time `json:"paid_at"`
}
// 管理员端详细 DTO
@@ -31,9 +31,9 @@ type WithdrawalDetailDTO struct {
UserID uint64 `json:"user_id"`
UserNickname string `json:"user_nickname"`
UserPhone string `json:"user_phone"`
Amount float64 `json:"amount"`
Fee float64 `json:"fee"`
ActualAmount float64 `json:"actual_amount"`
AmountCent int64 `json:"amount_cent"`
FeeCent int64 `json:"fee_cent"`
ActualAmountCent int64 `json:"actual_amount_cent"`
PaymentAccountID *uint64 `json:"payment_account_id"`
AccountType string `json:"account_type"`
AccountName string `json:"account_name"`
@@ -56,8 +56,8 @@ type WithdrawalDetailDTO struct {
}
type CreateWithdrawalRequest struct {
PaymentAccountID uint64 `json:"payment_account_id" binding:"required"`
Amount float64 `json:"amount" binding:"required,gt=0"`
PaymentAccountID uint64 `json:"payment_account_id" binding:"required"`
AmountCent int64 `json:"amount_cent" binding:"required,gt=0"`
}
type ReviewWithdrawalRequest struct {