From 76f8c2faf01dc45139b14356dd2db17f0dc54d29 Mon Sep 17 00:00:00 2001 From: mofangmin Date: Tue, 9 Jul 2024 20:24:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=B8=E6=88=8F=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- call/config.go | 1 - call/game.go | 11 ++++++++--- modules/web/handler/firstpage.go | 1 + modules/web/handler/game.go | 1 + 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/call/config.go b/call/config.go index 6f6c5f4..05f68c2 100644 --- a/call/config.go +++ b/call/config.go @@ -711,7 +711,6 @@ func GetConfigGameList(num int, cond ...int) []*common.ConfigGameList { return ret } } - GetGameInfo(ret) return ret } diff --git a/call/game.go b/call/game.go index c3571b2..2bf5888 100644 --- a/call/game.go +++ b/call/game.go @@ -65,10 +65,12 @@ func GetGameInfo(gameInfos []*common.ConfigGameList) { } cmds, err := pipeline.Exec(ctx) now := time.Now() - for i := 0; i < 2*len(gameInfos); i = i + 2 { - game := gameInfos[i/2] + fieldNum := 3 + for i := 0; i < fieldNum*len(gameInfos); i = i + fieldNum { + game := gameInfos[i/fieldNum] maxRewardCmd := cmds[i] maxRewardTimeCmd := cmds[i+1] + rtpCmd := cmds[i+2] key := fmt.Sprintf("firstpage:games:%d_%d", game.GameProvider, game.GameID) game.MaxReward, err = maxRewardCmd.(*redis.StringCmd).Int64() if errors.Is(err, redis.Nil) { @@ -78,15 +80,18 @@ func GetGameInfo(gameInfos []*common.ConfigGameList) { game.MaxReward = val pipeline.HSet(ctx, key, maxRewardField, val, maxRewardTimeField, time.Now(), rtpField, rtp) } else { + rtp, _ := rtpCmd.(*redis.StringCmd).Int64() maxRewardTime, _ := maxRewardTimeCmd.(*redis.StringCmd).Time() if now.Sub(maxRewardTime).Hours() >= 1 { val := util.RandBetween64(game.MaxReward, 9999) - rtp := util.RandBetween64(93, 104) + rtp = util.RandBetween64(93, 104) game.RTP = rtp game.MaxReward = val pipeline.HSet(ctx, key, maxRewardField, val, maxRewardTimeField, time.Now(), rtpField, rtp) } + game.RTP = rtp } + game.MaxReward *= common.DecimalDigits } _, err = pipeline.Exec(ctx) if err != nil { diff --git a/modules/web/handler/firstpage.go b/modules/web/handler/firstpage.go index 12baac4..081c220 100644 --- a/modules/web/handler/firstpage.go +++ b/modules/web/handler/firstpage.go @@ -68,6 +68,7 @@ func FirstPage(c *gin.Context) { one.List = call.GetConfigGameList(req.GameNum, 0, v.JumpID) } } + call.GetGameInfo(one.List) resp.Games = append(resp.Games, one) } for i := common.CurrencyTypeZero + 1; i < common.CurrencyAll; i++ { diff --git a/modules/web/handler/game.go b/modules/web/handler/game.go index bcc124a..a2f9618 100644 --- a/modules/web/handler/game.go +++ b/modules/web/handler/game.go @@ -60,6 +60,7 @@ func GameList(c *gin.Context) { end = len(list) } resp.List = list[start:end] + call.GetGameInfo(resp.List) for _, v := range resp.List { v.Jackpot = call.GetJackpot(common.JackpotTypeGame, v.GameID) }