/** * 忽略 * * @param array $notice */ public function ignoreNotice($notice, $ignore = 1) { if (!$notice) { return false; } Wind::import('SRV:message.dm.PwMessageNoticesDm'); $dm = new PwMessageNoticesDm(); $dm->setIgnore($ignore); Wekit::load('message.PwMessageNotices')->batchUpdateNoticeByUidAndType($notice['uid'], $notice['typeid'], $dm); return Wekit::load('message.srv.PwNoticeService')->setIgnoreNotice($notice['typeid'], $notice['uid'], $ignore); }
/** * 根据uid和type更新通知 * * @param array $ids * @param PwMessageNoticesDm $dm * return bool */ public function batchUpdateNoticeByUidAndType($uid, $type, $dm) { $uid = intval($uid); $type = intval($type); if ($uid < 1 || $type < 1 || ($result = $dm->beforeUpdate()) !== true) { return $result; } return $this->_getDao()->batchUpdateNoticeByUidAndType($uid, $type, $dm->getData()); }
/** * * (忽略|取消忽略)一个通知 */ public function ignoreNotice($id, $ignore = 1) { $id = intval($id); $ignore = intval($ignore); $ignore = $ignore ? 1 : 0; $notice = $this->_getNoticesDs()->getNotice($id); if (!$notice) { return false; } else { Wind::import('SRV:message.dm.PwMessageNoticesDm'); $dm = new PwMessageNoticesDm($id); $dm->setIgnore($ignore); $this->_getNoticesDs()->updateNotice($dm); //ingore to app $noticeAction = $this->_getActionByTypeid($notice['typeid']); if ($noticeAction && $noticeAction->ignoreNotice) { $noticeAction->ignoreNotice($notice, $ignore); } return true; } }
/** * * 设置已读 * @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); } } }