ZtController.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <?php
  2. /*
  3. Created by PhpStorm.
  4. User: xiaofeng
  5. Date: 2018/6/10
  6. Time: 下午3:15
  7. */
  8. namespace frontend\controllers;
  9. use common\models\House;
  10. use common\models\SpecialTopic;
  11. use frontend\base\CommonController;
  12. use Yii;
  13. use frontend\server\ZtServer;
  14. class ZtController extends CommonController
  15. {
  16. // 元旦专题
  17. public function actionNewyear()
  18. {
  19. return $this->render('newyear');
  20. }
  21. // 新年专题
  22. public function actionNewyearzt()
  23. {
  24. return $this->render('newyearzt');
  25. }
  26. // 碧桂园鼎龙湾专题
  27. public function actionBgydlw()
  28. {
  29. return $this->render('bgydlw');
  30. }
  31. /*金九银十专题*/
  32. public function actionJjys()
  33. {
  34. return $this->render('jjys');
  35. }
  36. /*国庆专题*/
  37. public function actionNationalzt()
  38. {
  39. return $this->render('nationalzt');
  40. }
  41. /*融创高隆湾 3天2晚游*/
  42. public function actionRcglw()
  43. {
  44. return $this->render('rcglw');
  45. }
  46. // 春节专题
  47. public function actionChunjiezt()
  48. {
  49. $ztmodel = new \common\models\SpecialTopic();
  50. $row = $ztmodel::findOne(7);
  51. $model = new \common\models\House();
  52. $cmodel = new \common\models\CategoryCity();
  53. $city = '';
  54. $house = '';
  55. $imgUrl = Yii::$app->params['httpImg']['host'] . Yii::$app->params['httpImg']['push_lb'];
  56. if (!empty(json_decode($row->hids, true))) {
  57. $hid = json_decode($row->hids, true);
  58. $query = $model::find();
  59. $query->andWhere(['pfg_house.id' => $hid]);
  60. $query->joinWith(['housedetail']);
  61. $query->with(['cityName']);
  62. $query->orderBy(['pfg_house.sort' => SORT_DESC]);
  63. $house = $query->asArray()->all();
  64. $pcity = array_column($house, 'province');
  65. $cquey = $cmodel::find();
  66. $cquey->select(['id', 'city_name']);
  67. $cquey->andWhere(['id' => $pcity]);
  68. $cquey->orderBy(['sort' => SORT_DESC]);
  69. $city = array_column($cquey->asArray()->all(), 'city_name', 'id');
  70. }
  71. empty($row->pc_img) ? '' : $row->pc_img = $imgUrl . $row->pc_img;
  72. return $this->render('chunjiezt', ['city' => $city, 'house' => $house, 'model' => $row]);
  73. }
  74. /**
  75. * 线上售楼处专题
  76. * @return string
  77. */
  78. public function actionSellhousezt()
  79. {
  80. $row = SpecialTopic::findOne(8);
  81. if (!empty($row)) {
  82. $hid = json_decode($row['hids'], true);
  83. $house = House::find()->select(['pfg_house.id', 'pfg_house.name', 'pfg_house_detail.address', 'pfg_house.thumb',
  84. 'pfg_house_detail.preferential_zt', 'pfg_house.sale_price', 'pfg_house_detail.price_unit', 'pfg_category_city.pid'])
  85. ->leftJoin('pfg_house_detail', 'pfg_house.id = pfg_house_detail.hid')
  86. ->leftJoin('pfg_category_city', 'pfg_house.city = pfg_category_city.id')
  87. ->andWhere(['pfg_house.id' => $hid])
  88. ->orderBy(['pfg_house.sort' => SORT_DESC])->asArray()->all();
  89. }
  90. return $this->render('sellhousezt', ['house' => $house, 'row' => $row]);
  91. }
  92. //楼盘随机电话
  93. public function RandTel($city)
  94. {
  95. $tel = new \common\models\CategoryTelCity();
  96. $tel->cid = $city;
  97. $telModel = $tel->CityTelOne();
  98. if ($telModel != null) {
  99. $telArr = explode(',', $telModel['tel']);
  100. $randNum = array_rand($telArr, 1);
  101. if (!empty($telArr[$randNum])) {
  102. return $telArr[$randNum];
  103. }
  104. }
  105. return Yii::$app->params['default_dialtel'];
  106. }
  107. // 写字楼专题
  108. public function actionOffice()
  109. {
  110. $cityList = \common\models\PushplaceType::find()->where(['type' => 4, 'state' => 1])->limit(2)->orderBy(['sort' => SORT_DESC])->select('id,title')->asArray()->all();
  111. foreach ($cityList as &$val) {
  112. $val['house_list'] = \common\models\PushhouseType::find()
  113. ->select('pfg_pushhouse_type.*,pfg_house.name,pfg_house.city,pfg_house.sale_price,pfg_house.thumb,pfg_house_detail.price_unit,pfg_house_detail.address,pfg_house_detail.preferential,pfg_house_detail.preferential_price,pfg_house_detail.preferential_zt')
  114. ->where(['pfg_pushhouse_type.previd' => $val['id'], 'pfg_pushhouse_type.type' => 4])
  115. ->innerJoin('pfg_house', 'pfg_house.id = pfg_pushhouse_type.hid')
  116. ->innerJoin('pfg_house_detail', 'pfg_house_detail.hid = pfg_house.id')
  117. ->orderBy(['pfg_pushhouse_type.sort' => SORT_DESC])->asArray()->all();
  118. foreach ($val['house_list'] as &$value) {
  119. $value['thumb'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['houses'] . $value['thumb'] . '/same';
  120. $value['tel'] = $this->RandTel($value['city']);
  121. }
  122. }
  123. if (!empty($cityList)) {
  124. $cityList[0]['house_list'] = array_chunk($cityList[0]['house_list'], 3);
  125. }
  126. return $this->render('office', ['cityList' => $cityList]);
  127. }
  128. // 国庆中秋专题
  129. public function actionAutumnzt()
  130. {
  131. $server = new ZtServer();
  132. $data = $server->GuoQingZhongQiu();
  133. return $this->render('autumnzt',['data'=>$data]);
  134. }
  135. }