1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033 |
- <?php
- /**
- * Created by PhpStorm.
- * User: xiaofeng
- * Date: 2018/3/4
- * Time: 下午2:11
- */
- namespace backend\controllers;
- use backend\base\CommonController;
- use backend\server\Houses;
- use backend\base\Help;
- //use backend\server\SetUploadImg;
- //use backend\server\UploadFile;
- //use common\models\HouseNews;
- use common\models\House;
- use common\models\HouseDetail;
- use common\models\CategoryCity;
- use common\models\HousePermit;
- use Yii;
- //use Tinify\Tinify;
- class HouseController extends CommonController
- {
- /*
- * 楼盘显示页面
- * */
- public function actionIndex()
- {
- $city = new \common\models\CategoryCity();
- // $city->pid = 0;
- $cityList = $city->getList([], ['city_name', 'id']);
- return $this->render('index', ['city' => $cityList]);
- }
- /*
- * 获取楼盘列表数据
- * */
- public function actionIndexform()
- {
- $model = new Houses();
- $rows = $model->GroupList(Yii::$app->request->post());
- if ($rows != null) {
- return Help::JsonData(0, '成功', $rows['count'], $rows['data']);
- }
- }
- /*
- * 添加楼盘页面
- * */
- public function actionCreate()
- {
- $model = new Houses();
- $rows = $model->HouseRelation();
- return $this->render('create', ['model' => $rows]);
- }
- /*
- * 添加楼盘数据
- * */
- public function actionCreatefrom()
- {
- $model = new Houses();
- $result = $model->add(Yii::$app->request->post());
- if ($result === true) {
- return Help::JsonCode(200, '新楼盘添加成功');
- }
- return Help::JsonCode(300, '新楼盘添加失败', $result);
- }
- /*
- *修改楼盘的显示页面
- * */
- public function actionEdit()
- {
- $modelDetails = new \common\models\House();
- $modelDetails->id = Yii::$app->request->get('id');
- $row = $modelDetails->HousesAll();
- if ($row != null) {
- $model = new Houses();
- $rows = $model->HouseRelation();
- $row['characteristic'] = json_decode($row['characteristic']);
- $row['type'] = json_decode($row['type']);
- $row['architecture_type'] = json_decode($row['architecture_type']);
- $row['property_tag'] = json_decode($row['property_tag']);
- // $row['fit'] = explode(',',$row['fit']);
- $row['evaluating'] = json_decode($row['evaluating']);
- if (empty($row['province'])) {
- $city = \common\models\CategoryCity::findOne($row['city']);
- if ($city) {
- $row['province'] = \common\models\CategoryCity::findOne($city['pid'])['id'];
- }
- }
- // if(!empty($details['architecture_type'])) if (in_array($val['id'], $details['architecture_type'])) echo 'checked'
- $row['thumb'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['houses'] . $row['thumb'] . Yii::$app->params['pfgwatermark'];
- $row['video_img'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['house_video'] . $row['video_img'] . Yii::$app->params['pfgwatermark'];
- $row['panorama_img'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['house_video'] . $row['panorama_img'] . Yii::$app->params['pfgwatermark'];
- return $this->render('edit', ['model' => $rows, 'details' => $row]);
- }
- }
- /*
- * 修改楼盘信息
- * */
- public function actionEditfrom()
- {
- $post = Yii::$app->request->post();
- $model = new Houses();
- $result = $model->Edit($post);
- if ($result === true) {
- return Help::JsonCode(Help::SUCCESS, '楼盘修改成功');
- }
- return Help::JsonCode(Help::ERROR, '楼盘修改失败', $result);
- }
- /*
- * 楼盘排序页面
- * */
- public function actionHousesort()
- {
- return $this->render('housesort');
- }
- /*
- * 排序页面一键清零
- * */
- public function actionQingzero()
- {
- $post = Yii::$app->request->post();
- if (empty($post['city'])) return Help::JsonCode(Help::ERROR, '请先选择区域');
- $city = CategoryCity::findOne($post['city']);
- if ($city['pid'] == 0) {
- $city = CategoryCity::find()->andWhere(['pid' => $city['id'], 'del' => 1])->column();
- } else {
- $city = $city['id'];
- }
- $houseid = House::find()->andWhere(['city' => $city, 'del' => 1])->column();
- $zero = Yii::$app->request->post('zero');
- switch ($zero) {
- case 1:
- $state = House::updateAll(['sort' => 0], ['id' => $houseid]);
- if ($state) return Help::JsonCode(Help::SUCCESS, '清零成功', $zero);
- break;
- case 2:
- $state = HouseDetail::updateAll(['regionsort' => 0], ['hid' => $houseid]);
- if ($state) return Help::JsonCode(Help::SUCCESS, '清零成功', $zero);
- break;
- case 3:
- $state = HouseDetail::updateAll(['allsort' => 0], ['hid' => $houseid]);
- if ($state) return Help::JsonCode(Help::SUCCESS, '清零成功', $zero);
- break;
- }
- return Help::JsonCode(Help::ERROR, '没有可清零的数据', $zero);
- }
- /*
- * 单独修改排序
- * */
- public function actionHousesortedit()
- {
- // $model = new \common\models\House();
- $input = Yii::$app->request->post();
- if (!empty($input['type']) && $input['type'] == 'allsort') {
- $model = new \common\models\HouseDetail();
- $find = $model->FindById($input['id']);
- } else if (!empty($input['type']) && $input['type'] == 'regionsort') {
- $model = new \common\models\HouseDetail();
- $find = $model->FindById($input['id']);
- } else {
- $model = new \common\models\House();
- $find = $model->FindById($input['id']);
- }
- if ($find != null) {
- switch ($input['type']) {
- case 'deal_num':
- $find->deal_num = $input['deal_num'];
- break;
- case 'sort':
- $find->sort = $input['sort'];
- break;
- case 'stars':
- $find->stars = $input['stars'];
- break;
- case 'city_ranking':
- $find->city_ranking = $input['city_ranking'];
- break;
- case 'allsort':
- $find->allsort = $input['allsort'];
- break;
- case 'regionsort':
- $find->regionsort = $input['regionsort'];
- break;
- }
- if (!empty($input['examineid'])) {
- switch ($find->is_view) {
- case 1:
- $find->is_view = 2;
- break;
- case 2:
- $find->is_view = 1;
- break;
- }
- }
- if ($find->update(false) == true) return Help::JsonCode(Help::SUCCESS, '操作成功');
- }
- return Help::JsonCode(Help::ERROR, '操作失败');
- }
- /*
- * 删除楼盘
- * */
- public function actionHousedel()
- {
- $result = \common\models\House::updateAll(['del' => 2, 'update_at' => $_SERVER['REQUEST_TIME']], ['id' => Yii::$app->request->post('hid')]);
- if ($result > 0) {
- $arr = [];
- foreach (Yii::$app->request->post('hid') as $key => $val) {
- $arr[$key]['uid'] = Yii::$app->session['user_info']['uid'];
- $arr[$key]['hid'] = $val;
- $arr[$key]['create_at'] = $_SERVER['REQUEST_TIME'];
- $arr[$key]['type'] = 2;
- }
- $res = Yii::$app->db->createCommand()->batchInsert(\common\models\UserHouse::tableName(), ['uid', 'hid', 'create_at', 'type'], $arr)->execute();
- return Help::JsonCode(Help::SUCCESS, '删除成功');
- }
- return Help::JsonCode(Help::ERROR, '删除失败');
- }
- public function actionOpenstate()
- {
- $id = Yii::$app->request->get('hid');
- if (!empty($id)) {
- $model = new \common\models\HouseAuditingrecord();
- $model->hid = $id;
- $rows = $model->getList();
- if (!empty($rows)) {
- foreach ($rows as &$val) {
- $val['create_at'] = date('Y-m-d H:i', $val['create_at']);
- $val['house_state'] = Yii::$app->params['house_view'][$val['house_state']];
- }
- }
- return $this->render('openstate', ['hid' => $id, 'model' => $rows]);
- }
- }
- public function actionOpenstateform()
- {
- $input = Yii::$app->request->post();
- $house = new House();
- $find = $house->FindById($input['hid']);
- if (!empty($find)) {
- $Transaction = Yii::$app->db->beginTransaction();
- $input['house_state'] = $find['is_view'];
- switch ($find['is_view']) {
- case 1:
- $find->is_view = 2;
- break;
- case 2:
- $find->is_view = 1;
- break;
- }
- $input['house_state'] = $find->is_view;
- $input['uid'] = Yii::$app->session['user_info']['uid'];
- $model = new \common\models\HouseAuditingrecord();
- if ($model->load($input, '') && $model->save() && $find->save(false)) {
- $Transaction->commit();
- return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'edit_success'));
- }
- $Transaction->rollBack();
- return Help::JsonCode(Help::ERROR, Yii::t('app', 'edit_error'), $model->errors);
- }
- }
- //批量操作
- public function actionBatchsave()
- {
- return $this->render('batchsave');
- }
- //批量操作
- public function actionBatchsaveform()
- {
- $input = Yii::$app->request->post();
- $model = \common\models\House::updateAll(['is_view' => 2], ['city' => $input['city']]);
- if ($model > 0) {
- return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'edit_success'));
- }
- return Help::JsonCode(Help::ERROR, Yii::t('app', 'edit_error'));
- }
- //================================楼盘资讯======================================
- /*
- * 关联楼盘的资讯
- * */
- public function actionNewslist()
- {
- $model = new \common\models\CategoryNews();
- $list = $model->getList([], ['id', 'news_name']);
- return $this->render('newslist', ['name' => Yii::$app->request->get(), 'category' => $list]);
- }
- /*
- * 获取跟楼盘有关的资讯
- * */
- public function actionNewslistform()
- {
- $model = new Houses();
- $result = $model->FilterNews();
- if (!empty($result['data'])) {
- return Help::JsonData(0, '成功', $result['count'], $result['data']);
- }
- return Help::JsonCode(Help::ERROR, '暂无关联的资讯信息');
- }
- /*
- * 加载资讯列表页面,
- * */
- public function actionLoadnews()
- {
- $model = new \common\models\CategoryNews();
- $list = $model->getList([], ['id', 'news_name']);
- return $this->render('loadnews', ['category' => $list, 'hid' => Yii::$app->request->get('hid')]);
- }
- /*
- * 加载资讯列表数据,
- * */
- public function actionLoadnewslist()
- {
- $model = new Houses();
- $rows = $model->FilterLoadNews();
- if (!empty($rows)) {
- return Help::JsonData(0, '成功', $rows['count'], $rows['data']);
- }
- return Help::JsonCode(Help::ERROR, '暂无关联的资讯信息');
- }
- /*
- * 楼盘关联资讯数据
- * */
- public function actionRelationnews()
- {
- $model = new Houses();
- $row = $model->RelationNewsRecord();
- if ($row === true) return Help::JsonCode(Help::SUCCESS, '资讯加载成功');
- return Help::JsonCode(Help::ERROR, '资讯加载失败');
- }
- /*
- * 删除楼盘关联的资讯
- * */
- public function actionHousenewsdel()
- {
- $model = new \common\models\HouseNews();
- $row = $model->FingById(Yii::$app->request->post('dataid'));
- if ($row != null) {
- if (Yii::$app->request->post('type') == 2) {
- if ($row->is_view == 2) {
- $row->is_view = 1;
- } else {
- $row->is_view = 2;
- }
- } else {
- $row->del = 2;
- }
- if ($row->update() == true) return Help::JsonCode(Help::SUCCESS, '删除成功');
- }
- return Help::JsonCode(Help::ERROR, '删除失败');
- }
- /*
- * 删除楼盘关联的资讯(改)
- * */
- public function actionHousenewsdelgai()
- {
- $input = Yii::$app->request->post();
- if($input['hn'] == 'news'){//资讯是从news表里的
- $row = \common\models\News::findOne($input['nid']);
- $row->hid = 0;
- if($row->update(false)){
- return Help::JsonCode(Help::SUCCESS, '删除成功');
- }
- }elseif(is_numeric($input['hn'])){
- $model = new \common\models\HouseNews();
- $row = $model->FingById($input['hn']);
- if($row->delete()){
- return Help::JsonCode(Help::SUCCESS, '删除成功');
- }
- }
- return Help::JsonCode(Help::ERROR, '删除失败');
- }
- //================================楼盘相册======================================
- /*
- * 楼盘相册页面
- * */
- public function actionAlbum()
- {
- $model = new \common\models\CategoryAlbum();
- $album = $model->getList([], ['id', 'name']);
- return $this->render('album', ['post' => Yii::$app->request->get(), 'model' => $album]);
- }
- /*
- * 楼盘相册数据
- * */
- public function actionAlbumform()
- {
- $model = new \common\models\HouseAlbum();
- $result = $model->AlbumGroup(Yii::$app->request->post());
- // foreach ($result as &$val)
- // {
- // $val['state'] = Yii::$app->params['newsStatus'][$val['state']];
- // }
- if ($result != null) {
- return Help::JsonData(0, '成功', 0, $result);
- }
- return Help::JsonCode(Help::ERROR, '暂无相册信息,请添加相册');
- }
- /*
- * 添加楼盘相册页面
- * */
- public function actionAlbumadd()
- {
- $model = new \common\models\CategoryAlbum();
- $album = $model->getList([], ['id', 'name']);
- return $this->render('albumadd', ['post' => Yii::$app->request->get(), 'model' => $album]);
- }
- /*
- * 添加楼盘相册数据
- * */
- public function actionAlbumaddform()
- {
- $model = new Houses();
- $result = $model->HouseAibumCreate();
- if ($result === true) {
- return Help::JsonCode(Help::SUCCESS, '添加成功');
- }
- return Help::JsonCode(Help::ERROR, '添加失败', $result);
- }
- /*
- * 修改楼盘相册页面
- * */
- public function actionAlbumedit()
- {
- $model = new \common\models\CategoryAlbum();
- $album = $model->getList([], ['id', 'name']);
- $modelAlbum = new \common\models\HouseAlbum();
- $modelAlbum->hid = Yii::$app->request->get('id');
- $modelAlbum->album_id = Yii::$app->request->get('alnumid');
- $rows = $modelAlbum->getList();
- if ($album != null) {
- foreach ($album as &$val) {
- $val['selected'] = '';
- if ($val['id'] == Yii::$app->request->get('alnumid')) {
- $val['selected'] = 'selected';
- }
- }
- foreach ($rows as &$val) {
- if (!empty($val['img'])) {
- $val['img'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['housealbums'] . $val['img'] . Yii::$app->params['pfgwatermark'];
- }
- }
- }
- return $this->render('albumedit', ['post' => Yii::$app->request->get(), 'model' => $album, 'albumlist' => $rows]);
- }
- /*
- * 修改相册数据
- * */
- public function actionAlbumeditformdata()
- {
- $model = new Houses();
- $result = $model->HouseAlbumSave();
- if ($result == true) return Help::JsonCode(Help::SUCCESS, '修改成功');
- return Help::JsonCode(Help::ERROR, '修改失败');
- }
- /*
- * 楼盘相册状态修改
- * */
- public function actionAlbumstatesave()
- {
- $model = new Houses();
- $row = $model->AlbumStateSave(1);
- if ($row === true) return Help::JsonCode(Help::SUCCESS, '操作成功');
- return Help::JsonCode(Help::ERROR, '操作失败');
- }
- /*
- * 楼盘相册删除
- * */
- public function actionAlbumdel()
- {
- $model = new Houses();
- $row = $model->AlbumStateSave(2);
- if ($row === true) return Help::JsonCode(Help::SUCCESS, '操作成功');
- return Help::JsonCode(Help::ERROR, '操作失败');
- }
- //================================楼盘户型======================================
- /*
- * 楼盘户型页面
- * */
- public function actionHousetype()
- {
- return $this->render('housetype', ['post' => Yii::$app->request->get()]);
- }
- /*
- * 楼盘户型数据
- * */
- public function actionHousetypeform()
- {
- $model = new \common\models\HouseType();
- $model->hid = Yii::$app->request->post('hid');
- $rows = $model->TypeGroup();
- foreach ($rows as &$val) {
- $val['state'] = Yii::$app->params['newsStatus'][$val['state']];
- }
- if ($rows != null) {
- return Help::JsonData(0, '成功', 0, $rows);
- }
- return Help::JsonCode(Help::ERROR, '暂无户型信息。');
- }
- /*
- * 楼盘户型添加页面
- * */
- public function actionHousetypeadd()
- {
- $model = new \common\models\CategoryHousetype();
- $rows = $model->getList([], ['id', 'huxing_name']);
- return $this->render('housetypeadd', ['typemodel' => $rows, 'post' => Yii::$app->request->get()]);
- }
- /*
- * 楼盘户型添加数据
- * */
- public function actionHousetypeaddform()
- {
- $model = new Houses();
- $result = $model->HouseTypeCreate();
- if ($result === true) {
- return Help::JsonCode(Help::SUCCESS, '添加成功');
- }
- return Help::JsonCode(Help::ERROR, '添加失败', $result);
- }
- /*
- * 楼盘类型修改
- * */
- public function actionHousetypeedit()
- {
- $model = new \common\models\CategoryHousetype();
- $houseType = $model->getList([], ['id', 'huxing_name']);
- $modelAlbum = new \common\models\HouseType();
- $modelAlbum->hid = Yii::$app->request->get('id');
- $modelAlbum->type_id = Yii::$app->request->get('type');
- $rows = $modelAlbum->getList();
- $hot = $rows[0]['hot'];
- if ($houseType != null) {
- foreach ($houseType as &$val) {
- $val['selected'] = '';
- if ($val['id'] == Yii::$app->request->get('type')) {
- $val['selected'] = 'selected';
- }
- }
- foreach ($rows as &$val) {
- if (!empty($val['img'])) {
- $val['img'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['housetypes'] . $val['img'] . Yii::$app->params['pfgwatermark'];
- }
- }
- }
- return $this->render('housetypeedit', ['post' => Yii::$app->request->get(), 'model' => $houseType, 'albumlist' => $rows, 'hot' => $hot]);
- }
- /*
- * 户型数据修改
- * */
- public function actionHousetypeeditform()
- {
- $model = new Houses();
- $result = $model->HouseTypeSave();
- if ($result === true) return Help::JsonCode(Help::SUCCESS, '修改成功');
- return Help::JsonCode(Help::ERROR, '修改失败');
- }
- /*
- * 户型状态修改
- * */
- public function actionTypetatesave()
- {
- $model = new Houses();
- $row = $model->HouseTypeStateSave(1);
- if ($row === true) return Help::JsonCode(Help::SUCCESS, '操作成功');
- return Help::JsonCode(Help::ERROR, '操作失败');
- }
- /*
- * 楼盘户型删除
- * */
- public function actionTypedel()
- {
- $model = new Houses();
- $row = $model->HouseTypeStateSave(2);
- if ($row === true) return Help::JsonCode(Help::SUCCESS, '操作成功');
- return Help::JsonCode(Help::ERROR, '操作失败');
- }
- //================================楼盘价格======================================
- /*
- * 价格历史列表显示页面
- * */
- public function actionPriceview()
- {
- return $this->render('priceview', ['post' => Yii::$app->request->get()]);
- }
- /*
- * 价格历史数据
- * */
- public function actionPriceviewform()
- {
- $model = new \common\models\HousePriceRecord();
- // p($_POST);
- $model->hid = Yii::$app->request->post('hid');
- $rows = $model->getList(Yii::$app->request->post());
- if ($rows != null) {
- return Help::JsonData(0, '成功', $model->Total(), $rows);
- }
- return Help::JsonCode(Help::ERROR, '暂无历史价格信息');
- }
- /*
- * 价格添加页面
- * */
- public function actionPriceadd()
- {
- $model = new \common\models\House();
- $row = $model->FindById(Yii::$app->request->get('hid'));
- if ($row != null) {
- // p($row);
- return $this->render('priceadd', ['post' => Yii::$app->request->get(), 'model' => $row]);
- }
- }
- /*
- * 价格数据添加
- * */
- public function actionPriceaddform()
- {
- $model = new Houses();
- $result = $model->HousePriceRecordadd(Yii::$app->request->post());
- if ($result === true) {
- return Help::JsonCode(Help::SUCCESS, '操作成功');
- }
- return Help::JsonCode(Help::ERROR, '操作失败', $result);
- }
- /*
- * 价格修改页面
- * */
- public function actionPriceedit()
- {
- $model = new \common\models\HousePriceRecord();
- $row = $model->FindById(Yii::$app->request->get('id'));
- if ($row != null) {
- return $this->render('priceedit', ['model' => $row, 'post' => Yii::$app->request->get()]);
- }
- }
- /*
- * 价格数据修改
- * */
- public function actionPriceeditform()
- {
- $model = new Houses();
- // p(Yii::$app->request->post());
- // exit;
- // p(Yii::$app->request->post());
- $result = $model->HousePriceRecordSave(Yii::$app->request->post());
- if ($result === true) {
- return Help::JsonCode(Help::SUCCESS, '操作成功');
- }
- return Help::JsonCode(Help::ERROR, '操作失败', $result);
- }
- /*
- * 楼盘历史价格删除
- * */
- public function actionPricedel()
- {
- $model = new Houses();
- $result = $model->HousePriceDelete(Yii::$app->request->post());
- if ($result === true) {
- return Help::JsonCode(Help::SUCCESS, '操作成功');
- }
- return Help::JsonCode(Help::ERROR, '操作失败', $result);
- }
- //================================楼盘周边配套======================================
- /*
- * 楼盘配套显示页面
- * */
- public function actionPeitao()
- {
- $house = new \common\models\HouseDetail();
- $input = Yii::$app->request->get();
- $ld = $house->FindById($input['id']);
- return $this->render('peitao', ['post' => $input, 'ld' => $ld]);
- }
- /*
- * 楼盘周边配套列表数据
- * */
- public function actionPeitaoform()
- {
- $model = new \common\models\HouseFacilities();
- $model->hid = Yii::$app->request->post('hid');
- $rows = $model->FacilitiesGroup();
- foreach ($rows as &$val) {
- $val['state'] = Yii::$app->params['newsStatus'][$val['state']];
- }
- if ($rows != null) {
- return Help::JsonData(0, '成功', 0, $rows);
- }
- return Help::JsonCode(Help::ERROR, '暂无周边配套信息。');
- }
- /*
- * 楼盘周边配套添加页面
- * */
- public function actionPeitaoadd()
- {
- $model = new \common\models\CategoryFacilities();
- $rows = $model->getList([]);
- $input = Yii::$app->request->get();
- return $this->render('peitaoadd', ['post' => $input, 'faci' => $rows]);
- }
- /*
- * 楼盘周边配套添加数据
- * */
- public function actionPeitaoaddform()
- {
- $model = new \common\models\HouseFacilities();
- $input = Yii::$app->request->post();
- $arr = [];
- if (!empty($input['data'])) {
- foreach ($input['data'] as $key => $val) {
- $arr[$key]['fid'] = $input['type_id'];
- $arr[$key]['name'] = $val['title'];
- $arr[$key]['distance'] = $val['rout'];
- $arr[$key]['latitude_longitude'] = $val['point'];
- $arr[$key]['hid'] = $input['hid'];
- $arr[$key]['create_at'] = $_SERVER['REQUEST_TIME'];
- $arr[$key]['update_at'] = $_SERVER['REQUEST_TIME'];
- }
- $result = Yii::$app->db->createCommand()->batchInsert(\common\models\HouseFacilities::tableName(), ['fid', 'name', 'distance', 'latitude_longitude', 'hid', 'create_at', 'update_at'], $arr)->execute();
- if ($result > 0) {
- return Help::JsonCode(Help::SUCCESS, '添加成功');
- }
- }
- return Help::JsonCode(Help::ERROR, '添加失败');
- }
- /*
- * 楼盘周边配套修改页面
- * */
- public function actionPeitaoedit()
- {
- if (Yii::$app->request->isPost) {
- $model = new \common\models\HouseFacilities();
- $model->hid = Yii::$app->request->post('hid');
- $model->fid = Yii::$app->request->post('fid');
- $rows = $model->getList();
- if ($rows != null) return Help::JsonData(0, '成功', 0, $rows);
- }
- $model = new \common\models\CategoryFacilities();
- $rows = $model->getList([]);
- return $this->render('peitaoedit', ['post' => Yii::$app->request->get(), 'faci' => $rows]);
- }
- /*
- * 楼盘周边配套修改
- * */
- public function actionPeitaodel()
- {
- $input = Yii::$app->request->post();
- $result = \common\models\HouseFacilities::updateAll(['del' => 2, 'update_at' => $_SERVER['REQUEST_TIME']], ['fid' => $input['type_id'], 'hid' => $input['hid'], 'del' => 1]);
- if ($result > 0) {
- return Help::JsonCode(Help::SUCCESS, '操作成功');
- }
- return Help::JsonCode(Help::ERROR, '操作失败');
- }
- /*
- * 楼盘周边配套修改数据
- * */
- public function actionPeitaoeditform()
- {
- $input = Yii::$app->request->post();
- $result = '';
- $arr = [];
- if (!empty($input['data'])) {
- foreach ($input['data'] as $key => $val) {
- $arr[$key]['fid'] = $input['type_id'];
- $arr[$key]['name'] = $val['title'];
- $arr[$key]['distance'] = $val['rout'];
- $arr[$key]['latitude_longitude'] = $val['point'];
- $arr[$key]['hid'] = $input['hid'];
- $arr[$key]['create_at'] = $_SERVER['REQUEST_TIME'];
- $arr[$key]['update_at'] = $_SERVER['REQUEST_TIME'];
- }
- $result = Yii::$app->db->createCommand()->batchInsert(\common\models\HouseFacilities::tableName(), ['fid', 'name', 'distance', 'latitude_longitude', 'hid', 'create_at', 'update_at'], $arr)->execute();
- }
- if (!empty($input['dataId'])) {
- $result = \common\models\HouseFacilities::updateAll(['del' => 2, 'update_at' => $_SERVER['REQUEST_TIME']], ['id' => $input['dataId']]);
- }
- return Help::JsonCode(Help::SUCCESS, '修改成功');
- if ($result > 0) {
- return Help::JsonCode(Help::SUCCESS, '修改成功');
- }
- return Help::JsonCode(Help::ERROR, '修改失败');
- //
- // $input = Yii::$app->request->post();
- // if(!empty($input['delall']))
- // {
- // $result = \common\models\HouseFacilities::updateAll(['del'=>2,'update_at'=>$_SERVER['REQUEST_TIME']],['id'=>$input['delall']]);
- // }
- // $model = new \common\models\HouseFacilities();
- // if(!empty($input['edit_matingName']))
- // {
- //
- // foreach ($input['edit_matingName'] as $key=>$val)
- // {
- // $_model = clone $model;
- // $find = $_model::findOne($input['edit_id'][$key]);
- // if($find != null)
- // {
- // $find->name = $input['edit_matingName'][$key];
- // $find->distance = $input['edit_distance'][$key];
- // $find->latitude_longitude = $input['edit_longitude'][$key];
- // $result = $find->save();
- // }
- // }
- // }
- //
- // if(!empty($input['name']))
- // {
- //
- // foreach ($input['name'] as $key=>$val)
- // {
- // $_model = clone $model;
- // if(!empty($input['name'][$key]))
- // {
- // $arr['name'] = $input['name'][$key];
- // }
- //
- // if(!empty($input['name'][$key]))
- // {
- // $arr['distance'] = $input['distance'][$key];
- // }
- //
- // if(!empty($input['longitude'][$key])){
- // $arr['latitude_longitude'] = $input['longitude'][$key];
- // }
- //
- // $arr['fid'] = $input['fid'];
- // $arr['hid'] = $input['hid'];
- // $auth = $_model->Authenticator($arr);
- // if(is_array($auth)) return Help::JsonCode(Help::ERROR,'操作失败',$auth);
- // $result = $auth->save();
- // }
- // }
- //
- // if($input['is_fid'] != $input['fid'])
- // {
- // $result = \common\models\HouseFacilities::updateAll(['fid'=>$input['is_fid'],'update_at'=>$_SERVER['REQUEST_TIME']],['fid'=>$input['fid'],'hid'=>$input['hid']]);
- // }
- //
- // if($result > 0 )
- // {
- // return Help::JsonCode(Help::SUCCESS,'操作成功');
- // }
- // return Help::JsonCode(Help::ERROR,'操作失败');
- }
- /*
- * 楼盘预售证列表 - 页面
- * */
- public function actionPresell()
- {
- return $this->render('presell', ['get' => Yii::$app->request->get()]);
- }
- /*
- * 楼盘预售证列表 - 数据
- * */
- public function actionPresellform()
- {
- $model = new HousePermit();
- $rows = $model->getList(Yii::$app->request->post());
- if (!empty($rows)) {
- $model->hid = Yii::$app->request->post('hid');
- return Help::JsonData(0, Yii::t('app', 'get_success'), $model->Total(), $rows);
- }
- return Help::JsonCode(Help::ERROR, Yii::t('app', 'get_error'));
- }
- /*
- * 楼盘预售证添加 - 页面
- * */
- public function actionPreselladd()
- {
- return $this->render('preselladd', ['get' => Yii::$app->request->get()]);
- }
- /*
- * 楼盘预售证添加 -数据
- * */
- public function actionPreselladdform()
- {
- $model = new HousePermit();
- $auth = $model->Authenticator(Yii::$app->request->post());
- if (is_object($auth)) {
- if ($auth->save()) return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'add_success'));
- }
- return Help::JsonCode(Help::ERROR, Yii::t('app', 'add_error'), $auth);
- }
- /*
- * 楼盘预售证修改
- * */
- public function actionPreselledit()
- {
- $model = new HousePermit();
- $find = $model->FindById(Yii::$app->request->get('id'));
- return $this->render('preselledit', ['model' => $find]);
- }
- /*
- * 楼盘预售证修改 - 数据
- * */
- public function actionPreselleditform()
- {
- $model = new HousePermit();
- $input = Yii::$app->request->post();
- $row = $model->Authenticator($input);
- if (is_object($row)) {
- $find = $model->FindById($input['id']);
- if (!empty($find)) {
- $auth = Help::SetAttr($input, $row, $find);
- if ($auth->save()) return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'edit_success'));
- }
- }
- return Help::JsonCode(Help::ERROR, Yii::t('app', 'edit_error'), $row);
- }
- /*
- * 楼盘预售证删除
- * */
- public function actionPreselldel()
- {
- $model = new HousePermit();
- $del = $model->FindById(Yii::$app->request->post('id'));
- if (!empty($del)) {
- $del->del = 2;
- if ($del->save()) return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'edit_success'));
- }
- return Help::JsonCode(Help::ERROR, Yii::t('app', 'edit_error'));
- }
- }
|