You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
4261 lines
177 KiB
PHP
4261 lines
177 KiB
PHP
<?php
|
|
|
|
namespace Home\Controller;
|
|
use Think\Controller;
|
|
use App\Model\GameModel;
|
|
use User\Api\PromoteApi;
|
|
use Base\Repository\PromoteRepository;
|
|
use Base\Repository\SpendRepository;
|
|
use Base\Repository\UserRepository;
|
|
use Base\Service\PromoteService;
|
|
use Base\Facade\Request;
|
|
use Base\Service\ApplyService;
|
|
use Base\Service\PromoteCoinRecordService;
|
|
use Base\Service\PromoteCoinTransferLogService;
|
|
|
|
/**
|
|
* @author elf<360197197@qq.com>
|
|
*/
|
|
class DownloadController extends BaseController {
|
|
public $payWay = [
|
|
-1 => '绑币',
|
|
0 => '平台币',
|
|
1 => '支付宝',
|
|
3 => '微信',
|
|
5 => '聚宝云',
|
|
6 => '竣付通',
|
|
7 => '苹果支付',
|
|
8 => '金猪支付',
|
|
9 => '双乾支付',
|
|
15 => '双乾支付-快捷'
|
|
];
|
|
|
|
//提现状态
|
|
public static $withdrawStatus = [
|
|
-1 => '审核未通过',
|
|
0 => '待审核',
|
|
1 => '汇款中',
|
|
2 => '已汇款',
|
|
];
|
|
|
|
public static $payStatus = [
|
|
0 => '下单未支付',
|
|
1 => '充值成功',
|
|
];
|
|
|
|
/**
|
|
* excel
|
|
*/
|
|
public function exportExcel($expTitle, $expCellName, $expTableData,$id)
|
|
{
|
|
$xlsTitle = iconv('utf-8', 'gb2312', $expTitle);//文件名称
|
|
// $fileName = session('user_auth.username').date('_YmdHis');//or $xlsTitle 文件名称可根据自己情况设定
|
|
$fileName = $expTitle.'_'.date('YmdHis');
|
|
$cellNum = count($expCellName);
|
|
$dataNum = count($expTableData);
|
|
Vendor("PHPExcel.PHPExcel");
|
|
|
|
$objPHPExcel = new \PHPExcel();
|
|
$cellName = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA', 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN', 'AO', 'AP', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AV', 'AW', 'AX', 'AY', 'AZ');
|
|
$objPHPExcel->getActiveSheet(0)->mergeCells('A1:' . $cellName[$cellNum - 1] . '1');//合并单元格
|
|
$objPHPExcel->setActiveSheetIndex(0)->setCellValue('A1', $expTitle);
|
|
$objPHPExcel->setActiveSheetIndex(0)->getStyle('A1')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
|
|
for ($i = 0; $i < $cellNum; $i++) {
|
|
$objPHPExcel->setActiveSheetIndex(0)->setCellValue($cellName[$i] . '2', $expCellName[$i][1]);
|
|
}
|
|
for ($i = 0; $i < $dataNum; $i++) {
|
|
for ($j = 0; $j < $cellNum; $j++) {
|
|
$objPHPExcel->getActiveSheet(0)->setCellValue($cellName[$j] . ($i + 3), $expTableData[$i][$expCellName[$j][0]]);
|
|
}
|
|
}
|
|
|
|
ob_end_clean();//清除缓冲区,避免乱码
|
|
header('pragma:public');
|
|
header('Content-type:application/vnd.ms-excel;charset=utf-8;name="' . $xlsTitle . '.xls"');
|
|
header("Content-Disposition:attachment;filename=$fileName.xls");//attachment新窗口打印inline本窗口打印
|
|
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
|
$objWriter->save('php://output');
|
|
$this->backSuccessExport($id);
|
|
exit;
|
|
}
|
|
|
|
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();
|
|
$childPromoteIds = '';
|
|
if(empty($res)) {
|
|
$map['tab_downloadlog.promote_id'] = PID;
|
|
}else {
|
|
foreach ($res as $rsKey => $rsValue) {
|
|
$id = $rsValue['id'];
|
|
$childPromoteIds .= $id.',';
|
|
}
|
|
$childPromoteIds = rtrim($childPromoteIds, ',');
|
|
$childPromoteIds .= ',' . PID;
|
|
$map['tab_downloadlog.promote_id'] = ['in', $childPromoteIds];
|
|
}
|
|
$levelPromote = $this->getLevelPromote();
|
|
$queryPromote = $this->getQueryPromote($levelPromote);
|
|
$map2[] = [
|
|
'_logic' => 'or',
|
|
'id' => $queryPromote['id'],
|
|
'chain' => ['like', $queryPromote['chain'] . $queryPromote['id'] . '/%']
|
|
];
|
|
$childPromoteIds = M('promote', 'tab_')->where($map2)->getField('id', true);
|
|
|
|
$map = [];
|
|
if (count($childPromoteIds) > 0) {
|
|
$map = ['promote_id' => ['in', $childPromoteIds]];
|
|
} else {
|
|
$map['_string'] = '1<>1';
|
|
}
|
|
if(!empty($_REQUEST['dataname'])) {
|
|
$map['dataname'] = ['like','%'.$_REQUEST['dataname'].'%'];
|
|
}
|
|
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));
|
|
|
|
}
|
|
$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();
|
|
foreach ($rs as $key => $value) {
|
|
$pid = intval($value['promote_id']);
|
|
$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();
|
|
$promoteNameArr[$key1]['name'] = $promoteName['real_name'];
|
|
$promoteNameArr[$key1]['promote_id'] = $value1;
|
|
}
|
|
/* 查询记录总数 */
|
|
$count = M("downloadlog", "tab_")
|
|
->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'];
|
|
$parameter['logid'] = $_REQUEST['logid'];
|
|
$parameter['begtime'] = I('begtime');
|
|
$parameter['endtime'] = I('endtime');
|
|
$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('data',$rs);
|
|
|
|
$this->assign('promoteNameArr',$promoteNameArr);
|
|
return $this->display();
|
|
}
|
|
|
|
/**
|
|
* 每日概况
|
|
* @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');
|
|
$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;
|
|
$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();
|
|
$childPromoteIds = '';
|
|
if(empty($rs)) {
|
|
$map['tab_test_resource.promote_id'] = PID;
|
|
}else {
|
|
foreach ($rs as $rsKey => $rsValue) {
|
|
$id = $rsValue['id'];
|
|
$childPromoteIds .= $id.',';
|
|
}
|
|
$childPromoteIds = rtrim($childPromoteIds, ',');
|
|
$childPromoteIds .= ',' . PID;
|
|
$map['promote_id'] = ['in', $childPromoteIds];
|
|
}
|
|
|
|
$ownId = intval(I('own_id'), 0);//本账号
|
|
if ($ownId) {
|
|
$map['promote_id'] = $queryPromote['id'];
|
|
} else {
|
|
$map2['chain'] = ['like', $queryPromote['chain'] . $queryPromote['id'] . '/%'];
|
|
$ids = M('promote', 'tab_')->where($map2)->getField('id', true);
|
|
$ids[] = $queryPromote['id'];
|
|
$ids = implode(',', $ids);
|
|
$map['promote_id'] = $ids;
|
|
}
|
|
if ($serverId > 0) {
|
|
$map['server_id'] = $serverId;
|
|
}
|
|
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;
|
|
}
|
|
|
|
$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() {
|
|
$withdrawNumber = I('widthdraw_number', '');
|
|
$initBegTime = I('begtime', '');
|
|
$initEndTime = I('endtime', '');
|
|
$begTime = strtotime(date('Y-m-d', strtotime($initBegTime)));
|
|
$endTime = strtotime(date('Y-m-d', strtotime($initEndTime))) + 3600 * 24;
|
|
$status = '';
|
|
$map['promote_id'] = $this->loginPromote['id'];
|
|
if (!empty($withdrawNumber)) {
|
|
$map['widthdraw_number'] = $withdrawNumber;
|
|
}
|
|
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])) {
|
|
$this->error('参数异常');
|
|
}
|
|
|
|
$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() {
|
|
$withdrawId = intval(I('get.id', 0));
|
|
if ($withdrawId == 0) {
|
|
$this->error('参数异常');
|
|
}
|
|
$withdraw = M('withdraw', 'tab_')->field('promote_id,status')->where(array('id' => $withdrawId))->find();
|
|
if (empty($withdraw) || $withdraw['promote_id'] != $this->loginPromote['id']) {
|
|
$this->error('参数异常');
|
|
}
|
|
$gameId = intval(I('game_id', 0));
|
|
$userAccount = I('user_account', '');
|
|
$payOrderNumber = I('pay_order_number', '');
|
|
$map['withdraw_id'] = $withdrawId;
|
|
if (!empty($gameId)) {
|
|
$map['game_id'] = $gameId;
|
|
}
|
|
if (!empty($userAccount)) {
|
|
$map['user_account'] = $userAccount;
|
|
}
|
|
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())));
|
|
$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 = $endTime + 3600 * 24;
|
|
$map['chain'] = ['like', $this->loginPromote['chain'] . $this->loginPromote['id'] . '/%'];
|
|
$promoteIds = M('promote', 'tab_')->where($map)->getField('id', true);
|
|
$promoteIds[] = $this->loginPromote['id'];
|
|
$promoteIds = implode(',', $promoteIds);
|
|
$map = [];
|
|
$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() {
|
|
$payOrderNumber = 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);
|
|
$gameId = intval(I('game_id', 0));
|
|
$status = intval(I('status', 0));
|
|
$map['chain'] = ['like', $this->loginPromote['chain'] . $this->loginPromote['id'] . '/%'];
|
|
$ids = M('promote', 'tab_')->where($map)->getField('id', true);
|
|
$ids[] = $this->loginPromote['id'];
|
|
$ids = implode(',', $ids);
|
|
$map = [];
|
|
$map['promote_id'] = ['in', $ids];
|
|
$map['pay_status'] = 1;
|
|
if (!empty($payOrderNumber)) {
|
|
$map['pay_order_number'] = $payOrderNumber;
|
|
}
|
|
if (!empty($gameId)) {
|
|
$map['game_id'] = $gameId;
|
|
}
|
|
if (!empty($begTime) && empty($endTime)) {
|
|
$map['pay_time'] = ['egt', $begTime];
|
|
} elseif (empty($begTime) && !empty($endTime)) {
|
|
$map['pay_time'] = ['elt', $endTime + 86399];
|
|
} elseif (!empty($begTime) && !empty($endTime)) {
|
|
$map['pay_time'] = ['between', [$begTime, $endTime + 86399]];
|
|
}
|
|
|
|
if (isset($_GET['status'])) {
|
|
if ($status == -2) {
|
|
$map['selle_status'] = 0;
|
|
} else {
|
|
$withdrawMap['promote_id'] = $this->loginPromote['id'];
|
|
$withdrawMap['status'] = $status;
|
|
$withdrawIds = M('withdraw', 'tab_')->where($withdrawMap)->getField('id', true);
|
|
|
|
if (empty($withdrawIds)) {
|
|
$map = '1 = 2';
|
|
} else {
|
|
$map['withdraw_id'] = ['in', $withdrawIds];
|
|
}
|
|
}
|
|
}
|
|
$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'));
|
|
|
|
}
|
|
/**
|
|
* 测试资源
|
|
* @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('server_name'))){
|
|
$map['server_name']=I('server_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($_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);
|
|
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 = '';
|
|
$map['tab_test_resource.promote_id'] = PID;
|
|
|
|
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('server_name'))){
|
|
$map['server_name']=I('server_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($_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);
|
|
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 = '';
|
|
$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();
|
|
$childPromoteIds = '';
|
|
if(empty($rs)) {
|
|
$map['tab_coin_pay_order.promote_id'] = PID;
|
|
}else {
|
|
foreach ($rs as $rsKey => $rsValue) {
|
|
$id = $rsValue['id'];
|
|
$childPromoteIds .= $id.',';
|
|
}
|
|
$childPromoteIds = rtrim($childPromoteIds, ',');
|
|
$childPromoteIds .= ',' . PID;
|
|
$map['tab_coin_pay_order.promote_id'] = ['in', $childPromoteIds];
|
|
}
|
|
$map['is_del'] = 0;
|
|
$start_time = strtotime(I('time_start'));
|
|
$end_time = strtotime(I('time_end'));
|
|
$order_number = I("order_number");
|
|
$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);
|
|
$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($levelPromote)) {
|
|
array_push($ids,PID);
|
|
|
|
}
|
|
array_push($ids,$queryPromote['id']);
|
|
if (!empty($ids)) {
|
|
$pro = "";
|
|
foreach ($ids as $value1) {
|
|
$pid = $value1;
|
|
$pro .= $pid.',';
|
|
}
|
|
$pro = rtrim($pro,',');
|
|
$map['promote_id'] = ['in',$pro];
|
|
|
|
}else {
|
|
$map['_string'] = '1<>1';
|
|
}
|
|
|
|
$searchGameName = '';
|
|
$searchServerName = '';
|
|
if ($gameId > 0) {
|
|
$map['game_id'] = $gameId;
|
|
$searchGameName = M('game', 'tab_')->where(['id' => $gameId])->getField('game_name');
|
|
}
|
|
if ($serverId > 0) {
|
|
$map['server_id'] = $serverId;
|
|
$searchServerName = M('server', 'tab_')->where(['server_id' => $serverId])->getField('server_name');
|
|
}
|
|
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() {
|
|
if (empty(I('begtime')) || empty(I('endtime'))) {
|
|
$this->error('请选择起止时间');
|
|
}
|
|
$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();
|
|
$childPromoteIds = '';
|
|
if(empty($rs)) {
|
|
$map['tab_user.promote_id'] = PID;
|
|
}else {
|
|
foreach ($rs as $rsKey => $rsValue) {
|
|
$id = $rsValue['id'];
|
|
$childPromoteIds .= $id.',';
|
|
}
|
|
$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($levelPromote)) {
|
|
array_push($ids,PID);
|
|
|
|
}
|
|
array_push($ids,$queryPromote['id']);
|
|
if (!empty($ids)) {
|
|
$map['tab_user.promote_id'] = ['in',$ids];
|
|
|
|
}else {
|
|
$map['_string'] = '1<>1';
|
|
}
|
|
|
|
if (!empty(I('own_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'))) {
|
|
$map['tab_user.register_time'] = ['elt', strtotime(I('endtime')) + 86399];
|
|
} elseif (!empty(I('begtime')) && !empty(I('endtime'))) {
|
|
$map['tab_user.register_time'] = ['between', [strtotime(I('begtime')), strtotime(I('endtime')) + 86399]];
|
|
}
|
|
|
|
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() {
|
|
$promoteType = intval(I('promote_type', 0));
|
|
$loginer = $this->getLoginPromote();
|
|
$map1['chain'] = ['like','%'.'/'.PID.'/'.'%'];
|
|
$rs = M('promote','tab_')->where($map1)->field('id,account,nickname')->select();
|
|
$childPromoteIds = '';
|
|
if(empty($rs)) {
|
|
$map['id'] = PID;
|
|
}else {
|
|
foreach ($rs as $rsKey => $rsValue) {
|
|
$id = $rsValue['id'];
|
|
$childPromoteIds .= $id.',';
|
|
}
|
|
$childPromoteIds = rtrim($childPromoteIds, ',');
|
|
$childPromoteIds .= ',' . PID;
|
|
$map['id'] = ['in', $childPromoteIds];
|
|
}
|
|
|
|
if ($promoteType == 0) {
|
|
$map['level'] = 2;
|
|
} elseif ($promoteType == 1) {
|
|
$map['level'] = 3;
|
|
} elseif ($promoteType == 2) {
|
|
$map['level'] = 4;
|
|
}
|
|
if(I('account', '')) {
|
|
$map['account'] = ['like', '%' . I('account', '') . '%'];
|
|
}
|
|
if (I('mobile', '')) {
|
|
$map['mobile_phone'] = ['like', '%' . I('mobile', '') . '%'];
|
|
}
|
|
if (I('idcard', '')) {
|
|
$map['idcard'] = ['like', '%' . I('idcard', '') . '%'];
|
|
}
|
|
if (I('real_name', '')) {
|
|
$map['real_name'] = ['like', '%' . I('real_name', '') . '%'];
|
|
}
|
|
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);
|
|
if (!$res) {
|
|
// $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res));
|
|
$this->error('添加下载失败');
|
|
}
|
|
$this->success('添加下载成功',U('listsIndex'));
|
|
|
|
}
|
|
|
|
/**
|
|
* 平台币转移
|
|
* @author sunke
|
|
*/
|
|
public function coinrecord_data_export() {
|
|
$gameId = I('game_id', -1);
|
|
$account = I('account', '');
|
|
$sn = I('sn', '');
|
|
$startTime = I('time_end', '');
|
|
$endTime = I('time_start', '');
|
|
$loginPromote = $this->getLoginPromote();
|
|
$map = ['promote_id' => $loginPromote['id']];
|
|
if ($startTime != '' || $endTime != '') {
|
|
if ($startTime != '') {
|
|
$map['create_time'] = ['egt', strtotime($startTime. ' 00:00:00')];
|
|
}
|
|
if ($endTime != '') {
|
|
$map['create_time'] = ['elt', strtotime($endTime. ' 23:59:59')];
|
|
}
|
|
}
|
|
if($sn) {
|
|
$map['sn'] = $sn;
|
|
}
|
|
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']).',';
|
|
}
|
|
$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);
|
|
$subType = I('sub_type', 0);
|
|
$targetType = I('target_type', '');
|
|
$startTime = I('start_time', '');
|
|
$endTime = I('end_time', '');
|
|
$gameId = I('game_id', 0);
|
|
$loginPromote = $this->getLoginPromote();
|
|
$map = [];
|
|
$map['game_id'] = $gameId;
|
|
$map['promote_id'] = $loginPromote['id'];
|
|
if ($type != 0) {
|
|
$map['type'] = $type;
|
|
}
|
|
if ($subType != 0) {
|
|
$map['sub_type'] = $subType;
|
|
}
|
|
if ($targetType != '') {
|
|
$targetTypeRow = explode('_', $targetType);
|
|
$map['target_type'] = $targetTypeRow[0];
|
|
if (count($targetTypeRow) == 2) {
|
|
$map['target_level'] = $targetTypeRow[1];
|
|
}
|
|
}
|
|
|
|
if ($startTime != '' || $endTime != '') {
|
|
if ($startTime != '') {
|
|
$map['create_time'] = ['egt', strtotime($startTime. ' 00:00:00')];
|
|
}
|
|
if ($endTime != '') {
|
|
$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);
|
|
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();
|
|
$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];
|
|
}
|
|
// var_dump($map);
|
|
$game_id = I('game_id');
|
|
if(!empty($game_id)) {
|
|
$map['game_id'] = $game_id;
|
|
}
|
|
$status = I("status");
|
|
if(!empty($status)) {
|
|
$map['status'] = $status;
|
|
}
|
|
$coin_type = I('coin_type');
|
|
if(!empty($coin_type)) {
|
|
switch ($coin_type) {
|
|
case 1:
|
|
$map['game_id'] = 0;
|
|
break;
|
|
case 2:
|
|
$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);
|
|
if (!$res) {
|
|
// $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res));
|
|
$this->error('添加下载失败');
|
|
}
|
|
$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');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)) {
|
|
$gameId1 = [-100];
|
|
}
|
|
$map['game_id'] = ['in', $gameId1];
|
|
}
|
|
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.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'));
|
|
}
|
|
|
|
public function promotelogs_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['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['pid'] = PID;
|
|
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() {
|
|
$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();
|
|
$childPromoteIds = '';
|
|
if(empty($rs)) {
|
|
$map['tab_spend.promote_id'] = PID;
|
|
}else {
|
|
foreach ($rs as $rsKey => $rsValue) {
|
|
$id = $rsValue['id'];
|
|
$childPromoteIds .= $id.',';
|
|
}
|
|
$childPromoteIds = rtrim($childPromoteIds, ',');
|
|
$childPromoteIds .= ',' . PID;
|
|
$map['tab_spend.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_spend.promote_id'] = ['in',$ids];
|
|
|
|
}else {
|
|
$map['_string'] = '1<>1';
|
|
}
|
|
|
|
if (!empty(I('own_id'))) {
|
|
$map['tab_spend.promote_id'] = $queryPromote['id'];//本账号
|
|
}
|
|
|
|
|
|
|
|
if (!empty(I('begtime')) && empty(I('endtime'))) {
|
|
$map['tab_spend.pay_time'] = ['egt', strtotime(I('begtime'))];
|
|
} elseif (empty(I('begtime')) && !empty(I('endtime'))) {
|
|
$map['tab_spend.pay_time'] = ['elt', strtotime(I('endtime')) + 86399];
|
|
} elseif (!empty(I('begtime')) && !empty(I('endtime'))) {
|
|
$map['tab_spend.pay_time'] = ['between', [strtotime(I('begtime')), strtotime(I('endtime')) + 86399]];
|
|
}else {
|
|
$nowTime = date('Y-m-d');
|
|
$initBegTime = date('Y-m-d', strtotime('-6 day', strtotime($nowTime)));
|
|
$initEndTime = date('Y-m-d');
|
|
$initBegTime = strtotime($initBegTime);
|
|
$initEndTime = strtotime($initEndTime);
|
|
$map['tab_spend.pay_time'] = ['between',[$initBegTime,$initEndTime]];
|
|
}
|
|
|
|
empty(I('relation_game_id')) || $map['tab_game.relation_game_id'] = I('relation_game_id');
|
|
empty(I('sdk_version')) || $map['tab_game.sdk_version'] = I('sdk_version');
|
|
empty(I('server_id')) || $map['tab_spend.server_id'] = I('server_id');
|
|
empty(I('game_player_name')) || $map['tab_spend.game_player_name'] = ['like', '%' . I('game_player_name') . '%'];
|
|
empty(I('user_account')) || $map['tab_spend.user_account'] = ['like', '%' . I('user_account') . '%'];
|
|
empty(I('pay_order_number')) || $map['tab_spend.pay_order_number'] = I('pay_order_number');
|
|
// $map['tab_spend.pay_status'] = 1;
|
|
// $map['tab_spend.is_check'] = ['neq', 2];
|
|
if (isset($_REQUEST['pay_status']) && $_REQUEST['pay_status'] !== '') {
|
|
$payStatus = intval(I('pay_status'));
|
|
|
|
if (in_array($payStatus, array_keys(self::$payStatus))) {
|
|
$map['tab_spend.pay_status'] = $payStatus + 2;
|
|
}
|
|
}
|
|
$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() {
|
|
$gameId = I('relation_game_id', 0);
|
|
$serverId = I('server_id', 0);
|
|
$isSelf = I('is_self', 0);
|
|
$roleName = I('role_name', '');
|
|
$userAccount = I('user_account', '');
|
|
$promoteId = I('promote_id', 0);
|
|
$sdkVersion = I('sdk_version', 0);
|
|
$headmanPromoteId = I('headman_promote_id', 0);
|
|
$costBegin = I('cost_begin', ''); //充值总额范围
|
|
$costEnd = I('cost_end', '');
|
|
$nowTime = date('Y-m-d');
|
|
$initBegTime = date('Y-m-d', strtotime('-7 day', strtotime($nowTime)));
|
|
$initBegTime = empty(I('begtime')) ? $initBegTime : I('begtime');
|
|
$initEndTime = $nowTime;
|
|
$initEndTime = empty(I('endtime')) ? $initEndTime : I('endtime');
|
|
$begTime = strtotime($initBegTime);
|
|
$endTime = strtotime($initEndTime);
|
|
$endTime += 3600 * 24;
|
|
|
|
$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['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;
|
|
}
|
|
if ($sdkVersion != 0) {
|
|
$gameMap['sdk_version'] = $sdkVersion;
|
|
}
|
|
$gameId1 = M('game', 'tab_')->where($gameMap)->getField('id', true);
|
|
if(empty($gameId1)) {
|
|
$gameId1 = [-100];
|
|
}
|
|
$map['game_id'] = ['in', $gameId1];
|
|
$subMap['game_id'] = ['in', $gameId1];
|
|
}
|
|
if ($serverId != 0) {
|
|
$map['server_id'] = $serverId;
|
|
}
|
|
if ($roleName != '') {
|
|
$map['role_name'] = ['like', '%' . $roleName . '%'];
|
|
}
|
|
if ($userAccount != '') {
|
|
$map['user_account'] = ['like', '%' . $userAccount . '%'];
|
|
}
|
|
if ($sdkVersion != 0) {
|
|
$map['sdk_version'] = $sdkVersion;
|
|
}
|
|
if ($isSelf) {
|
|
$map['promote_id'] = $queryPromote['id'];//本账号
|
|
} else {
|
|
if ($headmanPromoteId != 0) {
|
|
$map['promote_id'] = $headmanPromoteId;
|
|
}
|
|
if ($promoteId != 0) {
|
|
$map['promote_id'] = $promoteId;
|
|
}
|
|
}
|
|
|
|
if($costBegin) {
|
|
$map['costbegin'] = $costBegin;
|
|
}else {
|
|
$map['costbegin'] = "";
|
|
}
|
|
if($costEnd) {
|
|
$map['costend'] = $costEnd;
|
|
}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'));
|
|
|
|
}
|
|
|
|
/*推广员指标查看详情 */
|
|
|
|
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);
|
|
$relationGameId = I('relation_game_id', 0);
|
|
$sdkVersion = I('sdk_version', 0);
|
|
$serverId = I('server_id', 0);
|
|
$roleLevelBegin = intval(I('level_begin', 0));
|
|
$roleLevelEnd = intval(I('level_end', 0));
|
|
$promoteId = I('promote_id', 0);
|
|
$isSelf = I('is_self', 0);
|
|
|
|
if ($relationGameId != 0 || $sdkVersion != 0) {
|
|
$gameIds = gameSearch($relationGameId, $sdkVersion);
|
|
$map['game_id'] = ['in', $gameIds];
|
|
}
|
|
if ($serverId != 0) {
|
|
$map['server_id'] = $serverId;
|
|
}
|
|
if ($roleLevelBegin != 0 && $roleLevelEnd == 0) {
|
|
$map['role_level'] = ['egt', $roleLevelBegin];
|
|
} elseif ($roleLevelEnd != 0 && $roleLevelBegin == 0) {
|
|
$map['role_level'] = ['elt', $roleLevelEnd];
|
|
} elseif ($roleLevelEnd != 0 && $roleLevelBegin != 0) {
|
|
$map['role_level'] = ['between', [$roleLevelBegin, $roleLevelEnd]];
|
|
}
|
|
list($beginTime, $endTime) = $this->getBetweenTime($time);
|
|
$map['create_time'] = ['between', [$beginTime, $endTime]];
|
|
|
|
if ($promoteId) {
|
|
if ($isSelf) {
|
|
$map['promote_id'] = $promoteId;
|
|
} else {
|
|
$promote = M('promote', 'tab_')->field(['id', 'chain'])->where(array('id' => $promoteId))->find();
|
|
$promoteMap['chain'] = ['like', "{$promote['chain']}{$promote['id']}/%"];
|
|
$promoteIds = M('promote', 'tab_')->where($promoteMap)->getField('id', true);
|
|
$promoteIds[] = $promoteId;
|
|
$map['promote_id'] = ['in', $promoteIds];
|
|
}
|
|
} else {
|
|
$map = '1 = 2';
|
|
}
|
|
|
|
// $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);
|
|
if (!$res) {
|
|
$this->error('添加下载失败');
|
|
}
|
|
$this->success('添加下载成功',U('listsIndex'));
|
|
}
|
|
|
|
/*推广指标首页导出*/
|
|
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);
|
|
if (!empty($time)) {
|
|
$defaultTime = $time;
|
|
}
|
|
$sdkVersion = I('sdk_version', 0);
|
|
$relationGameId = I('relation_game_id', 0);
|
|
$serverId = I('server_id', 0);
|
|
$parentId = I('parent_id', 0);
|
|
$promoteId = I('promote_id', 0);
|
|
$levelBegin = I('level_begin', '');
|
|
$levelEnd = I('level_end', '');
|
|
$prevParentId = 0;
|
|
|
|
$promoteService = new PromoteService();
|
|
$loginPromote = $this->getLoginPromote();
|
|
$parent = null;
|
|
if ($parentId > 0) {
|
|
$parent = M('promote', 'tab_')->where(['id' => $parentId])->find();
|
|
$currentDisplay = $promoteService->getLevelName($parent['level']) . '推广';
|
|
$prevParentId = $parent['parent_id'] == $loginPromote['parent_id'] ? 0 : $parent['parent_id'];
|
|
} else {
|
|
$parent = $loginPromote;
|
|
$currentDisplay = '自己';
|
|
}
|
|
$map = ['parent_id' => $parent['id']];
|
|
if ($promoteId > 0) {
|
|
$map['id'] = $promoteId;
|
|
}
|
|
$data = M('promote', 'tab_')->field(['id', 'account', 'real_name', 'level'])->where($map)->select();
|
|
$ids = array_column($data, 'id');
|
|
|
|
$rows = [];
|
|
if (count($ids) > 0) {
|
|
$rows = M('promote', 'tab_')
|
|
->field(['id', 'chain'])
|
|
->where(['chain' => ['like', [$parent['chain'] . $parent['id'] . '/%']], 'level' => ['gt', $parent['level'] + 1]])
|
|
->select();
|
|
}
|
|
$basicPromotes = [];
|
|
foreach ($ids as $id) {
|
|
foreach ($rows as $row) {
|
|
$needChain = $parent['chain'] . $parent['id'] . '/' . $id . '/';
|
|
if (strpos($row['chain'], $needChain) !== false) {
|
|
$basicPromotes[$row['id']] = $id;
|
|
}
|
|
}
|
|
}
|
|
$map = [
|
|
'isContainSubs' => true,
|
|
'basicPromotes' => json_encode($basicPromotes,FALSE),
|
|
];
|
|
$map['promotes'] = json_encode($data,FALSE);
|
|
$map['parentsinfo'] = json_encode($parent,FALSE);;
|
|
$map['currentDisplay'] = $currentDisplay;
|
|
$map['ids'] = $ids;
|
|
if ($relationGameId != 0 || $sdkVersion != 0) {
|
|
$gameIds = gameSearch($relationGameId, $sdkVersion);
|
|
$map['game_id'] = ['in', $gameIds];
|
|
}
|
|
if ($serverId > 0) {
|
|
$map['server_id'] = $serverId;
|
|
}
|
|
$where = $map;
|
|
if ($sdkVersion != 0) {
|
|
$map['sdk_version'] = $sdkVersion;
|
|
}
|
|
if ($levelBegin !== '' || $levelEnd !== '') {
|
|
if ($levelBegin !== '' && $levelEnd !== '') {
|
|
$levelBegin = intval($levelBegin);
|
|
$levelEnd = intval($levelEnd);
|
|
if ($levelBegin > $levelEnd) {
|
|
$this->error('角色等级范围错误');
|
|
}
|
|
$map['role_level'] = ['between', [$levelBegin, $levelEnd]];
|
|
} elseif ($levelBegin !== '' && $levelEnd === '') {
|
|
$levelBegin = intval($levelBegin);
|
|
$map['role_level'] = ['egt', $levelBegin];
|
|
} elseif ($levelBegin === '' && $levelEnd !== '') {
|
|
$levelEnd = intval($levelEnd);
|
|
$map['role_level'] = ['elt', $levelEnd];
|
|
}
|
|
}
|
|
list($beginTime, $endTime) = $this->getBetweenTime($time);
|
|
$map['begin_time'] = $beginTime;
|
|
$map['end_time'] = $endTime;
|
|
$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);
|
|
if (!$res) {
|
|
// $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);
|
|
$serverId = I('server_id', 0);
|
|
$parentId = I('parent_id', 0);
|
|
$promoteId = I('promote_id', 0);
|
|
$status = I('status', 0);
|
|
$searchLevel = 0;
|
|
$searchLevelName = '';
|
|
$currentDisplay = '';
|
|
$prevParentId = 0;
|
|
$promoteService = new PromoteService();
|
|
$loginPromote = $this->getLoginPromote();
|
|
$parent = null;
|
|
if ($parentId > 0) {
|
|
$parent = M('promote', 'tab_')->where(['id' => $parentId])->find();
|
|
$currentDisplay = $promoteService->getLevelName($parent['level']) . '推广';
|
|
$prevParentId = $parent['parent_id'] == $loginPromote['parent_id'] ? 0 : $parent['parent_id'];
|
|
} else {
|
|
$parent = $loginPromote;
|
|
$currentDisplay = '自己';
|
|
}
|
|
$map = ['parent_id' => $parent['id']];
|
|
if ($promoteId > 0) {
|
|
$map['id'] = $promoteId;
|
|
}
|
|
$data = M('promote', 'tab_')->field(['id', 'account', 'real_name', 'level', 'chain'])->where($map)->select();
|
|
$ids = array_column($data, 'id');
|
|
$rows = [];
|
|
if (count($ids) > 0) {
|
|
$rows = M('promote', 'tab_')
|
|
->field(['id', 'chain'])
|
|
->where(['chain' => ['like', [$parent['chain'] . $parent['id'] . '/%']], 'level' => ['gt', $parent['level'] + 1]])
|
|
->select();
|
|
}
|
|
$basicPromotes = [];
|
|
|
|
$basicPromotes = [];
|
|
foreach ($ids as $id) {
|
|
foreach ($rows as $row) {
|
|
$needChain = $parent['chain'] . $parent['id'] . '/' . $id . '/';
|
|
if (strpos($row['chain'], $needChain) !== false) {
|
|
$basicPromotes[$row['id']] = $id;
|
|
}
|
|
}
|
|
}
|
|
$map = [
|
|
'isContainSubs' => true,
|
|
'basicPromotes' => json_encode($basicPromotes,FALSE),
|
|
];
|
|
$map['promotes'] = json_encode($data,FALSE);
|
|
$map['parentsinfo'] = json_encode($parent,FALSE);;
|
|
$map['currentDisplay'] = $currentDisplay;
|
|
$map['ids'] = $ids;
|
|
if ($gameId != 0 || $sdkVersion != 0) {
|
|
if ($gameId != 0) {
|
|
$gameMap['relation_game_id'] = $gameId;
|
|
}
|
|
if ($sdkVersion != 0) {
|
|
$gameMap['sdk_version'] = $sdkVersion;
|
|
}
|
|
$gameId1 = M('game', 'tab_')->where($gameMap)->getField('id', true);
|
|
if(empty($gameId1)) {
|
|
$gameId1 = [-100];
|
|
}
|
|
$map['game_id'] = ['in', $gameId1];
|
|
}
|
|
if ($serverId > 0) {
|
|
$map['server_id'] = $serverId;
|
|
}
|
|
if ($sdkVersion > 0) {
|
|
$map['sdk_version'] = $sdkVersion;
|
|
}
|
|
if ($status > 0) {
|
|
$map['lock_status'] = $status;
|
|
}
|
|
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'));
|
|
|
|
}
|
|
//玩家角色
|
|
public function userRoles_data_export() {
|
|
$gameId = I('relation_game_id', 0);
|
|
$serverId = I('server_id', 0);
|
|
$isSelf = I('is_self', 0);
|
|
$roleName = I('role_name', '');
|
|
$userAccount = I('user_account', '');
|
|
$promoteId = I('promote_id', 0);
|
|
$sdkVersion = I('sdk_version', 0);
|
|
$roleLevelBegin = intval(I('role_level_begin', 0));
|
|
$roleLevelEnd = intval(I('role_level_end', 0));
|
|
$headmanPromoteId = I('headman_promote_id', 0);
|
|
$playTime = I('create_time', '');
|
|
$promote = $this->getLoginPromote();
|
|
if (empty($playTime)) {
|
|
$this->error('请选择创建时间');
|
|
}
|
|
$map1['chain'] = ['like','%'.'/'.PID.'/'.'%'];
|
|
$rs = M('promote','tab_')->where($map1)->field('id,account,nickname')->select();
|
|
$childPromoteIds = '';
|
|
if(empty($rs)) {
|
|
$map['tab_user.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($levelPromote)) {
|
|
array_push($ids,PID);
|
|
|
|
}
|
|
//array_push($ids,$queryPromote['id']);
|
|
if (!empty($ids)) {
|
|
$map['promote_id'] = ['in',$ids];
|
|
|
|
}else {
|
|
$map['_string'] = '1<>1';
|
|
}
|
|
|
|
if ($gameId != 0 || $sdkVersion != 0) {
|
|
if ($gameId != 0) {
|
|
$gameMap['relation_game_id'] = $gameId;
|
|
}
|
|
if ($sdkVersion != 0) {
|
|
$gameMap['sdk_version'] = $sdkVersion;
|
|
}
|
|
$gameId1 = M('game', 'tab_')->where($gameMap)->getField('id', true);
|
|
if(empty($gameId1)) {
|
|
$gameId1 = [-100];
|
|
}
|
|
$map['game_id'] = ['in', $gameId1];
|
|
}
|
|
if ($serverId != 0) {
|
|
$map['serverId'] = $serverId;
|
|
}
|
|
if ($roleName != '') {
|
|
$map['role_name'] = ['like', '%' . $roleName . '%'];
|
|
}
|
|
if ($userAccount != '') {
|
|
$map['user_account'] = ['like', '%' . $userAccount . '%'];
|
|
}
|
|
if ($sdkVersion != 0) {
|
|
$map['sdk_version'] = $sdkVersion;
|
|
}
|
|
if ($roleLevelBegin != 0 && $roleLevelEnd == 0) {
|
|
$map['role_level'] = ['egt', $roleLevelBegin];
|
|
} elseif ($roleLevelEnd != 0 && $roleLevelBegin == 0) {
|
|
$map['role_level'] = ['elt', $roleLevelEnd];
|
|
} elseif ($roleLevelEnd != 0 && $roleLevelBegin != 0) {
|
|
$map['role_level'] = ['between', [$roleLevelBegin, $roleLevelEnd]];
|
|
}
|
|
if ($playTime != '') {
|
|
$playTimeRow = explode(' 至 ', $playTime);
|
|
$playTimeBegin = 0;
|
|
$playTimeEnd = 0;
|
|
if (count($playTimeRow) == 2) {
|
|
$playTimeBegin = strtotime($playTimeRow[0] . ' 00:00:00');
|
|
$playTimeEnd = strtotime($playTimeRow[1] . ' 23:59:59');
|
|
} else {
|
|
$playTimeBegin = strtotime($playTimeRow[0] . ' 00:00:00');
|
|
$playTimeEnd = strtotime($playTimeRow[0] . ' 23:59:59');
|
|
}
|
|
if (($playTimeEnd - $playTimeBegin) > 31 * 24 * 3600) {
|
|
$this->error('时间范围不能超过31天');
|
|
}
|
|
$map['create_time'] = ['between', [$playTimeBegin, $playTimeEnd]];
|
|
}
|
|
if ($isSelf) {
|
|
$map['promote_id'] = $queryPromote['id'];
|
|
} else {
|
|
if ($headmanPromoteId != 0) {
|
|
$map['promote_id'] = $headmanPromoteId;
|
|
}
|
|
if ($promoteId != 0) {
|
|
$map['promote_id'] = $promoteId;
|
|
}
|
|
}
|
|
|
|
|
|
$conditions = json_encode($map,TRUE);
|
|
$addtime = time();
|
|
$data = [
|
|
'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);
|
|
if (!$res) {
|
|
// $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res));
|
|
$this->error('添加下载失败');
|
|
}
|
|
$this->success('添加下载成功',U('listsIndex'));
|
|
|
|
|
|
}
|
|
/**
|
|
* 数据汇总添加下载
|
|
* @author sunke
|
|
*/
|
|
public function summary_data_export() {
|
|
$promoteId = I('promote_id',0);
|
|
$teamLeaderId = I('team_leader_id',0);
|
|
$own_id = I('own_id',0);
|
|
$relation_game_id = I('relation_game_id',0);
|
|
$sdk_version = I('sdk_version',0);
|
|
$begtime = I('begtime','');
|
|
$endtime = I('endtime','');
|
|
// $childPromoteIds = getAllChildPromoteList(3);
|
|
$map1['chain'] = ['like','%'.'/'.PID.'/'.'%'];
|
|
$rs = M('promote','tab_')->where($map1)->field('id,account,nickname')->select();
|
|
$childPromoteIds = '';
|
|
if(empty($rs)) {
|
|
$map['tab_user.promote_id'] = PID;
|
|
}else {
|
|
foreach ($rs as $rsKey => $rsValue) {
|
|
$id = $rsValue['id'];
|
|
$childPromoteIds .= $id.',';
|
|
}
|
|
$childPromoteIds = rtrim($childPromoteIds, ',');
|
|
$childPromoteIds .= ',' . PID;
|
|
$map['tab_apply.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_apply.promote_id'] = ['in',$ids];
|
|
|
|
}else {
|
|
$map['_string'] = '1<>1';
|
|
}
|
|
|
|
if (!empty($own_id)) {
|
|
if (!empty($map['_string'])) {
|
|
unset($map['_string']);
|
|
}
|
|
|
|
$map['tab_apply.promote_id'] = $queryPromote['id'];//本账号
|
|
|
|
}
|
|
empty($relation_game_id) || $map['tab_game.relation_game_id'] = $relation_game_id;
|
|
empty($sdk_version) || $map['tab_game.sdk_version'] = $sdk_version;
|
|
if(empty($begtime) && empty($endtime)) {
|
|
$nowTime = date('Y-m-d');
|
|
$begtime1 = date('Y-m-d', strtotime('-6 day', strtotime($nowTime)));
|
|
$endtime1 = $nowTime;
|
|
$map["apply_time"] = ["between",[strtotime($begtime1),strtotime($endtime1) + 3600*24]];
|
|
}
|
|
if(!empty($begtime) && !empty($endtime)) {
|
|
$map["apply_time"] = ["between",[strtotime($begtime),strtotime($endtime) + 3600 * 24]];
|
|
}
|
|
$serverField = '';
|
|
$serverJoin = '';
|
|
if (!empty(I('server_id'))) {
|
|
$map['tab_server.id'] = I('server_id');
|
|
}
|
|
|
|
$conditions = json_encode($map,TRUE);
|
|
$addtime = time();
|
|
$data = [
|
|
'logid' => 'hz_'.time(),
|
|
'promote_id' => PID,
|
|
'type' => '/Home/Query/summary',
|
|
'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 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); //注册明细
|
|
break;
|
|
case "角色查询数据":
|
|
$this->userRolesExcelInfo($id,$map); //角色查询
|
|
break;
|
|
case "数据汇总数据":
|
|
$this->summaryExcelInfo($id,$map);
|
|
break;
|
|
case "充值明细数据":
|
|
$this->rechargeExcelInfo($id,$map);
|
|
break;
|
|
case "充值玩家数据":
|
|
$this->userRechargeExcelInfo($id,$map);
|
|
break;
|
|
case "推广员业绩":
|
|
$this->achievementExcelInfo($id,$map);
|
|
break;
|
|
case "渠道管理":
|
|
$this->childrenExcelInfo($id,$map);
|
|
break;
|
|
case "我的平台币":
|
|
$this->mycoinExcelInfo($id,$map);
|
|
break;
|
|
case "我的平台币明细";
|
|
$this->mycoinRecordExcelInfo($id, $map);
|
|
break;
|
|
case "平台币转移":
|
|
$this->coinrecordExcelInfo($id,$map);
|
|
break;
|
|
case "申请测试资源":
|
|
$this->testresourceExcelInfo($id,$map);
|
|
break;
|
|
case "申请测试资源记录":
|
|
$this->testresourcelistExcelInfo($id, $map);
|
|
break;
|
|
case "扶持号管理":
|
|
$this->supportNumberListExcelInfo($id, $map);
|
|
break;
|
|
case "ARPU统计":
|
|
$this->arpuExcelInfo($id,$map);
|
|
break;
|
|
case "每日概况":
|
|
$this->dailysummaryExcelInfo($id,$map);
|
|
break;
|
|
case "结算中心":
|
|
$this->financeindexExcelInfo($id,$map);
|
|
break;
|
|
case "结算明细":
|
|
$this->settlementExcelInfo($id,$map);
|
|
break;
|
|
case "提现记录":
|
|
$this->withdrawRecordExcelInfo($id,$map);
|
|
break;
|
|
case "提现明细":
|
|
$this->withdrawDtlExcelInfo($id,$map);
|
|
break;
|
|
case "汇款证明":
|
|
$this->remitCerDownLoad($id,$map);
|
|
break;
|
|
case "平台币充值":
|
|
$this->orderlistExcelInfo($id,$map);
|
|
break;
|
|
case "玩家行为日志":
|
|
$this->playactionExcelInfo($id,$map);
|
|
break;
|
|
case "推广员指标":
|
|
$this->promotequotaExcelInfo($id,$map);
|
|
break;
|
|
case "推广员详情":
|
|
$this->promotequotaDtlExcelInfo($id,$map);
|
|
break;
|
|
case "推广员操作日志":
|
|
$this->promotelogsExcelInfo($id,$map);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
public function promotelogsExcelInfo($id,$map) {
|
|
$xlsName = "推广员操作日志";
|
|
$xlsCell = array(
|
|
'位置',
|
|
'类型',
|
|
'操作人',
|
|
'时间',
|
|
'ip地址',
|
|
);
|
|
$pid = $map['pid'];
|
|
unset($map['pid']);
|
|
$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];
|
|
}
|
|
$records = M('promote_action_logs', 'tab_')->where($map)->order('create_time')->select();
|
|
$csvFileName = $xlsName.'.csv';
|
|
header('Content-Description: File Transfer');
|
|
header('Content-Type: application/vnd.ms-excel');
|
|
header('Content-Disposition: attachment; filename="'. $csvFileName .'"');
|
|
header('Expires: 0');
|
|
header('Cache-Control: must-revalidate');
|
|
header('Pragma: public');
|
|
$fp = fopen('php://output', 'a');//打开output流
|
|
mb_convert_variables('gb2312', 'UTF-8', $xlsCell);
|
|
fputcsv($fp, $xlsCell);//将数据格式化为CSV格式并写入到output流中
|
|
$accessNum = count($records)?:0 ;
|
|
$perSize = 5000;//每次查询的条数
|
|
$pages = ceil($accessNum / $perSize);
|
|
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);
|
|
}
|
|
unset($csvData);
|
|
ob_flush();
|
|
flush();
|
|
}
|
|
fclose($fp);
|
|
$this->backSuccessExport($id);
|
|
}
|
|
|
|
public function promotequotaDtlExcelInfo($id,$map) {
|
|
$xlsName = "推广员详情";
|
|
$xlsCell = array(
|
|
'玩家账号',
|
|
'推广账号',
|
|
'游戏名称',
|
|
'平台',
|
|
'游戏区服',
|
|
'角色名',
|
|
'等级',
|
|
'创建时间',
|
|
);
|
|
$records = recordPromoteLogs('数据管理','推广员详情导出');
|
|
$records = M('user_play_info', 'tab_')->where($map)->order('create_time desc')->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($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 = '';
|
|
|
|
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);
|
|
$csvData['promote_account'] = $dataValue['promote_account'];
|
|
$csvData['game_name'] = $dataValue['game_name'];
|
|
if($dataValue['sdk_version'] == 1) {
|
|
$csvData['sdk_version'] = "安卓版";
|
|
}
|
|
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']);
|
|
mb_convert_variables('GBK', 'UTF-8', $csvData);
|
|
fputcsv($fp, $csvData);
|
|
}
|
|
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','角色数量'),
|
|
);
|
|
$records = recordPromoteLogs('数据管理','推广员指标导出');
|
|
$params['isContainSubs'] = $map['isContainSubs'];
|
|
$params['basicPromotes'] = json_decode($map['basicPromotes'],TRUE);
|
|
$ids = $map['ids'];
|
|
$promotes = json_decode($map["promotes"],TRUE);
|
|
if(!empty($map['game_id'])) {
|
|
$params['game_id'] = $map["game_id"];
|
|
}
|
|
if(!empty($map['server_id'])) {
|
|
$params['server_id'] = $map["server_id"];
|
|
}
|
|
if(!empty($map['sdk_version'])) {
|
|
$params['sdk_version'] = $map["sdk_version"];
|
|
}
|
|
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);
|
|
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);
|
|
$records = [];
|
|
$promoteRepository = new PromoteRepository();
|
|
$createRoleCountList = $promoteRepository->getCreateRoleCountByIds($ids, $params);
|
|
$selfParams = $params;
|
|
$selfParams['isContainSubs'] = false;
|
|
$selfCreateRoleCountList = $promoteRepository->getCreateRoleCountByIds([$parent['id']], $selfParams);
|
|
$game = $this->getgame($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').'**',
|
|
'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) {
|
|
$id = $promote['id'];
|
|
$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').'**',
|
|
'level' => $promote['level'],
|
|
'game_name' => $game['game_name'],
|
|
'sdk_version_text' => $game['sdk_version_text'],
|
|
'server_name' => $game['server_name'],
|
|
'role_num' => $createRoleCountList[$id],
|
|
'current_display' => '',
|
|
];
|
|
$records[] = $record;
|
|
}
|
|
$xlsData = [];
|
|
foreach ($records as $key1 => $value1) {
|
|
$value1['account'] = $this->encryption($value1['account']);
|
|
$xlsData[] = $value1;
|
|
}
|
|
$this->exportExcel($xlsName, $xlsCell, $xlsData,$tid);
|
|
}
|
|
|
|
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("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();
|
|
}
|
|
fclose($fp);
|
|
$this->backSuccessExport($id);
|
|
|
|
}
|
|
|
|
//注册明细excel信息
|
|
public function registerExcelInfo($id,$map) {
|
|
$xlsName = "注册明细";
|
|
$xlsCell = array(
|
|
'玩家账号',
|
|
'推广账号',
|
|
'设备IMIE/IDFA',
|
|
'注册时间',
|
|
'注册ip',
|
|
'登陆时间',
|
|
'登陆ip'
|
|
);
|
|
$records = recordPromoteLogs('数据管理','注册明细导出');
|
|
$model = M('user','tab_');
|
|
|
|
$data1 = $model->field('account')->where($map)->order('tab_user.id desc')->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++) {
|
|
$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)
|
|
->order('tab_user.id desc')
|
|
->select();
|
|
foreach($data as $value1) {
|
|
$csvData['account'] = $this->encryption($value1['account']);
|
|
$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['register_ip'] = $value1['register_ip'];
|
|
$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);
|
|
}
|
|
unset($csvData);
|
|
ob_flush();
|
|
flush();
|
|
}
|
|
fclose($fp);
|
|
$this->backSuccessExport($id);
|
|
}
|
|
|
|
//玩家角色excel信息
|
|
public function userRolesExcelInfo($id,$map) {
|
|
$xlsName = "角色查询";
|
|
$xlsCell = array(
|
|
array('user_account','玩家账号'),
|
|
array('promote_account','推广账号'),
|
|
array('game_name','游戏名称'),
|
|
array('server_name','区服'),
|
|
array('role_name','游戏昵称'),
|
|
array('role_level','等级'),
|
|
array('create_time','创建时间'),
|
|
);
|
|
$records = recordPromoteLogs('数据管理','角色查询导出');
|
|
$model = M('user_play_info','tab_');
|
|
$data = $model->field('user_account,promote_account,game_name,server_name,role_name,role_level,create_time')->where($map)->order('create_time desc')->select();
|
|
$xlsData = [];
|
|
foreach ($data as $key1 => $value1) {
|
|
$value1['user_account'] = $this->encryption($value1['user_account']);
|
|
$value1['create_time'] = date('Y-m-d H:i:s',$value1['create_time']);
|
|
$xlsData[] = $value1;
|
|
}
|
|
$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','登陆用户数'),
|
|
);
|
|
$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','代金券使用');
|
|
}
|
|
if(!empty($map['tab_apply.promote_id'][1])) {
|
|
$params['promote_ids'] = $map['tab_apply.promote_id'][1];
|
|
}
|
|
$serverJoin = '';
|
|
$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);
|
|
$params['begin_time'] = $begTime;
|
|
$params['end_time'] = $endTime -1;
|
|
if(!empty($map['apply_time'][1])) {
|
|
$begTime = $map['apply_time'][1][0];
|
|
$endTime = $map['apply_time'][1][1];
|
|
$params['begin_time'] = $begTime;
|
|
$params['end_time'] = $endTime -1;
|
|
unset($map['apply_time']);
|
|
}
|
|
if(!empty($map['tab_server.server_id'])) {
|
|
$serverJoin = 'tab_server on tab_server.game_id = tab_apply.game_id';
|
|
$params['server_id'] = $map['tab_server.server_id'];
|
|
}
|
|
$data = M('Apply', 'tab_')
|
|
->field('tab_apply.game_id,tab_apply.game_name,tab_apply.sdk_version')
|
|
->join('tab_game as g on g.id = tab_apply.game_id')
|
|
->join($serverJoin)//关联区服表
|
|
->where($map)
|
|
->group('tab_apply.game_id')
|
|
->order('g.sort desc,g.id desc')
|
|
->select();
|
|
$allGameIs = M('Apply', 'tab_')
|
|
->field('distinct tab_apply.game_id')
|
|
->join('tab_game as g on g.id = tab_apply.game_id')
|
|
->join($serverJoin)
|
|
->where($map)
|
|
->select();
|
|
$allGameIs = array_column($allGameIs, 'game_id');
|
|
$records = [];
|
|
if (!empty($data)) {
|
|
if (intval($endTime - $begTime) / (24 * 3600) <= 30) {
|
|
$gameIds = [];
|
|
foreach ($data as $list) {
|
|
$gameIds[] = $list['game_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);//登录用户数
|
|
$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);//现金充值
|
|
$params['pay_way'] = 0;
|
|
$spendGenericList = $spendRepository->getPayAmountGroupByGameAndType($params);//通用币充值
|
|
$params['pay_way'] = -1;
|
|
$spendBindingList = $spendRepository->getPayAmountGroupByGameAndType($params);//绑定币充值
|
|
foreach ($data as &$list) {
|
|
$gameId = $list['game_id'];
|
|
$records[] = [
|
|
'game_id' => $gameId,
|
|
'game_name' => $list['game_name'],
|
|
'sdk_version' => $list['sdk_version'],
|
|
'role_num' => $roleNumList[$gameId],
|
|
'user_num' => $userNumList[$gameId],
|
|
'new_user_num' => $newUserNumList[$gameId],
|
|
'new_device_num' => $newDeviceNumList[$gameId],
|
|
'new_ip_num' => $newIpNumList[$gameId],
|
|
'login_user_num' => $loginUserNumList[$gameId],
|
|
'spend_user_num' => $spendUserNumList[$gameId],
|
|
'spend_num' => $spendNumList[$gameId],
|
|
'spend_all_amount' => $spendAllAmountList[$gameId],
|
|
'spend_cash' => $spendCashList[$gameId],
|
|
'spend_generic' => $spendGenericList[$gameId],
|
|
'spend_binding' => $spendBindingList[$gameId],
|
|
'spend_discount' => 0,
|
|
'spend_voucher' => 0,
|
|
];
|
|
}
|
|
$params['all_data'] = 1;
|
|
$params['game_ids'] = $allGameIs;
|
|
$allData['game_name'] = "合计";
|
|
$allData['sdk_version'] = '--';
|
|
$allData['role_num'] = $userRepository->getCreateRoleCountByGame($params);//创角数
|
|
$allData['user_num'] = $userRepository->getCreateRoleUserCountByGame($params);//创角用户
|
|
$allData['new_user_num'] = $userRepository->getNewCreateRoleUserCountByGame($params);//新创角用户
|
|
$allData['new_device_num'] = $userRepository->getNewCreateRoleDeviceCountByGame($params);//新创角设备
|
|
$allData['new_ip_num'] = $userRepository->getNewCreateRoleIpCountByGame($params);//新创角IP
|
|
$allData['login_user_num'] = $userRepository->getLoginCountGroupByGame($params);//登录用户数
|
|
|
|
if($this->canViewUserRecharge) {
|
|
$record['spend_user_num'] = $spendUserNumList[$gameId];
|
|
$record['spend_num'] = $spendNumList[$gameId];
|
|
$record['spend_all_amount'] = $spendAllAmountList[$gameId];
|
|
$record['spend_cash'] = $spendCashList[$gameId];
|
|
$record['spend_generic'] = $spendGenericList[$gameId];
|
|
$record['spend_binding'] = $spendBindingList[$gameId];
|
|
$record['spend_discount'] = 0;
|
|
$record['spend_voucher'] = 0;
|
|
$allData['spend_user_num'] = $spendRepository->getPayUserCountByGame($params);//充值人数
|
|
$allData['spend_num'] = $spendRepository->getPayCountByGame($params);//充值次数
|
|
unset($params['pay_way']);
|
|
$allData['spend_all_amount'] = null_to_0($spendRepository->getPayAmountByGameAndType($params));//充值总额
|
|
$params['pay_way'] = ['in', '1,2,3,4,5,6'];
|
|
$allData['spend_cash'] = null_to_0($spendRepository->getPayAmountByGameAndType($params));//现金充值
|
|
$params['pay_way'] = 0;
|
|
$allData['spend_generic'] = null_to_0($spendRepository->getPayAmountByGameAndType($params));//通用币充值
|
|
$params['pay_way'] = -1;
|
|
$allData['spend_binding'] = null_to_0($spendRepository->getPayAmountByGameAndType($params));//绑定币充值
|
|
$allData['spend_discount'] = '0.00';
|
|
$allData['spend_voucher'] = '0.00';
|
|
|
|
}
|
|
$records[] = $record;
|
|
$records[] = $allData;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
$xlsData = [];
|
|
foreach ($records as $key1 => $value1) {
|
|
if($value1["sdk_version"] == 1) {
|
|
$value1["sdk_version"] = "安卓";
|
|
}
|
|
if($value1["sdk_version"] == 2) {
|
|
$value1["sdk_version"] = "苹果";
|
|
}
|
|
$xlsData[] = $value1;
|
|
}
|
|
$this->exportExcel($xlsName, $xlsCell, $xlsData,$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_');
|
|
$data = $model->where($map)->select();
|
|
$xlsData = [];
|
|
foreach ($data as $key1 => $value1) {
|
|
// $value1['status'] = $this->payWay[$value1['pay_way']];
|
|
$value1['promotestatus'] = "未知状态";
|
|
if($value1['status'] == 0) {
|
|
$value1['promotestatus'] = "审核中";
|
|
}
|
|
if($value1['status'] == 1) {
|
|
$value1['promotestatus'] = "启用";
|
|
}
|
|
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').'**';
|
|
$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']);
|
|
$xlsData[] = $value1;
|
|
}
|
|
$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('平台币管理','我的平台币导出');
|
|
$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) {
|
|
$value['cointype'] = "通用币";
|
|
$value['game_name'] = "通用";
|
|
}else {
|
|
$value['cointype'] = "绑定币";
|
|
$value['game_name'] = $value['game_name'];
|
|
}
|
|
if($value['status'] == 1) {
|
|
$value['status'] = "正常";
|
|
}elseif($value['status'] == 2) {
|
|
$value['status'] = "锁定";
|
|
}else {
|
|
$value['status'] = "验证失败";
|
|
}
|
|
$xlsData[] = $value;
|
|
}
|
|
$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('平台币管理','我的平台币明细导出');
|
|
$service = new PromoteCoinRecordService();
|
|
$data = M('promote_coin_record','tab_')->where($map)->select();
|
|
$records = [];
|
|
foreach ($data as $item) {
|
|
$records[] = [
|
|
'id' => $item['id'],
|
|
'sn' => $this->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']),
|
|
'coin' => $item['coin'],
|
|
'balance_coin' => $item['balance_coin'],
|
|
'remark' => $item['remark'],
|
|
'description' => $item['description'],
|
|
'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 = [];
|
|
$promoteIds = [];
|
|
$uesrIds = [];
|
|
foreach ($logs as $log) {
|
|
$gameIds[] = $log['game_id'];
|
|
if ($log['target_type'] == 1) {
|
|
$promoteIds[] = $log['target_id'];
|
|
}
|
|
if ($log['target_type'] == 2) {
|
|
$uesrIds[] = $log['target_id'];
|
|
}
|
|
}
|
|
$games = [];
|
|
$promotes = [];
|
|
$users = [];
|
|
if (count($gameIds) > 0) {
|
|
$games = M('game', 'tab_')->field(['id', 'game_name'])->where(['id' => ['in', $gameIds]])->select();
|
|
}
|
|
if (count($promoteIds) > 0) {
|
|
$promotes = M('promote', 'tab_')->field(['id', 'account'])->where(['id' => ['in', $promoteIds]])->select();
|
|
}
|
|
if (count($uesrIds) > 0) {
|
|
$users = M('user', 'tab_')->field(['id', 'account'])->where(['id' => ['in', $uesrIds]])->select();
|
|
}
|
|
$users = index_by_column('id', $users);
|
|
$promotes = index_by_column('id', $promotes);
|
|
$games = index_by_column('id', $games);
|
|
$records = [];
|
|
foreach ($logs as $log) {
|
|
$targetAccount = '';
|
|
if ($log['target_type'] == 1) {
|
|
$targetAccount = isset($promotes[$log['target_id']]) ? $promotes[$log['target_id']]['account'] : '未知推广账号';
|
|
}
|
|
if ($log['target_type'] == 2) {
|
|
$targetAccount = isset($promotes[$log['target_id']]) ? $promotes[$log['target_id']]['account'] : '未知玩家';
|
|
}
|
|
$records[] = [
|
|
'id' => $log['id'],
|
|
'sn' => $this->encryption($log['sn']),
|
|
'target_account' => $this->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'],
|
|
'description' => $log['description'],
|
|
'status_text' => '成功',
|
|
'create_time' => date('Y-m-d H:i:s', $log['create_time'])
|
|
];
|
|
}
|
|
$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) {
|
|
$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['check_status'] = "正常";
|
|
}else {
|
|
$value['check_status'] = "拉黑";
|
|
}
|
|
//获取累计发放
|
|
$where = array(
|
|
"user_id"=>$value['user_id'],
|
|
"game_id"=>$value['game_id'],
|
|
"server_id"=>$value['server_id']
|
|
);
|
|
$where1 = array(
|
|
"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();
|
|
//获取申请
|
|
$where2 = array(
|
|
"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);
|
|
}
|
|
$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) {
|
|
$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) {
|
|
$data[$key]['check_status'] = "启用";
|
|
}else {
|
|
$data[$key]['check_status'] = "冻结";
|
|
}
|
|
}
|
|
$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'),
|
|
);
|
|
$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);
|
|
|
|
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_');
|
|
$data = $model->where($map)->order('id DESC')->select();
|
|
foreach ($data as $key => $value) {
|
|
if($value['pay_type'] == 1) {
|
|
$data[$key]['pay_type'] = "线上充值";
|
|
} else {
|
|
$data[$key]['pay_type'] = "线下充值";
|
|
}
|
|
|
|
if($value['order_status'] == 0) {
|
|
$data[$key]['order_status1'] = "待付款";
|
|
}
|
|
if($value['order_status'] == 1) {
|
|
$data[$key]['order_status1'] = "付款成功";
|
|
}
|
|
if($value['order_status'] == 2) {
|
|
$data[$key]['order_status1'] = "待审核";
|
|
}
|
|
if($value['order_status'] == 3) {
|
|
$data[$key]['order_status1'] = "待发币";
|
|
}
|
|
if($value['order_status'] == 4) {
|
|
$data[$key]['order_status1'] = "已发币";
|
|
}
|
|
if($value['order_status'] == 5) {
|
|
$data[$key]['order_status1'] = "审核不通过";
|
|
}
|
|
|
|
$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) {
|
|
$xlsName = "提现记录";
|
|
$xlsCell = array(
|
|
'充值订单号',
|
|
'游戏',
|
|
'平台',
|
|
'玩家账号',
|
|
'订单总额',
|
|
'充值时间',
|
|
'收益',
|
|
'现金支付通道',
|
|
'现金分成基数',
|
|
'现金分成比例',
|
|
'平台币分成基数',
|
|
'平台币分成比例',
|
|
'绑定币分成基数',
|
|
'绑定币分成比例',
|
|
'订单状态',
|
|
);
|
|
$spendModel = M('spend', 'tab_');
|
|
$withdrawId = $map['withdraw_id'];
|
|
$withdraw = M('withdraw', 'tab_')->field('promote_id,status')->where(array('id' => $withdrawId))->find();
|
|
$data = $spendModel
|
|
->field('pay_order_number,game_name,sdk_version,user_account,pay_amount,pay_way,selle_ratio,pay_time')
|
|
->where($map)
|
|
->order('id desc')
|
|
->select();
|
|
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']);
|
|
switch ($list['pay_way']) {
|
|
case 2:
|
|
case 3:
|
|
case 4:
|
|
$list['pay_way_name'] = QueryController::$payWay[2];
|
|
break;
|
|
default:
|
|
$list['pay_way_name'] = QueryController::$payWay[$list['pay_way']];
|
|
break;
|
|
}
|
|
if($list['pay_way'] !== -1 && $list['pay_way'] !== 0) {
|
|
$list['cash_base'] = $list['pay_amount'];
|
|
}else {
|
|
$list['cash_base'] = 0;
|
|
}
|
|
$list['cash_selle_ratio'] = $list['selle_ratio'];
|
|
if($list['pay_way'] == 0) {
|
|
$list['platform_base'] = $list['pay_amount'];
|
|
}else {
|
|
$list['platform_base'] = 0;
|
|
}
|
|
$list['platform_selle_ratio'] = $list['selle_ratio'];
|
|
|
|
if($list['pay_way'] == -1) {
|
|
$list['bind_base'] = $list['pay_amount'];
|
|
}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']);
|
|
}
|
|
}
|
|
$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($data)?:0 ;
|
|
|
|
$perSize = 5000;//每次查询的条数
|
|
$pages = ceil($accessNum / $perSize);
|
|
for($i = 1; $i <= $pages; $i++) {
|
|
foreach($data as $value) {
|
|
mb_convert_variables('GBK', 'UTF-8', $value);
|
|
fputcsv($fp, $value);
|
|
}
|
|
unset($data);
|
|
ob_flush();
|
|
flush();
|
|
}
|
|
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','说明'),
|
|
);
|
|
$model = M('withdraw', 'tab_');
|
|
$data = $model->field('id,widthdraw_number,create_time,settlement_end_time,sum_money,status,respond')
|
|
->where($map)
|
|
->order('id desc')
|
|
->select();
|
|
if (!empty($data)) {
|
|
foreach ($data as &$list) {
|
|
$list['create_time'] = date('Y-m-d H:i:s', $list['create_time']);
|
|
$list['settlement_end_time'] = date('Y-m-d H:i:s', $list['settlement_end_time']);
|
|
$list['status'] = FinanceController::$withdrawStatus[$list['status']];
|
|
}
|
|
}
|
|
$xlsData = $data;
|
|
$this->exportExcel($xlsName, $xlsCell, $xlsData,$id);
|
|
}
|
|
|
|
public function settlementExcelInfo($id,$map) {
|
|
$xlsName = "结算明细";
|
|
$xlsCell = array(
|
|
'游戏订单号',
|
|
'游戏',
|
|
'玩家账号',
|
|
'推广员账号',
|
|
'订单总额',
|
|
'直充',
|
|
'内充',
|
|
'分成比例(直充)',
|
|
'分成比例(内充)',
|
|
'收益',
|
|
'充值时间',
|
|
'订单状态',
|
|
);
|
|
$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 = [];
|
|
$total = $model->field('sum(pay_amount) as pay_amount,sum(if(pay_way > -1,pay_amount,0)) as direct_pay_amount,sum(if(pay_way = -1,pay_amount,0)) as inner_pay_amount,sum(if(selle_ratio >= 0,selle_ratio * pay_amount,0)) as income')
|
|
->where($map)
|
|
->find();
|
|
$total['direct_pay_amount'] = empty($total['direct_pay_amount']) ? '0.00' : $total['direct_pay_amount'];
|
|
$total['inner_pay_amount'] = empty($total['inner_pay_amount']) ? '0.00' : $total['inner_pay_amount'];
|
|
$total['income'] = empty($total['income']) ? 0 : $total['income'];
|
|
$total['income'] = bcdiv($total['income'], 100, 2);
|
|
//提现状态
|
|
$csvFileName = $xlsName.'.csv';
|
|
//设置好告诉浏览器要下载excel文件的headers
|
|
header('Content-Description: File Transfer');
|
|
header('Content-Type: application/vnd.ms-excel');
|
|
header('Content-Disposition: attachment; filename="'. $csvFileName .'"');
|
|
header('Expires: 0');
|
|
header('Cache-Control: must-revalidate');
|
|
header('Pragma: public');
|
|
$fp = fopen('php://output', 'a');//打开output流
|
|
mb_convert_variables('gb2312', 'UTF-8', $xlsCell);
|
|
fputcsv($fp, $xlsCell);//将数据格式化为CSV格式并写入到output流中
|
|
$accessNum = count($data)?:0 ;
|
|
|
|
$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();
|
|
$withdrawIds = [];
|
|
foreach ($data as $key => $value) {
|
|
if ($value['withdraw_id'] > 0 && !in_array($value['withdraw_id'], $withdrawIds)) {
|
|
$withdrawIds[] = $value['withdraw_id'];
|
|
}
|
|
}
|
|
if(empty($withdrawIds)) {
|
|
$withdrawIds = "-10000";
|
|
}
|
|
$withdrawStatus = M('withdraw', 'tab_')
|
|
->where(array('id' => ['in',$withdrawIds]))
|
|
->getField('id,status');
|
|
|
|
$promotes = [];
|
|
$promoteService = new PromoteService();
|
|
if (count($data) > 0) {
|
|
$promoteIds = array_column($data, 'promote_id');
|
|
$promotes = M('promote', 'tab_')->field(['id', 'chain', 'account'])->where(['id' => ['in', $promoteIds]])->select();
|
|
$promotes = index_by_column('id', $promotes);
|
|
}
|
|
|
|
foreach ($data as &$list) {
|
|
//提现状态
|
|
$list['pay_order_number'] = $this->encryption($list['pay_order_number']);
|
|
$list['user_account'] = $this->encryption($list['user_account']);
|
|
if ($list['pay_status'] == 1) {
|
|
switch ($list['selle_status']) {
|
|
case 0:
|
|
$list['selle_status'] = '未提现';
|
|
break;
|
|
default:
|
|
if ($list['withdraw_id'] > 0) {
|
|
$list['selle_status'] = FinanceController::$withdrawStatus[$withdrawStatus[$list['withdraw_id']]];
|
|
} else {
|
|
$list['selle_status'] = '';
|
|
}
|
|
break;
|
|
}
|
|
} else {
|
|
$list['selle_status'] = '支付失败';
|
|
}
|
|
|
|
$list['income'] = bcmul($list['pay_amount'], bcdiv($list['selle_ratio'], 100, 2), 2);
|
|
$list['pay_time'] = date('Y-m-d H:i:s', $list['pay_time']);
|
|
if($list['pay_way'] == -1) {
|
|
$list['pay_amount_zhi'] = 0;
|
|
$list['pay_amount_nei'] = $list['pay_amount'];
|
|
}else {
|
|
$list['pay_amount_zhi'] = $list['pay_amount'];
|
|
$list['pay_amount_nei'] = 0;
|
|
}
|
|
|
|
$promoteGroup = isset($promotes[$list['promote_id']]) ? $promoteService->getGroupNameByChain($promotes[$list['promote_id']]['chain'], $list['promote_id']) : '';
|
|
|
|
$csvData["pay_order_number"] = $list["pay_order_number"];
|
|
$csvData["game_name"] = $list["game_name"];
|
|
$csvData["user_account"] = $list["user_account"];
|
|
$csvData["promote_account"] = $list["promote_account"] . ($promoteGroup == '' ? '' : '(' . $promoteGroup . ')');
|
|
$csvData["pay_amount"] = $list["pay_amount"];
|
|
$csvData["pay_amount_zhi"] = $list["pay_amount_zhi"];
|
|
$csvData["pay_amount_nei"] = $list["pay_amount_nei"];
|
|
$csvData["selle_ratio"] = $list["selle_ratio"];
|
|
$csvData["selle_ratio1"] = $list["selle_ratio"];
|
|
$csvData["income"] = $list["income"];
|
|
$csvData["pay_time"] = $list["pay_time"];
|
|
$csvData["selle_status"] = $list["selle_status"];
|
|
mb_convert_variables('GBK', 'UTF-8', $csvData);
|
|
fputcsv($fp, $csvData);
|
|
$xlsData[] = $csvData;
|
|
}
|
|
unset($xlsData);
|
|
ob_flush();
|
|
flush();
|
|
}
|
|
$allData['pay_order_number'] = '合计';
|
|
$allData['game_name'] = '--';
|
|
$allData['user_account'] = '--';
|
|
$allData['promote_account'] = '--';
|
|
$allData['pay_amount'] = $total['pay_amount'];
|
|
$allData['pay_amount_zhi'] = $total['direct_pay_amount'];
|
|
$allData['pay_amount_nei'] = $total['inner_pay_amount'];
|
|
$allData['selle_ratio'] = '--';
|
|
$allData['selle_ratio1'] = '--';
|
|
$allData['income'] = $total['income'];
|
|
$allData['pay_time'] = '--';
|
|
$allData['selle_status'] = '--';
|
|
mb_convert_variables('GBK', 'UTF-8', $allData);
|
|
fputcsv($fp, $allData);
|
|
$xlsData[] = $allData;
|
|
fclose($fp);
|
|
|
|
$this->backSuccessExport($id);
|
|
|
|
|
|
// $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');
|
|
$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 = $endTime + 3600 * 24;
|
|
}
|
|
$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')
|
|
->select();
|
|
$data = $this->assembleRecords($data, $dayList, 'income');
|
|
foreach ($dayList as $day) {
|
|
$date = date('Ymd', strtotime($day));
|
|
$records[] = [
|
|
'day' => $date,
|
|
'income' => bcdiv($data[$day], 100, 2),
|
|
|
|
];
|
|
}
|
|
$xlsData = [];
|
|
foreach ($records as $key1 => $value1) {
|
|
$xlsData[] = $value1;
|
|
}
|
|
$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','登陆用户数'),
|
|
|
|
);
|
|
$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','代金劵使用');
|
|
}
|
|
$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);
|
|
$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) {
|
|
$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);//充值总额
|
|
$params['pay_way'] = ['in', '1,2,3,4,5,6'];
|
|
$spendCashList = $spendRepository->getPayAmountGroupByDayAndType($params);//现金充值
|
|
$params['pay_way'] = 0;
|
|
$spendGenericList = $spendRepository->getPayAmountGroupByDayAndType($params);//通用币充值
|
|
$params['pay_way'] = -1;
|
|
$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) {
|
|
$allData['spend_user_num'] = 0;
|
|
$allData['spend_num'] = 0;
|
|
$allData['spend_all_amount'] = 0;
|
|
$allData['spend_cash'] = 0;
|
|
$allData['spend_generic'] = 0;
|
|
$allData['spend_binding'] = 0;
|
|
$allData['spend_discount'] = 0;
|
|
$allData['spend_voucher'] = 0;
|
|
}
|
|
foreach ($params['dayList'] as $day) {
|
|
$date = date('Ymd', strtotime($day));
|
|
$records[] = [
|
|
'day' => $date,
|
|
'role_num' => $roleNumList[$day],
|
|
'user_num' => $userNumList[$day],
|
|
'new_user_num' => $newUserNumList[$day],
|
|
'new_device_num' => $newDeviceNumList[$day],
|
|
'new_ip_num' => $newIpNumList[$day],
|
|
'login_user_num' => $loginUserNumList[$day],
|
|
'spend_user_num' => $spendUserNumList[$day],
|
|
'spend_num' => $spendNumList[$day],
|
|
'spend_all_amount' => $spendAllAmountList[$day],
|
|
'spend_cash' => $spendCashList[$day],
|
|
'spend_generic' => $spendGenericList[$day],
|
|
'spend_binding' => $spendBindingList[$day],
|
|
'spend_discount' => 0,
|
|
'spend_voucher' => 0,
|
|
];
|
|
$allData['role_num'] += $roleNumList[$day];
|
|
$allData['user_num'] += $userNumList[$day];
|
|
$allData['new_user_num'] += $newUserNumList[$day];
|
|
$allData['new_device_num'] += $newDeviceNumList[$day];
|
|
$allData['new_ip_num'] += $newIpNumList[$day];
|
|
$allData['login_user_num'] += $loginUserNumList[$day];
|
|
if ($this->canViewUserRecharge) {
|
|
$record['spend_user_num'] = $spendUserNumList[$day];
|
|
$record['spend_num'] = $spendNumList[$day];
|
|
$record['spend_all_amount'] = $$spendAllAmountList[$day];
|
|
$record['spend_cash'] = $spendCashList[$day];
|
|
$record['spend_generic'] = $spendGenericList[$day];
|
|
$record['spend_binding'] = $spendBindingList[$day];
|
|
$record['spend_discount'] = 0;
|
|
$record['spend_voucher'] = 0;
|
|
$allData['spend_user_num'] += $spendUserNumList[$day];
|
|
$allData['spend_num'] += $spendNumList[$day];
|
|
$allData['spend_all_amount'] = bcadd($allData['spend_all_amount'], $spendAllAmountList[$day], 2);
|
|
$allData['spend_cash'] = bcadd($allData['spend_cash'], $spendCashList[$day], 2);
|
|
$allData['spend_generic'] = bcadd($allData['spend_generic'], $spendGenericList[$day], 2);
|
|
$allData['spend_binding'] = bcadd($allData['spend_binding'], $spendBindingList[$day], 2);
|
|
$allData['spend_discount'] = bcadd($allData['spend_discount'], 0, 2);
|
|
$allData['spend_voucher'] = bcadd($allData['spend_voucher'], 0, 2);
|
|
}
|
|
$records[] = $record;
|
|
|
|
}
|
|
$allData['day'] = '合计';
|
|
$records[] = $allData;
|
|
$xlsData = [];
|
|
foreach ($records as $key1 => $value1) {
|
|
$xlsData[] = $value1;
|
|
}
|
|
|
|
$this->exportExcel($xlsName, $xlsCell, $xlsData,$id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public function achievementExcelInfo($tid, $map) {
|
|
$xlsName = "推广员业绩";
|
|
$xlsCell = array(
|
|
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','登陆用户数'),
|
|
);
|
|
$records = 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','现金充值');
|
|
}
|
|
$params['isContainSubs'] = $map['isContainSubs'];
|
|
$params['basicPromotes'] = json_decode($map['basicPromotes'],TRUE);
|
|
$ids = $map['ids'];
|
|
$promotes = json_decode($map["promotes"],TRUE);
|
|
if(!empty($map['game_id'])) {
|
|
$params['game_id'] = $map["game_id"];
|
|
}
|
|
if(!empty($map['server_id'])) {
|
|
$params['server_id'] = $map["server_id"];
|
|
}
|
|
if(!empty($map['sdk_version'])) {
|
|
$params['sdk_version'] = $map["sdk_version"];
|
|
}
|
|
if(!empty($map['lock_status'])) {
|
|
$params['lock_status'] = $map["lock_status"];
|
|
}
|
|
|
|
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'];
|
|
|
|
$promoteRepository = new PromoteRepository();
|
|
$createRoleCountList = $promoteRepository->getCreateRoleCountByIds($ids, $params);
|
|
$createRoleUserCountList = $promoteRepository->getCreateRoleUserCountByIds($ids, $params);
|
|
$newCreateRoleUserCountList = $promoteRepository->getNewCreateRoleUserCountByIds($ids, $params);
|
|
$newCreateRoleDeviceCountList = $promoteRepository->getNewCreateRoleDeviceCountByIds($ids, $params);
|
|
$newCreateRoleIpCountList = $promoteRepository->getNewCreateRoleIpCountByIds($ids, $params);
|
|
$loginUserCountList = $promoteRepository->getLoginUserCountByIds($ids, $params);
|
|
|
|
$rechargeCountList = [];
|
|
$rechargeUserCountList = [];
|
|
$rechargeAmountList = [];
|
|
if ($this->canViewUserRecharge) {
|
|
$rechargeCountList = $promoteRepository->getRechargeCountByIds($ids, $params);
|
|
$rechargeUserCountList = $promoteRepository->getRechargeUserCountByIds($ids, $params);
|
|
$rechargeAmountList = $promoteRepository->getRechargeAmountByIds($ids, $params);
|
|
}
|
|
$promoteService = new PromoteService();
|
|
$records = [];
|
|
if (I('p', 1) == 1) {
|
|
$selfParams = $params;
|
|
$selfParams['isContainSubs'] = false;
|
|
$selfCreateRoleCountList = $promoteRepository->getCreateRoleCountByIds([$parent['id']], $selfParams);
|
|
$selfCreateRoleUserCountList = $promoteRepository->getCreateRoleUserCountByIds([$parent['id']], $selfParams);
|
|
$selfNewCreateRoleUserCountList = $promoteRepository->getNewCreateRoleUserCountByIds([$parent['id']], $selfParams);
|
|
// $selfNewCreateRoleDeviceCountList = $promoteRepository->getNewCreateRoleDeviceCountByIds([$parent['id']], $selfParams);
|
|
$selfNewCreateRoleIpCountList = $promoteRepository->getNewCreateRoleIpCountByIds([$parent['id']], $selfParams);
|
|
$selfLoginUserCountList = $promoteRepository->getLoginUserCountByIds([$parent['id']], $selfParams);
|
|
$record = [
|
|
'id' => $parent['id'],
|
|
'account' => $parent['account'],
|
|
'promote_group' => $promoteService->getGroupNameByChain($parent['chain'], $parent['id']),
|
|
'real_name' => hideRealName($parent['real_name']),
|
|
'level' => $parent['level'],
|
|
'create_role_count' => $selfCreateRoleCountList[$parent['id']],
|
|
'create_role_user_count' => $selfCreateRoleUserCountList[$parent['id']],
|
|
'new_create_role_user_count' => $selfNewCreateRoleUserCountList[$parent['id']],
|
|
// 'new_create_role_device_count' => $selfNewCreateRoleDeviceCountList[$parent['id']],
|
|
'new_create_role_ip_count' => $selfNewCreateRoleIpCountList[$parent['id']],
|
|
'login_user_count' => $selfLoginUserCountList[$parent['id']],
|
|
'current_display' => $currentDisplay,
|
|
];
|
|
if ($this->canViewUserRecharge) {
|
|
$selfRechargeCountList = $promoteRepository->getRechargeCountByIds([$parent['id']], $selfParams);
|
|
$selfRechargeUserCountList = $promoteRepository->getRechargeUserCountByIds([$parent['id']], $selfParams);
|
|
$selfRechargeAmountList = $promoteRepository->getRechargeAmountByIds([$parent['id']], $selfParams);
|
|
$record['recharge_count'] = $selfRechargeCountList[$parent['id']];
|
|
$record['recharge_user_count'] = $selfRechargeUserCountList[$parent['id']];
|
|
$record['recharge_amount'] = $selfRechargeAmountList[$parent['id']]['ban_coin'] + $selfRechargeAmountList[$parent['id']]['coin'] + $selfRechargeAmountList[$parent['id']]['cash'];
|
|
$record['recharge_by_ban_coin'] = $selfRechargeAmountList[$parent['id']]['ban_coin'];
|
|
$record['recharge_by_coin'] = $selfRechargeAmountList[$parent['id']]['coin'];
|
|
$record['recharge_by_cash'] = $selfRechargeAmountList[$parent['id']]['cash'];
|
|
}
|
|
$records[] = $record;
|
|
}
|
|
foreach ($promotes as $promote) {
|
|
$id = $promote['id'];
|
|
$record = [
|
|
'id' => $id,
|
|
'account' => $promote['account'],
|
|
'promote_group' => $promoteService->getGroupNameByChain($promote['chain'], $promote['id']),
|
|
'real_name' => hideRealName($promote['real_name']),
|
|
'level' => $promote['level'],
|
|
'create_role_count' => $createRoleCountList[$id],
|
|
'create_role_user_count' => $createRoleUserCountList[$id],
|
|
'new_create_role_user_count' => $newCreateRoleUserCountList[$id],
|
|
'new_create_role_device_count' => $newCreateRoleDeviceCountList[$id],
|
|
'new_create_role_ip_count' => $newCreateRoleIpCountList[$id],
|
|
'login_user_count' => $loginUserCountList[$id],
|
|
'current_display' => '',
|
|
];
|
|
if ($this->canViewUserRecharge) {
|
|
$record['recharge_count'] = $rechargeCountList[$id];
|
|
$record['recharge_user_count'] = $rechargeUserCountList[$id];
|
|
$record['recharge_amount'] = $rechargeAmountList[$id]['ban_coin'] + $rechargeAmountList[$id]['coin'] + $rechargeAmountList[$id]['cash'];
|
|
$record['recharge_by_ban_coin'] = $rechargeAmountList[$id]['ban_coin'];
|
|
$record['recharge_by_coin'] = $rechargeAmountList[$id]['coin'];
|
|
$record['recharge_by_cash'] = $rechargeAmountList[$id]['cash'];
|
|
}
|
|
$records[] = $record;
|
|
}
|
|
$xlsData = [];
|
|
foreach ($records as $key1 => $value1) {
|
|
$value1['account'] = $this->encryption($value1['account']);
|
|
$xlsData[] = $value1;
|
|
}
|
|
$this->exportExcel($xlsName, $xlsCell, $xlsData,$tid);
|
|
}
|
|
|
|
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]];
|
|
if ($costBegin != '' || $costEnd != '') {
|
|
$having = '';
|
|
if ($costBegin != '' && $costEnd != '') {
|
|
$having = 'sum(recharge_cost) between ' . $costBegin . ' and ' . $costEnd;
|
|
} elseif ($costBegin != '' && $costEnd == '') {
|
|
$having = 'sum(recharge_cost) >= ' . $costBegin;
|
|
} elseif ($costBegin == '' && $costEnd != '') {
|
|
$having = 'sum(recharge_cost) <= ' . $costEnd;
|
|
}
|
|
$subQuery = M('user_play_data_count', 'tab_')->field('role_id')
|
|
->where($subMap)
|
|
->group('game_id,server_id,role_id')
|
|
->having($having)
|
|
->buildSql();
|
|
$map['_string'] = 'ui.role_id in (' . $subQuery . ')';
|
|
}
|
|
$secondDay = 24*3600 + 1;
|
|
//$map['uc.create_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]];
|
|
|
|
$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')
|
|
->where($map)
|
|
->group('uc.game_player_id,uc.server_id,uc.game_id,uc.user_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';
|
|
//设置好告诉浏览器要下载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($roles)?:0 ;
|
|
|
|
$perSize = 5000;//每次查询的条数
|
|
$pages = ceil($accessNum / $perSize);
|
|
for($i = 1; $i <= $pages; $i++) {
|
|
$data = M()->alias('record')
|
|
->table($subQuery)
|
|
->limit(($i-1)*$perSize ,$perSize)
|
|
->select();
|
|
|
|
if (count($data) > 0) {
|
|
$promoteService = new PromoteService();
|
|
$promoteIds = array_column($data, 'promote_id');
|
|
$promotes = M('promote', 'tab_')->field(['id', 'chain', 'account'])->where(['id' => ['in', $promoteIds]])->select();
|
|
$promotes = index_by_column('id', $promotes);
|
|
}
|
|
|
|
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['sdk_version'] = "Android";
|
|
}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['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'];
|
|
if (isset($promotes[$value['promote_id']])) {
|
|
$groupName = $promoteService->getGroupNameByChain($promotes[$value['promote_id']]['chain'], $value['promote_id']);
|
|
if ($groupName) {
|
|
$csvData['promote_account'] .= '(' . $groupName . ')';
|
|
}
|
|
}
|
|
mb_convert_variables('GBK', 'UTF-8', $csvData);
|
|
fputcsv($fp, $csvData);
|
|
$xlsData[] = $csvData;
|
|
}
|
|
unset($xlsData);
|
|
ob_flush();
|
|
flush();
|
|
}
|
|
$allData['user_account'] = '合计';
|
|
$allData['game_name'] = '--';
|
|
$allData['server_name'] = '--';
|
|
$allData['sdk_version'] = '--';
|
|
$allData['game_player_name'] = '--';
|
|
$allData['recharge_cost'] = $total['recharge_cost'];
|
|
$allData['recharge_count'] = $total['recharge_count'];
|
|
$allData['recharge_cost_today'] = $total['recharge_cost_today'];
|
|
$allData['unlogin_day'] = '--';
|
|
$allData['user_game_login_count'] = '--';
|
|
$allData['create_time'] = '--';
|
|
$allData['login_time'] = '--';
|
|
$allData['promote_account'] = '--';
|
|
mb_convert_variables('GBK', 'UTF-8', $allData);
|
|
fputcsv($fp, $allData);
|
|
$xlsData[] = $allData;
|
|
fclose($fp);
|
|
$this->backSuccessExport($id);
|
|
}
|
|
|
|
public function rechargeExcelInfo($id,$map) {
|
|
$xlsName = "订单查询";
|
|
$xlsCell = array(
|
|
'玩家账号',
|
|
'游戏订单',
|
|
'订单金额',
|
|
'支付方式',
|
|
'充值状态',
|
|
'游戏名称',
|
|
'设备类型',
|
|
'区服',
|
|
'角色名',
|
|
'部门长',
|
|
'组长',
|
|
'推广员',
|
|
'付款时间',
|
|
);
|
|
$records = 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')
|
|
->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')
|
|
->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 = 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['pay_time'] = ($value1['pay_status'] == 1) ? date('Y-m-d H:i:s', $value1['pay_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["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["pay_time"] = $value1["pay_time"];
|
|
mb_convert_variables('GBK', 'UTF-8', $csvData);
|
|
fputcsv($fp, $csvData);
|
|
$xlsData[] = $csvData;
|
|
}
|
|
unset($xlsData);
|
|
ob_flush();
|
|
flush();
|
|
}
|
|
$income = '0.00';
|
|
$income = M('Spend', 'tab_')
|
|
->field('sum(tab_spend.pay_amount) as income')
|
|
->join('tab_game on tab_spend.game_id = tab_game.id')
|
|
->join('left join tab_promote on tab_spend.promote_id = tab_promote.id')
|
|
->where($map)
|
|
->order('tab_spend.id desc')
|
|
->find()['income'];
|
|
$csvData1["user_account"] = "合计";
|
|
$csvData1["pay_order_number"] = "--";
|
|
$csvData1["pay_amount"] = $income;
|
|
$csvData1["pay_way"] = "--";
|
|
$csvData1['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["pay_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)
|
|
{
|
|
$promotes = [];
|
|
if ($promote['parent_id'] == 0) {
|
|
$promotes = M('promote', 'tab_')->field(['id', 'account', 'real_name'])->where(['parent_id' => $promote['id']])->select();
|
|
}
|
|
return $promotes;
|
|
}
|
|
|
|
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();
|
|
}
|
|
|
|
private function getBetweenTime($time, $defaultBegin = 0, $defaultEnd = 0)
|
|
{
|
|
$delimiter = ' 至 ';
|
|
$begin = $defaultBegin;
|
|
$end = $defaultEnd;
|
|
if ($time != '') {
|
|
if (strpos($time, $delimiter) == -1) {
|
|
$begin = strtotime($time . ' 00:00:00');
|
|
$end = strtotime($time . ' 23:59:59');
|
|
} else {
|
|
$timeRow = explode($delimiter, $time);
|
|
$begin = strtotime($timeRow[0] . ' 00:00:00');
|
|
$end = strtotime($timeRow[1] . ' 23:59:59');
|
|
}
|
|
}
|
|
return [$begin, $end];
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
public function getHandleType($promoteCoin, $promote)
|
|
{
|
|
if ($promoteCoin['source_type'] == 2) {
|
|
return '玩家转账';
|
|
} else {
|
|
if ($promote['parent_id'] == 1) {
|
|
return '会长转账';
|
|
} elseif ($promote['parent_id'] > 0 && $promote['grand_id'] == 0) {
|
|
return '组长转账';
|
|
} elseif ($promote['grand_id'] > 0) {
|
|
return '推广员转账';
|
|
}
|
|
}
|
|
}
|
|
|
|
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 getDayList($beginTime, $endTime)
|
|
{
|
|
$dayList = [];
|
|
do {
|
|
$dayList[] = date('Y-m-d', $beginTime);
|
|
$beginTime += 24 * 60 * 60;
|
|
} while ($beginTime < $endTime);
|
|
|
|
return $dayList;
|
|
}
|
|
|
|
private function assembleRecords($items, $keys, $valueColumn, $keyColumn = 'day')
|
|
{
|
|
$records = [];
|
|
foreach ($keys as $key) {
|
|
$value = 0;
|
|
foreach ($items as $item) {
|
|
if ($item[$keyColumn] == $key) {
|
|
$value = $item[$valueColumn];
|
|
}
|
|
}
|
|
$records[$key] = $value;
|
|
}
|
|
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 = '全部游戏';
|
|
$sdkVersionText = getSDKTypeName(0, true);
|
|
$serverName = '--';
|
|
if (isset($map['game_id']) || isset($map['sdk_version'])) {
|
|
$where = [];
|
|
if (!isset($map['game_id'])) {
|
|
$sdkVersionText = getSDKTypeName($map['sdk_version'], true);
|
|
} elseif (!isset($map['sdk_version'])) {
|
|
$where['id'] = $map['game_id'];
|
|
$gameName = M('game', 'tab_')->where($where)->getField('relation_game_name');
|
|
if (isset($map['server_id'])) {
|
|
$serverName = $this->getServerName($map['game_id'], 0, $map['server_id']);
|
|
}
|
|
} else {
|
|
$where['id'] = $map['game_id'];
|
|
$where['sdk_version'] = $map['sdk_version'];
|
|
$gameName = M('game', 'tab_')->where($where)->getField('game_name');
|
|
$sdkVersionText = getSDKTypeName($map['sdk_version'], true);
|
|
if (isset($map['server_id'])) {
|
|
$serverName = $this->getServerName($map['game_id'], $map['sdk_version'], $map['server_id']);
|
|
}
|
|
}
|
|
}
|
|
|
|
$game = [
|
|
'game_name' => $gameName,
|
|
'sdk_version_text' => $sdkVersionText,
|
|
'server_name' => $serverName,
|
|
];
|
|
return $game;
|
|
}
|
|
|
|
private function getServerName($gameIds, $serverVersion, $serverId)
|
|
{
|
|
$map['_string'] = '1 = 1';
|
|
if ($gameIds) {
|
|
$map['game_id'] = $gameIds;
|
|
}
|
|
if ($serverVersion) {
|
|
$map['server_version'] = $serverVersion;
|
|
}
|
|
if ($serverId) {
|
|
$map['server_id'] = $serverId;
|
|
}
|
|
return M('server', 'tab_')->where($map)->getField('server_name');
|
|
}
|
|
|
|
}
|
|
|