Merge remote-tracking branch 'origin/dev/dev1.0' into dev/dev1.0

This commit is contained in:
Rzy 2024-08-12 14:38:27 +08:00
commit 37100eb589
2 changed files with 56 additions and 0 deletions

View File

@ -13,6 +13,7 @@ import (
"github.com/go-pay/gopay/alipay"
"github.com/go-pay/gopay/wechat/v3"
"github.com/qit-team/snow-core/log/logger"
"io/ioutil"
"strconv"
"net/http"
@ -135,3 +136,56 @@ func AliCallback(c *gin.Context) {
c.String(http.StatusOK, "%s", "success")
return
}
func BrokerWechatUrl(c *gin.Context) {
url := c.Query("url")
if url == "" {
c.String(400, "url is empty")
return
}
method := "GET"
client := &http.Client{}
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Referer", "https://cardmallpay.85938.cn")
req.Header.Add("User-Agent", "Apifox/1.0.0 (https://apifox.com)")
req.Header.Add("Accept", "*/*")
req.Header.Add("Host", "wx.tenpay.com")
req.Header.Add("Connection", "keep-alive")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
// 读取响应体
body, err := ioutil.ReadAll(res.Body)
if err != nil {
c.AbortWithError(http.StatusInternalServerError, err)
return
}
// 复制响应头部(可选,根据需要选择需要的头部)
for name, values := range res.Header {
// 注意某些头部如Content-Length在转发时可能需要重新计算
for _, value := range values {
c.Writer.Header().Add(name, value)
}
}
// 设置状态码
c.Writer.WriteHeader(res.StatusCode)
// 写入响应体
_, err = c.Writer.Write(body)
if err != nil {
c.AbortWithError(http.StatusInternalServerError, err)
return
}
}

View File

@ -62,6 +62,8 @@ func RegisterRoute(router *gin.Engine) {
pay.POST("/query", front.QueryOrder) //查询订单
pay.POST("/refund", front.Refund)
}
// 测试微信支付唤起
v1.GET("/brokerWechatUrl", front.BrokerWechatUrl)
}
router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))