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

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package ejiaofei
import (
"context"
"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 用户余额查询
func (c *Client) MoneyJkUser(ctx context.Context) *MoneyJkUserResult {
// 签名
c.config.signStr = fmt.Sprintf("userid%vpwd%v", c.GetUserId(), c.GetPwd())
// 请求
request, err := c.request(ctx, apiUrl+"/money_jkuser.do", map[string]interface{}{}, http.MethodGet)
// 定义
var response MoneyJkUserResponse
err = xml.Unmarshal(request.ResponseBody, &response)
return newMoneyJkUserResult(response, request.ResponseBody, request, err)
}