Explorar el Código

add - 新增查询条件

liugc hace 1 año
padre
commit
4ddafd7270

+ 17 - 3
app/adminapi/lists/property/PropertyCommissionLists.php

@@ -18,6 +18,8 @@ namespace app\adminapi\lists\property;
 use app\adminapi\lists\BaseAdminDataLists;
 use app\common\model\property\PropertyCommission;
 use app\common\lists\ListsSearchInterface;
+use app\common\model\property\PropertyHead;
+use app\common\model\property\PropertyUser;
 
 
 /**
@@ -42,7 +44,19 @@ class PropertyCommissionLists extends BaseAdminDataLists implements ListsSearchI
 
         ];
     }
-
+    public function queryWhere()
+    {
+        $where = [];
+        if(isset($this->params['head_name']) && !empty($this->params['head_name'])){
+            $property_head_ids = PropertyHead::where('head_name', 'like', '%'.$this->params['head_name'].'%')->column('id');
+            $where[] = ['property_head_id','IN',$property_head_ids];
+        }
+        if(isset($this->params['householder_name']) && !empty($this->params['householder_name'])){
+            $property_user_ids = PropertyUser::where('householder_name', 'like', '%'.$this->params['householder_name'].'%')->column('id');
+            $where[] = ['property_user_id','IN',$property_user_ids];
+        }
+        return $where;
+    }
 
     /**
      * @notes 获取列表
@@ -55,7 +69,7 @@ class PropertyCommissionLists extends BaseAdminDataLists implements ListsSearchI
      */
     public function lists(): array
     {
-        return PropertyCommission::where($this->searchWhere)
+        return PropertyCommission::with(['propertyHead','propertyUser'])->where($this->searchWhere)->where($this->queryWhere())
             ->field(['id', 'property_head_id', 'property_user_id', 'property_order_id', 'work_id', 'order_amount', 'ratio', 'commission_amount'])
             ->limit($this->limitOffset, $this->limitLength)
             ->order(['id' => 'desc'])
@@ -72,7 +86,7 @@ class PropertyCommissionLists extends BaseAdminDataLists implements ListsSearchI
      */
     public function count(): int
     {
-        return PropertyCommission::where($this->searchWhere)->count();
+        return PropertyCommission::where($this->searchWhere)->where($this->queryWhere())->count();
     }
 
 }

+ 17 - 3
app/adminapi/lists/property/PropertyOrderLists.php

@@ -16,8 +16,10 @@ namespace app\adminapi\lists\property;
 
 
 use app\adminapi\lists\BaseAdminDataLists;
+use app\common\model\property\PropertyHead;
 use app\common\model\property\PropertyOrder;
 use app\common\lists\ListsSearchInterface;
+use app\common\model\property\PropertyUser;
 
 
 /**
@@ -42,7 +44,19 @@ class PropertyOrderLists extends BaseAdminDataLists implements ListsSearchInterf
 
         ];
     }
-
+    public function queryWhere()
+    {
+        $where = [];
+        if(isset($this->params['head_name']) && !empty($this->params['head_name'])){
+            $property_head_ids = PropertyHead::where('head_name', 'like', '%'.$this->params['head_name'].'%')->column('id');
+            $where[] = ['property_head_id','IN',$property_head_ids];
+        }
+        if(isset($this->params['householder_name']) && !empty($this->params['householder_name'])){
+            $property_user_ids = PropertyUser::where('householder_name', 'like', '%'.$this->params['householder_name'].'%')->column('id');
+            $where[] = ['property_user_id','IN',$property_user_ids];
+        }
+        return $where;
+    }
 
     /**
      * @notes 获取列表
@@ -55,7 +69,7 @@ class PropertyOrderLists extends BaseAdminDataLists implements ListsSearchInterf
      */
     public function lists(): array
     {
-        return PropertyOrder::where($this->searchWhere)
+        return PropertyOrder::with(['propertyHead','propertyUser'])->where($this->searchWhere)->where($this->queryWhere())
             ->field(['id', 'property_head_id', 'property_user_id', 'remark', 'order_status', 'work_id'])
             ->limit($this->limitOffset, $this->limitLength)
             ->order(['id' => 'desc'])
@@ -72,7 +86,7 @@ class PropertyOrderLists extends BaseAdminDataLists implements ListsSearchInterf
      */
     public function count(): int
     {
-        return PropertyOrder::where($this->searchWhere)->count();
+        return PropertyOrder::where($this->searchWhere)->where($this->queryWhere())->count();
     }
 
 }

+ 13 - 3
app/adminapi/lists/property/PropertySurplusLogLists.php

@@ -16,8 +16,10 @@ namespace app\adminapi\lists\property;
 
 
 use app\adminapi\lists\BaseAdminDataLists;
+use app\common\model\property\PropertyHead;
 use app\common\model\property\PropertySurplusLog;
 use app\common\lists\ListsSearchInterface;
+use app\common\model\property\PropertyUser;
 
 
 /**
@@ -42,7 +44,15 @@ class PropertySurplusLogLists extends BaseAdminDataLists implements ListsSearchI
 
         ];
     }
-
+    public function queryWhere()
+    {
+        $where = [];
+        if(isset($this->params['head_name']) && !empty($this->params['head_name'])){
+            $property_head_ids = PropertyHead::where('head_name', 'like', '%'.$this->params['head_name'].'%')->column('id');
+            $where[] = ['property_head_id','IN',$property_head_ids];
+        }
+        return $where;
+    }
 
     /**
      * @notes 获取列表
@@ -55,7 +65,7 @@ class PropertySurplusLogLists extends BaseAdminDataLists implements ListsSearchI
      */
     public function lists(): array
     {
-        return PropertySurplusLog::where($this->searchWhere)
+        return PropertySurplusLog::with(['propertyHead'])->where($this->searchWhere)->where($this->queryWhere())
             ->field(['id', 'in_out', 'property_commission_id', 'amount', 'status', 'remark', 'property_head_id'])
             ->limit($this->limitOffset, $this->limitLength)
             ->order(['id' => 'desc'])
@@ -72,7 +82,7 @@ class PropertySurplusLogLists extends BaseAdminDataLists implements ListsSearchI
      */
     public function count(): int
     {
-        return PropertySurplusLog::where($this->searchWhere)->count();
+        return PropertySurplusLog::where($this->searchWhere)->where($this->queryWhere())->count();
     }
 
 }

+ 13 - 4
app/adminapi/lists/property/PropertyUserLists.php

@@ -16,8 +16,10 @@ namespace app\adminapi\lists\property;
 
 
 use app\adminapi\lists\BaseAdminDataLists;
+use app\common\model\property\PropertyHead;
 use app\common\model\property\PropertyUser;
 use app\common\lists\ListsSearchInterface;
+use think\db\Query;
 
 
 /**
@@ -39,10 +41,17 @@ class PropertyUserLists extends BaseAdminDataLists implements ListsSearchInterfa
     {
         return [
             '=' => ['property_head_id', 'householder_name', 'householder_mobile', 'address', 'user_id'],
-
         ];
     }
-
+    public function queryWhere()
+    {
+        $where = [];
+        if(isset($this->params['head_name']) && !empty($this->params['head_name'])){
+            $property_head_ids = PropertyHead::where('head_name', 'like', '%'.$this->params['head_name'].'%')->column('id');
+            $where[] = ['property_head_id','IN',$property_head_ids];
+        }
+        return $where;
+    }
 
     /**
      * @notes 获取列表
@@ -55,7 +64,7 @@ class PropertyUserLists extends BaseAdminDataLists implements ListsSearchInterfa
      */
     public function lists(): array
     {
-        return PropertyUser::where($this->searchWhere)
+        return PropertyUser::with(['propertyHead'])->where($this->searchWhere)->where($this->queryWhere())
             ->field(['id', 'property_head_id', 'householder_name', 'householder_mobile', 'address', 'user_id'])
             ->limit($this->limitOffset, $this->limitLength)
             ->order(['id' => 'desc'])
@@ -72,7 +81,7 @@ class PropertyUserLists extends BaseAdminDataLists implements ListsSearchInterfa
      */
     public function count(): int
     {
-        return PropertyUser::where($this->searchWhere)->count();
+        return PropertyUser::where($this->searchWhere)->where($this->queryWhere())->count();
     }
 
 }

+ 10 - 1
app/common/model/property/PropertyCommission.php

@@ -28,7 +28,16 @@ class PropertyCommission extends BaseModel
 {
     
     protected $name = 'property_commission';
-    
 
+    public function propertyHead()
+    {
+        return $this->hasOne(PropertyHead::class, 'id', 'property_head_id')
+            ->field('id,property_name,village_name,head_name');
+    }
+    public function propertyUser()
+    {
+        return $this->hasOne(PropertyUser::class, 'id', 'property_user_id')
+            ->field('id,householder_name,householder_mobile');
+    }
     
 }

+ 10 - 2
app/common/model/property/PropertyOrder.php

@@ -28,7 +28,15 @@ class PropertyOrder extends BaseModel
 {
     
     protected $name = 'property_order';
-    
 
-    
+    public function propertyHead()
+    {
+        return $this->hasOne(PropertyHead::class, 'id', 'property_head_id')
+            ->field('id,property_name,village_name,head_name');
+    }
+    public function propertyUser()
+    {
+        return $this->hasOne(PropertyUser::class, 'id', 'property_user_id')
+            ->field('id,householder_name,householder_mobile');
+    }
 }

+ 5 - 1
app/common/model/property/PropertySurplusLog.php

@@ -28,7 +28,11 @@ class PropertySurplusLog extends BaseModel
 {
     
     protected $name = 'property_surplus_log';
-    
 
+    public function propertyHead()
+    {
+        return $this->hasOne(PropertyHead::class, 'id', 'property_head_id')
+            ->field('id,property_name,village_name,head_name');
+    }
     
 }

+ 5 - 2
app/common/model/property/PropertyUser.php

@@ -28,7 +28,10 @@ class PropertyUser extends BaseModel
 {
     
     protected $name = 'property_user';
-    
 
-    
+    public function propertyHead()
+    {
+        return $this->hasOne(PropertyHead::class, 'id', 'property_head_id')
+            ->field('id,property_name,village_name,head_name');
+    }
 }