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

43 lines
1.2 KiB

package ejiaofei
import (
"encoding/xml"
"fmt"
"net/http"
)
type CheckCostResponse struct {
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"` // 错误提示
}
type CheckCostResult struct {
Result CheckCostResponse // 结果
Body []byte // 内容
Err error // 错误
}
func NewCheckCostResult(result CheckCostResponse, body []byte, err error) *CheckCostResult {
return &CheckCostResult{Result: result, Body: body, Err: err}
}
// CheckCost 会员订单成本价查询接口
func (app *App) CheckCost(orderID string) *CheckCostResult {
// 参数
param := NewParams()
param.Set("orderid", orderID)
params := app.NewParamsWith(param)
// 签名
app.signStr = fmt.Sprintf("userid%vpwd%vorderid%v", app.UserID, app.Pwd, orderID)
// 请求
body, err := app.request("http://api.ejiaofei.net:11140/checkCost.do", params, http.MethodGet)
// 定义
var response CheckCostResponse
err = xml.Unmarshal(body, &response)
return NewCheckCostResult(response, body, err)
}