mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-11-25 15:23:25 +00:00
fix(payment): enhance fee rate input validation and UI
Backend: - Validate recharge_fee_rate: 0 ≤ rate ≤ 100, max 2 decimal places Frontend settings: - Add % suffix icon to fee rate input - Enforce max=100, min=0, step=0.01 with 2 decimal precision
This commit is contained in:
1 parent
e761d38fd1
commit
d149dbc91f
2 files changed
+11
-3
No files matched your search
@@ -272,8 +272,13 @@ func (s *PaymentConfigService) UpdatePaymentConfig(ctx context.Context, req Upda
|
||||
}
|
||||
}
|
||||
if req.RechargeFeeRate != nil {
|
||||
if math.IsNaN(*req.RechargeFeeRate) || math.IsInf(*req.RechargeFeeRate, 0) || *req.RechargeFeeRate < 0 {
|
||||
return infraerrors.BadRequest("INVALID_RECHARGE_FEE_RATE", "recharge fee rate must be >= 0")
|
||||
v := *req.RechargeFeeRate
|
||||
if math.IsNaN(v) || math.IsInf(v, 0) || v < 0 || v > 100 {
|
||||
return infraerrors.BadRequest("INVALID_RECHARGE_FEE_RATE", "recharge fee rate must be between 0 and 100")
|
||||
}
|
||||
// Enforce max 2 decimal places
|
||||
if math.Round(v*100) != v*100 {
|
||||
return infraerrors.BadRequest("INVALID_RECHARGE_FEE_RATE", "recharge fee rate allows at most 2 decimal places")
|
||||
}
|
||||
}
|
||||
m := map[string]string{
|
||||
|
||||
Reference in new issue
Block a user