HouseController.php 16 KB

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