From 968bf2c067658811774e7dfef185070c164a10d0 Mon Sep 17 00:00:00 2001 From: chenxiaojun <956334972@qq.com> Date: Mon, 2 Dec 2019 17:34:00 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E8=84=9A=E6=9C=AC=EF=BC=9A=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=8E=A8=E5=B9=BF=E5=91=98=E6=95=B0=E6=8D=AE=E5=88=B7?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/Controller/AutoController.class.php | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Application/Admin/Controller/AutoController.class.php b/Application/Admin/Controller/AutoController.class.php index 4ccc0022e..5193fce76 100644 --- a/Application/Admin/Controller/AutoController.class.php +++ b/Application/Admin/Controller/AutoController.class.php @@ -961,12 +961,14 @@ public function auto_rrdae(){ { $map['promote_id'] = ['gt', 0]; $map['_string'] = "promote_account = '' or promote_account = '自然注册' or promote_account = '官方渠道' or promote_account is NULL"; - $userData = M('user', 'tab_')->field('id,promote_id')->where($map)->select(); - $userPlayData = M('user_play', 'tab_')->field('id,promote_id')->where($map)->select(); - $userPlayInfoData = M('user_play_info', 'tab_')->field('id,promote_id')->where($map)->select(); + $userModel = M('user', 'tab_'); + $userPlayModel = M('user_play', 'tab_'); + $userPlayInfoModel = M('user_play_info', 'tab_'); + $userData = $userModel->field('id,promote_id')->where($map)->select(); + $userPlayData = $userPlayModel->field('id,promote_id')->where($map)->select(); + $userPlayInfoData = $userPlayInfoModel->field('id,promote_id')->where($map)->select(); $promoteData = []; - $userModel = 'tab_user'; $userRet = $this->updateUserPromoteAccountSql($userModel, $userData, $promoteData); $userSuccess = $userRet['success']; $userError = $userRet['error']; @@ -975,7 +977,6 @@ public function auto_rrdae(){ $userAll = count($userData); unset($userData); - $userPlayModel = 'tab_user_play'; $userPlayRet = $this->updateUserPromoteAccountSql($userPlayModel, $userPlayData, $promoteData); $userPlaySuccess = $userPlayRet['success']; $userPlayError = $userPlayRet['error']; @@ -984,7 +985,6 @@ public function auto_rrdae(){ $userPlayAll = count($userPlayData); unset($userPlayData); - $userPlayInfoModel = 'tab_user_play_info'; $userPlayInfoRet = $this->updateUserPromoteAccountSql($userPlayInfoModel, $userPlayInfoData, $promoteData); $userPlayInfoSuccess = $userPlayInfoRet['success']; $userPlayInfoError = $userPlayInfoRet['error']; @@ -993,11 +993,11 @@ public function auto_rrdae(){ $userPlayInfoAll = count($userPlayInfoData); unset($userPlayInfoData); - echo $userModel . ":all--{$userAll} success--{$userSuccess} error--{$userError} error_ids--{$userErrorData}"; + echo "tab_user:all--{$userAll} success--{$userSuccess} error--{$userError} error_ids--{$userErrorData}"; echo '
'; - echo $userPlayModel . ":all--{$userPlayAll} success--{$userPlaySuccess} error--{$userPlayError} error_ids--{$userPlayErrorData}"; + echo "tab_user_play:all--{$userPlayAll} success--{$userPlaySuccess} error--{$userPlayError} error_ids--{$userPlayErrorData}"; echo '
'; - echo $userPlayInfoModel . ":all--{$userPlayInfoAll} success--{$userPlayInfoSuccess} error--{$userPlayInfoError} error_ids--{$userPlayInfoErrorData}"; + echo "tab_user_play_info:all--{$userPlayInfoAll} success--{$userPlayInfoSuccess} error--{$userPlayInfoError} error_ids--{$userPlayInfoErrorData}"; echo '
'; } @@ -1015,7 +1015,9 @@ public function auto_rrdae(){ $promoteData[$list['promote_id']] = $promoteAccount; } - $res = M()->query("update `$model` set promote_account = '{$promoteAccount}' where id = {$list['id']}"); + $save['id'] = $list['id']; + $save['promote_account'] = $promoteAccount; + $res = $model->save($save); if ($res === false) { $error++; $errorData = $list['id']; From 42ae540dc3bf4acf515e154d19379511eb35fea8 Mon Sep 17 00:00:00 2001 From: chenxiaojun <956334972@qq.com> Date: Mon, 2 Dec 2019 18:06:58 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E6=8E=A8=E5=B9=BF=E5=B9=B3=E5=8F=B0->?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=AE=A1=E7=90=86->=E5=85=85=E5=80=BC?= =?UTF-8?q?=E7=8E=A9=E5=AE=B6--=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Home/View/default/Query/userRecharges.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Application/Home/View/default/Query/userRecharges.html b/Application/Home/View/default/Query/userRecharges.html index 67a7f0889..fbc9d3f99 100644 --- a/Application/Home/View/default/Query/userRecharges.html +++ b/Application/Home/View/default/Query/userRecharges.html @@ -155,7 +155,7 @@ {$record.user_account} {$record.game_name} - {:getSDKTypeName($record['sdk_version'])} + {$record.sdk_version} {$record.server_name} {$record.role_name} {$record.role_level} @@ -163,7 +163,7 @@ {$record.recharge_count} {$record.recharge_cost_today} {$record.unlogin_day} - {$record.play_time|date='Y-m-d H:i:s',###} + {$record.play_time} {$record.promote_account} From 4b21dcd239932cdabf90b6677df12cc5de67280e Mon Sep 17 00:00:00 2001 From: chenxiaojun <956334972@qq.com> Date: Mon, 2 Dec 2019 18:08:27 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=8E=A8=E5=B9=BF=E5=B9=B3=E5=8F=B0->?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=AE=A1=E7=90=86->=E5=85=85=E5=80=BC?= =?UTF-8?q?=E7=8E=A9=E5=AE=B6--=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Home/Controller/QueryController.class.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Application/Home/Controller/QueryController.class.php b/Application/Home/Controller/QueryController.class.php index 2c2a84c8b..847cf1f8f 100644 --- a/Application/Home/Controller/QueryController.class.php +++ b/Application/Home/Controller/QueryController.class.php @@ -1844,8 +1844,15 @@ class QueryController extends BaseController list($records, $pagination, $count) = $this->paginate($query); foreach ($records as &$list) { - $list['user_account'] = encryption($list['user_account']); - $list['unlogin_day'] = intval((strtotime(date('Y-m-d 00:00:00')) - strtotime(date('Y-m-d 00:00:00', $list['play_time']))) / (24 * 3600)); + $list['user_account'] = empty($list['user_account']) ? '--' : encryption($list['user_account']); + $list['game_name'] = empty($list['game_name']) ? '--' : $list['game_name']; + $list['sdk_version'] = empty($list['sdk_version']) ? '--' : getSDKTypeName($list['sdk_version']); + $list['server_name'] = empty($list['server_name']) ? '--' : $list['server_name']; + $list['role_name'] = empty($list['role_name']) ? '--' : $list['role_name']; + $list['role_level'] = empty($list['role_level']) ? '--' : $list['role_level']; + $list['unlogin_day'] = empty($list['unlogin_day']) ? '--' : intval((strtotime(date('Y-m-d 00:00:00')) - strtotime(date('Y-m-d 00:00:00', $list['play_time']))) / (24 * 3600)); + $list['play_time'] = empty($list['play_time']) ? '--' : date('Y-m-d H:i:s', $list['play_time']); + $list['promote_account'] = empty($list['promote_account']) ? '--' : $list['promote_account']; } } From 3c6e62851c0a15a3073cefbd9c808eb243986415 Mon Sep 17 00:00:00 2001 From: chenxiaojun <956334972@qq.com> Date: Mon, 2 Dec 2019 18:11:55 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E6=8E=A8=E5=B9=BF=E5=B9=B3=E5=8F=B0->?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=AE=A1=E7=90=86->=E5=85=85=E5=80=BC?= =?UTF-8?q?=E7=8E=A9=E5=AE=B6--=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Home/Controller/QueryController.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Application/Home/Controller/QueryController.class.php b/Application/Home/Controller/QueryController.class.php index 847cf1f8f..dabfd8ac5 100644 --- a/Application/Home/Controller/QueryController.class.php +++ b/Application/Home/Controller/QueryController.class.php @@ -1850,7 +1850,7 @@ class QueryController extends BaseController $list['server_name'] = empty($list['server_name']) ? '--' : $list['server_name']; $list['role_name'] = empty($list['role_name']) ? '--' : $list['role_name']; $list['role_level'] = empty($list['role_level']) ? '--' : $list['role_level']; - $list['unlogin_day'] = empty($list['unlogin_day']) ? '--' : intval((strtotime(date('Y-m-d 00:00:00')) - strtotime(date('Y-m-d 00:00:00', $list['play_time']))) / (24 * 3600)); + $list['unlogin_day'] = empty($list['play_time']) ? '--' : intval((strtotime(date('Y-m-d 00:00:00')) - strtotime(date('Y-m-d 00:00:00', $list['play_time']))) / (24 * 3600)); $list['play_time'] = empty($list['play_time']) ? '--' : date('Y-m-d H:i:s', $list['play_time']); $list['promote_account'] = empty($list['promote_account']) ? '--' : $list['promote_account']; } From 5597410ac224f53fe5556f2a52bace5864949e81 Mon Sep 17 00:00:00 2001 From: sunke <18850253506@163.com> Date: Mon, 2 Dec 2019 21:22:27 +0800 Subject: [PATCH 5/5] bug --- .../Controller/DownloadController.class.php | 315 +++++++++++++----- 1 file changed, 233 insertions(+), 82 deletions(-) diff --git a/Application/Home/Controller/DownloadController.class.php b/Application/Home/Controller/DownloadController.class.php index c3961f507..d41a710b7 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) > 31 * 24 * 3600) { - $this->error('时间范围不能超过31天'); + if (($endtime - $beginTime) > 7 * 24 * 3600) { + $this->error('时间范围不能超过7天'); } $map1['chain'] = ['like','%'.'/'.PID.'/'.'%']; $rs = M('promote','tab_')->where($map1)->field('id,account,nickname')->select(); @@ -1182,13 +1182,20 @@ class DownloadController extends BaseController { } - + if (!empty(I('begtime')) && empty(I('endtime'))) { $map['tab_spend.pay_time'] = ['egt', strtotime(I('begtime'))]; } elseif (empty(I('begtime')) && !empty(I('endtime'))) { $map['tab_spend.pay_time'] = ['elt', strtotime(I('endtime')) + 86399]; } elseif (!empty(I('begtime')) && !empty(I('endtime'))) { $map['tab_spend.pay_time'] = ['between', [strtotime(I('begtime')), strtotime(I('endtime')) + 86399]]; + }else { + $nowTime = date('Y-m-d'); + $initBegTime = date('Y-m-d', strtotime('-6 day', strtotime($nowTime))); + $initEndTime = date('Y-m-d'); + $initBegTime = strtotime($initBegTime); + $initEndTime = strtotime($initEndTime); + $map['tab_spend.pay_time'] = ['between',[$initBegTime,$initEndTime]]; } empty(I('relation_game_id')) || $map['tab_game.relation_game_id'] = I('relation_game_id'); @@ -1196,7 +1203,7 @@ class DownloadController extends BaseController { empty(I('server_id')) || $map['tab_spend.server_id'] = I('server_id'); empty(I('game_player_name')) || $map['tab_spend.game_player_name'] = ['like', '%' . I('game_player_name') . '%']; empty(I('user_account')) || $map['tab_spend.user_account'] = ['like', '%' . I('user_account') . '%']; - empty(I('order_number')) || $map['tab_spend.order_number'] = I('order_number'); + empty(I('pay_order_number')) || $map['tab_spend.pay_order_number'] = I('pay_order_number'); $map['tab_spend.pay_status'] = 1; $map['tab_spend.is_check'] = ['neq', 2]; @@ -1233,8 +1240,8 @@ class DownloadController extends BaseController { $costBegin = I('cost_begin', ''); //充值总额范围 $costEnd = I('cost_end', ''); $nowTime = date('Y-m-d'); - $initBegTime = date('Y-m-d', strtotime('-6 day', strtotime($nowTime))); - $initBegTime = empty(I('begtime')) ? $initBegTime : I('begtime'); + $initBegTime = date('Y-m-d', strtotime('-7 day', strtotime($nowTime))); + $initBegTime = empty(I('begtime')) ? $initBegTime : I('begtime'); $initEndTime = $nowTime; $initEndTime = empty(I('endtime')) ? $initEndTime : I('endtime'); $begTime = strtotime($initBegTime); @@ -1854,7 +1861,13 @@ class DownloadController extends BaseController { ->group('tab_apply.game_id') ->order('g.sort desc,g.id desc') ->select(); - + $allGameIs = M('Apply', 'tab_') + ->field('distinct tab_apply.game_id') + ->join('tab_game as g on g.id = tab_apply.game_id') + ->join($serverJoin) + ->where($map) + ->select(); + $allGameIs = array_column($allGameIs, 'game_id'); $records = []; if (!empty($data)) { if (intval($endTime - $begTime) / (24 * 3600) <= 30) { @@ -1902,6 +1915,30 @@ class DownloadController extends BaseController { 'spend_voucher' => 0, ]; } + $params['all_data'] = 1; + $params['game_ids'] = $allGameIs; + $allData['game_name'] = "合计"; + $allData['sdk_version'] = '--'; + $allData['role_num'] = $userRepository->getCreateRoleCountByGame($params);//创角数 + $allData['user_num'] = $userRepository->getCreateRoleUserCountByGame($params);//创角用户 + $allData['new_user_num'] = $userRepository->getNewCreateRoleUserCountByGame($params);//新创角用户 + $allData['new_device_num'] = $userRepository->getNewCreateRoleDeviceCountByGame($params);//新创角设备 + $allData['new_ip_num'] = $userRepository->getNewCreateRoleIpCountByGame($params);//新创角IP + $allData['login_user_num'] = $userRepository->getLoginCountGroupByGame($params);//登录用户数 + $allData['spend_user_num'] = $spendRepository->getPayUserCountByGame($params);//充值人数 + $allData['spend_num'] = $spendRepository->getPayCountByGame($params);//充值次数 + unset($params['pay_way']); + $allData['spend_all_amount'] = null_to_0($spendRepository->getPayAmountByGameAndType($params));//充值总额 + $params['pay_way'] = ['in', '1,2,3,4,5,6']; + $allData['spend_cash'] = null_to_0($spendRepository->getPayAmountByGameAndType($params));//现金充值 + $params['pay_way'] = 0; + $allData['spend_generic'] = null_to_0($spendRepository->getPayAmountByGameAndType($params));//通用币充值 + $params['pay_way'] = -1; + $allData['spend_binding'] = null_to_0($spendRepository->getPayAmountByGameAndType($params));//绑定币充值 + $allData['spend_discount'] = '0.00'; + $allData['spend_voucher'] = '0.00'; + $records[] = $allData; + } } @@ -2454,72 +2491,141 @@ 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') ->where($map) ->order('id desc') - ->select(); + ->select(); + $total = []; + $total = $model->field('sum(pay_amount) as pay_amount,sum(if(pay_way > -1,pay_amount,0)) as direct_pay_amount,sum(if(pay_way = -1,pay_amount,0)) as inner_pay_amount,sum(if(selle_ratio >= 0,selle_ratio * pay_amount,0)) as income') + ->where($map) + ->find(); + $total['direct_pay_amount'] = empty($total['direct_pay_amount']) ? '0.00' : $total['direct_pay_amount']; + $total['inner_pay_amount'] = empty($total['inner_pay_amount']) ? '0.00' : $total['inner_pay_amount']; + $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_ratio1"] = $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; + } + unset($xlsData); + ob_flush(); + flush(); + } + $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_ratio1'] = '--'; + $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); + - $xlsData = $data; - $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); + // $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); } @@ -2797,7 +2903,7 @@ class DownloadController extends BaseController { array('role_level','等级'), array('recharge_cost','充值总额'), array('recharge_count','充值次数'), - array('recharge_cost_today','今日充值'), + array('recharge_cost_today','昨日充值'), array('unlogin_day','未登录天数'), array('play_time','最后登录时间'), array('promote_account','推广员账号'), @@ -2849,7 +2955,8 @@ class DownloadController extends BaseController { ->buildSql(); $map['_string'] = 'ui.role_id in (' . $subQuery . ')'; } - $map['uc.create_time'] = ['between', [$map['begintime'], $map['endtime'] - 1]]; + $secondDay = 24*3600 + 1; + $map['uc.create_time'] = ['between', [$map['begintime'], $map['endtime'] - $secondDay]]; unset($map['begintime']); unset($map['endtime']); //$spendMap['_string'] = 'uc.game_id = tab_user_play_info.game_id and uc.server_id = tab_user_play_info.server_id and uc.role_id = tab_user_play_info.role_id'; @@ -2858,34 +2965,55 @@ class DownloadController extends BaseController { $field = $fieldUC . ',' . $fieldUI; $subQuery = M('user_play_data_count', 'tab_')->alias('uc') ->field($field) - ->join('tab_user_play_info as ui on ui.game_id = uc.game_id and ui.server_id = uc.server_id and ui.role_id = uc.role_id') + ->join('left join tab_user_play_info as ui on ui.game_id = uc.game_id and ui.server_id = uc.server_id and ui.role_id = uc.role_id') ->where($map) ->group('uc.role_id,uc.server_id,uc.game_id') ->buildSql(); $roles = M()->alias('record') ->table($subQuery) ->select(); + $total = []; + $total = M('user_play_data_count', 'tab_')->alias('uc') + ->field($fieldUC) + ->join('left join tab_user_play_info as ui on ui.game_id = uc.game_id and ui.server_id = uc.server_id and ui.role_id = uc.role_id') + ->where($map) + ->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'], - 'unlogin_day' => intval((strtotime(date('Y-m-d 00:00:00')) - strtotime(date('Y-m-d 00:00:00', $role['play_time']))) / (24 * 3600)) + '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' => empty($role['play_time']) ? '--' : intval((strtotime(date('Y-m-d 00:00:00')) - strtotime(date('Y-m-d 00:00:00', $role['play_time']))) / (24 * 3600)) ]; } - + $allData['user_account'] = '合计'; + $allData['game_name'] = '--'; + $allData['role_name'] = '--'; + $allData['role_id'] = '--'; + $allData['role_level'] = '--'; + $allData['server_id'] = '--'; + $allData['server_name'] = '--'; + $allData['recharge_cost'] = $total['recharge_cost']; + $allData['recharge_count'] = $total['recharge_count']; + $allData['recharge_cost_today'] = $total['recharge_cost_today']; + $allData['play_time'] = '--'; + $allData['play_ip'] = '--'; + $allData['promote_id'] = '--'; + $allData['promote_account'] = '--'; + $allData['sdk_version'] = '--'; + $allData['unlogin_day'] = '--'; $xlsData = []; foreach ($records as $key1 => $value1) { $value1['user_account'] = $this->encryption($value1['user_account']); @@ -2897,6 +3025,7 @@ class DownloadController extends BaseController { } $xlsData[] = $value1; } + $xlsData[] = $allData; $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); } @@ -2957,7 +3086,7 @@ class DownloadController extends BaseController { $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['order_number'] = $this->encryption($value1['order_number']); + $value1['pay_order_number'] = $this->encryption($value1['pay_order_number']); if(!empty($value1['chain'])) { $chain = trim($value1['chain'],'/'); $chainArr = explode('/', $chain); @@ -2977,9 +3106,9 @@ class DownloadController extends BaseController { } - } + } $csvData["user_account"] = $value1["user_account"]; - $csvData["order_number"] = $value1["order_number"]; + $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"]; @@ -2997,6 +3126,28 @@ class DownloadController extends BaseController { 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); }