From da79ff44416c6df37926253075ac8c4d58903e94 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Mon, 16 Dec 2019 16:54:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=A7=92=E8=89=B2=E6=9D=83?= =?UTF-8?q?=E9=99=902?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...PresidentIndexChartSetController.class.php | 55 +++++++++++++------ 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/Application/Admin/Controller/PresidentIndexChartSetController.class.php b/Application/Admin/Controller/PresidentIndexChartSetController.class.php index a63f99bb0..d39ba23af 100644 --- a/Application/Admin/Controller/PresidentIndexChartSetController.class.php +++ b/Application/Admin/Controller/PresidentIndexChartSetController.class.php @@ -215,29 +215,50 @@ class PresidentIndexChartSetController extends AdminController { */ public function payUser() { + $newUserdata = []; $map = ['pay_time'=>['between',[$this->beginTime,$this->endTime]],'pay_status'=>1];//1支付成功 - $hoursnews = $this->SpendModel->field('FROM_UNIXTIME(pay_time, "%H") as time,COUNT(DISTINCT user_id) AS payuser') + $hoursnews = $this->SpendModel->field('FROM_UNIXTIME(pay_time, "%H") as time,GROUP_CONCAT(DISTINCT user_id) AS user_id') ->where($map) ->group("time") ->select(); - $hours = ['00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23']; - $user_hours = array(); - foreach($hours as $v) { - $user_hours[$v] = 0; + //按小时统计每个会长的信息 + for ($i=0; $i < count($hoursnews); $i++) { + $tempres = self::getPresidentCount($hoursnews[$i]['user_id'],"COUNT(1) AS news,IFNULL(p.account,'官方渠道') account,GROUP_CONCAT(DISTINCT u.id) AS pay_user_list"); + for($j=0; $j < count($tempres); $j++){ + $newUserdata[$tempres[$j]['p_id']]["hoursnews"][$hoursnews[$i]['time']] = $tempres[$j]['news']; + $newUserdata[$tempres[$j]['p_id']]["president_account"]= $tempres[$j]['account']; + $newUserdata[$tempres[$j]['p_id']]["president_id"]= $tempres[$j]['p_id']; + $newUserdata[$tempres[$j]['p_id']]["pay_user_list"] .= (",".$tempres[$j]['pay_user_list']); + } } - foreach($hoursnews as $h) { - $user_hours[$h['time']] = (integer)$h['payuser']; + //拼凑小时 + foreach ($newUserdata as $k=>&$v) { + $h = $v['hoursnews']; + $t = []; + $hours = ['00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23']; + foreach($hours as $ht) { + if(isset($h[$ht])){ + $t[] = $h[$ht]; + }else{ + $t[] = 0; + } + } + unset($v["hoursnews"]); + $v["pay_user_hours"] = json_encode(array_map("intFun",$t)); + $ta = array_values(array_flip(array_flip(explode(",",trim($v["pay_user_list"],","))))); + $v["pay_user_count"] = count($ta); + $v["pay_user_list"] = json_encode($ta); + + if(array_key_exists($v['president_id'],$this->President_data)){ + $this->President_data[$v['president_id']]['pay_user_hours'] = $v["pay_user_hours"]; + $this->President_data[$v['president_id']]['pay_user_count'] = $v["pay_user_count"]; + $this->President_data[$v['president_id']]['pay_user_list'] = $v["pay_user_list"]; + }else{ + $this->President_data[$v['president_id']] = $v; + } } - $this->adddata["pay_user_hours"] = json_encode($user_hours); - unset($user_hours); - $activeCount = $this->SpendModel->field('user_id') - ->where($map) - ->group('user_id') - ->select(); - - $this->adddata["pay_user_count"] = count($activeCount); - $this->adddata["pay_user_list"] = json_encode(array_map("intFun",array_column($activeCount,'user_id'))); - unset($activeCount); + unset($newUserdata); + unset($hoursnews); } /** * 充值金额计算