diff --git a/Application/Admin/Controller/StatController.class.php b/Application/Admin/Controller/StatController.class.php index 3f3ee2da9..e6a7d1252 100644 --- a/Application/Admin/Controller/StatController.class.php +++ b/Application/Admin/Controller/StatController.class.php @@ -1375,7 +1375,7 @@ class StatController extends ThinkController $model = M('device_statistics','tab_'); if ($type == 0) { - $return = $model->sum('new_device'); + $return = $model->where(array('time'=>array('neq',0)))->sum('new_device'); // $return = $device->all_device(); } else if($type == 1) { $return = $model->where(['time'=>array('between',[$todaystart,$todaystart+86399])])->sum('new_device'); diff --git a/Application/Admin/Controller/TimingController.class.php b/Application/Admin/Controller/TimingController.class.php index 5cd2b799a..2a089ff0e 100644 --- a/Application/Admin/Controller/TimingController.class.php +++ b/Application/Admin/Controller/TimingController.class.php @@ -141,9 +141,15 @@ class TimingController extends AdminController { //当日新增设备 $newSql = M('device_record','tab_')->field('min(create_time) as create_time,model,unique_code,id')->where(['version'=>1])->group('unique_code')->select(false); $data['new_device'] = M('device_record','tab_')->table('(' . $newSql . ') as a')->where(['create_time'=>array('between',[$startTime,$startTime+86399])])->order('create_time')->count(); + $data['time'] = $startTime; echo $data['new_device'].' '; + $duration = $this->duration(['create_time'=>array('between',[$startTime-86400*7,$startTime-1])]); + $newSqls = M('device_record','tab_')->field('min(create_time) as create_time,model,unique_code,id')->group('unique_code')->select(false); + $data['duration7'] = ($duration/M('device_record','tab_')->table('(' . $newSqls . ') as a')->where(['create_time'=>array('between',[$startTime-86400*7,$startTime-1])])->order('create_time')->count())/7; + $data['version'] = 1; + $getStatistics = M('device_statistics','tab_')->where(['time'=>$startTime,'version'=>1])->find(); echo "\n"; if (!$getStatistics) { @@ -151,13 +157,14 @@ class TimingController extends AdminController { } else { M('device_statistics','tab_')->where(['time'=>$startTime,'version'=>1])->save($data); } - + $data['duration7'] = 0; echo date("Y-m-d",$startTime).' 苹果 '; //当日新增设备 $newSql = M('device_record','tab_')->field('min(create_time) as create_time,model,unique_code,id')->where(['version'=>2])->group('unique_code')->select(false); $data['new_device'] = M('device_record','tab_')->table('(' . $newSql . ') as a')->where(['create_time'=>array('between',[$startTime,$startTime+86399])])->order('create_time')->count(); echo $data['new_device'].' '; + $data['version'] = 2; $getStatistics = M('device_statistics','tab_')->where(['time'=>$startTime,'version'=>2])->find(); echo "\n";