完善租客等级免押与积分管理
This commit is contained in:
@@ -17,11 +17,16 @@ var (
|
||||
ErrInvalidWalletAmount = errors.New("invalid wallet amount")
|
||||
ErrInvalidWalletReason = errors.New("invalid wallet reason")
|
||||
ErrInsufficientBalance = errors.New("insufficient balance")
|
||||
ErrInvalidGrowthPoints = errors.New("invalid growth points")
|
||||
ErrInvalidGrowthReason = errors.New("invalid growth reason")
|
||||
ErrGrowthPointsUnchanged = errors.New("growth points unchanged")
|
||||
)
|
||||
|
||||
// 单笔人工调账上限:10 万元,防止误填。
|
||||
const maxWalletAdjustAmountCent int64 = 10_000_000
|
||||
|
||||
const maxRenterGrowthPoints int64 = 1_000_000_000
|
||||
|
||||
var manualRealnameIDPattern = regexp.MustCompile(`^\d{17}[\dXx]$`)
|
||||
|
||||
type Service struct {
|
||||
@@ -69,6 +74,21 @@ func (s *Service) SetDepositFreeQuota(ctx context.Context, adminID uint64, userI
|
||||
return s.repo.SetDepositFreeQuota(ctx, adminID, userID, req, meta)
|
||||
}
|
||||
|
||||
func (s *Service) AdjustGrowthPoints(ctx context.Context, adminID uint64, userID uint64, req GrowthPointsAdjustRequest, meta AuditMeta) (*UserDTO, error) {
|
||||
if s.repo == nil {
|
||||
return nil, ErrDependencyUnavailable
|
||||
}
|
||||
if userID == 0 || req.TargetPoints < 0 || req.TargetPoints > maxRenterGrowthPoints {
|
||||
return nil, ErrInvalidGrowthPoints
|
||||
}
|
||||
reason := strings.TrimSpace(req.Reason)
|
||||
if reasonLen := len([]rune(reason)); reasonLen < 2 || reasonLen > 200 {
|
||||
return nil, ErrInvalidGrowthReason
|
||||
}
|
||||
req.Reason = reason
|
||||
return s.repo.AdjustGrowthPoints(ctx, adminID, userID, req, meta)
|
||||
}
|
||||
|
||||
func (s *Service) RevokeRealname(ctx context.Context, adminID uint64, userID uint64, req RevokeRealnameRequest, meta AuditMeta) (*UserDTO, error) {
|
||||
if s.repo == nil {
|
||||
return nil, ErrDependencyUnavailable
|
||||
|
||||
Reference in New Issue
Block a user