推广员指标下载

master
sunke 5 years ago
parent 8c43defff3
commit 5974047e1c

@ -1446,6 +1446,183 @@ class DownloadController extends BaseController {
$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'));
@ -1863,15 +2040,142 @@ class DownloadController extends BaseController {
case "平台币充值":
$this->orderlistExcelInfo($id,$map);
break;
case "玩家行为日志";
case "玩家行为日志":
$this->playactionExcelInfo($id,$map);
break;
case "推广员指标":
$this->promotequotaExcelInfo($id,$map);
break;
case "推广员详情":
$this->promotequotaDtlExcelInfo($id,$map);
break;
default:
break;
}
}
public function promotequotaDtlExcelInfo($id,$map) {
$xlsName = "推广员详情";
$xlsCell = array(
array('user_account','玩家账号'),
array('promote_account','推广账号'),
array('game_name','游戏名称'),
array('sdk_version','平台'),
array('server_name','游戏区服'),
array('role_name','角色名'),
array('role_level','等级'),
array('create_time','创建时间'),
);
$records = M('user_play_info', 'tab_')->where($map)->order('create_time desc')->select();
foreach ($records as $key => $value) {
//订单隐藏算法
$orderLen = strlen($value['user_account']);
$strLen = 3;
$hideChar = '';
if ($orderLen <= 8) { $strLen = 2;}
for ($i = 0; $i < $orderLen - $strLen * 2; $i++) {
$hideChar .= '*';
}
$records[$key]['user_account'] = substr($value['user_account'], 0, $strLen) . $hideChar . substr($value['user_account'], $orderLen - $strLen);
}
$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 promotequotaExcelInfo($id,$map) {
$xlsName = "推广员指标";
$xlsCell = array(
array('account','账号'),
array('real_name','姓名'),
array('game_name','游戏名称'),
array('sdk_version_text','平台'),
array('server_name','游戏区服'),
array('role_num','角色数量'),
);
$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,$id);
}
public function playactionExcelInfo($id,$map) {
$xlsName = "玩家行为日志";
$xlsCell = array(
@ -3017,21 +3321,19 @@ class DownloadController extends BaseController {
public function achievementExcelInfo($tid,$map) {
$xlsName = "推广员业绩";
$xlsCell = array(
array('account','账号'),
array('real_name','姓名'),
array('create_role_count','创角数'),
array('create_role_user_count','创角用户'),
array('new_create_role_user_count','新创角用户'),
array('new_create_role_ip_count','新创角ip'),
array('login_user_count','登陆用户数'),
array('recharge_user_count','充值人数'),
array('recharge_count','充值次数'),
array('recharge_amount','充值总额'),
array('recharge_by_ban_coin','绑定币充值'),
array('recharge_by_coin','通用币充值'),
array('recharge_by_cash','现金充值'),
array('account','账号'),
array('real_name','姓名'),
array('create_role_count','创角数'),
array('create_role_user_count','创角用户'),
array('new_create_role_user_count','新创角用户'),
array('new_create_role_ip_count','新创角ip'),
array('login_user_count','登陆用户数'),
array('recharge_user_count','充值人数'),
array('recharge_count','充值次数'),
array('recharge_amount','充值总额'),
array('recharge_by_ban_coin','绑定币充值'),
array('recharge_by_coin','通用币充值'),
array('recharge_by_cash','现金充值'),
);
$params['isContainSubs'] = $map['isContainSubs'];
$params['basicPromotes'] = json_decode($map['basicPromotes'],TRUE);
@ -3675,6 +3977,40 @@ class DownloadController extends BaseController {
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;
}
}

@ -232,7 +232,7 @@ class PromoteController extends BaseController
$this->assign("rules", $rules);
$this->assign("rules_count", count($rules));
$redis = new \Org\RedisSDK\Redis(['host'=>'127.0.0.1','port'=>6379],[]);
/* $redis = new \Org\RedisSDK\Redis(['host'=>'127.0.0.1','port'=>6379],[]);
$cacheKey = "pop:rule:set";
if (!$redis->sIsMember($cacheKey, get_pid())) {
$currentTime = strtotime(date('Y-m-d'));
@ -245,7 +245,7 @@ class PromoteController extends BaseController
->select();
} else {
$match_rules = [];
}
} */
$this->assign("match_rules_id", $match_rules ? json_encode(array_column($match_rules, 'id')) : 'null');

@ -118,7 +118,7 @@
</div>
<div class="pagenation clearfix">
<?php if ($loginer['level'] !== 4) :?>
<a id="sch-btn" href="{:U('download/achievement_data_export',array_merge(['parent_id'=>$parentId,'time'=>$time],I('post.')))}" class="ajax-get">导出</a>
<a id="sch-btn" href="{:U('download/promoteQuota_data_export',array_merge(['parent_id'=>$parentId,'time'=>$time],I('post.')))}" class="ajax-get">导出</a>
<?php endif ;?>
{$pagination}
</div>

@ -68,7 +68,7 @@
</div>
<div class="pagenation clearfix">
<?php if ($loginer['level'] !== 4) :?>
<a id="sch-btn" data-href="{:U('download/userRoles_data_export',array_merge(['xlsname'=>'ceshi'],I('get.')))}" class="ajax-get">导出</a>
<a id="sch-btn" data-href="{:U('download/quotaDtl_data_export',array_merge(['xlsname'=>'ceshi'],I('get.')))}" class="ajax-get">导出</a>
<?php endif ;?>
{$pagination}
</div>

Loading…
Cancel
Save