This commit is contained in:
邹宗楠
2024-02-06 16:38:33 +08:00
parent 12abfdcfd0
commit b9652e0fd1
2 changed files with 56 additions and 56 deletions

View File

@@ -26,7 +26,7 @@ func init() {
//api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "") //api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "")
//商超 //商超
api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_l8IdyEVdQyRu4drJ1_dMGQ") //token_n4TwqCntWWuvQwAawzxC0w api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_tcaqk459xuIjL2l9OplDYg") //token_n4TwqCntWWuvQwAawzxC0w
cookieStr := ` cookieStr := `
acctId=57396785; token=0bWbK5VbK50E2BmIhIH2zHB-am_y7mB37yXHm6RLZWx4*; wmPoiId=-1; acctId=57396785; token=0bWbK5VbK50E2BmIhIH2zHB-am_y7mB37yXHm6RLZWx4*; wmPoiId=-1;
` `

View File

@@ -94,37 +94,64 @@ func TestRetailCatDelete(t *testing.T) {
//t.Fatal(errList1.GetErrListAsOne()) //t.Fatal(errList1.GetErrListAsOne())
} }
func TestRetailList(t *testing.T) { func TestRetailInitData(t *testing.T) {
offset := 0 api.RetailInitData(utils.GetUUID(), "18877719", "1", map[string]interface{}{
skus := make(map[string]string, 0) "operate_type": 2,
for { "price": 6.05,
result, err := api.RetailList("17211186", offset, 100) })
if err != nil { }
t.Fatal(err)
}
if len(result) == 0 {
t.Fatal("should have items")
}
for _, v := range result { func TestABC(t *testing.T) {
if v.SkuList != nil && len(v.SkuList) > 0 { for i := 0; i < 100; i++ {
for _, v2 := range v.SkuList { fmt.Println(fmt.Sprintf("%d", i))
mapSkuList := utils.Struct2MapByJson(v2) globals.SugarLogger.Debugf("%d", i)
if mapSkuList["upc"].(string) != "" { }
skus[mapSkuList["upc"].(string)] = mapSkuList["price"].(string) }
break
} func TestRetailList(t *testing.T) {
} offset := 27
} result, err := api.RetailListAll("18877719", offset)
} if err != nil {
if len(result) < 100 { t.Fatal(err)
break }
} if len(result) == 0 {
offset++ t.Fatal("should have items")
} }
t.Log(utils.Format4Output(skus, false)) for i := 0; i < len(result); i++ {
t.Log(utils.Format4Output(len(skus), false)) fmt.Println(fmt.Sprintf("skuId为空:%s , k = %d", result[i].Name, i))
//globals.SugarLogger.Debugf("skuId为空:%s , k = %d", result[i].Name, i)
}
//for k, v := range result {
// skuInfo := &BareStoreFoodInfo{
// AppFoodCode: v.AppFoodCode,
// }
//
// nowSkus := make([]*BareStoreSkuInfo, 0, 0)
// if err := json.Unmarshal([]byte(v.Skus), &nowSkus); err != nil {
// globals.SugarLogger.Debugf("errr:= %v", err)
// return
// }
// for _, ns := range nowSkus {
// ns.Price = fmt.Sprintf("%.2f", utils.Str2Float64(ns.Price)+utils.Str2Float64(ns.Price)*0.1)
// }
// time.Sleep(time.Millisecond * 200)
// skuInfo.Skus = nowSkus
// if skuInfo.Skus[0].SkuID == "" || len(skuInfo.Skus) == 0 {
// globals.SugarLogger.Debugf("skuId为空:%s , k = %d", v.Name, k)
// //fmt.Println(fmt.Sprintf("skuId为空:%s , k = %d", v.Name, k))
// continue
// }
// data, err := api.RetailSkuPrice(utils.GetUUID(), "18877719", []*BareStoreFoodInfo{skuInfo})
// if err != nil {
// fmt.Println(fmt.Sprintf("skuId为空:%s ,name = %s , k = %d", err.Error(), v.Name, k))
// }
// if data != nil {
// globals.SugarLogger.Debugf("err :%s", utils.Format4Output(data, false))
// }
//}
return
} }
func TestRetailGet(t *testing.T) { func TestRetailGet(t *testing.T) {
@@ -275,33 +302,6 @@ func TestRetailBatchInitData(t *testing.T) {
t.Log(utils.Format4Output(failedFoods, false)) t.Log(utils.Format4Output(failedFoods, false))
} }
func TestRetailSkuPrice(t *testing.T) {
result, err := api.RetailSkuPrice(utils.GetUUID(), testPoiCode, []*BareStoreFoodInfo{
&BareStoreFoodInfo{
AppFoodCode: "23841",
Skus: []*BareStoreSkuInfo{
&BareStoreSkuInfo{
SkuID: "23841",
Price: "1.2",
},
},
},
&BareStoreFoodInfo{
AppFoodCode: "23840",
Skus: []*BareStoreSkuInfo{
&BareStoreSkuInfo{
SkuID: "23840",
Price: "1.1",
},
},
},
})
if err != nil {
t.Fatal(err)
}
t.Log(utils.Format4Output(result, false))
}
func TestRetailSkuStock(t *testing.T) { func TestRetailSkuStock(t *testing.T) {
result, err := api.RetailSkuStock(utils.GetUUID(), testPoiCode, []*BareStoreFoodInfo{ result, err := api.RetailSkuStock(utils.GetUUID(), testPoiCode, []*BareStoreFoodInfo{
&BareStoreFoodInfo{ &BareStoreFoodInfo{