123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <?php
- namespace common\models;
- use Yii;
- class Vr extends Common
- {
- public function rules()
- {
- return [
- [['img', 'name', 'abstarct', 'covered_area', 'hid', 'path', 'type', 'uuid', 'house_type'], 'required', 'message' => '{attribute}不能为空'],
- [['state', 'sort'], 'safe'],
- ];
- }
- public function attributeLabels()
- {
- return [
- 'img' => 'VR封面图',
- 'name' => 'VR名称',
- 'abstarct' => '厅卫厨',
- 'covered_area' => '建筑面积',
- 'hid' => '楼盘id',
- 'path' => 'VR地址',
- 'type' => '国内外标识',
- 'uuid' => '唯一性标识',
- 'house_type' => '户型类别',
- ];
- }
- public function getList($input)
- {
- if (!isset($input['type']) || empty($input['type'])) {
- return '参数错误!';
- }
- $query = self::find();
- $query->where(['pfg_vr.type' => $input['type']]);
- if (isset($input['name']) && !empty($input['name'])) {
- $query->andFilterWhere(['like', 'pfg_vr.name', $input['name']]);
- }
- if (isset($input['cover_id']) && !empty($input['cover_id'])) {
- $query->andFilterWhere(['pfg_user.uid' => $input['cover_id']]);
- }
- if ($input['type'] == 1) {
- $query->select(['pfg_vr.*', 'pfg_house.name as house_name', 'pfg_category_city.city_name', 'pfg_category_housetype.huxing_name']);
- if (isset($input['house']) && !empty($input['house'])) {
- $query->andFilterWhere(['like', 'pfg_house.name', $input['house']]);
- }
- $query->leftJoin('pfg_house', 'pfg_vr.hid = pfg_house.id');
- $query->leftJoin('pfg_category_city', 'pfg_category_city.id = pfg_house.city');
- $query->leftJoin('pfg_category_housetype', 'pfg_category_housetype.id = pfg_vr.house_type');
- } else {
- // $query->select(['pfg_vr.*', 'pfg_house_cn.name as house_name', 'pfg_category_city.city_name', 'pfg_category_housetype.huxing_name']);
- // if (isset($input['house']) && !empty($input['house'])) {
- // $query->andFilterWhere(['like', 'pfg_house_cn.name', $input['house']]);
- // }
- // $query->leftJoin('pfg_house_cn', 'pfg_vr.hid = pfg_house_cn.id');
- // $query->leftJoin('pfg_category_city', 'pfg_category_city.id = pfg_house_cn.city');
- // $query->leftJoin('pfg_category_housetype', 'pfg_category_housetype.id = pfg_vr.house_type');
- }
- $count = $query->count();
- if (isset($input['page']) && !empty($input['page'])) {
- $query->offset(--$input['page'] * $input['limit']);
- }
- if (isset($input['limit']) && !empty($input['limit'])) {
- $query->limit($input['limit']);
- }
- $data = $query->orderBy(['pfg_vr.sort' => SORT_DESC])->asArray()->all();
- return ['count' => $count, 'data' => $data];
- }
- public function getFindByUuid($uuid)
- {
- $query = self::find();
- $query->select(['*']);
- $query->where(['uuid' => $uuid]);
- return $query->asArray()->one();
- }
- //获取所有VR楼盘hid
- public function getColumnHid()
- {
- $query = self::find();
- $query->select('hid');
- $query->where(['state' => 1,'type'=>1]);
- $query->groupBy('hid');
- return $query->asArray()->all();
- }
- //获取楼盘户型VR
- public function getListAndVr($input)
- {
- $query = self::find();
- $query->select(['img', 'name as title', 'abstarct as indoor_info', 'covered_area as area', 'path','hid']);
- $query->where(['hid' => $input['hid'],'state'=>1,'type'=>1]);
- if(!empty($input['type_id'])){
- $query->andFilterWhere(['house_type' => $input['type_id']]);
- }
- $data = $query->asArray()->all();
- return $data;
- }
- }
|