@ -403,134 +403,6 @@ class StatisticsController extends ThinkController {
}
/**
* 排行榜(推广员)
* @param string $nowtime 现在时间段( between 开始时间戳 and 结束时间戳)
* @param string $othertime 过去时间段( between 开始时间戳 and 结束时间戳)
* @return array 结果集
* @author lwx
*/
private function promote_data_order2($nowtime,$othertime){
$user = M("User","tab_");
$spend = M('Spend',"tab_");
$chart1 = [];
$chart2 = [];
$chart3 = [];
//今日注册排行
$ri_ug_order=$user->field('tab_user.promote_id,tab_promote.account as promote_account,count(tab_user.id) as cg')
->join('tab_promote on (tab_promote.id = tab_user.promote_id)','left')
->where(array('register_time'.$nowtime,'promote_id'=>array('gt',0),'puid'=>0))
->group('promote_id')->order('cg desc')->limit(10)->select();
$ri_ug_order=array_order($ri_ug_order);
$regids = array_column($ri_ug_order,'promote_id');
if ($regids) {
$yes_ug_order=$user->field('tab_user.promote_id,tab_promote.account as promote_account,count(tab_user.id) as cg')
->join('tab_promote on (tab_promote.id = tab_user.promote_id)')
->where([array('register_time'.$othertime,'promote_id'=>array('gt',0),'puid'=>0),array('register_time'.$othertime,'promote_id'=>array('in',$regids),'puid'=>0),'_logic'=>'or'])
->group('promote_id')->order('cg desc')->select();
$yes_ug_order=array_order($yes_ug_order);
// dump($ri_ug_order);
// dump($yes_ug_order);exit;
foreach ($ri_ug_order as $key => $value) {
$ri_ug_order[$key]['change'] = $value['rand']-count($ri_ug_order)-1;
$chart1['p'.$value['promote_id']] = $value;
foreach ($yes_ug_order as $k => $v) {
if($value['promote_id']==$v['promote_id']){
$ri_ug_order[$key]['change']=$value['rand']-$v['rand'];break;
}
}
}
}
// //今日活跃排行
$duser = D('User');
$ri_active_order = $duser->activeRankOnPromote($nowtime,'cg');
$ri_active_order=array_order($ri_active_order);
$activeids = array_column($ri_active_order,'promote_id');
if ($activeids) {
$yes_active = $duser->activeRankOnPromote($othertime,'cg',$activeids);
$yes_active=array_order($yes_active);
foreach ($ri_active_order as $key => $value) {
$ri_active_order[$key]['change'] = $value['rand']-count($ri_active_order)-1;
$chart2['p'.$value['promote_id']] = $value;
foreach ($yes_active as $k => $v) {
if($value['promote_id']==$v['promote_id']){
$ri_active_order[$key]['change']=$value['rand']-$v['rand'];break;
}
}
}
}
// //充值排行
//spend
$ri_spay_sql=$spend->field('tab_spend.promote_id,tab_promote.account as promote_account,sum(pay_amount) as cg')
->join('tab_promote on(tab_spend.promote_id = tab_promote.id)')
->union('select promote_id,tab_promote.account as promote_account,sum(pay_amount) as cg from tab_deposit inner join tab_promote on(tab_promote.id = tab_deposit.promote_id) where pay_status=1 and promote_id>0 and tab_deposit.create_time '.$nowtime.' group by promote_id ')
->where(array('pay_time'.$nowtime,'promote_id'=>array('gt',0),'pay_status'=>1))
->group('promote_id')->select(false);
$ri_spay_order = $spend->field('promote_id,promote_account,sum(cg) as cg')->table('('.$ri_spay_sql.') as a')->group('promote_id')->order('cg desc')->limit(10)->select();
$ri_spay_order=array_order($ri_spay_order);
$payids = array_column($ri_spay_order,'promote_id');
if ($payids) {
$yes_spay_sql=$spend->field('tab_spend.promote_id,tab_promote.account as promote_account,sum(pay_amount) as cg')
->join('tab_promote on(tab_spend.promote_id = tab_promote.id)')
->union('select promote_id,tab_promote.account as promote_account,sum(pay_amount) as cg from tab_deposit inner join tab_promote on(tab_promote.id = tab_deposit.promote_id) where pay_status=1 and promote_id>0 and tab_deposit.create_time '.$othertime.' group by promote_id ')
->where([array('pay_status'=>1,'pay_time'.$othertime,'promote_id'=>array('gt',0)),array('pay_time'.$othertime,'promote_id'=>array('in',$payids)),'_logic'=>'or'])
->group('promote_id')->select(false);
$yes_spay=$spend->field('promote_id,promote_account,sum(cg) as cg')->table('('.$yes_spay_sql.') as a')->group('promote_id')->order('cg desc')->select();
$yes_spay=array_order($yes_spay);
foreach ($ri_spay_order as $key => $value) {
$ri_spay_order[$key]['change'] = $value['rand']-count($ri_spay_order)-1;
$chart3['p'.$value['promote_id']] = $value;
foreach ($yes_spay as $k => $v) {
if($value['promote_id']==$v['promote_id']){
$ri_spay_order[$key]['change']=$value['rand']-$v['rand'];
}
}
}
}
$data['reg']=$ri_ug_order;
$data['active']=$ri_active_order;
$data['pay']=$ri_spay_order;
$chart4 = array_merge($chart1,$chart2,$chart3);
foreach($chart4 as $k => $v) {
$chart['promote'][$k] = $v['promote_account'];
foreach($chart1 as $c) {
$chart['reg'][$k] = 0;
if ($v['promote_id'] == $c['promote_id']) {
$chart['reg'][$k] = (integer)$c['cg'];break;
}
}
foreach($chart2 as $c) {
$chart['active'][$k] = 0;
if ($v['promote_id'] == $c['promote_id']) {
$chart['active'][$k] = (integer)$c['cg'];break;
}
}
foreach($chart3 as $c) {
$chart['pay'][$k] = 0;
if ($v['promote_id'] == $c['promote_id']) {
$chart['pay'][$k] = $c['cg'];break;
}
}
}
foreach($chart as $k => $v) {
if ($k == 'promote')
$data['chart'][$k] = '"'.implode('","',$v).'"';
else
$data['chart'][$k] = implode(',',$v);
}
return $data;
}
}
/**
/**
* 获取游戏排行
* 获取游戏排行
@ -637,7 +509,7 @@ class StatisticsController extends ThinkController {
}
}
//设置排名
//设置排名
public function setRand($randdata,$oldrand,$field = "promote_id")
private function setRand($randdata,$oldrand,$field = "promote_id")
{
{
//数据是否为空
//数据是否为空
$rcount = count($randdata);
$rcount = count($randdata);