diff --git a/config/define.php b/config/define.php index 05e3d65..d38fcc0 100644 --- a/config/define.php +++ b/config/define.php @@ -11,6 +11,8 @@ date_default_timezone_set("Asia/Shanghai"); + define('BEIAN', '鲁ICP备14002313号-1'); + define('LOG_PATH_BASE', DATACENTER_ROOT.'/logs/'); define('LOG_TRACK_SAVE_PATH', LOG_PATH_BASE.'track/%s/%s.log'); // 监控日志的路径,如2014-02-14/1(检测类型).log diff --git a/control/index.php b/control/index.php index 240a86c..cfea969 100644 --- a/control/index.php +++ b/control/index.php @@ -16,7 +16,7 @@ class index extends publicBase { $this->view['menu_page'] = 'home'; } - public function ajax_get_data() { + public function ajax_get_charts_data() { $shopinfo = $this->get_shopinfo(); $uid = $shopinfo['uid']; $shop_id = $shopinfo['id']; @@ -214,4 +214,11 @@ class index extends publicBase { return $nlist; } + public function logout() { + unset($_SESSION['app_uid']); + unset($_SESSION['app_name']); + header('Location:/index'); + exit(); + } + } diff --git a/model/mOrder.php b/model/mOrder.php index e74a0a0..42333a8 100644 --- a/model/mOrder.php +++ b/model/mOrder.php @@ -301,24 +301,33 @@ class mOrder extends mBase { } public function getSumData($uid, $shop_id, $day=7) { - $default_date = date("Y-m-d"); + $end_time = date("Y-m-d").' 23:59:59'; + + $dates = array(); if ($day == 7) { - $week = $this->getWeekStartEndDate($default_date); - $start_time = $week['start'].' 00:00:00'; - $end_time = $week['end'].' 23:59:59'; + $start_time = date("Y-m-d", strtotime('-6 day')).' 00:00:00'; + + for ($i=0;$i<7;$i++) { + $dates[] = date("Y-m-d", strtotime('-'.$i.' day')); + } - $sql = 'select sum(`pay_amount`) as sumgroup,DATE_FORMAT(`pay_time`,"%Y-%m-%d") as dategroup from '.$this->order.' where `uid`='.$uid.' and `shop_id`='.$shop_id.' and `pay_time`>="'.$start_time.'" and `pay_time`<="'.$end_time.'" group by DATE_FORMAT(`pay_time`,"%Y-%m-%d")'; + $sql = 'select IFNULL(sum(`pay_amount`), 0) as sumgroup,DATE_FORMAT(`pay_time`,"%Y-%m-%d") as dategroup from '.$this->order.' where `uid`='.$uid.' and `shop_id`='.$shop_id.' and `pay_time`>="'.$start_time.'" and `pay_time`<="'.$end_time.'" group by DATE_FORMAT(`pay_time`,"%Y-%m-%d")'; } elseif ($day == 30) { - $start_time = date("Y-m-01").' 00:00:00'; - $end_time = date("Y-m-t").' 23:59:59'; + $start_time = date("Y-m-d", strtotime('-29 day')).' 00:00:00'; + for ($i=0;$i<29;$i++) { + $dates[] = date("Y-m-d", strtotime('-'.$i.' day')); + } $sql = 'select sum(`pay_amount`) as sumgroup,DATE_FORMAT(`pay_time`,"%Y-%m-%d") as dategroup from '.$this->order.' where `uid`='.$uid.' and `shop_id`='.$shop_id.' and `pay_time`>="'.$start_time.'" and `pay_time`<="'.$end_time.'" group by DATE_FORMAT(`pay_time`,"%Y-%m-%d")'; } elseif ($day == 365) { - $start_time = date("Y-01-01").' 00:00:00'; - $end_time = date("Y-12-31").' 23:59:59'; + $start_time = date("Y-m-d", strtotime('-1 year')).' 00:00:00'; + + for ($i=0;$i<12;$i++) { + $dates[] = date("Y-m", strtotime('-'.$i.' month')); + } $sql = 'select sum(`pay_amount`) as sumgroup,DATE_FORMAT(`pay_time`,"%Y-%m") as dategroup from '.$this->order.' where `uid`='.$uid.' and `shop_id`='.$shop_id.' and `pay_time`>="'.$start_time.'" and `pay_time`<="'.$end_time.'" group by DATE_FORMAT(`pay_time`,"%Y-%m")'; @@ -328,49 +337,73 @@ class mOrder extends mBase { if (!$res) return array(); $date2sum = array(); - foreach ($res[0] as $info) { + foreach ($res as $info) { $date2sum[$info['dategroup']] = $info['sumgroup']; } + $dates = array_reverse($dates); + + $data = array(); + foreach ($dates as $date) { + $data[$date] = $date2sum[$date] ? $date2sum[$date] : 0; + } + unset($res); + unset($date2sum); - return $date2sum; + return $data; } public function getRefundCountData($uid, $shop_id, $day=7) { - $default_date = date("Y-m-d"); + $end_time = date("Y-m-d").' 23:59:59'; + + $dates = array(); if ($day == 7) { - $week = $this->getWeekStartEndDate($default_date); - $start_time = $week['start'].' 00:00:00'; - $end_time = $week['end'].' 23:59:59'; + $start_time = date("Y-m-d", strtotime('-6 day')).' 00:00:00'; + + for ($i=0;$i<7;$i++) { + $dates[] = date("Y-m-d", strtotime('-'.$i.' day')); + } $sql = 'select count(*) as countgroup,DATE_FORMAT(`pay_time`,"%Y-%m-%d") as dategroup from '.$this->order.' where `uid`='.$uid.' and `shop_id`='.$shop_id.' and `refund_status` != '.REFUND_STATUS_NO_AFTER_SALES.' and `pay_time`>="'.$start_time.'" and `pay_time`<="'.$end_time.'" group by DATE_FORMAT(`pay_time`,"%Y-%m-%d")'; } elseif ($day == 30) { - $start_time = date("Y-m-01").' 00:00:00'; - $end_time = date("Y-m-t").' 23:59:59'; + $start_time = date("Y-m-d", strtotime('-29 day')).' 00:00:00'; + for ($i=0;$i<29;$i++) { + $dates[] = date("Y-m-d", strtotime('-'.$i.' day')); + } $sql = 'select count(*) as countgroup,DATE_FORMAT(`pay_time`,"%Y-%m-%d") as dategroup from '.$this->order.' where `uid`='.$uid.' and `shop_id`='.$shop_id.' and `refund_status` != '.REFUND_STATUS_NO_AFTER_SALES.' and `pay_time`>="'.$start_time.'" and `pay_time`<="'.$end_time.'" group by DATE_FORMAT(`pay_time`,"%Y-%m-%d")'; } elseif ($day == 365) { - $start_time = date("Y-01-01").' 00:00:00'; - $end_time = date("Y-12-31").' 23:59:59'; + $start_time = date("Y-m-d", strtotime('-1 year')).' 00:00:00'; - $sql = 'select count(*) as countgroup,DATE_FORMAT(`pay_time`,"%Y-%m") as dategroup from '.$this->order.' where `uid`='.$uid.' and `shop_id`='.$shop_id.' and `refund_status` != '.REFUND_STATUS_NO_AFTER_SALES.' and `pay_time`>="'.$start_time.'" and `pay_time`<="'.$end_time.'" group by DATE_FORMAT(`pay_time`,"%Y-%m")'; + for ($i=0;$i<12;$i++) { + $dates[] = date("Y-m", strtotime('-'.$i.' month')); + } + $sql = 'select count(*) as countgroup,DATE_FORMAT(`pay_time`,"%Y-%m") as dategroup from '.$this->order.' where `uid`='.$uid.' and `shop_id`='.$shop_id.' and `refund_status` != '.REFUND_STATUS_NO_AFTER_SALES.' and `pay_time`>="'.$start_time.'" and `pay_time`<="'.$end_time.'" group by DATE_FORMAT(`pay_time`,"%Y-%m")'; } $res = $this->obj->execute($sql, true, true); if (!$res) return array(); $date2count = array(); - foreach ($res[0] as $info) { + foreach ($res as $info) { $date2count[$info['dategroup']] = $info['countgroup']; } + $dates = array_reverse($dates); + + $data = array(); + foreach ($dates as $date) { + $data[$date] = $date2count[$date] ? $date2count[$date] : 0; + } + unset($res); + unset($date2count); - return $date2count; + return $data; } } \ No newline at end of file diff --git a/view/templates/include/admin_header.html b/view/templates/include/admin_header.html index d340f92..f830801 100644 --- a/view/templates/include/admin_header.html +++ b/view/templates/include/admin_header.html @@ -27,7 +27,7 @@