ZtController.php 6.5 KB

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