1
This commit is contained in:
@@ -30,7 +30,9 @@ func init() {
|
||||
// 天天果园
|
||||
//api = New("c45e6510-00ba-4be2-977e-bcb9c9792cc7", "5d5577a2506f41b8b4ec520ba83490f5", "0b01b9eeb15b41dab1c3d05d95c17a26")
|
||||
// 京东果园 320406
|
||||
api = New("1e87595b-e850-4ba4-9ee0-53bcfe383a4f", "1dba76d40cac446ca500c0391a0b6c9d", "a88d031a1e7b462cb1579f12e97fe7f4")
|
||||
//api = New("1e87595b-e850-4ba4-9ee0-53bcfe383a4f", "1dba76d40cac446ca500c0391a0b6c9d", "a88d031a1e7b462cb1579f12e97fe7f4")
|
||||
// 京东白货
|
||||
api = New("9053e4fd-4e0e-4e9e-8ab1-f348e5cbf3e7", "4602bd4b84984186815dbc03299c7094", "386ab19719d9470487011217d0c57349")
|
||||
// 果切 379599
|
||||
//api = New("ad4061a1-6a5c-43f9-bf51-b1232fd9499d", "f2ed33075faf4773a47e065acd79532b", "aed14cbbecac4456843570e90c5f46ec")
|
||||
// 381564
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestQueryPageBrandInfo(t *testing.T) {
|
||||
@@ -33,241 +34,6 @@ func TestGetSkuCategoryByName(t *testing.T) {
|
||||
globals.SugarLogger.Debugf("data:=%v", err)
|
||||
}
|
||||
|
||||
//
|
||||
//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 {
|
||||
@@ -276,57 +42,6 @@ func TestGetSpuSaleAttr(t *testing.T) {
|
||||
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 {
|
||||
@@ -335,71 +50,22 @@ func TestGetSkuStatus(t *testing.T) {
|
||||
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))
|
||||
//}
|
||||
func TestDelete(t *testing.T) {
|
||||
for i := 0; i < 15; i++ {
|
||||
idList, _ := api.AuerySkuInfoList(int64(i), 20)
|
||||
if len(idList) != 0 {
|
||||
globals.SugarLogger.Debugf("------len := %d", len(idList))
|
||||
}
|
||||
for _, i3 := range idList {
|
||||
param := &OpSkuParam{
|
||||
TraceID: utils.Int64ToStr(time.Now().UnixNano()) + "_" + i3,
|
||||
OutSkuID: i3,
|
||||
FixedStatus: SkuFixedStatusDeleted,
|
||||
}
|
||||
delSkuId, err := api.UpdateSku2(param)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("---skuId := %s,err := %v", delSkuId, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package jdapi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
@@ -334,12 +335,63 @@ func (a *API) DelVipPrice(outStationNo string, skuIds []*SkuIdEntity) (err error
|
||||
}
|
||||
|
||||
// AuerySkuInfoList 查询已经上传的商品列表
|
||||
func (a *API) AuerySkuInfoList(pageNo, pageSize int64) error {
|
||||
func (a *API) AuerySkuInfoList(pageNo, pageSize int64) ([]string, error) {
|
||||
jdParams := map[string]interface{}{
|
||||
"pageNo": pageNo,
|
||||
"pageSize": pageSize,
|
||||
}
|
||||
data, err := a.AccessAPINoPage("pms/querySkuInfoList", jdParams, nil, nil, genNoPageResultParser("code", "msg", "", "0"))
|
||||
fmt.Println(data)
|
||||
return err
|
||||
data, err := a.AccessAPINoPage("pms/querySkuInfoList", jdParams, nil, nil, genNoPageResultParser("code", "msg", "result", "0"))
|
||||
skuList := data.(map[string]interface{})["result"]
|
||||
|
||||
sku := make([]*JDSkuList, 0, 0)
|
||||
json.Unmarshal([]byte(skuList.(string)), &sku)
|
||||
|
||||
skuId := make([]string, 0, 0)
|
||||
for _, list := range sku {
|
||||
if list.OutSkuId != "" {
|
||||
skuId = append(skuId, list.OutSkuId)
|
||||
}
|
||||
}
|
||||
return skuId, err
|
||||
}
|
||||
|
||||
type JDSkuList struct {
|
||||
SkuId int64 `json:"skuId"`
|
||||
OutSkuId string `json:"outSkuId"`
|
||||
OrgCode int `json:"orgCode"`
|
||||
CategoryId int `json:"categoryId"`
|
||||
BrandId int `json:"brandId"`
|
||||
SkuName string `json:"skuName"`
|
||||
Slogan string `json:"slogan"`
|
||||
SkuPrice int `json:"skuPrice"`
|
||||
StockNum int `json:"stockNum"`
|
||||
Weight float64 `json:"weight"`
|
||||
ProductLocation string `json:"productLocation"`
|
||||
Producter string `json:"producter"`
|
||||
UpcCode string `json:"upcCode"`
|
||||
FixedUpTime string `json:"fixedUpTime,omitempty"`
|
||||
FixedDownTime string `json:"fixedDownTime"`
|
||||
FixedStatus int `json:"fixedStatus"`
|
||||
ShopCategories []int `json:"shopCategories"`
|
||||
PriceUnit string `json:"priceUnit"`
|
||||
PrefixKey string `json:"prefixKey"`
|
||||
SuffixKey string `json:"suffixKey"`
|
||||
IsBreakable int `json:"isBreakable,omitempty"`
|
||||
LiquidStatue string `json:"liquidStatue,omitempty"`
|
||||
Prescripition string `json:"prescripition,omitempty"`
|
||||
HighSingularValue string `json:"highSingularValue,omitempty"`
|
||||
BusinessMark []interface{} `json:"businessMark,omitempty"`
|
||||
SellCities []int `json:"sellCities"`
|
||||
PackageFee float64 `json:"packageFee"`
|
||||
SuperName string `json:"superName"`
|
||||
SaleAttrValueId string `json:"saleAttrValueId"`
|
||||
SaleAttrValueName string `json:"saleAttrValueName"`
|
||||
SloganStartTime string `json:"sloganStartTime,omitempty"`
|
||||
SloganEndTime string `json:"sloganEndTime,omitempty"`
|
||||
Length int `json:"length,omitempty"`
|
||||
Wide int `json:"wide,omitempty"`
|
||||
High int `json:"high,omitempty"`
|
||||
TransportAttribute string `json:"transportAttribute,omitempty"`
|
||||
FixedType int `json:"fixedType,omitempty"`
|
||||
SuperId int `json:"superId,omitempty"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user