Răsfoiți Sursa

feature(跟进记录权限):
1.跟进经销商/代理商的记录对总经理、销售总监、产品线经理、销售助理开放查看权限,与客户的跟进记录一致。
2.大区总可查看下级的跟进记录,并可对跟进记录进行评论。
3.大区总可查看下级的打卡记录,销售工程师可在电脑端查看个人的打卡记录。

ZZH-wl 2 ani în urmă
părinte
comite
22b24fef92

+ 4 - 1
opms_parent/app/service/base/base_distributor.go

@@ -5,6 +5,7 @@ import (
 	"database/sql"
 	"encoding/json"
 	"fmt"
+	"github.com/gogf/gf/container/garray"
 	"io/ioutil"
 	"net/http"
 	"os"
@@ -64,7 +65,9 @@ func NewDistributorService(ctx context.Context) (svc *distributorService, err er
 // GetList 经销商信息列表
 func (s *distributorService) GetList(ctx context.Context, req *model.BaseDistributorSearchReq) (total int, distributorList []*model.BaseDistributorListRsp, err error) {
 	distributorModel := s.Dao.FieldsEx(s.Dao.C.DeletedTime)
-	distributorModel = distributorModel.DataScope(ctx, "belong_sale_id")
+	if garray.NewStrArrayFrom(s.CxtUser.Roles, true).Contains("SalesEngineer") {
+		distributorModel = distributorModel.DataScope(s.Ctx, "belong_sale_id")
+	}
 	if req.DistCode != "" {
 		distributorModel = distributorModel.WhereLike(s.Dao.C.DistCode, "%"+req.DistCode+"%")
 	}

+ 40 - 15
opms_parent/app/service/plat/plat_followup.go

@@ -2,8 +2,9 @@ package plat
 
 import (
 	"context"
+	distDao "dashoo.cn/micro/app/dao/base"
 	"dashoo.cn/micro/app/dao/cust"
-	projdao "dashoo.cn/micro/app/dao/proj"
+	projDao "dashoo.cn/micro/app/dao/proj"
 	"dashoo.cn/opms_libary/myerrors"
 	"database/sql"
 	"github.com/gogf/gf/container/garray"
@@ -117,11 +118,11 @@ func (s *followupService) Create(req *model.AddPlatFollowupReq) (err error) {
 	if platFollowup.TargetType == "20" {
 		// 更新客户 最后跟进时间 字段
 		toUpdate := map[string]interface{}{
-			projdao.ProjBusiness.C.FinalFollowTime: req.FollowDate,
-			projdao.ProjBusiness.C.FinalFollowId:   s.GetCxtUserId(),
-			projdao.ProjBusiness.C.FinalFollowName: s.GetCxtUserName(),
+			projDao.ProjBusiness.C.FinalFollowTime: req.FollowDate,
+			projDao.ProjBusiness.C.FinalFollowId:   s.GetCxtUserId(),
+			projDao.ProjBusiness.C.FinalFollowName: s.GetCxtUserName(),
 		}
-		_, err = s.Dao.DB.Update(projdao.ProjBusiness.Table, toUpdate, "id = ?", req.TargetId)
+		_, err = s.Dao.DB.Update(projDao.ProjBusiness.Table, toUpdate, "id = ?", req.TargetId)
 	}
 
 	return
@@ -141,20 +142,43 @@ func (s *followupService) GetListByDay(req *model.SearchPlatFollowupReq) (total
 			"orcols":  "cust_id",
 		}
 	} else if garray.NewStrArrayFrom(s.CxtUser.Roles, true).Contains("ProductLineManager") {
-		busIds, _ := projdao.NewProjBusinessDao(s.Tenant).DataScope(s.Ctx, "sale_id").Fields("id").Array()
+		var orCols []string
+		filter = map[string]interface{}{}
+		busIds, _ := projDao.NewProjBusinessDao(s.Tenant).DataScope(s.Ctx, "sale_id").Fields("id").Array()
 		custIds, _ := cust.NewCustCustomerDao(s.Tenant).DataScope(s.Ctx, "sales_id").Where("is_public", "20").Fields("id").Array()
-		filter = map[string]interface{}{
-			"target_type='20' AND target_id": busIds,
-			"target_type='10' AND target_id": custIds,
-			"orcols":                         []string{"target_type='20' AND target_id", "target_type='10' AND target_id"},
+		distributorIds, _ := distDao.NewBaseDistributorDao(s.Tenant).Fields("id").Array()
+		if len(busIds) > 0 {
+			filter["target_type='20' AND target_id"] = busIds
+			orCols = append(orCols, "target_type='20' AND target_id")
+		}
+		if len(custIds) > 0 {
+			filter["target_type='10' AND target_id"] = custIds
+			orCols = append(orCols, "target_type='10' AND target_id")
+		}
+		if len(distributorIds) > 0 {
+			filter["target_type='50' AND target_id"] = distributorIds
+			orCols = append(orCols, "target_type='50' AND target_id")
 		}
+		filter["orcols"] = orCols
 	} else {
 		if s.DataScope["userIds"] != "-1" {
-			vals, _ := cust.NewCustCustomerDao(s.Tenant).DataScope(s.Ctx, "sales_id").Where("is_public", "20").Fields("id").Array()
-			filter = map[string]interface{}{
-				"cust_id": vals,
-				"orcols":  "cust_id",
+			var orCols []string
+			filter = map[string]interface{}{}
+			custIds, _ := cust.NewCustCustomerDao(s.Tenant).DataScope(s.Ctx, "sales_id").Where("is_public", "20").Fields("id").Array()
+			distributorModel := &distDao.NewBaseDistributorDao(s.Tenant).BaseDistributorDao
+			if garray.NewStrArrayFrom(s.CxtUser.Roles, true).Contains("SalesEngineer") {
+				distributorModel = distributorModel.DataScope(s.Ctx, "belong_sale_id")
+			}
+			distributorIds, _ := distributorModel.Fields("id").Array()
+			if len(custIds) > 0 {
+				filter["cust_id"] = custIds
+				orCols = append(orCols, "cust_id")
+			}
+			if len(distributorIds) > 0 {
+				filter["target_type='50' AND target_id"] = distributorIds
+				orCols = append(orCols, "target_type='50' AND target_id")
 			}
+			filter["orcols"] = orCols
 		}
 	}
 	followupModel := s.Dao.DataScope(s.Ctx, filter)
@@ -203,7 +227,8 @@ func (s *followupService) GetListByDay(req *model.SearchPlatFollowupReq) (total
 		followupModel = followupModel.Where("follow_type", req.FollowType)
 	}
 	//跟进记录销售 添加销售人权限
-	if req.Sell != "" {
+	arr := garray.NewStrArrayFrom(s.CxtUser.Roles, true)
+	if arr.Len() == 1 && arr.Contains("SalesEngineer") && req.Sell != "" {
 		followupModel = followupModel.Where("created_by", s.CxtUser.Id)
 	}
 	//total, err = followupModel.Count()