meituan-union平台api对接
This commit is contained in:
parent
f867ca6aa2
commit
1e5037d017
@ -11,11 +11,19 @@ import (
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/util"
|
||||
)
|
||||
|
||||
// Api 调用第三方平台的api
|
||||
// MeituanUnionApi 美团联盟平台的api
|
||||
type MeituanUnionApi interface {
|
||||
// Sign 签名
|
||||
Sign(params map[string]interface{}) string
|
||||
// NotifySign 通知签名
|
||||
NotifySign(params map[string]interface{}) string
|
||||
// GetLink 获取推广链接
|
||||
GetLink(params GenerateLinkRequest) (*GenerateLinkResponse, error)
|
||||
// MiniCode 获取小程序码
|
||||
MiniCode(params MiniCodeRequest) (*MimiCodeResponse, error)
|
||||
// GetOrderBySinge 获取单个订单
|
||||
GetOrderBySinge(params GetOrderBySingeRequest) (*GetOrderBySingeResponse, error)
|
||||
// GetOrderByBatch 批量获取订单
|
||||
GetOrderByBatch(params GetOrderByBatchRequest) (*GetOrderByBatchResponse, error)
|
||||
}
|
||||
|
||||
@ -31,8 +39,25 @@ func newMeituanUnionApiImpl(log logx.Logger, client *Client) MeituanUnionApi {
|
||||
}
|
||||
}
|
||||
|
||||
// Sign 签名
|
||||
func (a *meituanUnionApiImpl) Sign(params map[string]interface{}) string {
|
||||
kvPairs := a.getSignStr(params)
|
||||
sort.Strings(kvPairs)
|
||||
paramStr := strings.Join(kvPairs, "")
|
||||
return util.Md5String(a.client.authConfig.SignKey + paramStr + a.client.authConfig.SignKey)
|
||||
}
|
||||
|
||||
// NotifySign 通知签名
|
||||
func (a *meituanUnionApiImpl) NotifySign(params map[string]interface{}) string {
|
||||
kvPairs := a.getSignStr(params)
|
||||
sort.Strings(kvPairs)
|
||||
paramStr := strings.Join(kvPairs, "")
|
||||
return util.Md5String(a.client.authConfig.NotifyKey + paramStr + a.client.authConfig.NotifyKey)
|
||||
}
|
||||
|
||||
// GetLink 获取推广链接
|
||||
func (a *meituanUnionApiImpl) GetLink(params GenerateLinkRequest) (*GenerateLinkResponse, error) {
|
||||
params.Sign = a.sign(util.StructToMap(params))
|
||||
params.Sign = a.Sign(util.StructToMap(params))
|
||||
queryArgs := util.StructToMap(params)
|
||||
req := &client.HttpRequest{Headers: a.client.Headers, QueryArgs: queryArgs}
|
||||
response := new(GenerateLinkResponse)
|
||||
@ -42,8 +67,9 @@ func (a *meituanUnionApiImpl) GetLink(params GenerateLinkRequest) (*GenerateLink
|
||||
return response, nil
|
||||
}
|
||||
|
||||
// MiniCode 获取小程序码
|
||||
func (a *meituanUnionApiImpl) MiniCode(params MiniCodeRequest) (*MimiCodeResponse, error) {
|
||||
params.Sign = a.sign(util.StructToMap(params))
|
||||
params.Sign = a.Sign(util.StructToMap(params))
|
||||
queryArgs := util.StructToMap(params)
|
||||
req := &client.HttpRequest{Headers: a.client.Headers, QueryArgs: queryArgs}
|
||||
response := new(MimiCodeResponse)
|
||||
@ -52,8 +78,10 @@ func (a *meituanUnionApiImpl) MiniCode(params MiniCodeRequest) (*MimiCodeRespons
|
||||
}
|
||||
return response, nil
|
||||
}
|
||||
|
||||
// GetOrderBySinge 获取单个订单
|
||||
func (a *meituanUnionApiImpl) GetOrderBySinge(params GetOrderBySingeRequest) (*GetOrderBySingeResponse, error) {
|
||||
params.Sign = a.sign(util.StructToMap(params))
|
||||
params.Sign = a.Sign(util.StructToMap(params))
|
||||
queryArgs := util.StructToMap(params)
|
||||
req := &client.HttpRequest{Headers: a.client.Headers, QueryArgs: queryArgs}
|
||||
response := new(GetOrderBySingeResponse)
|
||||
@ -62,8 +90,10 @@ func (a *meituanUnionApiImpl) GetOrderBySinge(params GetOrderBySingeRequest) (*G
|
||||
}
|
||||
return response, nil
|
||||
}
|
||||
|
||||
// GetOrderByBatch 批量获取订单
|
||||
func (a *meituanUnionApiImpl) GetOrderByBatch(params GetOrderByBatchRequest) (*GetOrderByBatchResponse, error) {
|
||||
params.Sign = a.sign(util.StructToMap(params))
|
||||
params.Sign = a.Sign(util.StructToMap(params))
|
||||
queryArgs := util.StructToMap(params)
|
||||
req := &client.HttpRequest{Headers: a.client.Headers, QueryArgs: queryArgs}
|
||||
response := new(GetOrderByBatchResponse)
|
||||
@ -73,20 +103,6 @@ func (a *meituanUnionApiImpl) GetOrderByBatch(params GetOrderByBatchRequest) (*G
|
||||
return response, nil
|
||||
}
|
||||
|
||||
func (a *meituanUnionApiImpl) sign(params map[string]interface{}) string {
|
||||
kvPairs := a.getSignStr(params)
|
||||
sort.Strings(kvPairs)
|
||||
paramStr := strings.Join(kvPairs, "")
|
||||
return util.Md5String(a.client.authConfig.SignKey + paramStr + a.client.authConfig.SignKey)
|
||||
}
|
||||
|
||||
func (a *meituanUnionApiImpl) notifySign(params map[string]interface{}) string {
|
||||
kvPairs := a.getSignStr(params)
|
||||
sort.Strings(kvPairs)
|
||||
paramStr := strings.Join(kvPairs, "")
|
||||
return util.Md5String(a.client.authConfig.NotifyKey + paramStr + a.client.authConfig.NotifyKey)
|
||||
}
|
||||
|
||||
func (a *meituanUnionApiImpl) getSignStr(dataMap map[string]any) []string {
|
||||
var kvPairs []string
|
||||
for k, v := range dataMap {
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package meituan_union
|
||||
|
||||
// GenerateLinkRequest 生成推广链接请求
|
||||
type GenerateLinkRequest struct {
|
||||
ActId int64 `form:"actId"`
|
||||
Appkey string `form:"appkey"`
|
||||
@ -9,6 +10,14 @@ type GenerateLinkRequest struct {
|
||||
Sign string `form:"sign"`
|
||||
}
|
||||
|
||||
// GenerateLinkResponse 生成推广链接响应
|
||||
type GenerateLinkResponse struct {
|
||||
Status int64 `json:"status"`
|
||||
Des string `json:"des"`
|
||||
Data string `json:"data"`
|
||||
}
|
||||
|
||||
// MiniCodeRequest 获取小程序码请求
|
||||
type MiniCodeRequest struct {
|
||||
ActId int64 `form:"actId"`
|
||||
Appkey string `form:"appkey"`
|
||||
@ -17,14 +26,14 @@ type MiniCodeRequest struct {
|
||||
LinkType int64 `form:"linkType"`
|
||||
}
|
||||
|
||||
// MimiCodeResponse 获取小程序码响应
|
||||
type MimiCodeResponse struct {
|
||||
}
|
||||
|
||||
type GenerateLinkResponse struct {
|
||||
Status int64 `json:"status"`
|
||||
Des string `json:"des"`
|
||||
Data string `json:"data"`
|
||||
}
|
||||
|
||||
// GetOrderBySingeRequest 获取单个订单请求
|
||||
type GetOrderBySingeRequest struct {
|
||||
Appkey string `form:"appkey"`
|
||||
ActId int64 `form:"actId"`
|
||||
@ -32,11 +41,15 @@ type GetOrderBySingeRequest struct {
|
||||
Sign string `form:"sign"`
|
||||
OrderId string `form:"orderId"`
|
||||
}
|
||||
|
||||
// GetOrderBySingeResponse 获取单个订单响应
|
||||
type GetOrderBySingeResponse struct {
|
||||
Status int64 `json:"status"`
|
||||
Des string `json:"des"`
|
||||
Data OrderSinge `json:"data"`
|
||||
}
|
||||
|
||||
// OrderSinge 订单详情
|
||||
type OrderSinge struct {
|
||||
ActId int64 `json:"actId"`
|
||||
Quantity int64 `json:"quantity"`
|
||||
@ -55,6 +68,7 @@ type OrderSinge struct {
|
||||
CpaRefundProfit string `json:"cpaRefundProfit"`
|
||||
}
|
||||
|
||||
// GetOrderByBatchRequest 批量获取订单请求
|
||||
type GetOrderByBatchRequest struct {
|
||||
Appkey string `form:"appkey"`
|
||||
Ts string `form:"ts"`
|
||||
@ -65,10 +79,14 @@ type GetOrderByBatchRequest struct {
|
||||
Page string `form:"page"`
|
||||
Limit string `form:"limit"`
|
||||
}
|
||||
|
||||
// GetOrderByBatchResponse 批量获取订单响应
|
||||
type GetOrderByBatchResponse struct {
|
||||
Total int64 `json:"total"`
|
||||
DataList []OrderBatch `json:"dataList"`
|
||||
}
|
||||
|
||||
// OrderBatch 订单详情
|
||||
type OrderBatch struct {
|
||||
ActId int64 `json:"actId"`
|
||||
OrderId string `json:"orderId"`
|
||||
|
||||
Loading…
Reference in New Issue
Block a user