123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- <?php
- /**
- * Created by PhpStorm.
- * User: xiaofeng
- * Date: 2018/4/22
- * Time: 下午6:20
- */
- namespace frontend\server;
- use Yii;
- use common\models\News;
- use common\models\CategoryNews;
- use common\models\PushNews;
- use common\models\PushCharacteristic;
- use common\models\House;
- class NewsServer
- {
- /*
- * 新闻资讯首页-推送部分
- * */
- public function Pushinfo($type)
- {
- $pushModel = new PushNews();
- $pushModel->type = $type;
- switch ($type)
- {
- case 1:
- $limit = 3; //
- break;
- case 2:
- $limit = 5;
- break;
- case 3:
- $limit = 2;
- break;
- default:
- return false;
- break;
- }
- $arr = $pushModel->Homegetlist($limit);
- return $arr;
- }
- /*
- * 资讯首页- 资讯栏目 and 资讯栏目所属资讯
- * */
- public function ColumnInfo()
- {
- $model = new CategoryNews();
- return $model->getList([],['news_name','id'],1);
- }
- /*
- * 热点直达
- * */
- public function hotArrive()
- {
- $ctype = new \common\models\PushCharacteristic();
- return $ctype->Homegetlist(10);
- }
- /*
- * 点击量 -- 热文
- * */
- public function clickList($num)
- {
- $model = new News();
- return $model->Clicks($num);
- }
- /*
- * 资讯详情
- * */
- public function NewsDetails($input)
- {
- $model = new News();
-
- if(is_numeric($input['nid']))
- {
- $info = $model->FindById($input['nid']);
- if(!empty($info))
- {
- $ip = new IpServer();
- $ipaddress = $ip->add();
- if($ipaddress === true)
- {
- $info->true_click = ++$info->true_click;
- $info->clicks = ++$info->clicks;
- $info->save(false);
- }
-
- return $info;
- }
- }
- }
- /*
- * 相关资讯
- * */
- public function Relevant($category)
- {
- $model = new News();
- $model->category = $category;
- return $model->Clicks(4);
- }
- /*
- * 根据区域,随机推荐楼盘
- * */
- public function NewsCityHouse($city)
- {
- $model = new House();
- $model->city = $city;
- return $model->randList(4);
- }
- /*
- * 获取最新资讯
- */
- public function GetNews($limit)
- {
- $model = new News();
- $query = $model::find();
- $query->select(['pfg_news.id','pfg_news.subject','pfg_news.create_at','pfg_category_news.news_name']);
- $query->andWhere(['pfg_news.del'=>1,'pfg_news.state'=>1]);
- $query->leftJoin('pfg_category_news','pfg_news.category = pfg_category_news.id');
- $query->limit = $limit;
- $query->orderBy(['pfg_news.create_at'=>SORT_DESC,'pfg_news.id'=>SORT_DESC]);
- return $query->asArray()->all();
- }
- }
|