Просмотр исходного кода

影院列表返回结构调整

family 1 год назад
Родитель
Сommit
c692abd3eb
1 измененных файлов с 11 добавлено и 5 удалено
  1. 11 5
      app/common/repositories/movie/CinemaRepository.php

+ 11 - 5
app/common/repositories/movie/CinemaRepository.php

@@ -46,9 +46,9 @@ class CinemaRepository extends BaseRepository
46 46
      */
47 47
     public function getLocalCinema($page, $limit, $longitude, $latitude, $where = [], $with = [], $order = 1)
48 48
     {
49
-        $field = 'cinema_sign,cinema_name,address,tel,city_sign,city_name,area_sign,area_name';
49
+        $field = 'cinema_sign,cinema_name,address,tel,city_sign,city_name,area_sign,area_name,longitude,latitude';
50 50
 
51
-        $result = $this->dao->search(null, $where)->when($with, function ($query) use ($with) {
51
+        $cinema_list = $this->dao->search(null, $where)->when($with, function ($query) use ($with) {
52 52
             $query->with($with);
53 53
         })->when($latitude && $longitude, function ($query) use ($field, $longitude, $latitude) {
54 54
             $query->field([$field, $this->distance($latitude, $longitude)]);
@@ -61,11 +61,17 @@ class CinemaRepository extends BaseRepository
61 61
                 $query->order('create_time desc');
62 62
             }
63 63
         })->field([$field])->select()->toArray();
64
-        foreach ($result as $key => $value) {
65
-            $result[$key]['distance'] = round($value['distance'] / 1000, 2);
64
+        foreach ($cinema_list as $key => $value) {
65
+            $cinema_list[$key]['distance'] = round($value['distance'] / 1000, 2);
66 66
         }
67 67
 
68
-        return $result;
68
+        $count = $this->dao->search(null, $where)->when($with, function ($query) use ($with) {
69
+            $query->with($with);
70
+        })->when($latitude && $longitude, function ($query) use ($field, $longitude, $latitude) {
71
+            $query->field([$field, $this->distance($latitude, $longitude)]);
72
+        })->count();
73
+
74
+        return compact('cinema_list', 'count');
69 75
     }
70 76
 
71 77
     /**