From 0e5d663cc5a1d4207176d607730a385980f1a8e7 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 18 Mar 2020 19:43:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0UrlValuesToMap=E5=87=BD?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PayServer/src/base/platApi/qqApi.go | 2 +- PayServer/src/base/util/strconvUtil.go | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/PayServer/src/base/platApi/qqApi.go b/PayServer/src/base/platApi/qqApi.go index 5ed45fe..ca50486 100755 --- a/PayServer/src/base/platApi/qqApi.go +++ b/PayServer/src/base/platApi/qqApi.go @@ -70,7 +70,7 @@ func QQPrePay(openid string, appid string, zone string, amt string, goodId strin h.Write([]byte(param)) sign := hex.EncodeToString(h.Sum(nil)) value.Set("sig", sign) - data, _ := json.Marshal(value) + data, _ := json.Marshal(util.UrlValuesToMap(value)) resp, err := http.Post(u, "application/json;charset=UTF-8", bytes.NewReader(data)) if err != nil { log.Error("Post error ", err) diff --git a/PayServer/src/base/util/strconvUtil.go b/PayServer/src/base/util/strconvUtil.go index 2451695..ef8062a 100755 --- a/PayServer/src/base/util/strconvUtil.go +++ b/PayServer/src/base/util/strconvUtil.go @@ -4,6 +4,7 @@ import ( "encoding/binary" "math" "math/rand" + "net/url" "strconv" "strings" "time" @@ -401,3 +402,15 @@ func CombineMapU64U32(m1, m2 map[uint64]uint32) map[uint64]uint32 { return m1 } + +func UrlValuesToMap(v url.Values) map[string]string { + ret := make(map[string]string) + for k := range v { + if len(v[k]) > 0 { + ret[k] = v[k][0] + } else { + ret[k] = "" + } + } + return ret +}