diff --git a/platformapi/autonavi/autonavi_page_test.go b/platformapi/autonavi/autonavi_page_test.go index f789a535..1ae9ad1f 100644 --- a/platformapi/autonavi/autonavi_page_test.go +++ b/platformapi/autonavi/autonavi_page_test.go @@ -7,7 +7,7 @@ import ( ) func TestGetCoordinateFromAddressByPage(t *testing.T) { - lng, lat, err := autonaviAPI.GetCoordinateFromAddressByPage("北京西城区内环到二环里西单大木仓胡同35号西五楼4-503") + lng, lat, err := autonaviAPI.GetCoordinateFromAddressByPage("兴月宏干杂", 510100) if err != nil { t.Fatal(err) } diff --git a/platformapi/autonavi/autonavi_test.go b/platformapi/autonavi/autonavi_test.go index 11ab230d..08f1a849 100644 --- a/platformapi/autonavi/autonavi_test.go +++ b/platformapi/autonavi/autonavi_test.go @@ -85,7 +85,7 @@ func TestGetDistricts(t *testing.T) { } func TestGetCoordinateFromAddress(t *testing.T) { - lng, lat, districtCode := autonaviAPI.GetCoordinateFromAddress("河北廊坊市三河市燕郊镇燕郊经济开发区迎宾北路燕京理工学院", "") + lng, lat, districtCode := autonaviAPI.GetCoordinateFromAddress("兴月宏干杂", "成都") t.Logf("lng:%f, lat:%f, districtCode:%d", lng, lat, districtCode) } diff --git a/platformapi/ebaiapi/activity_test.go b/platformapi/ebaiapi/activity_test.go index d7a8e358..e147ae79 100644 --- a/platformapi/ebaiapi/activity_test.go +++ b/platformapi/ebaiapi/activity_test.go @@ -79,7 +79,7 @@ func TestActivityGet(t *testing.T) { } func TestActivityDisable(t *testing.T) { - err := api.ActivityDisable(6000000208123866, "", 32267314429, 0) + err := api.ActivityDisable(6000000230771099, "", 42267069437, 0) if err != nil { t.Fatal(err) } diff --git a/platformapi/ebaiapi/ebaiapi_test.go b/platformapi/ebaiapi/ebaiapi_test.go index 29887a2c..660c2a59 100644 --- a/platformapi/ebaiapi/ebaiapi_test.go +++ b/platformapi/ebaiapi/ebaiapi_test.go @@ -29,10 +29,10 @@ func init() { // api = New("62289", "d3ec2358d6a819ea") // 京西菜市 - api = New("34665", "c3db75b754ea2d89") + // api = New("34665", "c3db75b754ea2d89") // 京西果园 - // api = New("35957", "10013fbb7c2ddad7") + api = New("35957", "10013fbb7c2ddad7") api.SetCookie("PASSPORT_DELIMONT_TOKEN", "PBE_2.0_5cd1c6141c127d4188f026ac01fc93656266683e8dfb3127c2fdf894259e9034125ff3bdd2a997a385802ee3ef1802ba93a04acea34fde2d2b6e802c5dcd4ec6e3f4ad909a1d806e3ceeb349ed726b03d60ed1fe7010d4140aa338d9c5f05e3fec172c78d3d7f0ca579d61b7015af1bf99aa46b04d2b8a64aa50646dc09afe94b6b60e0ba9a933635db5e8b2a035e9b6d693b289acf1b256d5b9a3f8478c87b0b009115bfd1394f20bb5a0dc2c07b8d013a25f286ec6bf7f2d86010d65507e31358834b7a6b58fbd88cb3f1a12cf71c997b91c1527f6f3c10693f7c2bd6073da8633a98cd2dc1114dfa5be5ee0e60b02cf7e4a94d0fb563a8c01717e7c050f02249117219c07a2eb211577c208ba77f4d536fa25139bc249be93b38d6fc495ef67a32aa206835d177db402bc534de1d29caf4f6b4fbcd912c13f167d00d1732222744c336a5189728f72fb5e153c4b1164171cfb0c811f34f4c2fedd43f721b8706b43f8d631251c") api.SetCookie("WMUSS", "4AAPQCAAB5PF0aUGcBVzoRTCEkOFhFIhx-Yk9vN2EfPHYoLlROKBEsQmAUQjhNUgRt0ADAP5x-RFklwAAdjxGO11iOj8xKXYSSDIJb2BcPghsaklNfQwGS10JOVRFfhAiYElhEXFXIzoJKyloCGdwdFE6Qk9FRxojUFN3FVEHNjJPZJu4Bt9nxQ13cwoMbjA") api.SetCookie("WMSTOKEN", "AcAANQZAABbC04rUBZFc2UYanlocDAaP0dcfzZCeS1SHQ1qJ15ExgAA13A2dGLjdbcitBZJu4Bn6B_g6cZAAA0tyyFm8cdBaNAQAAwug8HTG0xRjwt1UZzbcAAN7ofRO") diff --git a/platformapi/jdeclpapi/jdeclpapi.go b/platformapi/jdeclpapi/jdeclpapi.go index 21065579..d55a2a02 100644 --- a/platformapi/jdeclpapi/jdeclpapi.go +++ b/platformapi/jdeclpapi/jdeclpapi.go @@ -20,6 +20,7 @@ const ( sigKey = "sign" IsvSource = "ISV0020000000068" DepartmentNo = "EBU4418046609452" + ShipperNo = "CYS4398046511104" ShopNo = "ESP0020000066348" WarehouseNo = "110014006" CustomerCode = "028K595510" @@ -88,6 +89,7 @@ type AddOrderParam struct { ShopNo string `json:"shopNo"` //店铺编号(B2C订单必填,B2B(soType=2)订单非必填) DepartmentNo string `json:"departmentNo"` //事业部编号,且与pin匹配 WarehouseNo string `json:"warehouseNo"` //库房编号,事业部开启寻源拆分服务可不填;否则必填; + ShipperNo string `json:"shipperNo"` //承运商编号 SalesPlatformOrderNo string `json:"salesPlatformOrderNo"` //销售平台订单号,如果销售平台来源为京东平台,则该字段不能为空,长度不超过200 SalePlatformSource string `json:"salePlatformSource"` //销售平台来源 ConsigneeName string `json:"consigneeName"` //收货人姓名,长度不能超20 diff --git a/platformapi/jdeclpapi/jdeclpapi_test.go b/platformapi/jdeclpapi/jdeclpapi_test.go index 351ebed0..cf5275f7 100644 --- a/platformapi/jdeclpapi/jdeclpapi_test.go +++ b/platformapi/jdeclpapi/jdeclpapi_test.go @@ -127,7 +127,7 @@ func TestCancelWayBill(t *testing.T) { } func TestQueryDynamicTraceInfo(t *testing.T) { - result, err := api.QueryDynamicTraceInfo("JDVD01333952184") + result, err := api.QueryDynamicTraceInfo("JDVD01376429529") if err != nil { t.Fatal(err) } @@ -135,7 +135,7 @@ func TestQueryDynamicTraceInfo(t *testing.T) { } func TestWaybillQuery(t *testing.T) { - result, err := api.WaybillQuery("JDVD01319320290") + result, err := api.WaybillQuery("JDVD01345722555") if err != nil { t.Fatal(err) } diff --git a/platformapi/jdshopapi/store_page_test.go b/platformapi/jdshopapi/store_page_test.go index 3761ee3d..9dad1591 100644 --- a/platformapi/jdshopapi/store_page_test.go +++ b/platformapi/jdshopapi/store_page_test.go @@ -6,6 +6,7 @@ import ( "crypto/cipher" "encoding/base64" "fmt" + "sort" "testing" "git.rosy.net.cn/baseapi/utils" @@ -216,16 +217,201 @@ func TestUpdateExpand(t *testing.T) { } func TestUploadImageNew(t *testing.T) { - // data, _, err := DownloadFileByURL("http://image.jxc4.com/image/b90ae8585e8cf2f3871f6e8318bde1dc.tem.png") + // accountsMerge([][]string{[]string{ + // "John", "johnsmith@mail.com", "john00@mail.com", + // }, []string{ + // "John", "johnnybravo@mail.com", + // }, []string{ + // "John", "johnsmith@mail.com", "john_newyork@mail.com", + // }, []string{ + // "Mary", "mary@mail.com", + // }}) + fmt.Println(addToArrayForm([]int{1, 2, 6, 3, 0, 7, 1, 7, 1, 9, 7, 5, 6, 6, 4, 4, 0, 0, 6, 3}, 516)) +} - // result, err := api.UploadImageNew(data, "b90ae8585e8cf2f3871f6e8318bde1dc.tem.png") - // if err != nil { - // t.Fatal(err) +func addToArrayForm(A []int, K int) (a []int) { + for k, _ := range A { + A[k] = A[len(A)-k] + } + fmt.Println(A) + // for _, v := range result { + // if b, err := strconv.Atoi(string(v)); err == nil { + // a = append(a, b) + // } // } - // t.Log(utils.Format4Output(result, false)) - // str := "京西菜市松林农贸市场.生鲜店" - // str2 := str[0:strings.Index(str, ".")] + str[strings.Index(str, ".")+1:len(str)] - fmt.Println(2 % 4) + return a +} + +func maximumProduct(nums []int) int { + sort.Ints(nums) + n := len(nums) + fmt.Println(nums) + return max(nums[0]*nums[1]*nums[n-1], nums[n-3]*nums[n-2]*nums[n-1]) +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} + +func accountsMerge(accounts [][]string) (ans [][]string) { + emailToIndex := map[string]int{} + emailToName := map[string]string{} + for _, account := range accounts { + name := account[0] + for _, email := range account[1:] { + if _, has := emailToIndex[email]; !has { + emailToIndex[email] = len(emailToIndex) + emailToName[email] = name + } + } + } + fmt.Println(emailToIndex) + fmt.Println() + + fmt.Println(emailToName) + parent := make([]int, len(emailToIndex)) + for i := range parent { + parent[i] = i + } + var find func(int) int + find = func(x int) int { + if parent[x] != x { + parent[x] = find(parent[x]) + } + return parent[x] + } + union := func(from, to int) { + parent[find(from)] = find(to) + } + + for _, account := range accounts { + firstIndex := emailToIndex[account[1]] + for _, email := range account[2:] { + union(emailToIndex[email], firstIndex) + } + } + + fmt.Println(parent) + fmt.Println() + fmt.Println(accounts) + + indexToEmails := map[int][]string{} + for email, index := range emailToIndex { + index = find(index) + indexToEmails[index] = append(indexToEmails[index], email) + } + fmt.Println(indexToEmails) + + for _, emails := range indexToEmails { + sort.Strings(emails) + account := append([]string{emailToName[emails[0]]}, emails...) + ans = append(ans, account) + } + return +} + +func findRedundantConnection(edges [][]int) []int { + parent := make([]int, len(edges)+1) + for i := range parent { + parent[i] = i + } + fmt.Println("edges ", edges) + fmt.Println("parent ", parent) + var find func(int) int + find = func(x int) int { + if parent[x] != x { + parent[x] = find(parent[x]) + } + return parent[x] + } + union := func(from, to int) bool { + fmt.Println(from, to) + x, y := find(from), find(to) + fmt.Println(x, y) + if x == y { + return false + } + parent[x] = y + fmt.Println(parent) + fmt.Println("-------------------------------") + return true + } + for _, e := range edges { + if !union(e[0], e[1]) { + return e + } + } + return nil +} + +func removeStones(stones [][]int) int { + fa := map[int]int{} + var find func(int) int + find = func(x int) int { + if _, has := fa[x]; !has { + fa[x] = x + } + if fa[x] != x { + fa[x] = find(fa[x]) + } + fmt.Println(fa[x]) + return fa[x] + } + union := func(x, y int) { + fmt.Println(x, y) + fx, fy := find(x), find(y) + if fx == fy { + return + } + fa[fy] = fx + fmt.Println(fa) + } + for _, p := range stones { + union(p[0], p[1]+10000) + } + ans := len(stones) + for x, fx := range fa { + if x == fx { + ans-- + } + } + return ans +} + +//动态规划 +func maxUncrossedLines(A []int, B []int) (s int) { + var dynamic = make([][]int, len(A)+1, len(A)+1) + for index := range dynamic { + dynamic[index] = make([]int, len(B)+1, len(B)+1) //多创建一列,因为 index = 0 的时候,没有前置匹配 + } + for _, v := range dynamic { + fmt.Println(v) + } + fmt.Println("---------------------") + for index, a := range A { + for i, b := range B { + if a == b { + dynamic[index+1][i+1] = dynamic[index][i] + 1 + for _, v := range dynamic { + fmt.Println(v) + } + fmt.Println("---------------------") + } else { + dynamic[index+1][i+1] = dynamic[index][i+1] + if dynamic[index+1][i+1] < dynamic[index+1][i] { + dynamic[index+1][i+1] = dynamic[index+1][i] //判断大小,取大值 + } + for _, v := range dynamic { + fmt.Println(v) + } + fmt.Println("---------------------") + } + } + } + return dynamic[len(A)][len(B)] } func TestShopList(t *testing.T) { diff --git a/platformapi/mtwmapi/mtwmapi.go b/platformapi/mtwmapi/mtwmapi.go index be264797..6073585c 100644 --- a/platformapi/mtwmapi/mtwmapi.go +++ b/platformapi/mtwmapi/mtwmapi.go @@ -120,6 +120,7 @@ func (a *API) AccessAPI2(cmd string, isGet bool, bizParams map[string]interface{ params := make(map[string]interface{}) params["timestamp"] = time.Now().Unix() params["app_id"] = a.appID + // params["access_token"] = "token_nH_IlcWQKAkZBqklwItNRw" params = utils.MergeMaps(params, bizParams) imgData := params[KeyImgData] if imgData != nil { diff --git a/platformapi/mtwmapi/mtwmapi_test.go b/platformapi/mtwmapi/mtwmapi_test.go index cc60c963..4cd56597 100644 --- a/platformapi/mtwmapi/mtwmapi_test.go +++ b/platformapi/mtwmapi/mtwmapi_test.go @@ -19,35 +19,13 @@ func init() { baseapi.Init(sugarLogger) // 菜市 - // api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "") + api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "") // 果园 - api = New("4123", "df2c88338b85f830cebce2a9eab56628", "") - - // api.SetCookie("_lx_utm", "utm_source%3D60066") - // api.SetCookie("_lxsdk", "82B825F99C7098EE5254EB228DC2A863CE34008DFF4AD0913E8DC80D009AA95E") - // api.SetCookie("_lxsdk_cuid", "16b8c52943fc8-0f5c424b19a108-2d604637-3d10d-16b8c52943f24") - // api.SetCookie("_lxsdk_s", "16b8c529302-353-107-d17%7C%7C11") - // api.SetCookie("au_trace_key_net", "default") - // api.SetCookie("cssVersion", "b05eaa31") - // api.SetCookie("iuuid", "82B825F99C7098EE5254EB228DC2A863CE34008DFF4AD0913E8DC80D009AA95E") - // api.SetCookie("mt_c_token", "2Q-NiXyFZ6UViMatiHdP86YpX2QAAAAAqAgAABf6QG4n-W8Zy_l_WLbUUKNmy238OkBp9Fx7rVcqZH6aod8hhhyB3JjfYkOv-7024A") - // api.SetCookie("oops", "2Q-NiXyFZ6UViMatiHdP86YpX2QAAAAAqAgAABf6QG4n-W8Zy_l_WLbUUKNmy238OkBp9Fx7rVcqZH6aod8hhhyB3JjfYkOv-7024A") - // api.SetCookie("openh5_uuid", "82B825F99C7098EE5254EB228DC2A863CE34008DFF4AD0913E8DC80D009AA95E") - // api.SetCookie("showTopHeader", "show") - // api.SetCookie("token", "2Q-NiXyFZ6UViMatiHdP86YpX2QAAAAAqAgAABf6QG4n-W8Zy_l_WLbUUKNmy238OkBp9Fx7rVcqZH6aod8hhhyB3JjfYkOv-7024A") - // api.SetCookie("w_token", "2Q-NiXyFZ6UViMatiHdP86YpX2QAAAAAqAgAABf6QG4n-W8Zy_l_WLbUUKNmy238OkBp9Fx7rVcqZH6aod8hhhyB3JjfYkOv-7024A") - // api.SetCookie("userFace", "") - // api.SetCookie("userId", "69979334") - // api.SetCookie("userName", "thepool") - // api.SetCookie("uuid", "82B825F99C7098EE5254EB228DC2A863CE34008DFF4AD0913E8DC80D009AA95E") - // api.SetCookie("wm_order_channel", "default") - // api.SetCookie("w_utmz", "utm_campaign=(direct)&utm_source=5000&utm_medium=(none)&utm_content=(none)&utm_term=(none)") - // api.SetCookie("w_visitid", "c2d0e4c9-3ab8-4163-b94f-a3dbfd9d7a94") - // api.SetCookie("w_actual_lng", "104076656") - // api.SetCookie("w_actual_lat", "30665696") - // api.SetCookie("w_latlng", "30702250,104052315") + // api = New("4123", "df2c88338b85f830cebce2a9eab56628", "") + //商超 + // api = New("5873", "41c479790a76f86326f89e8048964739", "") //token_nH_IlcWQKAkZBqklwItNRw cookieStr := ` acctId=62884810; token=0_0_vJux6rcmm0XIzoI885_aew-gnfofUw9SR-a-QkLw*; brandId=-1; wmPoiId=-1; ` diff --git a/platformapi/mtwmapi/order_test.go b/platformapi/mtwmapi/order_test.go index d74d3c90..f04f0c55 100644 --- a/platformapi/mtwmapi/order_test.go +++ b/platformapi/mtwmapi/order_test.go @@ -1,6 +1,7 @@ package mtwmapi import ( + "fmt" "testing" "time" @@ -50,7 +51,7 @@ func TestOrderReceived(t *testing.T) { } func TestOrderConfirm(t *testing.T) { - err := api.OrderConfirm(25236872740350976) + err := api.OrderConfirm(27058923254735296) if err != nil { t.Fatal(err) } @@ -80,7 +81,7 @@ func TestOrderLogisticsStatus(t *testing.T) { } func TestOrderBatchPullPhoneNumber(t *testing.T) { - result, err := api.OrderBatchPullPhoneNumber(testPoiCode, 0, MaxBatchPullPhoneNumberLimit) + result, err := api.OrderBatchPullPhoneNumber("5873_2705892", 0, MaxBatchPullPhoneNumberLimit) t.Log(utils.Format4Output(result, false)) if err != nil { t.Fatal(err) @@ -135,3 +136,37 @@ func TestGetOrderIdByDaySeqSingle(t *testing.T) { t.Fatal(err) } } + +func TestOrderRefundReject(t *testing.T) { + err := api.OrderRefundReject(27058923254735296, "测试") + // t.Log(utils.Format4Output(result, false)) + if err != nil { + t.Fatal(err) + } +} + +func TestOrderRefundAgree(t *testing.T) { + err := api.OrderRefundAgree(27058922456066076, "测试") + // t.Log(utils.Format4Output(result, false)) + if err != nil { + t.Fatal(err) + } +} + +func TestOrderCancel(t *testing.T) { + err := api.OrderCancel(27058922397679200, "取消", 1) + // t.Log(utils.Format4Output(result, false)) + if err != nil { + t.Fatal(err) + } +} + +func TestAa2(t *testing.T) { + time := time.Now().Unix() + fmt.Println(api.signParams(apiURL+"/oauth/authorize?", map[string]interface{}{ + "timestamp": time, + "app_id": "5873", + "app_poi_code": "5873_2705892", + "response_type": "token", + }), time) +} diff --git a/platformapi/mtwmapi/poi_test.go b/platformapi/mtwmapi/poi_test.go index d2bd0b92..7a453b0a 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{"10414069"}) + result, err := api.PoiMGet([]string{"8675995"}) t.Log(utils.Format4Output(result, false)) if err != nil { t.Fatal(err) diff --git a/platformapi/txcloudapi/txcloudapi_test.go b/platformapi/txcloudapi/txcloudapi_test.go index 45ef10e9..49fe5b4f 100644 --- a/platformapi/txcloudapi/txcloudapi_test.go +++ b/platformapi/txcloudapi/txcloudapi_test.go @@ -21,7 +21,7 @@ func init() { } func TestGetWaybillDetailInfo(t *testing.T) { - result, err := api.GetWaybillDetailInfo("JDVD01294351024", "") + result, err := api.GetWaybillDetailInfo("4606698717581", "") if err != nil { t.Fatal(err) }