diff --git a/platform/jutuike/api.go b/platform/jutuike/api.go index bb25c00..d3529e9 100644 --- a/platform/jutuike/api.go +++ b/platform/jutuike/api.go @@ -3,6 +3,7 @@ package jutuike import ( "context" "errors" + "time" "github.com/zeromicro/go-zero/core/logx" @@ -33,6 +34,9 @@ func newJutuikeApiImpl(log logx.Logger, client *Client) JutuikeApi { // GenerateLink 生成推广链接 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 { req.ApiKey = a.client.authConfig.ApiKey } @@ -52,6 +56,15 @@ func (a *jutuikeApiImpl) GenerateLink(ctx context.Context, req GenerateLinkReque // QueryOrderList 查询订单列表 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 { req.ApiKey = a.client.authConfig.ApiKey } diff --git a/platform/jutuike/api_test.go b/platform/jutuike/api_test.go index d706cfd..5738c03 100644 --- a/platform/jutuike/api_test.go +++ b/platform/jutuike/api_test.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "testing" + "time" "github.com/stretchr/testify/suite" "github.com/zeromicro/go-zero/core/logx" @@ -46,7 +47,11 @@ func (a *apiClientSuite) Test_GenerateLink() { } 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) if !a.NoError(err) { a.T().Errorf("========[Test_QueryOrderList] response error:%s", err) diff --git a/platform/jutuike/types.go b/platform/jutuike/types.go index ca26c90..7af3eb5 100644 --- a/platform/jutuike/types.go +++ b/platform/jutuike/types.go @@ -3,14 +3,14 @@ package jutuike import "time" type GenerateLinkRequest struct { - ApiKey string `json:"apikey"` // api key - ActId int64 `json:"act_id"` // 活动id - Sid string `json:"sid"` // 自定义参数 + ApiKey string `json:"apikey"` // 必传 api key + ActId int64 `json:"act_id"` // 必传 活动id + Sid string `json:"sid"` // 必传 自定义参数 } // GenerateLinkResponse 生成推广链接响应 type GenerateLinkResponse struct { - Code int32 `json:"code"` // 错误码 + Code int32 `json:"code"` // 错误码:0-错误,1-成功 Msg string `json:"msg"` // 错误消息 Data *GenerateLinkData `json:"data"` // 数据结构 } @@ -30,22 +30,22 @@ type WeAppInfo struct { // 查询订单列表请求 type QueryOrderListRequest struct { - ApiKey string `json:"api_key"` // api key - StartTime time.Time `json:"start_time"` // 是 2021-06-05 00:00:00 开始时间与结束时间不能超过1小时 - EndTime time.Time `json:"end_time"` // 是 2021-06-05 00:00:00 结束时间与开始时间不能超过1小时 - QueryType int32 `json:"query_type"` // 否 1 1: 按支付时间 2:按更新时间 3:创建时间 ,默认:3 - Sid string `json:"sid"` // 否 自定义参数跟单 - 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 淘宝 - Status int32 `json:"status"` // 否 1 订单统一状态,0:未付款 1:已付款 2:待结算 3:已结算 4:无效订单 - OrderSn string `json:"order_sn"` // 否 1234567 订单号 - RelationFlagName string `json:"relation_flag_name"` // 否 第三方渠道标识 - Page int32 `json:"page"` // 否 1 页码 默认 1 - PageSize int32 `json:"pageSize"` // 否 20 每页显示多少 默认 20 最大 100 + ApiKey string `json:"apikey"` // 是 api key + StartTime string `json:"start_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,omitempty"` // 否 1 1: 按支付时间 2:按更新时间 3:创建时间 ,默认:3 + Sid string `json:"sid,omitempty"` // 否 自定义参数跟单 + 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,omitempty"` // 否 1 订单统一状态,0:未付款 1:已付款 2:待结算 3:已结算 4:无效订单 + OrderSn string `json:"order_sn,omitempty"` // 否 1234567 订单号 + RelationFlagName string `json:"relation_flag_name,omitempty"` // 否 第三方渠道标识 + Page int32 `json:"page,omitempty"` // 否 1 页码 默认 1 + PageSize int32 `json:"pageSize,omitempty"` // 否 20 每页显示多少 默认 20 最大 100 } // 查询订单列表响应 type QueryOrderListResponse struct { - Code int32 `json:"code"` // 错误码 + Code int32 `json:"code"` // 错误码:0-错误,1-成功 Msg string `json:"msg"` // 错误消息 Data *QueryOrderListData `json:"data"` // 数据结构 }