This commit is contained in:
richboo111
2022-12-06 11:28:34 +08:00
6 changed files with 20 additions and 25 deletions

View File

@@ -37,5 +37,5 @@ type WarehouseInfoMapItem struct {
} }
type WarehouseGetWarehouseByStoreData struct { type WarehouseGetWarehouseByStoreData struct {
// 仓信息map // 仓信息map
WarehouseInfoMap map[string]WarehouseInfoMapItem `json:"warehouse_info_map"` WarehouseInfoMap map[string][]*WarehouseInfoMapItem `json:"warehouse_info_map"`
} }

View File

@@ -1,11 +1,11 @@
package tiktok_api package tiktok_api
import ( import (
"crypto/md5"
"fmt" "fmt"
"git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/globals" "git.rosy.net.cn/jx-callback/globals"
"testing" "testing"
"time"
) )
var token = `{"access_token":"2baa1126-bba0-4510-8ffa-6af55ba0bdbd","expires_in":1670828768,"scope":"SCOPE","shop_id":57939570,"shop_name":"京西菜市速食","refresh_token":"23b3eb4e-bb00-4b85-952d-de47801de80d","authority_id":""}` var token = `{"access_token":"2baa1126-bba0-4510-8ffa-6af55ba0bdbd","expires_in":1670828768,"scope":"SCOPE","shop_id":57939570,"shop_name":"京西菜市速食","refresh_token":"23b3eb4e-bb00-4b85-952d-de47801de80d","authority_id":""}`
@@ -30,5 +30,12 @@ func TestGetSkuDetailLocalID(t *testing.T) {
// //
func TestName(t *testing.T) { func TestName(t *testing.T) {
fmt.Println(time.Now().Day()) body := `[{
"tag": "101",
"msg_id": "69793528590852580050:0:101:1670233754:1024588978:7136048270014416392",
"data": "{\"biz\":2,\"order_status\":2,\"order_type\":0,\"p_id\":5008525809582539796,\"pay_amount\":2640,\"pay_time\":1670233752,\"pay_type\":1,\"s_ids\":[5008525809582539796],\"shop_id\":57939570}"
}]`
signParam := a.appKey + body + a.appSecret
sign := fmt.Sprintf("%X", md5.Sum([]byte(signParam)))
fmt.Println(sign)
} }

View File

@@ -21,7 +21,7 @@ func TestApi(t *testing.T) {
} }
func TestQueryOrderDetail(t *testing.T) { func TestQueryOrderDetail(t *testing.T) {
data, err := a.GetTiktokOrderDetail("4996895368866964710") data, err := a.GetTiktokOrderDetail("5008526050099613284")
globals.SugarLogger.Debugf("=====%s", utils.Format4Output(data, false)) globals.SugarLogger.Debugf("=====%s", utils.Format4Output(data, false))
globals.SugarLogger.Debugf("=====%s", err) globals.SugarLogger.Debugf("=====%s", err)
} }

View File

@@ -9,7 +9,6 @@ import (
shop_batchCreateStore_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_batchCreateStore/request" shop_batchCreateStore_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_batchCreateStore/request"
shop_bindStoreSaleLimit_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_bindStoreSaleLimit/request" shop_bindStoreSaleLimit_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_bindStoreSaleLimit/request"
shop_editStore_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_editStore/request" shop_editStore_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_editStore/request"
shop_getStoreDetail_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_getStoreDetail/request"
shop_getStoreList_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_getStoreList/request" shop_getStoreList_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_getStoreList/request"
shop_storeSuspend_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_storeSuspend/request" shop_storeSuspend_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_storeSuspend/request"
shop_unsuspendStore_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_unsuspendStore/request" shop_unsuspendStore_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_unsuspendStore/request"
@@ -57,21 +56,6 @@ func TestCreateStore(t *testing.T) {
fmt.Println("err==", err) fmt.Println("err==", err)
} }
//单个获取门店详情
func TestGetStoreDetail(t *testing.T) {
accesstoken := `{"access_token":"8de708c3-f2d1-4b45-bc56-31f704ca0f1e","expires_in":1670227126,"scope":"SCOPE","shop_id":57939570,"shop_name":"京西菜市速食","refresh_token":"86ef17a7-7964-4f57-ae2d-4f8bcbfff97e","authority_id":""}`
a := New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", accesstoken)
data, err := a.GetStoreDetail(&shop_getStoreDetail_request.ShopGetStoreDetailParam{
//StoreId: 76879546,
StoreId: "76879546",
IsNeedRelShopUser: false,
IsNeedPoiAuditInfo: false,
IsNeedChargeInfo: false,
})
fmt.Println("data==========", utils.Format4Output(data, false))
fmt.Println(err)
}
//门店列表分页查询 //门店列表分页查询
func TestGetStoreList(t *testing.T) { func TestGetStoreList(t *testing.T) {
data, err := a.GetStoreList(&shop_getStoreList_request.ShopGetStoreListParam{ data, err := a.GetStoreList(&shop_getStoreList_request.ShopGetStoreListParam{
@@ -249,7 +233,7 @@ func TestUpdateStore(t *testing.T) {
fmt.Println(err) fmt.Println(err)
} }
//获取门店绑定仓库以及电子围栏 //获取门店绑定仓库
func TestGetWarehouseByStore(t *testing.T) { func TestGetWarehouseByStore(t *testing.T) {
resp, err := a.GetWarehouseByStore(63520016) resp, err := a.GetWarehouseByStore(63520016)
fmt.Println(resp) fmt.Println(resp)

View File

@@ -172,20 +172,24 @@ func (a *API) SNSGetUserPhone(jsCode string) (string, error) {
// 获取小程序短连接CBRetrieveToken // 获取小程序短连接CBRetrieveToken
func (a *API) MiniProgramSortLink() (string, error) { func (a *API) MiniProgramSortLink() (string, error) {
weChatToken := "" weChatToken := ""
if token := a.CBGetToken(); token == "" { token := a.CBGetToken()
if token == "" {
newToken, err := a.CBRetrieveToken() newToken, err := a.CBRetrieveToken()
if err != nil { if err != nil {
return "", err return "", err
} }
weChatToken = newToken.AccessToken weChatToken = newToken.AccessToken
} else {
weChatToken = token
} }
parmaJson := map[string]interface{}{ parmaJson := map[string]interface{}{
"access_token": weChatToken, "access_token": weChatToken,
} }
bodyJson := map[string]interface{}{ bodyJson := map[string]interface{}{
"access_token ": weChatToken, //"access_token ": weChatToken,
"expire_type ": 0, "expire_type ": 1,
"expire_time": 1,
} }
body, _ := json.Marshal(bodyJson) body, _ := json.Marshal(bodyJson)
result, err := a.AccessAPI("wxa/generate_urllink", parmaJson, string(body)) result, err := a.AccessAPI("wxa/generate_urllink", parmaJson, string(body))

View File

@@ -73,7 +73,7 @@ func isSNSAction(action string) bool {
} }
func (a *API) AccessAPI(action string, params map[string]interface{}, body string) (retVal map[string]interface{}, err error) { func (a *API) AccessAPI(action string, params map[string]interface{}, body string) (retVal map[string]interface{}, err error) {
if params != nil && body != "" { if params == nil && body == "" {
panic("params and body can not all be empty") panic("params and body can not all be empty")
} }
params2 := make(map[string]interface{}) params2 := make(map[string]interface{})