Example #1
0
 public function run()
 {
     $id = intval($this->getDataItem('id', 0));
     $page = intval($this->getDataItem('page', 1));
     $limit = $this->getConfig()->limit;
     if ($id == 0) {
         return $this->errorLog(ResultStatus::URL_PARAM_CANNOT_EMPTY, 'URL参数不全');
     }
     $list = ActivityComment::query()->columns(['comment_id', 'comment_content', 'addtime', 'comment_user_id user_id', 'u.user_nickname', 'u.user_gender', 'u.user_cover'])->leftJoin('\\Apps\\Common\\Models\\UserBase', 'u.user_id = \\Apps\\Common\\Models\\ActivityComment.comment_user_id', 'u')->where('activity_id = ' . $id)->orderBy('addtime DESC')->limit($limit, ($page - 1) * $limit)->execute()->toArray();
     foreach ($list as $k => $val) {
         $list[$k]['user_cover'] = PicUrl::ActivityCover($val['user_cover'], $this->getDi());
     }
     $this->setResult($list);
 }
Example #2
0
 /**
  * 活动预览
  * @date: 2016年1月12日 
  * @author: chenxiaolin
  */
 public function activityPreviewAction()
 {
     $id = $this->request->getQuery('id');
     if (empty($id)) {
         echo '活动不存在!';
         $this->view->disable();
         return;
     }
     //活动内容
     $date = date('Y-m-d H:i:s');
     $activity = Activity::query()->columns(['Apps\\Common\\Models\\Activity.activity_id', 'activity_title', 'activity_cover', 'activity_intro', 'out_link', 'activity_addtime', 'views', 'comments'])->where("activity_id = {$id} and activity_state in (0,1)")->execute()->getFirst();
     if (!$activity) {
         echo '活动不存在!';
         $this->view->disable();
         return;
     } else {
         $activity = $activity->toArray();
     }
     $activity['activity_cover'] = PicUrl::ActivityCover($activity['activity_cover'], $this->getDI());
     //活动回复
     $comment = ActivityComment::query()->columns(['comment_content', 'user.user_nickname', 'user.user_cover', 'user.user_gender'])->leftJoin('Apps\\Common\\Models\\UserBase', 'Apps\\Common\\Models\\ActivityComment.comment_user_id = user.user_id', 'user')->where("Apps\\Common\\Models\\ActivityComment.activity_id = {$id} and Apps\\Common\\Models\\ActivityComment.state = 1")->order('addtime desc')->execute()->toArray();
     foreach ($comment as $k => $v) {
         $comment[$k]['user_cover'] = PicUrl::UserCover($comment[$k]['user_cover'], $this->getDI());
     }
     $lastTime = ActivityComment::maximum(array("activity_id = {$id} and state = 1", 'column' => 'addtime'));
     //美人儿已阅处显示的头像
     $covers = ActivityComment::query()->columns(['distinct comment_user_id', 'user.user_cover'])->leftJoin('Apps\\Common\\Models\\UserBase', 'Apps\\Common\\Models\\ActivityComment.comment_user_id = user.user_id', 'user')->where("Apps\\Common\\Models\\ActivityComment.activity_id = {$id} and Apps\\Common\\Models\\ActivityComment.state = 1")->order('addtime desc')->limit(7)->execute()->toArray();
     foreach ($covers as $k => $v) {
         $covers[$k]['user_cover'] = PicUrl::UserCover($covers[$k]['user_cover'], $this->getDI());
     }
     $this->view->setVar('activity', $activity);
     $this->view->setVar('comment', $comment);
     $this->view->setVar('lastTime', $lastTime);
     $this->view->setVar('covers', $covers);
     $this->tag->setTitle($activity->activity_title);
 }
 /**
  * 查看活动回复列表
  * @date: 2016年1月5日 
  * @author: chenxiaolin
  */
 public function commentListAction()
 {
     $this->setLeftNav('commentList');
     $req = $this->request;
     $page = intval($req->getQuery('page', null, 1));
     $page = $page > 0 ? $page : 1;
     $limit = $this->pageNavLimit;
     $offset = $limit * ($page - 1);
     $activity_id = $req->getQuery('id');
     $user_name = $req->getQuery('user_name');
     $comment_content = $req->getQuery('comment_content');
     $addtime = $req->getQuery('addtime');
     $timeSlotarr = explode("至", $addtime);
     $columns = ['comment_id', 'comment_content', 'addtime', 'user.user_nickname as user_name'];
     $where = [];
     $bind = [];
     $medal = [];
     //通过用户名筛选数据
     if ($user_name != '') {
         $user = UserBase::query()->columns(['user_id'])->where("user_nickname like '%" . $user_name . "%'")->execute();
         foreach ($user as $k => $v) {
             $user_id .= $v['user_id'] . ',';
         }
         $user_id = rtrim($user_id, ",");
         if (!empty($user_id)) {
             $where[] = "comment_user_id in ( {$user_id} )";
         } else {
             $where[] = "comment_user_id in ( 0 )";
         }
         $this->view->setVar("user_name", $user_name);
     }
     //通过评论内容筛选数据
     if ($comment_content != '') {
         $where[] = "comment_content like '%" . $comment_content . "%'";
         $this->view->setVar("comment_content", $comment_content);
     }
     //通过评论时间筛选数据
     if ($addtime) {
         $where[] = "addtime > '" . $timeSlotarr[0] . "'";
         $where[] = "addtime < '" . $timeSlotarr[1] . "'";
         $this->view->setVar("addtime", $addtime);
     }
     $where[] = "activity_id = {$activity_id} and state = 1";
     $whereStr = implode(' AND ', $where);
     $query = ActivityComment::query()->columns($columns)->leftJoin('Apps\\Common\\Models\\UserBase', 'user.user_id=Apps\\Common\\Models\\ActivityComment.comment_user_id', 'user');
     if (!empty($whereStr)) {
         $query = $query->where($whereStr);
     }
     if (count($bind) > 0) {
         $query = $query->bind($bind);
     }
     $data = $query->orderBy('addtime DESC')->limit($limit, $offset)->execute();
     /* var_dump($data);
        exit;
         */
     // 总数
     $total = ActivityComment::count(['conditions' => $whereStr, 'bind' => $bind]);
     $this->view->setVar('total', $total);
     $this->view->setVar('page', $page);
     $this->view->setVar('limit', $limit);
     $this->view->setVar('data', $data);
     $this->view->setVar('activity_id', $activity_id);
 }