作者 linmadan

修复消息读取数目bug

@@ -65,6 +65,7 @@ func (dao *EmployeeDao) CalculatePersonUnReadNotification(uid int64) (map[string @@ -65,6 +65,7 @@ func (dao *EmployeeDao) CalculatePersonUnReadNotification(uid int64) (map[string
65 if count, err := tx.Model(sentNotificationModel).Relation("Notification"). 65 if count, err := tx.Model(sentNotificationModel).Relation("Notification").
66 Where(`sent_notification.receiver @> '{"uid":?}'`, uid). 66 Where(`sent_notification.receiver @> '{"uid":?}'`, uid).
67 Where("notification.notification_type = ?", domain.NOTIFICATION_TYPE_SYSTEM). 67 Where("notification.notification_type = ?", domain.NOTIFICATION_TYPE_SYSTEM).
  68 + Where("sent_notification.is_read = ?", false).
68 Count(); err != nil { 69 Count(); err != nil {
69 return nil, err 70 return nil, err
70 } else { 71 } else {
@@ -73,6 +74,7 @@ func (dao *EmployeeDao) CalculatePersonUnReadNotification(uid int64) (map[string @@ -73,6 +74,7 @@ func (dao *EmployeeDao) CalculatePersonUnReadNotification(uid int64) (map[string
73 if count, err := tx.Model(sentNotificationModel).Relation("Notification"). 74 if count, err := tx.Model(sentNotificationModel).Relation("Notification").
74 Where(`sent_notification.receiver @> '{"uid":?}'`, uid). 75 Where(`sent_notification.receiver @> '{"uid":?}'`, uid).
75 Where("notification.notification_type = ?", domain.NOTIFICATION_TYPE_INTERACTION). 76 Where("notification.notification_type = ?", domain.NOTIFICATION_TYPE_INTERACTION).
  77 + Where("sent_notification.is_read = ?", false).
76 Count(); err != nil { 78 Count(); err != nil {
77 return nil, err 79 return nil, err
78 } else { 80 } else {
@@ -15,7 +15,7 @@ func (dao *NotificationDao) ReadAllUnReadSentNotification(receiverId int64) (int @@ -15,7 +15,7 @@ func (dao *NotificationDao) ReadAllUnReadSentNotification(receiverId int64) (int
15 tx := dao.transactionContext.PgTx 15 tx := dao.transactionContext.PgTx
16 result, err := tx.Query( 16 result, err := tx.Query(
17 pg.Scan(), 17 pg.Scan(),
18 - `UPDATE sent_notifications SET is_read=?, read_time=? WHERE receiver @> '{"uid":?}'`, 18 + `UPDATE sent_notifications SET is_read=?, read_time=? WHERE receiver @> '{"uid":?}' AND is_read=false`,
19 true, time.Now(), receiverId) 19 true, time.Now(), receiverId)
20 if err != nil { 20 if err != nil {
21 return 0, err 21 return 0, err