1
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"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 {
|
||||
@@ -24,7 +28,7 @@ func (t *TiktokController) CallbackTiktokOrderMsg() {
|
||||
|
||||
// 2.参数解析
|
||||
orderStatus, resp := api.TiktokStore.CreateOrderCallback(t.Ctx.Request)
|
||||
globals.SugarLogger.Debug("美团订单回调数据打印测试===========", orderStatus)
|
||||
globals.SugarLogger.Debug("抖音订单回调数据打印测试===========", orderStatus)
|
||||
if resp.Code != 0 {
|
||||
t.Data["json"] = resp
|
||||
t.ServeJSON()
|
||||
@@ -46,3 +50,48 @@ func (t *TiktokController) CallbackTiktokOrderMsg() {
|
||||
t.ServeJSON()
|
||||
|
||||
}
|
||||
|
||||
// CallbackTiktokTokenMsg 抖音用户授权
|
||||
func (c *TiktokController) CallbackTiktokTokenMsg() {
|
||||
code := c.Ctx.Request.URL.Query().Get("code")
|
||||
globals.SugarLogger.Debugf("tictok callback callbackResponse:%s", code)
|
||||
result, err := api.TiktokStore.CreateToken(code)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("tictok callback create token:%s", err)
|
||||
c.Data["json"] = tiktok_api.CallbackResponse{Code: tiktok_api.CallbackFailCode, Msg: tiktok_api.CallbackFail}
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
result.ExpiresIn += time.Now().Unix()
|
||||
data, err := json.Marshal(result)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("tictok callback Marshal token:%s", err)
|
||||
c.Data["json"] = tiktok_api.CallbackResponse{Code: tiktok_api.CallbackFailCode, Msg: tiktok_api.CallbackFail}
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
param := &model.VendorOrgCode{
|
||||
VendorID: model.VendorIDDD,
|
||||
VendorOrgCode: result.ShopId,
|
||||
Comment: "抖音授权",
|
||||
VendorType: "platform",
|
||||
IsJxCat: 1,
|
||||
IsOpen: 1,
|
||||
EmpowerURL: "",
|
||||
StoreBrandName: result.ShopName,
|
||||
Token: string(data),
|
||||
AppKey: "", // web.AppConfig.DefaultString("tiktokShopAppId", "7136048270014416392"),
|
||||
AppSecret: "", // web.AppConfig.DefaultString("tiktokShopAppSecret", "c397aa9f-3927-47c4-8cfe-4d84e02602e0")
|
||||
}
|
||||
if err := common.AddVendorOrgCode(nil, param); err != nil {
|
||||
globals.SugarLogger.Debugf("tictok callback insert token:%s", err)
|
||||
c.Data["json"] = tiktok_api.CallbackResponse{Code: tiktok_api.CallbackFailCode, Msg: tiktok_api.CallbackFail}
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
c.Data["json"] = tiktok_api.CallbackResponse{Code: tiktok_api.CallbackSuccessCode, Msg: tiktok_api.CallbackSuccess}
|
||||
c.ServeJSON()
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user