From e895a25b989c5b074e43536d74ba84d949033732 Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Mon, 30 Aug 2021 16:06:01 +0800 Subject: [PATCH] aa --- platformapi/ebaiapi/ebaiapi_test.go | 2 +- platformapi/ebaiapi/order_test.go | 2 +- platformapi/ebaiapi/shop_test.go | 7 +- platformapi/ebaiapi/sku_test.go | 2 +- platformapi/ebaiapi/store_page.go | 18 ++- platformapi/ebaiapi/store_page_test.go | 8 ++ platformapi/ebaiapi/ugc_test.go | 2 +- platformapi/jdshopapi/store_page.go | 8 +- platformapi/jdshopapi/store_page_test.go | 165 ++++++++++++++++++++++- platformapi/mtwmapi/comment.go | 1 + platformapi/mtwmapi/comment_test.go | 2 +- platformapi/mtwmapi/poi_test.go | 2 +- 12 files changed, 203 insertions(+), 16 deletions(-) diff --git a/platformapi/ebaiapi/ebaiapi_test.go b/platformapi/ebaiapi/ebaiapi_test.go index a55a11da..370c17eb 100644 --- a/platformapi/ebaiapi/ebaiapi_test.go +++ b/platformapi/ebaiapi/ebaiapi_test.go @@ -40,7 +40,7 @@ func init() { //api.SetCookie("WMUSS", "NTE2NDMTAwMDAyNzYxNzAwOTEyTmUzNWJNcDlQ ") //api.SetCookie("WMSTOKEN", "NTE2NDMTAwMDAyNzYxNzAwOTEyTmUzNWJNcDlQ ") api.SetCookieWithStr(` -UTUSER=0; cna=A9cHGZw1jjgCAd3tly+uuYIG; ubt_ssid=kpqd18ueqc12rljyipjmobcr5vlc3xry_2021-04-23; t=bc6b1c1fc4e7ef841fff494286415f8b; xlly_s=1; _m_h5_tk=04ae81974ec5b88eedc9f03a5f7fe6cc_1620980209236; _m_h5_tk_enc=1918683bae593e636455ee3c7ea4efa2; SWITCH_SHOP=; WMUSS=N2U3OTMTAwMDAyNzYxNzAwOTEyTmUzeEZqczJQ; WMSTOKEN=N2U3OTMTAwMDAyNzYxNzAwOTEyTmUzeEZqczJQ; OUTER_AUTH_LOGIN=N2U3OTMTAwMDAyNzYxNzAwOTEyTmUzeEZqczJQ%3BN2U3OTMTAwMDAyNzYxNzAwOTEyTmUzeEZqczJQ; _wmcrmpush=2AE9B7448B12CAF4424E7BF4C6229B5B_1620971501_00_2233065879_hcxsqg0_1; EGG_SESS=HXhsa0ae3eimhuFUCB_6niZdqRWZnwHYGtQuBxHoxMEBzgRXLwDPCCEH6BeIhCvH; tfstk=cHsNBmgFjlEZNttbyhtqCO6bfrKOZpWGnDJWSw8VDJprydYGikcvK549LKO8xFf..; l=eBgWAKP7jpZewUbSBOfwourza77OSIRAguPzaNbMiOCPsXfp5it5B66FT6T9C3GVh6l6R37l8fV8BeYBqIc5qegwsUvKEYDmn; isg=BBkZNSjrnRZ3SkGPOQKKzEZLKAXzpg1YPZPZ3zvOlcC_QjnUg_YdKIdQRAY0eqWQ +UTUSER=0; cna=A9cHGZw1jjgCAd3tly+uuYIG; ubt_ssid=kpqd18ueqc12rljyipjmobcr5vlc3xry_2021-04-23; t=bc6b1c1fc4e7ef841fff494286415f8b; OPENUSS=N2NKOTMTAwMDAyNzYxNzAwOTEyTmpod0RtaTlQ; SWITCH_SHOP=%2F6bac%2BAb1bPK6koBkfv6k08FDLdMxARhpTN8yXhXvoflklVfUmxnSim7ZNZjEGNB8JBNv5vn946%2B7HtPrNmkcz5R4iSP9JCINIhfBd0fwz5lR%2B7DY72DtAidguPGmM778RF0rUhnjJhVMiuIe2Kt8OA%2FUTnG59pQNWfCtVjpfmQvNdtU%2FVcr1%2FWwDrbtAY2v; _m_h5_tk=a77351c2911f8484ff7c2a4c9c8def83_1629200451933; _m_h5_tk_enc=c113d3c67a3d35821adc914d799a2d6d; xlly_s=1; WMUSS=MJLLN2MTAwMDAyNzYxNzAwOTEyTmxrMm9PYzBQ; WMSTOKEN=MJLLN2MTAwMDAyNzYxNzAwOTEyTmxrMm9PYzBQ; OUTER_AUTH_LOGIN=MJLLN2MTAwMDAyNzYxNzAwOTEyTmxrMm9PYzBQ%3BMJLLN2MTAwMDAyNzYxNzAwOTEyTmxrMm9PYzBQ; EGG_SESS=m6drJjNW1sXiQ8e5om0V3oO39ZNOOo-XsaxKm6yWxBrYOA5xU8GuwFtZME4VD8yx; tfstk=c54GBNifxlo_sxn3VNg__oi3ULgNZnLqErzQ8rUOInR02YUFiXKe4_WdtA2gkn1..; l=eBgWAKP7jpZewuqWBO5Z-urza77TFIdf5sPzaNbMiInca1uR0UXMSNCKItmXUdtjgtCf1eKPrwlgwRButnzdgnbuzDKV9ydtnxJO.; isg=BLGxXdb4dFu3btnHkQqSlG7TwD1LniUQBRshF5PHB3jvutgM2u5d4m2c3E7ccr1I `) } diff --git a/platformapi/ebaiapi/order_test.go b/platformapi/ebaiapi/order_test.go index 52516a48..6ac395f2 100644 --- a/platformapi/ebaiapi/order_test.go +++ b/platformapi/ebaiapi/order_test.go @@ -7,7 +7,7 @@ import ( ) func TestOrderGet(t *testing.T) { - result, err := api.OrderGet("5032717275039729232") + result, err := api.OrderGet("5034788341689687660") if err != nil { t.Fatal(err) } else { diff --git a/platformapi/ebaiapi/shop_test.go b/platformapi/ebaiapi/shop_test.go index f6226d81..9b59b8f8 100644 --- a/platformapi/ebaiapi/shop_test.go +++ b/platformapi/ebaiapi/shop_test.go @@ -81,7 +81,7 @@ func TestShopUpdate(t *testing.T) { params := map[string]interface{}{ //KeyName: "好菜鲜生(龙宫市场店)", //KeyPhone: "13812345678", - KeyBaiduShopID: "32267358118", + KeyBaiduShopID: "2097134681", //"longitude": 116.307884, //"latitude": 40.036828, //"coord_type": "amap", @@ -89,7 +89,10 @@ func TestShopUpdate(t *testing.T) { //"city": "131", //"county": "1960", //"address": "北京市海淀区上地信息路甲9号", - "shop_logo": "http://image.jxc4.com/image/e078b225d7b232b4497a689dbf65159e.jpg", + "takeout_shop_logo": "https://image-star.elemecdn.com/pb/b79d499b9b0be5deb3ee3ce71bf29ad0a8", + "baidu_takeout_logo": "https://image-star.elemecdn.com/pb/b79d499b9b0be5deb3ee3ce71bf29ad0a8", + "ele_takeout_logo": "https://image-star.elemecdn.com/pb/b79d499b9b0be5deb3ee3ce71bf29ad0a8", + //"baidu_takeout_logo" //takeoutShopLogo//baiduTakeoutLogo } err := api.ShopUpdate(params) if err != nil { diff --git a/platformapi/ebaiapi/sku_test.go b/platformapi/ebaiapi/sku_test.go index f3487025..771a1ba9 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("http://image.jxc4.com/image/212c268d26f6237e33ba269d24e2f76b.jpg", nil) + result, err := api.PictureUpload("http://image.jxc4.com/image/e078b225d7b232b4497a689dbf65159e.jpg", nil) if err != nil { t.Fatal(err) } else { diff --git a/platformapi/ebaiapi/store_page.go b/platformapi/ebaiapi/store_page.go index 2a339197..82c79586 100644 --- a/platformapi/ebaiapi/store_page.go +++ b/platformapi/ebaiapi/store_page.go @@ -1,7 +1,6 @@ package ebaiapi import ( - "encoding/json" "fmt" "net/http" "strings" @@ -613,9 +612,10 @@ func (a *API) AccessStorePage2(subURL, storeURL2 string, params map[string]inter request, _ = http.NewRequest(http.MethodGet, utils.GenerateGetURL(url, subURL, params), nil) } else { if storeURL2 != "" { - result, _ := json.MarshalIndent(params, "", " ") - request, _ = http.NewRequest(http.MethodPost, utils.GenerateGetURL(url, subURL, nil), strings.NewReader(string(result))) - request.Header.Set("Content-Type", "application/ncp4+json") + //result, _ := json.MarshalIndent(params, "", " ") + request, _ = http.NewRequest(http.MethodPost, utils.GenerateGetURL(url, subURL, nil), strings.NewReader(utils.Map2URLValues(params).Encode())) + //request.Header.Set("Content-Type", "application/ncp4+json") + request.Header.Set("Content-Type", "application/x-www-form-urlencoded") } else { request, _ = http.NewRequest(http.MethodPost, utils.GenerateGetURL(url, subURL, nil), strings.NewReader(utils.Map2URLValues(params).Encode())) request.Header.Set("charset", "UTF-8") @@ -1476,3 +1476,13 @@ func (a *API) GetSubActivityDetail(actID int) (getSubActivityDetailResult *GetSu } return getSubActivityDetailResult, err } + +//饿百修改门店 +//https://ebai-zs.ele.me/api/activities/get-sub-activity-detail?id=6134599001&isMobile=0 +func (a *API) ModifyShop() (err error) { + _, err = a.AccessStorePage("h5/mtop.eleme.newretail.shop.admin.ebai.pc.store.modifyshop/1.0/?jsv=2.6.1&appKey=12574478&t=1629193871490&sign=c98e4f2e874ce2300ac77810ca86b1ad&api=mtop.eleme.newretail.shop.admin.ebai.pc.store.modifyShop&v=1.0&H5Request=true&type=originaljson&dataType=json", + "https://nrshop.ele.me", map[string]interface{}{ + "data": `{"wid":"32267358118","name":"好菜鲜生(龙宫市场店)","categoryId":277,"categoryName":"厨房生鲜","businessFormId":1917869373,"provinceName":"福建省","provinceId":10013,"cityName":"泉州市","cityId":102,"countyName":"鲤城区","countyId":5416,"address":"福建省泉州市鲤城区鲤中街道百源社区龙宫市场内","longitude":"118.5950827921","latitude":"24.903530599638","baiduTakeoutLogo":"https://image-star.elemecdn.com/pb/b79d499b9b0be5deb3ee3ce71bf29ad0a8"}`, + }, true) + return err +} diff --git a/platformapi/ebaiapi/store_page_test.go b/platformapi/ebaiapi/store_page_test.go index 176a67fa..80f9c0d6 100644 --- a/platformapi/ebaiapi/store_page_test.go +++ b/platformapi/ebaiapi/store_page_test.go @@ -225,3 +225,11 @@ func TestGetSubActivityDetail(t *testing.T) { } t.Log(utils.Format4Output(result, false)) } + +func TestModifyShop(t *testing.T) { + err := api.ModifyShop() + if err != nil { + t.Fatal(err) + } + //t.Log(utils.Format4Output(result, false)) +} diff --git a/platformapi/ebaiapi/ugc_test.go b/platformapi/ebaiapi/ugc_test.go index eb875901..6efe59ab 100644 --- a/platformapi/ebaiapi/ugc_test.go +++ b/platformapi/ebaiapi/ugc_test.go @@ -16,7 +16,7 @@ func TestOrderRatesGet(t *testing.T) { } func TestOrderCommetGet(t *testing.T) { - commentList, err := api.OrderCommetGet("103035", 0, utils.Str2Time("2020-07-01"), utils.Str2Time("2020-09-30"), ReplyStatusAll) + commentList, err := api.OrderCommetGet("103035", 0, utils.Str2Time("2021-07-01"), utils.Str2Time("2021-07-30"), ReplyStatusAll) if err != nil { t.Fatal(err) } diff --git a/platformapi/jdshopapi/store_page.go b/platformapi/jdshopapi/store_page.go index b6dca116..ae0e0162 100644 --- a/platformapi/jdshopapi/store_page.go +++ b/platformapi/jdshopapi/store_page.go @@ -741,7 +741,13 @@ func (a *API) SubmitBasic(updateBasicParam *UpdateBasicParam) (vendorStoreID int "requestId": reqID, }, true) if err == nil { - vendorStoreID = utils.MustInterface2Int64(result["data"]) + if result != nil { + if result["data"] != nil{ + vendorStoreID = utils.MustInterface2Int64(result["data"]) + }else{ + err = fmt.Errorf("err %s", result["msg"]) + } + } } return vendorStoreID, err } diff --git a/platformapi/jdshopapi/store_page_test.go b/platformapi/jdshopapi/store_page_test.go index 1c104819..80dc3771 100644 --- a/platformapi/jdshopapi/store_page_test.go +++ b/platformapi/jdshopapi/store_page_test.go @@ -226,9 +226,168 @@ func TestUpdateDeliveryPromise(t *testing.T) { } func TestUploadImageNew(t *testing.T) { - bkey, _ := base64.StdEncoding.DecodeString("EjTgnEa377fEcgzlQUbcgTzxPNznRjpOuSPgQAwv9aA" + "=") - block, _ := aes.NewCipher(bkey) - fmt.Println(bkey, block) + //dp[m][n] = dp[m-1][n] + dp[m][n-1] + fmt.Println(myAtoi("21A")) +} + +func myAtoi(s string) (r int) { + abs, sign, i, n := 0, 1, 0, len(s) + for i < n && s[i] == ' ' { + i++ + } + if i < n { + if s[i] == '-' { + sign = -1 + i++ + } else if s[i] == '+' { + sign = 1 + i++ + } + } + for i < n && s[i] >= '0' && s[i] <= '9' { + abs = 10*abs + int(s[i]-'0') //字节 byte '0' == 48 + if sign*abs < math.MinInt32 { //整数超过 32 位有符号整数范围 + return math.MinInt32 + } else if sign*abs > math.MaxInt32 { + return math.MaxInt32 + } + i++ + } + return r +} + +func minCostClimbingStairs(cost []int) int { + min := func(a, b int) int { + if a < b { + return a + } + return b + } + var dp = make([]int, len(cost)) + dp[0] = 0 + dp[1] = 0 + for i := 2; i < len(cost); i++ { + dp[i] = min(dp[i-1]+cost[i], dp[i-2]+cost[i-1]) + } + return dp[len(cost)] +} + +func climbStairs(n int) int { + a, b, c := 0, 0, 1 + for i := 1; i < n+1; i++ { + a = b + b = c + c = a + b + } + return c +} + +//leetcode 1876 +func countGoodSubstrings(s string) int { + if len(s) < 3 { + return 0 + } + count := 0 + a, b, c := s[0:1], s[1:2], s[2:3] + for i := 3; i < len(s)+1; i++ { + if a != b && b != c && a != c { + count++ + } + if i == len(s) { + break + } + a = b + b = c + c = s[i : i+1] + } + return count +} + +//T0 = 0, T1 = 1, T2 = 1, 且在 n >= 0 的条件下 Tn+3 = Tn + Tn+1 + Tn+2 +func tribonacci(n int) int { + if n == 0 || n == 1 { + return n + } + if n == 2 { + return 1 + } + var tris = make([]int, n+1) + tris[0] = 0 + tris[1] = 1 + tris[2] = 1 + for i := 3; i < n+1; i++ { + tris[i] = tris[i-1] + tris[i-2] + tris[i-3] + } + return tris[n] +} + +func fib(n int) (result int) { + //if n == 0 || n == 1 { + // return n + //} + //var fibs = make([]int, n+1) + //fibs[0] = 0 + //fibs[1] = 1 + //for i := 2; i < n+1; i++ { + // fibs[i] = fibs[i-1] + fibs[i-2] + //} + //return fibs[n] + if n == 0 || n == 1 { + return n + } + a, b, c := 0, 0, 1 + for i := 2; i < n+1; i++ { + a = b + b = c + c = a + b + } + return c +} + +//经典dp +func dp2(m, n int) (result int) { + var dp = make([][]int, m) + for i := 0; i < m; i++ { + dp[i] = make([]int, n) + for j := 0; j < n; j++ { + if i == 0 || j == 0 { + dp[i][j] = 1 + } else { + dp[i][j] = dp[i-1][j] + dp[i][j-1] + } + } + } + return dp[m-1][n-1] +} + +func a(n int) (ans int) { + const mod int = 1e9 + 7 + dp := make([][2][3]int, n+1) // 三个维度分别表示:长度,A 的数量,结尾连续 L 的数量 + dp[0][0][0] = 1 + for i := 1; i <= n; i++ { + // 以 P 结尾的数量 + for j := 0; j <= 1; j++ { + for k := 0; k <= 2; k++ { + dp[i][j][0] = (dp[i][j][0] + dp[i-1][j][k]) % mod + } + } + // 以 A 结尾的数量 + for k := 0; k <= 2; k++ { + dp[i][1][0] = (dp[i][1][0] + dp[i-1][0][k]) % mod + } + // 以 L 结尾的数量 + for j := 0; j <= 1; j++ { + for k := 1; k <= 2; k++ { + dp[i][j][k] = (dp[i][j][k] + dp[i-1][j][k-1]) % mod + } + } + } + for j := 0; j <= 1; j++ { + for k := 0; k <= 2; k++ { + ans = (ans + dp[n][j][k]) % mod + } + } + return ans } func checkRecord(s string) bool { diff --git a/platformapi/mtwmapi/comment.go b/platformapi/mtwmapi/comment.go index 0695e54b..14b877ea 100644 --- a/platformapi/mtwmapi/comment.go +++ b/platformapi/mtwmapi/comment.go @@ -44,6 +44,7 @@ func (a *API) CommentQuery(poiCode string, startDateStr, endDateStr string, offs "end_time": endDateStr, "pageoffset": offset, "pagesize": limit, + "replyStatus": replyStatus, } if limit <= 0 { limit = math.MaxInt32 diff --git a/platformapi/mtwmapi/comment_test.go b/platformapi/mtwmapi/comment_test.go index 3be549d6..ae6bc4fb 100644 --- a/platformapi/mtwmapi/comment_test.go +++ b/platformapi/mtwmapi/comment_test.go @@ -7,7 +7,7 @@ import ( ) func TestCommentQuery(t *testing.T) { - result, err := api.CommentQuery("6783778", "20190501", "20190515", 0, 0, CommentReplyStatusAll) + result, err := api.CommentQuery("7809572", "20210817", "20210818", 0, 0, CommentReplyStatusAll) if err != nil { t.Fatal(err) } diff --git a/platformapi/mtwmapi/poi_test.go b/platformapi/mtwmapi/poi_test.go index 5598818c..77f50acb 100644 --- a/platformapi/mtwmapi/poi_test.go +++ b/platformapi/mtwmapi/poi_test.go @@ -22,7 +22,7 @@ func TestPoiGetIDs(t *testing.T) { } func TestPoiMGet(t *testing.T) { - result, err := api.PoiMGet([]string{"11011885"}) + result, err := api.PoiMGet([]string{"12524795"}) t.Log(utils.Format4Output(result, false)) if err != nil { t.Fatal(err)