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

64 lines
3.4 KiB

2 years ago
package meituan
import (
2 years ago
"context"
2 years ago
"encoding/json"
"go.dtapp.net/gorequest"
"net/http"
)
type ApiOrderResponse struct {
Status int `json:"status"`
Des string `json:"des"`
Data struct {
BusinessLine int `json:"businessLine"` // 业务线
SubBusinessLine int `json:"subBusinessLine"` // 子业务线
ActId int `json:"actId"` // 活动id可以在联盟活动列表中查看获取
Quantity int `json:"quantity"` // 商品数量
ApiOrderId string `json:"ApiOrderId"` // 订单id
Paytime string `json:"paytime"` // 订单支付时间10位时间戳
ModTime string `json:"modTime"` // 订单信息修改时间10位时间戳
Payprice string `json:"payprice"` // 订单用户实际支付金额
Profit string `json:"profit,omitempty"` // 订单预估返佣金额
CpaProfit string `json:"cpaProfit,omitempty"` // 订单预估cpa总收益优选、话费券
Sid string `json:"sid"` // 订单对应的推广位sid
Appkey string `json:"appkey"` // 订单对应的appkey外卖、话费、闪购、优选、酒店订单会返回该字段
Smstitle string `json:"smstitle"` // 订单标题
Status int `json:"status"` // 订单状态,外卖、话费、闪购、优选、酒店订单会返回该字段 1 已付款 8 已完成 9 已退款或风控
TradeTypeList []int `json:"tradeTypeList"` // 订单的奖励类型 3 首购奖励 5 留存奖励 2 cps 3 首购奖励
RiskApiOrder int `json:"riskApiOrder"` // 0表示非风控订单1表示风控订单
Refundprofit string `json:"refundprofit,omitempty"` // 订单需要扣除的返佣金额,外卖、话费、闪购、优选、酒店订单若发生退款会返回该字段
CpaRefundProfit interface{} `json:"cpaRefundProfit"` // 订单需要扣除的cpa返佣金额优选、话费券
RefundInfoList interface{} `json:"refundInfoList"` // 退款列表
RefundProfitList interface{} `json:"refundProfitList"`
Extra interface{} `json:"extra"`
} `json:"data"`
}
type ApiOrderResult struct {
Result ApiOrderResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
Err error // 错误
}
2 years ago
func newApiOrderResult(result ApiOrderResponse, body []byte, http gorequest.Response, err error) *ApiOrderResult {
2 years ago
return &ApiOrderResult{Result: result, Body: body, Http: http, Err: err}
}
// ApiOrder 单订单查询接口(新版)
// https://union.meituan.com/v2/apiDetail?id=24
2 years ago
func (c *Client) ApiOrder(ctx context.Context, notMustParams ...gorequest.Params) *ApiOrderResult {
2 years ago
// 参数
params := gorequest.NewParamsWith(notMustParams...)
// 请求时刻10位时间戳(秒级)有效期60s
2 years ago
params["appkey"] = c.GetAppKey()
params["sign"] = c.getSign(c.GetSecret(), params)
2 years ago
// 请求
2 years ago
request, err := c.request(ctx, apiUrl+"/api/order", params, http.MethodGet)
2 years ago
// 定义
var response ApiOrderResponse
err = json.Unmarshal(request.ResponseBody, &response)
2 years ago
return newApiOrderResult(response, request.ResponseBody, request, err)
2 years ago
}