|
@@ -200,4 +200,67 @@ func GetSellerDepartmentList() (resp crm.SellerAdminWithGroupList, err error) {
|
|
|
resp.FiccList = ficcList
|
|
|
resp.RaiList = raiList
|
|
|
return
|
|
|
-}
|
|
|
+}
|
|
|
+
|
|
|
+// GetSellerDepartmentAndGroupMap 获取销售部门列表-包含大组和小组
|
|
|
+func GetSellerDepartmentListWithGroupAndTeamByDepartment() (ficcList []*crm.SellerAdminWithGroupTeam,raiList []*crm.SellerAdminWithGroupTeam, err error) {
|
|
|
+ departmentIds := []int{crm.SellerDepartmentId,crm.RaiSellerDepartmentId}
|
|
|
+ ficcList = make([]*crm.SellerAdminWithGroupTeam, 0)
|
|
|
+ raiList = make([]*crm.SellerAdminWithGroupTeam, 0)
|
|
|
+ // 获取组别列表
|
|
|
+ groupCond := "department_id in (?)"
|
|
|
+ groupPars := make([]interface{}, 0)
|
|
|
+ groupPars = append(groupPars, departmentIds)
|
|
|
+ groupOB := new(crm.SysGroup)
|
|
|
+ groupList, e := groupOB.List(groupCond, groupPars)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("获取组别列表失败, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ groupMap := make(map[int]*crm.SysGroup)
|
|
|
+ for i := range groupList {
|
|
|
+ groupMap[groupList[i].GroupId] = groupList[i]
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取销售部门所有销售信息
|
|
|
+ adminCond := "department_id in (?) AND enabled = 1"
|
|
|
+ adminPars := make([]interface{}, 0)
|
|
|
+ adminPars = append(adminPars, departmentIds)
|
|
|
+ adminOB := new(crm.Admin)
|
|
|
+ adminList, e := adminOB.List(adminCond, adminPars)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("获取销售列表失败, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 销售列表
|
|
|
+ for i := range adminList {
|
|
|
+ v := new(crm.SellerAdminWithGroupTeam)
|
|
|
+ v.DepartmentId = adminList[i].DepartmentId
|
|
|
+ v.SellerId = adminList[i].AdminId
|
|
|
+ v.SellerName = adminList[i].RealName
|
|
|
+ g := groupMap[adminList[i].GroupId]
|
|
|
+ if g != nil {
|
|
|
+ if g.ParentId > 0 {
|
|
|
+ // 三级分组
|
|
|
+ p := groupMap[g.ParentId]
|
|
|
+ if p != nil {
|
|
|
+ v.GroupId = p.GroupId
|
|
|
+ v.GroupName = p.GroupName
|
|
|
+ v.TeamId = g.GroupId
|
|
|
+ v.TeamName = g.GroupName
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 二级分组
|
|
|
+ v.GroupId = g.GroupId
|
|
|
+ v.GroupName = g.GroupName
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if v.DepartmentId == crm.SellerDepartmentId {
|
|
|
+ ficcList = append(ficcList, v)
|
|
|
+ } else {
|
|
|
+ raiList = append(raiList, v)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|