NewsServer.php 2.5 KB

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