where('jointime', 'between time', [$starttime, $endtime]) ->field('jointime, status, COUNT(*) AS nums, DATE_FORMAT(FROM_UNIXTIME(jointime), "%Y-%m-%d") AS join_date') ->group('join_date') ->select(); for ($time = $starttime; $time <= $endtime;) { $column[] = date("Y-m-d", $time); $time += 86400; } $userlist = array_fill_keys($column, 0); foreach ($joinlist as $k => $v) { $userlist[$v['join_date']] = $v['nums']; } $dbTableList = Db::query("SHOW TABLE STATUS"); $addonList = get_addon_list(); $totalworkingaddon = 0; $totaladdon = count($addonList); foreach ($addonList as $index => $item) { if ($item['state']) { $totalworkingaddon += 1; } } $this->view->assign([ 'totaluser' => User::count(), 'totaladdon' => $totaladdon, 'totaladmin' => Admin::count(), 'totalcategory' => \app\common\model\Category::count(), 'todayusersignup' => User::whereTime('jointime', 'today')->count(), 'todayuserlogin' => User::whereTime('logintime', 'today')->count(), 'sevendau' => User::whereTime('jointime|logintime|prevtime', '-7 days')->count(), 'thirtydau' => User::whereTime('jointime|logintime|prevtime', '-30 days')->count(), 'threednu' => User::whereTime('jointime', '-3 days')->count(), 'sevendnu' => User::whereTime('jointime', '-7 days')->count(), 'dbtablenums' => count($dbTableList), 'dbsize' => array_sum(array_map(function ($item) { return $item['Data_length'] + $item['Index_length']; }, $dbTableList)), 'totalworkingaddon' => $totalworkingaddon, 'attachmentnums' => Attachment::count(), 'attachmentsize' => Attachment::sum('filesize'), 'picturenums' => Attachment::where('mimetype', 'like', 'image/%')->count(), 'picturesize' => Attachment::where('mimetype', 'like', 'image/%')->sum('filesize'), ]); $this->assignconfig('column', array_keys($userlist)); $this->assignconfig('userdata', array_values($userlist)); return $this->view->fetch(); } /** * 订单统计笔数 */ public function order(){ $starttime = strtotime(date('Y-m-d',strtotime("-30 day"))); //默认30天前 $endtime = strtotime(date('Y-m-d')) - 1; //接收 $choicedatetime = input('choicedatetime',''); if(!empty($choicedatetime)){ $choicedatetime = explode(' - ',$choicedatetime); $starttime = strtotime($choicedatetime[0]); $endtime = strtotime($choicedatetime[1]) + 86399; } $this->view->assign('defaultdatetime',date('Y-m-d',$starttime).' - '.date('Y-m-d',$endtime)); //dump($starttime); //dump($endtime); //过去30天 $ec_date = []; $ec_ordernum = []; // $ec_orderfee = []; $whereop = $this->whereop('company_id'); $whereop['status'] = 3; for($i=$starttime;$i<$endtime;$i+=86400){ $starttime_i = $i; $endtime_i = $i + 86399; //dump($starttime); //日历 $ec_date[] = date('Y-m-d',$starttime_i); //下单人数 $whereop['finish_time'] = ['between',[$starttime_i,$endtime_i]]; $ec_ordernum[] = Db::name('order')->where($whereop)->count('id'); //下单金额 // $ec_orderfee[] = Db::name('order')->where(['createtime'=>['between',[$starttime_i,$endtime_i]]])->sum('pay_fee'); } $this->assignconfig('ec_date', $ec_date); $this->assignconfig('ec_ordernum', $ec_ordernum); // $this->assignconfig('ec_orderfee', $ec_orderfee); return $this->view->fetch(); } /** * 订单统计各类型 */ public function orderservicetype(){ $starttime = strtotime(date('Y-m-d',strtotime("-30 day"))); //默认30天前 $endtime = strtotime(date('Y-m-d')) - 1; //接收 $choicedatetime = input('choicedatetime',''); if(!empty($choicedatetime)){ $choicedatetime = explode(' - ',$choicedatetime); $starttime = strtotime($choicedatetime[0]); $endtime = strtotime($choicedatetime[1]) + 86399; } $this->view->assign('defaultdatetime',date('Y-m-d',$starttime).' - '.date('Y-m-d',$endtime)); //饼图 $whereop = $this->whereop('company_id'); $whereop['status'] = 3; $whereop['finish_time'] = ['between',[$starttime,$endtime]]; $servicetype = Db::name('servicetype')->field('id,title as name')->select(); $all_count = Db::name('order')->where($whereop)->count('id'); foreach($servicetype as $key => &$val){ $whereop['servicetype_id'] = $val['id']; $val['value'] = Db::name('order')->where($whereop)->count('id'); $val['name'] = $val['name'] . bcdiv($val['value'],$all_count,4)*100 . '%'; unset($val['id']); } $this->assignconfig('servicetype', $servicetype); return $this->view->fetch(); } /** * 客户统计 */ public function datacentertwo(){ $whereop = $this->whereop('company_id'); $usernumber = Db::name('user_wallet')->where($whereop)->count();//充卡客户数量 $summoney = Db::name('user_wallet')->where($whereop)->sum('money');//充卡余额 //客户类别 $comefrom_config = ['线下新客','老带新','平台引流','自然进店']; $comefrom_array = []; foreach($comefrom_config as $key => $val){ $number = Db::name('user_wallet')->where($whereop)->where('comefrom',$val)->count(); $comefrom_array[] = ['name'=>$val . bcdiv($number,$usernumber,4)*100 . '%','value'=>$number]; } // $this->assign('usernumber', $usernumber); $this->assign('summoney', $summoney); $this->assignconfig('comefrom_array', $comefrom_array); return $this->view->fetch(); } /** * 七日销售金额数据统计 */ public function datacenterthree(){ $servicetype = Db::name('servicetype')->field('id,title as name')->select(); $servicename = array_column($servicetype,'name'); $this->assignconfig('servicename',$servicename); //七日 $starttime = strtotime(date('Y-m-d')) - 518400; $endtime = strtotime(date('Y-m-d')) + 86399; $ec_date = []; $map = [ 'company_id' => $this->auth->company_id, 'status' => 3, ]; /*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).'日'; } $this->assignconfig('ec_date',$ec_date); foreach($servicetype as $key => &$val){ $val['type'] = 'bar'; if($key == 0){ $val['barGap'] = 0; } $val['emphasis'] = ['focus'=>'series']; $val['data'] = []; $map['servicetype_id'] = $val['id']; 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']); } $this->assignconfig('servicetype',$servicetype); return $this->view->fetch(); } /** * 半年销售金额数据统计 */ public function datacenterthree2(){ $servicetype = Db::name('servicetype')->field('id,title as name')->select(); $servicename = array_column($servicetype,'name'); $this->assignconfig('servicename',$servicename); $thismonth = strtotime(date('Y-m-01')); $ec_date = []; $map = [ 'company_id' => $this->auth->company_id, 'status' => 3, ]; /*if($this->auth->type == 2){ $map['staff_id'] = $this->auth->id; }*/ for($i=5;$i>=0;$i--){ $starttime_i = strtotime("-".$i." month",$thismonth); $endtime_i = strtotime("-".($i-1) ." month",$thismonth) - 1; //日历 $ec_date[] = date('m',$starttime_i).'月'; //dump(date('Y-m-d H:i:s',$starttime_i)); //dump(date('Y-m-d H:i:s',$endtime_i)); } $this->assignconfig('ec_date',$ec_date); foreach($servicetype as $key => &$val){ $val['type'] = 'bar'; if($key == 0){ $val['barGap'] = 0; } $val['emphasis'] = ['focus'=>'series']; $val['data'] = []; $map['servicetype_id'] = $val['id']; for($i=5;$i>=0;$i-=1){ $starttime_i = strtotime("-".$i." month",$thismonth); $endtime_i = strtotime("-".($i-1) ." month",$thismonth) - 1; //销售金额 $map['finish_time'] = ['between',[$starttime_i,$endtime_i]]; $val['data'][] = Db::name('order')->where($map)->sum('total_fee'); } unset($val['id']); } $this->assignconfig('servicetype',$servicetype); return $this->view->fetch(); } /** * 业绩统计笔数 */ public function datacenterfour(){ $starttime = strtotime(date('Y-m-d',strtotime("-30 day"))); //默认30天前 $endtime = strtotime(date('Y-m-d')) - 1; //接收 $choicedatetime = input('choicedatetime',''); if(!empty($choicedatetime)){ $choicedatetime = explode(' - ',$choicedatetime); $starttime = strtotime($choicedatetime[0]); $endtime = strtotime($choicedatetime[1]) + 86399; } $this->view->assign('defaultdatetime',date('Y-m-d',$starttime).' - '.date('Y-m-d',$endtime)); $staff = Db::name('company_staff')->field('id,truename')->where('type',2)->where('company_id',$this->auth->company_id)->select(); //柱状图 $ec_date = []; $ec_ordernum = []; $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[] = Db::name('order')->where($map)->count('id'); } $this->assignconfig('ec_date', $ec_date); $this->assignconfig('ec_ordernum', $ec_ordernum); return $this->view->fetch(); } /** * 业绩统计金额 */ public function datacenterfive(){ $starttime = strtotime(date('Y-m-d',strtotime("-30 day"))); //默认30天前 $endtime = strtotime(date('Y-m-d')) - 1; //接收 $choicedatetime = input('choicedatetime',''); if(!empty($choicedatetime)){ $choicedatetime = explode(' - ',$choicedatetime); $starttime = strtotime($choicedatetime[0]); $endtime = strtotime($choicedatetime[1]) + 86399; } $this->view->assign('defaultdatetime',date('Y-m-d',$starttime).' - '.date('Y-m-d',$endtime)); $staff = Db::name('company_staff')->field('id,truename')->where('type',2)->where('company_id',$this->auth->company_id)->select(); //柱状图 $ec_date = []; $ec_ordernum = []; $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[] = Db::name('order')->where($map)->sum('total_fee'); } $this->assignconfig('ec_date', $ec_date); $this->assignconfig('ec_ordernum', $ec_ordernum); return $this->view->fetch(); } }