推广员指标管理

master
chenxiaojun 5 years ago
parent ef41dbfcee
commit 535f185e37

@ -45,7 +45,10 @@ class PromoteRepository {
if (isset($params['sdk_version'])) { if (isset($params['sdk_version'])) {
$map['sdk_version'] = $params['sdk_version']; $map['sdk_version'] = $params['sdk_version'];
} }
if (isset($params['begin_time']) && isset($params['begin_time']) && isset($params['time_column'])) { if (isset($params['role_level'])) {
$map['role_level'] = $params['role_level'];
}
if (isset($params['begin_time']) && isset($params['end_time']) && isset($params['time_column'])) {
$map[$params['time_column']] = ['between', [$params['begin_time'], $params['end_time']]]; $map[$params['time_column']] = ['between', [$params['begin_time'], $params['end_time']]];
} }
if (isset($params['lock_status'])) { if (isset($params['lock_status'])) {

@ -1128,6 +1128,7 @@ class QueryController extends BaseController
$newDeviceNumList = $userRepository->getNewCreateRoleDeviceCountByDay($params);//新创角设备 $newDeviceNumList = $userRepository->getNewCreateRoleDeviceCountByDay($params);//新创角设备
$newIpNumList = $userRepository->getNewCreateRoleIpCountByDay($params);//新创角IP $newIpNumList = $userRepository->getNewCreateRoleIpCountByDay($params);//新创角IP
$loginUserNumList = $userRepository->getLoginCountGroupByDayNew($params);//登录用户数 $loginUserNumList = $userRepository->getLoginCountGroupByDayNew($params);//登录用户数
if ($this->canViewUserRecharge) {
$spendUserNumList = $spendRepository->getPayUserCountGroupByDayNew($params);//充值人数 $spendUserNumList = $spendRepository->getPayUserCountGroupByDayNew($params);//充值人数
$spendNumList = $spendRepository->getPayCountGroupByDay($params);//充值次数 $spendNumList = $spendRepository->getPayCountGroupByDay($params);//充值次数
$spendAllAmountList = $spendRepository->getPayAmountGroupByDayAndType($params);//充值总额 $spendAllAmountList = $spendRepository->getPayAmountGroupByDayAndType($params);//充值总额
@ -1137,6 +1138,7 @@ class QueryController extends BaseController
$spendGenericList = $spendRepository->getPayAmountGroupByDayAndType($params);//通用币充值 $spendGenericList = $spendRepository->getPayAmountGroupByDayAndType($params);//通用币充值
$params['pay_way'] = -1; $params['pay_way'] = -1;
$spendBindingList = $spendRepository->getPayAmountGroupByDayAndType($params);//绑定币充值 $spendBindingList = $spendRepository->getPayAmountGroupByDayAndType($params);//绑定币充值
}
$allData['role_num'] = 0; $allData['role_num'] = 0;
$allData['user_num'] = 0; $allData['user_num'] = 0;
@ -1144,6 +1146,7 @@ class QueryController extends BaseController
$allData['new_device_num'] = 0; $allData['new_device_num'] = 0;
$allData['new_ip_num'] = 0; $allData['new_ip_num'] = 0;
$allData['login_user_num'] = 0; $allData['login_user_num'] = 0;
if ($this->canViewUserRecharge) {
$allData['spend_user_num'] = 0; $allData['spend_user_num'] = 0;
$allData['spend_num'] = 0; $allData['spend_num'] = 0;
$allData['spend_all_amount'] = 0; $allData['spend_all_amount'] = 0;
@ -1152,9 +1155,10 @@ class QueryController extends BaseController
$allData['spend_binding'] = 0; $allData['spend_binding'] = 0;
$allData['spend_discount'] = 0; $allData['spend_discount'] = 0;
$allData['spend_voucher'] = 0; $allData['spend_voucher'] = 0;
}
foreach ($dayList as $day) { foreach ($dayList as $day) {
$date = date('Ymd', strtotime($day)); $date = date('Ymd', strtotime($day));
$records[] = [ $record = [
'day' => $date, 'day' => $date,
'role_num' => $roleNumList[$day], 'role_num' => $roleNumList[$day],
'user_num' => $userNumList[$day], 'user_num' => $userNumList[$day],
@ -1162,14 +1166,6 @@ class QueryController extends BaseController
'new_device_num' => $newDeviceNumList[$day], 'new_device_num' => $newDeviceNumList[$day],
'new_ip_num' => $newIpNumList[$day], 'new_ip_num' => $newIpNumList[$day],
'login_user_num' => $loginUserNumList[$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['role_num'] += $roleNumList[$day];
@ -1178,6 +1174,17 @@ class QueryController extends BaseController
$allData['new_device_num'] += $newDeviceNumList[$day]; $allData['new_device_num'] += $newDeviceNumList[$day];
$allData['new_ip_num'] += $newIpNumList[$day]; $allData['new_ip_num'] += $newIpNumList[$day];
$allData['login_user_num'] += $loginUserNumList[$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_user_num'] += $spendUserNumList[$day];
$allData['spend_num'] += $spendNumList[$day]; $allData['spend_num'] += $spendNumList[$day];
$allData['spend_all_amount'] = bcadd($allData['spend_all_amount'], $spendAllAmountList[$day], 2); $allData['spend_all_amount'] = bcadd($allData['spend_all_amount'], $spendAllAmountList[$day], 2);
@ -1187,6 +1194,8 @@ class QueryController extends BaseController
$allData['spend_discount'] = bcadd($allData['spend_discount'], 0, 2); $allData['spend_discount'] = bcadd($allData['spend_discount'], 0, 2);
$allData['spend_voucher'] = bcadd($allData['spend_voucher'], 0, 2); $allData['spend_voucher'] = bcadd($allData['spend_voucher'], 0, 2);
} }
$records[] = $record;
}
foreach ($dayListReverse as $day) { foreach ($dayListReverse as $day) {
$date = date('Ymd', strtotime($day)); $date = date('Ymd', strtotime($day));
$summaryData['date'][] = $date; $summaryData['date'][] = $date;
@ -1194,10 +1203,12 @@ class QueryController extends BaseController
$summaryData['user_num'][] = $userNumList[$day]; $summaryData['user_num'][] = $userNumList[$day];
$summaryData['new_user_num'][] = $newUserNumList[$day]; $summaryData['new_user_num'][] = $newUserNumList[$day];
$summaryData['new_device_num'][] = $newDeviceNumList[$day]; $summaryData['new_device_num'][] = $newDeviceNumList[$day];
if ($this->canViewUserRecharge) {
$summaryData['spend_user_num'][] = $spendUserNumList[$day]; $summaryData['spend_user_num'][] = $spendUserNumList[$day];
$summaryData['spend_all_amount'][] = $spendAllAmountList[$day]; $summaryData['spend_all_amount'][] = $spendAllAmountList[$day];
} }
} }
}
$serverData = $this->getServer($relationGameId, $sdkVersion); $serverData = $this->getServer($relationGameId, $sdkVersion);
@ -1314,6 +1325,7 @@ class QueryController extends BaseController
$newDeviceNumList = $userRepository->getNewCreateRoleDeviceCountByGame($params);//新创角设备 $newDeviceNumList = $userRepository->getNewCreateRoleDeviceCountByGame($params);//新创角设备
$newIpNumList = $userRepository->getNewCreateRoleIpCountByGame($params);//新创角IP $newIpNumList = $userRepository->getNewCreateRoleIpCountByGame($params);//新创角IP
$loginUserNumList = $userRepository->getLoginCountGroupByGame($params);//登录用户数 $loginUserNumList = $userRepository->getLoginCountGroupByGame($params);//登录用户数
if ($this->canViewUserRecharge) {
$spendUserNumList = $spendRepository->getPayUserCountGroupByGame($params);//充值人数 $spendUserNumList = $spendRepository->getPayUserCountGroupByGame($params);//充值人数
$spendNumList = $spendRepository->getPayCountGroupByGame($params);//充值次数 $spendNumList = $spendRepository->getPayCountGroupByGame($params);//充值次数
$spendAllAmountList = $spendRepository->getPayAmountGroupByGameAndType($params);//充值总额 $spendAllAmountList = $spendRepository->getPayAmountGroupByGameAndType($params);//充值总额
@ -1323,9 +1335,10 @@ class QueryController extends BaseController
$spendGenericList = $spendRepository->getPayAmountGroupByGameAndType($params);//通用币充值 $spendGenericList = $spendRepository->getPayAmountGroupByGameAndType($params);//通用币充值
$params['pay_way'] = -1; $params['pay_way'] = -1;
$spendBindingList = $spendRepository->getPayAmountGroupByGameAndType($params);//绑定币充值 $spendBindingList = $spendRepository->getPayAmountGroupByGameAndType($params);//绑定币充值
}
foreach ($data as &$list) { foreach ($data as &$list) {
$gameId = $list['game_id']; $gameId = $list['game_id'];
$records[] = [ $record = [
'game_id' => $gameId, 'game_id' => $gameId,
'game_name' => $list['game_name'], 'game_name' => $list['game_name'],
'sdk_version' => $list['sdk_version'], 'sdk_version' => $list['sdk_version'],
@ -1335,15 +1348,19 @@ class QueryController extends BaseController
'new_device_num' => $newDeviceNumList[$gameId], 'new_device_num' => $newDeviceNumList[$gameId],
'new_ip_num' => $newIpNumList[$gameId], 'new_ip_num' => $newIpNumList[$gameId],
'login_user_num' => $loginUserNumList[$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,
]; ];
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;
}
$records[] = $record;
} }
$params['all_data'] = 1; $params['all_data'] = 1;
$params['game_ids'] = $allGameIs; $params['game_ids'] = $allGameIs;
@ -1353,6 +1370,7 @@ class QueryController extends BaseController
$allData['new_device_num'] = $userRepository->getNewCreateRoleDeviceCountByGame($params);//新创角设备 $allData['new_device_num'] = $userRepository->getNewCreateRoleDeviceCountByGame($params);//新创角设备
$allData['new_ip_num'] = $userRepository->getNewCreateRoleIpCountByGame($params);//新创角IP $allData['new_ip_num'] = $userRepository->getNewCreateRoleIpCountByGame($params);//新创角IP
$allData['login_user_num'] = $userRepository->getLoginCountGroupByGame($params);//登录用户数 $allData['login_user_num'] = $userRepository->getLoginCountGroupByGame($params);//登录用户数
if ($this->canViewUserRecharge) {
$allData['spend_user_num'] = $spendRepository->getPayUserCountByGame($params);//充值人数 $allData['spend_user_num'] = $spendRepository->getPayUserCountByGame($params);//充值人数
$allData['spend_num'] = $spendRepository->getPayCountByGame($params);//充值次数 $allData['spend_num'] = $spendRepository->getPayCountByGame($params);//充值次数
unset($params['pay_way']); unset($params['pay_way']);
@ -1367,6 +1385,7 @@ class QueryController extends BaseController
$allData['spend_voucher'] = '0.00'; $allData['spend_voucher'] = '0.00';
} }
} }
}
$serverData = $this->getServer($relationGameId, $sdkVersion); $serverData = $this->getServer($relationGameId, $sdkVersion);
@ -2093,9 +2112,15 @@ class QueryController extends BaseController
// $newCreateRoleDeviceCountList = $promoteRepository->getNewCreateRoleDeviceCountByIds($ids, $params); // $newCreateRoleDeviceCountList = $promoteRepository->getNewCreateRoleDeviceCountByIds($ids, $params);
$newCreateRoleIpCountList = $promoteRepository->getNewCreateRoleIpCountByIds($ids, $params); $newCreateRoleIpCountList = $promoteRepository->getNewCreateRoleIpCountByIds($ids, $params);
$loginUserCountList = $promoteRepository->getLoginUserCountByIds($ids, $params); $loginUserCountList = $promoteRepository->getLoginUserCountByIds($ids, $params);
$rechargeCountList = [];
$rechargeUserCountList = [];
$rechargeAmountList = [];
if ($this->canViewUserRecharge) {
$rechargeCountList = $promoteRepository->getRechargeCountByIds($ids, $params); $rechargeCountList = $promoteRepository->getRechargeCountByIds($ids, $params);
$rechargeUserCountList = $promoteRepository->getRechargeUserCountByIds($ids, $params); $rechargeUserCountList = $promoteRepository->getRechargeUserCountByIds($ids, $params);
$rechargeAmountList = $promoteRepository->getRechargeAmountByIds($ids, $params); $rechargeAmountList = $promoteRepository->getRechargeAmountByIds($ids, $params);
}
if (I('p', 1) == 1) { if (I('p', 1) == 1) {
$selfParams = $params; $selfParams = $params;
@ -2106,10 +2131,7 @@ class QueryController extends BaseController
// $selfNewCreateRoleDeviceCountList = $promoteRepository->getNewCreateRoleDeviceCountByIds([$parent['id']], $selfParams); // $selfNewCreateRoleDeviceCountList = $promoteRepository->getNewCreateRoleDeviceCountByIds([$parent['id']], $selfParams);
$selfNewCreateRoleIpCountList = $promoteRepository->getNewCreateRoleIpCountByIds([$parent['id']], $selfParams); $selfNewCreateRoleIpCountList = $promoteRepository->getNewCreateRoleIpCountByIds([$parent['id']], $selfParams);
$selfLoginUserCountList = $promoteRepository->getLoginUserCountByIds([$parent['id']], $selfParams); $selfLoginUserCountList = $promoteRepository->getLoginUserCountByIds([$parent['id']], $selfParams);
$selfRechargeCountList = $promoteRepository->getRechargeCountByIds([$parent['id']], $selfParams); $record = [
$selfRechargeUserCountList = $promoteRepository->getRechargeUserCountByIds([$parent['id']], $selfParams);
$selfRechargeAmountList = $promoteRepository->getRechargeAmountByIds([$parent['id']], $selfParams);
$records[] = [
'id' => $parent['id'], 'id' => $parent['id'],
'account' => $parent['account'], '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').'**', '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').'**',
@ -2120,18 +2142,24 @@ class QueryController extends BaseController
// 'new_create_role_device_count' => $selfNewCreateRoleDeviceCountList[$parent['id']], // 'new_create_role_device_count' => $selfNewCreateRoleDeviceCountList[$parent['id']],
'new_create_role_ip_count' => $selfNewCreateRoleIpCountList[$parent['id']], 'new_create_role_ip_count' => $selfNewCreateRoleIpCountList[$parent['id']],
'login_user_count' => $selfLoginUserCountList[$parent['id']], 'login_user_count' => $selfLoginUserCountList[$parent['id']],
'recharge_count' => $selfRechargeCountList[$parent['id']],
'recharge_user_count' => $selfRechargeUserCountList[$parent['id']],
'recharge_amount' => $selfRechargeAmountList[$parent['id']]['ban_coin'] + $selfRechargeAmountList[$parent['id']]['coin'] + $selfRechargeAmountList[$parent['id']]['cash'],
'recharge_by_ban_coin' => $selfRechargeAmountList[$parent['id']]['ban_coin'],
'recharge_by_coin' => $selfRechargeAmountList[$parent['id']]['coin'],
'recharge_by_cash' => $selfRechargeAmountList[$parent['id']]['cash'],
'current_display' => $currentDisplay, '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) { foreach ($promotes as $promote) {
$id = $promote['id']; $id = $promote['id'];
$records[] = [ $record = [
'id' => $id, 'id' => $id,
'account' => $promote['account'], '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').'**', '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').'**',
@ -2142,14 +2170,17 @@ class QueryController extends BaseController
// 'new_create_role_device_count' => $newCreateRoleDeviceCountList[$id], // 'new_create_role_device_count' => $newCreateRoleDeviceCountList[$id],
'new_create_role_ip_count' => $newCreateRoleIpCountList[$id], 'new_create_role_ip_count' => $newCreateRoleIpCountList[$id],
'login_user_count' => $loginUserCountList[$id], 'login_user_count' => $loginUserCountList[$id],
'recharge_count' => $rechargeCountList[$id],
'recharge_user_count' => $rechargeUserCountList[$id],
'recharge_amount' => $rechargeAmountList[$id]['ban_coin'] + $rechargeAmountList[$id]['coin'] + $rechargeAmountList[$id]['cash'],
'recharge_by_ban_coin' => $rechargeAmountList[$id]['ban_coin'],
'recharge_by_coin' => $rechargeAmountList[$id]['coin'],
'recharge_by_cash' => $rechargeAmountList[$id]['cash'],
'current_display' => '', '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;
} }
} else { } else {
$timeout = 1; $timeout = 1;
@ -2179,4 +2210,206 @@ class QueryController extends BaseController
$this->ajaxReturn($data); $this->ajaxReturn($data);
} }
//推广员指标管理
public function promoteQuota()
{
$time = I('time', date('Y-m-d'));
if (!empty($time)) {
$defaultTime = $time;
} else {
$nowTime = date('Y-m-d', time());
$defaultTime = date('Y-m-d', strtotime('-6 day', time())) . " 至 " . $nowTime;
$time = $defaultTime;
}
$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 = '自己';
}
$searchLevel = $parent['level'] + 1;
$searchLevelName = $promoteService->getLevelName($searchLevel);
$games = get_promote_serach_game();
$subPromotes = M('promote', 'tab_')->field(['id', 'account', 'real_name'])->where(['parent_id' => $parent['id']])->select();
$map = ['parent_id' => $parent['id']];
if ($promoteId > 0) {
$map['id'] = $promoteId;
}
$query = M('promote', 'tab_')->field(['id', 'account', 'real_name', 'level'])->where($map);
list($promotes, $pagination, $count) = $this->paginate($query);
$ids = array_column($promotes, '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;
}
}
}
$params = [
'isContainSubs' => true,
'basicPromotes' => $basicPromotes,
];
if ($relationGameId != 0 || $sdkVersion != 0) {
$gameIds = gameSearch($relationGameId, $sdkVersion);
$params['game_id'] = ['in', $gameIds];
}
if ($serverId > 0) {
$params['server_id'] = $serverId;
}
$where = $params;
if ($sdkVersion != 0) {
$where['sdk_version'] = $sdkVersion;
}
$game = $this->getGame($where);
if ($levelBegin !== '' || $levelEnd !== '') {
if ($levelBegin !== '' && $levelEnd !== '') {
$levelBegin = intval($levelBegin);
$levelEnd = intval($levelEnd);
if ($levelBegin > $levelEnd) {
$this->error('角色等级范围错误');
}
$params['role_level'] = ['between', [$levelBegin, $levelEnd]];
} elseif ($levelBegin !== '' && $levelEnd === '') {
$levelBegin = intval($levelBegin);
$params['role_level'] = ['egt', $levelBegin];
} elseif ($levelBegin === '' && $levelEnd !== '') {
$levelEnd = intval($levelEnd);
$params['role_level'] = ['elt', $levelEnd];
}
}
list($beginTime, $endTime) = $this->getBetweenTime($time);
$params['begin_time'] = $beginTime;
$params['end_time'] = $endTime;
$records = [];
$promoteRepository = new PromoteRepository();
$createRoleCountList = $promoteRepository->getCreateRoleCountByIds($ids, $params);
if (I('p', 1) == 1) {
$selfParams = $params;
$selfParams['isContainSubs'] = false;
$selfCreateRoleCountList = $promoteRepository->getCreateRoleCountByIds([$parent['id']], $selfParams);
$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;
}
$this->assign('prevParentId', $prevParentId);
$this->assign('searchLevelName', $searchLevelName);
$this->assign('games', $games);
$this->assign('parent', $parent);
$this->assign('subPromotes', $subPromotes);
$this->assign('records', $records);
$this->assign('pagination', $pagination);
$this->assign('parentId', $parentId);
$this->assign('count', $count);
$this->assign('time', $defaultTime);
$this->assign('meta_title', '推广员指标管理');
$this->display();
}
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['game_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['game_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');
}
} }

@ -0,0 +1,178 @@
<extend name="Public/promote_base"/>
<block name="css">
<link href="__CSS__/20180207/account.css" rel="stylesheet" >
<style>
.form-group {
float: left;
margin-bottom: 10px;
}
.form-group label {
line-height: 34px;
height: 34px;
}
</style>
</block>
<block name="body">
<div class="page-list normal_list promote-mychlid-list">
<div class="trunk-title">
<div class="location">
<div class="location-container">当前位置:<span>数据管理></span><span>团队推广业绩</span></div>
</div>
<img src="__IMG__/20180207/icon_normal_game.png">
<span class="title_main">{$meta_title}</span>
</div>
<div class="trunk-content article">
<div class="trunk-search clearfix">
<form action="{:U('Query/promoteQuota',['row'=>I('get.row')])}" method="post" enctype="multipart/form-data">
<input type="hidden" name="parent_id" value="{:I('parent_id', 0)}">
<div class="form-group normal_space">
<select name="promote_id" class="reselect select_gallery" style="width: 220px;" >
<option value="0">请选择{$searchLevelName}</option>
<volist name="subPromotes" id="promote">
<option ba-id="{$promote.id}" value="{$promote.id}" <if condition="I('promote_id') == $promote['id']">selected</if>>{$promote.account}({$promote.real_name})</option>
</volist>
</select>
</div>
<div class="form-group normal_space">
<select id="game-select" name="relation_game_id" class="reselect select_gallery" style="width: 220px;" >
<option value="0">请选择游戏</option>
<volist name="games" id="game">
<option value="{$game.relation_game_id}" <if condition="I('relation_game_id') eq $game['relation_game_id']">selected</if>>{$game.relation_game_name}</option>
</volist>
</select>
</div>
<div class="form-group normal_space">
<select id="sdk_version" name="sdk_version" class="reselect select_gallery" style="width: 220px;" >
<option value="0">请选择设备类型</option>
<option value="1" <if condition="I('sdk_version') === '1'">selected</if>>Andriod</option>
<option value="2" <if condition="I('sdk_version') === '2'">selected</if>>IOS</option>
</select>
</div>
<div class="form-group normal_space">
<select id="server-select" name="server_id" class="reselect select_gallery" style="width: 220px;" data-server="{:I('server_id', 0)}" >
<option value="0">请选择区服</option>
</select>
</div>
<div class="form-group normal_space fr">
<input type="text" class="txt range-date" name="time" placeholder="创角时间" value="{$time}" >
</div>
<div class="form-group">
<input type="submit" class="submit normal_space" value="查询">
</div>
<?php if ($prevParentId > 0):?>
<div class="form-group">
<a class="submit normal_space" href="{:U('Query/promoteQuota', ['row'=>I('get.row'), 'parent_id' => $prevParentId,'time'=>$time])}" style="line-height: 36px; display: inline-block; text-align: center; background: #E5E5E5; color: #2bd8ed; cursor: pointer;">返回上级</a>
</div>
<?php endif;?>
</form>
</div>
<div class="trunk-list list_normal">
<table class="table normal_table">
<tr class="odd">
<th>推广员</th>
<th>游戏名称</th>
<th>平台</th>
<th>游戏区服</th>
<th>角色数量</th>
<?php if($parent['level'] < 4):?>
<th>操作</th>
<?php endif;?>
</tr>
<empty name="records">
<tr><td colspan="14" style="text-align: center;height: 45vh;"><img src="__IMG__/20180207/icon_wushujv2.png"/><p style="line-height: 40px;color: #A5A5A5;">暂无数据</p></td></tr>
<else />
<volist name="records" id="record" mod="2">
<tr data-id="{$vo.id}" class="<eq name='mod' value='1'>odd</eq>">
<td>{$record.account}({$record.real_name})
<?php if($record['current_display'] != ''):?>
<span style="color: #06C;">[{$record['current_display']}]</span>
<?php endif;?>
</td>
<td>{$record.game_name}</td>
<td>{$record.sdk_version_text}</td>
<td>{$record.server_name}</td>
<td>{$record.role_num}</td>
<?php if($parent['level'] < 4):?>
<td>
<?php if($record['current_display'] == '' && $record['level'] < 4):?>
<a href="{:U('Query/promoteQuota', ['parent_id' => $record['id'], 'time' => $time])}">查看下级</a>
<?php endif;?>
</td>
<?php endif;?>
</tr>
</volist>
</empty>
</table>
</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>
<?php endif ;?>
{$pagination}
</div>
</div>
<div class="page-explain promote-mychlid-explain">
<div class="trunk-content article border_normal">
<!-- <table class="desccontent">
<tr><td class="title" style="width: 100px;display: inline-block;">二级渠道说明:</td><td class="det">推广员默认为一级渠道,一级渠道可通过推广员后台新增二级渠道;二级渠道由一级渠道管理开启权限,并由一级渠道给二级渠道结算,结算可到财务管理操作。</td></tr>
</table>-->
</div>
</div>
</div>
</block>
<block name="script">
<link rel="stylesheet" href="__STATIC__/flatpickr/flatpickr.min.css">
<script src="__STATIC__/flatpickr/flatpickr.min.js"></script>
<script src="__STATIC__/flatpickr/l10n/zh.js"></script>
<script type="text/javascript" src="__JS__/20170831/select2.min.js"></script>
<eq name='timeout' value='1'>
<script>
layer.msg('时间间隔不能超过7天');
</script>
</eq>
<script type="text/javascript">
$(function() {
var defaultDate = $('.range-date').val()
defaultDate = defaultDate == '' ? [] : defaultDate.split(' 至 ')
$('.range-date').flatpickr({
mode: 'range',
locale: 'zh',
dateFormat: "Y-m-d",
defaultDate: defaultDate,
})
$('.select_gallery').select2()
var gameId = $('#game-select').val();
var sdkVersion = $('#sdk_version').val();
var defaultServerId = $('#server-select').attr('data-server');
getGameServers(gameId, sdkVersion, defaultServerId)
$('#game-select,#sdk_version').on({
change: function name() {
gameId = $('#game-select').val();
sdkVersion = $('#sdk_version').val();
getGameServers(gameId, sdkVersion, 0);
}
});
function getGameServers(gameId, sdkVersion, defaultServerId) {
$.ajax({
url: "{:U('Query/getGameServers')}",
dataType: 'json',
data: {game_id: gameId, sdk_version: sdkVersion},
success: function(response) {
var options = '<option value="0">请选择区服</option>'
for (var i in response.data.servers) {
var server = response.data.servers[i]
var selected = ''
if (defaultServerId > 0 && server.id==defaultServerId) {
selected = 'selected'
}
options += '<option value="' + server.server_id + '"' + selected + '>' + server.server_name + '</option>'
}
$('#server-select').html(options)
$("#server-select").val(defaultServerId).trigger("change")
}
})
}
})
</script>
</block>
Loading…
Cancel
Save