From 7d167dcf52ea132026a0e0e3b0dd32b567db618c Mon Sep 17 00:00:00 2001 From: denghui <1016848185@qq.com> Date: Mon, 23 Jun 2025 17:12:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=81=E8=A3=85=E6=B8=B8=E6=88=8F=E4=BA=BA?= =?UTF-8?q?=E7=94=9F=E8=83=8C=E5=8C=85=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utility/gamelife/gamelife.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/utility/gamelife/gamelife.go b/utility/gamelife/gamelife.go index 3358aaa..c1198d3 100644 --- a/utility/gamelife/gamelife.go +++ b/utility/gamelife/gamelife.go @@ -39,6 +39,7 @@ type gamelifeClient struct { unBoundURLMap map[string]string getBoundURL map[string]string taskURLMap map[string]string + packageURLMap map[string]string } // URLMaps defines the URL mappings for different environments. @@ -48,6 +49,7 @@ var URLMaps = struct { UnBound map[string]string GetBound map[string]string Task map[string]string + Package map[string]string }{ KeyIV: map[string]string{ "test": "https://api-test.nes.smoba.qq.com/pvpesport.sgamenes.commcgi.commcgi/GetExplatSecret", @@ -69,6 +71,10 @@ var URLMaps = struct { "test": "https://api-test.cafe.qq.com/netbar.cafe.open_api.open_api/", "prod": "https://api.cafe.qq.com/netbar.cafe.open_api.open_api/", }, + Package: map[string]string{ + "test": "https://test.igame.qq.com/tip/ingame-page/feature/add-game-life/igame-game-life-web/#/index/goods", + "prod": "https://igame.qq.com/tip/ingame-page/feature/add-game-life/igame-game-life-web/#/index/goods", + }, } var ( @@ -99,6 +105,7 @@ func newGamelifeClient(ctx context.Context) *gamelifeClient { unBoundURLMap: URLMaps.UnBound, getBoundURL: URLMaps.GetBound, taskURLMap: URLMaps.Task, + packageURLMap: URLMaps.Package, } glog.Info(ctx, "Initialized gamelifeClient successfully", map[string]interface{}{ "plat_id": cfg.PlatID, @@ -188,6 +195,22 @@ func (s *gamelifeClient) GetUrl(ctx context.Context, popenID, appName, nickname } return fmt.Sprintf("%s?%s", rootURL, params), nil } +func (s *gamelifeClient) GetGamelifePackageUrl(ctx context.Context, popenID, appName string, bindType int) (string, error) { + // 从配置中获取 package URL 前缀 + packageURL := s.packageURLMap[s.config.Mode] + + // 获取用户缓存 + cache, err := s.ensureUserCache(ctx, popenID) + if err != nil { + return "", err + } + params, err := s.buildQueryParams(ctx, popenID, cache, appName, "", bindType, true) + if err != nil { + return "", err + } + + return fmt.Sprintf("%s?%s", packageURL, params), nil +} // 通用缓存获取函数,只负责获取/刷新 aes、iv、token func (s *gamelifeClient) ensureUserCacheGeneral( @@ -465,6 +488,7 @@ func (s *gamelifeClient) RequestActivity(ctx context.Context, in *model.QQNetbar return nil, ecode.Fail.Sub("请求出现异常") } return &result, nil + default: return nil, ecode.Fail.Sub(fmt.Sprintf("不支持的任务: %s", in.ServiceName)) }