@ -55,19 +55,30 @@ class ExportController extends Controller
$xlsName = $_REQUEST['xlsname'];
$xlsName = $_REQUEST['xlsname'];
switch ($id) {
switch ($id) {
case 1:
case 1:
// $xlsCell = array(
$showMarketAdmin = session('user_auth')['show_market_admin'];
// array('user_account', "玩家账号"),
$showPromote = session('user_auth')['show_promote'];
// array('game_name', "游戏名称"),
$headers = [
// array('server_name', L('Game_area_clothing')),
'create_time' => '创建时间',
// array('role_name', "角色名"),
'user_account' => '玩家账号',
// array('role_level', "游戏等级"),
'game_name' => '游戏名称',
// array('play_time', "最后登录时间", 'time_format', '*'),
'server_id' => '游戏区服',
// array('play_ip', "最后登录ip"),
'server_name' => L('Game_area_clothing'),
// );
'role_id' => '角色ID',
$xlsCell = array(
'role_name' => '角色名',
"创建时间","玩家账号", "游戏名称","游戏区服", L('Game_area_clothing'), "角色ID", "角色名", "游戏等级","推广员ID", "所属推广员",
'role_level' => '游戏等级',
"最后登录时间", '最后登录ip','所属市场专员'
'promote_id' => '所属市场专员',
);
'promote_account' => '所属推广员',
'play_time' => '最后登录时间',
'play_ip' => '最后登录ip',
];
if ($showMarketAdmin == 0) {
unset($headers['promote_id']);
}
if ($showPromote == 0) {
unset($headers['promote_account']);
}
$xlsCell = array_values($headers);
$fields = array_keys($headers);
if (isset($_REQUEST['game_name'])) {
if (isset($_REQUEST['game_name'])) {
$map['game_name'] = ['like', trim($_REQUEST['game_name'])."%"];
$map['game_name'] = ['like', trim($_REQUEST['game_name'])."%"];
unset($_REQUEST['game_name']);
unset($_REQUEST['game_name']);
@ -95,14 +106,6 @@ class ExportController extends Controller
$map = withMarketAdminCondition($map, I('market_admin_id', 0));
$map = withMarketAdminCondition($map, I('market_admin_id', 0));
// $promoteRoot = getPowerPromoteIds();
// $data_empower_type = session('user_auth')['data_empower_type'];
//
// if ($promoteRoot) {
// $map['promote_id'] =array('in',$promoteRoot);
// } else if(!$promoteRoot& & $data_empower_type!=1){
// $map['id'] = array('lt',1);
// }
setPowerPromoteIds($map,'promote_id');
setPowerPromoteIds($map,'promote_id');
if (isset($_REQUEST['promote_id'])) {
if (isset($_REQUEST['promote_id'])) {
@ -140,26 +143,30 @@ class ExportController extends Controller
->where($map)
->where($map)
->order('play_time desc')
->order('play_time desc')
->count();
->count();
// $accessNum =$accessNum['count'];
$perSize = 5000;//每次查询的条数
$perSize = 5000;//每次查询的条数
$pages = ceil($accessNum / $perSize);
$pages = ceil($accessNum / $perSize);
$lastId = 0;
$lastId = 0;
for($i = 1; $i < = $pages; $i++) {
for($i = 1; $i < = $pages; $i++) {
$xlsData = M('user_play_info', 'tab_')
$xlsData = M('user_play_info', 'tab_')
->field("create_time,user_account,game_name,server_id,server_name,role_id,role_name,role_level,promote_id,promote_account,play_time,play_ip" )
->field($fields )
->where($map)
->where($map)
->limit(($i-1)*$perSize ,$perSize)
->limit(($i-1)*$perSize ,$perSize)
->order('play_time desc')
->order('play_time desc')
->select();
->select();
$adminList = getMarketAdminsByPromoteIds(array_column($xlsData, 'promote_id'));
if ($showMarketAdmin == 1) {
$adminList = getMarketAdminsByPromoteIds(array_column($xlsData, 'promote_id'));
}
foreach($xlsData as $value) {
foreach($xlsData as $value) {
($value['promote_account']=='官方渠道'||$value['promote_account']=='自然注册')?($value['promote_account']=C('OFFICIEL_CHANNEL')):'';
if ($showPromote == 1) {
$value['market_admin_username'] = isset($adminList[$value['promote_id']]) & & $adminList[$value['promote_id']]['admin'] ? $adminList[$value['promote_id']]['admin']['username'] : '无';
($value['promote_account']=='官方渠道'||$value['promote_account']=='自然注册')?($value['promote_account']=C('OFFICIEL_CHANNEL')):'';
}
if ($showMarketAdmin == 1) {
$value['promote_id'] = isset($adminList[$value['promote_id']]) & & $adminList[$value['promote_id']]['admin'] ? $adminList[$value['promote_id']]['admin']['username'] : '无';
}
$value['create_time'] = date("Y-m-d H:i:s",$value['create_time']);
$value['create_time'] = date("Y-m-d H:i:s",$value['create_time']);
$value['play_time'] = date("Y-m-d H:i:s",$value['play_time']);
$value['play_time'] = date("Y-m-d H:i:s",$value['play_time']);
mb_convert_variables('GBK', 'UTF-8', $value);
mb_convert_variables('GBK', 'UTF-8', $value);
@ -1149,14 +1156,6 @@ class ExportController extends Controller
$map['market_admin_id'] = $userAuth['uid'];
$map['market_admin_id'] = $userAuth['uid'];
}
}
// $promoteRoot = getPowerPromoteIds();
// $data_empower_type = session('user_auth')['data_empower_type'];
//
// if ($promoteRoot) {
// $map['promote_id'] =array('in',$promoteRoot);
// } else if(!$promoteRoot& & $data_empower_type!=1){
// $map['id'] = array('lt',1);
// }
setPowerPromoteIds($map,'promote_id');
setPowerPromoteIds($map,'promote_id');
if (isset($_REQUEST['promote_id'])) {
if (isset($_REQUEST['promote_id'])) {
@ -1204,11 +1203,42 @@ class ExportController extends Controller
// var_dump($total);die();
// var_dump($total);die();
$total=$total?$total:0;
$total=$total?$total:0;
$showMarketAdmin = session('user_auth')['show_market_admin'];
$showPromote = session('user_auth')['show_promote'];
$headers = [
'pay_order_number' => '支付订单号',
'extend' => 'CP订单号',
'pay_time' => '充值时间',
'payed_time' => '支付时间',
'user_account' => '玩家账号',
'game_name' => '游戏名称',
'promote_account' => L('Subordinate_channel'),
'0 as company_name' => '所属推广公司',
'market_admin_id' => '所属市场专员',
'merchant_id' => '所属商户',
'spend_ip' => '充值ip',
'server_id' => '区服ID',
'server_name' => '游戏区服',
'game_player_id' => '角色ID',
'game_player_name' => '角色名称',
'cost' => '订单金额',
'pay_amount' => '实付金额',
'pay_way' => '充值方式',
'pay_status' => L('Order_status'),
'pay_game_status' => '游戏通知状态',
'promote_id' => "消费"."{$total}",
];
$xlsCell = array(
if ($showMarketAdmin == 0) {
"支付订单号","CP订单号", "充值时间","支付时间", "玩家账号", "游戏名称", L('Subordinate_channel'), "所属推广公司", "所属市场专员","所属商户", "充值ip","区服ID", "游戏区服",
unset($headers['market_admin_id']);
"角色ID","角色名称", "订单金额", "实付金额", "充值方式", L('Order_status'), "游戏通知状态", "消费"."{$total}"
}
);
if ($showPromote == 0) {
unset($headers['promote_account']);
}
$xlsCell = array_values($headers);
$fields = array_keys($headers);
$csvFileName = $xlsName.'.csv';
$csvFileName = $xlsName.'.csv';
//设置好告诉浏览器要下载excel文件的headers
//设置好告诉浏览器要下载excel文件的headers
@ -1232,20 +1262,14 @@ class ExportController extends Controller
// var_dump($count);die();
// var_dump($count);die();
for($i = 1; $i < = $pages; $i++) {
for($i = 1; $i < = $pages; $i++) {
$xlsData = D('Spend')
$xlsData = D('Spend')
// ->field('pay_order_number,extend,pay_time,user_account,game_name,promote_account,spend_ip,server_id,server_name,game_player_id,game_player_name,cost,pay_amount,pay_way,pay_status,pay_game_status')
->field($fields)
// ->where($map)
// ->limit(($i-1)*$perSize ,$perSize)
// ->join($tab_promote_join)
// ->order('pay_time DESC')
// ->select();
->field('pay_order_number,extend,pay_time,payed_time,user_account,game_name,promote_account, 0 as company_name,market_admin_id,merchant_id,spend_ip,server_id,server_name,game_player_id,game_player_name,cost,pay_amount,pay_way,pay_status,pay_game_status, promote_id')
// ->join('tab_promote on tab_promote.id = tab_spend.promote_id', 'left')
// ->join('tab_promote_company on tab_promote_company.id and tab_promote.company_id', 'left')
->where($map)
->where($map)
->limit(($i-1)*$perSize ,$perSize)
->limit(($i-1)*$perSize ,$perSize)
->order($order ? $order : 'pay_time desc')
->order($order ? $order : 'pay_time desc')
->select();
->select();
$adminUsernameList = getAdminUsernameList(array_column($xlsData, 'market_admin_id'));
if ($showMarketAdmin == 1) {
$adminUsernameList = getAdminUsernameList(array_column($xlsData, 'market_admin_id'));
}
$promoters = D('Promote')->where(['id'=>['in', array_unique(array_column($xlsData, 'promote_id'))]])->field('id, company_id')->select();
$promoters = D('Promote')->where(['id'=>['in', array_unique(array_column($xlsData, 'promote_id'))]])->field('id, company_id')->select();
$promoters = $promoters ? array_column($promoters, 'company_id', 'id') : [];
$promoters = $promoters ? array_column($promoters, 'company_id', 'id') : [];
$companys = $promoters ? M('promote_company', 'tab_')->where(['id'=>['in', array_unique(array_values($promoters))]])->field('id, company_name')->select() : [];
$companys = $promoters ? M('promote_company', 'tab_')->where(['id'=>['in', array_unique(array_values($promoters))]])->field('id, company_name')->select() : [];
@ -1262,13 +1286,17 @@ class ExportController extends Controller
}
}
$value['merchant_id'] = getMerchantName($value['merchant_id']);
$value['merchant_id'] = getMerchantName($value['merchant_id']);
checkEncryptionAuth($value['user_account'],'spend_lists');
checkEncryptionAuth($value['user_account'],'spend_lists');
// $value['user_account'] = encryption($value['user_account']);
($value['promote_account']=='官方渠道'||$value['promote_account']=='自然注册')?($value['promote_account']=C('OFFICIEL_CHANNEL')):'';
if ($showPromote == 1) {
($value['promote_account']=='官方渠道'||$value['promote_account']=='自然注册')?($value['promote_account']=C('OFFICIEL_CHANNEL')):'';
}
$value['extend'] = $value['extend'].'`';
$value['extend'] = $value['extend'].'`';
$value['pay_way'] = get_pay_way($value['pay_way']);
$value['pay_way'] = get_pay_way($value['pay_way']);
$value['pay_status'] = get_info_status($value['pay_status'],9);
$value['pay_status'] = get_info_status($value['pay_status'],9);
$value['pay_game_status'] = get_info_status($value['pay_game_status'],14);
$value['pay_game_status'] = get_info_status($value['pay_game_status'],14);
$value['market_admin_id'] = $adminUsernameList[$value['market_admin_id']] ?? '无';
if ($showMarketAdmin == 1) {
$value['market_admin_id'] = $adminUsernameList[$value['market_admin_id']] ?? '无';
}
mb_convert_variables('GBK', 'UTF-8', $value);
mb_convert_variables('GBK', 'UTF-8', $value);
fputcsv($fp, $value);
fputcsv($fp, $value);
}
}
@ -4152,6 +4180,16 @@ class ExportController extends Controller
['retention_day30', '30日留存'],
['retention_day30', '30日留存'],
];
];
if (session('user_auth')['show_promote'] == 0) {
foreach ($xlsCell as $key => $item) {
if ($item[0] == 'promote_name') {
unset($xlsCell[$key]);
break;
}
}
$xlsCell = array_values($xlsCell);
}
$GetData = $_GET;
$GetData = $_GET;
unset($GetData['xlsname']);
unset($GetData['xlsname']);