55 lines
1.3 KiB
Go
55 lines
1.3 KiB
Go
package request
|
|
|
|
import (
|
|
"errors"
|
|
"strconv"
|
|
|
|
"gitea.ddegame.cn/open/servicebase/pkg/common"
|
|
"gitea.ddegame.cn/open/servicebase/pkg/htools"
|
|
)
|
|
|
|
// UserNCoinWithdrawRequest 用户魅力值提现
|
|
type UserNCoinWithdrawRequest struct {
|
|
BaseRequest
|
|
WithdrawCash string // 提现的金额
|
|
}
|
|
|
|
// CheckParameter 普通充值 参数校验
|
|
func (request *UserNCoinWithdrawRequest) 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.NCoin_WITHDRAW_MIN_CASH {
|
|
err = errors.New("提现金额最少要" + strconv.Itoa(common.CHARM_WITHDRAW_MIN_CASH))
|
|
return
|
|
}
|
|
// 最大值判断
|
|
if cashInt > common.NCoin_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
|
|
}
|