Browse Source

Merge branch 'user'

Roc 3 years ago
parent
commit
6319b6d625
1 changed files with 13 additions and 3 deletions
  1. 13 3
      services/user/user_bind.go

+ 13 - 3
services/user/user_bind.go

@@ -52,10 +52,12 @@ func BindWxUser(openid, mobile, email, code string, bindType, areaNum, registerP
 		return
 	}
 
-	userInfo, err = bindWxUser(openid, mobile, email, areaNum, registerPlatform)
+	userInfo, errMsg, err = bindWxUser(openid, mobile, email, areaNum, registerPlatform)
 
 	if err != nil {
-		errMsg = "绑定失败:" + err.Error()
+		if errMsg == `` {
+			errMsg = "绑定失败:" + err.Error()
+		}
 		return
 	}
 
@@ -117,7 +119,7 @@ func BindWxUser(openid, mobile, email, code string, bindType, areaNum, registerP
 }
 
 // bindWxUser 用户注册/绑定
-func bindWxUser(openid, mobile, email string, areaNum, registerPlatform int) (userInfo UserInfo, err error) {
+func bindWxUser(openid, mobile, email string, areaNum, registerPlatform int) (userInfo UserInfo, errMsg string, err error) {
 	var source int8
 	source = 6 //绑定来源,1:微信端,2:pc网页端,3:查研观向小程序,4:每日咨询
 	if mobile == "" && email == "" {
@@ -205,6 +207,14 @@ func bindWxUser(openid, mobile, email string, areaNum, registerPlatform int) (us
 	//如果存在该手机号/邮箱,那么需要校验
 	if userRecord.UserID > 0 && userRecord.UserID != userId {
 		err = errors.New(fmt.Sprint("用户已绑定其他账户,已绑定的用户编号:", userRecord.UserID, ",不允许重复绑定"))
+		currUser, tmpErr := wx_user.GetByUserId(userRecord.UserID)
+		if tmpErr != utils.ErrNoRow {
+			currBindAccount := currUser.Mobile
+			if currBindAccount == `` {
+				currBindAccount = currUser.Email
+			}
+			errMsg = "微信已绑定其它账户:" + currBindAccount
+		}
 		return
 	}
 	if userRecord.UserID == 0 {