1
This commit is contained in:
48
controllers/tiktok_order.go
Normal file
48
controllers/tiktok_order.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/platformapi/tiktok_shop/tiktok_api"
|
||||
"git.rosy.net.cn/jx-callback/business/partner/purchase/tiktok_store"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
"github.com/astaxie/beego/server/web"
|
||||
)
|
||||
|
||||
type TiktokController struct {
|
||||
web.Controller
|
||||
}
|
||||
|
||||
// CallbackTiktokOrderMsg 抖店用户下单订单推送 (tiktokStore)
|
||||
func (t *TiktokController) CallbackTiktokOrderMsg() {
|
||||
// 1.防伪校验
|
||||
resp := api.TiktokStore.EventSignChange(t.Ctx.Request)
|
||||
if resp.Code != 0 {
|
||||
t.Data["json"] = resp
|
||||
t.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
// 2.参数解析
|
||||
orderStatus, resp := api.TiktokStore.CreateOrderCallback(t.Ctx.Request)
|
||||
globals.SugarLogger.Debug("抖音订单回调数据打印测试===========", orderStatus)
|
||||
if resp.Code != 0 {
|
||||
t.Data["json"] = resp
|
||||
t.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
for k, v := range orderStatus {
|
||||
for _, callback := range v {
|
||||
resp2 := tiktok_store.OnOrderMsg(k, callback)
|
||||
if resp2.Code != 0 {
|
||||
t.Data["json"] = resp2
|
||||
t.ServeJSON()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
t.Data["json"] = tiktok_api.CallbackResponse{Code: tiktok_api.CallbackSuccessCode, Msg: tiktok_api.CallbackSuccess}
|
||||
t.ServeJSON()
|
||||
|
||||
}
|
||||
@@ -5,54 +5,18 @@ import (
|
||||
"git.rosy.net.cn/baseapi/platformapi/tiktok_shop/tiktok_api"
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/common"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/partner/purchase/tiktok_store"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
"github.com/astaxie/beego/server/web"
|
||||
"time"
|
||||
)
|
||||
|
||||
type TiktokController struct {
|
||||
type TiktokShopController struct {
|
||||
web.Controller
|
||||
}
|
||||
|
||||
// CallbackTiktokOrderMsg 抖店用户下单订单推送 (tiktokStore)
|
||||
func (t *TiktokController) CallbackTiktokOrderMsg() {
|
||||
// 1.防伪校验
|
||||
resp := api.TiktokStore.EventSignChange(t.Ctx.Request)
|
||||
if resp.Code != 0 {
|
||||
t.Data["json"] = resp
|
||||
t.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
// 2.参数解析
|
||||
orderStatus, resp := api.TiktokStore.CreateOrderCallback(t.Ctx.Request)
|
||||
globals.SugarLogger.Debug("抖音订单回调数据打印测试===========", orderStatus)
|
||||
if resp.Code != 0 {
|
||||
t.Data["json"] = resp
|
||||
t.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
for k, v := range orderStatus {
|
||||
for _, callback := range v {
|
||||
resp2 := tiktok_store.OnOrderMsg(k, callback)
|
||||
if resp2.Code != 0 {
|
||||
t.Data["json"] = resp2
|
||||
t.ServeJSON()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
t.Data["json"] = tiktok_api.CallbackResponse{Code: tiktok_api.CallbackSuccessCode, Msg: tiktok_api.CallbackSuccess}
|
||||
t.ServeJSON()
|
||||
|
||||
}
|
||||
|
||||
// TokenMsg 抖音用户授权
|
||||
func (c *TiktokController) TokenMsg() {
|
||||
func (c *TiktokShopController) TokenMsg() {
|
||||
code := c.Ctx.Request.URL.Query().Get("code")
|
||||
globals.SugarLogger.Debugf("tictok callback callbackResponse:%s", code)
|
||||
result, err := api.TiktokStore.CreateToken(code)
|
||||
|
||||
Reference in New Issue
Block a user