123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Administrator
- * Date: 2020/1/2
- * Time: 10:34
- */
- namespace backend\controllers;
- use Yii;
- use backend\base\CommonController;
- use backend\base\Help;
- use backend\server\UploadFile;
- use common\models\PushhouseType;
- use common\models\PushplaceType;
- class ZtController extends CommonController
- {
- public function actionHome()
- {
- return $this->render('home');
- }
- public function actionHomeform()
- {
- // p($this->cache['zt']);
- $model = new \common\models\SpecialTopic();
- $rows = $model->getList(Yii::$app->request->post());
- $imgUrl = Yii::$app->params['httpImg']['host'].Yii::$app->params['httpImg']['push_lb'];
- if(!empty($rows['data']))
- {
- array_walk($rows['data'],function(&$val) use ($imgUrl){
- $val['hids'] = implode(',',json_decode($val['hids'],true));
- list($val['pc_img'],$val['m_img']) = [(empty($val['pc_img'])? '' : $imgUrl.$val['pc_img']),(empty($val['m_img'])? '' : $imgUrl.$val['m_img'])];
- });
- return Help::JsonData(0,'成功',$rows['count'],$rows['data']);
- }
- return Help::JsonCode(Help::ERROR,'暂无数据');
- }
- public function actionAdd()
- {
- return $this->render('add');
- }
- public function actionAddform()
- {
- $model = new \common\models\SpecialTopic();
- $input = Yii::$app->request->post();
- $url = Yii::$app->params['img_url']['push_lb'];
- $img = UploadFile::InstanceImgName('img',$url);
- $img1 = UploadFile::InstanceImgName('img1',$url);
- if(empty($input['hid'])) return Help::JsonCode(Help::ERROR,'请选择推送的楼盘');
- $input['hids'] = json_encode($input['hid']);
- if(is_string($img) && is_string($img1)){
- list($input['pc_img'],$input['m_img']) = [$img,$img1];
- }
- $model->load($input,'');
- if($model->validate() && $model->save()){
- return Help::JsonCode(Help::SUCCESS,Yii::t('app','add_success'));
- }
- return Help::JsonCode(Help::SUCCESS,Yii::t('app','add_error'),$model->errors);
- }
- public function actionEdit()
- {
- $model = new \common\models\SpecialTopic();
- $zid = Yii::$app->request->get('id');
- $row = $model::findOne($zid);
- $imgUrl = Yii::$app->params['httpImg']['host'].Yii::$app->params['httpImg']['push_lb'];
- if(!empty($row)){
- $hmodel = new \common\models\House();
- $query = $hmodel::find();
- $hid = json_decode($row['hids'],true);
- $house = $query->select(['id','name'])->andWhere(['id'=>$hid])->asArray()->all();
- list($row['pc_img'],$row['m_img']) = [(empty($row['pc_img'])? '' : $imgUrl.$row['pc_img']),(empty($row['m_img'])? '' : $imgUrl.$row['m_img'])];
- }
- // p($house);die;
- return $this->render('edit',['model'=>$row,'house'=>$house]);
- }
- public function actionEditform()
- {
- $model = new \common\models\SpecialTopic();
- $input = Yii::$app->request->post();
- $row = $model::findOne($input['id']);
- $url = Yii::$app->params['img_url']['push_lb'];
- if(empty($input['hid'])) return Help::JsonCode(Help::ERROR,'请选择推送的楼盘');
- if(!empty($_FILES)){
- if(!empty($_FILES['img']['name'])){
- UploadFile::delImg($url,$row->pc_img);
- $img = UploadFile::InstanceImgName('img',$url);
- is_string($img)? $input['pc_img'] = $img : '' ;
- }
- if(!empty($_FILES['img1']['name'])){
- UploadFile::delImg($url,$row->m_img);
- $img1 = UploadFile::InstanceImgName('img1',$url);
- is_string($img1)? $input['m_img'] = $img1 : '' ;
- }
- }
- $input['hids'] = json_encode($input['hid']);
- $row->load($input,'');
- if($row->validate() && $row->save()){
- return Help::JsonCode(Help::SUCCESS,Yii::t('app','edit_success'));
- }
- return Help::JsonCode(Help::ERROR,Yii::t('app','edit_error'),$row->errors);
- }
- public function actionDel()
- {
- // p('没做');die;
- $input = Yii::$app->request->post();
- $model = new \common\models\SpecialTopic();
- $url = Yii::$app->params['img_url']['push_lb'];
- $row = $model::findOne($input['id']);
- if(!empty($row)){
- empty($row->pc_img)? '' : UploadFile::delImg($url,$row->pc_img);
- empty($row->m_img)? '' : UploadFile::delImg($url,$row->m_img);
- $row->delete();
- return Help::JsonCode(Help::SUCCESS,Yii::t('app','edit_success'));
- }
- return Help::JsonCode(Help::ERROR,Yii::t('app','edit_error'));
- }
- /*
- * ********************写字楼专题***********************
- * */
- public function actionGulfcitystate()
- {
- $input = Yii::$app->request->post();
- if (is_numeric($input['id'])) {
- $row = PushplaceType::findOne($input['id']);
- $row->state = $input['state'];
- if ($row->update(false)) return Help::JsonCode(Help::SUCCESS, '设置成功');
- return Help::JsonCode(Help::SUCCESS, '设置失败');
- } else {
- return Help::JsonCode(Help::SUCCESS, '设置失败');
- }
- }
- public function actionGulfcitysort()
- {
- $input = Yii::$app->request->post();
- if (is_numeric($input['id'])) {
- $row = PushplaceType::findOne($input['id']);
- $row->sort = $input['sort'];
- if ($row->update(false)) return Help::JsonCode(Help::SUCCESS, '排序成功');
- return Help::JsonCode(Help::SUCCESS, '排序失败');
- } else {
- return Help::JsonCode(Help::SUCCESS, '排序失败');
- }
- }
- public function actionGulfcitydel()
- {
- $id = Yii::$app->request->post('id');
- if (is_numeric($id)) {
- if (PushplaceType::findOne($id)->delete()) return Help::JsonCode(Help::SUCCESS, '删除成功');
- return Help::JsonCode(Help::ERROR, '删除失败');
- } else {
- return Help::JsonCode(Help::ERROR, '删除失败');
- }
- }
-
- //海南站专题别墅
- public function actionHainanville()
- {
- return $this->render('hainanville');
- }
-
- public function actionHainanvilleform()
- {
- $data = PushplaceType::find()->where(['type' => 1])->asArray()->all();
- return help::JsonData(0, '成功', 0, $data);
- }
-
- public function actionHainanvillestate()
- {
- $input = Yii::$app->request->post();
- if (is_numeric($input['id'])) {
- $row = PushplaceType::findOne($input['id']);
- $row->state = $input['state'];
- if ($row->update(false)) return Help::JsonCode(Help::SUCCESS, '设置成功');
- return Help::JsonCode(Help::SUCCESS, '设置失败');
- } else {
- return Help::JsonCode(Help::SUCCESS, '设置失败');
- }
- }
-
- public function actionTohainanvilleadd()
- {
- $input = Yii::$app->request->post('data');
- $row = PushplaceType::find();
- if (!$row->where(['title' => $input['title'], 'type' => 1])->exists()) {
- $query = new PushplaceType();
- $query->title = $input['title'];
- $query->type = 1;
- if ($query->save()) return Help::JsonCode(Help::SUCCESS, '添加成功');
- Help::JsonCode(Help::ERROR, '添加失败');
- } else {
- return Help::JsonCode(Help::SUCCESS, '地区已存在');
- }
- }
-
-
-
-
- public function actionHainanvilleadd()
- {
- return $this->render('hainanvilleadd');
- }
-
- public function actionHainanvillegl()
- {
- $id = Yii::$app->request->get('id');
- return $this->render('hainanvillegl', ['id' => $id]);
- }
-
- public function actionHainanvilleglform()
- {
- $previd = Yii::$app->request->get('previd');
- $data = PushhouseType::find()
- ->select('pfg_pushhouse_type.*,pfg_pushplace_type.title,pfg_house.name,')
- ->where(['pfg_pushhouse_type.previd' => $previd, 'pfg_pushhouse_type.type' => 2])
- ->leftJoin('pfg_house', 'pfg_house.id = pfg_pushhouse_type.hid')
- ->leftJoin('pfg_pushplace_type', 'pfg_pushplace_type.id = pfg_pushhouse_type.previd')
- ->orderBy(['pfg_pushhouse_type.sort' => SORT_DESC])->asArray()->all();
- return help::JsonData(0, '成功', 0, $data);
- }
-
- public function actionHainanvillegladd()
- {
- $previd = Yii::$app->request->get('previd');
- return $this->render('hainanvillegladd', ['previd' => $previd]);
- }
-
- public function actionGulfcitygledit()
- {
- $id = Yii::$app->request->get('id');
- $data = PushhouseType::find()
- ->select('pfg_pushhouse_type.*,pfg_house.name,')
- ->where(['pfg_pushhouse_type.id' => $id])
- ->leftJoin('pfg_house', 'pfg_house.id = pfg_pushhouse_type.hid')
- ->asArray()->one();
- return $this->render('gulfcitygledit', ['data' => $data]);
- }
-
- public function actionGulfcitygleditto()
- {
- $input = Yii::$app->request->post('data');
- $row = PushhouseType::find();
- if (!$row->where("id <> {$input['id']} AND previd = {$input['previd']} AND hid = {$input['hid']}")->exists()) {
- $query = PushhouseType::findOne($input['id']);
- $query->hid = $input['hid'];
- if ($query->update(false)) return Help::JsonCode(Help::SUCCESS, '编辑成功');
- return Help::JsonCode(Help::SUCCESS, '编辑失败');
- } else {
- return Help::JsonCode(Help::ERROR, '楼盘已存在');
- }
- }
-
- public function actionHainanvillegladdto()
- {
- $input = Yii::$app->request->post('data');
- $row = PushhouseType::find();
- if (!$row->where(['previd' => $input['previd'], 'type' => 2, 'hid' => $input['hid']])->exists()) {
- $query = new PushhouseType();
- $query->hid = $input['hid'];
- $query->previd = $input['previd'];
- $query->type = 2;
- if ($query->save()) return Help::JsonCode(Help::SUCCESS, '添加成功');
- Help::JsonCode(Help::ERROR, '添加失败');
- } else {
- Help::JsonCode(Help::ERROR, '楼盘已存在');
- }
- }
-
- public function actionTohainanvilleedit()
- {
- $input = Yii::$app->request->post('data');
- $rows = PushplaceType::find();
- if (!$rows->where(['type' => 1, 'title' => $input['title']])->exists()) {
- $qurey = PushplaceType::findOne($input['id']);
- $qurey->title = $input['title'];
- if ($qurey->update(false)) return Help::JsonCode(Help::SUCCESS, '编辑成功');
- return Help::JsonCode(Help::ERROR, '编辑失败');
- } else {
- return Help::JsonCode(Help::SUCCESS, '地区已存在');
- }
- }
- public function actionGulfcityglstate()
- {
- $input = Yii::$app->request->post();
- if (is_numeric($input['id'])) {
- $row = PushhouseType::findOne($input['id']);
- $row->state = $input['state'];
- if ($row->update(false)) return Help::JsonCode(Help::SUCCESS, '设置成功');
- return Help::JsonCode(Help::SUCCESS, '设置失败');
- } else {
- return Help::JsonCode(Help::SUCCESS, '设置失败');
- }
- }
- public function actionGulfcityglsort()
- {
- $input = Yii::$app->request->post();
- if (is_numeric($input['id'])) {
- $row = PushhouseType::findOne($input['id']);
- $row->sort = $input['sort'];
- if ($row->update(false)) return Help::JsonCode(Help::SUCCESS, '排序成功');
- return Help::JsonCode(Help::SUCCESS, '排序失败');
- } else {
- return Help::JsonCode(Help::SUCCESS, '排序失败');
- }
- }
- public function actionGulfcitygldel()
- {
- $id = Yii::$app->request->post('id');
- if (is_numeric($id)) {
- if (PushhouseType::findOne($id)->delete()) return Help::JsonCode(Help::SUCCESS, '删除成功');
- return Help::JsonCode(Help::ERROR, '删除失败');
- } else {
- return Help::JsonCode(Help::ERROR, '删除失败');
- }
- }
- public function actionOfficezt()
- {
- return $this->render('officezt');
- }
- //获取地区列表
- public function actionOfficeztform()
- {
- $dataInfo = PushplaceType::find()
- ->where(['type' => 4])
- ->orderBy(['sort' => SORT_DESC])
- ->asArray()->all();
- return help::JsonData(0, '成功', 0, $dataInfo);
- }
- public function actionOfficeztadd()
- {
- return $this->render('officeztadd');
- }
- public function actionOfficeztaddform()
- {
- $input = Yii::$app->request->post('data');
- $rows = PushplaceType::find();
- if (!$rows->where(['type' => 4, 'title' => $input['title']])->exists()) {
- $query = new PushplaceType();
- $query->title = $input['title'];
- $query->type = 4;
- if ($query->save()) return Help::JsonCode(Help::SUCCESS, '添加成功');
- Help::JsonCode(Help::ERROR, '添加失败');
- } else {
- return Help::JsonCode(Help::ERROR, '地区已存在');
- }
- }
- public function actionOfficeztdel()
- {
- $id = Yii::$app->request->post('id');
- $rows = PushplaceType::findOne($id);
- if ($rows->delete()) return Help::JsonCode(Help::SUCCESS, '删除成功');
- Help::JsonCode(Help::ERROR, '删除失败');
- }
- public function actionOfficeztedit()
- {
- $id = Yii::$app->request->get('id');
- $data = PushplaceType::findOne($id);
- return $this->render('officeztedit', ['data' => $data]);
- }
- public function actionOfficezteditform()
- {
- $input = Yii::$app->request->post();
- $rows = PushplaceType::findOne($input['id']);
- $rows->title = $input['title'];
- if ($rows->update(false)) return Help::JsonCode(Help::SUCCESS, '编辑成功');
- Help::JsonCode(Help::ERROR, '编辑失败');
- }
- public function actionOfficeztgl()
- {
- $id = Yii::$app->request->get('id');
- return $this->render('officeztgl', ['id' => $id]);
- }
- public function actionOfficeztglform()
- {
- $previd = Yii::$app->request->get('previd');
- $data = PushhouseType::find()
- ->select('pfg_pushhouse_type.*,pfg_pushplace_type.title,pfg_house.name,')
- ->where(['pfg_pushhouse_type.previd' => $previd, 'pfg_pushhouse_type.type' => 4])
- ->leftJoin('pfg_house', 'pfg_house.id = pfg_pushhouse_type.hid')
- ->leftJoin('pfg_pushplace_type', 'pfg_pushplace_type.id = pfg_pushhouse_type.previd')
- ->orderBy(['pfg_pushhouse_type.sort' => SORT_DESC])->asArray()->all();
- return help::JsonData(0, '成功', 0, $data);
- }
- public function actionOfficeztgladd()
- {
- $id = Yii::$app->request->get('id');
- return $this->render('officeztgladd', ['id' => $id]);
- }
- public function actionOfficeztgladdform()
- {
- $input = Yii::$app->request->post('data');
- $row = PushhouseType::find();
- if (!$row->where(['previd' => $input['previd'], 'type' => 4, 'hid' => $input['hid']])->exists()) {
- $query = new PushhouseType();
- $query->hid = $input['hid'];
- $query->previd = $input['previd'];
- $query->type = 4;
- if ($query->save()) return Help::JsonCode(Help::SUCCESS, '添加成功');
- Help::JsonCode(Help::ERROR, '添加失败');
- } else {
- Help::JsonCode(Help::ERROR, '楼盘已存在');
- }
- }
-
- public function actionHainanvilledel()
- {
- $id = Yii::$app->request->post('id');
- if (is_numeric($id)) {
- if (PushplaceType::findOne($id)->delete()) return Help::JsonCode(Help::SUCCESS, '删除成功');
- return Help::JsonCode(Help::ERROR, '删除失败');
- } else {
- return Help::JsonCode(Help::ERROR, '删除失败');
- }
- }
-
- public function actionHainanvilleedit()
- {
- $id = Yii::$app->request->get('id');
- $data = PushplaceType::findOne($id);
- return $this->render('hainanvilleedit', ['data' => $data]);
- }
-
- }
|