123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239 |
- <?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\Developers;
- use common\models\House;
- use common\models\PushmMansion;
- use Yii;
- use common\models\PushmRotation;
- use common\models\PushmVilla;
- use common\models\PushmMenu;
- use common\models\PushmRecommend;
- use common\models\PushChoice;
- use common\models\PushmHouse;
- use common\models\PushmCity;
- use common\models\PushmTimelimitsgroup;
- use common\models\PushmCharacteristic;
- use backend\server\UploadFile;
- /*
- * 热门区域 type = 1
- * 首页-拨打电话号码- 随机区域 type = 2
- *
- * */
- class PushmController extends CommonController
- {
- /*
- * 豪宅专区
- * */
- public function actionMansion ()
- {
- return $this->render( 'mansion' );
- }
-
- /*
- * 豪宅专区 - 数据
- * */
- public function actionMansionform ()
- {
- $model = new PushmMansion();
- $input = Yii::$app->request->post();
- $rows = $model->getList( $input );
-
- if ( $rows != null ) {
- $imgUrl = Yii::$app->params[ 'httpImg' ][ 'host' ] . Yii::$app->params[ 'httpImg' ][ 'housealbum' ];
- 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 actionMansionadd ()
- {
- $developers = $this->Developers();
- return $this->render( 'mansionadd' , [ 'developers' => $developers ] );
- }
-
- /*
- * 豪宅专区 - 添加页面 - 添加数据
- * */
- public function actionMansionaddform ()
- {
- $model = new PushmMansion();
- $input = Yii::$app->request->post();
-
- if ( $input != null ) {
- $url = Yii::$app->params[ 'img_url' ][ 'housealbum' ];
- $img = UploadFile::InstanceImgName( 'img' , $url );
-
- if ( is_string( $img ) ) {
- $model->img = $img;
- }
-
- if ( $model->load( $input , '' ) && $model->save( false ) ) return Help::JsonCode( Help::SUCCESS , '添加成功' );
- }
- return Help::JsonCode( Help::ERROR , '添加失败' );
- }
-
- /*
- * 豪宅专区 - 修改页面
- * */
- public function actionMansionedit ()
- {
- $model = new PushmMansion();
- $input = Yii::$app->request->get();
- $row = $model->FindById( $input[ 'id' ] );
-
- if ( $row != null ) {
- $house = new House();
- $house = $house->FindById( $row[ 'hid' ] );
-
- $developers = $this->Developers();
- foreach ( $developers as &$val ) {
- $val[ 'checked' ] = '';
- if ( $val[ 'id' ] == $row[ 'did' ] ) {
- $val[ 'checked' ] = 'selected';
- }
- }
-
- $imgUrl = Yii::$app->params[ 'httpImg' ][ 'host' ] . Yii::$app->params[ 'httpImg' ][ 'housealbum' ];
- $row[ 'img' ] = $imgUrl . $row[ 'img' ];
-
- return $this->render( 'mansionedit' , [ 'model' => $row , 'house' => $house , 'developers' => $developers ] );
- }
- }
-
- /*
- * 豪宅专区 - 修改页面 - 修改数据
- * */
- public function actionMansioneditform ()
- {
- $model = new PushmMansion();
- $input = Yii::$app->request->post();
- $row = $model->FindById( $input[ 'id' ] );
-
- if ( $row != null ) {
- $url = Yii::$app->params[ 'img_url' ][ 'housealbum' ];
- $img = UploadFile::InstanceImgName( 'img' , $url );
-
- if ( is_string( $img ) ) {
- UploadFile::delImg( $url , $row->img );
- $row->img = $img;
- }
-
- if ( $row->load( $input , '' ) && $row->update() == true ) return Help::JsonCode( Help::SUCCESS , '修改成功' );
- }
-
- return Help::JsonCode( Help::ERROR , '修改失败' );
- }
-
- /*
- * 豪宅专区 - 审核排序删除
- * */
- public function actionMansiondelshow ()
- {
- $model = new PushmMansion();
- $input = Yii::$app->request->post();
- $row = $model->FindById( $input[ 'id' ] );
-
- if ( $row != null ) {
- switch ( $input[ 'type' ] ) {
- case 'sort':
- $row->sort = $input[ 'sort' ];
- break;
-
- case 'show':
- if ( $row->is_show == 1 ) {
- $row->is_show = 2;
- } else {
- $row->is_show = 1;
- }
- break;
-
- case 'del':
- if ( !empty( $row->img ) ) {
- UploadFile::delImg( Yii::$app->params[ 'img_url' ][ 'housealbum' ] , $row->img );
- }
- if ( $row->delete() ) {
- return Help::JsonCode( Help::SUCCESS , '删除成功' );
- }
- break;
- }
- if ( $row->update( false ) ) return Help::JsonCode( Help::SUCCESS , '修改成功' );
- }
-
- return Help::JsonCode( Help::ERROR , '修改失败' );
- }
-
- /*
- * 豪宅专区 - 批量删除
- * */
- public function actionMansiondelall ()
- {
- $input = Yii::$app->request->post();
- $model = PushmMansion::find()->where( [ 'in' , 'id' , $input[ 'id' ] ] )->all();
- $delall = PushmMansion::deleteAll( [ 'id' => $input[ 'id' ] ] );
-
- if ( $delall ) {
- foreach ( $model as $value ) {
- UploadFile::delImg( Yii::$app->params[ 'img_url' ][ 'housealbum' ] , $value[ 'img' ] );
- }
- return Help::JsonCode( Help::SUCCESS , '批量删除成功' );
- }
- return Help::JsonCode( Help::ERROR , '批量删除失败' );
- }
-
-
- /*
- * 推送首页轮播
- * */
- public function actionRotation ()
- {
- $city = $this->City();
- return $this->render( 'rotation' , [ 'city' => $city ] );
- }
-
- /*
- * 推送首页轮播数据
- * */
- public function actionRotationforms ()
- {
- $model = new PushmRotation();
- $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 ()
- {
- try {
- $model = new PushmRotation();
- $input = Yii::$app->request->post();
- $url = Yii::$app->params[ 'img_url' ][ 'push_lb' ];
- $img = UploadFile::InstanceImgName_v1( 'img' , $url );
- if ( is_string( $img ) ) {
- $input[ 'img' ] = $img;
- }
- $model->load( $input , '' );
- if ( $model->save() ) return Help::JsonCode( Help::SUCCESS , Yii::t( 'app' , 'add_success' ) );
- return Help::JsonCode( Help::SUCCESS , Yii::t( 'app' , 'add_error' ) , $model->errors );
- } catch ( \Exception $e ) {
- return Help::JsonCode( Help::SUCCESS , Yii::t( 'app' , 'add_error' ) , $e->getMessage() );
-
- }
-
- }
-
- /*
- * 推送首页轮播 - 修改
- */
- public function actionRotationedit ()
- {
- $model = new PushmRotation();
- $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 actionRotationeditform ()
- {
- $model = new PushmRotation();
- $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;
- }
- 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 PushmRotation();
- $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() ) {
- UploadFile::delImg( Yii::$app->params[ 'img_url' ][ 'push_lb' ] , $row->img );
- return Help::JsonCode( Help::SUCCESS , Yii::t( 'app' , 'edit_success' ) );
- }
- 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 actionVilla ()
- {
- return $this->render( 'villa' );
- }
-
- /*
- * 推送首页轮播数据
- * */
- public function actionVillaforms ()
- {
- $model = new PushmVilla();
- $rows = $model->getList( Yii::$app->request->post() );
- if ( $rows != null ) {
- $imgUrl = Yii::$app->params[ 'httpImg' ][ 'host' ] . Yii::$app->params[ 'httpImg' ][ 'villa' ];
- 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() , $rows );
- }
- return Help::JsonCode( Help::ERROR , Yii::t( 'app' , 'get_error' ) );
- }
-
- /*
- * 推送首页轮播 - 添加页面
- */
- public function actionVillaadd ()
- {
- $cityModel = $this->City();
- $developers = $this->Developers();
- return $this->render( 'villaadd' , [ 'city' => $cityModel , 'developers' => $developers ] );
- }
-
- /*
- * 推送首页轮播 - 添加数据
- */
- public function actionVillaform ()
- {
- $model = new PushmVilla();
- $input = Yii::$app->request->post();
- $model = $model->Authenticator( $input );
- if ( is_object( $model ) ) {
- $url = Yii::$app->params[ 'img_url' ][ 'villa' ];
- $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 actionVillaedit ()
- {
- $model = new PushmVilla();
- $input = Yii::$app->request->get();
- $row = $model->FindById( $input[ 'id' ] );
- if ( $row != null ) {
- $imgUrl = Yii::$app->params[ 'httpImg' ][ 'host' ] . Yii::$app->params[ 'httpImg' ][ 'villa' ];
- $row[ 'img' ] = $imgUrl . $row[ 'img' ];
- $cityModel = $this->City();
- $developers = $this->Developers();
- foreach ( $cityModel as &$val ) {
- $val[ 'checked' ] = '';
- if ( $val[ 'id' ] == $row[ 'city' ] ) {
- $val[ 'checked' ] = 'selected';
- }
- }
- foreach ( $developers as &$val ) {
- $val[ 'checked' ] = '';
- if ( $val[ 'id' ] == $row[ 'developers' ] ) {
- $val[ 'checked' ] = 'selected';
- }
- }
- return $this->render( 'villaedit' , [ 'model' => $row , 'city' => $cityModel , 'developers' => $developers ] );
- }
- }
-
- /*
- * 推送首页轮播 - 修改数据
- * */
- public function actionVillaeditform ()
- {
- $model = new PushmVilla();
- $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' ][ 'villa' ];
- $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 actionVillaimgdelshow ()
- {
- $model = new PushmVilla();
- $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;
- }
- 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 actionRecommend ()
- {
-
- return $this->render( 'recommend' );
- }
-
- public function actionRecommendform ()
- {
- $model = new PushmRecommend();
- $input = Yii::$app->request->post();
- $rows = $model->getList( $input );
- 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() , $rows );
- }
- return Help::JsonData( Help::ERROR , Yii::t( 'app' , 'get_error' ) , 0 );
- }
-
- /*
- * 移动端导航推荐
- * */
- public function actionMenu ()
- {
- return $this->render( 'menu' );
- }
-
- /*
- * 推送移动端导航推荐
- * */
- public function actionMenuforms ()
- {
- $model = new PushmMenu();
- $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() , $rows );
- }
- return Help::JsonCode( Help::ERROR , Yii::t( 'app' , 'get_error' ) );
- }
-
- /*
- * 推送移动端导航推荐 - 添加页面
- */
- public function actionMenuadd ()
- {
- $cityModel = $this->City();
- $menu = $this->parentMenu();
- return $this->render( 'menuadd' , [ 'city' => $cityModel , 'menu' => $menu ] );
- }
-
- //*获取父级菜单*/
- private function parentMenu ()
- {
- $frontend = new \common\models\Frontend();
- //$menu=$frontend->PidList(0)
- return $frontend->PidList( 0 );
- }
-
- /*
- * 推送移动端导航推荐
- */
- public function actionMenuform ()
- {
- $model = new PushmMenu();
- $input = Yii::$app->request->post();
- $model = $model->Authenticator( $input );
- if ( is_object( $model ) ) {
- 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 actionMenudel ()
- {
- $model = new PushmMenu();
- $input = Yii::$app->request->post();
- $row = $model->FindById( $input[ 'id' ] );
- if ( $row != null ) {
- switch ( $input[ 'type' ] ) {
- case 'del':
- $row->del = 2;
- 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 actionRecommendadd ()
- {
- return $this->render( 'recommendadd' );
-
- }
-
- /*
- * 首页-品房推荐 - 添加数据
- * */
- public function actionRecommendaddform ()
- {
- $model = new PushmRecommend();
- $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;
- // }
-
- 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 actionRecommendedit ()
- {
- $model = new PushmRecommend();
- $row = $model->FindById( Yii::$app->request->get( 'id' ) );
- if ( $row != null ) {
- return $this->render( 'recommendedit' , [ 'model' => $row ] );
- }
- }
-
- /*
- * 首页-品房推荐 - 修改数据
- * */
- public function actionRecommendeditform ()
- {
- $model = new PushmRecommend();
- $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 );
-
- if ( $row->save() ) return Help::JsonCode( Help::SUCCESS , Yii::t( 'app' , 'edit_success' ) );
- }
- }
- return Help::JsonCode( Help::ERROR , Yii::t( 'app' , 'edit_error' ) , $setAttribute );
- }
-
- /*
- * 首页-品房推荐 - 删除 and 禁用
- * */
- public function actionRecommenddelshow ()
- {
- $model = new PushmRecommend();
- $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;
- }
- 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 actionHotsale ()
- {
- return $this->render( 'hotsale' , [ 'type' => 1 ] );
- }
-
-
- /*
- * 首页-热销楼盘 - 数据
- * */
- public function actionHotsaleform ()
- {
- $model = new PushmHouse();
- $input = Yii::$app->request->post();
- if ( !empty( $input[ 'city_id' ] ) ) {
-
- $input[ 'city_id' ] = explode( ',' , $input[ 'city_id' ] );
- }
- $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->Totalhotsalefeng( $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 PushmHouse();
- $model->scenario = 'add';
- $validate = $model->Authenticator( $input );
- if ( is_object( $validate ) ) {
- 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 );
- }
-
- /*
- * 首页-热销楼盘- - 删除 and 禁用
- * */
- public function actionSaledelshow ()
- {
- $model = new PushmHouse();
- $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 actionHotsaledelall ()
- {
- $input = Yii::$app->request->post();
- $delall = PushmHouse::deleteAll( [ 'id' => $input[ 'id' ] ] );
-
- if ( $delall ) {
- return Help::JsonCode( Help::SUCCESS , '批量删除成功' );
- }
- return Help::JsonCode( Help::ERROR , '批量删除失败' );
- }
-
- /*
- * 搜索框 - 热门筛选
- * */
- public function actionHotscreen ()
- {
- return $this->render( 'hotsale' , [ 'type' => 2 ] );
- }
-
- /*
- * 首页 - 精选楼盘
- * */
- public function actionHotselected ()
- {
-
- return $this->render( 'hotsale' , [ 'type' => 4 , 'city_id' => Yii::$app->request->get( 'city_id' ) ] );
- }
-
- /*
- *首页-热门地区
- * */
- public function actionHotcity ()
- {
- return $this->render( 'hotcity' , [ 'type' => 1 ] );
- }
-
- /*
- * 首页-热门区域-数据列表
- * */
- public function actionHotcityform ()
- {
- $model = new PushmCity();
-
- $input = Yii::$app->request->post();
- $model->type = $input[ 'type' ];
- $rows = $model->getList( $input );
- if ( !empty( $rows ) ) {
- foreach ( $rows as &$val ) {
- $val[ 'img' ] = Yii::$app->params[ 'httpImg' ][ 'host' ] . Yii::$app->params[ 'httpImg' ][ 'city' ] . $val[ 'img' ];
- $val[ 'create_at' ] = date( 'Y-m-d H:i' , $val[ 'create_at' ] );
- }
- return Help::JsonData( 0 , '成功' , $model->Total() , $rows );
- }
- }
-
- /*
- * 首页-热门区域-数据列表
- * */
- public function actionHotcityadd ()
- {
- $cityModel = ( new CategoryCity() )->SortgetList( [] );
- return $this->render( 'hotcityadd' , [ 'type' => Yii::$app->request->get( 'type' ) , 'city' => $cityModel ] );
- }
-
- /*
- * 首页-热门区域-数据列表
- * */
- public function actionHotcityaddform ()
- {
- $model = new PushmCity();
-
- $input = Yii::$app->request->post();
- $model->scenario = 'add';
- $auth = $model->Authenticator( $input );
- if ( is_object( $auth ) ) {
- $img = UploadFile::InstanceImgName( 'img' , Yii::$app->params[ 'img_url' ][ 'city' ] );
- if ( is_string( $img ) ) {
- $auth->img = $img;
- }
- 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 actionHotcityedit ()
- {
- $model = new PushmCity();
- $input = Yii::$app->request->get();
- $row = $model->FindById( $input[ 'id' ] );
- if ( $row != null ) {
- $cityModel = ( new CategoryCity() )->SortgetList( [] );
- foreach ( $cityModel as &$val ) {
- $val[ 'checked' ] = '';
- if ( $val[ 'id' ] == $row[ 'city_id' ] ) {
- $val[ 'checked' ] = 'selected';
- }
- }
- return $this->render( 'hotcityedit' , [ 'model' => $row , 'city' => $cityModel ] );
- }
- }
-
- /*
- * 推送首页轮播 - 修改数据
- * */
- public function actionHotcityeditform ()
- {
- $model = new PushmCity();
- $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 );
- 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 actionCitydelshow ()
- {
- $model = new PushmCity();
- $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' ][ 'city' ] , $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 actionCharacteristic ()
- {
- return $this->render( 'characteristic' );
- }
-
- /*
- * 首页-特色类型 数据
- * */
- public function actionCharacteristicform ()
- {
- $model = new PushmCharacteristic();
- $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 PushmCharacteristic();
- $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 PushmCharacteristic();
- $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 PushmCharacteristic();
- $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 PushmCharacteristic();
- $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 actionRandcity ()
- {
- return $this->render( 'randcity' , [ 'type' => 2 ] );
- }
-
- /*
- * 首页 - 拨打电话 数据
- * */
- public function actionRandcityform ()
- {
- $model = new PushmCity();
-
- $input = Yii::$app->request->post();
- $model->type = $input[ 'type' ];
- $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 actionRandcityadd ()
- {
- return $this->render( 'randcityadd' , [ 'type' => Yii::$app->request->get( 'type' ) ] );
- }
-
- /*
- * 首页 - 拨打电话 添加数据
- * */
- public function actionRandcityaddform ()
- {
-
- }
-
- /********限时团购*********/
- public function actionTimelimitsgroup ()
- {
- $cityModel = $this->City();
- return $this->render( 'timelimitsgroup' , [ 'type' => 1 , 'city' => $cityModel ] );
- }
-
- public function actionTimelimitsgroupform ()
- {
- $model = new PushmTimelimitsgroup();
- $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 actionTimelimitsgroupadd ()
- {
- $cityModel = $this->City();
- return $this->render( 'timelimitsgroupadd' , [ 'type' => Yii::$app->request->get( 'type' ) , 'city' => $cityModel ] );
- }
-
- public function actionTimelimitsgroupaddform ()
- {
- $input = Yii::$app->request->post();
- $model = new PushmTimelimitsgroup();
- $model->scenario = 'add';
- $validate = $model->Authenticator( $input );
- if ( is_object( $validate ) ) {
- 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 actionTimelimitsgroupedit ()
- {
- $model = new PushmTimelimitsgroup();
- $cityModel = $this->City();
- $row = $model->FindById( Yii::$app->request->get( 'id' ) );
- if ( $row != null ) {
- return $this->render( 'timelimitsgroupedit' , [ 'type' => Yii::$app->request->get( 'type' ) , 'row' => $row , 'house_name' => Yii::$app->request->get( 'house_name' ) , 'city' => $cityModel ] );
- }
- }
-
- /*
- * 显示抢购 修改数据
- * */
- public function actionTimelimitsgroupeditform ()
- {
- $model = new PushmTimelimitsgroup();
- $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 );
-
- if ( $row->save() ) return Help::JsonCode( Help::SUCCESS , Yii::t( 'app' , 'edit_success' ) );
- }
- }
- return Help::JsonCode( Help::ERROR , Yii::t( 'app' , 'edit_error' ) , $setAttribute );
- }
-
- /*排序 删除 显示*/
- public function actionTimelimitsgroupdelandshow ()
- {
- $model = new PushmTimelimitsgroup();
- $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':
- $row->sort = $input[ 'sort' ];
- break;
- case 'click':
- $row->click = $input[ 'click' ];
- break;
- case 'group_num':
- $row->group_num = $input[ 'group_num' ];
- 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 Developers ()
- {
- $developers = new \common\models\Developers();
- $developers->is_del = 1;
- $developers = $developers->getList( [] );
- return $developers;
- }
-
- private function City ()
- {
- $city = new \common\models\CategoryCity();
- $city->state = 1;
- $city->pid = 0;
- $cityModel = $city->getList( [] );
- return $cityModel;
- }
-
- public function actionHothouse ()
- {
- return $this->render( 'hothouse' , [ 'type' => 1 ] );
- }
-
- /**
- * 添加推送楼盘
- * @return string
- */
- public function actionHothouseadd ()
- {
- return $this->render( 'hothouseadd' , [ 'type' => Yii::$app->request->get( 'type' ) ] );
- }
- }
|