From fce03afdc2c7f1183c571038fe88f5de524bd268 Mon Sep 17 00:00:00 2001 From: richboo111 Date: Wed, 26 Oct 2022 18:16:56 +0800 Subject: [PATCH] 1 --- platformapi/jdapi/store_sku_test.go | 3 ++- platformapi/tiktok_shop/tiktok_api/store.go | 12 ++++++++---- platformapi/tiktok_shop/tiktok_api/store_test.go | 7 +++++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/platformapi/jdapi/store_sku_test.go b/platformapi/jdapi/store_sku_test.go index 19c06dca..5b5c1945 100644 --- a/platformapi/jdapi/store_sku_test.go +++ b/platformapi/jdapi/store_sku_test.go @@ -28,7 +28,8 @@ func TestDelVipPrice(t *testing.T) { if err != nil { t.Fatal(err) } - // t.Log(utils.Format4Output(result, false)) + t.Fatal(err) + //t.Log(utils.Format4Output(result, false)) } //func TestQueryOpenUseable(t *testing.T) { diff --git a/platformapi/tiktok_shop/tiktok_api/store.go b/platformapi/tiktok_shop/tiktok_api/store.go index d00b1918..e603aa27 100644 --- a/platformapi/tiktok_shop/tiktok_api/store.go +++ b/platformapi/tiktok_shop/tiktok_api/store.go @@ -238,11 +238,15 @@ func (a *API) GetStoreFreight(storeId int64) ([]int64, error) { if result.Code != RequestSuccessCode { return nil, errors.New(result.SubMsg) } - tempList := make([]int64, 0) - for _, v := range result.Data.StoreFreights { - tempList = append(tempList, v.FreightId) + if len(result.Data.StoreFreights) == 0 { + return []int64{0}, err + } else { + tempList := make([]int64, 0) + for _, v := range result.Data.StoreFreights { + tempList = append(tempList, v.FreightId) + } + return tempList, err } - return tempList, err } // 获取门店绑定的运费模板 diff --git a/platformapi/tiktok_shop/tiktok_api/store_test.go b/platformapi/tiktok_shop/tiktok_api/store_test.go index 4ad0558c..564aca29 100644 --- a/platformapi/tiktok_shop/tiktok_api/store_test.go +++ b/platformapi/tiktok_shop/tiktok_api/store_test.go @@ -255,3 +255,10 @@ func TestUpdateStore(t *testing.T) { err := a.EditStore(param) fmt.Println(err) } +func TestGetStoreBindFreight(t *testing.T) { + accesstoken := `{"access_token":"47690a84-3cc2-4958-abf9-41cc7fca5f82","expires_in":1666862533,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对接专用店","refresh_token":"66ea2395-07c7-409d-84ae-93ac1e600b74","authority_id":""}` + a := New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", accesstoken) + resp, err := a.GetStoreFreight(668619) + fmt.Println(resp) + fmt.Println(err) +}