Browse Source

第五个统计

lizhen_gitee 1 year ago
parent
commit
584e45e6d8
1 changed files with 38 additions and 0 deletions
  1. 38 0
      application/api/controller/company/Index.php

+ 38 - 0
application/api/controller/company/Index.php

@@ -290,6 +290,44 @@ class Index extends Apic
 
 
     }
+    public function datacenter_five(){
+        $date = input('date',date('Y-m-01'));
+        $starttime = strtotime($date);    //月初第一天
+        $endtime = strtotime("+1 month",$starttime) - 1; //月末最后一天
+
+        $staff = Db::name('company_staff')->field('id,truename')->where('type',2)->where('company_id',$this->auth->company_id)->select();
+
+        //柱状图
+        $ec_date = [];
+        $ec_ordernum = [
+            0 => [
+                'name'=>'金额',
+                'data'=>[],
+            ],
+        ];
+
+        $map = [
+            'company_id'  => $this->auth->company_id,
+            'status'      => 3,
+            'finish_time' => ['between',[$starttime,$endtime]],
+        ];
+
+        foreach($staff as $key => $val){
+            //日历
+            $ec_date[] = $val['truename'];
+            //开单金额
+            $map['staff_id']    = $val['id'];
+            $ec_ordernum[0]['data'][] = Db::name('order')->where($map)->sum('total_fee');
+        }
+
+        $result = [
+            'ec_data'     => $ec_date,
+            'ec_ordernum' => $ec_ordernum,
+        ];
+        $this->success(1,$result);
+
+
+    }