@ -120,6 +129,22 @@ class PromoteController extends BaseController
$user_count = 0;
}
$today=total(1);
$week=total(2);
$mounth=total(3);
//计算今日的统计数据
$data=M('User','tab_')
->field('promote_account,promote_id,date_format(FROM_UNIXTIME(register_time),"%Y-%m-%d") AS time, count(tab_user.id) as count,
IF(tab_promote.grand_id>0,tab_promote.grand_id,IF(tab_promote.grand_id=0 and tab_promote.parent_id >0,tab_promote.parent_id,promote_id)) as promote_id1 ,
count(IF(register_time '.$today.',1,null)) as today,
count(IF(register_time '.$week.',1,null)) as week,
count(IF(register_time '.$mounth.',1,null)) as mounth')
->join('tab_promote on promote_id = tab_promote.id','left')
->field('promote_account,promote_id,date_format(FROM_UNIXTIME(register_time),"%Y-%m-%d") AS time, count(tab_user.id) as count,
IF(tab_promote.grand_id>0,tab_promote.grand_id,IF(tab_promote.grand_id=0 and tab_promote.parent_id >0,tab_promote.parent_id,promote_id)) as promote_id1 ,
count(IF(register_time '.$today.',1,null)) as today,
count(IF(register_time '.$week.',1,null)) as week,
count(IF(register_time '.$mounth.',1,null)) as mounth')
->join('tab_promote on promote_id = tab_promote.id','left')
->field('max(id) as id,promote_account,promote_id,create_time as ordertime,date_format(FROM_UNIXTIME(create_time),"%Y-%m-%d") AS time,
floor(sum(IF(create_time '.$pay_time.',real_amount,0))*100) as scount,
floor(sum(IF(create_time '.$today.',real_amount,0))*100) as today,
floor(sum(IF(create_time '.$week.',real_amount,0))*100) as week,
floor(sum(IF(create_time '.$mounth.',real_amount,0))*100) as mounth')
->where($map1)
->group('promote_id')
->select(false);
$deposit_data = M('deposit','tab_')
->field('max(id) as id,promote_account,promote_id,create_time as ordertime,date_format(FROM_UNIXTIME(create_time),"%Y-%m-%d") AS time,
floor(sum(IF(create_time '.$pay_time.',pay_amount,0))*100) as scount,
floor(sum(IF(create_time '.$today.',pay_amount,0))*100) as today,
floor(sum(IF(create_time '.$week.',pay_amount,0))*100) as week,
floor(sum(IF(create_time '.$mounth.',pay_amount,0))*100) as mounth')
// ->join('tab_user on tab_user.id = tab_spend.user_id','left')
->where($map1)
->group('promote_id')
->select(false);
$spendData=$spend
->field('max(id) as id,promote_account,promote_id,pay_time as ordertime,date_format(FROM_UNIXTIME(pay_time),"%Y-%m-%d") AS time,
floor(sum(IF(pay_time '.$pay_time.',pay_amount,0))*100) as scount,
floor(sum(IF(pay_time '.$today.',pay_amount,0))*100) as today,
floor(sum(IF(pay_time '.$week.',pay_amount,0))*100) as week,
floor(sum(IF(pay_time '.$mounth.',pay_amount,0))*100) as mounth')
// ->join('tab_user on tab_user.id = tab_spend.user_id','left')
->where($map)
->union(' ('.$bindrecharge_data.') ')
->union(' ('.$deposit_data.') ')
->group('promote_id')
->select(false);
$spendData = $spend->field('a.promote_account,a.promote_id,a.time,sum(a.scount) as count,sum(a.today) as today,sum(a.week) as week,sum(a.mounth) as mounth,IF(tab_promote.grand_id>0,tab_promote.grand_id,IF(tab_promote.grand_id=0 and tab_promote.parent_id >0,tab_promote.parent_id,promote_id)) as promote_id1')
->join('tab_promote on promote_id = tab_promote.id','left')
->where($condition)
->table('('.$spendData.') as a')->group('promote_id1')->order('count desc,a.ordertime')->find();
$spendData['rand']=1;
$spendData['count']=$spendData['count']/100;
$spendData['today']=$spendData['today']/100;
$spendData['week']=$spendData['week']/100;
$spendData['mounth']=$spendData['mounth']/100;
return $spendData;
}
private function pay_total($type = 0, $newadd = 1,$promoteId="")
{
if ($_REQUEST['promote_id'] === null || $_REQUEST['promote_id'] === '0') {