123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- /*
- Created by PhpStorm.
- User: xiaofeng
- Date: 2018/6/10
- Time: 下午3:15
- */
- namespace wechat\controllers;
- use common\models\CategoryCity;
- use common\models\CategoryHousetype;
- use common\models\HousesPrice;
- use common\models\HouseType;
- use common\models\PushmMansion;
- use wechat\base\CommonController;
- use wechat\base\Help;
- use Yii;
- class VillaController extends CommonController
- {
- public $enableCsrfValidation = false;
- // 豪宅列表
- public function actionVillalist()
- {
- //显然页面搜索条件
- //价格
- $price = PushmMansion::find()->select(['pfg_house.id','pfg_house.price'])
- ->where(['pfg_pushm_mansion.del'=>1])
- ->leftJoin('pfg_house','pfg_house.id = pfg_pushm_mansion.hid')
- ->groupBy('pfg_house.price')
- ->asArray()->all();
- //区域
- $son_city = PushmMansion::find()->select(['pfg_category_city.pid'])
- ->where(['pfg_pushm_mansion.del'=>1])
- ->leftJoin('pfg_house','pfg_house.id = pfg_pushm_mansion.hid')
- ->leftJoin('pfg_category_city','pfg_category_city.id= pfg_house.city')
- ->groupBy('pfg_category_city.id')
- ->asArray()->all();
- //父类区域
- $city = CategoryCity::find()->select(['id','city_name','pinyin'])->andWhere(['pid'=>0,'del'=>1])->andWhere(['IN','id',array_column($son_city,'pid')])->asArray()->all();
- //户型
- $house = PushmMansion::find()->select(['pfg_house.id'])
- ->where(['pfg_pushm_mansion.del'=>1])
- ->leftJoin('pfg_house','pfg_house.id = pfg_pushm_mansion.hid')
- ->asArray()->all();
- $house_type = HouseType::find()->select(['pfg_house_type.type_id'])->where(['IN','hid',array_column($house,'id')])->groupBy('type_id')->asArray()->all();
- $type = CategoryHousetype::find()->select(['id','huxing_name'])->where(['IN','id',array_column($house_type,'type_id')])->asArray()->all();
- return $this->render('villalist',['price'=>$price,'city'=>$city,'type'=>$type]);
- }
- //区域子城市
- public function actionSoncity()
- {
- $CityModel = new \common\models\CategoryCity();
- $r = $CityModel->GetHaoSon(Yii::$app->request->post('pid'));
- return Help::JsonCode(Help::SUCCESS,'成功',$r);
- }
- }
|