|
@@ -28,15 +28,14 @@ type UserInfo struct {
|
|
// GetWxUserItemByOpenId 通过openid获取用户信息
|
|
// GetWxUserItemByOpenId 通过openid获取用户信息
|
|
func GetWxUserItemByOpenId(openid string) (userInfo UserInfo, err error) {
|
|
func GetWxUserItemByOpenId(openid string) (userInfo UserInfo, err error) {
|
|
//通过openid获取用户关联信息
|
|
//通过openid获取用户关联信息
|
|
- userRecord, userRecordErr := user_record.GetByOpenID(openid)
|
|
|
|
- if userRecordErr != nil {
|
|
|
|
- if userRecordErr == utils.ErrNoRow {
|
|
|
|
|
|
+ userRecord, e := user_record.GetByOpenID(openid)
|
|
|
|
+ if e != nil {
|
|
|
|
+ if e == utils.ErrNoRow {
|
|
err = ERR_NO_USER_RECORD
|
|
err = ERR_NO_USER_RECORD
|
|
return
|
|
return
|
|
- } else {
|
|
|
|
- err = userRecordErr
|
|
|
|
- return
|
|
|
|
}
|
|
}
|
|
|
|
+ err = e
|
|
|
|
+ return
|
|
}
|
|
}
|
|
|
|
|
|
//该openid在系统中没有关联关系
|
|
//该openid在系统中没有关联关系
|
|
@@ -288,26 +287,26 @@ QUERY_WX_USER:
|
|
goto QUERY_WX_USER
|
|
goto QUERY_WX_USER
|
|
} else if wxUserErr == ERR_USER_NOT_BIND {
|
|
} else if wxUserErr == ERR_USER_NOT_BIND {
|
|
// 未绑定则去查询unionId是否已经绑定了用户(其他平台,不区分平台),有相应的手机号邮箱信息则自动绑定
|
|
// 未绑定则去查询unionId是否已经绑定了用户(其他平台,不区分平台),有相应的手机号邮箱信息则自动绑定
|
|
- platformUser, platformErr := GetFirstWxUserItemByUnionId(unionId)
|
|
|
|
- if platformErr == nil {
|
|
|
|
- // 当公众号用户存在时
|
|
|
|
- if platformUser.Mobile != "" || platformUser.Email != "" {
|
|
|
|
- // 有手机号或邮箱则绑定信息则自动绑定并新增wx_user
|
|
|
|
- countryCode := 0
|
|
|
|
- if platformUser.CountryCode != "" {
|
|
|
|
- countryCode, _ = strconv.Atoi(platformUser.CountryCode)
|
|
|
|
- }
|
|
|
|
- tempToken, tempUser, tempErr, errMsg := BindWxUser(openId, platformUser.Mobile, platformUser.Email, "", 3, countryCode, 1)
|
|
|
|
- if tempErr != nil {
|
|
|
|
- err = errors.New("自动绑定公众号用户失败,Err:" + tempErr.Error() + ", errMsg:" + errMsg)
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- token = tempToken
|
|
|
|
- userId = int(tempUser.UserID)
|
|
|
|
- isBind = true
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ //platformUser, platformErr := GetFirstWxUserItemByUnionId(unionId)
|
|
|
|
+ //if platformErr == nil {
|
|
|
|
+ // // 当公众号用户存在时
|
|
|
|
+ // if platformUser.Mobile != "" || platformUser.Email != "" {
|
|
|
|
+ // // 有手机号或邮箱则绑定信息则自动绑定并新增wx_user
|
|
|
|
+ // countryCode := 0
|
|
|
|
+ // if platformUser.CountryCode != "" {
|
|
|
|
+ // countryCode, _ = strconv.Atoi(platformUser.CountryCode)
|
|
|
|
+ // }
|
|
|
|
+ // tempToken, tempUser, tempErr, errMsg := BindWxUser(openId, platformUser.Mobile, platformUser.Email, "", 3, countryCode, 1)
|
|
|
|
+ // if tempErr != nil {
|
|
|
|
+ // err = errors.New("自动绑定公众号用户失败,Err:" + tempErr.Error() + ", errMsg:" + errMsg)
|
|
|
|
+ // return
|
|
|
|
+ // }
|
|
|
|
+ // token = tempToken
|
|
|
|
+ // userId = int(tempUser.UserID)
|
|
|
|
+ // isBind = true
|
|
|
|
+ // return
|
|
|
|
+ // }
|
|
|
|
+ //}
|
|
} else if wxUserErr != nil {
|
|
} else if wxUserErr != nil {
|
|
err = wxUserErr
|
|
err = wxUserErr
|
|
return
|
|
return
|
|
@@ -420,14 +419,14 @@ func GetInfoByClaims(c *gin.Context) (userInfo UserInfo) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-// GetAdminByUserId 判断当前用户是否为内部人员
|
|
|
|
|
|
+// GetAdminByUserInfo 判断当前用户是否为内部人员
|
|
func GetAdminByUserInfo(userInfo UserInfo) (ok bool, adminInfo *admin2.Admin, err error) {
|
|
func GetAdminByUserInfo(userInfo UserInfo) (ok bool, adminInfo *admin2.Admin, err error) {
|
|
mobile := userInfo.Mobile
|
|
mobile := userInfo.Mobile
|
|
if mobile == "" {
|
|
if mobile == "" {
|
|
// 用户有可能是通过邮箱登录
|
|
// 用户有可能是通过邮箱登录
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- if userInfo.CompanyID != 16 {
|
|
|
|
|
|
+ if userInfo.CompanyID != utils.HzCompanyId {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
adminInfo, err = admin2.GetAdminByMobile(mobile)
|
|
adminInfo, err = admin2.GetAdminByMobile(mobile)
|
|
@@ -453,7 +452,7 @@ func GetResearcherByUserInfo(userInfo UserInfo) (ok bool, adminInfo *admin2.Admi
|
|
// 用户有可能是通过邮箱登录
|
|
// 用户有可能是通过邮箱登录
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- if userInfo.CompanyID != 16 {
|
|
|
|
|
|
+ if userInfo.CompanyID != utils.HzCompanyId {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
adminInfo, err = admin2.GetAdminByMobile(mobile)
|
|
adminInfo, err = admin2.GetAdminByMobile(mobile)
|