From ffb7bb81da04dcbb238ac0cb0d769bb3fc529c79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 26 Jan 2024 14:51:34 +0800 Subject: [PATCH] 1 --- platformapi/ebaiapi/shop_sku.go | 89 +++++++++++++++++----------- platformapi/ebaiapi/shop_sku_test.go | 4 +- 2 files changed, 57 insertions(+), 36 deletions(-) diff --git a/platformapi/ebaiapi/shop_sku.go b/platformapi/ebaiapi/shop_sku.go index c289d1c2..3bff2fd4 100644 --- a/platformapi/ebaiapi/shop_sku.go +++ b/platformapi/ebaiapi/shop_sku.go @@ -70,42 +70,62 @@ type SkuCustomCatInfo struct { } type SkuInfo struct { - CustomCatIDs string `json:"custom_cat_ids"` - CustomCatList []*SkuCustomCatInfo `json:"custom_cat_list"` - CustomSkuID string `json:"custom_sku_id"` - IsInActivity int `json:"is_in_activity"` - LeftNum int `json:"left_num"` - MarketPrice int `json:"market_price"` - Minimum int `json:"minimum"` - Name string `json:"name"` - NeedIce int `json:"need_ice"` - Photos []*SkuPhotoInfo `json:"photos"` - PreminusWeight int `json:"preminus_weight"` - PreparationTime string `json:"preparation_time"` - ProductionAddr1 string `json:"production_addr1"` - ProductionAddr2 string `json:"production_addr2"` - ProductionAddr3 string `json:"production_addr3"` - Rtf string `json:"rtf"` - SalePrice int64 `json:"sale_price"` - SaleStep string `json:"sale_step"` - SaleUnit string `json:"sale_unit"` - ShelfNumber string `json:"shelf_number"` - SkuID int64 `json:"sku_id"` - // SkuProperty []interface{} `json:"sku_property"` - Status int `json:"status"` - Summary string `json:"summary"` - Upc string `json:"upc"` - //UpcType string `json:"upc_type"` - UpdateTime string `json:"update_time"` - Weight int `json:"weight"` - WeightFlag int `json:"weight_flag"` + CateId int `json:"cate_id"` + CateId1 int `json:"cate_id1"` + CateId2 int `json:"cate_id2"` + CateName string `json:"cate_name"` + CateName1 string `json:"cate_name1"` + CateName2 string `json:"cate_name2"` + CustomCatIds string `json:"custom_cat_ids"` + CustomSkuId string `json:"custom_sku_id"` + DurationSaleFlag bool `json:"duration_sale_flag"` + IsInActivity int `json:"is_in_activity"` + ItemId int64 `json:"item_id"` + LeftNum int `json:"left_num"` + MarketPrice int `json:"market_price"` + Minimum int `json:"minimum"` + Name string `json:"name"` + NeedIce string `json:"need_ice"` + PackageFlag bool `json:"package_flag"` + Photos []struct { + IsMaster int `json:"is_master"` + Url string `json:"url"` + } `json:"photos"` + PreminusWeight int `json:"preminus_weight"` + PreparationTime int `json:"preparation_time"` + PrescriptionType string `json:"prescription_type"` + ProcessDetail []interface{} `json:"process_detail"` + ProcessType int `json:"process_type"` + ProductionAddr1 string `json:"production_addr1"` + ProductionAddr2 string `json:"production_addr2"` + ProductionAddr3 string `json:"production_addr3"` + Rtf string `json:"rtf"` + SalePrice int `json:"sale_price"` + SaleStep int `json:"sale_step"` + SaleUnit string `json:"sale_unit"` + SevenDaysNoReason bool `json:"seven_days_no_reason"` + SkuId int64 `json:"sku_id"` + SkuProperty []interface{} `json:"sku_property"` + Status string `json:"status"` + Summary string `json:"summary"` + Upc string `json:"upc"` + UpcType int `json:"upc_type"` + Weight string `json:"weight"` + WeightFlag int `json:"weight_flag"` + + CustomCatIDs string `json:"custom_cat_ids"` + CustomCatList []*SkuCustomCatInfo `json:"custom_cat_list"` + CustomSkuID string `json:"custom_sku_id"` + ShelfNumber string `json:"shelf_number"` + UpdateTime string `json:"update_time"` } type PageDataInfo struct { - Total int `json:"Total"` - Page int `json:"Page"` - Pages int `json:"Pages"` - List []*SkuInfo `json:"List"` + Total int `json:"Total"` + Page int `json:"Page"` + Pages int `json:"Pages"` + SkuIdOffset int `json:"sku_id_offset"` + List []*SkuInfo `json:"List"` } type BatchOpSkuResult struct { @@ -289,6 +309,7 @@ func (a *API) SkuGetItemsByCategoryId(shopID string, categoryID int64) (skus []m // 此函数查不到结果是不会报错的 func (a *API) SkuList(shopID string, params *SkuListParams) (skuInfo *PageDataInfo, err error) { + params.PageSize = 100 paramMap := utils.Struct2FlatMap(params) paramMap[KeyShopID] = shopID result, err := a.AccessAPI("sku.list", paramMap) @@ -585,7 +606,7 @@ func (a *API) GetEbaiSkuIDFromCustomID(shopID, customSkuID string) (ebaiSkuID in if skuInfo, err2 := a.SkuList(shopID, &SkuListParams{ CustomSkuID: customSkuID, }); err2 == nil && skuInfo != nil && len(skuInfo.List) > 0 { - ebaiSkuID = skuInfo.List[0].SkuID + ebaiSkuID = skuInfo.List[0].SkuId } return ebaiSkuID } diff --git a/platformapi/ebaiapi/shop_sku_test.go b/platformapi/ebaiapi/shop_sku_test.go index 8925dca8..8ae72285 100644 --- a/platformapi/ebaiapi/shop_sku_test.go +++ b/platformapi/ebaiapi/shop_sku_test.go @@ -40,7 +40,7 @@ func TestShopCategoryDelete(t *testing.T) { } func TestSkuGetItemsByCategoryId(t *testing.T) { - result, err := api.SkuGetItemsByCategoryId(testShopID, 153838813210900) + result, err := api.SkuGetItemsByCategoryId("667544", 153838813210900) if err != nil { t.Fatal(err) } else { @@ -307,7 +307,7 @@ func TestDeleteSku(t *testing.T) { fmt.Println(err2) } for _, v := range skuInfo2.List { - skuIds = append(skuIds, v.SkuID) + skuIds = append(skuIds, v.SkuId) } } for i := 1; i <= skuInfo.Pages; i++ {