From 763580877afd5e7953d43cd6d8b08ab5e85857a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Mon, 20 Nov 2023 09:36:43 +0800 Subject: [PATCH] 1 --- platformapi/ebaiapi/activity.go | 4 +- platformapi/ebaiapi/activity_test.go | 25 +++++++++++-- platformapi/ebaiapi/shop_test.go | 2 +- platformapi/mtwmapi/mtwmapi_test.go | 10 +---- platformapi/mtwmapi/retail_test.go | 37 +++++++++++++++---- .../tiktok_shop/tiktok_api/afs_test.go | 2 +- .../tiktok_api/settl_bill_detail_test.go | 2 +- .../tiktok_shop/tiktok_api/transport_test.go | 2 +- 8 files changed, 59 insertions(+), 25 deletions(-) diff --git a/platformapi/ebaiapi/activity.go b/platformapi/ebaiapi/activity.go index 701c827c..59feb455 100644 --- a/platformapi/ebaiapi/activity.go +++ b/platformapi/ebaiapi/activity.go @@ -1,6 +1,7 @@ package ebaiapi import ( + "fmt" "strings" "git.rosy.net.cn/baseapi/utils" @@ -347,13 +348,14 @@ type ActMultiChannelQueryInfosSkuList struct { Skuid string `json:"skuId"` } -// 多渠道查询活动详情 +// 多渠道查询活动详情(此接口成功率不达标,原因是上一个接口获取门店活动id时,把门店结束活动id查询出来了,但是此接口查询结束活动时,失效了) func (a *API) ActMultiChannelQueryInfos(activityID, shopID string, baiduShopID int64) (actMultiChannelQueryInfosResult *ActMultiChannelQueryInfosResult, err error) { pageSize := 100 params := a.genShopIDParams(shopID, baiduShopID, 0) params["activity_id"] = activityID params["page_size"] = pageSize result, err := a.AccessAPI("act.multi.channel.queryinfos", params) + fmt.Println(err) if err == nil { if result.Data != nil { utils.Map2StructByJson(result.Data.(map[string]interface{}), &actMultiChannelQueryInfosResult, false) diff --git a/platformapi/ebaiapi/activity_test.go b/platformapi/ebaiapi/activity_test.go index 4a130060..fdb8ab8c 100644 --- a/platformapi/ebaiapi/activity_test.go +++ b/platformapi/ebaiapi/activity_test.go @@ -1,6 +1,7 @@ package ebaiapi import ( + "fmt" "testing" "time" @@ -103,11 +104,27 @@ func TestActMultiChannelQueryIDs(t *testing.T) { } +//2233065924 +//2233065928 +//2233065934 +//2233065955 +//2233065956 func TestActMultiChannelQueryInfos(t *testing.T) { - result, err := api.ActMultiChannelQueryInfos("6000000418366727", "", 100000045925) - if err != nil { - t.Fatal(err) + for _, v1 := range []int64{2233065924} { // , 2233065928, 2233065934, 2233065955, 2233065956 + acts, err := api.ActMultiChannelQueryIDs("", v1, "2") + fmt.Println(acts) + if err != nil { + fmt.Println(err) + } + for _, v := range acts { + _, err2 := api.ActMultiChannelQueryInfos(utils.Int64ToStr(v), "", v1) + if err2 != nil { + fmt.Println(err2) + } + //t.Log(utils.Format4Output(result, false)) + } } - t.Log(utils.Format4Output(result, false)) + //_, err2 := api.ActMultiChannelQueryInfos("6000000927837760", "", 2233065924) + //fmt.Println(err2) } diff --git a/platformapi/ebaiapi/shop_test.go b/platformapi/ebaiapi/shop_test.go index 53e61271..281e13e7 100644 --- a/platformapi/ebaiapi/shop_test.go +++ b/platformapi/ebaiapi/shop_test.go @@ -169,7 +169,7 @@ func TestShopOpen(t *testing.T) { } func TestShopClose(t *testing.T) { - err := api.ShopClose("", testShopBaiduID) + err := api.ShopClose("", 2233065924) if err != nil { t.Fatal(err) } diff --git a/platformapi/mtwmapi/mtwmapi_test.go b/platformapi/mtwmapi/mtwmapi_test.go index 11877215..5427d527 100644 --- a/platformapi/mtwmapi/mtwmapi_test.go +++ b/platformapi/mtwmapi/mtwmapi_test.go @@ -23,16 +23,10 @@ func init() { //api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "") // 果园 - api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "") + //api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "") //商超 - //api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_nngsVP37s-HXY86xe85H7Q") //token_n4TwqCntWWuvQwAawzxC0w -<<<<<<< HEAD - //api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_rfAD6OxSVxkTeCO1XmNCZg") //token_n4TwqCntWWuvQwAawzxC0w -======= - api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_rn25Arxm_1JSvQM6CWpJzQ") //token_n4TwqCntWWuvQwAawzxC0w ->>>>>>> 9b9473f25286de4923c0006093e3e6c0a928211c - //api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_r36FEse6_ywebQI65FNNWA") //token_n4TwqCntWWuvQwAawzxC0w + api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_vvkN5u8ZfJgjwCQrOUNNsQ") //token_n4TwqCntWWuvQwAawzxC0w cookieStr := ` acctId=57396785; token=0bWbK5VbK50E2BmIhIH2zHB-am_y7mB37yXHm6RLZWx4*; wmPoiId=-1; ` diff --git a/platformapi/mtwmapi/retail_test.go b/platformapi/mtwmapi/retail_test.go index 1ba7b8d0..19b1b0c4 100644 --- a/platformapi/mtwmapi/retail_test.go +++ b/platformapi/mtwmapi/retail_test.go @@ -93,15 +93,36 @@ func TestRetailCatDelete(t *testing.T) { } func TestRetailList(t *testing.T) { - result, err := api.RetailList("785527", 1, 100) - if err != nil { - t.Fatal(err) + offset := 0 + skus := make(map[string]string, 0) + for { + result, err := api.RetailList("17211186", offset, 100) + if err != nil { + t.Fatal(err) + } + if len(result) == 0 { + t.Fatal("should have items") + } + + for _, v := range result { + if v.SkuList != nil && len(v.SkuList) > 0 { + for _, v2 := range v.SkuList { + mapSkuList := utils.Struct2MapByJson(v2) + if mapSkuList["upc"].(string) != "" { + skus[mapSkuList["upc"].(string)] = mapSkuList["price"].(string) + break + } + } + } + } + if len(result) < 100 { + break + } + offset++ } - if len(result) == 0 { - t.Fatal("should have items") - } - t.Log(utils.Format4Output(result, false)) - t.Log(len(result)) + + t.Log(utils.Format4Output(skus, false)) + t.Log(utils.Format4Output(len(skus), false)) } func TestRetailGet(t *testing.T) { diff --git a/platformapi/tiktok_shop/tiktok_api/afs_test.go b/platformapi/tiktok_shop/tiktok_api/afs_test.go index 86f83a45..0aab7bb2 100644 --- a/platformapi/tiktok_shop/tiktok_api/afs_test.go +++ b/platformapi/tiktok_shop/tiktok_api/afs_test.go @@ -8,7 +8,7 @@ import ( ) // 京西速食(蔬菜) -var token1 = `{"access_token":"624d864c-7750-4248-aecf-ac3f75b9b58e","expires_in":1700092125,"scope":"SCOPE","shop_id":57939570,"shop_name":"京西菜市速食","refresh_token":"70f8ffd2-7fe7-44f2-983f-d9db650b9fdb","authority_id":""}` +var token1 = `{"access_token":"74cfcbc2-4515-4a41-b9fb-f29f39efd4ba","expires_in":1700695057,"scope":"SCOPE","shop_id":57939570,"shop_name":"京西菜市速食","refresh_token":"621872c3-5b67-452d-8e45-f5ec25cc1b86","authority_id":""}` // 美好菜市 //var token1 = `{"access_token":"9a315a03-c737-4a82-ae52-c9a6ce827007","expires_in":1699490747,"scope":"SCOPE","shop_id":68032645,"shop_name":"美好菜市","refresh_token":"8334c006-5301-4d25-911b-4d8cc7b70ebb","authority_id":""}` diff --git a/platformapi/tiktok_shop/tiktok_api/settl_bill_detail_test.go b/platformapi/tiktok_shop/tiktok_api/settl_bill_detail_test.go index 3a5ad72a..42cd5feb 100644 --- a/platformapi/tiktok_shop/tiktok_api/settl_bill_detail_test.go +++ b/platformapi/tiktok_shop/tiktok_api/settl_bill_detail_test.go @@ -8,7 +8,7 @@ import ( ) func TestBillDetail(t *testing.T) { - orderDetail, err := a.GetTiktokOrderDetail("6923379475577116595") + orderDetail, err := a.GetTiktokOrderDetail("6923675806562457471") if err != nil { fmt.Println(err) } diff --git a/platformapi/tiktok_shop/tiktok_api/transport_test.go b/platformapi/tiktok_shop/tiktok_api/transport_test.go index e5fa334d..4ea06dd7 100644 --- a/platformapi/tiktok_shop/tiktok_api/transport_test.go +++ b/platformapi/tiktok_shop/tiktok_api/transport_test.go @@ -16,7 +16,7 @@ func TestGetDispatcherInfo(t *testing.T) { } func TestCancelWaybill(t *testing.T) { - err := a.ShopOrderDispatcher(103926218, "6923441722750145796", DispatcherFeeTypeCancel) + err := a.ShopOrderDispatcher(64251630, "6923758679166948853", DispatcherFeeTypeCancel) fmt.Println(err) }