This commit is contained in:
苏尹岚
2020-10-20 11:01:15 +08:00
parent 64f8ebd43f
commit 5dd72f7b2d
2 changed files with 42 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
package controllers
import (
"fmt"
"net/http"
"git.rosy.net.cn/baseapi/platformapi/wxpayapi"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/partner/purchase/jx/localjx"
"git.rosy.net.cn/jx-callback/globals"
"git.rosy.net.cn/jx-callback/globals/api"
"github.com/astaxie/beego"
)
type WXPayController struct {
beego.Controller
}
func (c *WXPayController) Msg() {
if c.Ctx.Input.Method() == http.MethodPost {
msg, callbackResponse := api.WxpayAPI.GetCallbackMsg(c.Ctx.Request)
globals.SugarLogger.Debugf("wxpayapi callback msg:%s, callbackResponse:%s, %t", utils.Format4Output(msg, true), utils.Format4Output(callbackResponse, true), callbackResponse == nil)
var err error
if callbackResponse == nil {
if msg.MsgType == wxpayapi.MsgTypeUnkown {
err = fmt.Errorf("未知的微信支付回调类型:%d", msg.MsgType)
} else {
err = localjx.OnWxPayCallback(msg)
}
}
if callbackResponse == nil {
callbackResponse = wxpayapi.SuccessResponse
} else if err != nil {
callbackResponse = wxpayapi.Err2CallbackResponse(err, "")
}
c.Data["xml"] = callbackResponse
c.ServeXML()
} else {
c.Abort("404")
}
}

View File

@@ -48,6 +48,7 @@ func init() {
),
)
beego.AddNamespace(ns)
// beego.AutoRouter(&controllers)
beego.AutoRouter(&controllers.TongLianController{})
// 如下都是用于检测存活的空接口