游戏充值导出修正

master
zhengyongxing 5 years ago
parent 059742043c
commit ba85fc8c76

@ -922,28 +922,76 @@ class ExportController extends Controller
} else { } else {
$total = sprintf("%.2f", $total); $total = sprintf("%.2f", $total);
} }
$xlsCell = array(
"订单号", "充值时间", "玩家账号", "游戏名称", L('Subordinate_channel'), "充值ip", "游戏区服",
"角色名称", "订单金额", "实付金额", "充值方式", L('Order_status'), "游戏通知状态", "消费"."{$total}"
);
$csvFileName = $xlsName.'.csv';
//设置好告诉浏览器要下载excel文件的headers
header('Content-Description: File Transfer');
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment; filename="'. $csvFileName .'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
$fp = fopen('php://output', 'a');//打开output流
mb_convert_variables('GBK', 'UTF-8', $xlsCell);
fputcsv($fp, $xlsCell);//将数据格式化为CSV格式并写入到output流中
$accessNum = D('Spend')
->field('pay_order_number,pay_time,user_account,game_name,promote_account,spend_ip,server_name,game_player_name,cost,pay_amount,pay_way,pay_status,pay_game_status')
->where($map)
->join($tab_promote_join)
->order('pay_time DESC')
->count();
$perSize = 10000;//每次查询的条数
$pages = ceil($accessNum / $perSize);
// var_dump($count);die();
for($i = 1; $i <= $pages; $i++) {
$xlsData = D('Spend') $xlsData = D('Spend')
->field('pay_order_number,pay_time,user_account,game_name,promote_account,spend_ip,pay_amount,pay_amount,pay_status,pay_game_status,pay_way,server_name,game_player_name,cost') ->field('pay_order_number,pay_time,user_account,game_name,promote_account,spend_ip,server_name,game_player_name,cost,pay_amount,pay_way,pay_status,pay_game_status')
->where($map) ->where($map)
->limit(($i-1)*$perSize ,$perSize)
->join($tab_promote_join) ->join($tab_promote_join)
->order('pay_time DESC') ->order('pay_time DESC')
->select(); ->select();
$xlsCell = array(
array('pay_order_number', "订单号"), foreach($xlsData as $value) {
array('pay_time', "充值时间", 'time_format', '*'), $value['pay_time'] = date('Y-m-d H:i:s',$value['pay_time']);
array('user_account', "玩家账号"), $value['pay_way'] = get_pay_way($value['pay_way']);
array('game_name', "游戏名称"), $value['pay_status'] = get_info_status($value['pay_status'],9);
array('promote_account', L('Subordinate_channel')), $value['pay_game_status'] = get_info_status($value['pay_game_status'],14);
array('spend_ip', "充值ip"), mb_convert_variables('GBK', 'UTF-8', $value);
array('server_name', "游戏区服"), fputcsv($fp, $value);
array('game_player_name', "角色名称"), }
array('cost', "订单金额"), unset($xlsData);//释放变量的内存
array('pay_amount', "实付金额"), //刷新输出缓冲到浏览器
array('pay_way', "充值方式", 'get_pay_way', '*'), ob_flush();
array('pay_status', L('Order_status'), 'get_info_status', '*', '9'), flush();//必须同时使用 ob_flush() 和flush() 函数来刷新输出缓冲。
array('pay_game_status', "游戏通知状态", 'get_info_status', '*', '14'), }
array('', "消费"."{$total}") fclose($fp);
); exit();
// $xlsCell = array(
// array('pay_order_number', "订单号"),
// array('pay_time', "充值时间", 'time_format', '*'),
// array('user_account', "玩家账号"),
// array('game_name', "游戏名称"),
// array('promote_account', L('Subordinate_channel')),
// array('spend_ip', "充值ip"),
// array('server_name', "游戏区服"),
// array('game_player_name', "角色名称"),
// array('cost', "订单金额"),
// array('pay_amount', "实付金额"),
// array('pay_way', "充值方式", 'get_pay_way', '*'),
// array('pay_status', L('Order_status'), 'get_info_status', '*', '9'),
// array('pay_game_status', "游戏通知状态", 'get_info_status', '*', '14'),
// array('', "消费"."{$total}")
// );
break; break;
case 8: case 8:
$xlsName = $xlsName?$xlsName:L('Platform_currency_recharge'); $xlsName = $xlsName?$xlsName:L('Platform_currency_recharge');

Loading…
Cancel
Save