|
@@ -54,38 +54,37 @@ func Distributor(region []string, entId, entUserId int) []*User {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
var rule_id string
|
|
var rule_id string
|
|
- var deptNo bool
|
|
|
|
//有区域限制 过滤筛选
|
|
//有区域限制 过滤筛选
|
|
rules := IC.MainMysql.Find("entniche_user_rule", map[string]interface{}{"user_id": v.Id}, "rule_id,dept_id", "", -1, -1)
|
|
rules := IC.MainMysql.Find("entniche_user_rule", map[string]interface{}{"user_id": v.Id}, "rule_id,dept_id", "", -1, -1)
|
|
if rules != nil && len(*rules) > 0 {
|
|
if rules != nil && len(*rules) > 0 {
|
|
if len(*rules) > 1 { //多条规则 查询优先级最高的规则
|
|
if len(*rules) > 1 { //多条规则 查询优先级最高的规则
|
|
|
|
+ ruleIds := make(map[int]string)
|
|
|
|
+ for _, v2 := range *rules {
|
|
|
|
+ ruleIds[common.IntAll(v2["dept_id"])] = common.InterfaceToStr(v2["rule_id"])
|
|
|
|
+ }
|
|
//获取部门优先级
|
|
//获取部门优先级
|
|
var ids []int
|
|
var ids []int
|
|
departSort(&ids, v.Dept_id)
|
|
departSort(&ids, v.Dept_id)
|
|
ids = append(ids, v.Dept_id)
|
|
ids = append(ids, v.Dept_id)
|
|
//Reverse(&ids)
|
|
//Reverse(&ids)
|
|
for _, v1 := range ids {
|
|
for _, v1 := range ids {
|
|
- for _, v2 := range *rules {
|
|
|
|
- if v1 == common.IntAll(v2["dept_id"]) {
|
|
|
|
- deptNo = true
|
|
|
|
- rule_id = common.InterfaceToStr(v2["rule_id"])
|
|
|
|
- break
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if deptNo {
|
|
|
|
|
|
+ if v2, ok := ruleIds[v1]; ok && v2 != "" {
|
|
|
|
+ rule_id = v2
|
|
break
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
rule_id = common.InterfaceToStr((*rules)[0]["rule_id"])
|
|
rule_id = common.InterfaceToStr((*rules)[0]["rule_id"])
|
|
}
|
|
}
|
|
- data, ok := IC.Mgo.FindById("entniche_distribute", rule_id, "")
|
|
|
|
- if ok && data != nil && len(*data) > 0 {
|
|
|
|
- o_area, _ := (*data)["o_area"].(map[string]interface{})
|
|
|
|
- if regionCheck(o_area, regions) {
|
|
|
|
- ss = append(ss, v)
|
|
|
|
|
|
+ if rule_id != "" {
|
|
|
|
+ data, ok := IC.Mgo.FindById("entniche_distribute", rule_id, "")
|
|
|
|
+ if ok && data != nil && len(*data) > 0 {
|
|
|
|
+ o_area, _ := (*data)["o_area"].(map[string]interface{})
|
|
|
|
+ if regionCheck(o_area, regions) {
|
|
|
|
+ ss = append(ss, v)
|
|
|
|
+ }
|
|
|
|
+ continue //企业设置分发区域
|
|
}
|
|
}
|
|
- continue //企业设置分发区域
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if isEnt && v.Power == 1 { // 企业未分配规则 商机管理用户查询个人
|
|
if isEnt && v.Power == 1 { // 企业未分配规则 商机管理用户查询个人
|