|
|
|
|
@ -103,16 +103,29 @@ func GetVipInfo(c *gin.Context) { |
|
|
|
|
q.Filter(elastic.NewTermQuery("uid", a.UID)) |
|
|
|
|
q.Filter(elastic.NewTermQuery("event", common.CurrencyEventVIPCashback)) |
|
|
|
|
resp.TotalCashback = db.ES().SumByInt64(common.ESIndexBalance, "value", q) |
|
|
|
|
// db.ES().QueryList(common.ESIndexBalance, req.Page, req.Num, q, &resp.CashbackList, "time", false)
|
|
|
|
|
num := 0 |
|
|
|
|
if resp.Info.Cashback > 0 { |
|
|
|
|
num = 1 |
|
|
|
|
db.ES().QueryList(common.ESIndexBalance, req.Page, req.Num, q, &resp.CashbackList, "time", false) |
|
|
|
|
reset = !util.IsSameDayTimeStamp(now.Unix(), resp.Info.ProfitTime) |
|
|
|
|
if reset && resp.Info.Cashback > 0 { |
|
|
|
|
call.PushRed(a.UID, pb.RedPointModule_RedPointVipCashback, uint32(1)) |
|
|
|
|
} |
|
|
|
|
if num > 0 { |
|
|
|
|
call.PushRed(a.UID, pb.RedPointModule_RedPointVipCashback, uint32(num)) |
|
|
|
|
if hasVipBonus(resp.Info) { |
|
|
|
|
call.PushRed(a.UID, pb.RedPointModule_RedPointVipReward, uint32(1)) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func hasVipBonus(vip *common.VipData) bool { |
|
|
|
|
// 遍历所有VIP级别
|
|
|
|
|
for level := 1; level <= vip.Level; level++ { |
|
|
|
|
// 计算标志位
|
|
|
|
|
flag := int64(1 << level) |
|
|
|
|
// 检查该级别的奖励是否已经领取
|
|
|
|
|
if vip.Draws&flag == 0 { |
|
|
|
|
return true |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func DrawVipBonus(c *gin.Context) { |
|
|
|
|
a := app.NewApp(c) |
|
|
|
|
defer func() { |
|
|
|
|
@ -139,7 +152,7 @@ func DrawVipBonus(c *gin.Context) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
flag := int64(1 << req.Level) |
|
|
|
|
if vip.Draws&int64(flag) > 0 { |
|
|
|
|
if vip.Draws&flag > 0 { |
|
|
|
|
a.Code = values.CodeParam |
|
|
|
|
a.Msg = "reward has been claimed" |
|
|
|
|
return |
|
|
|
|
@ -183,7 +196,7 @@ func DrawVipBonus(c *gin.Context) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
vip = call.GetVIP(a.UID) |
|
|
|
|
if vip.Draws == 0 { |
|
|
|
|
if !hasVipBonus(vip) { |
|
|
|
|
call.PushRed(a.UID, pb.RedPointModule_RedPointVipReward, uint32(0)) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|