PushController.php 43 KB

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