@ -1990,28 +1997,51 @@ class ExportController extends Controller
$map['tp1.chain'] = '/';
}
$data = M('promote', 'tab_')->alias('tp1')->field('tp1.account as promote_account,tp1.id as promote_id, date_format(FROM_UNIXTIME(register_time),"%Y-%m-%d") AS time, count(u.id) as count,
$data = M('promote', 'tab_')->alias('tp1')->field('tp1.account as promote_account,tp1.id, date_format(FROM_UNIXTIME(register_time),"%Y-%m-%d") AS time, count(u.id) as count,
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 AS tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%')", 'left')
->join("tab_promote AS tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%') OR tp2.id = tp1.id", 'left')
->join("tab_user as u on tp2.id = u.promote_id", 'left')
->join($play_info_map ? "tab_user_play_info as upi on upi.user_id = u.id " . $play_info_map : false)
->where($map)
->group('tp1.id')
->order('count desc, register_time')
->select();
unset($map['tp1.id']);
unset($map['tp1.chain']);
$map['promote_id'] = 0;
//官方渠道数据添加
$authorityData = M('user', 'tab_')->field('date_format(FROM_UNIXTIME(register_time),"%Y-%m-%d") AS time, count(id) as count,
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')
->where($map)
->find();
$authorityData['promote_account'] = "官方渠道";
$authorityData['id'] = "1";
if (isset($_REQUEST['promote_id'])||$authorityData['count']==0) {
$authorityData = [];
} else {
array_push($data, $authorityData);
}
//数据排序
$last_names = array_column($data,'count');
array_multisort($last_names,SORT_DESC,$data);
// var_dump($data);die();
$count=count($data);
foreach ($data as $key => $value) {
static $i=0;
$i++;
$data[$key]['rand']=$i;
}
foreach ($data as $key => $value) {
if($data[$key]['promote_id']==0){
unset($data[$key]);
}
}
// foreach ($data as $key => $value) {
// if($data[$key]['promote_id']==0){
// unset($data[$key]);
// }
// }
$total=A('Platform')->data_total($data);
if($_REQUEST['data_order']!=''){
@ -2027,24 +2057,27 @@ class ExportController extends Controller