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

64 lines
3.0 KiB

package meituan
import (
"context"
1 year ago
"github.com/dtapps/go-library/utils/gojson"
"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
1 year ago
err = gojson.Unmarshal(request.ResponseBody, &response)
return newApiMtUnionPoiResult(response, request.ResponseBody, request, err)
}