123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281 |
- <?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\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;
- }
- }
|