|
@@ -0,0 +1,2190 @@
|
|
|
+package controllers
|
|
|
+
|
|
|
+import (
|
|
|
+ "eta/eta_forum_admin/models"
|
|
|
+ "eta/eta_forum_admin/models/company"
|
|
|
+ "eta/eta_forum_admin/models/system"
|
|
|
+ "eta/eta_forum_admin/services"
|
|
|
+ "eta/eta_forum_admin/utils"
|
|
|
+ "fmt"
|
|
|
+ "strconv"
|
|
|
+)
|
|
|
+
|
|
|
+
|
|
|
+type CompanySellerController struct {
|
|
|
+ BaseAuthController
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func (this *CompanySellerController) RoadshowFiccList() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ if br.ErrMsg == "" {
|
|
|
+ br.IsSendEmail = false
|
|
|
+ }
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+ sysUser := this.SysUser
|
|
|
+ if sysUser == nil {
|
|
|
+ br.Msg = "请登录"
|
|
|
+ br.ErrMsg = "请登录,SysUser Is Empty"
|
|
|
+ br.Ret = 408
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ resp := new(system.RoadshowGroupResp)
|
|
|
+ productId := services.GetProductId(sysUser.RoleTypeCode)
|
|
|
+ if productId == utils.COMPANY_PRODUCT_RAI_ID {
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "获取成功"
|
|
|
+ br.Data = resp
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ departmentId := 2
|
|
|
+ groups, e := system.GetGroupByDepartmentId(departmentId)
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取FICC分组失败, Err: " + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ teamGroupId := make(map[int]int, 0)
|
|
|
+ var list []system.RoadshowGroups
|
|
|
+ for _, g := range groups {
|
|
|
+ if g.ParentId > 0 {
|
|
|
+ teamGroupId[g.GroupId] = g.ParentId
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ list = append(list, system.RoadshowGroups{
|
|
|
+ GroupId: g.GroupId,
|
|
|
+ GroupName: g.GroupName,
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ roleArr := []string{
|
|
|
+ utils.ROLE_TYPE_CODE_FICC_ADMIN, utils.ROLE_TYPE_CODE_FICC_DEPARTMENT, utils.ROLE_TYPE_CODE_FICC_GROUP,
|
|
|
+ utils.ROLE_TYPE_CODE_FICC_TEAM, utils.ROLE_TYPE_CODE_FICC_SELLER,
|
|
|
+ }
|
|
|
+ cond := fmt.Sprintf(` AND role_type_code IN (%s) AND enabled = 1`, utils.GetOrmInReplace(len(roleArr)))
|
|
|
+ pars := make([]interface{}, 0)
|
|
|
+ pars = append(pars, roleArr)
|
|
|
+ sellers, e := system.GetSysUserItemsOrderByCreated(cond, pars)
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取FICC销售失败, Err: " + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ groupIdChild := make(map[int][]system.RoadshowGroupSellers)
|
|
|
+ for _, s := range sellers {
|
|
|
+ var seller system.RoadshowGroupSellers
|
|
|
+ seller.AdminId = s.AdminId
|
|
|
+ seller.AdminName = s.RealName
|
|
|
+
|
|
|
+ gid := teamGroupId[s.GroupId]
|
|
|
+ if gid > 0 {
|
|
|
+
|
|
|
+ seller.GroupId = gid
|
|
|
+ seller.TeamId = s.GroupId
|
|
|
+ } else {
|
|
|
+
|
|
|
+ seller.GroupId = s.GroupId
|
|
|
+ }
|
|
|
+ groupIdChild[seller.GroupId] = append(groupIdChild[seller.GroupId], seller)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ for _, v := range list {
|
|
|
+
|
|
|
+ if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_GROUP || sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_TEAM || sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_SELLER {
|
|
|
+ if sysUser.GroupId != v.GroupId && teamGroupId[sysUser.GroupId] != v.GroupId {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ }
|
|
|
+ child := groupIdChild[v.GroupId]
|
|
|
+
|
|
|
+
|
|
|
+ if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_TEAM {
|
|
|
+ var team []system.RoadshowGroupSellers
|
|
|
+ for _, c := range child {
|
|
|
+ if c.TeamId == sysUser.GroupId {
|
|
|
+ team = append(team, c)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ v.Child = team
|
|
|
+ resp.List = append(resp.List, v)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_SELLER {
|
|
|
+ var self []system.RoadshowGroupSellers
|
|
|
+ for _, c := range child {
|
|
|
+ if c.AdminId == sysUser.AdminId {
|
|
|
+ self = append(self, c)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ v.Child = self
|
|
|
+ resp.List = append(resp.List, v)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ v.Child = child
|
|
|
+ resp.List = append(resp.List, v)
|
|
|
+ }
|
|
|
+
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "获取成功"
|
|
|
+ br.Data = resp
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func (this *CompanySellerController) CompanyQCCSearch() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+ sysUser := this.SysUser
|
|
|
+ if sysUser == nil {
|
|
|
+ br.Msg = "请登录"
|
|
|
+ br.ErrMsg = "请登录,SysUser Is Empty"
|
|
|
+ br.Ret = 408
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var err error
|
|
|
+ var results []services.Result
|
|
|
+ keyWord := this.GetString("KeyWord")
|
|
|
+ if keyWord != "" {
|
|
|
+ results, err = services.QCCFuzzySearch(keyWord)
|
|
|
+ if err != nil {
|
|
|
+ br.Data = results
|
|
|
+ br.Msg = "获取数据失败," + err.Error()
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ br.Data = results
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "获取成功"
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func (this *CompanySellerController) CheckListV2() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+ sysUser := this.SysUser
|
|
|
+ if sysUser == nil {
|
|
|
+ br.Msg = "请登录"
|
|
|
+ br.ErrMsg = "请登录,SysUser Is Empty"
|
|
|
+ br.Ret = 408
|
|
|
+ return
|
|
|
+ }
|
|
|
+ roleCodeTypeStr := ``
|
|
|
+ productId := services.GetProductId(sysUser.RoleTypeCode)
|
|
|
+ switch productId {
|
|
|
+ case 1:
|
|
|
+ roleCodeTypeStr = `"` + utils.ROLE_TYPE_CODE_FICC_SELLER + `","` + utils.ROLE_TYPE_CODE_FICC_GROUP + `","` + utils.ROLE_TYPE_CODE_FICC_TEAM + `"`
|
|
|
+ case 2:
|
|
|
+ roleCodeTypeStr = `"` + utils.ROLE_TYPE_CODE_RAI_SELLER + `","` + utils.ROLE_TYPE_CODE_RAI_GROUP + `"`
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN {
|
|
|
+ roleCodeTypeStr = ``
|
|
|
+ } else if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_ADMIN {
|
|
|
+
|
|
|
+ roleCodeTypeStr = `"` + utils.ROLE_TYPE_CODE_RAI_SELLER + `","` + utils.ROLE_TYPE_CODE_RAI_GROUP + `","` + utils.ROLE_TYPE_CODE_RAI_RESEARCHR + `","` + utils.ROLE_TYPE_CODE_RAI_ADMIN + `"`
|
|
|
+ }
|
|
|
+
|
|
|
+ getAllSeller, _ := this.GetBool("AllSeller", false)
|
|
|
+ getAllUser, _ := this.GetBool("AllUser", false)
|
|
|
+ status, _ := this.GetInt("Status", 0)
|
|
|
+ getAllEnabled, _ := this.GetBool("AllEnabled", false)
|
|
|
+ enabled := -1
|
|
|
+ if getAllEnabled {
|
|
|
+ enabled = -1
|
|
|
+ }
|
|
|
+ list := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ if getAllUser {
|
|
|
+ departmentList, err := system.GetDepartmentList()
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取部门失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, department := range departmentList {
|
|
|
+ departmentGroupSellerList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ item := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint("department_", department.DepartmentId),
|
|
|
+
|
|
|
+ RealName: department.DepartmentName,
|
|
|
+ ChildrenList: departmentGroupSellerList,
|
|
|
+ }
|
|
|
+
|
|
|
+ groupList, err := system.GetSysGroupByDepartmentId(department.DepartmentId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取分组失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, group := range groupList {
|
|
|
+ groupSellerList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ groupItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint("group_", group.DepartmentId),
|
|
|
+
|
|
|
+ RealName: group.GroupName,
|
|
|
+ ChildrenList: groupSellerList,
|
|
|
+ }
|
|
|
+ teamList, err := system.GetSysTeamByDepartmentId(group.GroupId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取小组失败"
|
|
|
+ br.ErrMsg = "获取小组失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, team := range teamList {
|
|
|
+ teamSellerList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ teamItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint("team_", team.GroupId),
|
|
|
+
|
|
|
+ RealName: team.GroupName,
|
|
|
+ ChildrenList: teamSellerList,
|
|
|
+ }
|
|
|
+ sellerList, err := system.GetTeamSysUserList(team.GroupId, enabled)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取销售失败"
|
|
|
+ br.ErrMsg = "获取销售失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, seller := range sellerList {
|
|
|
+ sellerItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint(seller.AdminId),
|
|
|
+
|
|
|
+ RealName: seller.RealName,
|
|
|
+ Authority: seller.Authority,
|
|
|
+ RoleTypeCode: seller.RoleTypeCode,
|
|
|
+ }
|
|
|
+
|
|
|
+ teamSellerList = append(teamSellerList, sellerItem)
|
|
|
+ }
|
|
|
+ teamSellerList = sortDepartmentGroupSellers(teamSellerList)
|
|
|
+ teamItem.ChildrenList = teamSellerList
|
|
|
+ if len(teamSellerList) > 0 {
|
|
|
+ groupSellerList = append(groupSellerList, teamItem)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ groupTeamSellerList, err := system.GetGrooupsysUserList(group.GroupId, roleCodeTypeStr, enabled)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取销售失败"
|
|
|
+ br.ErrMsg = "获取销售失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(groupTeamSellerList) > 0 {
|
|
|
+ tmpDepartmentGroupSellersList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ for _, seller := range groupTeamSellerList {
|
|
|
+ sellerItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint(seller.AdminId),
|
|
|
+
|
|
|
+ RealName: seller.RealName,
|
|
|
+ Authority: seller.Authority,
|
|
|
+ RoleTypeCode: seller.RoleTypeCode,
|
|
|
+ }
|
|
|
+ tmpDepartmentGroupSellersList = append(tmpDepartmentGroupSellersList, sellerItem)
|
|
|
+ }
|
|
|
+
|
|
|
+ tmpDepartmentGroupSellersList = sortDepartmentGroupSellers(tmpDepartmentGroupSellersList)
|
|
|
+ groupSellerList = append(groupSellerList, tmpDepartmentGroupSellersList...)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ groupItem.ChildrenList = groupSellerList
|
|
|
+ if len(groupSellerList) > 0 {
|
|
|
+ departmentGroupSellerList = append(departmentGroupSellerList, groupItem)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ departmentSellerList, err := system.GetDepartmentGroupSysUserList(department.DepartmentId, 0, roleCodeTypeStr)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取销售失败"
|
|
|
+ br.ErrMsg = "获取销售失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(departmentSellerList) > 0 {
|
|
|
+ tmpDepartmentGroupSellersList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ for _, seller := range departmentSellerList {
|
|
|
+ sellerItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint(seller.AdminId),
|
|
|
+
|
|
|
+ RealName: seller.RealName,
|
|
|
+ Authority: seller.Authority,
|
|
|
+ RoleTypeCode: seller.RoleTypeCode,
|
|
|
+ }
|
|
|
+ tmpDepartmentGroupSellersList = append(tmpDepartmentGroupSellersList, sellerItem)
|
|
|
+ }
|
|
|
+
|
|
|
+ tmpDepartmentGroupSellersList = sortDepartmentGroupSellers(tmpDepartmentGroupSellersList)
|
|
|
+ departmentGroupSellerList = append(departmentGroupSellerList, tmpDepartmentGroupSellersList...)
|
|
|
+ }
|
|
|
+
|
|
|
+ item.ChildrenList = departmentGroupSellerList
|
|
|
+ if len(departmentGroupSellerList) > 0 {
|
|
|
+ list = append(list, item)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "获取成功"
|
|
|
+ br.Data = company.DepartmentGroupSellersResp{
|
|
|
+ List: list,
|
|
|
+ }
|
|
|
+
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if getAllSeller == false {
|
|
|
+
|
|
|
+ if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_ADMIN {
|
|
|
+ departmentList, err := system.GetDepartmentList()
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取部门失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, department := range departmentList {
|
|
|
+ departmentGroupSellerList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ item := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint("department_", department.DepartmentId),
|
|
|
+
|
|
|
+ RealName: department.DepartmentName,
|
|
|
+ ChildrenList: departmentGroupSellerList,
|
|
|
+ }
|
|
|
+
|
|
|
+ groupList, err := system.GetSysGroupByDepartmentId(department.DepartmentId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取分组失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, group := range groupList {
|
|
|
+ groupSellerList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ groupItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint("group_", group.DepartmentId),
|
|
|
+
|
|
|
+ RealName: group.GroupName,
|
|
|
+ ChildrenList: groupSellerList,
|
|
|
+ }
|
|
|
+ teamList, err := system.GetSysTeamByDepartmentId(group.GroupId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取小组失败"
|
|
|
+ br.ErrMsg = "获取小组失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, team := range teamList {
|
|
|
+ teamSellerList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ teamItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint("team_", team.GroupId),
|
|
|
+
|
|
|
+ RealName: team.GroupName,
|
|
|
+ ChildrenList: teamSellerList,
|
|
|
+ }
|
|
|
+ sellerList, err := system.GetTeamSysUserList(team.GroupId, enabled)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取销售失败"
|
|
|
+ br.ErrMsg = "获取销售失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, seller := range sellerList {
|
|
|
+ sellerItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint(seller.AdminId),
|
|
|
+
|
|
|
+ RealName: seller.RealName,
|
|
|
+ Authority: seller.Authority,
|
|
|
+ RoleTypeCode: seller.RoleTypeCode,
|
|
|
+ }
|
|
|
+
|
|
|
+ teamSellerList = append(teamSellerList, sellerItem)
|
|
|
+ }
|
|
|
+ teamSellerList = sortDepartmentGroupSellers(teamSellerList)
|
|
|
+ teamItem.ChildrenList = teamSellerList
|
|
|
+ if len(teamSellerList) > 0 {
|
|
|
+ groupSellerList = append(groupSellerList, teamItem)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ groupTeamSellerList, err := system.GetGrooupsysUserList(group.GroupId, roleCodeTypeStr, enabled)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取销售失败"
|
|
|
+ br.ErrMsg = "获取销售失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(groupTeamSellerList) > 0 {
|
|
|
+ tmpDepartmentGroupSellersList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ for _, seller := range groupTeamSellerList {
|
|
|
+ sellerItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint(seller.AdminId),
|
|
|
+
|
|
|
+ RealName: seller.RealName,
|
|
|
+ Authority: seller.Authority,
|
|
|
+ RoleTypeCode: seller.RoleTypeCode,
|
|
|
+ }
|
|
|
+ tmpDepartmentGroupSellersList = append(tmpDepartmentGroupSellersList, sellerItem)
|
|
|
+ }
|
|
|
+
|
|
|
+ tmpDepartmentGroupSellersList = sortDepartmentGroupSellers(tmpDepartmentGroupSellersList)
|
|
|
+ groupSellerList = append(groupSellerList, tmpDepartmentGroupSellersList...)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ groupItem.ChildrenList = groupSellerList
|
|
|
+ if len(groupSellerList) > 0 {
|
|
|
+ departmentGroupSellerList = append(departmentGroupSellerList, groupItem)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ departmentSellerList, err := system.GetDepartmentGroupSysUserList(department.DepartmentId, 0, roleCodeTypeStr)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取销售失败"
|
|
|
+ br.ErrMsg = "获取销售失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(departmentSellerList) > 0 {
|
|
|
+ tmpDepartmentGroupSellersList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ for _, seller := range departmentSellerList {
|
|
|
+ sellerItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint(seller.AdminId),
|
|
|
+
|
|
|
+ RealName: seller.RealName,
|
|
|
+ Authority: seller.Authority,
|
|
|
+ RoleTypeCode: seller.RoleTypeCode,
|
|
|
+ }
|
|
|
+ tmpDepartmentGroupSellersList = append(tmpDepartmentGroupSellersList, sellerItem)
|
|
|
+ }
|
|
|
+
|
|
|
+ tmpDepartmentGroupSellersList = sortDepartmentGroupSellers(tmpDepartmentGroupSellersList)
|
|
|
+ departmentGroupSellerList = append(departmentGroupSellerList, tmpDepartmentGroupSellersList...)
|
|
|
+ }
|
|
|
+
|
|
|
+ item.ChildrenList = departmentGroupSellerList
|
|
|
+ if len(departmentGroupSellerList) > 0 {
|
|
|
+ list = append(list, item)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_TEAM || sysUser.Authority == 4 {
|
|
|
+
|
|
|
+ if status == 0 {
|
|
|
+ directorId := sysUser.GroupId
|
|
|
+ fmt.Println("directorId:", directorId)
|
|
|
+ groupList, err := system.GetSysGroupByDirectorId(directorId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取分组失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, group := range groupList {
|
|
|
+ groupSellerList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ groupItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint("group_", group.DepartmentId),
|
|
|
+
|
|
|
+ RealName: group.GroupName,
|
|
|
+ ChildrenList: groupSellerList,
|
|
|
+ }
|
|
|
+ teamList, err := system.GetSysTeamByDepartmentId(group.GroupId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取小组失败"
|
|
|
+ br.ErrMsg = "获取小组失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, team := range teamList {
|
|
|
+ teamSellerList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ teamItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint("team_", team.GroupId),
|
|
|
+
|
|
|
+ RealName: team.GroupName,
|
|
|
+ ChildrenList: teamSellerList,
|
|
|
+ }
|
|
|
+ sellerList, err := system.GetTeamSysUserList(team.GroupId, enabled)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取销售失败"
|
|
|
+ br.ErrMsg = "获取销售失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, seller := range sellerList {
|
|
|
+ sellerItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint(seller.AdminId),
|
|
|
+
|
|
|
+ RealName: seller.RealName,
|
|
|
+ Authority: seller.Authority,
|
|
|
+ RoleTypeCode: seller.RoleTypeCode,
|
|
|
+ }
|
|
|
+
|
|
|
+ teamSellerList = append(teamSellerList, sellerItem)
|
|
|
+ }
|
|
|
+ teamSellerList = sortDepartmentGroupSellers(teamSellerList)
|
|
|
+ teamItem.ChildrenList = teamSellerList
|
|
|
+ if len(teamSellerList) > 0 {
|
|
|
+ groupSellerList = append(groupSellerList, teamItem)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ groupTeamSellerList, err := system.GetGrooupsysUserList(group.GroupId, roleCodeTypeStr, enabled)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取销售失败"
|
|
|
+ br.ErrMsg = "获取销售失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(groupTeamSellerList) > 0 {
|
|
|
+ tmpDepartmentGroupSellersList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ for _, seller := range groupTeamSellerList {
|
|
|
+ sellerItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint(seller.AdminId),
|
|
|
+
|
|
|
+ RealName: seller.RealName,
|
|
|
+ Authority: seller.Authority,
|
|
|
+ RoleTypeCode: seller.RoleTypeCode,
|
|
|
+ }
|
|
|
+ tmpDepartmentGroupSellersList = append(tmpDepartmentGroupSellersList, sellerItem)
|
|
|
+ }
|
|
|
+
|
|
|
+ tmpDepartmentGroupSellersList = sortDepartmentGroupSellers(tmpDepartmentGroupSellersList)
|
|
|
+ groupSellerList = append(groupSellerList, tmpDepartmentGroupSellersList...)
|
|
|
+ }
|
|
|
+
|
|
|
+ groupItem.ChildrenList = groupSellerList
|
|
|
+ if len(groupSellerList) > 0 {
|
|
|
+ list = append(list, groupItem)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ departmentStr := `1,2`
|
|
|
+ departmentList, err := system.GetDepartmentListByIds(departmentStr)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取部门失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, department := range departmentList {
|
|
|
+ departmentGroupSellerList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ item := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint("department_", department.DepartmentId),
|
|
|
+
|
|
|
+ RealName: department.DepartmentName,
|
|
|
+ ChildrenList: departmentGroupSellerList,
|
|
|
+ }
|
|
|
+
|
|
|
+ groupList, err := system.GetSysGroupByDepartmentId(department.DepartmentId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取分组失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, group := range groupList {
|
|
|
+ groupSellerList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ groupItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint("group_", group.DepartmentId),
|
|
|
+
|
|
|
+ RealName: group.GroupName,
|
|
|
+ ChildrenList: groupSellerList,
|
|
|
+ }
|
|
|
+ teamList, err := system.GetSysTeamByDepartmentId(group.GroupId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取小组失败"
|
|
|
+ br.ErrMsg = "获取小组失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, team := range teamList {
|
|
|
+ teamSellerList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ teamItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint("team_", team.GroupId),
|
|
|
+
|
|
|
+ RealName: team.GroupName,
|
|
|
+ ChildrenList: teamSellerList,
|
|
|
+ }
|
|
|
+ sellerList, err := system.GetTeamSysUserList(team.GroupId, enabled)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取销售失败"
|
|
|
+ br.ErrMsg = "获取销售失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, seller := range sellerList {
|
|
|
+ sellerItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint(seller.AdminId),
|
|
|
+
|
|
|
+ RealName: seller.RealName,
|
|
|
+ Authority: seller.Authority,
|
|
|
+ RoleTypeCode: seller.RoleTypeCode,
|
|
|
+ }
|
|
|
+
|
|
|
+ teamSellerList = append(teamSellerList, sellerItem)
|
|
|
+ }
|
|
|
+ teamSellerList = sortDepartmentGroupSellers(teamSellerList)
|
|
|
+ teamItem.ChildrenList = teamSellerList
|
|
|
+ if len(teamSellerList) > 0 {
|
|
|
+ groupSellerList = append(groupSellerList, teamItem)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ groupTeamSellerList, err := system.GetGroupSysUserList(group.GroupId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取销售失败"
|
|
|
+ br.ErrMsg = "获取销售失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(groupTeamSellerList) > 0 {
|
|
|
+ tmpDepartmentGroupSellersList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ for _, seller := range groupTeamSellerList {
|
|
|
+ sellerItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint(seller.AdminId),
|
|
|
+
|
|
|
+ RealName: seller.RealName,
|
|
|
+ Authority: seller.Authority,
|
|
|
+ RoleTypeCode: seller.RoleTypeCode,
|
|
|
+ }
|
|
|
+ tmpDepartmentGroupSellersList = append(tmpDepartmentGroupSellersList, sellerItem)
|
|
|
+ }
|
|
|
+
|
|
|
+ tmpDepartmentGroupSellersList = sortDepartmentGroupSellers(tmpDepartmentGroupSellersList)
|
|
|
+ groupSellerList = append(groupSellerList, tmpDepartmentGroupSellersList...)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ groupItem.ChildrenList = groupSellerList
|
|
|
+ if len(groupSellerList) > 0 {
|
|
|
+ departmentGroupSellerList = append(departmentGroupSellerList, groupItem)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ departmentSellerList, err := system.GetDepartmentGroupSysUserList(department.DepartmentId, 0, "")
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取销售失败"
|
|
|
+ br.ErrMsg = "获取销售失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(departmentSellerList) > 0 {
|
|
|
+ tmpDepartmentGroupSellersList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ for _, seller := range departmentSellerList {
|
|
|
+ sellerItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint(seller.AdminId),
|
|
|
+
|
|
|
+ RealName: seller.RealName,
|
|
|
+ Authority: seller.Authority,
|
|
|
+ RoleTypeCode: seller.RoleTypeCode,
|
|
|
+ }
|
|
|
+ tmpDepartmentGroupSellersList = append(tmpDepartmentGroupSellersList, sellerItem)
|
|
|
+ }
|
|
|
+
|
|
|
+ tmpDepartmentGroupSellersList = sortDepartmentGroupSellers(tmpDepartmentGroupSellersList)
|
|
|
+ departmentGroupSellerList = append(departmentGroupSellerList, tmpDepartmentGroupSellersList...)
|
|
|
+ }
|
|
|
+
|
|
|
+ item.ChildrenList = departmentGroupSellerList
|
|
|
+ if len(departmentGroupSellerList) > 0 {
|
|
|
+ list = append(list, item)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_COMPLIANCE || sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FINANCE || sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN {
|
|
|
+ departmentStr := `2,5,7`
|
|
|
+ switch sysUser.RoleTypeCode {
|
|
|
+ case utils.ROLE_TYPE_CODE_FINANCE:
|
|
|
+ departmentStr = `2,5,8`
|
|
|
+ case utils.ROLE_TYPE_CODE_FICC_ADMIN:
|
|
|
+ departmentStr = utils.GetFiccAdminDepartmentIds()
|
|
|
+ }
|
|
|
+ departmentList, err := system.GetDepartmentListByIds(departmentStr)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取部门失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, department := range departmentList {
|
|
|
+ fmt.Println(department)
|
|
|
+ departmentGroupSellerList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ item := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint("department_", department.DepartmentId),
|
|
|
+
|
|
|
+ RealName: department.DepartmentName,
|
|
|
+ ChildrenList: departmentGroupSellerList,
|
|
|
+ }
|
|
|
+
|
|
|
+ groupList, err := system.GetSysGroupByDepartmentId(department.DepartmentId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取分组失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, group := range groupList {
|
|
|
+ groupSellerList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ groupItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint("group_", group.DepartmentId),
|
|
|
+
|
|
|
+ RealName: group.GroupName,
|
|
|
+ ChildrenList: groupSellerList,
|
|
|
+ }
|
|
|
+ teamList, err := system.GetSysTeamByDepartmentId(group.GroupId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取小组失败"
|
|
|
+ br.ErrMsg = "获取小组失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, team := range teamList {
|
|
|
+ teamSellerList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ teamItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint("team_", team.GroupId),
|
|
|
+
|
|
|
+ RealName: team.GroupName,
|
|
|
+ ChildrenList: teamSellerList,
|
|
|
+ }
|
|
|
+ sellerList, err := system.GetTeamSysUserList(team.GroupId, enabled)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取销售失败"
|
|
|
+ br.ErrMsg = "获取销售失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, seller := range sellerList {
|
|
|
+ sellerItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint(seller.AdminId),
|
|
|
+
|
|
|
+ RealName: seller.RealName,
|
|
|
+ Authority: seller.Authority,
|
|
|
+ RoleTypeCode: seller.RoleTypeCode,
|
|
|
+ }
|
|
|
+
|
|
|
+ teamSellerList = append(teamSellerList, sellerItem)
|
|
|
+ }
|
|
|
+ teamSellerList = sortDepartmentGroupSellers(teamSellerList)
|
|
|
+ teamItem.ChildrenList = teamSellerList
|
|
|
+ if len(teamSellerList) > 0 {
|
|
|
+ groupSellerList = append(groupSellerList, teamItem)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ groupTeamSellerList, err := system.GetGrooupsysUserList(group.GroupId, roleCodeTypeStr, enabled)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取销售失败"
|
|
|
+ br.ErrMsg = "获取销售失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(groupTeamSellerList) > 0 {
|
|
|
+ tmpDepartmentGroupSellersList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ for _, seller := range groupTeamSellerList {
|
|
|
+ sellerItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint(seller.AdminId),
|
|
|
+
|
|
|
+ RealName: seller.RealName,
|
|
|
+ Authority: seller.Authority,
|
|
|
+ RoleTypeCode: seller.RoleTypeCode,
|
|
|
+ }
|
|
|
+ tmpDepartmentGroupSellersList = append(tmpDepartmentGroupSellersList, sellerItem)
|
|
|
+ }
|
|
|
+
|
|
|
+ tmpDepartmentGroupSellersList = sortDepartmentGroupSellers(tmpDepartmentGroupSellersList)
|
|
|
+ groupSellerList = append(groupSellerList, tmpDepartmentGroupSellersList...)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ groupItem.ChildrenList = groupSellerList
|
|
|
+ if len(groupSellerList) > 0 {
|
|
|
+ departmentGroupSellerList = append(departmentGroupSellerList, groupItem)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ departmentSellerList, err := system.GetDepartmentGroupSysUserList(department.DepartmentId, 0, roleCodeTypeStr)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取销售失败"
|
|
|
+ br.ErrMsg = "获取销售失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(departmentSellerList) > 0 {
|
|
|
+ tmpDepartmentGroupSellerList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ for _, seller := range departmentSellerList {
|
|
|
+ sellerItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint(seller.AdminId),
|
|
|
+
|
|
|
+ RealName: seller.RealName,
|
|
|
+ Authority: seller.Authority,
|
|
|
+ RoleTypeCode: seller.RoleTypeCode,
|
|
|
+ }
|
|
|
+ tmpDepartmentGroupSellerList = append(tmpDepartmentGroupSellerList, sellerItem)
|
|
|
+ }
|
|
|
+
|
|
|
+ tmpDepartmentGroupSellerList = sortDepartmentGroupSellers(tmpDepartmentGroupSellerList)
|
|
|
+ departmentGroupSellerList = append(departmentGroupSellerList, tmpDepartmentGroupSellerList...)
|
|
|
+ }
|
|
|
+
|
|
|
+ item.ChildrenList = departmentGroupSellerList
|
|
|
+ if len(departmentGroupSellerList) > 0 {
|
|
|
+ list = append(list, item)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_ADMIN || sysUser.Authority == 1 {
|
|
|
+
|
|
|
+ departmentId := sysUser.DepartmentId
|
|
|
+ switch sysUser.RoleTypeCode {
|
|
|
+ case utils.ROLE_TYPE_CODE_RAI_ADMIN:
|
|
|
+ departmentId = 5
|
|
|
+ case utils.ROLE_TYPE_CODE_FICC_ADMIN:
|
|
|
+ departmentId = 2
|
|
|
+ }
|
|
|
+ groupList, err := system.GetSysGroupByDepartmentId(departmentId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取分组失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, group := range groupList {
|
|
|
+ groupSellerList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ groupItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint("group_", group.DepartmentId),
|
|
|
+
|
|
|
+ RealName: group.GroupName,
|
|
|
+ ChildrenList: groupSellerList,
|
|
|
+ }
|
|
|
+ teamList, err := system.GetSysTeamByDepartmentId(group.GroupId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取小组失败"
|
|
|
+ br.ErrMsg = "获取小组失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, team := range teamList {
|
|
|
+ teamSellerList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ teamItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint("team_", team.GroupId),
|
|
|
+
|
|
|
+ RealName: team.GroupName,
|
|
|
+ ChildrenList: teamSellerList,
|
|
|
+ }
|
|
|
+ sellerList, err := system.GetTeamSysUserList(team.GroupId, enabled)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取销售失败"
|
|
|
+ br.ErrMsg = "获取销售失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, seller := range sellerList {
|
|
|
+ sellerItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint(seller.AdminId),
|
|
|
+
|
|
|
+ RealName: seller.RealName,
|
|
|
+ Authority: seller.Authority,
|
|
|
+ RoleTypeCode: seller.RoleTypeCode,
|
|
|
+ }
|
|
|
+
|
|
|
+ teamSellerList = append(teamSellerList, sellerItem)
|
|
|
+ }
|
|
|
+ teamSellerList = sortDepartmentGroupSellers(teamSellerList)
|
|
|
+ teamItem.ChildrenList = teamSellerList
|
|
|
+ if len(teamSellerList) > 0 {
|
|
|
+ groupSellerList = append(groupSellerList, teamItem)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ groupTeamSellerList, err := system.GetGrooupsysUserList(group.GroupId, roleCodeTypeStr, enabled)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取销售失败"
|
|
|
+ br.ErrMsg = "获取销售失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(groupTeamSellerList) > 0 {
|
|
|
+ tmpDepartmentGroupSellersList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ for _, seller := range groupTeamSellerList {
|
|
|
+ sellerItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint(seller.AdminId),
|
|
|
+
|
|
|
+ RealName: seller.RealName,
|
|
|
+ Authority: seller.Authority,
|
|
|
+ RoleTypeCode: seller.RoleTypeCode,
|
|
|
+ }
|
|
|
+ tmpDepartmentGroupSellersList = append(tmpDepartmentGroupSellersList, sellerItem)
|
|
|
+ }
|
|
|
+
|
|
|
+ tmpDepartmentGroupSellersList = sortDepartmentGroupSellers(tmpDepartmentGroupSellersList)
|
|
|
+ groupSellerList = append(groupSellerList, tmpDepartmentGroupSellersList...)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ groupItem.ChildrenList = groupSellerList
|
|
|
+ if len(groupSellerList) > 0 {
|
|
|
+ list = append(list, groupItem)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ departmentSellerList, err := system.GetDepartmentGroupSysUserList(departmentId, 0, roleCodeTypeStr)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取销售失败"
|
|
|
+ br.ErrMsg = "获取销售失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(departmentSellerList) > 0 {
|
|
|
+ tmpDepartmentGroupSeller := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ for _, seller := range departmentSellerList {
|
|
|
+ sellerItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint(seller.AdminId),
|
|
|
+
|
|
|
+ RealName: seller.RealName,
|
|
|
+ Authority: seller.Authority,
|
|
|
+ RoleTypeCode: seller.RoleTypeCode,
|
|
|
+ }
|
|
|
+ tmpDepartmentGroupSeller = append(tmpDepartmentGroupSeller, sellerItem)
|
|
|
+ }
|
|
|
+ tmpDepartmentGroupSeller = sortDepartmentGroupSellers(tmpDepartmentGroupSeller)
|
|
|
+ list = append(list, tmpDepartmentGroupSeller...)
|
|
|
+ }
|
|
|
+ } else if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_GROUP || (sysUser.Authority == 2 && sysUser.RoleTypeCode != utils.ROLE_TYPE_CODE_FICC_GROUP) {
|
|
|
+
|
|
|
+ if status == 0 {
|
|
|
+ sellerList, err := system.GetTeamSysUserList(sysUser.GroupId, enabled)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取销售失败"
|
|
|
+ br.ErrMsg = "获取销售失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, seller := range sellerList {
|
|
|
+ sellerItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint(seller.AdminId),
|
|
|
+
|
|
|
+ RealName: seller.RealName,
|
|
|
+ Authority: seller.Authority,
|
|
|
+ RoleTypeCode: seller.RoleTypeCode,
|
|
|
+ }
|
|
|
+
|
|
|
+ list = append(list, sellerItem)
|
|
|
+ }
|
|
|
+ list = sortDepartmentGroupSellers(list)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ } else {
|
|
|
+ departmentId := 5
|
|
|
+ groupList, err := system.GetSysGroupByDepartmentId(departmentId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取分组失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, group := range groupList {
|
|
|
+ groupSellerList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ groupItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint("group_", group.DepartmentId),
|
|
|
+
|
|
|
+ RealName: group.GroupName,
|
|
|
+ ChildrenList: groupSellerList,
|
|
|
+ }
|
|
|
+ teamList, err := system.GetSysTeamByDepartmentId(group.GroupId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取小组失败"
|
|
|
+ br.ErrMsg = "获取小组失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, team := range teamList {
|
|
|
+ teamSellerList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ teamItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint("team_", team.GroupId),
|
|
|
+
|
|
|
+ RealName: team.GroupName,
|
|
|
+ ChildrenList: teamSellerList,
|
|
|
+ }
|
|
|
+ sellerList, err := system.GetTeamSysUserList(team.GroupId, enabled)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取销售失败"
|
|
|
+ br.ErrMsg = "获取销售失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, seller := range sellerList {
|
|
|
+ sellerItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint(seller.AdminId),
|
|
|
+
|
|
|
+ RealName: seller.RealName,
|
|
|
+ Authority: seller.Authority,
|
|
|
+ RoleTypeCode: seller.RoleTypeCode,
|
|
|
+ }
|
|
|
+
|
|
|
+ teamSellerList = append(teamSellerList, sellerItem)
|
|
|
+ }
|
|
|
+ teamSellerList = sortDepartmentGroupSellers(teamSellerList)
|
|
|
+ teamItem.ChildrenList = teamSellerList
|
|
|
+ if len(teamSellerList) > 0 {
|
|
|
+ groupSellerList = append(groupSellerList, teamItem)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ groupTeamSellerList, err := system.GetGrooupsysUserList(group.GroupId, roleCodeTypeStr, enabled)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取销售失败"
|
|
|
+ br.ErrMsg = "获取销售失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(groupTeamSellerList) > 0 {
|
|
|
+ tmpDepartmentGroupSellersList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ for _, seller := range groupTeamSellerList {
|
|
|
+ sellerItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint(seller.AdminId),
|
|
|
+
|
|
|
+ RealName: seller.RealName,
|
|
|
+ Authority: seller.Authority,
|
|
|
+ RoleTypeCode: seller.RoleTypeCode,
|
|
|
+ }
|
|
|
+ tmpDepartmentGroupSellersList = append(tmpDepartmentGroupSellersList, sellerItem)
|
|
|
+ }
|
|
|
+
|
|
|
+ tmpDepartmentGroupSellersList = sortDepartmentGroupSellers(tmpDepartmentGroupSellersList)
|
|
|
+ groupSellerList = append(groupSellerList, tmpDepartmentGroupSellersList...)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ groupItem.ChildrenList = groupSellerList
|
|
|
+ if len(groupSellerList) > 0 {
|
|
|
+ list = append(list, groupItem)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ departmentSellerList, err := system.GetDepartmentGroupSysUserList(departmentId, 0, roleCodeTypeStr)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取销售失败"
|
|
|
+ br.ErrMsg = "获取销售失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(departmentSellerList) > 0 {
|
|
|
+ tmpDepartmentGroupSeller := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ for _, seller := range departmentSellerList {
|
|
|
+ sellerItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint(seller.AdminId),
|
|
|
+
|
|
|
+ RealName: seller.RealName,
|
|
|
+ Authority: seller.Authority,
|
|
|
+ RoleTypeCode: seller.RoleTypeCode,
|
|
|
+ }
|
|
|
+ tmpDepartmentGroupSeller = append(tmpDepartmentGroupSeller, sellerItem)
|
|
|
+ }
|
|
|
+ tmpDepartmentGroupSeller = sortDepartmentGroupSellers(tmpDepartmentGroupSeller)
|
|
|
+ list = append(list, tmpDepartmentGroupSeller...)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_GROUP || sysUser.Authority == 2 {
|
|
|
+
|
|
|
+ if status == 0 {
|
|
|
+ pid, err := system.GetParentIdFromGroup(sysUser.GroupId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "查询父级id异常" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var realGroupId int
|
|
|
+ if pid != nil && *pid > 0 {
|
|
|
+
|
|
|
+ realGroupId = *pid
|
|
|
+ } else {
|
|
|
+
|
|
|
+ realGroupId = sysUser.GroupId
|
|
|
+ }
|
|
|
+ groupList, err := system.GetSysGroupByGroupId(realGroupId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取分组失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, group := range groupList {
|
|
|
+ groupSellerList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ teamList, err := system.GetSysTeamByDepartmentId(group.GroupId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取小组失败"
|
|
|
+ br.ErrMsg = "获取小组失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, team := range teamList {
|
|
|
+ teamSellerList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ teamItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint("team_", team.GroupId),
|
|
|
+
|
|
|
+ RealName: team.GroupName,
|
|
|
+ ChildrenList: teamSellerList,
|
|
|
+ }
|
|
|
+ sellerList, err := system.GetTeamSysUserList(team.GroupId, enabled)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取销售失败"
|
|
|
+ br.ErrMsg = "获取销售失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, seller := range sellerList {
|
|
|
+ sellerItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint(seller.AdminId),
|
|
|
+
|
|
|
+ RealName: seller.RealName,
|
|
|
+ Authority: seller.Authority,
|
|
|
+ RoleTypeCode: seller.RoleTypeCode,
|
|
|
+ }
|
|
|
+
|
|
|
+ teamSellerList = append(teamSellerList, sellerItem)
|
|
|
+ }
|
|
|
+ teamSellerList = sortDepartmentGroupSellers(teamSellerList)
|
|
|
+ teamItem.ChildrenList = teamSellerList
|
|
|
+ if len(teamSellerList) > 0 {
|
|
|
+ groupSellerList = append(groupSellerList, teamItem)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ groupTeamSellerList, err := system.GetGrooupsysUserList(realGroupId, roleCodeTypeStr, enabled)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取销售失败"
|
|
|
+ br.ErrMsg = "获取销售失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(groupTeamSellerList) > 0 {
|
|
|
+ tmpDepartmentGroupSellersList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ for _, seller := range groupTeamSellerList {
|
|
|
+ sellerItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint(seller.AdminId),
|
|
|
+
|
|
|
+ RealName: seller.RealName,
|
|
|
+ Authority: seller.Authority,
|
|
|
+ RoleTypeCode: seller.RoleTypeCode,
|
|
|
+ }
|
|
|
+ tmpDepartmentGroupSellersList = append(tmpDepartmentGroupSellersList, sellerItem)
|
|
|
+ }
|
|
|
+
|
|
|
+ tmpDepartmentGroupSellersList = sortDepartmentGroupSellers(tmpDepartmentGroupSellersList)
|
|
|
+ groupSellerList = append(groupSellerList, tmpDepartmentGroupSellersList...)
|
|
|
+ }
|
|
|
+ list = groupSellerList
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ departmentStr := `1,2`
|
|
|
+ departmentList, err := system.GetDepartmentListByIds(departmentStr)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取部门失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, department := range departmentList {
|
|
|
+ departmentGroupSellerList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ item := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint("department_", department.DepartmentId),
|
|
|
+
|
|
|
+ RealName: department.DepartmentName,
|
|
|
+ ChildrenList: departmentGroupSellerList,
|
|
|
+ }
|
|
|
+
|
|
|
+ groupList, err := system.GetSysGroupByDepartmentId(department.DepartmentId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取分组失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, group := range groupList {
|
|
|
+ groupSellerList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ groupItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint("group_", group.DepartmentId),
|
|
|
+
|
|
|
+ RealName: group.GroupName,
|
|
|
+ ChildrenList: groupSellerList,
|
|
|
+ }
|
|
|
+ teamList, err := system.GetSysTeamByDepartmentId(group.GroupId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取小组失败"
|
|
|
+ br.ErrMsg = "获取小组失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, team := range teamList {
|
|
|
+ teamSellerList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ teamItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint("team_", team.GroupId),
|
|
|
+
|
|
|
+ RealName: team.GroupName,
|
|
|
+ ChildrenList: teamSellerList,
|
|
|
+ }
|
|
|
+ sellerList, err := system.GetTeamSysUserList(team.GroupId, enabled)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取销售失败"
|
|
|
+ br.ErrMsg = "获取销售失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, seller := range sellerList {
|
|
|
+ sellerItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint(seller.AdminId),
|
|
|
+
|
|
|
+ RealName: seller.RealName,
|
|
|
+ Authority: seller.Authority,
|
|
|
+ RoleTypeCode: seller.RoleTypeCode,
|
|
|
+ }
|
|
|
+
|
|
|
+ teamSellerList = append(teamSellerList, sellerItem)
|
|
|
+ }
|
|
|
+ teamSellerList = sortDepartmentGroupSellers(teamSellerList)
|
|
|
+ teamItem.ChildrenList = teamSellerList
|
|
|
+ if len(teamSellerList) > 0 {
|
|
|
+ groupSellerList = append(groupSellerList, teamItem)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ groupTeamSellerList, err := system.GetGroupSysUserList(group.GroupId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取销售失败"
|
|
|
+ br.ErrMsg = "获取销售失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(groupTeamSellerList) > 0 {
|
|
|
+ tmpDepartmentGroupSellersList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ for _, seller := range groupTeamSellerList {
|
|
|
+ sellerItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint(seller.AdminId),
|
|
|
+
|
|
|
+ RealName: seller.RealName,
|
|
|
+ Authority: seller.Authority,
|
|
|
+ RoleTypeCode: seller.RoleTypeCode,
|
|
|
+ }
|
|
|
+ tmpDepartmentGroupSellersList = append(tmpDepartmentGroupSellersList, sellerItem)
|
|
|
+ }
|
|
|
+
|
|
|
+ tmpDepartmentGroupSellersList = sortDepartmentGroupSellers(tmpDepartmentGroupSellersList)
|
|
|
+ groupSellerList = append(groupSellerList, tmpDepartmentGroupSellersList...)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ groupItem.ChildrenList = groupSellerList
|
|
|
+ if len(groupSellerList) > 0 {
|
|
|
+ departmentGroupSellerList = append(departmentGroupSellerList, groupItem)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ departmentSellerList, err := system.GetDepartmentGroupSysUserList(department.DepartmentId, 0, "")
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取销售失败"
|
|
|
+ br.ErrMsg = "获取销售失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(departmentSellerList) > 0 {
|
|
|
+ tmpDepartmentGroupSellersList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ for _, seller := range departmentSellerList {
|
|
|
+ sellerItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint(seller.AdminId),
|
|
|
+
|
|
|
+ RealName: seller.RealName,
|
|
|
+ Authority: seller.Authority,
|
|
|
+ RoleTypeCode: seller.RoleTypeCode,
|
|
|
+ }
|
|
|
+ tmpDepartmentGroupSellersList = append(tmpDepartmentGroupSellersList, sellerItem)
|
|
|
+ }
|
|
|
+
|
|
|
+ tmpDepartmentGroupSellersList = sortDepartmentGroupSellers(tmpDepartmentGroupSellersList)
|
|
|
+ departmentGroupSellerList = append(departmentGroupSellerList, tmpDepartmentGroupSellersList...)
|
|
|
+ }
|
|
|
+
|
|
|
+ item.ChildrenList = departmentGroupSellerList
|
|
|
+ if len(departmentGroupSellerList) > 0 {
|
|
|
+ list = append(list, item)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_SELLER && status == 1 {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ departmentStr := `1,2`
|
|
|
+ departmentList, err := system.GetDepartmentListByIds(departmentStr)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取部门失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, department := range departmentList {
|
|
|
+ departmentGroupSellerList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ item := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint("department_", department.DepartmentId),
|
|
|
+
|
|
|
+ RealName: department.DepartmentName,
|
|
|
+ ChildrenList: departmentGroupSellerList,
|
|
|
+ }
|
|
|
+
|
|
|
+ groupList, err := system.GetSysGroupByDepartmentId(department.DepartmentId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取分组失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, group := range groupList {
|
|
|
+ groupSellerList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ groupItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint("group_", group.DepartmentId),
|
|
|
+
|
|
|
+ RealName: group.GroupName,
|
|
|
+ ChildrenList: groupSellerList,
|
|
|
+ }
|
|
|
+ teamList, err := system.GetSysTeamByDepartmentId(group.GroupId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取小组失败"
|
|
|
+ br.ErrMsg = "获取小组失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, team := range teamList {
|
|
|
+ teamSellerList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ teamItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint("team_", team.GroupId),
|
|
|
+
|
|
|
+ RealName: team.GroupName,
|
|
|
+ ChildrenList: teamSellerList,
|
|
|
+ }
|
|
|
+ sellerList, err := system.GetTeamSysUserList(team.GroupId, enabled)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取销售失败"
|
|
|
+ br.ErrMsg = "获取销售失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, seller := range sellerList {
|
|
|
+ sellerItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint(seller.AdminId),
|
|
|
+
|
|
|
+ RealName: seller.RealName,
|
|
|
+ Authority: seller.Authority,
|
|
|
+ RoleTypeCode: seller.RoleTypeCode,
|
|
|
+ }
|
|
|
+
|
|
|
+ teamSellerList = append(teamSellerList, sellerItem)
|
|
|
+ }
|
|
|
+ teamSellerList = sortDepartmentGroupSellers(teamSellerList)
|
|
|
+ teamItem.ChildrenList = teamSellerList
|
|
|
+ if len(teamSellerList) > 0 {
|
|
|
+ groupSellerList = append(groupSellerList, teamItem)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ groupTeamSellerList, err := system.GetGroupSysUserList(group.GroupId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取销售失败"
|
|
|
+ br.ErrMsg = "获取销售失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(groupTeamSellerList) > 0 {
|
|
|
+ tmpDepartmentGroupSellersList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ for _, seller := range groupTeamSellerList {
|
|
|
+ sellerItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint(seller.AdminId),
|
|
|
+
|
|
|
+ RealName: seller.RealName,
|
|
|
+ Authority: seller.Authority,
|
|
|
+ RoleTypeCode: seller.RoleTypeCode,
|
|
|
+ }
|
|
|
+ tmpDepartmentGroupSellersList = append(tmpDepartmentGroupSellersList, sellerItem)
|
|
|
+ }
|
|
|
+
|
|
|
+ tmpDepartmentGroupSellersList = sortDepartmentGroupSellers(tmpDepartmentGroupSellersList)
|
|
|
+ groupSellerList = append(groupSellerList, tmpDepartmentGroupSellersList...)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ groupItem.ChildrenList = groupSellerList
|
|
|
+ if len(groupSellerList) > 0 {
|
|
|
+ departmentGroupSellerList = append(departmentGroupSellerList, groupItem)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ departmentSellerList, err := system.GetDepartmentGroupSysUserList(department.DepartmentId, 0, "")
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取销售失败"
|
|
|
+ br.ErrMsg = "获取销售失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(departmentSellerList) > 0 {
|
|
|
+ tmpDepartmentGroupSellersList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ for _, seller := range departmentSellerList {
|
|
|
+ sellerItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint(seller.AdminId),
|
|
|
+
|
|
|
+ RealName: seller.RealName,
|
|
|
+ Authority: seller.Authority,
|
|
|
+ RoleTypeCode: seller.RoleTypeCode,
|
|
|
+ }
|
|
|
+ tmpDepartmentGroupSellersList = append(tmpDepartmentGroupSellersList, sellerItem)
|
|
|
+ }
|
|
|
+
|
|
|
+ tmpDepartmentGroupSellersList = sortDepartmentGroupSellers(tmpDepartmentGroupSellersList)
|
|
|
+ departmentGroupSellerList = append(departmentGroupSellerList, tmpDepartmentGroupSellersList...)
|
|
|
+ }
|
|
|
+
|
|
|
+ item.ChildrenList = departmentGroupSellerList
|
|
|
+ if len(departmentGroupSellerList) > 0 {
|
|
|
+ list = append(list, item)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_SELLER && status == 1 {
|
|
|
+
|
|
|
+ departmentId := 5
|
|
|
+ groupList, err := system.GetSysGroupByDepartmentId(departmentId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取分组失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, group := range groupList {
|
|
|
+ groupSellerList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ groupItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint("group_", group.DepartmentId),
|
|
|
+
|
|
|
+ RealName: group.GroupName,
|
|
|
+ ChildrenList: groupSellerList,
|
|
|
+ }
|
|
|
+ teamList, err := system.GetSysTeamByDepartmentId(group.GroupId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取小组失败"
|
|
|
+ br.ErrMsg = "获取小组失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, team := range teamList {
|
|
|
+ teamSellerList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ teamItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint("team_", team.GroupId),
|
|
|
+
|
|
|
+ RealName: team.GroupName,
|
|
|
+ ChildrenList: teamSellerList,
|
|
|
+ }
|
|
|
+ sellerList, err := system.GetTeamSysUserList(team.GroupId, enabled)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取销售失败"
|
|
|
+ br.ErrMsg = "获取销售失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, seller := range sellerList {
|
|
|
+ sellerItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint(seller.AdminId),
|
|
|
+
|
|
|
+ RealName: seller.RealName,
|
|
|
+ Authority: seller.Authority,
|
|
|
+ RoleTypeCode: seller.RoleTypeCode,
|
|
|
+ }
|
|
|
+
|
|
|
+ teamSellerList = append(teamSellerList, sellerItem)
|
|
|
+ }
|
|
|
+ teamSellerList = sortDepartmentGroupSellers(teamSellerList)
|
|
|
+ teamItem.ChildrenList = teamSellerList
|
|
|
+ if len(teamSellerList) > 0 {
|
|
|
+ groupSellerList = append(groupSellerList, teamItem)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ groupTeamSellerList, err := system.GetGrooupsysUserList(group.GroupId, roleCodeTypeStr, enabled)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取销售失败"
|
|
|
+ br.ErrMsg = "获取销售失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(groupTeamSellerList) > 0 {
|
|
|
+ tmpDepartmentGroupSellersList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ for _, seller := range groupTeamSellerList {
|
|
|
+ sellerItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint(seller.AdminId),
|
|
|
+
|
|
|
+ RealName: seller.RealName,
|
|
|
+ Authority: seller.Authority,
|
|
|
+ RoleTypeCode: seller.RoleTypeCode,
|
|
|
+ }
|
|
|
+ tmpDepartmentGroupSellersList = append(tmpDepartmentGroupSellersList, sellerItem)
|
|
|
+ }
|
|
|
+
|
|
|
+ tmpDepartmentGroupSellersList = sortDepartmentGroupSellers(tmpDepartmentGroupSellersList)
|
|
|
+ groupSellerList = append(groupSellerList, tmpDepartmentGroupSellersList...)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ groupItem.ChildrenList = groupSellerList
|
|
|
+ if len(groupSellerList) > 0 {
|
|
|
+ list = append(list, groupItem)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ departmentSellerList, err := system.GetDepartmentGroupSysUserList(departmentId, 0, roleCodeTypeStr)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取销售失败"
|
|
|
+ br.ErrMsg = "获取销售失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(departmentSellerList) > 0 {
|
|
|
+ tmpDepartmentGroupSeller := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ for _, seller := range departmentSellerList {
|
|
|
+ sellerItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint(seller.AdminId),
|
|
|
+
|
|
|
+ RealName: seller.RealName,
|
|
|
+ Authority: seller.Authority,
|
|
|
+ RoleTypeCode: seller.RoleTypeCode,
|
|
|
+ }
|
|
|
+ tmpDepartmentGroupSeller = append(tmpDepartmentGroupSeller, sellerItem)
|
|
|
+ }
|
|
|
+ tmpDepartmentGroupSeller = sortDepartmentGroupSellers(tmpDepartmentGroupSeller)
|
|
|
+ list = append(list, tmpDepartmentGroupSeller...)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+
|
|
|
+ sellerItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint(sysUser.AdminId),
|
|
|
+
|
|
|
+ RealName: sysUser.RealName,
|
|
|
+ }
|
|
|
+ list = append(list, sellerItem)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ departmentId := sysUser.DepartmentId
|
|
|
+ switch productId {
|
|
|
+ case 1:
|
|
|
+ departmentId = 2
|
|
|
+ case 5:
|
|
|
+ departmentId = 5
|
|
|
+ }
|
|
|
+
|
|
|
+ groupList, err := system.GetSysGroupByDepartmentId(departmentId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取分组失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, group := range groupList {
|
|
|
+ groupSellerList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ groupItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint("group_", group.DepartmentId),
|
|
|
+
|
|
|
+ RealName: group.GroupName,
|
|
|
+ ChildrenList: groupSellerList,
|
|
|
+ }
|
|
|
+ teamList, err := system.GetSysTeamByDepartmentId(group.GroupId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取小组失败"
|
|
|
+ br.ErrMsg = "获取小组失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, team := range teamList {
|
|
|
+ teamSellerList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ teamItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint("team_", team.GroupId),
|
|
|
+
|
|
|
+ RealName: team.GroupName,
|
|
|
+ ChildrenList: teamSellerList,
|
|
|
+ }
|
|
|
+ sellerList, err := system.GetTeamSysUserList(team.GroupId, enabled)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取销售失败"
|
|
|
+ br.ErrMsg = "获取销售失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, seller := range sellerList {
|
|
|
+ sellerItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint(seller.AdminId),
|
|
|
+
|
|
|
+ RealName: seller.RealName,
|
|
|
+ Authority: seller.Authority,
|
|
|
+ RoleTypeCode: seller.RoleTypeCode,
|
|
|
+ }
|
|
|
+
|
|
|
+ teamSellerList = append(teamSellerList, sellerItem)
|
|
|
+ }
|
|
|
+ teamSellerList = sortDepartmentGroupSellers(teamSellerList)
|
|
|
+ teamItem.ChildrenList = teamSellerList
|
|
|
+ if len(teamSellerList) > 0 {
|
|
|
+ groupSellerList = append(groupSellerList, teamItem)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ groupTeamSellerList, err := system.GetGrooupsysUserList(group.GroupId, roleCodeTypeStr, enabled)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取销售失败"
|
|
|
+ br.ErrMsg = "获取销售失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(groupTeamSellerList) > 0 {
|
|
|
+ tmpDepartmentGroupSellersList := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ for _, seller := range groupTeamSellerList {
|
|
|
+ sellerItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint(seller.AdminId),
|
|
|
+
|
|
|
+ RealName: seller.RealName,
|
|
|
+ Authority: seller.Authority,
|
|
|
+ RoleTypeCode: seller.RoleTypeCode,
|
|
|
+ }
|
|
|
+ tmpDepartmentGroupSellersList = append(tmpDepartmentGroupSellersList, sellerItem)
|
|
|
+ }
|
|
|
+
|
|
|
+ tmpDepartmentGroupSellersList = sortDepartmentGroupSellers(tmpDepartmentGroupSellersList)
|
|
|
+ groupSellerList = append(groupSellerList, tmpDepartmentGroupSellersList...)
|
|
|
+ }
|
|
|
+
|
|
|
+ groupItem.ChildrenList = groupSellerList
|
|
|
+ if len(groupSellerList) > 0 {
|
|
|
+ list = append(list, groupItem)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ departmentSellerList, err := system.GetDepartmentGroupSysUserList(departmentId, 0, roleCodeTypeStr)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取销售失败"
|
|
|
+ br.ErrMsg = "获取销售失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(departmentSellerList) > 0 {
|
|
|
+ tmpDepartmentGroupSeller := make([]company.DepartmentGroupSellers, 0)
|
|
|
+ for _, seller := range departmentSellerList {
|
|
|
+ sellerItem := company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprint(seller.AdminId),
|
|
|
+
|
|
|
+ RealName: seller.RealName,
|
|
|
+ Authority: seller.Authority,
|
|
|
+ RoleTypeCode: seller.RoleTypeCode,
|
|
|
+ }
|
|
|
+ tmpDepartmentGroupSeller = append(tmpDepartmentGroupSeller, sellerItem)
|
|
|
+ }
|
|
|
+
|
|
|
+ tmpDepartmentGroupSeller = sortDepartmentGroupSellers(tmpDepartmentGroupSeller)
|
|
|
+ list = append(list, tmpDepartmentGroupSeller...)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ seaDepartment, e := system.GetSysDepartmentByName("海外销售部")
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取海外销售部失败, Err: " + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if e == nil {
|
|
|
+
|
|
|
+ seaSellers, e := system.GetDepartmentGroupSysUserList(seaDepartment.DepartmentId, 0, "")
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取海外销售失败, Err: " + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ seaGroups, e := system.GetSysGroupListByDepartmentId(seaDepartment.DepartmentId)
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取海外销售部分组失败, Err: " + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var d company.DepartmentGroupSellers
|
|
|
+ d.AdminId = fmt.Sprintf("department_%d", seaDepartment.DepartmentId)
|
|
|
+ d.RealName = seaDepartment.DepartmentName
|
|
|
+ children := make([]company.DepartmentGroupSellers, 0)
|
|
|
+
|
|
|
+ if len(seaGroups) == 0 {
|
|
|
+ for _, s := range seaSellers {
|
|
|
+ children = append(children, company.DepartmentGroupSellers{
|
|
|
+ AdminId: strconv.Itoa(s.AdminId),
|
|
|
+ RealName: s.RealName,
|
|
|
+ RoleTypeCode: s.RoleTypeCode,
|
|
|
+ Authority: s.Authority,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(seaGroups) > 0 {
|
|
|
+
|
|
|
+ sellerMap := make(map[int][]company.DepartmentGroupSellers)
|
|
|
+ for _, s := range seaSellers {
|
|
|
+ sellerMap[s.GroupId] = append(sellerMap[s.GroupId], company.DepartmentGroupSellers{
|
|
|
+ AdminId: strconv.Itoa(s.AdminId),
|
|
|
+ RealName: s.RealName,
|
|
|
+ RoleTypeCode: s.RoleTypeCode,
|
|
|
+ Authority: s.Authority,
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ childrenMap := make(map[int][]company.DepartmentGroupSellers)
|
|
|
+ for _, g := range seaGroups {
|
|
|
+ if g.ParentId == 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ childrenMap[g.ParentId] = append(childrenMap[g.ParentId], company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprintf("team_%d", g.GroupId),
|
|
|
+ RealName: g.GroupName,
|
|
|
+ ChildrenList: sellerMap[g.GroupId],
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, g := range seaGroups {
|
|
|
+ if g.ParentId > 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ c := childrenMap[g.GroupId]
|
|
|
+ if len(sellerMap[g.GroupId]) > 0 {
|
|
|
+ c = append(c, sellerMap[g.GroupId]...)
|
|
|
+ }
|
|
|
+ children = append(children, company.DepartmentGroupSellers{
|
|
|
+ AdminId: fmt.Sprintf("group_%d", g.GroupId),
|
|
|
+ RealName: g.GroupName,
|
|
|
+ ChildrenList: c,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ d.ChildrenList = children
|
|
|
+ list = append(list, d)
|
|
|
+ }
|
|
|
+
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "获取成功"
|
|
|
+ br.Data = company.DepartmentGroupSellersResp{
|
|
|
+ List: list,
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func sortDepartmentGroupSellers(adminList []company.DepartmentGroupSellers) (list []company.DepartmentGroupSellers) {
|
|
|
+ sellerMap := make(map[int][]company.DepartmentGroupSellers)
|
|
|
+ for _, admin := range adminList {
|
|
|
+ index := 0
|
|
|
+ switch admin.RoleTypeCode {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ default:
|
|
|
+
|
|
|
+ switch admin.Authority {
|
|
|
+
|
|
|
+
|
|
|
+ case 2:
|
|
|
+ index = 2
|
|
|
+
|
|
|
+
|
|
|
+ default:
|
|
|
+ index = 3
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sellerList, ok := sellerMap[index]
|
|
|
+ if !ok {
|
|
|
+ sellerList = make([]company.DepartmentGroupSellers, 0)
|
|
|
+ }
|
|
|
+ sellerList = append(sellerList, admin)
|
|
|
+ sellerMap[index] = sellerList
|
|
|
+ }
|
|
|
+
|
|
|
+ var indexList = []int{0, 1, 2, 3}
|
|
|
+ for _, index := range indexList {
|
|
|
+ sellerList, ok := sellerMap[index]
|
|
|
+ if ok {
|
|
|
+ list = append(list, sellerList...)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|