作者 yangfu

公告消息数量统计修改

@@ -120,6 +120,18 @@ GROUP BY msg_type` @@ -120,6 +120,18 @@ GROUP BY msg_type`
120 return 120 return
121 } 121 }
122 122
  123 +//公告消息数量
  124 +func GetBulletinUserMsgTotals(userId int64, companyId int64, msgType int, v interface{}) (err error) {
  125 + o := orm.NewOrm()
  126 + sql := `select COUNT(*) as total from user_msg
  127 +where msg_type=1 and receive_user_id = ? and is_public=1 and is_read=0 and company_id=?
  128 +GROUP BY msg_type`
  129 + if err = utils.ExecuteQueryOneWithOrmer(o, v, sql, userId, companyId); err == nil {
  130 + return
  131 + }
  132 + return
  133 +}
  134 +
123 //标记消息已读 135 //标记消息已读
124 func UpdateUserMsgSetRead(userId int64, companyId int64, msgType int, msgId int64) (err error) { 136 func UpdateUserMsgSetRead(userId int64, companyId int64, msgType int, msgId int64) (err error) {
125 o := orm.NewOrm() 137 o := orm.NewOrm()
@@ -54,7 +54,7 @@ func SendApproveMsg(receiverId int64, name string, companyId int64, chanceId int @@ -54,7 +54,7 @@ func SendApproveMsg(receiverId int64, name string, companyId int64, chanceId int
54 Message: fmt.Sprintf(format, chanceType.Name), 54 Message: fmt.Sprintf(format, chanceType.Name),
55 SourceId: chanceId, 55 SourceId: chanceId,
56 SourceType: protocol.SourceTypeChance, 56 SourceType: protocol.SourceTypeChance,
57 - IsPublic: 0, 57 + IsPublic: 1,
58 CreateAt: time.Now(), 58 CreateAt: time.Now(),
59 ChanceId: chanceId, 59 ChanceId: chanceId,
60 Data: common.AssertJson(data), 60 Data: common.AssertJson(data),
@@ -108,7 +108,7 @@ func sendApproveMsg(header *protocol.RequestHeader, receiverId int64, name strin @@ -108,7 +108,7 @@ func sendApproveMsg(header *protocol.RequestHeader, receiverId int64, name strin
108 Message: fmt.Sprintf(format, chanceType.Name), 108 Message: fmt.Sprintf(format, chanceType.Name),
109 SourceId: chanceId, 109 SourceId: chanceId,
110 SourceType: protocol.SourceTypeChance, 110 SourceType: protocol.SourceTypeChance,
111 - IsPublic: 0, 111 + IsPublic: 1,
112 CreateAt: time.Now(), 112 CreateAt: time.Now(),
113 ChanceId: chanceId, 113 ChanceId: chanceId,
114 //Data: jsonData, , 114 //Data: jsonData, ,
@@ -141,7 +141,7 @@ func SendApproveMsgByFormat(header *protocol.RequestHeader, receiverId int64, ch @@ -141,7 +141,7 @@ func SendApproveMsgByFormat(header *protocol.RequestHeader, receiverId int64, ch
141 Message: message, //fmt.Sprintf(message, chanceType.Name), 141 Message: message, //fmt.Sprintf(message, chanceType.Name),
142 SourceId: chanceId, 142 SourceId: chanceId,
143 SourceType: protocol.SourceTypeChance, 143 SourceType: protocol.SourceTypeChance,
144 - IsPublic: 0, 144 + IsPublic: 1,
145 CreateAt: time.Now(), 145 CreateAt: time.Now(),
146 Data: common.AssertJson(data), 146 Data: common.AssertJson(data),
147 SenderUserId: header.UserId, 147 SenderUserId: header.UserId,
@@ -194,7 +194,7 @@ func SendMsg(receiverId int64, name string, companyId int64, sourceId int64, sou @@ -194,7 +194,7 @@ func SendMsg(receiverId int64, name string, companyId int64, sourceId int64, sou
194 Message: message, 194 Message: message,
195 SourceId: sourceId, 195 SourceId: sourceId,
196 SourceType: sourceType, 196 SourceType: sourceType,
197 - IsPublic: 0, 197 + IsPublic: 1,
198 CreateAt: time.Now(), 198 CreateAt: time.Now(),
199 ChanceId: chanceId, 199 ChanceId: chanceId,
200 } 200 }
@@ -218,7 +218,7 @@ func SendMsgWithData(receiverId int64, name string, companyId int64, sourceId in @@ -218,7 +218,7 @@ func SendMsgWithData(receiverId int64, name string, companyId int64, sourceId in
218 Message: message, 218 Message: message,
219 SourceId: sourceId, 219 SourceId: sourceId,
220 SourceType: sourceType, 220 SourceType: sourceType,
221 - IsPublic: 0, 221 + IsPublic: 1,
222 CreateAt: time.Now(), 222 CreateAt: time.Now(),
223 ChanceId: chanceId, 223 ChanceId: chanceId,
224 Data: common.AssertJson(msgData), 224 Data: common.AssertJson(msgData),
@@ -244,7 +244,7 @@ func SendMsgWithHeader(header *protocol.RequestHeader, receiverId int64, name st @@ -244,7 +244,7 @@ func SendMsgWithHeader(header *protocol.RequestHeader, receiverId int64, name st
244 Message: message, 244 Message: message,
245 SourceId: sourceId, 245 SourceId: sourceId,
246 SourceType: sourceType, 246 SourceType: sourceType,
247 - IsPublic: 0, 247 + IsPublic: 1,
248 CreateAt: time.Now(), 248 CreateAt: time.Now(),
249 ChanceId: chanceId, 249 ChanceId: chanceId,
250 } 250 }
@@ -51,6 +51,11 @@ func MessageCenter(header *protocol.RequestHeader, request *protocol.MessageCent @@ -51,6 +51,11 @@ func MessageCenter(header *protocol.RequestHeader, request *protocol.MessageCent
51 interactionCount += item.MsgTotal 51 interactionCount += item.MsgTotal
52 continue 52 continue
53 } 53 }
  54 + if item.MsgType == protocol.MsgTypeBulletin {
  55 + var tmpTotal int
  56 + models.GetBulletinUserMsgTotals(header.UserId, header.CompanyId, request.MsgType, &tmpTotal)
  57 + item.MsgTotal = tmpTotal
  58 + }
54 list = append(list, item) 59 list = append(list, item)
55 } 60 }
56 if interactionCount > 0 { 61 if interactionCount > 0 {