Compare commits
35 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f7b17cc03 | ||
|
|
4ae022fc5e | ||
|
|
ea00ab3a31 | ||
|
|
ce8c7bfd50 | ||
|
|
39c78abafe | ||
|
|
2dc89e17bc | ||
|
|
19124972ae | ||
|
|
a92f4890da | ||
|
|
edc20b3c7a | ||
|
|
d3e3119c14 | ||
|
|
338411e6ee | ||
|
|
460013ba5e | ||
|
|
e186c08583 | ||
|
|
02924de3f8 | ||
|
|
98580f4b7b | ||
|
|
82314317b3 | ||
|
|
b557a96fea | ||
|
|
532e0b68f2 | ||
|
|
982f6981d4 | ||
|
|
4c4478dc84 | ||
|
|
15b7beba01 | ||
|
|
d9f889ffd0 | ||
|
|
3a2a829f59 | ||
|
|
8c1cb9f856 | ||
|
|
bfd212cbb3 | ||
|
|
dcc3d9a8ba | ||
|
|
832a812e58 | ||
|
|
23c4f451cc | ||
|
|
68c12aa709 | ||
|
|
4280c226b1 | ||
|
|
bf2bc639eb | ||
|
|
7c14d9c20e | ||
|
|
90bad61d0a | ||
|
|
8f03a210f5 | ||
|
|
1156ddac7c |
@ -36,8 +36,8 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
sdk "gitee.com/chengdu-lenntc/third-platform-sdk"
|
||||
meituanapi "gitee.com/chengdu-lenntc/third-platform-sdk/platform/meituan-union"
|
||||
sdk "repository.lenntc.com/lenntc/third-platform-sdk"
|
||||
meituanapi "repository.lenntc.com/lenntc/third-platform-sdk/platform/meituan-union"
|
||||
)
|
||||
|
||||
type PromotionConf struct {
|
||||
|
||||
@ -7,7 +7,7 @@ import (
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/util"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/util"
|
||||
)
|
||||
|
||||
// HttpRequest http请求参数
|
||||
|
||||
25
go.mod
25
go.mod
@ -1,4 +1,4 @@
|
||||
module gitee.com/chengdu-lenntc/third-platform-sdk
|
||||
module repository.lenntc.com/lenntc/third-platform-sdk
|
||||
|
||||
go 1.19
|
||||
|
||||
@ -12,22 +12,43 @@ require (
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0
|
||||
)
|
||||
|
||||
require google.golang.org/genproto v0.0.0-20230526161137-0005af68ea54
|
||||
require google.golang.org/genproto v0.0.0-20230526161137-0005af68ea54 // indirect
|
||||
|
||||
require (
|
||||
github.com/cenkalti/backoff/v4 v4.2.0 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/fatih/color v1.15.0 // indirect
|
||||
github.com/go-logr/logr v1.2.3 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/golang/protobuf v1.5.3 // indirect
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.17 // indirect
|
||||
github.com/openzipkin/zipkin-go v0.4.1 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
||||
github.com/spf13/cast v1.7.0 // indirect
|
||||
go.opentelemetry.io/otel v1.14.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/jaeger v1.14.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.14.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.14.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.14.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.14.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.14.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/zipkin v1.14.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.14.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.14.0 // indirect
|
||||
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
|
||||
go.uber.org/atomic v1.10.0 // indirect
|
||||
go.uber.org/automaxprocs v1.5.3 // indirect
|
||||
go.uber.org/multierr v1.9.0 // indirect
|
||||
golang.org/x/net v0.14.0 // indirect
|
||||
golang.org/x/sys v0.11.0 // indirect
|
||||
golang.org/x/text v0.12.0 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20230525234035-dd9d682886f9 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 // indirect
|
||||
google.golang.org/grpc v1.57.0 // indirect
|
||||
google.golang.org/protobuf v1.31.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
||||
95
index.go
95
index.go
@ -2,15 +2,24 @@ package third_platform_sdk
|
||||
|
||||
import (
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
jd_union "repository.lenntc.com/lenntc/third-platform-sdk/platform/jd-union"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/platform/yapingtech"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/platform/zhetaoke"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/platform/zjdg"
|
||||
|
||||
didiunion "gitee.com/chengdu-lenntc/third-platform-sdk/platform/didi-union"
|
||||
elemeunion "gitee.com/chengdu-lenntc/third-platform-sdk/platform/eleme-union"
|
||||
elonghotel "gitee.com/chengdu-lenntc/third-platform-sdk/platform/elong-hotel"
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/platform/jutuike"
|
||||
meituancsr "gitee.com/chengdu-lenntc/third-platform-sdk/platform/meituan-csr"
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/platform/meituan-media"
|
||||
meituanunion "gitee.com/chengdu-lenntc/third-platform-sdk/platform/meituan-union"
|
||||
t3_union "gitee.com/chengdu-lenntc/third-platform-sdk/platform/t3-union"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/platform/fliggy"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/platform/meituan"
|
||||
shoutu_show "repository.lenntc.com/lenntc/third-platform-sdk/platform/shoutu-show"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/platform/youpiaopiao"
|
||||
|
||||
didiunion "repository.lenntc.com/lenntc/third-platform-sdk/platform/didi-union"
|
||||
elemeunion "repository.lenntc.com/lenntc/third-platform-sdk/platform/eleme-union"
|
||||
elonghotel "repository.lenntc.com/lenntc/third-platform-sdk/platform/elong-hotel"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/platform/jutuike"
|
||||
meituancsr "repository.lenntc.com/lenntc/third-platform-sdk/platform/meituan-csr"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/platform/meituan-media"
|
||||
meituanunion "repository.lenntc.com/lenntc/third-platform-sdk/platform/meituan-union"
|
||||
t3_union "repository.lenntc.com/lenntc/third-platform-sdk/platform/t3-union"
|
||||
)
|
||||
|
||||
// Platform 第三方平台
|
||||
@ -19,7 +28,7 @@ const (
|
||||
PlatformElemeUnion = "ele"
|
||||
// PlatformMeituanCsr 美团分销联盟
|
||||
PlatformMeituanCsr = "meituan_csr"
|
||||
// PlatformMeituanUnion 美团联盟
|
||||
// PlatformMeituanUnion 美团千载
|
||||
PlatformMeituanUnion = "meituan_union"
|
||||
// PlatformDidiUnion 滴滴联盟
|
||||
PlatformDidiUnion = "didi_union"
|
||||
@ -31,18 +40,42 @@ const (
|
||||
PlatformJutuike = "jutuike"
|
||||
// PlatformElongHotel 同程酒店
|
||||
PlatformElongHotel = "elong_hotel"
|
||||
// PlatformFliggy 飞猪
|
||||
PlatformFliggy = "fliggy"
|
||||
// PlatformShoutuShow 守兔演出
|
||||
PlatformShoutuShow = "shoutu_show"
|
||||
// PlatformYouPiaoPiao 有票票
|
||||
PlatformYouPiaoPiao = "youpiaopiao"
|
||||
// PlatformMeituan 美团联盟
|
||||
PlatformMeituan = "meituan"
|
||||
// PlatformZdjg 中捷乐淘-淘宝一分购
|
||||
PlatformZdjg = "zjdg"
|
||||
// PlatformJdUnion 京东联盟
|
||||
PlatformJdUnion = "jd_union"
|
||||
// PlatformZheTaoKe 折淘客
|
||||
PlatformZheTaoKe = "zhetaoke"
|
||||
// PlatformYaPingTech 亚平
|
||||
PlatformYaPingTech = "yapingtech"
|
||||
)
|
||||
|
||||
// PlatformNameMap 平台名称
|
||||
var PlatformNameMap = map[string]string{
|
||||
PlatformElemeUnion: "饿了么联盟",
|
||||
PlatformMeituanCsr: "美团分销联盟",
|
||||
PlatformMeituanUnion: "美团联盟",
|
||||
PlatformMeituanUnion: "美团千载",
|
||||
PlatformDidiUnion: "滴滴联盟",
|
||||
PlatformT3Union: "t3联盟",
|
||||
PlatformMeituanMedia: "美团-美天赚",
|
||||
PlatformJutuike: "聚推客",
|
||||
PlatformElongHotel: "同程酒店",
|
||||
PlatformFliggy: "飞猪",
|
||||
PlatformShoutuShow: "守兔演出",
|
||||
PlatformYouPiaoPiao: "有票票",
|
||||
PlatformMeituan: "美团联盟",
|
||||
PlatformZdjg: "中捷乐淘-淘宝一分购",
|
||||
PlatformJdUnion: "京东联盟",
|
||||
PlatformZheTaoKe: "折淘客",
|
||||
PlatformYaPingTech: "亚平",
|
||||
}
|
||||
|
||||
// GetPlatformName 获取平台名称
|
||||
@ -60,7 +93,7 @@ func NewMeituanCsrApi(log logx.Logger, conf meituancsr.AuthConfig) meituancsr.Me
|
||||
return meituancsr.NewApiClient(log, conf)
|
||||
}
|
||||
|
||||
// NewMeituanUnionApi 美团联盟
|
||||
// NewMeituanUnionApi 美团千载
|
||||
func NewMeituanUnionApi(log logx.Logger, conf meituanunion.AuthConfig) meituanunion.MeituanUnionApi {
|
||||
return meituanunion.NewApiClient(log, conf)
|
||||
}
|
||||
@ -89,3 +122,43 @@ 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)
|
||||
}
|
||||
|
||||
// NewFliggyApi 飞猪
|
||||
func NewFliggyApi(log logx.Logger, conf fliggy.AuthConfig) fliggy.FliggyApi {
|
||||
return fliggy.NewApiClient(log, conf)
|
||||
}
|
||||
|
||||
// NewShoutuShow 守兔
|
||||
func NewShoutuShow(log logx.Logger, conf shoutu_show.AuthConfig) shoutu_show.ShouTuShowApi {
|
||||
return shoutu_show.NewApiClient(log, conf)
|
||||
}
|
||||
|
||||
// NewYouPiaoPiao 有票票
|
||||
func NewYouPiaoPiao(log logx.Logger, conf youpiaopiao.AuthConfig) youpiaopiao.YouPiaoPiaoApi {
|
||||
return youpiaopiao.NewApiClient(log, conf)
|
||||
}
|
||||
|
||||
// NewMeituanApi 美团联盟
|
||||
func NewMeituanApi(log logx.Logger, conf meituan.AuthConfig) meituan.MeituanApi {
|
||||
return meituan.NewApiClient(log, conf)
|
||||
}
|
||||
|
||||
// NewZjdgApi 中捷乐淘-淘宝一分购
|
||||
func NewZjdgApi(log logx.Logger, conf zjdg.AuthConfig) zjdg.ZjdgApi {
|
||||
return zjdg.NewApiClient(log, conf)
|
||||
}
|
||||
|
||||
// NewJdUnion 京东联盟
|
||||
func NewJdUnion(log logx.Logger, conf jd_union.AuthConfig) jd_union.JdUnionApi {
|
||||
return jd_union.NewApiClient(log, conf)
|
||||
}
|
||||
|
||||
// NewZheTaoKe 折淘客
|
||||
func NewZheTaoKe(log logx.Logger, conf zhetaoke.AuthConfig) zhetaoke.ZheTaoKeApi {
|
||||
return zhetaoke.NewApiClient(log, conf)
|
||||
}
|
||||
|
||||
// NewYaPingTech 亚平
|
||||
func NewYaPingTech(log logx.Logger, conf yapingtech.AuthConfig) yapingtech.YaPingTechApi {
|
||||
return yapingtech.NewApiClient(log, conf)
|
||||
}
|
||||
|
||||
@ -9,8 +9,8 @@ import (
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"github.com/zywaited/xcopy"
|
||||
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/sdk/dunion-go-sdk/model"
|
||||
sdkutil "gitee.com/chengdu-lenntc/third-platform-sdk/sdk/dunion-go-sdk/util"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/dunion-go-sdk/model"
|
||||
sdkutil "repository.lenntc.com/lenntc/third-platform-sdk/sdk/dunion-go-sdk/util"
|
||||
)
|
||||
|
||||
// todo:: 定义统一的返回错误结构
|
||||
|
||||
@ -8,7 +8,7 @@ import (
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/sdk/dunion-go-sdk/model"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/dunion-go-sdk/model"
|
||||
)
|
||||
|
||||
// api-单元测试
|
||||
@ -24,8 +24,8 @@ func TestApiClient(t *testing.T) {
|
||||
func (a *apiClientSuite) SetupSuite() {
|
||||
log := logx.WithContext(context.Background())
|
||||
apiClient := NewApiClient(log, AuthConfig{
|
||||
AppKey: "2M0QUa0o6ER8nuX1",
|
||||
AppSecret: "obvJ5mmV45ZWA3YpO95njR1xH62JT50h",
|
||||
AppKey: "",
|
||||
AppSecret: "",
|
||||
})
|
||||
a.api = apiClient
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@ package didi_union
|
||||
import (
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/sdk/dunion-go-sdk/client"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/dunion-go-sdk/client"
|
||||
)
|
||||
|
||||
// AuthConfig api鉴权参数
|
||||
|
||||
@ -3,7 +3,7 @@ package didi_union
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/sdk/dunion-go-sdk/model"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/dunion-go-sdk/model"
|
||||
)
|
||||
|
||||
// GenerateLinkRequest 生成推广链接的请求
|
||||
|
||||
@ -2,20 +2,19 @@ package eleme_union
|
||||
|
||||
import (
|
||||
"errors"
|
||||
sdkutil "repository.lenntc.com/lenntc/third-platform-sdk/sdk/dunion-go-sdk/util"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/sdk/topsdk/defaultability/domain"
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/sdk/topsdk/defaultability/request"
|
||||
sdkutil "gitee.com/chengdu-lenntc/third-platform-sdk/sdk/topsdk/util"
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/util"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/topsdk/defaultability/domain"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/topsdk/defaultability/request"
|
||||
)
|
||||
|
||||
// ElemeUnionApi 调用第三方平台的api
|
||||
// Api defines the interface of eleme_union api
|
||||
type ElemeUnionApi interface {
|
||||
// Sign 签名
|
||||
Sign(publicParam PublicParam, data map[string]interface{}) string
|
||||
Sign(data map[string]interface{}) string
|
||||
// KbItemPromotionShareCreate 本地生活媒体创建商品推广链接
|
||||
KbItemPromotionShareCreate(req *request.AlibabaAlscUnionKbItemPromotionShareCreateRequest) (*domain.AlibabaAlscUnionKbItemPromotionShareCreateExtendDTO, error)
|
||||
// ElemePromotionOfficialActivityGet 本地联盟饿了么推广官方活动查询
|
||||
@ -43,8 +42,8 @@ func newElemeUnionApiImpl(log logx.Logger, client *Client) ElemeUnionApi {
|
||||
// Sign 签名
|
||||
// @param publicParam 公共参数
|
||||
// @param data 业务参数
|
||||
func (a *elemeUnionApiImpl) Sign(publicParam PublicParam, data map[string]interface{}) string {
|
||||
return sdkutil.GetSign(util.StructToMap(publicParam), data, a.client.authConfig.AppSecret)
|
||||
func (a *elemeUnionApiImpl) Sign(data map[string]interface{}) string {
|
||||
return sdkutil.GetSign(data, a.client.authConfig.AppSecret)
|
||||
}
|
||||
|
||||
// KbItemPromotionShareCreate 本地生活媒体创建商品推广链接
|
||||
@ -132,9 +131,7 @@ func (a *elemeUnionApiImpl) KbcpxPositiveOrderGet(req *request.AlibabaAlscUnionK
|
||||
}
|
||||
var result []*domain.AlibabaAlscUnionKbcpxPositiveOrderGetOrderDetailReportDTO
|
||||
for _, item := range resp.Result {
|
||||
entity := item
|
||||
entity.BizUnit = req.BizUnit // 将业务类型,手动添加到订单详情数据中
|
||||
result = append(result, &entity)
|
||||
result = append(result, &item)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@ -3,15 +3,13 @@ package eleme_union
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"testing"
|
||||
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/sdk/topsdk/defaultability/domain"
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/sdk/topsdk/defaultability/request"
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/util/pointer"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/topsdk/defaultability/domain"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/topsdk/defaultability/request"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/util/pointer"
|
||||
)
|
||||
|
||||
// api-单元测试
|
||||
@ -37,26 +35,41 @@ func (a *apiClientSuite) Test_Sign() {
|
||||
data := map[string]interface{}{
|
||||
"method": "test",
|
||||
}
|
||||
publicParam := PublicParam{
|
||||
Method: "taobao.item.seller.get", // 必传 API接口名称,具体参见各平台API接口文档,例:taobao.item.seller.get
|
||||
AppKey: "34632005", // 必传 TOP分配给应用的AppKey。例:12345678
|
||||
Session: "", // 可选 用户授权成功后,平台颁发给应用的授权session,详细介绍请点击这里。当此API文档的标签上注明:“需要授权”,则此参数必传;“不需要授权”,则此参数不需要传。
|
||||
Timestamp: time.Now().Format("2006-01-02 15:04:05"), // 必传 时间戳,格式为yyyy-MM-dd HH:mm:ss,时区为GMT+8,例如:2016-01-01 12:00:00。淘宝API服务端允许客户端请求最大时间误差为10分钟。
|
||||
V: "2.0", // 必传 API协议版本,可选值:2.0
|
||||
SignMethod: "md5", // 必传 签名的摘要算法,可选值为:hmac,md5,hmac-sha256。
|
||||
Format: "json", // 否 返回内容响应格式。不传默认为xml格式,可选值:xml,json。
|
||||
Simplify: false, // 否 是否采用精简JSON返回格式,仅当format=json时有效,可选值:false,true,不传为false。
|
||||
}
|
||||
//publicParam := PublicParam{
|
||||
// Method: "taobao.item.seller.get", // 必传 API接口名称,具体参见各平台API接口文档,例:taobao.item.seller.get
|
||||
// AppKey: "34632005", // 必传 TOP分配给应用的AppKey。例:12345678
|
||||
// Session: "", // 可选 用户授权成功后,平台颁发给应用的授权session,详细介绍请点击这里。当此API文档的标签上注明:“需要授权”,则此参数必传;“不需要授权”,则此参数不需要传。
|
||||
// Timestamp: time.Now().Format("2006-01-02 15:04:05"), // 必传 时间戳,格式为yyyy-MM-dd HH:mm:ss,时区为GMT+8,例如:2016-01-01 12:00:00。淘宝API服务端允许客户端请求最大时间误差为10分钟。
|
||||
// V: "2.0", // 必传 API协议版本,可选值:2.0
|
||||
// SignMethod: "md5", // 必传 签名的摘要算法,可选值为:hmac,md5,hmac-sha256。
|
||||
// Format: "json", // 否 返回内容响应格式。不传默认为xml格式,可选值:xml,json。
|
||||
// Simplify: false, // 否 是否采用精简JSON返回格式,仅当format=json时有效,可选值:false,true,不传为false。
|
||||
//}
|
||||
|
||||
sign := a.api.Sign(publicParam, data)
|
||||
sign := a.api.Sign(data)
|
||||
a.T().Logf("=====[TestSign] sign: %s", sign)
|
||||
}
|
||||
|
||||
func (a *apiClientSuite) Test_KbItemPromotionShareCreate() {
|
||||
req := &request.AlibabaAlscUnionKbItemPromotionShareCreateRequest{
|
||||
Pid: pointer.String("alsc_23378482_4796002_21291126"),
|
||||
ItemId: pointer.String("10144"),
|
||||
Sid: pointer.String("10001zdt100004"),
|
||||
}
|
||||
resp, err := a.api.KbItemPromotionShareCreate(req)
|
||||
if err != nil {
|
||||
a.T().Errorf("=====[Test_ElemePromotionOfficialActivityGet] err: %v", err)
|
||||
return
|
||||
}
|
||||
a.T().Logf("=====[Test_ElemePromotionOfficialActivityGet] resp: %+v", resp)
|
||||
}
|
||||
|
||||
func (a *apiClientSuite) Test_ElemePromotionOfficialActivityGet() {
|
||||
req := &request.AlibabaAlscUnionElemePromotionOfficialactivityGetRequest{
|
||||
QueryRequest: &domain.AlibabaAlscUnionElemePromotionOfficialactivityGetActivityRequest{
|
||||
Pid: pointer.String("alsc_23378482_4796002_15513017"),
|
||||
ActivityId: pointer.String("10690111"),
|
||||
ActivityId: pointer.String("12628"),
|
||||
Sid: pointer.String("10001zdt100004"),
|
||||
},
|
||||
}
|
||||
resp, err := a.api.ElemePromotionOfficialActivityGet(req)
|
||||
@ -64,7 +77,8 @@ func (a *apiClientSuite) Test_ElemePromotionOfficialActivityGet() {
|
||||
a.T().Errorf("=====[Test_ElemePromotionOfficialActivityGet] err: %v", err)
|
||||
return
|
||||
}
|
||||
a.T().Logf("=====[Test_ElemePromotionOfficialActivityGet] resp: %+v", resp)
|
||||
str, err := json.Marshal(resp)
|
||||
a.T().Logf("=====[Test_ElemePromotionOfficialActivityGet] resp: %s", str)
|
||||
}
|
||||
|
||||
func (a *apiClientSuite) Test_KbcpxPositiveOrderGet() {
|
||||
|
||||
@ -2,12 +2,12 @@ package eleme_union
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/topsdk"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/sdk/topsdk"
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/sdk/topsdk/defaultability"
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/util"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/topsdk/defaultability"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/util"
|
||||
)
|
||||
|
||||
// AuthConfig api鉴权参数
|
||||
|
||||
@ -6,12 +6,14 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"github.com/zywaited/xcopy"
|
||||
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/client"
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/util"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/client"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/util"
|
||||
)
|
||||
|
||||
// ElongHotelApi 同程酒店的api
|
||||
@ -19,8 +21,10 @@ import (
|
||||
type ElongHotelApi interface {
|
||||
// GetExternalChannelConfig 获取渠道配置信息
|
||||
GetExternalChannelConfig(ctx context.Context, req GetExternalChannelConfigRequest, env string) (*ExternalChannelConfigResponse, error)
|
||||
// GenerateUrl 生成链接
|
||||
GenerateUrl(ctx context.Context, req GenerateUrlRequest) (string, error)
|
||||
// GenerateWechatUrl 生成微信小程序链接
|
||||
GenerateWechatUrl(ctx context.Context, req GenerateWechatUrlRequest) (string, error)
|
||||
// GenerateH5Url 生成H5链接
|
||||
GenerateH5Url(ctx context.Context, req GenerateH5UrlRequest) (string, error)
|
||||
// QueryOrderList 查询订单列表
|
||||
QueryOrderList(ctx context.Context, req QueryOrderListRequest, env string) (*ExternalOrderData, error)
|
||||
}
|
||||
@ -37,9 +41,9 @@ func newElongHotelApiImpl(log logx.Logger, client *Client) ElongHotelApi {
|
||||
}
|
||||
}
|
||||
|
||||
// GenerateLink 生成短链
|
||||
// GetExternalChannelConfig 生成短链
|
||||
func (t *elongHotelApiImpl) GetExternalChannelConfig(ctx context.Context, req GetExternalChannelConfigRequest, env string) (*ExternalChannelConfigResponse, error) {
|
||||
var url string
|
||||
var apiUrl string
|
||||
token := t.client.authConfig.Token
|
||||
tn := time.Now()
|
||||
actionTime := tn.Unix()
|
||||
@ -55,11 +59,11 @@ func (t *elongHotelApiImpl) GetExternalChannelConfig(ctx context.Context, req Ge
|
||||
request := &client.HttpRequest{Headers: t.client.headers, QueryArgs: args}
|
||||
response := new(GetExternalChannelConfigResponse)
|
||||
if env == EnvHuidu {
|
||||
url = HDApiDomain + GetLinkUri
|
||||
apiUrl = HDApiDomain + GetLinkUri
|
||||
} else {
|
||||
url = ApiDomain + GetLinkUri
|
||||
apiUrl = ApiDomain + GetLinkUri
|
||||
}
|
||||
if err := t.client.HttpGet(url, request, &client.HttpResponse{Result: response}); err != nil {
|
||||
if err := t.client.HttpGet(apiUrl, request, &client.HttpResponse{Result: response}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if response.Code != 200 {
|
||||
@ -70,8 +74,8 @@ func (t *elongHotelApiImpl) GetExternalChannelConfig(ctx context.Context, req Ge
|
||||
return response.Data, nil
|
||||
}
|
||||
|
||||
// GenerateUrl 生成链接
|
||||
func (t *elongHotelApiImpl) GenerateUrl(ctx context.Context, req GenerateUrlRequest) (string, error) {
|
||||
// GenerateWechatUrl 生成微信小程序链接
|
||||
func (t *elongHotelApiImpl) GenerateWechatUrl(ctx context.Context, req GenerateWechatUrlRequest) (string, error) {
|
||||
if len(req.ActivityUrl) == 0 {
|
||||
return "", errors.New("url参数不能为空")
|
||||
}
|
||||
@ -95,23 +99,58 @@ func (t *elongHotelApiImpl) GenerateUrl(ctx context.Context, req GenerateUrlRequ
|
||||
srcUrl.RawQuery = srcParams.Encode()
|
||||
newSrc := url.QueryEscape(srcUrl.String())
|
||||
urlParams.Set("src", newSrc)
|
||||
urlParams.Add("isRefresh", "refresh")
|
||||
u.RawQuery = urlParams.Encode()
|
||||
urlSrc := fmt.Sprintf("src=%s", newSrc)
|
||||
urlParams.Del("src")
|
||||
u.RawQuery = fmt.Sprintf("%s&%s", urlSrc, urlParams.Encode())
|
||||
return u.String(), nil
|
||||
}
|
||||
|
||||
// GenerateH5Url 生成H5链接
|
||||
func (t *elongHotelApiImpl) 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参数有误")
|
||||
}
|
||||
|
||||
//u, err := url.Parse(req.ActivityUrl)
|
||||
//if err != nil {
|
||||
// return "", errors.New("activityUrl不是一个url")
|
||||
//}
|
||||
//
|
||||
//urlParams := u.Query()
|
||||
//urlParams.Set("linkCode", req.LinkCode)
|
||||
//urlParams.Set("actId", req.ActId)
|
||||
//u.RawQuery = urlParams.Encode()
|
||||
//return u.String(), nil
|
||||
}
|
||||
|
||||
// QueryOrderList 查询订单列表
|
||||
func (t *elongHotelApiImpl) QueryOrderList(ctx context.Context, req QueryOrderListRequest, env string) (*ExternalOrderData, error) {
|
||||
var url string
|
||||
args := util.StructToMap(req)
|
||||
var apiUrl string
|
||||
var apiReq *QueryOrderListReq
|
||||
if err := xcopy.Copy(&apiReq, req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
apiReq.AppId = t.client.authConfig.AppId
|
||||
args := util.StructToMap(apiReq)
|
||||
request := &client.HttpRequest{Headers: t.client.headers, QueryArgs: args}
|
||||
response := new(GetExternalOrderResp)
|
||||
if env == EnvHuidu {
|
||||
url = HDApiDomain + GetOrderListUri
|
||||
apiUrl = HDApiDomain + GetOrderListUri
|
||||
} else {
|
||||
url = ApiDomain + GetOrderListUri
|
||||
apiUrl = ApiDomain + GetOrderListUri
|
||||
}
|
||||
if err := t.client.HttpGet(url, request, &client.HttpResponse{Result: response}); err != nil {
|
||||
if err := t.client.HttpGet(apiUrl, request, &client.HttpResponse{Result: response}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if response.Code != 200 {
|
||||
|
||||
@ -22,7 +22,7 @@ func TestApiClient(t *testing.T) {
|
||||
func (a *apiClientSuite) SetupSuite() {
|
||||
log := logx.WithContext(context.Background())
|
||||
apiClient := NewApiClient(log, AuthConfig{
|
||||
Token: "dfae91a85341865b",
|
||||
Token: "",
|
||||
})
|
||||
a.api = apiClient
|
||||
}
|
||||
@ -44,12 +44,13 @@ func (a *apiClientSuite) Test_GenerateLink() {
|
||||
a.T().Logf("=====[Test_GenerateLink] result: %s", string(resultByte))
|
||||
}
|
||||
|
||||
func (a *apiClientSuite) Test_GenerateUrl() {
|
||||
req := GenerateUrlRequest{
|
||||
ActivityUrl: "/page/home/webview/webview?src=https%3A%2F%2Fmp.elong.com%2Ftenthousandaura%2F%3Factivitycode%3D5fd89a11-7b58-4f5c-8dc9-c360936d4207%26of%3D99810010",
|
||||
func (a *apiClientSuite) Test_GenerateWechtUrl() {
|
||||
req := GenerateWechatUrlRequest{
|
||||
//ActivityUrl: "/page/home/webview/webview?src=https%3A%2F%2Fmp.elong.com%2Ftenthousandaura%2F%3Factivitycode%3D5fd89a11-7b58-4f5c-8dc9-c360936d4207%26of%3D99810010",
|
||||
ActivityUrl: "/page/home/webview/webview?src=https%3A%2F%2Fmp.elong.com%2Ftenthousandaura%2F%3Factivitycode%3D73086812-aaae-48ba-b14a-f087a6b61a92%26isSocket%3DHotelActivityId_9043%26of%3D5027785&isRefresh=refresh&isSocket=HotelActivityId_9043",
|
||||
Uid: "11111111111111111",
|
||||
}
|
||||
result, err := a.api.GenerateUrl(context.Background(), req)
|
||||
result, err := a.api.GenerateWechatUrl(context.Background(), req)
|
||||
if !a.NoError(err) {
|
||||
a.T().Errorf("========[Test_GenerateUrl] response error:%s", err)
|
||||
return
|
||||
@ -57,9 +58,22 @@ func (a *apiClientSuite) Test_GenerateUrl() {
|
||||
a.T().Logf("=====[Test_GenerateUrl] result: %s", string(result))
|
||||
}
|
||||
|
||||
func (a *apiClientSuite) Test_GenerateH5Url() {
|
||||
req := GenerateH5UrlRequest{
|
||||
ActivityUrl: "https://cms.zhongdiantui.com/#/pages/toMiniProgram/toMiniProgram?type=2sfee",
|
||||
LinkCode: "ffaefe3r3434334trq34",
|
||||
ActId: "100006",
|
||||
}
|
||||
result, err := a.api.GenerateH5Url(context.Background(), req)
|
||||
if !a.NoError(err) {
|
||||
a.T().Errorf("========[Test_GenerateH5Url] response error:%s", err)
|
||||
return
|
||||
}
|
||||
a.T().Logf("=====[Test_GenerateH5Url] result: %s", string(result))
|
||||
}
|
||||
|
||||
func (a *apiClientSuite) Test_QueryOrderList() {
|
||||
req := QueryOrderListRequest{
|
||||
AppId: "",
|
||||
Trackid: "",
|
||||
BeginDate: "2024-07-01 00:00:00",
|
||||
EndDate: "2024-07-01 23:59:59",
|
||||
|
||||
@ -3,12 +3,13 @@ package elong_hotel
|
||||
import (
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/client"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/client"
|
||||
)
|
||||
|
||||
// AuthConfig api鉴权参数
|
||||
type AuthConfig struct {
|
||||
Token string // 分配的token
|
||||
AppId string // 应用id (getExternalChannelConfig接口返回的appId)
|
||||
}
|
||||
|
||||
// 连接第三方平台的client
|
||||
|
||||
@ -1,9 +1,5 @@
|
||||
package elong_hotel
|
||||
|
||||
import (
|
||||
"google.golang.org/genproto/googleapis/type/decimal"
|
||||
)
|
||||
|
||||
type CommonResponse struct {
|
||||
Code int32 `json:"code"` // 状态码,200为正常
|
||||
Msg string `json:"msg"` // 返回信息
|
||||
@ -44,14 +40,32 @@ type OtherActivityUrl struct {
|
||||
ActivityUrl string `json:"activityUrl"` // 渠道方合作页地址
|
||||
}
|
||||
|
||||
// GenerateUrlReq 生成链接的请求
|
||||
type GenerateUrlRequest struct {
|
||||
// GenerateWechatUrlRequest 生成微信小程序链接的请求
|
||||
type GenerateWechatUrlRequest struct {
|
||||
ActivityUrl string `json:"activityUrl"` // 活动url
|
||||
Uid string `json:"uid"` // 用户id
|
||||
}
|
||||
|
||||
// GenerateH5UrlRequest 生成H5链接请求
|
||||
type GenerateH5UrlRequest struct {
|
||||
ActivityUrl string `json:"activityUrl"` // 活动url
|
||||
LinkCode string `json:"linkCode"` // 链接code
|
||||
ActId string `json:"actId"` // 活动id
|
||||
}
|
||||
|
||||
// 获取外部订单请求
|
||||
type QueryOrderListRequest struct {
|
||||
Trackid string `json:"trackid"` // 必传,跟踪id,排查问题使用,guid即可
|
||||
BeginDate string `json:"begin_date"` // 订单更新时间查询起始,精确到秒, yyyy-MM-dd HH:mm:ss(除了传订单号外,其他查询必传)
|
||||
EndDate string `json:"end_date"` // 订单更新时间查询结束,精确到秒, yyyy-MM-dd HH:mm:ss(除了传订单号外,其他查询必传)
|
||||
OrderId string `json:"order_id"` // 指定订单号查询,返回该订单的最新详情
|
||||
Update int32 `json:"update"` // 0:仅已支付的订单, 1:所有状态订单, 默认查所有传1
|
||||
PageIndex int32 `json:"page_index"` // 分页index,从0开始(除了传订单号外,其他查询必传)
|
||||
PageSize int32 `json:"page_size"` // 分页条数(除了传订单号外,其他查询必传)
|
||||
}
|
||||
|
||||
// 获取外部订单请求
|
||||
type QueryOrderListReq struct {
|
||||
AppId string `json:"appId"` // 必传,分配token查询接口提供的appId(getExternalChannelConfig接口返回的appId)
|
||||
Trackid string `json:"trackid"` // 必传,跟踪id,排查问题使用,guid即可
|
||||
BeginDate string `json:"begin_date"` // 订单更新时间查询起始,精确到秒, yyyy-MM-dd HH:mm:ss(除了传订单号外,其他查询必传)
|
||||
@ -74,21 +88,21 @@ type ExternalOrderData struct {
|
||||
|
||||
// 订单详情
|
||||
type ExternalOrder struct {
|
||||
ExtendInfo string `json:"extendInfo"` // 订单附加信息json格式
|
||||
HotelCityName string `json:"hotelCityName"` // 酒店所在城市名称
|
||||
HotelName string `json:"hotelName"` // 酒店名称
|
||||
OrderCheckIn string `json:"orderCheckIn"` // 入住日期
|
||||
OrderCheckOut string `json:"orderCheckOut"` // 离店时间
|
||||
OrderCreateTime string `json:"orderCreateTime"` // 订单创建时间date-time
|
||||
OrderModifyTime string `json:"orderModifyTime"` // 订单更新时间date-time
|
||||
OrderNo string `json:"orderNo"` // 订单号
|
||||
OrderPayAmount decimal.Decimal `json:"orderPayAmount"` // 订单实付金额
|
||||
OrderPayTime string `json:"orderPayTime"` // 订单支付时间 date-time
|
||||
OrderStatus int32 `json:"orderStatus"` // 订单组推送的订单状态(1: 已支付 2:已离店 3:已取消)
|
||||
OrderCommission decimal.Decimal `json:"orderCommission"` // 订单佣金
|
||||
Uid string `json:"uid"` // 第三方用户id
|
||||
HotelProvinceName string `json:"hotelProvinceName"` // 酒店所在省份
|
||||
RoomNights int32 `json:"roomNights"` // 入住间夜
|
||||
RoomCount int32 `json:"roomCount"` // 入住房间数量
|
||||
HourRoom int32 `json:"hourRoom"` // 是否钟点房1:是 0:不是 -1:旧数据
|
||||
ExtendInfo string `json:"extendInfo"` // 订单附加信息json格式
|
||||
HotelCityName string `json:"hotelCityName"` // 酒店所在城市名称
|
||||
HotelName string `json:"hotelName"` // 酒店名称
|
||||
OrderCheckIn string `json:"orderCheckIn"` // 入住日期
|
||||
OrderCheckOut string `json:"orderCheckOut"` // 离店时间
|
||||
OrderCreateTime string `json:"orderCreateTime"` // 订单创建时间date-time
|
||||
OrderModifyTime string `json:"orderModifyTime"` // 订单更新时间date-time
|
||||
OrderNo string `json:"orderNo"` // 订单号
|
||||
OrderPayAmount float64 `json:"orderPayAmount"` // 订单实付金额
|
||||
OrderPayTime string `json:"orderPayTime"` // 订单支付时间 date-time
|
||||
OrderStatus int32 `json:"orderStatus"` // 订单组推送的订单状态(1: 已支付 2:已离店 3:已取消)
|
||||
OrderCommission float64 `json:"orderCommission"` // 订单佣金
|
||||
Uid string `json:"uid"` // 第三方用户id
|
||||
HotelProvinceName string `json:"hotelProvinceName"` // 酒店所在省份
|
||||
RoomNights int32 `json:"roomNights"` // 入住间夜
|
||||
RoomCount int32 `json:"roomCount"` // 入住房间数量
|
||||
HourRoom int32 `json:"hourRoom"` // 是否钟点房1:是 0:不是 -1:旧数据
|
||||
}
|
||||
|
||||
100
platform/fliggy/api.go
Normal file
100
platform/fliggy/api.go
Normal file
@ -0,0 +1,100 @@
|
||||
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"
|
||||
)
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
type fliggyApiImpl struct {
|
||||
log logx.Logger
|
||||
client *Client
|
||||
}
|
||||
|
||||
func newFliggyApiImpl(log logx.Logger, client *Client) FliggyApi {
|
||||
return &fliggyApiImpl{
|
||||
log: log,
|
||||
client: client,
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
if err != nil {
|
||||
a.log.WithFields(logx.LogField{Key: "data", Value: map[string]any{"req": req, "resp": resp}}).Errorf("[fliggyApiImpl][FliggyPromoteOrdersList] get promote orders failed, error: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
if resp == nil {
|
||||
return nil, fmt.Errorf("[fliggyApiImpl][FliggyPromoteOrdersList] get promote order list is empty")
|
||||
}
|
||||
var result []*domain.AlibabaFliggyPromoteOrdersListOrder
|
||||
if resp.Model.List != nil {
|
||||
for _, item := range *resp.Model.List {
|
||||
entity := item
|
||||
result = append(result, &entity)
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
53
platform/fliggy/api_test.go
Normal file
53
platform/fliggy/api_test.go
Normal file
@ -0,0 +1,53 @@
|
||||
package fliggy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/fliggysdk/util"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/fliggysdk/defaultability/request"
|
||||
)
|
||||
|
||||
// api-单元测试
|
||||
type apiClientSuite struct {
|
||||
suite.Suite
|
||||
api FliggyApi
|
||||
}
|
||||
|
||||
func TestApiClient(t *testing.T) {
|
||||
suite.Run(t, new(apiClientSuite))
|
||||
}
|
||||
|
||||
func (a *apiClientSuite) SetupSuite() {
|
||||
log := logx.WithContext(context.Background())
|
||||
apiClient := NewApiClient(log, AuthConfig{
|
||||
AppKey: "34755002",
|
||||
AppSecret: "",
|
||||
})
|
||||
a.api = apiClient
|
||||
}
|
||||
|
||||
func (a *apiClientSuite) Test_FliggyPromoteOrdersList() {
|
||||
page := int64(0)
|
||||
start, _ := time.ParseInLocation(time.DateTime, "2024-11-05 16:10:00", time.Local)
|
||||
end, _ := time.ParseInLocation(time.DateTime, "2024-11-05 16:20:00", time.Local)
|
||||
sTime := util.LocalTime(start)
|
||||
eTime := util.LocalTime(end)
|
||||
|
||||
req := &request.AlibabaFliggyPromoteOrdersListRequest{
|
||||
PageNo: &page,
|
||||
BeforeModifyTime: &eTime,
|
||||
AfterModifyTime: &sTime,
|
||||
}
|
||||
resp, err := a.api.FliggyPromoteOrdersList(req)
|
||||
if err != nil {
|
||||
a.T().Errorf("=====[Test_FliggyPromoteOrdersList] err: %v", err)
|
||||
return
|
||||
}
|
||||
ret, _ := json.Marshal(resp)
|
||||
a.T().Logf("=====[Test_FliggyPromoteOrdersList] resp: %+v", string(ret))
|
||||
}
|
||||
36
platform/fliggy/client.go
Normal file
36
platform/fliggy/client.go
Normal file
@ -0,0 +1,36 @@
|
||||
package fliggy
|
||||
|
||||
import (
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/fliggysdk"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/fliggysdk/defaultability"
|
||||
)
|
||||
|
||||
// AuthConfig api鉴权参数
|
||||
type AuthConfig struct {
|
||||
AppKey string // 应用key
|
||||
AppSecret string // 应用秘钥
|
||||
}
|
||||
|
||||
// 连接第三方平台的client
|
||||
type Client struct {
|
||||
topClient *fliggysdk.TopClient
|
||||
abilityClient *defaultability.Defaultability
|
||||
log logx.Logger
|
||||
authConfig AuthConfig
|
||||
}
|
||||
|
||||
func NewApiClient(log logx.Logger, conf AuthConfig) FliggyApi {
|
||||
clt := newClient(log, conf)
|
||||
return newFliggyApiImpl(log, clt)
|
||||
}
|
||||
|
||||
func newClient(log logx.Logger, conf AuthConfig) *Client {
|
||||
tc := fliggysdk.NewDefaultTopClient(conf.AppKey, conf.AppSecret, "https://eco.taobao.com/router/rest", 20000, 20000)
|
||||
return &Client{
|
||||
topClient: &tc,
|
||||
abilityClient: defaultability.NewDefaultability(&tc),
|
||||
log: log,
|
||||
authConfig: conf,
|
||||
}
|
||||
}
|
||||
8
platform/fliggy/consts.go
Normal file
8
platform/fliggy/consts.go
Normal file
@ -0,0 +1,8 @@
|
||||
package fliggy
|
||||
|
||||
// 相关地址
|
||||
const (
|
||||
SiteDomain = "https://sht-front.fliggy.com/" // SiteDomain 域名
|
||||
SiteUrl = "https://sht-front.fliggy.com/" // SiteUrl 后台地址
|
||||
ApiDocUrl = "https://open.taobao.com/api.htm?docId=63469&docType=2&scopeId=27205" // ApiDocUrl api文档地址
|
||||
)
|
||||
26
platform/fliggy/types.go
Normal file
26
platform/fliggy/types.go
Normal file
@ -0,0 +1,26 @@
|
||||
package fliggy
|
||||
|
||||
type PublicParam struct {
|
||||
Method string // 必传 API接口名称,具体参见各平台API接口文档,例:taobao.item.seller.get
|
||||
AppKey string // 必传 TOP分配给应用的AppKey。例:12345678
|
||||
Session string // 可选 用户授权成功后,平台颁发给应用的授权session,详细介绍请点击这里。当此API文档的标签上注明:“需要授权”,则此参数必传;“不需要授权”,则此参数不需要传。
|
||||
Timestamp string // 必传 时间戳,格式为yyyy-MM-dd HH:mm:ss,时区为GMT+8,例如:2016-01-01 12:00:00。淘宝API服务端允许客户端请求最大时间误差为10分钟。
|
||||
V string // 必传 API协议版本,可选值:2.0
|
||||
SignMethod string // 必传 签名的摘要算法,可选值为:hmac,md5,hmac-sha256。
|
||||
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
|
||||
}
|
||||
168
platform/jd-union/api.go
Normal file
168
platform/jd-union/api.go
Normal file
@ -0,0 +1,168 @@
|
||||
package jd_union
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/spf13/cast"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/client"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/util"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// JdUnionApi 京东联盟平台
|
||||
type JdUnionApi interface {
|
||||
// Sign 签名
|
||||
Sign(data map[string]interface{}) string
|
||||
// QueryOrderList 查询订单列表
|
||||
QueryOrderList(req QueryOrderListRequest) (*QueryOrderListResponse, error)
|
||||
// PromotionLink 转链
|
||||
PromotionLink(PromotionLinkRequest) (*PromotionLinkResponse, error)
|
||||
}
|
||||
|
||||
type jdUnionApiImpl struct {
|
||||
log logx.Logger
|
||||
client *Client
|
||||
params map[string]any
|
||||
}
|
||||
|
||||
func newJdUnionApiImpl(log logx.Logger, client *Client) JdUnionApi {
|
||||
return &jdUnionApiImpl{
|
||||
log: log,
|
||||
client: client,
|
||||
params: map[string]any{
|
||||
"method": "",
|
||||
"access_token": "",
|
||||
"app_key": client.authConfig.AppKey,
|
||||
"sign_method": SignMethod,
|
||||
"timestamp": time.Now().Format(time.DateTime),
|
||||
"360buy_param_json": "",
|
||||
"v": Version,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (t *jdUnionApiImpl) Sign(data map[string]any) string {
|
||||
// key排序
|
||||
arr := sort.StringSlice{}
|
||||
for k := range data {
|
||||
if k == "sign" {
|
||||
continue
|
||||
}
|
||||
arr = append(arr, k)
|
||||
}
|
||||
arr.Sort()
|
||||
// 参数拼接
|
||||
var build strings.Builder
|
||||
build.WriteString(t.client.authConfig.AppSecret)
|
||||
for _, k := range arr {
|
||||
build.WriteString(fmt.Sprintf("%s%v", k, data[k]))
|
||||
}
|
||||
build.WriteString(t.client.authConfig.AppSecret)
|
||||
return strings.ToUpper(util.Md5String(build.String()))
|
||||
}
|
||||
|
||||
func (t *jdUnionApiImpl) QueryOrderList(req QueryOrderListRequest) (*QueryOrderListResponse, error) {
|
||||
params := make(map[string]any)
|
||||
if req.OrderId != "" {
|
||||
params["orderId"] = req.OrderId
|
||||
} else {
|
||||
params["pageIndex"] = req.PageIndex
|
||||
params["pageSize"] = req.PageSize
|
||||
params["type"] = req.Type
|
||||
params["startTime"] = req.StartTime
|
||||
params["endTime"] = req.EndTime
|
||||
}
|
||||
requestPrams := map[string]any{
|
||||
"orderReq": params,
|
||||
}
|
||||
paramsJson, _ := json.Marshal(requestPrams)
|
||||
|
||||
SystemParams := t.params
|
||||
SystemParams["method"] = QueryOrderListMethod
|
||||
SystemParams["360buy_param_json"] = string(paramsJson)
|
||||
SystemParams["sign"] = t.Sign(SystemParams)
|
||||
|
||||
//values := url.Values{}
|
||||
//for key, value := range SystemParams {
|
||||
// values.Set(key, cast.ToString(value))
|
||||
//}
|
||||
//fmt.Println(fmt.Sprintf("%s?%s", BaseUrl, values.Encode()))
|
||||
|
||||
requestUrl := BaseUrl
|
||||
request := &client.HttpRequest{Headers: t.client.headers, QueryArgs: SystemParams}
|
||||
response := new(JdUnionOpenOrderRowQueryResponse)
|
||||
if err := t.client.HttpPost(requestUrl, request, &client.HttpResponse{Result: response}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if response == nil {
|
||||
return nil, nil
|
||||
}
|
||||
if response.ErrorResponse != nil {
|
||||
return nil, fmt.Errorf("京东联盟请求订单接口响应错误,Code[%s],请求ID[%s],错误信息:%s", response.ErrorResponse.Code, response.ErrorResponse.RequestId, response.ErrorResponse.ZhDesc)
|
||||
}
|
||||
if response.JdUnionOpenOrderRowQueryResponse == nil {
|
||||
return nil, nil
|
||||
}
|
||||
if cast.ToInt64(response.JdUnionOpenOrderRowQueryResponse.Code) != 0 {
|
||||
return nil, nil
|
||||
}
|
||||
resp := new(QueryOrderListResponse)
|
||||
err := json.Unmarshal([]byte(response.JdUnionOpenOrderRowQueryResponse.QueryResult), resp)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("京东联盟请求订单接口解析QueryResult失败,错误信息:%s", err.Error())
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// 转链
|
||||
func (t *jdUnionApiImpl) PromotionLink(req PromotionLinkRequest) (*PromotionLinkResponse, error) {
|
||||
params := map[string]any{
|
||||
"materialId": req.MaterialId,
|
||||
"positionId": req.PositionId,
|
||||
"siteId": req.SiteId,
|
||||
}
|
||||
requestPrams := map[string]any{
|
||||
"promotionCodeReq": params,
|
||||
}
|
||||
paramsJson, _ := json.Marshal(requestPrams)
|
||||
|
||||
SystemParams := t.params
|
||||
SystemParams["method"] = PromotionLinkMethod
|
||||
SystemParams["360buy_param_json"] = string(paramsJson)
|
||||
SystemParams["sign"] = t.Sign(SystemParams)
|
||||
|
||||
//values := url.Values{}
|
||||
//for key, value := range SystemParams {
|
||||
// values.Set(key, cast.ToString(value))
|
||||
//}
|
||||
//fmt.Println(fmt.Sprintf("%s?%s", BaseUrl, values.Encode()))
|
||||
|
||||
requestUrl := BaseUrl
|
||||
request := &client.HttpRequest{Headers: t.client.headers, QueryArgs: SystemParams}
|
||||
response := new(JdUnionOpenPromotionCommonGetResponse)
|
||||
if err := t.client.HttpPost(requestUrl, request, &client.HttpResponse{Result: response}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if response == nil {
|
||||
return nil, nil
|
||||
}
|
||||
if response.ErrorResponse != nil {
|
||||
return nil, fmt.Errorf("京东联盟请求转链接口响应错误,Code[%s],请求ID[%s],错误信息:%s", response.ErrorResponse.Code, response.ErrorResponse.RequestId, response.ErrorResponse.ZhDesc)
|
||||
}
|
||||
if response.JdUnionOpenPromotionCommonGetResponse == nil {
|
||||
return nil, nil
|
||||
}
|
||||
if cast.ToInt64(response.JdUnionOpenPromotionCommonGetResponse.Code) != 0 {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
resp := new(PromotionLinkResponse)
|
||||
err := json.Unmarshal([]byte(response.JdUnionOpenPromotionCommonGetResponse.GetResult), resp)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("京东联盟请求转链接口解析GetResult失败,错误信息:%s", err.Error())
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
70
platform/jd-union/api_test.go
Normal file
70
platform/jd-union/api_test.go
Normal file
@ -0,0 +1,70 @@
|
||||
package jd_union
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
// api-单元测试
|
||||
type apiClientSuite struct {
|
||||
suite.Suite
|
||||
api JdUnionApi
|
||||
}
|
||||
|
||||
func TestApiClient(t *testing.T) {
|
||||
suite.Run(t, new(apiClientSuite))
|
||||
}
|
||||
|
||||
func (a *apiClientSuite) SetupSuite() {
|
||||
log := logx.WithContext(context.Background())
|
||||
apiClient := NewApiClient(log, AuthConfig{
|
||||
AppKey: "",
|
||||
AppSecret: "",
|
||||
})
|
||||
a.api = apiClient
|
||||
}
|
||||
|
||||
func (a *apiClientSuite) Test_QueryOrderList() {
|
||||
data := QueryOrderListRequest{
|
||||
PageIndex: 1,
|
||||
PageSize: 20,
|
||||
Type: 1, //订单时间查询类型(1:下单时间,2:完成时间(购买用户确认收货时间),3:更新时间
|
||||
StartTime: "2025-05-14 17:00:00",
|
||||
EndTime: "2025-05-14 18:00:00",
|
||||
}
|
||||
resp, err := a.api.QueryOrderList(data)
|
||||
if err != nil {
|
||||
a.T().Errorf("=====[Test_QueryOrderList] err: %v", err)
|
||||
}
|
||||
if resp != nil {
|
||||
a.T().Logf("=====[Test_QueryOrderList] resp: %+v, err: %v", resp, err)
|
||||
if len(resp.Data) > 0 {
|
||||
for _, v := range resp.Data {
|
||||
va, _ := json.Marshal(v)
|
||||
fmt.Println(string(va))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (a *apiClientSuite) Test_PromotionLink() {
|
||||
data := PromotionLinkRequest{
|
||||
MaterialId: "https://u.jd.com/rDPUXnL",
|
||||
SiteId: "",
|
||||
PositionId: 100030093812,
|
||||
}
|
||||
resp, err := a.api.PromotionLink(data)
|
||||
if err != nil {
|
||||
a.T().Errorf("=====[Test_PromotionLink] err: %v", err)
|
||||
}
|
||||
a.T().Logf("=====[Test_PromotionLink] resp: %+v, err: %v", resp, err)
|
||||
if resp != nil {
|
||||
va, _ := json.Marshal(resp.Data)
|
||||
fmt.Println(string(va))
|
||||
}
|
||||
}
|
||||
37
platform/jd-union/client.go
Normal file
37
platform/jd-union/client.go
Normal file
@ -0,0 +1,37 @@
|
||||
package jd_union
|
||||
|
||||
import (
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/client"
|
||||
)
|
||||
|
||||
// AuthConfig api鉴权参数
|
||||
type AuthConfig struct {
|
||||
AppKey string
|
||||
AppSecret string
|
||||
}
|
||||
|
||||
// 连接第三方平台的client
|
||||
type Client struct {
|
||||
log logx.Logger
|
||||
authConfig AuthConfig
|
||||
client.HttpClient
|
||||
headers map[string]string
|
||||
}
|
||||
|
||||
func NewApiClient(log logx.Logger, conf AuthConfig) JdUnionApi {
|
||||
clt := newClient(log, conf)
|
||||
return newJdUnionApiImpl(log, clt)
|
||||
}
|
||||
|
||||
func newClient(log logx.Logger, conf AuthConfig) *Client {
|
||||
return &Client{
|
||||
log: log,
|
||||
authConfig: conf,
|
||||
HttpClient: client.NewHttpClient(log),
|
||||
headers: map[string]string{
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
}
|
||||
}
|
||||
12
platform/jd-union/consts.go
Normal file
12
platform/jd-union/consts.go
Normal file
@ -0,0 +1,12 @@
|
||||
package jd_union
|
||||
|
||||
const (
|
||||
Version = "1.0"
|
||||
Format = "json"
|
||||
JsonParamKey = "360buy_param_json"
|
||||
SignMethod = "md5"
|
||||
|
||||
BaseUrl = "https://api.jd.com/routerjson"
|
||||
QueryOrderListMethod = "jd.union.open.order.row.query"
|
||||
PromotionLinkMethod = "jd.union.open.promotion.common.get"
|
||||
)
|
||||
121
platform/jd-union/types.go
Normal file
121
platform/jd-union/types.go
Normal file
@ -0,0 +1,121 @@
|
||||
package jd_union
|
||||
|
||||
type QueryOrderListRequest struct {
|
||||
OrderId string `json:"orderId"` //订单号,当orderId不为空时,其他参数非必填
|
||||
PageIndex int64 `json:"pageIndex"` //页码
|
||||
PageSize int64 `json:"pageSize"` //每页包含条数,上限为200
|
||||
Type int64 `json:"type"` //订单时间查询类型(1:下单时间,2:完成时间(购买用户确认收货时间),3:更新时间
|
||||
StartTime string `json:"startTime"` //开始时间 格式yyyy-MM-dd HH:mm:ss,与endTime间隔不超过1小时
|
||||
EndTime string `json:"endTime"` //结束时间 格式yyyy-MM-dd HH:mm:ss,与startTime间隔不超过1小时
|
||||
}
|
||||
type QueryOrderListResponse struct {
|
||||
Code int64 `json:"code"`
|
||||
Data []*QueryOrderListItem `json:"data"`
|
||||
HasMore bool `json:"hasMore"`
|
||||
Message string `json:"message"`
|
||||
RequestId string `json:"requestId"`
|
||||
}
|
||||
type QueryOrderListItem struct {
|
||||
Id string `json:"id"` //标记唯一订单行:订单+sku维度的唯一标识
|
||||
OrderId int64 `json:"orderId"` //订单号
|
||||
ParentId int64 `json:"parentId"` //主单的订单号:如一个订单拆成多个子订单时,原订单号会作为主单号,拆分的订单号为子单号存储在orderid中。若未发生拆单,该字段为0
|
||||
OrderTime string `json:"orderTime"` //下单时间,格式yyyy-MM-dd HH:mm:ss
|
||||
FinishTime string `json:"finishTime"` //完成时间(购买用户确认收货时间),格式yyyy-MM-dd HH:mm:ss
|
||||
ModifyTime string `json:"modifyTime"` //更新时间,格式yyyy-MM-dd HH:mm:ss
|
||||
OrderEmt int64 `json:"orderEmt"` //下单设备 1.pc 2.无线
|
||||
Plus int64 `json:"plus"` //下单用户是否为PLUS会员 0:否,1:是
|
||||
UnionId int64 `json:"unionId"` //推客ID
|
||||
SkuId int64 `json:"skuId"` //商品ID
|
||||
SkuName string `json:"skuName"` //商品名称
|
||||
SkuNum int64 `json:"skuNum"` //商品数量
|
||||
SkuReturnNum int64 `json:"skuReturnNum"` //商品已退货数量
|
||||
SkuFrozenNum int64 `json:"skuFrozenNum"` //商品售后中数量
|
||||
Price float64 `json:"price"` //商品单价
|
||||
CommissionRate float64 `json:"commissionRate"` //佣金比例(投放的广告主计划比例)
|
||||
SubSideRate float64 `json:"subSideRate"` //分成比例(单位:%)
|
||||
SubsidyRate float64 `json:"subsidyRate"` //补贴比例(单位:%)
|
||||
FinalRate float64 `json:"finalRate"` //最终分佣比例(单位:%)=分成比例+补贴比例
|
||||
EstimateCosPrice float64 `json:"estimateCosPrice"` //预估计佣金额
|
||||
EstimateFee float64 `json:"estimateFee"` //推客的预估佣金
|
||||
ActualCosPrice float64 `json:"actualCosPrice"` //实际计算佣金的金额
|
||||
ActualFee float64 `json:"actualFee"` //推客分得的实际佣金
|
||||
ValidCode int64 `json:"validCode"` //sku维度的有效码/状态((-1:未知,2.无效-拆单,3.无效-取消,4.无效-京东帮帮主订单,5.无效-账号异常,6.无效-赠品类目不返佣,7.无效-校园订单,8.无效-企业订单,9.无效-团购订单,11.无效-乡村推广员下单,13. 违规订单-其他,14.无效-来源与备案网址不符,15.待付款,16.已付款,17.已完成(购买用户确认收货),19.无效-佣金比例为0,20.无效-此复购订单对应的首购订单无效,21.无效-云店订单,22.无效-PLUS会员佣金比例为0,23.无效-支付有礼,24.已付定金,25. 违规订单-流量劫持,26. 违规订单-流量异常,27. 违规订单-违反京东平台规则,28. 违规订单-多笔交易异常,29.无效-跨屏跨店,30.无效-累计件数超出类目上限,31.无效-黑名单sku,33.超市卡充值订单,34.无效-推卡订单无效)
|
||||
PositionId int64 `json:"positionId"` //推广位ID
|
||||
SiteId int64 `json:"siteId"` //应用id(网站id、appid、社交媒体id、流量媒体id)
|
||||
Pid string `json:"pid"` //格式:子推客ID_子站长应用ID_子推客推广位ID
|
||||
SubUnionId string `json:"subUnionId"` //子渠道标识,在转链时可自定义传入,格式要求:字母、数字或下划线,最多支持80个字符(需要联系运营开放白名单才能拿到数据)
|
||||
PayMonth int64 `json:"payMonth"` //预估结算时间,订单完成后才会返回,格式:yyyyMMdd,默认:0
|
||||
//BalanceExt string `json:"balanceExt"` //下面的数据暂时用不到
|
||||
//CategoryInfo struct {
|
||||
// Cid1 int64 `json:"cid1"`
|
||||
// Cid2 int64 `json:"cid2"`
|
||||
// Cid3 int64 `json:"cid3"`
|
||||
//} `json:"categoryInfo"`
|
||||
//ChannelId int64 `json:"channelId"`
|
||||
//Cid1 int64 `json:"cid1"`
|
||||
//Cid2 int64 `json:"cid2"`
|
||||
//Cid3 int64 `json:"cid3"`
|
||||
//CpActId int64 `json:"cpActId"`
|
||||
//ExpressStatus int64 `json:"expressStatus"`
|
||||
//Ext1 string `json:"ext1"`
|
||||
//GiftCouponKey string `json:"giftCouponKey"`
|
||||
//GiftCouponOcsAmount int64 `json:"giftCouponOcsAmount"`
|
||||
//GoodsInfo struct {
|
||||
// MainSkuId int64 `json:"mainSkuId"`
|
||||
// ProductId int64 `json:"productId"`
|
||||
// ShopId int64 `json:"shopId"`
|
||||
//} `json:"goodsInfo"`
|
||||
//ItemId string `json:"itemId"`
|
||||
//OrderTag string `json:"orderTag"`
|
||||
//PopId int64 `json:"popId"`
|
||||
//ProPriceAmount int64 `json:"proPriceAmount"`
|
||||
//Rid int64 `json:"rid"`
|
||||
//SkuTag string `json:"skuTag"`
|
||||
//TraceType int64 `json:"traceType"`
|
||||
//UnionAlias string `json:"unionAlias"`
|
||||
//UnionRole int64 `json:"unionRole"`
|
||||
//UnionTag string `json:"unionTag"`
|
||||
}
|
||||
type JdUnionOpenOrderRowQueryResponse struct {
|
||||
JdUnionOpenOrderRowQueryResponse *JdUnionOpenOrderRowQuery `json:"jd_union_open_order_row_query_responce"`
|
||||
ErrorResponse *ErrorResponse `json:"error_response"`
|
||||
}
|
||||
type JdUnionOpenOrderRowQuery struct {
|
||||
Code string `json:"code"`
|
||||
QueryResult string `json:"queryResult"`
|
||||
}
|
||||
type ErrorResponse struct {
|
||||
Code string `json:"code"`
|
||||
ZhDesc string `json:"zh_desc"`
|
||||
EnDesc string `json:"en_desc"`
|
||||
RequestId string `json:"request_id"`
|
||||
}
|
||||
|
||||
// 转链
|
||||
type PromotionLinkRequest struct {
|
||||
MaterialId string `json:"materialId"` //推广物料url,例如活动链接、商品链接等;支持仅传入skuid
|
||||
SiteId string `json:"siteId"` //网站ID/媒体ID
|
||||
PositionId int64 `json:"positionId"` //自定义推广位id,自定义的数字,自己在本地跟用户做好关联,订单中会透出自定义的数字
|
||||
SubUnionId string `json:"subUnionId"` //子渠道标识 暂时没用 需要申请权限
|
||||
ChainType int64 `json:"chainType"` // 转链类型,1:长链, 2 :短链 ,3: 长链+短链,默认短链,短链有效期60天
|
||||
}
|
||||
|
||||
type PromotionLinkResponse struct {
|
||||
Code int64 `json:"code"` //200为成功,其他失败
|
||||
Data *PromotionLink `json:"data"`
|
||||
Message string `json:"message"`
|
||||
RequestId string `json:"request_id"`
|
||||
}
|
||||
type PromotionLink struct {
|
||||
ShortURL string `json:"shortUrl"` //短链
|
||||
ClickURL string `json:"clickUrl"` //长链接
|
||||
JCommand string `json:"jCommand"` //口令
|
||||
}
|
||||
type JdUnionOpenPromotionCommonGetResponse struct {
|
||||
JdUnionOpenPromotionCommonGetResponse *JdUnionOpenPromotionCommonGet `json:"jd_union_open_promotion_common_get_responce"`
|
||||
ErrorResponse *ErrorResponse `json:"error_response"`
|
||||
}
|
||||
type JdUnionOpenPromotionCommonGet struct {
|
||||
Code string `json:"code"`
|
||||
GetResult string `json:"getResult"`
|
||||
}
|
||||
@ -3,13 +3,15 @@ package jutuike
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/spf13/cast"
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"github.com/zywaited/xcopy"
|
||||
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/client"
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/util"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/client"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/util"
|
||||
)
|
||||
|
||||
// JutuikeApi 美团-美天赚
|
||||
@ -48,12 +50,88 @@ func (a *jutuikeApiImpl) GenerateLink(ctx context.Context, req GenerateLinkReque
|
||||
return nil, err
|
||||
}
|
||||
if response.Code != 1 {
|
||||
a.log.WithFields(logx.LogField{Key: "data", Value: map[string]any{"req": req, "resp": response}}).
|
||||
Errorf("[jutuikeApiImpl][GenerateLink] response result error: %s", response.Msg)
|
||||
a.log.WithFields(logx.LogField{Key: "data", Value: map[string]any{"req": req, "resp": response}}).Errorf("[jutuikeApiImpl][GenerateLink] response result error: %s", response.Msg)
|
||||
return nil, errors.New(response.Msg)
|
||||
}
|
||||
result := response.Data.(GenerateLinkData)
|
||||
return &result, nil
|
||||
result := new(GenerateLinkData)
|
||||
data := cast.ToStringMap(response.Data)
|
||||
if actName, ok := data["act_name"]; ok {
|
||||
if actName != nil {
|
||||
result.ActName = cast.ToString(actName)
|
||||
}
|
||||
}
|
||||
if posterQrcodeUrl, ok := data["poster_qrcode_url"]; ok {
|
||||
if posterQrcodeUrl != nil {
|
||||
result.PosterQrcodeUrl = cast.ToString(posterQrcodeUrl)
|
||||
}
|
||||
}
|
||||
if taoBaoPoster, ok := data["taobao_poster_qrcode_url"]; ok {
|
||||
if result.PosterQrcodeUrl == "" {
|
||||
result.PosterQrcodeUrl = cast.ToString(taoBaoPoster)
|
||||
}
|
||||
}
|
||||
if tkl, ok := data["tkl"]; ok {
|
||||
result.Tkl = cast.ToString(tkl)
|
||||
}
|
||||
|
||||
if h5Url, ok := data["h5"]; ok {
|
||||
if h5Url != nil {
|
||||
result.H5 = cast.ToString(h5Url)
|
||||
}
|
||||
}
|
||||
if longH5, ok := data["long_h5"]; ok {
|
||||
if longH5 != nil {
|
||||
result.LongH5 = cast.ToString(longH5)
|
||||
}
|
||||
}
|
||||
if h5Evoke, ok := data["h5_evoke"]; ok {
|
||||
if h5Evoke != nil {
|
||||
result.H5Evoke = cast.ToString(h5Evoke)
|
||||
}
|
||||
}
|
||||
if deepLink, ok := data["deeplink"]; ok {
|
||||
if deepLink != nil {
|
||||
result.DeepLink = cast.ToString(deepLink)
|
||||
}
|
||||
|
||||
}
|
||||
if _, ok := data["we_app_info"]; ok {
|
||||
weApp := cast.ToStringMap(data["we_app_info"])
|
||||
weAppInfoTemp := new(WeAppInfo)
|
||||
if weAppAppId, tok := weApp["app_id"]; tok {
|
||||
if weAppAppId != nil {
|
||||
weAppInfoTemp.AppId = cast.ToString(weAppAppId)
|
||||
}
|
||||
}
|
||||
if weAppPagePath, tok := weApp["page_path"]; tok {
|
||||
if weAppPagePath != nil {
|
||||
weAppInfoTemp.PagePath = cast.ToString(weAppPagePath)
|
||||
}
|
||||
|
||||
}
|
||||
if weAppMiniCode, tok := weApp["miniCode"]; tok {
|
||||
if weAppMiniCode != nil {
|
||||
weAppInfoTemp.MiniCode = cast.ToString(weAppMiniCode)
|
||||
}
|
||||
}
|
||||
result.WeAppInfo = weAppInfoTemp
|
||||
}
|
||||
if _, ok := data["alipay_app_info"]; ok {
|
||||
alipayApp := cast.ToStringMap(data["alipay_app_info"])
|
||||
alipayAppInfoTemp := new(AlipayAppInfo)
|
||||
if alipayAppAppid, tok := alipayApp["app_id"]; tok {
|
||||
if alipayAppAppid != nil {
|
||||
alipayAppInfoTemp.AppId = cast.ToString(alipayAppAppid)
|
||||
}
|
||||
}
|
||||
if alipayAppPagePath, tok := alipayApp["page_path"]; tok {
|
||||
if alipayAppPagePath != nil {
|
||||
alipayAppInfoTemp.PagePath = cast.ToString(alipayAppPagePath)
|
||||
}
|
||||
}
|
||||
result.AlipayAppInfo = alipayAppInfoTemp
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// QueryOrderList 查询订单列表
|
||||
@ -76,12 +154,20 @@ func (a *jutuikeApiImpl) QueryOrderList(ctx context.Context, req QueryOrderListR
|
||||
if err := a.client.HttpPost(GetOrderListUrl, request, &client.HttpResponse{Result: response}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
responseData := new(QueryOrderListData)
|
||||
if response.Code != 1 {
|
||||
a.log.WithFields(logx.LogField{Key: "data", Value: map[string]any{"req": req, "resp": response}}).
|
||||
Errorf("[jutuikeApiImpl][QueryOrderList] response result error: %s", response.Msg)
|
||||
return nil, errors.New(response.Msg)
|
||||
dataType := reflect.TypeOf(response.Data).String()
|
||||
if dataType == "string" {
|
||||
a.log.WithFields(logx.LogField{Key: "data", Value: map[string]any{"req": req, "resp": response}}).Errorf("[jutuikeApiImpl][QueryOrderList] response result error: %s", response.Msg)
|
||||
return nil, errors.New(response.Msg)
|
||||
} else {
|
||||
responseData.PerPage = req.Page
|
||||
responseData.CurrentPage = req.Page
|
||||
responseData.LastPage = req.Page
|
||||
responseData.Data = make([]*OrderItem, 0)
|
||||
return responseData, nil
|
||||
}
|
||||
}
|
||||
var responseData *QueryOrderListData
|
||||
if err := xcopy.Copy(&responseData, response.Data); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -3,11 +3,9 @@ package jutuike
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// api-单元测试
|
||||
@ -23,15 +21,15 @@ func TestApiClient(t *testing.T) {
|
||||
func (a *apiClientSuite) SetupSuite() {
|
||||
log := logx.WithContext(context.Background())
|
||||
apiClient := NewApiClient(log, AuthConfig{
|
||||
ApiKey: "IyftVpzDVqDIRDqPZByW5xVpj9MgZSB7",
|
||||
ApiKey: "", //
|
||||
})
|
||||
a.api = apiClient
|
||||
}
|
||||
|
||||
func (a *apiClientSuite) Test_GenerateLink() {
|
||||
req := GenerateLinkRequest{
|
||||
ActId: 3,
|
||||
Sid: "f3a8c1",
|
||||
ActId: 60,
|
||||
Sid: "10001zdt100034",
|
||||
}
|
||||
result, err := a.api.GenerateLink(context.Background(), req)
|
||||
if !a.NoError(err) {
|
||||
@ -48,8 +46,8 @@ func (a *apiClientSuite) Test_GenerateLink() {
|
||||
|
||||
func (a *apiClientSuite) Test_QueryOrderList() {
|
||||
req := QueryOrderListRequest{
|
||||
StartTime: time.Unix(1718726400, 0).Format(time.DateTime),
|
||||
EndTime: time.Unix(1718812799, 0).Format(time.DateTime),
|
||||
StartTime: "2024-11-05 14:16:07",
|
||||
EndTime: "2024-11-05 14:26:07",
|
||||
PageSize: 1,
|
||||
}
|
||||
result, err := a.api.QueryOrderList(context.Background(), req)
|
||||
|
||||
@ -3,7 +3,7 @@ package jutuike
|
||||
import (
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/client"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/client"
|
||||
)
|
||||
|
||||
// AuthConfig api鉴权参数
|
||||
|
||||
@ -14,10 +14,20 @@ type GenerateLinkResponse struct {
|
||||
}
|
||||
|
||||
type GenerateLinkData struct {
|
||||
H5 string `json:"h5"` // 推广短链接(部分活动没有,请注意判断)
|
||||
WeAppInfo WeAppInfo `json:"we_app_info"` // 小程序信息(部分活动没有,请注意判断)
|
||||
ActName string `json:"act_name"` // 活动名称
|
||||
LongH5 string `json:"long_h5"` // 推广长链接(部分活动没有,请注意判断)
|
||||
ActName string `json:"act_name"` // 活动名称
|
||||
PosterQrcodeUrl string `json:"poster_qrcode_url"` //活动海报
|
||||
H5 string `json:"h5"` // 推广短链接(部分活动没有,请注意判断)
|
||||
LongH5 string `json:"long_h5"` // 推广长链接(部分活动没有,请注意判断)
|
||||
H5Evoke string `json:"h5_evoke"`
|
||||
DeepLink string `json:"deeplink"`
|
||||
Tkl string `json:"tkl"`
|
||||
WeAppInfo *WeAppInfo `json:"we_app_info"` // 微信小程序信息(部分活动没有,请注意判断)
|
||||
AlipayAppInfo *AlipayAppInfo `json:"alipay_app_info"` //支付宝小程序信息(部分活动没有,请注意判断)
|
||||
}
|
||||
|
||||
type AlipayAppInfo struct {
|
||||
AppId string `json:"app_id"` // 小程序ID
|
||||
PagePath string `json:"page_path"` // 小程序路径
|
||||
}
|
||||
|
||||
type WeAppInfo struct {
|
||||
|
||||
@ -8,8 +8,8 @@ import (
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"github.com/zeromicro/go-zero/core/trace"
|
||||
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/client"
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/util"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/client"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/util"
|
||||
)
|
||||
|
||||
// Api 调用第三方平台的api
|
||||
|
||||
@ -3,7 +3,7 @@ package meituan_csr
|
||||
import (
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/client"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/client"
|
||||
)
|
||||
|
||||
// AuthConfig api鉴权参数
|
||||
|
||||
@ -7,8 +7,8 @@ import (
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/client"
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/util"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/client"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/util"
|
||||
)
|
||||
|
||||
// MeituanMediaApi 美团-美天赚
|
||||
@ -36,7 +36,7 @@ func newMeituanMediaApiImpl(log logx.Logger, client *Client, sign *Sign) Meituan
|
||||
}
|
||||
}
|
||||
|
||||
// Sign todo:: 签名
|
||||
// Sign 签名
|
||||
func (a *meituanMediaApiImpl) Sign(methodType string, uri string, data map[string]interface{}) string {
|
||||
headers := a.sign.BuildHeader(methodType, uri, data)
|
||||
if sign, ok := headers[SCaSignature]; ok {
|
||||
|
||||
@ -23,7 +23,7 @@ func (a *apiClientSuite) SetupSuite() {
|
||||
log := logx.WithContext(context.Background())
|
||||
apiClient := NewApiClient(log, AuthConfig{
|
||||
AppKey: "edf37a6019e045aeaec646220e4bd369",
|
||||
AppSecret: "975a5782165041be891c098cd3afe4ce",
|
||||
AppSecret: "",
|
||||
})
|
||||
a.api = apiClient
|
||||
}
|
||||
@ -39,9 +39,10 @@ func (a *apiClientSuite) Test_Sign() {
|
||||
|
||||
func (a *apiClientSuite) Test_GenerateLink() {
|
||||
req := GenerateLinkRequest{
|
||||
LinkType: 1,
|
||||
ActId: "7",
|
||||
Sid: "f3a8c1",
|
||||
LinkType: 5,
|
||||
LinkTypeList: []int32{4, 5},
|
||||
ActId: "529",
|
||||
Sid: "f3a8c1",
|
||||
}
|
||||
result, err := a.api.GenerateLink(context.Background(), req)
|
||||
if !a.NoError(err) {
|
||||
|
||||
@ -3,7 +3,7 @@ package meituan_media
|
||||
import (
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/client"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/client"
|
||||
)
|
||||
|
||||
// AuthConfig api鉴权参数
|
||||
|
||||
@ -12,7 +12,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/util"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/util"
|
||||
)
|
||||
|
||||
type Sign struct {
|
||||
|
||||
@ -2,21 +2,23 @@ package meituan_media
|
||||
|
||||
// GenerateLinkRequest 生成推广链接请求
|
||||
type GenerateLinkRequest struct {
|
||||
LinkType int32 `json:"linkType"` // 必填 链接类型,枚举值:1 H5长链接;2 H5短链接;3 deeplink(唤起)链接;4 微信小程序唤起路径
|
||||
Platform int32 `json:"platform,omitempty"` // 非必填 商品所属业务一级分类类型;请求的商品推广链接所属的业务类型信息,即只有输入skuViewId时才需要传本字段:1 到家及其他业务类型,2 到店业务类型;不填则默认1
|
||||
BizLine int32 `json:"bizLine,omitempty"` // 非必填 商品所属业务二级分类类型;请求的商品推广链接所属的业务类型信息,即只有输入skuViewId时才需要传本字段;当字段platform为1,选择到家及其他业务类型时:5 医药,不填则默认null,表示外卖商品券;当字段platform为2,选择到店业务类型时:1 到餐,2 到综 3:酒店 4:门票 不填则默认1
|
||||
ActId string `json:"actId,omitempty"` // 非必填 活动物料ID,我要推广-活动推广中第一列的id信息(和商品id、活动链接三选一填写,不能全填)
|
||||
SkuViewId string `json:"skuViewId,omitempty"` // 非必填 商品id,对商品查询接口返回的skuViewid(和活动物料ID、活动链接三选一,不能全填)
|
||||
Sid string `json:"sid,omitempty"` // 非必填 二级媒体身份标识,用于渠道效果追踪,限制64个字符,仅支持英文、数字和下划线
|
||||
Text string `json:"text,omitempty"` // 非必填 只支持到家外卖商品券、买菜业务类型链接和活动物料链接。活动链接,即想要推广的目标链接,出参会返回成自己可推的链接,限定为当前可推广的活动链接或者商品券链接,请求内容尽量保持在200字以内,文本中仅存在一个http协议头的链接
|
||||
LinkType int32 `json:"linkType"` // 必填 链接类型,枚举值:1 H5长链接;2 H5短链接;3 deeplink(唤起)链接;4 微信小程序唤起路径
|
||||
LinkTypeList []int32 `json:"linkTypeList"` // 必填 链接类型,枚举值:1 H5长链接;2 H5短链接;3 deeplink(唤起)链接;4 微信小程序唤起路径
|
||||
Platform int32 `json:"platform,omitempty"` // 非必填 商品所属业务一级分类类型;请求的商品推广链接所属的业务类型信息,即只有输入skuViewId时才需要传本字段:1 到家及其他业务类型,2 到店业务类型;不填则默认1
|
||||
BizLine int32 `json:"bizLine,omitempty"` // 非必填 商品所属业务二级分类类型;请求的商品推广链接所属的业务类型信息,即只有输入skuViewId时才需要传本字段;当字段platform为1,选择到家及其他业务类型时:5 医药,不填则默认null,表示外卖商品券;当字段platform为2,选择到店业务类型时:1 到餐,2 到综 3:酒店 4:门票 不填则默认1
|
||||
ActId string `json:"actId,omitempty"` // 非必填 活动物料ID,我要推广-活动推广中第一列的id信息(和商品id、活动链接三选一填写,不能全填)
|
||||
SkuViewId string `json:"skuViewId,omitempty"` // 非必填 商品id,对商品查询接口返回的skuViewid(和活动物料ID、活动链接三选一,不能全填)
|
||||
Sid string `json:"sid,omitempty"` // 非必填 二级媒体身份标识,用于渠道效果追踪,限制64个字符,仅支持英文、数字和下划线
|
||||
Text string `json:"text,omitempty"` // 非必填 只支持到家外卖商品券、买菜业务类型链接和活动物料链接。活动链接,即想要推广的目标链接,出参会返回成自己可推的链接,限定为当前可推广的活动链接或者商品券链接,请求内容尽量保持在200字以内,文本中仅存在一个http协议头的链接
|
||||
}
|
||||
|
||||
// GenerateLinkResponse 生成推广链接响应
|
||||
type GenerateLinkResponse struct {
|
||||
Code int32 `json:"code"` // 响应码,0成功,其他失败
|
||||
Message string `json:"message"` // 响应文案
|
||||
Data string `json:"data"` // 返回对应的推广链接,这里的链接才能实现跟单计佣
|
||||
SkuViewId string `json:"skuViewId"` // 若用text进行入参取链,且返回的推广链接为商品券链接,则返回对应商品的展示ID,可以根据该ID查商品券接口获取对应的展示信息和佣金信息
|
||||
Code int32 `json:"code"` // 响应码,0成功,其他失败
|
||||
Message string `json:"message"` // 响应文案
|
||||
Data string `json:"data"` // 返回对应的推广链接,这里的链接才能实现跟单计佣
|
||||
SkuViewId string `json:"skuViewId"` // 若用text进行入参取链,且返回的推广链接为商品券链接,则返回对应商品的展示ID,可以根据该ID查商品券接口获取对应的展示信息和佣金信息
|
||||
ReferralLinkMap map[string]string `json:"referralLinkMap"` //多链接类型结果映射,对应入参linkTypeList中的各个有效链接类型(key:链接类型, value:推广链接)
|
||||
}
|
||||
|
||||
// QueryOrderListRequest 查询订单列表请求
|
||||
|
||||
@ -9,11 +9,11 @@ import (
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"github.com/zywaited/xcopy"
|
||||
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/client"
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/util"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/client"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/util"
|
||||
)
|
||||
|
||||
// MeituanUnionApi 美团联盟平台的api
|
||||
// MeituanUnionApi 美团千载 平台的api
|
||||
type MeituanUnionApi interface {
|
||||
// Sign 签名
|
||||
Sign(params map[string]interface{}) string
|
||||
|
||||
@ -21,9 +21,8 @@ func TestApiClient(t *testing.T) {
|
||||
func (a *apiClientSuite) SetupSuite() {
|
||||
log := logx.WithContext(context.Background())
|
||||
apiClient := NewApiClient(log, AuthConfig{
|
||||
//AppKey: "8b0a6d711cd573b5b048c90820dbb3fe756",
|
||||
SignKey: "3e4a697ecd9eafa27c2f3f4ccf22072d",
|
||||
NotifyKey: "gb8cwkj53x",
|
||||
SignKey: "",
|
||||
NotifyKey: "",
|
||||
})
|
||||
a.api = apiClient
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@ package meituan_union
|
||||
import (
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/client"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/client"
|
||||
)
|
||||
|
||||
// AuthConfig api鉴权参数
|
||||
|
||||
107
platform/meituan/api.go
Normal file
107
platform/meituan/api.go
Normal file
@ -0,0 +1,107 @@
|
||||
package meituan
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/client"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/util"
|
||||
)
|
||||
|
||||
// MeituanApi 美团联盟 平台的api
|
||||
type MeituanApi interface {
|
||||
// Sign 签名
|
||||
Sign(methodType string, url string, data map[string]interface{}) string
|
||||
// GenerateLink 获取推广链接
|
||||
GenerateLink(ctx context.Context, req GenerateLinkRequest) (*GenerateLinkResponse, error)
|
||||
// QueryOrderList 查询订单
|
||||
QueryOrderList(ctx context.Context, req QueryOrderListRequest) (*QueryOrderData, error)
|
||||
// QueryCouponList 查询商品
|
||||
QueryCouponList(ctx context.Context, req QueryCouponListRequest) (*QueryCouponListResponse, error)
|
||||
}
|
||||
|
||||
type meituanApiImpl struct {
|
||||
log logx.Logger
|
||||
client *Client
|
||||
sign *Sign
|
||||
}
|
||||
|
||||
func newMeituanApiImpl(log logx.Logger, client *Client, sign *Sign) MeituanApi {
|
||||
return &meituanApiImpl{
|
||||
log: log,
|
||||
client: client,
|
||||
sign: sign,
|
||||
}
|
||||
}
|
||||
|
||||
// Sign 签名
|
||||
func (a *meituanApiImpl) Sign(methodType string, uri string, data map[string]interface{}) string {
|
||||
headers := a.sign.BuildHeader(methodType, uri, data)
|
||||
if sign, ok := headers[SCaSignature]; ok {
|
||||
return sign
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// GetLink 获取推广链接
|
||||
func (a *meituanApiImpl) GenerateLink(ctx context.Context, req GenerateLinkRequest) (*GenerateLinkResponse, error) {
|
||||
args := util.StructToMap(req)
|
||||
headers := a.sign.BuildHeader(http.MethodPost, GetLinkUri, args)
|
||||
for k, v := range a.client.headers {
|
||||
headers[k] = v
|
||||
}
|
||||
request := &client.HttpRequest{Headers: headers, BodyArgs: args}
|
||||
response := new(GenerateLinkResponse)
|
||||
if err := a.client.HttpPost(GetLinkUrl, request, &client.HttpResponse{Result: response}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if response.Code != 0 {
|
||||
a.log.WithFields(logx.LogField{Key: "data", Value: map[string]any{"req": req, "args": args, "resp": response}}).
|
||||
Errorf("[meituanApiImpl][GenerateLink] response result error: %s", response.Message)
|
||||
return nil, errors.New(response.Message)
|
||||
}
|
||||
return response, nil
|
||||
}
|
||||
|
||||
// QueryOrderList 查询订单
|
||||
func (a *meituanApiImpl) QueryOrderList(ctx context.Context, req QueryOrderListRequest) (*QueryOrderData, error) {
|
||||
args := util.StructToMap(req)
|
||||
headers := a.sign.BuildHeader(http.MethodPost, GetOrderListUri, args)
|
||||
for k, v := range a.client.headers {
|
||||
headers[k] = v
|
||||
}
|
||||
request := &client.HttpRequest{Headers: headers, BodyArgs: args}
|
||||
response := new(QueryOrderListResponse)
|
||||
if err := a.client.HttpPost(GetOrderListUrl, request, &client.HttpResponse{Result: response}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if response.Code != 0 {
|
||||
a.log.WithFields(logx.LogField{Key: "data", Value: map[string]any{"req": req, "resp": response}}).
|
||||
Errorf("[meituanApiImpl][QueryOrderList] response result error: %s", response.Message)
|
||||
return nil, errors.New(response.Message)
|
||||
}
|
||||
return response.Data, nil
|
||||
}
|
||||
|
||||
// QueryCouponList 查询商品
|
||||
func (a *meituanApiImpl) QueryCouponList(ctx context.Context, req QueryCouponListRequest) (*QueryCouponListResponse, error) {
|
||||
args := util.StructToMap(req)
|
||||
headers := a.sign.BuildHeader(http.MethodPost, GetProductListUri, args)
|
||||
for k, v := range a.client.headers {
|
||||
headers[k] = v
|
||||
}
|
||||
request := &client.HttpRequest{Headers: headers, BodyArgs: args}
|
||||
response := new(QueryCouponListResponse)
|
||||
if err := a.client.HttpPost(GetProductListUrl, request, &client.HttpResponse{Result: response}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if response.Code != 0 {
|
||||
a.log.WithFields(logx.LogField{Key: "data", Value: map[string]any{"req": req, "resp": response}}).
|
||||
Errorf("[meituanApiImpl][QueryCouponList] response result error: %s", response.Message)
|
||||
return nil, errors.New(response.Message)
|
||||
}
|
||||
return response, nil
|
||||
}
|
||||
95
platform/meituan/api_test.go
Normal file
95
platform/meituan/api_test.go
Normal file
@ -0,0 +1,95 @@
|
||||
package meituan
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
// api-单元测试
|
||||
type apiClientSuite struct {
|
||||
suite.Suite
|
||||
api MeituanApi
|
||||
}
|
||||
|
||||
func TestApiClient(t *testing.T) {
|
||||
suite.Run(t, new(apiClientSuite))
|
||||
}
|
||||
|
||||
func (a *apiClientSuite) SetupSuite() {
|
||||
log := logx.WithContext(context.Background())
|
||||
apiClient := NewApiClient(log, AuthConfig{
|
||||
AppKey: "",
|
||||
AppSecret: "",
|
||||
})
|
||||
a.api = apiClient
|
||||
}
|
||||
|
||||
func (a *apiClientSuite) Test_Sign() {
|
||||
data := map[string]interface{}{
|
||||
"name": "zhangsan",
|
||||
"phone": "13800000001",
|
||||
}
|
||||
sign := a.api.Sign("POST", "/t3/union/test", data)
|
||||
a.T().Logf("=====[TestSign] sign: %s", sign)
|
||||
}
|
||||
|
||||
func (a *apiClientSuite) Test_GenerateLink() {
|
||||
req := GenerateLinkRequest{
|
||||
LinkType: 1,
|
||||
ActId: "7",
|
||||
Sid: "f3a8c1",
|
||||
}
|
||||
result, err := a.api.GenerateLink(context.Background(), req)
|
||||
if !a.NoError(err) {
|
||||
a.T().Errorf("========[Test_GenerateLink] response error:%s", err)
|
||||
return
|
||||
}
|
||||
resultByte, err := json.Marshal(result)
|
||||
if err != nil {
|
||||
a.T().Errorf("========[Test_GenerateLink] json_marshal error:%s", err)
|
||||
return
|
||||
}
|
||||
a.T().Logf("=====[Test_GenerateLink] result: %s", string(resultByte))
|
||||
}
|
||||
|
||||
func (a *apiClientSuite) Test_QueryOrderList() {
|
||||
req := QueryOrderListRequest{
|
||||
Page: 1,
|
||||
Limit: 2,
|
||||
}
|
||||
result, err := a.api.QueryOrderList(context.Background(), req)
|
||||
if !a.NoError(err) {
|
||||
a.T().Errorf("========[Test_QueryOrderList] response error:%s", err)
|
||||
return
|
||||
}
|
||||
resultByte, err := json.Marshal(result)
|
||||
if err != nil {
|
||||
a.T().Errorf("========[Test_QueryOrderList] json_marshal error:%s", err)
|
||||
return
|
||||
}
|
||||
a.T().Logf("=====[Test_QueryOrderList] result: %s", string(resultByte))
|
||||
}
|
||||
|
||||
func (a *apiClientSuite) Test_QueryCouponList() {
|
||||
req := QueryCouponListRequest{
|
||||
PageNo: 1,
|
||||
PageSize: 2,
|
||||
Platform: 1,
|
||||
SearchText: "券",
|
||||
}
|
||||
result, err := a.api.QueryCouponList(context.Background(), req)
|
||||
if !a.NoError(err) {
|
||||
a.T().Errorf("========[Test_QueryCouponList] response error:%s", err)
|
||||
return
|
||||
}
|
||||
resultByte, err := json.Marshal(result)
|
||||
if err != nil {
|
||||
a.T().Errorf("========[Test_QueryCouponList] json_marshal error:%s", err)
|
||||
return
|
||||
}
|
||||
a.T().Logf("=====[Test_QueryCouponList] result: %s", string(resultByte))
|
||||
}
|
||||
38
platform/meituan/client.go
Normal file
38
platform/meituan/client.go
Normal file
@ -0,0 +1,38 @@
|
||||
package meituan
|
||||
|
||||
import (
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/client"
|
||||
)
|
||||
|
||||
// AuthConfig api鉴权参数
|
||||
type AuthConfig struct {
|
||||
AppKey string // 应用key
|
||||
AppSecret string // 应用秘钥
|
||||
}
|
||||
|
||||
// 连接第三方平台的client
|
||||
type Client struct {
|
||||
log logx.Logger
|
||||
authConfig AuthConfig
|
||||
client.HttpClient
|
||||
headers map[string]string
|
||||
}
|
||||
|
||||
func NewApiClient(log logx.Logger, conf AuthConfig) MeituanApi {
|
||||
clt := newClient(log, conf)
|
||||
sign := newSign(conf.AppKey, conf.AppSecret)
|
||||
return newMeituanApiImpl(log, clt, sign)
|
||||
}
|
||||
|
||||
func newClient(log logx.Logger, conf AuthConfig) *Client {
|
||||
return &Client{
|
||||
log: log,
|
||||
authConfig: conf,
|
||||
HttpClient: client.NewHttpClient(log),
|
||||
headers: map[string]string{
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
}
|
||||
}
|
||||
29
platform/meituan/consts.go
Normal file
29
platform/meituan/consts.go
Normal file
@ -0,0 +1,29 @@
|
||||
package meituan
|
||||
|
||||
// 相关地址
|
||||
const (
|
||||
SiteDomain = "https://media.meituan.com" // Domain 后台域名
|
||||
SiteUrl = "https://media.meituan.com/pc/index.html#/account/qualification/view" // SiteUrl 后台地址
|
||||
DocUrl = "https://media.meituan.com/pc/index.html#/help" // DocUrl 文档地址
|
||||
ApiDocUrl = "https://media.meituan.com/pc/index.html#/materials/api" // ApiDocUrl api文档地址
|
||||
)
|
||||
|
||||
// 接口地址
|
||||
const (
|
||||
ApiDomain = "https://media.meituan.com" //
|
||||
GetLinkUri = "/cps_open/common/api/v1/get_referral_link"
|
||||
GetOrderListUri = "/cps_open/common/api/v1/query_order"
|
||||
GetProductListUri = "/cps_open/common/api/v1/query_coupon"
|
||||
GetLinkUrl = ApiDomain + GetLinkUri
|
||||
GetOrderListUrl = ApiDomain + GetOrderListUri
|
||||
GetProductListUrl = ApiDomain + GetProductListUri
|
||||
)
|
||||
|
||||
// header头信息
|
||||
const (
|
||||
SCaApp = "S-Ca-App"
|
||||
SCaTimestamp = "S-Ca-Timestamp"
|
||||
ContentMd5 = "Content-MD5"
|
||||
SCaSignature = "S-Ca-Signature"
|
||||
SCaSignatureHeaders = "S-Ca-Signature-Headers"
|
||||
)
|
||||
120
platform/meituan/sign.go
Normal file
120
platform/meituan/sign.go
Normal file
@ -0,0 +1,120 @@
|
||||
package meituan
|
||||
|
||||
import (
|
||||
"crypto/hmac"
|
||||
"crypto/md5"
|
||||
"crypto/sha256"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/util"
|
||||
)
|
||||
|
||||
type Sign struct {
|
||||
AppKey string // 应用key
|
||||
AppSecret string // 应用秘钥
|
||||
}
|
||||
|
||||
func newSign(appKey, appSecret string) *Sign {
|
||||
return &Sign{
|
||||
AppKey: appKey,
|
||||
AppSecret: appSecret,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Sign) BuildHeader(methodType string, uri string, data map[string]any) map[string]string {
|
||||
headers := map[string]string{
|
||||
SCaApp: s.AppKey, // 应用app_key
|
||||
SCaTimestamp: fmt.Sprintf("%d", time.Now().UnixMilli()), // 请求发起时间戳(毫秒),有效时1分钟
|
||||
SCaSignatureHeaders: "S-Ca-Timestamp,S-Ca-App", // 将需要签名的header
|
||||
ContentMd5: s.contentMD5(methodType, data), // body数据Md5加密
|
||||
//"Content-Type": "application/json",
|
||||
}
|
||||
headers[SCaSignature] = s.GetSign(methodType, uri, data, headers)
|
||||
return headers
|
||||
}
|
||||
|
||||
func (s *Sign) GetSign(methodType string, uri string, data map[string]any, signHeaders map[string]string) string {
|
||||
httpMethod := s.httpMethod(methodType)
|
||||
contentMD5 := s.contentMD5(methodType, data)
|
||||
headers := s.headers(signHeaders)
|
||||
url := s.url(methodType, uri, data)
|
||||
strSign := httpMethod + "\n" + contentMD5 + "\n" + headers + url
|
||||
hm := hmac.New(sha256.New, []byte(s.AppSecret))
|
||||
hm.Write([]byte(strSign))
|
||||
signStr := base64.StdEncoding.EncodeToString(hm.Sum(nil))
|
||||
return signStr
|
||||
}
|
||||
|
||||
// 请求方式大写
|
||||
func (s *Sign) httpMethod(methodType string) string {
|
||||
return strings.ToUpper(methodType)
|
||||
}
|
||||
|
||||
// 请求参数执行base64+md5的值
|
||||
func (s *Sign) contentMD5(methodType string, data map[string]any) string {
|
||||
methodType = s.httpMethod(methodType)
|
||||
if (methodType == http.MethodPost || methodType == http.MethodPut) && data != nil {
|
||||
dataByte, _ := json.Marshal(data)
|
||||
h := md5.New()
|
||||
h.Write(dataByte)
|
||||
return base64.StdEncoding.EncodeToString(h.Sum(nil))
|
||||
} else {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
// 签名计算Header的Key拼接
|
||||
func (s *Sign) headers(signHeaders map[string]string) string {
|
||||
var str = ""
|
||||
// key排序
|
||||
sortData := sort.StringSlice{}
|
||||
for k := range signHeaders {
|
||||
if k != SCaSignature && k != SCaSignatureHeaders && k != ContentMd5 {
|
||||
sortData = append(sortData, k)
|
||||
}
|
||||
}
|
||||
sortData.Sort()
|
||||
|
||||
for _, k := range sortData {
|
||||
str += k + ":" + signHeaders[k] + "\n"
|
||||
}
|
||||
return str
|
||||
}
|
||||
|
||||
// url拼接
|
||||
// post直接返回path,get有参数的情况下拼接url
|
||||
func (s *Sign) url(methodType, uri string, data map[string]any) string {
|
||||
var query = ""
|
||||
methodType = s.httpMethod(methodType)
|
||||
// key排序
|
||||
sortData := sort.StringSlice{}
|
||||
for k := range data {
|
||||
sortData = append(sortData, k)
|
||||
}
|
||||
sortData.Sort()
|
||||
if len(sortData) > 0 && methodType == http.MethodGet {
|
||||
for num, key := range sortData {
|
||||
value, err := util.ToString(data[key])
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
str1 := ""
|
||||
if len(sortData)-1 != num {
|
||||
str1 = "&"
|
||||
}
|
||||
if len(value) > 0 {
|
||||
query += fmt.Sprintf("%s=%s", key, value)
|
||||
} else {
|
||||
query += key
|
||||
}
|
||||
query += str1
|
||||
}
|
||||
}
|
||||
return fmt.Sprintf("%s%s", uri, query)
|
||||
}
|
||||
188
platform/meituan/types.go
Normal file
188
platform/meituan/types.go
Normal file
@ -0,0 +1,188 @@
|
||||
package meituan
|
||||
|
||||
// GenerateLinkRequest 生成推广链接请求
|
||||
type GenerateLinkRequest struct {
|
||||
LinkType int32 `json:"linkType"` // 必填 链接类型,枚举值:1 H5长链接;2 H5短链接;3 deeplink(唤起)链接;4 微信小程序唤起路径;5 团口令
|
||||
Platform int32 `json:"platform,omitempty"` // 非必填 商品所属业务一级分类类型;请求的商品推广链接所属的业务类型信息,即只有输入skuViewId时才需要传本字段:1 到家及其他业务类型,2 到店业务类型;不填则默认1
|
||||
BizLine int32 `json:"bizLine,omitempty"` // 非必填 商品所属业务二级分类类型;请求的商品推广链接所属的业务类型信息,即只有输入skuViewId时才需要传本字段;当字段platform为1,选择到家及其他业务类型时:5 医药,不填则默认null,表示外卖商品券;当字段platform为2,选择到店业务类型时:1 到餐,2 到综 3:酒店 4:门票 不填则默认1
|
||||
ActId string `json:"actId,omitempty"` // 非必填 活动物料ID,我要推广-活动推广中第一列的id信息(和商品id、活动链接三选一填写,不能全填)
|
||||
SkuViewId string `json:"skuViewId,omitempty"` // 非必填 商品id,对商品查询接口返回的skuViewid(和活动物料ID、活动链接三选一,不能全填)
|
||||
Sid string `json:"sid,omitempty"` // 非必填 二级媒体身份标识,用于渠道效果追踪,限制64个字符,仅支持英文、数字和下划线
|
||||
Text string `json:"text,omitempty"` // 非必填 只支持到家外卖商品券、买菜业务类型链接和活动物料链接。活动链接,即想要推广的目标链接,出参会返回成自己可推的链接,限定为当前可推广的活动链接或者商品券链接,请求内容尽量保持在200字以内,文本中仅存在一个http协议头的链接
|
||||
}
|
||||
|
||||
// GenerateLinkResponse 生成推广链接响应
|
||||
type GenerateLinkResponse struct {
|
||||
Code int32 `json:"code"` // 响应码,0成功,其他失败
|
||||
Message string `json:"message"` // 响应文案
|
||||
Data string `json:"data"` // 返回对应的推广链接,这里的链接才能实现跟单计佣
|
||||
SkuViewId string `json:"skuViewId"` // 若用text进行入参取链,且返回的推广链接为商品券链接,则返回对应商品的展示ID,可以根据该ID查商品券接口获取对应的展示信息和佣金信息
|
||||
}
|
||||
|
||||
// QueryOrderListRequest 查询订单请求
|
||||
type QueryOrderListRequest struct {
|
||||
Platform int32 `json:"platform,omitempty"` // 非必填 商品所属业务一级分类类型:1 到家及其他业务类型,2 到店业务类型(包含到店美食、休闲生活、酒店、门票);不填则默认1
|
||||
BusinessLine []int32 `json:"businessLine,omitempty"` // 非必填 业务线标识;1)当platform为1,选择到家及其他业务类型时,业务线枚举为1:外卖订单 WAIMAI 2:闪购红包 3:酒旅 4:美团电商订单(团好货) 5:医药 6:拼好饭 7:商品超值券包 COUPON 8:买菜 MAICAI 11:闪购商品;不传则默认传空表示非售卖券包订单类型的全部查询。若输入参数含7 商品超值券包,则只返回商品超值券包订单;2)当platform为2,选择到店业务类型 时,业务线枚举1:到餐 2:到综 3:酒店 4:门票,不填则默认传1
|
||||
CategoryIds []int64 `json:"categoryIds,omitempty"` // 订单品类;1)当platform为1,当businessLine为11时,枚举值支持:大型连锁商超便利店(12),小型商超便利店(14),线上便利店(21),日百服饰(128),数码家电(106),美妆日化(107),母婴玩具(108),宠物(110),生鲜食材(24),鲜花(16),水果(15),酒饮(26),休闲食品(25),旗舰店(137),其他(-2);
|
||||
// 2)当platform为1,当businessLine为9时,枚举值支持:进群(1),下单(2),首关注(3);
|
||||
// 3)当platform为2,当businessLine为3时,枚举值支持:酒店(209),非标住宿(2327);
|
||||
// 4)当platform为2,当businessLine为2时,枚举值支持:休闲娱乐(3),结婚(338),教育培训(289),养车/用车(390),运动健身(206),家居(600),购物(379),亲子(389),医疗健康(450),生活服务(4),K歌(1853),宠物(1861),其他(-1)
|
||||
ActId int64 `json:"actId,omitempty"` // 非必填 活动物料id,我要推广-活动推广中第一列的id信息,不传则返回所有actId的数据,建议查询订单时传入actId
|
||||
Sid string `json:"sid,omitempty"` // 非必填 二级推广位id,最长64位,不传则返回所有sid的数据
|
||||
OrderId string `json:"orderId,omitempty"` // 非必填 订单id,入参后可与业务线标识businessLine配合使用,输入的orderId需要与businessLine能对应上。举例:如查询商品超值券包订单时orderId传券包订单号,businessLine传7;除此以外其他查询筛选条件不生效,不传业务线标识businessLine则默认仅查非券包订单
|
||||
StartTime int32 `json:"startTime,omitempty"` // 非必填 查询时间类型对应的查询开始时间,10位时间戳表示,单位秒
|
||||
EndTime int32 `json:"endTime,omitempty"` // 非必填 查询时间类型对应的查询结束时间,10位时间戳表示,单位秒
|
||||
Page int32 `json:"page,omitempty"` // 非必填 页码,默认1,从1开始,若searchType选择2,本字段必须传1,若不传参数默认1
|
||||
Limit int32 `json:"limit,omitempty"` // 非必填 每页限制条数,默认100,最大支持100
|
||||
QueryTimeType int32 `json:"queryTimeType,omitempty"` // 非必填 查询时间类型,枚举值, 1 按订单支付时间查询, 2 按照更新时间查询, 默认为1
|
||||
TradeType int32 `json:"tradeType,omitempty"` // 非必填 交易类型,1表示CPS,2表示CPA
|
||||
ScrollId string `json:"scrollId,omitempty"` // 非必填 分页id,当searchType选择2逐页查询时,本字段为必填。若不填写,默认查询首页。取值为上一页查询时出参的scrollId字段
|
||||
SearchType int32 `json:"searchType,omitempty"` // 非必填 订单分页查询方案选择,不填则默认为1。1 分页查询(最多能查询到1万条订单),当选择本查询方案,page参数不能为空。此查询方式后续不再维护,建议使用2逐页查询。2 逐页查询(不限制查询订单数,只能逐页查询,不能指定页数),当选择本查询方案,需配合scrollId参数使用
|
||||
CityNames []string `json:"cityNames,omitempty"` // 非必填 可输入城市名称圈定特定城市的订单,单次最多查询10个城市(英文逗号分隔)。不传则默认全部城市订单。 注:如需确认城市具体名称,可参考后台订单明细页的城市筛选项,或参考具体活动的城市命名。目前只支持到家业务类型-商品超值券包业务线。
|
||||
}
|
||||
|
||||
// QueryOrderListResponse 查询订单响应
|
||||
type QueryOrderListResponse struct {
|
||||
Code int `json:"code"` // 响应码,0成功,其他值为失败
|
||||
Message string `json:"message"` // 响应文案
|
||||
Data *QueryOrderData `json:"data"` // 响应结果信息
|
||||
}
|
||||
|
||||
type QueryOrderData struct {
|
||||
ActId int64 `json:"actId"` // 活动物料id,我要推广-活动推广中第一列的id信息
|
||||
SkuCount int32 `json:"skuCount"` // 查询返回本页的数量合计(无实际使用场景,若查询订单购买商品数可以看返回的dataList中skuCount)
|
||||
ScrollId string `json:"scrollId"` // 分页id,当searchType选择2逐页查询时,出参会返回本字段。用于下一页查询的scrollId字段入参使用
|
||||
DataList []*OrderItem `json:"dataList"` // 数据列表
|
||||
}
|
||||
|
||||
type OrderItem struct {
|
||||
BusinessLine int32 `json:"businessLine"` // 业务线,同入参枚举说明
|
||||
OrderId string `json:"orderId"` // 订单ID
|
||||
PayTime int64 `json:"payTime"` // 订单支付时间
|
||||
PayPrice string `json:"payPrice"` // 订单支付价格。针对到餐、到综、酒店、闪购、医药业务类型,为父订单的支付价格,单位元
|
||||
UpdateTime int64 `json:"updateTime"` // 订单最近一次的更新时间。到家外卖商品券、到家医药、到家闪购商品业务、到店到餐、到综、酒店类型,订单时间为用户买券包的更新时间,非每张券的更新时间。针对以上业务类型,建议查询单张券的更新时间
|
||||
CommissionRate string `json:"commissionRate"` // 订单预估佣金比例,300表示3%
|
||||
Profit string `json:"profit"` // 订单整体的预估佣金收入,单位元,1.60表示1.6元
|
||||
CpaProfit string `json:"cpaProfit"` // cpa类型的预估佣金收入,单位元,6.50表示6.5元
|
||||
Sid string `json:"sid"` // 二级媒体身份标识,用于渠道效果追踪
|
||||
ProductId string `json:"productId"` // 产品ID,对应商品查询接口的skuViewId,目前只支持到家外卖商品券、到家医药、到家闪购商品业务、到店业务类型
|
||||
ProductName string `json:"productName"` // 产品名称,外卖订单展示店铺名称,到店取单个商品券的名称、其他展示全部商品名称
|
||||
OrderDetail []*OrderDetail `json:"orderDetail"` // 订单详情,只支持到家外卖商品券、到家医药、到家闪购商品业务、到店到餐、到综、酒店类型返回数据
|
||||
RefundPrice string `json:"refundPrice"` // 只对非到店到餐、非到综、非酒店业务类型有效。订单维度退款价格,该笔订单用户发生退款行为时的退款计佣金额之和,超值券包订单本期不返回退款数据,单位元
|
||||
RefundTime string `json:"refundTime"` // 只对非到店到餐、非到综、非酒店业务类型有效。订单维度最新一次发生退款的时间;超值券包订单本期不返回退款数据,单位元
|
||||
RefundProfit string `json:"refundProfit"` // 只对非到店到餐、非到综、非酒店业务类型有效。订单维度退款预估佣金,该笔订单用户发生退款行为时的退款预估佣金金额之和;超值券包订单本期不返回退款数据,单位元
|
||||
CpaRefundProfit string `json:"cpaRefundProfit"` // cpa退款预估佣金,单位元
|
||||
Status string `json:"status"` // 表示订单维度状态,枚举有 2:付款(如果是CPA订单则表示奖励已创建) 3:完成 4:取消 5:风控 6:结算
|
||||
TradeType int32 `json:"tradeType"` // 交易类型,1:cps,2:cpa
|
||||
ActId int64 `json:"actId"` // 活动物料id,我要推广-活动推广中第一列的id信息
|
||||
Appkey string `json:"appkey"` // 归因到的appKey,对应取链时入参的appkey
|
||||
SkuCount int32 `json:"skuCount"` // 表示sku数量,团好货和券包类型的CPS订单返回有值,其余类型订单不返回该值
|
||||
CityName string `json:"cityName"` // 订单所属的城市,目前支持二级城市粒度。目前只支持到家业务类型-商品超值券包业务线。
|
||||
CategoryId int64 `json:"categoryId"` // 订单品类id。
|
||||
CategoryName string `json:"categoryName"` // 订单品类名称。
|
||||
}
|
||||
|
||||
// 订单详情
|
||||
type OrderDetail struct {
|
||||
CouponStatus string `json:"couponStatus"` // 本期只有到到家外卖商品券、到家医药、到家闪购商品业务、到店到餐、到综、酒店业务类型展示订单明细,表示商品券/子订单推广计佣状态,1、付款,2、完成(或券已核销),3、结算,4、失效(含取消或风控的情况)
|
||||
ItemOrderId string `json:"itemOrderId"` // 针对到店到餐、到综、酒店商品券,返回商品券的子订单号。其他业务类型不返回
|
||||
FinishTime string `json:"finishTime"` // 1、针对到家外卖商品券,返回商品券核销完成履约的实物菜品订单号对应的完成时间;2、针对到家医药&闪购商品,返回商品订单完成时间;3、针对到店到餐、到综、酒店子订单,返回子订单对应的券核销时间
|
||||
BasicAmount string `json:"basicAmount"` // 商品的计佣金额,每个商品对应的支付分摊金额,单位元
|
||||
CouponFee string `json:"couponFee"` // 商品的佣金,当推广状态为失效、取消、风控时,佣金值为0,单位元
|
||||
OrderViewId string `json:"orderViewId"` // 只对到家外卖商品券有效。商品券的核销完成履约的实物菜品订单号
|
||||
RefundAmount string `json:"refundAmount"` // 到店到餐、到综、酒店子订单、到家闪购商品、到家医药业务类型的退款金额,到家其他业务类型不返回数据,单位元
|
||||
RefundFee string `json:"refundFee"` // 到店到餐、到综、酒店子订单、到家闪购商品、到家医药业务类型的退款佣金,到家其他业务类型不返回数据,单位元
|
||||
RefundTime string `json:"refundTime"` // 到店到餐、到综、酒店子订单、到家闪购商品、到家医药业务类型的退款时间,到家其他业务类型不返回数据
|
||||
SettleTime string `json:"settleTime"` // 到家商品券/到家闪购商品/到店到餐/到综/酒店子订单的结算时间,完成并且进入结算账期时则变为结算状态。若存在多次结算记录则取最新结算时间
|
||||
UpdateTime string `json:"updateTime"` // 到家商品券/到家闪购商品/到家医药/到店到餐、到综、酒店子订单的更新时间
|
||||
}
|
||||
|
||||
// QueryCouponListRequest 查询商品请求
|
||||
type QueryCouponListRequest struct {
|
||||
Platform int32 `json:"platform,omitempty"` // 非必填 商品所属业务一级分类类型:1 到家及其他业务类型,2 到店业务类型(包含到店美食、休闲生活、酒店、门票);不填则默认1
|
||||
BizLine int32 `json:"bizLine,omitempty"` // 非必填 商品所属业务二级分类类型;当字段platform为1,选择到家及其他业务类型时:5 医药 ,不填则默认为null,返回外卖商品券;当字段platform为2,选择到店业务类型时:1 到餐,2 到综 3:酒店 4:门票度假 不填则默认1
|
||||
Longitude int64 `json:"longitude,omitempty"` // 非必填 定位经纬度的经度,请传递经度*100万倍的整形数字,如经度116.404*100万倍为116404000; 针对到店、到家医药商品业务类型,若未输入经纬度,则默认北京;针对到家外卖商品券业务类型,若未输入经纬度,则默认全国
|
||||
Latitude int64 `json:"latitude,omitempty"` // 非必填 定位经纬度的纬度,请传递纬度*100万倍的整形数字,如纬度39.928*100万倍为39928000; 针对到店、到家医药商品业务类型,若未输入经纬度,则默认北京;针对到家外卖商品券业务类型,若未输入经纬度,则默认全国
|
||||
PriceCap int32 `json:"priceCap,omitempty"` // 非必填 筛选商品售卖价格上限【单位元】
|
||||
PriceFloor int32 `json:"priceFloor,omitempty"` // 非必填 筛选商品价格下限【单位元】
|
||||
CommissionCap int32 `json:"commissionCap,omitempty"` // 非必填 筛选商品佣金值上限【单位元】,若商品按照佣金值进行范围筛选,则排序只能按照佣金降序,本字段只支持到店业务类型、到家医药业务类型
|
||||
CommissionFloor int32 `json:"commissionFloor,omitempty"` // 非必填 筛选商品佣金值下限【单位元】,若商品按照佣金值进行范围筛选,则排序只能按照佣金降序,本字段只支持到店业务类型、到家医药业务类型
|
||||
VpSkuViewIds []string `json:"vpSkuViewIds,omitempty"` // 非必填 商品ID集合,非必填,若填写该字段则不支持其他筛选条件,集合里ID用英文“,”隔开。一次最多支持查询20个售卖券ID
|
||||
ListTopiId int32 `json:"listTopiId,omitempty"` // 非必填 选品池榜单主题ID,到家及其他业务类型支持查询:1 精选,2 今日必推,3 同城热销,4 跟推爆款的商品售卖券(其中到家医药业务类型,本项为必填,且只支持传枚举3);到店业务类型支持查询:2 今日必推,3 同城热销(全部商品)5 实时热销(其中到店酒店、门票业务类型,本项为必填,且只支持传枚举3)
|
||||
SearchText string `json:"searchText,omitempty"` // 非必填 搜索关键字,限制1-100个字符,不支持入参指定Platform、bizLine搜索,搜索范围为全品类。如需使用该字段查询商品信息,则vpSkuViewIds、listTopiId字段必须为空!!!如不为空,则按下述字段优先级执行查询:vpSkuViewIds>listTopiId>searchText。
|
||||
SearchId string `json:"searchId,omitempty"` // 非必填 仅搜索场景分页使用,首次调用不用填。查询相同搜索关键词、相同排序规则的下一页数据,需携带填写上次查询时出参中的'searchId'。如变更搜索关键字或排序规则,则也无需填写。
|
||||
PageSize int32 `json:"pageSize,omitempty"` // 非必填 分页大小,不填返回默认分页20
|
||||
PageNo int32 `json:"pageNo,omitempty"` // 非必填 页数,不填返回默认页数1
|
||||
SortField int32 `json:"sortField,omitempty"` // 非必填 1)未入参榜单listTopiId时:支持1 售价排序、2 销量排序;2)入参榜单listTopiId时:当platform为1,选择到家业务类型:外卖商品券类型,支持1 售价排序、 2 销量降序、 3佣金降序,不填则默认为1;到家医药类型,支持2 销量降序、 3 佣金降序,不填则默认为2; 当platform为2,选择到店业务类型:支持2 销量降序、 3佣金降序,不填则默认为2。其中listTopiId为5时,仅支持默认排序,sortField不生效;3)通过搜索searchText召回时:支持1综合排序、2价格升序,不填默认为1
|
||||
AscDescOrder int32 `json:"ascDescOrder,omitempty"` // 非必填 仅对到家业务类型生效,未入参榜单listTopiId时:1 升序,2 降序; 入参榜单listTopiId时:1 升序,2 降序,并且仅对sortField为1售价排序的时候生效,其他筛选值不生效; 其他说明:不填则默认为1升序
|
||||
}
|
||||
|
||||
// QueryCouponListResponse 查询商品响应
|
||||
type QueryCouponListResponse struct {
|
||||
Code int `json:"code"` // 响应码,0成功,其他值为失败
|
||||
Message string `json:"message"` // 响应文案
|
||||
HasNext bool `json:"hasNext"` // 分页使用,看是否有下一页
|
||||
SearchId string `json:"searchId"` // 搜索场景出参,用于相同条件下一页请求入参
|
||||
Data []*QueryCouponData `json:"data"` // 响应结果信息
|
||||
}
|
||||
|
||||
type QueryCouponData struct {
|
||||
AvailablePoiInfo *AvailablePoiInfo `json:"availablePoiInfo"` // 可用门店信息
|
||||
BrandInfo *BrandInfo `json:"brandInfo"` // 品牌信息
|
||||
CommissionInfo *CommissionInfo `json:"commissionInfo"` // 佣金信息
|
||||
CouponPackDetail *CouponPackDetail `json:"couponPackDetail"` // 商品详情
|
||||
DeliverablePoiInfo *DeliverablePoiInfo `json:"deliverablePoiInfo"` // 只支持到家外卖商品券业务类型,可配送门店信息
|
||||
PurchaseLimitInfo *PurchaseLimitInfo `json:"purchaseLimitInfo"` // 购买限制信息
|
||||
CouponValidTimeInfo *CouponValidTimeInfo `json:"couponValidTimeInfo"` // 只支持到家外卖商品券业务类型,券包活动有效时间信息
|
||||
}
|
||||
|
||||
type AvailablePoiInfo struct {
|
||||
AvailablePoiNum int64 `json:"availablePoiNum"` // 可用门店数量。针对到店、到家医药业务类型商品,若传入经纬度信息,则为经纬度所在城市可用的门店数。若不传入经纬度信息,则输出北京可用的门店数
|
||||
}
|
||||
|
||||
type BrandInfo struct {
|
||||
BrandName string `json:"brandName"` // 品牌名称
|
||||
BrandLogoUrl string `json:"brandLogoUrl"` // 品牌Logo的url
|
||||
}
|
||||
|
||||
type CommissionInfo struct {
|
||||
CommissionPercent string `json:"commissionPercent"` // 查询当时生效的佣金比例, 商品券拉取、通过商品券ID查询、通过榜单listTopiId查询,返回的数据需要除以100表示对应的佣金比例,如返回400表示佣金比例为4%
|
||||
Commission string `json:"commission"` // 只支持到店、到家医药业务类型。查询当时生效的佣金值。单位元,保留小数点后两位
|
||||
}
|
||||
|
||||
type CouponPackDetail struct {
|
||||
Name string `json:"name"` // 商品名称
|
||||
SkuViewId string `json:"skuViewId"` // 商品skuViewId,传入开放平台取链接口的skuViewId,取得对应推广链接才能正常归因订单
|
||||
Specification string `json:"specification"` // 规格信息,只支持到家医药商品业务类型
|
||||
CouponNum int32 `json:"couponNum"` // 只支持到家外卖商品券业务类型,券包中券的数量
|
||||
ValidTime int32 `json:"validTime"` // 只支持到家外卖商品券业务类型,活动截止有效日期,仅作参考,具体结束时间详见couponValidTimeInfo中的信息
|
||||
HeadUrl string `json:"headUrl"` // 商品头图的url
|
||||
SaleVolume string `json:"saleVolume"` // 美团累计销量,例:100+,1000+,10000+
|
||||
StartTime int64 `json:"startTime"` // 只支持到家外卖商品券业务类型,活动有效期开始时间
|
||||
EndTime int64 `json:"endTime"` // 只支持到家外卖商品券业务类型,活动有效期结束时间
|
||||
SaleStatus bool `json:"saleStatus"` // 售卖状态,可售为是,不可售为否。不可售商品不返回商品数据
|
||||
OriginalPrice string `json:"originalPrice"` // 原始价格,如划线价(元)
|
||||
SellPrice string `json:"sellPrice"` // 售卖价格(元)
|
||||
Platform int32 `json:"platform"` // 平台,1-到家、2-到店
|
||||
BizLine int32 `json:"bizLine"` // 二级分类,当platform为1时null代表外卖,当platform为2时1代表餐
|
||||
}
|
||||
|
||||
type DeliverablePoiInfo struct {
|
||||
PoiName string `json:"poiName"` // 门店名称,商品券可配送门店信息,无则不返回 注:入参经纬度可展示附近配送门店名称。按主题榜单查询时不展示该字段
|
||||
PoiLogoUrl string `json:"poiLogoUrl"` // 门店Logo的url 注:入参经纬度可展示附近配送门店logo。按主题榜单查询时不展示该字段。
|
||||
DeliveryDistance string `json:"deliveryDistance"` // 配送距离 注:入参经纬度可展示附近配送门店的配送距离。按主题榜单查询时不展示该字段。
|
||||
DistributionCost string `json:"distributionCost"` // 配送费 注:入参经纬度可展示附近配送门店的配送费。按主题榜单查询时不展示该字段。
|
||||
DeliveryDuration string `json:"deliveryDuration"` // 配送时长 注:入参经纬度可展示附近配送门店的配送时长。按主题榜单查询时不展示该字段。
|
||||
LastDeliveryFee string `json:"lastDeliveryFee"` // 起送额 注:入参经纬度可展示附近配送门店的起送金额。按主题榜单查询时不展示该字段。
|
||||
}
|
||||
|
||||
type PurchaseLimitInfo struct {
|
||||
SingleDayPurchaseLimit int32 `json:"singleDayPurchaseLimit"` // 单日售卖上限
|
||||
}
|
||||
|
||||
type CouponValidTimeInfo struct {
|
||||
CouponValidTimeType int32 `json:"couponValidTimeType"` // 券包活动生效时间类型,1:按生效天数,2:按时间段
|
||||
CouponValidDay int32 `json:"couponValidDay"` // 券生效天数;couponValidTimeType为1有效
|
||||
CouponValidSTime int64 `json:"couponValidSTime"` // 券开始时间戳,单位秒;couponValidTimeType为2有效
|
||||
CouponValidETime int64 `json:"couponValidETime"` // 券结束时间戳,单位秒;couponValidTimeType为2有效
|
||||
}
|
||||
83
platform/shoutu-show/api.go
Normal file
83
platform/shoutu-show/api.go
Normal file
@ -0,0 +1,83 @@
|
||||
package shoutu_show
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"github.com/zywaited/xcopy"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/client"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/util"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// ShouTuShowApi 守兔演唱会
|
||||
type ShouTuShowApi interface {
|
||||
// GenerateLink 生成推广链接
|
||||
GenerateLink(ctx context.Context, req GenerateLinkRequest) (*GenerateLinkResponse, error)
|
||||
// GenerateWechatUrl 生成微信小程序链接
|
||||
GenerateWechatUrl(ctx context.Context, req GenerateLinkRequest) (*GenerateLinkResponse, error)
|
||||
}
|
||||
|
||||
type ShouTuShowApiImpl struct {
|
||||
log logx.Logger
|
||||
client *Client
|
||||
}
|
||||
|
||||
func newShouTuShowApiImpl(log logx.Logger, client *Client) ShouTuShowApi {
|
||||
return &ShouTuShowApiImpl{
|
||||
log: log,
|
||||
client: client,
|
||||
}
|
||||
}
|
||||
|
||||
// 守兔演出不支持H5取链,生成的H5url为小程序中间页URL
|
||||
func (a *ShouTuShowApiImpl) GenerateLink(ctx context.Context, req GenerateLinkRequest) (*GenerateLinkResponse, error) {
|
||||
if req.ActivityUrl == "" || req.LinkCode == "" || req.ActId == "" {
|
||||
return nil, errors.New("请求参数activityUrl或linkCode或actId不能为空")
|
||||
}
|
||||
activityUrl := fmt.Sprintf("%s?linkCode=%s&actId=%s", req.ActivityUrl, req.LinkCode, req.ActId)
|
||||
return &GenerateLinkResponse{
|
||||
H5: activityUrl,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// 小程序链接
|
||||
func (a *ShouTuShowApiImpl) GenerateWechatUrl(ctx context.Context, req GenerateLinkRequest) (*GenerateLinkResponse, error) {
|
||||
if req.ActivityUrl == "" || req.Sid == "" {
|
||||
return nil, errors.New("请求参数activityUrl或sid不能为空")
|
||||
}
|
||||
//直接替换
|
||||
newUrl := strings.ReplaceAll(req.ActivityUrl, "subChannelId=", fmt.Sprintf("subChannelId=%s", req.Sid))
|
||||
return &GenerateLinkResponse{
|
||||
MiniProgramUrl: newUrl,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// QueryOrderList 查询订单列表
|
||||
func (a *ShouTuShowApiImpl) QueryOrderList(ctx context.Context, req QueryOrderListRequest) ([]*OrderItem, error) {
|
||||
if req.StartTime <= 0 || req.EndTime <= 0 {
|
||||
return nil, errors.New("请求参数start_time或end_time为必传")
|
||||
}
|
||||
//sTime := time.Unix(req.StartTime, 0)
|
||||
//eTime := time.Unix(req.EndTime, 0)
|
||||
pageSize := 50
|
||||
|
||||
//todo时间筛选
|
||||
args := util.StructToMap(map[string]any{
|
||||
"pageNum": req.Page,
|
||||
"pageSize": pageSize,
|
||||
})
|
||||
request := &client.HttpRequest{Headers: a.client.headers, BodyArgs: args}
|
||||
response := new(QueryOrderListResponse)
|
||||
if err := a.client.HttpPost(GetOrderListUrl, request, &client.HttpResponse{Result: response}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
responseData := make([]*OrderItem, 0)
|
||||
if response.Data != nil && len(response.Data.Records) > 0 {
|
||||
if err := xcopy.Copy(&responseData, response.Data.Records); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return responseData, nil
|
||||
}
|
||||
66
platform/shoutu-show/api_test.go
Normal file
66
platform/shoutu-show/api_test.go
Normal file
@ -0,0 +1,66 @@
|
||||
package shoutu_show
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// api-单元测试
|
||||
type apiClientSuite struct {
|
||||
suite.Suite
|
||||
api ShouTuShowApi
|
||||
}
|
||||
|
||||
func TestApiClient(t *testing.T) {
|
||||
suite.Run(t, new(apiClientSuite))
|
||||
}
|
||||
|
||||
func (a *apiClientSuite) SetupSuite() {
|
||||
log := logx.WithContext(context.Background())
|
||||
apiClient := NewApiClient(log, AuthConfig{
|
||||
AppKey: "", //
|
||||
AppSecret: "",
|
||||
})
|
||||
a.api = apiClient
|
||||
}
|
||||
|
||||
func (a *apiClientSuite) Test_GenerateLink() {
|
||||
req := GenerateLinkRequest{
|
||||
ActivityUrl: "https://cms.zhongdiantui.com/#/pages/toMiniProgram/toMiniProgram",
|
||||
Sid: "f3a8c1",
|
||||
LinkCode: "aaakfhkahfkadk",
|
||||
ActId: "1111",
|
||||
}
|
||||
result, err := a.api.GenerateLink(context.Background(), req)
|
||||
if !a.NoError(err) {
|
||||
a.T().Errorf("========[Test_GenerateLink] response error:%s", err)
|
||||
return
|
||||
}
|
||||
resultByte, err := json.Marshal(result)
|
||||
if err != nil {
|
||||
a.T().Errorf("========[Test_GenerateLink] json_marshal error:%s", err)
|
||||
return
|
||||
}
|
||||
a.T().Logf("=====[Test_GenerateLink] result: %s", string(resultByte))
|
||||
}
|
||||
|
||||
func (a *apiClientSuite) Test_GenerateWechatUrl() {
|
||||
req := GenerateLinkRequest{
|
||||
ActivityUrl: "pages/index/index?distributorId=VCiCWwU2&subChannelId=",
|
||||
Sid: "f3a8c1",
|
||||
}
|
||||
result, err := a.api.GenerateWechatUrl(context.Background(), req)
|
||||
if !a.NoError(err) {
|
||||
a.T().Errorf("========[Test_GenerateLink] response error:%s", err)
|
||||
return
|
||||
}
|
||||
resultByte, err := json.Marshal(result)
|
||||
if err != nil {
|
||||
a.T().Errorf("========[Test_GenerateLink] json_marshal error:%s", err)
|
||||
return
|
||||
}
|
||||
a.T().Logf("=====[Test_GenerateLink] result: %s", string(resultByte))
|
||||
}
|
||||
36
platform/shoutu-show/client.go
Normal file
36
platform/shoutu-show/client.go
Normal file
@ -0,0 +1,36 @@
|
||||
package shoutu_show
|
||||
|
||||
import (
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/client"
|
||||
)
|
||||
|
||||
// AuthConfig api鉴权参数
|
||||
type AuthConfig struct {
|
||||
AppKey string // api key
|
||||
AppSecret string // api key
|
||||
}
|
||||
|
||||
// Client 连接第三方平台的client
|
||||
type Client struct {
|
||||
log logx.Logger
|
||||
authConfig AuthConfig
|
||||
client.HttpClient
|
||||
headers map[string]string
|
||||
}
|
||||
|
||||
func NewApiClient(log logx.Logger, conf AuthConfig) ShouTuShowApi {
|
||||
clt := newClient(log, conf)
|
||||
return newShouTuShowApiImpl(log, clt)
|
||||
}
|
||||
|
||||
func newClient(log logx.Logger, conf AuthConfig) *Client {
|
||||
return &Client{
|
||||
log: log,
|
||||
authConfig: conf,
|
||||
HttpClient: client.NewHttpClient(log),
|
||||
headers: map[string]string{
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
}
|
||||
}
|
||||
15
platform/shoutu-show/consts.go
Normal file
15
platform/shoutu-show/consts.go
Normal file
@ -0,0 +1,15 @@
|
||||
package shoutu_show
|
||||
|
||||
// 相关地址
|
||||
const (
|
||||
SiteDomain = "https://show.shoutoinfo.cn/prod-api" // Domain 后台域名
|
||||
SiteUrl = "https://show.shoutoinfo.cn/prod-api" // SiteUrl 后台地址
|
||||
DocUrl = "https://apifox.com/apidoc/shared-2c9bfdd9-5307-4d29-b71f-63b93393d607" // DocUrl 文档地址
|
||||
ApiDocUrl = "https://apifox.com/apidoc/shared-2c9bfdd9-5307-4d29-b71f-63b93393d607" // ApiDocUrl api文档地址
|
||||
)
|
||||
|
||||
// 接口地址
|
||||
const (
|
||||
ApiDomain = "https://pre-show.shoutoinfo.cn/prod-api" // Domain api域名
|
||||
GetOrderListUrl = ApiDomain + "/api/open/channel-order/page"
|
||||
)
|
||||
57
platform/shoutu-show/types.go
Normal file
57
platform/shoutu-show/types.go
Normal file
@ -0,0 +1,57 @@
|
||||
package shoutu_show
|
||||
|
||||
type GenerateLinkRequest struct {
|
||||
ActivityUrl string `json:"activityUrl"` // 渠道方合作页地址
|
||||
Sid string `json:"sid"` // 必传 自定义参数
|
||||
LinkCode string `json:"linkCode"` // 链接code
|
||||
ActId string `json:"actId"` // 活动id
|
||||
}
|
||||
|
||||
// GenerateLinkResponse 生成推广链接响应
|
||||
type GenerateLinkResponse struct {
|
||||
H5 string `json:"h5"` // H5链接
|
||||
MiniProgramUrl string `json:"MiniProgramUrl"` //小程序链接
|
||||
}
|
||||
|
||||
type QueryOrderListRequest struct {
|
||||
StartTime int64 `json:"start_time"`
|
||||
EndTime int64 `json:"end_time"`
|
||||
Page int64 `json:"page"`
|
||||
}
|
||||
type QueryOrderListResponse struct {
|
||||
Code string `json:"code"`
|
||||
Mse string `json:"mse"`
|
||||
Success bool `json:"success"`
|
||||
CurrTime int64 `json:"currTime"`
|
||||
Data *OrderData `json:"data"`
|
||||
}
|
||||
type OrderData struct {
|
||||
PageNum int64 `json:"pageNum"` //当前页码
|
||||
PageSize int64 `json:"pageSize"` //每页数量
|
||||
Total int64 `json:"total"` //总数
|
||||
Records []*OrderItem `json:"records"`
|
||||
}
|
||||
type OrderItem struct {
|
||||
OrderNo string `json:"orderNo"` //订单号
|
||||
UserId int64 `json:"userId"` //用户Id
|
||||
UserNickname string `json:"userNickname"` //用户昵称
|
||||
UserHeadPic string `json:"userHeadPic"` //用户头像
|
||||
ChannelId int64 `json:"channelId"` //一级分销id
|
||||
SubChannelId int64 `json:"subChannelId"` //二级分销标识
|
||||
OrderSourceType string `json:"orderSourceType"` //订单来源类型【1-h5订单,2-api订单,3-微信小程序订单】
|
||||
PerformanceName string `json:"performanceName"` //演出信息
|
||||
SessionName string `json:"sessionName"` //场次信息
|
||||
TicketFaceName string `json:"ticketFaceName"` //票面信息
|
||||
BuyQty int `json:"buyQty"` //张数
|
||||
OrderType string `json:"orderType"` //订单类型
|
||||
OrderStatusDesc string `json:"orderStatusDesc"` //订单状态描述
|
||||
OrderStatus int `json:"orderStatus"` //订单状态值
|
||||
PayTime string `json:"payTime"` //订单支付时间 示例:2024-06-28 15:20:33
|
||||
PayAmt int `json:"payAmt"` //订单金额 单位:元
|
||||
CommissionAmt int `json:"commissionAmt"` //订单预估利润 单位:元
|
||||
CommissionRate int `json:"commissionRate"` //渠道分润比例 单位:%
|
||||
SettleTime string `json:"settleTime"` //渠道分润结算时间 示例:2024-06-28 15:20:33
|
||||
SettledCommissionAmt int `json:"settledCommissionAmt"` //已结算分润金额 单位:元
|
||||
OrderTime string `json:"orderTime"` //订单创建时间 示例:2024-06-28 15:20:33
|
||||
UpdateTime string `json:"updateTime"` //订单更新时间 示例:2024-06-28 15:20:33
|
||||
}
|
||||
@ -7,8 +7,8 @@ import (
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/client"
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/util"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/client"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/util"
|
||||
)
|
||||
|
||||
// T3UnionApi 调用第三方平台的api
|
||||
|
||||
@ -22,8 +22,8 @@ func TestApiClient(t *testing.T) {
|
||||
func (a *apiClientSuite) SetupSuite() {
|
||||
log := logx.WithContext(context.Background())
|
||||
apiClient := NewApiClient(log, AuthConfig{
|
||||
AppKey: "QOHEgCUTeK",
|
||||
AppSecret: "tsTSxrCgibcFbxGOxRDEBGQUhRVJLsFs",
|
||||
AppKey: "",
|
||||
AppSecret: "",
|
||||
})
|
||||
a.api = apiClient
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@ package t3_union
|
||||
import (
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/client"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/client"
|
||||
)
|
||||
|
||||
// AuthConfig api鉴权参数
|
||||
|
||||
@ -8,7 +8,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/util"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/util"
|
||||
)
|
||||
|
||||
type Sign struct {
|
||||
|
||||
54
platform/yapingtech/api.go
Normal file
54
platform/yapingtech/api.go
Normal file
@ -0,0 +1,54 @@
|
||||
package yapingtech
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/client"
|
||||
)
|
||||
|
||||
// YaPingTechApi 亚平平台
|
||||
type YaPingTechApi interface {
|
||||
QueryOrderList(ctx context.Context, req QueryOrderListRequest) ([]*QueryOrderListItem, error)
|
||||
}
|
||||
type yaPingTechApiImpl struct {
|
||||
log logx.Logger
|
||||
client *Client
|
||||
}
|
||||
|
||||
func newYaPingTechApiImpl(log logx.Logger, client *Client) YaPingTechApi {
|
||||
return &yaPingTechApiImpl{
|
||||
log: log,
|
||||
client: client,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *yaPingTechApiImpl) QueryOrderList(ctx context.Context, req QueryOrderListRequest) ([]*QueryOrderListItem, error) {
|
||||
params := map[string]any{
|
||||
"page": req.Page,
|
||||
"out_order_sn": req.OutOrderSn,
|
||||
}
|
||||
if req.Type != "" {
|
||||
params["type"] = req.Type
|
||||
}
|
||||
//加密参数
|
||||
paramsStr, _ := json.Marshal(params)
|
||||
jsonData, err := Encrypt(string(paramsStr), s.client.authConfig.AppSecret)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("yapingtech encrypt failed: %v", err)
|
||||
}
|
||||
args := map[string]any{
|
||||
"app_id": s.client.authConfig.AppId,
|
||||
"json_data": jsonData,
|
||||
}
|
||||
request := &client.HttpRequest{Headers: s.client.headers, BodyArgs: args}
|
||||
response := new(QueryOrderListResponse)
|
||||
if err := s.client.HttpPost(GetOrderListUrl, request, &client.HttpResponse{Result: response}); err != nil {
|
||||
return nil, fmt.Errorf("yapingtech http post failed: %v", err)
|
||||
}
|
||||
if response.Code != 200 {
|
||||
return nil, fmt.Errorf(response.Message)
|
||||
}
|
||||
return response.Data.Items, nil
|
||||
}
|
||||
46
platform/yapingtech/api_test.go
Normal file
46
platform/yapingtech/api_test.go
Normal file
@ -0,0 +1,46 @@
|
||||
package yapingtech
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// api-单元测试
|
||||
type apiClientSuite struct {
|
||||
suite.Suite
|
||||
api YaPingTechApi
|
||||
}
|
||||
|
||||
func TestApiClient(t *testing.T) {
|
||||
suite.Run(t, new(apiClientSuite))
|
||||
}
|
||||
|
||||
func (a *apiClientSuite) SetupSuite() {
|
||||
log := logx.WithContext(context.Background())
|
||||
apiClient := NewApiClient(log, AuthConfig{
|
||||
AppId: "ov595MzFifkk1usgIx3+3Q==",
|
||||
AppSecret: "8/3eQzZbj9ymbC80MHm1EgcMZ1wUI2wOrxjwx4dfiekG/u+wvW3lqz6PKnzYQ0Hs",
|
||||
})
|
||||
a.api = apiClient
|
||||
}
|
||||
|
||||
func (a *apiClientSuite) Test_QueryOrderList() {
|
||||
req := QueryOrderListRequest{
|
||||
Page: 1,
|
||||
OutOrderSn: "Y02141445536174133",
|
||||
}
|
||||
result, err := a.api.QueryOrderList(context.Background(), req)
|
||||
if !a.NoError(err) {
|
||||
a.T().Errorf("========[Test_QueryOrderList] response error:%s", err)
|
||||
return
|
||||
}
|
||||
resultByte, err := json.Marshal(result)
|
||||
if err != nil {
|
||||
a.T().Errorf("========[Test_QueryOrderList] json_marshal error:%s", err)
|
||||
return
|
||||
}
|
||||
a.T().Logf("================[Test_QueryOrderList] result: %s", string(resultByte))
|
||||
}
|
||||
36
platform/yapingtech/client.go
Normal file
36
platform/yapingtech/client.go
Normal file
@ -0,0 +1,36 @@
|
||||
package yapingtech
|
||||
|
||||
import (
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/client"
|
||||
)
|
||||
|
||||
// AuthConfig api鉴权参数
|
||||
type AuthConfig struct {
|
||||
AppId string // api id
|
||||
AppSecret string // api secret
|
||||
}
|
||||
|
||||
// Client 连接第三方平台的client
|
||||
type Client struct {
|
||||
log logx.Logger
|
||||
authConfig AuthConfig
|
||||
client.HttpClient
|
||||
headers map[string]string
|
||||
}
|
||||
|
||||
func NewApiClient(log logx.Logger, conf AuthConfig) YaPingTechApi {
|
||||
clt := newClient(log, conf)
|
||||
return newYaPingTechApiImpl(log, clt)
|
||||
}
|
||||
|
||||
func newClient(log logx.Logger, conf AuthConfig) *Client {
|
||||
return &Client{
|
||||
log: log,
|
||||
authConfig: conf,
|
||||
HttpClient: client.NewHttpClient(log),
|
||||
headers: map[string]string{
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
}
|
||||
}
|
||||
8
platform/yapingtech/consts.go
Normal file
8
platform/yapingtech/consts.go
Normal file
@ -0,0 +1,8 @@
|
||||
package yapingtech
|
||||
|
||||
const (
|
||||
ApiDomain = "https://api.haokavip.com" // 正式接口域名
|
||||
ApiTestDomain = "https://mp-api.66-six.com" // 测试接口域名
|
||||
|
||||
GetOrderListUrl = ApiDomain + "/open/api/list_order"
|
||||
)
|
||||
58
platform/yapingtech/encrypt.go
Normal file
58
platform/yapingtech/encrypt.go
Normal file
@ -0,0 +1,58 @@
|
||||
package yapingtech
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/aes"
|
||||
"crypto/cipher"
|
||||
"encoding/base64"
|
||||
)
|
||||
|
||||
// PKCS7Padding pads the input text according to the PKCS7 standard.
|
||||
func PKCS7Padding(data []byte, blockSize int) []byte {
|
||||
padding := blockSize - len(data)%blockSize
|
||||
padText := bytes.Repeat([]byte{byte(padding)}, padding)
|
||||
return append(data, padText...)
|
||||
}
|
||||
|
||||
// Encrypt encrypts the given plaintext using AES-256-ECB.
|
||||
func Encrypt(plaintext, key string) (string, error) {
|
||||
// Truncate the key to 32 bytes
|
||||
truncatedKey := []byte(key)[:32]
|
||||
block, err := aes.NewCipher(truncatedKey)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
paddedText := PKCS7Padding([]byte(plaintext), aes.BlockSize)
|
||||
cipherText := make([]byte, len(paddedText))
|
||||
mode := NewECBEncrypter(block)
|
||||
mode.CryptBlocks(cipherText, paddedText)
|
||||
return base64.StdEncoding.EncodeToString(cipherText), nil
|
||||
}
|
||||
|
||||
// ecbEncrypter is a custom implementation of ECB encryption mode.
|
||||
type ecbEncrypter struct {
|
||||
b cipher.Block
|
||||
blockSize int
|
||||
}
|
||||
|
||||
func NewECBEncrypter(b cipher.Block) cipher.BlockMode {
|
||||
return &ecbEncrypter{
|
||||
b: b,
|
||||
blockSize: b.BlockSize(),
|
||||
}
|
||||
}
|
||||
func (x *ecbEncrypter) BlockSize() int { return x.blockSize }
|
||||
|
||||
func (x *ecbEncrypter) CryptBlocks(dst, src []byte) {
|
||||
if len(src)%x.blockSize != 0 {
|
||||
panic("crypto/cipher: input not full blocks")
|
||||
}
|
||||
if len(dst) < len(src) {
|
||||
panic("crypto/cipher: output smaller than input")
|
||||
}
|
||||
for len(src) > 0 {
|
||||
x.b.Encrypt(dst, src[:x.blockSize])
|
||||
src = src[x.blockSize:]
|
||||
dst = dst[x.blockSize:]
|
||||
}
|
||||
}
|
||||
50
platform/yapingtech/types.go
Normal file
50
platform/yapingtech/types.go
Normal file
@ -0,0 +1,50 @@
|
||||
package yapingtech
|
||||
|
||||
type QueryOrderListRequest struct {
|
||||
Page int64 `json:"page"` // 分页
|
||||
OutOrderSn string `json:"out_order_sn"` //传入亚平科技的订单ID,多个订单号可以使用逗号【,】最大20个订单号。请求会有频次限制,每1秒最多5次,超过之后会禁止访问1小时
|
||||
Type string `json:"type"` //查询下级合伙人订单,proxy
|
||||
}
|
||||
|
||||
type QueryOrderListResponse struct {
|
||||
Success bool `json:"success"`
|
||||
Message string `json:"message"`
|
||||
Code int64 `json:"code"`
|
||||
Data struct {
|
||||
Items []*QueryOrderListItem `json:"items"`
|
||||
PageInfo struct {
|
||||
Total int64 `json:"total"`
|
||||
CurrentPage int64 `json:"currentPage"`
|
||||
TotalPage int64 `json:"totalPage"`
|
||||
} `json:"pageInfo"`
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
type QueryOrderListItem struct {
|
||||
OrderSn string `json:"order_sn"` //自己的ID
|
||||
OutOrderSn string `json:"out_order_sn"` //亚平科技订单ID
|
||||
Number string `json:"number"` //开卡号码
|
||||
Status int64 `json:"status"` //订单状态,1为开卡中,2为已发货,3为已充值,4为失败
|
||||
StatusText string `json:"status_text"` //订单状态描述
|
||||
IsActivated int64 `json:"is_activated"` //是否激活 1为激活,0为未激活
|
||||
ActivatedAt string `json:"activated_at"` //激活时间
|
||||
IsRecharged int64 `json:"is_recharged"` //是否首充 1为首充,0为未首充
|
||||
RechargedAt string `json:"recharged_at"` //首充时间 yyyy-mm-dd hh-mm-ss
|
||||
RechargedAmount int64 `json:"recharged_amount"` //充值金额
|
||||
ExpressName string `json:"express_name"` //物流公司
|
||||
ExpressSn string `json:"express_sn"` //物流单号
|
||||
Reason string `json:"reason"` //失败原因/生产备注
|
||||
ProductName string `json:"product_name"` //产品名称
|
||||
ProductId int64 `json:"product_id"` //产品ID
|
||||
UpdateTime string `json:"update_time"` //订单更新时间
|
||||
CreateTime string `json:"create_time"` //订单创建时间
|
||||
Name string `json:"name"` //开卡人姓名
|
||||
IdCard string `json:"id_card"` //开发人身份证号
|
||||
Phone string `json:"phone"` //开卡人电话
|
||||
Province string `json:"province"` //省
|
||||
City string `json:"city"` //市
|
||||
District string `json:"district"` //区
|
||||
Address string `json:"address"` //完整地址
|
||||
Channel string `json:"channel"` //渠道 sid
|
||||
ShortUrl string `json:"short_url"` //上传三证链接
|
||||
}
|
||||
33
platform/youpiaopiao/api.go
Normal file
33
platform/youpiaopiao/api.go
Normal file
@ -0,0 +1,33 @@
|
||||
package youpiaopiao
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
// YouPiaoPiaoApi 有票票
|
||||
type YouPiaoPiaoApi interface {
|
||||
// GenerateH5Url 生成H5链接
|
||||
GenerateH5Url(ctx context.Context, req GenerateH5UrlRequest) (string, error)
|
||||
}
|
||||
type youpiaopiaoApiImpl struct {
|
||||
log logx.Logger
|
||||
client *Client
|
||||
}
|
||||
|
||||
func newYoupiaopiaoApiImpl(log logx.Logger, client *Client) YouPiaoPiaoApi {
|
||||
return &youpiaopiaoApiImpl{
|
||||
log: log,
|
||||
client: client,
|
||||
}
|
||||
}
|
||||
|
||||
// GenerateH5Url 生成H5推广链接
|
||||
func (a *youpiaopiaoApiImpl) GenerateH5Url(ctx context.Context, req GenerateH5UrlRequest) (string, error) {
|
||||
if len(req.ActivityUrl) == 0 {
|
||||
return "", errors.New("url参数不能为空")
|
||||
}
|
||||
return fmt.Sprintf("%s&entpara=%s", req.ActivityUrl, req.Sid), nil
|
||||
}
|
||||
45
platform/youpiaopiao/api_test.go
Normal file
45
platform/youpiaopiao/api_test.go
Normal file
@ -0,0 +1,45 @@
|
||||
package youpiaopiao
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// api-单元测试
|
||||
type apiClientSuite struct {
|
||||
suite.Suite
|
||||
api YouPiaoPiaoApi
|
||||
}
|
||||
|
||||
func TestApiClient(t *testing.T) {
|
||||
suite.Run(t, new(apiClientSuite))
|
||||
}
|
||||
|
||||
func (a *apiClientSuite) SetupSuite() {
|
||||
log := logx.WithContext(context.Background())
|
||||
apiClient := NewApiClient(log, AuthConfig{
|
||||
ApiKey: "", //
|
||||
})
|
||||
a.api = apiClient
|
||||
}
|
||||
|
||||
func (a *apiClientSuite) Test_GenerateLink() {
|
||||
req := GenerateH5UrlRequest{
|
||||
ActivityUrl: "",
|
||||
Sid: "f3a8c1",
|
||||
}
|
||||
result, err := a.api.GenerateH5Url(context.Background(), req)
|
||||
if !a.NoError(err) {
|
||||
a.T().Errorf("========[Test_GenerateLink] response error:%s", err)
|
||||
return
|
||||
}
|
||||
resultByte, err := json.Marshal(result)
|
||||
if err != nil {
|
||||
a.T().Errorf("========[Test_GenerateLink] json_marshal error:%s", err)
|
||||
return
|
||||
}
|
||||
a.T().Logf("=====[Test_GenerateLink] result: %s", string(resultByte))
|
||||
}
|
||||
36
platform/youpiaopiao/client.go
Normal file
36
platform/youpiaopiao/client.go
Normal file
@ -0,0 +1,36 @@
|
||||
package youpiaopiao
|
||||
|
||||
import (
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/client"
|
||||
)
|
||||
|
||||
// AuthConfig api鉴权参数
|
||||
type AuthConfig struct {
|
||||
ApiKey string // api key
|
||||
AppSecret string // api secret
|
||||
}
|
||||
|
||||
// 连接第三方平台的client
|
||||
type Client struct {
|
||||
log logx.Logger
|
||||
authConfig AuthConfig
|
||||
client.HttpClient
|
||||
headers map[string]string
|
||||
}
|
||||
|
||||
func NewApiClient(log logx.Logger, conf AuthConfig) YouPiaoPiaoApi {
|
||||
clt := newClient(log, conf)
|
||||
return newYoupiaopiaoApiImpl(log, clt)
|
||||
}
|
||||
|
||||
func newClient(log logx.Logger, conf AuthConfig) *Client {
|
||||
return &Client{
|
||||
log: log,
|
||||
authConfig: conf,
|
||||
HttpClient: client.NewHttpClient(log),
|
||||
headers: map[string]string{
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
}
|
||||
}
|
||||
14
platform/youpiaopiao/consts.go
Normal file
14
platform/youpiaopiao/consts.go
Normal file
@ -0,0 +1,14 @@
|
||||
package youpiaopiao
|
||||
|
||||
// 相关地址
|
||||
const (
|
||||
SiteDomain = "https://www.youpiaopiao.cn" // Domain 后台域名
|
||||
SiteUrl = "https://www.youpiaopiao.cn" // SiteUrl 后台地址
|
||||
DocUrl = "https://www.youpiaopiao.cn" // DocUrl 文档地址
|
||||
ApiDocUrl = "https://www.youpiaopiao.cn" // ApiDocUrl api文档地址
|
||||
)
|
||||
|
||||
// 接口地址
|
||||
const (
|
||||
ApiDomain = "https://www.youpiaopiao.cn" // Domain api域名
|
||||
)
|
||||
7
platform/youpiaopiao/types.go
Normal file
7
platform/youpiaopiao/types.go
Normal file
@ -0,0 +1,7 @@
|
||||
package youpiaopiao
|
||||
|
||||
// GenerateH5UrlRequest 生成H5链接请求
|
||||
type GenerateH5UrlRequest struct {
|
||||
ActivityUrl string `json:"activityUrl"` // 活动url
|
||||
Sid string `json:"sid"` // 二级分销ID
|
||||
}
|
||||
61
platform/zhetaoke/api.go
Normal file
61
platform/zhetaoke/api.go
Normal file
@ -0,0 +1,61 @@
|
||||
package zhetaoke
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/client"
|
||||
)
|
||||
|
||||
// ZheTaoKeApi 折淘客
|
||||
type ZheTaoKeApi interface {
|
||||
// PromotionLink 转链
|
||||
PromotionLink(PromotionLinkRequest) (*PromotionLinkResponse, error)
|
||||
}
|
||||
|
||||
type zheTaoKeApiImpl struct {
|
||||
log logx.Logger
|
||||
client *Client
|
||||
}
|
||||
|
||||
func newZheTaoKeApiImpl(log logx.Logger, client *Client) ZheTaoKeApi {
|
||||
return &zheTaoKeApiImpl{
|
||||
log: log,
|
||||
client: client,
|
||||
}
|
||||
}
|
||||
|
||||
// 转链
|
||||
func (z *zheTaoKeApiImpl) PromotionLink(req PromotionLinkRequest) (*PromotionLinkResponse, error) {
|
||||
params := map[string]any{
|
||||
"appkey": z.client.authConfig.AppKey,
|
||||
"unionId": z.client.authConfig.UnionId,
|
||||
"materialId": req.MaterialId,
|
||||
"chainType": req.ChainType,
|
||||
"positionId": req.PositionId,
|
||||
}
|
||||
|
||||
request := &client.HttpRequest{Headers: z.client.headers, QueryArgs: params}
|
||||
response := new(JdUnionOpenPromotionByunionidGetResponse)
|
||||
if err := z.client.HttpPost(PromotionLinkUrl, request, &client.HttpResponse{Result: response}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if response == nil {
|
||||
return nil, nil
|
||||
}
|
||||
if response.Content != "" {
|
||||
return nil, fmt.Errorf("折淘客-京东联盟 转链接口失败:[%d]%s", response.Status, response.Content)
|
||||
}
|
||||
if response.JdUnionOpenPromotionByunionidGetResponse == nil {
|
||||
return nil, nil
|
||||
}
|
||||
if response.JdUnionOpenPromotionByunionidGetResponse.Result == "" {
|
||||
return nil, nil
|
||||
}
|
||||
resp := new(PromotionLinkResponse)
|
||||
err := json.Unmarshal([]byte(response.JdUnionOpenPromotionByunionidGetResponse.Result), &resp)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("折淘客-京东联盟 转链接口响应结果解析失败,错误信息:%s", err.Error())
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
48
platform/zhetaoke/api_test.go
Normal file
48
platform/zhetaoke/api_test.go
Normal file
@ -0,0 +1,48 @@
|
||||
package zhetaoke
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
// api-单元测试
|
||||
type apiClientSuite struct {
|
||||
suite.Suite
|
||||
api ZheTaoKeApi
|
||||
}
|
||||
|
||||
func TestApiClient(t *testing.T) {
|
||||
suite.Run(t, new(apiClientSuite))
|
||||
}
|
||||
|
||||
func (a *apiClientSuite) SetupSuite() {
|
||||
log := logx.WithContext(context.Background())
|
||||
apiClient := NewApiClient(log, AuthConfig{
|
||||
AppKey: "de6307e7af054f69bd2506696d96e47d",
|
||||
UnionId: "2036695914",
|
||||
})
|
||||
a.api = apiClient
|
||||
}
|
||||
|
||||
func (a *apiClientSuite) Test_PromotionLink() {
|
||||
data := PromotionLinkRequest{
|
||||
MaterialId: "https://u.jd.com/rGc3TeA", //推广物料url,例如活动链接、商品链接等;支持仅传入skuid
|
||||
PositionId: 10001100040, //自定义推广位id,自定义的数字,自己在本地跟用户做好关联,订单中会透出自定义的数字
|
||||
ChainType: 3, // 转链类型,1:长链, 2 :短链 ,3: 长链+短链,默认短链,短链有效期60天
|
||||
}
|
||||
resp, err := a.api.PromotionLink(data)
|
||||
if err != nil {
|
||||
a.T().Errorf("=====[Test_PromotionLink] err: %v", err)
|
||||
}
|
||||
a.T().Logf("=====[Test_PromotionLink] resp: %+v, err: %v", resp, err)
|
||||
if resp != nil {
|
||||
va, _ := json.Marshal(resp.Data)
|
||||
fmt.Println(string(va))
|
||||
}
|
||||
|
||||
}
|
||||
37
platform/zhetaoke/client.go
Normal file
37
platform/zhetaoke/client.go
Normal file
@ -0,0 +1,37 @@
|
||||
package zhetaoke
|
||||
|
||||
import (
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/client"
|
||||
)
|
||||
|
||||
// AuthConfig api鉴权参数
|
||||
type AuthConfig struct {
|
||||
UnionId string
|
||||
AppKey string
|
||||
}
|
||||
|
||||
// 连接第三方平台的client
|
||||
type Client struct {
|
||||
log logx.Logger
|
||||
authConfig AuthConfig
|
||||
client.HttpClient
|
||||
headers map[string]string
|
||||
}
|
||||
|
||||
func NewApiClient(log logx.Logger, conf AuthConfig) ZheTaoKeApi {
|
||||
clt := newClient(log, conf)
|
||||
return newZheTaoKeApiImpl(log, clt)
|
||||
}
|
||||
|
||||
func newClient(log logx.Logger, conf AuthConfig) *Client {
|
||||
return &Client{
|
||||
log: log,
|
||||
authConfig: conf,
|
||||
HttpClient: client.NewHttpClient(log),
|
||||
headers: map[string]string{
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
}
|
||||
}
|
||||
5
platform/zhetaoke/consts.go
Normal file
5
platform/zhetaoke/consts.go
Normal file
@ -0,0 +1,5 @@
|
||||
package zhetaoke
|
||||
|
||||
const (
|
||||
PromotionLinkUrl = "http://api.zhetaoke.com:20000/api/open_jing_union_open_promotion_byunionid_get.ashx"
|
||||
)
|
||||
30
platform/zhetaoke/types.go
Normal file
30
platform/zhetaoke/types.go
Normal file
@ -0,0 +1,30 @@
|
||||
package zhetaoke
|
||||
|
||||
type PromotionLinkRequest struct {
|
||||
MaterialId string `json:"materialId"` //推广物料url,例如活动链接、商品链接等;支持仅传入skuid
|
||||
PositionId int64 `json:"positionId"` //自定义推广位id,自定义的数字,自己在本地跟用户做好关联,订单中会透出自定义的数字
|
||||
SubUnionId string `json:"subUnionId"` //子渠道标识 暂时没用 需要申请权限
|
||||
ChainType int64 `json:"chainType"` // 转链类型,1:长链, 2 :短链 ,3: 长链+短链,默认短链,短链有效期60天
|
||||
}
|
||||
|
||||
type PromotionLinkResponse struct {
|
||||
Code int64 `json:"code"` //200为成功,其他失败
|
||||
Data *PromotionLink `json:"data"`
|
||||
Message string `json:"message"`
|
||||
RequestId string `json:"request_id"`
|
||||
}
|
||||
type PromotionLink struct {
|
||||
ShortURL string `json:"shortUrl"` //短链
|
||||
ClickURL string `json:"clickUrl"` //长链接
|
||||
JCommand string `json:"jCommand"` //口令
|
||||
}
|
||||
type JdUnionOpenPromotionByunionidGetResponse struct {
|
||||
JdUnionOpenPromotionByunionidGetResponse *JdUnionOpenPromotionByunionidGet `json:"jd_union_open_promotion_byunionid_get_response"`
|
||||
Status int64 `json:"status"`
|
||||
Content string `json:"content"`
|
||||
}
|
||||
|
||||
type JdUnionOpenPromotionByunionidGet struct {
|
||||
Code string `json:"code"`
|
||||
Result string `json:"result"`
|
||||
}
|
||||
73
platform/zjdg/api.go
Normal file
73
platform/zjdg/api.go
Normal file
@ -0,0 +1,73 @@
|
||||
package zjdg
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"net/url"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/client"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/util"
|
||||
)
|
||||
|
||||
// ZjdgApi 中捷乐淘-淘宝一分购
|
||||
type ZjdgApi interface {
|
||||
// ZoneAdd 获取推广编号-创建
|
||||
ZoneAdd(ctx context.Context, req ZoneAddRequest) (*ZoneAddResponse, error)
|
||||
// GenerateH5Url 生成H5链接
|
||||
GenerateH5Url(ctx context.Context, req GenerateH5UrlRequest) (string, error)
|
||||
}
|
||||
type zjdgApiImpl struct {
|
||||
log logx.Logger
|
||||
client *Client
|
||||
}
|
||||
|
||||
func newZjdgApiImpl(log logx.Logger, client *Client) ZjdgApi {
|
||||
return &zjdgApiImpl{
|
||||
log: log,
|
||||
client: client,
|
||||
}
|
||||
}
|
||||
|
||||
// ZoneAdd 获取推广编号
|
||||
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)
|
||||
request := &client.HttpRequest{Headers: a.client.headers, QueryArgs: args}
|
||||
response := new(ZoneAddOriginResponse)
|
||||
if err := a.client.HttpGet(zoneAddUrl, request, &client.HttpResponse{Result: response}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if response.Code != 0 {
|
||||
return nil, fmt.Errorf("获取推广编号失败,返回Code=%d", response.Code)
|
||||
}
|
||||
return &ZoneAddResponse{
|
||||
AdZoneId: response.Data,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (a *zjdgApiImpl) GenerateH5Url(ctx context.Context, req GenerateH5UrlRequest) (string, error) {
|
||||
u, err := url.Parse(req.ActivityUrl)
|
||||
if err != nil {
|
||||
return "", errors.New("activityUrl不是一个url")
|
||||
}
|
||||
urlParams := u.Query()
|
||||
for key, item := range urlParams {
|
||||
if key == "adzoneid" {
|
||||
urlParams.Set("adzoneid", req.Sid)
|
||||
} else if key == "userid" {
|
||||
urlParams.Set("userid", a.client.authConfig.UserId)
|
||||
} else {
|
||||
if len(item) > 0 {
|
||||
urlParams.Set(key, item[0])
|
||||
} else {
|
||||
urlParams.Set(key, "")
|
||||
}
|
||||
}
|
||||
fmt.Println(fmt.Sprintf("key=%s,val=%s,len=%d", key, item, len(item)))
|
||||
}
|
||||
u.RawQuery = urlParams.Encode()
|
||||
|
||||
return u.String(), nil
|
||||
}
|
||||
56
platform/zjdg/api_test.go
Normal file
56
platform/zjdg/api_test.go
Normal file
@ -0,0 +1,56 @@
|
||||
package zjdg
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// api-单元测试
|
||||
type apiClientSuite struct {
|
||||
suite.Suite
|
||||
api ZjdgApi
|
||||
}
|
||||
|
||||
func TestApiClient(t *testing.T) {
|
||||
suite.Run(t, new(apiClientSuite))
|
||||
}
|
||||
|
||||
func (a *apiClientSuite) SetupSuite() {
|
||||
log := logx.WithContext(context.Background())
|
||||
apiClient := NewApiClient(log, AuthConfig{
|
||||
UserId: "", //
|
||||
})
|
||||
a.api = apiClient
|
||||
}
|
||||
|
||||
func (a *apiClientSuite) Test_ZoneAdd() {
|
||||
req := ZoneAddRequest{}
|
||||
result, err := a.api.ZoneAdd(context.Background(), req)
|
||||
if !a.NoError(err) {
|
||||
a.T().Errorf("========[Test_ZoneAdd] response error:%s", err)
|
||||
return
|
||||
}
|
||||
resultByte, err := json.Marshal(result)
|
||||
if err != nil {
|
||||
a.T().Errorf("========[Test_ZoneAdd] json_marshal error:%s", err)
|
||||
return
|
||||
}
|
||||
a.T().Logf("=====[Test_ZoneAdd] result: %s", string(resultByte))
|
||||
}
|
||||
|
||||
func (a *apiClientSuite) Test_GenerateH5Url() {
|
||||
req := GenerateH5UrlRequest{
|
||||
ActivityUrl: PromotionUrl,
|
||||
Sid: "1963667",
|
||||
}
|
||||
result, err := a.api.GenerateH5Url(context.Background(), req)
|
||||
if !a.NoError(err) {
|
||||
a.T().Errorf("========[Test_GenerateH5Url] response error:%s", err)
|
||||
return
|
||||
}
|
||||
|
||||
a.T().Logf("=====[Test_GenerateH5Url] result: %s", result)
|
||||
}
|
||||
35
platform/zjdg/client.go
Normal file
35
platform/zjdg/client.go
Normal file
@ -0,0 +1,35 @@
|
||||
package zjdg
|
||||
|
||||
import (
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/client"
|
||||
)
|
||||
|
||||
// AuthConfig api鉴权参数
|
||||
type AuthConfig struct {
|
||||
UserId string //推广用户编号
|
||||
}
|
||||
|
||||
// 连接第三方平台的client
|
||||
type Client struct {
|
||||
log logx.Logger
|
||||
authConfig AuthConfig
|
||||
client.HttpClient
|
||||
headers map[string]string
|
||||
}
|
||||
|
||||
func NewApiClient(log logx.Logger, conf AuthConfig) ZjdgApi {
|
||||
clt := newClient(log, conf)
|
||||
return newZjdgApiImpl(log, clt)
|
||||
}
|
||||
|
||||
func newClient(log logx.Logger, conf AuthConfig) *Client {
|
||||
return &Client{
|
||||
log: log,
|
||||
authConfig: conf,
|
||||
HttpClient: client.NewHttpClient(log),
|
||||
headers: map[string]string{
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
}
|
||||
}
|
||||
6
platform/zjdg/consts.go
Normal file
6
platform/zjdg/consts.go
Normal file
@ -0,0 +1,6 @@
|
||||
package zjdg
|
||||
|
||||
const (
|
||||
ZoneAddUrl = "https://p.zjdg.cn/cpa/api/ugApi.ashx?method=getadzone_nologin&userid="
|
||||
PromotionUrl = "http://2025.zjdg.cn/ditui/qrcode?adzoneid=&userid="
|
||||
)
|
||||
20
platform/zjdg/types.go
Normal file
20
platform/zjdg/types.go
Normal file
@ -0,0 +1,20 @@
|
||||
package zjdg
|
||||
|
||||
// GenerateH5UrlRequest 生成H5链接请求
|
||||
type GenerateH5UrlRequest struct {
|
||||
ActivityUrl string `json:"activityUrl"` // 活动url
|
||||
Sid string `json:"sid"` // 二级分销ID
|
||||
}
|
||||
|
||||
type ZoneAddRequest struct {
|
||||
}
|
||||
type ZoneAddResponse struct {
|
||||
AdZoneId string `json:"ad_zone_id"` //推广编号
|
||||
}
|
||||
|
||||
type ZoneAddOriginResponse struct {
|
||||
Code int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
Data string `json:"data"`
|
||||
TokenId string `json:"token_id"`
|
||||
}
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
引入mod
|
||||
```
|
||||
go get gitee.com/chengdu-lenntc/third-platform-sdk/sdk/dunion-go-sdk@master
|
||||
go get repository.lenntc.com/lenntc/third-platform-sdk/sdk/dunion-go-sdk@master
|
||||
```
|
||||
使用方法
|
||||
```
|
||||
|
||||
@ -6,9 +6,9 @@ import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/sdk/dunion-go-sdk/const"
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/sdk/dunion-go-sdk/model"
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/sdk/dunion-go-sdk/util"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/dunion-go-sdk/const"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/dunion-go-sdk/model"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/dunion-go-sdk/util"
|
||||
)
|
||||
|
||||
type client struct {
|
||||
|
||||
@ -11,7 +11,7 @@ type ResponseOrderItem struct {
|
||||
// `393`: 滴滴货运<br>
|
||||
// `500`: 花小猪<br>
|
||||
// `120`: 滴滴代驾
|
||||
ProductId int64 `json:"product_id"`
|
||||
ProductId string `json:"product_id"`
|
||||
// 支付时间
|
||||
PayTime int64 `json:"pay_time"`
|
||||
// 支付金额,单位:分
|
||||
@ -30,7 +30,7 @@ type ResponseOrderItem struct {
|
||||
// 推送状态: 1.已预估归因 2.预估订单已推送 3.预估订单推送失败 4.结算已提交 5.结算提交中 6.结算取消 7.结算成功 8.结算失败
|
||||
Status int `json:"status"`
|
||||
// 推广位ID
|
||||
PromotionId int `json:"promotion_id"`
|
||||
PromotionId string `json:"promotion_id"`
|
||||
// 来源ID
|
||||
SourceId string `json:"source_id"`
|
||||
// 是否被风控
|
||||
|
||||
@ -10,8 +10,8 @@ import (
|
||||
netUrl "net/url"
|
||||
"time"
|
||||
|
||||
consts "gitee.com/chengdu-lenntc/third-platform-sdk/sdk/dunion-go-sdk/const"
|
||||
"gitee.com/chengdu-lenntc/third-platform-sdk/sdk/dunion-go-sdk/model"
|
||||
consts "repository.lenntc.com/lenntc/third-platform-sdk/sdk/dunion-go-sdk/const"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/dunion-go-sdk/model"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
198
sdk/fliggysdk/ability132/Ability132.go
Normal file
198
sdk/fliggysdk/ability132/Ability132.go
Normal file
@ -0,0 +1,198 @@
|
||||
package ability132
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"log"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/fliggysdk"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/fliggysdk/ability132/request"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/fliggysdk/ability132/response"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/fliggysdk/util"
|
||||
)
|
||||
|
||||
type Ability132 struct {
|
||||
Client *fliggysdk.TopClient
|
||||
}
|
||||
|
||||
func NewAbility132(client *fliggysdk.TopClient) *Ability132 {
|
||||
return &Ability132{client}
|
||||
}
|
||||
|
||||
/*
|
||||
删除消息topic分组路由
|
||||
*/
|
||||
func (ability *Ability132) TaobaoTmcTopicGroupDelete(req *request.TaobaoTmcTopicGroupDeleteRequest) (*response.TaobaoTmcTopicGroupDeleteResponse, error) {
|
||||
if ability.Client == nil {
|
||||
return nil, errors.New("Ability132 topClient is nil")
|
||||
}
|
||||
var jsonStr, err = ability.Client.Execute("taobao.tmc.topic.group.delete", req.ToMap(), req.ToFileMap())
|
||||
var respStruct = response.TaobaoTmcTopicGroupDeleteResponse{}
|
||||
if err != nil {
|
||||
log.Println("taobaoTmcTopicGroupDelete error", err)
|
||||
return &respStruct, err
|
||||
}
|
||||
err = util.HandleJsonResponse(jsonStr, &respStruct)
|
||||
if respStruct.Body == "" || len(respStruct.Body) == 0 {
|
||||
respStruct.Body = jsonStr
|
||||
}
|
||||
return &respStruct, err
|
||||
}
|
||||
|
||||
/*
|
||||
点对点消息topic分组路由
|
||||
*/
|
||||
func (ability *Ability132) TaobaoTmcTopicGroupAdd(req *request.TaobaoTmcTopicGroupAddRequest) (*response.TaobaoTmcTopicGroupAddResponse, error) {
|
||||
if ability.Client == nil {
|
||||
return nil, errors.New("Ability132 topClient is nil")
|
||||
}
|
||||
var jsonStr, err = ability.Client.Execute("taobao.tmc.topic.group.add", req.ToMap(), req.ToFileMap())
|
||||
var respStruct = response.TaobaoTmcTopicGroupAddResponse{}
|
||||
if err != nil {
|
||||
log.Println("taobaoTmcTopicGroupAdd error", err)
|
||||
return &respStruct, err
|
||||
}
|
||||
err = util.HandleJsonResponse(jsonStr, &respStruct)
|
||||
if respStruct.Body == "" || len(respStruct.Body) == 0 {
|
||||
respStruct.Body = jsonStr
|
||||
}
|
||||
return &respStruct, err
|
||||
}
|
||||
|
||||
/*
|
||||
批量发送消息
|
||||
*/
|
||||
func (ability *Ability132) TaobaoTmcMessagesProduce(req *request.TaobaoTmcMessagesProduceRequest) (*response.TaobaoTmcMessagesProduceResponse, error) {
|
||||
if ability.Client == nil {
|
||||
return nil, errors.New("Ability132 topClient is nil")
|
||||
}
|
||||
var jsonStr, err = ability.Client.Execute("taobao.tmc.messages.produce", req.ToMap(), req.ToFileMap())
|
||||
var respStruct = response.TaobaoTmcMessagesProduceResponse{}
|
||||
if err != nil {
|
||||
log.Println("taobaoTmcMessagesProduce error", err)
|
||||
return &respStruct, err
|
||||
}
|
||||
err = util.HandleJsonResponse(jsonStr, &respStruct)
|
||||
if respStruct.Body == "" || len(respStruct.Body) == 0 {
|
||||
respStruct.Body = jsonStr
|
||||
}
|
||||
return &respStruct, err
|
||||
}
|
||||
|
||||
/*
|
||||
获取自定义用户分组列表
|
||||
*/
|
||||
func (ability *Ability132) TaobaoTmcGroupsGet(req *request.TaobaoTmcGroupsGetRequest) (*response.TaobaoTmcGroupsGetResponse, error) {
|
||||
if ability.Client == nil {
|
||||
return nil, errors.New("Ability132 topClient is nil")
|
||||
}
|
||||
var jsonStr, err = ability.Client.Execute("taobao.tmc.groups.get", req.ToMap(), req.ToFileMap())
|
||||
var respStruct = response.TaobaoTmcGroupsGetResponse{}
|
||||
if err != nil {
|
||||
log.Println("taobaoTmcGroupsGet error", err)
|
||||
return &respStruct, err
|
||||
}
|
||||
err = util.HandleJsonResponse(jsonStr, &respStruct)
|
||||
if respStruct.Body == "" || len(respStruct.Body) == 0 {
|
||||
respStruct.Body = jsonStr
|
||||
}
|
||||
return &respStruct, err
|
||||
}
|
||||
|
||||
/*
|
||||
删除指定的分组或分组下的用户
|
||||
*/
|
||||
func (ability *Ability132) TaobaoTmcGroupDelete(req *request.TaobaoTmcGroupDeleteRequest) (*response.TaobaoTmcGroupDeleteResponse, error) {
|
||||
if ability.Client == nil {
|
||||
return nil, errors.New("Ability132 topClient is nil")
|
||||
}
|
||||
var jsonStr, err = ability.Client.Execute("taobao.tmc.group.delete", req.ToMap(), req.ToFileMap())
|
||||
var respStruct = response.TaobaoTmcGroupDeleteResponse{}
|
||||
if err != nil {
|
||||
log.Println("taobaoTmcGroupDelete error", err)
|
||||
return &respStruct, err
|
||||
}
|
||||
err = util.HandleJsonResponse(jsonStr, &respStruct)
|
||||
if respStruct.Body == "" || len(respStruct.Body) == 0 {
|
||||
respStruct.Body = jsonStr
|
||||
}
|
||||
return &respStruct, err
|
||||
}
|
||||
|
||||
/*
|
||||
为已开通用户添加用户分组
|
||||
*/
|
||||
func (ability *Ability132) TaobaoTmcGroupAdd(req *request.TaobaoTmcGroupAddRequest) (*response.TaobaoTmcGroupAddResponse, error) {
|
||||
if ability.Client == nil {
|
||||
return nil, errors.New("Ability132 topClient is nil")
|
||||
}
|
||||
var jsonStr, err = ability.Client.Execute("taobao.tmc.group.add", req.ToMap(), req.ToFileMap())
|
||||
var respStruct = response.TaobaoTmcGroupAddResponse{}
|
||||
if err != nil {
|
||||
log.Println("taobaoTmcGroupAdd error", err)
|
||||
return &respStruct, err
|
||||
}
|
||||
err = util.HandleJsonResponse(jsonStr, &respStruct)
|
||||
if respStruct.Body == "" || len(respStruct.Body) == 0 {
|
||||
respStruct.Body = jsonStr
|
||||
}
|
||||
return &respStruct, err
|
||||
}
|
||||
|
||||
/*
|
||||
确认消费消息的状态
|
||||
*/
|
||||
func (ability *Ability132) TaobaoTmcMessagesConfirm(req *request.TaobaoTmcMessagesConfirmRequest) (*response.TaobaoTmcMessagesConfirmResponse, error) {
|
||||
if ability.Client == nil {
|
||||
return nil, errors.New("Ability132 topClient is nil")
|
||||
}
|
||||
var jsonStr, err = ability.Client.Execute("taobao.tmc.messages.confirm", req.ToMap(), req.ToFileMap())
|
||||
var respStruct = response.TaobaoTmcMessagesConfirmResponse{}
|
||||
if err != nil {
|
||||
log.Println("taobaoTmcMessagesConfirm error", err)
|
||||
return &respStruct, err
|
||||
}
|
||||
err = util.HandleJsonResponse(jsonStr, &respStruct)
|
||||
if respStruct.Body == "" || len(respStruct.Body) == 0 {
|
||||
respStruct.Body = jsonStr
|
||||
}
|
||||
return &respStruct, err
|
||||
}
|
||||
|
||||
/*
|
||||
消费多条消息
|
||||
*/
|
||||
func (ability *Ability132) TaobaoTmcMessagesConsume(req *request.TaobaoTmcMessagesConsumeRequest) (*response.TaobaoTmcMessagesConsumeResponse, error) {
|
||||
if ability.Client == nil {
|
||||
return nil, errors.New("Ability132 topClient is nil")
|
||||
}
|
||||
var jsonStr, err = ability.Client.Execute("taobao.tmc.messages.consume", req.ToMap(), req.ToFileMap())
|
||||
var respStruct = response.TaobaoTmcMessagesConsumeResponse{}
|
||||
if err != nil {
|
||||
log.Println("taobaoTmcMessagesConsume error", err)
|
||||
return &respStruct, err
|
||||
}
|
||||
err = util.HandleJsonResponse(jsonStr, &respStruct)
|
||||
if respStruct.Body == "" || len(respStruct.Body) == 0 {
|
||||
respStruct.Body = jsonStr
|
||||
}
|
||||
return &respStruct, err
|
||||
}
|
||||
|
||||
/*
|
||||
TMC授权token
|
||||
*/
|
||||
func (ability *Ability132) TaobaoTmcAuthGet(req *request.TaobaoTmcAuthGetRequest) (*response.TaobaoTmcAuthGetResponse, error) {
|
||||
if ability.Client == nil {
|
||||
return nil, errors.New("Ability132 topClient is nil")
|
||||
}
|
||||
var jsonStr, err = ability.Client.Execute("taobao.tmc.auth.get", req.ToMap(), req.ToFileMap())
|
||||
var respStruct = response.TaobaoTmcAuthGetResponse{}
|
||||
if err != nil {
|
||||
log.Println("taobaoTmcAuthGet error", err)
|
||||
return &respStruct, err
|
||||
}
|
||||
err = util.HandleJsonResponse(jsonStr, &respStruct)
|
||||
if respStruct.Body == "" || len(respStruct.Body) == 0 {
|
||||
respStruct.Body = jsonStr
|
||||
}
|
||||
return &respStruct, err
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
package domain
|
||||
|
||||
type TaobaoTmcGroupsGetTmcGroup struct {
|
||||
/*
|
||||
分组名称 */
|
||||
Name *string `json:"name,omitempty" `
|
||||
}
|
||||
|
||||
func (s *TaobaoTmcGroupsGetTmcGroup) SetName(v string) *TaobaoTmcGroupsGetTmcGroup {
|
||||
s.Name = &v
|
||||
return s
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
package domain
|
||||
|
||||
import (
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/fliggysdk/util"
|
||||
)
|
||||
|
||||
type TaobaoTmcMessagesConsumeTmcMessage struct {
|
||||
/*
|
||||
消息所属的用户编号 */
|
||||
UserId *int64 `json:"user_id,omitempty" `
|
||||
|
||||
/*
|
||||
用户的昵称 */
|
||||
UserNick *string `json:"user_nick,omitempty" `
|
||||
|
||||
/*
|
||||
消息详细内容,格式为JSON/XML */
|
||||
Content *string `json:"content,omitempty" `
|
||||
|
||||
/*
|
||||
消息ID */
|
||||
Id *int64 `json:"id,omitempty" `
|
||||
|
||||
/*
|
||||
消息发布时间 */
|
||||
PubTime *util.LocalTime `json:"pub_time,omitempty" `
|
||||
|
||||
/*
|
||||
消息发布者的AppKey */
|
||||
PubAppKey *string `json:"pub_app_key,omitempty" `
|
||||
|
||||
/*
|
||||
消息所属主题 */
|
||||
Topic *string `json:"topic,omitempty" `
|
||||
}
|
||||
|
||||
func (s *TaobaoTmcMessagesConsumeTmcMessage) SetUserId(v int64) *TaobaoTmcMessagesConsumeTmcMessage {
|
||||
s.UserId = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessagesConsumeTmcMessage) SetUserNick(v string) *TaobaoTmcMessagesConsumeTmcMessage {
|
||||
s.UserNick = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessagesConsumeTmcMessage) SetContent(v string) *TaobaoTmcMessagesConsumeTmcMessage {
|
||||
s.Content = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessagesConsumeTmcMessage) SetId(v int64) *TaobaoTmcMessagesConsumeTmcMessage {
|
||||
s.Id = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessagesConsumeTmcMessage) SetPubTime(v util.LocalTime) *TaobaoTmcMessagesConsumeTmcMessage {
|
||||
s.PubTime = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessagesConsumeTmcMessage) SetPubAppKey(v string) *TaobaoTmcMessagesConsumeTmcMessage {
|
||||
s.PubAppKey = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessagesConsumeTmcMessage) SetTopic(v string) *TaobaoTmcMessagesConsumeTmcMessage {
|
||||
s.Topic = &v
|
||||
return s
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
package domain
|
||||
|
||||
type TaobaoTmcMessagesProduceTmcProduceResult struct {
|
||||
/*
|
||||
错误码 */
|
||||
ErrorCode *string `json:"error_code,omitempty" `
|
||||
|
||||
/*
|
||||
错误信息 */
|
||||
ErrorMessage *string `json:"error_message,omitempty" `
|
||||
|
||||
/*
|
||||
是否成功 */
|
||||
IsSuccess *bool `json:"is_success,omitempty" `
|
||||
}
|
||||
|
||||
func (s *TaobaoTmcMessagesProduceTmcProduceResult) SetErrorCode(v string) *TaobaoTmcMessagesProduceTmcProduceResult {
|
||||
s.ErrorCode = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessagesProduceTmcProduceResult) SetErrorMessage(v string) *TaobaoTmcMessagesProduceTmcProduceResult {
|
||||
s.ErrorMessage = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessagesProduceTmcProduceResult) SetIsSuccess(v bool) *TaobaoTmcMessagesProduceTmcProduceResult {
|
||||
s.IsSuccess = &v
|
||||
return s
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
package domain
|
||||
|
||||
type TaobaoTmcMessagesProduceTmcPublishMessage struct {
|
||||
/*
|
||||
消息内容的JSON表述,必须按照topic的定义来填充 */
|
||||
Content *string `json:"content,omitempty" `
|
||||
|
||||
/*
|
||||
消息的扩增属性,用json格式表示 */
|
||||
JsonExContent *string `json:"json_ex_content,omitempty" `
|
||||
|
||||
/*
|
||||
直发消息需要传入目标appkey */
|
||||
TargetAppKey *string `json:"target_app_key,omitempty" `
|
||||
|
||||
/*
|
||||
目标分组 */
|
||||
TargetGroup *string `json:"target_group,omitempty" `
|
||||
|
||||
/*
|
||||
消息类型 */
|
||||
Topic *string `json:"topic,omitempty" `
|
||||
}
|
||||
|
||||
func (s *TaobaoTmcMessagesProduceTmcPublishMessage) SetContent(v string) *TaobaoTmcMessagesProduceTmcPublishMessage {
|
||||
s.Content = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessagesProduceTmcPublishMessage) SetJsonExContent(v string) *TaobaoTmcMessagesProduceTmcPublishMessage {
|
||||
s.JsonExContent = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessagesProduceTmcPublishMessage) SetTargetAppKey(v string) *TaobaoTmcMessagesProduceTmcPublishMessage {
|
||||
s.TargetAppKey = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessagesProduceTmcPublishMessage) SetTargetGroup(v string) *TaobaoTmcMessagesProduceTmcPublishMessage {
|
||||
s.TargetGroup = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessagesProduceTmcPublishMessage) SetTopic(v string) *TaobaoTmcMessagesProduceTmcPublishMessage {
|
||||
s.Topic = &v
|
||||
return s
|
||||
}
|
||||
25
sdk/fliggysdk/ability132/request/TaobaoTmcAuthGetRequest.go
Normal file
25
sdk/fliggysdk/ability132/request/TaobaoTmcAuthGetRequest.go
Normal file
@ -0,0 +1,25 @@
|
||||
package request
|
||||
|
||||
type TaobaoTmcAuthGetRequest struct {
|
||||
/*
|
||||
tmc组名 */
|
||||
Group *string `json:"group,omitempty" required:"false" `
|
||||
}
|
||||
|
||||
func (s *TaobaoTmcAuthGetRequest) SetGroup(v string) *TaobaoTmcAuthGetRequest {
|
||||
s.Group = &v
|
||||
return s
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcAuthGetRequest) ToMap() map[string]interface{} {
|
||||
paramMap := make(map[string]interface{})
|
||||
if req.Group != nil {
|
||||
paramMap["group"] = *req.Group
|
||||
}
|
||||
return paramMap
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcAuthGetRequest) ToFileMap() map[string]interface{} {
|
||||
fileMap := make(map[string]interface{})
|
||||
return fileMap
|
||||
}
|
||||
49
sdk/fliggysdk/ability132/request/TaobaoTmcGroupAddRequest.go
Normal file
49
sdk/fliggysdk/ability132/request/TaobaoTmcGroupAddRequest.go
Normal file
@ -0,0 +1,49 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/fliggysdk/util"
|
||||
)
|
||||
|
||||
type TaobaoTmcGroupAddRequest struct {
|
||||
/*
|
||||
分组名称,同一个应用下需要保证唯一性,最长32个字符。添加分组后,消息通道会为用户的消息分配独立分组,但之前的消息还是存储于默认分组中。不能以default开头,default开头为系统默认组。 */
|
||||
GroupName *string `json:"group_name" required:"true" `
|
||||
/*
|
||||
用户昵称列表,以半角逗号分隔,支持子账号,支持增量添加用户 */
|
||||
Nicks *[]string `json:"nicks" required:"true" `
|
||||
/*
|
||||
用户所属于的平台类型,tbUIC:淘宝用户; icbu: icbu用户;ae:ae用户 defalutValue<EFBFBD><EFBFBD>tbUIC */
|
||||
UserPlatform *string `json:"user_platform,omitempty" required:"false" `
|
||||
}
|
||||
|
||||
func (s *TaobaoTmcGroupAddRequest) SetGroupName(v string) *TaobaoTmcGroupAddRequest {
|
||||
s.GroupName = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcGroupAddRequest) SetNicks(v []string) *TaobaoTmcGroupAddRequest {
|
||||
s.Nicks = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcGroupAddRequest) SetUserPlatform(v string) *TaobaoTmcGroupAddRequest {
|
||||
s.UserPlatform = &v
|
||||
return s
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcGroupAddRequest) ToMap() map[string]interface{} {
|
||||
paramMap := make(map[string]interface{})
|
||||
if req.GroupName != nil {
|
||||
paramMap["group_name"] = *req.GroupName
|
||||
}
|
||||
if req.Nicks != nil {
|
||||
paramMap["nicks"] = util.ConvertBasicList(*req.Nicks)
|
||||
}
|
||||
if req.UserPlatform != nil {
|
||||
paramMap["user_platform"] = *req.UserPlatform
|
||||
}
|
||||
return paramMap
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcGroupAddRequest) ToFileMap() map[string]interface{} {
|
||||
fileMap := make(map[string]interface{})
|
||||
return fileMap
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/fliggysdk/util"
|
||||
)
|
||||
|
||||
type TaobaoTmcGroupDeleteRequest struct {
|
||||
/*
|
||||
分组名称,分组删除后,用户的消息将会存储于默认分组中。警告:由于分组已经删除,用户之前未消费的消息将无法再获取。不能以default开头,default开头为系统默认组。 */
|
||||
GroupName *string `json:"group_name" required:"true" `
|
||||
/*
|
||||
用户列表,不传表示删除整个分组,如果用户全部删除后,也会自动删除整个分组 */
|
||||
Nicks *[]string `json:"nicks,omitempty" required:"false" `
|
||||
/*
|
||||
用户所属于的平台类型,tbUIC:淘宝用户; icbu: icbu用户;ae:ae用户 defalutValue<EFBFBD><EFBFBD>tbUIC */
|
||||
UserPlatform *string `json:"user_platform,omitempty" required:"false" `
|
||||
}
|
||||
|
||||
func (s *TaobaoTmcGroupDeleteRequest) SetGroupName(v string) *TaobaoTmcGroupDeleteRequest {
|
||||
s.GroupName = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcGroupDeleteRequest) SetNicks(v []string) *TaobaoTmcGroupDeleteRequest {
|
||||
s.Nicks = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcGroupDeleteRequest) SetUserPlatform(v string) *TaobaoTmcGroupDeleteRequest {
|
||||
s.UserPlatform = &v
|
||||
return s
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcGroupDeleteRequest) ToMap() map[string]interface{} {
|
||||
paramMap := make(map[string]interface{})
|
||||
if req.GroupName != nil {
|
||||
paramMap["group_name"] = *req.GroupName
|
||||
}
|
||||
if req.Nicks != nil {
|
||||
paramMap["nicks"] = util.ConvertBasicList(*req.Nicks)
|
||||
}
|
||||
if req.UserPlatform != nil {
|
||||
paramMap["user_platform"] = *req.UserPlatform
|
||||
}
|
||||
return paramMap
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcGroupDeleteRequest) ToFileMap() map[string]interface{} {
|
||||
fileMap := make(map[string]interface{})
|
||||
return fileMap
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/fliggysdk/util"
|
||||
)
|
||||
|
||||
type TaobaoTmcGroupsGetRequest struct {
|
||||
/*
|
||||
要查询分组的名称,多个分组用半角逗号分隔,不传代表查询所有分组信息,但不会返回组下面的用户信息。如果应用没有设置分组则返回空。组名不能以default开头,default开头是系统默认的组。 */
|
||||
GroupNames *[]string `json:"group_names,omitempty" required:"false" `
|
||||
/*
|
||||
页码 defalutValue<EFBFBD><EFBFBD>1 */
|
||||
PageNo *int64 `json:"page_no,omitempty" required:"false" `
|
||||
/*
|
||||
每页返回多少个分组 defalutValue<EFBFBD><EFBFBD>40 */
|
||||
PageSize *int64 `json:"page_size,omitempty" required:"false" `
|
||||
}
|
||||
|
||||
func (s *TaobaoTmcGroupsGetRequest) SetGroupNames(v []string) *TaobaoTmcGroupsGetRequest {
|
||||
s.GroupNames = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcGroupsGetRequest) SetPageNo(v int64) *TaobaoTmcGroupsGetRequest {
|
||||
s.PageNo = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcGroupsGetRequest) SetPageSize(v int64) *TaobaoTmcGroupsGetRequest {
|
||||
s.PageSize = &v
|
||||
return s
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcGroupsGetRequest) ToMap() map[string]interface{} {
|
||||
paramMap := make(map[string]interface{})
|
||||
if req.GroupNames != nil {
|
||||
paramMap["group_names"] = util.ConvertBasicList(*req.GroupNames)
|
||||
}
|
||||
if req.PageNo != nil {
|
||||
paramMap["page_no"] = *req.PageNo
|
||||
}
|
||||
if req.PageSize != nil {
|
||||
paramMap["page_size"] = *req.PageSize
|
||||
}
|
||||
return paramMap
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcGroupsGetRequest) ToFileMap() map[string]interface{} {
|
||||
fileMap := make(map[string]interface{})
|
||||
return fileMap
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/fliggysdk/util"
|
||||
)
|
||||
|
||||
type TaobaoTmcMessagesConfirmRequest struct {
|
||||
/*
|
||||
分组名称,不传代表默认分组 */
|
||||
GroupName *string `json:"group_name,omitempty" required:"false" `
|
||||
/*
|
||||
处理成功的消息ID列表 最大 200个ID */
|
||||
SMessageIds *[]int64 `json:"s_message_ids" required:"true" `
|
||||
/*
|
||||
处理失败的消息ID列表--已废弃,无需传此字段 */
|
||||
FMessageIds *[]int64 `json:"f_message_ids,omitempty" required:"false" `
|
||||
}
|
||||
|
||||
func (s *TaobaoTmcMessagesConfirmRequest) SetGroupName(v string) *TaobaoTmcMessagesConfirmRequest {
|
||||
s.GroupName = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessagesConfirmRequest) SetSMessageIds(v []int64) *TaobaoTmcMessagesConfirmRequest {
|
||||
s.SMessageIds = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessagesConfirmRequest) SetFMessageIds(v []int64) *TaobaoTmcMessagesConfirmRequest {
|
||||
s.FMessageIds = &v
|
||||
return s
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcMessagesConfirmRequest) ToMap() map[string]interface{} {
|
||||
paramMap := make(map[string]interface{})
|
||||
if req.GroupName != nil {
|
||||
paramMap["group_name"] = *req.GroupName
|
||||
}
|
||||
if req.SMessageIds != nil {
|
||||
paramMap["s_message_ids"] = util.ConvertBasicList(*req.SMessageIds)
|
||||
}
|
||||
if req.FMessageIds != nil {
|
||||
paramMap["f_message_ids"] = util.ConvertBasicList(*req.FMessageIds)
|
||||
}
|
||||
return paramMap
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcMessagesConfirmRequest) ToFileMap() map[string]interface{} {
|
||||
fileMap := make(map[string]interface{})
|
||||
return fileMap
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
package request
|
||||
|
||||
type TaobaoTmcMessagesConsumeRequest struct {
|
||||
/*
|
||||
用户分组名称,不传表示消费默认分组,如果应用没有设置用户分组,传入分组名称将会返回错误 */
|
||||
GroupName *string `json:"group_name,omitempty" required:"false" `
|
||||
/*
|
||||
每次批量消费消息的条数,最小值:10;最大值:200 defalutValue<EFBFBD><EFBFBD>100 */
|
||||
Quantity *int64 `json:"quantity,omitempty" required:"false" `
|
||||
}
|
||||
|
||||
func (s *TaobaoTmcMessagesConsumeRequest) SetGroupName(v string) *TaobaoTmcMessagesConsumeRequest {
|
||||
s.GroupName = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcMessagesConsumeRequest) SetQuantity(v int64) *TaobaoTmcMessagesConsumeRequest {
|
||||
s.Quantity = &v
|
||||
return s
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcMessagesConsumeRequest) ToMap() map[string]interface{} {
|
||||
paramMap := make(map[string]interface{})
|
||||
if req.GroupName != nil {
|
||||
paramMap["group_name"] = *req.GroupName
|
||||
}
|
||||
if req.Quantity != nil {
|
||||
paramMap["quantity"] = *req.Quantity
|
||||
}
|
||||
return paramMap
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcMessagesConsumeRequest) ToFileMap() map[string]interface{} {
|
||||
fileMap := make(map[string]interface{})
|
||||
return fileMap
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/fliggysdk/ability132/domain"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/fliggysdk/util"
|
||||
)
|
||||
|
||||
type TaobaoTmcMessagesProduceRequest struct {
|
||||
/*
|
||||
tmc消息列表, 最多50条,元素结构与taobao.tmc.message.produce一致,用json表示的消息列表。例如:[{"content": "{\"tid\":1234554321,\"status\":\"X_LOGISTICS_PRINTED\",\"action_time\":\"2014-08-08 18:24:00\",\"seller_nick\": \"向阳aa\",\"operator\":\"小张\"}","topic": "taobao_jds_TradeTrace"},{"content": "{\"tid\":1234554321,\"status\":\"X_LOGISTICS_PRINTED\",\"action_time\":\"2014-08-08 18:24:00\",\"seller_nick\": \"向阳aa\",\"operator\":\"小张\"}","topic": "taobao_jds_TradeTrace"}] */
|
||||
Messages *[]domain.TaobaoTmcMessagesProduceTmcPublishMessage `json:"messages" required:"true" `
|
||||
}
|
||||
|
||||
func (s *TaobaoTmcMessagesProduceRequest) SetMessages(v []domain.TaobaoTmcMessagesProduceTmcPublishMessage) *TaobaoTmcMessagesProduceRequest {
|
||||
s.Messages = &v
|
||||
return s
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcMessagesProduceRequest) ToMap() map[string]interface{} {
|
||||
paramMap := make(map[string]interface{})
|
||||
if req.Messages != nil {
|
||||
paramMap["messages"] = util.ConvertStructList(*req.Messages)
|
||||
}
|
||||
return paramMap
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcMessagesProduceRequest) ToFileMap() map[string]interface{} {
|
||||
fileMap := make(map[string]interface{})
|
||||
return fileMap
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/fliggysdk/util"
|
||||
)
|
||||
|
||||
type TaobaoTmcTopicGroupAddRequest struct {
|
||||
/*
|
||||
消息分组名,如果不存在,会自动创建 */
|
||||
GroupName *string `json:"group_name" required:"true" `
|
||||
/*
|
||||
消息topic名称,多个以逗号(,)分割 */
|
||||
Topics *[]string `json:"topics" required:"true" `
|
||||
}
|
||||
|
||||
func (s *TaobaoTmcTopicGroupAddRequest) SetGroupName(v string) *TaobaoTmcTopicGroupAddRequest {
|
||||
s.GroupName = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcTopicGroupAddRequest) SetTopics(v []string) *TaobaoTmcTopicGroupAddRequest {
|
||||
s.Topics = &v
|
||||
return s
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcTopicGroupAddRequest) ToMap() map[string]interface{} {
|
||||
paramMap := make(map[string]interface{})
|
||||
if req.GroupName != nil {
|
||||
paramMap["group_name"] = *req.GroupName
|
||||
}
|
||||
if req.Topics != nil {
|
||||
paramMap["topics"] = util.ConvertBasicList(*req.Topics)
|
||||
}
|
||||
return paramMap
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcTopicGroupAddRequest) ToFileMap() map[string]interface{} {
|
||||
fileMap := make(map[string]interface{})
|
||||
return fileMap
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/fliggysdk/util"
|
||||
)
|
||||
|
||||
type TaobaoTmcTopicGroupDeleteRequest struct {
|
||||
/*
|
||||
消息分组名 */
|
||||
GroupName *string `json:"group_name" required:"true" `
|
||||
/*
|
||||
消息分组Id,一般不用填写,如果分组已经被删除,则根据问题排查工具返回的ID删除路由关系 */
|
||||
GroupId *int64 `json:"group_id,omitempty" required:"false" `
|
||||
/*
|
||||
消息topic名称,多个以逗号(,)分割 */
|
||||
Topics *[]string `json:"topics" required:"true" `
|
||||
}
|
||||
|
||||
func (s *TaobaoTmcTopicGroupDeleteRequest) SetGroupName(v string) *TaobaoTmcTopicGroupDeleteRequest {
|
||||
s.GroupName = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcTopicGroupDeleteRequest) SetGroupId(v int64) *TaobaoTmcTopicGroupDeleteRequest {
|
||||
s.GroupId = &v
|
||||
return s
|
||||
}
|
||||
func (s *TaobaoTmcTopicGroupDeleteRequest) SetTopics(v []string) *TaobaoTmcTopicGroupDeleteRequest {
|
||||
s.Topics = &v
|
||||
return s
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcTopicGroupDeleteRequest) ToMap() map[string]interface{} {
|
||||
paramMap := make(map[string]interface{})
|
||||
if req.GroupName != nil {
|
||||
paramMap["group_name"] = *req.GroupName
|
||||
}
|
||||
if req.GroupId != nil {
|
||||
paramMap["group_id"] = *req.GroupId
|
||||
}
|
||||
if req.Topics != nil {
|
||||
paramMap["topics"] = util.ConvertBasicList(*req.Topics)
|
||||
}
|
||||
return paramMap
|
||||
}
|
||||
|
||||
func (req *TaobaoTmcTopicGroupDeleteRequest) ToFileMap() map[string]interface{} {
|
||||
fileMap := make(map[string]interface{})
|
||||
return fileMap
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package response
|
||||
|
||||
import ()
|
||||
|
||||
type TaobaoTmcAuthGetResponse struct {
|
||||
|
||||
/*
|
||||
System request id
|
||||
*/
|
||||
RequestId string `json:"request_id,omitempty" `
|
||||
|
||||
/*
|
||||
System body
|
||||
*/
|
||||
Body string
|
||||
|
||||
/*
|
||||
result
|
||||
*/
|
||||
Result string `json:"result,omitempty" `
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package response
|
||||
|
||||
import (
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/fliggysdk/util"
|
||||
)
|
||||
|
||||
type TaobaoTmcGroupAddResponse struct {
|
||||
|
||||
/*
|
||||
System request id
|
||||
*/
|
||||
RequestId string `json:"request_id,omitempty" `
|
||||
|
||||
/*
|
||||
System body
|
||||
*/
|
||||
Body string
|
||||
|
||||
/*
|
||||
创建时间
|
||||
*/
|
||||
Created util.LocalTime `json:"created,omitempty" `
|
||||
/*
|
||||
分组名称
|
||||
*/
|
||||
GroupName string `json:"group_name,omitempty" `
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package response
|
||||
|
||||
import ()
|
||||
|
||||
type TaobaoTmcGroupDeleteResponse struct {
|
||||
|
||||
/*
|
||||
System request id
|
||||
*/
|
||||
RequestId string `json:"request_id,omitempty" `
|
||||
|
||||
/*
|
||||
System body
|
||||
*/
|
||||
Body string
|
||||
|
||||
/*
|
||||
是否成功
|
||||
*/
|
||||
IsSuccess bool `json:"is_success,omitempty" `
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package response
|
||||
|
||||
import (
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/fliggysdk/ability132/domain"
|
||||
)
|
||||
|
||||
type TaobaoTmcGroupsGetResponse struct {
|
||||
|
||||
/*
|
||||
System request id
|
||||
*/
|
||||
RequestId string `json:"request_id,omitempty" `
|
||||
|
||||
/*
|
||||
System body
|
||||
*/
|
||||
Body string
|
||||
|
||||
/*
|
||||
dasdasd
|
||||
*/
|
||||
Groups []domain.TaobaoTmcGroupsGetTmcGroup `json:"groups,omitempty" `
|
||||
/*
|
||||
分组总数
|
||||
*/
|
||||
TotalResults int64 `json:"total_results,omitempty" `
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package response
|
||||
|
||||
import ()
|
||||
|
||||
type TaobaoTmcMessagesConfirmResponse struct {
|
||||
|
||||
/*
|
||||
System request id
|
||||
*/
|
||||
RequestId string `json:"request_id,omitempty" `
|
||||
|
||||
/*
|
||||
System body
|
||||
*/
|
||||
Body string
|
||||
|
||||
/*
|
||||
是否成功
|
||||
*/
|
||||
IsSuccess bool `json:"is_success,omitempty" `
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
package response
|
||||
|
||||
import (
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/fliggysdk/ability132/domain"
|
||||
)
|
||||
|
||||
type TaobaoTmcMessagesConsumeResponse struct {
|
||||
|
||||
/*
|
||||
System request id
|
||||
*/
|
||||
RequestId string `json:"request_id,omitempty" `
|
||||
|
||||
/*
|
||||
System body
|
||||
*/
|
||||
Body string
|
||||
|
||||
/*
|
||||
消息列表
|
||||
*/
|
||||
Messages []domain.TaobaoTmcMessagesConsumeTmcMessage `json:"messages,omitempty" `
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package response
|
||||
|
||||
import (
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/fliggysdk/ability132/domain"
|
||||
)
|
||||
|
||||
type TaobaoTmcMessagesProduceResponse struct {
|
||||
|
||||
/*
|
||||
System request id
|
||||
*/
|
||||
RequestId string `json:"request_id,omitempty" `
|
||||
|
||||
/*
|
||||
System body
|
||||
*/
|
||||
Body string
|
||||
|
||||
/*
|
||||
是否全部成功
|
||||
*/
|
||||
IsAllSuccess bool `json:"is_all_success,omitempty" `
|
||||
/*
|
||||
发送结果,与发送时的参数顺序一致。如果is_all_success为true时,不用校验result是否成功
|
||||
*/
|
||||
Results []domain.TaobaoTmcMessagesProduceTmcProduceResult `json:"results,omitempty" `
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user