ZtServer.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: xiaofeng
  5. * Date: 2018/4/24
  6. * Time: 下午3:51
  7. */
  8. namespace frontend\server;
  9. use Yii;
  10. use common\models\ListHouse;
  11. class ZtServer
  12. {
  13. public function GuoQingZhongQiu()
  14. {
  15. //获取推送楼盘
  16. $model = new ListHouse();
  17. $data = [];
  18. $data['one'] =$this->disposeHouse($model->zhongQiuGuoQing(101));
  19. $data['two'] =$this->disposeHouse($model->zhongQiuGuoQing(102));
  20. $data['three'] =$this->disposeHouse($model->zhongQiuGuoQing(103));
  21. return $data;
  22. }
  23. public function GuoQingZhongQiuY()
  24. {
  25. //获取推送楼盘
  26. $model = new ListHouse();
  27. $data = [];
  28. $data['one'] =$this->disposeHouse($model->zhongQiuGuoQing(101));
  29. $data['two'] =$this->disposeHouse($model->zhongQiuGuoQing(102));
  30. return $data;
  31. }
  32. public function disposeHouse($data)
  33. {
  34. if (!empty($data)) {
  35. foreach ($data as &$val) {
  36. $val['thumb'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['houses'] . $val['thumb'] . '/same';
  37. $val['tel'] = $this->RandTel($val['city']);
  38. }
  39. }
  40. return $data;
  41. }
  42. //楼盘随机电话
  43. public function RandTel($city)
  44. {
  45. $tel = new \common\models\CategoryTelCity();
  46. $tel->cid = $city;
  47. $telModel = $tel->CityTelOne();
  48. if ($telModel != null) {
  49. $telArr = explode(',', $telModel['tel']);
  50. $randNum = array_rand($telArr, 1);
  51. if (!empty($telArr[$randNum])) {
  52. return $telArr[$randNum];
  53. }
  54. }
  55. return Yii::$app->params['default_dialtel'];
  56. }
  57. }