|
@@ -5,11 +5,17 @@ import (
|
|
"fmt"
|
|
"fmt"
|
|
"hongze/hongze_yb/models/request"
|
|
"hongze/hongze_yb/models/request"
|
|
"hongze/hongze_yb/models/response"
|
|
"hongze/hongze_yb/models/response"
|
|
|
|
+ "hongze/hongze_yb/models/tables/admin"
|
|
|
|
+ "hongze/hongze_yb/models/tables/company"
|
|
|
|
+ "hongze/hongze_yb/models/tables/company_product"
|
|
"hongze/hongze_yb/models/tables/research_group"
|
|
"hongze/hongze_yb/models/tables/research_group"
|
|
"hongze/hongze_yb/models/tables/user_record"
|
|
"hongze/hongze_yb/models/tables/user_record"
|
|
|
|
+ "hongze/hongze_yb/models/tables/wx_user"
|
|
"hongze/hongze_yb/models/tables/yb_community_audio_listen_log"
|
|
"hongze/hongze_yb/models/tables/yb_community_audio_listen_log"
|
|
"hongze/hongze_yb/models/tables/yb_community_question"
|
|
"hongze/hongze_yb/models/tables/yb_community_question"
|
|
"hongze/hongze_yb/models/tables/yb_community_question_audio"
|
|
"hongze/hongze_yb/models/tables/yb_community_question_audio"
|
|
|
|
+ "hongze/hongze_yb/services"
|
|
|
|
+ "hongze/hongze_yb/services/alarm_msg"
|
|
"hongze/hongze_yb/services/user"
|
|
"hongze/hongze_yb/services/user"
|
|
"hongze/hongze_yb/services/wechat"
|
|
"hongze/hongze_yb/services/wechat"
|
|
"hongze/hongze_yb/utils"
|
|
"hongze/hongze_yb/utils"
|
|
@@ -121,7 +127,7 @@ func GetQuestionList(pageIndex, pageSize, onlyMine, chartPermissionId, replyStat
|
|
ReplyTime: v.ReplyTime.Format(utils.FormatDateTime),
|
|
ReplyTime: v.ReplyTime.Format(utils.FormatDateTime),
|
|
//AuthOk: authOk,
|
|
//AuthOk: authOk,
|
|
//PermissionInfo: permissionInfo,
|
|
//PermissionInfo: permissionInfo,
|
|
- AudioList: audios,
|
|
|
|
|
|
+ AudioList: audios,
|
|
}
|
|
}
|
|
if !isResearcher && item.IsRead == 0 && item.UserId == userId {
|
|
if !isResearcher && item.IsRead == 0 && item.UserId == userId {
|
|
item.IsTop = 1
|
|
item.IsTop = 1
|
|
@@ -187,7 +193,7 @@ func GetQuestionDetail(questionId int, userInfo user.UserInfo) (item *response.C
|
|
ReplyTime: detail.ReplyTime.Format(utils.FormatDateTime),
|
|
ReplyTime: detail.ReplyTime.Format(utils.FormatDateTime),
|
|
//AuthOk: authOk,
|
|
//AuthOk: authOk,
|
|
//PermissionInfo: permissionInfo,
|
|
//PermissionInfo: permissionInfo,
|
|
- AudioList: audios,
|
|
|
|
|
|
+ AudioList: audios,
|
|
}
|
|
}
|
|
errMsg = "获取成功"
|
|
errMsg = "获取成功"
|
|
return
|
|
return
|
|
@@ -218,6 +224,9 @@ func CreateQuestion(userId int, mobile, realName, content string) (err error) {
|
|
if e := item.Create(); e != nil {
|
|
if e := item.Create(); e != nil {
|
|
err = errors.New("新增问题失败 Err:" + e.Error())
|
|
err = errors.New("新增问题失败 Err:" + e.Error())
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // 新增问答后,消息通知管理员
|
|
|
|
+ go messageToAdmin(userId, item)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -417,7 +426,7 @@ func GetResearchGroupTree() (respList []*response.ResearchGroupItem, err error)
|
|
}
|
|
}
|
|
|
|
|
|
// AddAudioListenLog 添加用户点击音频日志
|
|
// AddAudioListenLog 添加用户点击音频日志
|
|
-func AddAudioListenLog(userInfo user.UserInfo, audioId int, sourceAgent int) (err error) {
|
|
|
|
|
|
+func AddAudioListenLog(userInfo user.UserInfo, audioId int, sourceAgent int) (err error) {
|
|
//1. 查询音频是否存在
|
|
//1. 查询音频是否存在
|
|
audio, err := yb_community_question_audio.GetByAudioId(audioId)
|
|
audio, err := yb_community_question_audio.GetByAudioId(audioId)
|
|
if err != nil && err != utils.ErrNoRow {
|
|
if err != nil && err != utils.ErrNoRow {
|
|
@@ -445,3 +454,89 @@ func AddAudioListenLog(userInfo user.UserInfo, audioId int, sourceAgent int) (er
|
|
}
|
|
}
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+// messageToAdmin 添加站内消息
|
|
|
|
+func messageToAdmin(userId int, ybCommunityQuestion *yb_community_question.YbCommunityQuestion) {
|
|
|
|
+ var err error
|
|
|
|
+
|
|
|
|
+ defer func() {
|
|
|
|
+ go alarm_msg.SendAlarmMsg("问答评论完成后发送消息给管理员失败"+time.Now().Format("2006-01-02 15:04:05")+";Err:"+err.Error(), 3)
|
|
|
|
+ }()
|
|
|
|
+
|
|
|
|
+ //因为产品说只要给沛总发送信息,那么没办法咯,只去获取沛总的信息 2022-07-19 11:29:16
|
|
|
|
+ vWangInfo, err := admin.GetVWangInfo()
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ //站内消息
|
|
|
|
+ go systemMessageToAdmin(*vWangInfo, userId, ybCommunityQuestion)
|
|
|
|
+ //微信模板消息
|
|
|
|
+ go wxMessageToAdmin(*vWangInfo, ybCommunityQuestion)
|
|
|
|
+
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// systemMessageToAdmin 系统消息消息通知管理员
|
|
|
|
+func systemMessageToAdmin(adminInfo admin.Admin, userId int, ybCommunityQuestion *yb_community_question.YbCommunityQuestion) {
|
|
|
|
+ var err error
|
|
|
|
+ defer func() {
|
|
|
|
+ go alarm_msg.SendAlarmMsg("站内评论信息发送给管理员失败"+time.Now().Format("2006-01-02 15:04:05")+";Err:"+err.Error(), 3)
|
|
|
|
+ }()
|
|
|
|
+ // 接收人的admin_id
|
|
|
|
+ receiveUserId := int(adminInfo.AdminID)
|
|
|
|
+
|
|
|
|
+ //获取评论人信息
|
|
|
|
+ wxUser, err := wx_user.GetByUserId(userId)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ var msgType, sourceType, approvalStatus int8
|
|
|
|
+ msgType = services.CompanyApprovalMessageMessageTypeByApply
|
|
|
|
+ sourceType = services.CompanyApprovalMessageSourceTypeByQuestion
|
|
|
|
+ approvalStatus = services.CompanyApprovalMessageApprovalStatusByPending
|
|
|
|
+
|
|
|
|
+ companyInfo, err := company.GetByCompanyId(wxUser.CompanyID)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ productId := 1
|
|
|
|
+ companyProductInfo, err := company_product.GetByCompany2ProductId(wxUser.CompanyID, int64(productId))
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ companyName := companyInfo.CompanyName
|
|
|
|
+ remark := ybCommunityQuestion.QuestionContent
|
|
|
|
+ content := ybCommunityQuestion.QuestionContent
|
|
|
|
+
|
|
|
|
+ messageInfo := services.MessageInfo{
|
|
|
|
+ CompanyName: companyInfo.CompanyName,
|
|
|
|
+ ProductId: productId,
|
|
|
|
+ CompanyProductStatus: companyProductInfo.Status,
|
|
|
|
+ Title: ybCommunityQuestion.QuestionContent,
|
|
|
|
+ Content: ybCommunityQuestion.QuestionContent,
|
|
|
|
+ UserId: wxUser.UserID,
|
|
|
|
+ UserName: ybCommunityQuestion.RealName,
|
|
|
|
+ }
|
|
|
|
+ //客户添加消息
|
|
|
|
+ err = services.AddCompanyApprovalMessage(utils.AdminId, receiveUserId, int(wxUser.CompanyID), ybCommunityQuestion.CommunityQuestionID, msgType, sourceType, approvalStatus, companyName, remark, content, messageInfo)
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// wxMessageToAdmin 微信模板消息通知管理员
|
|
|
|
+func wxMessageToAdmin(adminInfo admin.Admin, ybCommunityQuestion *yb_community_question.YbCommunityQuestion) {
|
|
|
|
+ var err error
|
|
|
|
+
|
|
|
|
+ defer func() {
|
|
|
|
+ go alarm_msg.SendAlarmMsg("问答评论信息发送微信模板消息给管理员失败"+time.Now().Format("2006-01-02 15:04:05")+";Err:"+err.Error(), 3)
|
|
|
|
+ }()
|
|
|
|
+
|
|
|
|
+ wxUser, err := wx_user.GetByMobile(adminInfo.Mobile)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ err = wechat.SendQuestionToAdmin(ybCommunityQuestion.CommunityQuestionID, int(wxUser.UserID), ybCommunityQuestion.QuestionContent)
|
|
|
|
+ return
|
|
|
|
+}
|