1
This commit is contained in:
@@ -51,7 +51,7 @@ func pay4OrderByTT(ctx *jxcontext.Context, order *model.GoodsOrder, vendorPayTyp
|
||||
}
|
||||
|
||||
func OnTTPayCallback(msg *tiktok.DetailCallBackMessage, refund *tiktok.DetailCallBackMessage2Refund, payType string) (err error) {
|
||||
globals.SugarLogger.Debugf("OnWxPayCallback msg:%s", utils.Format4Output(msg, true))
|
||||
globals.SugarLogger.Debugf("OnTTPayCallback msg:%s", utils.Format4Output(msg, true))
|
||||
switch payType {
|
||||
case tiktok.PayStatus: // 支付回调
|
||||
err = onTTPayFinished(msg)
|
||||
@@ -62,6 +62,7 @@ func OnTTPayCallback(msg *tiktok.DetailCallBackMessage, refund *tiktok.DetailCal
|
||||
}
|
||||
|
||||
func onTTPayFinished(msg *tiktok.DetailCallBackMessage) (err error) {
|
||||
globals.SugarLogger.Debugf("支付回调==================1")
|
||||
orderPay := &model.OrderPay{
|
||||
PayOrderID: msg.CpOrderno,
|
||||
PayType: model.PayTypeWX,
|
||||
@@ -88,6 +89,7 @@ func onTTPayFinished(msg *tiktok.DetailCallBackMessage) (err error) {
|
||||
}
|
||||
|
||||
func onTTPayRefund(msg *tiktok.DetailCallBackMessage2Refund) (err error) {
|
||||
globals.SugarLogger.Debugf("退款回调==================2")
|
||||
orderPayRefund := &model.OrderPayRefund{
|
||||
RefundID: msg.CpRefundno,
|
||||
}
|
||||
|
||||
@@ -38,19 +38,21 @@ func MsgFail() *TicktockRes {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *TicTocController) Msg() {
|
||||
func (c *TicTocController) TtMsg() {
|
||||
if c.Ctx.Input.Method() == http.MethodPost {
|
||||
call, refund, payType, err := api.TiktokApi.GetCallbackMsg(getPayInfo(c.Ctx))
|
||||
globals.SugarLogger.Debugf("tictok callback callbackResponse:%s", utils.Format4Output(call, true))
|
||||
if err != nil {
|
||||
c.Data["json"] = MsgFail()
|
||||
c.ServeJSON()
|
||||
globals.SugarLogger.Debugf("============err:%s", err)
|
||||
return
|
||||
}
|
||||
err = localjx.OnTTPayCallback(call, refund, payType)
|
||||
if err != nil {
|
||||
c.Data["json"] = MsgFail()
|
||||
c.ServeJSON()
|
||||
globals.SugarLogger.Debugf("============err:%s", err)
|
||||
return
|
||||
}
|
||||
c.Data["json"] = MsgSuccess()
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
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/server/web"
|
||||
)
|
||||
|
||||
type TTPayController struct {
|
||||
web.Controller
|
||||
}
|
||||
|
||||
func (c *TTPayController) TtMsg() {
|
||||
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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user