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.
kashangwl/api.outer-order.go

68 lines
3.2 KiB

2 years ago
package kashangwl
import (
2 years ago
"context"
2 years ago
"encoding/json"
"go.dtapp.net/gorequest"
)
type ApiOuterOrderResponse struct {
Code string `json:"code"`
Message string `json:"message"`
Data struct {
2 years ago
Id string `json:"id"` // 订单号
ProductId int `json:"product_id"` // 商品编号
2 years ago
ProductName string `json:"product_name"` // 商品名称
ProductType int `json:"product_type"` // 商品类型1充值2卡密3卡券4人工
ProductPrice string `json:"product_price"` // 售价
Quantity int `json:"quantity"` // 购买数量
TotalPrice string `json:"total_price"` // 总支付价格
RefundedAmount float64 `json:"refunded_amount"` // 已退款金额
2 years ago
BuyerCustomerId int `json:"buyer_customer_id"` // 买家编号
2 years ago
BuyerCustomerName string `json:"buyer_customer_name"` // 买家名称
2 years ago
SellerCustomerId int `json:"seller_customer_id"` // 卖家编号
2 years ago
SellerCustomerName string `json:"seller_customer_name"` // 卖家名称
State int `json:"state"` // 订单状态100等待发货101正在充值200交易成功500交易失败501未知状态
CreatedAt string `json:"created_at"` // 下单时间
RechargeAccount string `json:"recharge_account"` // 充值账号
ProgressInit int `json:"progress_init"` // 充值进度:初始值
ProgressNow int `json:"progress_now"` // 充值进度:现在值
ProgressTarget int `json:"progress_target"` // 充值进度:目标值
RechargeInfo string `json:"recharge_info"` // 返回信息
RechargeUrl string `json:"recharge_url"` // 卡密充值网址
Cards []struct {
No string `json:"no"`
Password string `json:"password"`
} `json:"cards"` //【卡密类订单】卡密
RechargeParams string `json:"recharge_params"` //【充值类订单】
2 years ago
OuterOrderId string `json:"outer_order_id,omitempty"` // 外部订单号
2 years ago
} `json:"data"`
}
type ApiOuterOrderResult struct {
Result ApiOuterOrderResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
Err error // 错误
}
func newApiOuterOrderResult(result ApiOuterOrderResponse, body []byte, http gorequest.Response, err error) *ApiOuterOrderResult {
return &ApiOuterOrderResult{Result: result, Body: body, Http: http, Err: err}
}
// ApiOuterOrder 使用外部订单号获取单个订单信息
// 仅能获取自己购买的订单
// http://doc.cqmeihu.cn/sales/outer-order-info.html
2 years ago
func (c *Client) ApiOuterOrder(ctx context.Context, orderId string) *ApiOuterOrderResult {
2 years ago
// 参数
param := gorequest.NewParams()
param.Set("outer_order_id", orderId)
params := gorequest.NewParamsWith(param)
// 请求
2 years ago
request, err := c.request(ctx, apiUrl+"/api/outer-order", params)
2 years ago
// 定义
var response ApiOuterOrderResponse
err = json.Unmarshal(request.ResponseBody, &response)
return newApiOuterOrderResult(response, request.ResponseBody, request, err)
}