89 lines
3.9 KiB
Go
89 lines
3.9 KiB
Go
|
|
package didi_union
|
|||
|
|
|
|||
|
|
import (
|
|||
|
|
"context"
|
|||
|
|
"fmt"
|
|||
|
|
"time"
|
|||
|
|
|
|||
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|||
|
|
|
|||
|
|
"gitee.com/chengdu-lenntc/third-platform-sdk/sdk/dunion-go-sdk/model"
|
|||
|
|
sdkutil "gitee.com/chengdu-lenntc/third-platform-sdk/sdk/dunion-go-sdk/util"
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
// DidiUnionApi 调用第三方平台的api
|
|||
|
|
// Api defines the interface of eleme_union api
|
|||
|
|
type DidiUnionApi interface {
|
|||
|
|
// Sign 签名
|
|||
|
|
Sign(data map[string]interface{}) string
|
|||
|
|
// GenerateH5Link 生成h5推广链接
|
|||
|
|
GenerateH5Link(ctx context.Context, req GenerateLinkRequest, opt model.Option) (*model.LinkResponse, error)
|
|||
|
|
// GenerateMiniLink 生成小程序页面推广路径
|
|||
|
|
GenerateMiniLink(ctx context.Context, req GenerateLinkRequest, opt model.Option) (*model.LinkResponse, error)
|
|||
|
|
// GenerateH5Code 生成h5二维码,需先取链得到dsi
|
|||
|
|
GenerateH5Code(ctx context.Context, req GenerateCodeRequest, opt model.Option) (*model.QrcodeResponse, error)
|
|||
|
|
// GenerateMiniCode 生成小程序太阳码,需先取链得到dsi
|
|||
|
|
GenerateMiniCode(ctx context.Context, req GenerateCodeRequest, opt model.Option) (*model.QrcodeResponse, error)
|
|||
|
|
// GeneratePoster 生成推广海报,需先取链得到dsi
|
|||
|
|
GeneratePoster(ctx context.Context, req GeneratePosterRequest, opt model.Option) (*model.PosterResponse, error)
|
|||
|
|
// QueryOrderList 查询订单列表
|
|||
|
|
QueryOrderList(ctx context.Context, req QueryOrderListRequest, opt model.Option) (*model.OrderResponse, error)
|
|||
|
|
// SelfQueryOrder 订单归因问题自查询
|
|||
|
|
SelfQueryOrder(ctx context.Context, req SelfQueryOrderRequest, opt model.Option) (*model.SelfQueryResponse, error)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
type didiUnionApiImpl struct {
|
|||
|
|
log logx.Logger
|
|||
|
|
client *Client
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
func newDidiUnionApiImpl(log logx.Logger, client *Client) DidiUnionApi {
|
|||
|
|
return &didiUnionApiImpl{
|
|||
|
|
log: log,
|
|||
|
|
client: client,
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Sign 签名
|
|||
|
|
func (d *didiUnionApiImpl) Sign(params map[string]any) string {
|
|||
|
|
params[sdkutil.AppKey] = d.client.authConfig.AppKey
|
|||
|
|
params[sdkutil.Timestamp] = fmt.Sprintf("%d", time.Now().Unix())
|
|||
|
|
sign := sdkutil.GetSign(params, d.client.authConfig.AppSecret)
|
|||
|
|
return sign
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// GenerateH5Link 生成h5推广链接
|
|||
|
|
func (d *didiUnionApiImpl) GenerateH5Link(ctx context.Context, req GenerateLinkRequest, opt model.Option) (*model.LinkResponse, error) {
|
|||
|
|
return d.client.clt.GenerateH5Link(ctx, req.ActivityID, req.PromotionID, req.SourceID, opt)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// GenerateMiniLink 生成小程序页面推广路径
|
|||
|
|
func (d *didiUnionApiImpl) GenerateMiniLink(ctx context.Context, req GenerateLinkRequest, opt model.Option) (*model.LinkResponse, error) {
|
|||
|
|
return d.client.clt.GenerateMiniLink(ctx, req.ActivityID, req.PromotionID, req.SourceID, opt)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// GenerateH5Code 生成h5二维码,需先取链得到dsi
|
|||
|
|
func (d *didiUnionApiImpl) GenerateH5Code(ctx context.Context, req GenerateCodeRequest, opt model.Option) (*model.QrcodeResponse, error) {
|
|||
|
|
return d.client.clt.GenerateH5Code(ctx, req.Dsi, req.SourceID, opt)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// GenerateMiniCode 生成小程序太阳码,需先取链得到dsi
|
|||
|
|
func (d *didiUnionApiImpl) GenerateMiniCode(ctx context.Context, req GenerateCodeRequest, opt model.Option) (*model.QrcodeResponse, error) {
|
|||
|
|
return d.client.clt.GenerateMiniCode(ctx, req.Dsi, req.SourceID, opt)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// GeneratePoster 生成推广海报,需先取链得到dsi
|
|||
|
|
func (d *didiUnionApiImpl) GeneratePoster(ctx context.Context, req GeneratePosterRequest, opt model.Option) (*model.PosterResponse, error) {
|
|||
|
|
return d.client.clt.GeneratePoster(ctx, req.Dsi, req.SourceID, opt)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// QueryOrderList 查询订单列表
|
|||
|
|
func (d *didiUnionApiImpl) QueryOrderList(ctx context.Context, req QueryOrderListRequest, opt model.Option) (*model.OrderResponse, error) {
|
|||
|
|
return d.client.clt.QueryOrderList(ctx, req.StartTime, req.EndTime, string(req.Typ), req.Page, req.Size, opt)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// SelfQueryOrder 订单归因问题自查询
|
|||
|
|
func (d *didiUnionApiImpl) SelfQueryOrder(ctx context.Context, req SelfQueryOrderRequest, opt model.Option) (*model.SelfQueryResponse, error) {
|
|||
|
|
return d.client.clt.SelfQueryOrder(ctx, req.OrderID, opt)
|
|||
|
|
}
|