修改飞猪,聚推客取链,订单问题
This commit is contained in:
parent
3a2a829f59
commit
d9f889ffd0
1
go.mod
1
go.mod
@ -28,6 +28,7 @@ require (
|
||||
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
|
||||
|
||||
9
index.go
9
index.go
@ -3,6 +3,7 @@ package third_platform_sdk
|
||||
import (
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/platform/fliggy"
|
||||
shoutu_show "repository.lenntc.com/lenntc/third-platform-sdk/platform/shoutu-show"
|
||||
|
||||
didiunion "repository.lenntc.com/lenntc/third-platform-sdk/platform/didi-union"
|
||||
elemeunion "repository.lenntc.com/lenntc/third-platform-sdk/platform/eleme-union"
|
||||
@ -34,6 +35,8 @@ const (
|
||||
PlatformElongHotel = "elong_hotel"
|
||||
// PlatformFliggy 飞猪
|
||||
PlatformFliggy = "fliggy"
|
||||
// PlatformShoutuShow 守兔演出
|
||||
PlatformShoutuShow = "shoutu_show"
|
||||
)
|
||||
|
||||
// PlatformNameMap 平台名称
|
||||
@ -47,6 +50,7 @@ var PlatformNameMap = map[string]string{
|
||||
PlatformJutuike: "聚推客",
|
||||
PlatformElongHotel: "同程酒店",
|
||||
PlatformFliggy: "飞猪",
|
||||
PlatformShoutuShow: "守兔演出",
|
||||
}
|
||||
|
||||
// GetPlatformName 获取平台名称
|
||||
@ -94,6 +98,11 @@ func NewElongHotelApi(log logx.Logger, conf elonghotel.AuthConfig) elonghotel.El
|
||||
return elonghotel.NewApiClient(log, conf)
|
||||
}
|
||||
|
||||
// NewFliggyApi 飞猪
|
||||
func NewFliggyApi(log logx.Logger, conf fliggy.AuthConfig) fliggy.FliggyApi {
|
||||
return fliggy.NewApiClient(log, conf)
|
||||
}
|
||||
|
||||
func NewShoutuShow(log logx.Logger, conf shoutu_show.AuthConfig) shoutu_show.ShouTuShowApi {
|
||||
return shoutu_show.NewApiClient(log, conf)
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ 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"
|
||||
@ -31,21 +32,22 @@ func (a *apiClientSuite) SetupSuite() {
|
||||
}
|
||||
|
||||
func (a *apiClientSuite) Test_FliggyPromoteOrdersList() {
|
||||
page := int64(1)
|
||||
start, _ := time.ParseInLocation(time.DateTime, "2024-08-04 00:00:00", time.Local)
|
||||
end, _ := time.ParseInLocation(time.DateTime, "2024-08-04 23:59:59", time.Local)
|
||||
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: &sTime,
|
||||
AfterModifyTime: &eTime,
|
||||
BeforeModifyTime: &eTime,
|
||||
AfterModifyTime: &sTime,
|
||||
}
|
||||
resp, err := a.api.FliggyPromoteOrdersList(req)
|
||||
if err != nil {
|
||||
a.T().Errorf("=====[Test_FliggyPromoteOrdersList] err: %v", err)
|
||||
return
|
||||
}
|
||||
a.T().Logf("=====[Test_FliggyPromoteOrdersList] resp: %+v", resp)
|
||||
ret, _ := json.Marshal(resp)
|
||||
a.T().Logf("=====[Test_FliggyPromoteOrdersList] resp: %+v", string(ret))
|
||||
}
|
||||
|
||||
@ -3,6 +3,8 @@ package jutuike
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/spf13/cast"
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
@ -48,12 +50,45 @@ 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 _, ok := data["act_name"]; ok {
|
||||
result.ActName = data["act_name"].(string)
|
||||
}
|
||||
if _, ok := data["poster_qrcode_url"]; ok {
|
||||
result.PosterQrcodeUrl = data["poster_qrcode_url"].(string)
|
||||
}
|
||||
if _, ok := data["h5"]; ok {
|
||||
result.H5 = data["h5"].(string)
|
||||
}
|
||||
if _, ok := data["long_h5"]; ok {
|
||||
result.LongH5 = data["long_h5"].(string)
|
||||
}
|
||||
if _, ok := data["h5_evoke"]; ok {
|
||||
result.H5Evoke = data["h5_evoke"].(string)
|
||||
}
|
||||
if _, ok := data["deeplink"]; ok {
|
||||
result.DeepLink = data["deeplink"].(string)
|
||||
}
|
||||
if _, ok := data["we_app_info"]; ok {
|
||||
weApp := cast.ToStringMap(data["we_app_info"])
|
||||
result.WeAppInfo = &WeAppInfo{
|
||||
AppId: weApp["app_id"].(string),
|
||||
PagePath: weApp["page_path"].(string),
|
||||
MiniCode: weApp["miniCode"].(string),
|
||||
}
|
||||
}
|
||||
if _, ok := data["alipay_app_info"]; ok {
|
||||
alipayApp := cast.ToStringMap(data["alipay_app_info"])
|
||||
result.AlipayAppInfo = &AlipayAppInfo{
|
||||
AppId: alipayApp["app_id"].(string),
|
||||
PagePath: alipayApp["page_path"].(string),
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// QueryOrderList 查询订单列表
|
||||
@ -76,12 +111,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)
|
||||
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,14 +21,14 @@ func TestApiClient(t *testing.T) {
|
||||
func (a *apiClientSuite) SetupSuite() {
|
||||
log := logx.WithContext(context.Background())
|
||||
apiClient := NewApiClient(log, AuthConfig{
|
||||
ApiKey: "IyftVpzDVqDIRDqPZByW5xVpj9MgZSB7",
|
||||
ApiKey: "IyftVpzDVqDIRDqPZByW5xVpj9MgZSB7", //
|
||||
})
|
||||
a.api = apiClient
|
||||
}
|
||||
|
||||
func (a *apiClientSuite) Test_GenerateLink() {
|
||||
req := GenerateLinkRequest{
|
||||
ActId: 3,
|
||||
ActId: 65,
|
||||
Sid: "f3a8c1",
|
||||
}
|
||||
result, err := a.api.GenerateLink(context.Background(), req)
|
||||
@ -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)
|
||||
|
||||
@ -14,10 +14,19 @@ type GenerateLinkResponse struct {
|
||||
}
|
||||
|
||||
type GenerateLinkData struct {
|
||||
H5 string `json:"h5"` // 推广短链接(部分活动没有,请注意判断)
|
||||
WeAppInfo WeAppInfo `json:"we_app_info"` // 小程序信息(部分活动没有,请注意判断)
|
||||
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"`
|
||||
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 {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user