From e106a982a149b4a257377e87ec8e035280bd9984 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Tue, 23 Feb 2021 16:07:46 +0800 Subject: [PATCH] aa --- platformapi/ebaiapi/ebaiapi_test.go | 4 +- platformapi/ebaiapi/order_test.go | 2 +- platformapi/jdshopapi/store_page_test.go | 76 ++++++++++++++++++++++-- platformapi/mtpsapi/shop.go | 19 ++++-- platformapi/mtpsapi/shop_test.go | 14 ++++- 5 files changed, 101 insertions(+), 14 deletions(-) diff --git a/platformapi/ebaiapi/ebaiapi_test.go b/platformapi/ebaiapi/ebaiapi_test.go index bff5a2d7..71ca3195 100644 --- a/platformapi/ebaiapi/ebaiapi_test.go +++ b/platformapi/ebaiapi/ebaiapi_test.go @@ -29,13 +29,13 @@ func init() { // api = New("62289", "d3ec2358d6a819ea") // 京西菜市 - // api = New("34665", "c3db75b754ea2d89") + api = New("34665", "c3db75b754ea2d89") //菜市测试 // api = New("62923", "aa4cdc6c1108486b") // 京西果园 - 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/ebaiapi/order_test.go b/platformapi/ebaiapi/order_test.go index 85dee1d1..1c945d79 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("2141992244233627664") + result, err := api.OrderGet("2143717024782172359") if err != nil { t.Fatal(err) } else { diff --git a/platformapi/jdshopapi/store_page_test.go b/platformapi/jdshopapi/store_page_test.go index 22d18f72..161e1f46 100644 --- a/platformapi/jdshopapi/store_page_test.go +++ b/platformapi/jdshopapi/store_page_test.go @@ -218,13 +218,69 @@ func TestUpdateExpand(t *testing.T) { } func TestUploadImageNew(t *testing.T) { - fmt.Println(spiralOrder([][]int{[]int{1, 2, 3, 4}, []int{5, 6, 7, 8}, []int{9, 10, 11, 12}})) + fmt.Println(calculate("22+23*2/22")) +} + +//给定一个包含正整数、加(+)、减(-)、乘(*)、除(/)的算数表达式(括号除外),计算其结果。 +//表达式仅包含非负整数,+, - ,*,/ 四种运算符和空格  。 整数除法仅保留整数部分。 +func calculate(s string) int { + // result := 0 + // s = strings.Trim(s, " ") + // count := map[string]func(a, b int) int{ + // "+": func(a, b int) int { + // return a + b + // }, + // "-": func(a, b int) int { + // return a - b + // }, + // "*": func(a, b int) int { + // return a * b + // }, + // "/": func(a, b int) int { + // return a / b + // }, + // } + // var str []string + // mem := "" + // for k, v := range s { + // if _, ok := count[string(v)]; !ok { + // mem = mem + string(v) + // } else { + // str = append(str, mem) + // mem = "" + // str = append(str, string(v)) + // } + // if k == len(s)-1 { + // str = append(str, mem) + // } + // } + // count := func(s []string) (r []string) { + + // return r + // } + + // for k, v := range str { + // if v == "*" || v == "/" { + // if k1, err := strconv.Atoi(str[k-1]); err == nil { + // if k2, err := strconv.Atoi(str[k+1]); err == nil { + // result += count[v](k1, k2) + // } + // } + // } + // } + return 1 } //输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字。 func spiralOrder(matrix [][]int) []int { var result []int - + if len(matrix) == 0 { + return result + } else { + if len(matrix[0]) == 0 { + return result + } + } l, h := len(matrix[0]), len(matrix) left, right, top, bottom := 0, l-1, 0, h-1 lmax, tmax := 0, 0 @@ -241,26 +297,34 @@ func spiralOrder(matrix [][]int) []int { for left <= lmax && top+1 <= tmax { for left1 := left; left1 <= right; left1++ { + if len(result) >= l*h { + break + } result = append(result, matrix[top][left1]) } - fmt.Println(result, 1) if h > 1 { for top1 := top + 1; top1 <= bottom; top1++ { + if len(result) >= l*h { + break + } result = append(result, matrix[top1][right]) } - fmt.Println(result, 2) if right > 0 { for right1 := right - 1; right1 >= left; right1-- { + if len(result) >= l*h { + break + } result = append(result, matrix[bottom][right1]) } } - fmt.Println(result, 3) if bottom > 0 { for bottom1 := bottom - 1; bottom1 >= top+1; bottom1-- { + if len(result) >= l*h { + break + } result = append(result, matrix[bottom1][left]) } } - fmt.Println(result, 4) } left++ top++ diff --git a/platformapi/mtpsapi/shop.go b/platformapi/mtpsapi/shop.go index ed3d33b4..8cea96f2 100644 --- a/platformapi/mtpsapi/shop.go +++ b/platformapi/mtpsapi/shop.go @@ -3,10 +3,12 @@ package mtpsapi import "git.rosy.net.cn/baseapi/utils" const ( - ShopStatusAuditRejected = 10 // 审核驳回 - ShopStatusAuditPassed = 20 // 审核通过 - ShopStatusAuditCreated = 30 // 创建成功 - ShopStatusAuditOnline = 40 // 上线可发单 + ShopStatusAuditRejected = 10 // 审核驳回 + ShopStatusAuditPassed = 20 // 审核通过 + ShopStatusAuditCreated = 30 // 创建成功 + ShopStatusAuditOnline = 40 // 上线可发单 + ShopStatusAuditUpdateRejected = 50 // 修改审核驳回 + ShopStatusAuditUpdatePassed = 60 // 修改审核通过 ) const ( @@ -55,6 +57,15 @@ func (a *API) ShopCreate(shopInfo *ShopInfo) (status int, err error) { return status, err } +func (a *API) ShopUpdate(shopInfo *ShopInfo) (status int, err error) { + params := utils.Struct2MapByJson(shopInfo) + result, err := a.AccessAPI("shop/update", params) + if err == nil { + status = int(utils.Interface2Int64WithDefault(result.Data["status"], 0)) + } + return status, err +} + func (a *API) ShopQuery(shopID string) (shopInfo *ShopInfo, err error) { result, err := a.AccessAPI("shop/query", map[string]interface{}{ "shop_id": shopID, diff --git a/platformapi/mtpsapi/shop_test.go b/platformapi/mtpsapi/shop_test.go index 4e0d77b8..39971ee7 100644 --- a/platformapi/mtpsapi/shop_test.go +++ b/platformapi/mtpsapi/shop_test.go @@ -18,7 +18,7 @@ func TestShopQuery(t *testing.T) { // if err == nil { // t.Fatal("应该报错找不到门店") // } - shopInfo, err := api.ShopQuery("666972") + shopInfo, err := api.ShopQuery("667018") if err != nil { t.Fatal(err) } @@ -46,6 +46,18 @@ func TestShopCreate(t *testing.T) { } } +func TestShopUpdate(t *testing.T) { + shopInfo := &ShopInfo{ + ShopID: "667018", + ShopLng: 113015935, + ShopLat: 25776427, + } + _, err := api.ShopUpdate(shopInfo) + if err != nil { + t.Fatal(err) + } +} + func TestSimulateArrange(t *testing.T) { err := api.SimulateArrange(123456789, "1529387562097059") handleError(t, err)