|
@@ -112,6 +112,79 @@ func getQueryParams(condition string, pars []interface{}, sysUser *system.Admin,
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// getQueryParams 获取基础查询信息(最开始关联的销售信息)
|
|
|
+func getQueryParamsInit(condition string, pars []interface{}, sysUser *system.Admin, tableAlias string) (newCondition string, newPars []interface{}) {
|
|
|
+ if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN {
|
|
|
+ condition += " AND " + tableAlias + "product_id=?"
|
|
|
+ pars = append(pars, 1)
|
|
|
+ } else if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_ADMIN {
|
|
|
+ condition += " AND " + tableAlias + "product_id=?"
|
|
|
+ pars = append(pars, 2)
|
|
|
+ } else if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_ADMIN || sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FINANCE {
|
|
|
+ //超级管理员账户,不做条件限制
|
|
|
+ } else {
|
|
|
+ //如果不是研究员,那么去找对应的 部门、小组、销售
|
|
|
+ if sysUser.Authority == 0 {
|
|
|
+ //普通用户
|
|
|
+ condition += " AND " + tableAlias + "seller_id_init=?"
|
|
|
+ pars = append(pars, sysUser.AdminId)
|
|
|
+ } else if sysUser.Authority == 1 {
|
|
|
+ //部门主管
|
|
|
+ condition += " AND " + tableAlias + "department_id=?"
|
|
|
+ pars = append(pars, sysUser.DepartmentId)
|
|
|
+ } else if sysUser.Authority == 2 && sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_GROUP {
|
|
|
+ //权益小组负责人
|
|
|
+ condition += " AND " + tableAlias + "group_id=?"
|
|
|
+ pars = append(pars, sysUser.GroupId)
|
|
|
+ } else if sysUser.Authority == 2 && sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_GROUP {
|
|
|
+ //ficc销售主管
|
|
|
+ pid, err := company.GetParentIdFromGroup(sysUser.GroupId)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var ids []*string
|
|
|
+ if pid != nil && *pid != 0 {
|
|
|
+ ids, err = company.GetGroupIdsByParentId(*pid)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err.Error())
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ ids, err = company.GetGroupIdsByParentId(sysUser.GroupId)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err.Error())
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var idSlice []string
|
|
|
+ var sid string
|
|
|
+ for _, id := range ids {
|
|
|
+ idSlice = append(idSlice, *id)
|
|
|
+ }
|
|
|
+ //加入父级groupId
|
|
|
+ if *pid > 0 {
|
|
|
+ idSlice = append(idSlice, strconv.Itoa(*pid))
|
|
|
+ } else {
|
|
|
+ idSlice = append(idSlice, strconv.Itoa(sysUser.GroupId))
|
|
|
+ }
|
|
|
+ sid = strings.Join(idSlice, ",")
|
|
|
+ condition += " AND " + tableAlias + `group_id IN (` + sid + `) `
|
|
|
+ fmt.Println("condition:", condition)
|
|
|
+ //pars = append(pars, sysUser.GroupId)
|
|
|
+ } else if sysUser.Authority == 4 {
|
|
|
+ //ficc小组负责人
|
|
|
+ condition += " AND " + tableAlias + "group_id=?"
|
|
|
+ pars = append(pars, sysUser.GroupId)
|
|
|
+ } else {
|
|
|
+ //不知道什么类型的用户(后面新增的位置类型客户)
|
|
|
+ condition += " AND " + tableAlias + "seller_id_init=?"
|
|
|
+ pars = append(pars, sysUser.AdminId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ newCondition = condition
|
|
|
+ newPars = pars
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
// Home
|
|
|
// @Title 获取首页工作台数据
|
|
|
// @Description 获取首页工作台数据接口
|
|
@@ -6835,7 +6908,7 @@ func getTodayStackCompanyListV2Rai(sysUser *system.Admin, currentIndex, pageSize
|
|
|
//pars = append(pars, adminId)
|
|
|
} else {
|
|
|
//根据当前角色来获取查询条件
|
|
|
- condition, pars = getQueryParams(condition, pars, sysUser, "c.")
|
|
|
+ condition, pars = getQueryParamsInit(condition, pars, sysUser, "c.")
|
|
|
|
|
|
}
|
|
|
if regionType != "" {
|