moonsflyer 4 mesi fa
parent
commit
1669236391

+ 21 - 2
app/adminapi/lists/agricultural_machinery/SupplyDemandLists.php

@@ -17,6 +17,7 @@ namespace app\adminapi\lists\agricultural_machinery;
 use app\adminapi\lists\BaseAdminDataLists;
 use app\common\lists\ListsSearchInterface;
 use app\common\lists\ListsSortInterface;
+use app\common\model\asset\AssetArea;
 use app\common\model\supply_demand\SupplyDemandInfo;
 use app\common\model\supply_demand\SupplyDemandCate;
 /**
@@ -54,7 +55,10 @@ class SupplyDemandLists extends BaseAdminDataLists implements ListsSearchInterfa
             $status =  $this->params['status'];
             $where[] = ['status', '=',$status];
         }
-
+        if (isset($this->params['type']) && $this->params['type']) {
+            $type =  $this->params['type'];
+            $where[] = ['type', '=',$type];
+        }
         if (isset($this->params['cate_id']) && $this->params['cate_id']) {
             $cate_id_arr = [];
             $cate_id =  $this->params['cate_id'];
@@ -74,8 +78,23 @@ class SupplyDemandLists extends BaseAdminDataLists implements ListsSearchInterfa
         }
 
         if (isset($this->params['area_id']) && $this->params['area_id']) {
+//            $area_id =  $this->params['area_id'];
+//            $where[] = ['area_id', '=',$area_id];
+            $area_id_arr = [];
             $area_id =  $this->params['area_id'];
-            $where[] = ['area_id', '=',$area_id];
+            $area_info = AssetArea::find($area_id);
+
+            if($area_info){
+                array_push($area_id_arr,$area_id);
+                if($area_info['level'] == 1){
+                    $children_area_info = AssetArea::where(['pid'=>$area_id])->field('id,pid')->select()->toArray();
+                    if($children_area_info){
+                        $children_area = array_column($children_area_info,'id');
+                        $area_id_arr=array_merge($area_id_arr,$children_area);
+                    }
+                }
+            }
+            $where[] = ['area_id', 'in',$area_id_arr];
         }
         return $where;
     }