Browse Source

feature(优化): 销售区域客户数量,打卡记录添加权限

ZZH-wl 2 years ago
parent
commit
1845e97e38

+ 3 - 3
opms_parent/app/service/base/base_sales_region_detail.go

@@ -44,10 +44,10 @@ func (s *salesRegionDetailService) GetList(req *model.SecBaseRegionDetailReq) (t
 	}
 	var districtList []int
 	for _, v := range RegionList {
-		districtList = append(districtList, v.CustProvinceId)
+		districtList = append(districtList, v.CustCityId)
 	}
 	//CustModel := p.CustomerDao.M
-	CustModel := s.CustomerDao.M.Fields("count(*) as count,cust_city_id").Where("cust_city_id in (?)", districtList)
+	CustModel := s.CustomerDao.DataScope(s.Ctx, "sales_id").M.Fields("count(*) as count,cust_city_id").Where("cust_city_id in (?)", districtList)
 	if req.CustName != "" {
 		CustModel = CustModel.Where(s.CustomerDao.C.CustName+" like ?", "%"+req.CustName+"%")
 	}
@@ -62,7 +62,7 @@ func (s *salesRegionDetailService) GetList(req *model.SecBaseRegionDetailReq) (t
 
 	for _, v := range RegionList {
 		for _, v3 := range custDist {
-			if v.CustProvinceId == gconv.Int(v3["cust_city_id"]) {
+			if v.CustCityId == gconv.Int(v3["cust_city_id"]) {
 				v.Count = gconv.Int(v3["count"])
 			}
 		}

+ 9 - 0
opms_parent/app/service/plat/plat_punch_records.go

@@ -4,6 +4,7 @@ import (
 	"context"
 	"dashoo.cn/opms_libary/myerrors"
 	"database/sql"
+	"github.com/gogf/gf/container/garray"
 	"github.com/gogf/gf/os/gtime"
 	"github.com/gogf/gf/util/gconv"
 	"strings"
@@ -29,6 +30,10 @@ func NewPunchRecordsService(ctx context.Context) (svc *PunchRecordsService, err
 
 func (s *PunchRecordsService) GetList(req *model.SearchPunchRecordsReq) (total int, punchRecordsList []*model.PlatPunchRecords, err error) {
 	db := s.Dao.Where(s.Dao.C.UserId, s.GetCxtUserId())
+	// 用户仅有销售工程师角色展示自己的数据,其他人可以看到所有数据
+	if garray.NewStrArrayFrom(s.CxtUser.Roles, true).Contains("SalesEngineer") {
+		db = db.WhereIn("user_id", s.DataScope["userIds"])
+	}
 	if req.BeginTime != "" {
 		db = db.WhereGTE(s.Dao.C.CreatedTime, req.BeginTime)
 	}
@@ -46,6 +51,10 @@ func (s *PunchRecordsService) GetList(req *model.SearchPunchRecordsReq) (total i
 }
 func (s *PunchRecordsService) GetListByDay(req *model.SearchPunchRecordsReq) (total int, list []*model.PunchRecordsRes, err error) {
 	db := s.Dao.FieldsEx(s.Dao.C.DeletedTime)
+	// 用户仅有销售工程师角色展示自己的数据,其他人可以看到所有数据
+	if garray.NewStrArrayFrom(s.CxtUser.Roles, true).Contains("SalesEngineer") {
+		db = db.WhereIn("user_id", s.DataScope["userIds"])
+	}
 	if req.UserNickName != "" {
 		db = db.WhereLike(s.Dao.C.UserNickName, "%"+req.UserNickName+"%")
 	}