HouseController.php 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: xiaofeng
  5. * Date: 2018/3/4
  6. * Time: 下午2:11
  7. */
  8. namespace backend\controllers;
  9. use backend\base\CommonController;
  10. use backend\server\Houses;
  11. use backend\base\Help;
  12. //use backend\server\SetUploadImg;
  13. //use backend\server\UploadFile;
  14. //use common\models\HouseNews;
  15. use common\models\House;
  16. use common\models\HouseDetail;
  17. use common\models\CategoryCity;
  18. use common\models\HousePermit;
  19. use Yii;
  20. //use Tinify\Tinify;
  21. class HouseController extends CommonController
  22. {
  23. /*
  24. * 楼盘显示页面
  25. * */
  26. public function actionIndex()
  27. {
  28. $city = new \common\models\CategoryCity();
  29. // $city->pid = 0;
  30. $cityList = $city->getList([], ['city_name', 'id']);
  31. return $this->render('index', ['city' => $cityList]);
  32. }
  33. /*
  34. * 获取楼盘列表数据
  35. * */
  36. public function actionIndexform()
  37. {
  38. $model = new Houses();
  39. $rows = $model->GroupList(Yii::$app->request->post());
  40. if ($rows != null) {
  41. return Help::JsonData(0, '成功', $rows['count'], $rows['data']);
  42. }
  43. }
  44. /*
  45. * 添加楼盘页面
  46. * */
  47. public function actionCreate()
  48. {
  49. $model = new Houses();
  50. $rows = $model->HouseRelation();
  51. return $this->render('create', ['model' => $rows]);
  52. }
  53. /*
  54. * 添加楼盘数据
  55. * */
  56. public function actionCreatefrom()
  57. {
  58. $model = new Houses();
  59. $result = $model->add(Yii::$app->request->post());
  60. if ($result === true) {
  61. return Help::JsonCode(200, '新楼盘添加成功');
  62. }
  63. return Help::JsonCode(300, '新楼盘添加失败', $result);
  64. }
  65. /*
  66. *修改楼盘的显示页面
  67. * */
  68. public function actionEdit()
  69. {
  70. $modelDetails = new \common\models\House();
  71. $modelDetails->id = Yii::$app->request->get('id');
  72. $row = $modelDetails->HousesAll();
  73. if ($row != null) {
  74. $model = new Houses();
  75. $rows = $model->HouseRelation();
  76. $row['characteristic'] = json_decode($row['characteristic']);
  77. $row['type'] = json_decode($row['type']);
  78. $row['architecture_type'] = json_decode($row['architecture_type']);
  79. $row['property_tag'] = json_decode($row['property_tag']);
  80. // $row['fit'] = explode(',',$row['fit']);
  81. $row['evaluating'] = json_decode($row['evaluating']);
  82. if (empty($row['province'])) {
  83. $city = \common\models\CategoryCity::findOne($row['city']);
  84. if ($city) {
  85. $row['province'] = \common\models\CategoryCity::findOne($city['pid'])['id'];
  86. }
  87. }
  88. // if(!empty($details['architecture_type'])) if (in_array($val['id'], $details['architecture_type'])) echo 'checked'
  89. $row['thumb'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['houses'] . $row['thumb'] . Yii::$app->params['pfgwatermark'];
  90. $row['video_img'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['house_video'] . $row['video_img'] . Yii::$app->params['pfgwatermark'];
  91. $row['panorama_img'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['house_video'] . $row['panorama_img'] . Yii::$app->params['pfgwatermark'];
  92. return $this->render('edit', ['model' => $rows, 'details' => $row]);
  93. }
  94. }
  95. /*
  96. * 修改楼盘信息
  97. * */
  98. public function actionEditfrom()
  99. {
  100. $post = Yii::$app->request->post();
  101. $model = new Houses();
  102. $result = $model->Edit($post);
  103. if ($result === true) {
  104. return Help::JsonCode(Help::SUCCESS, '楼盘修改成功');
  105. }
  106. return Help::JsonCode(Help::ERROR, '楼盘修改失败', $result);
  107. }
  108. /*
  109. * 楼盘排序页面
  110. * */
  111. public function actionHousesort()
  112. {
  113. return $this->render('housesort');
  114. }
  115. /*
  116. * 排序页面一键清零
  117. * */
  118. public function actionQingzero()
  119. {
  120. $post = Yii::$app->request->post();
  121. if (empty($post['city'])) return Help::JsonCode(Help::ERROR, '请先选择区域');
  122. $city = CategoryCity::findOne($post['city']);
  123. if ($city['pid'] == 0) {
  124. $city = CategoryCity::find()->andWhere(['pid' => $city['id'], 'del' => 1])->column();
  125. } else {
  126. $city = $city['id'];
  127. }
  128. $houseid = House::find()->andWhere(['city' => $city, 'del' => 1])->column();
  129. $zero = Yii::$app->request->post('zero');
  130. switch ($zero) {
  131. case 1:
  132. $state = House::updateAll(['sort' => 0], ['id' => $houseid]);
  133. if ($state) return Help::JsonCode(Help::SUCCESS, '清零成功', $zero);
  134. break;
  135. case 2:
  136. $state = HouseDetail::updateAll(['regionsort' => 0], ['hid' => $houseid]);
  137. if ($state) return Help::JsonCode(Help::SUCCESS, '清零成功', $zero);
  138. break;
  139. case 3:
  140. $state = HouseDetail::updateAll(['allsort' => 0], ['hid' => $houseid]);
  141. if ($state) return Help::JsonCode(Help::SUCCESS, '清零成功', $zero);
  142. break;
  143. }
  144. return Help::JsonCode(Help::ERROR, '没有可清零的数据', $zero);
  145. }
  146. /*
  147. * 单独修改排序
  148. * */
  149. public function actionHousesortedit()
  150. {
  151. // $model = new \common\models\House();
  152. $input = Yii::$app->request->post();
  153. if (!empty($input['type']) && $input['type'] == 'allsort') {
  154. $model = new \common\models\HouseDetail();
  155. $find = $model->FindById($input['id']);
  156. } else if (!empty($input['type']) && $input['type'] == 'regionsort') {
  157. $model = new \common\models\HouseDetail();
  158. $find = $model->FindById($input['id']);
  159. } else {
  160. $model = new \common\models\House();
  161. $find = $model->FindById($input['id']);
  162. }
  163. if ($find != null) {
  164. switch ($input['type']) {
  165. case 'deal_num':
  166. $find->deal_num = $input['deal_num'];
  167. break;
  168. case 'sort':
  169. $find->sort = $input['sort'];
  170. break;
  171. case 'stars':
  172. $find->stars = $input['stars'];
  173. break;
  174. case 'city_ranking':
  175. $find->city_ranking = $input['city_ranking'];
  176. break;
  177. case 'allsort':
  178. $find->allsort = $input['allsort'];
  179. break;
  180. case 'regionsort':
  181. $find->regionsort = $input['regionsort'];
  182. break;
  183. }
  184. if (!empty($input['examineid'])) {
  185. switch ($find->is_view) {
  186. case 1:
  187. $find->is_view = 2;
  188. break;
  189. case 2:
  190. $find->is_view = 1;
  191. break;
  192. }
  193. }
  194. if ($find->update(false) == true) return Help::JsonCode(Help::SUCCESS, '操作成功');
  195. }
  196. return Help::JsonCode(Help::ERROR, '操作失败');
  197. }
  198. /*
  199. * 删除楼盘
  200. * */
  201. public function actionHousedel()
  202. {
  203. $result = \common\models\House::updateAll(['del' => 2, 'update_at' => $_SERVER['REQUEST_TIME']], ['id' => Yii::$app->request->post('hid')]);
  204. if ($result > 0) {
  205. $arr = [];
  206. foreach (Yii::$app->request->post('hid') as $key => $val) {
  207. $arr[$key]['uid'] = Yii::$app->session['user_info']['uid'];
  208. $arr[$key]['hid'] = $val;
  209. $arr[$key]['create_at'] = $_SERVER['REQUEST_TIME'];
  210. $arr[$key]['type'] = 2;
  211. }
  212. $res = Yii::$app->db->createCommand()->batchInsert(\common\models\UserHouse::tableName(), ['uid', 'hid', 'create_at', 'type'], $arr)->execute();
  213. return Help::JsonCode(Help::SUCCESS, '删除成功');
  214. }
  215. return Help::JsonCode(Help::ERROR, '删除失败');
  216. }
  217. public function actionOpenstate()
  218. {
  219. $id = Yii::$app->request->get('hid');
  220. if (!empty($id)) {
  221. $model = new \common\models\HouseAuditingrecord();
  222. $model->hid = $id;
  223. $rows = $model->getList();
  224. if (!empty($rows)) {
  225. foreach ($rows as &$val) {
  226. $val['create_at'] = date('Y-m-d H:i', $val['create_at']);
  227. $val['house_state'] = Yii::$app->params['house_view'][$val['house_state']];
  228. }
  229. }
  230. return $this->render('openstate', ['hid' => $id, 'model' => $rows]);
  231. }
  232. }
  233. public function actionOpenstateform()
  234. {
  235. $input = Yii::$app->request->post();
  236. $house = new House();
  237. $find = $house->FindById($input['hid']);
  238. if (!empty($find)) {
  239. $Transaction = Yii::$app->db->beginTransaction();
  240. $input['house_state'] = $find['is_view'];
  241. switch ($find['is_view']) {
  242. case 1:
  243. $find->is_view = 2;
  244. break;
  245. case 2:
  246. $find->is_view = 1;
  247. break;
  248. }
  249. $input['house_state'] = $find->is_view;
  250. $input['uid'] = Yii::$app->session['user_info']['uid'];
  251. $model = new \common\models\HouseAuditingrecord();
  252. if ($model->load($input, '') && $model->save() && $find->save(false)) {
  253. $Transaction->commit();
  254. return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'edit_success'));
  255. }
  256. $Transaction->rollBack();
  257. return Help::JsonCode(Help::ERROR, Yii::t('app', 'edit_error'), $model->errors);
  258. }
  259. }
  260. //批量操作
  261. public function actionBatchsave()
  262. {
  263. return $this->render('batchsave');
  264. }
  265. //批量操作
  266. public function actionBatchsaveform()
  267. {
  268. $input = Yii::$app->request->post();
  269. $model = \common\models\House::updateAll(['is_view' => 2], ['city' => $input['city']]);
  270. if ($model > 0) {
  271. return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'edit_success'));
  272. }
  273. return Help::JsonCode(Help::ERROR, Yii::t('app', 'edit_error'));
  274. }
  275. //================================楼盘资讯======================================
  276. /*
  277. * 关联楼盘的资讯
  278. * */
  279. public function actionNewslist()
  280. {
  281. $model = new \common\models\CategoryNews();
  282. $list = $model->getList([], ['id', 'news_name']);
  283. return $this->render('newslist', ['name' => Yii::$app->request->get(), 'category' => $list]);
  284. }
  285. /*
  286. * 获取跟楼盘有关的资讯
  287. * */
  288. public function actionNewslistform()
  289. {
  290. $model = new Houses();
  291. $result = $model->FilterNews();
  292. if (!empty($result['data'])) {
  293. return Help::JsonData(0, '成功', $result['count'], $result['data']);
  294. }
  295. return Help::JsonCode(Help::ERROR, '暂无关联的资讯信息');
  296. }
  297. /*
  298. * 加载资讯列表页面,
  299. * */
  300. public function actionLoadnews()
  301. {
  302. $model = new \common\models\CategoryNews();
  303. $list = $model->getList([], ['id', 'news_name']);
  304. return $this->render('loadnews', ['category' => $list, 'hid' => Yii::$app->request->get('hid')]);
  305. }
  306. /*
  307. * 加载资讯列表数据,
  308. * */
  309. public function actionLoadnewslist()
  310. {
  311. $model = new Houses();
  312. $rows = $model->FilterLoadNews();
  313. if (!empty($rows)) {
  314. return Help::JsonData(0, '成功', $rows['count'], $rows['data']);
  315. }
  316. return Help::JsonCode(Help::ERROR, '暂无关联的资讯信息');
  317. }
  318. /*
  319. * 楼盘关联资讯数据
  320. * */
  321. public function actionRelationnews()
  322. {
  323. $model = new Houses();
  324. $row = $model->RelationNewsRecord();
  325. if ($row === true) return Help::JsonCode(Help::SUCCESS, '资讯加载成功');
  326. return Help::JsonCode(Help::ERROR, '资讯加载失败');
  327. }
  328. /*
  329. * 删除楼盘关联的资讯
  330. * */
  331. public function actionHousenewsdel()
  332. {
  333. $model = new \common\models\HouseNews();
  334. $row = $model->FingById(Yii::$app->request->post('dataid'));
  335. if ($row != null) {
  336. if (Yii::$app->request->post('type') == 2) {
  337. if ($row->is_view == 2) {
  338. $row->is_view = 1;
  339. } else {
  340. $row->is_view = 2;
  341. }
  342. } else {
  343. $row->del = 2;
  344. }
  345. if ($row->update() == true) return Help::JsonCode(Help::SUCCESS, '删除成功');
  346. }
  347. return Help::JsonCode(Help::ERROR, '删除失败');
  348. }
  349. /*
  350. * 删除楼盘关联的资讯(改)
  351. * */
  352. public function actionHousenewsdelgai()
  353. {
  354. $input = Yii::$app->request->post();
  355. if($input['hn'] == 'news'){//资讯是从news表里的
  356. $row = \common\models\News::findOne($input['nid']);
  357. $row->hid = 0;
  358. if($row->update(false)){
  359. return Help::JsonCode(Help::SUCCESS, '删除成功');
  360. }
  361. }elseif(is_numeric($input['hn'])){
  362. $model = new \common\models\HouseNews();
  363. $row = $model->FingById($input['hn']);
  364. if($row->delete()){
  365. return Help::JsonCode(Help::SUCCESS, '删除成功');
  366. }
  367. }
  368. return Help::JsonCode(Help::ERROR, '删除失败');
  369. }
  370. //================================楼盘相册======================================
  371. /*
  372. * 楼盘相册页面
  373. * */
  374. public function actionAlbum()
  375. {
  376. $model = new \common\models\CategoryAlbum();
  377. $album = $model->getList([], ['id', 'name']);
  378. return $this->render('album', ['post' => Yii::$app->request->get(), 'model' => $album]);
  379. }
  380. /*
  381. * 楼盘相册数据
  382. * */
  383. public function actionAlbumform()
  384. {
  385. $model = new \common\models\HouseAlbum();
  386. $result = $model->AlbumGroup(Yii::$app->request->post());
  387. // foreach ($result as &$val)
  388. // {
  389. // $val['state'] = Yii::$app->params['newsStatus'][$val['state']];
  390. // }
  391. if ($result != null) {
  392. return Help::JsonData(0, '成功', 0, $result);
  393. }
  394. return Help::JsonCode(Help::ERROR, '暂无相册信息,请添加相册');
  395. }
  396. /*
  397. * 添加楼盘相册页面
  398. * */
  399. public function actionAlbumadd()
  400. {
  401. $model = new \common\models\CategoryAlbum();
  402. $album = $model->getList([], ['id', 'name']);
  403. return $this->render('albumadd', ['post' => Yii::$app->request->get(), 'model' => $album]);
  404. }
  405. /*
  406. * 添加楼盘相册数据
  407. * */
  408. public function actionAlbumaddform()
  409. {
  410. $model = new Houses();
  411. $result = $model->HouseAibumCreate();
  412. if ($result === true) {
  413. return Help::JsonCode(Help::SUCCESS, '添加成功');
  414. }
  415. return Help::JsonCode(Help::ERROR, '添加失败', $result);
  416. }
  417. /*
  418. * 修改楼盘相册页面
  419. * */
  420. public function actionAlbumedit()
  421. {
  422. $model = new \common\models\CategoryAlbum();
  423. $album = $model->getList([], ['id', 'name']);
  424. $modelAlbum = new \common\models\HouseAlbum();
  425. $modelAlbum->hid = Yii::$app->request->get('id');
  426. $modelAlbum->album_id = Yii::$app->request->get('alnumid');
  427. $rows = $modelAlbum->getList();
  428. if ($album != null) {
  429. foreach ($album as &$val) {
  430. $val['selected'] = '';
  431. if ($val['id'] == Yii::$app->request->get('alnumid')) {
  432. $val['selected'] = 'selected';
  433. }
  434. }
  435. foreach ($rows as &$val) {
  436. if (!empty($val['img'])) {
  437. $val['img'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['housealbums'] . $val['img'] . Yii::$app->params['pfgwatermark'];
  438. }
  439. }
  440. }
  441. return $this->render('albumedit', ['post' => Yii::$app->request->get(), 'model' => $album, 'albumlist' => $rows]);
  442. }
  443. /*
  444. * 修改相册数据
  445. * */
  446. public function actionAlbumeditformdata()
  447. {
  448. $model = new Houses();
  449. $result = $model->HouseAlbumSave();
  450. if ($result == true) return Help::JsonCode(Help::SUCCESS, '修改成功');
  451. return Help::JsonCode(Help::ERROR, '修改失败');
  452. }
  453. /*
  454. * 楼盘相册状态修改
  455. * */
  456. public function actionAlbumstatesave()
  457. {
  458. $model = new Houses();
  459. $row = $model->AlbumStateSave(1);
  460. if ($row === true) return Help::JsonCode(Help::SUCCESS, '操作成功');
  461. return Help::JsonCode(Help::ERROR, '操作失败');
  462. }
  463. /*
  464. * 楼盘相册删除
  465. * */
  466. public function actionAlbumdel()
  467. {
  468. $model = new Houses();
  469. $row = $model->AlbumStateSave(2);
  470. if ($row === true) return Help::JsonCode(Help::SUCCESS, '操作成功');
  471. return Help::JsonCode(Help::ERROR, '操作失败');
  472. }
  473. //================================楼盘户型======================================
  474. /*
  475. * 楼盘户型页面
  476. * */
  477. public function actionHousetype()
  478. {
  479. return $this->render('housetype', ['post' => Yii::$app->request->get()]);
  480. }
  481. /*
  482. * 楼盘户型数据
  483. * */
  484. public function actionHousetypeform()
  485. {
  486. $model = new \common\models\HouseType();
  487. $model->hid = Yii::$app->request->post('hid');
  488. $rows = $model->TypeGroup();
  489. foreach ($rows as &$val) {
  490. $val['state'] = Yii::$app->params['newsStatus'][$val['state']];
  491. }
  492. if ($rows != null) {
  493. return Help::JsonData(0, '成功', 0, $rows);
  494. }
  495. return Help::JsonCode(Help::ERROR, '暂无户型信息。');
  496. }
  497. /*
  498. * 楼盘户型添加页面
  499. * */
  500. public function actionHousetypeadd()
  501. {
  502. $model = new \common\models\CategoryHousetype();
  503. $rows = $model->getList([], ['id', 'huxing_name']);
  504. return $this->render('housetypeadd', ['typemodel' => $rows, 'post' => Yii::$app->request->get()]);
  505. }
  506. /*
  507. * 楼盘户型添加数据
  508. * */
  509. public function actionHousetypeaddform()
  510. {
  511. $model = new Houses();
  512. $result = $model->HouseTypeCreate();
  513. if ($result === true) {
  514. return Help::JsonCode(Help::SUCCESS, '添加成功');
  515. }
  516. return Help::JsonCode(Help::ERROR, '添加失败', $result);
  517. }
  518. /*
  519. * 楼盘类型修改
  520. * */
  521. public function actionHousetypeedit()
  522. {
  523. $model = new \common\models\CategoryHousetype();
  524. $houseType = $model->getList([], ['id', 'huxing_name']);
  525. $modelAlbum = new \common\models\HouseType();
  526. $modelAlbum->hid = Yii::$app->request->get('id');
  527. $modelAlbum->type_id = Yii::$app->request->get('type');
  528. $rows = $modelAlbum->getList();
  529. $hot = $rows[0]['hot'];
  530. if ($houseType != null) {
  531. foreach ($houseType as &$val) {
  532. $val['selected'] = '';
  533. if ($val['id'] == Yii::$app->request->get('type')) {
  534. $val['selected'] = 'selected';
  535. }
  536. }
  537. foreach ($rows as &$val) {
  538. if (!empty($val['img'])) {
  539. $val['img'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['housetypes'] . $val['img'] . Yii::$app->params['pfgwatermark'];
  540. }
  541. }
  542. }
  543. return $this->render('housetypeedit', ['post' => Yii::$app->request->get(), 'model' => $houseType, 'albumlist' => $rows, 'hot' => $hot]);
  544. }
  545. /*
  546. * 户型数据修改
  547. * */
  548. public function actionHousetypeeditform()
  549. {
  550. $model = new Houses();
  551. $result = $model->HouseTypeSave();
  552. if ($result === true) return Help::JsonCode(Help::SUCCESS, '修改成功');
  553. return Help::JsonCode(Help::ERROR, '修改失败');
  554. }
  555. /*
  556. * 户型状态修改
  557. * */
  558. public function actionTypetatesave()
  559. {
  560. $model = new Houses();
  561. $row = $model->HouseTypeStateSave(1);
  562. if ($row === true) return Help::JsonCode(Help::SUCCESS, '操作成功');
  563. return Help::JsonCode(Help::ERROR, '操作失败');
  564. }
  565. /*
  566. * 楼盘户型删除
  567. * */
  568. public function actionTypedel()
  569. {
  570. $model = new Houses();
  571. $row = $model->HouseTypeStateSave(2);
  572. if ($row === true) return Help::JsonCode(Help::SUCCESS, '操作成功');
  573. return Help::JsonCode(Help::ERROR, '操作失败');
  574. }
  575. //================================楼盘价格======================================
  576. /*
  577. * 价格历史列表显示页面
  578. * */
  579. public function actionPriceview()
  580. {
  581. return $this->render('priceview', ['post' => Yii::$app->request->get()]);
  582. }
  583. /*
  584. * 价格历史数据
  585. * */
  586. public function actionPriceviewform()
  587. {
  588. $model = new \common\models\HousePriceRecord();
  589. // p($_POST);
  590. $model->hid = Yii::$app->request->post('hid');
  591. $rows = $model->getList(Yii::$app->request->post());
  592. if ($rows != null) {
  593. return Help::JsonData(0, '成功', $model->Total(), $rows);
  594. }
  595. return Help::JsonCode(Help::ERROR, '暂无历史价格信息');
  596. }
  597. /*
  598. * 价格添加页面
  599. * */
  600. public function actionPriceadd()
  601. {
  602. $model = new \common\models\House();
  603. $row = $model->FindById(Yii::$app->request->get('hid'));
  604. if ($row != null) {
  605. // p($row);
  606. return $this->render('priceadd', ['post' => Yii::$app->request->get(), 'model' => $row]);
  607. }
  608. }
  609. /*
  610. * 价格数据添加
  611. * */
  612. public function actionPriceaddform()
  613. {
  614. $model = new Houses();
  615. $result = $model->HousePriceRecordadd(Yii::$app->request->post());
  616. if ($result === true) {
  617. return Help::JsonCode(Help::SUCCESS, '操作成功');
  618. }
  619. return Help::JsonCode(Help::ERROR, '操作失败', $result);
  620. }
  621. /*
  622. * 价格修改页面
  623. * */
  624. public function actionPriceedit()
  625. {
  626. $model = new \common\models\HousePriceRecord();
  627. $row = $model->FindById(Yii::$app->request->get('id'));
  628. if ($row != null) {
  629. return $this->render('priceedit', ['model' => $row, 'post' => Yii::$app->request->get()]);
  630. }
  631. }
  632. /*
  633. * 价格数据修改
  634. * */
  635. public function actionPriceeditform()
  636. {
  637. $model = new Houses();
  638. // p(Yii::$app->request->post());
  639. // exit;
  640. // p(Yii::$app->request->post());
  641. $result = $model->HousePriceRecordSave(Yii::$app->request->post());
  642. if ($result === true) {
  643. return Help::JsonCode(Help::SUCCESS, '操作成功');
  644. }
  645. return Help::JsonCode(Help::ERROR, '操作失败', $result);
  646. }
  647. /*
  648. * 楼盘历史价格删除
  649. * */
  650. public function actionPricedel()
  651. {
  652. $model = new Houses();
  653. $result = $model->HousePriceDelete(Yii::$app->request->post());
  654. if ($result === true) {
  655. return Help::JsonCode(Help::SUCCESS, '操作成功');
  656. }
  657. return Help::JsonCode(Help::ERROR, '操作失败', $result);
  658. }
  659. //================================楼盘周边配套======================================
  660. /*
  661. * 楼盘配套显示页面
  662. * */
  663. public function actionPeitao()
  664. {
  665. $house = new \common\models\HouseDetail();
  666. $input = Yii::$app->request->get();
  667. $ld = $house->FindById($input['id']);
  668. return $this->render('peitao', ['post' => $input, 'ld' => $ld]);
  669. }
  670. /*
  671. * 楼盘周边配套列表数据
  672. * */
  673. public function actionPeitaoform()
  674. {
  675. $model = new \common\models\HouseFacilities();
  676. $model->hid = Yii::$app->request->post('hid');
  677. $rows = $model->FacilitiesGroup();
  678. foreach ($rows as &$val) {
  679. $val['state'] = Yii::$app->params['newsStatus'][$val['state']];
  680. }
  681. if ($rows != null) {
  682. return Help::JsonData(0, '成功', 0, $rows);
  683. }
  684. return Help::JsonCode(Help::ERROR, '暂无周边配套信息。');
  685. }
  686. /*
  687. * 楼盘周边配套添加页面
  688. * */
  689. public function actionPeitaoadd()
  690. {
  691. $model = new \common\models\CategoryFacilities();
  692. $rows = $model->getList([]);
  693. $input = Yii::$app->request->get();
  694. return $this->render('peitaoadd', ['post' => $input, 'faci' => $rows]);
  695. }
  696. /*
  697. * 楼盘周边配套添加数据
  698. * */
  699. public function actionPeitaoaddform()
  700. {
  701. $model = new \common\models\HouseFacilities();
  702. $input = Yii::$app->request->post();
  703. $arr = [];
  704. if (!empty($input['data'])) {
  705. foreach ($input['data'] as $key => $val) {
  706. $arr[$key]['fid'] = $input['type_id'];
  707. $arr[$key]['name'] = $val['title'];
  708. $arr[$key]['distance'] = $val['rout'];
  709. $arr[$key]['latitude_longitude'] = $val['point'];
  710. $arr[$key]['hid'] = $input['hid'];
  711. $arr[$key]['create_at'] = $_SERVER['REQUEST_TIME'];
  712. $arr[$key]['update_at'] = $_SERVER['REQUEST_TIME'];
  713. }
  714. $result = Yii::$app->db->createCommand()->batchInsert(\common\models\HouseFacilities::tableName(), ['fid', 'name', 'distance', 'latitude_longitude', 'hid', 'create_at', 'update_at'], $arr)->execute();
  715. if ($result > 0) {
  716. return Help::JsonCode(Help::SUCCESS, '添加成功');
  717. }
  718. }
  719. return Help::JsonCode(Help::ERROR, '添加失败');
  720. }
  721. /*
  722. * 楼盘周边配套修改页面
  723. * */
  724. public function actionPeitaoedit()
  725. {
  726. if (Yii::$app->request->isPost) {
  727. $model = new \common\models\HouseFacilities();
  728. $model->hid = Yii::$app->request->post('hid');
  729. $model->fid = Yii::$app->request->post('fid');
  730. $rows = $model->getList();
  731. if ($rows != null) return Help::JsonData(0, '成功', 0, $rows);
  732. }
  733. $model = new \common\models\CategoryFacilities();
  734. $rows = $model->getList([]);
  735. return $this->render('peitaoedit', ['post' => Yii::$app->request->get(), 'faci' => $rows]);
  736. }
  737. /*
  738. * 楼盘周边配套修改
  739. * */
  740. public function actionPeitaodel()
  741. {
  742. $input = Yii::$app->request->post();
  743. $result = \common\models\HouseFacilities::updateAll(['del' => 2, 'update_at' => $_SERVER['REQUEST_TIME']], ['fid' => $input['type_id'], 'hid' => $input['hid'], 'del' => 1]);
  744. if ($result > 0) {
  745. return Help::JsonCode(Help::SUCCESS, '操作成功');
  746. }
  747. return Help::JsonCode(Help::ERROR, '操作失败');
  748. }
  749. /*
  750. * 楼盘周边配套修改数据
  751. * */
  752. public function actionPeitaoeditform()
  753. {
  754. $input = Yii::$app->request->post();
  755. $result = '';
  756. $arr = [];
  757. if (!empty($input['data'])) {
  758. foreach ($input['data'] as $key => $val) {
  759. $arr[$key]['fid'] = $input['type_id'];
  760. $arr[$key]['name'] = $val['title'];
  761. $arr[$key]['distance'] = $val['rout'];
  762. $arr[$key]['latitude_longitude'] = $val['point'];
  763. $arr[$key]['hid'] = $input['hid'];
  764. $arr[$key]['create_at'] = $_SERVER['REQUEST_TIME'];
  765. $arr[$key]['update_at'] = $_SERVER['REQUEST_TIME'];
  766. }
  767. $result = Yii::$app->db->createCommand()->batchInsert(\common\models\HouseFacilities::tableName(), ['fid', 'name', 'distance', 'latitude_longitude', 'hid', 'create_at', 'update_at'], $arr)->execute();
  768. }
  769. if (!empty($input['dataId'])) {
  770. $result = \common\models\HouseFacilities::updateAll(['del' => 2, 'update_at' => $_SERVER['REQUEST_TIME']], ['id' => $input['dataId']]);
  771. }
  772. return Help::JsonCode(Help::SUCCESS, '修改成功');
  773. if ($result > 0) {
  774. return Help::JsonCode(Help::SUCCESS, '修改成功');
  775. }
  776. return Help::JsonCode(Help::ERROR, '修改失败');
  777. //
  778. // $input = Yii::$app->request->post();
  779. // if(!empty($input['delall']))
  780. // {
  781. // $result = \common\models\HouseFacilities::updateAll(['del'=>2,'update_at'=>$_SERVER['REQUEST_TIME']],['id'=>$input['delall']]);
  782. // }
  783. // $model = new \common\models\HouseFacilities();
  784. // if(!empty($input['edit_matingName']))
  785. // {
  786. //
  787. // foreach ($input['edit_matingName'] as $key=>$val)
  788. // {
  789. // $_model = clone $model;
  790. // $find = $_model::findOne($input['edit_id'][$key]);
  791. // if($find != null)
  792. // {
  793. // $find->name = $input['edit_matingName'][$key];
  794. // $find->distance = $input['edit_distance'][$key];
  795. // $find->latitude_longitude = $input['edit_longitude'][$key];
  796. // $result = $find->save();
  797. // }
  798. // }
  799. // }
  800. //
  801. // if(!empty($input['name']))
  802. // {
  803. //
  804. // foreach ($input['name'] as $key=>$val)
  805. // {
  806. // $_model = clone $model;
  807. // if(!empty($input['name'][$key]))
  808. // {
  809. // $arr['name'] = $input['name'][$key];
  810. // }
  811. //
  812. // if(!empty($input['name'][$key]))
  813. // {
  814. // $arr['distance'] = $input['distance'][$key];
  815. // }
  816. //
  817. // if(!empty($input['longitude'][$key])){
  818. // $arr['latitude_longitude'] = $input['longitude'][$key];
  819. // }
  820. //
  821. // $arr['fid'] = $input['fid'];
  822. // $arr['hid'] = $input['hid'];
  823. // $auth = $_model->Authenticator($arr);
  824. // if(is_array($auth)) return Help::JsonCode(Help::ERROR,'操作失败',$auth);
  825. // $result = $auth->save();
  826. // }
  827. // }
  828. //
  829. // if($input['is_fid'] != $input['fid'])
  830. // {
  831. // $result = \common\models\HouseFacilities::updateAll(['fid'=>$input['is_fid'],'update_at'=>$_SERVER['REQUEST_TIME']],['fid'=>$input['fid'],'hid'=>$input['hid']]);
  832. // }
  833. //
  834. // if($result > 0 )
  835. // {
  836. // return Help::JsonCode(Help::SUCCESS,'操作成功');
  837. // }
  838. // return Help::JsonCode(Help::ERROR,'操作失败');
  839. }
  840. /*
  841. * 楼盘预售证列表 - 页面
  842. * */
  843. public function actionPresell()
  844. {
  845. return $this->render('presell', ['get' => Yii::$app->request->get()]);
  846. }
  847. /*
  848. * 楼盘预售证列表 - 数据
  849. * */
  850. public function actionPresellform()
  851. {
  852. $model = new HousePermit();
  853. $rows = $model->getList(Yii::$app->request->post());
  854. if (!empty($rows)) {
  855. $model->hid = Yii::$app->request->post('hid');
  856. return Help::JsonData(0, Yii::t('app', 'get_success'), $model->Total(), $rows);
  857. }
  858. return Help::JsonCode(Help::ERROR, Yii::t('app', 'get_error'));
  859. }
  860. /*
  861. * 楼盘预售证添加 - 页面
  862. * */
  863. public function actionPreselladd()
  864. {
  865. return $this->render('preselladd', ['get' => Yii::$app->request->get()]);
  866. }
  867. /*
  868. * 楼盘预售证添加 -数据
  869. * */
  870. public function actionPreselladdform()
  871. {
  872. $model = new HousePermit();
  873. $auth = $model->Authenticator(Yii::$app->request->post());
  874. if (is_object($auth)) {
  875. if ($auth->save()) return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'add_success'));
  876. }
  877. return Help::JsonCode(Help::ERROR, Yii::t('app', 'add_error'), $auth);
  878. }
  879. /*
  880. * 楼盘预售证修改
  881. * */
  882. public function actionPreselledit()
  883. {
  884. $model = new HousePermit();
  885. $find = $model->FindById(Yii::$app->request->get('id'));
  886. return $this->render('preselledit', ['model' => $find]);
  887. }
  888. /*
  889. * 楼盘预售证修改 - 数据
  890. * */
  891. public function actionPreselleditform()
  892. {
  893. $model = new HousePermit();
  894. $input = Yii::$app->request->post();
  895. $row = $model->Authenticator($input);
  896. if (is_object($row)) {
  897. $find = $model->FindById($input['id']);
  898. if (!empty($find)) {
  899. $auth = Help::SetAttr($input, $row, $find);
  900. if ($auth->save()) return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'edit_success'));
  901. }
  902. }
  903. return Help::JsonCode(Help::ERROR, Yii::t('app', 'edit_error'), $row);
  904. }
  905. /*
  906. * 楼盘预售证删除
  907. * */
  908. public function actionPreselldel()
  909. {
  910. $model = new HousePermit();
  911. $del = $model->FindById(Yii::$app->request->post('id'));
  912. if (!empty($del)) {
  913. $del->del = 2;
  914. if ($del->save()) return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'edit_success'));
  915. }
  916. return Help::JsonCode(Help::ERROR, Yii::t('app', 'edit_error'));
  917. }
  918. }