ZtController.php 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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 backend\base\Help;
  10. use common\models\House;
  11. use common\models\SpecialTopic;
  12. use frontend\base\CommonController;
  13. use Yii;
  14. use frontend\server\ZtServer;
  15. class ZtController extends CommonController
  16. {
  17. public $enableCsrfValidation = false;
  18. // 元旦专题
  19. public function actionNewyear()
  20. {
  21. return $this->render('newyear');
  22. }
  23. // 新年专题
  24. public function actionNewyearzt()
  25. {
  26. return $this->render('newyearzt');
  27. }
  28. // 碧桂园鼎龙湾专题
  29. public function actionBgydlw()
  30. {
  31. return $this->render('bgydlw');
  32. }
  33. /*金九银十专题*/
  34. public function actionJjys()
  35. {
  36. return $this->render('jjys');
  37. }
  38. /*国庆专题*/
  39. public function actionNationalzt()
  40. {
  41. return $this->render('nationalzt');
  42. }
  43. /*融创高隆湾 3天2晚游*/
  44. public function actionRcglw()
  45. {
  46. return $this->render('rcglw');
  47. }
  48. // 春节专题
  49. public function actionChunjiezt()
  50. {
  51. $ztmodel = new \common\models\SpecialTopic();
  52. $row = $ztmodel::findOne(7);
  53. $model = new \common\models\House();
  54. $cmodel = new \common\models\CategoryCity();
  55. $city = '';
  56. $house = '';
  57. $imgUrl = Yii::$app->params['httpImg']['host'] . Yii::$app->params['httpImg']['push_lb'];
  58. if (!empty(json_decode($row->hids, true))) {
  59. $hid = json_decode($row->hids, true);
  60. $query = $model::find();
  61. $query->andWhere(['pfg_house.id' => $hid]);
  62. $query->joinWith(['housedetail']);
  63. $query->with(['cityName']);
  64. $query->orderBy(['pfg_house.sort' => SORT_DESC]);
  65. $house = $query->asArray()->all();
  66. $pcity = array_column($house, 'province');
  67. $cquey = $cmodel::find();
  68. $cquey->select(['id', 'city_name']);
  69. $cquey->andWhere(['id' => $pcity]);
  70. $cquey->orderBy(['sort' => SORT_DESC]);
  71. $city = array_column($cquey->asArray()->all(), 'city_name', 'id');
  72. }
  73. empty($row->pc_img) ? '' : $row->pc_img = $imgUrl . $row->pc_img;
  74. return $this->render('chunjiezt', ['city' => $city, 'house' => $house, 'model' => $row]);
  75. }
  76. /**
  77. * 线上售楼处专题
  78. * @return string
  79. */
  80. public function actionSellhousezt()
  81. {
  82. $row = SpecialTopic::findOne(8);
  83. if (!empty($row)) {
  84. $hid = json_decode($row['hids'], true);
  85. $house = House::find()->select(['pfg_house.id', 'pfg_house.name', 'pfg_house_detail.address', 'pfg_house.thumb',
  86. 'pfg_house_detail.preferential_zt', 'pfg_house.sale_price', 'pfg_house_detail.price_unit', 'pfg_category_city.pid'])
  87. ->leftJoin('pfg_house_detail', 'pfg_house.id = pfg_house_detail.hid')
  88. ->leftJoin('pfg_category_city', 'pfg_house.city = pfg_category_city.id')
  89. ->andWhere(['pfg_house.id' => $hid])
  90. ->orderBy(['pfg_house.sort' => SORT_DESC])->asArray()->all();
  91. }
  92. return $this->render('sellhousezt', ['house' => $house, 'row' => $row]);
  93. }
  94. //楼盘随机电话
  95. public function RandTel($city)
  96. {
  97. $tel = new \common\models\CategoryTelCity();
  98. $tel->cid = $city;
  99. $telModel = $tel->CityTelOne();
  100. if ($telModel != null) {
  101. $telArr = explode(',', $telModel['tel']);
  102. $randNum = array_rand($telArr, 1);
  103. if (!empty($telArr[$randNum])) {
  104. return $telArr[$randNum];
  105. }
  106. }
  107. return Yii::$app->params['default_dialtel'];
  108. }
  109. // 写字楼专题
  110. public function actionOffice()
  111. {
  112. $cityList = \common\models\PushplaceType::find()->where(['type' => 4, 'state' => 1])->limit(2)->orderBy(['sort' => SORT_DESC])->select('id,title')->asArray()->all();
  113. foreach ($cityList as &$val) {
  114. $val['house_list'] = \common\models\PushhouseType::find()
  115. ->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')
  116. ->where(['pfg_pushhouse_type.previd' => $val['id'], 'pfg_pushhouse_type.type' => 4])
  117. ->innerJoin('pfg_house', 'pfg_house.id = pfg_pushhouse_type.hid')
  118. ->innerJoin('pfg_house_detail', 'pfg_house_detail.hid = pfg_house.id')
  119. ->orderBy(['pfg_pushhouse_type.sort' => SORT_DESC])->asArray()->all();
  120. foreach ($val['house_list'] as &$value) {
  121. $value['thumb'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['houses'] . $value['thumb'] . '/same';
  122. $value['tel'] = $this->RandTel($value['city']);
  123. }
  124. }
  125. if (!empty($cityList)) {
  126. $cityList[0]['house_list'] = array_chunk($cityList[0]['house_list'], 3);
  127. }
  128. return $this->render('office', ['cityList' => $cityList]);
  129. }
  130. // 国庆中秋专题
  131. public function actionAutumnzt()
  132. {
  133. $server = new ZtServer();
  134. $data = $server->GuoQingZhongQiu();
  135. return $this->render('autumnzt',['data'=>$data]);
  136. }
  137. // 海南别墅专题
  138. public function actionHnbszt()
  139. {
  140. $row = new \common\models\PushplaceType();
  141. $city1 = $row->city1();
  142. $city2 = $row->city2();
  143. $hn_boutiquevilla = $row->boutiquevilla();
  144. $hn_city = \common\models\CategoryCity::find()->where(['pid'=>68])->select('id,city_name')->asArray()->all();
  145. $boutiquevillaList = [];
  146. foreach ($hn_boutiquevilla as $value){
  147. $boutiquevillaList[$value['id']] = (new \common\models\PushhouseType())->boutiquevillaList($value['id'],4);
  148. }
  149. $priceList = \common\models\HousePrice::find()->where(['del'=>1,'state'=>1])->orderBy(['sort'=>SORT_ASC])->asArray()->all();
  150. //别墅动态
  151. $villa_news = (new \common\models\PushnewsType())->getlist(4);
  152. foreach ($villa_news as &$value){
  153. $value['thumb'] = Yii::$app->params['httpImg']['host'] . Yii::$app->params['httpImg']['newsthumb'] . json_decode($value['thumb'],true)[0];
  154. $value['time'] = date('Y.m.d',$value['create_at']);
  155. }
  156. //获取最新资讯
  157. $new_news = \common\models\News::find()->select('id,subject,thumb,abstract,create_at')->where(['state'=>1,'del'=>1])->orderBy(['create_at'=>SORT_DESC,'id'=>SORT_DESC])->limit(4)->asArray()->all();
  158. foreach ($new_news as &$value){
  159. $value['thumb'] = Yii::$app->params['httpImg']['host'] . Yii::$app->params['httpImg']['newsthumb'] . json_decode($value['thumb'],true)[0];
  160. $value['time'] = date('Y.m.d',$value['create_at']);
  161. }
  162. return $this->render('hnbszt', [
  163. 'city1' => $city1,
  164. 'city2' => $city2,
  165. 'hn_city'=>$hn_city,
  166. 'priceList'=>$priceList,
  167. 'hn_boutiquevilla'=>$hn_boutiquevilla,
  168. 'boutiquevillaList'=>$boutiquevillaList,
  169. 'villa_news'=>$villa_news,
  170. 'new_news'=>$new_news
  171. ]);
  172. }
  173. //获取指定地区别墅TOP8
  174. public function actionGetprovince()
  175. {
  176. $id = Yii::$app->request->post('city');
  177. if(is_numeric($id)){
  178. $data = \common\models\PushhouseType::find()
  179. ->select(['pfg_house.id','pfg_house.name','pfg_house.sale_price','pfg_house.thumb','pfg_house_detail.price_unit','pfg_house_detail.preferential'])
  180. ->where(['pfg_pushhouse_type.previd' => $id,'pfg_pushhouse_type.type'=>2])
  181. ->innerJoin('pfg_house', 'pfg_house.id = pfg_pushhouse_type.hid')
  182. ->innerJoin('pfg_house_detail','pfg_house_detail.hid = pfg_house.id')
  183. ->limit(8)
  184. ->orderBy(['pfg_pushhouse_type.sort'=>SORT_DESC])->asArray()->all();
  185. foreach ($data as &$value){
  186. $value['thumb'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['houses'] . $value['thumb'] . '/same';
  187. }
  188. return Help::JsonData(Help::SUCCESS,'成功',0,$data);
  189. }else{
  190. return Help::JsonData(0,'成功',0,[]);
  191. }
  192. }
  193. //获取湾区列表
  194. public function actionGetgulfcitygl()
  195. {
  196. $id = Yii::$app->request->post('id');
  197. if(is_numeric($id)){
  198. $data = \common\models\PushhouseType::find()
  199. ->select('pfg_pushhouse_type.*,pfg_house.name,pfg_house.city,pfg_house.sale_price,pfg_house.thumb,pfg_house_detail.price_unit')
  200. ->where(['pfg_pushhouse_type.previd' => $id])
  201. ->innerJoin('pfg_house', 'pfg_house.id = pfg_pushhouse_type.hid')
  202. ->innerJoin('pfg_house_detail','pfg_house_detail.hid = pfg_house.id')
  203. ->limit(6)
  204. ->orderBy(['pfg_pushhouse_type.sort'=>SORT_DESC])->asArray()->all();
  205. foreach ($data as &$value){
  206. $value['thumb'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['houses'] . $value['thumb'] . '/same';
  207. $value['tel'] = $this->RandTel($value['city']);
  208. }
  209. return Help::JsonData(Help::SUCCESS,'成功',0,$data);
  210. }else{
  211. return Help::JsonData(0,'成功',0,[]);
  212. }
  213. }
  214. }