feat: stat 新增按游戏统计充值净额接口 GetGamePayAmount
对接 stat.gaore.com 的 /pay/getGamePayAmount: - pay_channel.go:GetGamePayAmountReq/Resp/Param + 工厂函数(POST form, 入参 tdate/tdate2/game_id/group_by_date),返回 game_id + pay_amount(单位元); - client.go:新增 GetGamePayAmount 方法; - client_test.go:新增 TestGetGamePayAmount。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
0375acccb9
commit
0d08ac88b8
@ -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
|
||||||
|
}
|
||||||
|
|||||||
@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
73
services/stat/pay_channel.go
Normal file
73
services/stat/pay_channel.go
Normal 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{},
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user