123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250 |
- <?php
- /**
- * Created by PhpStorm.
- * User: xiaofeng
- * Date: 2018/6/9
- * Time: 上午11:12
- */
- namespace mobile\server;
- use common\models\CategoryCity;
- use common\models\HouseNumber;
- use common\models\ListHouse;
- use common\models\ListNews;
- use common\models\PushmRotation;
- use common\models\PushmCharacteristic;
- use common\models\PushmHouse;
- use common\models\PushmRecommend;
- use common\models\Characteristic;
- use common\models\HousesPrice;
- use Yii;
- class IndexServer
- {
- /*
- * 轮播图
- * */
- public function Lunbo()
- {
- $model = new PushmRotation();
- if(Yii::$app->hostserver->hostId != 0)
- {
- $model->city = Yii::$app->hostserver->hostId;
- $result=$model->HomeGetList();
- if(empty($result)){
- return $model->GetAllList();
- }else{
- return $model->HomeGetList();
- }
- }
- return $model->GetAllList();
- }
- /*
- * 搜索框-热门筛选
- * */
- public function shaixuan()
- {
- $model = new PushmHouse();
- $model->type = 2;
- $rows = $model->Homegetlist(10);
- if(!empty($rows))
- {
- return $rows;
- }
- }
- /*
- * 搜索框 - 价格
- * */
- public function PriceList()
- {
- $PriceModel = new HousesPrice();
- $PriceList = $PriceModel->getList([],['price','id']);
- if($PriceList != null)
- {
- return $PriceList;
- }
- }
- /*
- * 特色推荐
- * */
- public function tese()
- {
- $model = new PushmCharacteristic();
- return $model->Homegetlist(3);
- }
- /*
- * 热销楼盘
- * */
- public function Hothouse($input)
- {
- $row = [];
- if(empty($input['city']))
- {
- $model = new PushmHouse();
- $model->type = $input['type'];
- $rows = $model->Homegetlist(6,$input['rand']);
- }
- else
- {
- $id = CategoryCity::find()->select(['id'])->andWhere(['pid'=>$input['city']])->asArray()->all();
- $city = array_column($id,'id');
- $h = new PushmHouse();
- $h->type = $input['type'];
- $rows = $h->CityGetHome($city);
- }
- // if(isset($input['city']) && $input['city'] == 0)
- // {
- // $model = new PushmHouse();
- // $model->type = $input['type'];
- // $rows = $model->Homegetlist(6,$input['rand']);
- // }
- // else if ( $input['city'] != 0)
- // {
- // $id = CategoryCity::find()->select(['id'])->andWhere(['pid'=>$input['city']])->asArray()->all();
- // $city = array_column($id,'id');
- // $h = new PushmHouse();
- // $h->type = $input['type'];
- // $rows = $h->CityGetHome($city);
- // }
- if(!empty($rows))
- {
- foreach ($rows as &$val)
- {
- if(!empty($val['characteristic']))
- {
- // $val['characteristic'] = $this->Subject(json_decode($val['characteristic']),3);
- $val['characteristic'] = \common\fm\HouseHandle::ChangeCharacteristic($val['characteristic']);
- }
- // $val['tel'] = $this->RandTel($val['cid']);
- $val['tel'] = \common\fm\HouseHandle::ChangeCityTel($val['cid']);
- //查询是否单独设置楼盘号码
- if (!empty(HouseNumber::SearchNumber($val['id']))) {
- $val['tel'] = HouseNumber::SearchNumber($val['id']);
- }
- //楼盘状态
- $val['state'] = Yii::$app->params['HouseSalesStatus'][$val['state']];
- }
- }
- return $rows;
- }
- /*
- * 品房推荐
- * */
- public function tuijian()
- {
- $model = new PushmRecommend();
- return $model->Homegetlist(10);
- }
- /*
- * 热门地区
- * */
- public function hotCity()
- {
- $model = new \common\models\PushmCity();
- $model->type = 1;
- $rows = $model->Homegetlist(6);
- return $rows;
- }
- //资讯
- public function newslist()
- {
- $model = new \common\models\PushmNews();
- $model->type = 1;
- return $model->Homegetlist(4);
- }
- //资讯栏目
- public function NewsColumn()
- {
- $model = new \common\models\PushmNewscolumn();
- return $model->Homegetlist(4);
- }
- //特色主题 超过3个随机返回3个元素
- public function Subject($id,$num = 3)
- {
- $char = new Characteristic();
- if(is_array($id) && !empty($id))
- {
- $char->id = $id;
- $charMode = array_column($char->getList([],['id','name']),'name','id');
- if($charMode != null)
- {
- $count = count($charMode);
- $arr = [];
- if($count >= 3)
- {
- $rand = array_rand($charMode,$num);
- foreach ($rand as $key=>$val)
- {
- $arr[$key] = $charMode[$val];
- }
- }
- else
- {
- $arr = $charMode;
- }
- return $arr;
- }
- }
- }
- //楼盘随机电话
- public function RandTel($city)
- {
- $tel = new \common\models\CategoryTelCity();
- $tel->cid = $city;
- $telModel = $tel->CityTelOne();
- if($telModel != null)
- {
- $telArr = explode(',',$telModel['tel']);
- $randNum = array_rand($telArr,1);
- return $telArr[$randNum];
- }
- }
- public function getProvinceName($province)
- {
- $model = new \common\models\CategoryCity();
- $data = $model::find()->select(['city_name'])->andWhere(['id'=>$province])->asArray()->one();
- if(!empty($data)){
- return $data;
- }
- }
-
- public function getHouseTouTiao($list_id, $limit = null)
- {
- $model = new ListNews();
- $data = $model->getPushInfo($list_id, $limit);
- return $data;
- }
-
- public function getHotHouse($list_id, $limit = null)
- {
- $model = new ListHouse();
- $data = $model->getIndexPushHouseDetail($list_id, $limit);
- foreach ($data as &$val) {
- if (empty($val['is_tel'])) {
- $val['is_tel'] = $this->RandTel($val['city']);
- }
- $val['thumb'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['houses'] . $val['thumb'] . '/same';
- }
- return $data;
- }
- }
|