123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- <?php
- /**
- * Created by PhpStorm.
- * User: xiaofeng
- * Date: 2018/3/4
- * Time: 上午9:41
- */
- namespace common\models;
- //use yii\db\ActiveRecord;
- class ListHouse extends Common
- {
- public function rules()
- {
- return [
- ['list_id', 'in', 'range' => [10, 11, 12,13, 101, 102, 103]],
- ['hid', 'required', 'message' => '楼盘不能为空'],
- [['sort', 'state', 'information'], 'safe']
- ];
- /**
- * list_id:[
- * 10:pc端首页VR全景看房推送
- * 11:pc端首页航拍视频看房推送
- * 12:M端首页热榜楼盘推送位
- * 13:M端首页热门楼盘推送位
- * 101,102,103:国庆中秋专题
- * ]
- */
- }
- /***********************************后台数据*******************************************/
- //获取品质新房数据
- public function GetCharachterForm($input)
- {
- $query = self::find();
- $query->select(['pfg_list_house.*', 'pfg_house.name']);
- $query->where(['pfg_list_house.list_id' => $input['type_id']]);
- $count = $query->count();
- $query->leftJoin('pfg_house', 'pfg_house.id = pfg_list_house.hid');
- if (!empty($input['page'])) {
- $query->offset(--$input['page'] * $input['limit']);
- }
- if (!empty($input['limit'])) {
- $query->limit($input['limit']);
- }
- $data = $query->orderBy(['pfg_list_house.state' => SORT_ASC, 'pfg_list_house.sort' => SORT_DESC])->asArray()->all();
- foreach ($data as &$val) {
- $val['create_at'] = date('Y-m-d H:i:s', $val['create_at']);
- }
- return ['msg' => '获取数据完成', 'count' => $count, 'data' => $data];
- }
- //获取数据列表
- public function getList($input)
- {
- $query = self::find();
- $query->select(['pfg_list_house.*', 'pfg_house.name']);
- $query->where(['pfg_list_house.list_id' => $input['list_id']]);
- $count = $query->count();
- $query->leftJoin('pfg_house', 'pfg_house.id = pfg_list_house.hid');
- if (!empty($input['page'])) {
- $query->offset(--$input['page'] * $input['limit']);
- }
- if (!empty($input['limit'])) {
- $query->limit($input['limit']);
- }
- $data = $query->orderBy(['pfg_list_house.state' => SORT_ASC, 'pfg_list_house.sort' => SORT_DESC])->asArray()->all();
- foreach ($data as &$val) {
- $val['create_at'] = date('Y-m-d H:i:s', $val['create_at']);
- }
- return ['msg' => '获取数据完成', 'count' => $count, 'data' => $data];
- }
- /**
- * 获取一条数据
- * */
- public function getFindOne($id)
- {
- $query = self::find();
- $query->select(['pfg_list_house.*', 'pfg_house.name']);
- $query->where(['pfg_list_house.id' => $id]);
- $query->leftJoin('pfg_house', 'pfg_house.id = pfg_list_house.hid');
- return $query->asArray()->one();
- }
- /*
- * 检测数据是否存在
- * */
- public function listExists($where)
- {
- return self::find()->where($where)->exists();
- }
- /***************************************** pc端数据 ********************************************/
- //获取中秋专题数据
- public function zhongQiuGuoQing($list_id, $limit = null)
- {
- $select = [
- 'pfg_house.id',
- 'pfg_house.name',
- 'pfg_house.thumb',
- 'pfg_house.city',
- 'pfg_house.sale_price',
- 'pfg_house_detail.price_unit',
- 'pfg_house_detail.address',
- 'pfg_house_detail.preferential',
- 'pfg_category_city.city_name'
- ];
- $query = self::find();
- $query->select($select);
- $query->where(['pfg_list_house.list_id' => $list_id, 'pfg_list_house.state' => 1, 'pfg_house.del' => 1, 'pfg_house.is_view' => 1]);
- $query->leftJoin('pfg_house', 'pfg_house.id = pfg_list_house.hid');
- $query->leftJoin('pfg_house_detail', 'pfg_house.id = pfg_house_detail.hid');
- $query->leftJoin('pfg_category_city', 'pfg_category_city.id = pfg_house.city');
- if (!empty($limit)) {
- $query->limit($limit);
- }
- return $query->orderBy(['pfg_list_house.sort' => SORT_DESC])->asArray()->all();
- }
- //获取指定楼盘推送数据列表
- public function getIndexPushHouse($list_id, $limit = null)
- {
- $select = [
- 'pfg_house.id',
- 'pfg_house.name',
- 'pfg_house.thumb',
- 'pfg_category_city.city_name',
- 'pfg_house_detail.panorama_img',
- 'pfg_house_detail.video_img'
- ];
- $query = self::find();
- $query->select($select);
- $query->where(['pfg_list_house.list_id' => $list_id, 'pfg_list_house.state' => 1, 'pfg_house.del' => 1, 'pfg_house.is_view' => 1]);
- $query->leftJoin('pfg_house', 'pfg_house.id = pfg_list_house.hid');
- $query->leftJoin('pfg_house_detail', 'pfg_house.id = pfg_house_detail.hid');
- $query->leftJoin('pfg_category_city', 'pfg_category_city.id = pfg_house.city');
- if (!empty($limit)) {
- $query->limit($limit);
- }
- return $query->orderBy(['pfg_list_house.sort' => SORT_DESC])->asArray()->all();
- }
- //获取指定楼盘推送数据列表详细信息
- public function getIndexPushHouseDetail($list_id, $limit = null)
- {
- $select = [
- 'pfg_house.id',
- 'pfg_house.name',
- 'pfg_house.thumb',
- 'pfg_house.state',
- 'pfg_house.sale_price',
- 'pfg_house.is_tel',
- 'pfg_house.city',
- 'pfg_house_detail.price_unit',
- 'pfg_house_detail.preferential',
- 'pfg_house_detail.video_url',
- 'pfg_category_city.city_name'
- ];
- $query = self::find();
- $query->select($select);
- $query->where(['pfg_list_house.list_id' => $list_id, 'pfg_list_house.state' => 1, 'pfg_house.del' => 1, 'pfg_house.is_view' => 1]);
- $query->leftJoin('pfg_house', 'pfg_house.id = pfg_list_house.hid');
- $query->leftJoin('pfg_house_detail', 'pfg_house.id = pfg_house_detail.hid');
- $query->leftJoin('pfg_category_city', 'pfg_category_city.id = pfg_house.city');
- if (!empty($limit)) {
- $query->limit($limit);
- }
- return $query->orderBy(['pfg_list_house.sort' => SORT_DESC])->asArray()->all();
- }
- }
|