123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249 |
- <?php
- namespace backend\controllers;
- use backend\base\CommonController;
- use backend\base\Help;
- use common\models\PushHousesale;
- use Yii;
- use common\models\PushRecommend;
- use common\models\PushHouserecommend;
- class PushrecommendController extends CommonController
- {
- /*
- * 页面显示
- * */
- public function actionIndex()
- {
- return $this->render('index');
- }
- /**数据读取*/
- public function actionIndexform()
- {
- $model = new PushRecommend();
- $rows = $model->adminList(Yii::$app->request->post());
- if(!empty($rows))
- {
- foreach($rows as &$val)
- {
- $val['create_at'] = date('Y-m-d H:i',$val['create_at']);
- }
- return Help::JsonData(0,Yii::t('app','get_success'),$model->Total(),$rows);
- }
- }
- /*
- * 加载楼盘 - 数据
- * */
- public function actionHouseloadform()
- {
- $model = new PushHouserecommend();
- $input = Yii::$app->request->post();
- $result = $model->getHouseList($input);
- if($result != null)
- {
- foreach ($result as &$val)
- {
- $val['create_at'] = date('Y-m-d H:i',$val['create_at']);
- }
- return Help::JsonData(0,Yii::t('app','get_success'),$model->Total($input),$result);
- }
- return Help::JsonCode(Help::ERROR,Yii::t('app','get_error'));
- }
- /*
- * 加载楼盘 - 批量删除
- * */
- public function actionHouseloaddelall()
- {
- //接收表单数据
- $input = Yii::$app->request->post();
- $delall = PushHouserecommend::deleteAll(['id'=>$input['id']]);
- if ($delall){
- return Help::JsonCode(Help::SUCCESS,'批量删除成功');
- }
- return Help::JsonCode(Help::ERROR,'批量删除失败');
- }
- /*
- * 优选新房栏目添加
- * */
- public function actionAddform()
- {
- $model = new PushRecommend();
- $model->scenario = 'add';
- $recommend = $model->Authenticator(Yii::$app->request->post());
- if(is_object($recommend) && $recommend->insert() == true)
- {
- return Help::JsonCode(Help::SUCCESS,'添加成功');
- }
- return Help::JsonCode(Help::ERROR,Yii::t('app','add_error'),$recommend);
- }
- public function actionAdd()
- {
- $city=$this->City();
- return $this->render('add',['city'=>$city]);
- }
- public function actionEdit()
- {
- $model = new PushRecommend();
- $city=$this->City();
- $row = $model->FindById(Yii::$app->request->get('id'));
- return $this->render('edit',['city'=>$city,'row'=>$row]);
- }
- public function actionEditform()
- {
- $model = new PushRecommend();
- $row = $model->findOne(Yii::$app->request->post('id'));
- if($row != null)
- {
- $row->title = Yii::$app->request->post('title');
- $row->city = Yii::$app->request->post('city');
- if($row->save()) return Help::JsonCode(Help::SUCCESS,'关键词修改成功');
-
- }
- return Help::JsonCode(Help::ERROR,'关键词修改失败');
- }
- public function actionLoadhouse()
- {
- return $this->render('loadhouse',['cat_id'=>Yii::$app->request->get('cat_id')]);
- }
- private function City()
- {
- $city = new \common\models\CategoryCity();
- $city->state = 1;
- $city->pid = 0;
- $cityModel = $city->getList([]);
- return $cityModel;
- }
- /*
- * 推送优选新房 - 数据
- * */
- public function actionGetHoustform()
- {
- $model = new PushHousesale();
- $input = Yii::$app->request->post();
- $result = $model->getList($input);
- if($result != null)
- {
- foreach ($result as &$val)
- {
- $val['create_at'] = date('Y-m-d H:i',$val['create_at']);
- }
- return Help::JsonData(0,Yii::t('app','get_success'),$model->Total($input),$result);
- }
- return Help::JsonCode(Help::ERROR,Yii::t('app','get_error'));
- }
- /*
- * 推送优选新房 - 添加
- */
- public function actionHouseadd()
- {
- return $this->render('houseadd',['cat_id'=>Yii::$app->request->get('cat_id')]);
- }
- //添加楼盘
- public function actionHouseaddform()
- {
- $input = Yii::$app->request->post();
- $model = new PushHouserecommend();
- $model->scenario = 'add';
- $validate = $model->Authenticator($input);
- if(is_object($validate))
- {
- $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'];
- if($validate->save(false)) return Help::JsonCode(Help::SUCCESS,Yii::t('app','add_success'));
- }
- return Help::JsonCode(Help::ERROR,Yii::t('app','add_error'),$validate);
- }
- public function actionDelshow()
- {
- $model = new PushHouserecommend();
- $input = Yii::$app->request->post();
- $row = $model->FindById($input['id']);
- if($row != null)
- {
- switch ($input['type'])
- {
- case 'show':
- if($row->is_show == 1)
- {
- $row->is_show = 2;
- }
- else if($row->is_show == 2)
- {
- $row->is_show = 1;
- }
- break;
- case 'del':
- $row->del = 2;
- break;
- case 'sort':
- if(is_numeric($input['sort']))
- {
- $row->sort = $input['sort'];
- }
- break;
- }
- if($row->save(false)) return Help::JsonCode(Help::SUCCESS,Yii::t('app','edit_success'));
- }
- return Help::JsonCode(Help::ERROR,Yii::t('app','edit_error'));
- }
- public function actionCatdelshow()
- {
- $model = new PushRecommend();
- $input = Yii::$app->request->post();
- $row = $model->FindById($input['id']);
- if($row != null)
- {
- switch ($input['type'])
- {
- case 'show':
- if($row->is_show == 1)
- {
- $row->is_show = 2;
- }
- else if($row->is_show == 2)
- {
- $row->is_show = 1;
- }
- break;
- case 'del':
- $row->del = 2;
- break;
- case 'sort':
- if(is_numeric($input['sort']))
- {
- $row->sort = $input['sort'];
- }
- break;
- }
- if($row->save(false)) return Help::JsonCode(Help::SUCCESS,Yii::t('app','edit_success'));
- }
- return Help::JsonCode(Help::ERROR,Yii::t('app','edit_error'));
- }
- /*
- * 优选新房 - 批量删除
- * */
- public function actionHousedelall()
- {
- $input = Yii::$app->request->post();
- $delall = PushHouserecommend::deleteAll(['id'=>$input['id']]);
- if ($delall){
- return Help::JsonCode(Help::SUCCESS,'批量删除成功');
- }
- return Help::JsonCode(Help::ERROR,'批量删除失败');
- }
- /********************below author:eit end***********************/
- }
|