123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- <?php
- namespace backend\controllers;
- use backend\base\CommonController;
- use backend\base\Help;
- use Yii;
- use common\models\CategoryVideo;
- use common\models\CategoryCity;
- use common\models\House;
- use common\models\GroupPurchase;
- use backend\server\UploadFile;
- use backend\server\Group;
- class GrouppurchaseController extends CommonController
- {
- /*
- * 团购列表显示页面
- * */
- public function actionIndex()
- {
- $cityModel = new CategoryCity();
- $city = $cityModel->getList([]);
- return $this->render('index',['city'=>$city]);
- }
- /*
- * 团购列表数据
- * */
- public function actionIndexform()
- {
- $model = new GroupPurchase();
- $input = Yii::$app->request->post();
- if(!empty($input['title']))
- {
- $model->title = $input['title'];
- }
- if(!empty($input['city']))
- {
- $model->city = $input['city'];
- }
- if(!empty($input['house_name']))
- {
- $model->hid = $input['house_name'];
- }
- $rows = $model->getList(Yii::$app->request->post());
- if($rows != null)
- {
- foreach ($rows as &$val)
- {
- $val['create_at'] = date('Y-m-d',$val['create_at']);
- $val['update_at'] = date('Y-m-d H:m:s',$val['update_at']);
- }
- return Help::JsonData(0,'成功',$model->Total(),$rows);
- }
- return Help::JsonCode(Help::ERROR,'暂无信息');
- }
- /*
- * 团购-添加页面
- * */
- public function actionAdd()
- {
- $city = new \common\models\CategoryCity();
- $city->pid = 0;
- $cityList = $city->getList([],['id','city_name']);
- return $this->render('add',['city'=>$cityList]);
- }
- /*
- * 添加团购数据
- * */
- public function actionAddform()
- {
- $model = new Group();
- $result = $model->GroupAdd();
- if($result === true)
- {
- return Help::JsonCode(Help::SUCCESS,'团购添加成功');
- }
- return Help::JsonCode(Help::ERROR,'添加失败','团购添加失败');
- }
- /*
- * 编辑团购页面
- * */
- public function actionEdit()
- {
- $cityModel = new CategoryCity();
- $city = $cityModel->getList([]);
- $group = new GroupPurchase();
- $groupData = $group->FindById(Yii::$app->request->get('id'));
- if($groupData != null)
- {
- $url = Yii::$app->params['httpImg']['host'].Yii::$app->params['httpImg']['group'];
- $groupData['img_pc'] = $url.$groupData['img_pc'];
- $groupData['img_mobile'] = $url.$groupData['img_mobile'];
- $groupData['many_img'] = json_decode($groupData['many_img'],true);
- return $this->render('edit',['city'=>$city,'group'=>$groupData,'post'=>Yii::$app->request->get()]);
- }
- }
- /*
- * 编辑-团购数据
- * */
- public function actionEditform()
- {
- $model = new Group();
- $result = $model->GroupEdit();
- if($result === true)
- {
- return Help::JsonCode(Help::SUCCESS,'修改成功');
- }
- return Help::JsonCode(Help::ERROR,'修改失败',$auth);
- }
- /*
- * 团购修改状态
- * */
- public function actionIs_view()
- {
- $model = new Group();
- if($model->StateAndDel(1) === true) return Help::JsonCode(Help::SUCCESS,'操作成功');
- return Help::JsonCode(Help::ERROR,'操作失败');
- }
- /*
- * 团购删除
- * */
- public function actionDel()
- {
- $model = new Group();
- if($model->StateAndDel(2) === true) return Help::JsonCode(Help::SUCCESS,'操作成功');
- return Help::JsonCode(Help::ERROR,'操作失败');
- }
- /*
- * 显示所有楼盘信息页面
- * */
- public function actionAllhouse()
- {
- return $this->render('allhouse');
- }
- /*
- * 获取所有楼盘数据
- * */
- public function actionAllhouseform()
- {
- $model = new House;
- $input = Yii::$app->request->post();
- if(!empty($input['name']))
- {
- $model->name = $input['name'];
- }
- $rows = $model->getList($input);
- if($rows != null)
- {
- return Help::JsonData(0,'成功',$model->getListTotal($input),$rows);
- }
- }
- }
|