zwxi 1 gadu atpakaļ
vecāks
revīzija
56edac939f
2 mainītis faili ar 60 papildinājumiem un 47 dzēšanām
  1. 3 1
      models/crm/company_seller.go
  2. 57 46
      services/crm/company_seller.go

+ 3 - 1
models/crm/company_seller.go

@@ -48,10 +48,12 @@ type SellerAdminWithGroupList struct {
 type SellerAdminWithGroupTree struct {
 	SellerId   int                        `json:"seller_id"`
 	SellerName string                     `json:"seller_name"`
+	ProductId  int                        `json:"product_id"`
+	Selected   bool                       `json:"selected"`
 	Child      []SellerAdminWithGroupTree `json:"child"`
 }
 
 type SellerAdminList struct {
 	SellerId   int    `json:"seller_id"`
 	SellerName string `json:"seller_name"`
-}
+}

+ 57 - 46
services/crm/company_seller.go

@@ -8,7 +8,7 @@ import (
 
 // GetSellerDepartmentAndGroupMap 获取销售部门列表-包含大组和小组
 func GetSellerDepartmentListWithGroupAndTeam() (sellerList []*crm.SellerAdminWithGroupTeam, err error) {
-	departmentIds := []int{crm.SellerDepartmentId,crm.RaiSellerDepartmentId}
+	departmentIds := []int{crm.SellerDepartmentId, crm.RaiSellerDepartmentId}
 	sellerList = make([]*crm.SellerAdminWithGroupTeam, 0)
 	// 获取组别列表
 	groupCond := "department_id in (?)"
@@ -91,11 +91,10 @@ func GetSellerTeamGroupMap() (teamGroupMap map[int]*crm.SysGroup, err error) {
 	return
 }
 
-
 // GetSellerDepartmentList 获取销售部门列表-大组
 func GetSellerDepartmentList() (resp crm.SellerAdminWithGroupList, err error) {
 	// 获取组别列表
-	departmentIds := []int{crm.SellerDepartmentId,crm.RaiSellerDepartmentId}
+	departmentIds := []int{crm.SellerDepartmentId, crm.RaiSellerDepartmentId}
 	groupCond := "department_id in (?)"
 	groupPars := make([]interface{}, 0)
 	groupPars = append(groupPars, departmentIds)
@@ -110,7 +109,7 @@ func GetSellerDepartmentList() (resp crm.SellerAdminWithGroupList, err error) {
 	for i := range groupList {
 		if groupList[i].ParentId > 0 {
 			teamMap[groupList[i].GroupId] = groupList[i]
-		}else{
+		} else {
 			groupMap[groupList[i].GroupId] = groupList[i]
 		}
 	}
@@ -132,41 +131,47 @@ func GetSellerDepartmentList() (resp crm.SellerAdminWithGroupList, err error) {
 	ficcList := make([]crm.SellerAdminList, 0)
 	raiList := make([]crm.SellerAdminList, 0)
 	for i := range adminList {
+		var productId int
 		v := crm.SellerAdminList{
-			SellerId:    adminList[i].AdminId,
-			SellerName:  adminList[i].RealName,
+			SellerId:   adminList[i].AdminId,
+			SellerName: adminList[i].RealName,
 		}
 		if adminList[i].DepartmentId == crm.SellerDepartmentId {
 			ficcList = append(ficcList, v)
-		}else if adminList[i].DepartmentId == crm.RaiSellerDepartmentId {
+			productId = 1
+		} else if adminList[i].DepartmentId == crm.RaiSellerDepartmentId {
 			raiList = append(raiList, v)
+			productId = 2
 		}
 		if t, ok := teamMap[adminList[i].GroupId]; ok { // 如果销售是在三级分组下面,则找到对应的二级分组
 			if g, ok1 := groupMap[t.ParentId]; ok1 {
 				tmp := crm.SellerAdminWithGroupTree{
-					SellerId:    adminList[i].AdminId,
-					SellerName:  adminList[i].RealName,
-					Child: nil,
+					SellerId:   adminList[i].AdminId,
+					SellerName: adminList[i].RealName,
+					ProductId:  productId,
+					Child:      nil,
 				}
 				groupSeller[g.GroupId] = append(groupSeller[g.GroupId], tmp)
-			}else{
-				fmt.Println("adminList[i]:",adminList[i].AdminId)
+			} else {
+				fmt.Println("adminList[i]:", adminList[i].AdminId)
 				err = errors.New("找不到对应的销售分组")
 				return
 			}
-		}else{
+		} else {
 			if g, ok1 := groupMap[adminList[i].GroupId]; ok1 {
 				tmp := crm.SellerAdminWithGroupTree{
-					SellerId:    adminList[i].AdminId,
-					SellerName:  adminList[i].RealName,
-					Child: nil,
+					SellerId:   adminList[i].AdminId,
+					SellerName: adminList[i].RealName,
+					ProductId:  productId,
+					Child:      nil,
 				}
 				groupSeller[g.GroupId] = append(groupSeller[g.GroupId], tmp)
-			}else{
+			} else {
 				tmp := crm.SellerAdminWithGroupTree{
-					SellerId:    adminList[i].AdminId,
-					SellerName:  adminList[i].RealName,
-					Child: nil,
+					SellerId:   adminList[i].AdminId,
+					SellerName: adminList[i].RealName,
+					ProductId:  productId,
+					Child:      nil,
 				}
 				departmentMap[adminList[i].DepartmentId] = append(departmentMap[adminList[i].DepartmentId], tmp)
 			}
@@ -180,23 +185,30 @@ func GetSellerDepartmentList() (resp crm.SellerAdminWithGroupList, err error) {
 			SellerName: v.GroupName,
 			Child:      child,
 		}
+		if v.DepartmentId == crm.SellerDepartmentId {
+			tmp.ProductId = 1
+		} else if v.DepartmentId == crm.RaiSellerDepartmentId {
+			tmp.ProductId = 2
+		}
 		departmentMap[v.DepartmentId] = append(departmentMap[v.DepartmentId], tmp)
 	}
 	//分部门
 	allTitleMap := map[int]string{
-		crm.SellerDepartmentId:"FICC销售",
-		crm.RaiSellerDepartmentId:"权益销售",
+		crm.SellerDepartmentId:    "FICC销售",
+		crm.RaiSellerDepartmentId: "权益销售",
 	}
 	ficcTree, _ := departmentMap[crm.SellerDepartmentId]
 	raiTree, _ := departmentMap[crm.RaiSellerDepartmentId]
 	tmp1 := crm.SellerAdminWithGroupTree{
 		SellerId:   crm.SellerDepartmentId,
 		SellerName: allTitleMap[crm.SellerDepartmentId],
+		ProductId:  1,
 		Child:      ficcTree,
 	}
 	tmp2 := crm.SellerAdminWithGroupTree{
 		SellerId:   crm.RaiSellerDepartmentId,
 		SellerName: allTitleMap[crm.RaiSellerDepartmentId],
+		ProductId:  2,
 		Child:      raiTree,
 	}
 	allList := make([]crm.SellerAdminWithGroupTree, 0)
@@ -209,8 +221,8 @@ func GetSellerDepartmentList() (resp crm.SellerAdminWithGroupList, err error) {
 }
 
 // GetSellerDepartmentAndGroupMap 获取销售部门列表-包含大组和小组
-func GetSellerDepartmentListWithGroupAndTeamByDepartment() (ficcList []*crm.SellerAdminWithGroupTeam,raiList []*crm.SellerAdminWithGroupTeam, err error) {
-	departmentIds := []int{crm.SellerDepartmentId,crm.RaiSellerDepartmentId}
+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)
 	// 获取组别列表
@@ -274,7 +286,7 @@ func GetSellerDepartmentListWithGroupAndTeamByDepartment() (ficcList []*crm.Sell
 // GetSellerList 获取销售部门列表-大组和小组
 func GetSellerList() (resp crm.SellerAdminWithGroupList, err error) {
 	// 获取组别列表
-	departmentIds := []int{crm.SellerDepartmentId,crm.RaiSellerDepartmentId}
+	departmentIds := []int{crm.SellerDepartmentId, crm.RaiSellerDepartmentId}
 	groupCond := "department_id in (?)"
 	groupPars := make([]interface{}, 0)
 	groupPars = append(groupPars, departmentIds)
@@ -285,7 +297,7 @@ func GetSellerList() (resp crm.SellerAdminWithGroupList, err error) {
 		return
 	}
 	fullGroupMap := make(map[int]*crm.SysGroup)
-	for _, v := range fullGroups{
+	for _, v := range fullGroups {
 		fullGroupMap[v.GroupId] = v
 	}
 	// 获取销售部门所有销售信息
@@ -305,25 +317,25 @@ func GetSellerList() (resp crm.SellerAdminWithGroupList, err error) {
 	groupListMap := make(map[int][]crm.SellerAdminWithGroupTree)
 	teamListMap := make(map[int][]crm.SellerAdminWithGroupTree)
 	//departmentHasMap := make(map[int]bool)
-	groupHasMap  := make(map[int]bool)
+	groupHasMap := make(map[int]bool)
 	teamHasMap := make(map[int]bool)
 
 	for _, v := range adminList {
 		tmp := crm.SellerAdminWithGroupTree{
-			SellerId:    v.AdminId,
-			SellerName:  v.RealName,
+			SellerId:   v.AdminId,
+			SellerName: v.RealName,
 		}
 		if v.GroupId > 0 {
 			if groupInfo, ok := fullGroupMap[v.GroupId]; ok {
 				if groupInfo.ParentId > 0 {
 					teamListMap[v.GroupId] = append(teamListMap[v.GroupId], tmp)
-				}else{
+				} else {
 					groupListMap[groupInfo.GroupId] = append(groupListMap[groupInfo.GroupId], tmp)
 				}
-			}else {
+			} else {
 				departmentListMap[v.DepartmentId] = append(departmentListMap[v.DepartmentId], tmp)
 			}
-		}else if v.DepartmentId > 0{
+		} else if v.DepartmentId > 0 {
 			departmentListMap[v.DepartmentId] = append(departmentListMap[v.DepartmentId], tmp)
 		}
 	}
@@ -331,12 +343,12 @@ func GetSellerList() (resp crm.SellerAdminWithGroupList, err error) {
 		var team1 crm.SellerAdminWithGroupTree
 		//处理小组
 		if groupInfo.ParentId > 0 {
-			if _, ok2 :=teamHasMap[groupInfo.GroupId]; !ok2 {
+			if _, ok2 := teamHasMap[groupInfo.GroupId]; !ok2 {
 				if len(teamListMap[groupInfo.GroupId]) > 0 {
 					team1 = crm.SellerAdminWithGroupTree{
-						SellerId:    groupInfo.GroupId,
-						SellerName:  groupInfo.GroupName,
-						Child: teamListMap[groupInfo.GroupId],
+						SellerId:   groupInfo.GroupId,
+						SellerName: groupInfo.GroupName,
+						Child:      teamListMap[groupInfo.GroupId],
 					}
 					teamHasMap[groupInfo.GroupId] = true
 					groupListMap[groupInfo.ParentId] = append(groupListMap[groupInfo.ParentId], team1)
@@ -348,12 +360,12 @@ func GetSellerList() (resp crm.SellerAdminWithGroupList, err error) {
 		var group1 crm.SellerAdminWithGroupTree
 		//处理大组
 		if groupInfo.ParentId == 0 {
-			if _, ok2 :=groupHasMap[groupInfo.GroupId]; !ok2 {
+			if _, ok2 := groupHasMap[groupInfo.GroupId]; !ok2 {
 				if len(groupListMap[groupInfo.GroupId]) > 0 {
 					group1 = crm.SellerAdminWithGroupTree{
-						SellerId:    groupInfo.GroupId,
-						SellerName:  groupInfo.GroupName,
-						Child: groupListMap[groupInfo.GroupId],
+						SellerId:   groupInfo.GroupId,
+						SellerName: groupInfo.GroupName,
+						Child:      groupListMap[groupInfo.GroupId],
 					}
 					groupHasMap[groupInfo.GroupId] = true
 					departmentListMap[groupInfo.DepartmentId] = append(departmentListMap[groupInfo.DepartmentId], group1)
@@ -363,11 +375,10 @@ func GetSellerList() (resp crm.SellerAdminWithGroupList, err error) {
 		}
 	}
 
-
 	//分部门
 	allTitleMap := map[int]string{
-		crm.SellerDepartmentId:"FICC销售",
-		crm.RaiSellerDepartmentId:"权益销售",
+		crm.SellerDepartmentId:    "FICC销售",
+		crm.RaiSellerDepartmentId: "权益销售",
 	}
 	tmp1 := crm.SellerAdminWithGroupTree{
 		SellerId:   crm.SellerDepartmentId,
@@ -377,7 +388,7 @@ func GetSellerList() (resp crm.SellerAdminWithGroupList, err error) {
 	tmp2 := crm.SellerAdminWithGroupTree{
 		SellerId:   crm.RaiSellerDepartmentId,
 		SellerName: allTitleMap[crm.RaiSellerDepartmentId],
-		Child:       departmentListMap[crm.RaiSellerDepartmentId],
+		Child:      departmentListMap[crm.RaiSellerDepartmentId],
 	}
 	allList := make([]crm.SellerAdminWithGroupTree, 0)
 	allList = append(allList, tmp1)
@@ -389,7 +400,7 @@ func GetSellerList() (resp crm.SellerAdminWithGroupList, err error) {
 
 // 获取销售部门列表-包含禁用
 func GetSellerDepartmentListWithEnable() (sellerList []*crm.SellerAdminWithGroupTeam, err error) {
-	departmentIds := []int{crm.SellerDepartmentId,crm.RaiSellerDepartmentId}
+	departmentIds := []int{crm.SellerDepartmentId, crm.RaiSellerDepartmentId}
 	sellerList = make([]*crm.SellerAdminWithGroupTeam, 0)
 	// 获取组别列表
 	groupCond := "department_id in (?)"
@@ -443,4 +454,4 @@ func GetSellerDepartmentListWithEnable() (sellerList []*crm.SellerAdminWithGroup
 		sellerList = append(sellerList, v)
 	}
 	return
-}
+}