コード例 #1
0
 /**
  * 
  * 设置已读
  * @param int $unreadCount
  * @param array $noticeList
  */
 private function _readNoticeList($unreadCount, $noticeList)
 {
     if ($unreadCount && $noticeList) {
         //更新用户的通知未读数
         $readnum = 0;
         //本次阅读数
         Wind::import('SRV:message.dm.PwMessageNoticesDm');
         $dm = new PwMessageNoticesDm();
         $dm->setRead(1);
         $ids = array();
         foreach ($noticeList as $v) {
             if ($v['is_read']) {
                 continue;
             }
             $readnum++;
             $ids[] = $v['id'];
         }
         $ids && $this->_getNoticeDs()->batchUpdateNotice($ids, $dm);
         $newUnreadCount = $unreadCount - $readnum;
         if ($newUnreadCount != $unreadCount) {
             Wind::import('SRV:user.dm.PwUserInfoDm');
             $dm = new PwUserInfoDm($this->loginUser->uid);
             $dm->setNoticeCount($newUnreadCount);
             $this->_getUserDs()->editUser($dm, PwUser::FETCH_DATA);
         }
     }
 }