|
@@ -218,6 +218,18 @@ func BindWxUser(openid, mobile, email string) (wxUser *models.WxUserItem, err er
|
|
|
return
|
|
|
}
|
|
|
userRecord.UserId = userId
|
|
|
+
|
|
|
+ //如果当前该第三方用户信息的昵称为空串的话,那么需要去查询该用户的第一个绑定信息的数据作为来源做数据修复
|
|
|
+ if userRecord.NickName == ""{
|
|
|
+ oldUserRecord, err := models.GetUserThirdRecordByUserId(userId)
|
|
|
+ if err == nil && oldUserRecord != nil{
|
|
|
+ //如果该用户绑定的第一条数据的头像信息不为空串,那么就去做新数据的修复
|
|
|
+ if oldUserRecord.NickName != ""{
|
|
|
+ _ = models.ModifyUserRecordByDetail(userRecord.OpenId, userRecord.UnionId, oldUserRecord.NickName, oldUserRecord.Headimgurl, oldUserRecord.City, oldUserRecord.Province, oldUserRecord.Country, oldUserRecord.Sex, userId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//格式化用户数据
|
|
|
formatWxUserAndUserRecord(wxUser, userRecord)
|
|
|
return
|
|
@@ -231,12 +243,20 @@ func WxLogin(code, openId, unionId string, wxUserInfo *WxUserInfo) (token string
|
|
|
//firstLogin==1,强制绑定手机号或者邮箱
|
|
|
firstLogin = 1
|
|
|
fmt.Println("GetWxUserItemByOpenId ", openId)
|
|
|
+
|
|
|
+QUERY_WX_USER:
|
|
|
wxUser, wxUserErr := GetWxUserItemByOpenId(openId)
|
|
|
fmt.Println("wxUserErr", wxUserErr)
|
|
|
if wxUserErr == ERR_NO_USER_RECORD { //没有用户openid记录
|
|
|
+ //先添加第三方信息(openid等信息)
|
|
|
_, recordErr := AddUserRecord(openId, unionId, wxUserInfo.Nickname, "", wxUserInfo.Province, wxUserInfo.City, wxUserInfo.Country, wxUserInfo.Headimgurl, wxUserInfo.SessionKey, 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
|