Merge branch 'jdshop' of e.coding.net:rosydev/jx-callback into jdshop
This commit is contained in:
@@ -160,6 +160,8 @@ func getFixedTokenName(token string) *AuthInfo {
|
||||
|
||||
func createAuthInfo(user IUser, authBindInfo *AuthBindEx) (authInfo *AuthInfo) {
|
||||
token, tokenType := createToken(user, authBindInfo)
|
||||
//user为空 tokenType=2
|
||||
globals.SugarLogger.Debug("token,tokenType,user============", token, tokenType, user)
|
||||
expireDuration := DefTokenDuration
|
||||
authInfo = &AuthInfo{
|
||||
AuthBindInfo: authBindInfo,
|
||||
@@ -247,6 +249,7 @@ func LoginInternal(ctx *Context, authType, authID, authIDType, authSecret string
|
||||
}
|
||||
realAuthID = user.GetID()
|
||||
}
|
||||
globals.SugarLogger.Debug("打印realAuthID检测是否为空==================", realAuthID)
|
||||
if authBindEx, err = handler.VerifySecret(realAuthID, authSecret); err == nil {
|
||||
globals.SugarLogger.Debugf("Login authBindEx", utils.Format4Output(authBindEx, false))
|
||||
if authBindEx == nil { // mobile, email会返回nil(表示不会新建AuthBind实体)
|
||||
@@ -262,15 +265,15 @@ func LoginInternal(ctx *Context, authType, authID, authIDType, authSecret string
|
||||
// 返回authBind中UserID为空表示只是认证,但本地没有记录,这种情况会返回临时TOKEN
|
||||
if authBindEx.UserHint != nil && authBindEx.UserID == "" {
|
||||
// 利用得到受信任的信息查找用户
|
||||
// if authBindEx.UserHint.Mobile != "" {
|
||||
// user = userProvider.GetUser(authBindEx.UserHint.Mobile, UserIDMobile)
|
||||
// }
|
||||
// if user == nil && authBindEx.UserHint.Email != "" {
|
||||
// user = userProvider.GetUser(authBindEx.UserHint.Email, UserIDEmail)
|
||||
// }
|
||||
// if user != nil {
|
||||
// authBindEx.UserID = user.GetID()
|
||||
// }
|
||||
if authBindEx.UserHint.Mobile != "" {
|
||||
user = userProvider.GetUser(authBindEx.UserHint.Mobile, UserIDMobile)
|
||||
}
|
||||
if user == nil && authBindEx.UserHint.Email != "" {
|
||||
user = userProvider.GetUser(authBindEx.UserHint.Email, UserIDEmail)
|
||||
}
|
||||
if user != nil {
|
||||
authBindEx.UserID = user.GetID()
|
||||
}
|
||||
if user2 := userProvider.GetUser(authBindEx.UserHint.Email, UserIDMobile); user2 != nil {
|
||||
user = user2
|
||||
}
|
||||
@@ -303,6 +306,7 @@ func LoginInternal(ctx *Context, authType, authID, authIDType, authSecret string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
err = ErrIllegalAuthType
|
||||
@@ -379,6 +383,7 @@ func AddAuthBind(user IUser, newAuthInfo *AuthInfo) (err error) {
|
||||
} else {
|
||||
if handler := authers[newAuthInfo.AuthBindInfo.Type]; handler != nil {
|
||||
newAuthInfo.AuthBindInfo.UserID = user.GetID()
|
||||
globals.SugarLogger.Debug("进入AddAuthBind获取userID", newAuthInfo.AuthBindInfo.UserID)
|
||||
handler.UnbindAuth(user.GetID(), newAuthInfo.GetAuthType(), newAuthInfo.GetAuthTypeID(), user.GetName())
|
||||
err = handler.AddAuthBind(newAuthInfo.AuthBindInfo, user.GetName())
|
||||
} else {
|
||||
|
||||
@@ -75,9 +75,6 @@ func (a *DefAuther) UnionFindAuthBind(curAuthType, curAuthTypeID string, unionAu
|
||||
if authDetail != nil {
|
||||
authBindEx.DetailData = string(utils.MustMarshal(authDetail))
|
||||
}
|
||||
globals.SugarLogger.Debug("检查一下数据样式===================", authBindEx)
|
||||
globals.SugarLogger.Debug("检查一下数据样式===================", authDetail)
|
||||
globals.SugarLogger.Debug("检查一下数据样式===================", authBindEx.DetailData)
|
||||
if authBind.TypeID == "" {
|
||||
authBind.TypeID = curAuthTypeID
|
||||
dao.UpdateEntity(db, authBind, "TypeID")
|
||||
@@ -85,16 +82,11 @@ func (a *DefAuther) UnionFindAuthBind(curAuthType, curAuthTypeID string, unionAu
|
||||
} else if dao.IsNoRowsError(err) { // 直接找不到,尝试unionID
|
||||
if unionID != "" || openID != "" { // 且有unionID
|
||||
var authBindList []*model.AuthBind
|
||||
globals.SugarLogger.Debug("输出一下", unionAuthTypeList)
|
||||
globals.SugarLogger.Debug("=====================输出一下model.AuthBindTypeAuth,openID,unionID", model.AuthBindTypeAuth, unionAuthTypeList, openID, unionID)
|
||||
authBindList, err = dao.GetUserBindAuthInfo(db, "", model.AuthBindTypeAuth, unionAuthTypeList, openID, unionID, nil)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debug("authBindList输出错误", err)
|
||||
return nil, err
|
||||
}
|
||||
globals.SugarLogger.Debug("检测这个authBindList", authBindList)
|
||||
if len(authBindList) > 0 { // 通过unionID找到至少一个认证方式
|
||||
globals.SugarLogger.Debug("进入authBindList, err = dao.GetUserBindAuthInfo 这里了")
|
||||
authBind = authBindList[0]
|
||||
authBind.Type = curAuthType
|
||||
authBind.TypeID = curAuthTypeID
|
||||
@@ -105,20 +97,16 @@ func (a *DefAuther) UnionFindAuthBind(curAuthType, curAuthTypeID string, unionAu
|
||||
authBindEx = &auth2.AuthBindEx{
|
||||
AuthBind: *authBind,
|
||||
}
|
||||
globals.SugarLogger.Debug("输出赋值后的authBind.DetailData", authBind.DetailData)
|
||||
globals.SugarLogger.Debug("输出赋值后的authBindEx", authBindEx)
|
||||
a.UnbindAuth(authBind.UserID, curAuthType, curAuthTypeID, model.AdminName)
|
||||
err = a.AddAuthBind(authBindEx, model.AdminName) // 自动绑定
|
||||
} else if dao.IsNoRowsError(err) {
|
||||
err = nil
|
||||
}
|
||||
globals.SugarLogger.Debug("输出一下authBindList", authBindList) //空的
|
||||
} else {
|
||||
err = nil
|
||||
}
|
||||
}
|
||||
if err == nil && authBindEx == nil { //如果没有报错,且没有找到一个认证方式,创建无用户(UserID为空)的认证方式
|
||||
globals.SugarLogger.Debug("没有找到一个认证方式")
|
||||
authBindEx = &auth2.AuthBindEx{
|
||||
AuthBind: model.AuthBind{
|
||||
Type: curAuthType,
|
||||
@@ -127,8 +115,6 @@ func (a *DefAuther) UnionFindAuthBind(curAuthType, curAuthTypeID string, unionAu
|
||||
AuthID2: unionID,
|
||||
},
|
||||
}
|
||||
globals.SugarLogger.Debug("输出一下authBindEx", authBindEx)
|
||||
globals.SugarLogger.Debug("===================再输出一下authBind", authBind)
|
||||
if authDetail != nil {
|
||||
authBindEx.DetailData = string(utils.MustMarshal(authDetail))
|
||||
}
|
||||
|
||||
@@ -21,18 +21,30 @@ func init() {
|
||||
auth2.RegisterAuther(AuthTypeQRCode, AutherObjQRCode)
|
||||
}
|
||||
|
||||
func (a *QRCodeAuther) VerifySecret(dummy, code string) (authBindEx *auth2.AuthBindEx, err error) {
|
||||
func (a *QRCodeAuther) VerifySecret(dummy, code string) (*auth2.AuthBindEx, error) {
|
||||
globals.SugarLogger.Debugf("dingding qrcode VerifySecret code:%s", code)
|
||||
|
||||
userQRInfo, err := api.DingDingQRCodeAPI.GetUserInfoByCode(code)
|
||||
if err == nil {
|
||||
globals.SugarLogger.Debugf("dingding qrcode VerifySecret code:%s, userQRInfo:%s", code, utils.Format4Output(userQRInfo, false))
|
||||
if authBindEx, err = a.UnionFindAuthBind(AuthTypeQRCode, api.DingDingQRCodeAPI.GetAppID(), []string{AuthTypeStaff, AuthTypeQRCode}, userQRInfo.OpenID, userQRInfo.UnionID, userQRInfo); err == nil {
|
||||
authBindEx.UserHint = &auth2.UserBasic{
|
||||
Name: userQRInfo.Nickname,
|
||||
//UserID: userQRInfo.,
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
tmp_userID, err := api.DingDingAPI.GetByUnionID(userQRInfo.UnionID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
userInfo, err := api.DingDingAPI.GetUser(tmp_userID.UserID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
globals.SugarLogger.Debugf("dingding qrcode VerifySecret code:%s, userQRInfo:%s", code, utils.Format4Output(userQRInfo, false))
|
||||
authBindEx, err := a.UnionFindAuthBind(AuthTypeQRCode, api.DingDingQRCodeAPI.GetAppID(), []string{AuthTypeStaff, AuthTypeQRCode}, userQRInfo.OpenID, userQRInfo.UnionID, userQRInfo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
authBindEx.UserHint = &auth2.UserBasic{
|
||||
UserID2: tmp_userID.UserID,
|
||||
Mobile: utils.Interface2String(userInfo["mobile"]),
|
||||
Email: utils.Interface2String(userInfo["email"]),
|
||||
Name: utils.Interface2String(userInfo["name"]),
|
||||
}
|
||||
return authBindEx, err
|
||||
}
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
package douyin
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/tiktok"
|
||||
"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/auth2/authprovider/weixin"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -30,14 +31,17 @@ func init() {
|
||||
|
||||
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.GetTiktokOauth(code)
|
||||
appID, realCode := splitCode(code)
|
||||
globals.SugarLogger.Debug("appID============", appID)
|
||||
globals.SugarLogger.Debug("realCode============", realCode)
|
||||
sessionInfo, err := getTikTokApp(appID).GetTiktokOauth(realCode)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
globals.SugarLogger.Debug("toktok mini VerifySecret sessionInfo:", sessionInfo)
|
||||
if err == nil {
|
||||
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
|
||||
}
|
||||
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
|
||||
}
|
||||
@@ -88,3 +92,24 @@ func getWxApp(appID string) (miniApi *weixinapi.API) {
|
||||
}
|
||||
return miniApi
|
||||
}
|
||||
|
||||
func getTikTokApp(appID string) (TikTokMini *tiktok.API) {
|
||||
TikTokMini = api.TiktokApi
|
||||
if len(appID) > 0 && appID == api.TiktokJXDJApiID {
|
||||
globals.SugarLogger.Debug("我进入这里了")
|
||||
TikTokMini = api.TiktokJXDJApi
|
||||
}
|
||||
globals.SugarLogger.Debug("输出一下TikTokMini", TikTokMini)
|
||||
return TikTokMini
|
||||
}
|
||||
func splitCode(code string) (appID, realCode string) {
|
||||
str := strings.Split(code, "&")
|
||||
if len(str) == 2 {
|
||||
appID = str[1]
|
||||
realCode = str[0]
|
||||
} else {
|
||||
globals.SugarLogger.Warnf("splitCode abnormal code:%s", code)
|
||||
}
|
||||
globals.SugarLogger.Debug("dayin realCode", realCode)
|
||||
return appID, realCode
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@ package dao
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
)
|
||||
@@ -64,10 +62,5 @@ func GetUserBindAuthInfo(db *DaoDB, userID string, bindType int, typeList []stri
|
||||
}
|
||||
sql += " ORDER BY t1.type"
|
||||
err = GetRows(db, &authList, sql, sqlParams...)
|
||||
globals.SugarLogger.Debug("输出一下sql", sql)
|
||||
globals.SugarLogger.Debug("authList==================", authList)
|
||||
globals.SugarLogger.Debug("param==================", sqlParams)
|
||||
globals.SugarLogger.Debug("err==================", err)
|
||||
globals.SugarLogger.Debug("err==================", err)
|
||||
return authList, err
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package dao
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"reflect"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -98,8 +97,6 @@ func GenQuestionMarks(count int) (marks string) {
|
||||
marks = builder.String()
|
||||
}
|
||||
}
|
||||
result := string(marks)
|
||||
globals.SugarLogger.Debug("输出一下marks", result)
|
||||
return marks
|
||||
}
|
||||
|
||||
|
||||
@@ -638,9 +638,9 @@ func (c *PurchaseHandler) GetOrderRealMobile(ctx *jxcontext.Context, order *mode
|
||||
return mobile, err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) AgreeOrRefuseCancel(ctx *jxcontext.Context, order *model.GoodsOrder, isAgree bool, reason string) (err error) {
|
||||
func (c *PurchaseHandler) AgreeOrRefuseCancel(ctx *jxcontext.Context, order *model.GoodsOrder, isAcceptIt bool, reason string) (err error) {
|
||||
if globals.EnableEbaiStoreWrite {
|
||||
if isAgree {
|
||||
if isAcceptIt {
|
||||
err = api.EbaiAPI.OrderAgreeRefund(order.VendorOrderID)
|
||||
} else {
|
||||
err = api.EbaiAPI.OrderDisagreeRefund(order.VendorOrderID, reason)
|
||||
|
||||
@@ -326,7 +326,7 @@ func Pay4Order(ctx *jxcontext.Context, orderID int64, payType int, vendorPayType
|
||||
err = dao.CreateEntity(dao.GetDB(), orderPay)
|
||||
}
|
||||
case model.PayTypeTL:
|
||||
if subAppID == tiktok.TiktokAppId {
|
||||
if subAppID == tiktok.TiktokAppId || subAppID == tiktok.TiktokJXDJAppID {
|
||||
subAppID = model.JXC4AppId // 京西商城
|
||||
}
|
||||
if orderPay, err = pay4OrderByTL(ctx, order, payType, vendorPayType, subAppID); err == nil && orderPay != nil {
|
||||
|
||||
@@ -45,6 +45,8 @@ func pay4OrderByTL(ctx *jxcontext.Context, order *model.GoodsOrder, payType int,
|
||||
if err == nil && authInfo.GetAuthType() == weixin.AuthTypeMini && authInfo.GetAuthTypeID() == subAppID {
|
||||
param.Acct = authInfo.GetAuthID()
|
||||
}
|
||||
globals.SugarLogger.Debug("authInfo=======================", authInfo)
|
||||
globals.SugarLogger.Debug("param.Acc=======================", param.Acct)
|
||||
}
|
||||
if vendorPayType == tonglianpayapi.PayTypeZfbJS || vendorPayType == tonglianpayapi.PayTypeZfbApp {
|
||||
if authInfo, err := ctx.GetV2AuthInfo(); err == nil {
|
||||
|
||||
Reference in New Issue
Block a user