1'
This commit is contained in:
@@ -18,54 +18,58 @@ type TiktokShopController struct {
|
|||||||
|
|
||||||
// TokenMsg 抖音用户授权
|
// TokenMsg 抖音用户授权
|
||||||
func (c *TiktokShopController) TokenMsg() {
|
func (c *TiktokShopController) TokenMsg() {
|
||||||
code := utils.Interface2StringList(c.Ctx.Request.URL.Query().Get("code"))[0]
|
codeList := c.Ctx.Request.URL.Query().Get("code")
|
||||||
if code == "" {
|
var code []string
|
||||||
|
if err := json.Unmarshal([]byte(codeList), &code); err != nil {
|
||||||
c.Data["json"] = tiktok_api.CallbackResponse{Code: tiktok_api.CallbackFailCode, Msg: tiktok_api.CallbackFail}
|
c.Data["json"] = tiktok_api.CallbackResponse{Code: tiktok_api.CallbackFailCode, Msg: tiktok_api.CallbackFail}
|
||||||
c.ServeJSON()
|
c.ServeJSON()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
globals.SugarLogger.Debugf("==========%s", code)
|
globals.SugarLogger.Debugf("codeList=====%s", utils.Format4Output(codeList, false))
|
||||||
result, err := api.TiktokStore.CreateToken(code)
|
globals.SugarLogger.Debugf("code=====%s", utils.Format4Output(code, false))
|
||||||
globals.SugarLogger.Debugf("=result=========%s", utils.Format4Output(result, false))
|
if len(code) == 0 {
|
||||||
globals.SugarLogger.Debugf("=err1=========%s", err)
|
|
||||||
if err != nil {
|
|
||||||
c.Data["json"] = tiktok_api.CallbackResponse{Code: tiktok_api.CallbackFailCode, Msg: tiktok_api.CallbackFail}
|
c.Data["json"] = tiktok_api.CallbackResponse{Code: tiktok_api.CallbackFailCode, Msg: tiktok_api.CallbackFail}
|
||||||
c.ServeJSON()
|
c.ServeJSON()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
result.ExpiresIn += time.Now().Unix()
|
for _, v := range code {
|
||||||
data, err := json.Marshal(result)
|
result, err := api.TiktokStore.CreateToken(v)
|
||||||
globals.SugarLogger.Debugf("=err12=========%s", utils.Format4Output(data, false))
|
if err != nil {
|
||||||
globals.SugarLogger.Debugf("=data=========%s", err)
|
c.Data["json"] = tiktok_api.CallbackResponse{Code: tiktok_api.CallbackFailCode, Msg: tiktok_api.CallbackFail}
|
||||||
if err != nil {
|
c.ServeJSON()
|
||||||
c.Data["json"] = tiktok_api.CallbackResponse{Code: tiktok_api.CallbackFailCode, Msg: tiktok_api.CallbackFail}
|
return
|
||||||
c.ServeJSON()
|
}
|
||||||
return
|
globals.SugarLogger.Debugf("result=====%s", utils.Format4Output(result, false))
|
||||||
}
|
|
||||||
|
|
||||||
param := &model.VendorOrgCode{
|
result.ExpiresIn += time.Now().Unix()
|
||||||
VendorID: model.VendorIDDD,
|
data, err := json.Marshal(result)
|
||||||
VendorOrgCode: utils.Int64ToStr(result.ShopId),
|
if err != nil {
|
||||||
Comment: "抖音授权",
|
c.Data["json"] = tiktok_api.CallbackResponse{Code: tiktok_api.CallbackFailCode, Msg: tiktok_api.CallbackFail}
|
||||||
VendorType: "platform",
|
c.ServeJSON()
|
||||||
IsJxCat: 1,
|
return
|
||||||
IsOpen: 1,
|
}
|
||||||
EmpowerURL: "",
|
|
||||||
StoreBrandName: result.ShopName,
|
param := &model.VendorOrgCode{
|
||||||
Token: string(data),
|
VendorID: model.VendorIDDD,
|
||||||
AppKey: "", // web.AppConfig.DefaultString("tiktokShopAppId", "7136048270014416392"),
|
VendorOrgCode: utils.Int64ToStr(result.ShopId),
|
||||||
AppSecret: "", // web.AppConfig.DefaultString("tiktokShopAppSecret", "c397aa9f-3927-47c4-8cfe-4d84e02602e0")
|
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 {
|
||||||
|
c.Data["json"] = tiktok_api.CallbackResponse{Code: tiktok_api.CallbackFailCode, Msg: tiktok_api.CallbackFail}
|
||||||
|
c.ServeJSON()
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if err := common.AddVendorOrgCode(nil, param); err != nil {
|
|
||||||
globals.SugarLogger.Debugf("=err123=========%s", err)
|
|
||||||
c.Data["json"] = tiktok_api.CallbackResponse{Code: tiktok_api.CallbackFailCode, Msg: tiktok_api.CallbackFail}
|
|
||||||
c.ServeJSON()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
globals.SugarLogger.Debugf("=4=========%s", err)
|
|
||||||
c.Data["json"] = tiktok_api.CallbackResponse{Code: tiktok_api.CallbackSuccessCode, Msg: tiktok_api.CallbackSuccess}
|
c.Data["json"] = tiktok_api.CallbackResponse{Code: tiktok_api.CallbackSuccessCode, Msg: tiktok_api.CallbackSuccess}
|
||||||
c.ServeJSON()
|
c.ServeJSON()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user