聚推客api对接

This commit is contained in:
wukesheng 2024-06-23 16:01:51 +08:00
parent a470a5ebb8
commit 6e990b37dc
3 changed files with 35 additions and 17 deletions

View File

@ -3,6 +3,7 @@ package jutuike
import ( import (
"context" "context"
"errors" "errors"
"time"
"github.com/zeromicro/go-zero/core/logx" "github.com/zeromicro/go-zero/core/logx"
@ -33,6 +34,9 @@ func newJutuikeApiImpl(log logx.Logger, client *Client) JutuikeApi {
// GenerateLink 生成推广链接 // GenerateLink 生成推广链接
func (a *jutuikeApiImpl) GenerateLink(ctx context.Context, req GenerateLinkRequest) (*GenerateLinkData, error) { func (a *jutuikeApiImpl) GenerateLink(ctx context.Context, req GenerateLinkRequest) (*GenerateLinkData, error) {
if req.ActId == 0 || len(req.Sid) == 0 {
return nil, errors.New("请求参数actId或sid不能为空")
}
if len(req.ApiKey) == 0 { if len(req.ApiKey) == 0 {
req.ApiKey = a.client.authConfig.ApiKey req.ApiKey = a.client.authConfig.ApiKey
} }
@ -52,6 +56,15 @@ func (a *jutuikeApiImpl) GenerateLink(ctx context.Context, req GenerateLinkReque
// QueryOrderList 查询订单列表 // QueryOrderList 查询订单列表
func (a *jutuikeApiImpl) QueryOrderList(ctx context.Context, req QueryOrderListRequest) (*QueryOrderListData, error) { func (a *jutuikeApiImpl) QueryOrderList(ctx context.Context, req QueryOrderListRequest) (*QueryOrderListData, error) {
if len(req.StartTime) == 0 || len(req.EndTime) == 0 {
return nil, errors.New("请求参数start_time或end_time为必传")
}
if _, err := time.Parse(time.DateTime, req.StartTime); err != nil {
return nil, errors.New("开始时间start_time时间格式错误")
}
if _, err := time.Parse(time.DateTime, req.EndTime); err != nil {
return nil, errors.New("结束时间end_time时间格式错误")
}
if len(req.ApiKey) == 0 { if len(req.ApiKey) == 0 {
req.ApiKey = a.client.authConfig.ApiKey req.ApiKey = a.client.authConfig.ApiKey
} }

View File

@ -4,6 +4,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"testing" "testing"
"time"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"github.com/zeromicro/go-zero/core/logx" "github.com/zeromicro/go-zero/core/logx"
@ -46,7 +47,11 @@ func (a *apiClientSuite) Test_GenerateLink() {
} }
func (a *apiClientSuite) Test_QueryOrderList() { func (a *apiClientSuite) Test_QueryOrderList() {
req := QueryOrderListRequest{} req := QueryOrderListRequest{
StartTime: time.Now().Add(-1 * time.Minute).Format(time.DateTime),
EndTime: time.Now().Format(time.DateTime),
PageSize: 1,
}
result, err := a.api.QueryOrderList(context.Background(), req) result, err := a.api.QueryOrderList(context.Background(), req)
if !a.NoError(err) { if !a.NoError(err) {
a.T().Errorf("========[Test_QueryOrderList] response error:%s", err) a.T().Errorf("========[Test_QueryOrderList] response error:%s", err)

View File

@ -3,14 +3,14 @@ package jutuike
import "time" import "time"
type GenerateLinkRequest struct { type GenerateLinkRequest struct {
ApiKey string `json:"apikey"` // api key ApiKey string `json:"apikey"` // 必传 api key
ActId int64 `json:"act_id"` // 活动id ActId int64 `json:"act_id"` // 必传 活动id
Sid string `json:"sid"` // 自定义参数 Sid string `json:"sid"` // 必传 自定义参数
} }
// GenerateLinkResponse 生成推广链接响应 // GenerateLinkResponse 生成推广链接响应
type GenerateLinkResponse struct { type GenerateLinkResponse struct {
Code int32 `json:"code"` // 错误码 Code int32 `json:"code"` // 错误码0-错误1-成功
Msg string `json:"msg"` // 错误消息 Msg string `json:"msg"` // 错误消息
Data *GenerateLinkData `json:"data"` // 数据结构 Data *GenerateLinkData `json:"data"` // 数据结构
} }
@ -30,22 +30,22 @@ type WeAppInfo struct {
// 查询订单列表请求 // 查询订单列表请求
type QueryOrderListRequest struct { type QueryOrderListRequest struct {
ApiKey string `json:"api_key"` // api key ApiKey string `json:"apikey"` // api key
StartTime time.Time `json:"start_time"` // 是 2021-06-05 00:00:00 开始时间与结束时间不能超过1小时 StartTime string `json:"start_time"` // 是 2021-06-05 00:00:00 开始时间与结束时间不能超过1小时
EndTime time.Time `json:"end_time"` // 是 2021-06-05 00:00:00 结束时间与开始时间不能超过1小时 EndTime string `json:"end_time"` // 是 2021-06-05 00:00:00 结束时间与开始时间不能超过1小时
QueryType int32 `json:"query_type"` // 否 1 1 按支付时间 2按更新时间 3创建时间 默认3 QueryType int32 `json:"query_type,omitempty"` // 否 1 1 按支付时间 2按更新时间 3创建时间 默认3
Sid string `json:"sid"` // 否 自定义参数跟单 Sid string `json:"sid,omitempty"` // 否 自定义参数跟单
BrandId int32 `json:"brand_id"` // 否 1 品牌id 1 美团 2 饿了么 3 拼多多 4 京东 5 肯德基 6 电影 7 麦当劳 8 话费充值 9 百果园 10 奈雪的茶 11 瑞幸咖啡 12 星巴克 13 喜茶 14 唯品会 15 滴滴/花小猪 16 汉堡王 17 高德打车 18 电费充值 19 会员充值 20 特价快递 21 联联周边游 22 抖音联盟 23 必胜客 24 旅划算 25 大牌餐券 26 千千惠生活 27 流量卡 28 同程出行 29 华莱士 30 T3出行 31 景点门票 32 淘宝 BrandId int32 `json:"brand_id,omitempty"` // 否 1 品牌id 1 美团 2 饿了么 3 拼多多 4 京东 5 肯德基 6 电影 7 麦当劳 8 话费充值 9 百果园 10 奈雪的茶 11 瑞幸咖啡 12 星巴克 13 喜茶 14 唯品会 15 滴滴/花小猪 16 汉堡王 17 高德打车 18 电费充值 19 会员充值 20 特价快递 21 联联周边游 22 抖音联盟 23 必胜客 24 旅划算 25 大牌餐券 26 千千惠生活 27 流量卡 28 同程出行 29 华莱士 30 T3出行 31 景点门票 32 淘宝
Status int32 `json:"status"` // 否 1 订单统一状态0未付款 1已付款 2待结算 3已结算 4无效订单 Status int32 `json:"status,omitempty"` // 否 1 订单统一状态0未付款 1已付款 2待结算 3已结算 4无效订单
OrderSn string `json:"order_sn"` // 否 1234567 订单号 OrderSn string `json:"order_sn,omitempty"` // 否 1234567 订单号
RelationFlagName string `json:"relation_flag_name"` // 否 第三方渠道标识 RelationFlagName string `json:"relation_flag_name,omitempty"` // 否 第三方渠道标识
Page int32 `json:"page"` // 否 1 页码 默认 1 Page int32 `json:"page,omitempty"` // 否 1 页码 默认 1
PageSize int32 `json:"pageSize"` // 否 20 每页显示多少 默认 20 最大 100 PageSize int32 `json:"pageSize,omitempty"` // 否 20 每页显示多少 默认 20 最大 100
} }
// 查询订单列表响应 // 查询订单列表响应
type QueryOrderListResponse struct { type QueryOrderListResponse struct {
Code int32 `json:"code"` // 错误码 Code int32 `json:"code"` // 错误码0-错误1-成功
Msg string `json:"msg"` // 错误消息 Msg string `json:"msg"` // 错误消息
Data *QueryOrderListData `json:"data"` // 数据结构 Data *QueryOrderListData `json:"data"` // 数据结构
} }