作者 yangfu

消息修改

@@ -208,7 +208,7 @@ func GetChanceCommentMsg(uid, lastId int64, pageSize int, msgType int, v interfa @@ -208,7 +208,7 @@ func GetChanceCommentMsg(uid, lastId int64, pageSize int, msgType int, v interfa
208 select a.*,b.images,b.speechs,b.videos from ( 208 select a.*,b.images,b.speechs,b.videos from (
209 select a.*,b.source_content,b.enable_status,b.user_id chance_user_id,b.create_at,b.review_status from ( 209 select a.*,b.source_content,b.enable_status,b.user_id chance_user_id,b.create_at,b.review_status from (
210 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 210 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
211 -where receive_user_id =? and (?=0 or id<?) and msg_type=? 211 +where receive_user_id =? and (?=0 or id<?) and msg_type=? and sender_user_id<>0
212 )a left outer join chance b on a.source_id = b.id and source_type=1 212 )a left outer join chance b on a.source_id = b.id and source_type=1
213 )a left outer join chance_data b on a.source_id = b.chance_id and source_type = 1 213 )a left outer join chance_data b on a.source_id = b.chance_id and source_type = 1
214 )a left outer join comment b on a.source_id = b.id and a.source_type=2 214 )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 @@ -216,7 +216,7 @@ order by a.comment_time desc
216 LIMIT ?` 216 LIMIT ?`
217 217
218 sqlCount := `select count(0) 218 sqlCount := `select count(0)
219 -from user_msg where receive_user_id=? and source_type=1 and msg_type=? ` 219 +from user_msg where receive_user_id=? and source_type=1 and msg_type=? and sender_user_id<>0`
220 if err = utils.ExecuteQueryOne(&total, sqlCount, uid, msgType); err != nil { 220 if err = utils.ExecuteQueryOne(&total, sqlCount, uid, msgType); err != nil {
221 return 221 return
222 } 222 }
@@ -142,6 +142,31 @@ func SendMsg(receiverId int64, name string, companyId int64, sourceId int64, sou @@ -142,6 +142,31 @@ func SendMsg(receiverId int64, name string, companyId int64, sourceId int64, sou
142 return 142 return
143 } 143 }
144 144
  145 +//发送消息
  146 +func SendMsgWithHeader(header *protocol.RequestHeader, receiverId int64, name string, sourceId int64, sourceType int, message string, msgType int, chanceId int64) (err error) {
  147 + var (
  148 + userMsg *models.UserMsg
  149 + )
  150 + userMsg = &models.UserMsg{
  151 + Id: idgen.Next(),
  152 + CompanyId: header.CompanyId,
  153 + ReceiveUserId: receiverId,
  154 + SenderUserId: header.UserId,
  155 + MsgType: msgType,
  156 + Message: message,
  157 + SourceId: sourceId,
  158 + SourceType: sourceType,
  159 + IsPublic: 0,
  160 + CreateAt: time.Now(),
  161 + ChanceId: chanceId,
  162 + }
  163 + if _, err = models.AddUserMsg(userMsg); err != nil {
  164 + return
  165 + }
  166 + logMsg(userMsg, name)
  167 + return
  168 +}
  169 +
145 //删除已发送的消息 170 //删除已发送的消息
146 func DeleteSendedMsg(sourceId int64, sourceType int, receiverId int64, msgType int) (err error) { 171 func DeleteSendedMsg(sourceId int64, sourceType int, receiverId int64, msgType int) (err error) {
147 o := orm.NewOrm() 172 o := orm.NewOrm()
@@ -78,7 +78,7 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc @@ -78,7 +78,7 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc
78 return 78 return
79 } 79 }
80 if chance, err = models.GetChanceById(request.ChanceId); err != nil { 80 if chance, err = models.GetChanceById(request.ChanceId); err != nil {
81 - log.Error(request.Id, "机会不存在", err) 81 + log.Error(request.ChanceId, "机会不存在", err)
82 err = protocol.NewErrWithMessage(5101) 82 err = protocol.NewErrWithMessage(5101)
83 return 83 return
84 } 84 }
@@ -168,7 +168,7 @@ END: @@ -168,7 +168,7 @@ END:
168 } else { 168 } else {
169 //发送点赞消息 169 //发送点赞消息
170 if header.UserId != userId { 170 if header.UserId != userId {
171 - agg.SendMsg(userId, fmt.Sprintf("%v", userId), header.CompanyId, request.Id, request.SourceType, message, protocol.MsgTypeThumbUp, request.ChanceId) 171 + agg.SendMsgWithHeader(header, userId, fmt.Sprintf("%v", userId), request.Id, request.SourceType, message, protocol.MsgTypeThumbUp, request.ChanceId)
172 } 172 }
173 } 173 }
174 if !utils.ExecuteSqlByRoll(true, agg.GetIncrementSql(table, "zan_total", incre, request.Id)) { 174 if !utils.ExecuteSqlByRoll(true, agg.GetIncrementSql(table, "zan_total", incre, request.Id)) {
@@ -75,7 +75,7 @@ func IComment(header *protocol.RequestHeader, request *protocol.ICommentRequest) @@ -75,7 +75,7 @@ func IComment(header *protocol.RequestHeader, request *protocol.ICommentRequest)
75 } 75 }
76 } 76 }
77 if recevierId != header.UserId { 77 if recevierId != header.UserId {
78 - if err = agg.SendMsg(recevierId, "", header.CompanyId, sourceId, request.SourceType, request.Content, protocol.MsgTypeComment, request.Id); err != nil { 78 + if err = agg.SendMsgWithHeader(header, recevierId, "", sourceId, request.SourceType, request.Content, protocol.MsgTypeComment, request.Id); err != nil {
79 log.Error(err) 79 log.Error(err)
80 orm.Rollback() 80 orm.Rollback()
81 return 81 return
@@ -429,9 +429,9 @@ func MsgChanceComment(header *protocol.RequestHeader, request *protocol.MsgChanc @@ -429,9 +429,9 @@ func MsgChanceComment(header *protocol.RequestHeader, request *protocol.MsgChanc
429 Id: chance.CommentId, 429 Id: chance.CommentId,
430 CommentTime: chance.CommentTime.Unix() * 1000, 430 CommentTime: chance.CommentTime.Unix() * 1000,
431 Content: chance.CommentContent, 431 Content: chance.CommentContent,
432 - Provider: provider, 432 + //Provider: provider,
433 } 433 }
434 - comment.Provider, _ = agg.GetUserBaseInfo(chance.ReceiveUserId, header.CompanyId) 434 + comment.Provider, _ = agg.GetUserBaseInfo(chance.SenderUserId, header.CompanyId)
435 commItem.CommentData = comment 435 commItem.CommentData = comment
436 commItem.IsRead = chance.IsRead == 1 436 commItem.IsRead = chance.IsRead == 1
437 commItem.SourceType = chance.SourceType 437 commItem.SourceType = chance.SourceType
@@ -508,9 +508,9 @@ func MsgChanceThumbUp(header *protocol.RequestHeader, request *protocol.MsgChanc @@ -508,9 +508,9 @@ func MsgChanceThumbUp(header *protocol.RequestHeader, request *protocol.MsgChanc
508 Id: chance.CommentId, 508 Id: chance.CommentId,
509 ThumbUpTime: chance.CommentTime.Unix() * 1000, 509 ThumbUpTime: chance.CommentTime.Unix() * 1000,
510 Content: chance.CommentContent, 510 Content: chance.CommentContent,
511 - Provider: provider, 511 + //Provider: provider,
512 } 512 }
513 - thumb.Provider, _ = agg.GetUserBaseInfo(chance.ReceiveUserId, header.CompanyId) 513 + thumb.Provider, _ = agg.GetUserBaseInfo(chance.SenderUserId, header.CompanyId)
514 commItem.ThumbUpData = thumb 514 commItem.ThumbUpData = thumb
515 commItem.IsRead = chance.IsRead == 1 515 commItem.IsRead = chance.IsRead == 1
516 commItem.SourceType = chance.SourceType 516 commItem.SourceType = chance.SourceType