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.
45 lines
1.4 KiB
45 lines
1.4 KiB
3 years ago
|
package ejiaofei
|
||
|
|
||
|
import (
|
||
|
"encoding/xml"
|
||
|
"fmt"
|
||
2 years ago
|
"go.dtapp.net/library/gorequest"
|
||
3 years ago
|
"net/http"
|
||
|
)
|
||
|
|
||
3 years ago
|
type CheckCostResponse struct {
|
||
3 years ago
|
XMLName xml.Name `xml:"response"`
|
||
|
UserID string `xml:"userid"` // 用户账号
|
||
|
OrderID string `xml:"orderid"` // 用户提交订单号
|
||
|
Face float64 `xml:"face"` // 官方价格
|
||
|
Price float64 `xml:"price"` // 用户成本价
|
||
|
Error int `xml:"error"` // 错误提示
|
||
|
}
|
||
|
|
||
3 years ago
|
type CheckCostResult struct {
|
||
2 years ago
|
Result CheckCostResponse // 结果
|
||
|
Body []byte // 内容
|
||
|
Http gorequest.Response // 请求
|
||
|
Err error // 错误
|
||
3 years ago
|
}
|
||
|
|
||
2 years ago
|
func NewCheckCostResult(result CheckCostResponse, body []byte, http gorequest.Response, err error) *CheckCostResult {
|
||
|
return &CheckCostResult{Result: result, Body: body, Http: http, Err: err}
|
||
3 years ago
|
}
|
||
|
|
||
3 years ago
|
// CheckCost 会员订单成本价查询接口
|
||
2 years ago
|
func (app *App) CheckCost(orderId string) *CheckCostResult {
|
||
3 years ago
|
// 参数
|
||
|
param := NewParams()
|
||
2 years ago
|
param.Set("orderid", orderId)
|
||
3 years ago
|
params := app.NewParamsWith(param)
|
||
|
// 签名
|
||
2 years ago
|
app.signStr = fmt.Sprintf("userid%vpwd%vorderid%v", app.userId, app.pwd, orderId)
|
||
3 years ago
|
// 请求
|
||
2 years ago
|
request, err := app.request("http://api.ejiaofei.net:11140/checkCost.do", params, http.MethodGet)
|
||
3 years ago
|
// 定义
|
||
|
var response CheckCostResponse
|
||
2 years ago
|
err = xml.Unmarshal(request.ResponseBody, &response)
|
||
|
return NewCheckCostResult(response, request.ResponseBody, request, err)
|
||
3 years ago
|
}
|