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:
@@ -14,9 +14,9 @@ var (
|
||||
)
|
||||
|
||||
const (
|
||||
MinWithdrawalAmount = 10.0 // 最低提现金额
|
||||
MaxWithdrawalAmount = 5000.0 // 单笔最高提现金额
|
||||
WithdrawalFeeRate = 0.0 // 手续费率(暂时0%)
|
||||
MinWithdrawalAmountCent = 1000 // 最低提现金额:10元 = 1000分
|
||||
MaxWithdrawalAmountCent = 500000 // 单笔最高提现金额:5000元 = 500000分
|
||||
WithdrawalFeeRate = 0.0 // 手续费率(暂时0%)
|
||||
)
|
||||
|
||||
type Service struct {
|
||||
@@ -34,10 +34,10 @@ func (s *Service) Create(userID uint64, req CreateWithdrawalRequest) (*Withdrawa
|
||||
}
|
||||
|
||||
// 验证金额
|
||||
if req.Amount < MinWithdrawalAmount {
|
||||
if req.AmountCent < MinWithdrawalAmountCent {
|
||||
return nil, ErrMinWithdrawalAmount
|
||||
}
|
||||
if req.Amount > MaxWithdrawalAmount {
|
||||
if req.AmountCent > MaxWithdrawalAmountCent {
|
||||
return nil, ErrMaxWithdrawalAmount
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user