1
This commit is contained in:
@@ -56,19 +56,21 @@ func PKCS5UnPadding(origData []byte) []byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Code struct {
|
type Code struct {
|
||||||
MsgType int64 `json:"msg_type"`
|
MsgType int64 `json:"msg_type"`
|
||||||
msg struct {
|
Msg string `json:"msg"`
|
||||||
ActionType int64 `json:"action_type"`
|
}
|
||||||
AppId int64 `json:"app_id"`
|
|
||||||
ShopId int64 `json:"shop_id"`
|
type MsgDetail struct {
|
||||||
Code string `json:"code"`
|
ActionType int `json:"action_type"`
|
||||||
CodeGenerateTime string `json:"code_generate_time"`
|
AppId int64 `json:"app_id"`
|
||||||
}
|
ShopId int `json:"shop_id"`
|
||||||
|
Code string `json:"code"`
|
||||||
|
CodeGenerateTime string `json:"code_generate_time"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *TiktokShopController) TokenMsg() {
|
func (c *TiktokShopController) TokenMsg() {
|
||||||
req := c.Ctx.Request
|
req := c.Ctx.Request
|
||||||
var code []string
|
var code string
|
||||||
switch req.Method {
|
switch req.Method {
|
||||||
case http.MethodPost:
|
case http.MethodPost:
|
||||||
data, err := ioutil.ReadAll(req.Body)
|
data, err := ioutil.ReadAll(req.Body)
|
||||||
@@ -85,15 +87,22 @@ func (c *TiktokShopController) TokenMsg() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
globals.SugarLogger.Debugf("codeToken============%s", utils.Format4Output(codeToken, false))
|
globals.SugarLogger.Debugf("codeToken============%s", utils.Format4Output(codeToken, false))
|
||||||
var codeResult Code
|
var codeMsg Code
|
||||||
if err := json.Unmarshal([]byte(codeToken), &codeResult); err != nil {
|
if err := json.Unmarshal([]byte(codeToken), &codeMsg); err != nil {
|
||||||
globals.SugarLogger.Debugf("err============%s", utils.Format4Output(codeToken, false))
|
globals.SugarLogger.Debugf("err============%s", utils.Format4Output(codeToken, false))
|
||||||
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("codeResult============%s", utils.Format4Output(codeResult, false))
|
|
||||||
code = append(code, codeResult.msg.Code)
|
var msg MsgDetail
|
||||||
|
if err := json.Unmarshal([]byte(codeMsg.Msg), &msg); err != nil {
|
||||||
|
globals.SugarLogger.Debugf("err============%s", utils.Format4Output(codeToken, false))
|
||||||
|
c.Data["json"] = tiktok_api.CallbackResponse{Code: tiktok_api.CallbackFailCode, Msg: tiktok_api.CallbackFail}
|
||||||
|
c.ServeJSON()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
code = msg.Code
|
||||||
case http.MethodGet:
|
case http.MethodGet:
|
||||||
codeValues := req.URL.Query()
|
codeValues := req.URL.Query()
|
||||||
codeList := codeValues.Get("code")
|
codeList := codeValues.Get("code")
|
||||||
@@ -112,42 +121,40 @@ func (c *TiktokShopController) TokenMsg() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, v := range code {
|
result, err := api.TiktokStore.CreateToken(code)
|
||||||
result, err := api.TiktokStore.CreateToken(v)
|
if err != nil {
|
||||||
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
|
}
|
||||||
}
|
|
||||||
|
|
||||||
globals.SugarLogger.Debugf("result=====%s", utils.Format4Output(result, false))
|
globals.SugarLogger.Debugf("result=====%s", utils.Format4Output(result, false))
|
||||||
|
|
||||||
data, err := json.Marshal(result)
|
data, err := json.Marshal(result)
|
||||||
if err != nil {
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
param := &model.VendorOrgCode{
|
param := &model.VendorOrgCode{
|
||||||
VendorID: model.VendorIDDD,
|
VendorID: model.VendorIDDD,
|
||||||
VendorOrgCode: utils.Int64ToStr(result.ShopId),
|
VendorOrgCode: utils.Int64ToStr(result.ShopId),
|
||||||
Comment: "抖音授权",
|
Comment: "抖音授权",
|
||||||
VendorType: "platform",
|
VendorType: "platform",
|
||||||
IsJxCat: 1,
|
IsJxCat: 1,
|
||||||
IsOpen: 1,
|
IsOpen: 1,
|
||||||
EmpowerURL: "https://fuwu.jinritemai.com/detail?from=open_partner_svcList&service_id=24070",
|
EmpowerURL: "https://fuwu.jinritemai.com/detail?from=open_partner_svcList&service_id=24070",
|
||||||
StoreBrandName: result.ShopName,
|
StoreBrandName: result.ShopName,
|
||||||
Token: string(data),
|
Token: string(data),
|
||||||
AppKey: "hhhh", // web.AppConfig.DefaultString("tiktokShopAppId", "7136048270014416392"),
|
AppKey: "hhhh", // web.AppConfig.DefaultString("tiktokShopAppId", "7136048270014416392"),
|
||||||
AppSecret: "heihei", // web.AppConfig.DefaultString("tiktokShopAppSecret", "c397aa9f-3927-47c4-8cfe-4d84e02602e0")
|
AppSecret: "heihei", // web.AppConfig.DefaultString("tiktokShopAppSecret", "c397aa9f-3927-47c4-8cfe-4d84e02602e0")
|
||||||
}
|
}
|
||||||
if err := common.AddVendorOrgCode(nil, param); err != nil {
|
if err := common.AddVendorOrgCode(nil, param); err != nil {
|
||||||
globals.SugarLogger.Debugf("AddVendorOrgCode=====err%s", err)
|
globals.SugarLogger.Debugf("AddVendorOrgCode=====err%s", err)
|
||||||
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
|
||||||
}
|
|
||||||
}
|
}
|
||||||
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