Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
abca5f01ed | ||
|
34de4b0401 | ||
|
71b93169e2 | ||
|
7dc4a177f9 | ||
|
9591e794f0 | ||
|
055fb8abb9 | ||
3652d43f34 | |||
|
7c96d7163b | ||
|
561eb1416a | ||
|
b9a481e71b | ||
5a8de98af3 | |||
6c3dfae18b | |||
b29010cac6 | |||
792d13fa32 |
@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
VERSION = "2025-04-27"
|
||||
VERSION = "2025-05-28"
|
||||
)
|
||||
|
||||
var HOST = requests.Host{
|
||||
@ -54,3 +54,24 @@ func (c *Client) GetProtocolByGameId(req *GetProtocolByGameIdRep) (resp *GetProt
|
||||
err = c.DoAction(req, resp)
|
||||
return
|
||||
}
|
||||
|
||||
// GetGameSimpleList 获取子游戏简单列表
|
||||
func (c *Client) GetGameSimpleList(req *GetGameSimpleListReq) (resp *GetGameSimpleListResp, err error) {
|
||||
resp = CreateGetGameSimpleListResp()
|
||||
err = c.DoAction(req, resp)
|
||||
return
|
||||
}
|
||||
|
||||
// GetGameServerV2 获取游戏服务器列表v2
|
||||
func (c *Client) GetGameServerV2(req *GetServerV2Request) (resp *GetServerV2Response, err error) {
|
||||
resp = CreateGetServerV2Response()
|
||||
err = c.DoAction(req, resp)
|
||||
return
|
||||
}
|
||||
|
||||
// GetGameCompany 获取单个根游戏信息
|
||||
func (c *Client) GetGameCompany(req *GetGameCompanyReq) (resp *GetGameCompanyResp, err error) {
|
||||
resp = CreateGetGameCompanyResp()
|
||||
err = c.DoAction(req, resp)
|
||||
return
|
||||
}
|
||||
|
@ -77,3 +77,46 @@ func TestGetProtocolByGameId(t *testing.T) {
|
||||
}
|
||||
fmt.Println(info)
|
||||
}
|
||||
|
||||
func TestGetGameSimpleList(t *testing.T) {
|
||||
client, err := NewClient()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
req := CreateGetGameSimpleListReq("8071,8062", "")
|
||||
info, err := client.GetGameSimpleList(req)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
fmt.Println(info)
|
||||
}
|
||||
|
||||
func TestGetGameServerV2(t *testing.T) {
|
||||
client, newErr := NewClient()
|
||||
if newErr != nil {
|
||||
panic(newErr)
|
||||
}
|
||||
req := CreateGetServerV2Request("n2", "", "")
|
||||
info, err := client.GetGameServerV2(req)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
fmt.Println(info)
|
||||
}
|
||||
|
||||
func TestGetGameCompany(t *testing.T) {
|
||||
client, err := NewClient()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
req := CreateGetGameCompanyReq("ascq")
|
||||
gameCompany, err := client.GetGameCompany(req)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
fmt.Println(gameCompany)
|
||||
fmt.Println(gameCompany.Data.System)
|
||||
}
|
||||
|
@ -162,3 +162,96 @@ func CreateGetGameInfoByIdResp() *GetGameInfoResp {
|
||||
BaseResponse: &responses.BaseResponse{},
|
||||
}
|
||||
}
|
||||
|
||||
type GetGameSimpleListReq struct {
|
||||
*requests.RpcRequest
|
||||
}
|
||||
|
||||
type GetGameSimpleListResp struct {
|
||||
*responses.BaseResponse
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Data map[string]GameSimple `json:"data"`
|
||||
}
|
||||
|
||||
type GameSimple struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
GameSign string `json:"game_sign"`
|
||||
}
|
||||
|
||||
// CreateGetGameSimpleListReq
|
||||
// gids 子游戏字符串,多个子游戏id用英文逗号分割
|
||||
// game_signs 根游戏标识字符串,多个标识用英文逗号分割
|
||||
func CreateGetGameSimpleListReq(gameIds string, gameSigns string) *GetGameSimpleListReq {
|
||||
req := &GetGameSimpleListReq{
|
||||
RpcRequest: &requests.RpcRequest{},
|
||||
}
|
||||
req.InitWithApiInfo(HOST, VERSION, "/api/game/getSimpleList")
|
||||
tmpParams := make(map[string]string)
|
||||
if gameIds != "" {
|
||||
tmpParams["gids"] = gameIds
|
||||
}
|
||||
if gameSigns != "" {
|
||||
tmpParams["game_signs"] = gameSigns
|
||||
}
|
||||
req.FormParams = tmpParams
|
||||
|
||||
req.Method = requests.POST
|
||||
return req
|
||||
}
|
||||
|
||||
func CreateGetGameSimpleListResp() *GetGameSimpleListResp {
|
||||
return &GetGameSimpleListResp{
|
||||
BaseResponse: &responses.BaseResponse{},
|
||||
}
|
||||
}
|
||||
|
||||
// GameCompany
|
||||
// 获取根游戏记录
|
||||
type GameCompany struct {
|
||||
Id int `json:"id"`
|
||||
GameSign string `json:"game_sign"`
|
||||
Name string `json:"name"`
|
||||
GameName string `json:"game_name"`
|
||||
ContractName string `json:"contract_name"`
|
||||
PayKey string `json:"pay_key"`
|
||||
LoginKey string `json:"login_key"`
|
||||
LoginUrlH5 string `json:"login_url_h5"`
|
||||
LoginUrlIos string `json:"login_url_ios"`
|
||||
LoginUrlAndroid string `json:"login_url_android"`
|
||||
PayUrl string `json:"pay_url"`
|
||||
Ext string `json:"ext"`
|
||||
Status int `json:"status"`
|
||||
Company string `json:"company"`
|
||||
System string `json:"system"`
|
||||
Sync int `json:"sync"`
|
||||
Type int `json:"type"`
|
||||
GameProductId int `json:"game_product_id"`
|
||||
}
|
||||
type GetGameCompanyReq struct {
|
||||
*requests.RpcRequest
|
||||
}
|
||||
type GetGameCompanyResp struct {
|
||||
*responses.BaseResponse
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Data GameCompany `json:"data"`
|
||||
}
|
||||
|
||||
func CreateGetGameCompanyReq(gameSign string) *GetGameCompanyReq {
|
||||
req := &GetGameCompanyReq{
|
||||
RpcRequest: &requests.RpcRequest{},
|
||||
}
|
||||
req.InitWithApiInfo(HOST, VERSION, "/api/game/getGameCompanyBySign")
|
||||
req.FormParams = map[string]string{
|
||||
"gameSign": gameSign,
|
||||
}
|
||||
req.Method = requests.POST
|
||||
return req
|
||||
}
|
||||
func CreateGetGameCompanyResp() *GetGameCompanyResp {
|
||||
return &GetGameCompanyResp{
|
||||
BaseResponse: &responses.BaseResponse{},
|
||||
}
|
||||
}
|
||||
|
107
services/game/game_server.go
Normal file
107
services/game/game_server.go
Normal file
@ -0,0 +1,107 @@
|
||||
package game
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
gameServerKey = "gaoreapi"
|
||||
)
|
||||
|
||||
// GetGameServerSign 子游戏区服信息,特有验签
|
||||
func GetGameServerSign(gameId int) (ts int64, sign string) {
|
||||
ts = time.Now().Unix()
|
||||
hash := md5.New()
|
||||
hash.Write([]byte(fmt.Sprintf("%v%v%v", gameId, ts, gameServerKey)))
|
||||
hashBytes := hash.Sum(nil)
|
||||
sign = hex.EncodeToString(hashBytes)
|
||||
return
|
||||
}
|
||||
|
||||
type GetServerIdRequest struct {
|
||||
*requests.RpcRequest
|
||||
}
|
||||
|
||||
type GetServerIdResponse struct {
|
||||
*responses.BaseResponse
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Data map[string]string `json:"data"`
|
||||
}
|
||||
|
||||
// CreateGetServerIdRequest
|
||||
// Deprecated 方法已废弃,不要用
|
||||
func CreateGetServerIdRequest(gameId int) (req *GetServerIdRequest) {
|
||||
req = &GetServerIdRequest{
|
||||
RpcRequest: &requests.RpcRequest{},
|
||||
}
|
||||
req.InitWithApiInfo(HOST, VERSION, "/api/game/getServerId")
|
||||
// 获取时间戳、签名
|
||||
ts, sign := GetGameServerSign(gameId)
|
||||
|
||||
req.FormParams = map[string]string{
|
||||
"appid": fmt.Sprintf("%v", gameId),
|
||||
"time": fmt.Sprintf("%v", ts),
|
||||
"sign": sign,
|
||||
}
|
||||
|
||||
req.Method = requests.POST
|
||||
return
|
||||
}
|
||||
|
||||
// CreateGetServerIdResponse
|
||||
// Deprecated 方法已废弃,不要用
|
||||
func CreateGetServerIdResponse() (response *GetServerIdResponse) {
|
||||
response = &GetServerIdResponse{
|
||||
BaseResponse: &responses.BaseResponse{},
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// --------------游戏区服v2列表查询----------
|
||||
|
||||
// GetServerV2Request 请求结构体
|
||||
type GetServerV2Request struct {
|
||||
*requests.RpcRequest
|
||||
}
|
||||
|
||||
type GetServerV2Response struct {
|
||||
*responses.BaseResponse
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Data []GameServerV2 `json:"data"`
|
||||
}
|
||||
|
||||
type GameServerV2 struct {
|
||||
ServerId int `json:"server_id"`
|
||||
Name string `json:"name"`
|
||||
GameSign string `json:"game_sign"`
|
||||
ServerSign int `json:"server_sign"`
|
||||
}
|
||||
|
||||
func CreateGetServerV2Request(gameSign string, serverSigns string, types string) (req *GetServerV2Request) {
|
||||
req = &GetServerV2Request{
|
||||
RpcRequest: &requests.RpcRequest{},
|
||||
}
|
||||
req.InitWithApiInfo(HOST, VERSION, "/api/game/getServerV2")
|
||||
|
||||
req.FormParams = map[string]string{
|
||||
"game_sign": gameSign,
|
||||
"server_signs": serverSigns,
|
||||
"types": types,
|
||||
}
|
||||
req.Method = requests.POST
|
||||
return
|
||||
}
|
||||
|
||||
func CreateGetServerV2Response() (response *GetServerV2Response) {
|
||||
response = &GetServerV2Response{
|
||||
BaseResponse: &responses.BaseResponse{},
|
||||
}
|
||||
return
|
||||
}
|
@ -13,41 +13,45 @@ type GetLoginInfoByIdReq struct {
|
||||
UserName string `position:"Body" field:"uname"`
|
||||
}
|
||||
|
||||
type PayInfo struct {
|
||||
HiddenAlipay int `json:"hide_alipay"`
|
||||
HiddenWx int `json:"hide_wx"`
|
||||
HiddenUnionPay int `json:"hide_union_pay"`
|
||||
}
|
||||
|
||||
type GameVersionInfo struct {
|
||||
AppName string `json:"app_name"`
|
||||
AppID string `json:"app_id"`
|
||||
LoginURL string `json:"login_url"`
|
||||
PayURL string `json:"pay_url"`
|
||||
GameURL string `json:"game_url"`
|
||||
PayCallbackURL string `json:"pay_callback_url"`
|
||||
IsH5Logout int `json:"is_h5_logout"`
|
||||
HideWindow int `json:"hidewindow"`
|
||||
GameVersion string `json:"version"`
|
||||
GameSign string `json:"game_sign"`
|
||||
GameSignName string `json:"game_sign_name"`
|
||||
GameSignID int `json:"game_sign_id"`
|
||||
IsYsdk int `json:"is_ysdk"`
|
||||
Company string `json:"company"`
|
||||
CompanyKf string `json:"company_kf"`
|
||||
CompanyProto string `json:"company_proto"`
|
||||
CompanySms string `json:"company_sms"`
|
||||
KfStatus int `json:"kf_status"`
|
||||
PopupTime int `json:"popup_time"`
|
||||
GameId int `json:"game_id"`
|
||||
ScreenType int `json:"screen_type"`
|
||||
GameSwitch int `json:"game_switch"` // 根据上下文,0 或 1 的整数表示布尔值
|
||||
ExtData map[string]any `json:"ext_data"`
|
||||
OsName string `json:"os_name"`
|
||||
PayInfo PayInfo `json:"pay_info"`
|
||||
}
|
||||
|
||||
type GetLoginInfoByIdResp struct {
|
||||
*responses.BaseResponse
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Data struct {
|
||||
AppName string `json:"app_name"`
|
||||
AppID string `json:"app_id"`
|
||||
LoginURL string `json:"login_url"`
|
||||
PayURL string `json:"pay_url"`
|
||||
GameURL string `json:"game_url"`
|
||||
PayCallbackURL string `json:"pay_callback_url"`
|
||||
IsH5Logout int `json:"is_h5_logout"`
|
||||
HideWindow int `json:"hidewindow"`
|
||||
GameVersion string `json:"version"`
|
||||
GameSign string `json:"game_sign"`
|
||||
GameSignName string `json:"game_sign_name"`
|
||||
GameSignID string `json:"game_sign_id"`
|
||||
IsYsdk int `json:"is_ysdk"`
|
||||
Company string `json:"company"`
|
||||
CompanyKf string `json:"company_kf"`
|
||||
CompanyProto string `json:"company_proto"`
|
||||
CompanySms string `json:"company_sms"`
|
||||
KfStatus string `json:"kf_status"`
|
||||
PopupTime int `json:"popup_time"`
|
||||
PayInfo struct {
|
||||
HiddenAlipay int `json:"hide_alipay"`
|
||||
HiddenWx int `json:"hide_wx"`
|
||||
HiddenUnionPay int `json:"hide_union_pay"`
|
||||
} `json:"pay_info"`
|
||||
GameID string `json:"game_id"`
|
||||
ScreenType string `json:"screen_type"`
|
||||
GameSwitch int `json:"game_switch"` // 根据上下文,0 或 1 的整数表示布尔值
|
||||
ExtData map[string]any `json:"ext_data"`
|
||||
OsName string `json:"os_name"`
|
||||
} `json:"data"`
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Data GameVersionInfo `json:"data"`
|
||||
}
|
||||
|
||||
func CreateGetLoginInfoByIdReq(gameId int, gameVersion string) *GetLoginInfoByIdReq {
|
||||
|
@ -16,7 +16,8 @@ type PutOssResponse struct {
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Data struct {
|
||||
Url string `json:"url"`
|
||||
Url string `json:"url"`
|
||||
SavePath string `json:"save_path"`
|
||||
}
|
||||
}
|
||||
|
||||
|
42
services/passport/client.go
Normal file
42
services/passport/client.go
Normal file
@ -0,0 +1,42 @@
|
||||
package passport
|
||||
|
||||
import (
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||
)
|
||||
|
||||
const (
|
||||
VERSION = "2025-05-28"
|
||||
// 对称加密密钥
|
||||
appKey = "#gr*%com#"
|
||||
)
|
||||
|
||||
var HOST requests.Host = requests.Host{
|
||||
Default: "passport.gaore.com",
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
sdk.Client
|
||||
}
|
||||
|
||||
func NewClient() (client *Client, err error) {
|
||||
client = new(Client)
|
||||
err = client.Init()
|
||||
return
|
||||
}
|
||||
|
||||
// GetUserList
|
||||
// 获取用户列表
|
||||
func (c *Client) GetUserList(req *GetUserListRequest) (response *GetUserListResponse, err error) {
|
||||
response = CreateGetUserListResponse()
|
||||
err = c.DoAction(req, response)
|
||||
return
|
||||
}
|
||||
|
||||
// GetUserRoleList
|
||||
// 获取用户角色列表
|
||||
func (c *Client) GetUserRoleList(req *GetUserRoleListRequest) (response *GetUserRoleListResponse, err error) {
|
||||
response = CreateGetUserRoleListResponse()
|
||||
err = c.DoAction(req, response)
|
||||
return
|
||||
}
|
33
services/passport/client_test.go
Normal file
33
services/passport/client_test.go
Normal file
@ -0,0 +1,33 @@
|
||||
package passport
|
||||
|
||||
import "testing"
|
||||
|
||||
// 单元测试
|
||||
|
||||
func TestGetUserList(t *testing.T) {
|
||||
client, err := NewClient()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
req := CreateGetUserListRequest("ws45265737")
|
||||
resp, err := client.GetUserList(req)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
t.Logf("resp code:%+v", resp.Code)
|
||||
t.Logf("resp data:%+v", resp.Data)
|
||||
}
|
||||
|
||||
func TestGetUserRoleList(t *testing.T) {
|
||||
client, err := NewClient()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
req := CreateGetUserRoleListRequest(63610626, 2850)
|
||||
resp, err := client.GetUserRoleList(req)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
t.Logf("resp code:%+v", resp.Code)
|
||||
t.Logf("resp data:%+v", resp.Data)
|
||||
}
|
114
services/passport/userinfo.go
Normal file
114
services/passport/userinfo.go
Normal file
@ -0,0 +1,114 @@
|
||||
package passport
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||
"time"
|
||||
)
|
||||
|
||||
type GetUserListRequest struct {
|
||||
*requests.RpcRequest
|
||||
}
|
||||
|
||||
type GetUserListResponse struct {
|
||||
*responses.BaseResponse
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Data []UserInfo `json:"data"`
|
||||
}
|
||||
|
||||
type UserInfo struct {
|
||||
UserName string `json:"user_name"` // 用户名
|
||||
Uid string `json:"uid"` // uid
|
||||
Telephone string `json:"telephone"` // 手机号
|
||||
}
|
||||
|
||||
// CreateGetUserListRequest 获取玩家用户列表
|
||||
func CreateGetUserListRequest(userName string) (req *GetUserListRequest) {
|
||||
ts, sign := GetSign()
|
||||
|
||||
req = &GetUserListRequest{
|
||||
RpcRequest: &requests.RpcRequest{},
|
||||
}
|
||||
req.InitWithApiInfo(HOST, VERSION, "/remote_login.php")
|
||||
req.FormParams = map[string]string{
|
||||
"act": "info",
|
||||
"do": "get_user_list",
|
||||
"user_names": userName,
|
||||
"time": fmt.Sprintf("%v", ts),
|
||||
"sign": sign,
|
||||
}
|
||||
|
||||
req.Method = requests.POST
|
||||
return
|
||||
}
|
||||
|
||||
func CreateGetUserListResponse() (response *GetUserListResponse) {
|
||||
response = &GetUserListResponse{
|
||||
BaseResponse: &responses.BaseResponse{},
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
type GetUserRoleListRequest struct {
|
||||
*requests.RpcRequest
|
||||
}
|
||||
|
||||
type GetUserRoleListResponse struct {
|
||||
*responses.BaseResponse
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Data []UserRoleInfo `json:"data"`
|
||||
}
|
||||
|
||||
type UserRoleInfo struct {
|
||||
Uid string `json:"uid"` // uid
|
||||
GameId string `json:"game_id"` // 子游戏id
|
||||
RoleId string `json:"role_id"` // 角色id
|
||||
RoleName string `json:"role_name"` // 角色名
|
||||
RoleServer string `json:"role_server"` // 角色服务器名
|
||||
AddTime string `json:"add_time"` // 创建时间戳
|
||||
UpdateTime string `json:"update_time"` // 更新时间戳
|
||||
}
|
||||
|
||||
// GetSign 封装一个方法,获取当天时间戳和api签名
|
||||
func GetSign() (ts int64, sign string) {
|
||||
ts = time.Now().Unix()
|
||||
hash := md5.New()
|
||||
hash.Write([]byte(fmt.Sprintf("%v%v", ts, appKey)))
|
||||
hashBytes := hash.Sum(nil)
|
||||
sign = hex.EncodeToString(hashBytes)
|
||||
return
|
||||
}
|
||||
|
||||
// CreateGetUserRoleListRequest 获取玩家角色列表
|
||||
func CreateGetUserRoleListRequest(uid int, gameId int) (req *GetUserRoleListRequest) {
|
||||
ts, sign := GetSign()
|
||||
|
||||
req = &GetUserRoleListRequest{
|
||||
RpcRequest: &requests.RpcRequest{},
|
||||
}
|
||||
req.InitWithApiInfo(HOST, VERSION, "/remote_login.php")
|
||||
req.FormParams = map[string]string{
|
||||
"act": "info",
|
||||
"do": "user_role",
|
||||
"method": "get",
|
||||
"uid": fmt.Sprintf("%d", uid),
|
||||
"game_id": fmt.Sprintf("%d", gameId),
|
||||
"time": fmt.Sprintf("%v", ts),
|
||||
"sign": sign,
|
||||
}
|
||||
|
||||
req.Method = requests.POST
|
||||
return
|
||||
}
|
||||
|
||||
func CreateGetUserRoleListResponse() (response *GetUserRoleListResponse) {
|
||||
response = &GetUserRoleListResponse{
|
||||
BaseResponse: &responses.BaseResponse{},
|
||||
}
|
||||
return
|
||||
}
|
@ -54,3 +54,11 @@ func (c *Client) MerchantConfigDebug(req *merchantConfigDebugRequest) (response
|
||||
err = c.DoAction(req, response)
|
||||
return
|
||||
}
|
||||
|
||||
// GetOrderState
|
||||
// 获取订单状态
|
||||
func (c *Client) GetOrderState(req *GetOrderStateRequest) (response *GetOrderStateResponse, err error) {
|
||||
response = CreateGetOrderStateResponse()
|
||||
err = c.DoAction(req, response)
|
||||
return
|
||||
}
|
||||
|
@ -24,3 +24,18 @@ func TestClient_GetUserInfo(t *testing.T) {
|
||||
//fmt.Println(resp.GetHttpContentString())
|
||||
//fmt.Println(resp.GetHttpHeaders())
|
||||
}
|
||||
|
||||
func TestGetOrderState(t *testing.T) {
|
||||
getOrderStateRequest := CreateGetOrderStateRequest("202112060000193551730")
|
||||
client, err := NewClient()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
getOrderStateResponse, err := client.GetOrderState(getOrderStateRequest)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
t.Log(getOrderStateResponse.GetHttpContentString())
|
||||
}
|
||||
|
44
services/pay/get_order_state.go
Normal file
44
services/pay/get_order_state.go
Normal file
@ -0,0 +1,44 @@
|
||||
package pay
|
||||
|
||||
import (
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||
)
|
||||
|
||||
type GetOrderStateRequest struct {
|
||||
*requests.RpcRequest
|
||||
OrderId string `position:"Body" field:"orderid" default:"" `
|
||||
}
|
||||
|
||||
type GetOrderStateResponse struct {
|
||||
*responses.BaseResponse
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Data struct {
|
||||
Orderid string `json:"orderid"` // 订单号
|
||||
Succ string `json:"succ"` // 是否成功
|
||||
Money string `json:"money"` // 支付金额
|
||||
UserName string `json:"user_name"` // 用户名
|
||||
BNum string `json:"b_num"`
|
||||
GameId string `json:"game_id"` // 游戏id
|
||||
PayDate string `json:"pay_date"` // 付费日期
|
||||
SyncDate string `json:"sync_date"` // 回调时间
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
func CreateGetOrderStateRequest(orderId string) (req *GetOrderStateRequest) {
|
||||
req = &GetOrderStateRequest{
|
||||
RpcRequest: &requests.RpcRequest{},
|
||||
OrderId: orderId,
|
||||
}
|
||||
req.InitWithApiInfo(HOST, VERSION, "/api/user/getOrderState")
|
||||
req.Method = requests.POST
|
||||
return
|
||||
}
|
||||
|
||||
func CreateGetOrderStateResponse() (response *GetOrderStateResponse) {
|
||||
response = &GetOrderStateResponse{
|
||||
BaseResponse: &responses.BaseResponse{},
|
||||
}
|
||||
return
|
||||
}
|
@ -15,7 +15,7 @@ const (
|
||||
)
|
||||
|
||||
var HOST = requests.Host{
|
||||
Default: "sms.gaore.com:8804",
|
||||
Default: "sms.gaore.com",
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
@ -83,17 +83,6 @@ func (c *Client) SendSms(req *SendSmsRequest) (resp *SendSmsResponse, err error)
|
||||
err = errors.New("type is empty")
|
||||
return
|
||||
}
|
||||
|
||||
if req.Expired == 0 {
|
||||
err = errors.New("expired is empty")
|
||||
return
|
||||
}
|
||||
|
||||
if req.Code == 0 {
|
||||
err = errors.New("code is empty")
|
||||
return
|
||||
}
|
||||
|
||||
resp = CreateSendSmsResponse()
|
||||
err = c.DoAction(req, resp)
|
||||
return
|
||||
|
@ -2,6 +2,7 @@ package sms
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@ -37,9 +38,9 @@ func TestClient_SendEmail(t *testing.T) {
|
||||
|
||||
func TestClient_SendFeiShuWebHook(t *testing.T) {
|
||||
//req := CreateSendFeiShuWebHookRequest(SendFeiShuWebHookParam{
|
||||
// Do: "sendCardText",
|
||||
// Do: FeiShuWebHookDoTypeSendRichText,
|
||||
// Token: "b762f80c-fe4f-4182-b48e-5c78041592bc",
|
||||
// Content: "[{\"tag\":\"div\",\"text\":{\"tag\":\"plain_text\",\"content\":\"请完成以下任务:\"}},{\"tag\":\"action\",\"actions\":[{\"tag\":\"button\",\"text\":{\"tag\":\"plain_text\",\"content\":\"查看详情\"},\"type\":\"primary\",\"url\":\"https:\\\\\\\\/\\\\\\\\/example.com\\\\\\\\/task\"}]}]",
|
||||
// Content: "[[{\"tag\":\"text\",\"text\":\"富文本信息: \"},{\"tag\":\"a\",\"text\":\"请查看\",\"href\":\"http://www.example.com/\"},{\"tag\":\"at\",\"user_id\":\"ou_18eac8********17ad4f02e8bbbb\"}]]",
|
||||
// Title: "卡片主标题",
|
||||
// TitleColor: "purple",
|
||||
//})
|
||||
@ -48,10 +49,10 @@ func TestClient_SendFeiShuWebHook(t *testing.T) {
|
||||
//if err != nil {
|
||||
// panic(err)
|
||||
//}
|
||||
//fmt.Println(resp)
|
||||
//
|
||||
//fmt.Println(resp.Msg)
|
||||
|
||||
//req2 := CreateSendFeiShuWebHookRequest(SendFeiShuWebHookParam{
|
||||
// Do: "sendSimpleText",
|
||||
// Do: FeiShuWebHookDoTypeSendSimpleText,
|
||||
// Token: "b762f80c-fe4f-4182-b48e-5c78041592bc",
|
||||
// Content: " - 苹果ID:XXXX\n - 游戏ID:XXXX\n - bundleID:XXXX\n - 应用名:XXX\n - 下架时间:2025-04-18 12:36:52\n - IP:XX(城市A省份)、XX(城市B省份);说明:XX为具体的IP,括号内为IP对应的城市;",
|
||||
//})
|
||||
@ -63,24 +64,24 @@ func TestClient_SendFeiShuWebHook(t *testing.T) {
|
||||
//fmt.Println(resp2)
|
||||
|
||||
//[
|
||||
// [
|
||||
// {
|
||||
// "tag": "text",
|
||||
// "text": "苹果ID:XXXX"
|
||||
// }
|
||||
// ],
|
||||
// [
|
||||
// {
|
||||
// "tag": "text",
|
||||
// "text": "游戏ID:XXXX"
|
||||
// }
|
||||
// ]
|
||||
// [
|
||||
// {
|
||||
// "tag": "text",
|
||||
// "text": "苹果ID:XXXX"
|
||||
// }
|
||||
// ],
|
||||
// [
|
||||
// {
|
||||
// "tag": "text",
|
||||
// "text": "游戏ID:XXXX"
|
||||
// }
|
||||
// ]
|
||||
//]
|
||||
|
||||
req3 := CreateSendFeiShuWebHookRequest(SendFeiShuWebHookParam{
|
||||
TitleColor: "purple",
|
||||
Title: "监控报警",
|
||||
Do: "sendCardText",
|
||||
Do: FeiShuWebHookDoTypeSendCardText,
|
||||
Token: "b762f80c-fe4f-4182-b48e-5c78041592bc",
|
||||
Content: "[{\"tag\":\"div\",\"text\":{\"tag\":\"plain_text\",\"content\":\"苹果ID:XXXX\"}},{\"tag\":\"div\",\"text\":{\"tag\":\"plain_text\",\"content\":\"游戏ID:XXXX\"}}]",
|
||||
})
|
||||
@ -93,14 +94,45 @@ func TestClient_SendFeiShuWebHook(t *testing.T) {
|
||||
fmt.Println(resp3)
|
||||
}
|
||||
|
||||
func TestClient_SendSms(t *testing.T) {
|
||||
func TestClient_SendSmsCode(t *testing.T) {
|
||||
req := CreateSendSmsRequest(SendSmsParam{
|
||||
Mobile: "18320021439",
|
||||
Type: SmsTypeRegister,
|
||||
Code: 123456,
|
||||
Expired: 5,
|
||||
Mobile: "18320021439",
|
||||
Type: SmsTypeBindPhone,
|
||||
Replaces: []Item{{
|
||||
Key: ReplaceKeyCode,
|
||||
Value: "6379",
|
||||
}, {
|
||||
Key: ReplaceKeySecond,
|
||||
Value: "120",
|
||||
}},
|
||||
})
|
||||
|
||||
req.Domain = requests.Host{
|
||||
Default: "127.0.0.1:8804",
|
||||
}
|
||||
|
||||
sms, err := client.SendSms(req)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
fmt.Println(sms)
|
||||
}
|
||||
|
||||
func TestClient_SendSmsUrl(t *testing.T) {
|
||||
req := CreateSendSmsRequest(SendSmsParam{
|
||||
Mobile: "18320021439",
|
||||
Type: TemplateTypeOrderComplete,
|
||||
Replaces: []Item{{
|
||||
Key: ReplaceKeyUrl,
|
||||
Value: "http://www.baidu.com",
|
||||
}},
|
||||
})
|
||||
|
||||
req.Domain = requests.Host{
|
||||
Default: "127.0.0.1:8804",
|
||||
}
|
||||
|
||||
sms, err := client.SendSms(req)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@ -32,7 +32,7 @@ func CreateSendEmailRequest(param SendEmailParam) (req *SendEmailRequest) {
|
||||
Body: param.Body,
|
||||
FromName: param.FromName,
|
||||
}
|
||||
req.InitWithApiInfo(HOST, VERSION, "/email/send")
|
||||
req.InitWithApiInfo(HOST, VERSION, "/v1/email/send")
|
||||
req.Method = requests.POST
|
||||
return
|
||||
}
|
||||
|
@ -19,8 +19,16 @@ type SendFeiShuWebHookResponse struct {
|
||||
FeishuData string `json:"feishu_data"`
|
||||
}
|
||||
|
||||
type FeiShuWebHookDoType = string
|
||||
|
||||
const (
|
||||
FeiShuWebHookDoTypeSendSimpleText FeiShuWebHookDoType = "sendSimpleText"
|
||||
FeiShuWebHookDoTypeSendRichText FeiShuWebHookDoType = "sendRichText"
|
||||
FeiShuWebHookDoTypeSendCardText FeiShuWebHookDoType = "sendCardText"
|
||||
)
|
||||
|
||||
type SendFeiShuWebHookParam struct {
|
||||
Do string
|
||||
Do FeiShuWebHookDoType
|
||||
Token string
|
||||
Content string
|
||||
Title string
|
||||
@ -36,7 +44,7 @@ func CreateSendFeiShuWebHookRequest(param SendFeiShuWebHookParam) (req *SendFeiS
|
||||
Title: param.Title,
|
||||
TitleColor: param.TitleColor,
|
||||
}
|
||||
req.InitWithApiInfo(HOST, VERSION, "/feishu/webhook_send")
|
||||
req.InitWithApiInfo(HOST, VERSION, "/v1/feishu/webhook_send")
|
||||
req.Method = requests.POST
|
||||
return
|
||||
}
|
||||
|
@ -5,12 +5,24 @@ import (
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||
)
|
||||
|
||||
type ReplaceKey = string
|
||||
|
||||
const (
|
||||
ReplaceKeyCode ReplaceKey = "${code}" // 验证码
|
||||
ReplaceKeySecond ReplaceKey = "${second}" // 秒数
|
||||
ReplaceKeyUrl ReplaceKey = "${url}" // 链接
|
||||
)
|
||||
|
||||
type Item struct {
|
||||
Key ReplaceKey // 要替换的key
|
||||
Value string // 要替换的值
|
||||
}
|
||||
|
||||
type SendSmsRequest struct {
|
||||
*requests.JsonRequest
|
||||
Mobile string `position:"Json" field:"mobile"`
|
||||
Type string `position:"Json" field:"type"`
|
||||
Expired int64 `position:"Json" field:"expired"`
|
||||
Code int64 `position:"Json" field:"code"`
|
||||
Mobile string `position:"Json" field:"mobile"`
|
||||
Type string `position:"Json" field:"type"`
|
||||
Replaces []Item `position:"Json" field:"replaces"`
|
||||
}
|
||||
|
||||
type SendSmsResponse struct {
|
||||
@ -20,14 +32,16 @@ type SendSmsResponse struct {
|
||||
type SmsType = string
|
||||
|
||||
const (
|
||||
SmsTypeRegister SmsType = "reg" // 注册
|
||||
SmsTypeRegister SmsType = "reg" // 注册
|
||||
SmsTypeBindPhone SmsType = "bind_phone" // 绑定手机号
|
||||
TemplateTypeOrderComplete SmsType = "kf_order_complete" // 客服工单完成
|
||||
TemplateTypeKFOrderAdditional SmsType = "kf_order_additional" // 客服工单完成
|
||||
)
|
||||
|
||||
type SendSmsParam struct {
|
||||
Mobile string // 手机号
|
||||
Type SmsType // 验证码类型
|
||||
Expired int64 // 过期时间,秒数
|
||||
Code int64 // 验证码
|
||||
Mobile string // 手机号
|
||||
Type SmsType // 验证码类型
|
||||
Replaces []Item
|
||||
}
|
||||
|
||||
func CreateSendSmsRequest(param SendSmsParam) (req *SendSmsRequest) {
|
||||
@ -35,10 +49,9 @@ func CreateSendSmsRequest(param SendSmsParam) (req *SendSmsRequest) {
|
||||
JsonRequest: &requests.JsonRequest{},
|
||||
Mobile: param.Mobile,
|
||||
Type: param.Type,
|
||||
Expired: param.Expired,
|
||||
Code: param.Code,
|
||||
Replaces: param.Replaces,
|
||||
}
|
||||
req.InitWithApiInfo(HOST, VERSION, "/sms/agg/send")
|
||||
req.InitWithApiInfo(HOST, VERSION, "/v1/sms/send")
|
||||
req.Method = requests.POST
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user