GrouppurchaseController.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <?php
  2. namespace backend\controllers;
  3. use backend\base\CommonController;
  4. use backend\base\Help;
  5. use Yii;
  6. use common\models\CategoryVideo;
  7. use common\models\CategoryCity;
  8. use common\models\House;
  9. use common\models\GroupPurchase;
  10. use backend\server\UploadFile;
  11. use backend\server\Group;
  12. class GrouppurchaseController extends CommonController
  13. {
  14. /*
  15. * 团购列表显示页面
  16. * */
  17. public function actionIndex()
  18. {
  19. $cityModel = new CategoryCity();
  20. $city = $cityModel->getList([]);
  21. return $this->render('index',['city'=>$city]);
  22. }
  23. /*
  24. * 团购列表数据
  25. * */
  26. public function actionIndexform()
  27. {
  28. $model = new GroupPurchase();
  29. $input = Yii::$app->request->post();
  30. if(!empty($input['title']))
  31. {
  32. $model->title = $input['title'];
  33. }
  34. if(!empty($input['city']))
  35. {
  36. $model->city = $input['city'];
  37. }
  38. if(!empty($input['house_name']))
  39. {
  40. $model->hid = $input['house_name'];
  41. }
  42. $rows = $model->getList(Yii::$app->request->post());
  43. if($rows != null)
  44. {
  45. foreach ($rows as &$val)
  46. {
  47. $val['create_at'] = date('Y-m-d',$val['create_at']);
  48. $val['update_at'] = date('Y-m-d H:m:s',$val['update_at']);
  49. }
  50. return Help::JsonData(0,'成功',$model->Total(),$rows);
  51. }
  52. return Help::JsonCode(Help::ERROR,'暂无信息');
  53. }
  54. /*
  55. * 团购-添加页面
  56. * */
  57. public function actionAdd()
  58. {
  59. $city = new \common\models\CategoryCity();
  60. $city->pid = 0;
  61. $cityList = $city->getList([],['id','city_name']);
  62. return $this->render('add',['city'=>$cityList]);
  63. }
  64. /*
  65. * 添加团购数据
  66. * */
  67. public function actionAddform()
  68. {
  69. $model = new Group();
  70. $result = $model->GroupAdd();
  71. if($result === true)
  72. {
  73. return Help::JsonCode(Help::SUCCESS,'团购添加成功');
  74. }
  75. return Help::JsonCode(Help::ERROR,'添加失败','团购添加失败');
  76. }
  77. /*
  78. * 编辑团购页面
  79. * */
  80. public function actionEdit()
  81. {
  82. $cityModel = new CategoryCity();
  83. $city = $cityModel->getList([]);
  84. $group = new GroupPurchase();
  85. $groupData = $group->FindById(Yii::$app->request->get('id'));
  86. if($groupData != null)
  87. {
  88. $url = Yii::$app->params['httpImg']['host'].Yii::$app->params['httpImg']['group'];
  89. $groupData['img_pc'] = $url.$groupData['img_pc'];
  90. $groupData['img_mobile'] = $url.$groupData['img_mobile'];
  91. $groupData['many_img'] = json_decode($groupData['many_img'],true);
  92. return $this->render('edit',['city'=>$city,'group'=>$groupData,'post'=>Yii::$app->request->get()]);
  93. }
  94. }
  95. /*
  96. * 编辑-团购数据
  97. * */
  98. public function actionEditform()
  99. {
  100. $model = new Group();
  101. $result = $model->GroupEdit();
  102. if($result === true)
  103. {
  104. return Help::JsonCode(Help::SUCCESS,'修改成功');
  105. }
  106. return Help::JsonCode(Help::ERROR,'修改失败',$auth);
  107. }
  108. /*
  109. * 团购修改状态
  110. * */
  111. public function actionIs_view()
  112. {
  113. $model = new Group();
  114. if($model->StateAndDel(1) === true) return Help::JsonCode(Help::SUCCESS,'操作成功');
  115. return Help::JsonCode(Help::ERROR,'操作失败');
  116. }
  117. /*
  118. * 团购删除
  119. * */
  120. public function actionDel()
  121. {
  122. $model = new Group();
  123. if($model->StateAndDel(2) === true) return Help::JsonCode(Help::SUCCESS,'操作成功');
  124. return Help::JsonCode(Help::ERROR,'操作失败');
  125. }
  126. /*
  127. * 显示所有楼盘信息页面
  128. * */
  129. public function actionAllhouse()
  130. {
  131. return $this->render('allhouse');
  132. }
  133. /*
  134. * 获取所有楼盘数据
  135. * */
  136. public function actionAllhouseform()
  137. {
  138. $model = new House;
  139. $input = Yii::$app->request->post();
  140. if(!empty($input['name']))
  141. {
  142. $model->name = $input['name'];
  143. }
  144. $rows = $model->getList($input);
  145. if($rows != null)
  146. {
  147. return Help::JsonData(0,'成功',$model->getListTotal($input),$rows);
  148. }
  149. }
  150. }