WH01243 8 місяців тому
батько
коміт
bb3c7f88e7
2 змінених файлів з 16 додано та 14 видалено
  1. 8 6
      common/src/qfw/util/jy/userPhoneUtil.go
  2. 8 8
      ent/entity/entity.go

+ 8 - 6
common/src/qfw/util/jy/userPhoneUtil.go

@@ -2,6 +2,7 @@ package jy
 
 import (
 	"fmt"
+	"github.com/gogf/gf/v2/util/gconv"
 	"time"
 
 	qutil "app.yhyue.com/moapp/jybase/common"
@@ -184,10 +185,10 @@ return exists:是否存在
 
 rule 1.不存在手机号,2.存在手机号用户,但此手机号未绑定微信 3.存在手机号用户,或绑定微信和当前账户绑定微信一致
 */
-func (this *PhoneUtil) BindPhoneIsOccupy(userId, unionId, phone string) (exists bool, relationPhoneId string) {
+func (this *PhoneUtil) BindPhoneIsOccupy(userId, unionId, phone string) (exists bool, relationPhoneId string, baseUserId int64) {
 	//已经有微信账户绑定过
 	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, ""
+		return true, "", baseUserId
 	}
 	relationUser, _ := this.UserMgoDB.Find("user", map[string]interface{}{
 		"i_appid": 2,
@@ -195,22 +196,23 @@ func (this *PhoneUtil) BindPhoneIsOccupy(userId, unionId, phone string) (exists
 	}, nil, `{"s_unionid":1}`, false, -1, -1)
 	//不存在手机号用户
 	if relationUser == nil || len(*relationUser) == 0 {
-		return false, ""
+		return false, "", baseUserId
 	}
 	for _, userData := range *relationUser {
 		unionidTmp, _ := userData["s_unionid"].(string)
 		//没绑定微信或绑定微信和当前账户绑定微信一致
 		if unionidTmp == "" || unionidTmp == unionId {
 			relationPhoneId = mg.BsonIdToSId(userData["_id"])
+			baseUserId = gconv.Int64(userData["base_user_id"])
 		} else {
-			return true, ""
+			return true, "", baseUserId
 		}
 	}
 	//但此手机号未绑定微信
 	if userId == relationPhoneId {
-		return true, ""
+		return true, "", baseUserId
 	}
-	return false, relationPhoneId
+	return false, relationPhoneId, baseUserId
 }
 
 /*

+ 8 - 8
ent/entity/entity.go

@@ -11,7 +11,7 @@ import (
 	. "app.yhyue.com/moapp/jypkg/ent/util"
 )
 
-//当前登录用户
+// 当前登录用户
 var VarCurrentUser = &CurrentUser{}
 
 type CurrentUser struct {
@@ -34,7 +34,7 @@ type CurrentUser struct {
 	NicheDis              int         //商机分配权限 1:企业商机分配管理员 2:部门商机分配管理员
 }
 
-//获取当前登录用户的手机号
+// 获取当前登录用户的手机号
 func (c *CurrentUser) Phone(userId string) (string, string) {
 	u, ok := MQFW.FindById("user", userId, `{"s_phone":1,"s_m_phone":1}`)
 	if ok && u != nil {
@@ -47,7 +47,7 @@ func (c *CurrentUser) Phone(userId string) (string, string) {
 	return "", ""
 }
 
-//当前登录用户的信息
+// 当前登录用户的信息
 func (c *CurrentUser) EntInfo(entId, entUserId int) *CurrentUser {
 	currentUser := &CurrentUser{
 		Ent:  &EntInfo{},
@@ -123,7 +123,7 @@ func (c *CurrentUser) EntInfo(entId, entUserId int) *CurrentUser {
 	return currentUser
 }
 
-//手机号是否被占用
+// 手机号是否被占用
 func (c *CurrentUser) PhoneIsOccupy(userId, phone string) (bool, int, string) {
 	user, ok := MQFW.FindById("user", userId, `{"i_appid":1}`)
 	if !ok || user == nil {
@@ -185,7 +185,7 @@ func (c *CurrentUser) PhoneIsOccupy(userId, phone string) (bool, int, string) {
 		if unionId == "" {
 			return true, 2, ""
 		}
-		exists, relationPhoneId := jy.NewPhoneUtil(MQFW).BindPhoneIsOccupy(userId, unionId, phone)
+		exists, relationPhoneId, _ := jy.NewPhoneUtil(MQFW).BindPhoneIsOccupy(userId, unionId, phone)
 		if !exists {
 			return false, 2, relationPhoneId
 		}
@@ -195,7 +195,7 @@ 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 {
@@ -215,7 +215,7 @@ func (c *CurrentUser) BindPhone(userId, phone, email string) (bool, int) {
 	}), appid
 }
 
-//更换手机号
+// 更换手机号
 func (c *CurrentUser) ReplacePhone(userId, phone string, entId int) (int, int) {
 	isOccupy, appid, _ := c.PhoneIsOccupy(userId, phone)
 	if isOccupy {
@@ -234,7 +234,7 @@ func (c *CurrentUser) ReplacePhone(userId, phone string, entId int) (int, int) {
 	return 0, appid
 }
 
-//个人信息
+// 个人信息
 func (c *CurrentUser) UserInfo(userId string) *CurrentUser {
 	currentUser := &CurrentUser{}
 	user, ok := MQFW.FindById("user", userId, `{"s_phone":1,"s_m_phone":1,"s_avatar":1,"s_headimage":1,"s_headimageurl":1,"s_nickname":1}`)