From d616e4240ba817f93702373797f02309601f70f6 Mon Sep 17 00:00:00 2001 From: zhora Date: Tue, 21 Oct 2025 10:34:25 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E6=A8=A1=E6=9D=BFid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/web/providers/sn/api.go | 38 ++++++++++++++++++++++-- modules/web/providers/sn/base.go | 3 ++ modules/web/providers/sn/handler.go | 45 ++++++++++++++++++++++++++--- modules/web/providers/sn/values.go | 5 ++++ 4 files changed, 84 insertions(+), 7 deletions(-) diff --git a/modules/web/providers/sn/api.go b/modules/web/providers/sn/api.go index e1b68b6..7addba0 100644 --- a/modules/web/providers/sn/api.go +++ b/modules/web/providers/sn/api.go @@ -185,9 +185,10 @@ type GameControlCallbackResp struct { type ControlReq struct { BaseReq - ThirdName string `json:"third_name"` - ControlId int `json:"control_id"` - Data []struct { + ThirdName string `json:"third_name"` + ControlId int `json:"control_id"` + TemplateId string `json:"template_id"` + Data []struct { TargetRtp int `json:"target_rtp"` } `json:"data"` Sn int `json:"sn"` @@ -210,3 +211,34 @@ type ControlResp struct { Data struct { } `json:"data"` } + +type ControlTemplateReq struct { + BaseReq + PageSize int `json:"page_size"` + PageIndex int `json:"page_index"` +} + +type ControlTemplateResp struct { + Code int `json:"code"` + Success bool `json:"success"` + StatusCode int `json:"status_code"` + System int `json:"system"` + Msg string `json:"msg"` + Prompt string `json:"prompt"` + RequestId string `json:"request_id"` + RequestMethod string `json:"request_method"` + Provider string `json:"provider"` + Doc string `json:"doc"` + Data struct { + List []struct { + TemplateId string `json:"template_id"` + DealerList interface{} `json:"dealer_list"` + Desc string `json:"desc"` + Operator string `json:"operator"` + Time int `json:"time"` + CoinType int `json:"coin_type"` + List interface{} `json:"list"` + } `json:"list"` + TotalCount int `json:"total_count"` + } `json:"data"` +} diff --git a/modules/web/providers/sn/base.go b/modules/web/providers/sn/base.go index 5ac7ed5..bca4f2f 100644 --- a/modules/web/providers/sn/base.go +++ b/modules/web/providers/sn/base.go @@ -25,6 +25,7 @@ func (s *Sub) Init() { API = APITest APICreate = APICreateUserTest APIControl = APIControlTest + APIGameControlTemplate = APIGameControlTemplateTest SnAccount = TestSnAccount DefaultLanguage = TestDefaultLanguage ApiKey = TestApiKey @@ -36,6 +37,7 @@ func (s *Sub) Init() { API = APIRlease APICreate = APICreateUserRlease APIControl = APIControlRlease + APIGameControlTemplate = APIGameControlTemplateRelease SnAccount = ReleaseSnAccount DefaultLanguage = ReleaseDefaultLanguage ApiKey = ReleaseApiKey @@ -44,6 +46,7 @@ func (s *Sub) Init() { AgentId = ReleaseAgentId SnId = ReleaseSnId } + InitGameControlTemplate() } type EnterReq struct { diff --git a/modules/web/providers/sn/handler.go b/modules/web/providers/sn/handler.go index bf0d6b2..65a869a 100644 --- a/modules/web/providers/sn/handler.go +++ b/modules/web/providers/sn/handler.go @@ -12,6 +12,7 @@ import ( "server/modules/web/providers/base" "server/util" "strconv" + "strings" "time" "github.com/gin-gonic/gin" @@ -641,10 +642,11 @@ func Control(uid int, controlId int) error { SnAccount: SnAccount, Time: time.Now().Unix(), }, - ThirdName: call.GetProviderUserName(fmt.Sprintf("%d", uid)), - ControlId: controlId, - Sn: SnId, - AgentId: AgentId, + ThirdName: call.GetProviderUserName(fmt.Sprintf("%d", uid)), + ControlId: controlId, + Sn: SnId, + AgentId: AgentId, + TemplateId: DefaultTemplateId, Data: []struct { TargetRtp int `json:"target_rtp"` }{ @@ -673,3 +675,38 @@ func Control(uid int, controlId int) error { return nil } + +func InitGameControlTemplate() error { + req := &ControlTemplateReq{ + BaseReq: BaseReq{ + SnAccount: SnAccount, + Time: time.Now().Unix(), + }, + } + + log.Debug("sn get control template req, %+v", *req) + reqBody, _ := json.Marshal(req) + var tmpValue map[string]interface{} + json.Unmarshal(reqBody, &tmpValue) + req.Sign = GeneratedSign(tmpValue, ApiKey) + + var resp ControlTemplateResp + err := util.HttpPost(APIGameControlTemplate, req, &resp, nil) + if err != nil { + log.Error("err:%v", err) + return err + } + if resp.Code != CodeRequestSuccess && resp.Code != CodeRequestExist { + log.Error("sn get control template err, %+v", resp) + return fmt.Errorf("sn get control template err, %+v ", resp) + } + + for _, v := range resp.Data.List { + if strings.Contains(v.Desc, "90%50") { + DefaultTemplateId = v.TemplateId + break + } + } + + return nil +} diff --git a/modules/web/providers/sn/values.go b/modules/web/providers/sn/values.go index 7a85175..8500ee5 100644 --- a/modules/web/providers/sn/values.go +++ b/modules/web/providers/sn/values.go @@ -20,6 +20,9 @@ const ( APIControlRlease = "https://ve-api.1betnbet.com/v1/control" APIControlTest = "https://api.nbetps.com/v1/control" + APIGameControlTemplateRelease = "https://ve-api.1betnbet.com/v1/game_control/search_control_template" + APIGameControlTemplateTest = "https://api.nbetps.com/v1/game_control/search_control_template" + TestSnAccount = "wjA77Game_N601" TestDefaultLanguage = "en" TestAgentId = 320 @@ -46,6 +49,8 @@ var ( API = "" APICreate = "" APIControl = "" + APIGameControlTemplate = "" + DefaultTemplateId = "" SnAccount, DefaultLanguage, ApiKey, WalletKey, ControlKey string AgentId, SnId int )