123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Administrator
- * Date: 2018/2/26/026
- * Time: 15:06
- */
- namespace backend\controllers;
- use backend\base\CommonController;
- use backend\base\Help;
- use Yii;
- use common\models\CategoryCity;
- use common\models\Pricetrends;
- class PricetrendController extends CommonController
- {
- /*
- * 价格走势 列表 页面
- * */
- public function actionHome()
- {
- $model = new CategoryCity();
- $input = Yii::$app->request->post();
- $rows = $model->getList($input,['id as city_id','city_name']);
- return $this->render('home',['rows'=>$rows]);
- }
- /*
- * 价格走势 列表 数据
- * */
- public function actionHomeform()
- {
- $model = new Pricetrends();
- $model->city_id=Yii::$app->request->post("city_id");
- $rows = $model->getList(Yii::$app->request->post());
- foreach($rows as $k=>$v)
- {
- $model->city_id=$v['city_id'];
- $data = $model->getCityList(Yii::$app->request->post());
- $rows[$k]['count']=count($data);
- }
- if(!empty($rows))
- {
- return Help::JsonData(0,'成功',$model->Total(),$rows);
- }
- return Help::JsonCode(Help::ERROR,Yii::t('app','get_error'));
- }
- /*
- * 区域历史价格 页面
- * */
- public function actionRecordprice()
- {
- return $this->render('recordprice',['cid'=>Yii::$app->request->get('cid')]);
- }
- /*
- * 区域历史价格数据
- * */
- public function actionRecordpriceform()
- {
- $model = new Pricetrends();
- $model->city_id = Yii::$app->request->post('city_id');
- $rows = $model->getCityList(Yii::$app->request->post());
- if(!empty($rows))
- {
- $arr = Yii::$app->params['CityPriceTrend'];
- foreach ($rows as &$val)
- {
- if(isset($arr[$val['trend']]) && !empty($arr[$val['trend']]))
- {
- $val['trend'] = $arr[$val['trend']];
- }
- }
- return Help::JsonData(0,'成功',$model->cityTotal(),$rows);
- }
- return Help::JsonCode(Help::ERROR,Yii::t('app','get_error'));
- }
- /*
- * 价格走势 添加 页面
- * */
- public function actionPriceadd()
- {
- $model = new CategoryCity();
- $input = Yii::$app->request->post();
- $rows = $model->getList($input,['id','city_name']);
- return $this->render('priceadd',['rows'=>$rows]);
- }
- /*
- * 价格走势 添加 数据
- * */
- public function actionPriceaddform()
- {
- $model = new \common\models\Pricetrends();
- $auth = $model->Authenticator(Yii::$app->request->post());
- if(is_object($auth))
- {
- if($auth->save())
- {
- return Help::JsonCode(Help::SUCCESS,Yii::t('app','add_success'));
- }
- }
- return Help::JsonCode(Help::ERROR,Yii::t('app','add_error'),$auth);
- }
- /*
- * 修改单个区域里面的历史记录
- * */
- public function actionPriceedit()
- {
- $model = new Pricetrends();
- $row = $model->FindById(Yii::$app->request->get('id'));
- return $this->render('priceedit',['model'=>$row]);
- }
- /*
- * 修改单个区域里面的历史记录 数据
- * */
- public function actionPriceeditform()
- {
- $model = new Pricetrends();
- $auth = $model->Authenticator(Yii::$app->request->post());
- if(is_object($auth))
- {
- $row = $model->FindById(Yii::$app->request->post('id'));
- if(!empty($row))
- {
- $attr = Help::SetAttr(Yii::$app->request->post(),$auth,$row);
- if($attr->save())
- {
- return Help::JsonCode(Help::SUCCESS,Yii::t('app','edit_success'));
- }
- }
- }
- return Help::JsonCode(Help::ERROR,Yii::t('app','edit_error'),$auth);
- }
- /*
- * 行里添加按钮
- * */
- public function actionLineadd()
- {
- return $this->render('lineadd',['model'=>Yii::$app->request->get()]);
- }
- /*
- * 删除单个区域里面的历史记录 数据
- * */
- public function actionPricedel()
- {
- $model = new Pricetrends();
- $row = $model->FindById(Yii::$app->request->post('id'));
- if(!empty($row))
- {
- $row->del = 2;
- if($row->save(false)) return Help::JsonCode(Help::SUCCESS,Yii::t('app','edit_success'));
- }
- return Help::JsonCode(Help::ERROR,Yii::t('app','edit_error'));
- }
- }
|