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/txchongzhi.go

58 lines
2.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 TxChOngZhiParams struct {
OrderID string `json:"orderid"` // 用户提交的订单号 用户提交的订单号最长32位用户保证其唯一性
Account string `json:"account"` // QQ号 需要充值的QQ号
ProductID int `json:"productid"` // 产品id
Amount int `json:"amount"` // 购买数量
Ip string `json:"ip"` // 充值QQ号ip
Times string `json:"times"` // 时间戳 格式yyyyMMddhhmmss
}
type TxChOngZhiResponse struct {
XMLName xml.Name `xml:"response"`
UserID string `xml:"userid"` // 用户编号
PorderID string `xml:"Porderid"` // 鼎信平台订单号
OrderID string `xml:"orderid"` // 用户订单号
Account string `xml:"account"` // 需要充值的QQ号
ProductID int `xml:"productid"` // 充值产品id
Amount int `xml:"amount"` // 购买数量
State int `xml:"state"` // 订单状态
StartTime string `xml:"starttime"` // 开始时间
EndTime string `xml:"endtime"` // 结束时间
Error string `xml:"error"` // 错误提示
}
type TxChOngZhiResult struct {
Result TxChOngZhiResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
Err error // 错误
}
func newTxChOngZhiResult(result TxChOngZhiResponse, body []byte, http gorequest.Response, err error) *TxChOngZhiResult {
return &TxChOngZhiResult{Result: result, Body: body, Http: http, Err: err}
}
// TxChOngZhi 流量充值接口
func (c *Client) TxChOngZhi(ctx context.Context, notMustParams ...gorequest.Params) *TxChOngZhiResult {
// 参数
params := gorequest.NewParamsWith(notMustParams...)
// 签名
c.config.signStr = fmt.Sprintf("userid%vpwd%vorderid%vaccount%vproductid%vamount%vip%vtimes%v", c.GetUserId(), c.GetPwd(), params["orderid"], params["account"], params["productid"], params["amount"], params["ip"], params["times"])
// 请求
request, err := c.request(ctx, apiUrl+"/txchongzhi.do", params, http.MethodGet)
// 定义
var response TxChOngZhiResponse
err = xml.Unmarshal(request.ResponseBody, &response)
return newTxChOngZhiResult(response, request.ResponseBody, request, err)
}