作者 yangfu

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

... ... @@ -84,7 +84,9 @@ func DeleteChanceFavorite(id int64) (err error) {
//获取用户点赞收藏机会
func GetChanceFavorites(userId, companyId int64, markFlag, sourceType int, sourceId int64, lastId int64, pageSize int) (v []*ChanceFavorite, total int, err error) {
sql := mybeego.NewSqlExutor().Table("chance_favorite").Order("create_at desc")
sql.Where(fmt.Sprintf("user_id=%d", userId))
if userId > 0 {
sql.Where(fmt.Sprintf("user_id=%d", userId))
}
sql.Where(fmt.Sprintf("company_id=%d", companyId))
if sourceType > 0 {
sql.Where(fmt.Sprintf("source_type=%d", sourceType))
... ...
... ... @@ -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
... ... @@ -176,7 +176,7 @@ func Thumbsups(header *protocol.RequestHeader, request *protocol.ThumbsupsReques
baseUserInfo *protocol.BaseUserInfo
)
rsp = &protocol.ThumbsupsResponse{}
if favorites, total, err = models.GetChanceFavorites(header.UserId, header.CompanyId, protocol.MarkFlagZan, request.SourceType, request.SourceId, request.LastId, request.PageSize); err != nil {
if favorites, total, err = models.GetChanceFavorites(0, header.CompanyId, protocol.MarkFlagZan, request.SourceType, request.SourceId, request.LastId, request.PageSize); err != nil {
if err == orm.ErrNoRows {
err = nil
return
... ...
... ... @@ -429,8 +429,9 @@ func MsgChanceComment(header *protocol.RequestHeader, request *protocol.MsgChanc
Id: chance.CommentId,
CommentTime: chance.CommentTime.Unix() * 1000,
Content: chance.CommentContent,
//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
... ... @@ -502,15 +503,14 @@ func MsgChanceThumbUp(header *protocol.RequestHeader, request *protocol.MsgChanc
Provider: provider,
}
}
if provider, _ = agg.GetUserBaseInfo(chance.Uid, header.CompanyId); err != nil {
}
thumb := protocol.ThumbUpData{
Id: chance.CommentId,
ThumbUpTime: chance.CommentTime.Unix() * 1000,
Content: chance.CommentContent,
//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
... ...