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:
@@ -3,33 +3,33 @@ package wallet
|
||||
import "time"
|
||||
|
||||
type AccountDTO struct {
|
||||
UserID uint64 `json:"user_id"`
|
||||
AvailableBalance float64 `json:"available_balance"`
|
||||
FrozenBalance float64 `json:"frozen_balance"`
|
||||
Status string `json:"status"`
|
||||
UserID uint64 `json:"user_id"`
|
||||
AvailableBalanceCent int64 `json:"available_balance_cent"`
|
||||
FrozenBalanceCent int64 `json:"frozen_balance_cent"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
type RechargeRequest struct {
|
||||
Amount float64 `json:"amount" binding:"required"`
|
||||
AmountCent int64 `json:"amount_cent" binding:"required"`
|
||||
}
|
||||
|
||||
type WithdrawRequest struct {
|
||||
Amount float64 `json:"amount" binding:"required"`
|
||||
AmountCent int64 `json:"amount_cent" binding:"required"`
|
||||
}
|
||||
|
||||
type LedgerDTO struct {
|
||||
ID uint64 `json:"id"`
|
||||
LedgerNo string `json:"ledger_no"`
|
||||
UserID uint64 `json:"user_id"`
|
||||
OrderID *uint64 `json:"order_id"`
|
||||
Direction string `json:"direction"`
|
||||
Amount float64 `json:"amount"`
|
||||
BalanceAfter float64 `json:"balance_after"`
|
||||
BalanceType string `json:"balance_type"`
|
||||
BizType string `json:"biz_type"`
|
||||
BizNo string `json:"biz_no"`
|
||||
Remark string `json:"remark"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
ID uint64 `json:"id"`
|
||||
LedgerNo string `json:"ledger_no"`
|
||||
UserID uint64 `json:"user_id"`
|
||||
OrderID *uint64 `json:"order_id"`
|
||||
Direction string `json:"direction"`
|
||||
AmountCent int64 `json:"amount_cent"`
|
||||
BalanceAfterCent int64 `json:"balance_after_cent"`
|
||||
BalanceType string `json:"balance_type"`
|
||||
BizType string `json:"biz_type"`
|
||||
BizNo string `json:"biz_no"`
|
||||
Remark string `json:"remark"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
type AdminLedgerQuery struct {
|
||||
@@ -48,19 +48,19 @@ type PaginatedResult struct {
|
||||
}
|
||||
|
||||
type AdminLedgerDTO struct {
|
||||
ID uint64 `json:"id"`
|
||||
LedgerNo string `json:"ledger_no"`
|
||||
UserID uint64 `json:"user_id"`
|
||||
UserPhone string `json:"user_phone"`
|
||||
UserNickname string `json:"user_nickname"`
|
||||
OrderID *uint64 `json:"order_id"`
|
||||
OrderNo string `json:"order_no"`
|
||||
Direction string `json:"direction"`
|
||||
Amount float64 `json:"amount"`
|
||||
BalanceAfter float64 `json:"balance_after"`
|
||||
BalanceType string `json:"balance_type"`
|
||||
BizType string `json:"biz_type"`
|
||||
BizNo string `json:"biz_no"`
|
||||
Remark string `json:"remark"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
ID uint64 `json:"id"`
|
||||
LedgerNo string `json:"ledger_no"`
|
||||
UserID uint64 `json:"user_id"`
|
||||
UserPhone string `json:"user_phone"`
|
||||
UserNickname string `json:"user_nickname"`
|
||||
OrderID *uint64 `json:"order_id"`
|
||||
OrderNo string `json:"order_no"`
|
||||
Direction string `json:"direction"`
|
||||
AmountCent int64 `json:"amount_cent"`
|
||||
BalanceAfterCent int64 `json:"balance_after_cent"`
|
||||
BalanceType string `json:"balance_type"`
|
||||
BizType string `json:"biz_type"`
|
||||
BizNo string `json:"biz_no"`
|
||||
Remark string `json:"remark"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user