1
This commit is contained in:
@@ -17,7 +17,6 @@ func init() {
|
|||||||
logger, _ := zap.NewDevelopment()
|
logger, _ := zap.NewDevelopment()
|
||||||
sugarLogger = logger.Sugar()
|
sugarLogger = logger.Sugar()
|
||||||
baseapi.Init(sugarLogger)
|
baseapi.Init(sugarLogger)
|
||||||
globals.SugarLogger.Debug("加载配置")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取登录
|
// 获取登录
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package q_bida
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -61,7 +60,6 @@ func (a *Api) GetExpressPrice(param *GetExpressPriceReq) (*GetExpressPriceRes, e
|
|||||||
return resultData, nil
|
return resultData, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// CreateOrder 创建订单
|
// CreateOrder 创建订单
|
||||||
func (a *Api) CreateOrder(param *MakeOrderReq) (string, error) {
|
func (a *Api) CreateOrder(param *MakeOrderReq) (string, error) {
|
||||||
if err := a.CheckTokenExpiration(); err != nil {
|
if err := a.CheckTokenExpiration(); err != nil {
|
||||||
@@ -94,7 +92,6 @@ func (a *Api) CancelOrder(param *CancelOrderReq) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
resultData := &PublicParams{}
|
resultData := &PublicParams{}
|
||||||
globals.SugarLogger.Debug("resultData===================", resultData.Code, resultData.Msg)
|
|
||||||
if err := utils.Map2StructByJson(result, resultData, false); err != nil {
|
if err := utils.Map2StructByJson(result, resultData, false); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ func (a *API) AccessAPI2(url string, params map[string]interface{}) (retVal map[
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
globals.SugarLogger.Debug("进入AccessAPI2,DATA=================", data)
|
|
||||||
err = platformapi.AccessPlatformAPIWithRetry(a.client,
|
err = platformapi.AccessPlatformAPIWithRetry(a.client,
|
||||||
func() *http.Request {
|
func() *http.Request {
|
||||||
request, _ := http.NewRequest(http.MethodPost, url, strings.NewReader(string(data)))
|
request, _ := http.NewRequest(http.MethodPost, url, strings.NewReader(string(data)))
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -67,7 +66,6 @@ func (a *API) GetTiktokToken() error {
|
|||||||
//tokenReq["appid"] = TiktokAppId
|
//tokenReq["appid"] = TiktokAppId
|
||||||
//tokenReq["secret"] = TiktokSecret
|
//tokenReq["secret"] = TiktokSecret
|
||||||
tokenReq["grant_type"] = "client_credential"
|
tokenReq["grant_type"] = "client_credential"
|
||||||
globals.SugarLogger.Debug("=============", tokenReq)
|
|
||||||
result, err := a.AccessAPI2(GetTiktokToken, tokenReq)
|
result, err := a.AccessAPI2(GetTiktokToken, tokenReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package tiktok_api
|
package tiktok_api
|
||||||
|
|
||||||
import "testing"
|
import (
|
||||||
|
"fmt"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
var token = `{"access_token":"60f530b2-9ab6-4723-b487-c094918f0d21","expires_in":1666257163,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对接专用店","refresh_token":"1220666a-5e88-458c-a8c0-06d949fbbd3f","authority_id":""}`
|
var token = `{"access_token":"60f530b2-9ab6-4723-b487-c094918f0d21","expires_in":1666257163,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对接专用店","refresh_token":"1220666a-5e88-458c-a8c0-06d949fbbd3f","authority_id":""}`
|
||||||
var a = New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", token)
|
var a = New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", token)
|
||||||
@@ -13,4 +16,5 @@ func TestAfsOrder(t *testing.T) {
|
|||||||
// 同意/拒绝售后单
|
// 同意/拒绝售后单
|
||||||
func TestAggreOrNotAggreAfs(t *testing.T) {
|
func TestAggreOrNotAggreAfs(t *testing.T) {
|
||||||
//a.AfterSaleOperate()
|
//a.AfterSaleOperate()
|
||||||
|
fmt.Println("11", 8|16|32|1)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,9 +78,6 @@ func (a *API) CreateToken(code string) (*doudian_sdk.CreateTokenData, error) {
|
|||||||
a.refreshToken = access.RefreshToken
|
a.refreshToken = access.RefreshToken
|
||||||
a.expiresIn = time.Now().Unix() + access.ExpiresIn
|
a.expiresIn = time.Now().Unix() + access.ExpiresIn
|
||||||
a.accessTokenObj = access
|
a.accessTokenObj = access
|
||||||
// 不要
|
|
||||||
strData, _ := json.Marshal(access)
|
|
||||||
globals.SugarLogger.Debug("=========", string(strData))
|
|
||||||
return &access.CreateTokenData, nil
|
return &access.CreateTokenData, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,13 +99,10 @@ func (a *API) RefreshToken() (*doudian_sdk.CreateTokenData, error) {
|
|||||||
a.accessToken = createToken.Data.AccessToken
|
a.accessToken = createToken.Data.AccessToken
|
||||||
a.refreshToken = createToken.Data.RefreshToken
|
a.refreshToken = createToken.Data.RefreshToken
|
||||||
a.expiresIn = time.Now().Unix() + createToken.Data.ExpiresIn
|
a.expiresIn = time.Now().Unix() + createToken.Data.ExpiresIn
|
||||||
globals.SugarLogger.Debug("===============data", createToken.Data)
|
|
||||||
a.accessTokenObj.CreateTokenData = createToken.Data
|
a.accessTokenObj.CreateTokenData = createToken.Data
|
||||||
|
|
||||||
// 不要
|
// 不要
|
||||||
createToken.Data.ExpiresIn = a.expiresIn
|
createToken.Data.ExpiresIn = a.expiresIn
|
||||||
strData, _ := json.Marshal(createToken.Data)
|
|
||||||
globals.SugarLogger.Debug("=========", string(strData))
|
|
||||||
return &createToken.Data, nil
|
return &createToken.Data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -99,13 +99,10 @@ func (a *APIExpress) RefreshToken() (*doudian_sdk.CreateTokenData, error) {
|
|||||||
a.accessToken = createToken.Data.AccessToken
|
a.accessToken = createToken.Data.AccessToken
|
||||||
a.refreshToken = createToken.Data.RefreshToken
|
a.refreshToken = createToken.Data.RefreshToken
|
||||||
a.expiresIn = time.Now().Unix() + createToken.Data.ExpiresIn
|
a.expiresIn = time.Now().Unix() + createToken.Data.ExpiresIn
|
||||||
globals.SugarLogger.Debug("===============data", createToken.Data)
|
|
||||||
|
|
||||||
// 不要
|
// 不要
|
||||||
createToken.Data.ExpiresIn = a.expiresIn
|
createToken.Data.ExpiresIn = a.expiresIn
|
||||||
strData, _ := json.Marshal(createToken.Data)
|
|
||||||
a.accessTokenObj.CreateTokenData = createToken.Data
|
a.accessTokenObj.CreateTokenData = createToken.Data
|
||||||
globals.SugarLogger.Debug("=========", string(strData))
|
|
||||||
return &createToken.Data, nil
|
return &createToken.Data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -325,8 +325,6 @@ func (a *API) LogisticsAdd(orderId string, companyCode string, isRefundReject bo
|
|||||||
|
|
||||||
// CreateOrderCallback 订单创建,抖店创建订单后,回调消息通知本服务器
|
// CreateOrderCallback 订单创建,抖店创建订单后,回调消息通知本服务器
|
||||||
func (a *API) CreateOrderCallback(orderStatus []byte) (map[string][]interface{}, *CallbackResponse) {
|
func (a *API) CreateOrderCallback(orderStatus []byte) (map[string][]interface{}, *CallbackResponse) {
|
||||||
globals.SugarLogger.Debugf("88888888888888=%s", utils.Format4Output(string(orderStatus), false))
|
|
||||||
|
|
||||||
var resp []*OrderCallback
|
var resp []*OrderCallback
|
||||||
if err := json.Unmarshal(orderStatus, &resp); err != nil {
|
if err := json.Unmarshal(orderStatus, &resp); err != nil {
|
||||||
baseapi.SugarLogger.Debugf("Tiktok Notify failed with err:%v", err)
|
baseapi.SugarLogger.Debugf("Tiktok Notify failed with err:%v", err)
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ func (a *API) UpdateSkuStock(param *sku_syncStock_request.SkuSyncStockParam) err
|
|||||||
request := sku_syncStock_request.New()
|
request := sku_syncStock_request.New()
|
||||||
request.Param = param
|
request.Param = param
|
||||||
resp, err := request.Execute(a.accessTokenObj)
|
resp, err := request.Execute(a.accessTokenObj)
|
||||||
globals.SugarLogger.Debug("======/sku/syncStock:%s", utils.Format4Output(resp, false))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -101,6 +100,7 @@ func (a *API) GetCatePropertyV2(categoryLeftId int64) (*product_getCatePropertyV
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
globals.SugarLogger.Debugf("GetCatePropertyV2-------------api:=%s", utils.Format4Output(result, false))
|
||||||
if result.Code != RequestSuccessCode {
|
if result.Code != RequestSuccessCode {
|
||||||
return nil, errors.New(result.SubMsg)
|
return nil, errors.New(result.SubMsg)
|
||||||
}
|
}
|
||||||
@@ -117,7 +117,6 @@ func (a *API) CreateStoreCommodity(skuParam *product_addV2_request.ProductAddV2P
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
globals.SugarLogger.Debug("=========/product/addV2", utils.Format4Output(result, false))
|
|
||||||
if result.Code != RequestSuccessCode {
|
if result.Code != RequestSuccessCode {
|
||||||
return nil, errors.New(result.SubMsg)
|
return nil, errors.New(result.SubMsg)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,9 +36,7 @@ func TestCategory(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetCatePropertyV2(t *testing.T) {
|
func TestGetCatePropertyV2(t *testing.T) {
|
||||||
token := `{"access_token":"a1746210-a8a3-4497-a87b-09d1f10dbb95","expires_in":1665652230,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对接专用店","refresh_token":"c1cf8d88-0983-4f2a-b969-3746fae6b0cd","authority_id":""}`
|
data, err := a.GetCatePropertyV2(22531)
|
||||||
a := New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", token)
|
|
||||||
data, err := a.GetCatePropertyV2(23065)
|
|
||||||
fmt.Println("err=====", err)
|
fmt.Println("err=====", err)
|
||||||
fmt.Println("data====", data) // 202209281558450102081001701D7B32C5
|
fmt.Println("data====", data) // 202209281558450102081001701D7B32C5
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,6 @@ func (a *API) GetStoreDetail(param *shop_getStoreDetail_request.ShopGetStoreDeta
|
|||||||
|
|
||||||
//BatchCreateStore 批量创建门店
|
//BatchCreateStore 批量创建门店
|
||||||
func (a *API) BatchCreateStore(param *shop_batchCreateStore_request.ShopBatchCreateStoreParam) (*shop_batchCreateStore_response.ShopBatchCreateStoreData, error) {
|
func (a *API) BatchCreateStore(param *shop_batchCreateStore_request.ShopBatchCreateStoreParam) (*shop_batchCreateStore_response.ShopBatchCreateStoreData, error) {
|
||||||
globals.SugarLogger.Debug("=========创建抖音门店api")
|
|
||||||
globals.SugarLogger.Debugf("BatchCreateStore:%s", utils.Format4Output(param, true))
|
globals.SugarLogger.Debugf("BatchCreateStore:%s", utils.Format4Output(param, true))
|
||||||
request := shop_batchCreateStore_request.New()
|
request := shop_batchCreateStore_request.New()
|
||||||
request.Param = param
|
request.Param = param
|
||||||
@@ -78,13 +77,11 @@ func (a *API) BatchCreateStore(param *shop_batchCreateStore_request.ShopBatchCre
|
|||||||
if response.Code != RequestSuccessCode {
|
if response.Code != RequestSuccessCode {
|
||||||
return nil, errors.New(response.SubMsg)
|
return nil, errors.New(response.SubMsg)
|
||||||
}
|
}
|
||||||
globals.SugarLogger.Debug("BatchCreateStore:response.Data============%v", response.Data)
|
|
||||||
return response.Data, nil
|
return response.Data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// EditStore 编辑门店
|
// EditStore 编辑门店
|
||||||
func (a *API) EditStore(param *shop_editStore_request.ShopEditStoreParam) (*shop_editStore_response.ShopEditStoreData, error) {
|
func (a *API) EditStore(param *shop_editStore_request.ShopEditStoreParam) (*shop_editStore_response.ShopEditStoreData, error) {
|
||||||
globals.SugarLogger.Debug("=========EditStore")
|
|
||||||
globals.SugarLogger.Debugf("EditStore EditStore:%s", utils.Format4Output(param, true))
|
globals.SugarLogger.Debugf("EditStore EditStore:%s", utils.Format4Output(param, true))
|
||||||
request := shop_editStore_request.New()
|
request := shop_editStore_request.New()
|
||||||
request.Param = param
|
request.Param = param
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
|
||||||
"github.com/clbanning/mxj"
|
"github.com/clbanning/mxj"
|
||||||
"github.com/nanjishidu/gomini/gocrypto"
|
"github.com/nanjishidu/gomini/gocrypto"
|
||||||
)
|
)
|
||||||
@@ -176,7 +175,6 @@ func (a *API) getCallbackMsg(msgBody string) (msg *CallbackMsg, callbackResponse
|
|||||||
sign := utils.Interface2String(mapData[sigKey])
|
sign := utils.Interface2String(mapData[sigKey])
|
||||||
desiredSign := a.signParam(sigType, mapData)
|
desiredSign := a.signParam(sigType, mapData)
|
||||||
if desiredSign != sign {
|
if desiredSign != sign {
|
||||||
globals.SugarLogger.Debugf("transactionID:%s, sigType:%s, desiredSign:%s <> sign:%s", transactionID, sigType, desiredSign, sign)
|
|
||||||
return nil, Err2CallbackResponse(fmt.Errorf("desiredSign:%s <> sign:%s", desiredSign, sign), "")
|
return nil, Err2CallbackResponse(fmt.Errorf("desiredSign:%s <> sign:%s", desiredSign, sign), "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ import (
|
|||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi"
|
"git.rosy.net.cn/baseapi"
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -74,19 +72,15 @@ func (p *Pool) callFun(func4Call func(), primaryID string, isAsync bool) (r inte
|
|||||||
result := md5.Sum([]byte(primaryID + utils.GetUUID()))
|
result := md5.Sum([]byte(primaryID + utils.GetUUID()))
|
||||||
resultInt64 := int64(binary.LittleEndian.Uint32(result[8:]))
|
resultInt64 := int64(binary.LittleEndian.Uint32(result[8:]))
|
||||||
chanIndex := int(resultInt64 % int64(p.curRoutineCount))
|
chanIndex := int(resultInt64 % int64(p.curRoutineCount))
|
||||||
globals.SugarLogger.Debugf("callFun1 %v , %v", chanIndex, primaryID)
|
|
||||||
chanParam := &TaskParam{
|
chanParam := &TaskParam{
|
||||||
handler: func4Call,
|
handler: func4Call,
|
||||||
}
|
}
|
||||||
if !isAsync {
|
if !isAsync {
|
||||||
chanParam.resultChan = make(chan interface{})
|
chanParam.resultChan = make(chan interface{})
|
||||||
}
|
}
|
||||||
globals.SugarLogger.Debugf("callFun2 %v , %v", chanIndex, primaryID)
|
|
||||||
p.taskChans[chanIndex] <- chanParam
|
p.taskChans[chanIndex] <- chanParam
|
||||||
globals.SugarLogger.Debugf("callFun3 %v , %v", chanIndex, primaryID)
|
|
||||||
if !isAsync {
|
if !isAsync {
|
||||||
r = <-chanParam.resultChan
|
r = <-chanParam.resultChan
|
||||||
globals.SugarLogger.Debugf("callFun4 %v , %v", chanIndex, primaryID)
|
|
||||||
close(chanParam.resultChan)
|
close(chanParam.resultChan)
|
||||||
}
|
}
|
||||||
return r
|
return r
|
||||||
|
|||||||
Reference in New Issue
Block a user