2024-04-30 17:57:27 +08:00
|
|
|
package eleme_union
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
2024-05-04 16:57:40 +08:00
|
|
|
|
|
|
|
|
"gitee.com/chengdu-lenntc/third-platform-sdk/sdk/topsdk/defaultability/request"
|
|
|
|
|
"gitee.com/chengdu-lenntc/third-platform-sdk/sdk/topsdk/defaultability/response"
|
2024-05-04 21:12:15 +08:00
|
|
|
sdkutil "gitee.com/chengdu-lenntc/third-platform-sdk/sdk/topsdk/util"
|
|
|
|
|
"gitee.com/chengdu-lenntc/third-platform-sdk/util"
|
2024-04-30 17:57:27 +08:00
|
|
|
)
|
|
|
|
|
|
2024-05-04 16:57:40 +08:00
|
|
|
// ElemeUnionApi 调用第三方平台的api
|
2024-04-30 17:57:27 +08:00
|
|
|
// Api defines the interface of eleme_union api
|
2024-05-04 16:57:40 +08:00
|
|
|
type ElemeUnionApi interface {
|
|
|
|
|
// Sign 签名
|
2024-05-04 21:12:15 +08:00
|
|
|
Sign(publicParam PublicParam, data map[string]interface{}) string
|
2024-05-04 16:57:40 +08:00
|
|
|
// GetLink 获取推广链接
|
|
|
|
|
GetLink(req *request.AlibabaAlscUnionKbItemPromotionShareCreateRequest) (*response.AlibabaAlscUnionKbItemPromotionShareCreateResponse, error)
|
2024-05-04 23:55:35 +08:00
|
|
|
// GetOrders 获取推广订单明细
|
2024-05-04 16:57:40 +08:00
|
|
|
GetOrders(req *request.AlibabaAlscUnionKbcpaOrderDetailsGetRequest) (*response.AlibabaAlscUnionKbcpaOrderDetailsGetResponse, error)
|
2024-05-04 23:55:35 +08:00
|
|
|
// GetPositiveOrders 获取推广订单明细报表
|
|
|
|
|
GetPositiveOrders(req *request.AlibabaAlscUnionKbcpxPositiveOrderGetRequest) (*response.AlibabaAlscUnionKbcpxPositiveOrderGetResponse, error)
|
2024-04-30 17:57:27 +08:00
|
|
|
}
|
|
|
|
|
|
2024-05-04 16:57:40 +08:00
|
|
|
type elemeUnionApiImpl struct {
|
2024-04-30 17:57:27 +08:00
|
|
|
log logx.Logger
|
|
|
|
|
client *Client
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-04 16:57:40 +08:00
|
|
|
func newElemeUnionApiImpl(log logx.Logger, client *Client) ElemeUnionApi {
|
|
|
|
|
return &elemeUnionApiImpl{
|
2024-04-30 17:57:27 +08:00
|
|
|
log: log,
|
|
|
|
|
client: client,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-04 16:57:40 +08:00
|
|
|
// Sign 签名
|
|
|
|
|
// @param publicParam 公共参数
|
|
|
|
|
// @param data 业务参数
|
2024-05-04 21:12:15 +08:00
|
|
|
func (a *elemeUnionApiImpl) Sign(publicParam PublicParam, data map[string]interface{}) string {
|
|
|
|
|
return sdkutil.GetSign(util.StructToMap(publicParam), data, a.client.authConfig.AppSecret)
|
2024-04-30 17:57:27 +08:00
|
|
|
}
|
|
|
|
|
|
2024-05-04 16:57:40 +08:00
|
|
|
// GetLink 获取推广链接
|
|
|
|
|
func (a *elemeUnionApiImpl) GetLink(req *request.AlibabaAlscUnionKbItemPromotionShareCreateRequest) (*response.AlibabaAlscUnionKbItemPromotionShareCreateResponse, error) {
|
|
|
|
|
resp, err := a.client.abilityClient.AlibabaAlscUnionKbItemPromotionShareCreate(req)
|
|
|
|
|
if err != nil {
|
|
|
|
|
a.log.WithFields(logx.LogField{Key: "req", Value: req}).Errorf("[elemeUnionApiImpl][GetLink] get link failed, error: %v", err)
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
return resp, nil
|
2024-04-30 17:57:27 +08:00
|
|
|
}
|
|
|
|
|
|
2024-05-04 16:57:40 +08:00
|
|
|
// GetOrders 获取推广订单
|
|
|
|
|
func (a *elemeUnionApiImpl) GetOrders(req *request.AlibabaAlscUnionKbcpaOrderDetailsGetRequest) (*response.AlibabaAlscUnionKbcpaOrderDetailsGetResponse, error) {
|
|
|
|
|
resp, err := a.client.abilityClient.AlibabaAlscUnionKbcpaOrderDetailsGet(req)
|
|
|
|
|
if err != nil {
|
|
|
|
|
a.log.WithFields(logx.LogField{Key: "req", Value: req}).Errorf("[elemeUnionApiImpl][GetOrders] get orders failed, error: %v", err)
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
return resp, nil
|
2024-04-30 17:57:27 +08:00
|
|
|
}
|
2024-05-04 23:55:35 +08:00
|
|
|
|
|
|
|
|
// GetPositiveOrders 获取推广订单明细报表
|
|
|
|
|
func (a *elemeUnionApiImpl) GetPositiveOrders(req *request.AlibabaAlscUnionKbcpxPositiveOrderGetRequest) (*response.AlibabaAlscUnionKbcpxPositiveOrderGetResponse, error) {
|
|
|
|
|
resp, err := a.client.abilityClient.AlibabaAlscUnionKbcpxPositiveOrderGet(req)
|
|
|
|
|
if err != nil {
|
|
|
|
|
a.log.WithFields(logx.LogField{Key: "req", Value: req}).Errorf("[elemeUnionApiImpl][GetPositiveOrders] get positive orders failed, error: %v", err)
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
return resp, nil
|
|
|
|
|
}
|