中捷乐淘-取链

This commit is contained in:
yanfan 2025-02-24 17:54:14 +08:00
parent e186c08583
commit 460013ba5e
4 changed files with 19 additions and 4 deletions

View File

@ -1,6 +1,7 @@
package zjdg
import (
"context"
"fmt"
"github.com/zeromicro/go-zero/core/logx"
"repository.lenntc.com/lenntc/third-platform-sdk/client"
@ -10,7 +11,9 @@ import (
// ZjdgApi 中捷乐淘-淘宝一分购
type ZjdgApi interface {
// ZoneAdd 获取推广编号-创建
ZoneAdd(req *ZoneAddRequest) (*ZoneAddResponse, error)
ZoneAdd(ctx context.Context, req ZoneAddRequest) (*ZoneAddResponse, error)
// GenerateH5Url 生成H5链接
GenerateH5Url(ctx context.Context, req GenerateH5UrlRequest) (string, error)
}
type zjdgApiImpl struct {
log logx.Logger
@ -25,7 +28,7 @@ func newZjdgApiImpl(log logx.Logger, client *Client) ZjdgApi {
}
// ZoneAdd 获取推广编号
func (a *zjdgApiImpl) ZoneAdd(req *ZoneAddRequest) (*ZoneAddResponse, error) {
func (a *zjdgApiImpl) ZoneAdd(ctx context.Context, req ZoneAddRequest) (*ZoneAddResponse, error) {
// 响应示例 {"code":0,"message":"获取成功","data":"1963667","token_id":""}
zoneAddUrl := fmt.Sprintf("%s%s", ZoneAddUrl, a.client.authConfig.UserId)
args := util.StructToMap(req)
@ -41,3 +44,8 @@ func (a *zjdgApiImpl) ZoneAdd(req *ZoneAddRequest) (*ZoneAddResponse, error) {
AdZoneId: response.Data,
}, nil
}
func (a *zjdgApiImpl) GenerateH5Url(ctx context.Context, req GenerateH5UrlRequest) (string, error) {
promotionUrl := fmt.Sprintf(PromotionUrl, req.Sid, a.client.authConfig.UserId)
return promotionUrl, nil
}

View File

@ -28,7 +28,7 @@ func (a *apiClientSuite) SetupSuite() {
func (a *apiClientSuite) Test_ZoneAdd() {
req := ZoneAddRequest{}
result, err := a.api.ZoneAdd(&req)
result, err := a.api.ZoneAdd(context.Background(), req)
if !a.NoError(err) {
a.T().Errorf("========[Test_GenerateLink] response error:%s", err)
return

View File

@ -1,5 +1,6 @@
package zjdg
const (
ZoneAddUrl = "https://p.zjdg.cn/cpa/api/ugApi.ashx?method=getadzone_nologin&userid="
ZoneAddUrl = "https://p.zjdg.cn/cpa/api/ugApi.ashx?method=getadzone_nologin&userid="
PromotionUrl = "http://2025.zjdg.cn/ditui/qrcode?adzoneid=%s&userid=%s"
)

View File

@ -1,5 +1,11 @@
package zjdg
// GenerateH5UrlRequest 生成H5链接请求
type GenerateH5UrlRequest struct {
ActivityUrl string `json:"activityUrl"` // 活动url
Sid string `json:"sid"` // 二级分销ID
}
type ZoneAddRequest struct {
}
type ZoneAddResponse struct {