作者 yangfu

Merge branch 'test' of http://gitlab.fjmaimaimai.com/mmm-go/opp into test

@@ -84,7 +84,9 @@ func DeleteChanceFavorite(id int64) (err error) { @@ -84,7 +84,9 @@ func DeleteChanceFavorite(id int64) (err error) {
84 //获取用户点赞收藏机会 84 //获取用户点赞收藏机会
85 func GetChanceFavorites(userId, companyId int64, markFlag, sourceType int, sourceId int64, lastId int64, pageSize int) (v []*ChanceFavorite, total int, err error) { 85 func GetChanceFavorites(userId, companyId int64, markFlag, sourceType int, sourceId int64, lastId int64, pageSize int) (v []*ChanceFavorite, total int, err error) {
86 sql := mybeego.NewSqlExutor().Table("chance_favorite").Order("create_at desc") 86 sql := mybeego.NewSqlExutor().Table("chance_favorite").Order("create_at desc")
87 - sql.Where(fmt.Sprintf("user_id=%d", userId)) 87 + if userId > 0 {
  88 + sql.Where(fmt.Sprintf("user_id=%d", userId))
  89 + }
88 sql.Where(fmt.Sprintf("company_id=%d", companyId)) 90 sql.Where(fmt.Sprintf("company_id=%d", companyId))
89 if sourceType > 0 { 91 if sourceType > 0 {
90 sql.Where(fmt.Sprintf("source_type=%d", sourceType)) 92 sql.Where(fmt.Sprintf("source_type=%d", sourceType))
@@ -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
@@ -176,7 +176,7 @@ func Thumbsups(header *protocol.RequestHeader, request *protocol.ThumbsupsReques @@ -176,7 +176,7 @@ func Thumbsups(header *protocol.RequestHeader, request *protocol.ThumbsupsReques
176 baseUserInfo *protocol.BaseUserInfo 176 baseUserInfo *protocol.BaseUserInfo
177 ) 177 )
178 rsp = &protocol.ThumbsupsResponse{} 178 rsp = &protocol.ThumbsupsResponse{}
179 - if favorites, total, err = models.GetChanceFavorites(header.UserId, header.CompanyId, protocol.MarkFlagZan, request.SourceType, request.SourceId, request.LastId, request.PageSize); err != nil { 179 + if favorites, total, err = models.GetChanceFavorites(0, header.CompanyId, protocol.MarkFlagZan, request.SourceType, request.SourceId, request.LastId, request.PageSize); err != nil {
180 if err == orm.ErrNoRows { 180 if err == orm.ErrNoRows {
181 err = nil 181 err = nil
182 return 182 return
@@ -429,8 +429,9 @@ func MsgChanceComment(header *protocol.RequestHeader, request *protocol.MsgChanc @@ -429,8 +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 } 433 }
433 - comment.Provider, _ = agg.GetUserBaseInfo(chance.ReceiveUserId, header.CompanyId) 434 + comment.Provider, _ = agg.GetUserBaseInfo(chance.SenderUserId, header.CompanyId)
434 commItem.CommentData = comment 435 commItem.CommentData = comment
435 commItem.IsRead = chance.IsRead == 1 436 commItem.IsRead = chance.IsRead == 1
436 commItem.SourceType = chance.SourceType 437 commItem.SourceType = chance.SourceType
@@ -502,15 +503,14 @@ func MsgChanceThumbUp(header *protocol.RequestHeader, request *protocol.MsgChanc @@ -502,15 +503,14 @@ func MsgChanceThumbUp(header *protocol.RequestHeader, request *protocol.MsgChanc
502 Provider: provider, 503 Provider: provider,
503 } 504 }
504 } 505 }
505 - if provider, _ = agg.GetUserBaseInfo(chance.Uid, header.CompanyId); err != nil {  
506 506
507 - }  
508 thumb := protocol.ThumbUpData{ 507 thumb := protocol.ThumbUpData{
509 Id: chance.CommentId, 508 Id: chance.CommentId,
510 ThumbUpTime: chance.CommentTime.Unix() * 1000, 509 ThumbUpTime: chance.CommentTime.Unix() * 1000,
511 Content: chance.CommentContent, 510 Content: chance.CommentContent,
  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