diff --git a/Application/Home/Controller/DownloadController.class.php b/Application/Home/Controller/DownloadController.class.php index b19f68679..45a84c811 100644 --- a/Application/Home/Controller/DownloadController.class.php +++ b/Application/Home/Controller/DownloadController.class.php @@ -1133,6 +1133,83 @@ class DownloadController extends BaseController { } $this->success('添加下载成功',U('listsIndex')); } + + 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(); + $childPromoteIds = ''; + if(empty($rs)) { + $map['tab_pay_info.promote_id'] = PID; + }else { + foreach ($rs as $rsKey => $rsValue) { + $id = $rsValue['id']; + $childPromoteIds .= $id.','; + } + $childPromoteIds = rtrim($childPromoteIds, ','); + $childPromoteIds .= ',' . PID; + $map['tab_pay_info.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($levelPromote)) { + array_push($ids,PID); + + } + array_push($ids,$queryPromote['id']); + if (!empty($ids)) { + $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'); + empty(I('server_id')) || $map['tab_pay_info.server_id'] = I('server_id'); + empty(I('game_player_name')) || $map['tab_pay_info.game_player_name'] = ['like', '%' . I('game_player_name') . '%']; + empty(I('user_account')) || $map['tab_pay_info.user_account'] = ['like', '%' . I('user_account') . '%']; + empty(I('extend')) || $map['tab_pay_info.extend'] = I('extend'); + empty(I('user_id')) || $map['tab_pay_info.user_id'] = I('user_id'); + if (!empty($begTime) && !empty($endTime)) { + $map['tab_pay_info.create_time'] = ['between', [strtotime($begTime), strtotime($endTime) - 1]]; + }else if (empty($begTime) && !empty($endTime)) { + $map['tab_pay_info.create_time'] = ['elt',strtotime($endTime)]; + }else if (!empty($begTime) && empty($endTime)) { + $map['tab_pay_info.create_time'] = ['EGT',strtotime($begTime)]; + } + + $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')); + } /** * 充值明细添加下载 * @author sunke @@ -1761,11 +1838,73 @@ class DownloadController extends BaseController { case "平台币充值": $this->orderlistExcelInfo($id,$map); break; + case "玩家行为日志"; + $this->playactionExcelInfo($id,$map); + break; default: break; } } + + public function playactionExcelInfo($id,$map) { + $xlsName = "玩家行为日志"; + $xlsCell = array( + 'cp订单号', + '充值时间', + '玩家账号', + '游戏名称', + '所属推广员', + '游戏区服', + '角色ID', + '角色名称', + '订单金额' + ); + $model = M('pay_info','tab_'); + $data1 = $model->field('id')->where($map)->select(); + $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($data1)?: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("nickname")->where(['id' => intval($v['promote_id'])])->find(); + $v['promote_id']= $promoteInfo['nickname']; + $csvData['extend'] = $this->encryption($v['extend']); + $csvData['create_time'] = $v['create_time']; + $csvData['user_account'] = $v['user_account']; + $csvData['game_name'] = $v['game_name']; + $csvData['promote_id'] = $v['promote_id']; + $csvData['server_name'] = $v['server_name']; + $csvData['user_id'] = $v['user_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(); + } + fclose($fp); + $this->backSuccessExport($id); + + } //注册明细excel信息 public function registerExcelInfo($id,$map) { diff --git a/Application/Home/Controller/PlayersController.class.php b/Application/Home/Controller/PlayersController.class.php new file mode 100644 index 000000000..427ae9b5a --- /dev/null +++ b/Application/Home/Controller/PlayersController.class.php @@ -0,0 +1,133 @@ +getLevelPromote(); + $queryPromote = $this->getQueryPromote($levelPromote); + // $loginPromote = $this->getLoginPromote(); + $map = []; + + $map['chain'] = ['like', $queryPromote['chain'] . $queryPromote['id'] . '/%']; + $ids = M('promote', 'tab_')->where($map)->getField('id', true); + $ids[] = $queryPromote['id']; + $map = []; + $map['tab_pay_info.promote_id'] = ['in', $ids]; + + if (!empty($relationGameId)) { + $map['tab_pay_info.relation_game_id'] = $relationGameId; + } + if (!empty($sdkVersion)) { + $map['tab_pay_info.sdk_version'] = $sdkVersion; + } + if (!empty($serverId)) { + $map['tab_pay_info.server_id'] = $serverId; + } + if (!empty($gamePlayerName)) { + $map['tab_pay_info.game_player_name'] = $gamePlayerName; + } + if (!empty($userAccount)) { + $map['tab_pay_info.user_account'] = $userAccount; + } + if (!empty($extend)) { + $map['tab_pay_info.extend'] = $extend; + } + if (!empty($userId)) { + $map['tab_pay_info.user_id'] = $userId; + } + if (!empty($begTime) && !empty($endTime)) { + $map['tab_pay_info.create_time'] = ['between', [$begTime, $endTime - 1]]; + }else if (empty($begTime) && !empty($endTime)) { + $map['tab_pay_info.create_time'] = ['elt',$endTime]; + }else if (!empty($begTime) && empty($endTime)) { + $map['tab_pay_info.create_time'] = ['EGT',$begTime]; + } + $page = intval(I('get.p', 1)); + $page = $page ? $page : 1; //默认显示第一页数据arraypage + $row=10; + $rs = M('pay_info','tab_')->where($map)->order('tab_pay_info.create_time desc') + ->page($page, $row)->select(); + foreach($rs as $key => $v) { + $rs[$key]['extend'] = encryption($v['extend']); + $rs[$key]['create_time'] = date('Y-m-d H:i:s',$v['create_time']); + $promoteInfo = M('promote','tab_')->field("nickname")->where(['id' => intval($v['promote_id'])])->find(); + $rs[$key]['promote_id']= $promoteInfo['nickname']; + } + $count = M('pay_info', 'tab_') + ->field('tab_pay_info.id') + ->where($map) + ->select(); + $count = count($count); + + //分页 + $parameter['p'] = $page; + $parameter['row'] = $row; + $parameter['begtime'] = $initBegTime; + $parameter['endtime'] = $initEndTime; + $parameter['relation_game_id'] = $relationGameId; + $parameter['sdk_version'] = $sdkVersion; + $parameter['server_id'] = $serverId; + $parameter['game_player_name'] = $gamePlayerName; + $parameter['user_account'] = $userAccount; + $parameter['extend'] = $extend; + $parameter['user_id'] = $user_id; + $parameter['level_promote_2'] = $levelPromote[0]; + $parameter['level_promote_3'] = $levelPromote[1]; + $parameter['level_promote_4'] = $levelPromote[2]; + $page = set_pagination($count, $row, $parameter); + if ($page) { + $this->assign('_page', $page); + } + $this->assign('listData',$rs); + $this->assign('initBegTime', I('begtime')); + $this->assign('initEndTime', I('endtime')); + $this->display(); + } + + private function getLevelPromote() + { + $levelPromote = []; + $levelPromote[] = I('level_promote_2', 0); + $levelPromote[] = I('level_promote_3', 0); + $levelPromote[] = I('level_promote_4', 0); + return $levelPromote; + } + + private function getQueryPromote($levelPromote) + { + $queryPromote = null; + $promote = $this->getLoginPromote(); + $queryPromoteId = 0; + foreach ($levelPromote as $item) { + if ($item != 0) { + $queryPromoteId = $item; + } + } + if ($queryPromoteId == 0) { + $queryPromote = $this->getLoginPromote(); + } else { + $queryPromote = M('promote', 'tab_')->where(['id' => $queryPromoteId])->find(); + } + return $queryPromote; + } +} \ No newline at end of file diff --git a/Application/Home/View/default/Players/playAction.html b/Application/Home/View/default/Players/playAction.html new file mode 100644 index 000000000..c3b1f63f1 --- /dev/null +++ b/Application/Home/View/default/Players/playAction.html @@ -0,0 +1,352 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Application/Home/View/default/Public/promote_base.html b/Application/Home/View/default/Public/promote_base.html index cd8f6eab3..1e53ffa9a 100644 --- a/Application/Home/View/default/Public/promote_base.html +++ b/Application/Home/View/default/Public/promote_base.html @@ -127,18 +127,11 @@ 平台币充值 - - - - - - - - - - - - + + +