From e027c1a12f9704cc4fe041aa6966d0177a3cc849 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=85=89=E6=98=A5?= Date: Fri, 23 Dec 2022 11:00:20 +0800 Subject: [PATCH] - update meituan --- CHANGELOG.md | 4 ++ library.go | 2 +- service/meituan/api.generate_link.go | 12 ++--- service/meituan/api.mini_code.go | 10 ++-- service/meituan/api.mtunion.category.go | 48 ++++++++++++++++++ service/meituan/api.mtunion.city.go | 48 ++++++++++++++++++ service/meituan/api.mtunion.poi.go | 63 ++++++++++++++++++++++++ service/meituan/api.mtunion.sku.go | 53 ++++++++++++++++++++ service/meituan/api.order.go | 61 ++++++++++++++--------- service/meituan/api.orderList.go | 65 +++++++++++++++++++++++++ service/meituan/api.order_list.go | 63 ------------------------ service/meituan/service_http.order.go | 4 +- 12 files changed, 329 insertions(+), 104 deletions(-) create mode 100644 service/meituan/api.mtunion.category.go create mode 100644 service/meituan/api.mtunion.city.go create mode 100644 service/meituan/api.mtunion.poi.go create mode 100644 service/meituan/api.mtunion.sku.go create mode 100644 service/meituan/api.orderList.go delete mode 100644 service/meituan/api.order_list.go diff --git a/CHANGELOG.md b/CHANGELOG.md index ba363f98..e467145f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v2022-12-23 + +- meituan:update api + ## v2022-12-19 - request:update ua diff --git a/library.go b/library.go index 434dcaac..7108d50c 100644 --- a/library.go +++ b/library.go @@ -1,5 +1,5 @@ package go_library func Version() string { - return "1.0.58" + return "1.0.59" } diff --git a/service/meituan/api.generate_link.go b/service/meituan/api.generate_link.go index e83d994f..c1f7ab1a 100644 --- a/service/meituan/api.generate_link.go +++ b/service/meituan/api.generate_link.go @@ -26,16 +26,10 @@ func newApiGenerateLinkResult(result ApiGenerateLinkResponse, body []byte, http // ApiGenerateLink 自助取链接口(新版) // https://union.meituan.com/v2/apiDetail?id=25 -func (c *Client) ApiGenerateLink(ctx context.Context, actId int64, sid string, linkType, shortLink int) *ApiGenerateLinkResult { +func (c *Client) ApiGenerateLink(ctx context.Context, notMustParams ...gorequest.Params) *ApiGenerateLinkResult { // 参数 - param := gorequest.NewParams() - param.Set("actId", actId) // 活动id,可以在联盟活动列表中查看获取 - param.Set("appkey", c.GetAppKey()) // 媒体名称,可在推广者备案-媒体管理中查询 - param.Set("sid", sid) // 推广位sid,支持通过接口自定义创建,不受平台200个上限限制,长度不能超过64个字符,支持小写字母和数字,历史已创建的推广位不受这个约束 - param.Set("linkType", linkType) // 投放链接的类型 - param.Set("shortLink", shortLink) // 获取长链还是短链 - // 转换 - params := gorequest.NewParamsWith(param) + params := gorequest.NewParamsWith(notMustParams...) + params.Set("appkey", c.GetAppKey()) // 媒体名称,可在推广者备案-媒体管理中查询 params["sign"] = c.getSign(c.GetSecret(), params) // 请求 request, err := c.request(ctx, apiUrl+"/api/generateLink", params, http.MethodGet) diff --git a/service/meituan/api.mini_code.go b/service/meituan/api.mini_code.go index 8fb0b68f..b5cb459b 100644 --- a/service/meituan/api.mini_code.go +++ b/service/meituan/api.mini_code.go @@ -26,14 +26,10 @@ func newApiMiniCodeResult(result ApiMiniCodeResponse, body []byte, http goreques // ApiMiniCode 小程序生成二维码(新版) // https://union.meituan.com/v2/apiDetail?id=26 -func (c *Client) ApiMiniCode(ctx context.Context, actId int64, sid string) *ApiMiniCodeResult { +func (c *Client) ApiMiniCode(ctx context.Context, notMustParams ...gorequest.Params) *ApiMiniCodeResult { // 参数 - param := gorequest.NewParams() - param.Set("appkey", c.GetAppKey()) - param.Set("sid", sid) - param.Set("actId", actId) - // 转换 - params := gorequest.NewParamsWith(param) + params := gorequest.NewParamsWith(notMustParams...) + params.Set("appkey", c.GetAppKey()) // 媒体名称,可在推广者备案-媒体管理中查询 params["sign"] = c.getSign(c.GetSecret(), params) // 请求 request, err := c.request(ctx, apiUrl+"/api/miniCode", params, http.MethodGet) diff --git a/service/meituan/api.mtunion.category.go b/service/meituan/api.mtunion.category.go new file mode 100644 index 00000000..7e6dc2a8 --- /dev/null +++ b/service/meituan/api.mtunion.category.go @@ -0,0 +1,48 @@ +package meituan + +import ( + "context" + "encoding/json" + "github.com/dtapps/go-library/utils/gorequest" + "github.com/dtapps/go-library/utils/gotime" + "net/http" +) + +type ApiMtUnionCategoryResponse struct { + Code int `json:"code"` + Msg string `json:"msg"` + Data struct { + DataList []struct { + CategoryId float64 `json:"categoryId"` // 商品类目ID + CategoryName string `json:"categoryName"` // 商品类目名称 + } `json:"dataList"` + Total int64 `json:"total"` // 查询总数 + } `json:"data"` +} +type ApiMtUnionCategoryResult struct { + Result ApiMtUnionCategoryResponse // 结果 + Body []byte // 内容 + Http gorequest.Response // 请求 + Err error // 错误 +} + +func newApiMtUnionCategoryResult(result ApiMtUnionCategoryResponse, body []byte, http gorequest.Response, err error) *ApiMtUnionCategoryResult { + return &ApiMtUnionCategoryResult{Result: result, Body: body, Http: http, Err: err} +} + +// ApiMtUnionCategory 商品类目查询(新版) +// https://union.meituan.com/v2/apiDetail?id=30 +func (c *Client) ApiMtUnionCategory(ctx context.Context, notMustParams ...gorequest.Params) *ApiMtUnionCategoryResult { + // 参数 + params := gorequest.NewParamsWith(notMustParams...) + // 请求时刻10位时间戳(秒级),有效期60s + params["ts"] = gotime.Current().Timestamp() + params["appkey"] = c.GetAppKey() + params["sign"] = c.getSign(c.GetSecret(), params) + // 请求 + request, err := c.request(ctx, apiUrl+"/api/getqualityscorebysid", params, http.MethodGet) + // 定义 + var response ApiMtUnionCategoryResponse + err = json.Unmarshal(request.ResponseBody, &response) + return newApiMtUnionCategoryResult(response, request.ResponseBody, request, err) +} diff --git a/service/meituan/api.mtunion.city.go b/service/meituan/api.mtunion.city.go new file mode 100644 index 00000000..4bfeaec1 --- /dev/null +++ b/service/meituan/api.mtunion.city.go @@ -0,0 +1,48 @@ +package meituan + +import ( + "context" + "encoding/json" + "github.com/dtapps/go-library/utils/gorequest" + "github.com/dtapps/go-library/utils/gotime" + "net/http" +) + +type ApiMtUnionCityResponse struct { + Code int `json:"code"` + Msg string `json:"msg"` + Data struct { + DataList []struct { + CityId float64 `json:"cityId"` // 城市ID + CityName string `json:"cityName"` // 城市名称 + } `json:"dataList"` + Total int64 `json:"total"` // 查询总数 + } `json:"data"` +} +type ApiMtUnionCityResult struct { + Result ApiMtUnionCityResponse // 结果 + Body []byte // 内容 + Http gorequest.Response // 请求 + Err error // 错误 +} + +func newApiMtUnionCityResult(result ApiMtUnionCityResponse, body []byte, http gorequest.Response, err error) *ApiMtUnionCityResult { + return &ApiMtUnionCityResult{Result: result, Body: body, Http: http, Err: err} +} + +// ApiMtUnionCity 城市信息查询(新版) +// https://union.meituan.com/v2/apiDetail?id=29 +func (c *Client) ApiMtUnionCity(ctx context.Context, notMustParams ...gorequest.Params) *ApiMtUnionCityResult { + // 参数 + params := gorequest.NewParamsWith(notMustParams...) + // 请求时刻10位时间戳(秒级),有效期60s + params["ts"] = gotime.Current().Timestamp() + params["appkey"] = c.GetAppKey() + params["sign"] = c.getSign(c.GetSecret(), params) + // 请求 + request, err := c.request(ctx, apiUrl+"/api/getqualityscorebysid", params, http.MethodGet) + // 定义 + var response ApiMtUnionCityResponse + err = json.Unmarshal(request.ResponseBody, &response) + return newApiMtUnionCityResult(response, request.ResponseBody, request, err) +} diff --git a/service/meituan/api.mtunion.poi.go b/service/meituan/api.mtunion.poi.go new file mode 100644 index 00000000..2b57fd7d --- /dev/null +++ b/service/meituan/api.mtunion.poi.go @@ -0,0 +1,63 @@ +package meituan + +import ( + "context" + "encoding/json" + "github.com/dtapps/go-library/utils/gorequest" + "github.com/dtapps/go-library/utils/gotime" + "net/http" +) + +type ApiMtUnionPoiResponse struct { + Code int `json:"code"` + Msg string `json:"msg"` + Data struct { + DataList []struct { + PoiViewId string `json:"poiViewId"` // POI门店ID + PoiName string `json:"poiName"` // POI名称 + PoiPicUrl string `json:"poiPicUrl"` // 店铺图URL + PoiScore string `json:"poiScore"` // 店铺评分,满分5分 + MonthSale string `json:"monthSale"` // 月售量 + ShippingFee string `json:"shippingFee"` // 配送费金额,单位元 + MinPrice string `json:"minPrice"` // 起送金额,单位元 + Distance string `json:"distance"` // 门店距离,单位米 + AvgDeliveryTime string `json:"avgDeliveryTime"` // 配送时长,单位分钟 + ReduceShippingFee float64 `json:"reduceShippingFee"` // 满减配送费 + PoiMarkTagUrl string `json:"poiMarkTagUrl"` // 角标信息 + MerchantFullSale string `json:"merchantFullSale"` // 店铺满减,举例:38减25 + MerchantDiscount string `json:"merchantDiscount"` // 店铺折扣,举例:3.4折起 + NewCustomerDiscount string `json:"newCustomerDiscount"` // 新客立减,举例:新客减1 + RebateCoupon string `json:"rebateCoupon"` // 返券,举例:返3元券 + MerchantCoupon string `json:"merchantCoupon"` // 商家券,举例:领3元券 + FullComplimentary string `json:"fullComplimentary"` // 满赠,举例:满68元得赠品 + } `json:"dataList"` + PageTraceId string `json:"pageTraceId"` // 分页查询参数,第二次查询传回 + } `json:"data"` +} +type ApiMtUnionPoiResult struct { + Result ApiMtUnionPoiResponse // 结果 + Body []byte // 内容 + Http gorequest.Response // 请求 + Err error // 错误 +} + +func newApiMtUnionPoiResult(result ApiMtUnionPoiResponse, body []byte, http gorequest.Response, err error) *ApiMtUnionPoiResult { + return &ApiMtUnionPoiResult{Result: result, Body: body, Http: http, Err: err} +} + +// ApiMtUnionPoi 门店POI查询(新版) +// https://union.meituan.com/v2/apiDetail?id=32 +func (c *Client) ApiMtUnionPoi(ctx context.Context, notMustParams ...gorequest.Params) *ApiMtUnionPoiResult { + // 参数 + params := gorequest.NewParamsWith(notMustParams...) + // 请求时刻10位时间戳(秒级),有效期60s + params["ts"] = gotime.Current().Timestamp() + params["appkey"] = c.GetAppKey() + params["sign"] = c.getSign(c.GetSecret(), params) + // 请求 + request, err := c.request(ctx, apiUrl+"/api/getqualityscorebysid", params, http.MethodGet) + // 定义 + var response ApiMtUnionPoiResponse + err = json.Unmarshal(request.ResponseBody, &response) + return newApiMtUnionPoiResult(response, request.ResponseBody, request, err) +} diff --git a/service/meituan/api.mtunion.sku.go b/service/meituan/api.mtunion.sku.go new file mode 100644 index 00000000..31d1575c --- /dev/null +++ b/service/meituan/api.mtunion.sku.go @@ -0,0 +1,53 @@ +package meituan + +import ( + "context" + "encoding/json" + "github.com/dtapps/go-library/utils/gorequest" + "github.com/dtapps/go-library/utils/gotime" + "net/http" +) + +type ApiMtUnionSkuResponse struct { + Code int `json:"code"` + Msg string `json:"msg"` + Data struct { + DataList []struct { + SkuId string `json:"skuId"` // sku编号 + SkuName string `json:"skuName"` // sku名称 + Price string `json:"price"` // 展示价格,单位分 + Pic float64 `json:"pic"` // 商品主图 + CategoryId float64 `json:"categoryId"` // 商品类目ID + CategoryName string `json:"categoryName"` // 商品类目名称 + SalesVolume float64 `json:"salesVolume"` // 当前sku销量 + } `json:"dataList"` + Total int64 `json:"total"` // 商品总数 + } `json:"data"` +} +type ApiMtUnionSkuResult struct { + Result ApiMtUnionSkuResponse // 结果 + Body []byte // 内容 + Http gorequest.Response // 请求 + Err error // 错误 +} + +func newApiMtUnionSkuResult(result ApiMtUnionSkuResponse, body []byte, http gorequest.Response, err error) *ApiMtUnionSkuResult { + return &ApiMtUnionSkuResult{Result: result, Body: body, Http: http, Err: err} +} + +// ApiMtUnionSku 商品列表查询(新版) +// https://union.meituan.com/v2/apiDetail?id=31 +func (c *Client) ApiMtUnionSku(ctx context.Context, notMustParams ...gorequest.Params) *ApiMtUnionSkuResult { + // 参数 + params := gorequest.NewParamsWith(notMustParams...) + // 请求时刻10位时间戳(秒级),有效期60s + params["ts"] = gotime.Current().Timestamp() + params["appkey"] = c.GetAppKey() + params["sign"] = c.getSign(c.GetSecret(), params) + // 请求 + request, err := c.request(ctx, apiUrl+"/api/getqualityscorebysid", params, http.MethodGet) + // 定义 + var response ApiMtUnionSkuResponse + err = json.Unmarshal(request.ResponseBody, &response) + return newApiMtUnionSkuResult(response, request.ResponseBody, request, err) +} diff --git a/service/meituan/api.order.go b/service/meituan/api.order.go index ef3eeec9..df039923 100644 --- a/service/meituan/api.order.go +++ b/service/meituan/api.order.go @@ -11,27 +11,45 @@ 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"` + ActId int `json:"actId,omitempty"` // 活动id,可以在联盟活动列表中查看获取 + BusinessLine int `json:"businessLine,omitempty"` // 业务线 + SubBusinessLine int `json:"subBusinessLine,omitempty"` // 子业务线 + Quantity int `json:"quantity,omitempty"` // 商品数量 + OrderId string `json:"orderId,omitempty"` // 订单id + Paytime string `json:"paytime,omitempty"` // 订单支付时间,10位时间戳 + ModTime string `json:"modTime,omitempty"` // 订单信息修改时间,10位时间戳 + Payprice string `json:"payprice,omitempty"` // 订单用户实际支付金额 + Profit string `json:"profit,omitempty"` // 订单预估返佣金额 + CpaProfit string `json:"cpaProfit,omitempty"` // 订单预估cpa总收益(优选、话费券) + Sid string `json:"sid,omitempty"` // 订单对应的推广位sid + Appkey string `json:"appkey,omitempty"` // 订单对应的appkey,外卖、话费、闪购、优选、酒店订单会返回该字段 + Smstitle string `json:"smstitle,omitempty"` // 订单标题 + Status int `json:"status,omitempty"` // 订单状态,外卖、话费、闪购、优选、酒店订单会返回该字段 1 已付款 8 已完成 9 已退款或风控 + TradeTypeList []int `json:"tradeTypeList,omitempty"` // 订单的奖励类型 3 首购奖励 5 留存奖励 2 cps 3 首购奖励 + RiskApiOrder int `json:"riskApiOrder,omitempty"` // 0表示非风控订单,1表示风控订单 + Refundprofit string `json:"refundprofit,omitempty"` // 订单需要扣除的返佣金额,外卖、话费、闪购、优选、酒店订单若发生退款会返回该字段 + CpaRefundProfit string `json:"cpaRefundProfit,omitempty"` // 订单需要扣除的cpa返佣金额(优选、话费券) + RefundInfoList struct { + Id string `json:"id,omitempty"` + RefundPrice string `json:"refundPrice,omitempty"` + RefundTime string `json:"refundTime,omitempty"` + RefundType int `json:"refundType,omitempty"` + } `json:"refundInfoList,omitempty"` // 退款列表 + RefundProfitList struct { + Id string `json:"id,omitempty"` + RefundProfit string `json:"refundProfit,omitempty"` + RefundFinishTime string `json:"refundFinishTime,omitempty"` + Type int `json:"type,omitempty"` + } `json:"refundProfitList,omitempty"` + ConsumeProfitList struct { + Id string `json:"id,omitempty"` + ConsumeProfit string `json:"consumeProfit,omitempty"` + ConsumeFinishTime string `json:"consumeFinishTime,omitempty"` + Type string `json:"type,omitempty"` + } `json:"consumeProfitList,omitempty"` + CouponCode string `json:"coupon_code,omitempty"` // 券码 + ProductId string `json:"productId,omitempty"` // 商品ID + ProductName string `json:"productName,omitempty"` // 商品名称 } `json:"data"` } @@ -51,7 +69,6 @@ func newApiOrderResult(result ApiOrderResponse, body []byte, http gorequest.Resp func (c *Client) ApiOrder(ctx context.Context, notMustParams ...gorequest.Params) *ApiOrderResult { // 参数 params := gorequest.NewParamsWith(notMustParams...) - // 请求时刻10位时间戳(秒级),有效期60s params["appkey"] = c.GetAppKey() params["sign"] = c.getSign(c.GetSecret(), params) // 请求 diff --git a/service/meituan/api.orderList.go b/service/meituan/api.orderList.go new file mode 100644 index 00000000..e499ee3b --- /dev/null +++ b/service/meituan/api.orderList.go @@ -0,0 +1,65 @@ +package meituan + +import ( + "context" + "encoding/json" + "github.com/dtapps/go-library/utils/gorequest" + "github.com/dtapps/go-library/utils/gotime" + "net/http" +) + +type ApiOrderListResponse struct { + DataList []struct { + ActId int `json:"actId,omitempty"` // 活动id,可以在联盟活动列表中查看获取 + BusinessLine int `json:"businessLine,omitempty"` // 业务线 + SubBusinessLine int `json:"subBusinessLine,omitempty"` // 子业务线 + Orderid string `json:"orderid,omitempty"` // 订单id + Paytime string `json:"paytime,omitempty"` // 订单支付时间,10位时间戳 + Payprice string `json:"payprice,omitempty"` // 订单用户实际支付金额 + Profit string `json:"profit,omitempty"` // 订单预估返佣金额 + CpaProfit string `json:"cpaProfit,omitempty"` // 订单预估cpa总收益(优选、话费券) + Sid string `json:"sid,omitempty"` // 订单对应的推广位sid + Appkey string `json:"appkey,omitempty"` // 订单对应的appkey,外卖、话费、闪购、优选订单会返回该字段 + Smstitle string `json:"smstitle,omitempty"` // 订单标题 + ProductId string `json:"productId,omitempty"` // 商品ID + ProductName string `json:"productName,omitempty"` // 商品名称 + Refundprice string `json:"refundprice,omitempty"` // 订单实际退款金额,外卖、话费、闪购、优选、酒店订单若发生退款会返回该字段 + Refundtime string `json:"refundtime,omitempty"` // 订单退款时间,10位时间戳,外卖、话费、闪购、优选、酒店订单若发生退款会返回该字段(退款时间为最近的一次退款) + Refundprofit string `json:"refundprofit,omitempty"` // 订单需要扣除的返佣金额,外卖、话费、闪购、优选、酒店订单若发生退款会返回该字段 + CpaRefundProfit string `json:"cpaRefundProfit,omitempty"` // 订单需要扣除的cpa返佣金额(优选、话费券) + Status int `json:"status,omitempty"` // 订单状态,外卖、话费、闪购、优选、酒店订单会返回该字段 1 已付款 8 已完成 9 已退款或风控 + TradeTypeList []int `json:"tradeTypeList,omitempty"` // 订单的奖励类型 3 首购奖励 5 留存奖励 2 cps 3 首购奖励 + RiskOrder int `json:"riskOrder,omitempty"` // 0表示非风控订单,1表示风控订单 + Extra string `json:"extra,omitempty"` + TradeTypeBusinessTypeMapStr string `json:"tradeTypeBusinessTypeMapStr,omitempty"` + } `json:"dataList"` + Total int `json:"total"` // 查询条件命中的总数据条数,用于计算分页参数 +} + +type ApiOrderListResult struct { + Result ApiOrderListResponse // 结果 + Body []byte // 内容 + Http gorequest.Response // 请求 + Err error // 错误 +} + +func newApiOrderListResult(result ApiOrderListResponse, body []byte, http gorequest.Response, err error) *ApiOrderListResult { + return &ApiOrderListResult{Result: result, Body: body, Http: http, Err: err} +} + +// ApiOrderList 订单列表查询接口(新版) +// https://union.meituan.com/v2/apiDetail?id=23 +func (c *Client) ApiOrderList(ctx context.Context, notMustParams ...gorequest.Params) *ApiOrderListResult { + // 参数 + params := gorequest.NewParamsWith(notMustParams...) + // 请求时刻10位时间戳(秒级),有效期60s + params["ts"] = gotime.Current().Timestamp() + params["appkey"] = c.GetAppKey() + params["sign"] = c.getSign(c.GetSecret(), params) + // 请求 + request, err := c.request(ctx, apiUrl+"/api/orderList", params, http.MethodGet) + // 定义 + var response ApiOrderListResponse + err = json.Unmarshal(request.ResponseBody, &response) + return newApiOrderListResult(response, request.ResponseBody, request, err) +} diff --git a/service/meituan/api.order_list.go b/service/meituan/api.order_list.go deleted file mode 100644 index b3a11185..00000000 --- a/service/meituan/api.order_list.go +++ /dev/null @@ -1,63 +0,0 @@ -package meituan - -import ( - "context" - "encoding/json" - "github.com/dtapps/go-library/utils/gorequest" - "github.com/dtapps/go-library/utils/gotime" - "net/http" -) - -type ApiOrderListResponse struct { - DataList []struct { - Orderid string `json:"orderid"` // 订单id - Paytime string `json:"paytime"` // 订单支付时间,10位时间戳 - Payprice string `json:"payprice"` // 订单用户实际支付金额 - Sid string `json:"sid"` // 订单对应的推广位sid - Smstitle string `json:"smstitle"` // 订单标题 - Appkey string `json:"appkey"` // 订单对应的appkey,外卖、话费、闪购、优选订单会返回该字段 - Status int `json:"status"` // 订单状态,外卖、话费、闪购、优选、酒店订单会返回该字段 1 已付款 8 已完成 9 已退款或风控 - Profit string `json:"profit"` // 订单预估返佣金额 - CpaProfit string `json:"cpaProfit"` // 订单预估cpa总收益(优选、话费券) - Refundtime string `json:"refundtime"` // 订单退款时间,10位时间戳,外卖、话费、闪购、优选、酒店订单若发生退款会返回该字段(退款时间为最近的一次退款) - Refundprice string `json:"refundprice"` // 订单实际退款金额,外卖、话费、闪购、优选、酒店订单若发生退款会返回该字段 - Refundprofit string `json:"refundprofit"` // 订单需要扣除的返佣金额,外卖、话费、闪购、优选、酒店订单若发生退款会返回该字段 - CpaRefundProfit string `json:"cpaRefundProfit"` // 订单需要扣除的cpa返佣金额(优选、话费券) - Extra string `json:"extra"` - TradeTypeList []int `json:"tradeTypeList"` // 订单的奖励类型 3 首购奖励 5 留存奖励 2 cps 3 首购奖励 - TradeTypeBusinessTypeMapStr string `json:"tradeTypeBusinessTypeMapStr"` - RiskOrder int `json:"riskOrder"` // 0表示非风控订单,1表示风控订单 - BusinessLine int `json:"businessLine"` // 业务线 - SubBusinessLine int `json:"subBusinessLine"` // 子业务线 - ActId int `json:"actId"` // 活动id,可以在联盟活动列表中查看获取 - } `json:"dataList"` - Total int `json:"total"` // 查询条件命中的总数据条数,用于计算分页参数 -} - -type ApiOrderListResult struct { - Result ApiOrderListResponse // 结果 - Body []byte // 内容 - Http gorequest.Response // 请求 - Err error // 错误 -} - -func newApiOrderListResult(result ApiOrderListResponse, body []byte, http gorequest.Response, err error) *ApiOrderListResult { - return &ApiOrderListResult{Result: result, Body: body, Http: http, Err: err} -} - -// ApiOrderList 订单列表查询接口(新版) -// https://union.meituan.com/v2/apiDetail?id=23 -func (c *Client) ApiOrderList(ctx context.Context, notMustParams ...gorequest.Params) *ApiOrderListResult { - // 参数 - params := gorequest.NewParamsWith(notMustParams...) - // 请求时刻10位时间戳(秒级),有效期60s - params["ts"] = gotime.Current().Timestamp() - params["appkey"] = c.GetAppKey() - params["sign"] = c.getSign(c.GetSecret(), params) - // 请求 - request, err := c.request(ctx, apiUrl+"/api/orderList", params, http.MethodGet) - // 定义 - var response ApiOrderListResponse - err = json.Unmarshal(request.ResponseBody, &response) - return newApiOrderListResult(response, request.ResponseBody, request, err) -} diff --git a/service/meituan/service_http.order.go b/service/meituan/service_http.order.go index 055f700c..a535b8d1 100644 --- a/service/meituan/service_http.order.go +++ b/service/meituan/service_http.order.go @@ -8,8 +8,8 @@ import ( // ResponseServeHttpOrder 返回参数 type ResponseServeHttpOrder struct { - Smstitle string `json:"appId,omitempty"` // 订单标题 - Quantity string `json:"CreateTime,omitempty"` // 订单数量 + Smstitle string `json:"smstitle,omitempty"` // 订单标题 + Quantity string `json:"quantity,omitempty"` // 订单数量 Orderid string `json:"orderid,omitempty"` // 订单id Dealid string `json:"dealid,omitempty"` // 店铺id(部分存在) Paytime string `json:"paytime,omitempty"` // 订单支付时间,10位时间戳