Compare commits
No commits in common. "832a812e58b2fa9f3f074ee9c9014c9d38a0aff8" and "68c12aa709962697fb3b543b4ef518b0a5a63da0" have entirely different histories.
832a812e58
...
68c12aa709
8
index.go
8
index.go
@ -2,7 +2,6 @@ package third_platform_sdk
|
||||
|
||||
import (
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/platform/fliggy"
|
||||
|
||||
didiunion "repository.lenntc.com/lenntc/third-platform-sdk/platform/didi-union"
|
||||
elemeunion "repository.lenntc.com/lenntc/third-platform-sdk/platform/eleme-union"
|
||||
@ -32,8 +31,6 @@ const (
|
||||
PlatformJutuike = "jutuike"
|
||||
// PlatformElongHotel 同程酒店
|
||||
PlatformElongHotel = "elong_hotel"
|
||||
// PlatformFliggy 飞猪
|
||||
PlatformFliggy = "fliggy"
|
||||
)
|
||||
|
||||
// PlatformNameMap 平台名称
|
||||
@ -46,7 +43,6 @@ var PlatformNameMap = map[string]string{
|
||||
PlatformMeituanMedia: "美团-美天赚",
|
||||
PlatformJutuike: "聚推客",
|
||||
PlatformElongHotel: "同程酒店",
|
||||
PlatformFliggy: "飞猪",
|
||||
}
|
||||
|
||||
// GetPlatformName 获取平台名称
|
||||
@ -93,7 +89,3 @@ func NewJutuikeApi(log logx.Logger, conf jutuike.AuthConfig) jutuike.JutuikeApi
|
||||
func NewElongHotelApi(log logx.Logger, conf elonghotel.AuthConfig) elonghotel.ElongHotelApi {
|
||||
return elonghotel.NewApiClient(log, conf)
|
||||
}
|
||||
|
||||
func NewFliggyApi(log logx.Logger, conf fliggy.AuthConfig) fliggy.FliggyApi {
|
||||
return fliggy.NewApiClient(log, conf)
|
||||
}
|
||||
|
||||
@ -1,13 +1,9 @@
|
||||
package fliggy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/fliggysdk/defaultability/domain"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/fliggysdk/defaultability/request"
|
||||
"strings"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
@ -15,10 +11,6 @@ import (
|
||||
// FliggyApi 飞猪平台
|
||||
// Api defines the interface of fliggy api
|
||||
type FliggyApi interface {
|
||||
// GenerateH5Url 生成H5链接
|
||||
GenerateH5Url(ctx context.Context, req GenerateH5UrlRequest) (string, error)
|
||||
// GenerateWechatUrl 生成微信小程序链接
|
||||
GenerateWechatUrl(ctx context.Context, req GenerateWechatUrlRequest) (string, error)
|
||||
// FliggyPromoteOrdersList 飞猪分销订单列表
|
||||
FliggyPromoteOrdersList(req *request.AlibabaFliggyPromoteOrdersListRequest) ([]*domain.AlibabaFliggyPromoteOrdersListOrder, error)
|
||||
}
|
||||
@ -35,50 +27,6 @@ func newFliggyApiImpl(log logx.Logger, client *Client) FliggyApi {
|
||||
}
|
||||
}
|
||||
|
||||
// GenerateH5Url 生成H5推广链接
|
||||
// 飞猪官方不支持H5取链,生成的H5url为小程序中间页URL
|
||||
func (a *fliggyApiImpl) GenerateH5Url(ctx context.Context, req GenerateH5UrlRequest) (string, error) {
|
||||
var activityUrl string
|
||||
if len(req.ActivityUrl) == 0 {
|
||||
return "", errors.New("url参数不能为空")
|
||||
}
|
||||
urls := strings.Split(req.ActivityUrl, "?")
|
||||
if len(urls) == 1 {
|
||||
activityUrl = fmt.Sprintf("%s?linkCode=%s&actId=%s", req.ActivityUrl, req.LinkCode, req.ActId)
|
||||
return activityUrl, nil
|
||||
} else if len(urls) == 2 {
|
||||
activityUrl = fmt.Sprintf("%s&linkCode=%s&actId=%s", req.ActivityUrl, req.LinkCode, req.ActId)
|
||||
return activityUrl, nil
|
||||
} else {
|
||||
return "", errors.New("url参数有误")
|
||||
}
|
||||
}
|
||||
|
||||
// GenerateWechatUrl 生成微信小程序推广链接
|
||||
func (a *fliggyApiImpl) GenerateWechatUrl(ctx context.Context, req GenerateWechatUrlRequest) (string, error) {
|
||||
// 分两种类型的URL
|
||||
// 1. 小程序路径为 pages/home/index 只处理fpsid的值即可
|
||||
// 2. 小程序路径为 pages/main/webview 需要将小程序后面的参数url urldecode后 将fpsid填充 再次urlencode后拼接回 小程序路径后面?url=
|
||||
urls := strings.Split("?", req.ActivityUrl)
|
||||
if len(urls) < 2 {
|
||||
return "", errors.New("活动链接错误")
|
||||
}
|
||||
newUrl := ""
|
||||
switch urls[0] {
|
||||
case "pages/home/index":
|
||||
newUrl = strings.ReplaceAll(req.ActivityUrl, "fpsid=", fmt.Sprintf("fpsid=%s", req.FpSid))
|
||||
case "pages/main/webview":
|
||||
parsedURL, err := url.Parse(req.ActivityUrl)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("error parsing url:%s", err.Error())
|
||||
}
|
||||
urlValue := parsedURL.Query().Get("url")
|
||||
newUrlValue := strings.ReplaceAll(urlValue, "fpsid=", fmt.Sprintf("fpsid=%s", req.FpSid))
|
||||
newUrl = fmt.Sprintf("pages/main/webview?url=%s", url.QueryEscape(newUrlValue))
|
||||
}
|
||||
return newUrl, nil
|
||||
}
|
||||
|
||||
// FliggyPromoteOrdersList 飞猪分销订单列表
|
||||
func (a *fliggyApiImpl) FliggyPromoteOrdersList(req *request.AlibabaFliggyPromoteOrdersListRequest) ([]*domain.AlibabaFliggyPromoteOrdersListOrder, error) {
|
||||
resp, err := a.client.abilityClient.AlibabaFliggyPromoteOrdersList(req)
|
||||
|
||||
@ -10,17 +10,3 @@ type PublicParam struct {
|
||||
Format string // 否 返回内容响应格式。不传默认为xml格式,可选值:xml,json。
|
||||
Simplify bool // 否 是否采用精简JSON返回格式,仅当format=json时有效,可选值:false,true,不传为false。
|
||||
}
|
||||
|
||||
// GenerateWechatUrlRequest 生成微信小程序链接的请求
|
||||
type GenerateWechatUrlRequest struct {
|
||||
ActivityUrl string `json:"activityUrl"` // 活动url
|
||||
FpSid string `json:"fpsid"` // 二级分销ID
|
||||
}
|
||||
|
||||
// GenerateH5UrlRequest 生成H5链接请求
|
||||
type GenerateH5UrlRequest struct {
|
||||
ActivityUrl string `json:"activityUrl"` // 活动url
|
||||
FpSid string `json:"fpSid"` // 二级分销ID
|
||||
LinkCode string `json:"linkCode"` // 链接code
|
||||
ActId string `json:"actId"` // 活动id
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user