HouseServer.php 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: xiaofeng
  5. * Date: 2018/6/7
  6. * Time: 上午10:39
  7. */
  8. namespace mobile\server;
  9. use common\models\HousesPrice;
  10. use common\models\Developers;
  11. use common\models\House;
  12. use common\models\HouseAlbum;
  13. use common\models\HouseComment;
  14. use common\models\HouseCommentLikes;
  15. use common\models\HouseCommentreply;
  16. use common\models\HouseFacilities;
  17. use common\models\HouseNumber;
  18. use common\models\HousePriceRecord;
  19. use common\models\Search;
  20. use common\models\Video;
  21. use mobile\base\Help;
  22. use Yii;
  23. use common\models\HouseNews;
  24. use common\models\News;
  25. use common\models\CategoryLabel;
  26. use common\models\HousePermit;
  27. use common\models\HouseType;
  28. class HouseServer
  29. {
  30. public static function Search($abroad = 1)
  31. {
  32. //搜索内容
  33. $renderData = [];
  34. $CityModel = new \common\models\CategoryCity();
  35. $CityModel->pid = 0;
  36. $CityModel->state = 1;
  37. if (Yii::$app->hostserver->hostId != 0) {
  38. $CityModel->pid = Yii::$app->hostserver->hostId;
  39. } else {
  40. $CityModel->abroad = $abroad;
  41. }
  42. // $renderData['city'] = $CityModel->getList([],['city_name','id']);
  43. $renderData['city'] = $CityModel->getList([], ['city_name', 'id', 'pinyin']);
  44. // p($renderData);
  45. $input = Yii::$app->request->get();
  46. if (!empty($input['city'])) {
  47. $renderData['select_city'] = $CityModel->FindById($input['city']);
  48. }
  49. $PriceModel = new \common\models\HousesPrice();
  50. $renderData['price'] = $PriceModel->getList([], ['id', 'price', 'price_short']);
  51. if (!empty($input['price'])) {
  52. $renderData['select_price'] = $input['price'];
  53. }
  54. $TypeModel = new \common\models\CategoryHousetype();
  55. $renderData['type'] = $TypeModel->getList([], ['id', 'huxing_name']);
  56. if (!empty($input['type'])) {
  57. $renderData['select_type'] = $TypeModel->FindById($input['type']);
  58. }
  59. $zhutiModel = new \common\models\Characteristic();
  60. $renderData['zhuti'] = $zhutiModel->getList([], ['id', 'name']);
  61. if (!empty($input['characteristic'])) {
  62. $renderData['select_zhuti'] = $zhutiModel->FindById($input['characteristic']);
  63. }
  64. return $renderData;
  65. }
  66. //搜索
  67. public function SearchForm($input)
  68. {
  69. $query = new House();
  70. if (!empty($input['price'])) {
  71. $query->price = $input['price'];
  72. }
  73. if (!empty($input['characteristic'])) {
  74. $query->characteristic = $input['characteristic'];
  75. }
  76. if (!empty($input['name'])) {
  77. $query->name = $input['name'];
  78. }
  79. //处理区域
  80. if (!empty($input['city'])) {
  81. $CityModel = new \common\models\CategoryCity();
  82. $pro = $CityModel->FindById($input['city']);
  83. if ($pro['pid'] == 0) {
  84. $r = $CityModel->GetAllSon($input['city'], ['city_name', 'id']);
  85. if (!empty($r)) {
  86. $input['city'] = array_column($r, 'id');
  87. }
  88. }
  89. $query->city = $input['city'];
  90. } else if (empty($input['city']) && Yii::$app->hostserver->hostId != 0) {
  91. $query->city = (new \common\models\CategoryCity())->TestingId(Yii::$app->hostserver->hostId);
  92. } else if (empty($input['city'])) {
  93. $CityModel = new \common\models\CategoryCity();
  94. $CityModel->pid = 0;
  95. $CityModel->state = 1;
  96. $CityModel->abroad = 1;
  97. $mainCity = $CityModel->getList([], ['id']);
  98. if ($mainCity) {
  99. $city_Id = $CityModel->GetAllSon(array_column($mainCity, 'id'), ['id']);
  100. if (!empty($city_Id)) {
  101. $query->city = array_column($city_Id, 'id');
  102. }
  103. }
  104. }
  105. if (!empty($input['type'])) {
  106. $type = \common\models\HouseType::find();
  107. $typeModel = $type->andWhere(['type_id' => $input['type'], 'del' => 1])->asArray()->all();
  108. if (!empty($typeModel)) {
  109. $query->id = array_unique(array_column($typeModel, 'hid'));
  110. } else {
  111. $query->id = 0;
  112. }
  113. }
  114. if (!empty($input['name'])) {
  115. $arr = (new \common\api\HouseServer())->HouseNameConvert($input['name']);
  116. if (!empty($arr['pinyin'])) {
  117. $query->pinyin = $arr['pinyin'];
  118. }
  119. if (!empty($arr['zhongwen'])) {
  120. $query->name = $arr['zhongwen'];
  121. }
  122. $query->city = '';
  123. }
  124. if (!empty($input['hao'])) {
  125. $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']);
  126. } else {
  127. $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']);
  128. }
  129. //豪宅总数
  130. if (!empty($input['hao'])) {
  131. $count = $query->Count_Mansion();
  132. } else {
  133. //正常数据的整数
  134. $count = $query->PcHouseListTotal();
  135. }
  136. if ($count < 1) {
  137. $count = 0;
  138. }
  139. if ($data != null) {
  140. // $Tel = new \common\models\CategoryTelCity();
  141. // $telRow = $Tel->QgetAll();
  142. //
  143. // $cityTel = [];
  144. // foreach ($telRow as &$v) {
  145. // $cityTel[$v['cid']] = explode(',', $v['tel']);
  146. // }
  147. $randArr = [];
  148. foreach ($data as &$val) {
  149. if ($val['click_num'] < 100) {
  150. $val['click_num'] = rand(200, 900);
  151. }
  152. $val['thumb'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['houses'] . $val['thumb'];
  153. if (!empty($val['hao_img'])) {
  154. $val['hao_img'] = $imgUrl = Yii::$app->params['httpImg']['host'] . Yii::$app->params['httpImg']['housealbum'] . $val['hao_img'];
  155. }
  156. if (!empty($val['logo'])) {
  157. $val['logo'] = $imgUrl = Yii::$app->params['httpImg']['host'] . Yii::$app->params['httpImg']['developers'] . $val['logo'];
  158. }
  159. $val['characteristic'] = \common\fm\HouseHandle::ChangeCharacteristic($val['characteristic']);
  160. $val['citytel'] = \common\fm\HouseHandle::ChangeCityTel($val['city']);
  161. if (empty($val['is_tel'])) {
  162. if (!empty($val['area']) && \common\fm\HouseHandle::ChangeCityTel($val['area']) != Yii::$app->params['default_dialtel']) {
  163. $val['citytel'] = \common\fm\HouseHandle::ChangeCityTel($val['area']);
  164. } else {
  165. $val['citytel'] = \common\fm\HouseHandle::ChangeCityTel($val['city']);
  166. }
  167. // $val['citytel'] = \common\fm\HouseHandle::ChangeCityTel($val['city']);
  168. } else {
  169. $val['citytel'] = $val['is_tel'];
  170. }
  171. //查询是否单独设置楼盘号码
  172. if (!empty(HouseNumber::SearchNumber($val['id']))) {
  173. $val['citytel'] = HouseNumber::SearchNumber($val['id']);
  174. }
  175. // if (isset($cityTel[$val['city']])) {
  176. // $rand = array_rand($cityTel[$val['city']], 1);
  177. // $val['citytel'] = $cityTel[$val['city']][$rand];
  178. //
  179. // } else {
  180. // $val['citytel'] = Yii::$app->params['default_dialtel'];
  181. // }
  182. // $val['video'] = $this->Video($val['id']);
  183. //楼盘状态
  184. $val['state'] = Yii::$app->params['HouseSalesStatus'][$val['state']];
  185. }
  186. return ['data' => $data, 'count' => $count];
  187. }
  188. }
  189. //Video楼盘视频
  190. public function Video($Id)
  191. {
  192. $data = Video::find()->select(['video_url', 'thumb'])
  193. ->andWhere(['del' => 1])->andWhere(['state' => 1])->andWhere(['hid' => $Id])
  194. ->orderBy(['create_at' => SORT_DESC])->asArray()->one();
  195. return $data;
  196. }
  197. /****Live楼盘直播视频****/
  198. public function GetLiveInfo($hid)
  199. {
  200. $data = \common\models\Live::find()
  201. ->select('id,hid,video_url,img,city')
  202. ->andWhere(['hid' => $hid])
  203. ->asArray()->one();
  204. if ($data) {
  205. $data['url'] = '/live/home/detail?id=' . $data['id'];
  206. }
  207. return $data;
  208. }
  209. /*
  210. * 搜索楼盘名字
  211. * */
  212. public function SearchHouseName($input)
  213. {
  214. if (!empty($input['title'])) {
  215. (new Search())->SaveSearch($input['title']);
  216. $query = new House();
  217. $arr = (new \common\api\HouseServer())->HouseNameConvert($input['title']);
  218. if (!empty($arr['pinyin'])) {
  219. $query->pinyin = $arr['pinyin'];
  220. }
  221. if (!empty($arr['zhongwen'])) {
  222. $query->name = $arr['zhongwen'];
  223. }
  224. $result = $query->HouseName();
  225. return $result;
  226. }
  227. }
  228. public function Details()
  229. {
  230. $input = Yii::$app->request->get();
  231. if (isset($input['hid']) && is_numeric($input['hid'])) {
  232. //楼盘点击量
  233. $click = new \common\api\HouseServer();
  234. $click->HouseClick($input['hid']);
  235. $arr = [];
  236. //所有信息,后期优化显示字段
  237. $model = new House();
  238. $model->id = $input['hid'];
  239. $select = ['pfg_house.*', 'pfg_house_detail.*', 'pfg_category_city.city_name'];
  240. $arr['house'] = $model->Qdetails($select);
  241. // $arr['house']['info'] = strip_tags($arr['house']['info']);
  242. //楼盘点击量
  243. if (!empty($arr['house'])) {
  244. //特色主题
  245. // $sub = new IndexServer();
  246. // $arr['characteristic'] = $sub->Subject(json_decode($arr['house']['characteristic']),3);
  247. if (isset($arr['house']['characteristic'])) {
  248. $arr['characteristic'] = \common\fm\HouseHandle::ChangeCharacteristic($arr['house']['characteristic']);
  249. }
  250. //楼盘相册
  251. $queryAlbum = new HouseAlbum();
  252. $arr['album'] = $queryAlbum->Groupfind(['hid' => $input['hid']]);
  253. //楼盘户型
  254. $queryType = new \common\models\HouseType();
  255. $queryType->hid = $input['hid'];
  256. $arr['type'] = $queryType->MgetList(2, ['area', 'title', 'img', 'indoor_info']);
  257. //电话
  258. // $arr['house']['tel'] = $sub->RandTel( $arr['house']['city']);
  259. // $arr['house']['tel'] = \common\fm\HouseHandle::ChangeCityTel($arr['house']['city']);
  260. // if(empty($arr['house']['is_tel']))
  261. // {
  262. // $arr['house']['tel'] = \common\fm\HouseHandle::ChangeCityTel($arr['house']['city']);
  263. // }
  264. // else
  265. // {
  266. // $arr['house']['tel'] = $arr['house']['is_tel'];
  267. // }
  268. // $arr['house']['tel'] = Yii::$app->params['default_dialtel'];
  269. $arr['house']['tel'] = \common\fm\HouseHandle::ChangeCityTel($arr['house']['city']);
  270. if (empty($arr['house']['is_tel'])) {
  271. //新增三级联动区域的电话获取修改
  272. if (!empty($arr['house']['area']) && \common\fm\HouseHandle::ChangeCityTel($arr['house']['area']) != Yii::$app->params['default_dialtel']) {
  273. $arr['house']['tel'] = \common\fm\HouseHandle::ChangeCityTel($arr['house']['area']);
  274. } else {
  275. $arr['house']['tel'] = \common\fm\HouseHandle::ChangeCityTel($arr['house']['city']);
  276. }
  277. } else {
  278. $arr['house']['tel'] = $arr['house']['is_tel'];
  279. }
  280. //查询是否单独设置楼盘号码
  281. if (!empty(HouseNumber::SearchNumber($arr['house']['id']))) {
  282. $arr['house']['tel'] = HouseNumber::SearchNumber($arr['house']['id']);
  283. }
  284. //预售证书
  285. $certificate = new \common\models\HousePermit();
  286. $certificate->hid = $input['hid'];
  287. $arr['certificate'] = $certificate->FindNewest();
  288. //楼盘状态
  289. $arr['house']['state'] = Yii::$app->params['HouseSalesStatus'][$arr['house']['state']];
  290. //新闻
  291. $arr['news'] = $this->NewsDynamic($input);
  292. //推荐楼盘
  293. $model = new \common\models\House();
  294. $model->city = $arr['house']['city'];
  295. $model->is_push = 2;
  296. $arr['tuijian_house'] = $model->randList(3, ['house_id' => $arr['house']['id']]);
  297. if (!empty($arr['tuijian_house'])) {
  298. foreach ($arr['tuijian_house'] as &$val) {
  299. $val['characteristic'] = \common\fm\HouseHandle::ChangeCharacteristic($val['characteristic']);
  300. $val['tel'] = \common\fm\HouseHandle::ChangeCityTel($val['city']);
  301. $val['thumb'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['houses'] . $val['thumb'] . '/' . 'same';
  302. $val['state'] = Yii::$app->params['HouseSalesStatus'][$val['state']];
  303. }
  304. }
  305. //楼盘点评
  306. $arr['remark'] = $this->getHouseRemarkList($input, 2);
  307. $vr3d = $this->Vr3d($arr['house']['id']);
  308. if (!empty($vr3d)) {
  309. $arr['house']['panorama'] = $vr3d['path'];
  310. $arr['house']['panorama_img'] = $vr3d['img'];
  311. } else {
  312. if ($arr['house']['panorama_img']) {
  313. $arr['house']['panorama_img'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['house_video'] . $arr['house']['panorama_img'] . '/same';
  314. } else {
  315. $arr['house']['panorama_img'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['houses'] . $arr['house']['thumb'] . '/same';
  316. }
  317. }
  318. if (!empty($arr['house']['video_url'])) {
  319. if (!empty($arr['house']['video_img'])) {
  320. $arr['house']['video_img'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['house_video'] . $arr['house']['video_img'] . '/same';
  321. } else {
  322. $arr['house']['video_img'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['houses'] . $arr['house']['thumb'] . '/same';
  323. }
  324. }
  325. return $arr;
  326. }
  327. }
  328. }
  329. public function Vr3d($hid)
  330. {
  331. $data = \common\models\Vr::find()->where(['hid' => $hid, 'state' => 1, 'type' => 1])->select(['img', 'name', 'path'])->orderBy(['sort' => SORT_DESC])->asArray()->one();
  332. if (!empty($data)) {
  333. $data['img'] = Yii::$app->params['httpImg']['host'] . Yii::$app->params['httpImg']['video'] . $data['img'];
  334. }
  335. return $data;
  336. }
  337. public function NewsDynamic($input)
  338. {
  339. $model = new HouseNews();
  340. $model->hid =$input['hid'];
  341. $houseNewsInfo = $model->getHidList();
  342. $nids = array_column($houseNewsInfo,'nid');
  343. $newsModel = new News();
  344. $newsModel->hid = $input['hid'];
  345. $result = $newsModel->getNewsListHouse($nids,2);
  346. if ($result != null) {
  347. return $result;
  348. }
  349. }
  350. //楼盘详情页数据
  351. public function ParamsDetails()
  352. {
  353. $input = Yii::$app->request->get();
  354. if (is_numeric($input['hid'])) {
  355. $result = [];
  356. $model = new House();
  357. $model->id = $input['hid'];
  358. $result['house'] = $model->HousesAll();
  359. //物业类型
  360. $result['house'] = $this->labelMatchHouse($result['house']);
  361. // p($result);die;
  362. if ($result['house']) {
  363. $sub = new IndexServer();
  364. $result['house']['characteristic'] = $sub->Subject(json_decode($result['house']['characteristic']), 3);
  365. $result['house']['tel'] = $sub->RandTel($result['house']['city']);
  366. $result['house']['architecture_type'] = $this->ArchitectureType(json_decode($result['house']['architecture_type']));
  367. $result['house']['provinceName'] = $sub->getProvinceName($result['house']['province']);
  368. //预售证号
  369. $zheng = new HousePermit();
  370. $result['house']['zhengshu'] = $zheng->getList($input);
  371. //价格历史
  372. $price = new HousePriceRecord();
  373. $price->hid = $input['hid'];
  374. $result['house']['price_record'] = $price->getList([]);
  375. $peitao = new HouseFacilities();
  376. $peitao->hid = $input['hid'];
  377. $pei = $peitao->InfoList();
  378. //查询是否单独设置楼盘号码
  379. if (!empty(HouseNumber::SearchNumber($result['house']['id']))) {
  380. $result['house']['tel'] = HouseNumber::SearchNumber($result['house']['id']);
  381. }
  382. if (!empty($pei)) {
  383. $peiArr = [];
  384. foreach ($pei as $key => &$val) {
  385. if (mb_strlen($val['name'], 'UTF8') == 2) {
  386. $val['name'] = mb_substr($val['name'], 0, 1, 'UTF8') . '&nbsp' . '&nbsp' . '&nbsp' . '&nbsp' . '&nbsp' . '&nbsp' . '&nbsp' . '&nbsp' . mb_substr($val['name'], 1, 1, 'UTF8');
  387. }
  388. if (mb_strlen($val['name'], 'UTF8') == 3) {
  389. $val['name'] = mb_substr($val['name'], 0, 1, 'UTF8') . '&nbsp' . '&nbsp' . mb_substr($val['name'], 1, 1, 'UTF8') . '&nbsp' . '&nbsp' . mb_substr($val['name'], 2, 2, 'UTF8');
  390. }
  391. if (strpos($val['name'], '银行') !== false) {
  392. $val['name'] = mb_substr($val['name'], 0, 1, 'UTF8') . '&nbsp' . '&nbsp' . '&nbsp' . '&nbsp' . '&nbsp' . '&nbsp' . '&nbsp' . '&nbsp' . mb_substr($val['name'], 1, 1, 'UTF8');
  393. }
  394. $peiArr[$val['name']]['name'][] = $val['pname'];
  395. }
  396. $result['peitao'] = $peiArr;
  397. }
  398. return $result;
  399. }
  400. // p( $result['house']['price_record']);
  401. // $peitao = new HouseFacilities();
  402. // $peitao->hid = $input['hid'];
  403. // $pei = $peitao->InfoList();
  404. // if(!empty($pei))
  405. // {
  406. // $peiArr = [];
  407. // foreach ($pei as $key=>$val)
  408. // {
  409. // $peiArr[$val['name']]['name'][] = $val['pname'];
  410. // }
  411. // $result['peitao'] = $peiArr;
  412. // }
  413. }
  414. }
  415. /*
  416. * 建筑类别
  417. * */
  418. public function ArchitectureType($id)
  419. {
  420. if (!empty($id)) {
  421. $model = new CategoryLabel();
  422. $model->id = $id;
  423. $model->type = 2;
  424. $rows = $model->getList([], ['name']);
  425. if (!empty($rows)) {
  426. return array_column($rows, 'name');
  427. }
  428. }
  429. return [];
  430. }
  431. /*
  432. * 楼盘户型-分组
  433. * */
  434. public function HouseType()
  435. {
  436. $input = Yii::$app->request->get();
  437. $typeModel = new HouseType();
  438. // $model = new House();
  439. // $citymodel = new \common\models\CategoryCity();
  440. $typeModel->hid = $input['hid'];
  441. $groupType = $typeModel->TypeGroup();
  442. // $house = $model::findOne($input['hid']);
  443. // $cityson = $citymodel::findOne($house['city']);
  444. // $pcity = $cityson->parentCity;
  445. // $groupType['province'] = $pcity->toArray();
  446. // $groupType['houseName'] = $house['name'];
  447. return $groupType;
  448. }
  449. //楼盘户型分组数据
  450. public function HouseTypeGroupAll($input)
  451. {
  452. if (!empty($input['hid']) && !empty($input['type_id'])) {
  453. $typeModel = new HouseType();
  454. $typeModel->hid = $input['hid'];
  455. $typeModel->type_id = $input['type_id'];
  456. $list = $typeModel->QgetList();
  457. if ($list != null) {
  458. foreach ($list as &$val) {
  459. $val['img'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['housetypes'] . $val['img'] . Yii::$app->params['pfgwatermark'];
  460. }
  461. }
  462. return $list;
  463. }
  464. }
  465. //获取楼盘相册逻辑
  466. public function HouseAlbum()
  467. {
  468. $input = Yii::$app->request->get();
  469. \common\models\House::find();
  470. $queryAlbum = new HouseAlbum();
  471. $arr = $queryAlbum->AlbumGroup(['hid' => $input['hid']]);
  472. return $arr;
  473. }
  474. //获取楼盘相册信息
  475. public function AlbumType()
  476. {
  477. $input = Yii::$app->request->get();
  478. $queryAlbum = new HouseAlbum();
  479. $arr['album'] = $queryAlbum->AlbumGroup(['hid' => $input['hid']]);
  480. $queryAlbum->hid = $input['hid'];
  481. $queryAlbum->album_id = Yii::$app->request->get('album_id', $arr['album'][0]['album_id']);
  482. $arr['data'] = $queryAlbum->getList();
  483. if (!empty($arr['data'])) {
  484. foreach ($arr['data'] as &$val) {
  485. $val['img'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['housealbums'] . $val['img'] . Yii::$app->params['pfgwatermark'];
  486. }
  487. }
  488. $arr['selectalbumtype'] = Yii::$app->request->get('album_id', $arr['album'][0]['album_id']);
  489. return $arr;
  490. }
  491. //获取楼盘分类的所有相册信息
  492. public function HouseAlbumAll()
  493. {
  494. $input = Yii::$app->request->post();
  495. if (!empty($input['hid']) && is_numeric($input['hid'])) {
  496. $queryAlbum = new HouseAlbum();
  497. $queryAlbum->hid = $input['hid'];
  498. $queryAlbum->album_id = $input['album_id'];
  499. $rows = $queryAlbum->getList();
  500. if ($rows) {
  501. foreach ($rows as &$val) {
  502. $val['img'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['housealbums'] . $val['img'] . Yii::$app->params['pfgwatermark'];
  503. }
  504. return $rows;
  505. }
  506. }
  507. }
  508. //楼盘资讯
  509. public function HouseNewsList()
  510. {
  511. $input = Yii::$app->request->get();
  512. if (is_numeric($input['hid'])) {
  513. $model = new HouseNews();
  514. $model->hid =$input['hid'];
  515. $houseNewsInfo = $model->getHidList();
  516. $nids = array_column($houseNewsInfo,'nid');
  517. $newsModel = new News();
  518. $newsModel->hid = $input['hid'];
  519. $result['data'] = $newsModel->getNewsListHouse($nids);
  520. $model = new House();
  521. $citymodel = new \common\models\CategoryCity();
  522. $house = $model::findOne($input['hid']);
  523. $cityson = $citymodel::findOne($house['city']);
  524. $pcity = $cityson->parentCity;
  525. $result['province'] = $pcity->toArray();
  526. $result['houseName'] = $house['name'];
  527. // foreach ($result as &$val)
  528. // {
  529. // $time_int = strtotime($val['open_time']);
  530. //
  531. // $val['y'] = date('Y',$time_int);
  532. // $val['md'] = date('m-d',$time_int);
  533. // $val['thumb'] = json_decode($val['thumb']);
  534. // }
  535. return $result;
  536. }
  537. }
  538. public function getHouseRemarkList($input, $page)
  539. {
  540. $houseComment = new HouseComment();
  541. $houseCommentLikes = new HouseCommentLikes();
  542. $houseCommentReply = new HouseCommentreply();
  543. $houseComment->hid = $input['hid'];
  544. $houseCommentList = $houseComment->getHouseList($page);
  545. if ($houseCommentList != null) {
  546. foreach ($houseCommentList as &$value) {
  547. $value['allremark'] = floor(($value['diduan'] + $value['jiaotong'] + $value['peitao'] + $value['huanjing'] + $value["xingjiabi"]) / 5);
  548. $value['mobile'] = preg_replace("/(\d{3})\d{4}(\d{2})/", "\$1******\$3", $value['mobile']);
  549. $houseCommentLikes->hid = $value['hid'];
  550. $houseCommentLikes->hcid = $value['id'];
  551. $value['count_likes'] = $houseCommentLikes->Total();
  552. $value['reply'] = $houseCommentReply->getCommentReply($value['id']);
  553. }
  554. return $houseCommentList;
  555. }
  556. }
  557. //物业类型
  558. public function labelMatchHouse($house)
  559. {
  560. $model = new \common\models\CategoryLabel();
  561. $label = $model::find()->select(['id', 'name'])->andWhere(['type' => 1])->andWhere(['del' => 1])->asArray()->all();
  562. $label = array_column($label, 'name', 'id');
  563. $arr = json_decode($house['type'], true);
  564. // p($arr);die;
  565. if (!empty($arr)) {
  566. foreach ($arr as $val) {
  567. if (isset($label[$val]) && !empty($label[$val])) {
  568. $house['propertyName'][] = $label[$val];
  569. }
  570. }
  571. }
  572. return $house;
  573. }
  574. //楼盘随机电话
  575. public function RandTel($city)
  576. {
  577. if (!empty($city)) {
  578. $tel = new \common\models\CategoryTelCity();
  579. $tel->cid = $city;
  580. $telModel = $tel->CityTelOne();
  581. if (!empty($telModel['tel'])) {
  582. $telArr = explode(',', $telModel['tel']);
  583. $randNum = array_rand($telArr, 1);
  584. return $telArr[$randNum];
  585. }
  586. }
  587. return Yii::$app->params['default_dialtel'];
  588. }
  589. //返回区域名称 SEO 需求
  590. public function SeoCity($city)
  591. {
  592. $meta = [];
  593. $meta['province'] = '全国';
  594. $meta['city'] = '';
  595. if (is_numeric($city)) {
  596. $model = new \common\models\CategoryCity();
  597. $row = $model->FindById($city);
  598. if ($row['pid'] == 0) {
  599. $meta['province'] = $row['city_name'];
  600. } else {
  601. $meta['city'] = $row['city_name'];
  602. $s = $model->FindById($row['pid']);
  603. if ($s) {
  604. $meta['province'] = $s['city_name'];
  605. }
  606. }
  607. }
  608. return $meta;
  609. }
  610. //楼盘公共信息
  611. public function PublicDetails()
  612. {
  613. $input = Yii::$app->request->get();
  614. $houseModel = new House();
  615. $houseModel->id = $input['hid'];
  616. $houseRow = $houseModel->OneDetails(['id', 'name', 'state', 'city', 'area', 'characteristic', 'thumb', 'is_tel']);
  617. if ($houseRow != null) {
  618. // $houseRow['city'] = '';
  619. if (!empty($houseRow['city'])) {
  620. $cityModel = new \common\models\CategoryCity();
  621. $houseRow['seo'] = $cityModel->FatherSon($houseRow['city']);
  622. if (empty($houseRow['seo']['city'])) {
  623. $houseRow['seo']['city'] = '';
  624. }
  625. }
  626. //猜你喜欢
  627. $houseModel->id = '';
  628. $houseModel->city = $houseRow['city'];
  629. $houseRow['randhouse'] = $houseModel->randList(4);
  630. $houseRow['state'] = Yii::$app->params['HouseSalesStatus'][$houseRow['state']];
  631. $houseRow['thumb'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['houses'] . $houseRow['thumb'];
  632. //特色主题
  633. // $subject =
  634. // $this->Subject(json_decode($houseRow['characteristic'],true));
  635. $houseRow['characteristic'] = \common\fm\HouseHandle::ChangeCharacteristic($houseRow['characteristic']);;
  636. //随机电话
  637. if (empty($houseRow['is_tel'])) {
  638. if (!empty($houseRow['area']) && \common\fm\HouseHandle::ChangeCityTel($houseRow['area']) != Yii::$app->params['default_dialtel']) {
  639. $houseRow['tel'] = \common\fm\HouseHandle::ChangeCityTel($houseRow['area']);
  640. } else {
  641. $houseRow['tel'] = \common\fm\HouseHandle::ChangeCityTel($houseRow['city']);
  642. }
  643. } else {
  644. $houseRow['tel'] = $houseRow['is_tel'];
  645. }
  646. return $houseRow;
  647. }
  648. }
  649. /**
  650. * 价格
  651. * @return mixed
  652. */
  653. public function PriceList()
  654. {
  655. $PriceModel = new HousesPrice();
  656. $PriceList = $PriceModel->getList([], ['price', 'id']);
  657. if ($PriceList != null) {
  658. return $PriceList;
  659. }
  660. }
  661. }