Explorar o código

add - 代理数据权限

liugc hai 1 ano
pai
achega
73e1b9355d

+ 23 - 3
app/adminapi/lists/property/PropertyActivityLists.php

@@ -18,6 +18,7 @@ namespace app\adminapi\lists\property;
 use app\adminapi\lists\BaseAdminDataLists;
 use app\common\model\property\PropertyActivity;
 use app\common\lists\ListsSearchInterface;
+use app\common\model\property\PropertyHead;
 
 
 /**
@@ -42,7 +43,26 @@ class PropertyActivityLists extends BaseAdminDataLists implements ListsSearchInt
 
         ];
     }
-
+    /**
+     * 获取数据权限
+     * $this->adminInfo['data_rules']
+     * province city admin_id sale_group_id sale_id  property_head_id
+     */
+    public function queryDataWhere(){
+        $where = [];
+        $data_rules = $this->adminInfo['data_rules'];
+        if (isset($data_rules['province']) && !empty($data_rules['province'])) {
+            $where[] = ['province','in' ,$data_rules['province']];
+        }
+        if (isset($data_rules['city']) && !empty($data_rules['city'])) {
+            $where[] = ['city','in' ,$data_rules['city']];
+        }
+        if(!empty($where)){
+            $head_ids = PropertyHead::where($where)->column('id')??[0];
+            $where = [['property_head_id','in' ,$head_ids]];
+        }
+        return $where;
+    }
 
     /**
      * @notes 获取列表
@@ -56,7 +76,7 @@ class PropertyActivityLists extends BaseAdminDataLists implements ListsSearchInt
     public function lists(): array
     {
         return PropertyActivity::with(['propertyHeadInfo'])
-        ->where($this->searchWhere)
+        ->where($this->searchWhere)->where($this->queryDataWhere())
             ->field(['id', 'property_head_id', 'activity_name', 'activity_start_time', 'activity_end_time','block_data','coupon_data','url_page','page_type','images'])
             ->limit($this->limitOffset, $this->limitLength)
             ->order(['id' => 'desc'])
@@ -73,7 +93,7 @@ class PropertyActivityLists extends BaseAdminDataLists implements ListsSearchInt
      */
     public function count(): int
     {
-        return PropertyActivity::where($this->searchWhere)->count();
+        return PropertyActivity::where($this->searchWhere)->where($this->queryDataWhere())->count();
     }
 
 }

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

@@ -57,7 +57,26 @@ class PropertyCommissionLists extends BaseAdminDataLists implements ListsSearchI
         }
         return $where;
     }
-
+    /**
+     * 获取数据权限
+     * $this->adminInfo['data_rules']
+     * province city admin_id sale_group_id sale_id  property_head_id
+     */
+    public function queryDataWhere(){
+        $where = [];
+        $data_rules = $this->adminInfo['data_rules'];
+        if (isset($data_rules['province']) && !empty($data_rules['province'])) {
+            $where[] = ['province','in' ,$data_rules['province']];
+        }
+        if (isset($data_rules['city']) && !empty($data_rules['city'])) {
+            $where[] = ['city','in' ,$data_rules['city']];
+        }
+        if(!empty($where)){
+            $head_ids = PropertyHead::where($where)->column('id')??[0];
+            $where = [['property_head_id','in' ,$head_ids]];
+        }
+        return $where;
+    }
     /**
      * @notes 获取列表
      * @return array
@@ -69,7 +88,7 @@ class PropertyCommissionLists extends BaseAdminDataLists implements ListsSearchI
      */
     public function lists(): array
     {
-        return PropertyCommission::with(['propertyHead','propertyUser'])->where($this->searchWhere)->where($this->queryWhere())
+        return PropertyCommission::with(['propertyHead','propertyUser'])->where($this->searchWhere)->where($this->queryWhere())->where($this->queryDataWhere())
             ->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'])
@@ -86,7 +105,7 @@ class PropertyCommissionLists extends BaseAdminDataLists implements ListsSearchI
      */
     public function count(): int
     {
-        return PropertyCommission::where($this->searchWhere)->where($this->queryWhere())->count();
+        return PropertyCommission::where($this->searchWhere)->where($this->queryWhere())->where($this->queryDataWhere())->count();
     }
 
 }

+ 3 - 3
app/adminapi/lists/property/PropertyHeadLists.php

@@ -52,12 +52,12 @@ class PropertyHeadLists extends BaseAdminDataLists implements ListsSearchInterfa
     public function queryDataWhere(){
         $where = [];
         $data_rules = $this->adminInfo['data_rules'];
-        /*if (isset($data_rules['province']) && !empty($data_rules['province'])) {
+        if (isset($data_rules['province']) && !empty($data_rules['province'])) {
             $where[] = ['province','in' ,$data_rules['province']];
         }
         if (isset($data_rules['city']) && !empty($data_rules['city'])) {
             $where[] = ['city','in' ,$data_rules['city']];
-        }*/
+        }
         if (isset($data_rules['sale_group_id']) && !empty($data_rules['sale_group_id'])) {
             $sale_ids = Sale::where('sale_group_id','in',$data_rules['sale_group_id'])->column('id')??[];
             $where[] = ['sale_id','in' ,$sale_ids];
@@ -82,7 +82,7 @@ class PropertyHeadLists extends BaseAdminDataLists implements ListsSearchInterfa
     public function lists(): array
     {
         return PropertyHead::where($this->searchWhere)->where($this->queryDataWhere())
-            ->field(['head_corporate_bank','id', 'property_name', 'village_name', 'address', 'head_name', 'head_mobile', 'ratio', 'head_bank_card', 'remark', 'user_id', 'all_profit_amount', 'surplus_profit_amount', 'extract_profit_amount','lon', 'lat','bind_date','sale_type','sale_id','is_cooperate'])
+            ->field(['province','city','area_name','head_corporate_bank','id', 'property_name', 'village_name', 'address', 'head_name', 'head_mobile', 'ratio', 'head_bank_card', 'remark', 'user_id', 'all_profit_amount', 'surplus_profit_amount', 'extract_profit_amount','lon', 'lat','bind_date','sale_type','sale_id','is_cooperate'])
             ->limit($this->limitOffset, $this->limitLength)
             ->order(['id' => 'desc'])
             ->select()

+ 21 - 1
app/adminapi/lists/property/PropertyOrderAnalysis.php

@@ -58,7 +58,26 @@ class PropertyOrderAnalysis extends BaseAdminDataLists implements ListsSearchInt
         }
         return $where;
     }
-
+    /**
+     * 获取数据权限
+     * $this->adminInfo['data_rules']
+     * province city admin_id sale_group_id sale_id  property_head_id
+     */
+    public function queryDataWhere(){
+        $where = [];
+        $data_rules = $this->adminInfo['data_rules'];
+        if (isset($data_rules['province']) && !empty($data_rules['province'])) {
+            $where[] = ['province','in' ,$data_rules['province']];
+        }
+        if (isset($data_rules['city']) && !empty($data_rules['city'])) {
+            $where[] = ['city','in' ,$data_rules['city']];
+        }
+        if(!empty($where)){
+            $head_ids = PropertyHead::where($where)->column('id')??[0];
+            $where = [['a.property_head_id','in' ,$head_ids]];
+        }
+        return $where;
+    }
     /**
      * @notes 获取列表
      * @return array
@@ -79,6 +98,7 @@ class PropertyOrderAnalysis extends BaseAdminDataLists implements ListsSearchInt
             ->where([['b.service_status','=',3],['b.approval','=',1]])
             ->where('b.finished_time','>',0)
             ->where($this->queryWhere())
+            ->where($this->queryDataWhere())
             ->group('a.property_head_id,month_format')
             ->limit($this->limitOffset, $this->limitLength)
             ->select()->toArray();

+ 6 - 2
app/adminapi/lists/property/PropertyOrderLists.php

@@ -67,12 +67,16 @@ class PropertyOrderLists extends BaseAdminDataLists implements ListsSearchInterf
     public function queryDataWhere(){
         $where = [];
         $data_rules = $this->adminInfo['data_rules'];
-        /*if (isset($data_rules['province']) && !empty($data_rules['province'])) {
+        if (isset($data_rules['province']) && !empty($data_rules['province'])) {
             $where[] = ['province','in' ,$data_rules['province']];
         }
         if (isset($data_rules['city']) && !empty($data_rules['city'])) {
             $where[] = ['city','in' ,$data_rules['city']];
-        }*/
+        }
+        if(!empty($where)){
+            $head_ids = PropertyHead::where($where)->column('id')??[0];
+            $where = [['property_head_id','in' ,$head_ids]];
+        }
         if (isset($data_rules['sale_group_id']) && !empty($data_rules['sale_group_id'])) {
             $where[] = ['sale_group_id','in' ,$data_rules['sale_group_id']];
         }

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

@@ -53,7 +53,26 @@ class PropertySurplusLogLists extends BaseAdminDataLists implements ListsSearchI
         }
         return $where;
     }
-
+    /**
+     * 获取数据权限
+     * $this->adminInfo['data_rules']
+     * province city admin_id sale_group_id sale_id  property_head_id
+     */
+    public function queryDataWhere(){
+        $where = [];
+        $data_rules = $this->adminInfo['data_rules'];
+        if (isset($data_rules['province']) && !empty($data_rules['province'])) {
+            $where[] = ['province','in' ,$data_rules['province']];
+        }
+        if (isset($data_rules['city']) && !empty($data_rules['city'])) {
+            $where[] = ['city','in' ,$data_rules['city']];
+        }
+        if(!empty($where)){
+            $head_ids = PropertyHead::where($where)->column('id')??[0];
+            $where = [['property_head_id','in' ,$head_ids]];
+        }
+        return $where;
+    }
     /**
      * @notes 获取列表
      * @return array
@@ -65,7 +84,7 @@ class PropertySurplusLogLists extends BaseAdminDataLists implements ListsSearchI
      */
     public function lists(): array
     {
-        return PropertySurplusLog::with(['propertyHead'])->where($this->searchWhere)->where($this->queryWhere())
+        return PropertySurplusLog::with(['propertyHead'])->where($this->searchWhere)->where($this->queryWhere())->where($this->queryDataWhere())
             ->field(['id', 'in_out', 'property_commission_id', 'amount', 'status', 'remark', 'property_head_id','create_time', 'update_time'])
             ->limit($this->limitOffset, $this->limitLength)
             ->order(['id' => 'desc'])
@@ -82,7 +101,7 @@ class PropertySurplusLogLists extends BaseAdminDataLists implements ListsSearchI
      */
     public function count(): int
     {
-        return PropertySurplusLog::where($this->searchWhere)->where($this->queryWhere())->count();
+        return PropertySurplusLog::where($this->searchWhere)->where($this->queryWhere())->where($this->queryDataWhere())->count();
     }
 
 }

+ 22 - 3
app/adminapi/lists/property/PropertyUserLists.php

@@ -52,7 +52,26 @@ class PropertyUserLists extends BaseAdminDataLists implements ListsSearchInterfa
         }
         return $where;
     }
-
+    /**
+     * 获取数据权限
+     * $this->adminInfo['data_rules']
+     * province city admin_id sale_group_id sale_id  property_head_id
+     */
+    public function queryDataWhere(){
+        $where = [];
+        $data_rules = $this->adminInfo['data_rules'];
+        if (isset($data_rules['province']) && !empty($data_rules['province'])) {
+            $where[] = ['province','in' ,$data_rules['province']];
+        }
+        if (isset($data_rules['city']) && !empty($data_rules['city'])) {
+            $where[] = ['city','in' ,$data_rules['city']];
+        }
+        if(!empty($where)){
+            $head_ids = PropertyHead::where($where)->column('id')??[0];
+            $where = [['property_head_id','in' ,$head_ids]];
+        }
+        return $where;
+    }
     /**
      * @notes 获取列表
      * @return array
@@ -64,7 +83,7 @@ class PropertyUserLists extends BaseAdminDataLists implements ListsSearchInterfa
      */
     public function lists(): array
     {
-        return PropertyUser::with(['propertyHead'])->where($this->searchWhere)->where($this->queryWhere())
+        return PropertyUser::with(['propertyHead'])->where($this->searchWhere)->where($this->queryWhere())->where($this->queryDataWhere())
             ->field(['id', 'property_head_id', 'householder_name', 'householder_mobile', 'address', 'user_id'])
             ->limit($this->limitOffset, $this->limitLength)
             ->order(['id' => 'desc'])
@@ -81,7 +100,7 @@ class PropertyUserLists extends BaseAdminDataLists implements ListsSearchInterfa
      */
     public function count(): int
     {
-        return PropertyUser::where($this->searchWhere)->where($this->queryWhere())->count();
+        return PropertyUser::where($this->searchWhere)->where($this->queryWhere())->where($this->queryDataWhere())->count();
     }
 
 }

+ 6 - 0
app/adminapi/logic/property/PropertyHeadLogic.php

@@ -61,6 +61,9 @@ class PropertyHeadLogic extends BaseLogic
                 'sale_type'=>$params['sale_type']??0,
                 'sale_id'=>$params['sale_id']??0,
                 'is_cooperate'=>$params['is_cooperate']??1,
+                'province' => $params['province']??0,
+                'city' => $params['city']??0,
+                'area_name' => $params['area_name']??'',
             ]);
 
             Db::commit();
@@ -110,6 +113,9 @@ class PropertyHeadLogic extends BaseLogic
                 'sale_type'=>$params['sale_type']??0,
                 'sale_id'=>$params['sale_id']??0,
                 'is_cooperate'=>$params['is_cooperate']??1,
+                'province' => $params['province']??0,
+                'city' => $params['city']??0,
+                'area_name' => $params['area_name']??'',
             ]);