8
0
This commit is contained in:
luoxun 2026-06-08 19:52:33 +08:00
commit 40d54327bf
3 changed files with 108 additions and 0 deletions

View File

@ -157,3 +157,10 @@ func (c *Client) CallbackWeightUpdate(req *CallbackWeightUpdateReq) (resp *Callb
err = c.DoAction(req, resp) err = c.DoAction(req, resp)
return 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
}

View File

@ -350,3 +350,31 @@ func TestCallbackWeightUpdate(t *testing.T) {
} }
t.Log(resp) t.Log(resp)
} }
// TestGetGamePayAmount 按游戏统计充值净额pay_amount单位元
func TestGetGamePayAmount(t *testing.T) {
client, err := NewClient()
if err != nil {
t.Fatal(err)
}
req := CreateGetGamePayAmountReq(GetGamePayAmountParam{
Tdate: "2026-05-01", // 开始日期
Tdate2: "2026-05-31", // 结束日期(含当天)
GameIds: []int64{3706}, // 游戏id(=switch_game_id),传 nil 则全部
GroupByDate: false, // 仅按游戏汇总true 则按日期+游戏拆分
})
resp, err := client.GetGamePayAmount(req)
if err != nil {
t.Fatal(err)
}
fmt.Println(resp.Code, resp.Msg)
for _, r := range resp.Data.List {
fmt.Printf("tdate=%s game_id=%d pay_amount=%.2f\n", r.Tdate, r.GameId, r.PayAmount)
}
// 成功码为 1
if resp.Code != 1 {
t.Errorf("GetGamePayAmount failed: code=%d msg=%s", resp.Code, resp.Msg)
}
}

View File

@ -0,0 +1,73 @@
package stat
import (
"strconv"
"strings"
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
)
// GetGamePayAmountReq 按游戏统计充值净额(gr_pay_channel.pay_amount)请求
type GetGamePayAmountReq struct {
*requests.RpcRequest
}
// GetGamePayAmountParam 调用参数
type GetGamePayAmountParam struct {
Tdate string // 开始日期 YYYY-MM-DD必填
Tdate2 string // 结束日期 YYYY-MM-DD选填含当天
GameIds []int64 // 游戏id选填空=全部游戏)
GroupByDate bool // true=按日期+游戏分组false=仅按游戏汇总
}
// GetGamePayAmountResp 响应
type GetGamePayAmountResp struct {
*responses.BaseResponse
Code int `json:"code"`
Msg string `json:"msg"`
Data GamePayAmountList `json:"data"`
}
type GamePayAmountList struct {
List []GamePayAmount `json:"list"`
}
// GamePayAmount 单条统计;未按日期分组时 Tdate 为空
type GamePayAmount struct {
Tdate string `json:"tdate"`
GameId int64 `json:"game_id"`
PayAmount float64 `json:"pay_amount"` // 充值净额,单位:元
}
// CreateGetGamePayAmountReq 创建「按游戏统计充值净额」请求
func CreateGetGamePayAmountReq(param GetGamePayAmountParam) *GetGamePayAmountReq {
req := &GetGamePayAmountReq{
&requests.RpcRequest{},
}
req.InitWithApiInfo(HOST, VERSION, "/pay/getGamePayAmount")
req.Method = requests.POST
gameIds := make([]string, 0, len(param.GameIds))
for _, id := range param.GameIds {
gameIds = append(gameIds, strconv.FormatInt(id, 10))
}
groupByDate := "0"
if param.GroupByDate {
groupByDate = "1"
}
req.FormParams = map[string]string{
"tdate": param.Tdate,
"tdate2": param.Tdate2,
"game_id": strings.Join(gameIds, ","),
"group_by_date": groupByDate,
}
return req
}
// CreateGetGamePayAmountResp 创建响应对象
func CreateGetGamePayAmountResp() *GetGamePayAmountResp {
return &GetGamePayAmountResp{
BaseResponse: &responses.BaseResponse{},
}
}