|
@@ -211,6 +211,16 @@ func BindWxUser(openid,mobile,email string) (wxUser *models.WxUserItem,err error
|
|
|
return
|
|
|
}
|
|
|
userRecord.UserId = userId
|
|
|
+ //如果当前该第三方用户信息的昵称为空串的话,那么需要去查询该用户的第一个绑定信息的数据作为来源做数据修复
|
|
|
+ if userRecord.NickName == ""{
|
|
|
+ oldUserRecord, err := models.GetUserThirdRecordByUserId(userId)
|
|
|
+ if err == nil && oldUserRecord != nil{
|
|
|
+ //如果该用户绑定的第一条数据的头像信息不为空串,那么就去做新数据的修复
|
|
|
+ if oldUserRecord.NickName != ""{
|
|
|
+ _ = models.ModifyUserRecordInfo(userRecord.OpenId,oldUserRecord.NickName, oldUserRecord.Headimgurl, oldUserRecord.City, oldUserRecord.Province, oldUserRecord.Country, oldUserRecord.Sex, userId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
//格式化用户数据
|
|
|
formatWxUserAndUserRecord(wxUser,userRecord)
|
|
|
return
|
|
@@ -226,11 +236,18 @@ func WxLogin(code string,wxAccessToken *WxAccessToken,wxUserInfo *WxUserInfo)(to
|
|
|
|
|
|
//firstLogin==1,强制绑定手机号或者邮箱
|
|
|
firstLogin = 1
|
|
|
+
|
|
|
+QUERY_WX_USER:
|
|
|
wxUser, wxUserErr := GetWxUserItemByOpenId(openId)
|
|
|
if wxUserErr == ERR_NO_USER_RECORD{ //没有用户openid记录
|
|
|
_,recordErr := AddUserRecord(openId,unionId,wxUserInfo.Nickname,"",wxUserInfo.Province,wxUserInfo.City,wxUserInfo.Country,wxUserInfo.Headimgurl,"",utils.WxPlatform,wxUserInfo.Sex,0)
|
|
|
- err = recordErr
|
|
|
- return
|
|
|
+ //如果插入失败,那么直接将错误信息返回
|
|
|
+ if recordErr != nil{
|
|
|
+ err = recordErr
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //插入成功后,需要重新查询该用户,并进入下面的逻辑
|
|
|
+ goto QUERY_WX_USER
|
|
|
}else if wxUserErr == ERR_USER_NOT_BIND{
|
|
|
//没有用户信息
|
|
|
//wxUser.FirstLogin = 1
|