Explorar o código

feature(优化): 跟进记录统计只统计销售

ZZH-wl %!s(int64=2) %!d(string=hai) anos
pai
achega
4e1b9ed615
Modificáronse 2 ficheiros con 41 adicións e 2 borrados
  1. 40 1
      opms_parent/app/service/base.go
  2. 1 1
      opms_parent/app/service/home/report.go

+ 40 - 1
opms_parent/app/service/base.go

@@ -3,6 +3,7 @@ package service
 import (
 	"context"
 	"dashoo.cn/opms_libary/myerrors"
+	"dashoo.cn/opms_libary/request"
 	"fmt"
 	"github.com/gogf/gf/container/gmap"
 	"github.com/gogf/gf/frame/g"
@@ -218,7 +219,7 @@ type DeptIdReq struct {
 	Include bool `json:"include,omitempty"`
 }
 
-// GetUsersByDept 根据部门获取用户获取系统
+// GetUsersByDept 根据部门获取用户
 func GetUsersByDept(ctx context.Context, req *DeptIdReq) (map[string]int, error) {
 	srv := micro_srv.InitMicroSrvClient("User", "micro_srv.auth")
 	defer srv.Close()
@@ -240,3 +241,41 @@ func GetUsersByDept(ctx context.Context, req *DeptIdReq) (map[string]int, error)
 	}
 	return res, nil
 }
+
+type SysUserSearchReq struct {
+	KeyWords string   `json:"keyWords"`
+	DeptId   int      `json:"deptId"` //部门id
+	DeptIds  []int    //所属部门id数据
+	Phone    string   `json:"phone"`
+	Status   string   `json:"status"`
+	Roles    []string `json:"roles"`
+	Posts    []string `json:"posts"`
+	Groups   []string `json:"groups"`
+	request.PageReq
+}
+
+// GetUsersByRoleCode 根据角色编码获取用户
+func GetUsersByRoleCode(ctx context.Context, roleCode []string, pageSize ...int) (map[string]int, error) {
+	srv := micro_srv.InitMicroSrvClient("User", "micro_srv.auth")
+	defer srv.Close()
+	resp := &comm_def.CommonMsg{}
+	req := &SysUserSearchReq{Roles: roleCode}
+	if len(pageSize) > 0 {
+		req.PageSize = pageSize[0]
+	}
+	err := srv.Call(ctx, "GetList", req, resp)
+	if err != nil {
+		return nil, myerrors.MicroCallError("根据角色编码获取用户失败")
+	}
+	if resp.Data == nil {
+		return nil, myerrors.TipsError("用户不存在")
+	}
+	data := resp.Data.(map[string]interface{})
+	list := data["list"].([]interface{})
+	res := map[string]int{}
+	for _, i := range list {
+		info := i.(map[string]interface{})
+		res[info["NickName"].(string)] = gconv.Int(info["Id"])
+	}
+	return res, nil
+}

+ 1 - 1
opms_parent/app/service/home/report.go

@@ -745,7 +745,7 @@ func (s *HomeService) QuerySalesEngineerFollowUpNum(day *gtime.Time) (interface{
 		followUpMonthData = append(followUpMonthData, data)
 	}
 	// 409022238
-	userList, err := service.GetUsersByDept(s.Ctx, &service.DeptIdReq{DeptId: 409022238, Include: true})
+	userList, err := service.GetUsersByRoleCode(s.Ctx, []string{"SalesEngineer", "ProductLineManager"})
 	if err != nil {
 		return nil, err
 	}