Vr.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. namespace common\models;
  3. use Yii;
  4. class Vr extends Common
  5. {
  6. public function rules()
  7. {
  8. return [
  9. [['img', 'name', 'abstarct', 'covered_area', 'hid', 'path', 'type', 'uuid', 'house_type'], 'required', 'message' => '{attribute}不能为空'],
  10. [['state', 'sort'], 'safe'],
  11. ];
  12. }
  13. public function attributeLabels()
  14. {
  15. return [
  16. 'img' => 'VR封面图',
  17. 'name' => 'VR名称',
  18. 'abstarct' => '厅卫厨',
  19. 'covered_area' => '建筑面积',
  20. 'hid' => '楼盘id',
  21. 'path' => 'VR地址',
  22. 'type' => '国内外标识',
  23. 'uuid' => '唯一性标识',
  24. 'house_type' => '户型类别',
  25. ];
  26. }
  27. public function getList($input)
  28. {
  29. if (!isset($input['type']) || empty($input['type'])) {
  30. return '参数错误!';
  31. }
  32. $query = self::find();
  33. $query->where(['pfg_vr.type' => $input['type']]);
  34. if (isset($input['name']) && !empty($input['name'])) {
  35. $query->andFilterWhere(['like', 'pfg_vr.name', $input['name']]);
  36. }
  37. if (isset($input['cover_id']) && !empty($input['cover_id'])) {
  38. $query->andFilterWhere(['pfg_user.uid' => $input['cover_id']]);
  39. }
  40. if ($input['type'] == 1) {
  41. $query->select(['pfg_vr.*', 'pfg_house.name as house_name', 'pfg_category_city.city_name', 'pfg_category_housetype.huxing_name']);
  42. if (isset($input['house']) && !empty($input['house'])) {
  43. $query->andFilterWhere(['like', 'pfg_house.name', $input['house']]);
  44. }
  45. $query->leftJoin('pfg_house', 'pfg_vr.hid = pfg_house.id');
  46. $query->leftJoin('pfg_category_city', 'pfg_category_city.id = pfg_house.city');
  47. $query->leftJoin('pfg_category_housetype', 'pfg_category_housetype.id = pfg_vr.house_type');
  48. } else {
  49. // $query->select(['pfg_vr.*', 'pfg_house_cn.name as house_name', 'pfg_category_city.city_name', 'pfg_category_housetype.huxing_name']);
  50. // if (isset($input['house']) && !empty($input['house'])) {
  51. // $query->andFilterWhere(['like', 'pfg_house_cn.name', $input['house']]);
  52. // }
  53. // $query->leftJoin('pfg_house_cn', 'pfg_vr.hid = pfg_house_cn.id');
  54. // $query->leftJoin('pfg_category_city', 'pfg_category_city.id = pfg_house_cn.city');
  55. // $query->leftJoin('pfg_category_housetype', 'pfg_category_housetype.id = pfg_vr.house_type');
  56. }
  57. $count = $query->count();
  58. if (isset($input['page']) && !empty($input['page'])) {
  59. $query->offset(--$input['page'] * $input['limit']);
  60. }
  61. if (isset($input['limit']) && !empty($input['limit'])) {
  62. $query->limit($input['limit']);
  63. }
  64. $data = $query->orderBy(['pfg_vr.sort' => SORT_DESC])->asArray()->all();
  65. return ['count' => $count, 'data' => $data];
  66. }
  67. public function getFindByUuid($uuid)
  68. {
  69. $query = self::find();
  70. $query->select(['*']);
  71. $query->where(['uuid' => $uuid]);
  72. return $query->asArray()->one();
  73. }
  74. //获取所有VR楼盘hid
  75. public function getColumnHid()
  76. {
  77. $query = self::find();
  78. $query->select('hid');
  79. $query->where(['state' => 1,'type'=>1]);
  80. $query->groupBy('hid');
  81. return $query->asArray()->all();
  82. }
  83. //获取楼盘户型VR
  84. public function getListAndVr($input)
  85. {
  86. $query = self::find();
  87. $query->select(['img', 'name as title', 'abstarct as indoor_info', 'covered_area as area', 'path','hid']);
  88. $query->where(['hid' => $input['hid'],'state'=>1,'type'=>1]);
  89. if(!empty($input['type_id'])){
  90. $query->andFilterWhere(['house_type' => $input['type_id']]);
  91. }
  92. $data = $query->asArray()->all();
  93. return $data;
  94. }
  95. }