IndexServer.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: xiaofeng
  5. * Date: 2018/6/9
  6. * Time: 上午11:12
  7. */
  8. namespace wechat\server;
  9. use common\models\CategoryCity;
  10. use common\models\MiniRotation;
  11. use common\models\PushmRotation;
  12. use common\models\PushmCharacteristic;
  13. use common\models\PushmHouse;
  14. use common\models\PushmRecommend;
  15. use common\models\Characteristic;
  16. use common\models\HousesPrice;
  17. use Yii;
  18. class IndexServer
  19. {
  20. /*
  21. * 轮播图
  22. * */
  23. public function Lunbo()
  24. {
  25. $model = new MiniRotation();
  26. if(Yii::$app->hostserver->hostId != 0)
  27. {
  28. $model->city = Yii::$app->hostserver->hostId;
  29. $result=$model->HomeGetList();
  30. if(empty($result)){
  31. return $model->GetAllList();
  32. }else{
  33. return $model->HomeGetList();
  34. }
  35. }
  36. return $model->GetAllList();
  37. }
  38. /*
  39. * 搜索框-热门筛选
  40. * */
  41. public function shaixuan()
  42. {
  43. $model = new PushmHouse();
  44. $model->type = 2;
  45. $rows = $model->Homegetlist(10);
  46. if(!empty($rows))
  47. {
  48. return $rows;
  49. }
  50. }
  51. /*
  52. * 搜索框 - 价格
  53. * */
  54. public function PriceList()
  55. {
  56. $PriceModel = new HousesPrice();
  57. $PriceList = $PriceModel->getList([],['price','id']);
  58. if($PriceList != null)
  59. {
  60. return $PriceList;
  61. }
  62. }
  63. /*
  64. * 特色推荐
  65. * */
  66. public function tese()
  67. {
  68. $model = new PushmCharacteristic();
  69. return $model->Homegetlist(3);
  70. }
  71. /*
  72. * 热销楼盘
  73. * */
  74. public function Hothouse($input)
  75. {
  76. $row = [];
  77. if(empty($input['city']))
  78. {
  79. $model = new PushmHouse();
  80. $model->type = $input['type'];
  81. $rows = $model->Homegetlist(6,$input['rand']);
  82. }
  83. else
  84. {
  85. $id = CategoryCity::find()->select(['id'])->andWhere(['pid'=>$input['city']])->asArray()->all();
  86. $city = array_column($id,'id');
  87. $h = new PushmHouse();
  88. $h->type = $input['type'];
  89. $rows = $h->CityGetHome($city);
  90. }
  91. // if(isset($input['city']) && $input['city'] == 0)
  92. // {
  93. // $model = new PushmHouse();
  94. // $model->type = $input['type'];
  95. // $rows = $model->Homegetlist(6,$input['rand']);
  96. // }
  97. // else if ( $input['city'] != 0)
  98. // {
  99. // $id = CategoryCity::find()->select(['id'])->andWhere(['pid'=>$input['city']])->asArray()->all();
  100. // $city = array_column($id,'id');
  101. // $h = new PushmHouse();
  102. // $h->type = $input['type'];
  103. // $rows = $h->CityGetHome($city);
  104. // }
  105. if(!empty($rows))
  106. {
  107. foreach ($rows as &$val)
  108. {
  109. if(!empty($val['characteristic']))
  110. {
  111. // $val['characteristic'] = $this->Subject(json_decode($val['characteristic']),3);
  112. $val['characteristic'] = \common\fm\HouseHandle::ChangeCharacteristic($val['characteristic']);
  113. }
  114. // $val['tel'] = $this->RandTel($val['cid']);
  115. $val['tel'] = \common\fm\HouseHandle::ChangeCityTel($val['cid']);
  116. }
  117. }
  118. return $rows;
  119. }
  120. /*
  121. * 品房推荐
  122. * */
  123. public function tuijian()
  124. {
  125. $model = new PushmRecommend();
  126. return $model->Homegetlist(10);
  127. }
  128. /*
  129. * 热门地区
  130. * */
  131. public function hotCity()
  132. {
  133. $model = new \common\models\PushmCity();
  134. $model->type = 1;
  135. $rows = $model->Homegetlist(6);
  136. return $rows;
  137. }
  138. //资讯
  139. public function newslist()
  140. {
  141. $model = new \common\models\PushmNews();
  142. $model->type = 1;
  143. return $model->Homegetlist(4);
  144. }
  145. //资讯栏目
  146. public function NewsColumn()
  147. {
  148. $model = new \common\models\PushmNewscolumn();
  149. return $model->Homegetlist(4);
  150. }
  151. //特色主题 超过3个随机返回3个元素
  152. public function Subject($id,$num = 3)
  153. {
  154. $char = new Characteristic();
  155. if(is_array($id) && !empty($id))
  156. {
  157. $char->id = $id;
  158. $charMode = array_column($char->getList([],['id','name']),'name','id');
  159. if($charMode != null)
  160. {
  161. $count = count($charMode);
  162. $arr = [];
  163. if($count >= 3)
  164. {
  165. $rand = array_rand($charMode,$num);
  166. foreach ($rand as $key=>$val)
  167. {
  168. $arr[$key] = $charMode[$val];
  169. }
  170. }
  171. else
  172. {
  173. $arr = $charMode;
  174. }
  175. return $arr;
  176. }
  177. }
  178. }
  179. //楼盘随机电话
  180. public function RandTel($city)
  181. {
  182. $tel = new \common\models\CategoryTelCity();
  183. $tel->cid = $city;
  184. $telModel = $tel->CityTelOne();
  185. if($telModel != null)
  186. {
  187. $telArr = explode(',',$telModel['tel']);
  188. $randNum = array_rand($telArr,1);
  189. return $telArr[$randNum];
  190. }
  191. }
  192. }