From 7d0deb756af7c9f405f0f0d7dcdcff68df758edc Mon Sep 17 00:00:00 2001 From: huangqz Date: Fri, 5 Sep 2025 10:25:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=8E=B7=E5=8F=96=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E7=B4=AF=E8=AE=A1=E4=BB=98=E8=B4=B9=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/stat/client.go | 10 ++++++ services/stat/client_test.go | 19 +++++++++++ services/stat/pay.go | 63 ++++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 services/stat/pay.go diff --git a/services/stat/client.go b/services/stat/client.go index 46fcacc..9c564d2 100644 --- a/services/stat/client.go +++ b/services/stat/client.go @@ -64,3 +64,13 @@ func (c *Client) GetUserRoleRegPage(req *UserRoleRegReq) (resp *UserRoleRegResp, } return } + +// GetUserTotalPay 获取用户累计付费 +func (c *Client) GetUserTotalPay(req *GetUserTotalPayReq) (resp *GetUserTotalPayResp, err error) { + resp = CreateGetUserTotalPayResp() + err = c.DoAction(req, resp) + if err != nil { + return + } + return +} diff --git a/services/stat/client_test.go b/services/stat/client_test.go index 03c2515..c3293b5 100644 --- a/services/stat/client_test.go +++ b/services/stat/client_test.go @@ -98,3 +98,22 @@ func TestClient_GetUserRoleRegPage(t *testing.T) { } fmt.Println(resp.Code, resp.Msg, resp.Data) } + +// 获取用户累计付费 +func TestGetUserTotalPay(t *testing.T) { + client, err := NewClient() + if err != nil { + panic(err) + } + req := CreateGetUserTotalPayReq(GetUserTotalPayParam{ + Where: "user_name = 'yoyo685757'", + Fields: []string{"user_name", "sum(total_pay_money) as total_pay_money", "last_pay_time"}, + GroupBy: []string{"user_name"}, + }) + + resp, err := client.GetUserTotalPay(req) + if err != nil { + panic(err) + } + fmt.Println(resp.Code, resp.Msg, resp.Data) +} diff --git a/services/stat/pay.go b/services/stat/pay.go new file mode 100644 index 0000000..102dbfe --- /dev/null +++ b/services/stat/pay.go @@ -0,0 +1,63 @@ +package stat + +import ( + "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests" + "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses" + "strings" +) + +type GetUserTotalPayReq struct { + *requests.RpcRequest +} + +type GetUserTotalPayParam struct { + Where string `json:"where"` + Fields []string `json:"fields"` + GroupBy []string `json:"group_by"` +} + +type GetUserTotalPayResp struct { + *responses.BaseResponse + Code int `json:"code"` + Msg string `json:"msg"` + Data TotalPayList `json:"data"` +} +type TotalPayList struct { + List []TotalPay `json:"list"` +} +type TotalPay struct { + UserName string `json:"user_name"` + RegDate string `json:"reg_date"` + AgentId int64 `json:"agent_id"` + SiteId int64 `json:"site_id"` + GameId int64 `json:"game_id"` + FirstPayTime string `json:"first_pay_time"` + FirstPayMoney float64 `json:"first_pay_money"` + TotalPayMoney float64 `json:"total_pay_money"` + LastPayTime string `json:"last_pay_time"` + PayTimes int64 `json:"pay_times"` + IsFirst int64 `json:"is_first"` +} + +// CreateGetUserTotalPayReq 获取用户累充 +func CreateGetUserTotalPayReq(data GetUserTotalPayParam) *GetUserTotalPayReq { + req := &GetUserTotalPayReq{ + &requests.RpcRequest{}, + } + + req.InitWithApiInfo(HOST, VERSION, "/pay/getUserTotalPay") + req.Method = requests.POST + req.FormParams = make(map[string]string) + req.FormParams["where"] = data.Where + req.FormParams["fields"] = strings.Join(data.Fields, ",") + req.FormParams["group_by"] = strings.Join(data.GroupBy, ",") + + return req +} + +// CreateGetUserTotalPayResp 获取用户累充 +func CreateGetUserTotalPayResp() *GetUserTotalPayResp { + return &GetUserTotalPayResp{ + BaseResponse: &responses.BaseResponse{}, + } +}