@ -1227,6 +1227,57 @@ class DownloadController extends BaseController {
}
}
$this->success('添加下载成功',U('listsIndex'));
$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
* @author sunke
@ -2049,12 +2100,82 @@ class DownloadController extends BaseController {
case "推广员详情":
case "推广员详情":
$this->promotequotaDtlExcelInfo($id,$map);
$this->promotequotaDtlExcelInfo($id,$map);
break;
break;
case "推广员操作日志":
$this->promotelogsExcelInfo($id,$map);
break;
default:
default:
break;
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) {
public function promotequotaDtlExcelInfo($id,$map) {
$xlsName = "推广员详情";
$xlsName = "推广员详情";
$xlsCell = array(
$xlsCell = array(
@ -2067,6 +2188,7 @@ class DownloadController extends BaseController {
'等级',
'等级',
'创建时间',
'创建时间',
);
);
$records = recordPromoteLogs('数据管理','推广员详情导出');
$records = M('user_play_info', 'tab_')->where($map)->order('create_time desc')->select();
$records = M('user_play_info', 'tab_')->where($map)->order('create_time desc')->select();
$csvFileName = $xlsName.'.csv';
$csvFileName = $xlsName.'.csv';
//设置好告诉浏览器要下载excel文件的headers
//设置好告诉浏览器要下载excel文件的headers
@ -2130,6 +2252,7 @@ class DownloadController extends BaseController {
array('server_name','游戏区服'),
array('server_name','游戏区服'),
array('role_num','角色数量'),
array('role_num','角色数量'),
);
);
$records = recordPromoteLogs('数据管理','推广员指标导出');
$params['isContainSubs'] = $map['isContainSubs'];
$params['isContainSubs'] = $map['isContainSubs'];
$params['basicPromotes'] = json_decode($map['basicPromotes'],TRUE);
$params['basicPromotes'] = json_decode($map['basicPromotes'],TRUE);
$ids = $map['ids'];
$ids = $map['ids'];
@ -2276,7 +2399,8 @@ class DownloadController extends BaseController {
'注册ip',
'注册ip',
'登陆时间',
'登陆时间',
'登陆ip'
'登陆ip'
);
);
$records = recordPromoteLogs('数据管理','注册明细导出');
$model = M('user','tab_');
$model = M('user','tab_');
$data1 = $model->field('account')->where($map)->order('tab_user.id desc')->select();
$data1 = $model->field('account')->where($map)->order('tab_user.id desc')->select();
@ -2335,7 +2459,8 @@ class DownloadController extends BaseController {
array('role_name','游戏昵称'),
array('role_name','游戏昵称'),
array('role_level','等级'),
array('role_level','等级'),
array('create_time','创建时间'),
array('create_time','创建时间'),
);
);
$records = recordPromoteLogs('数据管理','角色查询导出');
$model = M('user_play_info','tab_');
$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();
$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 = [];
$xlsData = [];
@ -2360,6 +2485,7 @@ class DownloadController extends BaseController {
array('new_ip_num','新增创角ip'),
array('new_ip_num','新增创角ip'),
array('login_user_num','登陆用户数'),
array('login_user_num','登陆用户数'),
);
);
$records = recordPromoteLogs('数据管理','数据汇总导出');
if($this->canViewUserRecharge) {
if($this->canViewUserRecharge) {
$xlsCell[] = array('spend_user_num','充值人数');
$xlsCell[] = array('spend_user_num','充值人数');
$xlsCell[] = array('spend_num','充值次数');
$xlsCell[] = array('spend_num','充值次数');
@ -2526,6 +2652,7 @@ class DownloadController extends BaseController {
array('create_time','创建时间'),
array('create_time','创建时间'),
);
);
$records = recordPromoteLogs('数据管理','渠道管理导出');
$model = M('promote','tab_');
$model = M('promote','tab_');
$data = $model->where($map)->select();
$data = $model->where($map)->select();
$xlsData = [];
$xlsData = [];
@ -2551,14 +2678,15 @@ class DownloadController extends BaseController {
}
}
public function mycoinExcelInfo($id,$map) {
public function mycoinExcelInfo($id,$map) {
$xlsName = "我的平台币";
$xlsName = "我的平台币";
$xlsCell = array(
$xlsCell = array(
array('cointype','平台币类型'),
array('cointype','平台币类型'),
array('game_name','游戏名称'),
array('game_name','游戏名称'),
array('num','平台币余额'),
array('num','平台币余额'),
array('status','资产状态'),
array('status','资产状态'),
);
);
$records = recordPromoteLogs('平台币管理','我的平台币导出');
$data = M('PromoteBalanceCoin', 'tab_')
$data = M('PromoteBalanceCoin', 'tab_')
->field('tab_promote_balance_coin.*,tab_game.game_name')
->field('tab_promote_balance_coin.*,tab_game.game_name')
->join('left join tab_game on tab_promote_balance_coin.game_id = tab_game.id')
->join('left join tab_game on tab_promote_balance_coin.game_id = tab_game.id')
@ -2585,8 +2713,8 @@ class DownloadController extends BaseController {
}
}
public function mycoinRecordExcelInfo($id,$map) {
public function mycoinRecordExcelInfo($id,$map) {
$xlsName = "我的平台币明细";
$xlsName = "我的平台币明细";
$xlsCell = array(
$xlsCell = array(
array('sn','流水号'),
array('sn','流水号'),
array('type_text','操作类型'),
array('type_text','操作类型'),
array('sub_type_text','操作方式'),
array('sub_type_text','操作方式'),
@ -2596,6 +2724,7 @@ class DownloadController extends BaseController {
array('description','交易说明'),
array('description','交易说明'),
array('create_time','交易时间'),
array('create_time','交易时间'),
);
);
$records = recordPromoteLogs('平台币管理','我的平台币明细导出');
$service = new PromoteCoinRecordService();
$service = new PromoteCoinRecordService();
$data = M('promote_coin_record','tab_')->where($map)->select();
$data = M('promote_coin_record','tab_')->where($map)->select();
$records = [];
$records = [];
@ -2632,6 +2761,7 @@ class DownloadController extends BaseController {
array('create_time',"交易时间"),
array('create_time',"交易时间"),
array('status',"交易状态"),
array('status',"交易状态"),
);
);
$records = recordPromoteLogs('平台币管理','平台币转移导出');
$model = M('promote_coin_transfer_log', 'tab_');
$model = M('promote_coin_transfer_log', 'tab_');
$logs = $model->where($map)->select();
$logs = $model->where($map)->select();
$service = new PromoteCoinTransferLogService();
$service = new PromoteCoinTransferLogService();
@ -2702,7 +2832,7 @@ class DownloadController extends BaseController {
array('check_status',"状态"),
array('check_status',"状态"),
array('create_time',"创建时间"),
array('create_time',"创建时间"),
);
);
$records = recordPromoteLogs('测试资源','测试资源导出');
$data = M('test_resource','tab_')
$data = M('test_resource','tab_')
->field("tab_test_resource.*,user.check_status")
->field("tab_test_resource.*,user.check_status")
->join('tab_user user on tab_test_resource.user_id=user.id','left')
->join('tab_user user on tab_test_resource.user_id=user.id','left')
@ -2759,6 +2889,7 @@ class DownloadController extends BaseController {
array('create_time',"申请时间"),
array('create_time',"申请时间"),
array('verify_time',"审核时间"),
array('verify_time',"审核时间"),
);
);
$records = recordPromoteLogs('测试资源','测试资源记录导出');
$data=M('test_resource','tab_')->where($map)->order('id desc')->select();
$data=M('test_resource','tab_')->where($map)->order('id desc')->select();
foreach($data as $key => $value) {
foreach($data as $key => $value) {
$data[$key]['user_account'] = $this->encryption($value['user_account']);
$data[$key]['user_account'] = $this->encryption($value['user_account']);
@ -2790,6 +2921,7 @@ class DownloadController extends BaseController {
array('check_status',"状态"),
array('check_status',"状态"),
array('create_time',"创建时间"),
array('create_time',"创建时间"),
);
);
$records = recordPromoteLogs('测试资源','扶持号管理导出');
$data = M('test_resource','tab_')
$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')
->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')
->join('left join tab_user as user on tab_test_resource.user_id = user.id')
@ -2824,7 +2956,8 @@ class DownloadController extends BaseController {
array('historyPayCount','累计付费用户'),
array('historyPayCount','累计付费用户'),
array('arpu','ARPU'),
array('arpu','ARPU'),
array('arppu','ARPPU'),
array('arppu','ARPPU'),
);
);
$records = recordPromoteLogs('数据管理','ARPU统计导出');
$dayList = $params["dayList"];
$dayList = $params["dayList"];
$arr = explode(',', $params['promote_id'][1]);
$arr = explode(',', $params['promote_id'][1]);
$params['promote_id'] = $arr;
$params['promote_id'] = $arr;
@ -2877,6 +3010,7 @@ class DownloadController extends BaseController {
array('order_status1','订单状态'),
array('order_status1','订单状态'),
array('time','申请时间'),
array('time','申请时间'),
);
);
$records = recordPromoteLogs('平台币管理','平台币充值导出');
$model = M('coin_pay_order','tab_');
$model = M('coin_pay_order','tab_');
$data = $model->where($map)->order('id DESC')->select();
$data = $model->where($map)->order('id DESC')->select();
foreach ($data as $key => $value) {
foreach ($data as $key => $value) {
@ -3248,6 +3382,7 @@ class DownloadController extends BaseController {
array('login_user_num','登陆用户数'),
array('login_user_num','登陆用户数'),
);
);
$records = recordPromoteLogs('数据管理','每日概况导出');
if ($this->canViewUserRecharge) {
if ($this->canViewUserRecharge) {
$xlsCell[] = array('spend_user_num','充值人数');
$xlsCell[] = array('spend_user_num','充值人数');
@ -3392,6 +3527,7 @@ class DownloadController extends BaseController {
array('new_create_role_ip_count','新创角ip'),
array('new_create_role_ip_count','新创角ip'),
array('login_user_count','登陆用户数'),
array('login_user_count','登陆用户数'),
);
);
$records = recordPromoteLogs('数据管理','推广员业绩导出');
if ($this->canViewUserRecharge) {
if ($this->canViewUserRecharge) {
$xlsCell[] = array('recharge_user_count','充值人数');
$xlsCell[] = array('recharge_user_count','充值人数');
$xlsCell[] = array('recharge_count','充值次数');
$xlsCell[] = array('recharge_count','充值次数');
@ -3534,6 +3670,7 @@ class DownloadController extends BaseController {
'推广员账号',
'推广员账号',
);
);
$records = recordPromoteLogs('数据管理','充值玩家导出');
$subMap = [];
$subMap = [];
if(!empty($map['game_id'])) {
if(!empty($map['game_id'])) {
$subMap['game_id'] = $map['game_id'];
$subMap['game_id'] = $map['game_id'];
@ -3734,6 +3871,7 @@ class DownloadController extends BaseController {
'推广员',
'推广员',
'付款时间',
'付款时间',
);
);
$records = recordPromoteLogs('数据管理','充值明细导出');
$model = M('spend','tab_');
$model = M('spend','tab_');
if(!empty($map['tab_spend.pay_status'])) {
if(!empty($map['tab_spend.pay_status'])) {
$map['tab_spend.pay_status'] = $map['tab_spend.pay_status'] -2 ;
$map['tab_spend.pay_status'] = $map['tab_spend.pay_status'] -2 ;