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(); foreach($servicetype as $key => &$val){ $whereop['servicetype_id'] = $val['id']; $val['value'] = Db::name('order')->where($whereop)->count('id'); unset($val['id']); } $this->assignconfig('servicetype', $servicetype); return $this->view->fetch(); } }