123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <?php
- /**
- * Created by PhpStorm.
- * User: xiaofeng
- * Date: 2018/5/21
- * Time: 下午5:18
- */
- namespace common\models;
- class PushHousesale extends Common
- {
- public function rules()
- {
- return [
- ['hid', 'unique', 'targetClass' => 'common\models\PushHousesale','on'=>['add'],'message'=>'该楼盘已存在','filter'=>function($query){
- $query->andWhere(['del'=>$this->setDel]);
- return $query->andWhere(['type'=>$this->type]);
- }],
- ['hid','number','message'=>'请选择楼盘'],
- ['city','number'],
- ['sort','number','message'=>'排序只能是数字'],
- ['sort','number','max'=>10000],
- ['type','number'],
- ];
- }
- public function attributeLabels()
- {
- return [
- 'hid'=>'楼盘名称',
- 'city'=>'区域',
- ];
- }
- public function Authenticator($input)
- {
- $this->load($input,'');
- if(!$this->validate()) return $this->errors;
- return $this;
- }
- public function FindById($id)
- {
- return self::findOne($id);
- }
- public function getList($input)
- {
- $query = self::find();
- $query->select(['pfg_house.name','pfg_push_housesale.id','pfg_push_housesale.hid','pfg_push_housesale.create_at','pfg_push_housesale.is_show','pfg_push_housesale.sort']);
- $query->andWhere(['pfg_push_housesale.del'=>$this->setDel]);
- if(!empty($input['city']))
- {
- $query->andWhere(['pfg_push_housesale.city'=>$input['city']]);
- }
- if(!empty($input['house_name']))
- {
- $query->andWhere(['like','pfg_house.name',$input['house_name']]);
- }
- $query->andWhere(['pfg_push_housesale.type'=>$input['type']]);
- $query->leftJoin('pfg_house','pfg_push_housesale.hid=pfg_house.id');
- if(!empty($input['page']))
- {
- $query->limit = $input['limit'];
- $query->offset = ($input['page']-1 )* $input['limit'];
- }
- return $query->orderBy(['pfg_push_housesale.sort'=>SORT_DESC,'pfg_push_housesale.id'=>SORT_DESC])->asArray()->all();
- }
- public function WhereColumn($query)
- {
- }
- public function Total($input)
- {
- $query = self::find();
- if(!empty($input['city']))
- {
- $query->andWhere(['pfg_push_housesale.city'=>$input['city']]);
- }
- $query->andWhere(['pfg_push_housesale.del'=>$this->setDel]);
- $query->andWhere(['pfg_push_housesale.type'=>$input['type']]);
- $query->leftJoin('pfg_house','pfg_push_housesale.hid=pfg_house.id');
- return $query->count();
- }
- public function Homegetlist($limit)
- {
- $query = self::find();
- $query->select(['pfg_category_city.city_name','pfg_house.name','pfg_house.sale_price','pfg_house_detail.price_unit','pfg_house.characteristic','pfg_house.id','pfg_house.thumb']);
- $query->andWhere(['pfg_push_housesale.del'=>$this->setDel]);
- $query->andWhere(['pfg_push_housesale.is_show'=>1]);
- $query->andWhere(['pfg_push_housesale.type'=>$this->type]);
- $query->andFilterWhere(['pfg_push_housesale.city'=>$this->city]);
- $query->leftJoin('pfg_house','pfg_push_housesale.hid=pfg_house.id');
- $query->leftJoin('pfg_category_city','pfg_house.city=pfg_category_city.id');
- $query->leftJoin('pfg_house_detail','pfg_house.id=pfg_house_detail.hid');
- $query->orderBy(['pfg_push_housesale.sort'=>SORT_DESC,'pfg_push_housesale.id'=>SORT_DESC]);
- $query->limit = $limit;
- return $query->asArray()->all();
- }
- }
|