|
@@ -228,7 +228,24 @@ QUERY_WX_USER:
|
|
|
//插入成功后,需要重新查询该用户,并进入下面的逻辑
|
|
|
goto QUERY_WX_USER
|
|
|
} else if wxUserErr == ERR_USER_NOT_BIND {
|
|
|
- //没有用户信息
|
|
|
+ // 未绑定则去查询是否为弘则研究公众号用户,有相应的手机号邮箱信息则自动绑定
|
|
|
+ platformUser, platformErr := GetWxUserItemByUnionId(unionId, 1)
|
|
|
+ if platformErr == nil {
|
|
|
+ // 当公众号用户存在时
|
|
|
+ if platformUser.Mobile != "" || platformUser.Email != "" {
|
|
|
+ // 有手机号或邮箱则绑定信息则自动绑定并新增wx_user
|
|
|
+ countryCode := 0
|
|
|
+ if platformUser.CountryCode != "" {
|
|
|
+ countryCode, _ = strconv.Atoi(platformUser.CountryCode)
|
|
|
+ }
|
|
|
+ _, _, tempErr, errMsg := BindWxUser(openId, platformUser.Mobile, platformUser.Email, "", 3, countryCode, 1)
|
|
|
+ if tempErr != nil {
|
|
|
+ err = errors.New("自动绑定公众号用户失败" + errMsg)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ isBind = true
|
|
|
+ }
|
|
|
+ }
|
|
|
} else if wxUserErr != nil {
|
|
|
err = wxUserErr
|
|
|
return
|
|
@@ -246,24 +263,6 @@ QUERY_WX_USER:
|
|
|
// 如果账户有绑定了手机号或者邮箱,那么标记为已绑定
|
|
|
if wxUser.Mobile != "" || wxUser.Email != "" {
|
|
|
isBind = true
|
|
|
- } else {
|
|
|
- // 未绑定则去查询是否为弘则研究公众号用户,有相应的手机号邮箱信息则自动绑定,无则进入下一步
|
|
|
- platformUser, platformErr := GetWxUserItemByUnionId(unionId, 1)
|
|
|
- if platformErr == nil {
|
|
|
- // 当公众号用户存在时
|
|
|
- if platformUser.Mobile != "" || platformUser.Email != "" {
|
|
|
- // 有手机号邮箱绑定信息则自动绑定,无则进入下一步
|
|
|
- wxUser.Mobile = platformUser.Mobile
|
|
|
- wxUser.Email = platformUser.Email
|
|
|
- var wxUserUpdateCols = []string{"Mobile", "Email"}
|
|
|
- updateErr := wxUser.Update(wxUserUpdateCols)
|
|
|
- if updateErr != nil {
|
|
|
- err = errors.New("用户信息更新失败")
|
|
|
- return
|
|
|
- }
|
|
|
- isBind = true
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
|