下载数据加密

master
sunke 5 years ago
parent 12a40d4ad4
commit e9b234df02

@ -440,7 +440,7 @@ class DownloadController extends BaseController {
* @author sunke
*/
public function testresource_data_export() {
$map1['chain'] = ['like','%'.'/'.PID.'/'.'%'];
$map1['chain'] = ['like','%'.'/'.PID.'/'.'%'];
$rs = M('promote','tab_')->where($map1)->field('id,account,nickname')->select();
$childPromoteIds = '';
if(empty($rs)) {
@ -793,7 +793,14 @@ class DownloadController extends BaseController {
* @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 = '';
@ -835,7 +842,7 @@ class DownloadController extends BaseController {
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'))) {
@ -912,7 +919,7 @@ class DownloadController extends BaseController {
$addtime = time();
$type = "/Home/Promote/children/promote_type/".$promoteType;
$data = [
'logid' => 'cz_'.time(),
'logid' => 'promote_'.time(),
'admin_id' => PID,
'type' => $type,
'dataname' => '渠道管理',
@ -1123,7 +1130,7 @@ class DownloadController extends BaseController {
}
$beginTime = strtotime(I('begtime') . ' 00:00:00');
$endtime = strtotime(I('endtime') . ' 23:59:59');
if (($endTime - $beginTime) > 31 * 24 * 3600) {
if (($endtime - $beginTime) > 31 * 24 * 3600) {
$this->error('时间范围不能超过31天');
}
$map1['chain'] = ['like','%'.'/'.PID.'/'.'%'];
@ -1280,7 +1287,7 @@ class DownloadController extends BaseController {
$map['promote_id'] = $promoteId;
}
}
$conditions = json_encode($map,TRUE);
$addtime = time();
$data = [
@ -1393,8 +1400,11 @@ class DownloadController extends BaseController {
$roleLevelBegin = intval(I('role_level_begin', 0));
$roleLevelEnd = intval(I('role_level_end', 0));
$headmanPromoteId = I('headman_promote_id', 0);
$playTime = I('play_time', '');
$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 = '';
@ -1468,6 +1478,9 @@ class DownloadController extends BaseController {
$playTimeBegin = strtotime($playTimeRow[0] . ' 00:00:00');
$playTimeEnd = strtotime($playTimeRow[0] . ' 23:59:59');
}
if (($playTimeEnd - $playTimeBegin) > 31 * 24 * 3600) {
$this->error('时间范围不能超过31天');
}
$map['play_time'] = ['between', [$playTimeBegin, $playTimeEnd]];
}
if ($isSelf) {
@ -1629,7 +1642,6 @@ class DownloadController extends BaseController {
$this->rechargeExcelInfo($id,$map);
break;
case "充值玩家数据":
var_dump('ss');die();
$this->userRechargeExcelInfo($id,$map);
break;
case "推广员业绩":
@ -1689,21 +1701,22 @@ class DownloadController extends BaseController {
//注册明细excel信息
public function registerExcelInfo($id,$map) {
$xlsName = "注册明细";
$xlsCell = array(
$xlsName = "注册明细";
$xlsCell = array(
array('account','玩家账号'),
array('promote_account','推广账号'),
array('register_time','注册时间'),
array('register_ip','注册ip'),
array('login_time','登陆时间'),
array('login_ip','登陆ip')
);
);
$model = M('user','tab_');
$data = $model->field('account,promote_account,register_time,register_ip,login_time,login_ip')->where($map)->select();
//var_dump($data);
$xlsData = [];
foreach ($data as $key1 => $value1) {
$value1['account'] = $this->encryption($value1['account']);
$xlsData[] = $value1;
}
$this->exportExcel($xlsName, $xlsCell, $xlsData,$id);
@ -1711,19 +1724,20 @@ class DownloadController extends BaseController {
//玩家角色excel信息
public function userRolesExcelInfo($id,$map) {
$xlsName = "角色查询";
$xlsCell = array(
$xlsName = "角色查询";
$xlsCell = array(
array('user_account','玩家账号'),
array('promote_account','推广账号'),
array('game_name','游戏名称'),
array('server_name','区服'),
array('user_nickname','游戏昵称'),
array('role_level','等级'),
);
array('user_nickname','游戏昵称'),
array('role_level','等级'),
);
$model = M('user_play_info','tab_');
$data = $model->field('user_account,promote_account,game_name,server_name,user_nickname,role_level')->where($map)->select();
$xlsData = [];
foreach ($data as $key1 => $value1) {
$value1['user_account'] = $this->encryption($value1['user_account']);
$xlsData[] = $value1;
}
$this->exportExcel($xlsName, $xlsCell, $xlsData,$id);
@ -1731,31 +1745,30 @@ class DownloadController extends BaseController {
//数据汇总excel信息
public function summaryExcelInfo($id,$map) {
$xlsName = "数据汇总";
$xlsCell = array(
$xlsName = "数据汇总";
$xlsCell = array(
array('game_name','游戏名称'),
array('sdk_version','平台'),
array('role_num','创角数'),
array('user_num','创建用户'),
array('new_user_num','新创角用户'),
array('new_device_num','新创角设备'),
array('new_ip_num','新增创角ip'),
array('login_user_num','登陆用户数'),
array('spend_user_num','充值人数'),
array('spend_num','充值次数'),
array('spend_all_amount','充值总额'),
array('spend_cash','现金充值'),
array('spend_generic','通用币充值'),
array('spend_binding','绑定币充值'),
array('spend_discount','折扣币充值'),
array('spend_voucher','代金券使用'),
);
if(!empty($map['tab_apply.promote_id'][1])) {
array('new_user_num','新创角用户'),
array('new_device_num','新创角设备'),
array('new_ip_num','新增创角ip'),
array('login_user_num','登陆用户数'),
array('spend_user_num','充值人数'),
array('spend_num','充值次数'),
array('spend_all_amount','充值总额'),
array('spend_cash','现金充值'),
array('spend_generic','通用币充值'),
array('spend_binding','绑定币充值'),
array('spend_discount','折扣币充值'),
array('spend_voucher','代金券使用'),
);
if(!empty($map['tab_apply.promote_id'][1])) {
$params['promote_ids'] = $map['tab_apply.promote_id'][1];
}
$serverJoin = '';
}
$serverJoin = '';
$initBegTime = date('Y-m-d', strtotime('-6 day', strtotime($nowTime)));
$initBegTime = empty(I('begtime')) ? $initBegTime : I('begtime');
$initEndTime = $nowTime;
@ -1880,7 +1893,8 @@ class DownloadController extends BaseController {
if($value1['status'] == 2) {
$value1['promotestatus'] = "冻结中";
}
$value1['account'] = substr_replace($value1['account'],'****',2);
$value1['idcard'] = substr_replace($value1['idcard'],'************',3,12);
$value1['create_time'] = date('Y-m-d H:i:s',$value1['create_time']);
$xlsData[] = $value1;
}
@ -1939,7 +1953,7 @@ class DownloadController extends BaseController {
foreach ($data as $item) {
$records[] = [
'id' => $item['id'],
'sn' => $item['sn'],
'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']),
@ -1961,7 +1975,7 @@ class DownloadController extends BaseController {
$xlsName = "平台币转移";
$xlsCell = array(
array("sn","订单号"),
array("source_name","收款方账号"),
array("target_account","收款方账号"),
array("game_name","适用游戏"),
array("handle_type","账号类型"),
array("num","转账数量"),
@ -2010,8 +2024,8 @@ class DownloadController extends BaseController {
}
$records[] = [
'id' => $log['id'],
'sn' => $log['sn'],
'target_account' => $targetAccount,
'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'],
@ -2049,6 +2063,7 @@ class DownloadController extends BaseController {
->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']);
//获取累计发放
$where = array(
"user_id"=>$value['user_id'],
@ -2092,6 +2107,7 @@ class DownloadController extends BaseController {
);
$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'] = "审核未通过";
}
@ -2109,8 +2125,8 @@ class DownloadController extends BaseController {
}
public function supportNumberListExcelInfo($id,$map) {
$xlsName = "扶持号管理";
$xlsCell = array(
$xlsName = "扶持号管理";
$xlsCell = array(
array('game_name',"产品名称"),
array('server_name',"区服"),
array('user_account',"测试账号"),
@ -2128,6 +2144,7 @@ class DownloadController extends BaseController {
->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 {
@ -2139,21 +2156,21 @@ class DownloadController extends BaseController {
}
public function arpuExcelInfo($id,$params) {
$xlsName = "ARPU统计";
$xlsCell = array(
$xlsName = "ARPU统计";
$xlsCell = array(
array('day','日期'),
array('payGameCount','付费游戏数'),
array('payGameCount','付费游戏数'),
array('loginCount','活跃用户'),
array('registerCount','新增用户'),
array('payUserCount','付费用户'),
array('newPayUserCount','新增付费用户'),
array('payAmount','付费总额'),
array('payRate','付费率'),
array('newPayAmount','新增付费额'),
array('historyPayCount','累计付费用户'),
array('arpu','ARPU'),
array('arppu','ARPPU'),
);
array('payUserCount','付费用户'),
array('newPayUserCount','新增付费用户'),
array('payAmount','付费总额'),
array('payRate','付费率'),
array('newPayAmount','新增付费额'),
array('historyPayCount','累计付费用户'),
array('arpu','ARPU'),
array('arppu','ARPPU'),
);
$dayList = $params["dayList"];
$arr = explode(',', $params['promote_id'][1]);
$params['promote_id'] = $arr;
@ -2556,26 +2573,26 @@ class DownloadController extends BaseController {
}
public function achievementExcelInfo($tid,$map) {
$xlsName = "推广员业绩";
$xlsCell = array(
$xlsName = "推广员业绩";
$xlsCell = array(
array('account','账号'),
array('real_name','姓名'),
array('create_role_count','创角数'),
array('real_name','姓名'),
array('create_role_count','创角数'),
array('create_role_user_count','创角用户'),
array('new_create_role_user_count','新创角用户'),
array('new_create_role_device_count','新创角设备'),
array('new_create_role_ip_count','新创角ip'),
array('login_user_count','登陆用户数'),
array('recharge_count','充值人数'),
array('recharge_user_count','充值次数'),
array('recharge_amount','充值总额'),
array('recharge_by_ban_coin','现金充值'),
array('recharge_by_coin','通用币充值'),
array('recharge_by_cash','绑定币充值'),
array('new_create_role_ip_count','新创角ip'),
array('login_user_count','登陆用户数'),
array('recharge_count','充值人数'),
array('recharge_user_count','充值次数'),
array('recharge_amount','充值总额'),
array('recharge_by_ban_coin','现金充值'),
array('recharge_by_coin','通用币充值'),
array('recharge_by_cash','绑定币充值'),
);
$params['isContainSubs'] =$map['isContainSubs'];
);
$params['isContainSubs'] = $map['isContainSubs'];
$params['basicPromotes'] = json_decode($map['basicPromotes'],TRUE);
$ids = $map['ids'];
$promotes = json_decode($map["promotes"],TRUE);
@ -2593,9 +2610,7 @@ class DownloadController extends BaseController {
}
$params['begin_time'] = $map['begin_time'];
$params['end_time'] = $map['end_time'];
// var_dump($params);die();
$promoteRepository = new PromoteRepository();
$promoteRepository = new PromoteRepository();
$createRoleCountList = $promoteRepository->getCreateRoleCountByIds($ids, $params);
$createRoleUserCountList = $promoteRepository->getCreateRoleUserCountByIds($ids, $params);
$newCreateRoleUserCountList = $promoteRepository->getNewCreateRoleUserCountByIds($ids, $params);
@ -2605,9 +2620,8 @@ class DownloadController extends BaseController {
$rechargeCountList = $promoteRepository->getRechargeCountByIds($ids, $params);
$rechargeUserCountList = $promoteRepository->getRechargeUserCountByIds($ids, $params);
$rechargeAmountList = $promoteRepository->getRechargeAmountByIds($ids, $params);
$records = [];
foreach ($promotes as $promote) {
foreach ($promotes as $promote) {
$id = $promote['id'];
$records[] = [
'id' => $id,
@ -2631,10 +2645,84 @@ class DownloadController extends BaseController {
}
$xlsData = [];
foreach ($records as $key1 => $value1) {
$xlsData[] = $value1;
$value1['account'] = $this->encryption($value1['account']);
$xlsData[] = $value1;
}
$this->exportExcel($xlsName, $xlsCell, $xlsData,$tid);
}
public function userRechargeExcelInfo($id,$map) {
$xlsName = "充值玩家";
$xlsCell = array(
array('user_account','玩家账号'),
array('game_name','游戏名称'),
array('server_name','游戏区服'),
array('sdk_version','平台'),
array('role_name','角色名'),
array('role_level','等级'),
array('recharge_cost','充值总额'),
array('recharge_count','充值次数'),
array('recharge_cost_today','今日充值'),
array('unlogin_day','未登录天数'),
array('play_time','最后登录时间'),
array('promote_account','组长|推广员'),
);
if(!empty($map['promote_id'])) {
$spendMap['promote_id'] = $map['promote_id'];
}
$map['create_time'] = ['between', [strtotime(date('Y-m-d 00:00:00')) - 31*24*3600, strtotime(date('Y-m-d 23:59:59'))]];
$roles = M('user_play_info','tab_')->where($map)->select();
$roleIds = array_column($roles, 'role_id');
$spendMap['pay_status'] = 1;
$spendMap['pay_game_status'] = 1;
if (count($roleIds) > 0) {
$spendMap['game_player_id'] = ['in', $roleIds];
} else {
$spendMap['_string'] = '1<>1';
}
$allRecharges = M('spend', 'tab_')->field('count(*) count, sum(cost) cost, game_player_id')->where($spendMap)->group('game_player_id')->select();
$allRecords = [];
foreach ($allRecharges as $recharge) {
$allRecords[$recharge['game_player_id']] = $recharge;
}
$map['pay_time'] = ['between', [strtotime(date('Y-m-d 00:00:00')), strtotime(date('Y-m-d 23:59:59'))]];
$todayRecharges = M('spend', 'tab_')->field('sum(cost) cost, game_player_id')->where($map)->group('game_player_id')->select();
$todayRecords = [];
foreach ($todayRecharges as $recharge) {
$todayRecords[$recharge['game_player_id']] = $recharge;
}
$records = [];
foreach ($roles as $role) {
$records[] = [
'user_account' => $role['user_account'],
'game_name' => $role['game_name'],
'role_name' => $role['role_name'],
'role_id' => $role['role_id'],
'role_level' => $role['role_level'],
'server_id' => $role['server_id'],
'server_name' => $role['server_name'],
'recharge_cost' => isset($allRecords[$role['role_id']]) ? round(floatval($allRecords[$role['role_id']]['cost']), 2) : 0,
'recharge_count' => isset($allRecords[$role['role_id']]) ? $allRecords[$role['role_id']]['count'] : 0,
'recharge_cost_today' => isset($todayRecords[$role['role_id']]) ? round(floatval($todayRecords[$role['role_id']]['cost']), 2) : 0,
'play_time' => $role['play_time'],
'play_ip' => $role['play_ip'],
'promote_id' => $role['promote_id'],
'promote_account' => $role['promote_account'],
'sdk_version' => $role['sdk_version'],
'unlogin_day' => intval((strtotime(date('Y-m-d 00:00:00')) - strtotime(date('Y-m-d 00:00:00', $role['play_time']))) / (24 * 3600))
];
}
$xlsData = [];
foreach ($records as $key1 => $value1) {
$value1['user_account'] = $this->encryption($value1['user_account']);
$xlsData[] = $value1;
}
$this->exportExcel($xlsName, $xlsCell, $xlsData,$id);
}
public function rechargeExcelInfo($id,$map) {
$xlsName = "订单查询";
@ -2658,16 +2746,18 @@ class DownloadController extends BaseController {
->join('left join tab_promote on tab_spend.promote_id = tab_promote.id')
->where($map)
->order('tab_spend.id desc')
->limit(1)
->select();
$xlsData = [];
foreach ($data as $key1 => $value1) {
$value1['pay_way'] = $this->payWay[$value1['pay_way']];
$value1['pay_time'] = date('Y-m-d H:i:s',$value1['pay_time']);
$value1['p_p_proinfo'] = $value1['pro_account'].'('.$value1['pro_real_name'].')';
$value1['pay_way'] = $this->payWay[$value1['pay_way']];
$value1['pay_time'] = date('Y-m-d H:i:s',$value1['pay_time']);
$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'].')';
if(!empty($value1['chain'])) {
$value1['proinfo'] = $value1['pro_account'].'('.$value1['pro_real_name'].')';
// $value1['user_account'] = substr_replace($value1['user_account'],'************',3,12);
$value1['user_account'] = $this->encryption($value1['user_account']);
$value1['order_number'] = $this->encryption($value1['order_number']);
if(!empty($value1['chain'])) {
$chain = trim($value1['chain'],'/');
$chainArr = explode('/', $chain);
if(!empty($chainArr[1])) {
@ -2872,5 +2962,22 @@ class DownloadController extends BaseController {
}
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);
}
}

Loading…
Cancel
Save