作者 yangfu

公告消息数量统计修改

... ... @@ -120,6 +120,18 @@ GROUP BY msg_type`
return
}
//公告消息数量
func GetBulletinUserMsgTotals(userId int64, companyId int64, msgType int, v interface{}) (err error) {
o := orm.NewOrm()
sql := `select COUNT(*) as total from user_msg
where msg_type=1 and receive_user_id = ? and is_public=1 and is_read=0 and company_id=?
GROUP BY msg_type`
if err = utils.ExecuteQueryOneWithOrmer(o, v, sql, userId, companyId); err == nil {
return
}
return
}
//标记消息已读
func UpdateUserMsgSetRead(userId int64, companyId int64, msgType int, msgId int64) (err error) {
o := orm.NewOrm()
... ...
... ... @@ -54,7 +54,7 @@ func SendApproveMsg(receiverId int64, name string, companyId int64, chanceId int
Message: fmt.Sprintf(format, chanceType.Name),
SourceId: chanceId,
SourceType: protocol.SourceTypeChance,
IsPublic: 0,
IsPublic: 1,
CreateAt: time.Now(),
ChanceId: chanceId,
Data: common.AssertJson(data),
... ... @@ -108,7 +108,7 @@ func sendApproveMsg(header *protocol.RequestHeader, receiverId int64, name strin
Message: fmt.Sprintf(format, chanceType.Name),
SourceId: chanceId,
SourceType: protocol.SourceTypeChance,
IsPublic: 0,
IsPublic: 1,
CreateAt: time.Now(),
ChanceId: chanceId,
//Data: jsonData, ,
... ... @@ -141,7 +141,7 @@ func SendApproveMsgByFormat(header *protocol.RequestHeader, receiverId int64, ch
Message: message, //fmt.Sprintf(message, chanceType.Name),
SourceId: chanceId,
SourceType: protocol.SourceTypeChance,
IsPublic: 0,
IsPublic: 1,
CreateAt: time.Now(),
Data: common.AssertJson(data),
SenderUserId: header.UserId,
... ... @@ -194,7 +194,7 @@ func SendMsg(receiverId int64, name string, companyId int64, sourceId int64, sou
Message: message,
SourceId: sourceId,
SourceType: sourceType,
IsPublic: 0,
IsPublic: 1,
CreateAt: time.Now(),
ChanceId: chanceId,
}
... ... @@ -218,7 +218,7 @@ func SendMsgWithData(receiverId int64, name string, companyId int64, sourceId in
Message: message,
SourceId: sourceId,
SourceType: sourceType,
IsPublic: 0,
IsPublic: 1,
CreateAt: time.Now(),
ChanceId: chanceId,
Data: common.AssertJson(msgData),
... ... @@ -244,7 +244,7 @@ func SendMsgWithHeader(header *protocol.RequestHeader, receiverId int64, name st
Message: message,
SourceId: sourceId,
SourceType: sourceType,
IsPublic: 0,
IsPublic: 1,
CreateAt: time.Now(),
ChanceId: chanceId,
}
... ...
... ... @@ -51,6 +51,11 @@ func MessageCenter(header *protocol.RequestHeader, request *protocol.MessageCent
interactionCount += item.MsgTotal
continue
}
if item.MsgType == protocol.MsgTypeBulletin {
var tmpTotal int
models.GetBulletinUserMsgTotals(header.UserId, header.CompanyId, request.MsgType, &tmpTotal)
item.MsgTotal = tmpTotal
}
list = append(list, item)
}
if interactionCount > 0 {
... ...