HouseController.php 16 KB

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