8
0
gaore-common-sdk-go/services/stat/pay_channel.go

74 lines
2.0 KiB
Go
Raw Normal View History

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{},
}
}