Browse Source

场地列表区域

15954078560 2 năm trước cách đây
mục cha
commit
a71a48cafd
1 tập tin đã thay đổi với 31 bổ sung3 xóa
  1. 31 3
      application/api/controller/Index.php

+ 31 - 3
application/api/controller/Index.php

@@ -1269,20 +1269,48 @@ class Index extends Api
         $this->success('详情', $info);
     }
 
+    //场地列表区域
+    public function gameplacearea() {
+        $id = input('id', 0, 'intval'); //排位赛id
+        if (!$id) {
+            $this->error('参数缺失');
+        }
+        $where['game_id'] = $id;
+
+        $hu_game_place = Db::name('game_place');
+        $list = $hu_game_place->field('city_id id')->where($where)->group('city_id')->select();
+        if ($list) {
+            $hu_area = Db::name('area');
+            foreach ($list as &$v) {
+                $v['name'] = $hu_area->where(['id' => $v['id']])->value('name');
+                $area_list = $hu_game_place->field('area_id id')->where(['game_id' => $id, 'city_id' => $v['id']])->select();
+                foreach ($area_list as &$value) {
+                    $value['name'] = $hu_area->where(['id' => $value['id']])->value('name');
+                }
+
+                $v['area_list'] = $area_list;
+            }
+        }
+
+        $this->success('场地列表区域', $list);
+    }
+
     //场地列表
     public function gameplace() {
         $id = input('id', 0, 'intval'); //排位赛id
         $area_id = input('area_id', 0, 'intval'); //区id
-        if (!$id || !$area_id) {
+        if (!$id) {
             $this->error('参数缺失');
         }
 
         $where['game_id'] = $id;
-        $where['area_id'] = $area_id;
+        if ($area_id) {
+            $where['area_id'] = $area_id;
+        }
         $where['status'] = 1;
 
         $list = Db::name('game_place')->field('id, name, image')
-            ->where($where)->page($this->page, $this->pagenum)->order('id')->select();
+            ->where($where)->order('id')->select();
 
         $list = list_domain_image($list, ['image']);