From 6f0b05fb0463b1197164e345f82abda1efef0911 Mon Sep 17 00:00:00 2001 From: elf <360197197@qq.com> Date: Sat, 30 Jul 2022 22:53:03 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Home/Controller/DownloadController.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Application/Home/Controller/DownloadController.class.php b/Application/Home/Controller/DownloadController.class.php index a95daf8ec..ff7ed321b 100644 --- a/Application/Home/Controller/DownloadController.class.php +++ b/Application/Home/Controller/DownloadController.class.php @@ -2061,8 +2061,8 @@ class DownloadController extends BaseController $createTimeBegin = strtotime($createTimeRow[0] . ' 00:00:00'); $createTimeEnd = strtotime($createTimeRow[0] . ' 23:59:59'); } - if (($createTimeEnd - $createTimeBegin) > 7*24*3600) { - $this->error('时间范围不能超过7天'); + if (($createTimeEnd - $createTimeBegin) > 31*24*3600) { + $this->error('时间范围不能超过31天'); } $map['create_time'] = ['between', [$createTimeBegin, $createTimeEnd]]; } From 1b33139ee358120369774c4cad9e1ff29f844b62 Mon Sep 17 00:00:00 2001 From: elf <360197197@qq.com> Date: Sun, 31 Jul 2022 00:44:31 +0800 Subject: [PATCH 2/3] yh --- Application/Common/Common/extend.php | 38 + .../Controller/DownloadController.class.php | 4627 ++++++++--------- .../Home/Controller/QueryController.class.php | 384 +- .../Controller/IndexController.class.php | 2 +- 4 files changed, 2480 insertions(+), 2571 deletions(-) diff --git a/Application/Common/Common/extend.php b/Application/Common/Common/extend.php index df438801d..5368941f8 100644 --- a/Application/Common/Common/extend.php +++ b/Application/Common/Common/extend.php @@ -1802,6 +1802,7 @@ function get_parent_name($id){ * @return [type] [description] */ function array_order($arr){ + $i = 0; foreach ($arr as $key => $value) { $arr[$key]['rand']=++$i; } @@ -3106,4 +3107,41 @@ function encodeStr($str) // ceil($length/2) 算出从第几个字符开始 } return $newStr; +} + +function getUserAccountOfPromote($account, $promote = null) +{ + if ($promote && $promote['level_id'] == 1) { + return $account; + } + return substr($account, 0, 2) . '******' . substr($account, 8); +} + +function hideOrderNumber($orderNumber) +{ + $orderLen = strlen($orderNumber); + $strLen = 4; + $hideChar = ''; + + if ($orderLen <= 8) { + $strLen = 2; + } + + for ($i = 0; $i < $orderLen - $strLen * 2; $i++) { + $hideChar .= '*'; + } + + return substr($orderNumber, 0, $strLen) . $hideChar . substr($orderNumber, $orderLen - $strLen); +} + +function hidePromoteAccount($account) { + $orderLen = strlen($account); + $strLen = 3; + $hideChar = ''; + + if ($orderLen <= 8) { $strLen = 2;} + for ($i = 0; $i < $orderLen - $strLen * 2; $i++) { + $hideChar .= '*'; + } + return substr($account, 0, $strLen) . $hideChar . substr($account, $orderLen - $strLen); } \ No newline at end of file diff --git a/Application/Home/Controller/DownloadController.class.php b/Application/Home/Controller/DownloadController.class.php index ff7ed321b..d3b4d526d 100644 --- a/Application/Home/Controller/DownloadController.class.php +++ b/Application/Home/Controller/DownloadController.class.php @@ -1,16 +1,12 @@ backSuccessExport($id); exit; } - - public function listsIndex($p = 0) { + + public function listsIndex($p = 0) + { $nowTime = date('Y-m-d'); $initBegTime = empty(I('begtime')) ? '' : I('begtime'); $initEndTime = $nowTime; $initEndTime = empty(I('endtime')) ? '' : I('endtime'); - $this->assign('begtime',$initBegTime); - $this->assign('endtime',$initEndTime); - $map1['chain'] = ['like','%'.'/'.PID.'/'.'%']; - $res = M('promote','tab_')->where($map1)->field('id,account,nickname')->select(); + $this->assign('begtime', $initBegTime); + $this->assign('endtime', $initEndTime); + $map1['chain'] = ['like', '%' . '/' . PID . '/' . '%']; + $res = M('promote', 'tab_')->where($map1)->field('id,account,nickname')->select(); $childPromoteIds = ''; - if(empty($res)) { + if (empty($res)) { $map['tab_downloadlog.promote_id'] = PID; - }else { - foreach ($res as $rsKey => $rsValue) { + } else { + foreach ($res as $rsKey => $rsValue) { $id = $rsValue['id']; - $childPromoteIds .= $id.','; + $childPromoteIds .= $id . ','; } - $childPromoteIds = rtrim($childPromoteIds, ','); - $childPromoteIds .= ',' . PID; - $map['tab_downloadlog.promote_id'] = ['in', $childPromoteIds]; + $childPromoteIds = rtrim($childPromoteIds, ','); + $childPromoteIds .= ',' . PID; + $map['tab_downloadlog.promote_id'] = ['in', $childPromoteIds]; } $levelPromote = $this->getLevelPromote(); $queryPromote = $this->getQueryPromote($levelPromote); @@ -128,46 +124,45 @@ class DownloadController extends BaseController } else { $map['_string'] = '1<>1'; } - if(!empty($_REQUEST['dataname'])) { - $map['dataname'] = ['like','%'.$_REQUEST['dataname'].'%']; + if (!empty($_REQUEST['dataname'])) { + $map['dataname'] = ['like', '%' . $_REQUEST['dataname'] . '%']; } - if(!empty($_REQUEST['logid'])) { - $map['logid'] = $_REQUEST['logid']; + if (!empty($_REQUEST['logid'])) { + $map['logid'] = $_REQUEST['logid']; } - if(!empty($_REQUEST['begtime']) && !empty($_REQUEST['endtime'])) { - if(strtotime($_REQUEST['begtime']) == strtotime($_REQUEST['endtime'])) { - $endtime = strtotime($_REQUEST['endtime']) + 24*60*60; - }else { - $endtime = strtotime($_REQUEST['endtime']); - } - $map['addtime'] = array('BETWEEN',array(strtotime($_REQUEST['begtime']),$endtime)); - + if (!empty($_REQUEST['begtime']) && !empty($_REQUEST['endtime'])) { + if (strtotime($_REQUEST['begtime']) == strtotime($_REQUEST['endtime'])) { + $endtime = strtotime($_REQUEST['endtime']) + 24 * 60 * 60; + } else { + $endtime = strtotime($_REQUEST['endtime']); + } + $map['addtime'] = array('BETWEEN', array(strtotime($_REQUEST['begtime']), $endtime)); } $page = intval(I('get.p', 1)); $page = $page ? $page : 1; //默认显示第一页数据arraypage - $row=10; - $rs = M('downloadlog','tab_')->where($map)->order('tab_downloadlog.addtime desc') - ->page($page, $row)->select(); + $row = 10; + $rs = M('downloadlog', 'tab_')->where($map)->order('tab_downloadlog.addtime desc') + ->page($page, $row)->select(); foreach ($rs as $key => $value) { $pid = intval($value['promote_id']); - $getNameRs = M('promote','tab_')->field("real_name")->where(['id' => $pid])->find(); + $getNameRs = M('promote', 'tab_')->field("real_name")->where(['id' => $pid])->find(); $rs[$key]['actor'] = $getNameRs['real_name']; } - + $promoteArr = explode(',', $childPromoteIds); $promoteNameArr = []; foreach ($promoteArr as $key1 => $value1) { - $promoteName = M('promote','tab_')->field("real_name")->where(['id' => intval($value1)])->find(); + $promoteName = M('promote', 'tab_')->field("real_name")->where(['id' => intval($value1)])->find(); $promoteNameArr[$key1]['name'] = $promoteName['real_name']; - $promoteNameArr[$key1]['promote_id'] = $value1; + $promoteNameArr[$key1]['promote_id'] = $value1; } /* 查询记录总数 */ $count = M("downloadlog", "tab_") - ->field('tab_downloadlog.id') - ->where($map) + ->field('tab_downloadlog.id') + ->where($map) ->select(); $count = count($count); - //分页 + //分页 $parameter['p'] = I('get.p', 1); $parameter['row'] = I('get.row'); $parameter['dataname'] = $_REQUEST['dataname']; @@ -181,43 +176,39 @@ class DownloadController extends BaseController if ($page) { $this->assign('_page', $page); } - $this->assign('data',$rs); + $this->assign('data', $rs); - $this->assign('promoteNameArr',$promoteNameArr); - return $this->display(); - } + $this->assign('promoteNameArr', $promoteNameArr); + return $this->display(); + } - /** - * IOS详细下载数统计 - * @author sunke - */ - public function iosdetail_data_export() { - $promote_id = $_REQUEST['promote_id']; - $belongs_president = $_REQUEST['belongs_president']; - $belongs_department = $_REQUEST['belongs_department']; - $belongs_group = $_REQUEST['belongs_group']; + /** + * IOS详细下载数统计 + * @author sunke + */ + public function iosdetail_data_export() + { $user_account = $_REQUEST['user_account']; $type = $_REQUEST['type']; $createTime = I('create_time', ''); - if(!empty($_REQUEST['promote_id'])) { + if (!empty($_REQUEST['promote_id'])) { $map['promote_id'] = $_REQUEST['promote_id']; } - if(!empty($_REQUEST['belongs_president'])) { + if (!empty($_REQUEST['belongs_president'])) { $map['belongs_president'] = $_REQUEST['belongs_president']; } - if(!empty($_REQUEST['belongs_department'])) { + if (!empty($_REQUEST['belongs_department'])) { $map['belongs_department'] = $_REQUEST['belongs_department']; } - if(!empty($_REQUEST['belongs_group'])) { + if (!empty($_REQUEST['belongs_group'])) { $map['belongs_group'] = $_REQUEST['belongs_group']; } - if($user_account) { - $user_id = M('user', 'tab_')->where(['account'=>$user_account])->getField('id'); + if ($user_account) { + $user_id = M('user', 'tab_')->where(['account' => $user_account])->getField('id'); $map['user_id'] = $user_id; } - if($type) { + if ($type) { $map['type'] = $type; - } $nowTime = date('Y-m-d'); $initBegTime = date('Y-m-d', strtotime('-6 day', strtotime($nowTime))); @@ -228,10 +219,10 @@ class DownloadController extends BaseController $endTime = strtotime($initEndTime); $endTime += 3600 * 24; $map['create_time'] = ['between', [$begTime, $endTime]]; - $conditions = json_encode($map,TRUE); + $conditions = json_encode($map, TRUE); $addtime = time(); $data = [ - 'logid' => 'IOSdetail_'.time(), + 'logid' => 'IOSdetail_' . time(), 'promote_id' => PID, 'type' => '/Home/Query/iosDownLoadDetail', 'dataname' => 'IOS玩家详情下载统计', @@ -239,32 +230,30 @@ class DownloadController extends BaseController 'addtime' => $addtime, 'begintime' => 0, 'content' => '', - 'conditions' =>$conditions + 'conditions' => $conditions ]; - $res = M('downloadlog','tab_')->add($data); + $res = M('downloadlog', 'tab_')->add($data); if (!$res) { - // $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res)); $this->error('添加下载失败'); - } - $this->success('添加下载成功',U('listsIndex')); - - } - /** - * IOS下载数统计 - * @author sunke - */ + } + $this->success('添加下载成功', U('listsIndex')); + } - public function ios_data_export() { + /** + * IOS下载数统计 + * @author sunke + */ + public function ios_data_export() + { $levelPromote = $this->getLevelPromote(); $queryPromote = $this->getQueryPromote($levelPromote); $localId = $queryPromote['id']; $map = []; if ($queryPromote['level'] == 4) { $map['id'] = $queryPromote['id']; - }else { + } else { $map['chain'] = ['like', $queryPromote['chain'] . $queryPromote['id'] . '/%']; } - $createTime = I('create_time', ''); $nowTime = date('Y-m-d'); $initBegTime = date('Y-m-d', strtotime('-6 day', strtotime($nowTime))); $initBegTime = empty(I('begtime')) ? $initBegTime : I('begtime'); @@ -276,12 +265,12 @@ class DownloadController extends BaseController $map['create_time'] = ['between', [$begTime, $endTime]]; $map['pid'] = PID; if ($localId !== PID) { - $map['localId'] = $localId; + $map['localId'] = $localId; } - $conditions = json_encode($map,TRUE); + $conditions = json_encode($map, TRUE); $addtime = time(); $data = [ - 'logid' => 'IOS_'.time(), + 'logid' => 'IOS_' . time(), 'promote_id' => PID, 'type' => '/Home/Query/iosDownLoadData', 'dataname' => 'IOS下载统计', @@ -289,22 +278,22 @@ class DownloadController extends BaseController 'addtime' => $addtime, 'begintime' => 0, 'content' => '', - 'conditions' =>$conditions + 'conditions' => $conditions ]; - $res = M('downloadlog','tab_')->add($data); + $res = M('downloadlog', 'tab_')->add($data); if (!$res) { - // $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res)); $this->error('添加下载失败'); - } - $this->success('添加下载成功',U('listsIndex')); - } - - /** - * 每日概况 - * @author sunke - */ - public function dailysummary_data_export() { - $relationGameId = intval(I('relation_game_id', 0)); + } + $this->success('添加下载成功', U('listsIndex')); + } + + /** + * 每日概况 + * @author sunke + */ + public function dailysummary_data_export() + { + $relationGameId = intval(I('relation_game_id', 0)); $sdkVersion = intval(I('sdk_version', 0)); $serverId = intval(I('server_id'), 0); $nowTime = date('Y-m-d'); @@ -318,24 +307,23 @@ class DownloadController extends BaseController $levelPromote = $this->getLevelPromote(); $queryPromote = $this->getQueryPromote($levelPromote); - $loginPromote = $this->getLoginPromote(); - $map1['chain'] = ['like','%'.'/'.PID.'/'.'%']; - $rs = M('promote','tab_')->where($map1)->field('id,account,nickname')->select(); + $map1['chain'] = ['like', '%' . '/' . PID . '/' . '%']; + $rs = M('promote', 'tab_')->where($map1)->field('id,account,nickname')->select(); $childPromoteIds = ''; - if(empty($rs)) { + if (empty($rs)) { $map['tab_test_resource.promote_id'] = PID; - }else { - foreach ($rs as $rsKey => $rsValue) { + } else { + foreach ($rs as $rsKey => $rsValue) { $id = $rsValue['id']; - $childPromoteIds .= $id.','; + $childPromoteIds .= $id . ','; } - $childPromoteIds = rtrim($childPromoteIds, ','); - $childPromoteIds .= ',' . PID; - $map['promote_id'] = ['in', $childPromoteIds]; + $childPromoteIds = rtrim($childPromoteIds, ','); + $childPromoteIds .= ',' . PID; + $map['promote_id'] = ['in', $childPromoteIds]; } - - $ownId = intval(I('own_id'), 0);//本账号 - if ($ownId) { + + $ownId = intval(I('own_id'), 0); //本账号 + if ($ownId) { $map['promote_id'] = $queryPromote['id']; } else { $map2['chain'] = ['like', $queryPromote['chain'] . $queryPromote['id'] . '/%']; @@ -344,53 +332,51 @@ class DownloadController extends BaseController $ids = implode(',', $ids); $map['promote_id'] = $ids; } - if ($serverId > 0) { + if ($serverId > 0) { $map['server_id'] = $serverId; } - if ($relationGameId > 0 || $sdkVersion > 0) { + if ($relationGameId > 0 || $sdkVersion > 0) { if ($sdkVersion > 0) { $map['sdk_version'] = $sdkVersion; } if ($relationGameId > 0) { $map['relation_game_id'] = $relationGameId; } - $gameIds = M('Game', 'tab_')->where($map)->getField('id', true); - $map['gameIds'] = $gameIds; + $gameIds = M('Game', 'tab_')->where($map)->getField('id', true); + $map['gameIds'] = $gameIds; } - + $map['begin_time'] = $begTime; $map['end_time'] = $endTime; $dayList = $this->getDayList($begTime, $endTime); $map['dayList'] = $dayList; - $conditions = json_encode($map,TRUE); - $addtime = time(); - $data = [ - 'logid' => 'dy_'.time(), - 'promote_id' => PID, - 'type' => '/Home/Query/dailySummary', - 'dataname' => '每日概况', - 'status' => 0, - 'addtime' => $addtime, - 'begintime' => 0, - 'content' => '', - 'conditions' =>$conditions - ]; - $res = M('downloadlog','tab_')->add($data); - if (!$res) { - // $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res)); - $this->error('添加下载失败'); - } - $this->success('添加下载成功',U('listsIndex')); - - - } - - /** - * 提现记录 - * @author sunke - */ - public function withdrawRecord_data_export() { + $conditions = json_encode($map, TRUE); + $addtime = time(); + $data = [ + 'logid' => 'dy_' . time(), + 'promote_id' => PID, + 'type' => '/Home/Query/dailySummary', + 'dataname' => '每日概况', + 'status' => 0, + 'addtime' => $addtime, + 'begintime' => 0, + 'content' => '', + 'conditions' => $conditions + ]; + $res = M('downloadlog', 'tab_')->add($data); + if (!$res) { + $this->error('添加下载失败'); + } + $this->success('添加下载成功', U('listsIndex')); + } + + /** + * 提现记录 + * @author sunke + */ + public function withdrawRecord_data_export() + { $withdrawNumber = I('widthdraw_number', ''); $initBegTime = I('begtime', ''); $initEndTime = I('endtime', ''); @@ -400,15 +386,15 @@ class DownloadController extends BaseController $map['promote_id'] = $this->loginPromote['id']; if (!empty($withdrawNumber)) { $map['widthdraw_number'] = $withdrawNumber; - } - if (!empty($initBegTime) && empty($initEndTime)) { + } + if (!empty($initBegTime) && empty($initEndTime)) { $map['create_time'] = ['egt', $begTime]; } elseif (empty($initBegTime) && !empty($initEndTime)) { $map['create_time'] = ['lt', $endTime]; } elseif (!empty($initBegTime) && !empty($initEndTime)) { $map['create_time'] = ['between', [$begTime, $endTime - 1]]; } - + if (isset($_GET['status']) && $_GET['status'] !== '') { $status = intval($_GET['status']); if (!isset(FinanceController::$withdrawStatus[$status])) { @@ -417,32 +403,33 @@ class DownloadController extends BaseController $map['status'] = $status; } - - $conditions = json_encode($map,TRUE); - $addtime = time(); - $data = [ - 'logid' => 'withdrawRecord'.time(), - 'promote_id' => PID, - 'type' => '/Home/Finance/withdrawRecord', - 'dataname' => '提现记录', - 'status' => 0, - 'addtime' => $addtime, - 'begintime' => 0, - 'content' => '', - 'conditions' =>$conditions - ]; - $res = M('downloadlog','tab_')->add($data); - if (!$res) { - // $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res)); - $this->error('添加下载失败'); - } - $this->success('添加下载成功',U('listsIndex')); - } - /** - * 提现明细 - * @author sunke - */ - public function withdrawDtl_data_export() { + + $conditions = json_encode($map, TRUE); + $addtime = time(); + $data = [ + 'logid' => 'withdrawRecord' . time(), + 'promote_id' => PID, + 'type' => '/Home/Finance/withdrawRecord', + 'dataname' => '提现记录', + 'status' => 0, + 'addtime' => $addtime, + 'begintime' => 0, + 'content' => '', + 'conditions' => $conditions + ]; + $res = M('downloadlog', 'tab_')->add($data); + if (!$res) { + $this->error('添加下载失败'); + } + $this->success('添加下载成功', U('listsIndex')); + } + + /** + * 提现明细 + * @author sunke + */ + public function withdrawDtl_data_export() + { $withdrawId = intval(I('get.id', 0)); if ($withdrawId == 0) { $this->error('参数异常'); @@ -454,7 +441,7 @@ class DownloadController extends BaseController $gameId = intval(I('game_id', 0)); $userAccount = I('user_account', ''); $payOrderNumber = I('pay_order_number', ''); - $map['withdraw_id'] = $withdrawId; + $map['withdraw_id'] = $withdrawId; if (!empty($gameId)) { $map['game_id'] = $gameId; } @@ -464,36 +451,33 @@ class DownloadController extends BaseController if (!empty($payOrderNumber)) { $map['pay_order_number'] = $payOrderNumber; } - - $conditions = json_encode($map,TRUE); - $addtime = time(); - $data = [ - 'logid' => 'withdrawDtl_'.time(), - 'promote_id' => PID, - 'type' => '/Home/Finance/withdrawDtl', - 'dataname' => '提现明细', - 'status' => 0, - 'addtime' => $addtime, - 'begintime' => 0, - 'content' => '', - 'conditions' =>$conditions - ]; - $res = M('downloadlog','tab_')->add($data); - if (!$res) { - // $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res)); - $this->error('添加下载失败'); - } - $this->success('添加下载成功',U('listsIndex')); - } - - /** - * 结算中心 - * @author sunke - */ - public function financeindex_data_export() { - $thisDay = strtotime(date('Y-m-d')); - $thisMonth = strtotime(date('Y-m')); - $yesterday = strtotime(date('Y-m-d', strtotime('-1 day', time()))); + + $conditions = json_encode($map, TRUE); + $addtime = time(); + $data = [ + 'logid' => 'withdrawDtl_' . time(), + 'promote_id' => PID, + 'type' => '/Home/Finance/withdrawDtl', + 'dataname' => '提现明细', + 'status' => 0, + 'addtime' => $addtime, + 'begintime' => 0, + 'content' => '', + 'conditions' => $conditions + ]; + $res = M('downloadlog', 'tab_')->add($data); + if (!$res) { + $this->error('添加下载失败'); + } + $this->success('添加下载成功', U('listsIndex')); + } + + /** + * 结算中心 + * @author sunke + */ + public function financeindex_data_export() + { $nowTime = date('Y-m-d'); $initBegTime = date('Y-m-d', strtotime('-6 day', strtotime($nowTime))); $initBegTime = empty(I('begtime')) ? $initBegTime : I('begtime'); @@ -510,33 +494,33 @@ class DownloadController extends BaseController $map['pay_status'] = 1; $map['promote_id'] = ['in', $promoteIds]; $map['pay_time'] = ['between', [$begTime, $endTime]]; - - $conditions = json_encode($map,TRUE); - $addtime = time(); - $data = [ - 'logid' => 'finance_'.time(), - 'promote_id' => PID, - 'type' => '/Home/Finance/index', - 'dataname' => '结算中心', - 'status' => 0, - 'addtime' => $addtime, - 'begintime' => 0, - 'content' => '', - 'conditions' =>$conditions - ]; - $res = M('downloadlog','tab_')->add($data); - if (!$res) { - // $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res)); - $this->error('添加下载失败'); - } - $this->success('添加下载成功',U('listsIndex')); - } - - /** - * 结算明细 - * @author sunke - */ - public function settlementDtl_data_export() { + + $conditions = json_encode($map, TRUE); + $addtime = time(); + $data = [ + 'logid' => 'finance_' . time(), + 'promote_id' => PID, + 'type' => '/Home/Finance/index', + 'dataname' => '结算中心', + 'status' => 0, + 'addtime' => $addtime, + 'begintime' => 0, + 'content' => '', + 'conditions' => $conditions + ]; + $res = M('downloadlog', 'tab_')->add($data); + if (!$res) { + $this->error('添加下载失败'); + } + $this->success('添加下载成功', U('listsIndex')); + } + + /** + * 结算明细 + * @author sunke + */ + public function settlementDtl_data_export() + { $payOrderNumber = I('pay_order_number', ''); $nowTime = date('Y-m-d'); $initBegTime = date('Y-m-d', strtotime('-6 day', strtotime($nowTime))); @@ -583,209 +567,210 @@ class DownloadController extends BaseController } } } - $conditions = json_encode($map,TRUE); - $addtime = time(); - $data = [ - 'logid' => 'settlementDtl_'.time(), - 'promote_id' => PID, - 'type' => '/Home/Finance/settlementDtl', - 'dataname' => '结算明细', - 'status' => 0, - 'addtime' => $addtime, - 'begintime' => 0, - 'content' => '', - 'conditions' =>$conditions - ]; - $res = M('downloadlog','tab_')->add($data); - if (!$res) { - // $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res)); - $this->error('添加下载失败'); - } - $this->success('添加下载成功',U('listsIndex')); - - } + $conditions = json_encode($map, TRUE); + $addtime = time(); + $data = [ + 'logid' => 'settlementDtl_' . time(), + 'promote_id' => PID, + 'type' => '/Home/Finance/settlementDtl', + 'dataname' => '结算明细', + 'status' => 0, + 'addtime' => $addtime, + 'begintime' => 0, + 'content' => '', + 'conditions' => $conditions + ]; + $res = M('downloadlog', 'tab_')->add($data); + if (!$res) { + $this->error('添加下载失败'); + } + $this->success('添加下载成功', U('listsIndex')); + } + /** - * 测试资源 - * @author sunke - */ - public function testresource_data_export() { - $map1['chain'] = ['like','%'.'/'.PID.'/'.'%']; - $rs = M('promote','tab_')->where($map1)->field('id,account,nickname')->select(); + * 测试资源 + * @author sunke + */ + public function testresource_data_export() + { + $map1['chain'] = ['like', '%' . '/' . PID . '/' . '%']; + $rs = M('promote', 'tab_')->where($map1)->field('id,account,nickname')->select(); $childPromoteIds = ''; $map['tab_test_resource.promote_id'] = PID; - - if(!empty(I('role_name'))){ - $map['role_name']=['like','%'.I('role_name').'%']; + + if (!empty(I('role_name'))) { + $map['role_name'] = ['like', '%' . I('role_name') . '%']; } - if(!empty(I('server_name'))){ - $map['server_name']=I('server_name'); + if (!empty(I('server_name'))) { + $map['server_name'] = I('server_name'); } - if(!empty(I('game_name'))){ - $map['game_name']=I('game_name'); + if (!empty(I('game_name'))) { + $map['game_name'] = I('game_name'); } - if(!empty(I('user_account'))){ - $map['user_account']=['like','%'.I('user_account').'%']; + if (!empty(I('user_account'))) { + $map['user_account'] = ['like', '%' . I('user_account') . '%']; } - if(!empty($_REQUEST['start'])&&empty($_REQUEST['end'])){ - $map['create_time'] = array('GT',strtotime($_REQUEST['start'])); + if (!empty($_REQUEST['start']) && empty($_REQUEST['end'])) { + $map['create_time'] = array('GT', strtotime($_REQUEST['start'])); unset($_REQUEST['start']); } - if(empty($_REQUEST['start'])&&!empty($_REQUEST['end'])){ - $map['create_time'] = array('LT',strtotime($_REQUEST['end'])+24*60*60-1); + if (empty($_REQUEST['start']) && !empty($_REQUEST['end'])) { + $map['create_time'] = array('LT', strtotime($_REQUEST['end']) + 24 * 60 * 60 - 1); unset($_REQUEST['end']); } - if(!empty($_REQUEST['start'])&&!empty($_REQUEST['end'])){ - $map['create_time'] = array('BETWEEN',array(strtotime($_REQUEST['start']),strtotime($_REQUEST['end'])+24*60*60-1)); - unset($_REQUEST['start']);unset($_REQUEST['end']); + if (!empty($_REQUEST['start']) && !empty($_REQUEST['end'])) { + $map['create_time'] = array('BETWEEN', array(strtotime($_REQUEST['start']), strtotime($_REQUEST['end']) + 24 * 60 * 60 - 1)); + unset($_REQUEST['start']); + unset($_REQUEST['end']); } - - $conditions = json_encode($map,TRUE); - $addtime = time(); - $data = [ - 'logid' => 'test_'.time(), - 'promote_id' => PID, - 'type' => '/Home/TestResource/index', - 'dataname' => '申请测试资源', - 'status' => 0, - 'addtime' => $addtime, - 'begintime' => 0, - 'content' => '', - 'conditions' =>$conditions - ]; - $res = M('downloadlog','tab_')->add($data); - if (!$res) { - // $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res)); - $this->error('添加下载失败'); - } - $this->success('添加下载成功',U('listsIndex')); - } - - /** - * 测试资源申请记录 - * @author sunke - */ - public function testresourcelists_data_export() { - $map1['chain'] = ['like','%'.'/'.PID.'/'.'%']; - $rs = M('promote','tab_')->where($map1)->field('id,account,nickname')->select(); - $childPromoteIds = ''; + + $conditions = json_encode($map, TRUE); + $addtime = time(); + $data = [ + 'logid' => 'test_' . time(), + 'promote_id' => PID, + 'type' => '/Home/TestResource/index', + 'dataname' => '申请测试资源', + 'status' => 0, + 'addtime' => $addtime, + 'begintime' => 0, + 'content' => '', + 'conditions' => $conditions + ]; + $res = M('downloadlog', 'tab_')->add($data); + if (!$res) { + $this->error('添加下载失败'); + } + $this->success('添加下载成功', U('listsIndex')); + } + + /** + * 测试资源申请记录 + * @author sunke + */ + public function testresourcelists_data_export() + { + $map1['chain'] = ['like', '%' . '/' . PID . '/' . '%']; + M('promote', 'tab_')->where($map1)->field('id,account,nickname')->select(); + $map['tab_test_resource.promote_id'] = PID; - - if(!empty(I('type'))||I('type')==='0'){ - $map['apply_status']=I('type'); + + if (!empty(I('type')) || I('type') === '0') { + $map['apply_status'] = I('type'); } - if(!empty(I('role_name'))){ - $map['role_name']=['like','%'.I('role_name').'%']; + if (!empty(I('role_name'))) { + $map['role_name'] = ['like', '%' . I('role_name') . '%']; } - if(!empty(I('server_name'))){ - $map['server_name']=I('server_name'); + if (!empty(I('server_name'))) { + $map['server_name'] = I('server_name'); } - if(!empty(I('game_name'))){ - $map['game_name']=I('game_name'); + if (!empty(I('game_name'))) { + $map['game_name'] = I('game_name'); } - if(!empty(I('user_account'))){ - $map['user_account']=['like','%'.I('user_account').'%']; + if (!empty(I('user_account'))) { + $map['user_account'] = ['like', '%' . I('user_account') . '%']; } - if(!empty($_REQUEST['start'])&&empty($_REQUEST['end'])){ - $map['create_time'] = array('GT',strtotime($_REQUEST['start'])); + if (!empty($_REQUEST['start']) && empty($_REQUEST['end'])) { + $map['create_time'] = array('GT', strtotime($_REQUEST['start'])); unset($_REQUEST['start']); } - if(empty($_REQUEST['start'])&&!empty($_REQUEST['end'])){ - $map['create_time'] = array('LT',strtotime($_REQUEST['end'])+24*60*60-1); + if (empty($_REQUEST['start']) && !empty($_REQUEST['end'])) { + $map['create_time'] = array('LT', strtotime($_REQUEST['end']) + 24 * 60 * 60 - 1); unset($_REQUEST['end']); } - if(!empty($_REQUEST['start'])&&!empty($_REQUEST['end'])){ - $map['create_time'] = array('BETWEEN',array(strtotime($_REQUEST['start']),strtotime($_REQUEST['end'])+24*60*60-1)); - unset($_REQUEST['start']);unset($_REQUEST['end']); - } - //$data=M('test_resource','tab_')->where($map)->order('id desc')->select(); - $conditions = json_encode($map,TRUE); - $addtime = time(); - $data = [ - 'logid' => 'test_'.time(), - 'promote_id' => PID, - 'type' => '/Home/TestResource/lists', - 'dataname' => '申请测试资源记录', - 'status' => 0, - 'addtime' => $addtime, - 'begintime' => 0, - 'content' => '', - 'conditions' =>$conditions - ]; - $res = M('downloadlog','tab_')->add($data); - if (!$res) { - // $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res)); - $this->error('添加下载失败'); - } - $this->success('添加下载成功',U('listsIndex')); - } - - /** - * 扶持号管理 - * @author sunke - */ - public function supportNumberList_data_export() { - $map1['chain'] = ['like','%'.'/'.PID.'/'.'%']; - $rs = M('promote','tab_')->where($map1)->field('id,account,nickname')->select(); - $childPromoteIds = ''; + if (!empty($_REQUEST['start']) && !empty($_REQUEST['end'])) { + $map['create_time'] = array('BETWEEN', array(strtotime($_REQUEST['start']), strtotime($_REQUEST['end']) + 24 * 60 * 60 - 1)); + unset($_REQUEST['start']); + unset($_REQUEST['end']); + } + + $conditions = json_encode($map, TRUE); + $addtime = time(); + $data = [ + 'logid' => 'test_' . time(), + 'promote_id' => PID, + 'type' => '/Home/TestResource/lists', + 'dataname' => '申请测试资源记录', + 'status' => 0, + 'addtime' => $addtime, + 'begintime' => 0, + 'content' => '', + 'conditions' => $conditions + ]; + $res = M('downloadlog', 'tab_')->add($data); + if (!$res) { + $this->error('添加下载失败'); + } + $this->success('添加下载成功', U('listsIndex')); + } + + /** + * 扶持号管理 + * @author sunke + */ + public function supportNumberList_data_export() + { + $map1['chain'] = ['like', '%' . '/' . PID . '/' . '%']; + M('promote', 'tab_')->where($map1)->field('id,account,nickname')->select(); + $map['tab_test_resource.promote_id'] = PID; - - if(!empty(I('server_name'))){ - $map['tab_test_resource.server_name']=I('server_name'); - } - if(!empty(I('game_name'))){ - $map['tab_test_resource.game_name']=I('game_name'); - } - if(!empty(I('role_name'))){ - $map['tab_test_resource.role_name']=['like','%'.I('role_name').'%']; - } - if(!empty(I('user_account'))){ - $map['tab_test_resource.user_account']=['like','%'.I('user_account').'%']; - } - if(!empty(I('promote_id'))){ - $map['tab_test_resource.promote_id']=I('promote_id'); - } - - $conditions = json_encode($map,TRUE); - $addtime = time(); - $data = [ - 'logid' => 'test_'.time(), - 'promote_id' => PID, - 'type' => '/Home/TestResource/supportNumberList', - 'dataname' => '扶持号管理', - 'status' => 0, - 'addtime' => $addtime, - 'begintime' => 0, - 'content' => '', - 'conditions' =>$conditions - ]; - $res = M('downloadlog','tab_')->add($data); - if (!$res) { - // $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res)); - $this->error('添加下载失败'); - } - $this->success('添加下载成功',U('listsIndex')); - } - /** - * 平台币充值 - * @author sunke - */ - - public function orderlist_data_export() { - $map1['chain'] = ['like','%'.'/'.PID.'/'.'%']; - $rs = M('promote','tab_')->where($map1)->field('id,account,nickname')->select(); + if (!empty(I('server_name'))) { + $map['tab_test_resource.server_name'] = I('server_name'); + } + if (!empty(I('game_name'))) { + $map['tab_test_resource.game_name'] = I('game_name'); + } + if (!empty(I('role_name'))) { + $map['tab_test_resource.role_name'] = ['like', '%' . I('role_name') . '%']; + } + if (!empty(I('user_account'))) { + $map['tab_test_resource.user_account'] = ['like', '%' . I('user_account') . '%']; + } + if (!empty(I('promote_id'))) { + $map['tab_test_resource.promote_id'] = I('promote_id'); + } + + $conditions = json_encode($map, TRUE); + $addtime = time(); + $data = [ + 'logid' => 'test_' . time(), + 'promote_id' => PID, + 'type' => '/Home/TestResource/supportNumberList', + 'dataname' => '扶持号管理', + 'status' => 0, + 'addtime' => $addtime, + 'begintime' => 0, + 'content' => '', + 'conditions' => $conditions + ]; + $res = M('downloadlog', 'tab_')->add($data); + if (!$res) { + $this->error('添加下载失败'); + } + $this->success('添加下载成功', U('listsIndex')); + } + + /** + * 平台币充值 + * @author sunke + */ + public function orderlist_data_export() + { + $map1['chain'] = ['like', '%' . '/' . PID . '/' . '%']; + $rs = M('promote', 'tab_')->where($map1)->field('id,account,nickname')->select(); $childPromoteIds = ''; - if(empty($rs)) { + if (empty($rs)) { $map['tab_coin_pay_order.promote_id'] = PID; - }else { - foreach ($rs as $rsKey => $rsValue) { + } else { + foreach ($rs as $rsKey => $rsValue) { $id = $rsValue['id']; - $childPromoteIds .= $id.','; + $childPromoteIds .= $id . ','; } - $childPromoteIds = rtrim($childPromoteIds, ','); - $childPromoteIds .= ',' . PID; - $map['tab_coin_pay_order.promote_id'] = ['in', $childPromoteIds]; + $childPromoteIds = rtrim($childPromoteIds, ','); + $childPromoteIds .= ',' . PID; + $map['tab_coin_pay_order.promote_id'] = ['in', $childPromoteIds]; } $map['is_del'] = 0; $start_time = strtotime(I('time_start')); @@ -794,100 +779,98 @@ class DownloadController extends BaseController $order_status = I("order_status"); $pay_type = I("pay_type"); if (!empty($start_time) && !empty($end_time)) { - $map['create_time'] = ['BETWEEN', [$start_time, $end_time + 24 * 60 * 60 - 1]]; - } else if (!empty($start_time)) { - $map['create_time'] = array('gt', $start_time); - } else if (!empty($end_time)) { - $map['create_time'] = array('lt', $end_time + 24 * 60 * 60 - 1); - } - if(!empty($order_number)){ - $map['order_number'] = $order_number; - } - if(!empty($order_status) || $order_status=='0'){ - $map['order_status'] = $order_status; - } - if(!empty($pay_type)){ - $map['pay_type'] = $pay_type; - } - $conditions = json_encode($map,TRUE); - $addtime = time(); - $data = [ - 'logid' => 'orderlist_'.time(), - 'promote_id' => PID, - 'type' => '/Home/CoinOrder/order_list', - 'dataname' => '平台币充值', - 'status' => 0, - 'addtime' => $addtime, - 'begintime' => 0, - 'content' => '', - 'conditions' =>$conditions - ]; - $res = M('downloadlog','tab_')->add($data); - if (!$res) { - // $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res)); - $this->error('添加下载失败'); - } - $this->success('添加下载成功',U('listsIndex')); - - } - /** - * arpu统计 - * @author sunke - */ - public function arpu_data_export() { - $defaultTime = date('Y-m-d', time() - 6 * 24 * 3600) . ' 至 ' . date('Y-m-d'); - - $time = I('time', ''); - $time = $time == '' ? $defaultTime : $time; - $sdkVersion = I('sdk_version', 0); - // $gameId = I('game_id', 0); - $relationGameId = I('relation_game_id', 0); - $serverId = I('server_id', 0); - - $map1['chain'] = ['like','%'.'/'.PID.'/'.'%']; - $rs = M('promote','tab_')->where($map1)->field('id,account,nickname')->select(); - $childPromoteIds = ''; - if(empty($rs)) { - $map['promote_id'] = PID; - }else { - foreach ($rs as $rsKey => $rsValue) { - $id = $rsValue['id']; - $childPromoteIds .= $id.','; - } - $childPromoteIds = rtrim($childPromoteIds, ','); - $childPromoteIds .= ',' . PID; - $map['promote_id'] = ['in', $childPromoteIds]; + $map['create_time'] = ['BETWEEN', [$start_time, $end_time + 24 * 60 * 60 - 1]]; + } else if (!empty($start_time)) { + $map['create_time'] = array('gt', $start_time); + } else if (!empty($end_time)) { + $map['create_time'] = array('lt', $end_time + 24 * 60 * 60 - 1); } - $levelPromote = $this->getLevelPromote(); - $queryPromote = $this->getQueryPromote($levelPromote); - - $map2[] = [ - '_logic' => 'or', - 'id' => $queryPromote['id'], + if (!empty($order_number)) { + $map['order_number'] = $order_number; + } + if (!empty($order_status) || $order_status == '0') { + $map['order_status'] = $order_status; + } + if (!empty($pay_type)) { + $map['pay_type'] = $pay_type; + } + $conditions = json_encode($map, TRUE); + $addtime = time(); + $data = [ + 'logid' => 'orderlist_' . time(), + 'promote_id' => PID, + 'type' => '/Home/CoinOrder/order_list', + 'dataname' => '平台币充值', + 'status' => 0, + 'addtime' => $addtime, + 'begintime' => 0, + 'content' => '', + 'conditions' => $conditions + ]; + $res = M('downloadlog', 'tab_')->add($data); + if (!$res) { + $this->error('添加下载失败'); + } + $this->success('添加下载成功', U('listsIndex')); + } + + /** + * arpu统计 + * @author sunke + */ + public function arpu_data_export() + { + $defaultTime = date('Y-m-d', time() - 6 * 24 * 3600) . ' 至 ' . date('Y-m-d'); + + $time = I('time', ''); + $time = $time == '' ? $defaultTime : $time; + $sdkVersion = I('sdk_version', 0); + // $gameId = I('game_id', 0); + $relationGameId = I('relation_game_id', 0); + $serverId = I('server_id', 0); + + $map1['chain'] = ['like', '%' . '/' . PID . '/' . '%']; + $rs = M('promote', 'tab_')->where($map1)->field('id,account,nickname')->select(); + $childPromoteIds = ''; + if (empty($rs)) { + $map['promote_id'] = PID; + } else { + foreach ($rs as $rsKey => $rsValue) { + $id = $rsValue['id']; + $childPromoteIds .= $id . ','; + } + $childPromoteIds = rtrim($childPromoteIds, ','); + $childPromoteIds .= ',' . PID; + $map['promote_id'] = ['in', $childPromoteIds]; + } + $levelPromote = $this->getLevelPromote(); + $queryPromote = $this->getQueryPromote($levelPromote); + + $map2[] = [ + '_logic' => 'or', + 'id' => $queryPromote['id'], 'chain' => ['like', $queryPromote['chain'] . $queryPromote['id'] . '/%'] ]; $ids = M('promote', 'tab_')->where($map2)->getField('id', true); - if(empty($ids)) { - $ids = array(); + if (empty($ids)) { + $ids = array(); } - if(empty($levelPromote)) { - array_push($ids,PID); - + if (empty($levelPromote)) { + array_push($ids, PID); } - array_push($ids,$queryPromote['id']); + array_push($ids, $queryPromote['id']); if (!empty($ids)) { $pro = ""; foreach ($ids as $value1) { $pid = $value1; - $pro .= $pid.','; + $pro .= $pid . ','; } - $pro = rtrim($pro,','); - $map['promote_id'] = ['in',$pro]; - - }else { + $pro = rtrim($pro, ','); + $map['promote_id'] = ['in', $pro]; + } else { $map['_string'] = '1<>1'; } - + $searchGameName = ''; $searchServerName = ''; if ($relationGameId > 0) { @@ -905,39 +888,40 @@ class DownloadController extends BaseController } if ($sdkVersion > 0) { $map['sdk_version'] = $sdkVersion; - } + } list($beginTime, $endTime) = $this->getBetweenTime($time); $map['begin_time'] = $beginTime; $map['end_time'] = $endTime; - + $dayList = $this->getDayList($beginTime, $endTime); $map['dayList'] = $dayList; - $conditions = json_encode($map,TRUE); - $addtime = time(); - $data = [ - 'logid' => 'zc_'.time(), - 'promote_id' => PID, - 'type' => '/Home/Query/arpu', - 'dataname' => 'ARPU统计', - 'status' => 0, - 'addtime' => $addtime, - 'begintime' => 0, - 'content' => '', - 'conditions' =>$conditions - ]; - $res = M('downloadlog','tab_')->add($data); - if (!$res) { - // $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res)); - $this->error('添加下载失败'); - } - $this->success('添加下载成功',U('listsIndex')); - - } - /** - * 注册数据添加下载 - * @author sunke - */ - public function regist_data_export() { + $conditions = json_encode($map, TRUE); + $addtime = time(); + $data = [ + 'logid' => 'zc_' . time(), + 'promote_id' => PID, + 'type' => '/Home/Query/arpu', + 'dataname' => 'ARPU统计', + 'status' => 0, + 'addtime' => $addtime, + 'begintime' => 0, + 'content' => '', + 'conditions' => $conditions + ]; + $res = M('downloadlog', 'tab_')->add($data); + if (!$res) { + // $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res)); + $this->error('添加下载失败'); + } + $this->success('添加下载成功', U('listsIndex')); + } + + /** + * 注册数据添加下载 + * @author sunke + */ + public function regist_data_export() + { if (empty(I('begtime')) || empty(I('endtime'))) { $this->error('请选择起止时间'); } @@ -946,48 +930,46 @@ class DownloadController extends BaseController if (($endtime - $beginTime) > 31 * 24 * 3600) { $this->error('时间范围不能超过31天'); } - $map1['chain'] = ['like','%'.'/'.PID.'/'.'%']; - $rs = M('promote','tab_')->where($map1)->field('id,account,nickname')->select(); + $map1['chain'] = ['like', '%' . '/' . PID . '/' . '%']; + $rs = M('promote', 'tab_')->where($map1)->field('id,account,nickname')->select(); $childPromoteIds = ''; - if(empty($rs)) { + if (empty($rs)) { $map['tab_user.promote_id'] = PID; - }else { - foreach ($rs as $rsKey => $rsValue) { + } else { + foreach ($rs as $rsKey => $rsValue) { $id = $rsValue['id']; - $childPromoteIds .= $id.','; + $childPromoteIds .= $id . ','; } - $childPromoteIds = rtrim($childPromoteIds, ','); - $childPromoteIds .= ',' . PID; - $map['tab_user.promote_id'] = ['in', $childPromoteIds]; + $childPromoteIds = rtrim($childPromoteIds, ','); + $childPromoteIds .= ',' . PID; + $map['tab_user.promote_id'] = ['in', $childPromoteIds]; } $levelPromote = $this->getLevelPromote(); $queryPromote = $this->getQueryPromote($levelPromote); - + $map2[] = [ '_logic' => 'or', 'id' => $queryPromote['id'], 'chain' => ['like', $queryPromote['chain'] . $queryPromote['id'] . '/%'] ]; $ids = M('promote', 'tab_')->where($map2)->getField('id', true); - if(empty($ids)) { - $ids = array(); + if (empty($ids)) { + $ids = array(); } - if(empty($levelPromote)) { - array_push($ids,PID); - + if (empty($levelPromote)) { + array_push($ids, PID); } - array_push($ids,$queryPromote['id']); + array_push($ids, $queryPromote['id']); if (!empty($ids)) { - $map['tab_user.promote_id'] = ['in',$ids]; - - }else { + $map['tab_user.promote_id'] = ['in', $ids]; + } else { $map['_string'] = '1<>1'; } - + if (!empty(I('own_id'))) { - $map['tab_user.promote_id'] = $queryPromote['id'];//本账号 + $map['tab_user.promote_id'] = $queryPromote['id']; //本账号 } - + if (!empty(I('begtime')) && empty(I('endtime'))) { $map['tab_user.register_time'] = ['egt', strtotime(I('begtime'))]; } elseif (empty(I('begtime')) && !empty(I('endtime'))) { @@ -998,46 +980,46 @@ class DownloadController extends BaseController empty(I('account')) || $map['tab_user.account'] = ['like', '%' . I('account') . '%']; empty(I('id')) || $map['tab_user.id'] = intval(I('id')); - $conditions = json_encode($map,TRUE); - $addtime = time(); - $data = [ - 'logid' => 'zc_'.time(), - 'promote_id' => PID, - 'type' => '/Home/Query/registe', - 'dataname' => '注册明细数据', - 'status' => 0, - 'addtime' => $addtime, - 'begintime' => 0, - 'content' => '', - 'conditions' =>$conditions - ]; - $res = M('downloadlog','tab_')->add($data); - if (!$res) { - // $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res)); - $this->error('添加下载失败'); - } - $this->success('添加下载成功',U('listsIndex')); - } - - //渠道管理 - public function children_data_export() { + $conditions = json_encode($map, TRUE); + $addtime = time(); + $data = [ + 'logid' => 'zc_' . time(), + 'promote_id' => PID, + 'type' => '/Home/Query/registe', + 'dataname' => '注册明细数据', + 'status' => 0, + 'addtime' => $addtime, + 'begintime' => 0, + 'content' => '', + 'conditions' => $conditions + ]; + $res = M('downloadlog', 'tab_')->add($data); + if (!$res) { + $this->error('添加下载失败'); + } + $this->success('添加下载成功', U('listsIndex')); + } + + //渠道管理 + public function children_data_export() + { $promoteType = intval(I('promote_type', 0)); $loginer = $this->getLoginPromote(); - $map1['chain'] = ['like','%'.'/'.PID.'/'.'%']; - $rs = M('promote','tab_')->where($map1)->field('id,account,nickname')->select(); + $map1['chain'] = ['like', '%' . '/' . PID . '/' . '%']; + $rs = M('promote', 'tab_')->where($map1)->field('id,account,nickname')->select(); $childPromoteIds = ''; - if(empty($rs)) { + if (empty($rs)) { $map['id'] = PID; - }else { - foreach ($rs as $rsKey => $rsValue) { + } else { + foreach ($rs as $rsKey => $rsValue) { $id = $rsValue['id']; - $childPromoteIds .= $id.','; + $childPromoteIds .= $id . ','; } - $childPromoteIds = rtrim($childPromoteIds, ','); - $childPromoteIds .= ',' . PID; - $map['id'] = ['in', $childPromoteIds]; + $childPromoteIds = rtrim($childPromoteIds, ','); + $childPromoteIds .= ',' . PID; + $map['id'] = ['in', $childPromoteIds]; } - + if ($promoteType == 0) { $map['level'] = 2; } elseif ($promoteType == 1) { @@ -1045,10 +1027,10 @@ class DownloadController extends BaseController } elseif ($promoteType == 2) { $map['level'] = 4; } - if(I('account', '')) { + if (I('account', '')) { $map['account'] = ['like', '%' . I('account', '') . '%']; } - if (I('mobile', '')) { + if (I('mobile', '')) { $map['mobile_phone'] = ['like', '%' . I('mobile', '') . '%']; } if (I('idcard', '')) { @@ -1060,34 +1042,33 @@ class DownloadController extends BaseController if (I('status', 'all') != 'all') { $map['status'] = ['eq', I('status', 'all')]; } - $conditions = json_encode($map,TRUE); - $addtime = time(); - $type = "/Home/Promote/children/promote_type/".$promoteType; - $data = [ - 'logid' => 'promote_'.time(), - 'promote_id' => PID, - 'type' => $type, - 'dataname' => '渠道管理', - 'status' => 0, - 'addtime' => $addtime, - 'begintime' => 0, - 'content' => '', - 'conditions' =>$conditions - ]; - $res = M('downloadlog','tab_')->add($data); + $conditions = json_encode($map, TRUE); + $addtime = time(); + $type = "/Home/Promote/children/promote_type/" . $promoteType; + $data = [ + 'logid' => 'promote_' . time(), + 'promote_id' => PID, + 'type' => $type, + 'dataname' => '渠道管理', + 'status' => 0, + 'addtime' => $addtime, + 'begintime' => 0, + 'content' => '', + 'conditions' => $conditions + ]; + $res = M('downloadlog', 'tab_')->add($data); if (!$res) { - // $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res)); - $this->error('添加下载失败'); - } - $this->success('添加下载成功',U('listsIndex')); - - } - - /** - * 平台币转移 - * @author sunke - */ - public function coinrecord_data_export() { + $this->error('添加下载失败'); + } + $this->success('添加下载成功', U('listsIndex')); + } + + /** + * 平台币转移 + * @author sunke + */ + public function coinrecord_data_export() + { $gameId = I('game_id', -1); $account = I('account', ''); $sn = I('sn', ''); @@ -1097,58 +1078,56 @@ class DownloadController extends BaseController $map = ['promote_id' => $loginPromote['id']]; if ($startTime != '' || $endTime != '') { if ($startTime != '') { - $map['create_time'] = ['egt', strtotime($startTime. ' 00:00:00')]; + $map['create_time'] = ['egt', strtotime($startTime . ' 00:00:00')]; } if ($endTime != '') { - $map['create_time'] = ['elt', strtotime($endTime. ' 23:59:59')]; + $map['create_time'] = ['elt', strtotime($endTime . ' 23:59:59')]; } } - if($sn) { + if ($sn) { $map['sn'] = $sn; } - if($account) { - $map1['account'] = ['like','%'.$account.'%']; - $promotesRs = M('promote','tab_')->field('id')->where($map1)->select(); + if ($account) { + $map1['account'] = ['like', '%' . $account . '%']; + $promotesRs = M('promote', 'tab_')->field('id')->where($map1)->select(); $idArr = ""; foreach ($promotesRs as $key => $value) { - $idArr .= intval($value['id']).','; + $idArr .= intval($value['id']) . ','; } - $idArr1 = rtrim($idArr,','); - $map['target_id'] = ['in',$idArr1]; - } - if($gameId !== -1) { - $map['game_id'] = $gameId; - } - $conditions = json_encode($map,TRUE); - $addtime = time(); - $type = "/Home/PromoteCoin/transferLogs"; - $data = [ - 'logid' => 'cr_'.time(), - 'promote_id' => PID, - 'type' => $type, - 'dataname' => '平台币转移', - 'status' => 0, - 'addtime' => $addtime, - 'begintime' => 0, - 'content' => '', - 'conditions' =>$conditions - ]; - $res = M('downloadlog','tab_')->add($data); + $idArr1 = rtrim($idArr, ','); + $map['target_id'] = ['in', $idArr1]; + } + if ($gameId !== -1) { + $map['game_id'] = $gameId; + } + $conditions = json_encode($map, TRUE); + $addtime = time(); + $type = "/Home/PromoteCoin/transferLogs"; + $data = [ + 'logid' => 'cr_' . time(), + 'promote_id' => PID, + 'type' => $type, + 'dataname' => '平台币转移', + 'status' => 0, + 'addtime' => $addtime, + 'begintime' => 0, + 'content' => '', + 'conditions' => $conditions + ]; + $res = M('downloadlog', 'tab_')->add($data); if (!$res) { - // $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res)); - $this->error('添加下载失败'); - } - $this->success('添加下载成功',U('listsIndex')); - - - } - - /** - * 我的平台币明细 - * @author sunke - */ - public function mycoinrecord_data_export() { - $type = I('type', 0); + $this->error('添加下载失败'); + } + $this->success('添加下载成功', U('listsIndex')); + } + + /** + * 我的平台币明细 + * @author sunke + */ + public function mycoinrecord_data_export() + { + $type = I('type', 0); $subType = I('sub_type', 0); $targetType = I('target_type', ''); $startTime = I('start_time', ''); @@ -1171,120 +1150,118 @@ class DownloadController extends BaseController $map['target_level'] = $targetTypeRow[1]; } } - + if ($startTime != '' || $endTime != '') { if ($startTime != '') { - $map['create_time'] = ['egt', strtotime($startTime. ' 00:00:00')]; + $map['create_time'] = ['egt', strtotime($startTime . ' 00:00:00')]; } if ($endTime != '') { - $map['create_time'] = ['elt', strtotime($endTime. ' 23:59:59')]; + $map['create_time'] = ['elt', strtotime($endTime . ' 23:59:59')]; } } - - - $conditions = json_encode($map,TRUE); - $addtime = time(); - $data = [ - 'logid' => 'pt_'.time(), - 'promote_id' => PID, - 'type' => "/Home/PromoteCoin/coinRecord", - 'dataname' => '我的平台币明细', - 'status' => 0, - 'addtime' => $addtime, - 'begintime' => 0, - 'content' => '', - 'conditions' =>$conditions - ]; - $res = M('downloadlog','tab_')->add($data); + + $conditions = json_encode($map, TRUE); + $addtime = time(); + $data = [ + 'logid' => 'pt_' . time(), + 'promote_id' => PID, + 'type' => "/Home/PromoteCoin/coinRecord", + 'dataname' => '我的平台币明细', + 'status' => 0, + 'addtime' => $addtime, + 'begintime' => 0, + 'content' => '', + 'conditions' => $conditions + ]; + $res = M('downloadlog', 'tab_')->add($data); if (!$res) { - // $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res)); - $this->error('添加下载失败'); - } - $this->success('添加下载成功',U('listsIndex')); - - - } - /** - * 我的平台币 - * @author sunke - */ - public function mycoin_data_export() { - $map1['chain'] = ['like','%'.'/'.PID.'/'.'%']; - $rs = M('promote','tab_')->where($map1)->field('id,account,nickname')->select(); + $this->error('添加下载失败'); + } + $this->success('添加下载成功', U('listsIndex')); + } + + /** + * 我的平台币 + * @author sunke + */ + public function mycoin_data_export() + { + $map1['chain'] = ['like', '%' . '/' . PID . '/' . '%']; + $rs = M('promote', 'tab_')->where($map1)->field('id,account,nickname')->select(); $childPromoteIds = ''; - if(empty($rs)) { + if (empty($rs)) { $map['promote_id'] = PID; - }else { - foreach ($rs as $rsKey => $rsValue) { + } else { + foreach ($rs as $rsValue) { $id = $rsValue['id']; - $childPromoteIds .= $id.','; + $childPromoteIds .= $id . ','; } - $childPromoteIds = rtrim($childPromoteIds, ','); - $childPromoteIds .= ',' . PID; - $map['promote_id'] = ['in', $childPromoteIds]; + $childPromoteIds = rtrim($childPromoteIds, ','); + $childPromoteIds .= ',' . PID; + $map['promote_id'] = ['in', $childPromoteIds]; } - // var_dump($map); + $game_id = I('game_id'); - if(!empty($game_id)) { + if (!empty($game_id)) { $map['game_id'] = $game_id; } $status = I("status"); - if(!empty($status)) { - $map['status'] = $status; + if (!empty($status)) { + $map['status'] = $status; } $coin_type = I('coin_type'); - if(!empty($coin_type)) { + if (!empty($coin_type)) { switch ($coin_type) { case 1: $map['game_id'] = 0; break; case 2: - $map['game_id'] = ["gt",0]; + $map['game_id'] = ["gt", 0]; break; } } - - $conditions = json_encode($map,TRUE); - $addtime = time(); - $type = "/Home/PromoteCoin/myCoin"; - $data = [ - 'logid' => 'pt_'.time(), - 'promote_id' => PID, - 'type' => $type, - 'dataname' => '我的平台币', - 'status' => 0, - 'addtime' => $addtime, - 'begintime' => 0, - 'content' => '', - 'conditions' =>$conditions - ]; - $res = M('downloadlog','tab_')->add($data); + + $conditions = json_encode($map, TRUE); + $addtime = time(); + $type = "/Home/PromoteCoin/myCoin"; + $data = [ + 'logid' => 'pt_' . time(), + 'promote_id' => PID, + 'type' => $type, + 'dataname' => '我的平台币', + 'status' => 0, + 'addtime' => $addtime, + 'begintime' => 0, + 'content' => '', + 'conditions' => $conditions + ]; + $res = M('downloadlog', 'tab_')->add($data); if (!$res) { - // $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res)); - $this->error('添加下载失败'); - } - $this->success('添加下载成功',U('listsIndex')); - } + $this->error('添加下载失败'); + } + $this->success('添加下载成功', U('listsIndex')); + } - public function players_data_export() { + public function players_data_export() + { $begTime = I('begtime'); $endTime = I('endtime'); - $map1['chain'] = ['like','%'.'/'.PID.'/'.'%']; - $rs = M('promote','tab_')->where($map1)->field('id,account,nickname')->select(); + $map1['chain'] = ['like', '%' . '/' . PID . '/' . '%']; + $rs = M('promote', 'tab_')->where($map1)->field('id,account,nickname')->select(); $childPromoteIds = ''; - if(empty($rs)) { + if (empty($rs)) { $map['tab_pay_info.promote_id'] = PID; - }else { - foreach ($rs as $rsKey => $rsValue) { + } else { + foreach ($rs as $rsKey => $rsValue) { $id = $rsValue['id']; - $childPromoteIds .= $id.','; + $childPromoteIds .= $id . ','; } - $childPromoteIds = rtrim($childPromoteIds, ','); - $childPromoteIds .= ',' . PID; - $map['tab_pay_info.promote_id'] = ['in', $childPromoteIds]; + $childPromoteIds = rtrim($childPromoteIds, ','); + $childPromoteIds .= ',' . PID; + $map['tab_pay_info.promote_id'] = ['in', $childPromoteIds]; } - $levelPromote = $this->getLevelPromote(); + $levelPromote = $this->getLevelPromote(); $queryPromote = $this->getQueryPromote($levelPromote); $map2[] = [ '_logic' => 'or', @@ -1292,34 +1269,27 @@ class DownloadController extends BaseController 'chain' => ['like', $queryPromote['chain'] . $queryPromote['id'] . '/%'] ]; $ids = M('promote', 'tab_')->where($map2)->getField('id', true); - if(empty($ids)) { - $ids = array(); + if (empty($ids)) { + $ids = array(); } - if(empty($levelPromote)) { - array_push($ids,PID); - + if (empty($levelPromote)) { + array_push($ids, PID); } - array_push($ids,$queryPromote['id']); + array_push($ids, $queryPromote['id']); if (!empty($ids)) { - $map['tab_pay_info.promote_id'] = ['in',$ids]; - - }else { + $map['tab_pay_info.promote_id'] = ['in', $ids]; + } else { $map['_string'] = '1<>1'; } - // empty(I('relation_game_id')) || $map['tab_pay_info.relation_game_id'] = I('relation_game_id'); - // empty(I('sdk_version')) || $map['tab_pay_info.sdk_version'] = I('sdk_version');relation_game_id $relation_game_id = I('relation_game_id'); $sdk_version = I('sdk_version'); if ($relation_game_id != 0 || $sdk_version != 0) { if ($relation_game_id != 0) { $gameMap['relation_game_id'] = $relation_game_id; } - if ($sdkVersion != 0) { - $gameMap['sdk_version'] = $sdkVersion; - } $gameId1 = M('game', 'tab_')->where($gameMap)->getField('id', true); - if(empty($gameId1)) { + if (empty($gameId1)) { $gameId1 = [-100]; } $map['game_id'] = ['in', $gameId1]; @@ -1330,36 +1300,37 @@ class DownloadController extends BaseController empty(I('extend')) || $map['tab_pay_info.extend'] = I('extend'); empty(I('user_id')) || $map['tab_pay_info.game_player_id'] = I('user_id'); if (!empty($begTime) && !empty($endTime)) { - $map['tab_pay_info.create_time'] = ['between', [strtotime($begTime), strtotime($endTime) +24*3600- 1]]; - }else if (empty($begTime) && !empty($endTime)) { - $map['tab_pay_info.create_time'] = ['elt',strtotime($endTime) + 24*3600]; - }else if (!empty($begTime) && empty($endTime)) { - $map['tab_pay_info.create_time'] = ['EGT',strtotime($begTime) + 24*3600]; - } - - - $conditions = json_encode($map,TRUE); - $addtime = time(); - $data = [ - 'logid' => 'players_'.time(), - 'promote_id' => PID, - 'type' => '/Home/Players/playaction', - 'dataname' => '玩家行为日志', - 'status' => 0, - 'addtime' => $addtime, - 'begintime' => 0, - 'content' => '', - 'conditions' =>$conditions - ]; - $res = M('downloadlog','tab_')->add($data); - if (!$res) { - // $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res)); - $this->error('添加下载失败'); - } - $this->success('添加下载成功',U('listsIndex')); - } + $map['tab_pay_info.create_time'] = ['between', [strtotime($begTime), strtotime($endTime) + 24 * 3600 - 1]]; + } else if (empty($begTime) && !empty($endTime)) { + $map['tab_pay_info.create_time'] = ['elt', strtotime($endTime) + 24 * 3600]; + } else if (!empty($begTime) && empty($endTime)) { + $map['tab_pay_info.create_time'] = ['EGT', strtotime($begTime) + 24 * 3600]; + } + + + $conditions = json_encode($map, TRUE); + $addtime = time(); + $data = [ + 'logid' => 'players_' . time(), + 'promote_id' => PID, + 'type' => '/Home/Players/playaction', + 'dataname' => '玩家行为日志', + 'status' => 0, + 'addtime' => $addtime, + 'begintime' => 0, + 'content' => '', + 'conditions' => $conditions + ]; + $res = M('downloadlog', 'tab_')->add($data); + if (!$res) { + // $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res)); + $this->error('添加下载失败'); + } + $this->success('添加下载成功', U('listsIndex')); + } - public function promotelogs_data_export() { + public function promotelogs_data_export() + { $begTime = I('begtime'); $endTime = I('endtime'); // $map1['chain'] = ['like','%'.'/'.PID.'/'.'%']; @@ -1381,39 +1352,40 @@ class DownloadController extends BaseController empty(I('user_account')) || $map['promote'] = ['like', '%' . I('user_account') . '%']; empty(I('action_type')) || $map['action_type'] = ['like', '%' . I('action_type') . '%']; if (!empty($begTime) && !empty($endTime)) { - $map['create_time'] = ['between', [strtotime($begTime), strtotime($endTime) +24*3600- 1]]; - }else if (empty($begTime) && !empty($endTime)) { - $map['create_time'] = ['elt',strtotime($endTime) + 24*3600]; - }else if (!empty($begTime) && empty($endTime)) { - $map['create_time'] = ['EGT',strtotime($begTime) + 24*3600]; - } - - - $conditions = json_encode($map,TRUE); - $addtime = time(); - $data = [ - 'logid' => 'promoteLogs_'.time(), - 'promote_id' => PID, - 'type' => '/Home/Safe/promoteLogs', - 'dataname' => '推广员操作日志', - 'status' => 0, - 'addtime' => $addtime, - 'begintime' => 0, - 'content' => '', - 'conditions' =>$conditions - ]; - $res = M('downloadlog','tab_')->add($data); - if (!$res) { - // $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res)); - $this->error('添加下载失败'); - } - $this->success('添加下载成功',U('listsIndex')); - } - /** - * 充值明细添加下载 - * @author sunke - */ - public function recharge_data_export() { + $map['create_time'] = ['between', [strtotime($begTime), strtotime($endTime) + 24 * 3600 - 1]]; + } else if (empty($begTime) && !empty($endTime)) { + $map['create_time'] = ['elt', strtotime($endTime) + 24 * 3600]; + } else if (!empty($begTime) && empty($endTime)) { + $map['create_time'] = ['EGT', strtotime($begTime) + 24 * 3600]; + } + + + $conditions = json_encode($map, TRUE); + $addtime = time(); + $data = [ + 'logid' => 'promoteLogs_' . time(), + 'promote_id' => PID, + 'type' => '/Home/Safe/promoteLogs', + 'dataname' => '推广员操作日志', + 'status' => 0, + 'addtime' => $addtime, + 'begintime' => 0, + 'content' => '', + 'conditions' => $conditions + ]; + $res = M('downloadlog', 'tab_')->add($data); + if (!$res) { + // $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res)); + $this->error('添加下载失败'); + } + $this->success('添加下载成功', U('listsIndex')); + } + /** + * 充值明细添加下载 + * @author sunke + */ + public function recharge_data_export() + { // 支付到账时间 $payedBegTime = I("payed_begtime", ''); if ($payedBegTime) { @@ -1429,57 +1401,55 @@ class DownloadController extends BaseController if (($payedEndTime - $payedBegTime) > 31 * 24 * 3600) { $this->error('到账时间范围不能超过31天'); } - - // 下单时间 + + // 下单时间 $beginTime = strtotime(I('begtime') . ' 00:00:00'); $endtime = strtotime(I('endtime') . ' 23:59:59'); if (($endtime - $beginTime) > 31 * 24 * 3600) { $this->error('下单时间范围不能超过31天'); } - $map1['chain'] = ['like','%'.'/'.PID.'/'.'%']; - $rs = M('promote','tab_')->where($map1)->field('id,account,nickname')->select(); + $map1['chain'] = ['like', '%' . '/' . PID . '/' . '%']; + $rs = M('promote', 'tab_')->where($map1)->field('id,account,nickname')->select(); $childPromoteIds = ''; - if(empty($rs)) { + if (empty($rs)) { $map['tab_spend.promote_id'] = PID; - }else { - foreach ($rs as $rsKey => $rsValue) { + } else { + foreach ($rs as $rsKey => $rsValue) { $id = $rsValue['id']; - $childPromoteIds .= $id.','; + $childPromoteIds .= $id . ','; } - $childPromoteIds = rtrim($childPromoteIds, ','); - $childPromoteIds .= ',' . PID; - $map['tab_spend.promote_id'] = ['in', $childPromoteIds]; + $childPromoteIds = rtrim($childPromoteIds, ','); + $childPromoteIds .= ',' . PID; + $map['tab_spend.promote_id'] = ['in', $childPromoteIds]; } - $levelPromote = $this->getLevelPromote(); + $levelPromote = $this->getLevelPromote(); $queryPromote = $this->getQueryPromote($levelPromote); - + $map2[] = [ '_logic' => 'or', 'id' => $queryPromote['id'], 'chain' => ['like', $queryPromote['chain'] . $queryPromote['id'] . '/%'] ]; $ids = M('promote', 'tab_')->where($map2)->getField('id', true); - if(empty($ids)) { - $ids = array(); + if (empty($ids)) { + $ids = array(); } - if(empty($levelPromote)) { - array_push($ids,PID); - + if (empty($levelPromote)) { + array_push($ids, PID); } - array_push($ids,$queryPromote['id']); + array_push($ids, $queryPromote['id']); if (!empty($ids)) { - $map['tab_spend.promote_id'] = ['in',$ids]; - - }else { + $map['tab_spend.promote_id'] = ['in', $ids]; + } else { $map['_string'] = '1<>1'; } - + if (!empty(I('own_id'))) { - $map['tab_spend.promote_id'] = $queryPromote['id'];//本账号 + $map['tab_spend.promote_id'] = $queryPromote['id']; //本账号 } - + if (!empty(I('begtime')) && empty(I('endtime'))) { $map['tab_spend.spend_time'] = ['egt', strtotime(I('begtime'))]; @@ -1487,19 +1457,19 @@ class DownloadController extends BaseController $map['tab_spend.spend_time'] = ['elt', strtotime(I('endtime')) + 86399]; } elseif (!empty(I('begtime')) && !empty(I('endtime'))) { $map['tab_spend.spend_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.spend_time'] = ['between',[$initBegTime,$initEndTime]]; + } 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.spend_time'] = ['between',[$initBegTime,$initEndTime]]; } - + if ($payedBegTime) { $map['tab_spend.payed_time'] = ['between', [$payedBegTime, $payedEndTime - 1]]; } - + empty(I('relation_game_id')) || $map['tab_game.relation_game_id'] = I('relation_game_id'); empty(I('sdk_version')) || $map['tab_game.sdk_version'] = I('sdk_version'); empty(I('server_id')) || $map['tab_spend.server_id'] = I('server_id'); @@ -1516,28 +1486,29 @@ class DownloadController extends BaseController $map = $this->spendRepository->withIsCheck($map, 'tab_spend.is_check'); - $conditions = json_encode($map, true); + $conditions = json_encode($map, true); $addtime = time(); $data = [ - 'logid' => 'cz_'.time(), - 'promote_id' => PID, - 'type' => '/Home/Query/recharge', - 'dataname' => '充值明细数据', - 'status' => 0, - 'addtime' => $addtime, - 'begintime' => 0, - 'content' => '', - 'conditions' =>$conditions - ]; - $res = M('downloadlog','tab_')->add($data); - if (!$res) { - // $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res)); - $this->error('添加下载失败'); - } - $this->success('添加下载成功,导出数据不包含当天',U('listsIndex')); - } - - public function userRecharge_data_export() { + 'logid' => 'cz_' . time(), + 'promote_id' => PID, + 'type' => '/Home/Query/recharge', + 'dataname' => '充值明细数据', + 'status' => 0, + 'addtime' => $addtime, + 'begintime' => 0, + 'content' => '', + 'conditions' => $conditions + ]; + $res = M('downloadlog', 'tab_')->add($data); + if (!$res) { + // $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res)); + $this->error('添加下载失败'); + } + $this->success('添加下载成功,导出数据不包含当天', U('listsIndex')); + } + + public function userRecharge_data_export() + { $gameId = I('relation_game_id', 0); $serverId = I('server_id', 0); $isSelf = I('is_self', 0); @@ -1556,31 +1527,31 @@ class DownloadController extends BaseController $begTime = strtotime($initBegTime); $endTime = strtotime($initEndTime); $endTime += 3600 * 24; - - $map1['chain'] = ['like','%'.'/'.PID.'/'.'%']; - $rs = M('promote','tab_')->where($map1)->field('id,account,nickname')->select(); + + $map1['chain'] = ['like', '%' . '/' . PID . '/' . '%']; + $rs = M('promote', 'tab_')->where($map1)->field('id,account,nickname')->select(); $childPromoteIds = ''; - if(empty($rs)) { + if (empty($rs)) { $map['promote_id'] = PID; - }else { - foreach ($rs as $rsKey => $rsValue) { + } else { + foreach ($rs as $rsKey => $rsValue) { $id = $rsValue['id']; - $childPromoteIds .= $id.','; + $childPromoteIds .= $id . ','; } - $childPromoteIds = rtrim($childPromoteIds, ','); - $childPromoteIds .= ',' . PID; - $map['promote_id'] = ['in', $childPromoteIds]; + $childPromoteIds = rtrim($childPromoteIds, ','); + $childPromoteIds .= ',' . PID; + $map['promote_id'] = ['in', $childPromoteIds]; } $levelPromote = $this->getLevelPromote(); $queryPromote = $this->getQueryPromote($levelPromote); - + $map2['chain'] = ['like', $queryPromote['chain'] . $queryPromote['id'] . '/%']; $ids = M('promote', 'tab_')->where($map2)->getField('id', true); $ids[] = $queryPromote['id']; $map = ['promote_id' => ['in', $ids]]; $subMap = ['promote_id' => ['in', $ids]]; - + if ($gameId != 0 || $sdkVersion != 0) { if ($gameId != 0) { $gameMap['relation_game_id'] = $gameId; @@ -1589,7 +1560,7 @@ class DownloadController extends BaseController $gameMap['sdk_version'] = $sdkVersion; } $gameId1 = M('game', 'tab_')->where($gameMap)->getField('id', true); - if(empty($gameId1)) { + if (empty($gameId1)) { $gameId1 = [-100]; } $map['game_id'] = ['in', $gameId1]; @@ -1608,7 +1579,7 @@ class DownloadController extends BaseController $map['sdk_version'] = $sdkVersion; } if ($isSelf) { - $map['promote_id'] = $queryPromote['id'];//本账号 + $map['promote_id'] = $queryPromote['id']; //本账号 } else { if ($headmanPromoteId != 0) { $map['promote_id'] = $headmanPromoteId; @@ -1617,43 +1588,43 @@ class DownloadController extends BaseController $map['promote_id'] = $promoteId; } } - - if($costBegin) { + + if ($costBegin) { $map['costbegin'] = $costBegin; - }else { + } else { $map['costbegin'] = ""; } - if($costEnd) { + if ($costEnd) { $map['costend'] = $costEnd; - }else { + } else { $map['costend'] = ""; } $map['begintime'] = $begTime; $map['endtime'] = $endTime; - $conditions = json_encode($map,TRUE); - $addtime = time(); - $data = [ - 'logid' => 'wj_'.time(), - 'promote_id' => PID, - 'type' => '/Home/Query/userRecharges', - 'dataname' => '充值玩家数据', - 'status' => 0, - 'addtime' => $addtime, - 'begintime' => 0, - 'content' => '', - 'conditions' =>$conditions - ]; - $res = M('downloadlog','tab_')->add($data); - if (!$res) { - $this->error('添加下载失败'); - } - $this->success('添加下载成功',U('listsIndex')); - - } + $conditions = json_encode($map, TRUE); + $addtime = time(); + $data = [ + 'logid' => 'wj_' . time(), + 'promote_id' => PID, + 'type' => '/Home/Query/userRecharges', + 'dataname' => '充值玩家数据', + 'status' => 0, + 'addtime' => $addtime, + 'begintime' => 0, + 'content' => '', + 'conditions' => $conditions + ]; + $res = M('downloadlog', 'tab_')->add($data); + if (!$res) { + $this->error('添加下载失败'); + } + $this->success('添加下载成功', U('listsIndex')); + } - /*推广员指标查看详情 */ + /*推广员指标查看详情 */ - public function quotaDtl_data_export() { + public function quotaDtl_data_export() + { $nowTime = date('Y-m-d', time()); $defaultTime = date('Y-m-d', strtotime('-6 day', time())) . " 至 " . $nowTime; $time = I('time', $defaultTime); @@ -1696,29 +1667,30 @@ class DownloadController extends BaseController $map = '1 = 2'; } - // $data = M('user_play_info', 'tab_')->where($map)->order('create_time desc')->select(); - $conditions = json_encode($map,TRUE); + // $data = M('user_play_info', 'tab_')->where($map)->order('create_time desc')->select(); + $conditions = json_encode($map, TRUE); $addtime = time(); $data1 = [ - 'logid' => 'quotadtl_'.time(), - 'promote_id' => PID, - 'type' => '/Home/Query/promoteQuota', - 'dataname' => '推广员详情', - 'status' => 0, - 'addtime' => $addtime, - 'begintime' => 0, - 'content' => '', - 'conditions' =>$conditions - ]; - $res = M('downloadlog','tab_')->add($data1); + 'logid' => 'quotadtl_' . time(), + 'promote_id' => PID, + 'type' => '/Home/Query/promoteQuota', + 'dataname' => '推广员详情', + 'status' => 0, + 'addtime' => $addtime, + 'begintime' => 0, + 'content' => '', + 'conditions' => $conditions + ]; + $res = M('downloadlog', 'tab_')->add($data1); if (!$res) { - $this->error('添加下载失败'); - } - $this->success('添加下载成功',U('listsIndex')); - } + $this->error('添加下载失败'); + } + $this->success('添加下载成功', U('listsIndex')); + } - /*推广指标首页导出*/ - public function promoteQuota_data_export() { + /*推广指标首页导出*/ + public function promoteQuota_data_export() + { $nowTime = date('Y-m-d', time()); $defaultTime = date('Y-m-d', strtotime('-6 day', time())) . " 至 " . $nowTime; $time = I('time', $defaultTime); @@ -1770,10 +1742,10 @@ class DownloadController extends BaseController } $map = [ 'isContainSubs' => true, - 'basicPromotes' => json_encode($basicPromotes,FALSE), + 'basicPromotes' => json_encode($basicPromotes, FALSE), ]; - $map['promotes'] = json_encode($data,FALSE); - $map['parentsinfo'] = json_encode($parent,FALSE);; + $map['promotes'] = json_encode($data, FALSE); + $map['parentsinfo'] = json_encode($parent, FALSE);; $map['currentDisplay'] = $currentDisplay; $map['ids'] = $ids; if ($relationGameId != 0 || $sdkVersion != 0) { @@ -1806,29 +1778,29 @@ class DownloadController extends BaseController list($beginTime, $endTime) = $this->getBetweenTime($time); $map['begin_time'] = $beginTime; $map['end_time'] = $endTime; - $conditions = json_encode($map,TRUE); + $conditions = json_encode($map, TRUE); $addtime = time(); $data1 = [ - 'logid' => 'quota_'.time(), - 'promote_id' => PID, - 'type' => '/Home/Query/promoteQuota', - 'dataname' => '推广员指标', - 'status' => 0, - 'addtime' => $addtime, - 'begintime' => 0, - 'content' => '', - 'conditions' =>$conditions - ]; - $res = M('downloadlog','tab_')->add($data1); + 'logid' => 'quota_' . time(), + 'promote_id' => PID, + 'type' => '/Home/Query/promoteQuota', + 'dataname' => '推广员指标', + 'status' => 0, + 'addtime' => $addtime, + 'begintime' => 0, + 'content' => '', + 'conditions' => $conditions + ]; + $res = M('downloadlog', 'tab_')->add($data1); if (!$res) { - // $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res)); - $this->error('添加下载失败'); - } - $this->success('添加下载成功',U('listsIndex')); - - } - - public function achievement_data_export() { + // $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res)); + $this->error('添加下载失败'); + } + $this->success('添加下载成功', U('listsIndex')); + } + + public function achievement_data_export() + { $time = I('time', date('Y-m-d')); $sdkVersion = I('sdk_version', 0); $gameId = I('relation_game_id', 0); @@ -1856,7 +1828,7 @@ class DownloadController extends BaseController $map['id'] = $promoteId; } $data = M('promote', 'tab_')->field(['id', 'account', 'real_name', 'level', 'chain'])->where($map)->select(); - $ids = array_column($data, 'id'); + $ids = array_column($data, 'id'); $rows = []; if (count($ids) > 0) { $rows = M('promote', 'tab_') @@ -1877,10 +1849,10 @@ class DownloadController extends BaseController } $map = [ 'isContainSubs' => true, - 'basicPromotes' => json_encode($basicPromotes,FALSE), + 'basicPromotes' => json_encode($basicPromotes, FALSE), ]; - $map['promotes'] = json_encode($data,FALSE); - $map['parentsinfo'] = json_encode($parent,FALSE);; + $map['promotes'] = json_encode($data, FALSE); + $map['parentsinfo'] = json_encode($parent, FALSE);; $map['currentDisplay'] = $currentDisplay; $map['ids'] = $ids; if ($gameId != 0 || $sdkVersion != 0) { @@ -1891,7 +1863,7 @@ class DownloadController extends BaseController $gameMap['sdk_version'] = $sdkVersion; } $gameId1 = M('game', 'tab_')->where($gameMap)->getField('id', true); - if(empty($gameId1)) { + if (empty($gameId1)) { $gameId1 = [-100]; } $map['game_id'] = ['in', $gameId1]; @@ -1908,30 +1880,29 @@ class DownloadController extends BaseController list($beginTime, $endTime) = $this->getBetweenTime($time); $map['begin_time'] = $beginTime; $map['end_time'] = $endTime; - $conditions = json_encode($map,TRUE); - $addtime = time(); - $data1 = [ - 'logid' => 'tg_'.time(), - 'promote_id' => PID, - 'type' => '/Home/Query/achievement', - 'dataname' => '推广员业绩', - 'status' => 0, - 'addtime' => $addtime, - 'begintime' => 0, - 'content' => '', - 'conditions' =>$conditions - ]; - $res = M('downloadlog','tab_')->add($data1); - if (!$res) { - // $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res)); - $this->error('添加下载失败'); - } - $this->success('添加下载成功',U('listsIndex')); - - } + $conditions = json_encode($map, TRUE); + $addtime = time(); + $data1 = [ + 'logid' => 'tg_' . time(), + 'promote_id' => PID, + 'type' => '/Home/Query/achievement', + 'dataname' => '推广员业绩', + 'status' => 0, + 'addtime' => $addtime, + 'begintime' => 0, + 'content' => '', + 'conditions' => $conditions + ]; + $res = M('downloadlog', 'tab_')->add($data1); + if (!$res) { + // $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res)); + $this->error('添加下载失败'); + } + $this->success('添加下载成功', U('listsIndex')); + } - public function promote_grade_export() - { + public function promote_grade_export() + { $month = I('month', date('Y-m')); $month = $month ? $month : date('Y-m'); $baseGameId = I('base_game_id', 0); @@ -1979,7 +1950,7 @@ class DownloadController extends BaseController $conditions = json_encode(['promotes' => $promotes, 'setting' => $setting, 'month' => $month, 'base_game_id' => $baseGameId], true); $addtime = time(); $data1 = [ - 'logid' => 'pg_'.time(), + 'logid' => 'pg_' . time(), 'promote_id' => PID, 'type' => '/Home/PromoteGrade/index', 'dataname' => '团队评级', @@ -1989,15 +1960,15 @@ class DownloadController extends BaseController 'content' => '', 'conditions' => $conditions ]; - $res = M('downloadlog','tab_')->add($data1); + $res = M('downloadlog', 'tab_')->add($data1); if (!$res) { $this->error('添加下载失败'); } - $this->success('添加下载成功', U('listsIndex')); - } - //玩家角色 - public function userRoles_data_export() - { + $this->success('添加下载成功', U('listsIndex')); + } + //玩家角色 + public function userRoles_data_export() + { $relationGameId = I('relation_game_id', 0); $serverId = I('server_id', 0); $isSelf = I('is_self', 0); @@ -2009,7 +1980,7 @@ class DownloadController extends BaseController $roleLevelBegin = intval(I('role_level_begin', 0)); $roleLevelEnd = intval(I('role_level_end', 0)); $headmanPromoteId = I('headman_promote_id', 0); - $createTime = I('create_time', date('Y-m-d') . ' 至 ' . date('Y-m-d', time()-7*24*3600)); + $createTime = I('create_time', date('Y-m-d') . ' 至 ' . date('Y-m-d', time() - 7 * 24 * 3600)); $lastSortName = trim(I('last_sort_name', '')); $sortName = trim(I('sort_name', '')); $sort = intval(I('sort', 1)); @@ -2061,7 +2032,7 @@ class DownloadController extends BaseController $createTimeBegin = strtotime($createTimeRow[0] . ' 00:00:00'); $createTimeEnd = strtotime($createTimeRow[0] . ' 23:59:59'); } - if (($createTimeEnd - $createTimeBegin) > 31*24*3600) { + if (($createTimeEnd - $createTimeBegin) > 31 * 24 * 3600) { $this->error('时间范围不能超过31天'); } $map['create_time'] = ['between', [$createTimeBegin, $createTimeEnd]]; @@ -2085,34 +2056,34 @@ class DownloadController extends BaseController $orderBy = $sortName . $sortString; } } - - + + $conditions = json_encode(['map' => $map, 'order' => $orderBy], true); $addtime = time(); $data = [ - 'logid' => 'js_'.time(), - 'promote_id' => PID, - 'type' => '/Home/Query/userRoles', - 'dataname' => '角色查询数据', - 'status' => 0, - 'addtime' => $addtime, - 'begintime' => 0, - 'content' => '', - 'conditions' => $conditions + 'logid' => 'js_' . time(), + 'promote_id' => PID, + 'type' => '/Home/Query/userRoles', + 'dataname' => '角色查询数据', + 'status' => 0, + 'addtime' => $addtime, + 'begintime' => 0, + 'content' => '', + 'conditions' => $conditions ]; - $res = M('downloadlog','tab_')->add($data); + $res = M('downloadlog', 'tab_')->add($data); if (!$res) { $this->error('添加下载失败'); } - $this->success('添加下载成功',U('listsIndex')); - } + $this->success('添加下载成功', U('listsIndex')); + } - public function userretention_data_export() - { + public function userretention_data_export() + { $baseGameId = I('game_id', 0); $deviceType = I('device_type', ''); - $timeRange = I('time_range', date('Y-m-d',strtotime('-7 day')) . ' 至 ' . date('Y-m-d')); + $timeRange = I('time_range', date('Y-m-d', strtotime('-7 day')) . ' 至 ' . date('Y-m-d')); $lastSortName = trim(I('last_sort_name', '')); $sortName = trim(I('sort_name', '')); $sort = intval(I('sort', 1)); @@ -2138,7 +2109,7 @@ class DownloadController extends BaseController $orderColumn = $sortName; $orderType = ($sort == 1) ? 'desc' : 'asc'; } - + $status = true; $data = false; $error = ''; @@ -2148,7 +2119,7 @@ class DownloadController extends BaseController } $startTime = strtotime($start . ' 00:00:00'); $endTime = strtotime($end . ' 23:59:59') + 1; - if ((($endTime - $startTime)/(24*3600)) > 31) { + if ((($endTime - $startTime) / (24 * 3600)) > 31) { $error = '时间间隔不能超过31天'; $status = false; } @@ -2156,8 +2127,8 @@ class DownloadController extends BaseController if (!$status) { $this->error($error); } - - + + $conditions = json_encode([ 'base_game_id' => $baseGameId, 'start' => $start, @@ -2170,28 +2141,28 @@ class DownloadController extends BaseController $addtime = time(); $data = [ - 'logid' => 'ur_'.time(), - 'promote_id' => PID, - 'type' => '/Home/Query/userretention', - 'dataname' => '用户留存率', - 'status' => 0, - 'addtime' => $addtime, - 'begintime' => 0, - 'content' => '', - 'conditions' => $conditions + 'logid' => 'ur_' . time(), + 'promote_id' => PID, + 'type' => '/Home/Query/userretention', + 'dataname' => '用户留存率', + 'status' => 0, + 'addtime' => $addtime, + 'begintime' => 0, + 'content' => '', + 'conditions' => $conditions ]; - $res = M('downloadlog','tab_')->add($data); + $res = M('downloadlog', 'tab_')->add($data); if (!$res) { $this->error('添加下载失败'); } - $this->success('添加下载成功',U('listsIndex')); + $this->success('添加下载成功', U('listsIndex')); } public function gameData_data_export() { $gameId = I('game_id', 0); $serverId = I('server_id', ''); - $timeRange = I('time_range', date('Y-m-d',strtotime('-7 day')) . ' 至 ' . date('Y-m-d')); + $timeRange = I('time_range', date('Y-m-d', strtotime('-7 day')) . ' 至 ' . date('Y-m-d')); $lastSortName = trim(I('last_sort_name', '')); $sortName = trim(I('sort_name', '')); $sort = intval(I('sort', 1)); @@ -2210,7 +2181,7 @@ class DownloadController extends BaseController $start = $timeRangeRow[0]; $end = $timeRangeRow[0]; } - + $spendMap = ['pay_status' => 1, '_string' => '1=1']; $roleMap = ['_string' => '1=1']; $map = []; @@ -2218,7 +2189,7 @@ class DownloadController extends BaseController $betweenTime = [strtotime($start . ' 00:00:00'), strtotime($end . ' 23:59:59')]; $spendMap['pay_time'] = ['between', $betweenTime]; $roleMap['create_time'] = ['between', $betweenTime]; - + $promoteService = new PromoteService(); $subInSql = $promoteService->subInSql($queryPromote); @@ -2255,10 +2226,10 @@ class DownloadController extends BaseController } $spendMap = $this->spendRepository->withIsCheck($spendMap); - + $spendSubSql = M('spend', 'tab_')->field(['game_id', 'server_id', 'sum(pay_amount) amount'])->where($spendMap)->group('game_id, server_id')->select(false); $roleSubSql = M('user_play_info', 'tab_')->field(['game_id', 'server_id', 'count(*) count'])->where($roleMap)->group('game_id, server_id')->select(false); - + $conditions = json_encode([ 'spendSubSql' => $spendSubSql, 'roleSubSql' => $roleSubSql, @@ -2268,30 +2239,30 @@ class DownloadController extends BaseController $addtime = time(); $data = [ - 'logid' => 'gd_'.time(), - 'promote_id' => PID, - 'type' => '/Home/Query/gameData', - 'dataname' => '游戏分区数据汇总', - 'status' => 0, - 'addtime' => $addtime, - 'begintime' => 0, - 'content' => '', - 'conditions' => $conditions + 'logid' => 'gd_' . time(), + 'promote_id' => PID, + 'type' => '/Home/Query/gameData', + 'dataname' => '游戏分区数据汇总', + 'status' => 0, + 'addtime' => $addtime, + 'begintime' => 0, + 'content' => '', + 'conditions' => $conditions ]; - $res = M('downloadlog','tab_')->add($data); + $res = M('downloadlog', 'tab_')->add($data); if (!$res) { $this->error('添加下载失败'); } - $this->success('添加下载成功',U('listsIndex')); + $this->success('添加下载成功', U('listsIndex')); } - /** - * 数据汇总添加下载 - * @author sunke - */ - public function summary_data_export() - { - $ownId = intval(I('own_id'), 0);//本账号 + /** + * 数据汇总添加下载 + * @author sunke + */ + public function summary_data_export() + { + $ownId = intval(I('own_id'), 0); //本账号 $relationGameId = intval(I('relation_game_id', 0)); $sdkVersion = intval(I('sdk_version', 0)); $serverId = I('server_id', ''); @@ -2305,7 +2276,7 @@ class DownloadController extends BaseController $endTime += 3600 * 24; $levelPromote = $this->getLevelPromote(); $queryPromote = $this->getQueryPromote($levelPromote); - + $loginPromote = $this->getLoginPromote(); $params = []; @@ -2335,7 +2306,7 @@ class DownloadController extends BaseController $conditions = json_encode(['map' => $map, 'params' => $params], true); $addtime = time(); $data = [ - 'logid' => 'hz_'.time(), + 'logid' => 'hz_' . time(), 'promote_id' => PID, 'type' => '/Home/Query/summary', 'dataname' => '数据汇总数据', @@ -2343,69 +2314,70 @@ class DownloadController extends BaseController 'addtime' => $addtime, 'begintime' => 0, 'content' => '', - 'conditions' =>$conditions + 'conditions' => $conditions ]; - $res = M('downloadlog','tab_')->add($data); + $res = M('downloadlog', 'tab_')->add($data); if (!$res) { - // $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res)); - $this->error('添加下载失败'); - } - $this->success('添加下载成功',U('listsIndex')); - } - - /* + // $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res)); + $this->error('添加下载失败'); + } + $this->success('添加下载成功', U('listsIndex')); + } + + /* * 开始导出数据 */ - public function export() { //开始导出 - $id = $_REQUEST['lid']; - $downloadStatus = M('downloadlog','tab_')->where(['id'=>$id])->field('dataname,status,conditions')->select(); - if($downloadStatus[0]['status'] == 1) { - $this->error("该数据已下载请重新添加",U('listsIndex')); - } - $dataname = $downloadStatus[0]['dataname']; - $conditions = $downloadStatus[0]['conditions']; - $map = array(); - foreach (json_decode($conditions, FALSE) as $key => $value) { - if($value !== 0 && $value !== "" ) { - $map[$key] = $value; + public function export() + { //开始导出 + $id = $_REQUEST['lid']; + $downloadStatus = M('downloadlog', 'tab_')->where(['id' => $id])->field('dataname,status,conditions')->select(); + if ($downloadStatus[0]['status'] == 1) { + $this->error("该数据已下载请重新添加", U('listsIndex')); + } + $dataname = $downloadStatus[0]['dataname']; + $conditions = $downloadStatus[0]['conditions']; + $map = array(); + foreach (json_decode($conditions, FALSE) as $key => $value) { + if ($value !== 0 && $value !== "") { + $map[$key] = $value; } - } + } switch ($dataname) { case "注册明细数据": - $this->registerExcelInfo($id,$map); //注册明细 + $this->registerExcelInfo($id, $map); //注册明细 break; case "角色查询数据": - $this->userRolesExcelInfo($id,$map); //角色查询 + $this->userRolesExcelInfo($id, $map); //角色查询 break; case "数据汇总数据": - $this->summaryExcelInfo($id,$map); + $this->summaryExcelInfo($id, $map); break; case "充值明细数据": - $this->rechargeExcelInfo($id,$map); - break; + $this->rechargeExcelInfo($id, $map); + break; case "充值玩家数据": - $this->userRechargeExcelInfo($id,$map); + $this->userRechargeExcelInfo($id, $map); break; case "推广员业绩": - $this->achievementExcelInfo($id,$map); + $this->achievementExcelInfo($id, $map); break; case "团队评级": - $this->promoteGradeExcelInfo($id,$map); + $this->promoteGradeExcelInfo($id, $map); break; case "渠道管理": - $this->childrenExcelInfo($id,$map); + $this->childrenExcelInfo($id, $map); break; case "我的平台币": - $this->mycoinExcelInfo($id,$map); + $this->mycoinExcelInfo($id, $map); break; case "我的平台币明细"; $this->mycoinRecordExcelInfo($id, $map); break; case "平台币转移": - $this->coinrecordExcelInfo($id,$map); + $this->coinrecordExcelInfo($id, $map); break; case "申请测试资源": - $this->testresourceExcelInfo($id,$map); + $this->testresourceExcelInfo($id, $map); break; case "申请测试资源记录": $this->testresourcelistExcelInfo($id, $map); @@ -2414,67 +2386,67 @@ class DownloadController extends BaseController $this->supportNumberListExcelInfo($id, $map); break; case "ARPU统计": - $this->arpuExcelInfo($id,$map); + $this->arpuExcelInfo($id, $map); break; case "每日概况": - $this->dailysummaryExcelInfo($id,$map); + $this->dailysummaryExcelInfo($id, $map); break; case "结算中心": - $this->financeindexExcelInfo($id,$map); + $this->financeindexExcelInfo($id, $map); break; case "结算明细": - $this->settlementExcelInfo($id,$map); + $this->settlementExcelInfo($id, $map); break; case "提现记录": - $this->withdrawRecordExcelInfo($id,$map); + $this->withdrawRecordExcelInfo($id, $map); break; case "提现明细": - $this->withdrawDtlExcelInfo($id,$map); + $this->withdrawDtlExcelInfo($id, $map); break; case "汇款证明": - $this->remitCerDownLoad($id,$map); + $this->remitCerDownLoad($id, $map); break; case "平台币充值": - $this->orderlistExcelInfo($id,$map); + $this->orderlistExcelInfo($id, $map); break; case "玩家行为日志": - $this->playactionExcelInfo($id,$map); + $this->playactionExcelInfo($id, $map); break; case "推广员指标": - $this->promotequotaExcelInfo($id,$map); + $this->promotequotaExcelInfo($id, $map); break; case "推广员详情": - $this->promotequotaDtlExcelInfo($id,$map); - break; + $this->promotequotaDtlExcelInfo($id, $map); + break; case "推广员操作日志": - $this->promotelogsExcelInfo($id,$map); + $this->promotelogsExcelInfo($id, $map); break; case "IOS下载统计": - $this->iosDataExcelInfo($id,$map); + $this->iosDataExcelInfo($id, $map); break; - case "IOS玩家详情下载统计": - $this->iosDetailExcelInfo($id,$map); + case "IOS玩家详情下载统计": + $this->iosDetailExcelInfo($id, $map); break; case "汇总单信息": - $this->WithdrawIndexExcelInfo($id,$map); + $this->WithdrawIndexExcelInfo($id, $map); break; case "结算单明细": - $this->WithdrawOrderExcelInfo($id,$map); + $this->WithdrawOrderExcelInfo($id, $map); break; case "用户留存率": - $this->userretentionExcelInfo($id,$map); + $this->userretentionExcelInfo($id, $map); break; case "游戏分区数据汇总": - $this->gameDataExcelInfo($id,$map); + $this->gameDataExcelInfo($id, $map); break; default: break; } - - } + } -public function iosDetailExcelInfo($id,$map) { - $xlsName ="IOS详情下载数统计"; + public function iosDetailExcelInfo($id, $map) + { + $xlsName = "IOS详情下载数统计"; $xlsCell = array( '玩家账号', '类型', @@ -2483,7 +2455,7 @@ public function iosDetailExcelInfo($id,$map) { '所属会长', '所属部门长', '所属组长' - ); + ); if (!empty($map['user_id'])) { $map1['user_id'] = $map['user_id']; @@ -2496,7 +2468,6 @@ public function iosDetailExcelInfo($id,$map) { $tfMap['create_time'] = $map['create_time']; $superMap['create_time'] = $map['create_time']; $companyMap['create_time'] = $map['create_time']; - } $belongs_president = ''; $belongs_department = ''; @@ -2517,47 +2488,47 @@ public function iosDetailExcelInfo($id,$map) { $rs = M('package_download_log', 'tab_')->field('id,game_id,user_id,type,create_time')->where($map1)->select(); $tfMap['promote_id'] = $promote_id; - $tfMap['type'] = 2; + $tfMap['type'] = 2; $TFCounts = M('package_download_log', 'tab_')->where($tfMap)->count(); $superMap['promote_id'] = $promote_id; $superMap['type'] = 3; $superCounts = M('package_download_log', 'tab_')->where($superMap)->count(); - + $companyMap['promote_id'] = $promote_id; $companyMap['type'] = 1; $companyCounts = M('package_download_log', 'tab_')->where($companyMap)->count(); - $csvFileName = $xlsName.'.csv'; + $csvFileName = $xlsName . '.csv'; header('Content-Description: File Transfer'); header('Content-Type: application/vnd.ms-excel'); - header('Content-Disposition: attachment; filename="'. $csvFileName .'"'); + header('Content-Disposition: attachment; filename="' . $csvFileName . '"'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); - $fp = fopen('php://output', 'a');//打开output流 + $fp = fopen('php://output', 'a'); //打开output流 mb_convert_variables('gb2312', 'UTF-8', $xlsCell); - fputcsv($fp, $xlsCell);//将数据格式化为CSV格式并写入到output流中 - $accessNum = count($rs)?:0 ; - $perSize = 5000;//每次查询的条数 + fputcsv($fp, $xlsCell); //将数据格式化为CSV格式并写入到output流中 + $accessNum = count($rs) ?: 0; + $perSize = 5000; //每次查询的条数 $pages = ceil($accessNum / $perSize); - for($i = 1; $i <= $pages; $i++) { + for ($i = 1; $i <= $pages; $i++) { $data = M('package_download_log', 'tab_')->field('id,game_id,user_id,type,create_time')->where($map1) - ->limit(($i-1)*$perSize ,$perSize)->select(); - foreach($data as $key => $value) { + ->limit(($i - 1) * $perSize, $perSize)->select(); + foreach ($data as $key => $value) { $user_id = $value['user_id']; $usersAccount = M('user', 'tab_')->where(['id' => $user_id])->getField('account'); $csvData['account'] = $usersAccount; if ($value['type'] == 1) { $csvData['typename'] = "企业签下载"; } - if($value['type'] == 2) { + if ($value['type'] == 2) { $csvData['typename'] = "TF下载"; } - if($value['type'] == 3) { + if ($value['type'] == 3) { $csvData['typename'] = "超级签下载"; } - $csvData['create_time'] = date('Y-m-d H:i:s', $package['create_time']); - $promoteInfo = M('promote', 'tab_')->field('account')->where(['id'=>$promote_id])->find(); + + $promoteInfo = M('promote', 'tab_')->field('account')->where(['id' => $promote_id])->find(); $csvData['promote_account'] = $promoteInfo['account']; $csvData['belongs_president'] = $belongs_president; $csvData['belongs_department'] = $belongs_department; @@ -2566,24 +2537,25 @@ public function iosDetailExcelInfo($id,$map) { mb_convert_variables('GBK', 'UTF-8', $csvData); fputcsv($fp, $csvData); $xlsData[] = $csvData; - } + } unset($xlsData); ob_flush(); flush(); } $allData['account'] = '汇总'; - $allData['typename'] = "TF下载次数:".$TFCounts; - $allData['create_time'] = "超级签下载次数:".$superCounts; - $allData['promote_account'] = "企业签下载次数:".$companyCounts; + $allData['typename'] = "TF下载次数:" . $TFCounts; + $allData['create_time'] = "超级签下载次数:" . $superCounts; + $allData['promote_account'] = "企业签下载次数:" . $companyCounts; mb_convert_variables('GBK', 'UTF-8', $allData); fputcsv($fp, $allData); $xlsData[] = $allData; fclose($fp); - $this->backSuccessExport($id); - } + $this->backSuccessExport($id); + } - public function iosDataExcelInfo($tid,$map) { - $xlsName ="IOS下载数统计"; + public function iosDataExcelInfo($tid, $map) + { + $xlsName = "IOS下载数统计"; $xlsCell = array( '推广员账号', 'IOS用户总数', @@ -2601,14 +2573,14 @@ public function iosDetailExcelInfo($id,$map) { $map1['chain'] = $map['chain']; } if (!empty($map['create_time'])) { - // $map1['create_time'] = $map['create_time']; + // $map1['create_time'] = $map['create_time']; $tfMap['create_time'] = $map['create_time']; $companyMap['create_time'] = $map['create_time']; $superMap['create_time'] = $map['create_time']; $allTFMap['create_time'] = $map['create_time']; $companyMap['create_time'] = $map['create_time']; $allSuperMap['create_time'] = $map['create_time']; - // $iosTimeMap['register_time'] = $map['create_time']; + // $iosTimeMap['register_time'] = $map['create_time']; $map10['register_time'] = $map['create_time']; $alliosMap['register_time'] = $map['create_time']; $allUserMap['register_time'] = $map['create_time']; @@ -2634,65 +2606,62 @@ public function iosDetailExcelInfo($id,$map) { array_push($allids, PID); $allUserMap['promote_id'] = ['in', $allids]; $allUserMap['device_type'] = 2; - $allTFMap['promote_id'] = ['in', $allids]; + $allTFMap['promote_id'] = ['in', $allids]; $allTFMap['type'] = 2; - - $allSuperMap['promote_id'] = ['in', $allids]; + + $allSuperMap['promote_id'] = ['in', $allids]; $allSuperMap['type'] = 3; - - $companyMap['promote_id'] = ['in', $allids]; + + $companyMap['promote_id'] = ['in', $allids]; $companyMap['type'] = 1; - + $allUsersCounts = M('user', 'tab_')->where($allUserMap)->count(); $allTFCounts = M('package_download_log', 'tab_')->where($allTFMap)->count(); $allSuperCounts = M('package_download_log', 'tab_')->where($allSuperMap)->count(); $allCompanyCounts = M('package_download_log', 'tab_')->where($companyMap)->count(); $alliosMap['promote_id'] = ['in', $allids]; $alliosMap['device_type'] = 2; - + $allIosCounts = M('user', 'tab_')->where($alliosMap)->count(); - $csvFileName = $xlsName.'.csv'; + $csvFileName = $xlsName . '.csv'; header('Content-Description: File Transfer'); header('Content-Type: application/vnd.ms-excel'); - header('Content-Disposition: attachment; filename="'. $csvFileName .'"'); + header('Content-Disposition: attachment; filename="' . $csvFileName . '"'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); - $fp = fopen('php://output', 'a');//打开output流 + $fp = fopen('php://output', 'a'); //打开output流 mb_convert_variables('gb2312', 'UTF-8', $xlsCell); - fputcsv($fp, $xlsCell);//将数据格式化为CSV格式并写入到output流中 - $accessNum = count($rs)?:0 ; - $perSize = 5000;//每次查询的条数 + fputcsv($fp, $xlsCell); //将数据格式化为CSV格式并写入到output流中 + $accessNum = count($rs) ?: 0; + $perSize = 5000; //每次查询的条数 $pages = ceil($accessNum / $perSize); if ($pages == 0) { $pages = 1; } - for($i = 1; $i <= $pages; $i++) { + for ($i = 1; $i <= $pages; $i++) { $data = M('promote', 'tab_')->field(['id'])->where($map1) - ->limit(($i-1)*$perSize ,$perSize)->select(); + ->limit(($i - 1) * $perSize, $perSize)->select(); $ids = array_column($data, 'id'); if (in_array($map['localId'], $ids)) { - }else { - + } else { } if ($i == 1) { if (!empty($map['localId']) && !in_array($map['localId'], $ids)) { - array_unshift($ids,$map['localId'] ); + array_unshift($ids, $map['localId']); } if (!in_array(PID, $ids)) { array_unshift($ids, PID); } - - } - foreach($ids as $key => $id) { + foreach ($ids as $key => $id) { $promote1 = M('promote', 'tab_')->field('account, level, parent_id, chain')->where(['id' => $id])->select(); $promote = $promote1[0]; $chain = $promote['chain']; - if($id == PID) { - $csvData['account'] = $promote['account'].'[自己]'; - }else { + if ($id == PID) { + $csvData['account'] = $promote['account'] . '[自己]'; + } else { $csvData['account'] = $promote['account']; } $iosTimeMap['promote_id'] = $id; @@ -2710,58 +2679,58 @@ public function iosDetailExcelInfo($id,$map) { $map10['promote_id'] = $id; $map10['device_type'] = 2; $usersCounts = M('user', 'tab_')->where($map10)->count(); - $tfpercent = number_format((intval($tfCounts) / intval($usersCounts)),2,'.','') * 100; + $tfpercent = number_format((intval($tfCounts) / intval($usersCounts)), 2, '.', '') * 100; if (intval($usersCounts) == 0) { - $tfpercent = 0; + $tfpercent = 0; } $csvData['userscounts'] = intval($usersCounts); $csvData['ioscount'] = $iosCount; - $csvData['tfcounts'] = intval($tfCounts).'('.$tfpercent.'%)'; + $csvData['tfcounts'] = intval($tfCounts) . '(' . $tfpercent . '%)'; $csvData['supercounts'] = intval($superCounts); $csvData['companycounts'] = intval($companyCounts); - - if($promote['level'] == 1) { + + if ($promote['level'] == 1) { $csvData['belongs_president'] = $promote['account']; $csvData['belongs_department'] = "无所属部门长"; $csvData['belongs_group'] = "无所属组长"; } if ($promote['level'] == 2) { - $parentPromote = M('promote', 'tab_')->field('account')->where(['id'=>$promote['parent_id']])->select(); + $parentPromote = M('promote', 'tab_')->field('account')->where(['id' => $promote['parent_id']])->select(); $csvData['belongs_president'] = $parentPromote[0]['account']; $csvData['belongs_department'] = $promote['account']; $csvData['belongs_group'] = "无所属组长"; } if ($promote['level'] == 3) { - $chainArr = explode('/', $chain); - $presidentAccount = M('promote', 'tab_')->where(['id' => $chainArr[1]])->getField('account'); - $departmentAccount = M('promote', 'tab_')->where(['id' => $chainArr[2]])->getField('account'); - $csvData['belongs_president'] = $presidentAccount; - $csvData['belongs_department'] = $departmentAccount; - $csvData['belongs_group'] = $promote['account']; + $chainArr = explode('/', $chain); + $presidentAccount = M('promote', 'tab_')->where(['id' => $chainArr[1]])->getField('account'); + $departmentAccount = M('promote', 'tab_')->where(['id' => $chainArr[2]])->getField('account'); + $csvData['belongs_president'] = $presidentAccount; + $csvData['belongs_department'] = $departmentAccount; + $csvData['belongs_group'] = $promote['account']; } - + if ($promote['level'] == 4) { - $chainArr = explode('/', $chain); - $presidentAccount = M('promote', 'tab_')->where(['id' => $chainArr[1]])->getField('account'); - $departmentAccount = M('promote', 'tab_')->where(['id' => $chainArr[2]])->getField('account'); - $groupAccount = M('promote', 'tab_')->where(['id' => $chainArr[3]])->getField('account'); - $csvData['belongs_president'] = $presidentAccount; - $csvData['belongs_department'] = $departmentAccount; - $csvData['belongs_group'] = $groupAccount; + $chainArr = explode('/', $chain); + $presidentAccount = M('promote', 'tab_')->where(['id' => $chainArr[1]])->getField('account'); + $departmentAccount = M('promote', 'tab_')->where(['id' => $chainArr[2]])->getField('account'); + $groupAccount = M('promote', 'tab_')->where(['id' => $chainArr[3]])->getField('account'); + $csvData['belongs_president'] = $presidentAccount; + $csvData['belongs_department'] = $departmentAccount; + $csvData['belongs_group'] = $groupAccount; } mb_convert_variables('GBK', 'UTF-8', $csvData); fputcsv($fp, $csvData); $xlsData[] = $csvData; - } + } unset($xlsData); - ob_flush(); - flush(); + ob_flush(); + flush(); } $allData['account'] = '汇总'; $allData['userscounts'] = $allUsersCounts; $allData['iosycounts'] = $allIosCounts; - $allData['tfcounts'] = $allTFCounts.'('.(number_format((intval($allTFCounts) / intval($allUsersCounts)),2,'.','') * 100).'%)'; + $allData['tfcounts'] = $allTFCounts . '(' . (number_format((intval($allTFCounts) / intval($allUsersCounts)), 2, '.', '') * 100) . '%)'; $allData['supercounts'] = $allSuperCounts; $allData['companycounts'] = $allCompanyCounts; @@ -2772,10 +2741,11 @@ public function iosDetailExcelInfo($id,$map) { fputcsv($fp, $allData); $xlsData[] = $allData; fclose($fp); - $this->backSuccessExport($tid); - } - - public function promotelogsExcelInfo($id,$map) { + $this->backSuccessExport($tid); + } + + public function promotelogsExcelInfo($id, $map) + { $xlsName = "推广员操作日志"; $xlsCell = array( '位置', @@ -2783,66 +2753,69 @@ public function iosDetailExcelInfo($id,$map) { '操作人', '时间', 'ip地址', - ); + ); $pid = $map['pid']; unset($map['pid']); - $map1['chain'] = ['like','%'.'/'.$pid.'/'.'%']; - $rs = M('promote','tab_')->where($map1)->field('id,account,nickname')->select(); + $map1['chain'] = ['like', '%' . '/' . $pid . '/' . '%']; + $rs = M('promote', 'tab_')->where($map1)->field('id,account,nickname')->select(); $childPromoteIds = ''; - if(empty($rs)) { + if (empty($rs)) { $map['promote_id'] = $pid; - }else { + } else { foreach ($rs as $rsKey => $rsValue) { $id = $rsValue['id']; - $childPromoteIds .= $id.','; + $childPromoteIds .= $id . ','; } $childPromoteIds = rtrim($childPromoteIds, ','); $childPromoteIds .= ',' . $pid; $map['promote_id'] = ['in', $childPromoteIds]; } $records = M('promote_action_logs', 'tab_')->where($map)->order('create_time')->select(); - $csvFileName = $xlsName.'.csv'; + $csvFileName = $xlsName . '.csv'; header('Content-Description: File Transfer'); header('Content-Type: application/vnd.ms-excel'); - header('Content-Disposition: attachment; filename="'. $csvFileName .'"'); + header('Content-Disposition: attachment; filename="' . $csvFileName . '"'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); - $fp = fopen('php://output', 'a');//打开output流 + $fp = fopen('php://output', 'a'); //打开output流 mb_convert_variables('gb2312', 'UTF-8', $xlsCell); - fputcsv($fp, $xlsCell);//将数据格式化为CSV格式并写入到output流中 - $accessNum = count($records)?:0 ; - $perSize = 5000;//每次查询的条数 + fputcsv($fp, $xlsCell); //将数据格式化为CSV格式并写入到output流中 + $accessNum = count($records) ?: 0; + $perSize = 5000; //每次查询的条数 $pages = ceil($accessNum / $perSize); - for($i = 1; $i <= $pages; $i++) { + for ($i = 1; $i <= $pages; $i++) { $data = M('promote_action_logs', 'tab_')->where($map)->order('create_time') - ->limit(($i-1)*$perSize ,$perSize)->select(); - foreach($data as $dataKey => $dataValue) { - $orderLen = strlen($dataValue['promote']); - $strLen = 3; - $hideChar = ''; - - if ($orderLen <= 8) { $strLen = 2;} - for ($i = 0; $i < $orderLen - $strLen * 2; $i++) { - $hideChar .= '*'; - } - $csvData['module'] = $dataValue['module']; - $csvData['action_type'] = $dataValue['action_type']; - $csvData['user_account'] = substr($dataValue['promote'], 0, $strLen) . $hideChar . substr($dataValue['promote'], $orderLen - $strLen); - $csvData['create_time'] = date("Y-m-d H:i:s",$dataValue['create_time']); - $csvData['ip'] = $dataValue['ip']; - mb_convert_variables('GBK', 'UTF-8', $csvData); - fputcsv($fp, $csvData); + ->limit(($i - 1) * $perSize, $perSize)->select(); + foreach ($data as $dataKey => $dataValue) { + $orderLen = strlen($dataValue['promote']); + $strLen = 3; + $hideChar = ''; + + if ($orderLen <= 8) { + $strLen = 2; + } + for ($i = 0; $i < $orderLen - $strLen * 2; $i++) { + $hideChar .= '*'; + } + $csvData['module'] = $dataValue['module']; + $csvData['action_type'] = $dataValue['action_type']; + $csvData['user_account'] = substr($dataValue['promote'], 0, $strLen) . $hideChar . substr($dataValue['promote'], $orderLen - $strLen); + $csvData['create_time'] = date("Y-m-d H:i:s", $dataValue['create_time']); + $csvData['ip'] = $dataValue['ip']; + mb_convert_variables('GBK', 'UTF-8', $csvData); + fputcsv($fp, $csvData); } unset($csvData); ob_flush(); flush(); - } - fclose($fp); - $this->backSuccessExport($id); - } + } + fclose($fp); + $this->backSuccessExport($id); + } - public function promotequotaDtlExcelInfo($id,$map) { + public function promotequotaDtlExcelInfo($id, $map) + { $xlsName = "推广员详情"; $xlsCell = array( '玩家账号', @@ -2853,100 +2826,91 @@ public function iosDetailExcelInfo($id,$map) { '角色名', '等级', '创建时间', - ); - $records = recordPromoteLogs('数据管理','推广员详情导出'); + ); + recordPromoteLogs('数据管理', '推广员详情导出'); $records = M('user_play_info', 'tab_')->where($map)->order('create_time desc')->select(); - $csvFileName = $xlsName.'.csv'; - //设置好告诉浏览器要下载excel文件的headers + $csvFileName = $xlsName . '.csv'; + //设置好告诉浏览器要下载excel文件的headers header('Content-Description: File Transfer'); header('Content-Type: application/vnd.ms-excel'); - header('Content-Disposition: attachment; filename="'. $csvFileName .'"'); + header('Content-Disposition: attachment; filename="' . $csvFileName . '"'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); - $fp = fopen('php://output', 'a');//打开output流 + $fp = fopen('php://output', 'a'); //打开output流 mb_convert_variables('gb2312', 'UTF-8', $xlsCell); - fputcsv($fp, $xlsCell);//将数据格式化为CSV格式并写入到output流中 - $accessNum = '100000';//从数据库获取总量,假设是十万 - $accessNum = count($records)?:0 ; - - $perSize = 5000;//每次查询的条数 - $pages = ceil($accessNum / $perSize); - for($i = 1; $i <= $pages; $i++) { - $data = M('user_play_info','tab_')->where($map)->order('create_time desc') - ->limit(($i-1)*$perSize ,$perSize)->select(); - foreach($data as $dataKey => $dataValue) { - $orderLen = strlen($dataValue['user_account']); - $strLen = 3; - $hideChar = ''; + fputcsv($fp, $xlsCell); //将数据格式化为CSV格式并写入到output流中 + $accessNum = '100000'; //从数据库获取总量,假设是十万 + $accessNum = count($records) ?: 0; - if ($orderLen <= 8) { $strLen = 2;} - for ($i = 0; $i < $orderLen - $strLen * 2; $i++) { - $hideChar .= '*'; - } - $csvData['user_account'] = substr($dataValue['user_account'], 0, $strLen) . $hideChar . substr($dataValue['user_account'], $orderLen - $strLen); + $perSize = 5000; //每次查询的条数 + $pages = ceil($accessNum / $perSize); + $loginPromote = $this->getLoginPromote(); + for ($i = 1; $i <= $pages; $i++) { + $data = M('user_play_info', 'tab_')->where($map)->order('create_time desc') + ->limit(($i - 1) * $perSize, $perSize)->select(); + foreach ($data as $dataKey => $dataValue) { + $csvData['user_account'] = getUserAccountOfPromote($dataValue['user_account'], $loginPromote); $csvData['promote_account'] = $dataValue['promote_account']; $csvData['game_name'] = $dataValue['game_name']; - if($dataValue['sdk_version'] == 1) { + if ($dataValue['sdk_version'] == 1) { $csvData['sdk_version'] = "安卓版"; } - if($dataValue['sdk_version'] == 2) { + if ($dataValue['sdk_version'] == 2) { $csvData['sdk_version'] = "苹果版"; } $csvData['server_name'] = $dataValue['server_name']; $csvData['role_name'] = $dataValue['role_name']; $csvData['role_level'] = $dataValue['role_level']; - $csvData['create_time'] = date("Y-m-d H:i:s",$dataValue['create_time']); + $csvData['create_time'] = date("Y-m-d H:i:s", $dataValue['create_time']); mb_convert_variables('GBK', 'UTF-8', $csvData); fputcsv($fp, $csvData); - } - unset($csvData); - ob_flush(); - flush(); + } + unset($csvData); + ob_flush(); + flush(); } fclose($fp); $this->backSuccessExport($id); - } - - public function promotequotaExcelInfo($tid,$map) { - $xlsName = "推广员指标"; - $xlsCell = array( - array('account','账号'), - array('real_name','姓名'), - array('game_name','游戏名称'), - array('sdk_version_text','平台'), - array('server_name','游戏区服'), - array('role_num','角色数量'), + } + + public function promotequotaExcelInfo($tid, $map) + { + $xlsName = "推广员指标"; + $xlsCell = array( + array('account', '账号'), + array('real_name', '姓名'), + array('game_name', '游戏名称'), + array('sdk_version_text', '平台'), + array('server_name', '游戏区服'), + array('role_num', '角色数量'), ); - $records = recordPromoteLogs('数据管理','推广员指标导出'); + recordPromoteLogs('数据管理', '推广员指标导出'); $params['isContainSubs'] = $map['isContainSubs']; - $params['basicPromotes'] = json_decode($map['basicPromotes'],TRUE); + $params['basicPromotes'] = json_decode($map['basicPromotes'], TRUE); $ids = $map['ids']; - $promotes = json_decode($map["promotes"],TRUE); - if(!empty($map['game_id'])) { + $promotes = json_decode($map["promotes"], TRUE); + if (!empty($map['game_id'])) { $params['game_id'] = $map["game_id"]; } - if(!empty($map['server_id'])) { + if (!empty($map['server_id'])) { $params['server_id'] = $map["server_id"]; } - if(!empty($map['sdk_version'])) { + if (!empty($map['sdk_version'])) { $params['sdk_version'] = $map["sdk_version"]; } - if(!empty($map['role_level'])) { + if (!empty($map['role_level'])) { $params['role_level'] = $map['role_level']; unset($map['role_level']); } - if(!empty($map['parentsinfo'])) { - $parent = json_decode($map['parentsinfo'],TRUE); + if (!empty($map['parentsinfo'])) { + $parent = json_decode($map['parentsinfo'], TRUE); unset($map['parentsinfo']); } - // if(!empty($map['currentDisplay'])) { - // $currentDisplay = $map['currentDisplay']; - // unset($map['currentDisplay']); - // } + $params['begin_time'] = $map['begin_time']; - $params['end_time'] = $map['end_time']; - //var_dump($params); + $params['end_time'] = $map['end_time']; + $records = []; $promoteRepository = new PromoteRepository(); $createRoleCountList = $promoteRepository->getCreateRoleCountByIds($ids, $params); @@ -2957,13 +2921,12 @@ public function iosDetailExcelInfo($id,$map) { $record = [ 'id' => $parent['id'], 'account' => $parent['account'], - 'real_name' => mb_strlen($parent['real_name'],'utf-8') == 2 ? mb_substr($parent['real_name'],0,1,'utf-8').'*':mb_substr($parent['real_name'],0,1,'utf-8').'**', + 'real_name' => mb_strlen($parent['real_name'], 'utf-8') == 2 ? mb_substr($parent['real_name'], 0, 1, 'utf-8') . '*' : mb_substr($parent['real_name'], 0, 1, 'utf-8') . '**', 'level' => $parent['level'], 'game_name' => $game['game_name'], 'sdk_version_text' => $game['sdk_version_text'], 'server_name' => $game['server_name'], 'role_num' => $selfCreateRoleCountList[$parent['id']], - 'current_display' => $currentDisplay, ]; $records[] = $record; foreach ($promotes as $promote) { @@ -2971,7 +2934,7 @@ public function iosDetailExcelInfo($id,$map) { $record = [ 'id' => $id, 'account' => $promote['account'], - 'real_name' => mb_strlen($promote['real_name'],'utf-8') == 2 ? mb_substr($promote['real_name'],0,1,'utf-8').'*':mb_substr($promote['real_name'],0,1,'utf-8').'**', + 'real_name' => hideRealName($promote['real_name']), 'level' => $promote['level'], 'game_name' => $game['game_name'], 'sdk_version_text' => $game['sdk_version_text'], @@ -2983,15 +2946,16 @@ public function iosDetailExcelInfo($id,$map) { } $xlsData = []; foreach ($records as $key1 => $value1) { - $value1['account'] = $this->encryption($value1['account']); + $value1['account'] = encryption($value1['account']); $xlsData[] = $value1; } - $this->exportExcel($xlsName, $xlsCell, $xlsData,$tid); - } + $this->exportExcel($xlsName, $xlsCell, $xlsData, $tid); + } - public function playactionExcelInfo($id,$map) { - $xlsName = "玩家行为日志"; - $xlsCell = array( + public function playactionExcelInfo($id, $map) + { + $xlsName = "玩家行为日志"; + $xlsCell = array( // 'cp订单号', '充值时间', '玩家账号', @@ -3001,106 +2965,104 @@ public function iosDetailExcelInfo($id,$map) { '角色ID', '角色名称', '订单金额' - ); - $model = M('pay_info','tab_'); - $count = M('pay_info','tab_')->field('id')->where($map)->count(); - $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 = '100000';//从数据库获取总量,假设是十万 - $accessNum = $count ?? 0; - $perSize = 5000;//每次查询的条数 - $pages = ceil($accessNum / $perSize); - for($i = 1; $i <= $pages; $i++) { - $data = $model->where($map)->order('tab_pay_info.create_time desc') - ->limit(($i-1)*$perSize ,$perSize)->select(); - foreach($data as $key => $v) { - $v['create_time'] = date('Y-m-d H:i:s',$v['create_time']); - $promoteInfo = M('promote','tab_')->field("account")->where(['id' => intval($v['promote_id'])])->find(); - $serverId = $v['server_id']; - $gameId = $v['game_id']; - $serverInfo = M('server','tab_')->field('server_name')->where(['server_num'=>$serverId,'game_id'=>$gameId])->find(); - $v['promote_id']= $promoteInfo['account']; - /* if(empty($v['extend'])) { - $v['extend'] = $v['order_id']; - } */ - // $csvData['extend'] = $this->encryption($v['extend']); - $csvData['create_time'] = $v['create_time']; - $csvData['user_account'] = $this->encryption($v['user_account']); - $csvData['game_name'] = $v['game_name']; - $csvData['promote_id'] = $v['promote_id']; - $csvData['server_name'] = $serverInfo['server_name']; - $csvData['user_id'] = $v['game_player_id']; - $csvData['game_player_name'] = $v['game_player_name']; - $csvData['price'] = $v['price']; - mb_convert_variables('GBK', 'UTF-8', $csvData); - fputcsv($fp, $csvData); - } - unset($csvData); - ob_flush(); - flush(); + ); + $model = M('pay_info', 'tab_'); + $count = M('pay_info', 'tab_')->field('id')->where($map)->count(); + $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 = '100000'; //从数据库获取总量,假设是十万 + $accessNum = $count ?? 0; + $perSize = 5000; //每次查询的条数 + $pages = ceil($accessNum / $perSize); + $loginPromote = $this->getLoginPromote(); + for ($i = 1; $i <= $pages; $i++) { + $data = $model->where($map)->order('tab_pay_info.create_time desc') + ->limit(($i - 1) * $perSize, $perSize)->select(); + foreach ($data as $key => $v) { + $v['create_time'] = date('Y-m-d H:i:s', $v['create_time']); + $promoteInfo = M('promote', 'tab_')->field("account")->where(['id' => intval($v['promote_id'])])->find(); + $serverId = $v['server_id']; + $gameId = $v['game_id']; + $serverInfo = M('server', 'tab_')->field('server_name')->where(['server_num' => $serverId, 'game_id' => $gameId])->find(); + $v['promote_id'] = $promoteInfo['account']; + $csvData['create_time'] = $v['create_time']; + $csvData['user_account'] = getUserAccountOfPromote($v['user_account'], $loginPromote); + $csvData['game_name'] = $v['game_name']; + $csvData['promote_id'] = $v['promote_id']; + $csvData['server_name'] = $serverInfo['server_name']; + $csvData['user_id'] = $v['game_player_id']; + $csvData['game_player_name'] = $v['game_player_name']; + $csvData['price'] = $v['price']; + mb_convert_variables('GBK', 'UTF-8', $csvData); + fputcsv($fp, $csvData); } - fclose($fp); - $this->backSuccessExport($id); + unset($csvData); + ob_flush(); + flush(); + } + fclose($fp); + $this->backSuccessExport($id); + } - } - - //注册明细excel信息 - public function registerExcelInfo($id,$map) { + //注册明细excel信息 + public function registerExcelInfo($id, $map) + { $xlsName = "注册明细"; $xlsCell = array( - '玩家账号', - '推广账号', - '设备IMIE/IDFA', - '注册时间', - '注册ip', - '登陆时间', - '登陆ip' + '玩家账号', + '推广账号', + '设备IMIE/IDFA', + '注册时间', + '注册ip', + '登陆时间', + '登陆ip' ); - $records = recordPromoteLogs('数据管理','注册明细导出'); - $model = M('user','tab_'); - + recordPromoteLogs('数据管理', '注册明细导出'); + $model = M('user', 'tab_'); + $data1 = $model->field('account')->where($map)->order('tab_user.id desc')->select(); - $csvFileName = $xlsName.'.csv'; + $csvFileName = $xlsName . '.csv'; //设置好告诉浏览器要下载excel文件的headers header('Content-Description: File Transfer'); header('Content-Type: application/vnd.ms-excel'); - header('Content-Disposition: attachment; filename="'. $csvFileName .'"'); + header('Content-Disposition: attachment; filename="' . $csvFileName . '"'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); - $fp = fopen('php://output', 'a');//打开output流 + $fp = fopen('php://output', 'a'); //打开output流 mb_convert_variables('gb2312', 'UTF-8', $xlsCell); - fputcsv($fp, $xlsCell);//将数据格式化为CSV格式并写入到output流中 - $accessNum = '100000';//从数据库获取总量,假设是十万 - $accessNum = count($data1)?:0 ; + fputcsv($fp, $xlsCell); //将数据格式化为CSV格式并写入到output流中 + $accessNum = '100000'; //从数据库获取总量,假设是十万 + $accessNum = count($data1) ?: 0; - $perSize = 5000;//每次查询的条数 + $perSize = 5000; //每次查询的条数 $pages = ceil($accessNum / $perSize); - for($i = 1; $i <= $pages; $i++) { - $model = M('user','tab_'); - + $loginPromote = $this->getLoginPromote(); + for ($i = 1; $i <= $pages; $i++) { + $model = M('user', 'tab_'); + $data = $model ->field('account,device_number,promote_account,register_time,register_ip,login_time,login_ip') ->where($map) - ->limit(($i-1)*$perSize ,$perSize) + ->limit(($i - 1) * $perSize, $perSize) ->order('tab_user.id desc') ->select(); - foreach($data as $value1) { - $csvData['account'] = $this->encryption($value1['account']); + foreach ($data as $value1) { + $csvData['account'] = getUserAccountOfPromote($value1['account'], $loginPromote); $csvData['promote_account'] = $value1['promote_account']; - $csvData['device_number'] = $this->encryption($value1['device_number']); - $csvData['register_time'] = date("Y-m-d H:i:s",$value1['register_time']); + $csvData['device_number'] = encryption($value1['device_number']); + $csvData['register_time'] = date("Y-m-d H:i:s", $value1['register_time']); $csvData['register_ip'] = $value1['register_ip']; - $csvData['login_time'] = date("Y-m-d H:i:s",$value1['login_time']); + $csvData['login_time'] = date("Y-m-d H:i:s", $value1['login_time']); $csvData['login_ip'] = $value1['login_ip']; mb_convert_variables('GBK', 'UTF-8', $csvData); fputcsv($fp, $csvData); @@ -3111,29 +3073,30 @@ public function iosDetailExcelInfo($id,$map) { } fclose($fp); $this->backSuccessExport($id); - } - - //玩家角色excel信息 - public function userRolesExcelInfo($id, $map) { + } + + //玩家角色excel信息 + public function userRolesExcelInfo($id, $map) + { $xlsName = "角色查询"; $xlsCell = array( - array('user_account','玩家账号'), - array('promote_account','推广账号'), - array('game_name','游戏名称'), - - array('device_number','设备码'), - array('register_time','注册时间'), - array('register_ip','注册IP'), - array('role_id','角色ID'), - array('login_time','最近登录时间'), - array('login_ip','最近登录IP'), - - array('server_name','区服'), - array('role_name','角色名'), - array('role_level','等级'), - array('create_time','创建时间'), - ); - $records = recordPromoteLogs('数据管理','角色查询导出'); + array('user_account', '玩家账号'), + array('promote_account', '推广账号'), + array('game_name', '游戏名称'), + + array('device_number', '设备码'), + array('register_time', '注册时间'), + array('register_ip', '注册IP'), + array('role_id', '角色ID'), + array('login_time', '最近登录时间'), + array('login_ip', '最近登录IP'), + + array('server_name', '区服'), + array('role_name', '角色名'), + array('role_level', '等级'), + array('create_time', '创建时间'), + ); + recordPromoteLogs('数据管理', '角色查询导出'); $map = json_decode(json_encode($map), true); @@ -3163,11 +3126,13 @@ public function iosDetailExcelInfo($id,$map) { ->where($map['map']) ->order($map['order']) ->select(); - + + $loginPromote = $this->getLoginPromote(); + $xlsData = []; - foreach ($data as $key1 => $value1) { - $value1['user_account'] = $this->encryption($value1['user_account']); - if($value1['create_time'] == 0) { + foreach ($data as $value1) { + $value1['user_account'] = getUserAccountOfPromote($value1['user_account'], $loginPromote); + if ($value1['create_time'] == 0) { $value1['create_time'] = date('Y-m-d H:i:s', $value1['play_time']); } else { $value1['create_time'] = date('Y-m-d H:i:s', $value1['create_time']); @@ -3176,34 +3141,35 @@ public function iosDetailExcelInfo($id,$map) { $value1['login_time'] = date('Y-m-d H:i:s', $value1['login_time']); $xlsData[] = $value1; } - $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); - } - - //数据汇总excel信息 - public function summaryExcelInfo($id, $map) { + $this->exportExcel($xlsName, $xlsCell, $xlsData, $id); + } + + //数据汇总excel信息 + public function summaryExcelInfo($id, $map) + { $xlsName = "数据汇总"; $xlsCell = array( - array('game_name','游戏名称'), - array('sdk_version','平台'), - array('role_num','创角数'), - array('user_num','创建用户'), - array('new_user_num','新创角用户'), - array('new_device_num','新创角设备'), - array('new_ip_num','新增创角ip'), - array('login_user_num','登陆用户数'), + array('game_name', '游戏名称'), + array('sdk_version', '平台'), + array('role_num', '创角数'), + array('user_num', '创建用户'), + array('new_user_num', '新创角用户'), + array('new_device_num', '新创角设备'), + array('new_ip_num', '新增创角ip'), + array('login_user_num', '登陆用户数'), ); - $records = recordPromoteLogs('数据管理','数据汇总导出'); - if($this->canViewUserRecharge) { - $xlsCell[] = array('spend_user_num','充值人数'); - $xlsCell[] = array('spend_num','充值次数'); - $xlsCell[] = array('spend_all_amount','充值总额'); - $xlsCell[] = array('spend_cash','现金充值'); - $xlsCell[] = array('spend_generic','通用币充值'); - $xlsCell[] = array('spend_binding','绑定币充值'); - $xlsCell[] = array('spend_discount','折扣币充值'); - $xlsCell[] = array('spend_voucher','代金券使用'); + recordPromoteLogs('数据管理', '数据汇总导出'); + if ($this->canViewUserRecharge) { + $xlsCell[] = array('spend_user_num', '充值人数'); + $xlsCell[] = array('spend_num', '充值次数'); + $xlsCell[] = array('spend_all_amount', '充值总额'); + $xlsCell[] = array('spend_cash', '现金充值'); + $xlsCell[] = array('spend_generic', '通用币充值'); + $xlsCell[] = array('spend_binding', '绑定币充值'); + $xlsCell[] = array('spend_discount', '折扣币充值'); + $xlsCell[] = array('spend_voucher', '代金券使用'); } - + $loginPromote = $this->getLoginPromote(); $map = json_decode(json_encode($map), true); $gameMap = $map['map']; @@ -3220,28 +3186,30 @@ public function iosDetailExcelInfo($id,$map) { $data = M('game', 'tab_')->where($gameMap)->order('sort desc,id desc')->select(); $records = []; - if (!empty($data)) { - if (intval($endTime - $begTime) / (24 * 3600) <= 31) { + if (!empty($data)) { + // $distanceTime = intval($endTime - $begTime); + $distanceTime = 0; + if ($distanceTime / (24 * 3600) <= 31) { $gameIds = array_column($data, 'id'); $params['game_ids'] = $gameIds; $userRepository = new UserRepository(); $spendRepository = new SpendRepository(); - $roleNumList = $userRepository->getCreateRoleCountByGame($params);//创角数 - $userNumList = $userRepository->getCreateRoleUserCountByGame($params);//创角用户 - $newUserNumList = $userRepository->getNewCreateRoleUserCountByGame($params);//新创角用户 - $newDeviceNumList = $userRepository->getNewCreateRoleDeviceCountByGame($params);//新创角设备 - $newIpNumList = $userRepository->getNewCreateRoleIpCountByGame($params);//新创角IP - $loginUserNumList = $userRepository->getLoginCountGroupByGame($params);//登录用户数 + $roleNumList = $userRepository->getCreateRoleCountByGame($params); //创角数 + $userNumList = $userRepository->getCreateRoleUserCountByGame($params); //创角用户 + $newUserNumList = $userRepository->getNewCreateRoleUserCountByGame($params); //新创角用户 + $newDeviceNumList = $userRepository->getNewCreateRoleDeviceCountByGame($params); //新创角设备 + $newIpNumList = $userRepository->getNewCreateRoleIpCountByGame($params); //新创角IP + $loginUserNumList = $userRepository->getLoginCountGroupByGame($params); //登录用户数 if ($this->canViewUserRecharge) { - $spendUserNumList = $spendRepository->getPayUserCountGroupByGame($params);//充值人数 - $spendNumList = $spendRepository->getPayCountGroupByGame($params);//充值次数 - $spendAllAmountList = $spendRepository->getPayAmountGroupByGameAndType($params);//充值总额 + $spendUserNumList = $spendRepository->getPayUserCountGroupByGame($params); //充值人数 + $spendNumList = $spendRepository->getPayCountGroupByGame($params); //充值次数 + $spendAllAmountList = $spendRepository->getPayAmountGroupByGameAndType($params); //充值总额 $params['pay_way'] = ['in', '1,2,3,4,5,6']; - $spendCashList = $spendRepository->getPayAmountGroupByGameAndType($params);//现金充值 + $spendCashList = $spendRepository->getPayAmountGroupByGameAndType($params); //现金充值 $params['pay_way'] = 0; - $spendGenericList = $spendRepository->getPayAmountGroupByGameAndType($params);//通用币充值 + $spendGenericList = $spendRepository->getPayAmountGroupByGameAndType($params); //通用币充值 $params['pay_way'] = -1; - $spendBindingList = $spendRepository->getPayAmountGroupByGameAndType($params);//绑定币充值 + $spendBindingList = $spendRepository->getPayAmountGroupByGameAndType($params); //绑定币充值 } foreach ($data as $list) { $gameId = $list['id']; @@ -3274,131 +3242,133 @@ public function iosDetailExcelInfo($id,$map) { $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);//登录用户数 - - if($this->canViewUserRecharge) { - $allData['spend_user_num'] = $spendRepository->getPayUserCountByGame($params);//充值人数 - $allData['spend_num'] = $spendRepository->getPayCountByGame($params);//充值次数 + $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); //登录用户数 + + if ($this->canViewUserRecharge) { + $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));//充值总额 + $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));//现金充值 + $allData['spend_cash'] = null_to_0($spendRepository->getPayAmountByGameAndType($params)); //现金充值 $params['pay_way'] = 0; - $allData['spend_generic'] = null_to_0($spendRepository->getPayAmountByGameAndType($params));//通用币充值 + $allData['spend_generic'] = null_to_0($spendRepository->getPayAmountByGameAndType($params)); //通用币充值 $params['pay_way'] = -1; - $allData['spend_binding'] = null_to_0($spendRepository->getPayAmountByGameAndType($params));//绑定币充值 + $allData['spend_binding'] = null_to_0($spendRepository->getPayAmountByGameAndType($params)); //绑定币充值 $allData['spend_discount'] = '0.00'; $allData['spend_voucher'] = '0.00'; - } - $records[] = $allData; + $records[] = $allData; } } - $this->exportExcel($xlsName, $xlsCell, $records,$id); - } - - /* + $this->exportExcel($xlsName, $xlsCell, $records, $id); + } + + /* *渠道管理 */ - public function childrenExcelInfo($id,$map) { - $xlsName = "渠道管理"; - $xlsCell = array( - array('id','ID'), - array('account','账号'), - array('real_name','真实姓名'), - array('idcard','身份证'), - array('mobile_phone','手机号'), - array('parent_name','上级渠道'), - array('nickname','昵称'), - array('promotestatus','帐号状态'), - array('create_time','创建时间'), - - ); - $records = recordPromoteLogs('数据管理','渠道管理导出'); - $model = M('promote','tab_'); + public function childrenExcelInfo($id, $map) + { + $xlsName = "渠道管理"; + $xlsCell = array( + array('id', 'ID'), + array('account', '账号'), + array('real_name', '真实姓名'), + array('idcard', '身份证'), + array('mobile_phone', '手机号'), + array('parent_name', '上级渠道'), + array('nickname', '昵称'), + array('promotestatus', '帐号状态'), + array('create_time', '创建时间'), + + ); + recordPromoteLogs('数据管理', '渠道管理导出'); + $model = M('promote', 'tab_'); $data = $model->where($map)->select(); $xlsData = []; - foreach ($data as $key1 => $value1) { -// $value1['status'] = $this->payWay[$value1['pay_way']]; + foreach ($data as $key1 => $value1) { + // $value1['status'] = $this->payWay[$value1['pay_way']]; $value1['promotestatus'] = "未知状态"; - if($value1['status'] == 0) { + if ($value1['status'] == 0) { $value1['promotestatus'] = "审核中"; } - if($value1['status'] == 1) { + if ($value1['status'] == 1) { $value1['promotestatus'] = "启用"; } - if($value1['status'] == 2) { + if ($value1['status'] == 2) { $value1['promotestatus'] = "冻结中"; } - $realname = mb_strlen($value1['real_name'],'utf-8') == 2 ? mb_substr($value1['real_name'],0,1,'utf-8').'*':mb_substr($value1['real_name'],0,1,'utf-8').'**'; + $realname = mb_strlen($value1['real_name'], 'utf-8') == 2 ? mb_substr($value1['real_name'], 0, 1, 'utf-8') . '*' : mb_substr($value1['real_name'], 0, 1, 'utf-8') . '**'; $value1['real_name'] = $realname; - $value1['idcard'] = substr_replace($value1['idcard'],'************',3,12); - $value1['create_time'] = date('Y-m-d H:i:s',$value1['create_time']); + $value1['idcard'] = substr_replace($value1['idcard'], '************', 3, 12); + $value1['create_time'] = date('Y-m-d H:i:s', $value1['create_time']); $xlsData[] = $value1; } - $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); - } - - public function mycoinExcelInfo($id,$map) { + $this->exportExcel($xlsName, $xlsCell, $xlsData, $id); + } + + public function mycoinExcelInfo($id, $map) + { $xlsName = "我的平台币"; $xlsCell = array( - array('cointype','平台币类型'), - array('game_name','游戏名称'), - array('num','平台币余额'), - array('status','资产状态'), - - ); - $records = recordPromoteLogs('平台币管理','我的平台币导出'); + array('cointype', '平台币类型'), + array('game_name', '游戏名称'), + array('num', '平台币余额'), + array('status', '资产状态'), + + ); + recordPromoteLogs('平台币管理', '我的平台币导出'); $data = M('PromoteBalanceCoin', 'tab_') ->field('tab_promote_balance_coin.*,tab_game.game_name') ->join('left join tab_game on tab_promote_balance_coin.game_id = tab_game.id') ->where($map) - ->select(); - foreach($data as $key => $value) { - if($value['game_id'] == 0) { + ->select(); + foreach ($data as $key => $value) { + if ($value['game_id'] == 0) { $value['cointype'] = "通用币"; $value['game_name'] = "通用"; - }else { + } else { $value['cointype'] = "绑定币"; $value['game_name'] = $value['game_name']; } - if($value['status'] == 1) { + if ($value['status'] == 1) { $value['status'] = "正常"; - }elseif($value['status'] == 2) { + } elseif ($value['status'] == 2) { $value['status'] = "锁定"; - }else { + } else { $value['status'] = "验证失败"; } $xlsData[] = $value; } - $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); - } - - public function mycoinRecordExcelInfo($id,$map) { + $this->exportExcel($xlsName, $xlsCell, $xlsData, $id); + } + + public function mycoinRecordExcelInfo($id, $map) + { $xlsName = "我的平台币明细"; $xlsCell = array( - array('sn','流水号'), - array('type_text','操作类型'), - array('sub_type_text','操作方式'), - array('target_type_text','对手操作类型'), - array('coin','平台币数量'), - array('balance_coin','平台币余额'), - array('description','交易说明'), - array('create_time','交易时间'), - ); - $records = recordPromoteLogs('平台币管理','我的平台币明细导出'); + array('sn', '流水号'), + array('type_text', '操作类型'), + array('sub_type_text', '操作方式'), + array('target_type_text', '对手操作类型'), + array('coin', '平台币数量'), + array('balance_coin', '平台币余额'), + array('description', '交易说明'), + array('create_time', '交易时间'), + ); + recordPromoteLogs('平台币管理', '我的平台币明细导出'); $service = new PromoteCoinRecordService(); - $data = M('promote_coin_record','tab_')->where($map)->select(); + $data = M('promote_coin_record', 'tab_')->where($map)->select(); $records = []; foreach ($data as $item) { - $records[] = [ + $records[] = [ 'id' => $item['id'], - 'sn' => $this->encryption($item['sn']), + 'sn' => encryption($item['sn']), 'type_text' => $service->getTypeText($item['type']), 'sub_type_text' => $service->getSubTypeText($item['sub_type']), 'target_type_text' => $service->getTargetTypeText($item['target_type'], $item['target_level']), @@ -3409,30 +3379,30 @@ public function iosDetailExcelInfo($id,$map) { 'create_time' => date('Y-m-d H:i:s', $item['create_time']), ]; } - + $xlsData = $records; - $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); - - } - - // 我的平台币的交易明细 - public function coinrecordExcelInfo($id,$map) { - $xlsName = "平台币转移"; - $xlsCell = array( - array("sn","订单号"), - array("target_account","收款方账号"), - array("game_name","适用游戏"), - array("handle_type","账号类型"), - array("num","转账数量"), - array('description',"交易说明"), - array('create_time',"交易时间"), - array('status',"交易状态"), - ); - $records = recordPromoteLogs('平台币管理','平台币转移导出'); - $model = M('promote_coin_transfer_log', 'tab_'); - $logs = $model->where($map)->select(); - $service = new PromoteCoinTransferLogService(); - $gameIds = []; + $this->exportExcel($xlsName, $xlsCell, $xlsData, $id); + } + + // 我的平台币的交易明细 + public function coinrecordExcelInfo($id, $map) + { + $xlsName = "平台币转移"; + $xlsCell = array( + array("sn", "订单号"), + array("target_account", "收款方账号"), + array("game_name", "适用游戏"), + array("handle_type", "账号类型"), + array("num", "转账数量"), + array('description', "交易说明"), + array('create_time', "交易时间"), + array('status', "交易状态"), + ); + recordPromoteLogs('平台币管理', '平台币转移导出'); + $model = M('promote_coin_transfer_log', 'tab_'); + $logs = $model->where($map)->select(); + $service = new PromoteCoinTransferLogService(); + $gameIds = []; $promoteIds = []; $uesrIds = []; foreach ($logs as $log) { @@ -3456,7 +3426,7 @@ public function iosDetailExcelInfo($id,$map) { if (count($uesrIds) > 0) { $users = M('user', 'tab_')->field(['id', 'account'])->where(['id' => ['in', $uesrIds]])->select(); } - $users = index_by_column('id', $users); + $users = index_by_column('id', $users); $promotes = index_by_column('id', $promotes); $games = index_by_column('id', $games); $records = []; @@ -3470,8 +3440,8 @@ public function iosDetailExcelInfo($id,$map) { } $records[] = [ 'id' => $log['id'], - 'sn' => $this->encryption($log['sn']), - 'target_account' => $this->encryption($targetAccount), + 'sn' => encryption($log['sn']), + 'target_account' => encryption($targetAccount), 'game_name' => isset($games[$log['game_id']]) ? $games[$log['game_id']]['game_name'] : '所有游戏', 'target_type_text' => $service->getTargetTypeText($log['target_type'], $log['target_level']), 'num' => $log['num'], @@ -3481,246 +3451,248 @@ public function iosDetailExcelInfo($id,$map) { ]; } $xlsData = $records; - $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); - - } - - public function testresourceExcelInfo($id,$map) { - $xlsName = "测试资源"; - $xlsCell = array( - array('game_name',"产品名称"), - array('server_name',"区服"), - array('user_account',"测试账号"), - array('promote_account',"所属推广员"), - array('role_name',"角色名称"), - array('verify_resource_count',"累计发放资源"), - array('verify_count',"累计发放次数"), - array('apply_resource_count',"申请数量"), - array('check_status',"状态"), - array('create_time',"创建时间"), - ); - $records = recordPromoteLogs('测试资源','测试资源导出'); - $data = M('test_resource','tab_') - ->field("tab_test_resource.*,user.check_status") - ->join('tab_user user on tab_test_resource.user_id=user.id','left') - ->order("create_time desc") - ->where($map) - ->group("user_id,game_id,server_id") - ->select(); - foreach ($data as $key => $value) { + $this->exportExcel($xlsName, $xlsCell, $xlsData, $id); + } + + public function testresourceExcelInfo($id, $map) + { + $xlsName = "测试资源"; + $xlsCell = array( + array('game_name', "产品名称"), + array('server_name', "区服"), + array('user_account', "测试账号"), + array('promote_account', "所属推广员"), + array('role_name', "角色名称"), + array('verify_resource_count', "累计发放资源"), + array('verify_count', "累计发放次数"), + array('apply_resource_count', "申请数量"), + array('check_status', "状态"), + array('create_time', "创建时间"), + ); + recordPromoteLogs('测试资源', '测试资源导出'); + $data = M('test_resource', 'tab_') + ->field("tab_test_resource.*,user.check_status") + ->join('tab_user user on tab_test_resource.user_id=user.id', 'left') + ->order("create_time desc") + ->where($map) + ->group("user_id,game_id,server_id") + ->select(); + $loginPromote = $this->getLoginPromote(); + foreach ($data as $key => $value) { $value['create_time'] = date("Y-m-d H:i:s", $value['create_time']); - $value['user_account'] = $this->encryption($value['user_account']); - if($value['check_status'] == 1) { + $value['user_account'] = getUserAccountOfPromote($value['user_account'], $loginPromote); + if ($value['check_status'] == 1) { $value['check_status'] = "正常"; - }else { + } else { $value['check_status'] = "拉黑"; } //获取累计发放 $where = array( - "user_id"=>$value['user_id'], - "game_id"=>$value['game_id'], - "server_id"=>$value['server_id'] + "user_id" => $value['user_id'], + "game_id" => $value['game_id'], + "server_id" => $value['server_id'] ); $where1 = array( - "apply_status"=>2, + "apply_status" => 2, ); //获取累计 - $verify_resource = M('test_resource','tab_')->field("IFNULL(sum(verify_resource),0) verify_resource_count,count(*) verify_count")->where(array_merge($where,$where1))->find(); + $verify_resource = M('test_resource', 'tab_')->field("IFNULL(sum(verify_resource),0) verify_resource_count,count(*) verify_count")->where(array_merge($where, $where1))->find(); //获取申请 $where2 = array( - "apply_status"=>0, + "apply_status" => 0, ); - $apply_resource = M('test_resource','tab_')->field("IFNULL(sum(apply_resource),0) apply_resource_count")->where(array_merge($where,$where2))->find(); - $data[$key] = array_merge($value,$verify_resource,$apply_resource); + $apply_resource = M('test_resource', 'tab_')->field("IFNULL(sum(apply_resource),0) apply_resource_count")->where(array_merge($where, $where2))->find(); + $data[$key] = array_merge($value, $verify_resource, $apply_resource); } $xlsData = $data; - $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); - - - } - - public function testresourcelistExcelInfo($id,$map){ - $xlsName = "测试资源申请记录"; - $xlsCell = array( - array('game_name',"游戏名称"), - array('server_name',"区服"), - array('user_account',"测试账号"), - array('phone',"手机号"), - array('role_name',"角色名称"), - array('apply_resource',"申请数量"), - array('verify_resource',"实际发放"), - array('apply_remark',"备注"), - array('apply_status',"审核状态"), - array('verify_remark',"审核意见"), - array('promote_account',"申请人"), - array('create_time',"申请时间"), - array('verify_time',"审核时间"), - ); - $records = recordPromoteLogs('测试资源','测试资源记录导出'); - $data=M('test_resource','tab_')->where($map)->order('id desc')->select(); - foreach($data as $key => $value) { - $data[$key]['user_account'] = $this->encryption($value['user_account']); - if($value['apply_status'] == 1) { - $data[$key]['apply_status'] = "审核未通过"; - } - elseif($value['apply_status'] == 2) { - $data[$key]['apply_status'] = "审核通过"; - } - else { - $data[$key]['apply_status'] = "待审核"; - } - $data[$key]['create_time'] = date('Y-m-d H:i:s',$value['create_time']); - $data[$key]['verify_time'] = date('Y-m-d H:i:s',$value['verify_time']); - } - $xlsData = $data; - $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); - } - - public function supportNumberListExcelInfo($id,$map) { + $this->exportExcel($xlsName, $xlsCell, $xlsData, $id); + } + + public function testresourcelistExcelInfo($id, $map) + { + $xlsName = "测试资源申请记录"; + $xlsCell = array( + array('game_name', "游戏名称"), + array('server_name', "区服"), + array('user_account', "测试账号"), + array('phone', "手机号"), + array('role_name', "角色名称"), + array('apply_resource', "申请数量"), + array('verify_resource', "实际发放"), + array('apply_remark', "备注"), + array('apply_status', "审核状态"), + array('verify_remark', "审核意见"), + array('promote_account', "申请人"), + array('create_time', "申请时间"), + array('verify_time', "审核时间"), + ); + recordPromoteLogs('测试资源', '测试资源记录导出'); + $data = M('test_resource', 'tab_')->where($map)->order('id desc')->select(); + $loginPromote = $this->getLoginPromote(); + foreach ($data as $key => $value) { + $data[$key]['user_account'] = getUserAccountOfPromote($value['user_account'], $loginPromote); + if ($value['apply_status'] == 1) { + $data[$key]['apply_status'] = "审核未通过"; + } elseif ($value['apply_status'] == 2) { + $data[$key]['apply_status'] = "审核通过"; + } else { + $data[$key]['apply_status'] = "待审核"; + } + $data[$key]['create_time'] = date('Y-m-d H:i:s', $value['create_time']); + $data[$key]['verify_time'] = date('Y-m-d H:i:s', $value['verify_time']); + } + $xlsData = $data; + $this->exportExcel($xlsName, $xlsCell, $xlsData, $id); + } + + public function supportNumberListExcelInfo($id, $map) + { $xlsName = "扶持号管理"; $xlsCell = array( - array('game_name',"产品名称"), - array('server_name',"区服"), - array('user_account',"测试账号"), - array('promote_account',"所属推广员"), - array('role_name',"角色名称"), - array('device_number',"设备信息"), - array('check_status',"状态"), - array('create_time',"创建时间"), - ); - $records = recordPromoteLogs('测试资源','扶持号管理导出'); - $data = M('test_resource','tab_') - ->field('tab_test_resource.id,tab_test_resource.user_id,tab_test_resource.game_name,tab_test_resource.server_name,tab_test_resource.user_account,tab_test_resource.promote_account,tab_test_resource.role_name,tab_test_resource.create_time,device_number,lock_status as check_status') - ->join('left join tab_user as user on tab_test_resource.user_id = user.id') - ->where($map) - ->order('tab_test_resource.create_time DESC') - ->select(); - foreach ($data as $key => $value) { - $data[$key]['create_time'] = date('Y-m-d H:m:i',$value['create_time']); - $data[$key]['user_account'] = $this->encryption($value['user_account']); - if($value['check_status'] == 1) { + array('game_name', "产品名称"), + array('server_name', "区服"), + array('user_account', "测试账号"), + array('promote_account', "所属推广员"), + array('role_name', "角色名称"), + array('device_number', "设备信息"), + array('check_status', "状态"), + array('create_time', "创建时间"), + ); + recordPromoteLogs('测试资源', '扶持号管理导出'); + $data = M('test_resource', 'tab_') + ->field('tab_test_resource.id,tab_test_resource.user_id,tab_test_resource.game_name,tab_test_resource.server_name,tab_test_resource.user_account,tab_test_resource.promote_account,tab_test_resource.role_name,tab_test_resource.create_time,device_number,lock_status as check_status') + ->join('left join tab_user as user on tab_test_resource.user_id = user.id') + ->where($map) + ->order('tab_test_resource.create_time DESC') + ->select(); + $loginPromote = $this->getLoginPromote(); + foreach ($data as $key => $value) { + $data[$key]['create_time'] = date('Y-m-d H:m:i', $value['create_time']); + $data[$key]['user_account'] = getUserAccountOfPromote($value['user_account'], $loginPromote); + if ($value['check_status'] == 1) { $data[$key]['check_status'] = "启用"; - }else { + } else { $data[$key]['check_status'] = "冻结"; } } - $xlsData = $data; - $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); - } - - public function arpuExcelInfo($id,$params) { + $xlsData = $data; + $this->exportExcel($xlsName, $xlsCell, $xlsData, $id); + } + + public function arpuExcelInfo($id, $params) + { $xlsName = "ARPU统计"; $xlsCell = array( - array('day','日期'), - array('payGameCount','付费游戏数'), - array('loginCount','活跃用户'), - array('registerCount','新增用户'), - array('payUserCount','付费用户'), - array('newPayUserCount','新增付费用户'), - array('payAmount','付费总额'), - array('payRate','付费率'), - array('newPayAmount','新增付费额'), - // array('historyPayCount','累计付费用户'), - array('arpu','ARPU'), - array('arppu','ARPPU'), + array('day', '日期'), + array('payGameCount', '付费游戏数'), + array('loginCount', '活跃用户'), + array('registerCount', '新增用户'), + array('payUserCount', '付费用户'), + array('newPayUserCount', '新增付费用户'), + array('payAmount', '付费总额'), + array('payRate', '付费率'), + array('newPayAmount', '新增付费额'), + // array('historyPayCount','累计付费用户'), + array('arpu', 'ARPU'), + array('arppu', 'ARPPU'), ); - $records = recordPromoteLogs('数据管理','ARPU统计导出'); - $dayList = $params["dayList"]; - $arr = explode(',', $params['promote_id'][1]); - $params['promote_id'] = $arr; - $records = []; - $userRepository = new UserRepository(); - $spendRepository = new SpendRepository(); - $payGameCountList = $spendRepository->getPayGameCountGroupByDay($params); - $payUserCountList = $spendRepository->getPayUserCountGroupByDay($params); - $newPayUserCountList = $spendRepository->getNewPayUserCountGroupByDay($params); - $payAmountList = $spendRepository->getPayAmountGroupByDay($params); - $newPayAmountList = $spendRepository->getNewPayAmountGroupByDay($params); - // $historyPayCountList = $spendRepository->getHistoryPayCountGroupByDay($params); - $loginCountList = $userRepository->getLoginCountGroupByDay($params); - $registerCountList = $userRepository->getRegisterCountGroupByDay($params); + recordPromoteLogs('数据管理', 'ARPU统计导出'); + $dayList = $params["dayList"]; + $arr = explode(',', $params['promote_id'][1]); + $params['promote_id'] = $arr; + $records = []; + $userRepository = new UserRepository(); + $spendRepository = new SpendRepository(); + $payGameCountList = $spendRepository->getPayGameCountGroupByDay($params); + $payUserCountList = $spendRepository->getPayUserCountGroupByDay($params); + $newPayUserCountList = $spendRepository->getNewPayUserCountGroupByDay($params); + $payAmountList = $spendRepository->getPayAmountGroupByDay($params); + $newPayAmountList = $spendRepository->getNewPayAmountGroupByDay($params); + // $historyPayCountList = $spendRepository->getHistoryPayCountGroupByDay($params); + $loginCountList = $userRepository->getLoginCountGroupByDay($params); + $registerCountList = $userRepository->getRegisterCountGroupByDay($params); - foreach ($dayList as $day) { - $records[] = [ - 'day' => $day, - 'payGameCount' => $payGameCountList[$day], - 'payUserCount' => $payUserCountList[$day], - 'newPayUserCount' => $newPayUserCountList[$day], - 'payAmount' => number_format($payAmountList[$day], 2), - 'newPayAmount' => number_format($newPayAmountList[$day], 2), - // 'historyPayCount' => $historyPayCountList[$day], - 'loginCount' => $loginCountList[$day], - 'registerCount' => $registerCountList[$day], - 'payRate' => $loginCountList[$day] == 0 ? '--' : round($payUserCountList[$day] / $loginCountList[$day] * 100, 2) . '%', - 'ratentionOneDay' => '--', - 'arpu' => $loginCountList[$day] == 0 ? '0.00' : number_format(round($payAmountList[$day] / $loginCountList[$day], 2), 2), - 'arppu' => $payUserCountList[$day] == 0 ? '0.00' : number_format(round($payAmountList[$day] / $payUserCountList[$day], 2), 2), - ]; - } - $xlsData = []; - foreach ($records as $key1 => $value1) { - $xlsData[] = $value1; - } - $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); - - - } - - public function orderlistExcelInfo($id,$map) { - $xlsName = "平台币充值"; - $xlsCell = array( - array('order_number','充值订单号'), - array('pay_amount','充值金额'), - array('discount','优惠值'), - array('coin_num','平台币数量'), - array('pay_type','转账类型'), - array('order_status1','订单状态'), - array('time','申请时间'), - ); - $records = recordPromoteLogs('平台币管理','平台币充值导出'); - $model = M('coin_pay_order','tab_'); + foreach ($dayList as $day) { + $records[] = [ + 'day' => $day, + 'payGameCount' => $payGameCountList[$day], + 'payUserCount' => $payUserCountList[$day], + 'newPayUserCount' => $newPayUserCountList[$day], + 'payAmount' => number_format($payAmountList[$day], 2), + 'newPayAmount' => number_format($newPayAmountList[$day], 2), + // 'historyPayCount' => $historyPayCountList[$day], + 'loginCount' => $loginCountList[$day], + 'registerCount' => $registerCountList[$day], + 'payRate' => $loginCountList[$day] == 0 ? '--' : round($payUserCountList[$day] / $loginCountList[$day] * 100, 2) . '%', + 'ratentionOneDay' => '--', + 'arpu' => $loginCountList[$day] == 0 ? '0.00' : number_format(round($payAmountList[$day] / $loginCountList[$day], 2), 2), + 'arppu' => $payUserCountList[$day] == 0 ? '0.00' : number_format(round($payAmountList[$day] / $payUserCountList[$day], 2), 2), + ]; + } + $xlsData = []; + foreach ($records as $key1 => $value1) { + $xlsData[] = $value1; + } + $this->exportExcel($xlsName, $xlsCell, $xlsData, $id); + } + + public function orderlistExcelInfo($id, $map) + { + $xlsName = "平台币充值"; + $xlsCell = array( + array('order_number', '充值订单号'), + array('pay_amount', '充值金额'), + array('discount', '优惠值'), + array('coin_num', '平台币数量'), + array('pay_type', '转账类型'), + array('order_status1', '订单状态'), + array('time', '申请时间'), + ); + recordPromoteLogs('平台币管理', '平台币充值导出'); + $model = M('coin_pay_order', 'tab_'); $data = $model->where($map)->order('id DESC')->select(); foreach ($data as $key => $value) { - if($value['pay_type'] == 1) { + if ($value['pay_type'] == 1) { $data[$key]['pay_type'] = "线上充值"; } else { $data[$key]['pay_type'] = "线下充值"; } - - if($value['order_status'] == 0) { + + if ($value['order_status'] == 0) { $data[$key]['order_status1'] = "待付款"; } - if($value['order_status'] == 1) { + if ($value['order_status'] == 1) { $data[$key]['order_status1'] = "付款成功"; } - if($value['order_status'] == 2) { + if ($value['order_status'] == 2) { $data[$key]['order_status1'] = "待审核"; } - if($value['order_status'] == 3) { + if ($value['order_status'] == 3) { $data[$key]['order_status1'] = "待发币"; } - if($value['order_status'] == 4) { + if ($value['order_status'] == 4) { $data[$key]['order_status1'] = "已发币"; } - if($value['order_status'] == 5) { + if ($value['order_status'] == 5) { $data[$key]['order_status1'] = "审核不通过"; } - - $data[$key]['time'] = date('Y-m-d H:i:s' ,$value['create_time']); - + + $data[$key]['time'] = date('Y-m-d H:i:s', $value['create_time']); } $xlsData = $data; - $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); - } - - public function remitCerDownLoad($id,$map) { - $proof_id = $map['id']; - $file = new FileController(); - $file->download($proof_id); - $this->backSuccessExport($id); - } - - public function withdrawDtlExcelInfo($id,$map) { + $this->exportExcel($xlsName, $xlsCell, $xlsData, $id); + } + + public function remitCerDownLoad($id, $map) + { + $proof_id = $map['id']; + $file = new FileController(); + $file->download($proof_id); + $this->backSuccessExport($id); + } + + public function withdrawDtlExcelInfo($id, $map) + { $xlsName = "提现记录"; $xlsCell = array( '充值订单号', @@ -3747,11 +3719,12 @@ public function iosDetailExcelInfo($id,$map) { ->where($map) ->order('id desc') ->select(); + $loginPromote = $this->getLoginPromote(); if (!empty($data)) { foreach ($data as $key => &$list) { $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']); - $list['user_account'] = $this->encryption($list['user_account']); + $list['user_account'] = getUserAccountOfPromote($list['user_account'], $loginPromote); switch ($list['pay_way']) { case 2: case 3: @@ -3762,49 +3735,49 @@ public function iosDetailExcelInfo($id,$map) { $list['pay_way_name'] = QueryController::$payWay[$list['pay_way']]; break; } - if($list['pay_way'] !== -1 && $list['pay_way'] !== 0) { + if ($list['pay_way'] !== -1 && $list['pay_way'] !== 0) { $list['cash_base'] = $list['pay_amount']; - }else { + } else { $list['cash_base'] = 0; } - $list['cash_selle_ratio'] = $list['selle_ratio']; - if($list['pay_way'] == 0) { + $list['cash_selle_ratio'] = $list['selle_ratio']; + if ($list['pay_way'] == 0) { $list['platform_base'] = $list['pay_amount']; - }else { + } else { $list['platform_base'] = 0; } $list['platform_selle_ratio'] = $list['selle_ratio']; - if($list['pay_way'] == -1) { + if ($list['pay_way'] == -1) { $list['bind_base'] = $list['pay_amount']; - }else { + } else { $list['bind_base'] = 0; } $list['bind_selle_ratio'] = $list['selle_ratio']; $list['status'] = FinanceController::$withdrawStatus[$withdraw['status']]; unset($list['pay_way']); - unset($list['selle_ratio']); + unset($list['selle_ratio']); } } - $csvFileName = $xlsName.'.csv'; + $csvFileName = $xlsName . '.csv'; //设置好告诉浏览器要下载excel文件的headers header('Content-Description: File Transfer'); header('Content-Type: application/vnd.ms-excel'); - header('Content-Disposition: attachment; filename="'. $csvFileName .'"'); + header('Content-Disposition: attachment; filename="' . $csvFileName . '"'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); - $fp = fopen('php://output', 'a');//打开output流 + $fp = fopen('php://output', 'a'); //打开output流 mb_convert_variables('gb2312', 'UTF-8', $xlsCell); - fputcsv($fp, $xlsCell);//将数据格式化为CSV格式并写入到output流中 - $accessNum = '100000';//从数据库获取总量,假设是十万 - $accessNum = count($data)?:0 ; + fputcsv($fp, $xlsCell); //将数据格式化为CSV格式并写入到output流中 + $accessNum = '100000'; //从数据库获取总量,假设是十万 + $accessNum = count($data) ?: 0; - $perSize = 5000;//每次查询的条数 + $perSize = 5000; //每次查询的条数 $pages = ceil($accessNum / $perSize); - for($i = 1; $i <= $pages; $i++) { - foreach($data as $value) { + for ($i = 1; $i <= $pages; $i++) { + foreach ($data as $value) { mb_convert_variables('GBK', 'UTF-8', $value); fputcsv($fp, $value); } @@ -3814,20 +3787,20 @@ public function iosDetailExcelInfo($id,$map) { } fclose($fp); $this->backSuccessExport($id); - } - - public function withdrawRecordExcelInfo($id,$map) { - $xlsName = "提现记录"; - $xlsCell = array( - array('widthdraw_number','提现订单'), - array('create_time','提现日期'), - array('settlement_end_time','结算截止日期'), - array('sum_money','收益金额'), - array('sum_money','实际提现金额'), - array('status','提现状态'), - array('respond','说明'), - ); + + public function withdrawRecordExcelInfo($id, $map) + { + $xlsName = "提现记录"; + $xlsCell = array( + array('widthdraw_number', '提现订单'), + array('create_time', '提现日期'), + array('settlement_end_time', '结算截止日期'), + array('sum_money', '收益金额'), + array('sum_money', '实际提现金额'), + array('status', '提现状态'), + array('respond', '说明'), + ); $model = M('withdraw', 'tab_'); $data = $model->field('id,widthdraw_number,create_time,settlement_end_time,sum_money,status,respond') ->where($map) @@ -3841,12 +3814,13 @@ public function iosDetailExcelInfo($id,$map) { } } $xlsData = $data; - $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); - } - - public function settlementExcelInfo($id,$map) { - $xlsName = "结算明细"; - $xlsCell = array( + $this->exportExcel($xlsName, $xlsCell, $xlsData, $id); + } + + public function settlementExcelInfo($id, $map) + { + $xlsName = "结算明细"; + $xlsCell = array( '游戏订单号', '游戏', '玩家账号', @@ -3864,53 +3838,54 @@ public function iosDetailExcelInfo($id,$map) { $spendRepository = new SpendRepository(); $map = $spendRepository->withIsCheck($map); - $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') + $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(); - $total = []; + ->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(); + ->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); //提现状态 - $csvFileName = $xlsName.'.csv'; + $csvFileName = $xlsName . '.csv'; //设置好告诉浏览器要下载excel文件的headers header('Content-Description: File Transfer'); header('Content-Type: application/vnd.ms-excel'); - header('Content-Disposition: attachment; filename="'. $csvFileName .'"'); + header('Content-Disposition: attachment; filename="' . $csvFileName . '"'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); - $fp = fopen('php://output', 'a');//打开output流 + $fp = fopen('php://output', 'a'); //打开output流 mb_convert_variables('gb2312', 'UTF-8', $xlsCell); - fputcsv($fp, $xlsCell);//将数据格式化为CSV格式并写入到output流中 - $accessNum = count($data)?:0 ; + fputcsv($fp, $xlsCell); //将数据格式化为CSV格式并写入到output流中 + $accessNum = count($data) ?: 0; - $perSize = 5000;//每次查询的条数 + $perSize = 5000; //每次查询的条数 $pages = ceil($accessNum / $perSize); - for($i = 1; $i <= $pages; $i++) { - - $data = $model->field('pay_order_number,game_name,user_account,promote_id,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(); + $loginPromote = $this->getLoginPromote(); + for ($i = 1; $i <= $pages; $i++) { + + $data = $model->field('pay_order_number,game_name,user_account,promote_id,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']; } } - if(empty($withdrawIds)) { + if (empty($withdrawIds)) { $withdrawIds = "-10000"; } $withdrawStatus = M('withdraw', 'tab_') - ->where(array('id' => ['in',$withdrawIds])) + ->where(array('id' => ['in', $withdrawIds])) ->getField('id,status'); $promotes = []; @@ -3923,8 +3898,8 @@ public function iosDetailExcelInfo($id,$map) { foreach ($data as &$list) { //提现状态 - $list['pay_order_number'] = $this->encryption($list['pay_order_number']); - $list['user_account'] = $this->encryption($list['user_account']); + $list['pay_order_number'] = encryption($list['pay_order_number']); + $list['user_account'] = getUserAccountOfPromote($list['user_account'], $loginPromote); if ($list['pay_status'] == 1) { switch ($list['selle_status']) { case 0: @@ -3944,12 +3919,12 @@ public function iosDetailExcelInfo($id,$map) { $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) { + 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; + } else { + $list['pay_amount_zhi'] = $list['pay_amount']; + $list['pay_amount_nei'] = 0; } $promoteGroup = isset($promotes[$list['promote_id']]) ? $promoteService->getGroupNameByChain($promotes[$list['promote_id']]['chain'], $list['promote_id']) : ''; @@ -3969,7 +3944,7 @@ public function iosDetailExcelInfo($id,$map) { mb_convert_variables('GBK', 'UTF-8', $csvData); fputcsv($fp, $csvData); $xlsData[] = $csvData; - } + } unset($xlsData); ob_flush(); flush(); @@ -3992,23 +3967,20 @@ public function iosDetailExcelInfo($id,$map) { fclose($fp); $this->backSuccessExport($id); - - - // $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); - - } - - public function financeindexExcelInfo($id,$map) { - $xlsName = "结算中心"; - $xlsCell = array( - array('day','时间'), - array('income','收益') - ); - if(!empty($map['pay_time'])) { - $begTime = $map['pay_time'][1][0]; - $endTime = $map['pay_time'][1][1]; - }else { - $nowTime = date('Y-m-d'); + } + + public function financeindexExcelInfo($id, $map) + { + $xlsName = "结算中心"; + $xlsCell = array( + array('day', '时间'), + array('income', '收益') + ); + if (!empty($map['pay_time'])) { + $begTime = $map['pay_time'][1][0]; + $endTime = $map['pay_time'][1][1]; + } else { + $nowTime = date('Y-m-d'); $initBegTime = date('Y-m-d', strtotime('-6 day', strtotime($nowTime))); $initBegTime = empty(I('begtime')) ? $initBegTime : I('begtime'); $initEndTime = $nowTime; @@ -4016,14 +3988,14 @@ public function iosDetailExcelInfo($id,$map) { $begTime = strtotime($initBegTime); $endTime = strtotime($initEndTime); $endTime = $endTime + 3600 * 24; - } + } - $spendRepository = new SpendRepository(); - $map = $spendRepository->withIsCheck($map); + $spendRepository = new SpendRepository(); + $map = $spendRepository->withIsCheck($map); - $model = M('spend', 'tab_'); - $dayList = $this->getDayList($begTime, $endTime); - $data = $model->field('FROM_UNIXTIME(pay_time, "%Y-%m-%d") as day, + $model = M('spend', 'tab_'); + $dayList = $this->getDayList($begTime, $endTime); + $data = $model->field('FROM_UNIXTIME(pay_time, "%Y-%m-%d") as day, sum(if(selle_ratio > 0, pay_amount * selle_ratio, 0)) as income') ->where($map) ->group('day') @@ -4034,41 +4006,41 @@ public function iosDetailExcelInfo($id,$map) { $records[] = [ 'day' => $date, 'income' => bcdiv($data[$day], 100, 2), - + ]; } - $xlsData = []; + $xlsData = []; foreach ($records as $key1 => $value1) { - $xlsData[] = $value1; + $xlsData[] = $value1; } - $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); - - } - - public function dailysummaryExcelInfo($id,$map) { + $this->exportExcel($xlsName, $xlsCell, $xlsData, $id); + } + + public function dailysummaryExcelInfo($id, $map) + { $xlsName = "每日概况"; $xlsCell = array( - array('day','日期'), - array('role_num','创角数'), - array('user_num','创角用户'), - array('new_user_num','新创角用户'), - array('new_device_num','新创角设备'), - array('new_ip_num','新增创角IP'), - array('login_user_num','登陆用户数'), + array('day', '日期'), + array('role_num', '创角数'), + array('user_num', '创角用户'), + array('new_user_num', '新创角用户'), + array('new_device_num', '新创角设备'), + array('new_ip_num', '新增创角IP'), + array('login_user_num', '登陆用户数'), ); - $records = recordPromoteLogs('数据管理','每日概况导出'); + recordPromoteLogs('数据管理', '每日概况导出'); if ($this->canViewUserRecharge) { - $xlsCell[] = array('spend_user_num','充值人数'); - $xlsCell[] = array('spend_num','充值次数'); - $xlsCell[] = array('spend_all_amount','充值总额'); - $xlsCell[] = array('spend_cash','现金充值'); - $xlsCell[] = array('spend_generic','通用币充值'); - $xlsCell[] = array('spend_binding','绑定币充值'); - $xlsCell[] = array('spend_discount','折扣币充值'); - $xlsCell[] = array('spend_voucher','代金劵使用'); - } + $xlsCell[] = array('spend_user_num', '充值人数'); + $xlsCell[] = array('spend_num', '充值次数'); + $xlsCell[] = array('spend_all_amount', '充值总额'); + $xlsCell[] = array('spend_cash', '现金充值'); + $xlsCell[] = array('spend_generic', '通用币充值'); + $xlsCell[] = array('spend_binding', '绑定币充值'); + $xlsCell[] = array('spend_discount', '折扣币充值'); + $xlsCell[] = array('spend_voucher', '代金劵使用'); + } $nowTime = date('Y-m-d'); $initBegTime = date('Y-m-d', strtotime('-6 day', strtotime($nowTime))); $initBegTime = empty(I('begtime')) ? $initBegTime : I('begtime'); @@ -4076,52 +4048,51 @@ public function iosDetailExcelInfo($id,$map) { $initEndTime = empty(I('endtime')) ? $initEndTime : I('endtime'); $begTime = strtotime($initBegTime); $endTime = strtotime($initEndTime); - $params['promote_id'] = $map['promote_id']; - if(!empty($map['sdk_version']) || !empty($map['relation_game_id'])) { - if(!empty($map['gameIds'])) { - $params['game_id'] = ['in',$map['gameIds']]; - }else { - $params['_string'] = '1=2'; - } - } - if(!empty($map['begin_time'])) { - $params['begin_time'] = $map['begin_time']; - }else { - $params['begin_time'] = $begTime; - } - - if(!empty($map['end_time'])) { - $params['end_time'] = $map['end_time']; - }else { - $params['begin_time'] = $endTime - 1; - } - $params['dayList'] = $map["dayList"]; - $summaryData = []; - if (intval($endTime - $begTime) / (24 * 3600) <= 30) { + $params['promote_id'] = $map['promote_id']; + if (!empty($map['sdk_version']) || !empty($map['relation_game_id'])) { + if (!empty($map['gameIds'])) { + $params['game_id'] = ['in', $map['gameIds']]; + } else { + $params['_string'] = '1=2'; + } + } + if (!empty($map['begin_time'])) { + $params['begin_time'] = $map['begin_time']; + } else { + $params['begin_time'] = $begTime; + } + + if (!empty($map['end_time'])) { + $params['end_time'] = $map['end_time']; + } else { + $params['begin_time'] = $endTime - 1; + } + $params['dayList'] = $map["dayList"]; + if (intval($endTime - $begTime) / (24 * 3600) <= 30) { $userRepository = new UserRepository(); $spendRepository = new SpendRepository(); - $roleNumList = $userRepository->getCreateRoleCountByDay($params);//创角数 - $userNumList = $userRepository->getCreateRoleUserCountByDay($params);//创角用户 - $newUserNumList = $userRepository->getNewCreateRoleUserCountByDay($params);//新创角用户 - $newDeviceNumList = $userRepository->getNewCreateRoleDeviceCountByDay($params);//新创角设备 - $newIpNumList = $userRepository->getNewCreateRoleIpCountByDay($params);//新创角IP - $loginUserNumList = $userRepository->getLoginCountGroupByDayNew($params);//登录用户数 - $spendUserNumList = $spendRepository->getPayUserCountGroupByDayNew($params);//充值人数 - $spendNumList = $spendRepository->getPayCountGroupByDay($params);//充值次数 - $spendAllAmountList = $spendRepository->getPayAmountGroupByDayAndType($params);//充值总额 + $roleNumList = $userRepository->getCreateRoleCountByDay($params); //创角数 + $userNumList = $userRepository->getCreateRoleUserCountByDay($params); //创角用户 + $newUserNumList = $userRepository->getNewCreateRoleUserCountByDay($params); //新创角用户 + $newDeviceNumList = $userRepository->getNewCreateRoleDeviceCountByDay($params); //新创角设备 + $newIpNumList = $userRepository->getNewCreateRoleIpCountByDay($params); //新创角IP + $loginUserNumList = $userRepository->getLoginCountGroupByDayNew($params); //登录用户数 + $spendUserNumList = $spendRepository->getPayUserCountGroupByDayNew($params); //充值人数 + $spendNumList = $spendRepository->getPayCountGroupByDay($params); //充值次数 + $spendAllAmountList = $spendRepository->getPayAmountGroupByDayAndType($params); //充值总额 $params['pay_way'] = ['in', '1,2,3,4,5,6']; - $spendCashList = $spendRepository->getPayAmountGroupByDayAndType($params);//现金充值 + $spendCashList = $spendRepository->getPayAmountGroupByDayAndType($params); //现金充值 $params['pay_way'] = 0; - $spendGenericList = $spendRepository->getPayAmountGroupByDayAndType($params);//通用币充值 + $spendGenericList = $spendRepository->getPayAmountGroupByDayAndType($params); //通用币充值 $params['pay_way'] = -1; - $spendBindingList = $spendRepository->getPayAmountGroupByDayAndType($params);//绑定币充值 + $spendBindingList = $spendRepository->getPayAmountGroupByDayAndType($params); //绑定币充值 $allData['role_num'] = 0; $allData['user_num'] = 0; $allData['new_user_num'] = 0; $allData['new_device_num'] = 0; $allData['new_ip_num'] = 0; $allData['login_user_num'] = 0; - if($this->canViewUserRecharge) { + if ($this->canViewUserRecharge) { $allData['spend_user_num'] = 0; $allData['spend_num'] = 0; $allData['spend_all_amount'] = 0; @@ -4131,9 +4102,10 @@ public function iosDetailExcelInfo($id,$map) { $allData['spend_discount'] = 0; $allData['spend_voucher'] = 0; } + $records = []; foreach ($params['dayList'] as $day) { $date = date('Ymd', strtotime($day)); - $records[] = [ + $record = [ 'day' => $date, 'role_num' => $roleNumList[$day], 'user_num' => $userNumList[$day], @@ -4175,32 +4147,29 @@ public function iosDetailExcelInfo($id,$map) { $allData['spend_voucher'] = bcadd($allData['spend_voucher'], 0, 2); } $records[] = $record; - } $allData['day'] = '合计'; - $records[] = $allData; + $records[] = $allData; $xlsData = []; - foreach ($records as $key1 => $value1) { - $xlsData[] = $value1; + foreach ($records as $value1) { + $xlsData[] = $value1; + } + + $this->exportExcel($xlsName, $xlsCell, $xlsData, $id); } - - $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); - - } - - } - - public function promoteGradeExcelInfo($tid, $map) - { + } + + public function promoteGradeExcelInfo($tid, $map) + { $xlsName = "团队评级"; $xlsCell = array( - array('account','账号'), - array('real_name','姓名'), + array('account', '账号'), + array('real_name', '姓名'), array('promote_group', '部门/小组'), - array('grade_name','等级'), - array('value','系数值'), - array('num','当月玩家达标个数'), - array('amount','当月注册充值总额'), + array('grade_name', '等级'), + array('value', '系数值'), + array('num', '当月玩家达标个数'), + array('amount', '当月注册充值总额'), ); recordPromoteLogs('评级管理', '团队评级导出'); @@ -4218,51 +4187,52 @@ public function iosDetailExcelInfo($id,$map) { $xlsData[] = $value; } $this->exportExcel($xlsName, $xlsCell, $xlsData, $tid); - } + } - public function achievementExcelInfo($tid, $map) { + public function achievementExcelInfo($tid, $map) + { $xlsName = "推广员业绩"; $xlsCell = array( - array('account','账号'), - array('real_name','姓名'), + array('account', '账号'), + array('real_name', '姓名'), array('promote_group', '部门/小组'), - array('create_role_count','创角数'), - array('create_role_user_count','创角用户'), - array('new_create_role_user_count','新创角用户'), - array('new_create_role_ip_count','新创角ip'), - array('login_user_count','登陆用户数'), + array('create_role_count', '创角数'), + array('create_role_user_count', '创角用户'), + array('new_create_role_user_count', '新创角用户'), + array('new_create_role_ip_count', '新创角ip'), + array('login_user_count', '登陆用户数'), ); - $records = recordPromoteLogs('数据管理','推广员业绩导出'); + recordPromoteLogs('数据管理', '推广员业绩导出'); if ($this->canViewUserRecharge) { - $xlsCell[] = array('recharge_user_count','充值人数'); - $xlsCell[] = array('recharge_count','充值次数'); - $xlsCell[] = array('recharge_amount','充值总额'); - $xlsCell[] = array('recharge_by_ban_coin','绑定币充值'); - $xlsCell[] = array('recharge_by_coin','通用币充值'); - $xlsCell[] = array('recharge_by_cash','现金充值'); + $xlsCell[] = array('recharge_user_count', '充值人数'); + $xlsCell[] = array('recharge_count', '充值次数'); + $xlsCell[] = array('recharge_amount', '充值总额'); + $xlsCell[] = array('recharge_by_ban_coin', '绑定币充值'); + $xlsCell[] = array('recharge_by_coin', '通用币充值'); + $xlsCell[] = array('recharge_by_cash', '现金充值'); } $params['isContainSubs'] = $map['isContainSubs']; - $params['basicPromotes'] = json_decode($map['basicPromotes'],TRUE); + $params['basicPromotes'] = json_decode($map['basicPromotes'], TRUE); $ids = $map['ids']; - $promotes = json_decode($map["promotes"],TRUE); - if(!empty($map['game_id'])) { + $promotes = json_decode($map["promotes"], TRUE); + if (!empty($map['game_id'])) { $params['game_id'] = $map["game_id"]; } - if(!empty($map['server_id'])) { + if (!empty($map['server_id'])) { $params['server_id'] = $map["server_id"]; } - if(!empty($map['sdk_version'])) { + if (!empty($map['sdk_version'])) { $params['sdk_version'] = $map["sdk_version"]; } - if(!empty($map['lock_status'])) { + if (!empty($map['lock_status'])) { $params['lock_status'] = $map["lock_status"]; } - if(!empty($map['parentsinfo'])) { - $parent = json_decode($map['parentsinfo'],TRUE); + if (!empty($map['parentsinfo'])) { + $parent = json_decode($map['parentsinfo'], TRUE); unset($map['parentsinfo']); } - if(!empty($map['currentDisplay'])) { + if (!empty($map['currentDisplay'])) { $currentDisplay = $map['currentDisplay']; unset($map['currentDisplay']); } @@ -4351,63 +4321,64 @@ public function iosDetailExcelInfo($id,$map) { } $xlsData = []; foreach ($records as $key1 => $value1) { - $value1['account'] = $this->encryption($value1['account']); + $value1['account'] = encryption($value1['account']); $xlsData[] = $value1; } - $this->exportExcel($xlsName, $xlsCell, $xlsData,$tid); - } + $this->exportExcel($xlsName, $xlsCell, $xlsData, $tid); + } - public function userRechargeExcelInfo($id,$map) { + public function userRechargeExcelInfo($id, $map) + { $xlsName = "充值玩家"; $xlsCell = array( - '玩家账号', - '游戏名称', - '游戏区服', - '平台', - '角色名', - '充值总额', - '充值次数', - '今日充值', - '未登录天数', - '游戏累计登陆天数', - '注册时间', - '最后登录时间', - '推广员账号', - - ); - $records = recordPromoteLogs('数据管理','充值玩家导出'); - $subMap = []; - if(!empty($map['game_id'])) { - $subMap['game_id'] = $map['game_id']; - $map['uc.game_id'] = $map['game_id']; - unset($map['game_id']); - } - if(!empty($map['server_id'])) { - $subMap['server_id'] = $map['server_id']; - $map['ui.server_id'] = $map['server_id']; - unset($map['server_id']); - } - if(!empty($map['role_name'])) { - $map['ui.role_name'] = $map['role_name']; - unset($map['role_name']); - } - - if(!empty($map['user_account'])) { - $userId = M('user', 'tab_')->where(array('account' => $map['user_account']))->getField('id'); - $userId = $userId ?? 0; - $map['uc.user_id'] = $userId; - unset($map['user_account']); - } - if(!empty($map['promote_id'])) { - $map['uc.promote_id'] = $map['promote_id']; - unset($map['promote_id']); - } - $costBegin = $map['costbegin']; - $costEnd = $map['costend']; - unset($map['costbegin']); - unset($map['costend']); - $nowTime = strtotime(date('Y-m-d 00:00:00', time())); - $subMap['create_time'] = ['between', [$map['begintime'], $map['endtime']-1]]; + '玩家账号', + '游戏名称', + '游戏区服', + '平台', + '角色名', + '充值总额', + '充值次数', + '今日充值', + '未登录天数', + '游戏累计登陆天数', + '注册时间', + '最后登录时间', + '推广员账号', + + ); + recordPromoteLogs('数据管理', '充值玩家导出'); + $subMap = []; + if (!empty($map['game_id'])) { + $subMap['game_id'] = $map['game_id']; + $map['uc.game_id'] = $map['game_id']; + unset($map['game_id']); + } + if (!empty($map['server_id'])) { + $subMap['server_id'] = $map['server_id']; + $map['ui.server_id'] = $map['server_id']; + unset($map['server_id']); + } + if (!empty($map['role_name'])) { + $map['ui.role_name'] = $map['role_name']; + unset($map['role_name']); + } + + if (!empty($map['user_account'])) { + $userId = M('user', 'tab_')->where(array('account' => $map['user_account']))->getField('id'); + $userId = $userId ?? 0; + $map['uc.user_id'] = $userId; + unset($map['user_account']); + } + if (!empty($map['promote_id'])) { + $map['uc.promote_id'] = $map['promote_id']; + unset($map['promote_id']); + } + $costBegin = $map['costbegin']; + $costEnd = $map['costend']; + unset($map['costbegin']); + unset($map['costend']); + $nowTime = strtotime(date('Y-m-d 00:00:00', time())); + $subMap['create_time'] = ['between', [$map['begintime'], $map['endtime'] - 1]]; if ($costBegin != '' || $costEnd != '') { $having = ''; if ($costBegin != '' && $costEnd != '') { @@ -4424,78 +4395,79 @@ public function iosDetailExcelInfo($id,$map) { ->buildSql(); $map['_string'] = 'ui.role_id in (' . $subQuery . ')'; } - $secondDay = 24*3600 + 1; + $secondDay = 24 * 3600 + 1; //$map['uc.create_time'] = ['between', [$map['begintime'], $map['endtime']-1]]; - $map['uc.pay_time'] = ['between', [$map['begintime'], $map['endtime']-1]]; + $map['uc.pay_time'] = ['between', [$map['begintime'], $map['endtime'] - 1]]; unset($map['begintime']); unset($map['endtime']); $map['uc.pay_status'] = 1; - $fieldS = "sum(uc.pay_amount) recharge_cost, count(*) recharge_count, uc.user_id, uc.user_account, uc.promote_id, uc.promote_account, uc.game_name, uc.sdk_version, uc.server_name, SUBSTRING_INDEX(GROUP_CONCAT(uc.game_player_name order by uc.id desc), ',', 1) as game_player_name"; - $fieldUser = 'u.register_time, u.login_time'; - - $now = date('Y-m-d'); - $now = strtotime($now); - $nowTimeEnd = $now + 3600 * 24 - 1; - $spendMap['_string'] = 'today.user_id = uc.user_id and today.game_id = uc.game_id and today.server_id = uc.server_id and today.game_player_id = uc.game_player_id and today.promote_id = uc.promote_id'; - $spendMap['today.pay_status'] = 1; - $spendMap['today.pay_time'] = ['between', [$now, $nowTimeEnd]]; + $fieldS = "sum(uc.pay_amount) recharge_cost, count(*) recharge_count, uc.user_id, uc.user_account, uc.promote_id, uc.promote_account, uc.game_name, uc.sdk_version, uc.server_name, SUBSTRING_INDEX(GROUP_CONCAT(uc.game_player_name order by uc.id desc), ',', 1) as game_player_name"; + $fieldUser = 'u.register_time, u.login_time'; + + $now = date('Y-m-d'); + $now = strtotime($now); + $nowTimeEnd = $now + 3600 * 24 - 1; + $spendMap['_string'] = 'today.user_id = uc.user_id and today.game_id = uc.game_id and today.server_id = uc.server_id and today.game_player_id = uc.game_player_id and today.promote_id = uc.promote_id'; + $spendMap['today.pay_status'] = 1; + $spendMap['today.pay_time'] = ['between', [$now, $nowTimeEnd]]; $map = $this->spendRepository->withIsCheck($map, 'uc.is_check'); $spendMap = $this->spendRepository->withIsCheck($spendMap, 'today.is_check'); - $fieldToday = M('spend', 'tab_')->alias('today') - ->field('sum(pay_amount) as recharge_cost_today') - ->where($spendMap) - ->buildSql(); - - $loginRecordMap['lr.create_time'] = $map['uc.pay_time']; - $loginRecordMap['_string'] = 'lr.user_id = uc.user_id and lr.game_id = uc.game_id'; - $fieldLR = M('login_daily_record', 'tab_')->alias('lr') - ->field("count(*) as count") - ->where($loginRecordMap) - ->buildSql(); - //$field = $fieldUC . ',' . $fieldUI . ',' . $fieldLR . ' as user_game_login_count'; - $field = "$fieldS, $fieldUser, $fieldToday as recharge_cost_today, $fieldLR as user_game_login_count"; - $subQuery = M('spend', 'tab_')->alias('uc') - ->field($field) + $fieldToday = M('spend', 'tab_')->alias('today') + ->field('sum(pay_amount) as recharge_cost_today') + ->where($spendMap) + ->buildSql(); + + $loginRecordMap['lr.create_time'] = $map['uc.pay_time']; + $loginRecordMap['_string'] = 'lr.user_id = uc.user_id and lr.game_id = uc.game_id'; + $fieldLR = M('login_daily_record', 'tab_')->alias('lr') + ->field("count(*) as count") + ->where($loginRecordMap) + ->buildSql(); + //$field = $fieldUC . ',' . $fieldUI . ',' . $fieldLR . ' as user_game_login_count'; + $field = "$fieldS, $fieldUser, $fieldToday as recharge_cost_today, $fieldLR as user_game_login_count"; + $subQuery = M('spend', 'tab_')->alias('uc') + ->field($field) // ->join('left join tab_user_play_info as ui on ui.user_id = uc.user_id and ui.game_id = uc.game_id and ui.server_id = uc.server_id and ui.role_id = uc.role_id') - ->join('join tab_user as u on u.id = uc.user_id') + ->join('join tab_user as u on u.id = uc.user_id') ->where($map) - ->group('uc.game_player_id,uc.server_id,uc.game_id,uc.user_id,uc.promote_id') - ->buildSql(); + ->group('uc.game_player_id,uc.server_id,uc.game_id,uc.user_id,uc.promote_id') + ->buildSql(); $roles = M()->alias('record') ->table($subQuery) ->select(); - $total = M('spend', 'tab_')->alias('uc') - ->field($fieldS) - ->where($map) - ->find(); - $map['uc.pay_time'] = $spendMap['today.pay_time']; - $total['recharge_cost_today'] = M('spend', 'tab_')->alias('uc') - ->field('sum(uc.pay_amount) as recharge_cost_today') - ->where($map) - ->find()['recharge_cost_today']; - $total['recharge_cost_today'] = empty($total['recharge_cost_today']) ? '0.00' :$total['recharge_cost_today']; - $csvFileName = $xlsName.'.csv'; + $total = M('spend', 'tab_')->alias('uc') + ->field($fieldS) + ->where($map) + ->find(); + $map['uc.pay_time'] = $spendMap['today.pay_time']; + $total['recharge_cost_today'] = M('spend', 'tab_')->alias('uc') + ->field('sum(uc.pay_amount) as recharge_cost_today') + ->where($map) + ->find()['recharge_cost_today']; + $total['recharge_cost_today'] = empty($total['recharge_cost_today']) ? '0.00' : $total['recharge_cost_today']; + $csvFileName = $xlsName . '.csv'; //设置好告诉浏览器要下载excel文件的headers header('Content-Description: File Transfer'); header('Content-Type: application/vnd.ms-excel'); - header('Content-Disposition: attachment; filename="'. $csvFileName .'"'); + header('Content-Disposition: attachment; filename="' . $csvFileName . '"'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); - $fp = fopen('php://output', 'a');//打开output流 + $fp = fopen('php://output', 'a'); //打开output流 mb_convert_variables('gb2312', 'UTF-8', $xlsCell); - fputcsv($fp, $xlsCell);//将数据格式化为CSV格式并写入到output流中 - $accessNum = '100000';//从数据库获取总量,假设是十万 - $accessNum = count($roles)?:0 ; + fputcsv($fp, $xlsCell); //将数据格式化为CSV格式并写入到output流中 + $accessNum = '100000'; //从数据库获取总量,假设是十万 + $accessNum = count($roles) ?: 0; - $perSize = 5000;//每次查询的条数 + $perSize = 5000; //每次查询的条数 $pages = ceil($accessNum / $perSize); - for($i = 1; $i <= $pages; $i++) { + $loginPromote = $this->getLoginPromote(); + for ($i = 1; $i <= $pages; $i++) { $data = M()->alias('record') ->table($subQuery) - ->limit(($i-1)*$perSize ,$perSize) + ->limit(($i - 1) * $perSize, $perSize) ->select(); if (count($data) > 0) { @@ -4505,29 +4477,29 @@ public function iosDetailExcelInfo($id,$map) { $promotes = index_by_column('id', $promotes); } - foreach($data as $key => $value) { + foreach ($data as $key => $value) { // if (empty($value['user_account']) ) { // $value['user_account'] = $users[$value['user_id']] ?? ''; // } - $csvData['user_account'] = empty($value['user_account']) ? '--' : encryption($value['user_account']); - $csvData['game_name'] = empty($value['game_name']) ? '--' :$value['game_name']; - $csvData['server_name'] = empty($value['server_name']) ? '--' :$value['server_name']; - if($value['sdk_version'] == 1) { + $csvData['user_account'] = empty($value['user_account']) ? '--' : getUserAccountOfPromote($value['user_account'], $loginPromote); + $csvData['game_name'] = empty($value['game_name']) ? '--' : $value['game_name']; + $csvData['server_name'] = empty($value['server_name']) ? '--' : $value['server_name']; + if ($value['sdk_version'] == 1) { $csvData['sdk_version'] = "Android"; - }else if($value['sdk_version'] == 2) { + } else if ($value['sdk_version'] == 2) { $csvData['sdk_version'] = "ios"; } else { $csvData['sdk_version'] = "--"; } - $csvData['game_player_name'] = empty($value['game_player_name']) ? '--' :$value['game_player_name']; + $csvData['game_player_name'] = empty($value['game_player_name']) ? '--' : $value['game_player_name']; $csvData['recharge_cost'] = empty($value['recharge_cost']) ? 0 : $value['recharge_cost']; $csvData['recharge_count'] = empty($value['recharge_count']) ? 0 : $value['recharge_count']; $csvData['recharge_cost_today'] = empty($value['recharge_cost_today']) ? 0 : $value['recharge_cost_today']; $csvData['unlogin_day'] = empty($value['login_time']) ? '--' : intval((strtotime(date('Y-m-d 00:00:00')) - strtotime(date('Y-m-d 00:00:00', $value['login_time']))) / (24 * 3600)); $csvData['user_game_login_count'] = empty($value['user_game_login_count']) ? 0 : $value['user_game_login_count']; $csvData['create_time'] = empty($value['register_time']) ? '--' : date('Y-m-d H:i:s', $value['register_time']); - $csvData['login_time'] = empty($value['login_time']) ? '--' :date('Y-m-d H:i:s',$value['login_time']); - $csvData['promote_account'] = empty($value['promote_account']) ? '--' :$value['promote_account']; + $csvData['login_time'] = empty($value['login_time']) ? '--' : date('Y-m-d H:i:s', $value['login_time']); + $csvData['promote_account'] = empty($value['promote_account']) ? '--' : $value['promote_account']; if (isset($promotes[$value['promote_id']])) { $groupName = $promoteService->getGroupNameByChain($promotes[$value['promote_id']]['chain'], $value['promote_id']); if ($groupName) { @@ -4537,10 +4509,10 @@ public function iosDetailExcelInfo($id,$map) { mb_convert_variables('GBK', 'UTF-8', $csvData); fputcsv($fp, $csvData); $xlsData[] = $csvData; - } + } unset($xlsData); ob_flush(); - flush(); + flush(); } $allData['user_account'] = '合计'; $allData['game_name'] = '--'; @@ -4560,11 +4532,12 @@ public function iosDetailExcelInfo($id,$map) { $xlsData[] = $allData; fclose($fp); $this->backSuccessExport($id); - } - - public function rechargeExcelInfo($id,$map) { - $xlsName = "订单查询"; - $xlsCell = array( + } + + public function rechargeExcelInfo($id, $map) + { + $xlsName = "订单查询"; + $xlsCell = array( '玩家账号', '游戏订单', '订单金额', @@ -4582,10 +4555,12 @@ public function iosDetailExcelInfo($id,$map) { '下单时间', '到账时间', ); - $records = recordPromoteLogs('数据管理','充值明细导出'); - $model = M('spend','tab_'); - if(!empty($map['tab_spend.pay_status'])) { - $map['tab_spend.pay_status'] = $map['tab_spend.pay_status'] -2 ; + + recordPromoteLogs('数据管理', '充值明细导出'); + + $model = M('spend', 'tab_'); + if (!empty($map['tab_spend.pay_status'])) { + $map['tab_spend.pay_status'] = $map['tab_spend.pay_status'] - 2; } $data1 = $model ->field('tab_spend.id') @@ -4594,234 +4569,199 @@ public function iosDetailExcelInfo($id,$map) { ->where($map) ->order('tab_spend.id desc') ->select(); - $csvFileName = $xlsName.'.csv'; + $csvFileName = $xlsName . '.csv'; //设置好告诉浏览器要下载excel文件的headers header('Content-Description: File Transfer'); header('Content-Type: application/vnd.ms-excel'); - header('Content-Disposition: attachment; filename="'. $csvFileName .'"'); + header('Content-Disposition: attachment; filename="' . $csvFileName . '"'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); - $fp = fopen('php://output', 'a');//打开output流 + $fp = fopen('php://output', 'a'); //打开output流 mb_convert_variables('gb2312', 'UTF-8', $xlsCell); - fputcsv($fp, $xlsCell);//将数据格式化为CSV格式并写入到output流中 - $accessNum = count($data1)?:0 ; - $perSize = 5000;//每次查询的条数 + fputcsv($fp, $xlsCell); //将数据格式化为CSV格式并写入到output流中 + $accessNum = count($data1) ?: 0; + $perSize = 5000; //每次查询的条数 $pages = ceil($accessNum / $perSize); - $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['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']); - $value1['payed_time'] = ($value1['pay_status'] == 1) ? date('Y-m-d H:i:s', $value1['payed_time']) : '--'; - $value1['pay_status'] = isset(self::$payStatus[$value1['pay_status']]) ? self::$payStatus[$value1['pay_status']] : "未知状态"; - $value1['sdk_version'] = getSDKTypeName($value1['sdk_version']); - 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["cost"] = $value1["cost"]; + $promoteIdData = []; + $promoteData = []; + $loginPromote = $this->getLoginPromote(); + 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['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'] = getUserAccountOfPromote($value1['user_account'], $loginPromote); + $value1['pay_order_number'] = hideOrderNumber($value1['pay_order_number']); + $value1['payed_time'] = ($value1['pay_status'] == 1) ? date('Y-m-d H:i:s', $value1['payed_time']) : '--'; + $value1['pay_status'] = isset(self::$payStatus[$value1['pay_status']]) ? self::$payStatus[$value1['pay_status']] : "未知状态"; + $value1['sdk_version'] = getSDKTypeName($value1['sdk_version']); + 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["cost"] = $value1["cost"]; // $csvData["discount_amount"] = $value1["discount_amount"]; - $csvData["pay_amount"] = $value1["pay_amount"]; - $csvData["pay_way"] = $value1["pay_way"]; - $csvData['pay_status'] = $value1['pay_status']; - $csvData["game_name"] = $value1["game_name"]; - $csvData["sdk_version"] = $value1['sdk_version']; - $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["spend_time"] = date('Y-m-d H:i:s', $value1["spend_time"]); - $csvData["payed_time"] = $value1["payed_time"]; - mb_convert_variables('GBK', 'UTF-8', $csvData); - fputcsv($fp, $csvData); - $xlsData[] = $csvData; - } - unset($xlsData); - ob_flush(); - flush(); - } - $aggregation = M('Spend', 'tab_') - ->field('sum(tab_spend.cost) as cost, sum(tab_spend.pay_amount) as pay_amount, sum(tab_spend.discount_amount) as discount_amount') - ->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(); - $csvData1["user_account"] = "合计"; - $csvData1["pay_order_number"] = "--"; - $csvData1["cost"] = $aggregation['cost']; + $csvData["pay_amount"] = $value1["pay_amount"]; + $csvData["pay_way"] = $value1["pay_way"]; + $csvData['pay_status'] = $value1['pay_status']; + $csvData["game_name"] = $value1["game_name"]; + $csvData["sdk_version"] = $value1['sdk_version']; + $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["spend_time"] = date('Y-m-d H:i:s', $value1["spend_time"]); + $csvData["payed_time"] = $value1["payed_time"]; + mb_convert_variables('GBK', 'UTF-8', $csvData); + fputcsv($fp, $csvData); + $xlsData[] = $csvData; + } + unset($xlsData); + ob_flush(); + flush(); + } + $aggregation = M('Spend', 'tab_') + ->field('sum(tab_spend.cost) as cost, sum(tab_spend.pay_amount) as pay_amount, sum(tab_spend.discount_amount) as discount_amount') + ->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(); + $csvData1["user_account"] = "合计"; + $csvData1["pay_order_number"] = "--"; + $csvData1["cost"] = $aggregation['cost']; // $csvData1["discount_amount"] = $aggregation['discount_amount']; - $csvData1["pay_amount"] = $aggregation['pay_amount']; - $csvData1["pay_way"] = "--"; - $csvData1['pay_status'] = "--"; - $csvData1["game_name"] = "--"; - $csvData1["sdk_version"] = "--"; - $csvData1["server_name"] = "--"; - $csvData1["game_player_name"] = "--"; - $csvData1["p_p_proinfo"] = "--"; - $csvData1["p_proinfo"] = "--"; - $csvData1["proinfo"] = "--"; - $csvData1["spend_time"] = "--"; - $csvData1["payed_time"] = "--"; - mb_convert_variables('GBK', 'UTF-8', $csvData1); - fputcsv($fp, $csvData1); - $xlsData[] = $csvData1; - fclose($fp); - $this->backSuccessExport($id); - } - - public function backSuccessExport($id) { //导出成功后 - if(!$id) { - - }else { - $res = M('downloadlog','tab_')->where(['id'=>$id])->select(); - $data = $res[0]; - $data['status'] = 1; - $data['begintime'] = time(); - $updateRs = M('downloadlog','tab_')->where(['id'=>$id])->save($data); - } - - } - /* + $csvData1["pay_amount"] = $aggregation['pay_amount']; + $csvData1["pay_way"] = "--"; + $csvData1['pay_status'] = "--"; + $csvData1["game_name"] = "--"; + $csvData1["sdk_version"] = "--"; + $csvData1["server_name"] = "--"; + $csvData1["game_player_name"] = "--"; + $csvData1["p_p_proinfo"] = "--"; + $csvData1["p_proinfo"] = "--"; + $csvData1["proinfo"] = "--"; + $csvData1["spend_time"] = "--"; + $csvData1["payed_time"] = "--"; + mb_convert_variables('GBK', 'UTF-8', $csvData1); + fputcsv($fp, $csvData1); + $xlsData[] = $csvData1; + fclose($fp); + $this->backSuccessExport($id); + } + + public function backSuccessExport($id) + { //导出成功后 + if (!$id) { + } else { + $res = M('downloadlog', 'tab_')->where(['id' => $id])->select(); + $data = $res[0]; + $data['status'] = 1; + $data['begintime'] = time(); + $updateRs = M('downloadlog', 'tab_')->where(['id' => $id])->save($data); + } + } + /* * 汇款证明 * */ - public function Remittancecer() { - $id = $_REQUEST["id"]; - $model = M("withdraw","tab_"); - $res = $model->where(['id'=>$id])->field('transfer_proof,status')->find(); - $transfer_proof = intval($res["transfer_proof"]); - $map = ['id'=>$transfer_proof]; - $addtime = time(); - $conditions = json_encode($map,TRUE); - $data = [ - 'logid' => 'remitrecord_'.time(), - 'promote_id' => PID, - 'type' => '/Home/Finance/withdrawRecord', - 'dataname' => '汇款证明', - 'status' => 0, - 'addtime' => $addtime, - 'begintime' => 0, - 'content' => '', - 'conditions' =>$conditions, - ]; - $log = M('downloadlog','tab_')->add($data); - if (!$log) { - $this->error('添加下载失败'); - } - $this->success('添加下载成功',U('listsIndex')); - - - } - - - - - - public function encryptDecrypt($key, $string, $decrypt){ - if($decrypt){ - $decrypted = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($string), MCRYPT_MODE_CBC, md5(md5($key))), "12"); - return $decrypted; - }else{ - $encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $string, MCRYPT_MODE_CBC, md5(md5($key)))); - return $encrypted; - } - } - -// public function getLoginPromote() -// { -// $promoteId = session('promote_auth.pid'); -// return M('promote', 'tab_')->where(['id' => $promoteId])->find(); -// } - - private function getGroupPromotes($promote) + public function Remittancecer() { - $promotes = []; - if ($promote['parent_id'] == 0) { - $promotes = M('promote', 'tab_')->field(['id', 'account', 'real_name'])->where(['parent_id' => $promote['id']])->select(); + $id = $_REQUEST["id"]; + $model = M("withdraw", "tab_"); + $res = $model->where(['id' => $id])->field('transfer_proof,status')->find(); + $transfer_proof = intval($res["transfer_proof"]); + $map = ['id' => $transfer_proof]; + $addtime = time(); + $conditions = json_encode($map, TRUE); + $data = [ + 'logid' => 'remitrecord_' . time(), + 'promote_id' => PID, + 'type' => '/Home/Finance/withdrawRecord', + 'dataname' => '汇款证明', + 'status' => 0, + 'addtime' => $addtime, + 'begintime' => 0, + 'content' => '', + 'conditions' => $conditions, + ]; + $log = M('downloadlog', 'tab_')->add($data); + if (!$log) { + $this->error('添加下载失败'); } - return $promotes; + $this->success('添加下载成功', U('listsIndex')); } - + public function paginate($query, $defaultPageSize = 10, $defaultPage = 1) { - $page = I('get.p', $defaultPage); - $pageSize = I('get.row', $defaultPageSize); - - $countQuery = clone $query; - $count = $countQuery->count(); - $records = $query->page($page, $pageSize)->select(); - - $params = [ - 'p' => $page, - 'row' => $pageSize - ]; - $pagination = set_pagination($count, $pageSize); - - return [$records, $pagination, $count]; - } - - private function getGamesByPromote($promote) - { - return M('apply', 'tab_')->field(['game_id', 'game_name'])->where(['promote_id' => $promote['id']])->select(); + $page = I('get.p', $defaultPage); + $pageSize = I('get.row', $defaultPageSize); + + $countQuery = clone $query; + $count = $countQuery->count(); + $records = $query->page($page, $pageSize)->select(); + + $params = [ + 'p' => $page, + 'row' => $pageSize + ]; + $pagination = set_pagination($count, $pageSize); + + return [$records, $pagination, $count]; } - + private function getBetweenTime($time, $defaultBegin = 0, $defaultEnd = 0) { $delimiter = ' 至 '; @@ -4839,13 +4779,13 @@ public function iosDetailExcelInfo($id,$map) { } return [$begin, $end]; } - - private function getQueryPromote($levelPromote) + + private function getQueryPromote($levelPromote) { $queryPromote = null; $promote = $this->getLoginPromote(); $queryPromoteId = 0; - foreach($levelPromote as $item) { + foreach ($levelPromote as $item) { if ($item != 0) { $queryPromoteId = $item; } @@ -4872,8 +4812,8 @@ public function iosDetailExcelInfo($id,$map) { } } } - - private function getLevelPromote() + + private function getLevelPromote() { $levelPromote = []; $levelPromote[] = I('level_promote_2', 0); @@ -4881,7 +4821,7 @@ public function iosDetailExcelInfo($id,$map) { $levelPromote[] = I('level_promote_4', 0); return $levelPromote; } - + private function getDayList($beginTime, $endTime) { $dayList = []; @@ -4892,7 +4832,7 @@ public function iosDetailExcelInfo($id,$map) { return $dayList; } - + private function assembleRecords($items, $keys, $valueColumn, $keyColumn = 'day') { $records = []; @@ -4908,22 +4848,6 @@ public function iosDetailExcelInfo($id,$map) { return $records; } - public function encryption($string) { - $orderLen = strlen($string); - $strLen = 3; - $hideChar = ''; - - if($orderLen <=8) { - $strLen = 2; - } - - for($i = 0;$i<$orderLen-$strLen*2;$i++) { - $hideChar .='*'; - } - - return substr($string, 0, $strLen) . $hideChar . substr($string, $orderLen-$strLen); - } - private function getGame($map = []) { $gameName = '全部游戏'; @@ -4973,43 +4897,41 @@ public function iosDetailExcelInfo($id,$map) { return M('server', 'tab_')->where($map)->getField('server_name'); } - /** * 汇总单信息 * @author sunke */ - public function Withdraw_index_export() { + public function Withdraw_index_export() + { $map = []; -// $map['pay_time'] = strtotime($_REQUEST['start_time']); - $map["promote.id"] = get_pid(); - $map['tab_company_statement_info.company_type'] = ['in',"1,2"]; -// $map['pay_type'] = 1; + $map['tab_company_statement_info.company_type'] = ['in', "1,2"]; if ($_REQUEST['pay_status'] || $_REQUEST['pay_status'] == '0') { $map['pay_status'] = $_REQUEST['pay_status']; } - if(!empty($_REQUEST['start'])&&empty($_REQUEST['end'])){ - $map['statement_begin_time'] = array('GT',strtotime($_REQUEST['start'])); + if (!empty($_REQUEST['start']) && empty($_REQUEST['end'])) { + $map['statement_begin_time'] = array('GT', strtotime($_REQUEST['start'])); unset($_REQUEST['start']); } - if(empty($_REQUEST['start'])&&!empty($_REQUEST['end'])){ - $map['statement_end_time'] = array('LT',strtotime($_REQUEST['end'])+24*60*60-1); + if (empty($_REQUEST['start']) && !empty($_REQUEST['end'])) { + $map['statement_end_time'] = array('LT', strtotime($_REQUEST['end']) + 24 * 60 * 60 - 1); unset($_REQUEST['end']); } - if(!empty($_REQUEST['start'])&&!empty($_REQUEST['end'])){ - $map['statement_begin_time'] = array('GT',strtotime($_REQUEST['start'])); - $map['statement_end_time'] = array('LT',strtotime($_REQUEST['end'])+24*60*60-1); - unset($_REQUEST['start']);unset($_REQUEST['end']); + if (!empty($_REQUEST['start']) && !empty($_REQUEST['end'])) { + $map['statement_begin_time'] = array('GT', strtotime($_REQUEST['start'])); + $map['statement_end_time'] = array('LT', strtotime($_REQUEST['end']) + 24 * 60 * 60 - 1); + unset($_REQUEST['start']); + unset($_REQUEST['end']); } - $conditions = json_encode($map,TRUE); + $conditions = json_encode($map, TRUE); $addtime = time(); $data = [ - 'logid' => 'withdraw_'.time(), + 'logid' => 'withdraw_' . time(), 'promote_id' => PID, 'type' => '/Home/Withdraw/index', 'dataname' => '汇总单信息', @@ -5017,18 +4939,18 @@ public function iosDetailExcelInfo($id,$map) { 'addtime' => $addtime, 'begintime' => 0, 'content' => '', - 'conditions' =>$conditions + 'conditions' => $conditions ]; - $res = M('downloadlog','tab_')->add($data); + $res = M('downloadlog', 'tab_')->add($data); if (!$res) { - // $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res)); $this->error('添加下载失败'); } - $this->success('添加下载成功',U('listsIndex')); + $this->success('添加下载成功', U('listsIndex')); } - public function WithdrawIndexExcelInfo($id,$map) { - $xlsName ="汇总单信息"; + public function WithdrawIndexExcelInfo($id, $map) + { + $xlsName = "汇总单信息"; $xlsCell = array( '结算时间', '结算金额', @@ -5037,28 +4959,28 @@ public function iosDetailExcelInfo($id,$map) { '提现状态', ); - $count = M("company_statement_info","tab_") + $count = M("company_statement_info", "tab_") ->field("tab_company_statement_info.*") ->join("left join tab_promote_company company on tab_company_statement_info.company_id=company.id") ->join("left join tab_promote promote on company.id=promote.company_id") ->where($map) ->count(); - $csvFileName = $xlsName.'.csv'; + $csvFileName = $xlsName . '.csv'; header('Content-Description: File Transfer'); header('Content-Type: application/vnd.ms-excel'); - header('Content-Disposition: attachment; filename="'. $csvFileName .'"'); + header('Content-Disposition: attachment; filename="' . $csvFileName . '"'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); - $fp = fopen('php://output', 'a');//打开output流 + $fp = fopen('php://output', 'a'); //打开output流 mb_convert_variables('gb2312', 'UTF-8', $xlsCell); - fputcsv($fp, $xlsCell);//将数据格式化为CSV格式并写入到output流中 - $accessNum = $count ; - $perSize = 5000;//每次查询的条数 + fputcsv($fp, $xlsCell); //将数据格式化为CSV格式并写入到output流中 + $accessNum = $count; + $perSize = 5000; //每次查询的条数 $pages = ceil($accessNum / $perSize); - for($i = 1; $i <= $pages; $i++) { - $data = M("company_statement_info","tab_") + for ($i = 1; $i <= $pages; $i++) { + $data = M("company_statement_info", "tab_") ->field("tab_company_statement_info.statement_begin_time time, tab_company_statement_info.statement_money, tab_company_statement_info.pool_id, @@ -5066,19 +4988,19 @@ public function iosDetailExcelInfo($id,$map) { tab_company_statement_info.pay_status") ->join("left join tab_promote_company company on tab_company_statement_info.company_id=company.id") ->join("left join tab_promote promote on company.id=promote.company_id") - ->limit(($i-1)*$perSize ,$perSize) + ->limit(($i - 1) * $perSize, $perSize) ->where($map) ->select(); foreach ($data as $key => $value) { - $value['time'] = date("Y-m-d H:i:s",$value["statement_begin_time"])."-".date("Y-m-d H:i:s",$value["statement_end_time"]); + $value['time'] = date("Y-m-d H:i:s", $value["statement_begin_time"]) . "-" . date("Y-m-d H:i:s", $value["statement_end_time"]); if ($value['pay_status'] == '-1') { $value['pay_status'] = '打款失败'; - } elseif($value['pay_status'] == '0') { + } elseif ($value['pay_status'] == '0') { $value['pay_status'] = '未打款'; - } elseif($value['pay_status'] == '1') { + } elseif ($value['pay_status'] == '1') { $value['pay_status'] = '打款成功'; } @@ -5098,62 +5020,63 @@ public function iosDetailExcelInfo($id,$map) { * 结算单详情 * @author sunke */ - public function Withdraw_order_export() { + public function Withdraw_order_export() + { $start = $_REQUEST['start']; $end = $_REQUEST['end']; $game_map['relation_game_id'] = $_REQUEST['relation_game_id']; - $game_id = M("game","tab_")->field("id")->where($game_map)->select(); + $game_id = M("game", "tab_")->field("id")->where($game_map)->select(); $promote_data = []; - $promote_id = M("promote","tab_")->field("id")->where(['company_id'=>$_REQUEST['company_id']])->select(); + $promote_id = M("promote", "tab_")->field("id")->where(['company_id' => $_REQUEST['company_id']])->select(); foreach ($promote_id as $key => $value) { $promote_data[] = $value['id']; - $data = M("promote","tab_")->field("id")->where(['chain'=>['like',"/{$value['id']}/"]])->select(); + $data = M("promote", "tab_")->field("id")->where(['chain' => ['like', "/{$value['id']}/"]])->select(); foreach ($data as $k => $v) { $promote_data[] = $v['id']; } - } if ($promote_data) { - $map['promote_id'] = ['in',$promote_data]; + $map['promote_id'] = ['in', $promote_data]; } - $game_id = array_column($game_id,'id'); + $game_id = array_column($game_id, 'id'); $map['pay_status'] = 1; - $map['pay_time'] = ['between',[strtotime($start),strtotime($end)+86399]]; - $map['game_id'] = ['in',$game_id]; + $map['pay_time'] = ['between', [strtotime($start), strtotime($end) + 86399]]; + $map['game_id'] = ['in', $game_id]; if ($_REQUEST['team_leader_id']) { - $promote_id = M("promote","tab_")->field("id")->where("id = {$_REQUEST['team_leader_id']} or chain like '%/{$_REQUEST['team_leader_id']}/%'")->select(); - $map['promote_id'] = ['in',array_column($promote_id,'id')]; + $promote_id = M("promote", "tab_")->field("id")->where("id = {$_REQUEST['team_leader_id']} or chain like '%/{$_REQUEST['team_leader_id']}/%'")->select(); + $map['promote_id'] = ['in', array_column($promote_id, 'id')]; } - if(!empty($_REQUEST['start'])&&empty($_REQUEST['end'])){ - $map['pay_time'] = array('GT',strtotime($_REQUEST['start'])); + if (!empty($_REQUEST['start']) && empty($_REQUEST['end'])) { + $map['pay_time'] = array('GT', strtotime($_REQUEST['start'])); unset($_REQUEST['start']); } - if(empty($_REQUEST['start'])&&!empty($_REQUEST['end'])){ - $map['pay_time'] = array('LT',strtotime($_REQUEST['end'])+24*60*60-1); + if (empty($_REQUEST['start']) && !empty($_REQUEST['end'])) { + $map['pay_time'] = array('LT', strtotime($_REQUEST['end']) + 24 * 60 * 60 - 1); unset($_REQUEST['end']); } - if(!empty($_REQUEST['start'])&&!empty($_REQUEST['end'])){ - $map['pay_time'] = array('between',[strtotime($_REQUEST['start']),strtotime($_REQUEST['end'])+24*60*60-1]); - unset($_REQUEST['start']);unset($_REQUEST['end']); + if (!empty($_REQUEST['start']) && !empty($_REQUEST['end'])) { + $map['pay_time'] = array('between', [strtotime($_REQUEST['start']), strtotime($_REQUEST['end']) + 24 * 60 * 60 - 1]); + unset($_REQUEST['start']); + unset($_REQUEST['end']); } - if($_REQUEST['pay_order_number']) { - $map['pay_order_number'] = ['like',"%{$_REQUEST['pay_order_number']}%"]; + if ($_REQUEST['pay_order_number']) { + $map['pay_order_number'] = ['like', "%{$_REQUEST['pay_order_number']}%"]; } - $conditions = json_encode($map,TRUE); + $conditions = json_encode($map, TRUE); $addtime = time(); $data = [ - 'logid' => 'withdraw_order_'.time(), + 'logid' => 'withdraw_order_' . time(), 'promote_id' => PID, 'type' => '/Home/Withdraw/withdrawOrderDetail', 'dataname' => '结算单明细', @@ -5161,18 +5084,18 @@ public function iosDetailExcelInfo($id,$map) { 'addtime' => $addtime, 'begintime' => 0, 'content' => '', - 'conditions' =>$conditions + 'conditions' => $conditions ]; - $res = M('downloadlog','tab_')->add($data); + $res = M('downloadlog', 'tab_')->add($data); if (!$res) { - // $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res)); $this->error('添加下载失败'); } - $this->success('添加下载成功',U('listsIndex')); + $this->success('添加下载成功', U('listsIndex')); } - public function WithdrawOrderExcelInfo($id,$map) { - $xlsName ="结算单明细"; + public function WithdrawOrderExcelInfo($id, $map) + { + $xlsName = "结算单明细"; $xlsCell = array( '游戏订单号', '游戏', @@ -5182,34 +5105,33 @@ public function iosDetailExcelInfo($id,$map) { '充值时间', ); - $count = M("spend","tab_") + $count = M("spend", "tab_") ->where($map) ->count(); - $csvFileName = $xlsName.'.csv'; + $csvFileName = $xlsName . '.csv'; header('Content-Description: File Transfer'); header('Content-Type: application/vnd.ms-excel'); - header('Content-Disposition: attachment; filename="'. $csvFileName .'"'); + header('Content-Disposition: attachment; filename="' . $csvFileName . '"'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); - $fp = fopen('php://output', 'a');//打开output流 + $fp = fopen('php://output', 'a'); //打开output流 mb_convert_variables('gb2312', 'UTF-8', $xlsCell); - fputcsv($fp, $xlsCell);//将数据格式化为CSV格式并写入到output流中 - $accessNum = $count ; - $perSize = 5000;//每次查询的条数 + fputcsv($fp, $xlsCell); //将数据格式化为CSV格式并写入到output流中 + $accessNum = $count; + $perSize = 5000; //每次查询的条数 $pages = ceil($accessNum / $perSize); - for($i = 1; $i <= $pages; $i++) { - - $data = M("spend","tab_") + for ($i = 1; $i <= $pages; $i++) { + $data = M("spend", "tab_") ->field("pay_order_number,game_name,user_account,promote_account,pay_amount,pay_time") ->where($map) - ->limit(($i-1)*$perSize ,$perSize) + ->limit(($i - 1) * $perSize, $perSize) ->select(); foreach ($data as $key => $value) { - $value['pay_time'] = date("Y-m-d H:i:s",$data[$key]['pay_time']); + $value['pay_time'] = date("Y-m-d H:i:s", $data[$key]['pay_time']); if ($value['promote_account'] == "官方渠道") { $value['promote_account'] = "江息网络"; } @@ -5228,8 +5150,8 @@ public function iosDetailExcelInfo($id,$map) { public function multisort($records, $column, $type = 'asc') { $length = count($records); - for ($i = 0; $i < $length; $i ++) { - for ($j = $i + 1; $j < $length; $j ++) { + for ($i = 0; $i < $length; $i++) { + for ($j = $i + 1; $j < $length; $j++) { if ($type == 'asc') { if ($records[$i][$column] > $records[$j][$column]) { $temp = $records[$i]; @@ -5248,25 +5170,26 @@ public function iosDetailExcelInfo($id,$map) { return $records; } - public function userretentionExcelInfo($id,$map) + public function userretentionExcelInfo($id, $map) { $xlsName = "用户留存率"; $xlsCell = array( - array('date','日期'), - array('game_name','游戏名称'), - array('promote_name','渠道名称'), - array('register_count','新增玩家'), - array('retention_day1', '1日留存'), - array('retention_day2', '2日留存'), - array('retention_day3', '3日留存'), - array('retention_day4', '4日留存'), - array('retention_day5', '5日留存'), - array('retention_day6', '6日留存'), - array('retention_day7', '7日留存'), - array('retention_day15', '15日留存'), - array('retention_day30', '30日留存'), - ); - $records = recordPromoteLogs('数据管理', '用户留存率导出'); + array('date', '日期'), + array('game_name', '游戏名称'), + array('promote_name', '渠道名称'), + array('register_count', '新增玩家'), + array('retention_day1', '1日留存'), + array('retention_day2', '2日留存'), + array('retention_day3', '3日留存'), + array('retention_day4', '4日留存'), + array('retention_day5', '5日留存'), + array('retention_day6', '6日留存'), + array('retention_day7', '7日留存'), + array('retention_day15', '15日留存'), + array('retention_day30', '30日留存'), + ); + + recordPromoteLogs('数据管理', '用户留存率导出'); $map = json_decode(json_encode($map), true); $baseGameId = $map['base_game_id']; @@ -5299,7 +5222,7 @@ public function iosDetailExcelInfo($id,$map) { 'game_ids' => $gameIds, ] ]); - + $result = (string)$response->getBody(); $result = json_decode($result, true); if (!$result) { @@ -5309,17 +5232,17 @@ public function iosDetailExcelInfo($id,$map) { $dayList = [1, 2, 3, 4, 5, 6, 7, 15, 30]; $gameName = $deviceType ? get_game_name($searchGameId) : $baseGame['name']; $promoteName = '全部'; - if ($promoteId) { - $promoteName = get_promote_account($promoteId); + if ($queryPromoteId) { + $promoteName = get_promote_account($queryPromoteId); } foreach ($data as $key => $item) { $item['promote_name'] = $promoteName; $item['game_name'] = $gameName; foreach ($dayList as $day) { if ($item['register_count'] > 0) { - $item['retention_day'. $day] = round($item['retention_day'. $day]/$item['register_count'], 4)*100; + $item['retention_day' . $day] = round($item['retention_day' . $day] / $item['register_count'], 4) * 100; } else { - $item['retention_day'. $day] = '--'; + $item['retention_day' . $day] = '--'; } } $data[$key] = $item; @@ -5330,7 +5253,6 @@ public function iosDetailExcelInfo($id,$map) { foreach ($data as $key => $item) { foreach ($dayList as $day) { if ($item['retention_day' . $day] === '--') { - } else { $item['retention_day' . $day] .= '%'; } @@ -5340,16 +5262,16 @@ public function iosDetailExcelInfo($id,$map) { $this->exportExcel($xlsName, $xlsCell, $data, $id); } - public function gameDataExcelInfo($id,$map) + public function gameDataExcelInfo($id, $map) { $xlsName = "游戏分区数据汇总"; $xlsCell = array( - array('game_name','游戏名称'), - array('server_name','区服名称'), - array('count','创角数'), + array('game_name', '游戏名称'), + array('server_name', '区服名称'), + array('count', '创角数'), array('amount', '消费金额'), ); - $records = recordPromoteLogs('数据管理', '游戏分区数据汇总'); + recordPromoteLogs('数据管理', '游戏分区数据汇总'); $map = json_decode(json_encode($map), true); $spendSubSql = $map['spendSubSql']; @@ -5374,5 +5296,4 @@ public function iosDetailExcelInfo($id,$map) { } $this->exportExcel($xlsName, $xlsCell, $data, $id); } -} - +} \ No newline at end of file diff --git a/Application/Home/Controller/QueryController.class.php b/Application/Home/Controller/QueryController.class.php index a5fe4a1d0..57bbcd20c 100644 --- a/Application/Home/Controller/QueryController.class.php +++ b/Application/Home/Controller/QueryController.class.php @@ -2,8 +2,6 @@ namespace Home\Controller; -use OT\DataDictionary; -use User\Api\PromoteApi; use Base\Repository\PromoteRepository; use Base\Repository\SpendRepository; use Base\Repository\UserRepository; @@ -54,16 +52,16 @@ class QueryController extends BaseController $userAccount = trim(I('user_account', '')); $payOrderNumber = trim(I('pay_order_number', '')); $nowTime = date('Y-m-d'); - + $initBegTime = date('Y-m-d', strtotime('-6 day', strtotime($nowTime))); $initBegTime = empty(I('begtime')) ? $initBegTime : I('begtime'); $initEndTime = $nowTime; $initEndTime = empty(I('endtime')) ? $initEndTime : I('endtime'); - + $begTime = strtotime($initBegTime); $endTime = strtotime($initEndTime); $endTime += 3600 * 24; - + $payedBegTime = I("payed_begtime", ''); if ($payedBegTime) $payedBegTime = strtotime($payedBegTime); $payedEndTime = I("payed_endtime", ''); @@ -78,7 +76,7 @@ class QueryController extends BaseController $endTime = 0; } } - + $levelPromote = $this->getLevelPromote(); $queryPromote = $this->getQueryPromote($levelPromote); $loginPromote = $this->getLoginPromote(); @@ -136,7 +134,7 @@ class QueryController extends BaseController if ($payedBegTime && $payedEndTime) { $map['tab_spend.payed_time'] = ['between', [$payedBegTime, $payedEndTime - 1]]; } - + $map = $this->spendRepository->withIsCheck($map, 'tab_spend.is_check'); $data = []; @@ -146,8 +144,10 @@ class QueryController extends BaseController 'pay_amount' => '0.00', 'discount_amount' => '0.00', ]; - if (intval($endTime - $begTime) / (24 * 3600) <= 31 - || intval($payedEndTime - $payedBegTime) / (24 * 3600) <= 31) { + if ( + intval($endTime - $begTime) / (24 * 3600) <= 31 + || intval($payedEndTime - $payedBegTime) / (24 * 3600) <= 31 + ) { $data = M('Spend', 'tab_') ->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') @@ -188,7 +188,7 @@ class QueryController extends BaseController $promoteData = []; if (!empty($promoteIdData)) { $promoteIdData = array_unique($promoteIdData); - $promoteData = M('promote', 'tab_')->where(array('id' => ['in',$promoteIdData]))->getField('id,account,real_name,group_remark'); + $promoteData = M('promote', 'tab_')->where(array('id' => ['in', $promoteIdData]))->getField('id,account,real_name,group_remark'); } foreach ($data as &$list) { switch ($list['level']) { @@ -217,26 +217,12 @@ class QueryController extends BaseController $list['p_pro_group_remark'] = $promoteData[$list['parent_id']]['group_remark']; break; } - $list['user_account'] = substr($list['user_account'], 0, 2) . '******' . substr($list['user_account'], 8); + $list['user_account'] = getUserAccountOfPromote($list['user_account'], $loginPromote); $list['spend_time'] = date('Y-m-d H:i:s', $list['spend_time']); $list['pay_time'] = ($list['pay_status'] == 1) ? date('Y-m-d H:i:s', $list['pay_time']) : '--'; $list['pay_status'] = isset(QueryController::$payStatus[$list['pay_status']]) ? QueryController::$payStatus[$list['pay_status']] : '未知状态'; $list['sdk_version'] = getSDKTypeName($list['sdk_version']); - - //订单隐藏算法 - $orderLen = strlen($list['pay_order_number']); - $strLen = 4; - $hideChar = ''; - - if ($orderLen <= 8) { - $strLen = 2; - } - - for ($i = 0; $i < $orderLen - $strLen * 2; $i++) { - $hideChar .= '*'; - } - - $list['pay_order_number'] = substr($list['pay_order_number'], 0, $strLen) . $hideChar . substr($list['pay_order_number'], $orderLen - $strLen); + $list['pay_order_number'] = hideOrderNumber($list['pay_order_number']); } } @@ -285,7 +271,7 @@ class QueryController extends BaseController { $page = intval(I('p', 1)); $row = intval(I('row', 10)); - $ownId = intval(I('own_id'), 0);//本账号 + $ownId = intval(I('own_id'), 0); //本账号 $account = trim(I('account', '')); $id = intval(I('id', 0)); $nowTime = date('Y-m-d'); @@ -342,14 +328,13 @@ class QueryController extends BaseController ->where($loginMap) ->order('login_time desc') ->find(); - + $list['new_login_time'] = date('Y-m-d H:i:s', $newLoginData['login_time']); $list['new_login_ip'] = $newLoginData['login_ip']; $list['account'] = getHideAccount($list['account']); - if(!empty($list['device_number'])) { - $list['device_number'] = encryption($list['device_number']); + if (!empty($list['device_number'])) { + $list['device_number'] = encryption($list['device_number']); } - } } @@ -599,7 +584,6 @@ class QueryController extends BaseController $promote_child = get_sub_channel_id($chid, PRO_GRADE + 1); $map['s.promote_id'] = $mapp['u.promote_id'] = array('in', $promote_child); - } else { $promote_child = get_zi_promote_id(PID); if (empty($promote_child)) { @@ -619,12 +603,10 @@ class QueryController extends BaseController $mmap = array($mapp, $map); $user = A('User', 'Event'); $user->check_child_bill($model, $p, $mmap); - } else { $this->meta_title = '子渠道结算'; $this->display(); } - } public function generatesub() @@ -720,7 +702,6 @@ class QueryController extends BaseController public function son_apply_withdraw($settlement_number = '') { $map['settlement_number'] = $settlement_number; - $with_map['settlement_number'] = $totalSett['settlement_number']; $result = M("SonSettlement", "tab_")->where($map)->save(array('ti_status' => 0)); if ($result !== false) { echo json_encode(array("status" => 1)); @@ -732,7 +713,6 @@ class QueryController extends BaseController public function audit_withdraw($settlement_number = '') { $map['settlement_number'] = $settlement_number; - $with_map['settlement_number'] = $totalSett['settlement_number']; $result = M("SonSettlement", "tab_")->where($map)->save(array('ti_status' => 1)); if ($result !== false) { $this->success('审核成功'); @@ -967,7 +947,6 @@ class QueryController extends BaseController $map_list['promote_id'] = array('in', $pro_arr); $promote_id = implode(',', $pro_arr); $join .= " AND u.promote_id in ({$promote_id})"; - } $spend2 = D('Spend'); $data = M('Apply', 'tab_')->field('game_id, game_name')->where(['promote_id' => $promote_id])->order('game_id desc')->select(); @@ -1085,7 +1064,6 @@ class QueryController extends BaseController { $this->meta_title = '留存统计'; A('User', 'Event')->retention_analysis(); - } public function details() @@ -1132,7 +1110,7 @@ class QueryController extends BaseController $loginPromote = $this->getLoginPromote(); - $ownId = intval(I('own_id'), 0);//本账号 + $ownId = intval(I('own_id'), 0); //本账号 if ($ownId) { $params['promote_id'] = $queryPromote['id']; } else { @@ -1174,22 +1152,22 @@ class QueryController extends BaseController if (intval($endTime - $begTime) / (24 * 3600) <= 31) { $userRepository = new UserRepository(); $spendRepository = new SpendRepository(); - $roleNumList = $userRepository->getCreateRoleCountByDay($params);//创角数 - $userNumList = $userRepository->getCreateRoleUserCountByDay($params);//创角用户 - $newUserNumList = $userRepository->getNewCreateRoleUserCountByDay($params);//新创角用户 - $newDeviceNumList = $userRepository->getNewCreateRoleDeviceCountByDay($params);//新创角设备 - $newIpNumList = $userRepository->getNewCreateRoleIpCountByDay($params);//新创角IP - $loginUserNumList = $userRepository->getLoginCountGroupByDayNew($params);//登录用户数 + $roleNumList = $userRepository->getCreateRoleCountByDay($params); //创角数 + $userNumList = $userRepository->getCreateRoleUserCountByDay($params); //创角用户 + $newUserNumList = $userRepository->getNewCreateRoleUserCountByDay($params); //新创角用户 + $newDeviceNumList = $userRepository->getNewCreateRoleDeviceCountByDay($params); //新创角设备 + $newIpNumList = $userRepository->getNewCreateRoleIpCountByDay($params); //新创角IP + $loginUserNumList = $userRepository->getLoginCountGroupByDayNew($params); //登录用户数 if ($this->canViewUserRecharge) { - $spendUserNumList = $spendRepository->getPayUserCountGroupByDayNew($params);//充值人数 - $spendNumList = $spendRepository->getPayCountGroupByDay($params);//充值次数 - $spendAllAmountList = $spendRepository->getPayAmountGroupByDayAndType($params);//充值总额 + $spendUserNumList = $spendRepository->getPayUserCountGroupByDayNew($params); //充值人数 + $spendNumList = $spendRepository->getPayCountGroupByDay($params); //充值次数 + $spendAllAmountList = $spendRepository->getPayAmountGroupByDayAndType($params); //充值总额 $params['pay_way'] = ['in', '1,2,3,4,5,6']; - $spendCashList = $spendRepository->getPayAmountGroupByDayAndType($params);//现金充值 + $spendCashList = $spendRepository->getPayAmountGroupByDayAndType($params); //现金充值 $params['pay_way'] = 0; - $spendGenericList = $spendRepository->getPayAmountGroupByDayAndType($params);//通用币充值 + $spendGenericList = $spendRepository->getPayAmountGroupByDayAndType($params); //通用币充值 $params['pay_way'] = -1; - $spendBindingList = $spendRepository->getPayAmountGroupByDayAndType($params);//绑定币充值 + $spendBindingList = $spendRepository->getPayAmountGroupByDayAndType($params); //绑定币充值 } $allData['role_num'] = 0; @@ -1282,7 +1260,7 @@ class QueryController extends BaseController $page = intval(I('get.p', 1)); $page = $page ? $page : 1; //默认显示第一页数据arraypage $row = intval(I('get.row', 10)); - $ownId = intval(I('own_id'), 0);//本账号 + $ownId = intval(I('own_id'), 0); //本账号 $relationGameId = intval(I('relation_game_id', 0)); $sdkVersion = intval(I('sdk_version', 0)); $serverId = I('server_id', ''); @@ -1308,9 +1286,9 @@ class QueryController extends BaseController $parameter['own_id'] = $ownId; $parameter['p'] = $page; $parameter['row'] = $row; - + $loginPromote = $this->getLoginPromote(); - + $map = []; $map = ['_string' => '1=1']; if ($ownId) { @@ -1333,16 +1311,16 @@ class QueryController extends BaseController $params['begin_time'] = $begTime; $params['end_time'] = $endTime - 1; - + $promoteService = new PromoteService(); $allGameIs = $promoteService->getHistoryGameIds($loginPromote); - + if ($allGameIs && count($allGameIs) > 0) { $map['_string'] .= ' and id in(' . implode(',', $allGameIs) . ')'; } else { $map['_string'] .= '1=0'; } - + $data = M('game', 'tab_')->where($map)->order('sort desc,id desc')->page($page, $row)->select(); $count = M('game', 'tab_')->where($map)->count(); $records = []; @@ -1354,22 +1332,22 @@ class QueryController extends BaseController $userRepository = new UserRepository(); $spendRepository = new SpendRepository(); - $roleNumList = $userRepository->getCreateRoleCountByGame($params);//创角数 - $userNumList = $userRepository->getCreateRoleUserCountByGame($params);//创角用户 - $newUserNumList = $userRepository->getNewCreateRoleUserCountByGame($params);//新创角用户 - $newDeviceNumList = $userRepository->getNewCreateRoleDeviceCountByGame($params);//新创角设备 - $newIpNumList = $userRepository->getNewCreateRoleIpCountByGame($params);//新创角IP - $loginUserNumList = $userRepository->getLoginCountGroupByGame($params);//登录用户数 + $roleNumList = $userRepository->getCreateRoleCountByGame($params); //创角数 + $userNumList = $userRepository->getCreateRoleUserCountByGame($params); //创角用户 + $newUserNumList = $userRepository->getNewCreateRoleUserCountByGame($params); //新创角用户 + $newDeviceNumList = $userRepository->getNewCreateRoleDeviceCountByGame($params); //新创角设备 + $newIpNumList = $userRepository->getNewCreateRoleIpCountByGame($params); //新创角IP + $loginUserNumList = $userRepository->getLoginCountGroupByGame($params); //登录用户数 if ($this->canViewUserRecharge) { - $spendUserNumList = $spendRepository->getPayUserCountGroupByGame($params);//充值人数 - $spendNumList = $spendRepository->getPayCountGroupByGame($params);//充值次数 - $spendAllAmountList = $spendRepository->getPayAmountGroupByGameAndType($params);//充值总额 + $spendUserNumList = $spendRepository->getPayUserCountGroupByGame($params); //充值人数 + $spendNumList = $spendRepository->getPayCountGroupByGame($params); //充值次数 + $spendAllAmountList = $spendRepository->getPayAmountGroupByGameAndType($params); //充值总额 $params['pay_way'] = ['in', '1,2,3,4,5,6']; - $spendCashList = $spendRepository->getPayAmountGroupByGameAndType($params);//现金充值 + $spendCashList = $spendRepository->getPayAmountGroupByGameAndType($params); //现金充值 $params['pay_way'] = 0; - $spendGenericList = $spendRepository->getPayAmountGroupByGameAndType($params);//通用币充值 + $spendGenericList = $spendRepository->getPayAmountGroupByGameAndType($params); //通用币充值 $params['pay_way'] = -1; - $spendBindingList = $spendRepository->getPayAmountGroupByGameAndType($params);//绑定币充值 + $spendBindingList = $spendRepository->getPayAmountGroupByGameAndType($params); //绑定币充值 } foreach ($data as $list) { $gameId = $list['id']; @@ -1399,23 +1377,23 @@ class QueryController extends BaseController } $params['all_data'] = 1; $params['game_ids'] = $allGameIs; - $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['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); //登录用户数 if ($this->canViewUserRecharge) { - $allData['spend_user_num'] = $spendRepository->getPayUserCountByGame($params);//充值人数 - $allData['spend_num'] = $spendRepository->getPayCountByGame($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));//充值总额 + $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));//现金充值 + $allData['spend_cash'] = null_to_0($spendRepository->getPayAmountByGameAndType($params)); //现金充值 $params['pay_way'] = 0; - $allData['spend_generic'] = null_to_0($spendRepository->getPayAmountByGameAndType($params));//通用币充值 + $allData['spend_generic'] = null_to_0($spendRepository->getPayAmountByGameAndType($params)); //通用币充值 $params['pay_way'] = -1; - $allData['spend_binding'] = null_to_0($spendRepository->getPayAmountByGameAndType($params));//绑定币充值 + $allData['spend_binding'] = null_to_0($spendRepository->getPayAmountByGameAndType($params)); //绑定币充值 $allData['spend_discount'] = '0.00'; $allData['spend_voucher'] = '0.00'; } @@ -1487,14 +1465,12 @@ class QueryController extends BaseController $promote = $_REQUEST['promote_id']; if (PID == $promote) { - } else { $pids = get_prmoote_chlid_account($promote); $pro_arr = array_column($pids, 'id'); $pro_arr[] = $promote; $promote = implode(',', $pro_arr); - } $game = M('apply', 'tab_') @@ -1601,7 +1577,8 @@ class QueryController extends BaseController public function viewRole($p = 0) { $promoteId = D('User')->where('id = %d', I('get.id'))->getField('promote_id'); - $permission = hasPromotePermission(PID, $promoteId);//是否有该推广员权限 + $permission = hasPromotePermission(PID, $promoteId); //是否有该推广员权限 + $loginPromote = $this->getLoginPromote(); if ($permission === false) { $this->error('无推广员权限'); @@ -1646,7 +1623,7 @@ class QueryController extends BaseController if (!empty($data)) { foreach ($data as &$list) { - $list['user_account'] = substr($list['user_account'], 0, 2) . '******' . substr($list['user_account'], 8); + $list['user_account'] = getUserAccountOfPromote($list['user_account'], $loginPromote); } } @@ -1721,20 +1698,20 @@ class QueryController extends BaseController $roleLevelBegin = intval(I('role_level_begin', 0)); $roleLevelEnd = intval(I('role_level_end', 0)); $headmanPromoteId = I('headman_promote_id', 0); - $createTime = I('create_time', date('Y-m-d') . ' 至 ' . date('Y-m-d', time()-7*24*3600)); + $createTime = I('create_time', date('Y-m-d') . ' 至 ' . date('Y-m-d', time() - 7 * 24 * 3600)); $lastSortName = trim(I('last_sort_name', '')); $sortName = trim(I('sort_name', '')); $sort = intval(I('sort', 1)); - - $promote = $this->getLoginPromote(); + + $loginPromote = $this->getLoginPromote(); $levelPromote = $this->getLevelPromote(); - $queryPromote = $this->getQueryPromote($levelPromote, function() use ($promote) { - if ($promote['shift_over_apply'] == 1) { + $queryPromote = $this->getQueryPromote($levelPromote, function () use ($loginPromote) { + if ($loginPromote['shift_over_apply'] == 1) { $promoteService = new PromoteService(); - return $promoteService->getTopPromote($promote); + return $promoteService->getTopPromote($loginPromote); } else { - return $promote; + return $loginPromote; } }); @@ -1754,7 +1731,8 @@ class QueryController extends BaseController } if ($roleName != '') { $map['role_name'] = ['like', '%' . $roleName . '%']; - }if ($roleId != '') { + } + if ($roleId != '') { $map['role_id'] = $roleId; } if ($userAccount != '') { @@ -1851,25 +1829,13 @@ class QueryController extends BaseController // var_dump($records);die(); foreach ($records as $key => $value) { - - //隐藏算法 - $orderLen = strlen($value['user_account']); - $strLen = 3; - $hideChar = ''; - if ($orderLen <= 8) { - $strLen = 2; - } - for ($i = 0; $i < $orderLen - $strLen * 2; $i++) { - $hideChar .= '*'; - } - - if($records[$key]['create_time'] == 0) { + if ($records[$key]['create_time'] == 0) { $records[$key]['create_time'] = date('Y-m-d', $value['play_time']) . '
' . date('H:i:s', $value['play_time']); } else { $records[$key]['create_time'] = date('Y-m-d', $value['create_time']) . '
' . date('H:i:s', $value['create_time']); } - $records[$key]['user_account'] = substr($value['user_account'], 0, $strLen) . $hideChar . substr($value['user_account'], $orderLen - $strLen); + $records[$key]['user_account'] = getUserAccountOfPromote($value['user_account'], $loginPromote); $records[$key]['register_time'] = date('Y-m-d', $value['register_time']) . '
' . date('H:i:s', $value['register_time']); $records[$key]['login_time'] = date('Y-m-d', $value['login_time']) . '
' . date('H:i:s', $value['login_time']); @@ -1928,7 +1894,7 @@ class QueryController extends BaseController $nowTime = strtotime($nowTime); $nowTimeEnd = $nowTime + 3600 * 24 - 1; - $promote = $this->getLoginPromote(); + $loginPromote = $this->getLoginPromote(); $levelPromote = $this->getLevelPromote(); $queryPromote = $this->getQueryPromote($levelPromote); @@ -1998,7 +1964,7 @@ class QueryController extends BaseController $map['s.pay_time'] = ['between', [$begTime, $endTime - 1]]; $fieldS = "sum(s.pay_amount) recharge_cost, count(*) recharge_count, s.user_id, s.user_account, s.promote_id, s.promote_account, s.game_name, s.sdk_version, s.server_name, SUBSTRING_INDEX(GROUP_CONCAT(s.game_player_name order by s.id desc), ',', 1) as game_player_name"; $fieldUser = 'u.register_time, u.login_time'; - + $spendMap['_string'] = 'today.user_id = s.user_id and today.game_id = s.game_id and today.server_id = s.server_id and today.game_player_id = s.game_player_id and today.promote_id = s.promote_id'; $spendMap['today.pay_status'] = 1; $spendMap['today.pay_time'] = ['between', [$nowTime, $nowTimeEnd]]; @@ -2048,7 +2014,7 @@ class QueryController extends BaseController $promotes = M('promote', 'tab_')->field(['id', 'chain', 'account'])->where(['id' => ['in', $promoteIds]])->select(); $promotes = index_by_column('id', $promotes); foreach ($records as &$list) { - $list['user_account'] = empty($list['user_account']) ? '--' : encryption($list['user_account']); + $list['user_account'] = empty($list['user_account']) ? '--' : getUserAccountOfPromote($list['user_account'], $loginPromote); $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']; @@ -2132,7 +2098,7 @@ class QueryController extends BaseController if ($id > 0) { $promoteId = D('Spend')->where('id = %d', $id)->getField('promote_id'); - $permission = hasPromotePermission(PID, $promoteId);//是否有该推广员权限 + $permission = hasPromotePermission(PID, $promoteId); //是否有该推广员权限 if ($permission) { $map['id'] = $id; @@ -2258,7 +2224,7 @@ class QueryController extends BaseController // $newCreateRoleDeviceCountList = $promoteRepository->getNewCreateRoleDeviceCountByIds($ids, $params); $newCreateRoleIpCountList = $promoteRepository->getNewCreateRoleIpCountByIds($ids, $params); $loginUserCountList = $promoteRepository->getLoginUserCountByIds($ids, $params); - + $rechargeCountList = []; $rechargeUserCountList = []; $rechargeAmountList = []; @@ -2472,7 +2438,7 @@ class QueryController extends BaseController $record = [ 'id' => $parent['id'], 'account' => $parent['account'], - 'real_name' => mb_strlen($parent['real_name'],'utf-8') == 2 ? mb_substr($parent['real_name'],0,1,'utf-8').'*':mb_substr($parent['real_name'],0,1,'utf-8').'**', + 'real_name' => hideRealName($parent['real_name']), 'level' => $parent['level'], 'game_name' => $game['game_name'], 'sdk_version_text' => $game['sdk_version_text'], @@ -2487,7 +2453,7 @@ class QueryController extends BaseController $record = [ 'id' => $id, 'account' => $promote['account'], - 'real_name' => mb_strlen($promote['real_name'],'utf-8') == 2 ? mb_substr($promote['real_name'],0,1,'utf-8').'*':mb_substr($promote['real_name'],0,1,'utf-8').'**', + 'real_name' => hideRealName($promote['real_name']), 'level' => $promote['level'], 'game_name' => $game['game_name'], 'sdk_version_text' => $game['sdk_version_text'], @@ -2524,6 +2490,7 @@ class QueryController extends BaseController $roleLevelEnd = intval(I('level_end', 0)); $promoteId = I('promote_id', 0); $isSelf = I('is_self', 0); + $loginPromote = $this->getLoginPromote(); if ($relationGameId != 0 || $sdkVersion != 0) { $gameIds = gameSearch($relationGameId, $sdkVersion); @@ -2558,20 +2525,7 @@ class QueryController extends BaseController $query = M('user_play_info', 'tab_')->where($map)->order('create_time desc'); list($records, $pagination, $count) = $this->paginate($query); foreach ($records as $key => $value) { - //订单隐藏算法 - $orderLen = strlen($value['user_account']); - $strLen = 3; - $hideChar = ''; - - if ($orderLen <= 8) { - $strLen = 2; - } - - for ($i = 0; $i < $orderLen - $strLen * 2; $i++) { - $hideChar .= '*'; - } - - $records[$key]['user_account'] = substr($value['user_account'], 0, $strLen) . $hideChar . substr($value['user_account'], $orderLen - $strLen); + $records[$key]['user_account'] = getUserAccountOfPromote($value['user_account'], $loginPromote); } $this->assign('records', $records); @@ -2629,7 +2583,8 @@ class QueryController extends BaseController return M('server', 'tab_')->where($map)->getField('server_name'); } - public function iosDownLoadData() { + public function iosDownLoadData() + { $page = intval(I('get.p', 1)); $page = $page ? $page : 1; //默认显示第一页数据arraypage $row = intval(I('get.row', 10)); @@ -2640,7 +2595,7 @@ class QueryController extends BaseController $map = []; if ($queryPromote['level'] == 4) { $map['id'] = $queryPromote['id']; - }else { + } else { $map['chain'] = ['like', $queryPromote['chain'] . $queryPromote['id'] . '%']; } $iostime = time(); @@ -2681,18 +2636,18 @@ class QueryController extends BaseController $map = []; $map['tab_package_download_log.promote_id'] = ['in', $ids]; - // $data = M('package_download_log','tab_')->where($map)->select(); + // $data = M('package_download_log','tab_')->where($map)->select(); $listData = []; $allUserMap['promote_id'] = ['in', $allids]; $allUserMap['device_type'] = 2; $allUserMap['register_time'] = ['between', [$begTime, $endTime]]; - $allTFMap['promote_id'] = ['in', $allids]; + $allTFMap['promote_id'] = ['in', $allids]; $allTFMap['type'] = 2; $allTFMap['create_time'] = ['between', [$begTime, $endTime]]; - $allSuperMap['promote_id'] = ['in', $allids]; + $allSuperMap['promote_id'] = ['in', $allids]; $allSuperMap['type'] = 3; $allSuperMap['create_time'] = ['between', [$begTime, $endTime]]; - $companyMap['promote_id'] = ['in', $allids]; + $companyMap['promote_id'] = ['in', $allids]; $companyMap['type'] = 1; $companyMap['create_time'] = ['between', [$begTime, $endTime]]; $alliosMap['promote_id'] = ['in', $allids]; @@ -2700,19 +2655,19 @@ class QueryController extends BaseController $alliosMap['register_time'] = ['between', [$sunday, $iostime]]; $allUsersCounts = M('user', 'tab_')->where($allUserMap)->count(); $allIosCounts = M('user', 'tab_')->where($alliosMap)->count(); - + $allTFCounts = M('package_download_log', 'tab_')->where($allTFMap)->count(); $allSuperCounts = M('package_download_log', 'tab_')->where($allSuperMap)->count(); $allCompanyCounts = M('package_download_log', 'tab_')->where($companyMap)->count(); - + foreach ($ids as $key => $id) { $promote1 = M('promote', 'tab_')->field('account, level, parent_id, chain')->where(['id' => $id])->select(); $promote = $promote1[0]; $chain = $promote['chain']; $listData[$key]['promote_id'] = $id; - if($id == PID) { - $listData[$key]['account'] = $promote['account'].''.'['.'自己'.']'.''; - }else { + if ($id == PID) { + $listData[$key]['account'] = $promote['account'] . '' . '[' . '自己' . ']' . ''; + } else { $listData[$key]['account'] = $promote['account']; } $iosTimeMap['promote_id'] = $id; @@ -2735,42 +2690,42 @@ class QueryController extends BaseController $usersCounts = M('user', 'tab_')->where($map10)->count(); $listData[$key]['userscounts'] = intval($usersCounts); $listData[$key]['tfcounts'] = intval($tfCounts); - $listData[$key]['tfpercent'] = number_format((intval($tfCounts) / intval($usersCounts)),2,'.','') * 100; + $listData[$key]['tfpercent'] = number_format((intval($tfCounts) / intval($usersCounts)), 2, '.', '') * 100; if (intval($usersCounts) == 0) { - $listData[$key]['tfpercent'] = 0; + $listData[$key]['tfpercent'] = 0; } - if($promote['level'] == 1) { + if ($promote['level'] == 1) { $listData[$key]['belongs_president'] = $promote['account']; $listData[$key]['belongs_department'] = "无所属部门长"; $listData[$key]['belongs_group'] = "无所属组长"; } if ($promote['level'] == 2) { - $parentPromote = M('promote', 'tab_')->field('account')->where(['id'=>$promote['parent_id']])->select(); + $parentPromote = M('promote', 'tab_')->field('account')->where(['id' => $promote['parent_id']])->select(); $listData[$key]['belongs_president'] = $parentPromote[0]['account']; $listData[$key]['belongs_department'] = $promote['account']; $listData[$key]['belongs_group'] = "无所属组长"; } if ($promote['level'] == 3) { - $chainArr = explode('/', $chain); - $presidentAccount = M('promote', 'tab_')->where(['id' => $chainArr[1]])->getField('account'); - $departmentAccount = M('promote', 'tab_')->where(['id' => $chainArr[2]])->getField('account'); - $listData[$key]['belongs_president'] = $presidentAccount; - $listData[$key]['belongs_department'] = $departmentAccount; - $listData[$key]['belongs_group'] = $promote['account']; + $chainArr = explode('/', $chain); + $presidentAccount = M('promote', 'tab_')->where(['id' => $chainArr[1]])->getField('account'); + $departmentAccount = M('promote', 'tab_')->where(['id' => $chainArr[2]])->getField('account'); + $listData[$key]['belongs_president'] = $presidentAccount; + $listData[$key]['belongs_department'] = $departmentAccount; + $listData[$key]['belongs_group'] = $promote['account']; } if ($promote['level'] == 4) { - $chainArr = explode('/', $chain); - $presidentAccount = M('promote', 'tab_')->where(['id' => $chainArr[1]])->getField('account'); - $departmentAccount = M('promote', 'tab_')->where(['id' => $chainArr[2]])->getField('account'); - $groupAccount = M('promote', 'tab_')->where(['id' => $chainArr[3]])->getField('account'); - $listData[$key]['belongs_president'] = $presidentAccount; - $listData[$key]['belongs_department'] = $departmentAccount; - $listData[$key]['belongs_group'] = $groupAccount; + $chainArr = explode('/', $chain); + $presidentAccount = M('promote', 'tab_')->where(['id' => $chainArr[1]])->getField('account'); + $departmentAccount = M('promote', 'tab_')->where(['id' => $chainArr[2]])->getField('account'); + $groupAccount = M('promote', 'tab_')->where(['id' => $chainArr[3]])->getField('account'); + $listData[$key]['belongs_president'] = $presidentAccount; + $listData[$key]['belongs_department'] = $departmentAccount; + $listData[$key]['belongs_group'] = $groupAccount; } } - $totalpercent = number_format($allTFCounts/$allUsersCounts,2,'.','') * 100; + $totalpercent = number_format($allTFCounts / $allUsersCounts, 2, '.', '') * 100; if ($allUsersCounts == 0) { $totalpercent = '0'; } @@ -2784,76 +2739,75 @@ class QueryController extends BaseController $this->assign('initBegTime', $initBegTime); $this->assign('initEndTime', $initEndTime); $this->assign('allIosCounts', $allIosCounts); - $this->assign('tfpercent', $tfpercent); $this->display(); } - public function iosDownLoadDetail() { - $promote_id = $_REQUEST['promote_id']; - $belongs_president = $_REQUEST['belongs_president']; - $belongs_department = $_REQUEST['belongs_department']; - $belongs_group = $_REQUEST['belongs_group']; - // $createTime = I('create_time', ''); - - $nowTime = date('Y-m-d'); - $initBegTime = date('Y-m-d', strtotime('-6 day', strtotime($nowTime))); - $initBegTime = empty(I('begtime')) ? $initBegTime : I('begtime'); - $initEndTime = $nowTime; - $initEndTime = empty(I('endtime')) ? $initEndTime : I('endtime'); - $begTime = strtotime($initBegTime); - $endTime = strtotime($initEndTime); - $endTime += 3600 * 24; - - $map['create_time'] = ['between', [$begTime, $endTime]]; - $tfMap['create_time'] = ['between', [$begTime, $endTime]]; - $superMap['create_time'] = ['between', [$begTime, $endTime]]; - $companyMap['create_time'] = ['between', [$begTime, $endTime]]; - - if(!empty(I('user_account'))) { - $user_id = M('user', 'tab_')->where(['account'=>I('user_account')])->getField('id'); - $map['user_id'] = $user_id; - $tfMap['user_id'] = $user_id; - $superMap['user_id'] = $user_id; - $companyMap['user_id'] = $user_id; - } - if(!empty(I('type'))) { - $map['type'] = I('type'); - - } - $map['promote_id'] = $promote_id; + public function iosDownLoadDetail() + { + $promote_id = $_REQUEST['promote_id']; + $belongs_president = $_REQUEST['belongs_president']; + $belongs_department = $_REQUEST['belongs_department']; + $belongs_group = $_REQUEST['belongs_group']; + // $createTime = I('create_time', ''); + $loginPromote = $this->getLoginPromote(); + + $nowTime = date('Y-m-d'); + $initBegTime = date('Y-m-d', strtotime('-6 day', strtotime($nowTime))); + $initBegTime = empty(I('begtime')) ? $initBegTime : I('begtime'); + $initEndTime = $nowTime; + $initEndTime = empty(I('endtime')) ? $initEndTime : I('endtime'); + $begTime = strtotime($initBegTime); + $endTime = strtotime($initEndTime); + $endTime += 3600 * 24; + + $map['create_time'] = ['between', [$begTime, $endTime]]; + $tfMap['create_time'] = ['between', [$begTime, $endTime]]; + $superMap['create_time'] = ['between', [$begTime, $endTime]]; + $companyMap['create_time'] = ['between', [$begTime, $endTime]]; + + if (!empty(I('user_account'))) { + $user_id = M('user', 'tab_')->where(['account' => I('user_account')])->getField('id'); + $map['user_id'] = $user_id; + $tfMap['user_id'] = $user_id; + $superMap['user_id'] = $user_id; + $companyMap['user_id'] = $user_id; + } + if (!empty(I('type'))) { + $map['type'] = I('type'); + } + $map['promote_id'] = $promote_id; //$packAges = M('package_download_log', 'tab_')->field('id,game_id,user_id,type,create_time')->where(['promote_id'=>$promote_id])->select(); - $query = M('package_download_log', 'tab_')->field('id,game_id,user_id,type,create_time')->where($map); - list($packAges, $pagination, $count) = $this->paginate($query); - foreach ($packAges as $key =>$package) { + $query = M('package_download_log', 'tab_')->field('id,game_id,user_id,type,create_time')->where($map); + list($packAges, $pagination, $count) = $this->paginate($query); + foreach ($packAges as $key => $package) { $user_id = $package['user_id']; $usersAccount = M('user', 'tab_')->where(['id' => $user_id])->getField('account'); $packAges[$key]['account'] = $usersAccount; if ($package['type'] == 1) { $packAges[$key]['typename'] = "企业签下载"; } - if($package['type'] == 2) { + if ($package['type'] == 2) { $packAges[$key]['typename'] = "TF下载"; } - if($package['type'] == 3) { + if ($package['type'] == 3) { $packAges[$key]['typename'] = "超级签下载"; } $packAges[$key]['create_time'] = date('Y-m-d H:i:s', $package['create_time']); - $promoteInfo = M('promote', 'tab_')->field('account')->where(['id'=>$promote_id])->find(); + $promoteInfo = M('promote', 'tab_')->field('account')->where(['id' => $promote_id])->find(); $packAges[$key]['promote_account'] = $promoteInfo['account']; $packAges[$key]['belongs_president'] = $belongs_president; $packAges[$key]['belongs_department'] = $belongs_department; $packAges[$key]['belongs_group'] = $belongs_group; - $packAges[$key]['account'] = encryption($packAges[$key]['account']); - + $packAges[$key]['account'] = getUserAccountOfPromote($packAges[$key]['account'], $loginPromote); } $tfMap['promote_id'] = $promote_id; - $tfMap['type'] = 2; + $tfMap['type'] = 2; $TFCounts = M('package_download_log', 'tab_')->where($tfMap)->count(); $superMap['promote_id'] = $promote_id; $superMap['type'] = 3; $superCounts = M('package_download_log', 'tab_')->where($superMap)->count(); - + $companyMap['promote_id'] = $promote_id; $companyMap['type'] = 1; $companyCounts = M('package_download_log', 'tab_')->where($companyMap)->count(); @@ -2874,8 +2828,8 @@ class QueryController extends BaseController public function multisort($records, $column, $type = 'asc') { $length = count($records); - for ($i = 0; $i < $length; $i ++) { - for ($j = $i + 1; $j < $length; $j ++) { + for ($i = 0; $i < $length; $i++) { + for ($j = $i + 1; $j < $length; $j++) { if ($type == 'asc') { if ($records[$i][$column] > $records[$j][$column]) { $temp = $records[$i]; @@ -2898,8 +2852,7 @@ class QueryController extends BaseController { $baseGameId = I('game_id', 0); $deviceType = I('device_type', ''); - $timeRange = I('time_range', date('Y-m-d',strtotime('-7 day')) . ' 至 ' . date('Y-m-d')); - $lastSortName = trim(I('last_sort_name', '')); + $timeRange = I('time_range', date('Y-m-d', strtotime('-7 day')) . ' 至 ' . date('Y-m-d')); $sortName = trim(I('sort_name', '')); $sort = intval(I('sort', 1)); @@ -2914,7 +2867,6 @@ class QueryController extends BaseController $end = $timeRangeRow[0]; } - $promote = $this->getLoginPromote(); $levelPromote = $this->getLevelPromote(); $queryPromote = $this->getQueryPromote($levelPromote); @@ -2924,7 +2876,7 @@ class QueryController extends BaseController $orderColumn = $sortName; $orderType = ($sort == 1) ? 'desc' : 'asc'; } - + $status = true; $data = false; $error = ''; @@ -2934,7 +2886,7 @@ class QueryController extends BaseController } $startTime = strtotime($start . ' 00:00:00'); $endTime = strtotime($end . ' 23:59:59') + 1; - if ((($endTime - $startTime)/(24*3600)) > 31) { + if ((($endTime - $startTime) / (24 * 3600)) > 31) { $error = '时间间隔不能超过31天'; $status = false; } @@ -2963,7 +2915,7 @@ class QueryController extends BaseController 'game_ids' => $gameIds, ] ]); - + $result = (string)$response->getBody(); $result = json_decode($result, true); if (!$result) { @@ -2973,17 +2925,15 @@ class QueryController extends BaseController $dayList = [1, 2, 3, 4, 5, 6, 7, 15, 30]; $gameName = $deviceType ? get_game_name($searchGameId) : $baseGame['name']; $promoteName = '全部'; - if ($promoteId) { - $promoteName = get_promote_account($promoteId); - } + foreach ($data as $key => $item) { $item['promote_name'] = $promoteName; $item['game_name'] = $gameName; foreach ($dayList as $day) { if ($item['register_count'] > 0) { - $item['retention_day'. $day] = round($item['retention_day'. $day]/$item['register_count'], 4)*100; + $item['retention_day' . $day] = round($item['retention_day' . $day] / $item['register_count'], 4) * 100; } else { - $item['retention_day'. $day] = '--'; + $item['retention_day' . $day] = '--'; } } $data[$key] = $item; @@ -3010,7 +2960,7 @@ class QueryController extends BaseController { $gameId = I('game_id', 0); $serverId = I('server_id', ''); - $timeRange = I('time_range', date('Y-m-d',strtotime('-7 day')) . ' 至 ' . date('Y-m-d')); + $timeRange = I('time_range', date('Y-m-d', strtotime('-7 day')) . ' 至 ' . date('Y-m-d')); $lastSortName = trim(I('last_sort_name', '')); $sortName = trim(I('sort_name', '')); $sort = intval(I('sort', 1)); @@ -3029,7 +2979,7 @@ class QueryController extends BaseController $start = $timeRangeRow[0]; $end = $timeRangeRow[0]; } - + $spendMap = ['pay_status' => 1, '_string' => '1=1']; $roleMap = ['_string' => '1=1']; $map = []; @@ -3037,7 +2987,7 @@ class QueryController extends BaseController $betweenTime = [strtotime($start . ' 00:00:00'), strtotime($end . ' 23:59:59')]; $spendMap['pay_time'] = ['between', $betweenTime]; $roleMap['create_time'] = ['between', $betweenTime]; - + $promoteService = new PromoteService(); $subInSql = $promoteService->subInSql($queryPromote); diff --git a/Application/Media/Controller/IndexController.class.php b/Application/Media/Controller/IndexController.class.php index ddf4dd26a..e9aec9961 100644 --- a/Application/Media/Controller/IndexController.class.php +++ b/Application/Media/Controller/IndexController.class.php @@ -348,7 +348,7 @@ class IndexController extends BaseController { //生成二维码图片 //echo $_SERVER['REQUEST_URI']; ob_clean(); - $object = new \QRcode(); + $object = new \QRcode(null); echo $object->png($url, false, $errorCorrectionLevel, $matrixPointSize, 2); } From d4d78e75b3b297d95c71f86b7d9e10f70e39df7b Mon Sep 17 00:00:00 2001 From: elf <360197197@qq.com> Date: Sun, 31 Jul 2022 00:56:04 +0800 Subject: [PATCH 3/3] bug --- Application/Common/Common/extend.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Application/Common/Common/extend.php b/Application/Common/Common/extend.php index 5368941f8..98a4c8c84 100644 --- a/Application/Common/Common/extend.php +++ b/Application/Common/Common/extend.php @@ -3111,7 +3111,7 @@ function encodeStr($str) function getUserAccountOfPromote($account, $promote = null) { - if ($promote && $promote['level_id'] == 1) { + if ($promote && $promote['level'] == 1) { return $account; } return substr($account, 0, 2) . '******' . substr($account, 8);