Ver código fonte

账号查询处理

WH01243 2 anos atrás
pai
commit
d7e0fd4ddb
2 arquivos alterados com 21 adições e 18 exclusões
  1. 4 1
      common/src/qfw/util/jy/userPhoneUtil.go
  2. 17 17
      ent/entity/entity.go

+ 4 - 1
common/src/qfw/util/jy/userPhoneUtil.go

@@ -184,7 +184,7 @@ return exists:是否存在
 
 rule 1.不存在手机号,2.存在手机号用户,但此手机号未绑定微信 3.存在手机号用户,或绑定微信和当前账户绑定微信一致
 */
-func (this *PhoneUtil) BindPhoneIsOccupy(unionId, phone string) (exists bool, relationPhoneId string) {
+func (this *PhoneUtil) BindPhoneIsOccupy(userId, unionId, phone string) (exists bool, relationPhoneId string) {
 	//已经有微信账户绑定过
 	if this.UserMgoDB.Count("user", map[string]interface{}{"i_appid": 2, "s_m_phone": phone, "s_phone": map[string]interface{}{"$exists": 0}}) > 0 {
 		return true, ""
@@ -207,6 +207,9 @@ func (this *PhoneUtil) BindPhoneIsOccupy(unionId, phone string) (exists bool, re
 		}
 	}
 	//但此手机号未绑定微信
+	if userId == relationPhoneId {
+		return true, ""
+	}
 	return false, relationPhoneId
 }
 

+ 17 - 17
ent/entity/entity.go

@@ -182,7 +182,7 @@ func (c *CurrentUser) PhoneIsOccupy(userId, phone string) (bool, int, string) {
 		if unionId == "" {
 			return true, 2, ""
 		}
-		exists, relationPhoneId := jy.NewPhoneUtil(MQFW).BindPhoneIsOccupy(unionId, phone)
+		exists, relationPhoneId := jy.NewPhoneUtil(MQFW).BindPhoneIsOccupy(userId, unionId, phone)
 		if !exists {
 			return false, 2, relationPhoneId
 		}
@@ -194,22 +194,22 @@ func (c *CurrentUser) PhoneIsOccupy(userId, phone string) (bool, int, string) {
 
 //绑定手机号
 func (c *CurrentUser) BindPhone(userId, phone, email string) (bool, int) {
-        isOccupy, appid, _ := c.PhoneIsOccupy(userId, phone)
-        if isOccupy {
-	      return false, appid
-        }
-        if appid == 2 {
-	      //商机管理绑定手机号需要和剑鱼保持一致,建立双向绑定关系
-	      //err := jy.NewPhoneUtil(MQFW).BindPhone(userId, relationPhoneId, phone, email, nil)\
-                var err error
-	      if err == nil {
-		    return true, appid
-	      }
-	      return false, appid
-        }
-        return MQFW.UpdateById("user", userId, map[string]interface{}{
-	      "$set": map[string]interface{}{"s_m_phone": phone},
-        }), appid
+	isOccupy, appid, _ := c.PhoneIsOccupy(userId, phone)
+	if isOccupy {
+		return false, appid
+	}
+	if appid == 2 {
+		//商机管理绑定手机号需要和剑鱼保持一致,建立双向绑定关系
+		//err := jy.NewPhoneUtil(MQFW).BindPhone(userId, relationPhoneId, phone, email, nil)\
+		var err error
+		if err == nil {
+			return true, appid
+		}
+		return false, appid
+	}
+	return MQFW.UpdateById("user", userId, map[string]interface{}{
+		"$set": map[string]interface{}{"s_m_phone": phone},
+	}), appid
 }
 
 //更换手机号