ZtController.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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. //获取指定地区别墅TOP8
  166. public function actionGetprovince()
  167. {
  168. $id = Yii::$app->request->post('city');
  169. if(is_numeric($id)){
  170. $data = \common\models\PushhouseType::find()
  171. ->select(['pfg_house.id','pfg_house.name','pfg_house.sale_price','pfg_house.thumb','pfg_house_detail.price_unit','pfg_house_detail.preferential'])
  172. ->where(['pfg_pushhouse_type.previd' => $id,'pfg_pushhouse_type.type'=>2])
  173. ->innerJoin('pfg_house', 'pfg_house.id = pfg_pushhouse_type.hid')
  174. ->innerJoin('pfg_house_detail','pfg_house_detail.hid = pfg_house.id')
  175. ->limit(8)
  176. ->orderBy(['pfg_pushhouse_type.sort'=>SORT_DESC])->asArray()->all();
  177. foreach ($data as &$value){
  178. $value['thumb'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['houses'] . $value['thumb'] . '/same';
  179. }
  180. return \backend\base\Help::JsonData(Help::SUCCESS,'成功',0,$data);
  181. }else{
  182. return Help::JsonData(0,'成功',0,[]);
  183. }
  184. }
  185. //获取湾区列表
  186. public function actionGetgulfcitygl()
  187. {
  188. $id = Yii::$app->request->post('id');
  189. if (is_numeric($id)) {
  190. $data = \common\models\PushhouseType::find()
  191. ->select('pfg_pushhouse_type.*,pfg_house.name,pfg_house.city,pfg_house.sale_price,pfg_house.thumb,pfg_house_detail.price_unit')
  192. ->where(['pfg_pushhouse_type.previd' => $id])
  193. ->innerJoin('pfg_house', 'pfg_house.id = pfg_pushhouse_type.hid')
  194. ->innerJoin('pfg_house_detail', 'pfg_house_detail.hid = pfg_house.id')
  195. ->limit(6)
  196. ->orderBy(['pfg_pushhouse_type.sort' => SORT_DESC])->asArray()->all();
  197. foreach ($data as &$value) {
  198. $value['thumb'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['houses'] . $value['thumb'] . '/same';
  199. $value['tel'] = $this->RandTel($value['city']);
  200. }
  201. return \backend\base\Help::JsonData(Help::SUCCESS, '成功', 0, $data);
  202. } else {
  203. return Help::JsonData(0, '成功', 0, []);
  204. }
  205. }
  206. // 海南别墅专题
  207. public function actionHnbszt()
  208. {
  209. $row = new \common\models\PushplaceType();
  210. $city1 = $row->city1();
  211. $city2 = $row->city2();
  212. $hn_boutiquevilla = $row->boutiquevilla();
  213. $hn_city = \common\models\CategoryCity::find()->where(['pid' => 68])->select('id,city_name')->asArray()->all();
  214. $priceList = \common\models\HousePrice::find()->where(['del' => 1, 'state' => 1])->orderBy(['sort' => SORT_ASC])->asArray()->all();
  215. //别墅动态
  216. $villa_news = (new \common\models\PushnewsType())->getlist(4);
  217. foreach ($villa_news as &$value){
  218. $value['thumb'] = Yii::$app->params['httpImg']['host'] . Yii::$app->params['httpImg']['newsthumb'] . json_decode($value['thumb'],true)[0];
  219. $value['time'] = date('Y.m.d',$value['create_at']);
  220. }
  221. //获取最新资讯
  222. $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();
  223. foreach ($new_news as &$value){
  224. $value['thumb'] = Yii::$app->params['httpImg']['host'] . Yii::$app->params['httpImg']['newsthumb'] . json_decode($value['thumb'],true)[0];
  225. $value['time'] = date('Y.m.d',$value['create_at']);
  226. }
  227. return $this->render('hnbszt', [
  228. 'city1' => $city1,
  229. 'city2' => $city2,
  230. 'hn_city' => $hn_city,
  231. 'priceList' => $priceList,
  232. 'hn_boutiquevilla' => $hn_boutiquevilla,
  233. 'villa_news'=>$villa_news,
  234. 'new_news'=>$new_news
  235. ]);
  236. }
  237. //获取专栏广告位
  238. public function actionGetboutiquevillalist()
  239. {
  240. $id = Yii::$app->request->post('id');
  241. $data = (new \common\models\PushhouseType())->boutiquevillaList($id,8);
  242. foreach ($data as &$value){
  243. $value['img'] = Yii::$app->params['httpImg']['host'] . Yii::$app->params['httpImg']['boutiquevilla'] . $value['img'];
  244. }
  245. return \backend\base\Help::JsonData(Help::SUCCESS, '成功', 0, $data);
  246. }
  247. }