Compare commits

..

No commits in common. "58f8cedb8545d2149abf46a2a3d9036ae06f8914" and "7ed1ca131b905c1b07f988c8290fe89c11d6c373" have entirely different histories.

1 changed files with 2 additions and 28 deletions

View File

@ -6,7 +6,6 @@ import (
"PaymentCenter/app/models/paychannelmodel" "PaymentCenter/app/models/paychannelmodel"
"PaymentCenter/app/services" "PaymentCenter/app/services"
"PaymentCenter/app/third/paymentService" "PaymentCenter/app/third/paymentService"
"bytes"
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
@ -14,7 +13,6 @@ import (
"github.com/go-pay/gopay/alipay" "github.com/go-pay/gopay/alipay"
"github.com/go-pay/gopay/wechat/v3" "github.com/go-pay/gopay/wechat/v3"
"github.com/qit-team/snow-core/log/logger" "github.com/qit-team/snow-core/log/logger"
"io"
"strconv" "strconv"
"net/http" "net/http"
@ -22,7 +20,7 @@ import (
// WxCallback 微信支付回调 // WxCallback 微信支付回调
func WxCallback(c *gin.Context) { func WxCallback(c *gin.Context) {
saveLogger(c, "wx") logger.Info(c, "WxCallback-回调数据", c.Request)
payChannelId := c.Param("payChannelId") payChannelId := c.Param("payChannelId")
logger.Info(c, "WxCallback-回调数据payChannelId", payChannelId) logger.Info(c, "WxCallback-回调数据payChannelId", payChannelId)
if payChannelId == "" { if payChannelId == "" {
@ -82,7 +80,7 @@ func WxCallback(c *gin.Context) {
// AliCallback 支付宝支付回调 // AliCallback 支付宝支付回调
func AliCallback(c *gin.Context) { func AliCallback(c *gin.Context) {
saveLogger(c, "ALI") logger.Info(c, "AliCallback-回调数据", c.Request)
payChannelId := c.Param("payChannelId") payChannelId := c.Param("payChannelId")
logger.Info(c, "AliCallback-回调数据APPID", payChannelId) logger.Info(c, "AliCallback-回调数据APPID", payChannelId)
if payChannelId == "" { if payChannelId == "" {
@ -137,27 +135,3 @@ func AliCallback(c *gin.Context) {
c.String(http.StatusOK, "%s", "success") c.String(http.StatusOK, "%s", "success")
return return
} }
func saveLogger(c *gin.Context, payType string) {
// 保存请求的方法和URL
method := c.Request.Method
url := c.Request.URL.String()
// 保存请求头
headers := make(map[string]string)
for k, v := range c.Request.Header {
headers[k] = v[0]
}
// 保存请求体
var bodyBytes []byte
if c.Request.Body != nil {
bodyBytes, _ = io.ReadAll(c.Request.Body)
}
// 由于 io.ReadAll 会将 body 读完,所以需要重新赋值
c.Request.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))
// 使用 logger 记录请求信息
logger.Info(c, "支付回调"+payType, fmt.Sprintf("接受的参数method: %s , url: %s , headers: %s , body: %s", method, url, headers, string(bodyBytes)))
c.Next()
}