“wwangchuanjin 5 lat temu
rodzic
commit
e0dc6b13a8

+ 2 - 2
entbase/src/service/ent/ent.go

@@ -43,10 +43,10 @@ func (a *Action) MyEnts() {
 
 //企业信息
 func (a *Action) EntInfo() {
-	userId, _ := a.GetSession("userId").(string)
 	entName, _ := a.GetSession("entName").(string)
 	entId := qutil.IntAll(a.GetSession("entId"))
-	entInfo := VarCurrentUser.EntInfo(userId, entId)
+	entUserId := qutil.IntAll(a.GetSession("entUserId"))
+	entInfo := VarCurrentUser.EntInfo(entId, entUserId)
 	m := M{
 		"ent_id":           qutil.SE.Encode2HexByCheck(fmt.Sprint(entId)),
 		"ent_name":         entName,

+ 5 - 7
entniche/src/service/customer/customer.go

@@ -29,10 +29,9 @@ func (this *CustomerAction) CustomerQuery() {
 		pageSize = qutil.If(pageSize == 0, 10, pageSize).(int) //默认每页10条
 
 		//获取当前用户信息
-		userId := qutil.ObjToString(this.GetSession("userId"))
 		ent_id := qutil.IntAll(this.GetSession("entId"))
 		entUserId := qutil.IntAll(this.GetSession("entUserId"))
-		curUser := VarCurrentUser.EntInfo(userId, ent_id)
+		curUser := VarCurrentUser.EntInfo(ent_id, entUserId)
 
 		var count int64
 		var customerList *[]map[string]interface{}
@@ -168,9 +167,9 @@ func (this *CustomerAction) CustomerDetail() {
 	errMsg, rData := func() (string, map[string]interface{}) {
 		//获取请求参数
 		customer_id := qutil.SE.Decode4HexByCheck(this.GetString("customer_id")) //客户id
-		userId := qutil.ObjToString(this.GetSession("userId"))
 		ent_id := qutil.IntAll(this.GetSession("entId"))
-		curUser := VarCurrentUser.EntInfo(userId, ent_id)
+		entUserId := qutil.IntAll(this.GetSession("entUserId"))
+		curUser := VarCurrentUser.EntInfo(ent_id, entUserId)
 
 		customerMsg := map[string]interface{}{}
 		if curUser.Role_admin_system { //查看企业所有客户信息
@@ -245,8 +244,8 @@ func (this *CustomerAction) CustomerUpdate() {
 		}
 		//获取当前用户信息
 		ent_id := qutil.IntAll(this.GetSession("entId"))
-		userId := qutil.ObjToString(this.GetSession("userId"))
-		curEntUser := VarCurrentUser.EntInfo(userId, ent_id)
+		entUserId := qutil.IntAll(this.GetSession("entUserId"))
+		curEntUser := VarCurrentUser.EntInfo(ent_id, entUserId)
 		//判断是否有修改权限
 		if curEntUser.Role_admin_department { //判断该客户是否属于此部门管理员管辖
 			if Mysql.CountBySql(`SELECT count(1)
@@ -264,7 +263,6 @@ func (this *CustomerAction) CustomerUpdate() {
 			}
 		}
 		//获取当前部门和操作人名字
-		entUserId := qutil.IntAll(this.GetSession("entUserId"))
 		curUser := VarUser.GetAllInfoById(ent_id, entUserId)
 		if curUser.Dept_id == 0 {
 			return "获取部门信息异常", nil

+ 4 - 4
entniche/src/service/customer/distribute.go

@@ -19,12 +19,12 @@ func (this *CustomerAction) DistributePersons() {
 	}
 	errMsg, rData := func() (string, interface{}) {
 		customer_id := qutil.SE.Decode4HexByCheck(this.GetString("customer_id")) //客户id
-		userId := qutil.ObjToString(this.GetSession("userId"))
 		ent_id := qutil.IntAll(this.GetSession("entId"))
+		entUserId := qutil.IntAll(this.GetSession("entUserId"))
 		distributeUsers := VarCustomer.GetDistributeUser(ent_id, customer_id) //获取已分发人员id
 		//获取人员列表
 		var users []*User
-		curUser := VarCurrentUser.EntInfo(userId, ent_id)
+		curUser := VarCurrentUser.EntInfo(ent_id, entUserId)
 		if curUser.Role_admin_department {
 			users = *VarDepartment.GetDisUsersDeptDetail(curUser.Ent.Id, curUser.Dept.Id)
 		} else if curUser.Role_admin_system {
@@ -76,9 +76,9 @@ func (this *CustomerAction) DistributeSubmit() {
 		customer_id := qutil.SE.Decode4HexByCheck(this.GetString("customer_id")) //客户id
 		staffIdsStr := this.GetString("staff_ids")                               //被分发人员id
 		//获取当前用户信息
-		userId := qutil.ObjToString(this.GetSession("userId"))
 		ent_id := qutil.IntAll(this.GetSession("entId"))
-		curUser := VarCurrentUser.EntInfo(userId, ent_id)
+		entUserId := qutil.IntAll(this.GetSession("entUserId"))
+		curUser := VarCurrentUser.EntInfo(ent_id, entUserId)
 		//获取人员列表
 		var users []*User
 		if curUser.Role_admin_department {

+ 14 - 12
entniche/src/service/distribute/distribute.go

@@ -32,9 +32,9 @@ type Action struct {
 
 //分发设置列表接口
 func (ac *Action) Distribute_list() {
-	userId := qutil.ObjToString(ac.GetSession("userId"))
 	ent_id := qutil.IntAll(ac.GetSession("entId"))
-	userinfo := VarCurrentUser.EntInfo(userId, ent_id)
+	entUserId := qutil.IntAll(ac.GetSession("entUserId"))
+	userinfo := VarCurrentUser.EntInfo(ent_id, entUserId)
 	queryMap := map[string]interface{}{
 		"i_deptid": userinfo.Dept.Id,
 		"i_entid":  ent_id,
@@ -109,10 +109,10 @@ func (ac *Action) Distribute_list() {
 
 //分发员工列表接口
 func (ac *Action) Distribute_persons() {
-	userId := qutil.ObjToString(ac.GetSession("userId"))
 	ent_id := qutil.IntAll(ac.GetSession("entId"))
+	entUserId := qutil.IntAll(ac.GetSession("entUserId"))
 	var users []*User
-	entInfo := VarCurrentUser.EntInfo(userId, ent_id)
+	entInfo := VarCurrentUser.EntInfo(ent_id, entUserId)
 
 	if entInfo.Role_admin_department {
 		users = *VarDepartment.GetDisUsers(ent_id, entInfo.Dept.Id)
@@ -171,8 +171,9 @@ func (ac *Action) Distribute_persons() {
 func (ac *Action) Distribute_add() {
 	userId := qutil.ObjToString(ac.GetSession("userId"))
 	ent_id := qutil.IntAll(ac.GetSession("entId"))
-	entInfo := VarCurrentUser.EntInfo(userId, ent_id) //获取用户信息
-	dept_id := entInfo.Dept.Id                        //获取部门id
+	entUserId := qutil.IntAll(ac.GetSession("entUserId"))
+	entInfo := VarCurrentUser.EntInfo(ent_id, entUserId) //获取用户信息
+	dept_id := entInfo.Dept.Id                           //获取部门id
 	getdistribute := ac.Body()
 	distribute_ruleMap, distribute_rule := map[string]interface{}{}, map[string]interface{}{}
 	err := json.Unmarshal(getdistribute, &distribute_ruleMap)
@@ -233,9 +234,9 @@ func (ac *Action) Distribute_delete() {
 	if !R.CheckReqParam(ac.ResponseWriter, ac.Request, "id") {
 		return
 	}
-	userId, _ := ac.GetSession("userId").(string)
 	entId := qutil.IntAll(ac.GetSession("entId"))
-	deptId := VarCurrentUser.EntInfo(userId, entId).Dept.Id
+	entUserId := qutil.IntAll(ac.GetSession("entUserId"))
+	deptId := VarCurrentUser.EntInfo(entId, entUserId).Dept.Id
 	id := ac.GetString("id")
 	//分发规则状态    0--未删除  1--删除
 	bl := util.MQFW.Update(util.Entniche_distribute, bson.M{
@@ -291,10 +292,10 @@ func (ac *Action) Distribute_detail() {
 func (ac *Action) Distribute_update() {
 	status := 0
 	getupdate := ac.Body()
-	userId := qutil.ObjToString(ac.GetSession("userId"))
 	ent_id := qutil.IntAll(ac.GetSession("entId"))
-	entInfo := VarCurrentUser.EntInfo(userId, ent_id) //获取用户信息
-	dept_id := entInfo.Dept.Id                        //获取部门id
+	entUserId := qutil.IntAll(ac.GetSession("entUserId"))
+	entInfo := VarCurrentUser.EntInfo(ent_id, entUserId) //获取用户信息
+	dept_id := entInfo.Dept.Id                           //获取部门id
 	update_map := map[string]interface{}{}
 	distribute_rule := map[string]interface{}{}
 	err := json.Unmarshal(getupdate, &update_map)
@@ -357,7 +358,8 @@ func (ac *Action) Distribute_nodiff() {
 	status := 0
 	nodiff, _ := ac.GetInteger("nodiff")
 	ent_id := qutil.IntAll(ac.GetSession("entId"))
-	entInfo := VarCurrentUser.EntInfo(qutil.ObjToString(ac.GetSession("userId")), ent_id)
+	entUserId := qutil.IntAll(ac.GetSession("entUserId"))
+	entInfo := VarCurrentUser.EntInfo(ent_id, entUserId)
 	if VarDepartment.NoDiff(ent_id, entInfo.Dept.Id, nodiff) {
 		status = 1
 	}

+ 3 - 3
entniche/src/service/push/push.go

@@ -30,11 +30,11 @@ func (a *Action) List() {
 		formatTime = time.Unix(select_time, 0).Format("2006-01-02")
 	}
 	entId := util.IntAll(a.GetSession("entId"))
-	hasNextPage, list := jy.EntnichePush.Datas(MQFW, PushMysql, entId, util.IntAll(a.GetSession("entUserId")), pageNum, formatTime, area)
+	entUserId := util.IntAll(a.GetSession("entUserId"))
+	hasNextPage, list := jy.EntnichePush.Datas(MQFW, PushMysql, entId, entUserId, pageNum, formatTime, area)
 	subscribe := true
 	if area == "" && formatTime == "" && pageNum <= 1 {
-		userId, _ := a.GetSession("userId").(string)
-		if entInfo := VarCurrentUser.EntInfo(userId, entId); entInfo.Role_admin_system {
+		if entInfo := VarCurrentUser.EntInfo(entId, entUserId); entInfo.Role_admin_system {
 			if MQFW.Count("entniche_rule", map[string]interface{}{"i_entid": entId, "i_deptid": entInfo.Dept.Id}) == 0 {
 				subscribe = false
 			}

+ 66 - 51
entniche/src/service/subscribe/subscribe.go

@@ -37,7 +37,8 @@ type Action struct {
 func (ac *Action) Subscribe_index() error {
 	userId := qutil.ObjToString(ac.GetSession("userId"))
 	entId := qutil.IntAll(ac.GetSession("entId"))
-	entInfo := VarCurrentUser.EntInfo(userId, entId)
+	entUserId := qutil.IntAll(ac.GetSession("entUserId"))
+	entInfo := VarCurrentUser.EntInfo(entId, entUserId)
 	subscribe := map[string]interface{}{}
 	result := map[string]interface{}{
 		"model":  entInfo.Ent.Model,
@@ -135,7 +136,7 @@ func (ac *Action) Subscribe_index() error {
 		}
 	} else if model == 2 {
 		o_entniche, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
-			"i_userid": qutil.IntAll(ac.GetSession("entUserId")),
+			"i_userid": entUserId,
 			"i_entid":  entId,
 		})
 	}
@@ -204,20 +205,21 @@ func (ac *Action) Subscribe_index() error {
 
 //区域
 func (ac *Action) Get_area() error {
-	userId := qutil.ObjToString(ac.GetSession("userId"))
-	entInfo := VarCurrentUser.EntInfo(userId, qutil.IntAll(ac.GetSession("entId")))
+	entId := qutil.IntAll(ac.GetSession("entId"))
+	entUserId := qutil.IntAll(ac.GetSession("entUserId"))
+	entInfo := VarCurrentUser.EntInfo(entId, entUserId)
 	model := entInfo.Ent.Model //1-统一订阅 2-个人订阅
 	var res *map[string]interface{}
 	switch model {
 	case 1:
 		res, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
 			"i_deptid": entInfo.Dept.Id,
-			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+			"i_entid":  entId,
 		})
 	case 2:
 		res, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
-			"i_userid": qutil.IntAll(ac.GetSession("entUserId")),
-			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+			"i_userid": entUserId,
+			"i_entid":  entId,
 		})
 	}
 	if res == nil {
@@ -266,7 +268,9 @@ func (ac *Action) Update_area() {
 			return
 		}
 		after_arr, only_area_arr := []string{}, []string{}
-		entInfo := VarCurrentUser.EntInfo(qutil.ObjToString(ac.GetSession("userId")), qutil.IntAll(ac.GetSession("entId")))
+		entId := qutil.IntAll(ac.GetSession("entId"))
+		entUserId := qutil.IntAll(ac.GetSession("entUserId"))
+		entInfo := VarCurrentUser.EntInfo(entId, entUserId)
 		if len(area) > 0 {
 			for k, v := range area {
 				if len(v.([]interface{})) > 0 {
@@ -289,7 +293,7 @@ func (ac *Action) Update_area() {
 			distribute_area_map, distribute_area_new_map := map[string]interface{}{}, map[string]interface{}{}
 			list_items, _ := util.MQFW.Find(util.Entniche_distribute, map[string]interface{}{
 				"i_deptid": entInfo.Dept.Id,
-				"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+				"i_entid":  entId,
 				"i_status": 0,
 			}, nil, nil, false, -1, -1)
 			if len(*list_items) > 0 {
@@ -348,9 +352,10 @@ func (ac *Action) Update_area() {
 
 //行业
 func (ac *Action) Get_buyerclass() {
-	userId := qutil.ObjToString(ac.GetSession("userId"))
+	entId := qutil.IntAll(ac.GetSession("entId"))
+	entUserId := qutil.IntAll(ac.GetSession("entUserId"))
 	data := []string{}
-	entInfo := VarCurrentUser.EntInfo(userId, qutil.IntAll(ac.GetSession("entId")))
+	entInfo := VarCurrentUser.EntInfo(entId, entUserId)
 	model := entInfo.Ent.Model //1-统一订阅 2-个人订阅
 	//	res, ok := util.MQFW.FindById("user", userId, `{"o_entniche.a_buyerclass":1}`)
 	var res *map[string]interface{}
@@ -358,12 +363,12 @@ func (ac *Action) Get_buyerclass() {
 	case 1:
 		res, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
 			"i_deptid": entInfo.Dept.Id,
-			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+			"i_entid":  entId,
 		})
 	case 2:
 		res, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
-			"i_userid": qutil.IntAll(ac.GetSession("entUserId")),
-			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+			"i_userid": entUserId,
+			"i_entid":  entId,
 		})
 	}
 	if res == nil {
@@ -403,11 +408,13 @@ func (ac *Action) Update_buyerclass() {
 		if bl {
 			//分类名有分发规则
 			//			distribute_buyerclass := []string{}
-			entInfo := VarCurrentUser.EntInfo(qutil.ObjToString(ac.GetSession("userId")), qutil.IntAll(ac.GetSession("entId")))
+			entId := qutil.IntAll(ac.GetSession("entId"))
+			entUserId := qutil.IntAll(ac.GetSession("entUserId"))
+			entInfo := VarCurrentUser.EntInfo(entId, entUserId)
 			distribute_buyerclass_map, distribute_buyerclass_new_map := map[string]interface{}{}, map[string]interface{}{}
 			list_items, _ := util.MQFW.Find(util.Entniche_distribute, map[string]interface{}{
 				"i_deptid": entInfo.Dept.Id,
-				"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+				"i_entid":  entId,
 				"i_status": 0,
 			}, nil, nil, false, -1, -1)
 			if len(*list_items) > 0 {
@@ -446,8 +453,9 @@ func (ac *Action) Update_buyerclass() {
 //信息类型
 func (ac *Action) Get_infotype() {
 	data := []string{}
-	userId := qutil.ObjToString(ac.GetSession("userId"))
-	entInfo := VarCurrentUser.EntInfo(userId, qutil.IntAll(ac.GetSession("entId")))
+	entId := qutil.IntAll(ac.GetSession("entId"))
+	entUserId := qutil.IntAll(ac.GetSession("entUserId"))
+	entInfo := VarCurrentUser.EntInfo(entId, entUserId)
 	model := entInfo.Ent.Model //1-统一订阅 2-个人订阅
 	//	res, ok := util.MQFW.FindById("user", userId, `{"o_entniche.a_infotype":1}`)
 	var res *map[string]interface{}
@@ -455,12 +463,12 @@ func (ac *Action) Get_infotype() {
 	case 1:
 		res, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
 			"i_deptid": entInfo.Dept.Id,
-			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+			"i_entid":  entId,
 		})
 	case 2:
 		res, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
-			"i_userid": qutil.IntAll(ac.GetSession("entUserId")),
-			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+			"i_userid": entUserId,
+			"i_entid":  entId,
 		})
 	}
 	if len(*res) == 0 || res == nil {
@@ -517,19 +525,21 @@ func (ac *Action) Get_key() {
 	}
 	delete(*res, "_id")
 	//查看是否使用过快速导入
-	entInfo := VarCurrentUser.EntInfo(userId, qutil.IntAll(ac.GetSession("entId")))
+	entId := qutil.IntAll(ac.GetSession("entId"))
+	entUserId := qutil.IntAll(ac.GetSession("entUserId"))
+	entInfo := VarCurrentUser.EntInfo(entId, entUserId)
 	model := entInfo.Ent.Model //1-统一订阅 2-个人订阅
 	var res_ *map[string]interface{}
 	switch model {
 	case 1:
 		res_, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
 			"i_deptid": entInfo.Dept.Id,
-			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+			"i_entid":  entId,
 		})
 	case 2:
 		res_, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
-			"i_userid": qutil.IntAll(ac.GetSession("entUserId")),
-			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+			"i_userid": entUserId,
+			"i_entid":  entId,
 		})
 	}
 	if res_ == nil {
@@ -577,9 +587,9 @@ func (ac *Action) Get_key() {
 
 //关键词{"_id" : ObjectId("5e69cd765484c8457bf06006")}
 func (ac *Action) Update_key() {
-	userId := qutil.ObjToString(ac.GetSession("userId"))
 	entId := qutil.IntAll(ac.GetSession("entId"))
-	entInfo := VarCurrentUser.EntInfo(userId, entId)
+	entUserId := qutil.IntAll(ac.GetSession("entUserId"))
+	entInfo := VarCurrentUser.EntInfo(entId, entUserId)
 	status := 0 //0:失败,1:成功,-1:分类名重复,-2:关联有分发规则,不能删除
 	keywords := map[string]interface{}{}
 	distribute_item_map := map[string]interface{}{} //用来计算规则顺序
@@ -684,19 +694,21 @@ func (ac *Action) Get_fastimport() {
 	a := map[string]int{}  //分类 位置
 	b := map[string]bool{} //关键词
 	//从entniche_rule中获取o_entniche
-	entInfo := VarCurrentUser.EntInfo(userId, qutil.IntAll(ac.GetSession("entId")))
+	entId := qutil.IntAll(ac.GetSession("entId"))
+	entUserId := qutil.IntAll(ac.GetSession("entUserId"))
+	entInfo := VarCurrentUser.EntInfo(entId, entUserId)
 	model := entInfo.Ent.Model //1-统一订阅 2-个人订阅
 	var res_ *map[string]interface{}
 	switch model {
 	case 1:
 		res_, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
 			"i_deptid": entInfo.Dept.Id,
-			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+			"i_entid":  entId,
 		})
 	case 2:
 		res_, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
-			"i_userid": qutil.IntAll(ac.GetSession("entUserId")),
-			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+			"i_userid": entUserId,
+			"i_entid":  entId,
 		})
 	}
 	if res_ == nil {
@@ -859,7 +871,7 @@ func (ac *Action) Get_fastimport() {
 		if model == 1 {
 			bl = util.MQFW.Update("entniche_rule", bson.M{
 				"i_deptid": entInfo.Dept.Id,
-				"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+				"i_entid":  entId,
 			}, bson.M{
 				"$set": bson.M{
 					"o_entniche.a_items":          b_items_ent,
@@ -869,8 +881,8 @@ func (ac *Action) Get_fastimport() {
 			}, true, false)
 		} else if model == 2 {
 			bl = util.MQFW.Update("entniche_rule", bson.M{
-				"i_userid": qutil.IntAll(ac.GetSession("entUserId")),
-				"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+				"i_userid": entUserId,
+				"i_entid":  entId,
 			}, bson.M{
 				"$set": bson.M{
 					"o_entniche.a_items":          b_items_ent,
@@ -902,21 +914,22 @@ func (ac *Action) Update_projectmatch() {
 //推送设置
 func (ac *Action) Get_pushset() {
 	data := map[string]interface{}{}
-	userId := qutil.ObjToString(ac.GetSession("userId"))
+	entId := qutil.IntAll(ac.GetSession("entId"))
+	entUserId := qutil.IntAll(ac.GetSession("entUserId"))
 	//	res, ok := util.MQFW.FindById("user", userId, `{"o_entniche.i_ratemode":1,"o_entniche.i_apppush":1,"o_entniche.i_mailpush":1,"o_entniche.i_matchway":1}`)
-	entInfo := VarCurrentUser.EntInfo(userId, qutil.IntAll(ac.GetSession("entId")))
+	entInfo := VarCurrentUser.EntInfo(entId, entUserId)
 	model := entInfo.Ent.Model //1-统一订阅 2-个人订阅
 	var res *map[string]interface{}
 	switch model {
 	case 1:
 		res, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
 			"i_deptid": entInfo.Dept.Id,
-			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+			"i_entid":  entId,
 		})
 	case 2:
 		res, _ = util.MQFW.FindOne("entniche_rule", map[string]interface{}{
-			"i_userid": qutil.IntAll(ac.GetSession("entUserId")),
-			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+			"i_userid": entUserId,
+			"i_entid":  entId,
 		})
 	}
 	if res == nil {
@@ -938,8 +951,9 @@ func (ac *Action) Get_pushset() {
 //推送设置
 func (ac *Action) Update_pushset() {
 	bl := false
-	userId := qutil.ObjToString(ac.GetSession("userId"))
-	entInfo := VarCurrentUser.EntInfo(userId, qutil.IntAll(ac.GetSession("entId")))
+	entId := qutil.IntAll(ac.GetSession("entId"))
+	entUserId := qutil.IntAll(ac.GetSession("entUserId"))
+	entInfo := VarCurrentUser.EntInfo(entId, entUserId)
 	model := entInfo.Ent.Model //1-统一订阅 2-个人订阅
 	status := 0
 	ratemode, _ := ac.GetInteger("ratemode")
@@ -950,7 +964,7 @@ func (ac *Action) Update_pushset() {
 	case 1:
 		bl = util.MQFW.Update("entniche_rule", bson.M{
 			"i_deptid": entInfo.Dept.Id,
-			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+			"i_entid":  entId,
 		}, bson.M{"$set": bson.M{
 			"l_updatetime":          time.Now().Unix(),
 			`o_entniche.i_ratemode`: ratemode,
@@ -960,8 +974,8 @@ func (ac *Action) Update_pushset() {
 		}}, true, false)
 	case 2:
 		bl = util.MQFW.Update("entniche_rule", bson.M{
-			"i_userid": qutil.IntAll(ac.GetSession("entUserId")),
-			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+			"i_userid": entUserId,
+			"i_entid":  entId,
 		}, bson.M{"$set": bson.M{
 			"l_updatetime":          time.Now().Unix(),
 			`o_entniche.i_ratemode`: ratemode,
@@ -983,8 +997,8 @@ func (ac *Action) Subscribe_subdis() {
 	}
 	subdis, _ := ac.GetInteger("subdis")
 	ent_id := qutil.IntAll(ac.GetSession("entId"))
-	userId := qutil.ObjToString(ac.GetSession("userId"))
-	entInfo := VarCurrentUser.EntInfo(userId, ent_id)
+	entUserId := qutil.IntAll(ac.GetSession("entUserId"))
+	entInfo := VarCurrentUser.EntInfo(ent_id, entUserId)
 	status := 0
 	if VarDepartment.SubDis(ent_id, entInfo.Dept.Id, subdis) {
 		status = 1
@@ -1059,22 +1073,23 @@ func ReplaceValues(slice []string, before, after string) []string {
 //修改或新增 entniche_rule 表的 entinfo 信息   parameter_name参数名  parameter参数
 func (ac *Action) updateEntnicheRule(parameter_name string, parameter interface{}) bool {
 	bl := false
-	userId := qutil.ObjToString(ac.GetSession("userId"))
-	entInfo := VarCurrentUser.EntInfo(userId, qutil.IntAll(ac.GetSession("entId")))
+	entId := qutil.IntAll(ac.GetSession("entId"))
+	entUserId := qutil.IntAll(ac.GetSession("entUserId"))
+	entInfo := VarCurrentUser.EntInfo(entId, entUserId)
 	model := entInfo.Ent.Model //1-统一订阅(i_deptid i_entid) 2-个人订阅(i_userid i_entid)
 	switch model {
 	case 1:
 		bl = util.MQFW.Update("entniche_rule", bson.M{
 			"i_deptid": entInfo.Dept.Id,
-			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+			"i_entid":  entId,
 		}, bson.M{"$set": bson.M{
 			"l_updatetime":                 time.Now().Unix(),
 			"o_entniche." + parameter_name: parameter,
 		}}, true, false)
 	case 2:
 		bl = util.MQFW.Update("entniche_rule", bson.M{
-			"i_userid": qutil.IntAll(ac.GetSession("entUserId")),
-			"i_entid":  qutil.IntAll(ac.GetSession("entId")),
+			"i_userid": entUserId,
+			"i_entid":  entId,
 		}, bson.M{"$set": bson.M{
 			"l_updatetime":                 time.Now().Unix(),
 			"o_entniche." + parameter_name: parameter,

+ 2 - 2
nicheinsight/src/service/ent/ent.go

@@ -45,10 +45,10 @@ func (a *Action) Myents() {
 
 //企业信息
 func (a *Action) Entinfo() {
-	userId, _ := a.GetSession("userId").(string)
 	entName, _ := a.GetSession("nicheinsight_entname").(string)
 	entId := qutil.IntAll(a.GetSession("nicheinsight_entid"))
-	entInfo := VarCurrentUser.EntInfo(userId, entId)
+	entUserId := qutil.IntAll(a.GetSession("nicheinsight_userid"))
+	entInfo := VarCurrentUser.EntInfo(entId, entUserId)
 	a.ServeJson(Result{Data: M{
 		"ent_name":         entName,
 		"dept_id":          entInfo.Dept.Id,

+ 6 - 10
public/src/ent/entity/entity.go

@@ -37,17 +37,13 @@ func (c *CurrentUser) Phone(userId string) (string, string) {
 }
 
 //当前登录用户的信息
-func (c *CurrentUser) EntInfo(userId string, entId int) *CurrentUser {
+func (c *CurrentUser) EntInfo(entId, entUserId int) *CurrentUser {
 	currentUser := &CurrentUser{
 		Ent:  &EntInfo{},
 		Dept: &Department{},
 	}
-	phone, _ := c.Phone(userId)
-	if phone == "" {
-		return currentUser
-	}
 	currentUser.Ent = VarEntInfo.GetById(entId)
-	user := Mysql.SelectBySql(`SELECT a.name as user_name from entniche_user a INNER JOIN entniche_user_role b on (a.id=b.user_id) where a.phone=? and a.ent_id=? and b.role_id=? limit 1`, phone, entId, Role_admin_system)
+	user := Mysql.SelectBySql(`SELECT a.name as user_name from entniche_user a INNER JOIN entniche_user_role b on (a.id=b.user_id) where a.id=? and b.role_id=? limit 1`, entUserId, Role_admin_system)
 	if user != nil && len(*user) > 0 {
 		currentUser.Role_admin_system = true
 		currentUser.User_name, _ = (*user)[0]["user_name"].(string)
@@ -63,11 +59,11 @@ func (c *CurrentUser) EntInfo(userId string, entId int) *CurrentUser {
 	} else {
 		//角色、权限
 		r := Mysql.SelectBySql(`SELECT a.name as user_name,a.power as user_power,b.role_id,d.id as dept_id,d.name as dept_name,d.subdis as dept_subdis,d.nodiff as dept_nodiff,e.id as dept_pid from entniche_user a 
-			LEFT JOIN entniche_user_role b on (a.id=b.user_id) 
-			INNER JOIN entniche_department_user c on (a.ent_id=? and a.phone=? and a.id=c.user_id) 
-			INNER JOIN entniche_department d on (d.ent_id=? and c.dept_id=d.id) 
+			LEFT JOIN entniche_user_role b on (b.user_id=?) 
+			INNER JOIN entniche_department_user c on (a.id=? and a.id=c.user_id) 
+			INNER JOIN entniche_department d on (c.dept_id=d.id) 
 			INNER JOIN entniche_department e on (e.ent_id=? and e.pid=0) 
-			order by a.id desc limit 1`, entId, phone, entId, entId)
+			order by a.id desc limit 1`, entUserId, entUserId, entId)
 		if r != nil && len(*r) == 1 {
 			currentUser.User_name, _ = (*r)[0]["user_name"].(string)
 			currentUser.User_power = qutil.IntAll((*r)[0]["user_power"])