From e760d92332d1e89717f84de57596ed983f2e145c Mon Sep 17 00:00:00 2001 From: wolter Date: Mon, 12 Aug 2024 09:52:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E8=AE=B0=E5=BD=95=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/http/controllers/api.go | 6 +++++- app/http/middlewares/base.go | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/http/controllers/api.go b/app/http/controllers/api.go index 085c8b1..1b7f4c7 100644 --- a/app/http/controllers/api.go +++ b/app/http/controllers/api.go @@ -63,9 +63,13 @@ func ApiRes(c *gin.Context, data interface{}, code int, msg ...string) { } // 记录日志 if logId > 0 { + var appId int64 + if appCheckInfo != nil { + appId = appCheckInfo.AppId + } services.RequestLogUpdate(&orderrequestlogmodel.OrderRequestLog{ Id: logId, - AppId: appCheckInfo.AppId, + AppId: appId, OutTradeNo: GetOutTradeNo(c), MerchantResponse: originData, Status: common.STATUS_DISABLED, diff --git a/app/http/middlewares/base.go b/app/http/middlewares/base.go index 1af7e68..3f30a3b 100644 --- a/app/http/middlewares/base.go +++ b/app/http/middlewares/base.go @@ -156,6 +156,7 @@ func ValidatePayRequest() gin.HandlerFunc { controllers.ApiRes(c, nil, appCheck.Code) return } + c.Set("appCheckInfo", appCheck) //解密 dataByte, errCode := api.DeCrypt(appCheck.App, requestDataStruct.Data, requestDataStruct.Key) if errCode != errorcode.Success { @@ -186,7 +187,7 @@ func ValidatePayRequest() gin.HandlerFunc { if err != nil { utils.Log(c, "参数错误", "path=", path, "err=", err.Error(), "msg=", msg) controllers.ApiRes(c, nil, errorcode.ParamError, msg...) - c.Abort() + return } err = json.Unmarshal(dataByte, &v) if err != nil { @@ -194,7 +195,7 @@ func ValidatePayRequest() gin.HandlerFunc { return } c.Set("request", v) - c.Set("appCheckInfo", appCheck) + c.Next() } }