对接 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>
74 lines
2.0 KiB
Go
74 lines
2.0 KiB
Go
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{},
|
||
}
|
||
}
|