From ff713b9ea339afe773943699385113d76a11d960 Mon Sep 17 00:00:00 2001 From: chenxiaojun <956334972@qq.com> Date: Tue, 3 Dec 2019 11:40:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A8=E5=B9=BF=E5=B9=B3=E5=8F=B0->=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=AE=A1=E7=90=86->=E5=85=85=E5=80=BC=E7=8E=A9?= =?UTF-8?q?=E5=AE=B6->=E5=AF=BC=E5=87=BA--=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/DownloadController.class.php | 191 ++++++++++-------- 1 file changed, 107 insertions(+), 84 deletions(-) diff --git a/Application/Home/Controller/DownloadController.class.php b/Application/Home/Controller/DownloadController.class.php index a45607e66..1711a1f6d 100644 --- a/Application/Home/Controller/DownloadController.class.php +++ b/Application/Home/Controller/DownloadController.class.php @@ -1135,8 +1135,8 @@ class DownloadController extends BaseController { public function recharge_data_export() { $beginTime = strtotime(I('begtime') . ' 00:00:00'); $endtime = strtotime(I('endtime') . ' 23:59:59'); - if (($endtime - $beginTime) > 7 * 24 * 3600) { - $this->error('时间范围不能超过7天'); + if (($endtime - $beginTime) > 31 * 24 * 3600) { + $this->error('时间范围不能超过31天'); } $map1['chain'] = ['like','%'.'/'.PID.'/'.'%']; $rs = M('promote','tab_')->where($map1)->field('id,account,nickname')->select(); @@ -3068,88 +3068,111 @@ class DownloadController extends BaseController { $perSize = 5000;//每次查询的条数 $pages = ceil($accessNum / $perSize); - for($i = 1; $i <= $pages; $i++) { - $model = M('spend','tab_'); - $data = $model - ->field('tab_spend.*,tab_promote.account as pro_account,tab_promote.real_name as pro_real_name,tab_promote.chain as chain') - ->join('tab_game on tab_spend.game_id = tab_game.id') - ->join('left join tab_promote on tab_spend.promote_id = tab_promote.id') - ->where($map) - ->limit(($i-1)*$perSize ,$perSize) - ->order('tab_spend.id desc') - ->select(); - foreach ($data as $key1 => $value1) { - $value1['pay_way'] = $this->payWay[$value1['pay_way']]; - $value1['pay_time'] = date('Y-m-d H:i:s',$value1['pay_time']); - $value1['p_p_proinfo'] = $value1['pro_account'].'('.$value1['pro_real_name'].')'; - $value1['p_proinfo'] = $value1['pro_account'].'('.$value1['pro_real_name'].')'; - $value1['proinfo'] = $value1['pro_account'].'('.$value1['pro_real_name'].')'; - // $value1['user_account'] = substr_replace($value1['user_account'],'************',3,12); - $value1['user_account'] = $this->encryption($value1['user_account']); - $value1['pay_order_number'] = $this->encryption($value1['pay_order_number']); - if(!empty($value1['chain'])) { - $chain = trim($value1['chain'],'/'); - $chainArr = explode('/', $chain); - if(!empty($chainArr[1])) { - $thisPromoteData1 = D('Promote') - ->field('account,real_name') - ->where(array('id' => $chainArr[1])) - ->find(); - $value1['p_p_proinfo'] = $thisPromoteData1['account'].'('.$thisPromoteData1['real_name'].')'; //部门长 - } - if(!empty($chainArr[2])) { - $thisPromoteData2 = D('Promote') - ->field('account,real_name') - ->where(array('id' => $chainArr[2])) - ->find(); - $value1['p_proinfo'] = $thisPromoteData2['account'].'('.$thisPromoteData2['real_name'].')'; //组长 - } - - - } - $csvData["user_account"] = $value1["user_account"]; - $csvData["pay_order_number"] = $value1["pay_order_number"]; - $csvData["pay_amount"] = $value1["pay_amount"]; - $csvData["pay_way"] = $value1["pay_way"]; - $csvData["game_name"] = $value1["game_name"]; - $csvData["server_name"] = $value1["server_name"]; - $csvData["game_player_name"] = $value1["game_player_name"]; - $csvData["p_p_proinfo"] = $value1["p_p_proinfo"]; - $csvData["p_proinfo"] = $value1["p_proinfo"]; - $csvData["proinfo"] = $value1["proinfo"]; - $csvData["pay_time"] = $value1["pay_time"]; - mb_convert_variables('GBK', 'UTF-8', $csvData); - fputcsv($fp, $csvData); - $xlsData[] = $csvData; - } - unset($xlsData); - ob_flush(); - flush(); - } - $income = '0.00'; - $income = M('Spend', 'tab_') - ->field('sum(tab_spend.pay_amount) as income') - ->join('tab_game on tab_spend.game_id = tab_game.id') - ->join('left join tab_promote on tab_spend.promote_id = tab_promote.id') - ->where($map) - ->order('tab_spend.id desc') - ->find()['income']; - $csvData1["user_account"] = "合计"; - $csvData1["pay_order_number"] = "--"; - $csvData1["pay_amount"] = $income; - $csvData1["pay_way"] = "--"; - $csvData1["game_name"] = "--"; - $csvData1["server_name"] = "--"; - $csvData1["game_player_name"] = "--"; - $csvData1["p_p_proinfo"] = "--"; - $csvData1["p_proinfo"] = "--"; - $csvData1["proinfo"] = "--"; - $csvData1["pay_time"] = "--"; - mb_convert_variables('GBK', 'UTF-8', $csvData1); - fputcsv($fp, $csvData1); - $xlsData[] = $csvData1; - fclose($fp); - $this->backSuccessExport($id); + $promoteIdData = []; + $promoteData = []; + for($i = 1; $i <= $pages; $i++) { + $model = M('spend','tab_'); + $data = $model + ->field('tab_spend.*,tab_promote.account as pro_account,tab_promote.real_name as pro_real_name,tab_promote.chain as chain,tab_promote.level,tab_promote.parent_id') + ->join('tab_game on tab_spend.game_id = tab_game.id') + ->join('left join tab_promote on tab_spend.promote_id = tab_promote.id') + ->where($map) + ->limit(($i-1)*$perSize ,$perSize) + ->order('tab_spend.id desc') + ->select(); + foreach ($data as $list) { + switch ($list['level']) { + case 3: + $promoteIdData[] = $list['parent_id']; + break; + case 4: + $promoteIdData[] = $list['parent_id']; + $chain = trim($list['chain'], '/'); + $chainArr = explode('/', $chain); + $promoteIdData[] = $chainArr[1]; + break; + } + } + if (!empty($promoteIdData)) { + $promoteIdData = array_unique($promoteIdData); + $promoteData = M('promote', 'tab_')->where(array('id' => ['in',$promoteIdData]))->getField('id,account,real_name'); + } + foreach ($data as $key1 => $value1) { + $value1['pay_way'] = $this->payWay[$value1['pay_way']]; + $value1['pay_time'] = date('Y-m-d H:i:s',$value1['pay_time']); + $value1['p_p_proinfo'] = $value1['pro_account'].'('.$value1['pro_real_name'].')'; + $value1['p_proinfo'] = $value1['pro_account'].'('.$value1['pro_real_name'].')'; + $value1['proinfo'] = $value1['pro_account'].'('.$value1['pro_real_name'].')'; + // $value1['user_account'] = substr_replace($value1['user_account'],'************',3,12); + $value1['user_account'] = $this->encryption($value1['user_account']); + $value1['pay_order_number'] = $this->encryption($value1['pay_order_number']); + switch ($value1['level']) { + case 3: + $value1['p_p_pro_account'] = $promoteData[$value1['parent_id']]['account']; + $value1['p_p_pro_real_name'] = $promoteData[$value1['parent_id']]['real_name']; + $value1['p_pro_account'] = $value1['pro_account']; + $value1['p_pro_real_name'] = $value1['pro_real_name']; + break; + case 4: + $promoteIdData[] = $value1['parent_id']; + $chain = trim($value1['chain'], '/'); + $chainArr = explode('/', $chain); + $value1['p_p_pro_account'] = $promoteData[$chainArr[1]]['account']; + $value1['p_p_pro_real_name'] = $promoteData[$chainArr[1]]['real_name']; + $value1['p_pro_account'] = $promoteData[$value1['parent_id']]['account']; + $value1['p_pro_real_name'] = $promoteData[$value1['parent_id']]['real_name']; + break; + } + $value1['p_p_proinfo'] = $value1['p_p_pro_account'].'('.$value1['p_p_pro_real_name'].')'; //部门长 + $value1['p_proinfo'] = $value1['p_pro_account'].'('.$value1['p_pro_real_name'].')'; //组长 + unset($value1['p_p_pro_account']); + unset($value1['p_p_pro_real_name']); + unset($value1['p_pro_account']); + unset($value1['p_pro_real_name']); + + $csvData["user_account"] = $value1["user_account"]; + $csvData["pay_order_number"] = $value1["pay_order_number"]; + $csvData["pay_amount"] = $value1["pay_amount"]; + $csvData["pay_way"] = $value1["pay_way"]; + $csvData["game_name"] = $value1["game_name"]; + $csvData["server_name"] = $value1["server_name"]; + $csvData["game_player_name"] = $value1["game_player_name"]; + $csvData["p_p_proinfo"] = $value1["p_p_proinfo"]; + $csvData["p_proinfo"] = $value1["p_proinfo"]; + $csvData["proinfo"] = $value1["proinfo"]; + $csvData["pay_time"] = $value1["pay_time"]; + mb_convert_variables('GBK', 'UTF-8', $csvData); + fputcsv($fp, $csvData); + $xlsData[] = $csvData; + } + unset($xlsData); + ob_flush(); + flush(); + } + $income = '0.00'; + $income = M('Spend', 'tab_') + ->field('sum(tab_spend.pay_amount) as income') + ->join('tab_game on tab_spend.game_id = tab_game.id') + ->join('left join tab_promote on tab_spend.promote_id = tab_promote.id') + ->where($map) + ->order('tab_spend.id desc') + ->find()['income']; + $csvData1["user_account"] = "合计"; + $csvData1["pay_order_number"] = "--"; + $csvData1["pay_amount"] = $income; + $csvData1["pay_way"] = "--"; + $csvData1["game_name"] = "--"; + $csvData1["server_name"] = "--"; + $csvData1["game_player_name"] = "--"; + $csvData1["p_p_proinfo"] = "--"; + $csvData1["p_proinfo"] = "--"; + $csvData1["proinfo"] = "--"; + $csvData1["pay_time"] = "--"; + mb_convert_variables('GBK', 'UTF-8', $csvData1); + fputcsv($fp, $csvData1); + $xlsData[] = $csvData1; + fclose($fp); + $this->backSuccessExport($id); } public function backSuccessExport($id) { //导出成功后