package app
import (
"fmt"
"server/call"
"server/common"
"server/db"
"server/modules/web/values"
"server/util"
)
// CheckWithdrawCondition 判断是否满足退出的配置条件
func ( g * Gin ) CheckWithdrawCondition ( amount int64 , t common . CurrencyType ) ( ok bool ) {
down , up := call . GetConfigWithdrawLimits ( )
if amount < down || amount > up {
g . Code = values . CodeWithdrawCondition
g . Msg = fmt . Sprintf ( "The amount entered should be between $%s and %s." , util . FormatNumberBrazil ( float64 ( down ) / common . DecimalDigits ) , util . FormatNumberBrazil ( float64 ( up ) / common . DecimalDigits ) )
return
}
// 拉取当前所需下注
bet := call . GetUserNeedBet ( g . UID )
if bet > 0 {
g . Code = values . CodeWithdrawConditionBet
g . Msg = "You have not completed the required bets yet. Before making an extraction it should be done."
return
}
vip := call . GetVIP ( g . UID )
if vip . Level == 0 {
var limit int64 = 20
if con := call . GetConfigVIPByLevel ( 1 ) ; con != nil {
limit = con . Exp / common . DecimalDigits
}
g . Code = values . CodeWithdrawConditionVip
g . Msg = fmt . Sprintf ( "Insufficient VIP levels your topup amount ($%d to become vip1 and be able to withdraw your money." , limit )
return
}
re := call . GetRechargeInfo ( g . UID )
con := call . GetVipCon ( g . UID )
if con == nil {
g . Code = values . CodeWithdrawCondition
return
}
if re . DayWithdraw + amount >= int64 ( con . WithdrawAmount ) {
g . Code = values . CodeWithdrawLimit
g . Msg = "Clearance amount has reached today!"
return
}
if re . WithdrawCount >= con . WithdrawCount {
g . Code = values . CodeWithdrawLimit
g . Msg = "Clearance count has reached today!"
return
}
ok = true
return
}
// CanBuyProduct 判断是否满足可以购买该商品
func ( g * Gin ) CanBuyProduct ( actID , pid int ) ( can bool ) {
if actID == 0 || actID < common . ProductTypeAll {
return true
}
if ! g . CheckActivityExpire ( actID ) {
return
}
switch actID {
case common . ActivityIDRecharge :
one := & common . RechargeInfo { UID : g . UID }
db . Mysql ( ) . Get ( one )
if common . GetProductPayCount ( one . ProductPayCount , pid ) >= 1 {
g . Code = values . CodeBuyLimit
return
}
}
return true
}