ss 4 months ago
parent
commit
47b9cefd54
1 changed files with 25 additions and 11 deletions
  1. 25 11
      application/api/controller/screen/Repair.php

+ 25 - 11
application/api/controller/screen/Repair.php

@@ -64,7 +64,7 @@ class Repair extends Index
             ['name'=>'已取消','value'=>[2,3]],
             ['name'=>'进行中','value'=>4],
             ['name'=>'已完成','value'=>5],
-            ['name'=>'已评价','value'=>6],
+          //  ['name'=>'已评价','value'=>6],
         ];
         $list = [];
         foreach ($orderMode as $k=>$v){
@@ -359,21 +359,31 @@ class Repair extends Index
     public function wxDepData(){
         $date = date('Ymd');
         $edate = date('Ymd',strtotime("-1 months",strtotime($date)));
-        $dep = Db::name('dep')
+//        $dep = Db::name('dep')
+//            ->field('id,title')
+//            ->where('org_id',$this->orgId)
+//            ->where('del',0)
+//            ->where('enable',1)
+//            ->limit(6)
+//            ->select();
+
+
+        $dep = Db::name('address')
             ->field('id,title')
             ->where('org_id',$this->orgId)
             ->where('del',0)
             ->where('enable',1)
-            ->limit(6)
+            ->where('','exp',Db::raw("FIND_IN_SET(1,types)"))
             ->select();
 
         $title = $count = $count2 = [];
         foreach ($dep as $k=>$v){
-            $title[] =$v['title'];
-            $count[] = Db::name('orders')
+           // $title[] =$v['title'];
+            $dep[$k]['count'] = Db::name('orders')
                 ->alias('o')
                 ->join('todo t','t.order_id=o.id')
-                ->where('o.dep_id',$v['id'])
+                ->join('order_repair or','or.order_id=o.id')
+                ->where('or.address_id',$v['id'])
                 ->where('t.work_type_mode',1)
                 ->where('t.create_yyyymmdd',$date)
                 ->where('t.del',0)
@@ -383,20 +393,24 @@ class Repair extends Index
             $nums= Db::name('orders')
                 ->alias('o')
                 ->join('todo t','t.order_id=o.id')
-                ->where('o.dep_id',$v['id'])
+                ->join('order_repair or','or.order_id=o.id')
+                ->where('or.address_id',$v['id'])
                 ->where('t.work_type_mode',1)
                 ->where('t.create_yyyymmdd','<=',$date)
                 ->where('t.create_yyyymmdd','>=',$edate)
                 ->where('t.del',0)
                 ->where('t.org_id',$this->orgId)
                 ->count();
-            $count2[] = round($nums/30,1);
+            $dep[$k]['num'] = round($nums/30,1);
         }
 
+
+        $newList = array_slice(list_sort_by($dep,'count','desc'),0,5);
+
         $data =[
-            'title' =>$title,
-            'list' =>$count,
-            'list2' =>$count2,
+            'title' =>array_column($newList,'title'),
+            'list' =>array_column($newList,'count'),
+            'list2' =>array_column($newList,'num'),
         ];
         HelpHander::success($data);