HouseServer.php 29 KB

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