You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ejiaofei/money_jkuser.go

40 lines
1.2 KiB

2 years ago
package ejiaofei
import (
2 years ago
"context"
2 years ago
"encoding/xml"
"fmt"
"go.dtapp.net/gorequest"
"net/http"
)
type MoneyJkUserResponse struct {
XMLName xml.Name `xml:"response"`
LastMoney float64 `xml:"lastMoney"` // 用户余额
Tag int `xml:"tag"` // 用户状态0正常 1暂停
Error int `xml:"error"` // 错误提示
}
type MoneyJkUserResult struct {
Result MoneyJkUserResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
Err error // 错误
}
func newMoneyJkUserResult(result MoneyJkUserResponse, body []byte, http gorequest.Response, err error) *MoneyJkUserResult {
return &MoneyJkUserResult{Result: result, Body: body, Http: http, Err: err}
}
// MoneyJkUser 用户余额查询
2 years ago
func (c *Client) MoneyJkUser(ctx context.Context) *MoneyJkUserResult {
2 years ago
// 签名
2 years ago
c.config.signStr = fmt.Sprintf("userid%vpwd%v", c.GetUserId(), c.GetPwd())
2 years ago
// 请求
2 years ago
request, err := c.request(ctx, apiUrl+"/money_jkuser.do", map[string]interface{}{}, http.MethodGet)
2 years ago
// 定义
var response MoneyJkUserResponse
err = xml.Unmarshal(request.ResponseBody, &response)
return newMoneyJkUserResult(response, request.ResponseBody, request, err)
}