守兔演出订单api接口支持

This commit is contained in:
yanfan 2024-08-07 22:16:49 +08:00
parent 832a812e58
commit dcc3d9a8ba
4 changed files with 175 additions and 0 deletions

View File

@ -0,0 +1,70 @@
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)
}
type ShouTuShowApiImpl struct {
log logx.Logger
client *Client
}
func newShouTuShowApiImpl(log logx.Logger, client *Client) ShouTuShowApi {
return &ShouTuShowApiImpl{
log: log,
client: client,
}
}
func (a *ShouTuShowApiImpl) GenerateLink(ctx context.Context, req GenerateLinkRequest) (*GenerateLinkResponse, error) {
if req.ActivityUrl == "" || req.Sid == "" {
return nil, errors.New("请求参数activityUrl或sid不能为空")
}
//测试联调地址 https://pre-show.shouto.cn/?distributorId=8&subChannelId=
//直接替换
newUrl := strings.ReplaceAll(req.ActivityUrl, "subChannelId=", fmt.Sprintf("subChannelId=%s", req.Sid))
return &GenerateLinkResponse{
H5: 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
}

View 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",
},
}
}

View 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"
)

View File

@ -0,0 +1,54 @@
package shoutu_show
type GenerateLinkRequest struct {
ActivityUrl string `json:"activityUrl"` // 渠道方合作页地址
Sid string `json:"sid"` // 必传 自定义参数
}
// GenerateLinkResponse 生成推广链接响应
type GenerateLinkResponse struct {
H5 string `json:"h5"` // H5链接
}
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
}