From 9c2c0930fdbcf9d40d91cc6893841f8f310881e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Mon, 8 Feb 2021 11:45:00 +0800 Subject: [PATCH] aa --- platformapi/aliupcapi/aliupcapi_test.go | 2 +- platformapi/ebaiapi/common.go | 2 +- platformapi/ebaiapi/common_test.go | 21 +++++++++++++++++++-- platformapi/ebaiapi/shop_test.go | 12 ++++++------ platformapi/ebaiapi/sku_test.go | 2 +- platformapi/jdapi/store_page_test.go | 13 ++++++++----- platformapi/jdapi/store_sku.go | 12 ++++++++++++ platformapi/jdapi/store_sku_test.go | 14 +++++++++++++- platformapi/mtwmapi/mtwmapi.go | 1 + platformapi/mtwmapi/mtwmapi_test.go | 6 +++--- platformapi/mtwmapi/order_test.go | 4 ++-- 11 files changed, 67 insertions(+), 22 deletions(-) diff --git a/platformapi/aliupcapi/aliupcapi_test.go b/platformapi/aliupcapi/aliupcapi_test.go index df0397d8..42cc05a9 100644 --- a/platformapi/aliupcapi/aliupcapi_test.go +++ b/platformapi/aliupcapi/aliupcapi_test.go @@ -21,7 +21,7 @@ func init() { } func TestGetAliUpcInfo(t *testing.T) { - result, err := api.GetAliUpcInfo("6901028227278") + result, err := api.GetAliUpcInfo("6940863603571") if err != nil { t.Fatal(err) } else { diff --git a/platformapi/ebaiapi/common.go b/platformapi/ebaiapi/common.go index 8f4c3792..c017a124 100644 --- a/platformapi/ebaiapi/common.go +++ b/platformapi/ebaiapi/common.go @@ -42,7 +42,7 @@ func (a *API) CommonShopCategories(parentID, level int) (cityList []*CatInfo, er } func (a *API) CommonBusinessCategories(parentID int) (cityList []*CatInfo, err error) { - result, err := a.AccessAPI("common.businesscategories", utils.Params2Map("category_id", parentID)) + result, err := a.AccessAPI("common.businesscategories", nil) if err == nil { err = utils.Map2StructByJson(result.Data, &cityList, true) } diff --git a/platformapi/ebaiapi/common_test.go b/platformapi/ebaiapi/common_test.go index d45fb9ee..1b01f879 100644 --- a/platformapi/ebaiapi/common_test.go +++ b/platformapi/ebaiapi/common_test.go @@ -25,7 +25,24 @@ func TestCommonShopCategoriesGet(t *testing.T) { } func TestCommonShopCategories(t *testing.T) { - result, err := api.CommonShopCategories(166, 2) + /* + { + "category1": "厨房生鲜", + "category2": "蔬菜" + }, + { + "category1": "水果", + "category2": "水果店" + }, + { + "category1": "厨房生鲜", + "category2": "肉类" + }, + { + "category1": "厨房生鲜", + "category2": "水产" + } */ + result, err := api.CommonShopCategories(277, 2) if err != nil { t.Fatal(err) } else { @@ -34,7 +51,7 @@ func TestCommonShopCategories(t *testing.T) { } func TestCommonBusinessCategories(t *testing.T) { - result, err := api.CommonBusinessCategories(166) + result, err := api.CommonBusinessCategories(0) if err != nil { t.Fatal(err) } else { diff --git a/platformapi/ebaiapi/shop_test.go b/platformapi/ebaiapi/shop_test.go index aa112e8b..420947e5 100644 --- a/platformapi/ebaiapi/shop_test.go +++ b/platformapi/ebaiapi/shop_test.go @@ -18,18 +18,18 @@ func TestShopList(t *testing.T) { func TestShopCreate(t *testing.T) { result, err := api.ShopCreate(map[string]interface{}{ "shop_id": "667550", - "name": "互利超市(金牛店)", + "name": "互利超市(金牛区店)", "supplier_id": "1486975681715", "province": 32, "city": 75, "county": 698, "address": "成都市金牛区二环路北一段8号", - "phone": 18980429231, - "service_phone": 18980429231, - "ivr_phone": 18048531223, + "phone": 18160030913, // 18980429231, + "service_phone": 18160030913, //18980429231, + "ivr_phone": 18160030913, //18048531223, "longitude": 104.043677, "latitude": 30.692361, - "shop_logo": "http://image.jxc4.com/image/4573e7789c647d4961f8955e3733dbd6.tem.jpg", + "shop_logo": "https://image-star.elemecdn.com/pb/dab294b0d3e9fa4b5fa63007ff02d06e98", "coord_type": "amap", "categorys": []map[string]int{ map[string]int{ @@ -53,7 +53,7 @@ func TestShopCreate(t *testing.T) { } func TestShopGet(t *testing.T) { - result, err := api.ShopGet("", 335768207) //2233065879 + result, err := api.ShopGet("", 2267237821) //2233065879 ,22267134648 if err != nil { t.Fatal(err) } else { diff --git a/platformapi/ebaiapi/sku_test.go b/platformapi/ebaiapi/sku_test.go index c1ad9b9f..f3487025 100644 --- a/platformapi/ebaiapi/sku_test.go +++ b/platformapi/ebaiapi/sku_test.go @@ -25,7 +25,7 @@ func TestSkuBrandList(t *testing.T) { } func TestPictureUpload(t *testing.T) { - result, err := api.PictureUpload("https://www.jxcs.net/emoji/ceshi2.gif", nil) + result, err := api.PictureUpload("http://image.jxc4.com/image/212c268d26f6237e33ba269d24e2f76b.jpg", nil) if err != nil { t.Fatal(err) } else { diff --git a/platformapi/jdapi/store_page_test.go b/platformapi/jdapi/store_page_test.go index da883310..f7569c05 100644 --- a/platformapi/jdapi/store_page_test.go +++ b/platformapi/jdapi/store_page_test.go @@ -2,6 +2,7 @@ package jdapi import ( "fmt" + "regexp" "strings" "testing" @@ -9,6 +10,10 @@ import ( "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" @@ -317,9 +322,7 @@ func findTheDifference(s string, t string) byte { } func TestGetJdStoreInfo(t *testing.T) { - result, err := api.GetJdStoreInfo("11942642") - if err != nil { - t.Fatal(err) - } - t.Log(utils.Format4Output(result, false)) + str := "汤臣倍健 辅酶Q10天然维生素E软胶囊 400mg*60粒/瓶" + searchResult := skuNamePat.FindStringSubmatch(str) + fmt.Println(searchResult) } diff --git a/platformapi/jdapi/store_sku.go b/platformapi/jdapi/store_sku.go index 7bd3103f..915001f6 100644 --- a/platformapi/jdapi/store_sku.go +++ b/platformapi/jdapi/store_sku.go @@ -321,3 +321,15 @@ func (a *API) AddByStoreAndSkus(stationNo int64, skuIDs []int64) (err error) { _, err = a.AccessAPINoPage("OrgSortService/addByStoreAndSkus", jdParams, nil, nil, genNoPageResultParser("status", "message", "", "200")) return err } + +// 删除门店商品会员价接口 +// https://openo2o.jddj.com/staticnew/widgets/resources.html?groupid=205&apiid=73116e2b9f374814880f1272ba301fdf +func (a *API) DelVipPrice(outStationNo string, skuIds []*SkuIdEntity, userPin string) (err error) { + jdParams := map[string]interface{}{ + "outStationNo": outStationNo, + "skuPriceInfoList": skuIds, + "source": utils.GetAPIOperator(userPin), + } + _, err = a.AccessAPINoPage("vender/delVipPrice", jdParams, nil, nil, genNoPageResultParser("code", "msg", "", "0")) + return err +} diff --git a/platformapi/jdapi/store_sku_test.go b/platformapi/jdapi/store_sku_test.go index 55e6fbf0..ed20f6d3 100644 --- a/platformapi/jdapi/store_sku_test.go +++ b/platformapi/jdapi/store_sku_test.go @@ -13,13 +13,25 @@ const ( ) func TestGetStationInfoList(t *testing.T) { - result, err := api.GetStationInfoList(mustExistStoreID, []int64{mustExistSkuID}) + result, err := api.GetStationInfoList("12005640", []int64{2023434101}) if err != nil { t.Fatal(err) } t.Log(utils.Format4Output(result, false)) } +func TestDelVipPrice(t *testing.T) { + err := api.DelVipPrice("667281", []*SkuIdEntity{ + &SkuIdEntity{ + OutSkuId: "26074", + }, + }, "") + if err != nil { + t.Fatal(err) + } + // t.Log(utils.Format4Output(result, false)) +} + func TestQueryOpenUseable(t *testing.T) { result, err := api.QueryOpenUseable([]*BaseStockCenterRequest{ &BaseStockCenterRequest{ diff --git a/platformapi/mtwmapi/mtwmapi.go b/platformapi/mtwmapi/mtwmapi.go index 609da51c..b3c3259f 100644 --- a/platformapi/mtwmapi/mtwmapi.go +++ b/platformapi/mtwmapi/mtwmapi.go @@ -85,6 +85,7 @@ func New(appID, secret, callbackURL, token string, config ...*platformapi.APICon return &API{ appID: appID, secret: secret, + token: token, callbackURL: callbackURL, client: &http.Client{Timeout: curConfig.ClientTimeout}, config: &curConfig, diff --git a/platformapi/mtwmapi/mtwmapi_test.go b/platformapi/mtwmapi/mtwmapi_test.go index f95c5ee1..66c2215f 100644 --- a/platformapi/mtwmapi/mtwmapi_test.go +++ b/platformapi/mtwmapi/mtwmapi_test.go @@ -19,13 +19,13 @@ func init() { baseapi.Init(sugarLogger) // 菜市 - // api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "") + // api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "") // 果园 // api = New("4123", "df2c88338b85f830cebce2a9eab56628", "") //商超 - api = New("5873", "41c479790a76f86326f89e8048964739", "") //token_nH_IlcWQKAkZBqklwItNRw + api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_gYtTGPVDP6pTDLECwp1BFA") //token_nH_IlcWQKAkZBqklwItNRw cookieStr := ` acctId=62884810; token=0_0_vJux6rcmm0XIzoI885_aew-gnfofUw9SR-a-QkLw*; brandId=-1; wmPoiId=-1; ` @@ -41,7 +41,7 @@ func TestAccessAPI(t *testing.T) { } func TestGetOAuthCode(t *testing.T) { - result, err := api.GetOAuthCode("11011885") + result, err := api.GetOAuthCode("10874383") if err != nil { t.Fatal(err) } diff --git a/platformapi/mtwmapi/order_test.go b/platformapi/mtwmapi/order_test.go index f04f0c55..3ce57abf 100644 --- a/platformapi/mtwmapi/order_test.go +++ b/platformapi/mtwmapi/order_test.go @@ -9,7 +9,7 @@ import ( ) func TestOrderViewStatus(t *testing.T) { - result, err := api.OrderViewStatus(33762863658107006) + result, err := api.OrderViewStatus(123) if err != nil { t.Fatal(err) } @@ -122,7 +122,7 @@ func TestGetOrderActDetaill(t *testing.T) { } func TestGetOrderIdByDaySeq(t *testing.T) { - result, err := api.GetOrderIdByDaySeq("7111597", utils.Time2Date(time.Now()), 1, MaxGap4GetOrderIdByDaySeq) + result, err := api.GetOrderIdByDaySeq("10874383", utils.Time2Date(time.Now()), 1, MaxGap4GetOrderIdByDaySeq) t.Log(utils.Format4Output(result, false)) if err != nil { t.Fatal(err)