From 8f36f7204ffcee86acd49beb690fd43741ad3d0f Mon Sep 17 00:00:00 2001 From: chenzhi <“chenzhi063@qq.com> Date: Wed, 27 Nov 2019 18:21:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=A6=96=E9=A1=B5=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/IndexController.class.php | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/Application/Admin/Controller/IndexController.class.php b/Application/Admin/Controller/IndexController.class.php index f779e3c5f..8a47b995f 100644 --- a/Application/Admin/Controller/IndexController.class.php +++ b/Application/Admin/Controller/IndexController.class.php @@ -260,14 +260,24 @@ class IndexController extends AdminController { $count1 = array(); $active_user_list = []; $pay_user_list = []; - $dbdata = M("IndexChart","tab_")->field("new_user_count,active_user_count,active_user_list,pay_user_count,pay_user_list,pay_money_count,promote_new_count") - ->where($map)->select(); + $dbdata = M("IndexChart","tab_")->field("FROM_UNIXTIME(`date`, '%Y-%m-%d') as time,new_user_count,active_user_count,active_user_list,pay_user_count,pay_user_list,pay_money_count,promote_new_count") + ->where($map) + ->group("time") + ->select(); + //替换数据 + $temparr = array(); + for ($i=0; $i < count($datelist); $i++) { + $temparr[$datelist[$i]]['news'] = 0; + $temparr[$datelist[$i]]['active'] = 0; + $temparr[$datelist[$i]]['player'] = 0; + $temparr[$datelist[$i]]['money'] = 0; + } foreach($dbdata as $k => $v) { - $data['news'][$k] = $v['new_user_count']; - $data['active'][$k] = $v['active_user_count']; - $data['player'][$k] = $v['pay_user_count']; - $data['money'][$k] = $v['pay_money_count']; + $temparr[$v['time']]['news'] =$v['new_user_count']; + $temparr[$v['time']]['active'] =$v['active_user_count']; + $temparr[$v['time']]['player'] =$v['pay_user_count']; + $temparr[$v['time']]['money'] =$v['pay_money_count']; $active_user_list += json_decode($v['active_user_list'],true); unset($v['active_user_list']); unset($dbdata[$k]['active_user_list']); @@ -278,6 +288,14 @@ class IndexController extends AdminController { $count1['pay_money_count'] += $v['pay_money_count']; $count1['promote_new_count'] += $v['promote_new_count']; } + foreach ($temparr as $key => $value) { + # code... + $data['news'][] = $value['news']; + $data['active'][] = $value['active']; + $data['player'][] = $value['player']; + $data['money'][] = $value['money']; + } + unset($dbdata); $count1['active_user_count'] = count(array_flip(array_flip($active_user_list))); unset($active_user_list);