|
|
@@ -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
|
|
|
}
|