123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- <?php
- namespace frontend\controllers;
- use common\models\House;
- use common\models\HousePriceRecord;
- use common\models\News;
- use common\models\Pricetrends;
- use frontend\base\Help;
- use frontend\base\BaseController;
- use frontend\server\HouseServer;
- use Yii;
- class JsonController extends BaseController
- {
- /**
- * @var boolpushnewslist
- */
- public $enableCsrfValidation = false;
- /**
- * 区域价格走势
- * @return mixed
- */
- public function actionCityprice()
- {
- $model = new Pricetrends();
- $model->city_id = Yii::$app->request->get('id');
- $rows = $model->CityRecordPrice();
- if (!empty($rows)) {
- $arr = [];
- foreach ($rows as &$val) {
- $val['price_at'] = trim(date('m', $val['price_at']) . '月', '0');
- $arr['categories'][] = $val['price_at'];
- $arr['data'][] = $val['price'];
- $arr['region'][] = $val['city_name'];
- }
- return Help::JsonCode(Help::SUCCESS, '成功', $arr);
- }
- return Help::JsonCode(Help::ERROR, '暂无数据');
- }
- /**
- * 楼盘价格走势
- * @return mixed
- */
- public function actionHouseprice()
- {
- $input = Yii::$app->request->post();
- if (is_numeric($input['id'])) {
- $model = new HousePriceRecord();
- $model->hid = $input['id'];
- $rows = $model->getList([]);
- if (!empty($rows)) {
- $arr = [];
- foreach ($rows as $val) {
- $arr['categories'][] = $val['create_time'];
- $arr['data'][] = $val['price'];
- }
- return Help::JsonCode(Help::SUCCESS, '成功', $arr);
- }
- }
- return Help::JsonCode(Help::ERROR, '失败');
- }
- /**
- * 底部推荐楼盘
- * @param $input
- * @return mixed
- */
- public function actionall()
- {
- $input = Yii::$app->request->post();
- switch ($input['type']) {
- case 'price':
- $model = new House();
- $model->sale_price = $input['content'];
- $a['sale_price'] = $input['content'];
- $result = $model->HomegetList(4, $a);
- break;
- case 'quyu':
- $model = new House();
- $model->city = $input['content'];
- $result = $model->HomegetList(4);
- break;
- }
- if (!empty($result)) {
- foreach ($result as &$val) {
- $val['thumb'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['houses'] . $val['thumb'] . '/same';
- }
- return Help::JsonCode(Help::SUCCESS, '成功', $result);
- }
- return Help::JsonCode(Help::ERROR, '暂无数据');
- }
- /**
- * 楼盘所有相册
- * @return mixed
- */
- public function actionAlbumlist()
- {
- $model = new HouseServer();
- $album = $model->AlbumAll();
- if ($album != null) {
- return Help::JsonCode(Help::SUCCESS, '成功', $album);
- }
- return Help::JsonCode(Help::ERROR, '暂无数据');
- }
- /**
- * 楼盘户型数据
- * @return mixed
- */
- public function actionHousetypeall()
- {
- $model = new HouseServer();
- $rows = $model->TypeAll(Yii::$app->request->post(), false);
- if ($rows != null) {
- return Help::JsonCode(Help::SUCCESS, '成功', $rows);
- }
- }
- /**
- * 弹窗搜索结果
- * @return mixed
- */
- public function actionSearchresult()
- {
- $model = new HouseServer();
- $res = $model->SearchHouseName(Yii::$app->request->get());
- if (!empty($res)) {
- return Help::JsonCode(Help::SUCCESS, '成功', $res);
- }
- return Help::JsonCode(Help::ERROR, '暂无数据');
- }
- /**
- * 首页-大家都在关注
- * @return mixed
- */
- public function actionHousefollow()
- {
- $input = Yii::$app->request->get();
- $query = House::find();
- $query->select(['id', 'name'])->where(['is_push' => 2, 'del' => 1, 'province' => 68]);
- $query->limit = $input['limit'];
- $data = $query->orderBy('RAND()')->asArray()->all();
- if ($data) {
- return Help::JsonCode(Help::SUCCESS, '成功', $data);
- }
- return Help::JsonCode(Help::ERROR, '失败', $data);
- }
- //2020.10.22 vr改版获取推送区域的楼盘数据
- public function actionPushcityhouselist()
- {
- $input = Yii::$app->request->post();
- $model = new HouseServer();
- $data = $model->getHouseListByCity($input['city'], 6);
- return Help::JsonCode(Help::SUCCESS, '成功', $data);
- }
- //2020.10.25 v2改版首页推送资讯数据获取
- public function actionPushnewslist()
- {
- $input = Yii::$app->request->post();
- $data = (new News())->getNewsByCategory($input['news'],14);
- foreach ($data as &$val){
- $val['thumb'] = Yii::$app->params['httpImg']['host']. Yii::$app->params['httpImg']['newsthumb']. json_decode($val['thumb'],true)[0];
- }
- return Help::JsonCode(Help::SUCCESS, '成功', $data);
- }
- /**
- * 底部推荐楼盘
- * @param $input
- * @return mixed
- */
- public function actionTall()
- {
- $input = Yii::$app->request->post();
- switch ($input['type']) {
- case 'price':
- $model = new House();
- $model->sale_price = $input['content'];
- $a['sale_price'] = $input['content'];
- $result = $model->HomegetList(4, $a);
- break;
- case 'quyu':
- $model = new House();
- $model->city = $input['content'];
- $result = $model->HomegetList(4);
- break;
- }
- if (!empty($result)) {
- foreach ($result as &$val) {
- $val['thumb'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['houses'] . $val['thumb'] . '/same';
- }
- return Help::JsonCode(Help::SUCCESS, '成功', $result);
- }
- return Help::JsonCode(Help::ERROR, '暂无数据');
- }
- }
|