123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765 |
- <?php
- /**
- * Created by PhpStorm.
- * User: xiaofeng
- * Date: 2018/6/7
- * Time: 上午10:39
- */
- namespace mobile\server;
- use common\models\HousesPrice;
- use common\models\Developers;
- use common\models\House;
- use common\models\HouseAlbum;
- use common\models\HouseComment;
- use common\models\HouseCommentLikes;
- use common\models\HouseCommentreply;
- use common\models\HouseFacilities;
- use common\models\HouseNumber;
- use common\models\HousePriceRecord;
- use common\models\Search;
- use common\models\Video;
- use mobile\base\Help;
- use Yii;
- use common\models\HouseNews;
- use common\models\News;
- use common\models\CategoryLabel;
- use common\models\HousePermit;
- use common\models\HouseType;
- class HouseServer
- {
- public static function Search($abroad = 1)
- {
- //搜索内容
- $renderData = [];
- $CityModel = new \common\models\CategoryCity();
- $CityModel->pid = 0;
- $CityModel->state = 1;
- if (Yii::$app->hostserver->hostId != 0) {
- $CityModel->pid = Yii::$app->hostserver->hostId;
- } else {
- $CityModel->abroad = $abroad;
- }
- // $renderData['city'] = $CityModel->getList([],['city_name','id']);
- $renderData['city'] = $CityModel->getList([], ['city_name', 'id', 'pinyin']);
- // p($renderData);
- $input = Yii::$app->request->get();
- if (!empty($input['city'])) {
- $renderData['select_city'] = $CityModel->FindById($input['city']);
- }
- $PriceModel = new \common\models\HousesPrice();
- $renderData['price'] = $PriceModel->getList([], ['id', 'price', 'price_short']);
- if (!empty($input['price'])) {
- $renderData['select_price'] = $input['price'];
- }
- $TypeModel = new \common\models\CategoryHousetype();
- $renderData['type'] = $TypeModel->getList([], ['id', 'huxing_name']);
- if (!empty($input['type'])) {
- $renderData['select_type'] = $TypeModel->FindById($input['type']);
- }
- $zhutiModel = new \common\models\Characteristic();
- $renderData['zhuti'] = $zhutiModel->getList([], ['id', 'name']);
- if (!empty($input['characteristic'])) {
- $renderData['select_zhuti'] = $zhutiModel->FindById($input['characteristic']);
- }
- return $renderData;
- }
- //搜索
- public function SearchForm($input)
- {
- $query = new House();
-
- if (!empty($input['price'])) {
- $query->price = $input['price'];
- }
- if (!empty($input['characteristic'])) {
- $query->characteristic = $input['characteristic'];
- }
- if (!empty($input['name'])) {
- $query->name = $input['name'];
- }
- //处理区域
- if (!empty($input['city'])) {
- $CityModel = new \common\models\CategoryCity();
- $pro = $CityModel->FindById($input['city']);
- if ($pro['pid'] == 0) {
- $r = $CityModel->GetAllSon($input['city'], ['city_name', 'id']);
- if (!empty($r)) {
- $input['city'] = array_column($r, 'id');
- }
- }
- $query->city = $input['city'];
- } else if (empty($input['city']) && Yii::$app->hostserver->hostId != 0) {
- $query->city = (new \common\models\CategoryCity())->TestingId(Yii::$app->hostserver->hostId);
- } else if (empty($input['city'])) {
- $CityModel = new \common\models\CategoryCity();
- $CityModel->pid = 0;
- $CityModel->state = 1;
- $CityModel->abroad = 1;
- $mainCity = $CityModel->getList([], ['id']);
- if ($mainCity) {
- $city_Id = $CityModel->GetAllSon(array_column($mainCity, 'id'), ['id']);
- if (!empty($city_Id)) {
- $query->city = array_column($city_Id, 'id');
- }
- }
- }
- if (!empty($input['type'])) {
- $type = \common\models\HouseType::find();
- $typeModel = $type->andWhere(['type_id' => $input['type'], 'del' => 1])->asArray()->all();
- if (!empty($typeModel)) {
- $query->id = array_unique(array_column($typeModel, 'hid'));
- } else {
- $query->id = 0;
- }
- }
- if (!empty($input['name'])) {
- $arr = (new \common\api\HouseServer())->HouseNameConvert($input['name']);
- if (!empty($arr['pinyin'])) {
- $query->pinyin = $arr['pinyin'];
- }
- if (!empty($arr['zhongwen'])) {
- $query->name = $arr['zhongwen'];
- }
- $query->city = '';
- }
- if (!empty($input['hao'])) {
- $data = $query->PcHouseList($input, ['pfg_house.state', 'pfg_house_detail.video_url', 'pfg_house_detail.preferential', 'pfg_house_detail.panorama', 'pfg_house.area', 'pfg_category_city.city_name', 'pfg_house.id', 'pfg_house.is_tel', 'pfg_house.city', 'pfg_house.price', 'pfg_house.name', 'pfg_house_detail.address', 'pfg_house_detail.developers', 'pfg_house_detail.main_units', 'pfg_house_detail.price_unit', 'pfg_house.thumb', 'pfg_house.sale_price', 'pfg_house.characteristic', 'pfg_pushm_mansion.haoqi', 'pfg_pushm_mansion.jingmi', 'pfg_pushm_mansion.reason', 'pfg_pushm_mansion.img as hao_img', 'pfg_developers.logo']);
- } else {
- $data = $query->PcHouseList($input, ['pfg_house.state', 'pfg_house_detail.video_url', 'pfg_house_detail.preferential', 'pfg_house_detail.panorama', 'pfg_house.area', 'pfg_category_city.city_name', 'pfg_house.id', 'pfg_house.is_tel', 'pfg_house.city', 'pfg_house.price', 'pfg_house.name', 'pfg_house_detail.address', 'pfg_house_detail.main_units', 'pfg_house_detail.price_unit', 'pfg_house.thumb', 'pfg_house.sale_price', 'pfg_house.characteristic', 'pfg_house.click_num']);
- }
- //豪宅总数
- if (!empty($input['hao'])) {
- $count = $query->Count_Mansion();
- } else {
- //正常数据的整数
- $count = $query->PcHouseListTotal();
- }
- if ($count < 1) {
- $count = 0;
- }
- if ($data != null) {
- // $Tel = new \common\models\CategoryTelCity();
- // $telRow = $Tel->QgetAll();
- //
- // $cityTel = [];
- // foreach ($telRow as &$v) {
- // $cityTel[$v['cid']] = explode(',', $v['tel']);
- // }
- $randArr = [];
- foreach ($data as &$val) {
- if ($val['click_num'] < 100) {
- $val['click_num'] = rand(200, 900);
- }
- $val['thumb'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['houses'] . $val['thumb'];
- if (!empty($val['hao_img'])) {
- $val['hao_img'] = $imgUrl = Yii::$app->params['httpImg']['host'] . Yii::$app->params['httpImg']['housealbum'] . $val['hao_img'];
- }
- if (!empty($val['logo'])) {
- $val['logo'] = $imgUrl = Yii::$app->params['httpImg']['host'] . Yii::$app->params['httpImg']['developers'] . $val['logo'];
- }
- $val['characteristic'] = \common\fm\HouseHandle::ChangeCharacteristic($val['characteristic']);
- $val['citytel'] = \common\fm\HouseHandle::ChangeCityTel($val['city']);
- if (empty($val['is_tel'])) {
- if (!empty($val['area']) && \common\fm\HouseHandle::ChangeCityTel($val['area']) != Yii::$app->params['default_dialtel']) {
- $val['citytel'] = \common\fm\HouseHandle::ChangeCityTel($val['area']);
- } else {
- $val['citytel'] = \common\fm\HouseHandle::ChangeCityTel($val['city']);
- }
- // $val['citytel'] = \common\fm\HouseHandle::ChangeCityTel($val['city']);
- } else {
- $val['citytel'] = $val['is_tel'];
- }
- //查询是否单独设置楼盘号码
- if (!empty(HouseNumber::SearchNumber($val['id']))) {
- $val['citytel'] = HouseNumber::SearchNumber($val['id']);
- }
- // if (isset($cityTel[$val['city']])) {
- // $rand = array_rand($cityTel[$val['city']], 1);
- // $val['citytel'] = $cityTel[$val['city']][$rand];
- //
- // } else {
- // $val['citytel'] = Yii::$app->params['default_dialtel'];
- // }
- // $val['video'] = $this->Video($val['id']);
- //楼盘状态
- $val['state'] = Yii::$app->params['HouseSalesStatus'][$val['state']];
- }
- return ['data' => $data, 'count' => $count];
- }
- }
- //Video楼盘视频
- public function Video($Id)
- {
- $data = Video::find()->select(['video_url', 'thumb'])
- ->andWhere(['del' => 1])->andWhere(['state' => 1])->andWhere(['hid' => $Id])
- ->orderBy(['create_at' => SORT_DESC])->asArray()->one();
- return $data;
- }
- /****Live楼盘直播视频****/
- public function GetLiveInfo($hid)
- {
- $data = \common\models\Live::find()
- ->select('id,hid,video_url,img,city')
- ->andWhere(['hid' => $hid])
- ->asArray()->one();
- if ($data) {
- $data['url'] = '/live/home/detail?id=' . $data['id'];
- }
- return $data;
- }
- /*
- * 搜索楼盘名字
- * */
- public function SearchHouseName($input)
- {
- if (!empty($input['title'])) {
- (new Search())->SaveSearch($input['title']);
- $query = new House();
- $arr = (new \common\api\HouseServer())->HouseNameConvert($input['title']);
- if (!empty($arr['pinyin'])) {
- $query->pinyin = $arr['pinyin'];
- }
- if (!empty($arr['zhongwen'])) {
- $query->name = $arr['zhongwen'];
- }
- $result = $query->HouseName();
- return $result;
- }
- }
- public function Details()
- {
- $input = Yii::$app->request->get();
- if (isset($input['hid']) && is_numeric($input['hid'])) {
- //楼盘点击量
- $click = new \common\api\HouseServer();
- $click->HouseClick($input['hid']);
- $arr = [];
- //所有信息,后期优化显示字段
- $model = new House();
- $model->id = $input['hid'];
- $select = ['pfg_house.*', 'pfg_house_detail.*', 'pfg_category_city.city_name'];
- $arr['house'] = $model->Qdetails($select);
- // $arr['house']['info'] = strip_tags($arr['house']['info']);
- //楼盘点击量
- if (!empty($arr['house'])) {
- //特色主题
- // $sub = new IndexServer();
- // $arr['characteristic'] = $sub->Subject(json_decode($arr['house']['characteristic']),3);
- if (isset($arr['house']['characteristic'])) {
- $arr['characteristic'] = \common\fm\HouseHandle::ChangeCharacteristic($arr['house']['characteristic']);
- }
- //楼盘相册
- $queryAlbum = new HouseAlbum();
- $arr['album'] = $queryAlbum->Groupfind(['hid' => $input['hid']]);
- //楼盘户型
- $queryType = new \common\models\HouseType();
- $queryType->hid = $input['hid'];
- $arr['type'] = $queryType->MgetList(2, ['area', 'title', 'img', 'indoor_info']);
- //电话
- // $arr['house']['tel'] = $sub->RandTel( $arr['house']['city']);
- // $arr['house']['tel'] = \common\fm\HouseHandle::ChangeCityTel($arr['house']['city']);
- // if(empty($arr['house']['is_tel']))
- // {
- // $arr['house']['tel'] = \common\fm\HouseHandle::ChangeCityTel($arr['house']['city']);
- // }
- // else
- // {
- // $arr['house']['tel'] = $arr['house']['is_tel'];
- // }
- // $arr['house']['tel'] = Yii::$app->params['default_dialtel'];
- $arr['house']['tel'] = \common\fm\HouseHandle::ChangeCityTel($arr['house']['city']);
- if (empty($arr['house']['is_tel'])) {
- //新增三级联动区域的电话获取修改
- if (!empty($arr['house']['area']) && \common\fm\HouseHandle::ChangeCityTel($arr['house']['area']) != Yii::$app->params['default_dialtel']) {
- $arr['house']['tel'] = \common\fm\HouseHandle::ChangeCityTel($arr['house']['area']);
- } else {
- $arr['house']['tel'] = \common\fm\HouseHandle::ChangeCityTel($arr['house']['city']);
- }
- } else {
- $arr['house']['tel'] = $arr['house']['is_tel'];
- }
- //查询是否单独设置楼盘号码
- if (!empty(HouseNumber::SearchNumber($arr['house']['id']))) {
- $arr['house']['tel'] = HouseNumber::SearchNumber($arr['house']['id']);
- }
- //预售证书
- $certificate = new \common\models\HousePermit();
- $certificate->hid = $input['hid'];
- $arr['certificate'] = $certificate->FindNewest();
- //楼盘状态
- $arr['house']['state'] = Yii::$app->params['HouseSalesStatus'][$arr['house']['state']];
- //新闻
- $arr['news'] = $this->NewsDynamic($input);
- //推荐楼盘
- $model = new \common\models\House();
- $model->city = $arr['house']['city'];
- $model->is_push = 2;
- $arr['tuijian_house'] = $model->randList(3, ['house_id' => $arr['house']['id']]);
- if (!empty($arr['tuijian_house'])) {
- foreach ($arr['tuijian_house'] 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'] . '/' . 'same';
- $val['state'] = Yii::$app->params['HouseSalesStatus'][$val['state']];
- }
- }
- //楼盘点评
- $arr['remark'] = $this->getHouseRemarkList($input, 2);
- $vr3d = $this->Vr3d($arr['house']['id']);
- if (!empty($vr3d)) {
- $arr['house']['panorama'] = $vr3d['path'];
- $arr['house']['panorama_img'] = $vr3d['img'];
- } else {
- if ($arr['house']['panorama_img']) {
- $arr['house']['panorama_img'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['house_video'] . $arr['house']['panorama_img'] . '/same';
- } else {
- $arr['house']['panorama_img'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['houses'] . $arr['house']['thumb'] . '/same';
- }
- }
- if (!empty($arr['house']['video_url'])) {
- if (!empty($arr['house']['video_img'])) {
- $arr['house']['video_img'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['house_video'] . $arr['house']['video_img'] . '/same';
- } else {
- $arr['house']['video_img'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['houses'] . $arr['house']['thumb'] . '/same';
- }
- }
- return $arr;
- }
- }
- }
- public function Vr3d($hid)
- {
- $data = \common\models\Vr::find()->where(['hid' => $hid, 'state' => 1, 'type' => 1])->select(['img', 'name', 'path'])->orderBy(['sort' => SORT_DESC])->asArray()->one();
- if (!empty($data)) {
- $data['img'] = Yii::$app->params['httpImg']['host'] . Yii::$app->params['httpImg']['video'] . $data['img'];
- }
- return $data;
- }
- public function NewsDynamic($input)
- {
- $model = new HouseNews();
- $model->hid =$input['hid'];
- $houseNewsInfo = $model->getHidList();
- $nids = array_column($houseNewsInfo,'nid');
- $newsModel = new News();
- $newsModel->hid = $input['hid'];
- $result = $newsModel->getNewsListHouse($nids,2);
- if ($result != null) {
- return $result;
- }
- }
- //楼盘详情页数据
- public function ParamsDetails()
- {
- $input = Yii::$app->request->get();
- if (is_numeric($input['hid'])) {
- $result = [];
- $model = new House();
- $model->id = $input['hid'];
- $result['house'] = $model->HousesAll();
- //物业类型
- $result['house'] = $this->labelMatchHouse($result['house']);
- // p($result);die;
- if ($result['house']) {
- $sub = new IndexServer();
- $result['house']['characteristic'] = $sub->Subject(json_decode($result['house']['characteristic']), 3);
- $result['house']['tel'] = $sub->RandTel($result['house']['city']);
- $result['house']['architecture_type'] = $this->ArchitectureType(json_decode($result['house']['architecture_type']));
- $result['house']['provinceName'] = $sub->getProvinceName($result['house']['province']);
- //预售证号
- $zheng = new HousePermit();
- $result['house']['zhengshu'] = $zheng->getList($input);
- //价格历史
- $price = new HousePriceRecord();
- $price->hid = $input['hid'];
- $result['house']['price_record'] = $price->getList([]);
- $peitao = new HouseFacilities();
- $peitao->hid = $input['hid'];
- $pei = $peitao->InfoList();
- //查询是否单独设置楼盘号码
- if (!empty(HouseNumber::SearchNumber($result['house']['id']))) {
- $result['house']['tel'] = HouseNumber::SearchNumber($result['house']['id']);
- }
- if (!empty($pei)) {
- $peiArr = [];
- foreach ($pei as $key => &$val) {
- if (mb_strlen($val['name'], 'UTF8') == 2) {
- $val['name'] = mb_substr($val['name'], 0, 1, 'UTF8') . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . mb_substr($val['name'], 1, 1, 'UTF8');
- }
- if (mb_strlen($val['name'], 'UTF8') == 3) {
- $val['name'] = mb_substr($val['name'], 0, 1, 'UTF8') . ' ' . ' ' . mb_substr($val['name'], 1, 1, 'UTF8') . ' ' . ' ' . mb_substr($val['name'], 2, 2, 'UTF8');
- }
- if (strpos($val['name'], '银行') !== false) {
- $val['name'] = mb_substr($val['name'], 0, 1, 'UTF8') . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . ' ' . mb_substr($val['name'], 1, 1, 'UTF8');
- }
- $peiArr[$val['name']]['name'][] = $val['pname'];
- }
- $result['peitao'] = $peiArr;
- }
- return $result;
- }
- // p( $result['house']['price_record']);
- // $peitao = new HouseFacilities();
- // $peitao->hid = $input['hid'];
- // $pei = $peitao->InfoList();
- // if(!empty($pei))
- // {
- // $peiArr = [];
- // foreach ($pei as $key=>$val)
- // {
- // $peiArr[$val['name']]['name'][] = $val['pname'];
- // }
- // $result['peitao'] = $peiArr;
- // }
- }
- }
- /*
- * 建筑类别
- * */
- public function ArchitectureType($id)
- {
- if (!empty($id)) {
- $model = new CategoryLabel();
- $model->id = $id;
- $model->type = 2;
- $rows = $model->getList([], ['name']);
- if (!empty($rows)) {
- return array_column($rows, 'name');
- }
- }
- return [];
- }
- /*
- * 楼盘户型-分组
- * */
- public function HouseType()
- {
- $input = Yii::$app->request->get();
- $typeModel = new HouseType();
- // $model = new House();
- // $citymodel = new \common\models\CategoryCity();
- $typeModel->hid = $input['hid'];
- $groupType = $typeModel->TypeGroup();
- // $house = $model::findOne($input['hid']);
- // $cityson = $citymodel::findOne($house['city']);
- // $pcity = $cityson->parentCity;
- // $groupType['province'] = $pcity->toArray();
- // $groupType['houseName'] = $house['name'];
- return $groupType;
- }
- //楼盘户型分组数据
- public function HouseTypeGroupAll($input)
- {
- if (!empty($input['hid']) && !empty($input['type_id'])) {
- $typeModel = new HouseType();
- $typeModel->hid = $input['hid'];
- $typeModel->type_id = $input['type_id'];
- $list = $typeModel->QgetList();
- if ($list != null) {
- foreach ($list as &$val) {
- $val['img'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['housetypes'] . $val['img'] . Yii::$app->params['pfgwatermark'];
- }
- }
- return $list;
- }
- }
- //获取楼盘相册逻辑
- public function HouseAlbum()
- {
- $input = Yii::$app->request->get();
- \common\models\House::find();
- $queryAlbum = new HouseAlbum();
- $arr = $queryAlbum->AlbumGroup(['hid' => $input['hid']]);
- return $arr;
- }
- //获取楼盘相册信息
- public function AlbumType()
- {
- $input = Yii::$app->request->get();
- $queryAlbum = new HouseAlbum();
- $arr['album'] = $queryAlbum->AlbumGroup(['hid' => $input['hid']]);
- $queryAlbum->hid = $input['hid'];
- $queryAlbum->album_id = Yii::$app->request->get('album_id', $arr['album'][0]['album_id']);
- $arr['data'] = $queryAlbum->getList();
- if (!empty($arr['data'])) {
- foreach ($arr['data'] as &$val) {
- $val['img'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['housealbums'] . $val['img'] . Yii::$app->params['pfgwatermark'];
- }
- }
- $arr['selectalbumtype'] = Yii::$app->request->get('album_id', $arr['album'][0]['album_id']);
- return $arr;
- }
- //获取楼盘分类的所有相册信息
- public function HouseAlbumAll()
- {
- $input = Yii::$app->request->post();
- if (!empty($input['hid']) && is_numeric($input['hid'])) {
- $queryAlbum = new HouseAlbum();
- $queryAlbum->hid = $input['hid'];
- $queryAlbum->album_id = $input['album_id'];
- $rows = $queryAlbum->getList();
- if ($rows) {
- foreach ($rows as &$val) {
- $val['img'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['housealbums'] . $val['img'] . Yii::$app->params['pfgwatermark'];
- }
- return $rows;
- }
- }
- }
- //楼盘资讯
- public function HouseNewsList()
- {
- $input = Yii::$app->request->get();
-
- if (is_numeric($input['hid'])) {
- $model = new HouseNews();
- $model->hid =$input['hid'];
- $houseNewsInfo = $model->getHidList();
-
- $nids = array_column($houseNewsInfo,'nid');
- $newsModel = new News();
- $newsModel->hid = $input['hid'];
- $result['data'] = $newsModel->getNewsListHouse($nids);
-
- $model = new House();
- $citymodel = new \common\models\CategoryCity();
- $house = $model::findOne($input['hid']);
- $cityson = $citymodel::findOne($house['city']);
- $pcity = $cityson->parentCity;
- $result['province'] = $pcity->toArray();
- $result['houseName'] = $house['name'];
- // foreach ($result as &$val)
- // {
- // $time_int = strtotime($val['open_time']);
- //
- // $val['y'] = date('Y',$time_int);
- // $val['md'] = date('m-d',$time_int);
- // $val['thumb'] = json_decode($val['thumb']);
- // }
- return $result;
- }
- }
- public function getHouseRemarkList($input, $page)
- {
- $houseComment = new HouseComment();
- $houseCommentLikes = new HouseCommentLikes();
- $houseCommentReply = new HouseCommentreply();
- $houseComment->hid = $input['hid'];
- $houseCommentList = $houseComment->getHouseList($page);
- if ($houseCommentList != null) {
- foreach ($houseCommentList as &$value) {
- $value['allremark'] = floor(($value['diduan'] + $value['jiaotong'] + $value['peitao'] + $value['huanjing'] + $value["xingjiabi"]) / 5);
- $value['mobile'] = preg_replace("/(\d{3})\d{4}(\d{2})/", "\$1******\$3", $value['mobile']);
- $houseCommentLikes->hid = $value['hid'];
- $houseCommentLikes->hcid = $value['id'];
- $value['count_likes'] = $houseCommentLikes->Total();
- $value['reply'] = $houseCommentReply->getCommentReply($value['id']);
- }
- return $houseCommentList;
- }
- }
- //物业类型
- public function labelMatchHouse($house)
- {
- $model = new \common\models\CategoryLabel();
- $label = $model::find()->select(['id', 'name'])->andWhere(['type' => 1])->andWhere(['del' => 1])->asArray()->all();
- $label = array_column($label, 'name', 'id');
- $arr = json_decode($house['type'], true);
- // p($arr);die;
- if (!empty($arr)) {
- foreach ($arr as $val) {
- if (isset($label[$val]) && !empty($label[$val])) {
- $house['propertyName'][] = $label[$val];
- }
- }
- }
- return $house;
- }
- //楼盘随机电话
- public function RandTel($city)
- {
- if (!empty($city)) {
- $tel = new \common\models\CategoryTelCity();
- $tel->cid = $city;
- $telModel = $tel->CityTelOne();
- if (!empty($telModel['tel'])) {
- $telArr = explode(',', $telModel['tel']);
- $randNum = array_rand($telArr, 1);
- return $telArr[$randNum];
- }
- }
- return Yii::$app->params['default_dialtel'];
- }
- //返回区域名称 SEO 需求
- public function SeoCity($city)
- {
- $meta = [];
- $meta['province'] = '全国';
- $meta['city'] = '';
- if (is_numeric($city)) {
- $model = new \common\models\CategoryCity();
- $row = $model->FindById($city);
- if ($row['pid'] == 0) {
- $meta['province'] = $row['city_name'];
- } else {
- $meta['city'] = $row['city_name'];
- $s = $model->FindById($row['pid']);
- if ($s) {
- $meta['province'] = $s['city_name'];
- }
- }
- }
- return $meta;
- }
- //楼盘公共信息
- public function PublicDetails()
- {
- $input = Yii::$app->request->get();
- $houseModel = new House();
- $houseModel->id = $input['hid'];
- $houseRow = $houseModel->OneDetails(['id', 'name', 'state', 'city', 'area', 'characteristic', 'thumb', 'is_tel']);
- if ($houseRow != null) {
- // $houseRow['city'] = '';
- if (!empty($houseRow['city'])) {
- $cityModel = new \common\models\CategoryCity();
- $houseRow['seo'] = $cityModel->FatherSon($houseRow['city']);
- if (empty($houseRow['seo']['city'])) {
- $houseRow['seo']['city'] = '';
- }
- }
- //猜你喜欢
- $houseModel->id = '';
- $houseModel->city = $houseRow['city'];
- $houseRow['randhouse'] = $houseModel->randList(4);
- $houseRow['state'] = Yii::$app->params['HouseSalesStatus'][$houseRow['state']];
- $houseRow['thumb'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['houses'] . $houseRow['thumb'];
- //特色主题
- // $subject =
- // $this->Subject(json_decode($houseRow['characteristic'],true));
- $houseRow['characteristic'] = \common\fm\HouseHandle::ChangeCharacteristic($houseRow['characteristic']);;
- //随机电话
- if (empty($houseRow['is_tel'])) {
- if (!empty($houseRow['area']) && \common\fm\HouseHandle::ChangeCityTel($houseRow['area']) != Yii::$app->params['default_dialtel']) {
- $houseRow['tel'] = \common\fm\HouseHandle::ChangeCityTel($houseRow['area']);
- } else {
- $houseRow['tel'] = \common\fm\HouseHandle::ChangeCityTel($houseRow['city']);
- }
- } else {
- $houseRow['tel'] = $houseRow['is_tel'];
- }
- return $houseRow;
- }
- }
-
- /**
- * 价格
- * @return mixed
- */
- public function PriceList()
- {
- $PriceModel = new HousesPrice();
- $PriceList = $PriceModel->getList([], ['price', 'id']);
- if ($PriceList != null) {
- return $PriceList;
- }
- }
- }
|