package jdapi import ( "git.rosy.net.cn/baseapi/utils" "testing" ) // //import ( // "fmt" // "testing" // // "git.rosy.net.cn/baseapi" // "git.rosy.net.cn/baseapi/utils" //) // //func TestQueryPageBrandInfo(t *testing.T) { // result, _, err := api.QueryPageBrandInfo(0, 0, 0, "京西") // if err != nil { // t.Fatal(err) // } // if len(result) == 0 { // t.Fatal("QueryPageBrandInfo brand list is empty!") // } // baseapi.SugarLogger.Debug(utils.Format4Output(result, false), err) //} // func TestQueryCategoriesByOrgCode(t *testing.T) { result, err := api.QueryCategoriesByOrgCode() if err != nil { t.Fatal(err) } if len(result) == 0 { t.Fatal("QueryCategoriesByOrgCode category list is empty!") } } func TestChangeShopCategoryOrder(t *testing.T) { var aa = []int64{6836731, 6836749, 6836718, 6836757, 6836770, 6836779, 6836719, 6836720, 6836721, 6836722, 6836793, 6836937, 6836723, 6836724, 6836794, 6836839, 6836725, 6836796, 6836726, 6836797, 6836798, 6836799, 6836727, 6836840, 6836940, 6836800, 6836801, 6836802, 6837303} api.ChangeShopCategoryOrder(0, aa) } // //func TestQueryChildCategoriesForOP(t *testing.T) { // result, err := api.QueryChildCategoriesForOP(0) // if err != nil { // t.Fatal(err) // } // if len(result) == 0 { // t.Fatal("QueryChildCategoriesForOP jd category list is empty!") // } //} // //func TestBatchUpdateOutSkuId(t *testing.T) { // result, err := api.BatchUpdateOutSkuId([]*SkuIDPair{ // &SkuIDPair{ // SkuId: 2037664182, // OutSkuId: "", // }, // }) // baseapi.SugarLogger.Debug(utils.Format4Output(result, false), err) // if err != nil { // t.Fatal(err) // } //} // //func TestQuerySkuInfos(t *testing.T) { // pageSize := MaxSkuIDsCount4QueryListBySkuIds // pageNo := 1 // var skuList []*SkuMain // for { // result, totalCount, err := api.QuerySkuInfos(&QuerySkuParam{ // PageSize: pageSize, // PageNo: pageNo, // IsFilterDel: IsFilterDelTrue, // }) // if err != nil { // t.Fatal(err) // } // skuList = append(skuList, result...) // if len(skuList) >= totalCount { // break // } // pageNo++ // } // var abnormalSkuList []*SkuMain // for _, v := range skuList { // if len(v.ShopCategories) == 0 { // abnormalSkuList = append(abnormalSkuList, v) // } // } // t.Log(utils.Format4Output(abnormalSkuList, false)) // t.Log(len(abnormalSkuList)) //} // //func TestQueryListBySkuIds(t *testing.T) { // ids := []int64{ // 2018806493, // 2018805873, // } // result, err := api.QueryListBySkuIds(&QueryListBySkuIdsParam{ // SkuIDs: ids, // }) // t.Log(utils.Format4Output(result, false)) // if err != nil { // t.Fatal(err) // } // if len(result) != len(ids) { // baseapi.SugarLogger.Debug(result) // t.Fatalf("QueryListBySkuIds result size is not same as requested:%d", len(ids)) // } //} // //func TestQueryKeyWordDicInfo(t *testing.T) { // result, totalCount, err := api.QueryKeyWordDicInfo(0, 0, "") // if err != nil { // t.Fatal(err) // } // if len(result) == 0 || totalCount == 0 { // t.Fatalf("QueryKeyWordDicInfo size is wrong") // } // // baseapi.SugarLogger.Debug(result[0], totalCount) //} // //func TestSyncProduct(t *testing.T) { // _, err := api.SyncProduct("11734846", "2023346662") // if err != nil { // t.Fatal(err) // } // //baseapi.SugarLogger.Debug(result) // //result, err = api.SyncProduct("wrongstoreid", "2022250244") // //if err == nil { // // t.Fatal("SyncProduct should return error") // //} // //result, err = api.SyncProduct(mustExistStoreID, "wrongskuid") // //if err == nil { // // t.Fatal("SyncProduct should return error") // //} //} // //func TestGetProductStatust(t *testing.T) { // result, err := api.GetProductStatus(mustExistStoreID, "2022250244") // if err != nil || result == nil { // t.Fatal(err) // } // // baseapi.SugarLogger.Debug(result) // result, err = api.GetProductStatus("wrongstoreid", "2022250244") // if err == nil { // t.Fatal("GetProductStatus should return error") // } // result, err = api.GetProductStatus(mustExistStoreID, "wrongskuid") // if err == nil { // t.Fatal("GetProductStatus should return error") // } //} // //func TestAddShopCategory(t *testing.T) { // result, err := api.AddShopCategory(0, "hello", 1, 0, "test") // if err != nil { // t.Fatal(err) // } // t.Log(result) //} // //func TestDelShopCategory(t *testing.T) { // map1 := map[string][][]string{ // "363436": [][]string{ // []string{ // "b922658a-8f07-4932-a616-6a4b5347cf0a", "b5e6b41babba4743ab9c0896b9c6003f", "6511abe10f28405081e4f5a351457c22", // }, // []string{ // "5492150", // "5492148", // "5492146", // }, // }, // "363558": [][]string{ // []string{ // "c91173f4-567b-4bc9-a1e3-a1608407ec9d", "349b0b2156de4fd1adec4f34a5ca7247", "bee0d13695e64d13bb93ac9d50b95f94", // }, // []string{ // "5490060", // "5490053", // "5490056", // }, // }, // "363701": [][]string{ // []string{ // "3e21445d-ac39-428e-866c-69dca7b95ddc", "2148e08b14444b73bb04ee8dae4217ac", "7f541ab195934c109b8eee7a56b6f58d", // }, // []string{ // "5498539", // "5498535", // "5498536", // }, // }, // "363739": [][]string{ // []string{ // "fdb687b1-8e0a-4072-b251-04ef6d7a1a92", "218c544106e84cb08cbeed186c0d5bac", "fdd384a632354f189abce33f5a32ea14", // }, // []string{ // "5498692", // "5498688", // "5498689", // }, // }, // "363786": [][]string{ // []string{ // "098c8550-cfe7-4820-91fa-1bbf63ed9b20", "a396d930904047738dc70b6d2eb54e2d", "262f4656f16a48ed94003a1f261cd7d3", // }, // []string{ // "5499968", // "5499966", // "5499964", // }, // }, // "363788": [][]string{ // []string{ // "9b78cbb9-b956-4820-9b2f-330daaed2828", "5ecd3d4b65b44c9f9f820af232110f20", "63b0d12d32734334bf8c95d43e396035", // }, // []string{ // "5500121", // "5500123", // "5500120", // }, // }, // "363892": [][]string{ // []string{ // "163a032f-72df-44c9-a405-b7675e68d2a6", "f40e9fc714e741359c8fc4f2a1ea9e59", "e486c09cfded4fe3a15ee1cff546155f", // }, // []string{ // "5502844", // "5502840", // "5502842", // }, // }, // "363894": [][]string{ // []string{ // "840b4a7c-5b9a-40fc-95e8-e53b56573565", "fbeeef71305c46f192979ca6a00d380c", "feeec4ccf24744d892c4e892f5978847", // }, // []string{ // "5503000", // "5502996", // "5502997", // }, // }, // "363896": [][]string{ // []string{ // "064ee734-e819-455b-b4c4-cc5ee21c6b2f", "ab938148ff0444eba773a7851029d082", "8f659292e639499ca41d39476fc9c2df", // }, // []string{ // "5503152", // "5503150", // "5503151", // }, // }, // } // for _, v := range map1 { // apijd := New(v[0][0], v[0][1], v[0][2]) // for _, vv := range v[1] { // apijd.DelShopCategory(utils.Str2Int64(vv)) // } // } // // err := api.DelShopCategory(5496926) // // if err != nil { // // t.Fatal(err) // // } //} // //func TestGetSkuSaleAttrName(t *testing.T) { // result, err := api.GetSkuSaleAttrName() // if err != nil { // t.Fatal(err) // } // t.Log(utils.Format4Output(result, false)) //} // func TestGetSpuSaleAttr(t *testing.T) { result, err := api.GetSpuSaleAttr("30331") if err != nil { t.Fatal(err) } t.Log(utils.Format4Output(result, false)) } //func TestAddSku(t *testing.T) { // str := ` // {"brandId":35247, // "categoryId":20847, // "fixedStatus":1, // "ifViewDesc":0, // "images":["http://image.jxc4.com/e42be71501d0fbb841743bfb7a9ebbcf.jpg"], // "isSale":false, // "outSkuId":"123", // "shopCategories":[4247719], // "skuName":"黑3龙江冰宝珍珠米10kg/袋", // "skuPrice":7245,"traceId":"4414AEAD1CCA11EAB689525400E86DC0,xujianhua","weight":1} // ` // var param *OpSkuParam // err := utils.UnmarshalUseNumber([]byte(str), ¶m) // if err != nil { // t.Fatal(err) // } // param.Upc = "66660003446710" // result, err := api.AddSku2(param) // if err != nil { // t.Fatal(err) // } // t.Log(utils.Format4Output(result, false)) //} // //func TestBatchAddSku(t *testing.T) { // paramList := []*CreateByUpcParam{ // &CreateByUpcParam{ // UniqueUpc: "6948939649102", // OutSku: "50001", // JdPrice: "2.13", // ShopCategoryID: 4247719, // IsSale: true, // }, // } // result, err := api.BatchAddSku(paramList) // if err != nil { // t.Fatal(err) // } // t.Log(utils.Format4Output(result, false)) //} // //func TestGetSpuStatus(t *testing.T) { // result, err := api.GetSpuStatus("8515") // if err != nil { // t.Fatal(err) // } // t.Log(utils.Format4Output(result, false)) //} // func TestGetSkuStatus(t *testing.T) { result, err := api.GetSkuStatus("6043681") if err != nil { t.Fatal(err) } t.Log(utils.Format4Output(result, false)) } // //func TestUpdateSpuSaleAttr(t *testing.T) { // err := api.UpdateSpuSaleAttr("3628", "1001", "", "10", "hello") // if err != nil { // t.Fatal(err) // } //} // //func TestUpdateSpu(t *testing.T) { // err := api.UpdateSpu("8620", nil) // if err != nil { // t.Fatal(err) // } //} // //func TestUpdateSku(t *testing.T) { // _, err := api.UpdateSku("27379", map[string]interface{}{ // "upc": "ttld20190712", // }) // if err != nil { // t.Fatal(err) // } //} // //func TestUpdateShopCategory(t *testing.T) { // err := api.UpdateShopCategory(4760208, "中秋必抢🍳") // if err != nil { // t.Fatal(err) // } //} // //func TestQueren(t *testing.T) { // for i := 1; i < 85; i++ { // result, _, _ := api.QuerySkuInfos(&QuerySkuParam{ // PageNo: i, // }) // fmt.Println(i) // for _, v := range result { // api.UpdateSku2(&OpSkuParam{ // TraceID: utils.GetUUID(), // OutSkuID: v.OutSkuID, // }) // } // } // // // result, _, err := api.QuerySkuInfos(&QuerySkuParam{ // // PageNo: 1, // // }) // // if err != nil { // // t.Fatal(err) // // } // // t.Log(utils.Format4Output(result, false)) //} // //func TestBatchAddSkuByUPC(t *testing.T) { // result, err := api.BatchAddSkuByUPC([]*CreateByUpcParam2{ // &CreateByUpcParam2{ // OutSkuId: "6048265", // Upc: "6911672042530", // JdPrice: "29800", // ShopCategoryID: 5485102, // }, // }) // if err != nil { // t.Fatal(err) // } // t.Log(utils.Format4Output(result, false)) //}