소스 검색

feature(跟进记录): 跟进记录评论增加提醒功能,提醒到销售工程师和销售助理

ZZH-wl 2 년 전
부모
커밋
4221b1d950
3개의 변경된 파일33개의 추가작업 그리고 5개의 파일을 삭제
  1. 1 1
      opms_parent/app/service/home/report.go
  2. 0 1
      opms_parent/app/service/plat/plat_followup.go
  3. 32 3
      opms_parent/app/service/plat/plat_followup_comment.go

+ 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: 1001, Include: true})
+	userList, err := service.GetUsersByDept(s.Ctx, &service.DeptIdReq{DeptId: 409022238, Include: true})
 	if err != nil {
 		return nil, err
 	}

+ 0 - 1
opms_parent/app/service/plat/plat_followup.go

@@ -18,7 +18,6 @@ import (
 
 type followupService struct {
 	*service.ContextService
-
 	Dao *plat.PlatFollowupDao
 }
 

+ 32 - 3
opms_parent/app/service/plat/plat_followup_comment.go

@@ -2,8 +2,9 @@ package plat
 
 import (
 	"context"
-
 	"dashoo.cn/opms_libary/myerrors"
+	"database/sql"
+	"fmt"
 	"github.com/gogf/gf/frame/g"
 	"github.com/gogf/gf/util/gconv"
 
@@ -14,8 +15,8 @@ import (
 
 type followupCommentService struct {
 	*service.ContextService
-
-	Dao *plat.PlatFollowupCommentDao
+	Dao         *plat.PlatFollowupCommentDao
+	FollowupDao *plat.PlatFollowupDao
 }
 
 func NewFollowupCommentService(ctx context.Context) (svc *followupCommentService, err error) {
@@ -24,6 +25,7 @@ func NewFollowupCommentService(ctx context.Context) (svc *followupCommentService
 		return nil, err
 	}
 	svc.Dao = plat.NewPlatFollowupCommentDao(svc.Tenant)
+	svc.FollowupDao = plat.NewPlatFollowupDao(svc.Tenant)
 	return svc, nil
 }
 
@@ -50,6 +52,11 @@ func (s *followupCommentService) GetList(req *model.SearchPlatFollowupCommentReq
 
 // 添加信息
 func (s *followupCommentService) Create(req *model.AddPlatFollowupCommentReq) (err error) {
+	followup, err := s.FollowupDao.WherePri(req.FollowId).One()
+	if err != nil {
+		return err
+	}
+
 	platFollowupComment := new(model.PlatFollowupComment)
 	if err = gconv.Struct(req, platFollowupComment); err != nil {
 		return
@@ -63,5 +70,27 @@ func (s *followupCommentService) Create(req *model.AddPlatFollowupCommentReq) (e
 		return
 	}
 
+	// 从配置中获取消息提醒设置
+	config, err := g.DB(s.Tenant).Model("sys_config").Where("config_key = 'SalesAssociate'").One()
+	if err != nil && err != sql.ErrNoRows {
+		g.Log().Error(err)
+		return
+	}
+	// 销售助理用户Id
+	salesAssociate := config["config_value"].String()
+	recvUserIds := salesAssociate + "," + gconv.String(followup.CreatedBy)
+
+	msg := g.MapStrStr{
+		"msgTitle":    "跟进记录评论提醒",
+		"msgContent":  fmt.Sprintf("<p>%v %v 评论:%v</p>", followup.TargetName, platFollowupComment.CreatedName, platFollowupComment.Content),
+		"msgType":     "20",
+		"recvUserIds": recvUserIds,
+		"msgStatus":   "10",
+		"sendType":    "10",
+	}
+	if err := service.CreateSystemMessage(msg); err != nil {
+		g.Log().Error("消息提醒异常:", err)
+	}
+
 	return
 }