Преглед изворни кода

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	go.mod
#	go.sum
WH01243 пре 2 година
родитељ
комит
fca8c75f29
4 измењених фајлова са 25 додато и 14 уклоњено
  1. 4 0
      common/src/qfw/util/jy/switchService.go
  2. 1 1
      go.mod
  3. 2 2
      go.sum
  4. 18 11
      identity/identity.go

+ 4 - 0
common/src/qfw/util/jy/switchService.go

@@ -62,6 +62,10 @@ func (s *switchService) GetEntniche(session *httpsession.Session, middleground m
 		      }
 	        }*/
 	entniche := data.Data.Entniche.Status > 0
+	//有商机管理服务的用户 就不是商机管理用户 逻辑同isadd中商机管理用户状态判断
+	if isEntService := data.Data.Ent.PowerSource > 0 && data.Data.Entniche.IsEntPower > 0; isEntService {
+		entniche = false
+	}
 	if data != nil {
 		if i_member_status := data.Status; v == s.Member && i_member_status > 0 {
 			return s.Member

+ 1 - 1
go.mod

@@ -5,7 +5,7 @@ go 1.18
 require (
 	app.yhyue.com/moapp/jybase v0.0.0-20230117032034-ad7c00ffe11a
 	app.yhyue.com/moapp/message v0.0.0-20221223100203-6402e389d9ae
-	bp.jydev.jianyu360.cn/BaseService/entManageApplication v0.0.0-20230105062832-20c4dc148f8d
+	bp.jydev.jianyu360.cn/BaseService/entManageApplication v0.0.0-20230214091519-89a98c01ab0e
 	bp.jydev.jianyu360.cn/BaseService/powerCheckCenter v0.0.0-20230210052334-7b32c3b8c773
 	bp.jydev.jianyu360.cn/BaseService/resourceCenter v0.0.7
 	bp.jydev.jianyu360.cn/BaseService/userCenter v1.2.13

+ 2 - 2
go.sum

@@ -6,8 +6,8 @@ app.yhyue.com/moapp/jybase v0.0.0-20230117032034-ad7c00ffe11a h1:wD4aWPSYdiX1cIP
 app.yhyue.com/moapp/jybase v0.0.0-20230117032034-ad7c00ffe11a/go.mod h1:zB47XTeJvpcbtBRYgkQuxOICWNexiZfbUO+7aUf6mNs=
 app.yhyue.com/moapp/message v0.0.0-20221223100203-6402e389d9ae h1:6rDDaz6yxvE8viTSzEBwKYOFWq14TMfuBivSazUZMz4=
 app.yhyue.com/moapp/message v0.0.0-20221223100203-6402e389d9ae/go.mod h1:b0zZHev3gmJao1Fo+2Z2KPVjsuLOJVvVxf+kCnu9WkA=
-bp.jydev.jianyu360.cn/BaseService/entManageApplication v0.0.0-20230105062832-20c4dc148f8d h1:LhAwi6+LfwXJRnuIrUw/L+pQ76PVFGOkgv89FX8z8q4=
-bp.jydev.jianyu360.cn/BaseService/entManageApplication v0.0.0-20230105062832-20c4dc148f8d/go.mod h1:purH81w7lL+6l4T1NIrMtMmCh3CXq0ePXUXUhMu9Nsk=
+bp.jydev.jianyu360.cn/BaseService/entManageApplication v0.0.0-20230214091519-89a98c01ab0e h1:h+VEI3o1qC0jeCzkFGTrLI4f27cfa/W/y+0sXokWMgE=
+bp.jydev.jianyu360.cn/BaseService/entManageApplication v0.0.0-20230214091519-89a98c01ab0e/go.mod h1:7Xhygw0KBuL4h0G76FnFg4otQcA9bmOO0c8M0FCjAyQ=
 bp.jydev.jianyu360.cn/BaseService/powerCheckCenter v0.0.0-20230210052334-7b32c3b8c773 h1:IbbM9kFSbqJ44UpN99C2cZKX/X/yC03baBYJ7oc0j/w=
 bp.jydev.jianyu360.cn/BaseService/powerCheckCenter v0.0.0-20230210052334-7b32c3b8c773/go.mod h1:5nimT8GJh46AyfeeDeyRlDQygMlO7TRM8Pwm41Gxemc=
 bp.jydev.jianyu360.cn/BaseService/resourceCenter v0.0.7 h1:G6PHMWAHfYEuY6kbl7OM/KnCQf1Xa54mdhuP7JzK8/I=

+ 18 - 11
identity/identity.go

@@ -66,7 +66,7 @@ func (i *IdentityInfo) Switch(sess *httpsession.Session, mgo *MongodbSim) bool {
 		ok = true
 	}
 	sess.SetMultiple(m)
-	go mgo.UpdateById("user", mgoUserId, map[string]interface{}{
+	mgo.UpdateById("user", mgoUserId, map[string]interface{}{
 		"$set": map[string]interface{}{
 			"login_positionid": i.PositionId,
 		},
@@ -75,15 +75,22 @@ func (i *IdentityInfo) Switch(sess *httpsession.Session, mgo *MongodbSim) bool {
 }
 
 //切换到最优身份
-func SwitchToBest(userId int64, sess *httpsession.Session, mgd *Middleground, mgo *MongodbSim) bool {
+func SwitchToBest(userId int64, sess *httpsession.Session, mgd *Middleground, mgo *MongodbSim, isSelectLast bool) (int64, bool) {
 	list := mgd.UserCenter.IdentityList(userId)
 	if list == nil || len(list) == 0 {
-		return false
+		return -1, false
 	}
-	if beforePositionId := Int64All(sess.Get("beforePositionId")); beforePositionId > 0 {
-		for _, v := range list {
-			if v.PositionId == beforePositionId {
-				return NewIdentityInfo(v).Switch(sess, mgo)
+	if isSelectLast {
+		if mgoUserId, _ := sess.Get("mgoUserId").(string); mgoUserId != "" {
+			user, ok := mgo.FindById("user", mgoUserId, `{"login_positionid":1}`)
+			if ok && user != nil && len(*user) > 0 {
+				if login_positionid := Int64All((*user)["login_positionid"]); login_positionid > 0 {
+					for _, v := range list {
+						if v.PositionId == login_positionid {
+							return v.PositionId, NewIdentityInfo(v).Switch(sess, mgo)
+						}
+					}
+				}
 			}
 		}
 	}
@@ -94,18 +101,18 @@ func SwitchToBest(userId int64, sess *httpsession.Session, mgd *Middleground, mg
 		}
 	}
 	if len(reqIds) > 0 {
-		if resp := mgd.EntManageApplication.EmpowerUserIds(reqIds); len(resp.Ids) > 0 {
+		if resp := mgd.EntManageApplication.EmpowerUserIds(reqIds); resp != nil && len(resp.Ids) > 0 {
 			for _, v := range list {
 				if v.PositionType == 1 && v.EntUserId == resp.Ids[0] {
-					return NewIdentityInfo(v).Switch(sess, mgo)
+					return v.PositionId, NewIdentityInfo(v).Switch(sess, mgo)
 				}
 			}
 		}
 	}
 	for _, v := range list {
 		if v.PositionType == 0 {
-			return NewIdentityInfo(v).Switch(sess, mgo)
+			return v.PositionId, NewIdentityInfo(v).Switch(sess, mgo)
 		}
 	}
-	return false
+	return -1, false
 }