From 280202e5207d8c68465f7861854b38a67c9db6be Mon Sep 17 00:00:00 2001 From: zhora Date: Sat, 11 Oct 2025 16:36:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=B8=E6=88=8F=E5=90=8D=E6=A8=A1=E7=B3=8A?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=EF=BC=9B=E7=89=B9=E6=AE=8A=E6=B8=B8=E6=88=8F?= =?UTF-8?q?rtp=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- call/config.go | 20 ++++++++++++++++++++ call/user.go | 2 ++ modules/web/handler/game.go | 12 ++++++++++-- modules/web/providers/sn/handler.go | 27 ++++++++++++++++++++++++++- modules/web/values/firstpage.go | 1 + modules/web/values/game.go | 9 +++++---- 6 files changed, 64 insertions(+), 7 deletions(-) diff --git a/call/config.go b/call/config.go index fc9a780..66404e2 100644 --- a/call/config.go +++ b/call/config.go @@ -2218,6 +2218,26 @@ func GetGameListByTags(tagIds []int) (result []*common.ConfigGameList) { return result } +func GetGameListByName(gameList []*common.ConfigGameList, gameName string) (result []*common.ConfigGameList) { + gameNameLower := strings.ToLower(gameName) + gameNameLower = strings.ReplaceAll(gameNameLower, " ", "") + gameListAll := gameList + if len(gameListAll) == 0 { + gameListAll = configGameListAll + } + for _, v := range gameListAll { + tmpGameName := strings.ToLower(v.Name) + tmpGameName = strings.ReplaceAll(tmpGameName, " ", "") + if strings.Contains(tmpGameName, gameNameLower) { + result = append(result, v) + } + } + sort.Slice(result, func(i, j int) bool { + return result[i].Sort > result[j].Sort + }) + return result +} + func GetConfigGameListByCode(provider int, gameCode string) *common.ConfigGameList { for _, v := range configGameListAll { if v.GameProvider == provider && v.GameCode == gameCode { diff --git a/call/user.go b/call/user.go index 4108f9c..b228558 100644 --- a/call/user.go +++ b/call/user.go @@ -738,6 +738,7 @@ func AddGameRecord(uid int, provider int, gameId int) error { member := fmt.Sprintf("%v_%v", provider, gameId) playerGamesSetKey := fmt.Sprintf("player:%v:games:set", uid) playerGamesListKey := fmt.Sprintf("player:%v:games:list", uid) + playerGamesAt := fmt.Sprintf("player:%v:games:at", uid) ctx := context.Background() client := db.Redis().GetRedis() // 检查集合中是否已经存在该游戏记录 @@ -746,6 +747,7 @@ func AddGameRecord(uid int, provider int, gameId int) error { return err } if !exists { + client.Set(ctx, playerGamesAt, member, 0) // 将游戏ID添加到集合进行去重 client.SAdd(ctx, playerGamesSetKey, member) // 将游戏ID添加到列表的头部 diff --git a/modules/web/handler/game.go b/modules/web/handler/game.go index 0c251d4..9745ab6 100644 --- a/modules/web/handler/game.go +++ b/modules/web/handler/game.go @@ -158,8 +158,15 @@ func GameListNew(c *gin.Context) { } resp := &values.GameListNewResp{} a.Data = resp - gameList := call.GetGameListByTags([]int{req.SubTagId}) - resp.Total = len(gameList) + var gameList []*common.ConfigGameList + if req.SubTagId > 0 { + gameList = call.GetGameListByTags([]int{req.SubTagId}) + resp.Total = len(gameList) + } + if req.GameName != "" { + gameList = call.GetGameListByName(gameList, req.GameName) + resp.Total = len(gameList) + } if resp.Total == 0 { return @@ -178,6 +185,7 @@ func GameListNew(c *gin.Context) { GameTag: gameTmp.Mark, GameStatus: gameTmp.GameStatus, GameIcon: gameTmp.Icon, + GameName: gameTmp.Name, }) } resp.List = list[start:end] diff --git a/modules/web/providers/sn/handler.go b/modules/web/providers/sn/handler.go index 7cd552f..bf0d6b2 100644 --- a/modules/web/providers/sn/handler.go +++ b/modules/web/providers/sn/handler.go @@ -1,6 +1,7 @@ package sn import ( + "context" "encoding/json" "fmt" "io/ioutil" @@ -607,10 +608,34 @@ func GameControlCallback(c *gin.Context) { }() } +var controlGameId = []int{ + 23007913, +} + +func checkSpecialControl(result string) bool { + if result == "" { + return false + } + for _, v := range controlGameId { + if result == fmt.Sprintf("%d_%d", common.ProviderSn, v) { + return true + } + } + return false +} + +const specialControlRtp = 85 + func Control(uid int, controlId int) error { if controlId == 0 { controlId = 1 } + rtp := call.GetRtpControlV1(uid) + result, _ := db.Redis().GetRedis().Get(context.Background(), fmt.Sprintf("player:%v:games:at", uid)).Result() + if rtp > specialControlRtp && checkSpecialControl(result) { + rtp = specialControlRtp + log.Debug("rtpControl special, uid:%d result:%s, rtp:%d", uid, result, specialControlRtp) + } req := &ControlReq{ BaseReq: BaseReq{ SnAccount: SnAccount, @@ -624,7 +649,7 @@ func Control(uid int, controlId int) error { TargetRtp int `json:"target_rtp"` }{ { - TargetRtp: call.GetRtpControlV1(uid), + TargetRtp: rtp, }, }, } diff --git a/modules/web/values/firstpage.go b/modules/web/values/firstpage.go index fef7ce6..8932cf2 100644 --- a/modules/web/values/firstpage.go +++ b/modules/web/values/firstpage.go @@ -37,6 +37,7 @@ type GameData struct { GameTag int `json:"gameTag"` // 游戏标签(1:热门,2:最新,3:推荐) GameStatus int `json:"gameStatus"` // 展示状态(1:上线,2:下线,3:维护中,4:即将上线) GameIcon string `json:"gameIcon"` // 游戏图标 + GameName string `json:"gameName"` // 游戏名称 } type TagWithGameList struct { diff --git a/modules/web/values/game.go b/modules/web/values/game.go index fecc7f9..5339d45 100644 --- a/modules/web/values/game.go +++ b/modules/web/values/game.go @@ -28,10 +28,11 @@ type GameTagResp struct { } type GameListNewReq struct { - TagId int `json:"tagId"` // 一级标签 - SubTagId int `json:"subTagId"` // 二级标签 - Page int `json:"page"` - PageSize int `json:"pageSize"` + TagId int `json:"tagId"` // 一级标签 + SubTagId int `json:"subTagId"` // 二级标签 + GameName string `json:"gameName"` // 游戏名称(模糊匹配) + Page int `json:"page"` + PageSize int `json:"pageSize"` } // Provider 游戏提供商