Explorar o código

工序大废品奖惩记录菜单优化

qiuenguang hai 1 ano
pai
achega
9346a039ba
Modificáronse 1 ficheiros con 11 adicións e 4 borrados
  1. 11 4
      application/api/controller/LargeWasteRewardPunish.php

+ 11 - 4
application/api/controller/LargeWasteRewardPunish.php

@@ -34,17 +34,24 @@ class LargeWasteRewardPunish extends Api
             $this->error('请求方式错误');
             $this->error('请求方式错误');
         }
         }
         $rows = db()->table('db_大废品')
         $rows = db()->table('db_大废品')
-            ->field('LEFT(sys_rq, 10) as date, COUNT(*) as counts')
+            ->field('DISTINCT(LEFT(sys_rq, 7)) AS mouth,LEFT(sys_rq, 10) as date, COUNT(*) as counts')
             ->group('date')
             ->group('date')
             ->order('UniqId desc')
             ->order('UniqId desc')
             ->limit(40)
             ->limit(40)
             ->select();
             ->select();
 
 
-
+        $list = [];
         foreach($rows as $key=>$value){
         foreach($rows as $key=>$value){
-            $rows[$key]['date'] = str_replace('-', '.', $rows[$key]['date']);
+            if (!isset($list[$value['mouth']])){
+                $list[$value['mouth']] = [];
+            }
+            $arr['date'] = str_replace('-', '.', $rows[$key]['date']);
+            $arr['counts'] = $rows[$key]['counts'];
+            array_push($list[$value['mouth']],$arr);
+//            $list[$value['mouth']]['date'] = str_replace('-', '.', $rows[$key]['date']);
+
         }
         }
-        $this->success('成功',$rows);
+        $this->success('成功',$list);
     }
     }
 
 
     /**
     /**