Browse Source

数据隔离优化

Zhouzhendong 4 năm trước cách đây
mục cha
commit
bf25fdf59f

+ 1 - 0
app/Http/Controllers/RejectedController.php

@@ -475,6 +475,7 @@ class RejectedController extends Controller
     //analyzeSearch 统计查询 zengjun
     public function indexAnalyze(Request $request)
     {
+        ini_set('max_execution_time',2500);
         if(!Gate::allows('退货管理-查询')){ return redirect(url('/'));  }
         $paginateParams = $this->getAnalyzeSearchParams($request);
         $rejectedBills =  RejectedAnalyzeOwner::findBy($paginateParams);

+ 2 - 4
app/Http/Controllers/TestController.php

@@ -62,10 +62,8 @@ class TestController extends Controller
         }
     }
     public function test(){
-        $s = new LogisticService();
-        $logistic = Logistic::query()->select("id","name")->where("name","like","%{$s->assertExpressCompany("9785871490917")}%")->first();
-        $logisticId = $logistic ? $logistic->id : 0;
-        dd($logisticId);
+        $owners = [1,32];
+        dd("AND id_owner IN (".implode(",",$owners).")");
     }
 
     public function test123()

+ 10 - 4
app/RejectedAnalyzeOwner.php

@@ -81,7 +81,7 @@ class RejectedAnalyzeOwner extends Model
     }
 
     // 拼接条件     zengjun
-    public static function getCondition($array)
+    public static function getCondition($array, $owners)
     {
         if (isset($array['data'])){
             $condition=RejectedAnalyzeOwner::getSqlToIDs($array['data']);
@@ -105,6 +105,9 @@ class RejectedAnalyzeOwner extends Model
                 }
             }
         }
+        if (count($owners) > 0){
+            $condition .= "AND id_owner IN (".implode(",",$owners).")";
+        }
         $condition .= ' group by id_owner';
         return $condition;
     }
@@ -126,8 +129,9 @@ class RejectedAnalyzeOwner extends Model
     }
 
     // 返回sql    zengjun
-    public static  function getQuerySQL($array= null){
-        $condition = RejectedAnalyzeOwner::getCondition($array);// 条件
+    public static  function getQuerySQL($array){
+        $owners = app("OwnerService")->getIdArr();
+        $condition = RejectedAnalyzeOwner::getCondition($array, $owners);// 条件
         $sql = 'select distinct rao.id_owner,owners.name owner_name,sum(bounce_amount) bounce_amount,sum(check_amount) check_amount,sum(in_storage_count) in_storage_count,sum(not_in_storage_count) not_in_storage_count from';
         $sql .= '(';
         // 退件单数
@@ -147,8 +151,10 @@ class RejectedAnalyzeOwner extends Model
         $sql .= $condition;
         $sql .= ') rao ';
         $sql .= ' left join owners on owners.id = rao.id_owner and owners.deleted_at is null ';
+        if (count($owners) == 0){
+            $sql .= " WHERE 0=1 ";
+        }
         $sql .= ' group by rao.id_owner';
-        $sql .= ' having owners.name is not null';
         if(isset($array['uncheck_amount'])){
             // 审核数为0
             if($array['uncheck_amount'] == 0)$sql.=' and bounce_amount - check_amount in (0)  ';