添加抖音授权登录,国美测试接口,修改运单重复骑手,添加推送骑手信息

This commit is contained in:
邹宗楠
2022-05-13 16:05:19 +08:00
parent 977d11ed9c
commit a91f46207f
49 changed files with 3355 additions and 254 deletions

View File

@@ -1,89 +1,91 @@
package douyin
//
//import (
// "git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin"
//
// "git.rosy.net.cn/baseapi/platformapi/weixinapi"
// "git.rosy.net.cn/jx-callback/business/auth2"
// "git.rosy.net.cn/jx-callback/business/auth2/authprovider"
// "git.rosy.net.cn/jx-callback/business/model"
// "git.rosy.net.cn/jx-callback/globals"
// "git.rosy.net.cn/jx-callback/globals/api"
//)
//
//const (
// AuthTypeTiktokMini = "tiktokmini" // 抖音小程序
//)
//
//type TiktopMiniAuther struct {
// authprovider.DefAuther
//}
//
//
//var (
// AutherObjMini *TiktopMiniAuther
//)
//
//func init() {
// AutherObjMini = new(TiktopMiniAuther)
// auth2.RegisterAuther(AuthTypeTiktokMini, AutherObjMini)
//}
//
//func (a *TiktopMiniAuther) VerifySecret(dummy, code string) (authBindEx *auth2.AuthBindEx, err error) {
// globals.SugarLogger.Debugf("toktok mini VerifySecret jsCode:%s", code)
//
// sessionInfo, err := api.TiktokApi.GetTiktokToken(code)
// if err == nil {
// if authBindEx, err = a.UnionFindAuthBind(AuthTypeTiktokMini, api.TiktokApi.GetAppID(), []string{AuthTypeTiktokMini}, sessionInfo.Data.OpenId, sessionInfo.Data.UnionId, sessionInfo); err == nil {
// authBindEx.UserData = sessionInfo.Data
// }
// }
// return authBindEx, err
//}
//
//// 特殊接口
//func (a *TiktopMiniAuther) DecryptData(authInfo *auth2.AuthInfo, jsCode, encryptedData, iv string) (decryptedDataBase64 string, err error) {
// globals.SugarLogger.Debugf("weixin mini DecryptData jsCode:%s, encryptedData:%s, iv:%s", jsCode, encryptedData, iv)
// var sessionKey string
// appID, jsCode := weixin.SplitJsCode(jsCode)
// if jsCode != "" {
// sessionInfo, err := getWxApp(appID).SNSCode2Session(jsCode)
// if err == nil {
// // if authBindEx, err := a.UnionFindAuthBind(AuthTypeMini, getWxApp(appID).GetAppID(), []string{AuthTypeMini}, sessionInfo.OpenID, "", nil); err == nil {
// // if authBindEx.UserID != authInfo.GetID() {
// // return "", fmt.Errorf("jsCode与token不匹配")
// // }
// // } else {
// // return "", err
// // }
// sessionKey = sessionInfo.SessionKey
// } else {
// return "", err
// }
// } else {
// if authInfo.AuthBindInfo.Type != AuthTypeTiktokMini {
// // return "", ErrAuthTypeShouldBeMini
// }
// sessionKey = authInfo.AuthBindInfo.UserData.(string)
// }
// decryptedData, err := weixinapi.SNSDecodeMiniProgramData(encryptedData, sessionKey, iv)
// if err != nil {
// return "", err
// }
// return string(decryptedData), nil
//}
//
//func (a *TiktopMiniAuther) GetUserType() (userType int8) {
// return model.UserTypeStoreBoss
//}
//
//func getWxApp(appID string) (miniApi *weixinapi.API) {
// miniApi = api.WeixinMiniAPI
// if len(appID) > 0 && appID == api.WeixinMiniAppID2 {
// miniApi = api.WeixinMiniAPI2
// }
// if len(appID) > 0 && appID == api.WeixinMiniAppIDsc {
// miniApi = api.WeixinMiniAPIsc
// }
// return miniApi
//}
import (
"git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin"
"git.rosy.net.cn/baseapi/platformapi/weixinapi"
"git.rosy.net.cn/jx-callback/business/auth2"
"git.rosy.net.cn/jx-callback/business/auth2/authprovider"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/globals"
"git.rosy.net.cn/jx-callback/globals/api"
)
const (
AuthTypeTiktokMini = "tiktokmini" // 抖音小程序
)
type TiktopMiniAuther struct {
authprovider.DefAuther
}
var (
AutherObjMini *TiktopMiniAuther
)
func init() {
AutherObjMini = new(TiktopMiniAuther)
auth2.RegisterAuther(AuthTypeTiktokMini, AutherObjMini)
}
func (a *TiktopMiniAuther) VerifySecret(dummy, code string) (authBindEx *auth2.AuthBindEx, err error) {
globals.SugarLogger.Debugf("toktok mini VerifySecret jsCode:%s", code)
sessionInfo, err := api.TiktokApi.GetTiktokToken2(code)
if err == nil {
sessionKey := sessionInfo.Data.SessionKey
sessionInfo.Data.SessionKey = ""
if authBindEx, err = a.UnionFindAuthBind(AuthTypeTiktokMini, api.TiktokApi.GetAppID(), []string{AuthTypeTiktokMini}, sessionInfo.Data.OpenId, sessionInfo.Data.Unionid, sessionInfo); err == nil {
authBindEx.UserData = sessionKey
}
}
return authBindEx, err
}
// 特殊接口
func (a *TiktopMiniAuther) DecryptData(authInfo *auth2.AuthInfo, jsCode, encryptedData, iv string) (decryptedDataBase64 string, err error) {
globals.SugarLogger.Debugf("weixin mini DecryptData jsCode:%s, encryptedData:%s, iv:%s", jsCode, encryptedData, iv)
var sessionKey string
appID, jsCode := weixin.SplitJsCode(jsCode)
if jsCode != "" {
sessionInfo, err := getWxApp(appID).SNSCode2Session(jsCode)
if err == nil {
// if authBindEx, err := a.UnionFindAuthBind(AuthTypeMini, getWxApp(appID).GetAppID(), []string{AuthTypeMini}, sessionInfo.OpenID, "", nil); err == nil {
// if authBindEx.UserID != authInfo.GetID() {
// return "", fmt.Errorf("jsCode与token不匹配")
// }
// } else {
// return "", err
// }
sessionKey = sessionInfo.SessionKey
} else {
return "", err
}
} else {
if authInfo.AuthBindInfo.Type != AuthTypeTiktokMini {
// return "", ErrAuthTypeShouldBeMini
}
sessionKey = authInfo.AuthBindInfo.UserData.(string)
}
decryptedData, err := weixinapi.SNSDecodeMiniProgramData(encryptedData, sessionKey, iv)
if err != nil {
return "", err
}
return string(decryptedData), nil
}
func (a *TiktopMiniAuther) GetUserType() (userType int8) {
return model.UserTypeStoreBoss
}
func getWxApp(appID string) (miniApi *weixinapi.API) {
miniApi = api.WeixinMiniAPI
if len(appID) > 0 && appID == api.WeixinMiniAppID2 {
miniApi = api.WeixinMiniAPI2
}
if len(appID) > 0 && appID == api.WeixinMiniAppIDsc {
miniApi = api.WeixinMiniAPIsc
}
return miniApi
}