VillaController.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /*
  3. Created by PhpStorm.
  4. User: xiaofeng
  5. Date: 2018/6/10
  6. Time: 下午3:15
  7. */
  8. namespace wechat\controllers;
  9. use common\models\CategoryCity;
  10. use common\models\CategoryHousetype;
  11. use common\models\HousesPrice;
  12. use common\models\HouseType;
  13. use common\models\PushmMansion;
  14. use wechat\base\CommonController;
  15. use wechat\base\Help;
  16. use Yii;
  17. class VillaController extends CommonController
  18. {
  19. public $enableCsrfValidation = false;
  20. // 豪宅列表
  21. public function actionVillalist()
  22. {
  23. //显然页面搜索条件
  24. //价格
  25. $price = PushmMansion::find()->select(['pfg_house.id','pfg_house.price'])
  26. ->where(['pfg_pushm_mansion.del'=>1])
  27. ->leftJoin('pfg_house','pfg_house.id = pfg_pushm_mansion.hid')
  28. ->groupBy('pfg_house.price')
  29. ->asArray()->all();
  30. //区域
  31. $son_city = PushmMansion::find()->select(['pfg_category_city.pid'])
  32. ->where(['pfg_pushm_mansion.del'=>1])
  33. ->leftJoin('pfg_house','pfg_house.id = pfg_pushm_mansion.hid')
  34. ->leftJoin('pfg_category_city','pfg_category_city.id= pfg_house.city')
  35. ->groupBy('pfg_category_city.id')
  36. ->asArray()->all();
  37. //父类区域
  38. $city = CategoryCity::find()->select(['id','city_name','pinyin'])->andWhere(['pid'=>0,'del'=>1])->andWhere(['IN','id',array_column($son_city,'pid')])->asArray()->all();
  39. //户型
  40. $house = PushmMansion::find()->select(['pfg_house.id'])
  41. ->where(['pfg_pushm_mansion.del'=>1])
  42. ->leftJoin('pfg_house','pfg_house.id = pfg_pushm_mansion.hid')
  43. ->asArray()->all();
  44. $house_type = HouseType::find()->select(['pfg_house_type.type_id'])->where(['IN','hid',array_column($house,'id')])->groupBy('type_id')->asArray()->all();
  45. $type = CategoryHousetype::find()->select(['id','huxing_name'])->where(['IN','id',array_column($house_type,'type_id')])->asArray()->all();
  46. return $this->render('villalist',['price'=>$price,'city'=>$city,'type'=>$type]);
  47. }
  48. //区域子城市
  49. public function actionSoncity()
  50. {
  51. $CityModel = new \common\models\CategoryCity();
  52. $r = $CityModel->GetHaoSon(Yii::$app->request->post('pid'));
  53. return Help::JsonCode(Help::SUCCESS,'成功',$r);
  54. }
  55. }