From fa15909fc57956127438eeac6b5cb3133e982160 Mon Sep 17 00:00:00 2001 From: yuxh Date: Mon, 17 Aug 2026 15:28:00 +0800 Subject: [PATCH] =?UTF-8?q?feat(stat):=20=E6=96=B0=E5=A2=9E=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E5=BD=92=E5=9B=A0=E4=B8=8A=E6=8A=A5=E4=B8=8E=E5=AA=92?= =?UTF-8?q?=E4=BD=93=E6=8A=95=E6=94=BE=E8=B4=A6=E5=8F=B7=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit msdk 的 skan 归因逻辑迁移到 nsdk(Go)需要这两个接口, 对应 PHP 侧 GaoreSDK\Package\Stat 的同名方法: - DeviceAttribution: POST JSON 到 /api/device/attribution, 上报各媒体的设备归因结果(内部推入 kafka)。各媒体上报字段集合 与类型差异较大,PHP 侧直接传关联数组,故请求体以 map 承载而不 收敛成结构体,避免类型转换导致上报内容与 PHP 不一致。 - GetGameAppByGameIdChannel: POST 表单到 /api/game/getGameAppByGameIdChannel,按游戏与渠道取媒体投放 账号配置,腾讯归因查询需要其中的 access_token。 Co-Authored-By: Claude Opus 5 (1M context) --- services/stat/client.go | 14 ++++++++ services/stat/device.go | 79 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 services/stat/device.go diff --git a/services/stat/client.go b/services/stat/client.go index 4735fd1..bee6fea 100644 --- a/services/stat/client.go +++ b/services/stat/client.go @@ -180,3 +180,17 @@ func (c *Client) AddWeworkCustomer(req *AddWeworkCustomerRequest) (resp *AddWewo err = c.DoAction(req, resp) return } + +// DeviceAttribution 上报设备归因数据(内部推入 kafka) +func (c *Client) DeviceAttribution(req *DeviceAttributionReq) (resp *DeviceAttributionResp, err error) { + resp = CreateDeviceAttributionResp() + err = c.DoAction(req, resp) + return +} + +// GetGameAppByGameIdChannel 按游戏与渠道获取媒体投放账号配置 +func (c *Client) GetGameAppByGameIdChannel(req *GetGameAppByGameIdChannelReq) (resp *GetGameAppByGameIdChannelResp, err error) { + resp = CreateGetGameAppByGameIdChannelResp() + err = c.DoAction(req, resp) + return +} diff --git a/services/stat/device.go b/services/stat/device.go new file mode 100644 index 0000000..68778fb --- /dev/null +++ b/services/stat/device.go @@ -0,0 +1,79 @@ +package stat + +import ( + "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests" + "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses" +) + +// DeviceAttributionReq 设备归因数据上报请求。 +// +// 各媒体上报的字段集合与类型差异较大(PHP 侧直接传关联数组), +// 这里以 map 承载而不收敛成结构体,避免类型转换导致上报内容与 PHP 不一致。 +type DeviceAttributionReq struct { + *requests.JsonRequest +} + +type DeviceAttributionResp struct { + *responses.BaseResponse + Code int `json:"code"` + Msg string `json:"msg"` +} + +// CreateDeviceAttributionReq 创建设备归因上报请求。 +// 对应 PHP GaoreSDK\Package\Stat::deviceAttribution,POST JSON 到 /api/device/attribution。 +func CreateDeviceAttributionReq(data map[string]any) *DeviceAttributionReq { + req := &DeviceAttributionReq{JsonRequest: &requests.JsonRequest{}} + req.InitWithApiInfo(HOST, VERSION, "api/device/attribution") + req.Method = requests.POST + for k, v := range data { + req.JsonParams[k] = v + } + return req +} + +func CreateDeviceAttributionResp() *DeviceAttributionResp { + return &DeviceAttributionResp{ + BaseResponse: &responses.BaseResponse{}, + } +} + +// GetGameAppByGameIdChannelReq 按游戏与渠道获取媒体投放账号配置。 +type GetGameAppByGameIdChannelReq struct { + *requests.RpcRequest + GameId int64 `position:"Body" field:"game_id" json:"game_id"` + Channel string `position:"Body" field:"channel" json:"channel"` +} + +type GetGameAppByGameIdChannelResp struct { + *responses.BaseResponse + Code int `json:"code"` + Msg string `json:"msg"` + Data GameAppInfo `json:"data"` +} + +// GameAppInfo 媒体投放账号配置,腾讯归因查询需要其中的 access_token。 +type GameAppInfo struct { + AccountId string `json:"account_id"` + AppId string `json:"app_id"` + AccessToken string `json:"access_token"` +} + +// CreateGetGameAppByGameIdChannelReq 创建媒体投放账号查询请求。 +// 对应 PHP GaoreSDK\Package\Stat::getGameAppByGameIdChannel, +// POST 表单到 /api/game/getGameAppByGameIdChannel。 +func CreateGetGameAppByGameIdChannelReq(gameId int64, channel string) *GetGameAppByGameIdChannelReq { + req := &GetGameAppByGameIdChannelReq{ + RpcRequest: &requests.RpcRequest{}, + GameId: gameId, + Channel: channel, + } + req.InitWithApiInfo(HOST, VERSION, "api/game/getGameAppByGameIdChannel") + req.Method = requests.POST + return req +} + +func CreateGetGameAppByGameIdChannelResp() *GetGameAppByGameIdChannelResp { + return &GetGameAppByGameIdChannelResp{ + BaseResponse: &responses.BaseResponse{}, + } +}