Merge branch 'dev' of 47.111.118.107:/srv/git/platform into dev

master
chenzhi 5 years ago
commit 3cde3f0a12

@ -1966,11 +1966,18 @@ class ExportController extends Controller
if(isset($_REQUEST['timestart'])&&isset($_REQUEST['timeend'])){
$map['register_time'] =array('BETWEEN',array(strtotime($_REQUEST['timestart']),strtotime($_REQUEST['timeend'])+24*60*60-1));
unset($_REQUEST['timestart']);unset($_REQUEST['timeend']);
} elseif (!empty($_REQUEST['timestart']) && empty($_REQUEST['timeend'])) {
$map['register_time'] = ['between', array(strtotime($_REQUEST['timestart']), time())];
unset($_REQUEST['timestart']);
} elseif (empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) {
$map['register_time'] = ['elt', strtotime($_REQUEST['timeend']) + 86399];
unset($_REQUEST['timeend']);
}
if(isset($_REQUEST['start'])&&isset($_REQUEST['end'])){
$map['register_time'] =array('BETWEEN',array(strtotime($_REQUEST['start']),strtotime($_REQUEST['end'])+24*60*60-1));
unset($_REQUEST['start']);unset($_REQUEST['end']);
}
// if(isset($_REQUEST['start'])&&isset($_REQUEST['end'])){
// $map['register_time'] =array('BETWEEN',array(strtotime($_REQUEST['start']),strtotime($_REQUEST['end'])+24*60*60-1));
// unset($_REQUEST['start']);unset($_REQUEST['end']);
// }
$play_info_map = '';
if (isset($_REQUEST['game_name'])) {
@ -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
}
$data=my_sort($data,$data_order_type,(int)$data_order);
$size=$row;//每页显示的记录数
$pnum = ceil(count($data) / $size); //总页数ceil()函数用于求大于数字的最小整数
//用array_slice(array,offset,length) 函数在数组中根据条件取出一段值;array(数组),offset(元素的开始位置),length(组的长度)
$data = array_slice($data, ($arraypage-1)*$size, $size);
// $data = array_slice($data, ($arraypage-1)*$size, $size);
$xlsName = $_REQUEST['xlsname']?$_REQUEST['xlsname']:'推广员注册统计';
$xlsCell = array(
array('promote_id', "推广员账号"),
array('promote_account', "推广员账号"),
array('count' , "累计注册"),
array('rand' , "排行榜"),
array('today' , "今日注册"),
array('week' , "本周注册"),
array('mounth' , "本月注册"),
);
foreach ($data as $key => $value) {
$data[$key]['promote_id'] = get_promote_account($data[$key]['promote_id']);
}
// foreach ($data as $key => $value) {
// $data[$key]['promote_id'] = get_promote_account($data[$key]['promote_id']);
// }
// var_dump($data);die();
$length = count($data);
$data[$length] = array(
'promote_id'=>'汇总',
'promote_account'=>'汇总',
'count'=>$total['sum_count'],
'rand'=>'---',
'today'=>$total['sum_today'],
@ -2052,6 +2085,7 @@ class ExportController extends Controller
'mounth'=>$total['sum_mounth']
);
$xlsData = $data;
// var_dump($xlsData);die();
$this->exportExcel($xlsName, $xlsCell, $xlsData);
}

Loading…
Cancel
Save