6
0
gaore-common-sdk-go/services/stat/client.go
yuxh fa15909fc5 feat(stat): 新增设备归因上报与媒体投放账号查询接口
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) <noreply@anthropic.com>
2026-08-17 15:28:00 +08:00

197 lines
5.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package stat
import (
"fmt"
"time"
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
)
const (
VERSION = "2020-11-16"
)
var HOST = requests.Host{
Default: "stat",
}
type Client struct {
sdk.Client
}
func NewClient() (client *Client, err error) {
client = new(Client)
err = client.Init()
return
}
// SyncGameServerList 同步开服数据
func (c *Client) SyncGameServerList(req *SyncGameServerListReq) (resp *SyncGameServerListResp, err error) {
resp = CreateSyncGameServerListResp()
err = c.DoAction(req, resp)
if err != nil {
return
}
return
}
func (c *Client) SetUserNewGameAuth(req *SetUserNewGameAuthReq) (resp *SetUserNewGameAuthResp, err error) {
resp = CreateSetUserNewGameAuthResp()
err = c.DoAction(req, resp)
return
}
// GetAgentList 获取推广渠道列表
func (c *Client) GetAgentList(req *GetAgentListReq) (resp *GetAgentListResp, err error) {
resp = CreateGetAgentListResp()
err = c.DoAction(req, resp)
if err != nil {
return
}
return
}
// GetUserRoleRegPage 获取用户角色注册分页列表
func (c *Client) GetUserRoleRegPage(req *UserRoleRegReq) (resp *UserRoleRegResp, err error) {
resp = CreateUserRoleRegPageResp()
// 设置超时时间
req.SetConnectTimeout(10 * time.Second)
// 设置读取超时时间
req.SetReadTimeout(20 * time.Second)
err = c.DoAction(req, resp)
if err != nil {
return
}
return
}
// GetAnchorBySiteId 通过site_id获取达人信息
func (c *Client) GetAnchorBySiteId(req *GetAnchorBySiteId) (resp *GetAnchorBySiteIdResp, err error) {
resp = &GetAnchorBySiteIdResp{
BaseResponse: &responses.BaseResponse{},
}
err = c.DoAction(req, resp)
return
}
// GetUserTotalPay 获取用户累计付费
func (c *Client) GetUserTotalPay(req *GetUserTotalPayReq) (resp *GetUserTotalPayResp, err error) {
resp = CreateGetUserTotalPayResp()
err = c.DoAction(req, resp)
if err != nil {
return
}
return
}
// GetGameServerCountData 获取区服统计数据
func (c *Client) GetGameServerCountData(req *GetGameServerCountDataReq) (resp *GetGameServerCountDataResp, err error) {
resp = CreateGetGameServerCountDataResp()
err = c.DoAction(req, resp)
if err != nil {
return
}
return
}
// GetAnchorByLiveCode 通过口令获取达人信息
func (c *Client) GetAnchorByLiveCode(req *GetAnchorByLiveCodeReq) (resp *GetAnchorByLiveCodeResp, err error) {
resp = &GetAnchorByLiveCodeResp{
BaseResponse: &responses.BaseResponse{},
}
err = c.DoAction(req, resp)
return
}
// GetLiveCode 根据口令获取口令信息
func (c *Client) GetLiveCode(req *GetLiveCodeReq) (resp *GetLiveCodeResp, err error) {
resp = &GetLiveCodeResp{
BaseResponse: &responses.BaseResponse{},
}
err = c.DoAction(req, resp)
return
}
func (c *Client) BindLiveCode(req *BindLiveCodeReq) (resp *BindLiveCodeResp, err error) {
resp = &BindLiveCodeResp{
BaseResponse: &responses.BaseResponse{},
}
err = c.DoAction(req, resp)
return
}
func (c *Client) UserReg(req *UserRegRequest) (resp *UserRegResponse, err error) {
resp = &UserRegResponse{
BaseResponse: &responses.BaseResponse{},
}
if req == nil {
err = fmt.Errorf("request is nil")
return
}
req.Electric = req.Battery
err = c.DoAction(req, resp)
return
}
func (c *Client) UserLogin(req *UserLoginRequest) (resp *UserLoginResponse, err error) {
resp = &UserLoginResponse{
BaseResponse: &responses.BaseResponse{},
}
err = c.DoAction(req, resp)
return
}
func (c *Client) SetSiteKey(req *SetSiteKeyReq) (resp *SetSiteKeyResp, err error) {
resp = &SetSiteKeyResp{
BaseResponse: &responses.BaseResponse{},
}
err = c.DoAction(req, resp)
return
}
// CallbackWeightUpdate 回调权重更新
func (c *Client) CallbackWeightUpdate(req *CallbackWeightUpdateReq) (resp *CallbackWeightUpdateResp, err error) {
resp = CreateCallbackWeightUpdateResp()
err = c.DoAction(req, resp)
return
}
// GetGamePayAmount 按游戏统计充值净额(gr_pay_channel.pay_amount)
func (c *Client) GetGamePayAmount(req *GetGamePayAmountReq) (resp *GetGamePayAmountResp, err error) {
resp = CreateGetGamePayAmountResp()
err = c.DoAction(req, resp)
return
}
// KafkaEvent 通用推入kafka数据
func (c *Client) KafkaEvent(req *KafkaEventReq) (resp *KafkaEventResp, err error) {
resp = CreateKafkaEventResp()
err = c.DoAction(req, resp)
return
}
func (c *Client) AddWeworkCustomer(req *AddWeworkCustomerRequest) (resp *AddWeworkCustomerResponse, err error) {
resp = &AddWeworkCustomerResponse{
BaseResponse: &responses.BaseResponse{},
}
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
}