IndexServer.php 7.1 KB

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