|
|
@@ -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()
|