印度包网
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

111 lines
2.9 KiB

package app
import (
"fmt"
"github.com/liangdas/mqant/log"
"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
}
con := call.GetVipCon(g.UID)
if con == nil {
g.Code = values.CodeWithdrawCondition
return
}
vip := call.GetVIP(g.UID)
if vip.Level == 0 && con.WithdrawCount == 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)
withdrawAmount := re.DayWithdraw + amount
withdrawCount := re.WithdrawCount
if con.Level == 0 {
withdrawAmount = re.TotalWithdraw + amount
withdrawCount = int(re.TotalWithdrawCount)
}
if withdrawAmount >= int64(con.WithdrawAmount) {
g.Code = values.CodeWithdrawLimit
g.Msg = "Clearance amount has reached"
if vip.Level > 0 {
g.Msg += " today!"
}
return
}
if withdrawCount >= con.WithdrawCount {
g.Code = values.CodeWithdrawLimit
g.Msg = "Clearance count has reached"
if vip.Level > 0 {
g.Msg += " today!"
}
return
}
ok = true
return
}
// CanBuyProduct 判断是否满足可以购买该商品
func (g *Gin) CanBuyProduct(actID, pid int) (can bool, product *common.ConfigPayProduct) {
if actID == 0 {
return
}
productList := call.GetConfigPayProductByActivityID(actID)
if len(productList) == 0 {
log.Debug("get activity[%d] product is nil", 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
}
case common.ActivityIDWeekCard:
configWeekCard := call.GetConfigWeekCard()
if configWeekCard == nil {
return
}
weekCardData, err := call.GetWeekCardData(g.UID)
if err != nil {
return
}
if weekCardData.BeginAt > 0 { // 还在周期中,不能购买
return
}
for _, v := range productList {
if configWeekCard.Amount*common.DecimalDigits == v.Amount {
can = true
product = v
return
}
}
}
return
}