lizhen_gitee 1 year ago
parent
commit
2f6557c4da
1 changed files with 54 additions and 8 deletions
  1. 54 8
      application/api/controller/company/Index.php

+ 54 - 8
application/api/controller/company/Index.php

@@ -93,6 +93,7 @@ class Index extends Apic
         $starttime = strtotime($date);    //月初第一天
         $endtime = strtotime("+1 month",$starttime) - 1; //月末最后一天
 
+        //柱状图
         $ec_date = [];
         $ec_ordernum = [];
 
@@ -107,7 +108,7 @@ class Index extends Apic
             $starttime_i = $i;
             $endtime_i = $i + 86399;
             //日历
-            $ec_date[] = date('d',$starttime_i);
+            $ec_date[] = date('d',$starttime_i).'日';
             //下单人数
             $map['finish_time'] = ['between',[$starttime_i,$endtime_i]];
             $ec_ordernum[] = Db::name('order')->where($map)->count('id');
@@ -115,10 +116,11 @@ class Index extends Apic
 
         //饼图
         $map['finish_time'] = ['between',[$starttime,$endtime]];
-        $servicetype = Db::name('servicetype')->field('id,title')->select();
+        $servicetype = Db::name('servicetype')->field('id,title as name')->select();
         foreach($servicetype as $key => &$val){
             $map['servicetype_id'] = $val['id'];
-            $val['ordernum'] = Db::name('order')->where($map)->count('id');
+            $val['value'] = Db::name('order')->where($map)->count('id');
+            unset($val['id']);
         }
 
         $result = [
@@ -134,28 +136,72 @@ class Index extends Apic
         $summoney = Db::name('user_wallet')->where('company_id',$this->auth->company_id)->sum('money');//充卡余额
         //客户类别
         $comefrom_config = ['自然进店','平台引流','线下新客','老带新'];
-        $comefrom_bili = [];
         $comefrom_array = [];
         foreach($comefrom_config as $key => $val){
             $number = Db::name('user_wallet')->where('company_id',$this->auth->company_id)->where('comefrom',$val)->count();
             $bili = bcdiv($number*100,$usernumber,2).'%';
 
-            $comefrom_bili[] = $bili;
-            $comefrom_array[$val] = $bili;
+            $comefrom_array[] = ['name'=>$val,'value'=>$bili];
         }
 
         //
         $result = [
             'usernumber' => $usernumber,
             'summoney' => $summoney,
-            'comefrom_config' => $comefrom_config,
-            'comefrom_bili'   => $comefrom_bili,
             'comefrom_array'  => $comefrom_array,
         ];
 
         $this->success(1,$result);
     }
+
     public function datacenter_three(){
+        $type = input('type',1);
+
+        $servicetype = Db::name('servicetype')->field('id,title as name')->select();
+        //七日
+        if($type == 1){
+            $starttime = strtotime(date('Y-m-d')) - 518400;
+            $endtime   = strtotime(date('Y-m-d')) + 86399;
+
+            $ec_date = [];
+            $ec_totalfee = [];
+
+            $map = [
+                'company_id'  => $this->auth->company_id,
+            ];
+            if($this->auth->type == 2){
+                $map['staff_id'] = $this->auth->id;
+            }
+
+
+            for($i=$starttime;$i<$endtime;$i+=86400){
+                $starttime_i = $i;
+                $endtime_i = $i + 86399;
+                //日历
+                $ec_date[] = date('d',$starttime_i).'日';
+            }
+
+            foreach($servicetype as $key => &$val){
+                $map['servicetype_id'] = $val['id'];
+                $val['data'] = [];
+                $val['textColor'] = '#FFFFFF';
+                for($i=$starttime;$i<$endtime;$i+=86400){
+                    $starttime_i = $i;
+                    $endtime_i = $i + 86399;
+                    //销售金额
+                    $map['finish_time'] = ['between',[$starttime_i,$endtime_i]];
+                    $val['data'][] = Db::name('order')->where($map)->sum('total_fee');
+                }
+                unset($val['id']);
+            }
+            $ec_totalfee = $servicetype;
+
+            $result = [
+                'ec_data'     => $ec_date,
+                'ec_totalfee' => $ec_totalfee,
+            ];
+            $this->success(1,$result);
+        }
 
     }
     public function datacenter_four(){