|
@@ -188,6 +188,7 @@ func (this *CompanySellerController) CheckListV2() {
|
|
|
}
|
|
|
|
|
|
getAllSeller, _ := this.GetBool("AllSeller", false)
|
|
|
+ getAllUser, _ := this.GetBool("AllUser", false)
|
|
|
status, _ := this.GetInt("Status", 0)
|
|
|
getAllEnabled, _ := this.GetBool("AllEnabled", false)
|
|
|
enabled := 1
|
|
@@ -195,6 +196,164 @@ func (this *CompanySellerController) CheckListV2() {
|
|
|
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 {
|