diff --git a/business/auth2/auth2.go b/business/auth2/auth2.go index 039b112b2..bcf932354 100644 --- a/business/auth2/auth2.go +++ b/business/auth2/auth2.go @@ -446,5 +446,5 @@ func DisableUser(userID, operatorUserName string) (err error) { } func GetUserBindAuthInfo(userID string) (authList []*model.AuthBind, err error) { - return dao.GetUserBindAuthInfo(dao.GetDB(), userID, model.AuthBindTypeAuth, nil, "", "") + return dao.GetUserBindAuthInfo(dao.GetDB(), userID, model.AuthBindTypeAuth, nil, "", "", "") } diff --git a/business/auth2/authprovider/defauther.go b/business/auth2/authprovider/defauther.go index ea0ea4620..510a0c17c 100644 --- a/business/auth2/authprovider/defauther.go +++ b/business/auth2/authprovider/defauther.go @@ -82,7 +82,7 @@ func (a *DefAuther) UnionFindAuthBind(curAuthType, curAuthTypeID string, unionAu } else if dao.IsNoRowsError(err) { // 直接找不到,尝试unionID if unionID != "" { // 且有unionID var authBindList []*model.AuthBind - if authBindList, err = dao.GetUserBindAuthInfo(db, "", model.AuthBindTypeAuth, unionAuthTypeList, "", unionID); err == nil && len(authBindList) > 0 { // 通过unionID找到至少一个认证方式 + if authBindList, err = dao.GetUserBindAuthInfo(db, "", model.AuthBindTypeAuth, unionAuthTypeList, "", unionID, ""); err == nil && len(authBindList) > 0 { // 通过unionID找到至少一个认证方式 authBind = authBindList[0] authBind.Type = curAuthType authBind.TypeID = curAuthTypeID diff --git a/business/jxstore/cms/user2.go b/business/jxstore/cms/user2.go index d71983974..ff29eb99b 100644 --- a/business/jxstore/cms/user2.go +++ b/business/jxstore/cms/user2.go @@ -804,7 +804,7 @@ func HandleUserWXRemark(db *dao.DaoDB, mobile string, mobileIsUerID bool) (err e } } if userID != "" { - authBindList, err2 := dao.GetUserBindAuthInfo(db, userID, model.AuthBindTypeAuth, []string{weixin.AuthTypeMP}, "", "") + authBindList, err2 := dao.GetUserBindAuthInfo(db, userID, model.AuthBindTypeAuth, []string{weixin.AuthTypeMP}, "", "", "") if err = err2; err == nil { for _, v := range authBindList { openIDs = append(openIDs, v.AuthID) @@ -972,7 +972,7 @@ func WriteToExcelJd(task *tasksch.SeqTask, jd []JdUserStruct) (err error) { func UpdateUserWxNoAndPercent(user *model.User, isReceiver bool) (num int64, err error) { db := dao.GetDB() user2, err := dao.GetUserByID(db, "user_id", user.UserID) - auth, err := dao.GetUserBindAuthInfo(db, user.UserID, model.AuthBindTypeAuth, []string{"weixinmini"}, "", "") + auth, err := dao.GetUserBindAuthInfo(db, user.UserID, model.AuthBindTypeAuth, []string{"weixinmini"}, "", "", "wx4b5930c13f8b1170") if len(auth) == 0 { return 0, fmt.Errorf("未找到此用户的微信验证方式!用户ID:[%v]\n", user.UserID) } diff --git a/business/jxutils/weixinmsg/weixinmsg.go b/business/jxutils/weixinmsg/weixinmsg.go index 5123629ac..306dd8fb0 100644 --- a/business/jxutils/weixinmsg/weixinmsg.go +++ b/business/jxutils/weixinmsg/weixinmsg.go @@ -96,7 +96,7 @@ func GetWeixinOpenIDsFromStoreID(storeID int) (retVal []string) { if globals.EnableWXAuth2 { if userIDList, err2 := api2.RoleMan.GetRoleUserList(autils.NewStoreBossRole(storeID)); err2 == nil { for _, v := range userIDList { - if authList, err2 := dao.GetUserBindAuthInfo(db, v, model.AuthBindTypeAuth, []string{weixin.AuthTypeMP}, "", ""); err2 == nil { + if authList, err2 := dao.GetUserBindAuthInfo(db, v, model.AuthBindTypeAuth, []string{weixin.AuthTypeMP}, "", "", ""); err2 == nil { for _, v := range authList { retVal = append(retVal, v.AuthID) openIDMap[v.AuthID] = 1 diff --git a/business/model/dao/dao_auth2.go b/business/model/dao/dao_auth2.go index 6933f0040..24f876168 100644 --- a/business/model/dao/dao_auth2.go +++ b/business/model/dao/dao_auth2.go @@ -27,7 +27,7 @@ func GetAuthBind(db *DaoDB, bindType int, authType, authID string) (authBind *mo return authBind, err } -func GetUserBindAuthInfo(db *DaoDB, userID string, bindType int, typeList []string, authID, authID2 string) (authList []*model.AuthBind, err error) { +func GetUserBindAuthInfo(db *DaoDB, userID string, bindType int, typeList []string, authID, authID2, typeID string) (authList []*model.AuthBind, err error) { sql := ` SELECT * FROM auth_bind t1 @@ -56,6 +56,10 @@ func GetUserBindAuthInfo(db *DaoDB, userID string, bindType int, typeList []stri sql += " AND t1.auth_id2 = ?" sqlParams = append(sqlParams, authID2) } + if typeID != "" { + sql += " AND t1.type_id = ?" + sqlParams = append(sqlParams, typeID) + } sql += " ORDER BY t1.type" err = GetRows(db, &authList, sql, sqlParams...) return authList, err diff --git a/business/partner/purchase/jx/localjx/order.go b/business/partner/purchase/jx/localjx/order.go index b9484f2e3..68813e0d1 100644 --- a/business/partner/purchase/jx/localjx/order.go +++ b/business/partner/purchase/jx/localjx/order.go @@ -652,7 +652,7 @@ func PayForPopluarMan(ctx *jxcontext.Context, vendorOrderID, userID string, pric if user == nil { return fmt.Errorf("未找到此用户!用户ID:[%v]\n", userID) } - auth, err := dao.GetUserBindAuthInfo(db, userID, model.AuthBindTypeAuth, []string{"weixinmini"}, "", "") + auth, err := dao.GetUserBindAuthInfo(db, userID, model.AuthBindTypeAuth, []string{"weixinmini"}, "", "", "wx4b5930c13f8b1170") if len(auth) == 0 { return fmt.Errorf("未找到此用户的微信验证方式!用户ID:[%v]\n", userID) } @@ -698,7 +698,7 @@ func AutoPayForPopluarMan(ctx *jxcontext.Context) (err error) { return err } user2, err := dao.GetUserByID(db, "mobile", user.ParentMobile) - auths, err := dao.GetUserBindAuthInfo(db, user2.UserID, model.AuthBindTypeAuth, []string{"weixinmini"}, "", "") + auths, err := dao.GetUserBindAuthInfo(db, user2.UserID, model.AuthBindTypeAuth, []string{"weixinmini"}, "", "", "wx4b5930c13f8b1170") if err != nil { return err } @@ -726,7 +726,7 @@ func AutoPayForPopluarMan(ctx *jxcontext.Context) (err error) { } if user2.ParentMobile != "" { user3, err := dao.GetUserByID(db, "mobile", user2.ParentMobile) - auths, err := dao.GetUserBindAuthInfo(db, user3.UserID, model.AuthBindTypeAuth, []string{"weixinmini"}, "", "") + auths, err := dao.GetUserBindAuthInfo(db, user3.UserID, model.AuthBindTypeAuth, []string{"weixinmini"}, "", "", "wx4b5930c13f8b1170") if err != nil { return err }