作者 yangfu

消息修改

... ... @@ -208,7 +208,7 @@ func GetChanceCommentMsg(uid, lastId int64, pageSize int, msgType int, v interfa
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 from (
select id,message content,source_type,source_id,is_read,create_at comment_time,chance_id,receive_user_id,sender_user_id from user_msg
where receive_user_id =? and (?=0 or id<?) and msg_type=?
where receive_user_id =? and (?=0 or id<?) and msg_type=? and sender_user_id<>0
)a left outer join chance b on a.source_id = b.id and source_type=1
)a left outer join chance_data b on a.source_id = b.chance_id and source_type = 1
)a left outer join comment b on a.source_id = b.id and a.source_type=2
... ... @@ -216,7 +216,7 @@ order by a.comment_time desc
LIMIT ?`
sqlCount := `select count(0)
from user_msg where receive_user_id=? and source_type=1 and msg_type=? `
from user_msg where receive_user_id=? and source_type=1 and msg_type=? and sender_user_id<>0`
if err = utils.ExecuteQueryOne(&total, sqlCount, uid, msgType); err != nil {
return
}
... ...
... ... @@ -142,6 +142,31 @@ func SendMsg(receiverId int64, name string, companyId int64, sourceId int64, sou
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
)
userMsg = &models.UserMsg{
Id: idgen.Next(),
CompanyId: header.CompanyId,
ReceiveUserId: receiverId,
SenderUserId: header.UserId,
MsgType: msgType,
Message: message,
SourceId: sourceId,
SourceType: sourceType,
IsPublic: 0,
CreateAt: time.Now(),
ChanceId: chanceId,
}
if _, err = models.AddUserMsg(userMsg); err != nil {
return
}
logMsg(userMsg, name)
return
}
//删除已发送的消息
func DeleteSendedMsg(sourceId int64, sourceType int, receiverId int64, msgType int) (err error) {
o := orm.NewOrm()
... ...
... ... @@ -78,7 +78,7 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc
return
}
if chance, err = models.GetChanceById(request.ChanceId); err != nil {
log.Error(request.Id, "机会不存在", err)
log.Error(request.ChanceId, "机会不存在", err)
err = protocol.NewErrWithMessage(5101)
return
}
... ... @@ -168,7 +168,7 @@ END:
} else {
//发送点赞消息
if header.UserId != userId {
agg.SendMsg(userId, fmt.Sprintf("%v", userId), header.CompanyId, request.Id, request.SourceType, message, protocol.MsgTypeThumbUp, request.ChanceId)
agg.SendMsgWithHeader(header, userId, fmt.Sprintf("%v", userId), request.Id, request.SourceType, message, protocol.MsgTypeThumbUp, request.ChanceId)
}
}
if !utils.ExecuteSqlByRoll(true, agg.GetIncrementSql(table, "zan_total", incre, request.Id)) {
... ...
... ... @@ -75,7 +75,7 @@ func IComment(header *protocol.RequestHeader, request *protocol.ICommentRequest)
}
}
if recevierId != header.UserId {
if err = agg.SendMsg(recevierId, "", header.CompanyId, sourceId, request.SourceType, request.Content, protocol.MsgTypeComment, request.Id); err != nil {
if err = agg.SendMsgWithHeader(header, recevierId, "", sourceId, request.SourceType, request.Content, protocol.MsgTypeComment, request.Id); err != nil {
log.Error(err)
orm.Rollback()
return
... ...
... ... @@ -429,9 +429,9 @@ func MsgChanceComment(header *protocol.RequestHeader, request *protocol.MsgChanc
Id: chance.CommentId,
CommentTime: chance.CommentTime.Unix() * 1000,
Content: chance.CommentContent,
Provider: provider,
//Provider: provider,
}
comment.Provider, _ = agg.GetUserBaseInfo(chance.ReceiveUserId, header.CompanyId)
comment.Provider, _ = agg.GetUserBaseInfo(chance.SenderUserId, header.CompanyId)
commItem.CommentData = comment
commItem.IsRead = chance.IsRead == 1
commItem.SourceType = chance.SourceType
... ... @@ -508,9 +508,9 @@ func MsgChanceThumbUp(header *protocol.RequestHeader, request *protocol.MsgChanc
Id: chance.CommentId,
ThumbUpTime: chance.CommentTime.Unix() * 1000,
Content: chance.CommentContent,
Provider: provider,
//Provider: provider,
}
thumb.Provider, _ = agg.GetUserBaseInfo(chance.ReceiveUserId, header.CompanyId)
thumb.Provider, _ = agg.GetUserBaseInfo(chance.SenderUserId, header.CompanyId)
commItem.ThumbUpData = thumb
commItem.IsRead = chance.IsRead == 1
commItem.SourceType = chance.SourceType
... ...