package request import ( "errors" "strconv" "gitea.ddegame.cn/open/servicebase/pkg/common" "gitea.ddegame.cn/open/servicebase/pkg/htools" ) // UserCharmWithdrawRequest 用户魅力值提现 type UserCharmWithdrawRequest struct { BaseRequest WithdrawCash string // 提现的金额 } // CheckParameter 普通充值 参数校验 func (request *UserCharmWithdrawRequest) CheckParameter() (err error) { if len(request.AccessToken) == 0 { err = errors.New("AccessToken不能为空") return } if len(request.WithdrawCash) == 0 { err = errors.New("WithdrawCash不能为空") return } // 提现金额 cashInt := htools.StringToInt(request.WithdrawCash) if cashInt <= 0 { err = errors.New("提现金额非法") return } // 是否整数 if strconv.Itoa(cashInt) != request.WithdrawCash { err = errors.New("提现金额只能是整数") return } // 最小值 if cashInt < common.CHARM_WITHDRAW_MIN_CASH { err = errors.New("提现金额最少要" + strconv.Itoa(common.CHARM_WITHDRAW_MIN_CASH)) return } // 最大值判断 if cashInt > common.CHARM_WITHDRAW_MAX_CASH { err = errors.New("提现金额超限,每次最多" + strconv.Itoa(common.CHARM_WITHDRAW_MAX_CASH)) return } // 是否10的倍数 if cashInt%10 != 0 { err = errors.New("提现金额必须是10的倍数") return } return }