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.
go-library/service/ejiaofei/money_jkuser.go

42 lines
1.3 KiB

2 years ago
package ejiaofei
import (
2 years ago
"context"
2 years ago
"encoding/xml"
"fmt"
2 years ago
"github.com/dtapps/go-library/utils/gorequest"
2 years ago
"net/http"
)
type MoneyJkUserResponse struct {
2 years ago
XMLName xml.Name `xml:"response"`
LastMoney float64 `xml:"lastMoney"` // 用户余额
Tag int64 `xml:"tag"` // 用户状态0正常 1暂停
Error int64 `xml:"error"` // 错误提示
2 years ago
}
type MoneyJkUserResult struct {
Result MoneyJkUserResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
}
func newMoneyJkUserResult(result MoneyJkUserResponse, body []byte, http gorequest.Response) *MoneyJkUserResult {
return &MoneyJkUserResult{Result: result, Body: body, Http: http}
}
2 years ago
// MoneyJkUser 用户余额查询
func (c *Client) MoneyJkUser(ctx context.Context) (*MoneyJkUserResult, error) {
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)
if err != nil {
return newMoneyJkUserResult(MoneyJkUserResponse{}, request.ResponseBody, request), err
}
// 定义
var response MoneyJkUserResponse
err = xml.Unmarshal(request.ResponseBody, &response)
return newMoneyJkUserResult(response, request.ResponseBody, request), err
2 years ago
}