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

57 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 ChOngZhiJkOrdersResponse struct {
XMLName xml.Name `xml:"response"`
UserID string `xml:"userid"` // 会员账号
PorderID string `xml:"Porderid"` // 鼎信平台订单号
OrderID string `xml:"orderid"` // 用户订单号
Account string `xml:"account"` // 需要充值的手机号码
Face string `xml:"face"` // 充值面值
Amount string `xml:"amount"` // 购买数量
StartTime string `xml:"starttime"` // 开始时间
State string `xml:"state"` // 订单状态
EndTime string `xml:"endtime"` // 结束时间
Error string `xml:"error"` // 错误提示
}
type ChOngZhiJkOrdersResult struct {
Result ChOngZhiJkOrdersResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
Err error // 错误
}
func newChOngZhiJkOrdersResult(result ChOngZhiJkOrdersResponse, body []byte, http gorequest.Response, err error) *ChOngZhiJkOrdersResult {
return &ChOngZhiJkOrdersResult{Result: result, Body: body, Http: http, Err: err}
}
// ChOngZhiJkOrders 话费充值接口
// orderid 用户提交的订单号 用户提交的订单号最长32位用户保证其唯一性
// face 充值面值 以元为单位包含10、20、30、50、100、200、300、500 移动联通电信
// account 手机号码 需要充值的手机号码
func (c *Client) ChOngZhiJkOrders(ctx context.Context, orderID string, face int, account string) *ChOngZhiJkOrdersResult {
// 参数
param := gorequest.NewParams()
param.Set("orderid", orderID)
param.Set("face", face)
param.Set("account", account)
param.Set("amount", 1)
params := gorequest.NewParamsWith(param)
// 签名
c.config.signStr = fmt.Sprintf("userid%vpwd%vorderid%vface%vaccount%vamount1", c.GetUserId(), c.GetPwd(), orderID, face, account)
// 请求
request, err := c.request(ctx, apiUrl+"/chongzhi_jkorders.do", params, http.MethodGet)
// 定义
var response ChOngZhiJkOrdersResponse
err = xml.Unmarshal(request.ResponseBody, &response)
return newChOngZhiJkOrdersResult(response, request.ResponseBody, request, err)
}