From 8a7a94368ed3c0489218576c9a4f8dc27d743639 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Fri, 21 Feb 2020 13:32:33 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E9=A5=BF=E9=B2=9C=E6=89=93?= =?UTF-8?q?=E5=85=A8=E5=9B=BD=E8=B4=A6=E5=8F=B7=E5=95=86=E5=93=81=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platformapi/ebaiapi/store_page.go | 59 ++++++++++++++++++++++++++ platformapi/ebaiapi/store_page_test.go | 10 +++++ 2 files changed, 69 insertions(+) diff --git a/platformapi/ebaiapi/store_page.go b/platformapi/ebaiapi/store_page.go index e33cfc2a..88d488ae 100644 --- a/platformapi/ebaiapi/store_page.go +++ b/platformapi/ebaiapi/store_page.go @@ -32,6 +32,8 @@ const ( ShopStatusOnLine = 1 //饿百商家中心商户 上线 ShopStatusOffLine = 2 //饿百商家中心商户 未上线 ProxyBusinessState = 10 //饿百商家中心商户,除正常营业外的状态 + + EbaiWholeCountryStore = "22267110836" ) type PageShopUserInfo struct { @@ -572,6 +574,28 @@ type EbaiSku struct { } `json:"ctrl_edit"` } +type EbaiSkuList struct { + UpcID string `json:"upc_id"` + UpcType string `json:"upc_type"` + Photos string `json:"photos"` + UpcName string `json:"upc_name"` + Upc string `json:"upc"` + BrandID string `json:"brand_id"` + Weight string `json:"weight"` + Wid string `json:"wid"` + Enabled string `json:"enabled"` + Cat1ID string `json:"cat1_id"` + Cat2ID string `json:"cat2_id"` + Cat3ID string `json:"cat3_id"` + BrandName string `json:"brand_name"` + PhotosList []struct { + URL string `json:"url"` + IsMaster int `json:"is_master"` + } `json:"photos_list"` + Shopsku int `json:"shopsku"` + IsInActivity int `json:"is_in_activity"` +} + func (a *API) AccessStorePage2(subURL, storeURL2 string, params map[string]interface{}, isPost bool, cookies map[string]string) (retVal map[string]interface{}, err error) { if a.GetCookieCount() == 0 { return nil, fmt.Errorf("需要设置Store Cookie才能使用此方法") @@ -1080,3 +1104,38 @@ func (a *API) GetExianDaSku(exdSkuID int64) (results *ExianDaSku, err error) { utils.Map2StructByJson(result["data"], &results, false) return results, err } + +//查询饿百全国账号商品库商品 +func (a *API) GetEbaiDepotSku(supplierID string, upc string) (ebaiSkuList []*EbaiSkuList, err error) { + params := map[string]interface{}{ + "wid": 0, + "supplierId": supplierID, + "upc": upc, + "curpage": 1, + "perpage": 20, + } + result, err := a.AccessStorePage("commodity/getsuppliergoods", "", params, false) + if err == nil { + err2 := utils.Map2StructByJson(result["sku_list"], &ebaiSkuList, false) + if err2 != nil { + return ebaiSkuList, err + } + } + return ebaiSkuList, err +} + +//查询饿百商品,根据upc +func (a *API) GetEbaiSku(upcID string, supplierID string) (ebaiSku *EbaiSku, err error) { + params := map[string]interface{}{ + "supplierId": supplierID, + "upc_id": upcID, + } + result, err := a.AccessStorePage("commodity/getsku", "", params, false) + if err == nil { + err2 := utils.Map2StructByJson(result, &ebaiSku, false) + if err2 != nil { + return ebaiSku, err + } + } + return ebaiSku, err +} diff --git a/platformapi/ebaiapi/store_page_test.go b/platformapi/ebaiapi/store_page_test.go index dfe4bd2f..8aa68720 100644 --- a/platformapi/ebaiapi/store_page_test.go +++ b/platformapi/ebaiapi/store_page_test.go @@ -169,3 +169,13 @@ func TestPageGetSku(t *testing.T) { result, _ := api.PageGetSku(32267350915, 15813853840796298) t.Log(utils.Format4Output(result, false)) } + +func TestGetEbaiDepotSku(t *testing.T) { + result, _ := api.GetEbaiDepotSku(EbaiWholeCountryStore, "190700570") + t.Log(utils.Format4Output(result, false)) +} + +func TestGetEbaiSku(t *testing.T) { + result, _ := api.GetEbaiSku("1578500400097", EbaiWholeCountryStore) + t.Log(utils.Format4Output(result, false)) +}