From 876268c3b7789fe347e182b46b8f169b1bbc1f7b Mon Sep 17 00:00:00 2001 From: sunke <18850253506@163.com> Date: Mon, 2 Dec 2019 19:03:13 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=BB=93=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/DownloadController.class.php | 206 +++++++++++------- 1 file changed, 127 insertions(+), 79 deletions(-) diff --git a/Application/Home/Controller/DownloadController.class.php b/Application/Home/Controller/DownloadController.class.php index c8fa36a90..5441ff6c8 100644 --- a/Application/Home/Controller/DownloadController.class.php +++ b/Application/Home/Controller/DownloadController.class.php @@ -2491,18 +2491,18 @@ class DownloadController extends BaseController { public function settlementExcelInfo($id,$map) { $xlsName = "结算明细"; $xlsCell = array( - array('pay_order_number','游戏订单号'), - array('game_name','游戏'), - array('user_account','玩家账号'), - array('promote_account','推广员账号'), - array('pay_amount','订单总额'), - array('pay_amount_zhi','直充'), - array('pay_amount_nei','内充'), - array('selle_ratio','分成比例(直充)'), - array('selle_ratio','分成比例(内充)'), - array('income','收益'), - array('pay_time','充值时间'), - array('selle_status','订单状态'), + '游戏订单号', + '游戏', + '玩家账号', + '推广员账号', + '订单总额', + '直充', + '内充', + '分成比例(直充)', + '分成比例(内充)', + '收益', + '充值时间', + '订单状态', ); $model = M('spend', 'tab_'); $data = $model->field('pay_order_number,game_name,user_account,promote_account,pay_amount,pay_way,if(selle_ratio >= 0,selle_ratio,0) as selle_ratio,pay_time,selle_status,pay_status,withdraw_id') @@ -2518,66 +2518,114 @@ class DownloadController extends BaseController { $total['income'] = empty($total['income']) ? 0 : $total['income']; $total['income'] = bcdiv($total['income'], 100, 2); //提现状态 - $withdrawIds = []; - foreach ($data as $key => $value) { - if ($value['withdraw_id'] > 0 && !in_array($value['withdraw_id'], $withdrawIds)) { - $withdrawIds[] = $value['withdraw_id']; - } - } - if(empty($withdrawIds)) { - $withdrawIds = "-10000"; - } - $withdrawStatus = M('withdraw', 'tab_') - ->where(array('id' => ['in',$withdrawIds])) - ->getField('id,status'); + $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('gb2312', 'UTF-8', $xlsCell); + fputcsv($fp, $xlsCell);//将数据格式化为CSV格式并写入到output流中 + $accessNum = count($data)?:0 ; - foreach ($data as &$list) { - //提现状态 - $list['pay_order_number'] = $this->encryption($list['pay_order_number']); - $list['user_account'] = $this->encryption($list['user_account']); - if ($list['pay_status'] == 1) { - switch ($list['selle_status']) { - case 0: - $list['selle_status'] = '未提现'; - break; - default: - if ($list['withdraw_id'] > 0) { - $list['selle_status'] = FinanceController::$withdrawStatus[$withdrawStatus[$list['withdraw_id']]]; - } else { - $list['selle_status'] = ''; - } - break; + $perSize = 5000;//每次查询的条数 + $pages = ceil($accessNum / $perSize); + for($i = 1; $i <= $pages; $i++) { + + $data = $model->field('pay_order_number,game_name,user_account,promote_account,pay_amount,pay_way,if(selle_ratio >= 0,selle_ratio,0) as selle_ratio,pay_time,selle_status,pay_status,withdraw_id') + ->where($map) + ->order('id desc') + ->limit(($i-1)*$perSize ,$perSize) + ->select(); + $withdrawIds = []; + foreach ($data as $key => $value) { + if ($value['withdraw_id'] > 0 && !in_array($value['withdraw_id'], $withdrawIds)) { + $withdrawIds[] = $value['withdraw_id']; } - } else { - $list['selle_status'] = '支付失败'; } - - $list['income'] = bcmul($list['pay_amount'], bcdiv($list['selle_ratio'], 100, 2), 2); - $list['pay_time'] = date('Y-m-d H:i:s', $list['pay_time']); - if($list['pay_way'] == -1) { - $list['pay_amount_zhi'] = 0; - $list['pay_amount_nei'] = $list['pay_amount']; - }else { - $list['pay_amount_zhi'] = $list['pay_amount']; - $list['pay_amount_nei'] = 0; + if(empty($withdrawIds)) { + $withdrawIds = "-10000"; } - } + $withdrawStatus = M('withdraw', 'tab_') + ->where(array('id' => ['in',$withdrawIds])) + ->getField('id,status'); + + foreach ($data as &$list) { + //提现状态 + $list['pay_order_number'] = $this->encryption($list['pay_order_number']); + $list['user_account'] = $this->encryption($list['user_account']); + if ($list['pay_status'] == 1) { + switch ($list['selle_status']) { + case 0: + $list['selle_status'] = '未提现'; + break; + default: + if ($list['withdraw_id'] > 0) { + $list['selle_status'] = FinanceController::$withdrawStatus[$withdrawStatus[$list['withdraw_id']]]; + } else { + $list['selle_status'] = ''; + } + break; + } + } else { + $list['selle_status'] = '支付失败'; + } + + $list['income'] = bcmul($list['pay_amount'], bcdiv($list['selle_ratio'], 100, 2), 2); + $list['pay_time'] = date('Y-m-d H:i:s', $list['pay_time']); + if($list['pay_way'] == -1) { + $list['pay_amount_zhi'] = 0; + $list['pay_amount_nei'] = $list['pay_amount']; + }else { + $list['pay_amount_zhi'] = $list['pay_amount']; + $list['pay_amount_nei'] = 0; + } + + + $csvData["pay_order_number"] = $list["pay_order_number"]; + $csvData["game_name"] = $list["game_name"]; + $csvData["user_account"] = $list["user_account"]; + $csvData["promote_account"] = $list["promote_account"]; + $csvData["pay_amount"] = $list["pay_amount"]; + $csvData["pay_amount_zhi"] = $list["pay_amount_zhi"]; + $csvData["pay_amount_nei"] = $list["pay_amount_nei"]; + $csvData["selle_ratio"] = $list["selle_ratio"]; + $csvData["selle_ratio"] = $list["selle_ratio"]; + $csvData["income"] = $list["income"]; + $csvData["pay_time"] = $list["pay_time"]; + $csvData["selle_status"] = $list["selle_status"]; + mb_convert_variables('GBK', 'UTF-8', $csvData); + fputcsv($fp, $csvData); + $xlsData[] = $csvData; + } + $allData['pay_order_number'] = '合计'; + $allData['game_name'] = '--'; + $allData['user_account'] = '--'; + $allData['promote_account'] = '--'; + $allData['pay_amount'] = $total['pay_amount']; + $allData['pay_amount_zhi'] = $total['direct_pay_amount']; + $allData['pay_amount_nei'] = $total['inner_pay_amount']; + $allData['selle_ratio'] = '--'; + $allData['selle_ratio'] = '--'; + $allData['income'] = $total['income']; + $allData['pay_time'] = '--'; + $allData['selle_status'] = '--'; + mb_convert_variables('GBK', 'UTF-8', $allData); + fputcsv($fp, $allData); + $xlsData[] = $allData; + fclose($fp); + unset($xlsData); + ob_flush(); + flush(); + $this->backSuccessExport($id); + } + + - $allData['pay_order_number'] = '合计'; - $allData['game_name'] = '--'; - $allData['user_account'] = '--'; - $allData['promote_account'] = '--'; - $allData['pay_amount'] = $total['pay_amount']; - $allData['pay_amount_zhi'] = $total['direct_pay_amount']; - $allData['pay_amount_nei'] = $total['inner_pay_amount']; - $allData['selle_ratio'] = '--'; - $allData['selle_ratio'] = '--'; - $allData['income'] = $total['income']; - $allData['pay_time'] = '--'; - $allData['selle_status'] = '--'; - $data[] = $allData; - $xlsData = $data; - $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); + // $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); } @@ -2932,21 +2980,21 @@ class DownloadController extends BaseController { ->find(); foreach ($roles as $role) { $records[] = [ - 'user_account' => encryption($role['user_account']), - 'game_name' => $role['game_name'], - 'role_name' => $role['role_name'], - 'role_id' => $role['role_id'], - 'role_level' => $role['role_level'], - 'server_id' => $role['server_id'], - 'server_name' => $role['server_name'], + 'user_account' => empty($role['user_account']) ? '--' : encryption($role['user_account']), + 'game_name' => empty($role['game_name']) ? '--' : $role['game_name'], + 'role_name' => empty($role['role_name']) ? '--' : $role['role_name'], + 'role_id' => empty($role['role_id']) ? '--' : $role['role_id'], + 'role_level' => empty($role['role_level']) ? '--' : $role['role_level'], + 'server_id' => empty($role['server_id']) ? '--' : $role['server_id'], + 'server_name' => empty($role['server_name']) ? '--' : $role['server_name'], 'recharge_cost' => empty($role['recharge_cost']) ? 0 : $role['recharge_cost'], 'recharge_count' => empty($role['recharge_count']) ? 0 : $role['recharge_count'], 'recharge_cost_today' => empty($role['recharge_cost_today']) ? 0 : $role['recharge_cost_today'], - 'play_time' => $role['play_time'], - 'play_ip' => $role['play_ip'], - 'promote_id' => $role['promote_id'], - 'promote_account' => $role['promote_account'], - 'sdk_version' => $role['sdk_version'], + 'play_time' => empty($role['play_time']) ? '--' : $role['play_time'], + 'play_ip' => empty($role['play_ip']) ? '--' : $role['play_ip'], + 'promote_id' => empty($role['promote_id']) ? '--' : $role['promote_id'], + 'promote_account' => empty($role['promote_account']) ? '--' : $role['promote_account'], + 'sdk_version' => empty($role['sdk_version']) ? '--' : $role['sdk_version'], 'unlogin_day' => intval((strtotime(date('Y-m-d 00:00:00')) - strtotime(date('Y-m-d 00:00:00', $role['play_time']))) / (24 * 3600)) ]; } From e5891a9d4514ddb38d0aa2f6d24315510c068b1e Mon Sep 17 00:00:00 2001 From: sunke <18850253506@163.com> Date: Mon, 2 Dec 2019 19:06:24 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=BB=93=E7=AE=97=E6=98=8E=E7=BB=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/DownloadController.class.php | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/Application/Home/Controller/DownloadController.class.php b/Application/Home/Controller/DownloadController.class.php index 5441ff6c8..20c9b3b22 100644 --- a/Application/Home/Controller/DownloadController.class.php +++ b/Application/Home/Controller/DownloadController.class.php @@ -2601,28 +2601,28 @@ class DownloadController extends BaseController { fputcsv($fp, $csvData); $xlsData[] = $csvData; } - $allData['pay_order_number'] = '合计'; - $allData['game_name'] = '--'; - $allData['user_account'] = '--'; - $allData['promote_account'] = '--'; - $allData['pay_amount'] = $total['pay_amount']; - $allData['pay_amount_zhi'] = $total['direct_pay_amount']; - $allData['pay_amount_nei'] = $total['inner_pay_amount']; - $allData['selle_ratio'] = '--'; - $allData['selle_ratio'] = '--'; - $allData['income'] = $total['income']; - $allData['pay_time'] = '--'; - $allData['selle_status'] = '--'; - mb_convert_variables('GBK', 'UTF-8', $allData); - fputcsv($fp, $allData); - $xlsData[] = $allData; - fclose($fp); unset($xlsData); ob_flush(); flush(); - $this->backSuccessExport($id); } + $allData['pay_order_number'] = '合计'; + $allData['game_name'] = '--'; + $allData['user_account'] = '--'; + $allData['promote_account'] = '--'; + $allData['pay_amount'] = $total['pay_amount']; + $allData['pay_amount_zhi'] = $total['direct_pay_amount']; + $allData['pay_amount_nei'] = $total['inner_pay_amount']; + $allData['selle_ratio'] = '--'; + $allData['selle_ratio'] = '--'; + $allData['income'] = $total['income']; + $allData['pay_time'] = '--'; + $allData['selle_status'] = '--'; + mb_convert_variables('GBK', 'UTF-8', $allData); + fputcsv($fp, $allData); + $xlsData[] = $allData; + fclose($fp); + $this->backSuccessExport($id); // $this->exportExcel($xlsName, $xlsCell, $xlsData,$id);