From 39e64c8a220949531eb843f2c3abd97462f2a120 Mon Sep 17 00:00:00 2001 From: wolter Date: Thu, 8 Aug 2024 15:44:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8E=E5=8F=B0=EF=BC=8Crsa=E7=94=9F?= =?UTF-8?q?=E6=88=90=E5=AF=86=E9=92=A5=E8=B0=83=E6=95=B4,=E5=85=B3?= =?UTF-8?q?=E9=97=AD=E8=AE=A2=E5=8D=95fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/console/command.go | 7 +++---- app/utils/encrypt/rsa/rsa.go | 7 ++++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/console/command.go b/app/console/command.go index 67596a3..4ba35b5 100644 --- a/app/console/command.go +++ b/app/console/command.go @@ -82,11 +82,10 @@ func closeOrder() { // 发起关闭订单请求 response := paymentService.OrderClose(ctx, req) // 成功 - if response.Code == payCommon.PAY_SUCCESS_CODE { - orderIds = append(orderIds, orderInfo.Id) - } else { - utils.Log(nil, "关闭订单,上游失败", response) + if response.Code != payCommon.PAY_SUCCESS_CODE { + utils.Log(nil, "关闭订单,上游失败", response, orderInfo.Id) } + orderIds = append(orderIds, orderInfo.Id) } // 修改订单状态为关闭 cond = builder.NewCond() diff --git a/app/utils/encrypt/rsa/rsa.go b/app/utils/encrypt/rsa/rsa.go index f93101e..4ce9ff9 100644 --- a/app/utils/encrypt/rsa/rsa.go +++ b/app/utils/encrypt/rsa/rsa.go @@ -8,6 +8,7 @@ import ( "encoding/base64" "encoding/pem" "fmt" + "strings" ) // parseRSAPublicKeyFromPEM 解析PEM编码的RSA公钥 @@ -136,5 +137,9 @@ func GenerateKey() (string, string, error) { Bytes: derPkix, } pubPem := pem.EncodeToMemory(pubBlock) - return string(pubPem), string(privPem), nil + pri := strings.Replace(string(privPem), "-----BEGIN RSA PRIVATE KEY-----\n", "", -1) + pri = strings.Replace(pri, "\n-----END RSA PRIVATE KEY-----\n", "", -1) + pub := strings.Replace(string(pubPem), "-----BEGIN PUBLIC KEY-----\n", "", -1) + pub = strings.Replace(pub, "\n-----END PUBLIC KEY-----\n", "", -1) + return pub, pri, nil }