HouseController.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: xiaofeng
  5. * Date: 2018/4/19
  6. * Time: 下午2:52
  7. */
  8. namespace mobile\controllers;
  9. use common\fm\HouseHandle;
  10. use common\models\Brand;
  11. use common\models\CategoryLabel;
  12. use common\models\Characteristic;
  13. use common\models\House;
  14. use common\models\HouseComment;
  15. use common\models\HouseCommentLikes;
  16. use common\models\Sensitivewords;
  17. use mobile\base\CommonController;
  18. use mobile\server\IndexServer;
  19. use mobile\server\WordMatcher;
  20. use linslin\yii2\curl;
  21. use Yii;
  22. use mobile\base\Help;
  23. //use yii\data\Pagination;
  24. //use frontend\server\HouseServer;
  25. //use frontend\base\Help;
  26. use mobile\server\HouseServer;
  27. use yii\helpers\Html;
  28. class HouseController extends CommonController
  29. {
  30. const LOCATIONCITYHOUSE = 'locationcityhouse';
  31. public $enableCsrfValidation = false;
  32. public function beforeAction($action)
  33. {
  34. if (in_array(Yii::$app->controller->action->id, ['home', 'type', 'details', 'album', 'houseremark', 'news'])) {
  35. $input = Yii::$app->request->get();
  36. if (!is_numeric($input['hid'])) {
  37. $input['hid'] = explode('-', Yii::$app->request->get('hid'))[1];
  38. }
  39. if (empty((new House())->HouseIsshow($input['hid']))) {
  40. return $this->redirect('/public/showhouse')->send();
  41. }
  42. }
  43. return parent::beforeAction($action); // TODO: Change the autogenerated stub
  44. }
  45. /*
  46. * 楼盘首页
  47. * */
  48. public function actionHome()
  49. {
  50. $this->on(self::LOCATIONCITYHOUSE, [new \common\fm\HouseHandle(), 'MobileCityLocation']);
  51. $this->trigger(self::LOCATIONCITYHOUSE);
  52. $model = new HouseServer();
  53. $sub = new \mobile\server\IndexServer();
  54. $row = $model->Details();
  55. /***2020.6.18 lyy 获取楼盘直播视频****/
  56. $row['house']['live'] = $model->GetLiveInfo($row['house']['id']);
  57. $row['house']['provinceName'] = $sub->getProvinceName($row['house']['province']);
  58. // p($row);die;
  59. $str = [];
  60. $type = $model->HouseType();
  61. $row['seo'] = $model->SeoCity(isset($row['house']['city']) ? $row['house']['city'] : '');
  62. return $this->render('home', ['model' => $row, 'pince' => $str, 'type' => $type]);
  63. }
  64. /**
  65. * 楼盘列表
  66. * */
  67. public function actionSearch()
  68. {
  69. $data = HouseServer::Search(1);
  70. $data['characteristic'] = (new Characteristic())->getListAll();
  71. //物业类型
  72. $labelType = new CategoryLabel();
  73. $labelType->type = 1;
  74. $labelType->state = 1;
  75. $data['label'] = $labelType->getList([], ['id', 'name']); //物业
  76. // $model = new IndexServer();
  77. // $lunbo = $model->Lunbo();
  78. // 'lunbo'=>$lunbo,
  79. $CityModel = new \common\models\CategoryCity();
  80. $city = $CityModel->FindById(Yii::$app->hostserver->hostId);
  81. //遍历前10条数据
  82. $house = new HouseServer();
  83. $input = Yii::$app->request->get();
  84. $input['abroad'] = 1;
  85. $rows = $house->SearchForm($input);
  86. $start_time = date('Y/m') . '/01-' . date('Y/m', strtotime('+ 2 month')) . '/01'; //有效日期
  87. $gCity = Yii::$app->hostserver->hostId;
  88. if ($gCity != 0) {
  89. $cityName = \common\models\CategoryCity::findOne($gCity)['city_name'];
  90. } else {
  91. $cityName = '全国';
  92. }
  93. //SEO
  94. $meta = $house->SeoCity(isset($input['city']) ? $input['city'] : (empty($gCity)? '' : $gCity ));
  95. return $this->render('search', [
  96. 'model' => $data,
  97. 'city' => $city,
  98. 'house' => $rows['data'],
  99. 'start_time' => $start_time,
  100. 'house_total' => $rows['count'],
  101. 'cityname' => $cityName,'seo'=>$meta],
  102. );
  103. }
  104. public function actionSearchdata()
  105. {
  106. $model = new HouseServer();
  107. $input = Yii::$app->request->get();
  108. $input['abroad'] = 1;
  109. $rows = $model->SearchForm($input);
  110. if (!empty($rows)) {
  111. return Help::JsonData(Help::SUCCESS, '成功', $rows['count'], $rows['data']);
  112. //return Help::JsonCode(Help::SUCCESS,'成功',$rows);
  113. }
  114. return Help::JsonCode(Help::ERROR, '暂无相关楼盘数据');
  115. }
  116. /*
  117. * 国外楼盘
  118. */
  119. public function actionAbroad()
  120. {
  121. $data = HouseServer::Search(2);
  122. // $model = new IndexServer();
  123. // $lunbo = $model->Lunbo();
  124. //遍历前10条数据
  125. $house = new HouseServer();
  126. $input = Yii::$app->request->get();
  127. $input['abroad'] = 2;
  128. $rows = $house->SearchForm($input);
  129. $start_time = date('Y/m') . '/01-' . date('Y/m', strtotime('+ 2 month')) . '/01'; //有效日期
  130. return $this->render('abroad', ['model' => $data, 'house' => $rows['data'], 'start_time' => $start_time, 'house_count' => $rows['count']]);
  131. }
  132. /*
  133. * 国外楼盘数据
  134. */
  135. public function actionSearchdatas()
  136. {
  137. $model = new HouseServer();
  138. $input = Yii::$app->request->get();
  139. $input['abroad'] = 2;
  140. $rows = $model->SearchForm($input);
  141. if (!empty($rows)) {
  142. return Help::JsonData(Help::SUCCESS, '成功', $rows['count'], $rows['data']);
  143. }
  144. return Help::JsonCode(Help::ERROR, '暂无相关楼盘数据');
  145. }
  146. /*
  147. * 楼盘名称搜索
  148. * */
  149. public function actionSearchname()
  150. {
  151. $model = new HouseServer();
  152. $row = $model->SearchHouseName(Yii::$app->request->get());
  153. if (!empty($row)) {
  154. return Help::JsonCode(Help::SUCCESS, '成功', $row);
  155. }
  156. return Help::JsonCode(Help::ERROR, '暂无搜索数据');
  157. }
  158. /*
  159. * 获取区域子类信息
  160. * */
  161. public function actionSoncity()
  162. {
  163. $CityModel = new \common\models\CategoryCity();
  164. $r = $CityModel->GetAllSon(Yii::$app->request->post('pid'), ['city_name', 'id', 'pinyin'], 2);
  165. return Help::JsonCode(Help::SUCCESS, '成功', $r);
  166. }
  167. /*
  168. * 获取楼盘户型分组和分组总数
  169. * */
  170. public function actionType()
  171. {
  172. $model = new HouseServer();
  173. $row = $model->HouseType();
  174. $publiHouse = $model->PublicDetails();
  175. $input['hid'] = Yii::$app->request->get('hid');
  176. $input['type_id'] = Yii::$app->request->get('type_id',$row[0]['type_id'] );
  177. $typeimg = $model->HouseTypeGroupAll($input);
  178. return $this->render('type', ['model' => $row, 'hid' => Yii::$app->request->get('hid'),'public' => $publiHouse,'typeimg'=>$typeimg]);
  179. }
  180. /*
  181. * 楼盘户型分组后的数据
  182. * */
  183. public function actionHousetype()
  184. {
  185. $model = new HouseServer();
  186. $rows = $model->HouseTypeGroupAll(Yii::$app->request->post());
  187. if ($rows != null) {
  188. return Help::JsonCode(Help::SUCCESS, '成功', $rows);
  189. }
  190. return Help::JsonCode(Help::ERROR, '暂无楼盘户型图数据');
  191. }
  192. /*
  193. * 楼盘户型数据
  194. * */
  195. public function actionHousetypeall()
  196. {
  197. // $model = new HouseServer();
  198. // $rows = $model->TypeAll(Yii::$app->request->post(),false);
  199. // if($rows != null)
  200. // {
  201. // return Help::JsonCode(Help::SUCCESS,'成功',$rows);
  202. // }
  203. }
  204. /*
  205. * 楼盘首页-楼盘动态
  206. * */
  207. public function actionDynamic()
  208. {
  209. // $model = new HouseServer();
  210. // $rows = $model->NewsDynamic(Yii::$app->request->post());
  211. // if($rows != null)
  212. // {
  213. // return Help::JsonCode(Help::SUCCESS,'成功',$rows);
  214. // }
  215. // return Help::JsonCode(Help::ERROR,'失败');
  216. }
  217. /*
  218. * 楼盘详细信息
  219. * */
  220. public function actionDetails()
  221. {
  222. $model = new HouseServer();
  223. $row = $model->ParamsDetails();
  224. $publiHouse = $model->PublicDetails();
  225. // $row['house']['state'] = Yii::$app->params['HouseSalesStatus'][$row['house']['state']];
  226. // p($row);die;
  227. return $this->render('details', ['model' => $row, 'hid' => Yii::$app->request->get('hid'),'public' => $publiHouse]);
  228. }
  229. /*
  230. * 楼盘详细介绍
  231. * */
  232. public function actionIntro()
  233. {
  234. $model = new HouseServer();
  235. $row = $model->ParamsDetails();
  236. if ($row) return $this->render('intro', ['model' => $row]);
  237. return $this->goBack();
  238. }
  239. /*
  240. * 楼盘资讯
  241. * */
  242. public function actionNews()
  243. {
  244. $model = new HouseServer();
  245. $rows = $model->HouseNewsList();
  246. $publiHouse = $model->PublicDetails();
  247. return $this->render('news', ['model' => $rows, 'hid' => Yii::$app->request->get('hid'),'public' => $publiHouse]);
  248. }
  249. public function actionPeriphery()
  250. {
  251. return $this->render('periphery');
  252. }
  253. /*
  254. * 楼盘相册页面
  255. * */
  256. public function actionAlbum()
  257. {
  258. $model = new HouseServer();
  259. // $rows = $model->HouseAlbum();
  260. $rows = $model->AlbumType();
  261. $publiHouse = $model->PublicDetails();
  262. return $this->render('album', ['model' => $rows, 'hid' => Yii::$app->request->get('hid'),'public' => $publiHouse]);
  263. }
  264. /*
  265. * 楼盘所有相册
  266. * */
  267. public function actionAlbumlist()
  268. {
  269. $model = new HouseServer();
  270. $rows = $model->HouseAlbumAll();
  271. if (!empty($rows)) {
  272. return Help::JsonCode(Help::SUCCESS, '成功', $rows);
  273. }
  274. return Help::JsonCode(Help::ERROR, '暂无楼盘相册信息');
  275. }
  276. /*
  277. * 楼盘首页底部---推荐楼盘 同价位楼盘 周边楼盘
  278. * */
  279. public function actionTall()
  280. {
  281. $model = new \common\models\House();
  282. $input = Yii::$app->request->post();
  283. $arr = [];
  284. if (isset($input['type'])) {
  285. switch ($input['type']) {
  286. case 1: //后期如果不要传递价格作为参数 在删除掉
  287. $arr['price'] = $input['price'];
  288. if ($arr['price'] == 0) {
  289. $arr['price'] = "";
  290. }
  291. $model->price = $arr['price'];
  292. $model->city = $input['city'];
  293. break;
  294. case 2:
  295. $arr['city'] = $input['city'];
  296. $model->city = $arr['city'];
  297. break;
  298. }
  299. }
  300. $model->is_push = 2;
  301. $rows = $model->randList(3, $arr);
  302. if (!empty($rows)) {
  303. foreach ($rows as &$val) {
  304. $val['characteristic'] = \common\fm\HouseHandle::ChangeCharacteristic($val['characteristic']);
  305. $val['tel'] = \common\fm\HouseHandle::ChangeCityTel($val['city']);
  306. $val['thumb'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['houses'] . $val['thumb'];
  307. }
  308. return Help::JsonCode(Help::SUCCESS, '成功', $rows);
  309. }
  310. return Help::JsonCode(Help::ERROR, '暂无数据');
  311. }
  312. /**
  313. * @return mixed
  314. * 获取楼盘ID,返回楼盘预售证书信息
  315. */
  316. public function actionLicence()
  317. {
  318. $input = Yii::$app->request->post();
  319. if (!empty($input['hid'])) {
  320. $model = new \common\models\HousePermit();
  321. $rows = $model->getList($input);
  322. if ($rows != null) {
  323. return Help::JsonCode(Help::SUCCESS, '成功', $rows);
  324. }
  325. }
  326. return Help::JsonCode(Help::ERROR, '失败');
  327. }
  328. /*
  329. * 楼盘---点评
  330. * */
  331. // public function actionRemark()
  332. // {
  333. // return $this->render('remark');
  334. // }
  335. /*
  336. * 楼盘--周边配套
  337. * */
  338. // public function actionPeitao()
  339. // {
  340. // return $this->render('peitao');
  341. // }
  342. public function actionRemarkfrom()
  343. {
  344. $input = Yii::$app->request->post();
  345. $model = new HouseComment();
  346. $input['ip'] = Yii::$app->request->userIP;
  347. $wordMatcher = new WordMatcher();
  348. $sensitivewords = new Sensitivewords();
  349. $senWordsInfo = $sensitivewords->getList();
  350. $list = explode("、", $senWordsInfo['info']);
  351. foreach ($list as $val) {
  352. $wordMatcher->addWord($val);
  353. }
  354. $wordMatcher->match($input['content'], $matched);
  355. if (!empty($matched)) {
  356. return Help::JsonCode(Help::ERROR, '点评内容存在敏感词汇', $matched);
  357. }
  358. $true = $model->Iplimit($input);
  359. if ($true === false) return Help::JsonCode(Help::ERROR, '一个楼盘最多只能点评2次');
  360. $input['initiator'] = 2;
  361. $input['is_show'] = 2;
  362. if ($model->load($input, '') && $model->save()) {
  363. $curlArr = array(
  364. "mobile" => $input['mobile'],
  365. "source" => 40,
  366. "equipment" => 1,
  367. "hid" => $input['hid'],
  368. );
  369. $curl = new curl\Curl();
  370. $url = 'http://m.yigouf.com/enroll/signup';
  371. $response = $curl->reset()->setOption(CURLOPT_POSTFIELDS, http_build_query($curlArr))->post($url);
  372. return Help::JsonCode(Help::SUCCESS, Yii::t('app', '点评成功'));
  373. }
  374. return Help::JsonCode(Help::ERROR, Yii::t('app', '点评失败'), $model->errors);
  375. }
  376. public function actionRemarklikesfrom()
  377. {
  378. $input = Yii::$app->request->post();
  379. $model = new HouseCommentLikes();
  380. $input['ip'] = Yii::$app->request->userIP;
  381. $true = $model->Iplimit($input);
  382. if ($true === false) return Help::JsonCode(Help::ERROR, '一条点评最多只能赞一次');
  383. if ($model->load($input, '') && $model->save()) {
  384. $model->hid = $input['hid'];
  385. $model->hcid = $input['hcid'];
  386. $total = $model->Total();
  387. return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'add_success'), $total);
  388. }
  389. return Help::JsonCode(Help::ERROR, Yii::t('app', 'add_error'), $model->errors);
  390. }
  391. public function actionHouseremark()
  392. {
  393. $model = new HouseServer();
  394. $houseComment = new HouseComment();
  395. $rows = $model->Details();
  396. $input = Yii::$app->request->get();
  397. $getHouseList = $model->getHouseRemarkList($input, 10);
  398. $houseComment->hid = $input['hid'];
  399. $getHouseListTotal = $houseComment->getHouseListTotal();
  400. $publiHouse = $model->PublicDetails();
  401. return $this->render('houseremark', ['model' => $rows, 'hid' => Yii::$app->request->get('hid'), 'xuqiu' => $houseComment->xuqiu, 'commentList' => $getHouseList, 'getHouseListTotal' => $getHouseListTotal,'public' => $publiHouse]);
  402. }
  403. public function actionHouseloadremark()
  404. {
  405. $model = new HouseServer();
  406. $houseComment = new HouseComment();
  407. $input['hid'] = Yii::$app->request->get('hid');
  408. $input['page'] = Yii::$app->request->get('page');
  409. $input['limit'] = Yii::$app->request->get('limit');
  410. $getHouseList = $model->getHouseRemarkList($input);
  411. if ($getHouseList != null) {
  412. return Help::JsonCode(Help::SUCCESS, '成功', $getHouseList);
  413. }
  414. return Help::JsonCode(Help::ERROR, '失败');
  415. }
  416. /*
  417. * 楼盘详细信息
  418. * */
  419. public function actionLoan()
  420. {
  421. return $this->render('loan');
  422. }
  423. /*
  424. * 楼盘---点评详情
  425. * */
  426. public function actionRemarkdetails()
  427. {
  428. return $this->render('remarkdetails');
  429. }
  430. /*
  431. * 楼盘---相册放大页
  432. * */
  433. public function actionPvimage()
  434. {
  435. $input = Yii::$app->request->get();
  436. $house = House::find()->select(['name'])->andWhere(['id' => $input['hid']])->asArray()->one();
  437. $model = new HouseServer();
  438. $rows = $model->HouseAlbum();
  439. return $this->render('pvimage', ['hid' => $input['hid'], 'row' => $rows, 'house' => $house]);
  440. }
  441. /*
  442. * 户型---相册放大页
  443. * */
  444. public function actionHximage()
  445. {
  446. $input = Yii::$app->request->get();
  447. $house = House::find()->select(['name'])->andWhere(['id' => $input['hid']])->asArray()->one();
  448. $model = new HouseServer();
  449. $rows = $model->HouseType();
  450. return $this->render('hximage', ['hid' => $input['hid'], 'row' => $rows, 'house' => $house]);
  451. }
  452. //楼盘详情页价格走势
  453. public function actionHouseprice()
  454. {
  455. $get = Yii::$app->request->get();
  456. if (is_numeric($get['id'])) {
  457. $price = HouseHandle::HousePrice($get['id']);
  458. if ($price != null) {
  459. return Help::JsonCode(Help::SUCCESS, '成功', $price);
  460. }
  461. return Help::JsonCode(Help::ERROR, '失败');
  462. }
  463. }
  464. // 独立拔打电话页面
  465. public function actionSelftel()
  466. {
  467. $input = Yii::$app->request->get();
  468. $row = (new HouseServer())->Details($input);
  469. return $this->renderPartial('selftel', ['model' => $row]);
  470. }
  471. // 众趣播放页面
  472. public function actionZhongqu()
  473. {
  474. $input = Yii::$app->request->get();
  475. return $this->render('zhongqu',['url'=>$input['h']]);
  476. }
  477. }