作者 yangfu

消息 我的提交 增加审核评分

... ... @@ -22,6 +22,7 @@ type UserMsg struct {
CreateAt time.Time `orm:"column(create_at);type(timestamp);auto_now" description:"创建时间"`
ChanceId int64 `orm:"column(chance_id)" description:"机会编号"`
SenderUserId int64 `orm:"column(sender_user_id)" description:"发送人用户id"`
Data string `orm:"column(data)" description:"扩展数据"`
}
const (
... ... @@ -182,7 +183,7 @@ func GetUserMsgsBulletin(userId, companyId int64, msgType int, lastId int64, pag
func GetChanceMsg(uid, lastId int64, pageSize int, msgType int, v interface{}) (total int, err error) {
sql := `select a.*,b.images,b.speechs,b.videos from (
select a.*,b.source_content,b.enable_status,b.user_id chance_user_id,b.create_at,b.review_status,b.approve_data from (
select id,company_id,receive_user_id,message,source_id,is_read,chance_id,create_at msg_time
select id,company_id,receive_user_id,message,source_id,is_read,chance_id,create_at msg_time,data
from user_msg where receive_user_id=? and source_type=1 and (?=0 or id<?) and msg_type=?
)a left outer join chance b on a.source_id = b.id
)a left outer join chance_data b on a.source_id =b.chance_id
... ...
... ... @@ -276,6 +276,7 @@ type MsgChanceApproveItemOrm struct {
IsRead int64 `orm:"column(is_read)"`
ChanceId int64 `orm:"column(chance_id)"` // 机会id
//EnableStatus int `orm:"column(enable_status)"`
Data string `orm:"column(data)"`
}
/*Announcement H5公告详情*/
... ... @@ -313,3 +314,8 @@ type Answer struct {
VoteResults []int `json:"voteResults"`
EditContent string `json:"editContent"`
}
//扩展消息附加数据
type MsgData struct {
Score *Score `json:"score,omitempty"`
}
... ...
... ... @@ -3,6 +3,7 @@ package agg
import (
"fmt"
"github.com/astaxie/beego/orm"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/common"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/identity/idgen"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
"opp/internal/utils"
... ... @@ -19,7 +20,7 @@ var (
)
//发送审批消息
func SendApproveMsg(receiverId int64, name string, companyId int64, chanceId int64, chanceTypeId int, reviewStatus int) (err error) {
func SendApproveMsg(receiverId int64, name string, companyId int64, chanceId int64, chanceTypeId int, reviewStatus int, data protocol.MsgData) (err error) {
var (
userMsg *models.UserMsg
chanceType *models.ChanceType
... ... @@ -56,6 +57,7 @@ func SendApproveMsg(receiverId int64, name string, companyId int64, chanceId int
IsPublic: 0,
CreateAt: time.Now(),
ChanceId: chanceId,
Data: common.AssertJson(data),
}
if _, err = models.AddUserMsg(userMsg); err != nil {
return
... ... @@ -65,7 +67,7 @@ func SendApproveMsg(receiverId int64, name string, companyId int64, chanceId int
}
//发送审批消息
func SendApproveMsgByFormat(receiverId int64, name string, companyId int64, chanceId int64, chanceTypeId int, format string) (err error) {
func SendApproveMsgByFormat(receiverId int64, name string, companyId int64, chanceId int64, chanceTypeId int, format string, data protocol.MsgData) (err error) {
var (
userMsg *models.UserMsg
chanceType *models.ChanceType
... ... @@ -83,6 +85,7 @@ func SendApproveMsgByFormat(receiverId int64, name string, companyId int64, chan
SourceType: protocol.SourceTypeChance,
IsPublic: 0,
CreateAt: time.Now(),
Data: common.AssertJson(data),
}
if _, err = models.AddUserMsg(userMsg); err != nil {
return
... ... @@ -92,7 +95,7 @@ func SendApproveMsgByFormat(receiverId int64, name string, companyId int64, chan
}
//发送被审核消息
func SendApprovedMsg(receiverId int64, name string, companyId int64, chanceId int64, chanceTypeId int, reviewStatus int, msgType int) (err error) {
func SendApprovedMsg(receiverId int64, name string, companyId int64, chanceId int64, chanceTypeId int, reviewStatus int, msgType int, msgData protocol.MsgData) (err error) {
var (
chanceType *models.ChanceType
format string
... ... @@ -115,7 +118,7 @@ func SendApprovedMsg(receiverId int64, name string, companyId int64, chanceId in
return
}
format = fmt.Sprintf(format, chanceType.Name)
return SendMsg(receiverId, name, companyId, chanceId, protocol.SourceTypeChance, format, msgType, chanceId)
return SendMsgWithData(receiverId, name, companyId, chanceId, protocol.SourceTypeChance, format, msgType, chanceId, msgData)
}
//发送消息
... ... @@ -143,6 +146,31 @@ func SendMsg(receiverId int64, name string, companyId int64, sourceId int64, sou
}
//发送消息
func SendMsgWithData(receiverId int64, name string, companyId int64, sourceId int64, sourceType int, message string, msgType int, chanceId int64, msgData protocol.MsgData) (err error) {
var (
userMsg *models.UserMsg
)
userMsg = &models.UserMsg{
Id: idgen.Next(),
CompanyId: companyId,
ReceiveUserId: receiverId,
MsgType: msgType,
Message: message,
SourceId: sourceId,
SourceType: sourceType,
IsPublic: 0,
CreateAt: time.Now(),
ChanceId: chanceId,
Data: common.AssertJson(msgData),
}
if _, err = models.AddUserMsg(userMsg); err != nil {
return
}
logMsg(userMsg, name)
return
}
//发送消息
func SendMsgWithHeader(header *protocol.RequestHeader, receiverId int64, name string, sourceId int64, sourceType int, message string, msgType int, chanceId int64) (err error) {
var (
userMsg *models.UserMsg
... ...
... ... @@ -365,7 +365,7 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro
//更新下一批次的审核人
var nextApprovers []int64
if err = agg.SendApprovedMsg(chance.UserId, "",
header.CompanyId, chance.Id, chance.ChanceTypeId, request.ReviewStatus, protocol.MsgTypeAuditBy); err != nil {
header.CompanyId, chance.Id, chance.ChanceTypeId, request.ReviewStatus, protocol.MsgTypeAuditBy, protocol.MsgData{Score: &request.ApproveData.Score}); err != nil {
log.Error(err)
orm.Rollback()
return
... ... @@ -391,7 +391,7 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro
message := approveItemResponse.MessageData.ApproveMessage[i]
nextApprovers = append(nextApprovers, message.ReceiverInfo.ReceiverUid)
if err = agg.SendApproveMsg(message.ReceiverInfo.ReceiverUid, message.ReceiverInfo.ReceiverName,
header.CompanyId, chance.Id, chance.ChanceTypeId, protocol.ReviewStatusAuditging); err != nil {
header.CompanyId, chance.Id, chance.ChanceTypeId, protocol.ReviewStatusAuditging, protocol.MsgData{}); err != nil {
log.Error(err)
orm.Rollback()
return
... ...
... ... @@ -414,7 +414,7 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit
for i := range m.MessageData {
message := m.MessageData[i]
if err = agg.SendApproveMsg(message.ReceiverInfo.ReceiverUid, message.ReceiverInfo.ReceiverName,
header.CompanyId, chance.Id, chance.ChanceTypeId, protocol.ReviewStatusAuditging); err != nil {
header.CompanyId, chance.Id, chance.ChanceTypeId, protocol.ReviewStatusAuditging, protocol.MsgData{}); err != nil {
log.Error(err)
orm.Rollback()
return
... ... @@ -473,9 +473,9 @@ func setChanceAutoPass(header *protocol.RequestHeader, chance *models.Chance, or
chance.ApproveData = common.AssertJson(approveData)
chance.ApproveTime = time.Now()
chance.ReviewStatus = protocol.ReviewStatusPass
msgData := protocol.MsgData{Score: &approveData.Score}
if err = agg.SendApproveMsgByFormat(chance.UserId, "",
header.CompanyId, chance.Id, chance.ChanceTypeId, fmt.Sprintf(agg.MessageApproveAutoPass, chanceType.Name)); err != nil {
header.CompanyId, chance.Id, chance.ChanceTypeId, fmt.Sprintf(agg.MessageApproveAutoPass, chanceType.Name), msgData); err != nil {
log.Error(err)
return
}
... ... @@ -619,7 +619,7 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate
for i := range m.MessageData {
message := m.MessageData[i]
if err = agg.SendApproveMsg(message.ReceiverInfo.ReceiverUid, message.ReceiverInfo.ReceiverName,
header.CompanyId, chance.Id, chance.ChanceTypeId, protocol.ReviewStatusAuditging); err != nil {
header.CompanyId, chance.Id, chance.ChanceTypeId, protocol.ReviewStatusAuditging, protocol.MsgData{}); err != nil {
log.Error(err)
orm.Rollback()
return
... ...
... ... @@ -354,6 +354,11 @@ func MsgChanceSubmit(header *protocol.RequestHeader, request *protocol.MsgChance
commItem.Score = approveData.Score
}
}
if len(chance.Data) > 0 { //获取评分
var msgData *protocol.MsgData
utils.JsonUnmarshal(chance.ApproveData, &msgData)
commItem.Score = msgData.Score
}
commItem.IsRead = chance.IsRead == 1
//审核完有审核数据
commItem.Message = chance.Message
... ...