From 8179cbcdd6715509adb0b5b9c22ae0060bbd0752 Mon Sep 17 00:00:00 2001 From: mofangmin Date: Thu, 8 Aug 2024 10:13:05 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BA=A2=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/web/handler/account.go | 6 ------ modules/web/handler/task.go | 2 -- modules/web/handler/user.go | 3 +++ modules/web/handler/vip.go | 29 +++++++++++++++++++++-------- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/modules/web/handler/account.go b/modules/web/handler/account.go index ea45b0f..d3b7084 100644 --- a/modules/web/handler/account.go +++ b/modules/web/handler/account.go @@ -1,14 +1,12 @@ package handler import ( - "fmt" "server/call" "server/common" "server/config" "server/db" "server/modules/web/app" "server/modules/web/values" - "server/pb" "server/util" "time" @@ -103,10 +101,6 @@ func onLogin(user *common.PlayerDBInfo, a *app.Gin, isNew bool) { } call.InsertLoginRecord(uid, cid, ip, birth, deviceType) - // 第二次登录 - if db.Mysql().Count(&common.LoginRecord{}, fmt.Sprintf(" uid = %d", uid)) == 1 { - call.PushRed(uid, pb.RedPointModule_RedPointLoginAgain, 1) - } // if db.Mysql().CountTable(common.PlayerRechargeTableName, fmt.Sprintf("uid = %d", uid)) == 0 { // db.Mysql().C().Table(common.PlayerRechargeTableName).Create(&common.PlayerCurrency{UID: uid, ChannelID: cid}) // } diff --git a/modules/web/handler/task.go b/modules/web/handler/task.go index 97fb100..a0e107c 100644 --- a/modules/web/handler/task.go +++ b/modules/web/handler/task.go @@ -98,7 +98,6 @@ func DrawTask(c *gin.Context) { } TaskComplete(a, req) a.Data = req - num := 0 for _, task := range GetUserTaskStatus(a) { if task.Status == 1 { @@ -106,5 +105,4 @@ func DrawTask(c *gin.Context) { } } call.PushRed(a.UID, pb.RedPointModule_RedPointTask, uint32(num)) - } diff --git a/modules/web/handler/user.go b/modules/web/handler/user.go index 09bf20d..d538547 100644 --- a/modules/web/handler/user.go +++ b/modules/web/handler/user.go @@ -9,6 +9,7 @@ import ( "server/db" "server/modules/web/app" "server/modules/web/values" + "server/pb" "server/util" "time" @@ -279,6 +280,7 @@ func CheckRedPoint(uid int, c *gin.Context) { // 防止玩家未连接网关,所以延迟3秒 time.AfterFunc(time.Second*3, func() { nc := newContext(c) + call.PushRed(uid, pb.RedPointModule_RedPointLoginAgain, 1) // 是否可以转动转盘 ActivityBetDrawInfo(nc) // 是否可以签到 @@ -289,5 +291,6 @@ func CheckRedPoint(uid int, c *gin.Context) { ShareInfo(nc) // vip奖励 GetVipInfo(nc) + }) } diff --git a/modules/web/handler/vip.go b/modules/web/handler/vip.go index a065648..6676996 100644 --- a/modules/web/handler/vip.go +++ b/modules/web/handler/vip.go @@ -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)) } }