|
|
@@ -28,13 +28,27 @@ func CheckWithdraw(c *gin.Context, amount string) (err error, realAmount, fee st |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
//2、判断是否为第一次提现 |
|
|
|
var isCompleteFirstWithdraw bool |
|
|
|
has, err := db.Db.Where("uid = ? and ", user.Id). |
|
|
|
And("uid =?", user.Id). |
|
|
|
Get(model.FinWithdrawApply{}) |
|
|
|
if has { //第一次提现 |
|
|
|
isFirst = true |
|
|
|
var firstWithdrawSet md.FirstWithdrawSet |
|
|
|
utils.Unserialize([]byte(withdrawSetting.FrequencySet), &firstWithdrawSet) |
|
|
|
if firstWithdrawSet.IsNeedRealName == 0 && firstWithdrawSet.FirstWithdrawAmountLimit >= amount { |
|
|
|
isCompleteFirstWithdraw = true |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//2、判断“是否实名” |
|
|
|
if withdrawSetting.IsRealName == 1 && user.IsRealName != 1 { |
|
|
|
if isCompleteFirstWithdraw && withdrawSetting.IsRealName == 1 && user.IsRealName != 1 { |
|
|
|
return errors.New("非实名用户不可提现"), realAmount, fee, isAuto, isFirst |
|
|
|
} |
|
|
|
|
|
|
|
//3、判断“提现金额” |
|
|
|
if utils.StrToFloat64(withdrawSetting.WithdrawAmountLimit) > 0 { |
|
|
|
if isCompleteFirstWithdraw && utils.StrToFloat64(withdrawSetting.WithdrawAmountLimit) > 0 { |
|
|
|
withdrawAmountLimitValue, _ := decimal.NewFromString(withdrawSetting.WithdrawAmountLimit) |
|
|
|
if amountValue.GreaterThan(withdrawAmountLimitValue) { |
|
|
|
return errors.New("非可提现金额"), realAmount, fee, isAuto, isFirst |
|
|
@@ -42,7 +56,7 @@ func CheckWithdraw(c *gin.Context, amount string) (err error, realAmount, fee st |
|
|
|
} |
|
|
|
|
|
|
|
//4、判断“提现倍数” |
|
|
|
if utils.StrToFloat64(withdrawSetting.WithdrawMultipleLimit) > 0 { |
|
|
|
if isCompleteFirstWithdraw && utils.StrToFloat64(withdrawSetting.WithdrawMultipleLimit) > 0 { |
|
|
|
result := utils.StrToFloat64(amount) / utils.StrToFloat64(withdrawSetting.WithdrawMultipleLimit) |
|
|
|
// 检查结果是否非常接近一个整数 |
|
|
|
roundedResult := math.Round(result) |
|
|
@@ -52,12 +66,12 @@ func CheckWithdraw(c *gin.Context, amount string) (err error, realAmount, fee st |
|
|
|
} |
|
|
|
|
|
|
|
//5、验证会员等级 |
|
|
|
if withdrawSetting.VipLevelLimit > 0 && withdrawSetting.VipLevelLimit > user.Level { |
|
|
|
if isCompleteFirstWithdraw && withdrawSetting.VipLevelLimit > 0 && withdrawSetting.VipLevelLimit > user.Level { |
|
|
|
return errors.New("非可提现会员等级"), realAmount, fee, isAuto, isFirst |
|
|
|
} |
|
|
|
|
|
|
|
//6、 验证小数点 |
|
|
|
if withdrawSetting.IsSupportDecimalPoint == 0 && strings.Contains(amount, ".") { |
|
|
|
if isCompleteFirstWithdraw && withdrawSetting.IsSupportDecimalPoint == 0 && strings.Contains(amount, ".") { |
|
|
|
return errors.New("不支持的提现金额"), realAmount, fee, isAuto, isFirst |
|
|
|
} |
|
|
|
|
|
|
@@ -151,14 +165,6 @@ func CheckWithdraw(c *gin.Context, amount string) (err error, realAmount, fee st |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//11、判断是否为第一次提现 |
|
|
|
has, err := db.Db.Where("uid = ? and ", user.Id). |
|
|
|
And("uid =?", user.Id). |
|
|
|
Get(model.FinWithdrawApply{}) |
|
|
|
if has { |
|
|
|
isFirst = true |
|
|
|
} |
|
|
|
|
|
|
|
if utils.StrToFloat64(realAmount) <= 0 { |
|
|
|
return errors.New("当前提现金额有误"), realAmount, fee, isAuto, isFirst |
|
|
|
} |
|
|
|