@ -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,COU NT(DISTINCT user_id) AS pay user')
$hoursnews = $this->SpendModel->field('FROM_UNIXTIME(pay_time, "%H") as time,GROUP_ CONCA T(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);
}
/**
* 充值金额计算