package mtwmapi import ( "errors" "fmt" <<<<<<< HEAD "git.rosy.net.cn/jx-callback/globals" ======= "git.rosy.net.cn/baseapi/utils/errlist" >>>>>>> 85884e9932497f156e47da04db8229b88cf36e23 "testing" "git.rosy.net.cn/baseapi/utils" ) func TestRetailCatList(t *testing.T) { result, err := api.RetailCatList("8694203 ") if err != nil { t.Fatal(err) } t.Log(utils.Format4Output(result, false)) } func TestRetailCatUpdate(t *testing.T) { err := api.RetailCatUpdate("8694203", "时令鲜蔬", &Param4UpdateCat{ CategoryNameOrigin: "1", CategoryCodeOrigin: "1", CategoryCode: "1", Sequence: 3, }) if err != nil { t.Fatal(err) } } func TestRetailCatDelete(t *testing.T) { var err error errList := errlist.New() info := []string{"11309161", "16227684", "7379027", "14422863", "16194618", "12405467", "12398353", "12422620", "12422751", "11437415", "2391979", "11037873", "11646173", "16126553", "12286931", "11086818", "9000444", "13413407", "10874383", "11674367", "11824223", "11939392", "11810047", "12071134", "16336571", "11799045", "12848707", "11596643", "14038247", "9676866", "15382980", "8967897", "11566485", "11774697", "11730687", "11798089", "11488932", "11651698", "11637939", "11831005", "11883106", "11011885", "11342761", "12131910", "12833849", "11209533", "16034387", "12211457", "11440630", "12665305", "11440628", "9578183", "11213162", "12665208", "13887316", "16218203"} str := []string{"token_l69jtloeNOyfYoIv5vtAqA", "token_sPpMgp5WrqH--3oUPf5A2Q", "token_mqXPXS__T45VI3WK8iRGyA", "token_h_0MbgOUqP1zu1lQUoVLVA", "token_nRk9S74kkyAmJwnHUnNNTQ", "token_g04eYyajpFtB7z3ZIPhEgQ", "token_ji6aHTKAttUr5HpG-P1ILw", "token_iVA8HCqCw25WKAYAeoxI6w", "token_nZ7wvaGrgCKo_9eEGWpFhQ", "token_g0nXxm1y_b3WG-869uFHvQ", "token_mNksHDmG0qmuan9X2PNAXg", "token_nzqieSpknIntGYVnSctCyg", "token_jheBN1obUU6mCB6u93FBzA", "token_pCpFSUwf_57qrxGpXdNGWw", "token_rt3u9NYfIK5Fw7vCCjJI_A", "token_tcwAXxe5Y6vkZfWiV5pCVA", "token_gEUkpazta411uA4AoSNOzA", "token_ohaUdeTfmvdSD7UCNqNDXw", "token_nf9QokI2udnECY2s1zBIeA", "token_qSg63aT-Wt6BYgOO8r9MpQ", "token_jRfqTEHnchVH8-3SBzRD-Q", "token_hSw6aphyuATaU1524PpAog", "token_gpkQ3am3MIjtmL3WIp9LIQ", "token_v6p8GXKDXG64Mz9d6SlJ8g", "token_mVsCcR9Knd776UkwrqZCfg", "token_uN6yb9hg2L58Z_eI04hPZA", "token_smMsR19Ib6u5LEtkcpZIRw", "token_pJdrB68qBrJu_DAkEMNGow", "token_oE0SITdA7dSlT-yfVpdHqQ", "token_sT9UC1PA7yGF0i_ZN-9LKA", "token_ifEUVfiOnCWSkRH7uBpEKA", "token_lAH8mmNcd4FMrRNI4PhNgg", "token_r2KorM-YOndp3WD2icRNXA", "token_ukvP9JmDe8kzKvn2lP9HhA", "token_jN00JUjbTA7mHouHgHJD_w", "token_jF9quf44XfZLd89ew_xIDQ", "token_neBnndby2RbQ3YDmitxELw", "token_gOyTabNAYD_8kO7D3rJH4A", "token_nH7t8V0ib82ZMZyT0N1EzA", "token_mWp3EsfRBKnIZVIvq99Iww", "token_saH3wIiaXWHrEp1BYd9O5A", "token_g2RPkuiaJpB5FL93aSdL0Q", "token_pWOdbMFUxVw9rMKaeMRCAA", "token_hNc_xjRPdCiemK1YzwJBnQ", "token_kZj0G0WN5ggEbrBf-vtLSA", "token_jdfG0c3LmJL2_PZO8u1DTA", "token_r8Rll9OBeGP86Arp409AyQ", "token_kpxTu56s_wdcXbkvTOJIBA", "token_saPyD06boPCm9T7C2o9Htw", "token_uQQTtEL2oqlR5G5rQ_NHkQ", "token_k8JY5o5eR-GyxZTEH0pLBQ", "", "token_qNnnfVJweCf6Cv-wqNdJlg", "token_hVQ5K6FcX-gkRXVNLplPvA", "", "token_rq2dpLklomhaQA78qH1LMQ"} for _, v := range info { for _, i := range str { err = New("5873", "41c479790a76f86326f89e8048964739", "", i).RetailCatDelete(v, "", "热销") if err != nil { errList.AddErr(err) } } } fmt.Printf("errList==============%s", errList) //t.Fatal(errList) //err := api.RetailCatDelete("8694203", "" /*utils.GetUpperUUID()*/, "国产水果") //t.Fatal(err) } func TestRetailList(t *testing.T) { result, err := api.RetailList("8967897"+ "", 0, 20) if err != nil { t.Fatal(err) } if len(result) == 0 { t.Fatal("should have items") } t.Log(utils.Format4Output(result, false)) t.Log(len(result)) } func TestRetailListAll(t *testing.T) { result, err := api.RetailListAll("8967897") if err != nil { t.Fatal(err) } if len(result) == 0 { t.Fatal("should have items") } t.Log(utils.Format4Output(result, false)) t.Log(len(result)) } func TestRetailGet(t *testing.T) { result, err := api.RetailGet(testPoiCode, "4267") if err != nil { t.Fatal(err) } t.Log(utils.Format4Output(result, false)) } func TestRetailGetSpTagIds(t *testing.T) { result, err := api.RetailGetSpTagIds() if err != nil { t.Fatal(err) } if len(result) == 0 { t.Fatal("should have items") } t.Log(utils.Format4Output(result, false)) } func TestRetailCatSkuBatchDelete(t *testing.T) { err := api.RetailCatSkuBatchDelete2(utils.GetUUID(), testPoiCode, nil, []string{"精品水果2"}, nil, nil, nil) t.Log(IsErrCategoryNotExist(err)) if err != nil { t.Fatal(err) } } //批量更新商品进货价 func TestBatchSetPrice(t *testing.T) { param := []*SpuData{ { AppSpuCode: "25420", SkuID: "11395394828", PurchasePrice: "50", }, } err := api.BatchSetRestockingPrice(utils.GetUUID(), "12422751", param) fmt.Println(err) } func TestRetailDelete(t *testing.T) { err := api.RetailDelete(utils.GetUUID(), testPoiCode, "32427") if err != nil { t.Fatal(err) } } func TestRetailDat(t *testing.T) { err := api.RetailInitData("F71D0F0881A211ED9D81525400E86DC0", "16185779", "31173", map[string]interface{}{ "app_spu_code": "31173", "category_code": "3039", "common_attr_value": "[{\"attrId\":1200000088,\"attrName\":\"品牌\",\"valueList\":[{\"valueId\":1000001,\"value\":\"其他品牌\"}]},{\"attrId\":1200000094,\"attrName\":\"产地\",\"valueList\":[{\"valueId\":100000050,\"value\":\"中国\"}]},{\"attrId\":1200000132,\"attrName\":\"国产/进口\",\"valueList\":[{\"valueId\":1300000003,\"value\":\"国产\"}]},{\"attrId\":1200000210,\"attrName\":\"商品类别\",\"valueList\":[{\"valueId\":1300002991,\"value\":\"水果混合切片\"}]},{\"attrId\":1200000286,\"attrName\":\"果品品牌\",\"valueList\":[{\"valueId\":1300000249,\"value\":\"其他\"}]},{\"attrId\":1200004449,\"attrName\":\"拼数\",\"valueList\":[{\"valueId\":1300015654,\"value\":\"单拼\"}]}]", "description": "", "is_sold_out": 0, "min_order_count": 1, "name": "【果切】香甜芒果果切1盒约250g", "picture": "https://image.jxc4.com/image/4fd5cd77a6fce23ee26f8d40392d83b1.jpg,https://image.jxc4.com/image/4fd5cd77a6fce23ee26f8d40392d83b1.jpg,https://image.jxc4.com/image/4fd5cd77a6fce23ee26f8d40392d83b1.jpg,https://image.jxc4.com/image/4fd5cd77a6fce23ee26f8d40392d83b1.jpg,https://image.jxc4.com/image/4fd5cd77a6fce23ee26f8d40392d83b1.jpg", "price": 13.9, "sequence": 494, "skus": "[{\"ladder_box_num\":1,\"ladder_box_price\":0.5,\"price\":13.9,\"sku_id\":\"31173\",\"spec\":\"250g\",\"stock\":\"9999\",\"weight\":250}]", "tag_id": "200002727", "unit": "盒", }) globals.SugarLogger.Debugf("err %s", utils.Format4Output(err, false)) } func TestErrList(t *testing.T) { data := utils.IsErrMatch(errors.New("无需切自配送 level:0, code:1"), "301251", nil) fmt.Println(data) } func TestRetailBatchInitData(t *testing.T) { failedFoods, err := api.RetailBatchInitData(utils.GetUUID(), testPoiCode, []map[string]interface{}{ map[string]interface{}{ "app_food_code": "23841", "box_num": 0, "box_price": 0, "category_name": "南北干货", "description": "", "is_sold_out": 0, "min_order_count": 1, "name": "干腐竹约150g/份", "picture": "http://image.jxc4.com/5f7fba025fc9348796039423c48ac3f5.jpg", "price": 1000, "skus": []map[string]interface{}{ map[string]interface{}{ "price": 1000, "sku_id": "23841", "spec": "150g", "stock": "*", "upc": "", }, }, // "tag_id": "200000380", "unit": "份", }, map[string]interface{}{ "app_food_code": "23840", "box_num": 0, "box_price": 0, "category_name": "南北干货", "description": "", "is_sold_out": 0, "min_order_count": 1, "name": "干腐竹约150g/份", "picture": "http://image.jxc4.com/5f7fba025fc9348796039423c48ac3f5.jpg", "price": 1000, "skus": []map[string]interface{}{ map[string]interface{}{ "price": 1000, "sku_id": "23840", "spec": "150g", "stock": "*", "upc": "", }, }, "tag_id": "200000380", "unit": "份", }, }) if err != nil { t.Fatal(err) } 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) { result, err := api.RetailSkuStock(utils.GetUUID(), testPoiCode, []*BareStoreFoodInfo{ &BareStoreFoodInfo{ AppFoodCode: "2212", Skus: []*BareStoreSkuInfo{ &BareStoreSkuInfo{ SkuID: "2212", Price: "1.2", Stock: "123", }, }, }, &BareStoreFoodInfo{ AppFoodCode: "23840", Skus: []*BareStoreSkuInfo{ &BareStoreSkuInfo{ SkuID: "23840", Stock: "123", }, }, }, }) if err != nil { t.Fatal(err) } t.Log(utils.Format4Output(result, false)) } func TestRetailSkuSellStatus(t *testing.T) { result, err := api.RetailSkuSellStatus(utils.GetUUID(), testPoiCode, []*BareStoreFoodInfo{ &BareStoreFoodInfo{ AppFoodCode: "23841", Skus: []*BareStoreSkuInfo{ &BareStoreSkuInfo{ SkuID: "23841", Price: "1.2", Stock: "123", }, }, }, &BareStoreFoodInfo{ AppFoodCode: "23840", Skus: []*BareStoreSkuInfo{ &BareStoreSkuInfo{ SkuID: "23840", Stock: "123", }, }, }, &BareStoreFoodInfo{ AppFoodCode: "2384999", Skus: []*BareStoreSkuInfo{ &BareStoreSkuInfo{ SkuID: "2384999", Stock: "123", }, }, }, }, SellStatusOffline) if err != nil { t.Fatal(err) } t.Log(utils.Format4Output(result, false)) } func TestRetailSellStatus(t *testing.T) { result, err := api.RetailSellStatus(utils.GetUUID(), testPoiCode, []*BareStoreFoodInfo{ &BareStoreFoodInfo{ AppFoodCode: "2212", Skus: []*BareStoreSkuInfo{ &BareStoreSkuInfo{ SkuID: "2212", Price: "1.2", Stock: "123", }, }, }, &BareStoreFoodInfo{ AppFoodCode: "23840", Skus: []*BareStoreSkuInfo{ &BareStoreSkuInfo{ SkuID: "23840", Stock: "123", }, }, }, &BareStoreFoodInfo{ AppFoodCode: "2384999", Skus: []*BareStoreSkuInfo{ &BareStoreSkuInfo{ SkuID: "2384999", Stock: "123", }, }, }, }, SellStatusOnline) if err != nil { t.Fatal(err) } t.Log(utils.Format4Output(result, false)) } func TestCategoryAttrList(t *testing.T) { result, err := api.CategoryAttrList(200002680) if err != nil { t.Fatal(err) } t.Log(utils.Format4Output(result, false)) } func TestCategoryAttrValueList(t *testing.T) { result, err := api.CategoryAttrValueList(100002442, "是", 1, 5) if err != nil { t.Fatal(err) } t.Log(utils.Format4Output(result, false)) }