优化支付退款钱包链路
This commit is contained in:
@@ -6,6 +6,8 @@ var (
|
||||
ErrDependencyUnavailable = errors.New("dependency unavailable")
|
||||
ErrInvalidAmount = errors.New("invalid amount")
|
||||
ErrInsufficientBalance = errors.New("insufficient balance")
|
||||
ErrFeaturePending = errors.New("feature pending")
|
||||
ErrRechargeDisabled = errors.New("wallet recharge disabled")
|
||||
)
|
||||
|
||||
const MinRechargeAmount = 0.01
|
||||
@@ -36,10 +38,14 @@ func (s *Service) Recharge(userID uint64, req RechargeRequest) (*AccountDTO, err
|
||||
if s.repo == nil {
|
||||
return nil, ErrDependencyUnavailable
|
||||
}
|
||||
if req.Amount < MinRechargeAmount {
|
||||
return nil, ErrInvalidAmount
|
||||
return nil, ErrRechargeDisabled
|
||||
}
|
||||
|
||||
func (s *Service) Withdraw(userID uint64, req WithdrawRequest) (*AccountDTO, error) {
|
||||
if s.repo == nil {
|
||||
return nil, ErrDependencyUnavailable
|
||||
}
|
||||
return s.repo.Recharge(userID, req.Amount)
|
||||
return nil, ErrFeaturePending
|
||||
}
|
||||
|
||||
func (s *Service) AdminLedger(query AdminLedgerQuery) (*PaginatedResult, error) {
|
||||
|
||||
Reference in New Issue
Block a user