NewsServer.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: xiaofeng
  5. * Date: 2018/4/22
  6. * Time: 下午6:20
  7. */
  8. namespace mobile\server;
  9. use Yii;
  10. use common\models\News;
  11. use common\models\CategoryNews;
  12. use common\models\PushmNews;
  13. use common\models\House;
  14. class NewsServer
  15. {
  16. /*
  17. * 新闻资讯首页-推送部分
  18. * */
  19. public function Pushinfo($type)
  20. {
  21. $pushModel = new PushmNews();
  22. $pushModel->type = $type;
  23. switch ($type)
  24. {
  25. case 1:
  26. $limit = 3; //
  27. break;
  28. case 2:
  29. $limit = 3;
  30. break;
  31. case 3:
  32. $limit = 2;
  33. break;
  34. default:
  35. return false;
  36. break;
  37. }
  38. $arr = $pushModel->Homegetlist($limit);
  39. return $arr;
  40. }
  41. /*
  42. * 资讯首页- 资讯栏目 and 资讯栏目所属资讯
  43. * */
  44. public function ColumnInfo()
  45. {
  46. $model = new CategoryNews();
  47. return $model->getList([],['news_name','id','img'],1);
  48. }
  49. // public func
  50. /*
  51. * 点击量 -- 热文
  52. * */
  53. public function clickList($num)
  54. {
  55. $model = new News();
  56. return $model->Clicks($num);
  57. }
  58. /*
  59. * 资讯详情
  60. * */
  61. public function NewsDetails($input)
  62. {
  63. $model = new News();
  64. if(is_numeric($input['nid']))
  65. {
  66. $info = $model->FindById($input['nid']);
  67. if(!empty($info))
  68. {
  69. //$ip = new IpServer();
  70. //$ipaddress = $ip->add($input['nid']);
  71. //if($ipaddress === true)
  72. //{
  73. $info->clicks = ++$info->clicks;
  74. $info->true_click = ++$info->true_click;
  75. $info->save(false);
  76. //}
  77. return $info;
  78. }
  79. }
  80. }
  81. /*
  82. * 相关资讯
  83. * */
  84. public function Relevant($category)
  85. {
  86. $model = new News();
  87. $model->category = $category;
  88. return $model->Clicks(4);
  89. }
  90. /*
  91. * 根据区域,随机推荐楼盘
  92. * */
  93. public function NewsCityHouse($city)
  94. {
  95. $model = new House();
  96. $model->city = $city;
  97. $model->is_push=2;
  98. return $model->ispush(3);
  99. }
  100. }