123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539 |
- <?php
- /**
- * Created by PhpStorm.
- * User: xiaofeng
- * Date: 2018/4/19
- * Time: 下午2:52
- */
- namespace mobile\controllers;
- use common\fm\HouseHandle;
- use common\models\Brand;
- use common\models\CategoryLabel;
- use common\models\Characteristic;
- use common\models\House;
- use common\models\HouseComment;
- use common\models\HouseCommentLikes;
- use common\models\Sensitivewords;
- use mobile\base\CommonController;
- use mobile\server\IndexServer;
- use mobile\server\WordMatcher;
- use linslin\yii2\curl;
- use Yii;
- use mobile\base\Help;
- //use yii\data\Pagination;
- //use frontend\server\HouseServer;
- //use frontend\base\Help;
- use mobile\server\HouseServer;
- use yii\helpers\Html;
- class HouseController extends CommonController
- {
- const LOCATIONCITYHOUSE = 'locationcityhouse';
- public $enableCsrfValidation = false;
- public function beforeAction($action)
- {
- if (in_array(Yii::$app->controller->action->id, ['home', 'type', 'details', 'album', 'houseremark', 'news'])) {
- $input = Yii::$app->request->get();
- if (!is_numeric($input['hid'])) {
- $input['hid'] = explode('-', Yii::$app->request->get('hid'))[1];
- }
- if (empty((new House())->HouseIsshow($input['hid']))) {
- return $this->redirect('/public/showhouse')->send();
- }
- }
- return parent::beforeAction($action); // TODO: Change the autogenerated stub
- }
- /*
- * 楼盘首页
- * */
- public function actionHome()
- {
- $this->on(self::LOCATIONCITYHOUSE, [new \common\fm\HouseHandle(), 'MobileCityLocation']);
- $this->trigger(self::LOCATIONCITYHOUSE);
- $model = new HouseServer();
- $sub = new \mobile\server\IndexServer();
- $row = $model->Details();
- /***2020.6.18 lyy 获取楼盘直播视频****/
- $row['house']['live'] = $model->GetLiveInfo($row['house']['id']);
- $row['house']['provinceName'] = $sub->getProvinceName($row['house']['province']);
- // p($row);die;
- $str = [];
- $type = $model->HouseType();
- $row['seo'] = $model->SeoCity(isset($row['house']['city']) ? $row['house']['city'] : '');
- return $this->render('home', ['model' => $row, 'pince' => $str, 'type' => $type]);
- }
- /**
- * 楼盘列表
- * */
- public function actionSearch()
- {
- $data = HouseServer::Search(1);
- $data['characteristic'] = (new Characteristic())->getListAll();
-
- //物业类型
- $labelType = new CategoryLabel();
- $labelType->type = 1;
- $labelType->state = 1;
- $data['label'] = $labelType->getList([], ['id', 'name']); //物业
-
- // $model = new IndexServer();
- // $lunbo = $model->Lunbo();
- // 'lunbo'=>$lunbo,
- $CityModel = new \common\models\CategoryCity();
- $city = $CityModel->FindById(Yii::$app->hostserver->hostId);
- //遍历前10条数据
- $house = new HouseServer();
- $input = Yii::$app->request->get();
- $input['abroad'] = 1;
- $rows = $house->SearchForm($input);
- $start_time = date('Y/m') . '/01-' . date('Y/m', strtotime('+ 2 month')) . '/01'; //有效日期
- $gCity = Yii::$app->hostserver->hostId;
- if ($gCity != 0) {
- $cityName = \common\models\CategoryCity::findOne($gCity)['city_name'];
- } else {
- $cityName = '全国';
- }
- //SEO
- $meta = $house->SeoCity(isset($input['city']) ? $input['city'] : (empty($gCity)? '' : $gCity ));
- return $this->render('search', [
- 'model' => $data,
- 'city' => $city,
- 'house' => $rows['data'],
- 'start_time' => $start_time,
- 'house_total' => $rows['count'],
- 'cityname' => $cityName,'seo'=>$meta],
- );
- }
- public function actionSearchdata()
- {
- $model = new HouseServer();
- $input = Yii::$app->request->get();
- $input['abroad'] = 1;
- $rows = $model->SearchForm($input);
- if (!empty($rows)) {
- return Help::JsonData(Help::SUCCESS, '成功', $rows['count'], $rows['data']);
- //return Help::JsonCode(Help::SUCCESS,'成功',$rows);
- }
- return Help::JsonCode(Help::ERROR, '暂无相关楼盘数据');
- }
- /*
- * 国外楼盘
- */
- public function actionAbroad()
- {
- $data = HouseServer::Search(2);
- // $model = new IndexServer();
- // $lunbo = $model->Lunbo();
- //遍历前10条数据
- $house = new HouseServer();
- $input = Yii::$app->request->get();
- $input['abroad'] = 2;
- $rows = $house->SearchForm($input);
- $start_time = date('Y/m') . '/01-' . date('Y/m', strtotime('+ 2 month')) . '/01'; //有效日期
- return $this->render('abroad', ['model' => $data, 'house' => $rows['data'], 'start_time' => $start_time, 'house_count' => $rows['count']]);
- }
- /*
- * 国外楼盘数据
- */
- public function actionSearchdatas()
- {
- $model = new HouseServer();
- $input = Yii::$app->request->get();
- $input['abroad'] = 2;
- $rows = $model->SearchForm($input);
- if (!empty($rows)) {
- return Help::JsonData(Help::SUCCESS, '成功', $rows['count'], $rows['data']);
- }
- return Help::JsonCode(Help::ERROR, '暂无相关楼盘数据');
- }
- /*
- * 楼盘名称搜索
- * */
- public function actionSearchname()
- {
- $model = new HouseServer();
- $row = $model->SearchHouseName(Yii::$app->request->get());
- if (!empty($row)) {
- return Help::JsonCode(Help::SUCCESS, '成功', $row);
- }
- return Help::JsonCode(Help::ERROR, '暂无搜索数据');
- }
- /*
- * 获取区域子类信息
- * */
- public function actionSoncity()
- {
- $CityModel = new \common\models\CategoryCity();
- $r = $CityModel->GetAllSon(Yii::$app->request->post('pid'), ['city_name', 'id', 'pinyin'], 2);
- return Help::JsonCode(Help::SUCCESS, '成功', $r);
- }
- /*
- * 获取楼盘户型分组和分组总数
- * */
- public function actionType()
- {
- $model = new HouseServer();
- $row = $model->HouseType();
- $publiHouse = $model->PublicDetails();
- $input['hid'] = Yii::$app->request->get('hid');
- $input['type_id'] = Yii::$app->request->get('type_id',$row[0]['type_id'] );
- $typeimg = $model->HouseTypeGroupAll($input);
- return $this->render('type', ['model' => $row, 'hid' => Yii::$app->request->get('hid'),'public' => $publiHouse,'typeimg'=>$typeimg]);
- }
- /*
- * 楼盘户型分组后的数据
- * */
- public function actionHousetype()
- {
- $model = new HouseServer();
- $rows = $model->HouseTypeGroupAll(Yii::$app->request->post());
- if ($rows != null) {
- return Help::JsonCode(Help::SUCCESS, '成功', $rows);
- }
- return Help::JsonCode(Help::ERROR, '暂无楼盘户型图数据');
- }
- /*
- * 楼盘户型数据
- * */
- public function actionHousetypeall()
- {
- // $model = new HouseServer();
- // $rows = $model->TypeAll(Yii::$app->request->post(),false);
- // if($rows != null)
- // {
- // return Help::JsonCode(Help::SUCCESS,'成功',$rows);
- // }
- }
- /*
- * 楼盘首页-楼盘动态
- * */
- public function actionDynamic()
- {
- // $model = new HouseServer();
- // $rows = $model->NewsDynamic(Yii::$app->request->post());
- // if($rows != null)
- // {
- // return Help::JsonCode(Help::SUCCESS,'成功',$rows);
- // }
- // return Help::JsonCode(Help::ERROR,'失败');
- }
- /*
- * 楼盘详细信息
- * */
- public function actionDetails()
- {
- $model = new HouseServer();
- $row = $model->ParamsDetails();
- $publiHouse = $model->PublicDetails();
- // $row['house']['state'] = Yii::$app->params['HouseSalesStatus'][$row['house']['state']];
- // p($row);die;
- return $this->render('details', ['model' => $row, 'hid' => Yii::$app->request->get('hid'),'public' => $publiHouse]);
- }
- /*
- * 楼盘详细介绍
- * */
- public function actionIntro()
- {
- $model = new HouseServer();
- $row = $model->ParamsDetails();
- if ($row) return $this->render('intro', ['model' => $row]);
- return $this->goBack();
- }
- /*
- * 楼盘资讯
- * */
- public function actionNews()
- {
- $model = new HouseServer();
- $rows = $model->HouseNewsList();
-
- $publiHouse = $model->PublicDetails();
- return $this->render('news', ['model' => $rows, 'hid' => Yii::$app->request->get('hid'),'public' => $publiHouse]);
- }
- public function actionPeriphery()
- {
- return $this->render('periphery');
- }
- /*
- * 楼盘相册页面
- * */
- public function actionAlbum()
- {
- $model = new HouseServer();
- // $rows = $model->HouseAlbum();
- $rows = $model->AlbumType();
- $publiHouse = $model->PublicDetails();
-
- return $this->render('album', ['model' => $rows, 'hid' => Yii::$app->request->get('hid'),'public' => $publiHouse]);
- }
- /*
- * 楼盘所有相册
- * */
- public function actionAlbumlist()
- {
- $model = new HouseServer();
- $rows = $model->HouseAlbumAll();
- if (!empty($rows)) {
- return Help::JsonCode(Help::SUCCESS, '成功', $rows);
- }
- return Help::JsonCode(Help::ERROR, '暂无楼盘相册信息');
- }
- /*
- * 楼盘首页底部---推荐楼盘 同价位楼盘 周边楼盘
- * */
- public function actionTall()
- {
- $model = new \common\models\House();
- $input = Yii::$app->request->post();
- $arr = [];
- if (isset($input['type'])) {
- switch ($input['type']) {
- case 1: //后期如果不要传递价格作为参数 在删除掉
- $arr['price'] = $input['price'];
- if ($arr['price'] == 0) {
- $arr['price'] = "";
- }
- $model->price = $arr['price'];
- $model->city = $input['city'];
- break;
- case 2:
- $arr['city'] = $input['city'];
- $model->city = $arr['city'];
- break;
- }
- }
- $model->is_push = 2;
- $rows = $model->randList(3, $arr);
- if (!empty($rows)) {
- foreach ($rows as &$val) {
- $val['characteristic'] = \common\fm\HouseHandle::ChangeCharacteristic($val['characteristic']);
- $val['tel'] = \common\fm\HouseHandle::ChangeCityTel($val['city']);
- $val['thumb'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['houses'] . $val['thumb'];
- }
- return Help::JsonCode(Help::SUCCESS, '成功', $rows);
- }
- return Help::JsonCode(Help::ERROR, '暂无数据');
- }
- /**
- * @return mixed
- * 获取楼盘ID,返回楼盘预售证书信息
- */
- public function actionLicence()
- {
- $input = Yii::$app->request->post();
- if (!empty($input['hid'])) {
- $model = new \common\models\HousePermit();
- $rows = $model->getList($input);
- if ($rows != null) {
- return Help::JsonCode(Help::SUCCESS, '成功', $rows);
- }
- }
- return Help::JsonCode(Help::ERROR, '失败');
- }
- /*
- * 楼盘---点评
- * */
- // public function actionRemark()
- // {
- // return $this->render('remark');
- // }
- /*
- * 楼盘--周边配套
- * */
- // public function actionPeitao()
- // {
- // return $this->render('peitao');
- // }
- public function actionRemarkfrom()
- {
- $input = Yii::$app->request->post();
- $model = new HouseComment();
- $input['ip'] = Yii::$app->request->userIP;
- $wordMatcher = new WordMatcher();
- $sensitivewords = new Sensitivewords();
- $senWordsInfo = $sensitivewords->getList();
- $list = explode("、", $senWordsInfo['info']);
- foreach ($list as $val) {
- $wordMatcher->addWord($val);
- }
- $wordMatcher->match($input['content'], $matched);
- if (!empty($matched)) {
- return Help::JsonCode(Help::ERROR, '点评内容存在敏感词汇', $matched);
- }
- $true = $model->Iplimit($input);
- if ($true === false) return Help::JsonCode(Help::ERROR, '一个楼盘最多只能点评2次');
- $input['initiator'] = 2;
- $input['is_show'] = 2;
- if ($model->load($input, '') && $model->save()) {
- $curlArr = array(
- "mobile" => $input['mobile'],
- "source" => 40,
- "equipment" => 1,
- "hid" => $input['hid'],
- );
- $curl = new curl\Curl();
- $url = 'http://m.yigouf.com/enroll/signup';
- $response = $curl->reset()->setOption(CURLOPT_POSTFIELDS, http_build_query($curlArr))->post($url);
- return Help::JsonCode(Help::SUCCESS, Yii::t('app', '点评成功'));
- }
- return Help::JsonCode(Help::ERROR, Yii::t('app', '点评失败'), $model->errors);
- }
- public function actionRemarklikesfrom()
- {
- $input = Yii::$app->request->post();
- $model = new HouseCommentLikes();
- $input['ip'] = Yii::$app->request->userIP;
- $true = $model->Iplimit($input);
- if ($true === false) return Help::JsonCode(Help::ERROR, '一条点评最多只能赞一次');
- if ($model->load($input, '') && $model->save()) {
- $model->hid = $input['hid'];
- $model->hcid = $input['hcid'];
- $total = $model->Total();
- return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'add_success'), $total);
- }
- return Help::JsonCode(Help::ERROR, Yii::t('app', 'add_error'), $model->errors);
- }
- public function actionHouseremark()
- {
- $model = new HouseServer();
- $houseComment = new HouseComment();
- $rows = $model->Details();
- $input = Yii::$app->request->get();
- $getHouseList = $model->getHouseRemarkList($input, 10);
- $houseComment->hid = $input['hid'];
- $getHouseListTotal = $houseComment->getHouseListTotal();
- $publiHouse = $model->PublicDetails();
- return $this->render('houseremark', ['model' => $rows, 'hid' => Yii::$app->request->get('hid'), 'xuqiu' => $houseComment->xuqiu, 'commentList' => $getHouseList, 'getHouseListTotal' => $getHouseListTotal,'public' => $publiHouse]);
- }
- public function actionHouseloadremark()
- {
- $model = new HouseServer();
- $houseComment = new HouseComment();
- $input['hid'] = Yii::$app->request->get('hid');
- $input['page'] = Yii::$app->request->get('page');
- $input['limit'] = Yii::$app->request->get('limit');
- $getHouseList = $model->getHouseRemarkList($input);
- if ($getHouseList != null) {
- return Help::JsonCode(Help::SUCCESS, '成功', $getHouseList);
- }
- return Help::JsonCode(Help::ERROR, '失败');
- }
- /*
- * 楼盘详细信息
- * */
- public function actionLoan()
- {
- return $this->render('loan');
- }
- /*
- * 楼盘---点评详情
- * */
- public function actionRemarkdetails()
- {
- return $this->render('remarkdetails');
- }
- /*
- * 楼盘---相册放大页
- * */
- public function actionPvimage()
- {
- $input = Yii::$app->request->get();
- $house = House::find()->select(['name'])->andWhere(['id' => $input['hid']])->asArray()->one();
- $model = new HouseServer();
- $rows = $model->HouseAlbum();
- return $this->render('pvimage', ['hid' => $input['hid'], 'row' => $rows, 'house' => $house]);
- }
- /*
- * 户型---相册放大页
- * */
- public function actionHximage()
- {
- $input = Yii::$app->request->get();
- $house = House::find()->select(['name'])->andWhere(['id' => $input['hid']])->asArray()->one();
- $model = new HouseServer();
- $rows = $model->HouseType();
- return $this->render('hximage', ['hid' => $input['hid'], 'row' => $rows, 'house' => $house]);
- }
- //楼盘详情页价格走势
- public function actionHouseprice()
- {
- $get = Yii::$app->request->get();
- if (is_numeric($get['id'])) {
- $price = HouseHandle::HousePrice($get['id']);
- if ($price != null) {
- return Help::JsonCode(Help::SUCCESS, '成功', $price);
- }
- return Help::JsonCode(Help::ERROR, '失败');
- }
- }
- // 独立拔打电话页面
- public function actionSelftel()
- {
- $input = Yii::$app->request->get();
- $row = (new HouseServer())->Details($input);
- return $this->renderPartial('selftel', ['model' => $row]);
- }
- // 众趣播放页面
- public function actionZhongqu()
- {
- $input = Yii::$app->request->get();
- return $this->render('zhongqu',['url'=>$input['h']]);
- }
- }
|