ソースを参照

feat:免费权限

wangshan 2 年 前
コミット
fce6d9b39b
1 ファイル変更40 行追加38 行削除
  1. 40 38
      entity/user.go

+ 40 - 38
entity/user.go

@@ -75,42 +75,6 @@ func (m *WorkDesktopMenu) AutoUserPowerInfo() map[string]int {
 		)
 		phone, _ := MC.If((*data)["s_phone"] != nil, (*data)["s_phone"], (*data)["s_m_phone"]).(string)
 		if phone != "" {
-			//当前企业id
-			if m.EntId > 0 {
-				entNicheInfos := Mysql.SelectBySql(`SELECT i.status,i.isNew,i.power_source,r.role_id,u.power FROM (entniche_user u LEFT JOIN entniche_user_role r ON r.user_id = u.id)  LEFT JOIN entniche_info i ON u.ent_id=i.id WHERE u.phone = ? and i.id = ? ORDER BY r.role_id,i.isNew DESC`, phone, m.EntId)
-				//商机管理用户信息判断
-				logx.Info("entNicheInfos:", entNicheInfos)
-				if entNicheInfos != nil && len(*entNicheInfos) > 0 {
-					isFree = false
-					entNicheInfo := (*entNicheInfos)[0]
-					//判断是否是企业级服务管理员
-					entnichePower = MC.IntAll(entNicheInfo["role_id"]) == 1
-					//商机管理
-					if MC.IntAll(entNicheInfo["status"]) == 1 && MC.IntAll(entNicheInfo["power"]) == 1 {
-						//商机管理服务 P259需求
-						powerSource = MC.IntAll(entNicheInfo["power_source"])
-						//entNicheInfo := (*entNicheInfos)[0]
-						switch MC.IntAll(entNicheInfo["isNew"]) {
-						case 1: //新版商机管理
-							UserPowerMap["110"] = 1
-							switch MC.IntAll(entNicheInfo["role_id"]) {
-							case 2: //部门管理员
-								UserPowerMap["111"] = 1
-							case 1: //企业管理员
-								UserPowerMap["112"] = 1
-							}
-						case 0: //老版商机管理
-							UserPowerMap["100"] = 1
-							switch MC.IntAll(entNicheInfo["role_id"]) {
-							case 2: //部门管理员
-								UserPowerMap["101"] = 1
-							case 1: //企业管理员
-								UserPowerMap["102"] = 1
-							}
-						}
-					}
-				}
-			}
 			//大会员
 			if memberStatus := MC.IntAll((*data)["i_member_status"]); memberStatus > 0 || ConfigJson.BigMemberOff {
 				mainUserId := m.UserId
@@ -149,6 +113,46 @@ func (m *WorkDesktopMenu) AutoUserPowerInfo() map[string]int {
 					}
 				}
 			}
+			//当前企业id
+			if m.EntId > 0 {
+				entNicheInfos := Mysql.SelectBySql(`SELECT i.status,i.isNew,i.power_source,r.role_id,u.power FROM (entniche_user u LEFT JOIN entniche_user_role r ON r.user_id = u.id)  LEFT JOIN entniche_info i ON u.ent_id=i.id WHERE u.phone = ? and i.id = ? ORDER BY r.role_id,i.isNew DESC`, phone, m.EntId)
+				//商机管理用户信息判断
+				logx.Info("entNicheInfos:", entNicheInfos)
+				if entNicheInfos != nil && len(*entNicheInfos) > 0 {
+					entNicheInfo := (*entNicheInfos)[0]
+					//判断是否是企业级服务管理员
+					entnichePower = MC.IntAll(entNicheInfo["role_id"]) == 1
+					//商机管理
+					if MC.IntAll(entNicheInfo["status"]) == 1 && MC.IntAll(entNicheInfo["power"]) == 1 {
+						isFree = false
+						//商机管理服务 P259需求
+						powerSource = MC.IntAll(entNicheInfo["power_source"])
+						//客户管理服务(商机管理服务) [前提:大会员、超级订阅、医械通用户]
+						//有商机管理服务 不会再有商机管理订阅菜单
+						if UserPowerMap["600"] = MC.If(powerSource > 0 && domainBool, 1, 0).(int); UserPowerMap["600"] == 0 {
+							//entNicheInfo := (*entNicheInfos)[0]
+							switch MC.IntAll(entNicheInfo["isNew"]) {
+							case 1: //新版商机管理
+								UserPowerMap["110"] = 1
+								switch MC.IntAll(entNicheInfo["role_id"]) {
+								case 2: //部门管理员
+									UserPowerMap["111"] = 1
+								case 1: //企业管理员
+									UserPowerMap["112"] = 1
+								}
+							case 0: //老版商机管理
+								UserPowerMap["100"] = 1
+								switch MC.IntAll(entNicheInfo["role_id"]) {
+								case 2: //部门管理员
+									UserPowerMap["101"] = 1
+								case 1: //企业管理员
+									UserPowerMap["102"] = 1
+								}
+							}
+						}
+					}
+				}
+			}
 			//免费用户
 			if isFree {
 				UserPowerMap["300"] = 1
@@ -169,8 +173,6 @@ func (m *WorkDesktopMenu) AutoUserPowerInfo() map[string]int {
 					UserPowerMap[plv] = 1
 				}
 			}
-			//客户管理服务(商机管理服务) [前提:大会员、超级订阅、医械通用户]
-			UserPowerMap["600"] = MC.If(powerSource > 0 && domainBool, 1, 0).(int)
 			//必须是企业管理员-&-购买了企业级应用服务
 			c := Mysql.CountBySql(fmt.Sprintf(`SELECT COUNT(id) FROM %s WHERE ent_id = ? AND TO_DAYS(end_time) >= TO_DAYS(NOW())`, EntnicheWaitEmpower), m.EntId)
 			logx.Info(entnichePower, "cccccc:", c)