1
This commit is contained in:
@@ -2,6 +2,8 @@ package order_ordeReportList_request
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
order_ordeReportList_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/order_ordeReportList/response"
|
||||||
|
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
type OrderOrdeReportListRequest struct {
|
type OrderOrdeReportListRequest struct {
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
package order_ordeReportList_response
|
package order_ordeReportList_response
|
||||||
|
|
||||||
|
import (
|
||||||
|
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
|
||||||
|
)
|
||||||
|
|
||||||
type OrderOrdeReportListResponse struct {
|
type OrderOrdeReportListResponse struct {
|
||||||
doudian_sdk.BaseDoudianOpApiResponse
|
doudian_sdk.BaseDoudianOpApiResponse
|
||||||
Data *OrderOrdeReportListData `json:"data"`
|
Data *OrderOrdeReportListData `json:"data"`
|
||||||
|
|||||||
74
platformapi/tiktok_shop/tiktok_api/api.go
Normal file
74
platformapi/tiktok_shop/tiktok_api/api.go
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
package tiktok_api
|
||||||
|
|
||||||
|
import (
|
||||||
|
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
var AccessToken *doudian_sdk.AccessToken // 存储数据库
|
||||||
|
|
||||||
|
type Api struct {
|
||||||
|
appKey string
|
||||||
|
appSecret string
|
||||||
|
accessToken string
|
||||||
|
refreshToken string
|
||||||
|
expiresIn int64
|
||||||
|
}
|
||||||
|
|
||||||
|
func New(appKey, appSecret string) *Api {
|
||||||
|
return &Api{
|
||||||
|
appKey: appKey,
|
||||||
|
appSecret: appSecret,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Api) GetToken() string {
|
||||||
|
if a.expiresIn != 0 && a.expiresIn > time.Now().Unix() && a.accessToken != "" {
|
||||||
|
return a.accessToken
|
||||||
|
} else {
|
||||||
|
if err := a.RefreshToken(); err != nil {
|
||||||
|
globals.SugarLogger.Debug("Tiktok RefreshToken Err : ", err)
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return a.accessToken
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateToken 创建token只有第一次授权或者更新授权才需要,其他时候直接刷新就可以啦
|
||||||
|
func (a *Api) CreateToken(code string) error {
|
||||||
|
doudian_sdk.GlobalConfig.AppKey = a.appKey
|
||||||
|
doudian_sdk.GlobalConfig.AppSecret = a.appSecret
|
||||||
|
buildParam := &doudian_sdk.BuildAccessTokenParam{
|
||||||
|
Code: code, // 定死还是自动获取
|
||||||
|
ShopId: 0,
|
||||||
|
Config: nil,
|
||||||
|
}
|
||||||
|
access, err := doudian_sdk.BuildAccessToken(buildParam)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
a.accessToken = access.AccessToken
|
||||||
|
a.refreshToken = access.RefreshToken
|
||||||
|
a.expiresIn = access.ExpiresIn
|
||||||
|
AccessToken = access
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RefreshToken 刷新token
|
||||||
|
func (a *Api) RefreshToken() error {
|
||||||
|
refresh := doudian_sdk.NewRefreshTokenRequest()
|
||||||
|
refresh.GetParam().RefreshToken = a.refreshToken
|
||||||
|
refresh.GetParam().GrantType = "refresh_token"
|
||||||
|
|
||||||
|
createToken, err := refresh.Execute(AccessToken)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
a.accessToken = createToken.Data.AccessToken
|
||||||
|
a.refreshToken = createToken.Data.RefreshToken
|
||||||
|
a.expiresIn = createToken.Data.ExpiresIn
|
||||||
|
AccessToken.CreateTokenData = createToken.Data
|
||||||
|
return nil
|
||||||
|
}
|
||||||
15
platformapi/tiktok_shop/tiktok_api/sku.go
Normal file
15
platformapi/tiktok_shop/tiktok_api/sku.go
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package tiktok_api
|
||||||
|
|
||||||
|
import (
|
||||||
|
order_orderDetail_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/order_orderDetail/request"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetTiktokOrderDetail 获取订单详情
|
||||||
|
func (a *Api) GetTiktokOrderDetail(storeId string) {
|
||||||
|
reqParam := order_orderDetail_request.New()
|
||||||
|
reqParam.Param = &order_orderDetail_request.OrderOrderDetailParam{
|
||||||
|
ShopOrderId: storeId,
|
||||||
|
IsSearchable: false,
|
||||||
|
}
|
||||||
|
reqParam.Execute(AccessToken)
|
||||||
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
package sku
|
|
||||||
Reference in New Issue
Block a user