123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <?php
- /**
- * Created by PhpStorm.
- * User: xiaofeng
- * Date: 2018/3/31
- * Time: 下午7:20
- */
- namespace common\models;
- class HouseFacilities extends Common
- {
- public function rules()
- {
- return [
- [['name','fid','distance'],'required','message'=>'{attribute}不能为空'],
- // [,'required','message'=>'不能为空'],
- ['fid','number'],
- ['hid','number'],
- // [,'required','message'=>'不能为空'],
- ['distance','string','max'=>50],
- ['latitude_longitude','string','max'=>100],
- ['del','in','range'=>[1,2]],
- ['del','default','value'=>1],
- ];
- }
- public function attributeLabels()
- {
- return [
- 'name'=>'配套名称',
- 'distance'=>'距离',
- 'latitude_longitude'=>'经纬度',
- 'fid'=>'配套类目'
- // '配套名称'=>'name',
- // '配套类目'=>'fid',
- // '距离'=>'distance',
- // '经纬度'=>'latitude_longitude',
- ];
- }
- public function Authenticator($input)
- {
- $this->load($input,'');
- if(!$this->validate()) return $this->errors;
- return $this;
- }
- //分组
- public function FacilitiesGroup()
- {
- $query = self::find();
- $query->andFilterWhere(['pfg_house_facilities.hid'=>$this->hid]);
- $query->andWhere(['pfg_house_facilities.del'=>$this->setDel]);
- $query->select(['pfg_category_facilities.name','pfg_house_facilities.id','pfg_house_facilities.fid','pfg_house_facilities.state',"count('fid') as num"]);
- $query->leftJoin('pfg_category_facilities','pfg_house_facilities.fid = pfg_category_facilities.id');
- return $query->groupBy('pfg_house_facilities.fid')->orderBy(['pfg_house_facilities.create_at'=>SORT_DESC])->asArray()->all();
- }
- public function getList()
- {
- $query = self::find();
- $query->andFilterWhere(['hid'=>$this->hid]);
- $query->andFilterWhere(['fid'=>$this->fid]);
- $query->andWhere(['del'=>$this->setDel]);
- return $query->orderBy(['create_at'=>SORT_DESC])->asArray()->all();
- }
- //
- public function InfoList()
- {
- $query = self::find();
- $query->andWhere(['pfg_house_facilities.hid'=>$this->hid]);
- $query->andWhere(['pfg_house_facilities.del'=>$this->setDel]);
- $query->select(['pfg_category_facilities.name','pfg_house_facilities.id','pfg_house_facilities.fid','pfg_house_facilities.state','pfg_house_facilities.name as pname','pfg_house_facilities.distance','pfg_house_facilities.latitude_longitude']);
- $query->leftJoin('pfg_category_facilities','pfg_house_facilities.fid = pfg_category_facilities.id');
- return $query->orderBy(['pfg_house_facilities.fid'=>SORT_DESC])->asArray()->all();
- }
- public function GroupPeitao()
- {
- $query = self::find();
- $query->andFilterWhere(['pfg_house_facilities.hid'=>$this->hid]);
- $query->andWhere(['pfg_house_facilities.del'=>$this->setDel]);
- $group = $query->groupBy('fid')->asArray()->all();
- if(!empty($group))
- {
- }
- }
- //楼盘分组查询统计
- public function HidTotal()
- {
- $query = self::find();
- $query->select(["count('hid') as num",'hid']);
- $query->andFilterWhere(['hid'=>$this->hid]);
- $query->andWhere(['del'=>$this->setDel]);
- // $query->andWhere(['NOT',['img'=>'']]);
- return $query->groupBy('hid')->asArray()->all();
- }
- }
|