Merge branch 'master' of e.coding.net:rosydev/baseapi
This commit is contained in:
@@ -1,399 +1,400 @@
|
||||
package jdapi
|
||||
|
||||
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 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("3628")
|
||||
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("6092943")
|
||||
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))
|
||||
}
|
||||
//
|
||||
//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 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("3628")
|
||||
// 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("6092943")
|
||||
// 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))
|
||||
//}
|
||||
|
||||
@@ -1,324 +1,325 @@
|
||||
package jdapi
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
|
||||
var (
|
||||
skuNamePat = regexp.MustCompile(`([\((\[【][^\((\[【\))\]】]*[\))\]】])?(.*?)([((].*[))])?\s*约?([1-9][\d\.]*)(g|G|kg|mg|kG|Kg|KG|l|L|ml|mL|Ml|ML|克)\s*([((].*[))])?\s*(?:\/|/|)\s*([^\s()()]{0,2})(\s.*)?$\s*([((].*[))])?$`)
|
||||
)
|
||||
|
||||
func TestGetRealMobileNumber4Order(t *testing.T) {
|
||||
orderId := "921823424000122"
|
||||
desiredMobile := "13722455105"
|
||||
mobile, err := api.GetRealMobile4Order(orderId, "11893205")
|
||||
fmt.Println("1111111111111111", mobile, err.Error())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if mobile != desiredMobile {
|
||||
t.Fatalf("orderId:%s's mobile is wrong, should be %s, but it's:%s", orderId, desiredMobile, mobile)
|
||||
}
|
||||
baseapi.SugarLogger.Debug(mobile)
|
||||
}
|
||||
|
||||
func TestGetStoreOrderInfo(t *testing.T) {
|
||||
orderId := "2113752262000061"
|
||||
orderInfo, err := api.GetStoreOrderInfo(orderId, "11930291")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
baseapi.SugarLogger.Debug(utils.Format4Output(orderInfo, false))
|
||||
}
|
||||
|
||||
func TestGetStoreOrderInfoList(t *testing.T) {
|
||||
orderInfoList, err := api.GetStoreOrderInfoList("2018-05-01 12:00:00", "2018-05-01 12:59:59")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if true {
|
||||
baseapi.SugarLogger.Debug(utils.Format4Output(orderInfoList, false))
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetSkuPageInfo(t *testing.T) {
|
||||
skuInfo, err := api.GetSkuPageInfo(2023524346)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
baseapi.SugarLogger.Debug(utils.Format4Output(skuInfo, false))
|
||||
}
|
||||
|
||||
func TestGetSkuPageImageInfo(t *testing.T) {
|
||||
imgList, err := api.GetSkuPageImageInfo(2025112058)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
baseapi.SugarLogger.Debug(utils.Format4Output(imgList, false))
|
||||
}
|
||||
|
||||
func TestGetCorporationInfo(t *testing.T) {
|
||||
imgList, err := api.GetCorporationInfo("", "92330104MA28XPXH5G")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
baseapi.SugarLogger.Debug(utils.Format4Output(imgList, false))
|
||||
}
|
||||
|
||||
func TestGetStoreList(t *testing.T) {
|
||||
result, err := api.GetStoreList("104.054195", "30.581782")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestGetStoreInfo(t *testing.T) {
|
||||
result, err := api.GetStoreInfo("11750116")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestGetStoreInfo2(t *testing.T) {
|
||||
result, err := api.GetStoreInfo2("11883852")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestMonthSaleNum2Int(t *testing.T) {
|
||||
num1 := MonthSaleNum2Int("1千+")
|
||||
if num1 != 1000 {
|
||||
t.Fatalf("num1:%d", num1)
|
||||
}
|
||||
num2 := MonthSaleNum2Int("2万+")
|
||||
if num2 != 20000 {
|
||||
t.Fatalf("num2:%d", num2)
|
||||
}
|
||||
num3 := MonthSaleNum2Int("234")
|
||||
if num3 != 234 {
|
||||
t.Fatalf("num3:%d", num3)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStoreUploadImgByURL(t *testing.T) {
|
||||
outImgURL, err := api.StoreUploadImgByURL("http://image.jxc4.com/940c151db7e396f2ceaec0304597836f.jpg")
|
||||
t.Log(outImgURL)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSaveQualify(t *testing.T) {
|
||||
jsonStr := `
|
||||
[
|
||||
{"qualifyUrl":"http://img30.360buyimg.com/vendersettle/jfs/t1/169610/5/8031/168819/60386ed6E3e1d3543/34b3856c9e4e1282.jpg","qualifyType":"25","qualifyExpireForever":0,"qualifyExpireStart":"2020-11-04+00:00:00","qualifyName":"左凤娟","licenceType":"-1","qualifyNumber":"92331002MA2HJU1Q0J","qualifyAddress":"浙江省台州市椒江区白云街道花园新村60号楼二单元101室车库(自主申报)","licenceName":"台州市椒江彤彤蔬菜经营部","econKind":"个体工商户","scope":"一般项目:小食杂店(三小行业);食用农产品零售(除依法须经批准的项目外,凭营业执照依法自主开展经营活动)。"},{"qualifyUrl":"http://img30.360buyimg.com/vendersettle/jfs/t1/154609/37/19742/6390/60386ed6E9caa7248/a25278c9d3b01428.jpg","qualifyType":"22","qualifyExpireForever":1,"qualifyExpireStart":"2012-02-22+00:00:00","qualifyExpireEnd":"2022-02-22+00:00:00","qualifyOwner":"左凤娟","qualifyNumber":"411481198912063324"}
|
||||
]
|
||||
`
|
||||
var qualityList []*QualifyItem
|
||||
err := utils.UnmarshalUseNumber([]byte(jsonStr), &qualityList)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
err = api.SaveQualify("12085905", 0, qualityList)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetJdUserBindStoreIDs(t *testing.T) {
|
||||
vv, err := api.GetJdUserBindStoreIDs(339890)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
fmt.Println(vv)
|
||||
}
|
||||
|
||||
func TestPrivilegeSearchUser(t *testing.T) {
|
||||
list, _ := api.PrivilegeSearchUserAll()
|
||||
for _, v := range list {
|
||||
fmt.Println(v.LoginName)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPrivilegeUpdateJdUserStatus(t *testing.T) {
|
||||
result, err := api.PrivilegeUpdateJdUserStatus(339020, 1)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
func TestUpdateJdUserRoles(t *testing.T) {
|
||||
result, err := api.UpdateJdUserRoles(345919, []string{"28926"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
func TestIsJdManagerUser(t *testing.T) {
|
||||
aa, _ := api.IsJdManagerUser(334683)
|
||||
fmt.Println(aa)
|
||||
}
|
||||
|
||||
func TestGetJdStoreLevel(t *testing.T) {
|
||||
api.GetJdStoreLevel("320406", "11732427", 1)
|
||||
}
|
||||
|
||||
func TestGetJdUpcCodeByName(t *testing.T) {
|
||||
result, err := api.GetJdUpcCodeByName("", "6920174736731", 1, 5)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestGetJdSkuDirectPrice(t *testing.T) {
|
||||
result, err := api.GetJdSkuDirectPrice(31031)
|
||||
fmt.Println("test1", result, err)
|
||||
}
|
||||
|
||||
func TestSearchDeleteWare(t *testing.T) {
|
||||
var (
|
||||
page = 1
|
||||
pageSize = 20
|
||||
searchResults []*SearchDeleteWareResult
|
||||
)
|
||||
for ; page < 367; page++ {
|
||||
searchDeleteWareResults, err := api.SearchDeleteWare("2020-04-22", "2020-04-23", page, pageSize)
|
||||
if err == nil && len(searchDeleteWareResults) > 0 {
|
||||
searchResults = append(searchResults, searchDeleteWareResults...)
|
||||
}
|
||||
}
|
||||
fmt.Println(utils.Format4Output(searchResults, false))
|
||||
}
|
||||
|
||||
func TestGetJdStoreID(t *testing.T) {
|
||||
result, err := api.GetJdStoreID(801246)
|
||||
fmt.Println("test1", result, err)
|
||||
}
|
||||
|
||||
func TestUpdateClosetStatus(t *testing.T) {
|
||||
err := api.UpdateClosetStatus(801246, 1)
|
||||
fmt.Println("test1", err)
|
||||
}
|
||||
|
||||
func TestGetJdShopOrders(t *testing.T) {
|
||||
result, err := api.GetJdShopOrders("20210501", "20210531", "320406", "jd_jxcs1223")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestGetJdTopSkus(t *testing.T) {
|
||||
// err := api.GetJdStoreInfo("12050477")
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// t.Log(utils.Format4Output(result, false))
|
||||
s1 := "ymbgaraibkfmvocpizdydugvalagaivdbfsfbepeyccqfepzvtpyxtbadkhmwmoswrcxnargtlswqemafandgkmydtimuzvjwxvlfwlhvkrgcsithaqlcvrihrwqkpjdhgfgreqoxzfvhjzojhghfwbvpfzectwwhexthbsndovxejsntmjihchaotbgcysfdaojkjldprwyrnischrgmtvjcorypvopfmegizfkvudubnejzfqffvgdoxohuinkyygbdzmshvyqyhsozwvlhevfepdvafgkqpkmcsikfyxczcovrmwqxxbnhfzcjjcpgzjjfateajnnvlbwhyppdleahgaypxidkpwmfqwqyofwdqgxhjaxvyrzupfwesmxbjszolgwqvfiozofncbohduqgiswuiyddmwlwubetyaummenkdfptjczxemryuotrrymrfdxtrebpbjtpnuhsbnovhectpjhfhahbqrfbyxggobsweefcwxpqsspyssrmdhuelkkvyjxswjwofngpwfxvknkjviiavorwyfzlnktmfwxkvwkrwdcxjfzikdyswsuxegmhtnxjraqrdchaauazfhtklxsksbhwgjphgbasfnlwqwukprgvihntsyymdrfovaszjywuqygpvjtvlsvvqbvzsmgweiayhlubnbsitvfxawhfmfiatxvqrcwjshvovxknnxnyyfexqycrlyksderlqarqhkxyaqwlwoqcribumrqjtelhwdvaiysgjlvksrfvjlcaiwrirtkkxbwgicyhvakxgdjwnwmubkiazdjkfmotglclqndqjxethoutvjchjbkoasnnfbgrnycucfpeovruguzumgmgddqwjgdvaujhyqsqtoexmnfuluaqbxoofvotvfoiexbnprrxptchmlctzgqtkivsilwgwgvpidpvasurraqfkcmxhdapjrlrnkbklwkrvoaziznlpor"
|
||||
s2 := "qhxepbshlrhoecdaodgpousbzfcqjxulatciapuftffahhlmxbufgjuxstfjvljybfxnenlacmjqoymvamphpxnolwijwcecgwbcjhgdybfffwoygikvoecdggplfohemfypxfsvdrseyhmvkoovxhdvoavsqqbrsqrkqhbtmgwaurgisloqjixfwfvwtszcxwktkwesaxsmhsvlitegrlzkvfqoiiwxbzskzoewbkxtphapavbyvhzvgrrfriddnsrftfowhdanvhjvurhljmpxvpddxmzfgwwpkjrfgqptrmumoemhfpojnxzwlrxkcafvbhlwrapubhveattfifsmiounhqusvhywnxhwrgamgnesxmzliyzisqrwvkiyderyotxhwspqrrkeczjysfujvovsfcfouykcqyjoobfdgnlswfzjmyucaxuaslzwfnetekymrwbvponiaojdqnbmboldvvitamntwnyaeppjaohwkrisrlrgwcjqqgxeqerjrbapfzurcwxhcwzugcgnirkkrxdthtbmdqgvqxilllrsbwjhwqszrjtzyetwubdrlyakzxcveufvhqugyawvkivwonvmrgnchkzdysngqdibhkyboyftxcvvjoggecjsajbuqkjjxfvynrjsnvtfvgpgveycxidhhfauvjovmnbqgoxsafknluyimkczykwdgvqwlvvgdmufxdypwnajkncoynqticfetcdafvtqszuwfmrdggifokwmkgzuxnhncmnsstffqpqbplypapctctfhqpihavligbrutxmmygiyaklqtakdidvnvrjfteazeqmbgklrgrorudayokxptswwkcircwuhcavhdparjfkjypkyxhbgwxbkvpvrtzjaetahmxevmkhdfyidhrdeejapfbafwmdqjqszwnwzgclitdhlnkaiyldwkwwzvhyorgbysyjbxsspnjdewjxbhpsvj"
|
||||
fmt.Println(string(findTheDifference(s1, s2)))
|
||||
}
|
||||
|
||||
func findTheDifference(s string, t string) byte {
|
||||
var (
|
||||
map1 = make(map[byte]int)
|
||||
map2 = make(map[byte]int)
|
||||
)
|
||||
if s == "" {
|
||||
return []byte(t)[0]
|
||||
}
|
||||
for k, _ := range s {
|
||||
map1[s[k]]++
|
||||
}
|
||||
for k, _ := range t {
|
||||
map2[t[k]]++
|
||||
}
|
||||
for k, v := range map1 {
|
||||
if map2[k] != v {
|
||||
return k
|
||||
}
|
||||
}
|
||||
for k, v := range t {
|
||||
if k == len(t)-1 {
|
||||
return t[k]
|
||||
} else {
|
||||
if strings.Index(string(v), string(s[k])) == -1 {
|
||||
return t[k]
|
||||
}
|
||||
}
|
||||
}
|
||||
return []byte(t)[0]
|
||||
}
|
||||
|
||||
func TestGetJdStoreInfo(t *testing.T) {
|
||||
str := "汤臣倍健 辅酶Q10天然维生素E软胶囊 400mg*60粒/瓶"
|
||||
searchResult := skuNamePat.FindStringSubmatch(str)
|
||||
fmt.Println(searchResult)
|
||||
}
|
||||
|
||||
func TestUpdateInterStatus(t *testing.T) {
|
||||
err := api.UpdateInterStatus("f93ddfb7034b468da4d1ef10abe4b3ab", "message.djsw.newOrder", 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// fmt.Println(result)
|
||||
}
|
||||
|
||||
func TestSaveMsgUrl(t *testing.T) {
|
||||
err := api.SaveMsgUrl("f93ddfb7034b468da4d1ef10abe4b3ab", "http://callback.test.jxc4.com", "http://callback.jxc4.com", 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// fmt.Println(result)
|
||||
}
|
||||
|
||||
func TestExcuteInvoking(t *testing.T) {
|
||||
err := api.ExcuteInvoking("e95911589479472e8b6f4d099ad343b5", 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// fmt.Println(result)
|
||||
}
|
||||
|
||||
func TestPeiZhiJdZhangHao(t *testing.T) {
|
||||
for k, v := range interfaceMap {
|
||||
if err := api.UpdateInterStatus(k, v[0].(string), v[1].(int)); err == nil {
|
||||
if err2 := api.SaveMsgUrl(k, "http://callback.test.jxc4.com", "http://callback.jxc4.com", v[1].(int)); err2 == nil {
|
||||
if err3 := api.ExcuteInvoking(k, v[1].(int)); err3 == nil {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if err := api.SaveCheckedInters(); err == nil {
|
||||
time.Sleep(time.Second * 2)
|
||||
api.ToOnline()
|
||||
}
|
||||
}
|
||||
|
||||
func TestQueryMemberTransListByCondition(t *testing.T) {
|
||||
result, err := api.QueryMemberTransListByCondition("", "", 4, 200)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
type GuoMei struct {
|
||||
appKey string
|
||||
timestamp string
|
||||
sign string
|
||||
}
|
||||
//
|
||||
//import (
|
||||
// "fmt"
|
||||
// "regexp"
|
||||
// "strings"
|
||||
// "testing"
|
||||
// "time"
|
||||
//
|
||||
// "git.rosy.net.cn/baseapi"
|
||||
// "git.rosy.net.cn/baseapi/utils"
|
||||
//)
|
||||
//
|
||||
//var (
|
||||
// skuNamePat = regexp.MustCompile(`([\((\[【][^\((\[【\))\]】]*[\))\]】])?(.*?)([((].*[))])?\s*约?([1-9][\d\.]*)(g|G|kg|mg|kG|Kg|KG|l|L|ml|mL|Ml|ML|克)\s*([((].*[))])?\s*(?:\/|/|)\s*([^\s()()]{0,2})(\s.*)?$\s*([((].*[))])?$`)
|
||||
//)
|
||||
//
|
||||
//func TestGetRealMobileNumber4Order(t *testing.T) {
|
||||
// orderId := "921823424000122"
|
||||
// desiredMobile := "13722455105"
|
||||
// mobile, err := api.GetRealMobile4Order(orderId, "11893205")
|
||||
// fmt.Println("1111111111111111", mobile, err.Error())
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// if mobile != desiredMobile {
|
||||
// t.Fatalf("orderId:%s's mobile is wrong, should be %s, but it's:%s", orderId, desiredMobile, mobile)
|
||||
// }
|
||||
// baseapi.SugarLogger.Debug(mobile)
|
||||
//}
|
||||
//
|
||||
//func TestGetStoreOrderInfo(t *testing.T) {
|
||||
// orderId := "2113752262000061"
|
||||
// orderInfo, err := api.GetStoreOrderInfo(orderId, "11930291")
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// baseapi.SugarLogger.Debug(utils.Format4Output(orderInfo, false))
|
||||
//}
|
||||
//
|
||||
//func TestGetStoreOrderInfoList(t *testing.T) {
|
||||
// orderInfoList, err := api.GetStoreOrderInfoList("2018-05-01 12:00:00", "2018-05-01 12:59:59")
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// if true {
|
||||
// baseapi.SugarLogger.Debug(utils.Format4Output(orderInfoList, false))
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func TestGetSkuPageInfo(t *testing.T) {
|
||||
// skuInfo, err := api.GetSkuPageInfo(2023524346)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// baseapi.SugarLogger.Debug(utils.Format4Output(skuInfo, false))
|
||||
//}
|
||||
//
|
||||
//func TestGetSkuPageImageInfo(t *testing.T) {
|
||||
// imgList, err := api.GetSkuPageImageInfo(2025112058)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// baseapi.SugarLogger.Debug(utils.Format4Output(imgList, false))
|
||||
//}
|
||||
//
|
||||
//func TestGetCorporationInfo(t *testing.T) {
|
||||
// imgList, err := api.GetCorporationInfo("", "92330104MA28XPXH5G")
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// baseapi.SugarLogger.Debug(utils.Format4Output(imgList, false))
|
||||
//}
|
||||
//
|
||||
//func TestGetStoreList(t *testing.T) {
|
||||
// result, err := api.GetStoreList("104.054195", "30.581782")
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// t.Log(utils.Format4Output(result, false))
|
||||
//}
|
||||
//
|
||||
//func TestGetStoreInfo(t *testing.T) {
|
||||
// result, err := api.GetStoreInfo("11750116")
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// t.Log(utils.Format4Output(result, false))
|
||||
//}
|
||||
//
|
||||
//func TestGetStoreInfo2(t *testing.T) {
|
||||
// result, err := api.GetStoreInfo2("11883852")
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// t.Log(utils.Format4Output(result, false))
|
||||
//}
|
||||
//
|
||||
//func TestMonthSaleNum2Int(t *testing.T) {
|
||||
// num1 := MonthSaleNum2Int("1千+")
|
||||
// if num1 != 1000 {
|
||||
// t.Fatalf("num1:%d", num1)
|
||||
// }
|
||||
// num2 := MonthSaleNum2Int("2万+")
|
||||
// if num2 != 20000 {
|
||||
// t.Fatalf("num2:%d", num2)
|
||||
// }
|
||||
// num3 := MonthSaleNum2Int("234")
|
||||
// if num3 != 234 {
|
||||
// t.Fatalf("num3:%d", num3)
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func TestStoreUploadImgByURL(t *testing.T) {
|
||||
// outImgURL, err := api.StoreUploadImgByURL("http://image.jxc4.com/940c151db7e396f2ceaec0304597836f.jpg")
|
||||
// t.Log(outImgURL)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func TestSaveQualify(t *testing.T) {
|
||||
// jsonStr := `
|
||||
// [
|
||||
// {"qualifyUrl":"http://img30.360buyimg.com/vendersettle/jfs/t1/169610/5/8031/168819/60386ed6E3e1d3543/34b3856c9e4e1282.jpg","qualifyType":"25","qualifyExpireForever":0,"qualifyExpireStart":"2020-11-04+00:00:00","qualifyName":"左凤娟","licenceType":"-1","qualifyNumber":"92331002MA2HJU1Q0J","qualifyAddress":"浙江省台州市椒江区白云街道花园新村60号楼二单元101室车库(自主申报)","licenceName":"台州市椒江彤彤蔬菜经营部","econKind":"个体工商户","scope":"一般项目:小食杂店(三小行业);食用农产品零售(除依法须经批准的项目外,凭营业执照依法自主开展经营活动)。"},{"qualifyUrl":"http://img30.360buyimg.com/vendersettle/jfs/t1/154609/37/19742/6390/60386ed6E9caa7248/a25278c9d3b01428.jpg","qualifyType":"22","qualifyExpireForever":1,"qualifyExpireStart":"2012-02-22+00:00:00","qualifyExpireEnd":"2022-02-22+00:00:00","qualifyOwner":"左凤娟","qualifyNumber":"411481198912063324"}
|
||||
// ]
|
||||
// `
|
||||
// var qualityList []*QualifyItem
|
||||
// err := utils.UnmarshalUseNumber([]byte(jsonStr), &qualityList)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// err = api.SaveQualify("12085905", 0, qualityList)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func TestGetJdUserBindStoreIDs(t *testing.T) {
|
||||
// vv, err := api.GetJdUserBindStoreIDs(339890)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// fmt.Println(vv)
|
||||
//}
|
||||
//
|
||||
//func TestPrivilegeSearchUser(t *testing.T) {
|
||||
// list, _ := api.PrivilegeSearchUserAll()
|
||||
// for _, v := range list {
|
||||
// fmt.Println(v.LoginName)
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func TestPrivilegeUpdateJdUserStatus(t *testing.T) {
|
||||
// result, err := api.PrivilegeUpdateJdUserStatus(339020, 1)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// fmt.Println(result)
|
||||
//}
|
||||
//
|
||||
//func TestUpdateJdUserRoles(t *testing.T) {
|
||||
// result, err := api.UpdateJdUserRoles(345919, []string{"28926"})
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// fmt.Println(result)
|
||||
//}
|
||||
//
|
||||
//func TestIsJdManagerUser(t *testing.T) {
|
||||
// aa, _ := api.IsJdManagerUser(334683)
|
||||
// fmt.Println(aa)
|
||||
//}
|
||||
//
|
||||
//func TestGetJdStoreLevel(t *testing.T) {
|
||||
// api.GetJdStoreLevel("320406", "11732427", 1)
|
||||
//}
|
||||
//
|
||||
//func TestGetJdUpcCodeByName(t *testing.T) {
|
||||
// result, err := api.GetJdUpcCodeByName("", "6920174736731", 1, 5)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// t.Log(utils.Format4Output(result, false))
|
||||
//}
|
||||
//
|
||||
//func TestGetJdSkuDirectPrice(t *testing.T) {
|
||||
// result, err := api.GetJdSkuDirectPrice(31031)
|
||||
// fmt.Println("test1", result, err)
|
||||
//}
|
||||
//
|
||||
//func TestSearchDeleteWare(t *testing.T) {
|
||||
// var (
|
||||
// page = 1
|
||||
// pageSize = 20
|
||||
// searchResults []*SearchDeleteWareResult
|
||||
// )
|
||||
// for ; page < 367; page++ {
|
||||
// searchDeleteWareResults, err := api.SearchDeleteWare("2020-04-22", "2020-04-23", page, pageSize)
|
||||
// if err == nil && len(searchDeleteWareResults) > 0 {
|
||||
// searchResults = append(searchResults, searchDeleteWareResults...)
|
||||
// }
|
||||
// }
|
||||
// fmt.Println(utils.Format4Output(searchResults, false))
|
||||
//}
|
||||
//
|
||||
//func TestGetJdStoreID(t *testing.T) {
|
||||
// result, err := api.GetJdStoreID(801246)
|
||||
// fmt.Println("test1", result, err)
|
||||
//}
|
||||
//
|
||||
//func TestUpdateClosetStatus(t *testing.T) {
|
||||
// err := api.UpdateClosetStatus(801246, 1)
|
||||
// fmt.Println("test1", err)
|
||||
//}
|
||||
//
|
||||
//func TestGetJdShopOrders(t *testing.T) {
|
||||
// result, err := api.GetJdShopOrders("20210501", "20210531", "320406", "jd_jxcs1223")
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// t.Log(utils.Format4Output(result, false))
|
||||
//}
|
||||
//
|
||||
//func TestGetJdTopSkus(t *testing.T) {
|
||||
// // err := api.GetJdStoreInfo("12050477")
|
||||
// // if err != nil {
|
||||
// // t.Fatal(err)
|
||||
// // }
|
||||
// // t.Log(utils.Format4Output(result, false))
|
||||
// s1 := "ymbgaraibkfmvocpizdydugvalagaivdbfsfbepeyccqfepzvtpyxtbadkhmwmoswrcxnargtlswqemafandgkmydtimuzvjwxvlfwlhvkrgcsithaqlcvrihrwqkpjdhgfgreqoxzfvhjzojhghfwbvpfzectwwhexthbsndovxejsntmjihchaotbgcysfdaojkjldprwyrnischrgmtvjcorypvopfmegizfkvudubnejzfqffvgdoxohuinkyygbdzmshvyqyhsozwvlhevfepdvafgkqpkmcsikfyxczcovrmwqxxbnhfzcjjcpgzjjfateajnnvlbwhyppdleahgaypxidkpwmfqwqyofwdqgxhjaxvyrzupfwesmxbjszolgwqvfiozofncbohduqgiswuiyddmwlwubetyaummenkdfptjczxemryuotrrymrfdxtrebpbjtpnuhsbnovhectpjhfhahbqrfbyxggobsweefcwxpqsspyssrmdhuelkkvyjxswjwofngpwfxvknkjviiavorwyfzlnktmfwxkvwkrwdcxjfzikdyswsuxegmhtnxjraqrdchaauazfhtklxsksbhwgjphgbasfnlwqwukprgvihntsyymdrfovaszjywuqygpvjtvlsvvqbvzsmgweiayhlubnbsitvfxawhfmfiatxvqrcwjshvovxknnxnyyfexqycrlyksderlqarqhkxyaqwlwoqcribumrqjtelhwdvaiysgjlvksrfvjlcaiwrirtkkxbwgicyhvakxgdjwnwmubkiazdjkfmotglclqndqjxethoutvjchjbkoasnnfbgrnycucfpeovruguzumgmgddqwjgdvaujhyqsqtoexmnfuluaqbxoofvotvfoiexbnprrxptchmlctzgqtkivsilwgwgvpidpvasurraqfkcmxhdapjrlrnkbklwkrvoaziznlpor"
|
||||
// s2 := "qhxepbshlrhoecdaodgpousbzfcqjxulatciapuftffahhlmxbufgjuxstfjvljybfxnenlacmjqoymvamphpxnolwijwcecgwbcjhgdybfffwoygikvoecdggplfohemfypxfsvdrseyhmvkoovxhdvoavsqqbrsqrkqhbtmgwaurgisloqjixfwfvwtszcxwktkwesaxsmhsvlitegrlzkvfqoiiwxbzskzoewbkxtphapavbyvhzvgrrfriddnsrftfowhdanvhjvurhljmpxvpddxmzfgwwpkjrfgqptrmumoemhfpojnxzwlrxkcafvbhlwrapubhveattfifsmiounhqusvhywnxhwrgamgnesxmzliyzisqrwvkiyderyotxhwspqrrkeczjysfujvovsfcfouykcqyjoobfdgnlswfzjmyucaxuaslzwfnetekymrwbvponiaojdqnbmboldvvitamntwnyaeppjaohwkrisrlrgwcjqqgxeqerjrbapfzurcwxhcwzugcgnirkkrxdthtbmdqgvqxilllrsbwjhwqszrjtzyetwubdrlyakzxcveufvhqugyawvkivwonvmrgnchkzdysngqdibhkyboyftxcvvjoggecjsajbuqkjjxfvynrjsnvtfvgpgveycxidhhfauvjovmnbqgoxsafknluyimkczykwdgvqwlvvgdmufxdypwnajkncoynqticfetcdafvtqszuwfmrdggifokwmkgzuxnhncmnsstffqpqbplypapctctfhqpihavligbrutxmmygiyaklqtakdidvnvrjfteazeqmbgklrgrorudayokxptswwkcircwuhcavhdparjfkjypkyxhbgwxbkvpvrtzjaetahmxevmkhdfyidhrdeejapfbafwmdqjqszwnwzgclitdhlnkaiyldwkwwzvhyorgbysyjbxsspnjdewjxbhpsvj"
|
||||
// fmt.Println(string(findTheDifference(s1, s2)))
|
||||
//}
|
||||
//
|
||||
//func findTheDifference(s string, t string) byte {
|
||||
// var (
|
||||
// map1 = make(map[byte]int)
|
||||
// map2 = make(map[byte]int)
|
||||
// )
|
||||
// if s == "" {
|
||||
// return []byte(t)[0]
|
||||
// }
|
||||
// for k, _ := range s {
|
||||
// map1[s[k]]++
|
||||
// }
|
||||
// for k, _ := range t {
|
||||
// map2[t[k]]++
|
||||
// }
|
||||
// for k, v := range map1 {
|
||||
// if map2[k] != v {
|
||||
// return k
|
||||
// }
|
||||
// }
|
||||
// for k, v := range t {
|
||||
// if k == len(t)-1 {
|
||||
// return t[k]
|
||||
// } else {
|
||||
// if strings.Index(string(v), string(s[k])) == -1 {
|
||||
// return t[k]
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return []byte(t)[0]
|
||||
//}
|
||||
//
|
||||
//func TestGetJdStoreInfo(t *testing.T) {
|
||||
// str := "汤臣倍健 辅酶Q10天然维生素E软胶囊 400mg*60粒/瓶"
|
||||
// searchResult := skuNamePat.FindStringSubmatch(str)
|
||||
// fmt.Println(searchResult)
|
||||
//}
|
||||
//
|
||||
//func TestUpdateInterStatus(t *testing.T) {
|
||||
// err := api.UpdateInterStatus("f93ddfb7034b468da4d1ef10abe4b3ab", "message.djsw.newOrder", 0)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// // fmt.Println(result)
|
||||
//}
|
||||
//
|
||||
//func TestSaveMsgUrl(t *testing.T) {
|
||||
// err := api.SaveMsgUrl("f93ddfb7034b468da4d1ef10abe4b3ab", "http://callback.test.jxc4.com", "http://callback.jxc4.com", 0)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// // fmt.Println(result)
|
||||
//}
|
||||
//
|
||||
//func TestExcuteInvoking(t *testing.T) {
|
||||
// err := api.ExcuteInvoking("e95911589479472e8b6f4d099ad343b5", 0)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// // fmt.Println(result)
|
||||
//}
|
||||
//
|
||||
//func TestPeiZhiJdZhangHao(t *testing.T) {
|
||||
// for k, v := range interfaceMap {
|
||||
// if err := api.UpdateInterStatus(k, v[0].(string), v[1].(int)); err == nil {
|
||||
// if err2 := api.SaveMsgUrl(k, "http://callback.test.jxc4.com", "http://callback.jxc4.com", v[1].(int)); err2 == nil {
|
||||
// if err3 := api.ExcuteInvoking(k, v[1].(int)); err3 == nil {
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if err := api.SaveCheckedInters(); err == nil {
|
||||
// time.Sleep(time.Second * 2)
|
||||
// api.ToOnline()
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func TestQueryMemberTransListByCondition(t *testing.T) {
|
||||
// result, err := api.QueryMemberTransListByCondition("", "", 4, 200)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// t.Log(utils.Format4Output(result, false))
|
||||
//}
|
||||
//
|
||||
//type GuoMei struct {
|
||||
// appKey string
|
||||
// timestamp string
|
||||
// sign string
|
||||
//}
|
||||
|
||||
@@ -1,159 +1,160 @@
|
||||
package jdapi
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
mustExistStoreID = "11053496"
|
||||
mustExistStoreJXID = "2"
|
||||
|
||||
// mustExistStoreID = "11734851"
|
||||
// mustExistStoreJXID = "100118"
|
||||
)
|
||||
|
||||
func TestGetAllCities(t *testing.T) {
|
||||
result, err := api.GetAllCities()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestGetStationsByVenderId(t *testing.T) {
|
||||
result, err := api.GetStationsByVenderId()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
findStore := false
|
||||
for _, v := range result {
|
||||
if v == mustExistStoreID {
|
||||
findStore = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !findStore {
|
||||
baseapi.SugarLogger.Fatalf("result have no store:%s", mustExistStoreID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetStoreInfoByStationNo(t *testing.T) {
|
||||
result, err := api.GetStoreInfoByStationNo2("11946249")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
|
||||
}
|
||||
|
||||
func TestUpdateStoreInfo4Open(t *testing.T) {
|
||||
result, err := api.GetStoreInfoByStationNo2(mustExistStoreID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
oldAddress := result.StationAddress
|
||||
params := &OpStoreParams{
|
||||
StationNo: mustExistStoreID,
|
||||
Operator: "test",
|
||||
StationAddress: oldAddress + "T",
|
||||
}
|
||||
err = api.UpdateStoreInfo4Open2(params, false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
result, err = api.GetStoreInfoByStationNo2(mustExistStoreID)
|
||||
newAddress := result.StationAddress
|
||||
if newAddress != params.StationAddress {
|
||||
t.Fatalf("address not match, newAddress:%s, oldAddress:%s", newAddress, oldAddress)
|
||||
}
|
||||
|
||||
params.StationAddress = oldAddress
|
||||
api.UpdateStoreInfo4Open2(params, false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetCommentByOrderId(t *testing.T) {
|
||||
testOrderID := int64(922520919000622)
|
||||
result, err := api.GetCommentByOrderId2(testOrderID)
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestUpdateStoreConfig4Open(t *testing.T) {
|
||||
testStationNo := "11785740"
|
||||
desiredValue := true
|
||||
// 马上修改了后,通过GetStoreInfoByStationNo得到的数据不及时,测试不能过的。。。
|
||||
result, err := api.UpdateStoreConfig4Open(testStationNo, desiredValue)
|
||||
if err != nil || !result {
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
t.Fatal(result)
|
||||
}
|
||||
time.Sleep(2 * time.Second)
|
||||
result2, err := api.GetStoreInfoByStationNo2(testStationNo)
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
isAutoOrder := result2.IsAutoOrder
|
||||
if isAutoOrder != 0 && desiredValue || isAutoOrder == 0 && !desiredValue {
|
||||
t.Fatalf("UpdateStoreConfig4Open failed, isAutoOrder:%d", isAutoOrder)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDisableAutoOrder4AllStores(t *testing.T) {
|
||||
storeIDs, err := api.GetStationsByVenderId()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, storeID := range storeIDs {
|
||||
if storeInfo, err := api.GetStoreInfoByStationNo2(storeID); err == nil {
|
||||
if storeInfo.Yn == 0 && storeInfo.IsAutoOrder == 0 {
|
||||
t.Log(storeID)
|
||||
api.UpdateStoreConfig4Open(storeID, false)
|
||||
}
|
||||
t.Log(utils.Format4Output(storeInfo, false))
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpdateStoreFreightConfigNew(t *testing.T) {
|
||||
err := api.UpdateStoreFreightConfigNew(&UpdateStoreFreightParam{
|
||||
UserPin: "test",
|
||||
MerchantStationNo: "2",
|
||||
OpenDistanceFreight: true,
|
||||
IsFullFree: true,
|
||||
|
||||
StartCharge: 1890,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetDeliveryRangeByStationNo(t *testing.T) {
|
||||
const testStoreID = "11946249"
|
||||
result, err := api.GetDeliveryRangeByStationNo2(testStoreID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
baseapi.SugarLogger.Debug(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestQueryMerchantMemberInfo(t *testing.T) {
|
||||
result, err := api.GetCommonMemberRegisteredInfo("562012843072000442")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
baseapi.SugarLogger.Debug(utils.Format4Output(result, false))
|
||||
}
|
||||
//
|
||||
//import (
|
||||
// "testing"
|
||||
// "time"
|
||||
//
|
||||
// "git.rosy.net.cn/baseapi"
|
||||
// "git.rosy.net.cn/baseapi/utils"
|
||||
//)
|
||||
//
|
||||
//const (
|
||||
// mustExistStoreID = "11053496"
|
||||
// mustExistStoreJXID = "2"
|
||||
//
|
||||
// // mustExistStoreID = "11734851"
|
||||
// // mustExistStoreJXID = "100118"
|
||||
//)
|
||||
//
|
||||
//func TestGetAllCities(t *testing.T) {
|
||||
// result, err := api.GetAllCities()
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// t.Log(utils.Format4Output(result, false))
|
||||
//}
|
||||
//
|
||||
//func TestGetStationsByVenderId(t *testing.T) {
|
||||
// result, err := api.GetStationsByVenderId()
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// findStore := false
|
||||
// for _, v := range result {
|
||||
// if v == mustExistStoreID {
|
||||
// findStore = true
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
// if !findStore {
|
||||
// baseapi.SugarLogger.Fatalf("result have no store:%s", mustExistStoreID)
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func TestGetStoreInfoByStationNo(t *testing.T) {
|
||||
// result, err := api.GetStoreInfoByStationNo2("11946249")
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// t.Log(utils.Format4Output(result, false))
|
||||
//
|
||||
//}
|
||||
//
|
||||
//func TestUpdateStoreInfo4Open(t *testing.T) {
|
||||
// result, err := api.GetStoreInfoByStationNo2(mustExistStoreID)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// oldAddress := result.StationAddress
|
||||
// params := &OpStoreParams{
|
||||
// StationNo: mustExistStoreID,
|
||||
// Operator: "test",
|
||||
// StationAddress: oldAddress + "T",
|
||||
// }
|
||||
// err = api.UpdateStoreInfo4Open2(params, false)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
//
|
||||
// result, err = api.GetStoreInfoByStationNo2(mustExistStoreID)
|
||||
// newAddress := result.StationAddress
|
||||
// if newAddress != params.StationAddress {
|
||||
// t.Fatalf("address not match, newAddress:%s, oldAddress:%s", newAddress, oldAddress)
|
||||
// }
|
||||
//
|
||||
// params.StationAddress = oldAddress
|
||||
// api.UpdateStoreInfo4Open2(params, false)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func TestGetCommentByOrderId(t *testing.T) {
|
||||
// testOrderID := int64(922520919000622)
|
||||
// result, err := api.GetCommentByOrderId2(testOrderID)
|
||||
// if err != nil {
|
||||
// t.Fatal(err.Error())
|
||||
// }
|
||||
// t.Log(utils.Format4Output(result, false))
|
||||
//}
|
||||
//
|
||||
//func TestUpdateStoreConfig4Open(t *testing.T) {
|
||||
// testStationNo := "11785740"
|
||||
// desiredValue := true
|
||||
// // 马上修改了后,通过GetStoreInfoByStationNo得到的数据不及时,测试不能过的。。。
|
||||
// result, err := api.UpdateStoreConfig4Open(testStationNo, desiredValue)
|
||||
// if err != nil || !result {
|
||||
// if err != nil {
|
||||
// t.Fatal(err.Error())
|
||||
// }
|
||||
// t.Fatal(result)
|
||||
// }
|
||||
// time.Sleep(2 * time.Second)
|
||||
// result2, err := api.GetStoreInfoByStationNo2(testStationNo)
|
||||
// if err != nil {
|
||||
// t.Fatal(err.Error())
|
||||
// }
|
||||
// isAutoOrder := result2.IsAutoOrder
|
||||
// if isAutoOrder != 0 && desiredValue || isAutoOrder == 0 && !desiredValue {
|
||||
// t.Fatalf("UpdateStoreConfig4Open failed, isAutoOrder:%d", isAutoOrder)
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func TestDisableAutoOrder4AllStores(t *testing.T) {
|
||||
// storeIDs, err := api.GetStationsByVenderId()
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// for _, storeID := range storeIDs {
|
||||
// if storeInfo, err := api.GetStoreInfoByStationNo2(storeID); err == nil {
|
||||
// if storeInfo.Yn == 0 && storeInfo.IsAutoOrder == 0 {
|
||||
// t.Log(storeID)
|
||||
// api.UpdateStoreConfig4Open(storeID, false)
|
||||
// }
|
||||
// t.Log(utils.Format4Output(storeInfo, false))
|
||||
// }
|
||||
// break
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func TestUpdateStoreFreightConfigNew(t *testing.T) {
|
||||
// err := api.UpdateStoreFreightConfigNew(&UpdateStoreFreightParam{
|
||||
// UserPin: "test",
|
||||
// MerchantStationNo: "2",
|
||||
// OpenDistanceFreight: true,
|
||||
// IsFullFree: true,
|
||||
//
|
||||
// StartCharge: 1890,
|
||||
// })
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func TestGetDeliveryRangeByStationNo(t *testing.T) {
|
||||
// const testStoreID = "11946249"
|
||||
// result, err := api.GetDeliveryRangeByStationNo2(testStoreID)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// baseapi.SugarLogger.Debug(utils.Format4Output(result, false))
|
||||
//}
|
||||
//
|
||||
//func TestQueryMerchantMemberInfo(t *testing.T) {
|
||||
// result, err := api.GetCommonMemberRegisteredInfo("562012843072000442")
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// baseapi.SugarLogger.Debug(utils.Format4Output(result, false))
|
||||
//}
|
||||
|
||||
Reference in New Issue
Block a user