PushmController.php 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: xiaofeng
  5. * Date: 2018/3/13
  6. * Time: 上午8:46
  7. */
  8. namespace backend\controllers;
  9. use backend\base\CommonController;
  10. use backend\base\Help;
  11. use backend\server\NewsInformation;
  12. use common\models\CategoryCity;
  13. use common\models\Developers;
  14. use common\models\House;
  15. use common\models\PushmMansion;
  16. use Yii;
  17. use common\models\PushmRotation;
  18. use common\models\PushmVilla;
  19. use common\models\PushmMenu;
  20. use common\models\PushmRecommend;
  21. use common\models\PushChoice;
  22. use common\models\PushmHouse;
  23. use common\models\PushmCity;
  24. use common\models\PushmTimelimitsgroup;
  25. use common\models\PushmCharacteristic;
  26. use backend\server\UploadFile;
  27. /*
  28. * 热门区域 type = 1
  29. * 首页-拨打电话号码- 随机区域 type = 2
  30. *
  31. * */
  32. class PushmController extends CommonController
  33. {
  34. /*
  35. * 豪宅专区
  36. * */
  37. public function actionMansion()
  38. {
  39. return $this->render('mansion');
  40. }
  41. /*
  42. * 豪宅专区 - 数据
  43. * */
  44. public function actionMansionform()
  45. {
  46. $model = new PushmMansion();
  47. $input = Yii::$app->request->post();
  48. $rows = $model->getList($input);
  49. if($rows != null)
  50. {
  51. $imgUrl = Yii::$app->params['httpImg']['host'].Yii::$app->params['httpImg']['housealbum'];
  52. foreach ($rows as &$val)
  53. {
  54. $val['create_at'] = date('Y-m-d H:i',$val['create_at']);
  55. $val['img'] = $imgUrl.$val['img'];
  56. }
  57. return Help::JsonData(0,Yii::t('app','get_success'),$model->Total(Yii::$app->request->post()),$rows);
  58. }
  59. return Help::JsonCode(Help::ERROR,Yii::t('app','get_error'));
  60. }
  61. /*
  62. * 豪宅专区 - 添加页面
  63. * */
  64. public function actionMansionadd()
  65. {
  66. $developers = $this->Developers();
  67. return $this->render('mansionadd',['developers'=>$developers]);
  68. }
  69. /*
  70. * 豪宅专区 - 添加页面 - 添加数据
  71. * */
  72. public function actionMansionaddform()
  73. {
  74. $model = new PushmMansion();
  75. $input = Yii::$app->request->post();
  76. if ($input != null){
  77. $url = Yii::$app->params['img_url']['housealbum'];
  78. $img = UploadFile::InstanceImgName('img',$url);
  79. if (is_string($img)){
  80. $model->img = $img;
  81. }
  82. if($model->load($input,'') && $model->save(false)) return Help::JsonCode(Help::SUCCESS,'添加成功');
  83. }
  84. return Help::JsonCode(Help::ERROR,'添加失败');
  85. }
  86. /*
  87. * 豪宅专区 - 修改页面
  88. * */
  89. public function actionMansionedit()
  90. {
  91. $model = new PushmMansion();
  92. $input = Yii::$app->request->get();
  93. $row = $model->FindById($input['id']);
  94. if ($row != null){
  95. $house = new House();
  96. $house = $house->FindById($row['hid']);
  97. $developers = $this->Developers();
  98. foreach ($developers as &$val)
  99. {
  100. $val['checked'] = '';
  101. if($val['id'] == $row['did']){
  102. $val['checked'] = 'selected';
  103. }
  104. }
  105. $imgUrl = Yii::$app->params['httpImg']['host'].Yii::$app->params['httpImg']['housealbum'];
  106. $row['img'] = $imgUrl.$row['img'];
  107. return $this->render('mansionedit',['model'=>$row,'house'=>$house,'developers'=>$developers]);
  108. }
  109. }
  110. /*
  111. * 豪宅专区 - 修改页面 - 修改数据
  112. * */
  113. public function actionMansioneditform()
  114. {
  115. $model = new PushmMansion();
  116. $input = Yii::$app->request->post();
  117. $row = $model->FindById($input['id']);
  118. if ($row != null) {
  119. $url = Yii::$app->params['img_url']['housealbum'];
  120. $img = UploadFile::InstanceImgName('img', $url);
  121. if (is_string($img)) {
  122. UploadFile::delImg($url, $row->img);
  123. $row->img = $img;
  124. }
  125. if ($row->load($input,'') && $row->update() == true)return Help::JsonCode(Help::SUCCESS,'修改成功');
  126. }
  127. return Help::JsonCode(Help::ERROR,'修改失败');
  128. }
  129. /*
  130. * 豪宅专区 - 审核排序删除
  131. * */
  132. public function actionMansiondelshow()
  133. {
  134. $model = new PushmMansion();
  135. $input = Yii::$app->request->post();
  136. $row = $model->FindById($input['id']);
  137. if ($row != null){
  138. switch ($input['type']){
  139. case 'sort':
  140. $row->sort = $input['sort'];
  141. break;
  142. case 'show':
  143. if ($row->is_show == 1){
  144. $row->is_show = 2;
  145. }else{
  146. $row->is_show = 1;
  147. }
  148. break;
  149. case 'del':
  150. if (!empty($row->img)){
  151. UploadFile::delImg(Yii::$app->params['img_url']['housealbum'],$row->img);
  152. }
  153. if ($row->delete()){
  154. return Help::JsonCode(Help::SUCCESS,'删除成功');
  155. }
  156. break;
  157. }
  158. if ($row->update(false))return Help::JsonCode(Help::SUCCESS,'修改成功');
  159. }
  160. return Help::JsonCode(Help::ERROR,'修改失败');
  161. }
  162. /*
  163. * 豪宅专区 - 批量删除
  164. * */
  165. public function actionMansiondelall()
  166. {
  167. $input = Yii::$app->request->post();
  168. $model = PushmMansion::find()->where(['in','id',$input['id']])->all();
  169. $delall = PushmMansion::deleteAll(['id'=>$input['id']]);
  170. if ($delall){
  171. foreach ($model as $value){
  172. UploadFile::delImg(Yii::$app->params['img_url']['housealbum'],$value['img']);
  173. }
  174. return Help::JsonCode(Help::SUCCESS,'批量删除成功');
  175. }
  176. return Help::JsonCode(Help::ERROR,'批量删除失败');
  177. }
  178. /*
  179. * 推送首页轮播
  180. * */
  181. public function actionRotation()
  182. {
  183. $city = $this->City();
  184. return $this->render('rotation',['city'=>$city]);
  185. }
  186. /*
  187. * 推送首页轮播数据
  188. * */
  189. public function actionRotationforms()
  190. {
  191. $model = new PushmRotation();
  192. $rows = $model->getList(Yii::$app->request->post());
  193. if($rows != null)
  194. {
  195. $imgUrl = Yii::$app->params['httpImg']['host'].Yii::$app->params['httpImg']['push_lb'];
  196. foreach ($rows as &$val)
  197. {
  198. $val['create_at'] = date('Y-m-d H:i',$val['create_at']);
  199. $val['img'] = $imgUrl.$val['img'];
  200. }
  201. return Help::JsonData(0,Yii::t('app','get_success'),$model->Total(Yii::$app->request->post()),$rows);
  202. }
  203. return Help::JsonCode(Help::ERROR,Yii::t('app','get_error'));
  204. }
  205. /*
  206. * 推送首页轮播 - 添加页面
  207. */
  208. public function actionRotationadd()
  209. {
  210. $cityModel = $this->City();
  211. return $this->render('rotationadd',['city'=>$cityModel]);
  212. }
  213. /*
  214. * 推送首页轮播 - 添加数据
  215. */
  216. public function actionRotationform()
  217. {
  218. try{
  219. $model = new PushmRotation();
  220. $input = Yii::$app->request->post();
  221. $url = Yii::$app->params['img_url']['push_lb'];
  222. $img = UploadFile::InstanceImgName_v1('img',$url);
  223. if(is_string($img))
  224. {
  225. $input['img'] = $img;
  226. }
  227. $model->load($input,'');
  228. if($model->save()) return Help::JsonCode(Help::SUCCESS,Yii::t('app','add_success'));
  229. return Help::JsonCode(Help::SUCCESS,Yii::t('app','add_error'),$model->errors);
  230. }catch (\Exception $e){
  231. return Help::JsonCode(Help::SUCCESS,Yii::t('app','add_error'),$e->getMessage());
  232. }
  233. }
  234. /*
  235. * 推送首页轮播 - 修改
  236. */
  237. public function actionRotationedit()
  238. {
  239. $model = new PushmRotation();
  240. $input = Yii::$app->request->get();
  241. $row = $model->FindById($input['id']);
  242. if($row != null)
  243. {
  244. $imgUrl = Yii::$app->params['httpImg']['host'].Yii::$app->params['httpImg']['push_lb'];
  245. $row['img'] = $imgUrl.$row['img'];
  246. $cityModel = $this->City();
  247. foreach ($cityModel as &$val)
  248. {
  249. $val['checked'] = '';
  250. if($val['id'] == $row['city']){
  251. $val['checked'] = 'selected';
  252. }
  253. }
  254. return $this->render('rotationedit',['model'=>$row,'city'=>$cityModel]);
  255. }
  256. }
  257. /*
  258. * 推送首页轮播 - 修改数据
  259. * */
  260. public function actionRotationeditform()
  261. {
  262. $model = new PushmRotation();
  263. $input = Yii::$app->request->post();
  264. $setAttribute = $model->Authenticator($input);
  265. if(is_object($setAttribute))
  266. {
  267. $row = $model->FindById($input['id']);
  268. if($row != null)
  269. {
  270. $row = Help::SetAttr($input,$model,$row);
  271. $url = Yii::$app->params['img_url']['push_lb'];
  272. $img = UploadFile::InstanceImgName('img',$url);
  273. if(is_string($img))
  274. {
  275. UploadFile::delImg($url,$row->img);
  276. $row->img = $img;
  277. }
  278. if($row->save(false)) return Help::JsonCode(Help::SUCCESS,Yii::t('app','edit_success'));
  279. }
  280. }
  281. return Help::JsonCode(Help::ERROR,Yii::t('app','edit_error'),$setAttribute);
  282. }
  283. /*
  284. * 推送首页轮播 - 删除 and 禁用
  285. * */
  286. public function actionImgdelshow()
  287. {
  288. $model = new PushmRotation();
  289. $input = Yii::$app->request->post();
  290. $row = $model->FindById($input['id']);
  291. if($row != null)
  292. {
  293. switch ($input['type'])
  294. {
  295. case 'show':
  296. if($row->is_show == 1)
  297. {
  298. $row->is_show = 2;
  299. }
  300. else if($row->is_show == 2)
  301. {
  302. $row->is_show = 1;
  303. }
  304. break;
  305. case 'sort':
  306. if(is_numeric($input['sort']))
  307. {
  308. $row->sort = $input['sort'];
  309. }
  310. break;
  311. case 'del':
  312. if($row->delete())
  313. {
  314. UploadFile::delImg(Yii::$app->params['img_url']['push_lb'],$row->img);
  315. return Help::JsonCode(Help::SUCCESS,Yii::t('app','edit_success'));
  316. }
  317. break;
  318. case 'expiration':
  319. $row->expiration_date = $input['expiration'];
  320. break;
  321. }
  322. if($row->save(false)) return Help::JsonCode(Help::SUCCESS,Yii::t('app','edit_success'));
  323. }
  324. return Help::JsonCode(Help::ERROR,Yii::t('app','edit_error'));
  325. }
  326. /******************************豪宅楼盘*************************************/
  327. /*
  328. * 推送首页轮播
  329. * */
  330. public function actionVilla()
  331. {
  332. return $this->render('villa');
  333. }
  334. /*
  335. * 推送首页轮播数据
  336. * */
  337. public function actionVillaforms()
  338. {
  339. $model = new PushmVilla();
  340. $rows = $model->getList(Yii::$app->request->post());
  341. if($rows != null)
  342. {
  343. $imgUrl = Yii::$app->params['httpImg']['host'].Yii::$app->params['httpImg']['villa'];
  344. foreach ($rows as &$val)
  345. {
  346. $val['create_at'] = date('Y-m-d H:i',$val['create_at']);
  347. $val['img'] = $imgUrl.$val['img'];
  348. }
  349. return Help::JsonData(0,Yii::t('app','get_success'),$model->Total(),$rows);
  350. }
  351. return Help::JsonCode(Help::ERROR,Yii::t('app','get_error'));
  352. }
  353. /*
  354. * 推送首页轮播 - 添加页面
  355. */
  356. public function actionVillaadd()
  357. {
  358. $cityModel = $this->City();
  359. $developers = $this->Developers();
  360. return $this->render('villaadd',['city'=>$cityModel,'developers'=>$developers]);
  361. }
  362. /*
  363. * 推送首页轮播 - 添加数据
  364. */
  365. public function actionVillaform()
  366. {
  367. $model = new PushmVilla();
  368. $input = Yii::$app->request->post();
  369. $model = $model->Authenticator($input);
  370. if(is_object($model))
  371. {
  372. $url = Yii::$app->params['img_url']['villa'];
  373. $img = UploadFile::InstanceImgName('img',$url);
  374. if(is_string($img))
  375. {
  376. $model->img = $img;
  377. //压缩图片
  378. $compressParams = [];
  379. $compressParams['data']['imgname'] = $img;;
  380. $compressParams['data']['url'] = $url;
  381. $compressParams['data']['source'] = '移动端推送位,首页热门活动@添加';
  382. $ya = new \backend\event\TinifyEvent();
  383. $ya->CompressImg($compressParams);
  384. }
  385. if($model->save(false)) return Help::JsonCode(Help::SUCCESS,Yii::t('app','add_success'));
  386. }
  387. return Help::JsonCode(Help::SUCCESS,Yii::t('app','add_error'),$model);
  388. }
  389. /*
  390. * 推送首页轮播 - 修改
  391. */
  392. public function actionVillaedit()
  393. {
  394. $model = new PushmVilla();
  395. $input = Yii::$app->request->get();
  396. $row = $model->FindById($input['id']);
  397. if($row != null)
  398. {
  399. $imgUrl = Yii::$app->params['httpImg']['host'].Yii::$app->params['httpImg']['villa'];
  400. $row['img'] = $imgUrl.$row['img'];
  401. $cityModel = $this->City();
  402. $developers = $this->Developers();
  403. foreach ($cityModel as &$val)
  404. {
  405. $val['checked'] = '';
  406. if($val['id'] == $row['city']){
  407. $val['checked'] = 'selected';
  408. }
  409. }
  410. foreach ($developers as &$val)
  411. {
  412. $val['checked'] = '';
  413. if($val['id'] == $row['developers']){
  414. $val['checked'] = 'selected';
  415. }
  416. }
  417. return $this->render('villaedit',['model'=>$row,'city'=>$cityModel,'developers'=>$developers]);
  418. }
  419. }
  420. /*
  421. * 推送首页轮播 - 修改数据
  422. * */
  423. public function actionVillaeditform()
  424. {
  425. $model = new PushmVilla();
  426. $input = Yii::$app->request->post();
  427. $setAttribute = $model->Authenticator($input);
  428. if(is_object($setAttribute))
  429. {
  430. $row = $model->FindById($input['id']);
  431. if($row != null)
  432. {
  433. $row = Help::SetAttr($input,$model,$row);
  434. $url = Yii::$app->params['img_url']['villa'];
  435. $img = UploadFile::InstanceImgName('img',$url);
  436. if(is_string($img))
  437. {
  438. UploadFile::delImg($url,$row->img);
  439. $row->img = $img;
  440. //压缩图片
  441. $compressParams = [];
  442. $compressParams['data']['imgname'] = $img;;
  443. $compressParams['data']['url'] = $url;
  444. $compressParams['data']['source'] = '移动端推送位,首页热门活动@修改';
  445. $ya = new \backend\event\TinifyEvent();
  446. $ya->CompressImg($compressParams);
  447. }
  448. if($row->save(false)) return Help::JsonCode(Help::SUCCESS,Yii::t('app','edit_success'));
  449. }
  450. }
  451. return Help::JsonCode(Help::ERROR,Yii::t('app','edit_error'),$setAttribute);
  452. }
  453. /*
  454. * 推送首页轮播 - 删除 and 禁用
  455. * */
  456. public function actionVillaimgdelshow()
  457. {
  458. $model = new PushmVilla();
  459. $input = Yii::$app->request->post();
  460. $row = $model->FindById($input['id']);
  461. if($row != null)
  462. {
  463. switch ($input['type'])
  464. {
  465. case 'show':
  466. if($row->is_show == 1)
  467. {
  468. $row->is_show = 2;
  469. }
  470. else if($row->is_show == 2)
  471. {
  472. $row->is_show = 1;
  473. }
  474. break;
  475. case 'del':
  476. $row->del = 2;
  477. break;
  478. }
  479. if($row->save(false)) return Help::JsonCode(Help::SUCCESS,Yii::t('app','edit_success'));
  480. }
  481. return Help::JsonCode(Help::ERROR,Yii::t('app','edit_error'));
  482. }
  483. /******************************豪宅楼盘*************************************/
  484. /*
  485. * 首页-品房推荐 -列表
  486. * */
  487. public function actionRecommend()
  488. {
  489. return $this->render('recommend');
  490. }
  491. public function actionRecommendform()
  492. {
  493. $model = new PushmRecommend();
  494. $input = Yii::$app->request->post();
  495. $rows = $model->getList($input);
  496. if($rows != null)
  497. {
  498. foreach ($rows as &$val)
  499. {
  500. $val['create_at'] = date('Y-m-d H:i',$val['create_at']);
  501. }
  502. return Help::JsonData(0,Yii::t('app','get_success'),$model->Total(),$rows);
  503. }
  504. return Help::JsonData(Help::ERROR,Yii::t('app','get_error'),0);
  505. }
  506. /*
  507. * 移动端导航推荐
  508. * */
  509. public function actionMenu()
  510. {
  511. return $this->render('menu');
  512. }
  513. /*
  514. * 推送移动端导航推荐
  515. * */
  516. public function actionMenuforms()
  517. {
  518. $model = new PushmMenu();
  519. $rows = $model->getList(Yii::$app->request->post());
  520. if($rows != null)
  521. {
  522. foreach ($rows as &$val)
  523. {
  524. $val['create_at'] = date('Y-m-d H:i',$val['create_at']);
  525. }
  526. return Help::JsonData(0,Yii::t('app','get_success'),$model->Total(),$rows);
  527. }
  528. return Help::JsonCode(Help::ERROR,Yii::t('app','get_error'));
  529. }
  530. /*
  531. * 推送移动端导航推荐 - 添加页面
  532. */
  533. public function actionMenuadd()
  534. {
  535. $cityModel = $this->City();
  536. $menu = $this->parentMenu();
  537. return $this->render('menuadd',['city'=>$cityModel,'menu'=>$menu]);
  538. }
  539. //*获取父级菜单*/
  540. private function parentMenu()
  541. {
  542. $frontend = new \common\models\Frontend();
  543. //$menu=$frontend->PidList(0)
  544. return $frontend->PidList(0);
  545. }
  546. /*
  547. * 推送移动端导航推荐
  548. */
  549. public function actionMenuform()
  550. {
  551. $model = new PushmMenu();
  552. $input = Yii::$app->request->post();
  553. $model = $model->Authenticator($input);
  554. if(is_object($model))
  555. {
  556. if($model->save(false)) return Help::JsonCode(Help::SUCCESS,Yii::t('app','add_success'));
  557. }
  558. return Help::JsonCode(Help::SUCCESS,Yii::t('app','add_error'),$model);
  559. }
  560. public function actionMenudel()
  561. {
  562. $model = new PushmMenu();
  563. $input = Yii::$app->request->post();
  564. $row = $model->FindById($input['id']);
  565. if($row != null)
  566. {
  567. switch ($input['type'])
  568. {
  569. case 'del':
  570. $row->del = 2;
  571. break;
  572. }
  573. if($row->save(false)) return Help::JsonCode(Help::SUCCESS,Yii::t('app','edit_success'));
  574. }
  575. return Help::JsonCode(Help::ERROR,Yii::t('app','edit_error'));
  576. }
  577. /*
  578. * 首页-品房推荐 - 添加页面
  579. */
  580. public function actionRecommendadd()
  581. {
  582. return $this->render('recommendadd');
  583. }
  584. /*
  585. * 首页-品房推荐 - 添加数据
  586. * */
  587. public function actionRecommendaddform()
  588. {
  589. $model = new PushmRecommend();
  590. $input = Yii::$app->request->post();
  591. $auth = $model->Authenticator($input);
  592. if(is_object($auth))
  593. {
  594. // $url = Yii::$app->params['img_url']['hot_activity'];
  595. // $img = UploadFile::InstanceImgName('img',$url);
  596. // if(is_string($img))
  597. // {
  598. // $auth->img = $img;
  599. // }
  600. if($auth->save()) return Help::JsonCode(Help::SUCCESS,Yii::t('app','add_success'));
  601. }
  602. return Help::JsonCode(Help::ERROR,Yii::t('app','add_error'),$auth);
  603. }
  604. /*
  605. * 首页-品房推荐 - 修改页面
  606. */
  607. public function actionRecommendedit()
  608. {
  609. $model = new PushmRecommend();
  610. $row = $model->FindById(Yii::$app->request->get('id'));
  611. if($row != null)
  612. {
  613. return $this->render('recommendedit',['model'=>$row]);
  614. }
  615. }
  616. /*
  617. * 首页-品房推荐 - 修改数据
  618. * */
  619. public function actionRecommendeditform()
  620. {
  621. $model = new PushmRecommend();
  622. $input = Yii::$app->request->post();
  623. $setAttribute = $model->Authenticator($input);
  624. if(is_object($setAttribute))
  625. {
  626. $row = $model->FindById($input['id']);
  627. if($row != null)
  628. {
  629. $row = Help::SetAttr($input,$model,$row);
  630. if($row->save()) return Help::JsonCode(Help::SUCCESS,Yii::t('app','edit_success'));
  631. }
  632. }
  633. return Help::JsonCode(Help::ERROR,Yii::t('app','edit_error'),$setAttribute);
  634. }
  635. /*
  636. * 首页-品房推荐 - 删除 and 禁用
  637. * */
  638. public function actionRecommenddelshow()
  639. {
  640. $model = new PushmRecommend();
  641. $input = Yii::$app->request->post();
  642. $row = $model->FindById($input['id']);
  643. if($row != null)
  644. {
  645. switch ($input['type'])
  646. {
  647. case 'show':
  648. if($row->is_show == 1)
  649. {
  650. $row->is_show = 2;
  651. }
  652. else if($row->is_show == 2)
  653. {
  654. $row->is_show = 1;
  655. }
  656. break;
  657. case 'del':
  658. $row->del = 2;
  659. break;
  660. }
  661. if($row->save(false)) return Help::JsonCode(Help::SUCCESS,Yii::t('app','edit_success'));
  662. }
  663. return Help::JsonCode(Help::ERROR,Yii::t('app','edit_error'));
  664. }
  665. /*
  666. * 首页-热销楼盘
  667. * */
  668. public function actionHotsale()
  669. {
  670. return $this->render('hotsale',['type'=>1]);
  671. }
  672. /*
  673. * 首页-热销楼盘 - 数据
  674. * */
  675. public function actionHotsaleform()
  676. {
  677. $model = new PushmHouse();
  678. $input = Yii::$app->request->post();
  679. if (!empty($input['city_id'])) {
  680. $input['city_id'] = explode(',',$input['city_id']);
  681. }
  682. $result = $model->getList($input);
  683. if($result != null)
  684. {
  685. foreach ($result as &$val)
  686. {
  687. $val['create_at'] = date('Y-m-d H:i',$val['create_at']);
  688. }
  689. return Help::JsonData(0,Yii::t('app','get_success'),$model->Totalhotsalefeng($input),$result);
  690. }
  691. return Help::JsonCode(Help::ERROR,Yii::t('app','get_error'));
  692. }
  693. /*
  694. * 首页-热销楼盘 - 添加
  695. */
  696. public function actionHotsaleadd()
  697. {
  698. return $this->render('hotsaleadd',['type'=>Yii::$app->request->get('type')]);
  699. }
  700. /*
  701. * 首页-热销楼盘 - 添加数据
  702. */
  703. public function actionHotsaleaddform()
  704. {
  705. $input = Yii::$app->request->post();
  706. $model = new PushmHouse();
  707. $model->scenario = 'add';
  708. $validate = $model->Authenticator($input);
  709. if(is_object($validate))
  710. {
  711. if($validate->save(false)) return Help::JsonCode(Help::SUCCESS,Yii::t('app','add_success'));
  712. }
  713. return Help::JsonCode(Help::ERROR,Yii::t('app','add_error'),$validate);
  714. }
  715. /*
  716. * 首页-热销楼盘- - 删除 and 禁用
  717. * */
  718. public function actionSaledelshow()
  719. {
  720. $model = new PushmHouse();
  721. $input = Yii::$app->request->post();
  722. $row = $model->FindById($input['id']);
  723. if($row != null)
  724. {
  725. switch ($input['type'])
  726. {
  727. case 'show':
  728. if($row->is_show == 1)
  729. {
  730. $row->is_show = 2;
  731. }
  732. else if($row->is_show == 2)
  733. {
  734. $row->is_show = 1;
  735. }
  736. break;
  737. case 'del':
  738. $row->del = 2;
  739. break;
  740. case 'sort':
  741. if(is_numeric($input['sort']))
  742. {
  743. $row->sort = $input['sort'];
  744. }
  745. break;
  746. }
  747. if($row->save(false)) return Help::JsonCode(Help::SUCCESS,Yii::t('app','edit_success'));
  748. }
  749. return Help::JsonCode(Help::ERROR,Yii::t('app','edit_error'));
  750. }
  751. /*
  752. * 首页-热销楼盘- 批量删除
  753. * */
  754. public function actionHotsaledelall()
  755. {
  756. $input = Yii::$app->request->post();
  757. $delall = PushmHouse::deleteAll(['id'=>$input['id']]);
  758. if ($delall){
  759. return Help::JsonCode(Help::SUCCESS,'批量删除成功');
  760. }
  761. return Help::JsonCode(Help::ERROR,'批量删除失败');
  762. }
  763. /*
  764. * 搜索框 - 热门筛选
  765. * */
  766. public function actionHotscreen()
  767. {
  768. return $this->render('hotsale',['type'=>2]);
  769. }
  770. /*
  771. * 首页 - 精选楼盘
  772. * */
  773. public function actionHotselected()
  774. {
  775. return $this->render('hotsale',['type'=>4,'city_id'=>Yii::$app->request->get('city_id')]);
  776. }
  777. /*
  778. *首页-热门地区
  779. * */
  780. public function actionHotcity()
  781. {
  782. return $this->render('hotcity',['type'=>1]);
  783. }
  784. /*
  785. * 首页-热门区域-数据列表
  786. * */
  787. public function actionHotcityform()
  788. {
  789. $model = new PushmCity();
  790. $input = Yii::$app->request->post();
  791. $model->type = $input['type'];
  792. $rows = $model->getList($input);
  793. if(!empty($rows))
  794. {
  795. foreach ($rows as &$val)
  796. {
  797. $val['img'] = Yii::$app->params['httpImg']['host'].Yii::$app->params['httpImg']['city'].$val['img'];
  798. $val['create_at'] = date('Y-m-d H:i',$val['create_at']);
  799. }
  800. return Help::JsonData(0,'成功',$model->Total(),$rows);
  801. }
  802. }
  803. /*
  804. * 首页-热门区域-数据列表
  805. * */
  806. public function actionHotcityadd()
  807. {
  808. $cityModel = (new CategoryCity())->SortgetList([]);
  809. return $this->render('hotcityadd',['type'=>Yii::$app->request->get('type'),'city'=>$cityModel]);
  810. }
  811. /*
  812. * 首页-热门区域-数据列表
  813. * */
  814. public function actionHotcityaddform()
  815. {
  816. $model = new PushmCity();
  817. $input = Yii::$app->request->post();
  818. $model->scenario = 'add';
  819. $auth = $model->Authenticator($input);
  820. if(is_object($auth)) {
  821. $img = UploadFile::InstanceImgName('img', Yii::$app->params['img_url']['city']);
  822. if (is_string($img))
  823. {
  824. $auth->img = $img;
  825. }
  826. if($auth->save(false)) return Help::JsonCode(Help::SUCCESS,Yii::t('app','add_success'));
  827. }
  828. return Help::JsonCode(Help::ERROR,Yii::t('app','add_error'),$auth);
  829. }
  830. /*
  831. * 热门区域- 修改
  832. */
  833. public function actionHotcityedit()
  834. {
  835. $model = new PushmCity();
  836. $input = Yii::$app->request->get();
  837. $row = $model->FindById($input['id']);
  838. if($row != null)
  839. {
  840. $cityModel = (new CategoryCity())->SortgetList([]);
  841. foreach ($cityModel as &$val)
  842. {
  843. $val['checked'] = '';
  844. if($val['id'] == $row['city_id']){
  845. $val['checked'] = 'selected';
  846. }
  847. }
  848. return $this->render('hotcityedit',['model'=>$row,'city'=>$cityModel]);
  849. }
  850. }
  851. /*
  852. * 推送首页轮播 - 修改数据
  853. * */
  854. public function actionHotcityeditform()
  855. {
  856. $model = new PushmCity();
  857. $input = Yii::$app->request->post();
  858. $setAttribute = $model->Authenticator($input);
  859. if(is_object($setAttribute))
  860. {
  861. $row = $model->FindById($input['id']);
  862. if($row != null)
  863. {
  864. $row = Help::SetAttr($input,$model,$row);
  865. if($row->save(false)) return Help::JsonCode(Help::SUCCESS,Yii::t('app','edit_success'));
  866. }
  867. }
  868. return Help::JsonCode(Help::ERROR,Yii::t('app','edit_error'),$setAttribute);
  869. }
  870. /*
  871. * 首页-精选 - 删除 and 禁用
  872. * */
  873. public function actionCitydelshow()
  874. {
  875. $model = new PushmCity();
  876. $input = Yii::$app->request->post();
  877. $row = $model->FindById($input['id']);
  878. if($row != null)
  879. {
  880. switch ($input['type'])
  881. {
  882. case 'show':
  883. if($row->is_show == 1)
  884. {
  885. $row->is_show = 2;
  886. }
  887. else if($row->is_show == 2)
  888. {
  889. $row->is_show = 1;
  890. }
  891. break;
  892. case 'del':
  893. if(!empty($row->img))
  894. {
  895. UploadFile::delImg(Yii::$app->params['img_url']['city'],$row->img);
  896. }
  897. if($row->delete()){
  898. return Help::JsonCode(Help::SUCCESS,Yii::t('app','edit_success'));
  899. }
  900. break;
  901. case 'sort':
  902. if(!is_numeric($input['sort']))
  903. {
  904. return Help::JsonCode(Help::ERROR,'请输入数字');
  905. }
  906. $row->sort = $input['sort'];
  907. break;
  908. }
  909. if($row->save(false)) return Help::JsonCode(Help::SUCCESS,Yii::t('app','edit_success'));
  910. }
  911. return Help::JsonCode(Help::ERROR,Yii::t('app','edit_error'));
  912. }
  913. /*
  914. * 首页-特色类型 页面
  915. * */
  916. public function actionCharacteristic()
  917. {
  918. return $this->render('characteristic');
  919. }
  920. /*
  921. * 首页-特色类型 数据
  922. * */
  923. public function actionCharacteristicform()
  924. {
  925. $model = new PushmCharacteristic();
  926. $input = Yii::$app->request->post();
  927. $rows = $model->getList($input);
  928. if(!empty($rows))
  929. {
  930. $url = Yii::$app->params['httpImg']['host'].Yii::$app->params['httpImg']['characteristic'];
  931. foreach ($rows as &$val)
  932. {
  933. $val['create_at'] = date('Y-m-d H:i',$val['create_at']);
  934. $val['img'] = $url.$val['img'];
  935. }
  936. return Help::JsonData(0,Yii::t('app','get_success'),$model->Total(),$rows);
  937. }
  938. }
  939. /*
  940. * 首页-特色类型 添加页面
  941. * */
  942. public function actionCharacteristicadd()
  943. {
  944. return $this->render('characteristicadd');
  945. }
  946. /*
  947. * 首页-特色类型 添加页面
  948. * */
  949. public function actionCharacteristicaddform()
  950. {
  951. $model = new PushmCharacteristic();
  952. $input = Yii::$app->request->post();
  953. $auth = $model->Authenticator($input);
  954. if(is_object($auth))
  955. {
  956. $url = Yii::$app->params['img_url']['characteristic'];
  957. $imgStr = UploadFile::InstanceImgName('img',$url);
  958. if(is_string($imgStr))
  959. {
  960. $auth->img = $imgStr;
  961. }
  962. if($auth->save(false)) return Help::JsonCode(Help::SUCCESS,Yii::t('app','add_success'));
  963. }
  964. return Help::JsonCode(Help::ERROR,Yii::t('app','add_error'),$auth);
  965. }
  966. /*
  967. * 首页-特色类型 修改页面
  968. * */
  969. public function actionCharacteristicedit()
  970. {
  971. $model = new PushmCharacteristic();
  972. $row = $model->FindById(Yii::$app->request->get('id'));
  973. if($row != null)
  974. {
  975. $row['img'] = Yii::$app->params['httpImg']['host'].Yii::$app->params['httpImg']['characteristic'].$row['img'];
  976. return $this->render('characteristicedit',['model'=>$row,'get'=>Yii::$app->request->get()]);
  977. }
  978. }
  979. /*
  980. * 首页-特色类型 修改页面
  981. * */
  982. public function actionCharacteristiceditform()
  983. {
  984. $model = new PushmCharacteristic();
  985. $input = Yii::$app->request->post();
  986. $auth = $model->Authenticator($input);
  987. if(is_object($auth))
  988. {
  989. $row = $model->FindById($input['id']);
  990. if(!empty($row))
  991. {
  992. $url = Yii::$app->params['img_url']['characteristic'];
  993. $imgStr = UploadFile::InstanceImgName('img',$url);
  994. $result = Help::SetAttr($input,$auth,$row);
  995. if(is_string($imgStr))
  996. {
  997. UploadFile::delImg($url,$row['img']);
  998. $result->img = $imgStr;
  999. }
  1000. if($result->save(false)) return Help::JsonCode(Help::SUCCESS,Yii::t('app','edit_success'));
  1001. }
  1002. }
  1003. return Help::JsonCode(Help::ERROR,Yii::t('app','edit_error'),$auth);
  1004. }
  1005. /*
  1006. * 首页-特色类型 - 删除 and 禁用
  1007. * */
  1008. public function actionCharacteristicdelshow()
  1009. {
  1010. $model = new PushmCharacteristic();
  1011. $input = Yii::$app->request->post();
  1012. $row = $model->FindById($input['id']);
  1013. if($row != null)
  1014. {
  1015. switch ($input['type'])
  1016. {
  1017. case 'show':
  1018. if($row->is_show == 1)
  1019. {
  1020. $row->is_show = 2;
  1021. }
  1022. else if($row->is_show == 2)
  1023. {
  1024. $row->is_show = 1;
  1025. }
  1026. break;
  1027. case 'del':
  1028. if(!empty($row->img))
  1029. {
  1030. UploadFile::delImg(Yii::$app->params['img_url']['characteristic'],$row->img);
  1031. }
  1032. if($row->delete()){
  1033. return Help::JsonCode(Help::SUCCESS,Yii::t('app','edit_success'));
  1034. }
  1035. break;
  1036. case 'sort':
  1037. if(!is_numeric($input['sort']))
  1038. {
  1039. return Help::JsonCode(Help::ERROR,'请输入数字');
  1040. }
  1041. $row->sort = $input['sort'];
  1042. break;
  1043. }
  1044. if($row->save(false)) return Help::JsonCode(Help::SUCCESS,Yii::t('app','edit_success'));
  1045. }
  1046. return Help::JsonCode(Help::ERROR,Yii::t('app','edit_error'));
  1047. }
  1048. /*
  1049. * 首页 - 拨打电话图标 随机区域里面的电话号码
  1050. * */
  1051. public function actionRandcity()
  1052. {
  1053. return $this->render('randcity',['type'=>2]);
  1054. }
  1055. /*
  1056. * 首页 - 拨打电话 数据
  1057. * */
  1058. public function actionRandcityform()
  1059. {
  1060. $model = new PushmCity();
  1061. $input = Yii::$app->request->post();
  1062. $model->type = $input['type'];
  1063. $rows = $model->getList($input);
  1064. if(!empty($rows))
  1065. {
  1066. foreach ($rows as &$val)
  1067. {
  1068. $val['create_at'] = date('Y-m-d H:i',$val['create_at']);
  1069. }
  1070. return Help::JsonData(0,'成功',$model->Total(),$rows);
  1071. }
  1072. }
  1073. /*
  1074. * 首页 - 拨打电话 添加页面
  1075. * */
  1076. public function actionRandcityadd()
  1077. {
  1078. return $this->render('randcityadd',['type'=>Yii::$app->request->get('type')]);
  1079. }
  1080. /*
  1081. * 首页 - 拨打电话 添加数据
  1082. * */
  1083. public function actionRandcityaddform()
  1084. {
  1085. }
  1086. /********限时团购*********/
  1087. public function actionTimelimitsgroup()
  1088. {
  1089. $cityModel = $this->City();
  1090. return $this->render('timelimitsgroup',['type'=>1,'city'=>$cityModel]);
  1091. }
  1092. public function actionTimelimitsgroupform()
  1093. {
  1094. $model = new PushmTimelimitsgroup();
  1095. $input = Yii::$app->request->post();
  1096. $result = $model->getList($input);
  1097. if($result != null)
  1098. {
  1099. foreach ($result as &$val)
  1100. {
  1101. $val['create_at'] = date('Y-m-d H:i',$val['create_at']);
  1102. }
  1103. return Help::JsonData(0,Yii::t('app','get_success'),$model->Total($input),$result);
  1104. }
  1105. return Help::JsonCode(Help::ERROR,Yii::t('app','get_error'));
  1106. }
  1107. public function actionTimelimitsgroupadd()
  1108. {
  1109. $cityModel = $this->City();
  1110. return $this->render('timelimitsgroupadd',['type'=>Yii::$app->request->get('type'),'city'=>$cityModel]);
  1111. }
  1112. public function actionTimelimitsgroupaddform()
  1113. {
  1114. $input = Yii::$app->request->post();
  1115. $model = new PushmTimelimitsgroup();
  1116. $model->scenario = 'add';
  1117. $validate = $model->Authenticator($input);
  1118. if(is_object($validate))
  1119. {
  1120. if($validate->save(false)) return Help::JsonCode(Help::SUCCESS,Yii::t('app','add_success'));
  1121. }
  1122. return Help::JsonCode(Help::ERROR,Yii::t('app','add_error'),$validate);
  1123. }
  1124. /*
  1125. * 首页 - 修改页面
  1126. */
  1127. public function actionTimelimitsgroupedit()
  1128. {
  1129. $model = new PushmTimelimitsgroup();
  1130. $cityModel = $this->City();
  1131. $row = $model->FindById(Yii::$app->request->get('id'));
  1132. if($row != null)
  1133. {
  1134. return $this->render('timelimitsgroupedit',['type'=>Yii::$app->request->get('type'),'row'=>$row,'house_name'=>Yii::$app->request->get('house_name'),'city'=>$cityModel]);
  1135. }
  1136. }
  1137. /*
  1138. * 显示抢购 修改数据
  1139. * */
  1140. public function actionTimelimitsgroupeditform()
  1141. {
  1142. $model = new PushmTimelimitsgroup();
  1143. $input = Yii::$app->request->post();
  1144. $setAttribute = $model->Authenticator($input);
  1145. if(is_object($setAttribute))
  1146. {
  1147. $row = $model->FindById($input['id']);
  1148. if($row != null)
  1149. {
  1150. $row = Help::SetAttr($input,$model,$row);
  1151. if($row->save()) return Help::JsonCode(Help::SUCCESS,Yii::t('app','edit_success'));
  1152. }
  1153. }
  1154. return Help::JsonCode(Help::ERROR,Yii::t('app','edit_error'),$setAttribute);
  1155. }
  1156. /*排序 删除 显示*/
  1157. public function actionTimelimitsgroupdelandshow()
  1158. {
  1159. $model = new PushmTimelimitsgroup();
  1160. $input = Yii::$app->request->post();
  1161. $row = $model->FindById($input['id']);
  1162. if($row != null)
  1163. {
  1164. switch ($input['type'])
  1165. {
  1166. case 'show':
  1167. if($row->is_show == 1)
  1168. {
  1169. $row->is_show = 2;
  1170. }
  1171. else if($row->is_show == 2)
  1172. {
  1173. $row->is_show = 1;
  1174. }
  1175. break;
  1176. case 'del':
  1177. $row->del = 2;
  1178. break;
  1179. case 'sort':
  1180. $row->sort = $input['sort'];
  1181. break;
  1182. case 'click':
  1183. $row->click = $input['click'];
  1184. break;
  1185. case 'group_num':
  1186. $row->group_num = $input['group_num'];
  1187. break;
  1188. }
  1189. if($row->save(false)) return Help::JsonCode(Help::SUCCESS,Yii::t('app','edit_success'));
  1190. }
  1191. return Help::JsonCode(Help::ERROR,Yii::t('app','edit_error'));
  1192. }
  1193. private function Developers()
  1194. {
  1195. $developers = new \common\models\Developers();
  1196. $developers->is_del = 1;
  1197. $developers = $developers->getList([]);
  1198. return $developers;
  1199. }
  1200. private function City()
  1201. {
  1202. $city = new \common\models\CategoryCity();
  1203. $city->state = 1;
  1204. $city->pid = 0;
  1205. $cityModel = $city->getList([]);
  1206. return $cityModel;
  1207. }
  1208. }