同程api对接

This commit is contained in:
wukesheng 2024-07-14 22:58:45 +08:00
parent 08359eefcc
commit b3b0b5a629
2 changed files with 7 additions and 7 deletions

View File

@ -16,8 +16,8 @@ import (
// TongChengApi 同程酒店的api // TongChengApi 同程酒店的api
// Api defines the interface of tong-cheng api // Api defines the interface of tong-cheng api
type TongChengApi interface { type TongChengApi interface {
// GenerateLink 生成链接 // GetExternalChannelConfig 获取渠道配置信息
GenerateLink(ctx context.Context, req GenerateLinkRequest, env string) (*ExternalChannelConfigResponse, error) GetExternalChannelConfig(ctx context.Context, req GetExternalChannelConfigRequest, env string) (*ExternalChannelConfigResponse, error)
// QueryOrderList 查询订单列表 // QueryOrderList 查询订单列表
QueryOrderList(ctx context.Context, req QueryOrderListRequest, env string) (*ExternalOrderData, error) QueryOrderList(ctx context.Context, req QueryOrderListRequest, env string) (*ExternalOrderData, error)
} }
@ -35,7 +35,7 @@ func newTongChengApiImpl(log logx.Logger, client *Client) TongChengApi {
} }
// GenerateLink 生成短链 // GenerateLink 生成短链
func (t *tongChengApiImpl) GenerateLink(ctx context.Context, req GenerateLinkRequest, env string) (*ExternalChannelConfigResponse, error) { func (t *tongChengApiImpl) GetExternalChannelConfig(ctx context.Context, req GetExternalChannelConfigRequest, env string) (*ExternalChannelConfigResponse, error) {
var url string var url string
token := t.client.authConfig.Token token := t.client.authConfig.Token
tn := time.Now() tn := time.Now()
@ -50,7 +50,7 @@ func (t *tongChengApiImpl) GenerateLink(ctx context.Context, req GenerateLinkReq
} }
args := util.StructToMap(queryArgs) args := util.StructToMap(queryArgs)
request := &client.HttpRequest{Headers: t.client.headers, QueryArgs: args} request := &client.HttpRequest{Headers: t.client.headers, QueryArgs: args}
response := new(GetExternalChannelConfigResp) response := new(GetExternalChannelConfigResponse)
if env == EnvHuidu { if env == EnvHuidu {
url = HDApiDomain + GetLinkUri url = HDApiDomain + GetLinkUri
} else { } else {
@ -61,7 +61,7 @@ func (t *tongChengApiImpl) GenerateLink(ctx context.Context, req GenerateLinkReq
} }
if response.Code != 200 { if response.Code != 200 {
t.log.WithFields(logx.LogField{Key: "data", Value: map[string]any{"req": req, "resp": response}}). t.log.WithFields(logx.LogField{Key: "data", Value: map[string]any{"req": req, "resp": response}}).
Errorf("[tongChengApiImpl][GenerateLink] response result error: %s", response.Msg) Errorf("[tongChengApiImpl][GetExternalChannelConfig] response result error: %s", response.Msg)
return nil, errors.New(response.Msg) return nil, errors.New(response.Msg)
} }
return response.Data, nil return response.Data, nil

View File

@ -12,7 +12,7 @@ type CommonResponse struct {
} }
// 生成链接请求 // 生成链接请求
type GenerateLinkRequest struct { type GetExternalChannelConfigRequest struct {
Trackid string `json:"trackid"` // 跟踪id,排查问题使用guid即可 Trackid string `json:"trackid"` // 跟踪id,排查问题使用guid即可
} }
@ -25,7 +25,7 @@ type GetExternalChannelConfigReq struct {
} }
// 获取外部渠道配置响应 // 获取外部渠道配置响应
type GetExternalChannelConfigResp struct { type GetExternalChannelConfigResponse struct {
CommonResponse CommonResponse
Data *ExternalChannelConfigResponse `json:"data"` // 数据 Data *ExternalChannelConfigResponse `json:"data"` // 数据
} }