From cbbb9bfd89e4e1868a6f3ff347a086750a83786d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 2 Jun 2022 10:13:04 +0800 Subject: [PATCH] 1 --- .../partner/purchase/jx/localjx/tiktokPay.go | 4 +- controllers/tictok_callback.go | 4 +- controllers/ttpay_callback.go | 41 ------------------- 3 files changed, 6 insertions(+), 43 deletions(-) delete mode 100644 controllers/ttpay_callback.go diff --git a/business/partner/purchase/jx/localjx/tiktokPay.go b/business/partner/purchase/jx/localjx/tiktokPay.go index 8559080e2..64448aa6e 100644 --- a/business/partner/purchase/jx/localjx/tiktokPay.go +++ b/business/partner/purchase/jx/localjx/tiktokPay.go @@ -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, } diff --git a/controllers/tictok_callback.go b/controllers/tictok_callback.go index cbf2ecc80..1160d0f3a 100644 --- a/controllers/tictok_callback.go +++ b/controllers/tictok_callback.go @@ -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() diff --git a/controllers/ttpay_callback.go b/controllers/ttpay_callback.go deleted file mode 100644 index 6c2f5a2f7..000000000 --- a/controllers/ttpay_callback.go +++ /dev/null @@ -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") - } -}