12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301 |
- <?php
- /**
- * Created by PhpStorm.
- * User: xiaofeng
- * Date: 2018/3/13
- * Time: 上午8:46
- */
- namespace backend\controllers;
- use backend\base\CommonController;
- use backend\base\Help;
- use backend\server\NewsInformation;
- use common\models\CategoryCity;
- use common\models\PushHothouse;
- use common\models\HomeDiscount;
- use common\models\PushBottom;
- use common\models\PushCityprice;
- use common\models\PushSojourncity;
- use Yii;
- use common\models\PushRotation;
- use common\models\PushActivity;
- use common\models\PushChoice;
- use common\models\PushHousesale;
- use common\models\PushCity;
- use common\models\PushCharacteristic;
- use backend\server\UploadFile;
- class PushController extends CommonController
- {
- /*
- * 推送首页轮播
- * */
- public function actionRotation()
- {
- $cityModel = $this->City();
- return $this->render('rotation', ['city' => $cityModel]);
- }
- /*
- * 推送首页轮播数据
- * */
- public function actionRotationforms()
- {
- $model = new PushRotation();
- $rows = $model->getList(Yii::$app->request->post());
- if ($rows != null) {
- $imgUrl = Yii::$app->params['httpImg']['host'] . Yii::$app->params['httpImg']['push_lb'];
- foreach ($rows as &$val) {
- $val['create_at'] = date('Y-m-d H:i', $val['create_at']);
- $val['img'] = $imgUrl . $val['img'];
- }
- return Help::JsonData(0, Yii::t('app', 'get_success'), $model->Total(Yii::$app->request->post()), $rows);
- }
- return Help::JsonCode(Help::ERROR, Yii::t('app', 'get_error'));
- }
- /*
- * 推送首页轮播 - 添加页面
- */
- public function actionRotationadd()
- {
- $cityModel = $this->City();
- return $this->render('rotationadd', ['city' => $cityModel]);
- }
- /*
- * 推送首页轮播 - 添加数据
- */
- public function actionRotationform()
- {
- $model = new PushRotation();
- $input = Yii::$app->request->post();
- $model = $model->Authenticator($input);
- if (is_object($model)) {
- $url = Yii::$app->params['img_url']['push_lb'];
- $img = UploadFile::InstanceImgName('img', $url);
- if (is_string($img)) {
- $model->img = $img;
- //压缩图片
- $compressParams = [];
- $compressParams['data']['imgname'] = $img;;
- $compressParams['data']['url'] = $url;
- $compressParams['data']['source'] = '推送位,首页轮播图@添加';
- $ya = new \backend\event\TinifyEvent();
- $ya->CompressImg($compressParams);
- }
- if ($model->save(false)) return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'add_success'));
- }
- return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'add_error'), $model);
- }
- /*
- * 推送首页轮播 - 修改
- */
- public function actionRotationedit()
- {
- $model = new PushRotation();
- $input = Yii::$app->request->get();
- $row = $model->FindById($input['id']);
- if ($row != null) {
- $imgUrl = Yii::$app->params['httpImg']['host'] . Yii::$app->params['httpImg']['push_lb'];
- $row['img'] = $imgUrl . $row['img'];
- $cityModel = $this->City();
- foreach ($cityModel as &$val) {
- $val['checked'] = '';
- if ($val['id'] == $row['city']) {
- $val['checked'] = 'selected';
- }
- }
- return $this->render('rotationedit', ['model' => $row, 'city' => $cityModel]);
- }
- }
- /*
- * 推送首页轮播图 - 公用轮播图设定
- * */
- public function actionRotationuniversal()
- {
- $input = Yii::$app->request->post();
- $rows = PushRotation::findOne($input['id']);
- $rows->universal = $input['universal'];
- if ($rows->update(false)) return Help::JsonCode(Help::SUCCESS, '设置完成');
- return Help::JsonCode(Help::SUCCESS, '设置失败');
- }
- /*
- * 推送首页轮播 - 修改数据
- * */
- public function actionRotationeditform()
- {
- $model = new PushRotation();
- $input = Yii::$app->request->post();
- $setAttribute = $model->Authenticator($input);
- if (is_object($setAttribute)) {
- $row = $model->FindById($input['id']);
- if ($row != null) {
- $row = Help::SetAttr($input, $model, $row);
- $url = Yii::$app->params['img_url']['push_lb'];
- $img = UploadFile::InstanceImgName('img', $url);
- if (is_string($img)) {
- UploadFile::delImg($url, $row->img);
- $row->img = $img;
- //压缩图片
- $compressParams = [];
- $compressParams['data']['imgname'] = $img;;
- $compressParams['data']['url'] = $url;
- $compressParams['data']['source'] = '推送位,首页轮播图@修改';
- $ya = new \backend\event\TinifyEvent();
- $ya->CompressImg($compressParams);
- }
- if ($row->save(false)) return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'edit_success'));
- }
- }
- return Help::JsonCode(Help::ERROR, Yii::t('app', 'edit_error'), $setAttribute);
- }
- /*
- * 推送首页轮播 - 删除 and 禁用
- * */
- public function actionImgdelshow()
- {
- $model = new PushRotation();
- $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 'sort':
- if (is_numeric($input['sort'])) {
- $row->sort = $input['sort'];
- }
- break;
- case 'del':
- $row->del = 2;
- break;
- case 'expiration':
- $row->expiration_date = $input['expiration'];
- 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 actionImgdelall()
- {
- $input = Yii::$app->request->post();
- $model = PushRotation::find()->where(['in', 'id', $input['id']])->all();
- $delall = PushRotation::deleteAll(['id' => $input['id']]);
- if ($delall) {
- foreach ($model as $value) {
- UploadFile::delImg(Yii::$app->params['img_url']['push_lb'], $value['img']);
- }
- return Help::JsonCode(Help::SUCCESS, '批量删除成功');
- }
- return Help::JsonCode(Help::ERROR, '批量删除失败');
- }
- /*
- * 首页-热门活动 -列表
- * */
- public function actionHotactivity()
- {
- $city = $this->City();
- return $this->render('hotactivity', ['city' => $city]);
- }
- public function actionHotactivityform()
- {
- $model = new PushActivity();
- $input = Yii::$app->request->post();
- $rows = $model->getList($input);
- if ($rows != null) {
- $url = Yii::$app->params['httpImg']['host'] . Yii::$app->params['httpImg']['hot_activity'];
- foreach ($rows as &$val) {
- $val['create_at'] = date('Y-m-d H:i', $val['create_at']);
- $val['img'] = $url . $val['img'];
- }
- return Help::JsonData(0, Yii::t('app', 'get_success'), $model->Total($input), $rows);
- }
- return Help::JsonData(Help::ERROR, Yii::t('app', 'get_error'), 0);
- }
- /*
- * 首页-热门活动 - 添加页面
- */
- public function actionHotactivityadd()
- {
- $cityModel = $this->City();
- return $this->render('hotactivityadd', ['city' => $cityModel]);
- }
- /*
- * 首页-热门活动 - 添加数据
- * */
- public function actionHotactivityaddform()
- {
- $model = new PushActivity();
- $input = Yii::$app->request->post();
- $auth = $model->Authenticator($input);
- if (is_object($auth)) {
- $url = Yii::$app->params['img_url']['hot_activity'];
- $img = UploadFile::InstanceImgName('img', $url);
- if (is_string($img)) {
- $auth->img = $img;
- //压缩图片
- $compressParams = [];
- $compressParams['data']['imgname'] = $img;;
- $compressParams['data']['url'] = $url;
- $compressParams['data']['source'] = '推送位,首页热门活动@添加';
- $ya = new \backend\event\TinifyEvent();
- $ya->CompressImg($compressParams);
- }
- if ($auth->save(false)) return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'add_success'));
- }
- return Help::JsonCode(Help::ERROR, Yii::t('app', 'add_error'), $auth);
- }
- /*
- * 推送热门活动 - 修改页面
- */
- public function actionHotactivityedit()
- {
- $model = new PushActivity();
- $row = $model->FindById(Yii::$app->request->get('id'));
- if ($row != null) {
- $cityModel = $this->City();
- foreach ($cityModel as &$val) {
- $val['checked'] = '';
- if ($val['id'] == $row['city']) {
- $val['checked'] = 'selected';
- }
- }
- $row['img'] = Yii::$app->params['httpImg']['host'] . Yii::$app->params['httpImg']['hot_activity'] . $row['img'];
- return $this->render('hotactivityedit', ['model' => $row, 'city' => $cityModel]);
- }
- }
- /*
- * 推送热门活动 - 修改数据
- * */
- public function actionHotactivityeditform()
- {
- $model = new PushActivity();
- $input = Yii::$app->request->post();
- $setAttribute = $model->Authenticator($input);
- if (is_object($setAttribute)) {
- $row = $model->FindById($input['id']);
- if ($row != null) {
- $row = Help::SetAttr($input, $model, $row);
- $url = Yii::$app->params['img_url']['hot_activity'];
- $img = UploadFile::InstanceImgName('img', $url);
- if (is_string($img)) {
- UploadFile::delImg($url, $row->img);
- $row->img = $img;
- //压缩图片
- $compressParams = [];
- $compressParams['data']['imgname'] = $img;;
- $compressParams['data']['url'] = $url;
- $compressParams['data']['source'] = '推送位,首页热门活动@修改';
- $ya = new \backend\event\TinifyEvent();
- $ya->CompressImg($compressParams);
- }
- if ($row->save(false)) return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'edit_success'));
- }
- }
- return Help::JsonCode(Help::ERROR, Yii::t('app', 'edit_error'), $setAttribute);
- }
- /*
- * 推送首页轮播 - 删除 and 禁用
- * */
- public function actionHotactivitydelshow()
- {
- $model = new PushActivity();
- $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 'expiration':
- $row->expiration_date = $input['expiration'];
- 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 actionHotactivitydelall()
- {
- $input = Yii::$app->request->post();
- $model = PushActivity::find()->where(['in', 'id', $input['id']])->all();
- $delall = PushActivity::deleteAll(['id' => $input['id']]);
- if ($delall) {
- foreach ($model as $value) {
- UploadFile::delImg(Yii::$app->params['img_url']['hot_activity'], $value['img']);
- }
- return Help::JsonCode(Help::SUCCESS, '批量删除成功');
- }
- return Help::JsonCode(Help::ERROR, '批量删除失败');
- }
- /*
- * 推送本周精选
- * */
- public function actionChoice()
- {
- $city = $this->City();
- return $this->render('choice', ['city' => $city]);
- }
- /*
- * 推送本周精选 数据列表
- * */
- public function actionChoiceform()
- {
- $model = new PushChoice();
- $input = Yii::$app->request->post();
- $rows = $model->getList($input);
- if ($rows != null) {
- $url = Yii::$app->params['httpImg']['host'] . Yii::$app->params['httpImg']['choice'];
- foreach ($rows as &$val) {
- $val['create_at'] = date('Y-m-d H:i', $val['create_at']);
- $val['img'] = $url . $val['img'];
- }
- return Help::JsonData(0, Yii::t('app', 'get_success'), $model->Total($input), $rows);
- }
- return Help::JsonCode(Help::ERROR, Yii::t('app', 'get_error'));
- }
- /*
- * 推送本周精选 - 添加
- */
- public function actionChoiceadd()
- {
- $cityModel = $this->City();
- return $this->render('choiceadd', ['city' => $cityModel]);
- }
- /*
- * 推送本周精选 - 添加数据
- */
- public function actionChoiceaddform()
- {
- $model = new PushChoice();
- $input = Yii::$app->request->post();
- $auth = $model->Authenticator($input);
- if (is_object($auth)) {
- $url = Yii::$app->params['img_url']['choice'];
- $img = UploadFile::InstanceImgName('img', $url);
- if (is_string($img)) {
- $auth->img = $img;
- //压缩图片
- $compressParams = [];
- $compressParams['data']['imgname'] = $img;;
- $compressParams['data']['url'] = $url;
- $compressParams['data']['source'] = '推送位,首页本周精选@添加';
- $ya = new \backend\event\TinifyEvent();
- $ya->CompressImg($compressParams);
- }
- if ($auth->save(false)) return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'add_success'));
- }
- return Help::JsonCode(Help::ERROR, Yii::t('app', 'add_error'), $auth);
- }
- /*
- * 推送本周精选 - 修改
- */
- public function actionChoiceedit()
- {
- $model = new PushChoice();
- $row = $model->FindById(Yii::$app->request->get('id'));
- if ($row != null) {
- $cityModel = $this->City();
- foreach ($cityModel as &$val) {
- $val['checked'] = '';
- if ($val['id'] == $row['city']) {
- $val['checked'] = 'selected';
- }
- }
- $row['img'] = Yii::$app->params['httpImg']['host'] . Yii::$app->params['httpImg']['choice'] . $row['img'];
- return $this->render('choiceedit', ['model' => $row, 'city' => $cityModel]);
- }
- }
- /*
- * 推送本周精选 - 修改
- */
- public function actionChoiceeditform()
- {
- $model = new PushChoice();
- $input = Yii::$app->request->post();
- $setAttribute = $model->Authenticator($input);
- if (is_object($setAttribute)) {
- $row = $model->FindById($input['id']);
- if ($row != null) {
- $row = Help::SetAttr($input, $model, $row);
- $url = Yii::$app->params['img_url']['choice'];
- $img = UploadFile::InstanceImgName('img', $url);
- if (is_string($img)) {
- UploadFile::delImg($url, $row->img);
- $row->img = $img;
- //压缩图片
- $compressParams = [];
- $compressParams['data']['imgname'] = $img;;
- $compressParams['data']['url'] = $url;
- $compressParams['data']['source'] = '推送位,首页本周精选@修改';
- $ya = new \backend\event\TinifyEvent();
- $ya->CompressImg($compressParams);
- }
- if ($row->save(false)) return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'edit_success'));
- }
- }
- return Help::JsonCode(Help::ERROR, Yii::t('app', 'edit_error'), $setAttribute);
- }
- /*
- * 首页-精选 - 删除 and 禁用
- * */
- public function actionChoicedelshow()
- {
- $model = new PushChoice();
- $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 'expiration':
- $row->expiration_date = $input['expiration'];
- 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 actionChoicedelall()
- {
- $input = Yii::$app->request->post();
- $model = PushChoice::find()->where(['in', 'id', $input['id']])->all();
- $delall = PushChoice::deleteAll(['id' => $input['id']]);
- if ($delall) {
- foreach ($model as $value) {
- UploadFile::delImg(Yii::$app->params['img_url']['choice'], $value['img']);
- }
- return Help::JsonCode(Help::SUCCESS, '批量删除成功');
- }
- return Help::JsonCode(Help::ERROR, '批量删除失败');
- }
- /*
- * 推送热销楼盘 - 页面
- * */
- public function actionHotsale()
- {
- return $this->render('hotsale', ['type' => 1]);
- }
- /*
- * 推送热销楼盘 - 数据
- * */
- public function actionHotsaleform()
- {
- $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 actionHotsaleadd()
- {
- return $this->render('hotsaleadd', ['type' => Yii::$app->request->get('type')]);
- }
- public function actionHotsaleaddform()
- {
- $input = Yii::$app->request->post();
- $model = new PushHousesale();
- $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 actionHotsaledelall()
- {
- $input = Yii::$app->request->post();
- $delall = PushHousesale::deleteAll(['id' => $input['hid']]);
- if ($delall) {
- return Help::JsonCode(Help::SUCCESS, '批量删除成功');
- }
- return Help::JsonCode(Help::ERROR, '批量删除失败');
- }
- /*
- * 首页-精选 - 删除 and 禁用
- * */
- public function actionSaledelshow()
- {
- $model = new PushHousesale();
- $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 actionHotcity()
- {
- return $this->render('hotcity');
- }
- /*
- * 首页-热门区域-数据列表
- * */
- public function actionHotcityform()
- {
- $model = new PushCity();
- $input = Yii::$app->request->post();
- $rows = $model->getList($input);
- if (!empty($rows)) {
- foreach ($rows as &$val) {
- $val['create_at'] = date('Y-m-d H:i', $val['create_at']);
- }
- return Help::JsonData(0, '成功', $model->Total(), $rows);
- }
- }
- /*
- * 首页-热门区域-数据列表
- * */
- public function actionHotcityadd()
- {
- return $this->render('hotcityadd');
- }
- /*
- * 首页-热门区域-数据列表
- * */
- public function actionHotcityaddform()
- {
- $model = new PushCity();
- $input = Yii::$app->request->post();
- $auth = $model->Authenticator($input);
- if (is_object($auth)) {
- if (!empty($input)) {
- $arrData = [];
- $rows = $model->getList($input);
- if (!empty($rows)) {
- return Help::JsonCode(Help::ERROR, '请查看是否有重复添加的区域');
- }
- foreach ($input['city_id'] as $key => $val) {
- $arrData[$key]['city_id'] = $val;
- $arrData[$key]['sort'] = 0;
- $arrData[$key]['is_show'] = 1;
- $arrData[$key]['del'] = 1;
- $arrData[$key]['create_at'] = $_SERVER['REQUEST_TIME'];
- $arrData[$key]['update_at'] = $_SERVER['REQUEST_TIME'];
- }
- $result = Yii::$app->db->createCommand()->batchInsert($model::tableName(), ['city_id', 'sort', 'is_show', 'del', 'create_at', 'update_at'], $arrData)->execute();
- if ($result > 0) {
- return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'add_success'));
- }
- }
- }
- return Help::JsonCode(Help::ERROR, Yii::t('app', 'add_error'), $auth);
- }
- /*
- * 首页-精选 - 删除 and 禁用
- * */
- public function actionCitydelshow()
- {
- $model = new PushCity();
- $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':
- if ($row->delete()) {
- return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'edit_success'));
- }
- break;
- case 'sort':
- if (!is_numeric($input['sort'])) {
- return Help::JsonCode(Help::ERROR, '请输入数字');
- }
- $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 actionCharacteristic()
- {
- return $this->render('characteristic');
- }
- /*
- * 首页-特色类型 数据
- * */
- public function actionCharacteristicform()
- {
- $model = new PushCharacteristic();
- $input = Yii::$app->request->post();
- $rows = $model->getList($input);
- if (!empty($rows)) {
- $url = Yii::$app->params['httpImg']['host'] . Yii::$app->params['httpImg']['characteristic'];
- foreach ($rows as &$val) {
- $val['create_at'] = date('Y-m-d H:i', $val['create_at']);
- $val['img'] = $url . $val['img'];
- }
- return Help::JsonData(0, Yii::t('app', 'get_success'), $model->Total(), $rows);
- }
- }
- /*
- * 首页-特色类型 添加页面
- * */
- public function actionCharacteristicadd()
- {
- return $this->render('characteristicadd');
- }
- /*
- * 首页-特色类型 添加页面
- * */
- public function actionCharacteristicaddform()
- {
- $model = new PushCharacteristic();
- $input = Yii::$app->request->post();
- $auth = $model->Authenticator($input);
- if (is_object($auth)) {
- $url = Yii::$app->params['img_url']['characteristic'];
- $imgStr = UploadFile::InstanceImgName('img', $url);
- if (is_string($imgStr)) {
- $auth->img = $imgStr;
- }
- if ($auth->save(false)) return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'add_success'));
- }
- return Help::JsonCode(Help::ERROR, Yii::t('app', 'add_error'), $auth);
- }
- /*
- * 首页-特色类型 修改页面
- * */
- public function actionCharacteristicedit()
- {
- $model = new PushCharacteristic();
- $row = $model->FindById(Yii::$app->request->get('id'));
- if ($row != null) {
- $row['img'] = Yii::$app->params['httpImg']['host'] . Yii::$app->params['httpImg']['characteristic'] . $row['img'];
- return $this->render('characteristicedit', ['model' => $row, 'get' => Yii::$app->request->get()]);
- }
- }
- /*
- * 首页-特色类型 修改页面
- * */
- public function actionCharacteristiceditform()
- {
- $model = new PushCharacteristic();
- $input = Yii::$app->request->post();
- $auth = $model->Authenticator($input);
- if (is_object($auth)) {
- $row = $model->FindById($input['id']);
- if (!empty($row)) {
- $url = Yii::$app->params['img_url']['characteristic'];
- $imgStr = UploadFile::InstanceImgName('img', $url);
- $result = Help::SetAttr($input, $auth, $row);
- if (is_string($imgStr)) {
- UploadFile::delImg($url, $row['img']);
- $result->img = $imgStr;
- }
- if ($result->save(false)) return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'edit_success'));
- }
- }
- return Help::JsonCode(Help::ERROR, Yii::t('app', 'edit_error'), $auth);
- }
- /*
- * 首页-特色类型 - 删除 and 禁用
- * */
- public function actionCharacteristicdelshow()
- {
- $model = new PushCharacteristic();
- $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':
- if (!empty($row->img)) {
- UploadFile::delImg(Yii::$app->params['img_url']['characteristic'], $row->img);
- }
- if ($row->delete()) {
- return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'edit_success'));
- }
- break;
- case 'sort':
- if (!is_numeric($input['sort'])) {
- return Help::JsonCode(Help::ERROR, '请输入数字');
- }
- $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 actionSojourncity()
- {
- return $this->render('sojourncity');
- }
- /**
- * 首页 - 旅居城市 数据
- */
- public function actionSojourncityform()
- {
- $model = new PushSojourncity();
- $rows = $model->getList(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);
- }
- return Help::JsonCode(Help::ERROR, Yii::t('app', 'get_error'));
- }
- /**
- * 首页 - 旅居城市 添加页面
- */
- public function actionSojourncityadd()
- {
- return $this->render('sojourncityadd');
- }
- /**
- * 首页 - 旅居城市 添加数据
- */
- public function actionSojourncityaddform()
- {
- $model = new PushSojourncity();
- $model->scenario = 'add';
- $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);
- }
- /**
- * 首页 - 旅居城市 删除AND 隐藏
- */
- public function actionSojourncitydelshow()
- {
- $model = new PushSojourncity();
- $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':
- if ($row->delete()) {
- return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'edit_success'));
- }
- break;
- case 'sort':
- if (!is_numeric($input['sort'])) {
- return Help::JsonCode(Help::ERROR, '请输入数字');
- }
- $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 actionSojourncitydelall()
- {
- $input = Yii::$app->request->post();
- $delall = PushSojourncity::deleteAll(['id' => $input['id']]);
- if ($delall) {
- return Help::JsonCode(Help::SUCCESS, '批量删除成功');
- }
- return Help::JsonCode(Help::ERROR, '批量删除失败');
- }
- /*------------------------------------底部横幅-----------------------------------------------------*/
- //底部横幅页面
- public function actionBottom()
- {
- $city = $this->City();
- return $this->render('bottom', ['city' => $city]);
- }
- //底部横幅页面 - 数据
- public function actionBottomform()
- {
- $model = new PushBottom();
- $row = $model->getList(Yii::$app->request->post());
- if ($row != null) {
- foreach ($row as &$val) {
- $val['create_at'] = date('Y-m-d H:i', $val['create_at']);
- $val['img'] = Yii::$app->params['httpImg']['host'] . Yii::$app->params['httpImg']['bottom'] . $val['img'];
- $val['img_small'] = Yii::$app->params['httpImg']['host'] . Yii::$app->params['httpImg']['bottom'] . $val['img_small'];
- }
- return Help::JsonData(0, Yii::t('app', 'get_success'), $model->Total(Yii::$app->request->post()), $row);
- }
- return Help::JsonCode(Help::ERROR, Yii::t('app', 'get_error'));
- }
- //底部横幅 - 添加页面
- public function actionBottomadd()
- {
- $city = new CategoryCity();
- $pidcity = $this->City();
- $city->pid = 0;
- $soncity = $city->SortgetList([]);
- return $this->render('bottomadd', ['pidcity' => $pidcity, 'city' => $soncity]);
- }
- //底部横幅 - 添加数据
- public function actionBottomaddform()
- {
- $model = new PushBottom();
- $input = Yii::$app->request->post();
- $model = $model->Authenticator($input);
- if (is_object($model)) {
- $url = Yii::$app->params['img_url']['bottom'];
- $img = UploadFile::InstanceImgName('img', $url);
- if (is_string($img)) {
- $model->img = $img;
- }
- $img_small = UploadFile::InstanceImgName('img_small', $url);
- if (is_string($img_small)) {
- $model->img_small = $img_small;
- }
- if ($model->save(false)) return Help::JsonCode(Help::SUCCESS, '添加成功');
- }
- return Help::JsonCode(Help::ERROR, '添加失败');
- }
- //底部横幅 - 修改页面
- public function actionBottomedit()
- {
- $model = new PushBottom();
- $row = $model->FindById(Yii::$app->request->get('id'));
- if ($row != null) {
- $row['img'] = Yii::$app->params['httpImg']['host'] . Yii::$app->params['httpImg']['bottom'] . $row['img'];
- $row['img_small'] = Yii::$app->params['httpImg']['host'] . Yii::$app->params['httpImg']['bottom'] . $row['img_small'];
- $city = new CategoryCity();
- $pidcity = $this->City();
- $city->pid = 0;
- $soncity = $city->SortgetList([]);
- return $this->render('bottomedit', ['row' => $row, 'pidcity' => $pidcity, 'city' => $soncity]);
- }
- }
- //底部横幅 - 公共横幅设置
- public function actionBottomuniversal()
- {
- $input = Yii::$app->request->post();
- $rows = PushBottom::findOne($input['id']);
- $rows->universal = $input['universal'];
- if ($rows->update(false)) return Help::JsonCode(Help::SUCCESS, '设置完成');
- return Help::JsonCode(Help::SUCCESS, '设置失败');
- }
- //底部横幅 - 修改数据
- public function actionBottomeditform()
- {
- $model = new PushBottom();
- $row = $model->FindById(Yii::$app->request->post('id'));
- if ($row != null) {
- $url = Yii::$app->params['img_url']['bottom'];
- $img = UploadFile::InstanceImgName('img', $url);
- if (is_string($img)) {
- UploadFile::delImg($url, $row->img);
- $row->img = $img;
- }
- $img_small = UploadFile::InstanceImgName('img_small', $url);
- if (is_string($img_small)) {
- UploadFile::delImg($url, $row->img_small);
- $row->img_small = $img_small;
- }
- if ($row->load(Yii::$app->request->post(), '') && $row->update(false))
- return Help::JsonCode(Help::SUCCESS, '修改成功');
- }
- return Help::JsonCode(Help::ERROR, '修改失败');
- }
- //底部横幅 - 审核&排序&删除
- public function actionBottomdelshow()
- {
- $model = new PushBottom();
- $input = Yii::$app->request->post();
- $row = $model->FindById($input['id']);
- $rows = PushBottom::find()->select(['id', 'img_show'])->andWhere(['<>', 'id', $row['id']])->asArray()->all();
- if ($row != null) {
- switch ($input['type']) {
- case 'del':
- if (!empty($row->img)) {
- UploadFile::delImg(Yii::$app->params['img_url']['bottom'], $row->img);
- }
- if (!empty($row->img_small)) {
- UploadFile::delImg(Yii::$app->params['img_url']['bottom'], $row->img_small);
- }
- if ($row->delete()) {
- return Help::JsonCode(Help::SUCCESS, '删除成功');
- }
- break;
- case 'show':
- if ($row->is_show == 1) {
- $row->is_show = 2;
- } else {
- $row->is_show = 1;
- }
- break;
- case 'state':
- if ($row->state == 1) {
- $row->state = 2;
- } else {
- $row->state = 1;
- }
- break;
- case 'img_show':
- if ($row->img_show == 2) {
- $row->img_show = 1;
- foreach ($rows as $val) {
- $query = PushBottom::findOne($val['id']);
- if ($query) {
- if ($query->img_show == 1) {
- $query->img_show = 2;
- $query->save(false);
- }
- }
- }
- } else {
- $row->img_show = 2;
- }
- break;
- case 'sort':
- if (!is_numeric($input['sort'])) {
- return Help::JsonCode(Help::ERROR, '请输入数字');
- }
- $row->sort = $input['sort'];
- break;
- }
- if ($row->save()) return Help::JsonCode(Help::SUCCESS, '操作成功');
- }
- return Help::JsonCode(Help::ERROR, '操作失败');
- }
- //底部横幅 - 批量删除
- public function actionBottomdelall()
- {
- $input = Yii::$app->request->post();
- $model = PushBottom::find()->where(['IN', 'id', $input['id']])->asArray()->all();
- $del = PushBottom::deleteAll(['id' => $input['id']]);
- if ($del) {
- foreach ($model as $val) {
- UploadFile::delImg(Yii::$app->params['img_url']['bottom'], $val['img']);
- UploadFile::delImg(Yii::$app->params['img_url']['bottom'], $val['img_small']);
- }
- return Help::JsonCode(Help::SUCCESS, '批量删除成功');
- }
- return Help::JsonCode(Help::ERROR, '批量删除失败');
- }
- /*------------------------------------楼盘首页优惠推荐-----------------------------------------------------*/
- public function actionHomediscount()
- {
- return $this->render('homediscount');
- }
- public function actionHomediscountform()
- {
- $model = new HomeDiscount();
- $rows = $model->getList(Yii::$app->request->post());
- if ($rows != null) {
- 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(Yii::$app->request->post()), $rows);
- }
- return Help::JsonCode(Help::ERROR, Yii::t('app', 'get_error'));
- }
- public function actionHomediscountadd()
- {
- return $this->render('homediscountadd');
- }
- public function actionHomediscountaddform()
- {
- $model = new HomeDiscount();
- $model->scenario = 'add';
- $input = Yii::$app->request->post();
- if (!empty($input)) {
- if ($model->load($input, '') && $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 actionHomediscountedit()
- {
- $model = new HomeDiscount();
- $input = Yii::$app->request->get();
- $row = $model->FindById($input['id']);
- if ($row != null) {
- return $this->render('homediscountedit', ['model' => $row]);
- }
- }
- public function actionHomediscounteditform()
- {
- $model = new HomeDiscount();
- $input = Yii::$app->request->post();
- $row = $model->FindById($input['id']);
- $row->scenario = 'edit';
- if ($row != null) {
- if ($row->load($input, '') && $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 actionSethomediscount()
- {
- $model = new HomeDiscount();
- $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 'sort':
- if (is_numeric($input['sort'])) {
- $row->sort = $input['sort'];
- }
- break;
- case 'del':
- if ($row->delete()) return Help::JsonCode(Help::SUCCESS, '删除成功');
- 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'));
- }
- /*******************************************************************************************************/
- private function City()
- {
- $city = new \common\models\CategoryCity();
- $city->state = 1;
- $city->pid = 0;
- $cityModel = $city->getList([]);
- return $cityModel;
- }
-
-
- /**
- * 推送楼盘数据
- * @return mixed
- */
- public function actionHothouseform()
- {
- $model = new PushHothouse();
- $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'));
- }
- }
|