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.
713 lines
31 KiB
PHP
713 lines
31 KiB
PHP
<?php
|
|
|
|
namespace Base\Repository;
|
|
|
|
use Base\Service\GameService;
|
|
use Base\Tool\Registry;
|
|
use Base\Service\PromoteService;
|
|
|
|
class TestingResourceRepository
|
|
{
|
|
public static $provideStatusList = [
|
|
'0' => '待发放',
|
|
'1' => '已发放',
|
|
'2' => '异常',
|
|
];
|
|
|
|
public static $verifyStatusList = [
|
|
'0' => '未审核',
|
|
'1' => '审核通过',
|
|
'2' => '审核拒绝',
|
|
];
|
|
|
|
public static $userVerifyStatusList = [
|
|
'0' => '待审核',
|
|
'1' => '审核通过',
|
|
'2' => '审核拒绝',
|
|
];
|
|
|
|
public static $userStatusList = [
|
|
'1' => '正常',
|
|
'2' => '警告',
|
|
'3' => '禁用',
|
|
];
|
|
|
|
public function getProvideStatusText($provideStatus)
|
|
{
|
|
return self::$provideStatusList[$provideStatus] ?? '未知';
|
|
}
|
|
|
|
public function getVerifyStatusText($verifyStatus)
|
|
{
|
|
return self::$verifyStatusList[$verifyStatus] ?? '未知';
|
|
}
|
|
|
|
public function getGameRoleId($gameId, $roleId)
|
|
{
|
|
return $gameId . '#' . $roleId;
|
|
}
|
|
|
|
public function getGameSettings($isRefresh = false)
|
|
{
|
|
$settings = Registry::get('testing_game_settings');
|
|
if ($isRefresh || is_null($settings)) {
|
|
$settings = M('testing_game_setting', 'tab_')->where('1=1')->select();
|
|
Registry::set('testing_game_settings', $settings);
|
|
}
|
|
return $settings;
|
|
}
|
|
|
|
public function getGameSetting($baseGameId)
|
|
{
|
|
return M('testing_game_setting', 'tab_')->where(['base_game_id' => $baseGameId])->find();
|
|
}
|
|
|
|
public function getGameSettingByGameId($gameId)
|
|
{
|
|
$gameRepository = new GameRepository();
|
|
$baseGame = $gameRepository->getBaseGameByGameId($gameId);
|
|
$baseGameId = $baseGame ? $baseGame['id'] : 0;
|
|
return $this->getGameSetting($baseGameId);
|
|
}
|
|
|
|
public function getHadSettingGameIds()
|
|
{
|
|
$baseGameIds = M('testing_game_setting', 'tab_')->getField('base_game_id', true);
|
|
if (empty($baseGameIds)) {
|
|
return [];
|
|
}
|
|
$baseGames = M('base_game', 'tab_')->where(['id' => ['in', $baseGameIds]])->select();
|
|
return array_merge(array_column($baseGames, 'android_game_id'), array_column($baseGames, 'ios_game_id'));
|
|
}
|
|
|
|
public function getBatchesQuery($params, $promote = null)
|
|
{
|
|
$gameId = $params['game_id'] ?? 0;
|
|
$serverId = $params['server_id'] ?? '';
|
|
$createTimeStart = $params['create_time_start'] ?? '';
|
|
$createTimeEnd = $params['create_time_end'] ?? '';
|
|
$verifyStatus = $params['verify_status'] ?? -1;
|
|
$provideStatus = $params['provide_status'] ?? -1;
|
|
$account = $params['account'] ?? '';
|
|
$adminId = $params['verify_admin_id'] ?? -1;
|
|
|
|
$conditions = [];
|
|
$conditions['_string'] = '1=1';
|
|
|
|
if (!is_null($promote)) {
|
|
$promoteService = new PromoteService();
|
|
$permissionPromote = $promoteService->getTSPermPromote($promote);
|
|
$subSql = M('user', 'tab_')
|
|
->where('id=tab_testing_resource_batch.user_id and promote_id in (' . $promoteService->subInSql($permissionPromote) . ')')
|
|
->select(false);
|
|
|
|
$conditions['_string'] .= ' and exists (' . $subSql . ')';
|
|
}
|
|
|
|
if ($createTimeStart) {
|
|
$conditions['_string'] .= ' and create_time >=' . strtotime($createTimeStart . ' 00:00:00');
|
|
}
|
|
if ($createTimeEnd) {
|
|
$conditions['_string'] .= ' and create_time <=' . strtotime($createTimeEnd . ' 23:59:59');
|
|
}
|
|
if ($verifyStatus != -1) {
|
|
$conditions['verify_status'] = $verifyStatus;
|
|
}
|
|
if ($provideStatus != -1) {
|
|
$conditions['provide_status'] = $provideStatus;
|
|
}
|
|
if ($adminId != -1) {
|
|
$conditions['verify_admin_id'] = $adminId;
|
|
}
|
|
if ($gameId) {
|
|
$conditions['game_id'] = $gameId;
|
|
}
|
|
if ($serverId) {
|
|
$conditions['server_id'] = $serverId;
|
|
}
|
|
if ($account) {
|
|
$user = M('user', 'tab_')->field(['id'])->where('account like "' . $account . '%"')->find();
|
|
if ($user) {
|
|
$conditions['user_id'] = $user['id'];
|
|
} else {
|
|
$conditions['_string'] .= ' and 1<>1';
|
|
}
|
|
}
|
|
return M('testing_resource_batch', 'tab_')->where($conditions)->order('create_time desc');
|
|
}
|
|
|
|
public function getBatchesRelations($batches)
|
|
{
|
|
$roles = [];
|
|
$applyPromotes = [];
|
|
$users = [];
|
|
$promotes = [];
|
|
$verifyAdmins = [];
|
|
$applyAdmins = [];
|
|
if (count($batches) > 0) {
|
|
$gameRoleIds = [];
|
|
foreach ($batches as $batch) {
|
|
$gameRoleIds[] = $this->getGameRoleId($batch['game_id'], $batch['role_id']);
|
|
}
|
|
$roles = M('user_play_info', 'tab_')
|
|
->field(['id', 'game_name', 'server_name', 'role_name', 'game_role_id', 'user_account'])
|
|
->where(['game_role_id' => ['in', $gameRoleIds]])
|
|
->select();
|
|
$roles = index_by_column('game_role_id', $roles);
|
|
|
|
$users = M('user', 'tab_')->field(['id', 'account', 'phone', 'promote_id'])->where(['id' => ['in', array_column($batches, 'user_id')]])->select();
|
|
$users = index_by_column('id', $users);
|
|
|
|
$applyPromotes = M('promote', 'tab_')->field(['id', 'account'])->where(['id' => ['in', array_column($batches, 'apply_promote_id')]])->select();
|
|
$applyPromotes = index_by_column('id', $applyPromotes);
|
|
|
|
$applyAdminIds = array_column($batches, 'apply_admin_id');
|
|
$applyAdmins = M('ucenter_member', 'sys_')->field(['id', 'username'])->where(['id' => ['in', $applyAdminIds]])->select();
|
|
$applyAdmins = index_by_column('id', $applyAdmins);
|
|
|
|
if (count($users) > 0) {
|
|
$promotes = M('promote', 'tab_')->field(['id', 'account', 'level1_id'])->where(['id' => ['in', array_column($users, 'promote_id')]])->select();
|
|
$promotes = index_by_column('id', $promotes);
|
|
}
|
|
$verifyAdminIds = array_column($batches, 'verify_admin_id');
|
|
$verifyAdmins = M('ucenter_member', 'sys_')->field(['id', 'username'])->where(['id' => ['in', $verifyAdminIds]])->select();
|
|
$verifyAdmins = index_by_column('id', $verifyAdmins);
|
|
}
|
|
return [
|
|
'roles' => $roles,
|
|
'applyPromotes' => $applyPromotes,
|
|
'users' => $users,
|
|
'promotes' => $promotes,
|
|
'verifyAdmins' => $verifyAdmins,
|
|
'applyAdmins' => $applyAdmins,
|
|
];
|
|
}
|
|
|
|
public function makeBatchesRecords($batches)
|
|
{
|
|
$result = $this->getBatchesRelations($batches);
|
|
$roles = $result['roles'];
|
|
$applyPromotes = $result['applyPromotes'];
|
|
$users = $result['users'];
|
|
$promotes = $result['promotes'];
|
|
$verifyAdmins = $result['verifyAdmins'];
|
|
$applyAdmins = $result['applyAdmins'];
|
|
|
|
$records = [];
|
|
foreach ($batches as $batch) {
|
|
$roleKey = $this->getGameRoleId($batch['game_id'], $batch['role_id']);
|
|
$role = isset($roles[$roleKey]) ? $roles[$roleKey] : null;
|
|
$user = $users[$batch['user_id']] ?? null;
|
|
$applyPromote = $applyPromotes[$batch['apply_promote_id']] ?? null;
|
|
$promote = $user && isset($promotes[$user['promote_id']]) ? $promotes[$user['promote_id']] : null;
|
|
$verifyAdmin = $verifyAdmins[$batch['verify_admin_id']] ?? null;
|
|
$applyAdmin = $applyAdmins[$batch['apply_admin_id']] ?? null;
|
|
$records[] = [
|
|
'id' => $batch['id'],
|
|
'batch_no' => substr($batch['batch_no'], 14),
|
|
'create_time' => date('Y-m-d H:i:s', $batch['create_time']),
|
|
'game_name' => $role ? $role['game_name'] : '--',
|
|
'server_name' => $role ? $role['server_name'] : '--',
|
|
'role_name' => $role ? $role['role_name'] : '--',
|
|
'user_account' => $role ?$role['user_account'] : '--',
|
|
'user_phone' => $user ? $user['phone'] : '',
|
|
'apply_username' => $applyPromote ? $applyPromote['account'] . '[推广员]' : ($applyAdmin ? $applyAdmin['username'] . '[管理员]' : ''),
|
|
'promote_account' => $promote['account'],
|
|
'verify_admin_username' => $batch['verify_status'] == 0 ? '--' : ($verifyAdmin ? $verifyAdmin['username'] : '系統'),
|
|
// 'history_provide_amount' => 0.00,
|
|
'apply_amount' => $batch['apply_amount'],
|
|
'provide_amount' => $batch['provide_amount'],
|
|
'verify_status' => $batch['verify_status'],
|
|
'verify_status_text' => $this->getVerifyStatusText($batch['verify_status']),
|
|
'verify_time' => $batch['verify_time'] == 0 ? '--' : date('Y-m-d H:i:s', $batch['verify_time']),
|
|
'provide_status' => $batch['provide_status'],
|
|
'provide_status_text' => $this->getProvideStatusText($batch['provide_status']),
|
|
'provide_time' => $batch['provide_time'] == 0 ? '--' : date('Y-m-d H:i:s', $batch['provide_time']),
|
|
'content' => '',
|
|
];
|
|
}
|
|
return $records;
|
|
}
|
|
public function makeDailyCountData($items)
|
|
{
|
|
$result = $this->getBatchesRelations($items);
|
|
$roles = $result['roles'];
|
|
$applyPromotes = $result['applyPromotes'];
|
|
$users = $result['users'];
|
|
$promotes = $result['promotes'];
|
|
$verifyAdmins = $result['verifyAdmins'];
|
|
$applyAdmins = $result['applyAdmins'];
|
|
if(!empty($promotes)){
|
|
$levelTopPromotes = M('promote', 'tab_')->where(['id' => ['in', array_unique(array_column($promotes,'level1_id'))]])->getField('id,account',true);
|
|
}else{
|
|
$levelTopPromotes = [];
|
|
}
|
|
//获取申请人
|
|
$records = [];
|
|
foreach ($items as $batch) {
|
|
$roleKey = $this->getGameRoleId($batch['game_id'], $batch['role_id']);
|
|
$role = isset($roles[$roleKey]) ? $roles[$roleKey] : null;
|
|
$user = $users[$batch['user_id']] ?? null;
|
|
$applyPromote = $applyPromotes[$batch['apply_promote_id']] ?? null;
|
|
$promote = $user && isset($promotes[$user['promote_id']]) ? $promotes[$user['promote_id']] : null;
|
|
$levelTopPromote = $promote && isset($levelTopPromotes[$promote['level1_id']]) ? $levelTopPromotes[$promote['level1_id']] : null;
|
|
$verifyAdmin = $verifyAdmins[$batch['verify_admin_id']] ?? null;
|
|
$applyAdmin = $applyAdmins[$batch['apply_admin_id']] ?? null;
|
|
$jumpParm = [
|
|
'game_id'=>$batch['game_id'],
|
|
'server_id'=>$batch['server_id'],
|
|
'account'=> $role ? $role['user_account'] : '',
|
|
'create_time_start'=>$batch['create_day_time'],
|
|
'create_time_end'=>$batch['create_day_time']
|
|
];
|
|
$jumpUrl = U("TestingResource/batches",$jumpParm);
|
|
$records[] = [
|
|
'create_day_time' => $batch['create_day_time'],
|
|
'role_name' => $role ? $role['role_name'] : '--',
|
|
'game_name' => $role ? $role['game_name'] : '--',
|
|
'server_name' => $role ? $role['server_name'] : '--',
|
|
'user_account' => $role ?$role['user_account'] : '--',
|
|
'apply_username' => $applyPromote ? $applyPromote['account'] . '[推广员]' : ($applyAdmin ? $applyAdmin['username'] . '[管理员]' : ''),
|
|
'promote_account' => $promote['account'],
|
|
'level_top_promote'=>$levelTopPromote,
|
|
'apply_amount' => $batch['apply_amount'],
|
|
'provide_amount' => $batch['provide_amount'],
|
|
'jump_url'=>$jumpUrl
|
|
];
|
|
}
|
|
return $records;
|
|
}
|
|
public function makeDailyCountTipData($items)
|
|
{
|
|
$result = $this->getBatchesRelations($items);
|
|
$roles = $result['roles'];
|
|
$applyPromotes = $result['applyPromotes'];
|
|
$users = $result['users'];
|
|
$promotes = $result['promotes'];
|
|
$verifyAdmins = $result['verifyAdmins'];
|
|
$applyAdmins = $result['applyAdmins'];
|
|
//获取申请人
|
|
$records = [];
|
|
foreach ($items as $batch) {
|
|
$roleKey = $this->getGameRoleId($batch['game_id'], $batch['role_id']);
|
|
$role = isset($roles[$roleKey]) ? $roles[$roleKey] : null;
|
|
$user = $users[$batch['user_id']] ?? null;
|
|
$applyPromote = $applyPromotes[$batch['apply_promote_id']] ?? null;
|
|
$promote = $user && isset($promotes[$user['promote_id']]) ? $promotes[$user['promote_id']] : null;
|
|
$verifyAdmin = $verifyAdmins[$batch['verify_admin_id']] ?? null;
|
|
$applyAdmin = $applyAdmins[$batch['apply_admin_id']] ?? null;
|
|
$records[$roleKey] = [
|
|
'create_day_time' => $batch['create_day_time'],
|
|
'role_name' => $role ? $role['role_name'] : '--',
|
|
'game_name' => $role ? $role['game_name'] : '--',
|
|
'server_name' => $role ? $role['server_name'] : '--',
|
|
'user_account' => $role ?$role['user_account'] : '--',
|
|
'apply_username' => $applyPromote ? $applyPromote['account'] . '[推广员]' : ($applyAdmin ? $applyAdmin['username'] . '[管理员]' : ''),
|
|
'promote_account' => $promote['account'],
|
|
'apply_amount' => $batch['apply_amount'],
|
|
'provide_amount' => $batch['provide_amount'],
|
|
];
|
|
}
|
|
return $records;
|
|
}
|
|
|
|
|
|
private function statByRoles($roles)
|
|
{
|
|
$bindingOrWhere = [];
|
|
foreach ($roles as $role) {
|
|
$bindingOrWhere[] = '(role_id="' . $role['role_id'] . '" and game_id=' . $role['game_id'] . ')';
|
|
}
|
|
$bindingOrWhereStr = '(' . implode(' or ', $bindingOrWhere) . ')';
|
|
$userIds = array_unique(array_column($roles, 'user_id'));
|
|
|
|
$users = [];
|
|
$bindings = [];
|
|
$bindingRoles = [];
|
|
$applyRecords = [];
|
|
$testingUsers = [];
|
|
if (count($roles) > 0) {
|
|
$games = M('game', 'tab_')->field(['id', 'data_share'])->where(['id' => ['in', array_column($roles, 'game_id')]])->select();
|
|
$games = index_by_column('id', $games);
|
|
|
|
$gameRepository = new GameRepository();
|
|
$baseGames = $gameRepository->getBaseGames();
|
|
|
|
$testingUsers = M('testing_user', 'tab_')->where(['user_id' => ['in', $userIds]])->select();
|
|
$testingUsers = index_by_column('user_id', $testingUsers);
|
|
$users = M('user', 'tab_')->field(['id', 'phone', 'lock_status'])->where(['id' => ['in', $userIds]])->select();
|
|
$users = index_by_column('id', $users);
|
|
$bindingRows = M('testing_binding', 'tab_')->where(['_string' => $bindingOrWhereStr])->select();
|
|
$bindingRoleIds = [];
|
|
foreach ($bindingRows as $bindingRow) {
|
|
$bindings[$this->getGameRoleId($bindingRow['game_id'], $bindingRow['role_id'])] = $bindingRow;
|
|
$bindingRoleIds[] = $this->getGameRoleId($bindingRow['game_id'], $bindingRow['bind_role_id']);
|
|
$game = $games[$bindingRow['game_id']];
|
|
$gameIds = [$bindingRow['game_id']];
|
|
if ($game['data_share'] == 1) {
|
|
$baseGame = $gameRepository->getBaseGameByGameId($bindingRow['game_id'], $baseGames);
|
|
$gameIds = $gameRepository->getGameIdsByBaseGame($baseGame);
|
|
}
|
|
foreach ($gameIds as $gameId) {
|
|
$bindingRoleIds[] = $this->getGameRoleId($gameId, $bindingRow['bind_role_id']);
|
|
}
|
|
}
|
|
if (count($bindings) > 0) {
|
|
$bindingRoles = M('user_play_info', 'tab_')
|
|
->field(['id', 'role_id', 'role_name', 'user_account', 'game_id', 'game_role_id'])
|
|
->where(['game_role_id' => ['in', $bindingRoleIds]])
|
|
->select();
|
|
$bindingRoles = index_by_column('game_role_id', $bindingRoles);
|
|
}
|
|
|
|
$verifyItems = M('testing_resource_batch', 'tab_')
|
|
->field('sum(apply_amount) amount, game_id, role_id')
|
|
->where([
|
|
'verify_status' => 0,
|
|
'_string' => $bindingOrWhereStr,
|
|
])
|
|
->group('game_id,role_id')->select();
|
|
$verifyRecords = [];
|
|
foreach ($verifyItems as $item) {
|
|
$verifyRecords[$this->getGameRoleId($item['game_id'], $item['role_id'])] = $item['amount'] ;
|
|
}
|
|
|
|
$provideItems = M('testing_resource_batch', 'tab_')
|
|
->field('sum(provide_amount) amount, game_id, role_id')
|
|
->where([
|
|
'verify_status' => 1,
|
|
'_string' => $bindingOrWhereStr,
|
|
])
|
|
->group('game_id,role_id')->select();
|
|
$provideRecords = [];
|
|
foreach ($provideItems as $item) {
|
|
$provideRecords[$this->getGameRoleId($item['game_id'], $item['role_id'])] = $item['amount'] ;
|
|
}
|
|
|
|
$todayProvideItems = M('testing_resource_batch', 'tab_')
|
|
->field('sum(provide_amount) amount, game_id, role_id')
|
|
->where([
|
|
'verify_status' => 1,
|
|
'_string' => $bindingOrWhereStr,
|
|
'provide_time' => ['between', [strtotime(date('Y-m-d 00:00:00')), strtotime(date('Y-m-d 23:59:59'))]],
|
|
])
|
|
->group('game_id,role_id')->select();
|
|
$todayProvideRecords = [];
|
|
foreach ($todayProvideItems as $item) {
|
|
$todayProvideRecords[$this->getGameRoleId($item['game_id'], $item['role_id'])] = $item['amount'] ;
|
|
}
|
|
|
|
$applyItems = M('testing_resource_batch', 'tab_')
|
|
->field('sum(apply_amount) amount, game_id, role_id')
|
|
->where([
|
|
'_string' => $bindingOrWhereStr,
|
|
])
|
|
->group('game_id,role_id')->select();
|
|
$applyRecords = [];
|
|
foreach ($applyItems as $item) {
|
|
$applyRecords[$this->getGameRoleId($item['game_id'], $item['role_id'])] = $item['amount'] ;
|
|
}
|
|
|
|
}
|
|
|
|
$spendItems = [];
|
|
$revGameIdMap = [];
|
|
$gameIdMap = [];
|
|
if (count($bindingRoles) > 0) {
|
|
$games = M('game', 'tab_')->field(['id', 'data_share'])->where(['id' => ['in', array_column($bindingRoles, 'game_id')]])->select();
|
|
foreach ($games as $game) {
|
|
if ($game['data_share'] == 1) {
|
|
$baseGame = $gameRepository->getBaseGameByGameId($game['id'], $baseGames);
|
|
$gameIds = $gameRepository->getGameIdsByBaseGame($baseGame);
|
|
$gameIdMap[$game['id']] = $gameIds;
|
|
foreach ($gameIds as $gameId) {
|
|
$revGameIdMap[$gameId] = $game['id'];
|
|
}
|
|
} else {
|
|
$gameIdMap[$game['id']] = [$game['id']];
|
|
$revGameIdMap[$game['id']] = $game['id'];
|
|
}
|
|
}
|
|
$spendOrWhere = [];
|
|
foreach ($bindingRoles as $bindingRole) {
|
|
$gameIds = $gameIdMap[$bindingRole['game_id']];
|
|
$spendOrWhere[] = '(game_player_id="' . $bindingRole['role_id'] . '" and game_id in (' . implode(',', $gameIds) . '))';
|
|
}
|
|
$spendCondition = [
|
|
'pay_status' => 1,
|
|
'_string' => '(' . implode(' or ', $spendOrWhere) . ')',
|
|
];
|
|
$subBindingCondition = [
|
|
'_string' =>
|
|
'tab_testing_binding.bind_role_id = tab_spend.game_player_id and ' .
|
|
'tab_testing_binding.bind_user_id = tab_spend.user_id and ' .
|
|
'UNIX_TIMESTAMP(FROM_UNIXTIME(tab_testing_binding.create_time, "%Y-%m-%d 00:00:00")) <= tab_spend.pay_time'
|
|
];
|
|
$spendRepository = new SpendRepository();
|
|
$subBindingCondition = $spendRepository->withIsCheck($subBindingCondition, 'tab_spend.is_check');
|
|
$spendCondition = $spendRepository->withIsCheck($spendCondition);
|
|
|
|
$subBindingSql = M('testing_binding', 'tab_')
|
|
->where($subBindingCondition)
|
|
->select(false);
|
|
$spendCondition['_string'] .= ' and exists(' . $subBindingSql . ')';
|
|
$spendList = M('spend', 'tab_')
|
|
->field('sum(pay_amount) amount, game_id, game_player_id')
|
|
->where($spendCondition)
|
|
->group('game_id,game_player_id')
|
|
->select();
|
|
foreach ($spendList as $item) {
|
|
$mainGameId = $revGameIdMap[$item['game_id']];
|
|
$itemKey = $this->getGameRoleId($mainGameId, $item['game_player_id']);
|
|
if (isset($spendItems[$itemKey])) {
|
|
$spendItems[$itemKey] += $item['amount'];
|
|
} else {
|
|
$spendItems[$itemKey] = $item['amount'];
|
|
}
|
|
}
|
|
}
|
|
$gameSettings = $this->getGameSettings();
|
|
return [
|
|
'users' => $users,
|
|
'spendItems' => $spendItems,
|
|
'bindings' => $bindings,
|
|
'bindingRoles' => $bindingRoles,
|
|
'applyRecords' => $applyRecords,
|
|
'provideRecords' => $provideRecords,
|
|
'verifyRecords' => $verifyRecords,
|
|
'todayProvideRecords' => $todayProvideRecords,
|
|
'gameSettings' => $gameSettings,
|
|
'testingUsers' => $testingUsers,
|
|
'revGameIdMap' => $revGameIdMap
|
|
];
|
|
}
|
|
|
|
public function makeTestingRoleRecords($roles)
|
|
{
|
|
$result = $this->statByRoles($roles);
|
|
$users = $result['users'];
|
|
$testingUsers = $result['testingUsers'];
|
|
$spendItems = $result['spendItems'];
|
|
$gameSettings = $result['gameSettings'];
|
|
$bindings = $result['bindings'];
|
|
$bindingRoles = $result['bindingRoles'];
|
|
$revGameIdMap = $result['revGameIdMap'];
|
|
$applyRecords = $result['applyRecords'];
|
|
$provideRecords = $result['provideRecords'];
|
|
$verifyRecords = $result['verifyRecords'];
|
|
$todayProvideRecords = $result['todayProvideRecords'];
|
|
$gameSettings = index_by_column('base_game_id', $gameSettings);
|
|
$gameRepository = new GameRepository();
|
|
$baseGames = $gameRepository->getBaseGames();
|
|
$records = [];
|
|
foreach ($roles as $role) {
|
|
$user = $users[$role['user_id']] ?? null;
|
|
$testingUser = $testingUsers[$role['user_id']] ?? null;
|
|
$binding = $bindings[$role['game_role_id']] ?? null;
|
|
$bindingRole = null;
|
|
|
|
$baseGame = $gameRepository->getBaseGameByGameId($role['game_id'], $baseGames);
|
|
$gameSetting = null;
|
|
if ($baseGame && isset($gameSettings[$baseGame['id']])) {
|
|
$gameSetting = $gameSettings[$baseGame['id']];
|
|
}
|
|
|
|
$spendQuota = 0;
|
|
$quota = 0;
|
|
if ($binding) {
|
|
$gameIds = $gameRepository->getGameIdsByBaseGame($baseGame);
|
|
foreach ($gameIds as $gameId) {
|
|
$bindGameRoleId = $this->getGameRoleId($gameId, $binding['bind_role_id']);
|
|
if (isset($bindingRoles[$bindGameRoleId])) {
|
|
$bindingRole = $bindingRoles[$bindGameRoleId];
|
|
break;
|
|
}
|
|
}
|
|
|
|
if ($bindingRole) {
|
|
$mainGameId = $revGameIdMap[$binding['game_id']];
|
|
$mainGameRoleId = $this->getGameRoleId($mainGameId, $binding['bind_role_id']);
|
|
$spendQuota = isset($spendItems[$mainGameRoleId]) ? $spendItems[$mainGameRoleId] : 0;
|
|
}
|
|
$quota = $gameSetting ? round($spendQuota * $gameSetting['rate'] / 100, 2) : 0;
|
|
}
|
|
|
|
$statusText = '正常';
|
|
if (is_null($user) || is_null($testingUser)) {
|
|
$statusText = '错误';
|
|
} elseif ($testingUser['status'] == 2) {
|
|
$statusText = '警告';
|
|
} elseif ($testingUser['status'] == 3) {
|
|
$statusText = '禁用';
|
|
}
|
|
|
|
if (is_null($user)) {
|
|
$statusText .= '(账号不存在)';
|
|
} elseif ($user['lock_status'] != 1) {
|
|
$statusText .= '(账号锁定)';
|
|
}
|
|
|
|
$records[] = [
|
|
'id' => $role['id'],
|
|
'game_name' => $role['game_name'],
|
|
'server_name' => $role['server_name'],
|
|
'server_id' => $role['server_id'],
|
|
'role_id' => $role['role_id'],
|
|
'user_account' => $role['user_account'],
|
|
'user_phone' => $user ? $user['phone'] : '',
|
|
'role_name' => $role['role_name'],
|
|
'binding_id' => $binding ? $binding['id'] : 0,
|
|
'bind_user_account' => $bindingRole ? $bindingRole['user_account'] : '',
|
|
'bind_role_name' => $bindingRole ? $bindingRole['role_name'] : '',
|
|
'base_quota' => $gameSetting ? $gameSetting['base_quota'] : 0,
|
|
'other_quota' => intval($role['testing_other_quota']),
|
|
'other_quota_remark' => $role['testing_other_quota_remark'],
|
|
'quota' => $quota,
|
|
'verify_amount' => $verifyRecords[$role['game_role_id']] ?? 0,
|
|
'provide_amount' => $provideRecords[$role['game_role_id']] ?? 0,
|
|
'today_amount' => $todayProvideRecords[$role['game_role_id']] ?? 0,
|
|
'apply_amount' => $applyRecords[$role['game_role_id']] ?? 0,
|
|
'status' => $statusText,
|
|
'create_time' => date('Y-m-d H:i:s', $role['create_time'])
|
|
];
|
|
}
|
|
return $records;
|
|
}
|
|
|
|
public function getTestingRolesQuery($params, array $promote = null)
|
|
{
|
|
$createTimeStart = $params['create_time_start'] ?? '';
|
|
$createTimeEnd = $params['create_time_end'] ?? '';
|
|
$gameId = $params['game_id'] ?? 0;
|
|
$serverId = $params['server_id'] ?? '';
|
|
$account = $params['account'] ?? '';
|
|
$status = $params['status'] ?? 0;
|
|
$roleName = $params['role_name'] ?? '';
|
|
|
|
$conditions = [];
|
|
$subConditions = [
|
|
'_string' => '1=1'
|
|
];
|
|
|
|
$strCondition = '1=1';
|
|
|
|
$promoteService = new PromoteService();
|
|
$permissionPromote = $promoteService->getTSPermPromote($promote);
|
|
if ($permissionPromote) {
|
|
$visibleGameIds = $promoteService->getVisibleGameIds($permissionPromote);
|
|
if (count($visibleGameIds) > 0) {
|
|
$strCondition .= ' and game_id in (' . implode(',', $visibleGameIds) . ')';
|
|
} else {
|
|
$strCondition .= ' and 1=0';
|
|
}
|
|
$strCondition .= ' and promote_id in (' . $promoteService->subInSql($permissionPromote) . ')';
|
|
}
|
|
|
|
$gameIds = $this->getHadSettingGameIds();
|
|
if (!empty($gameIds)) {
|
|
$strCondition .= ' and game_id in ('. implode(',', $gameIds) . ')';
|
|
} else {
|
|
$strCondition .= ' and 1=0';
|
|
}
|
|
|
|
if ($createTimeStart) {
|
|
$strCondition .= ' and create_time >=' . strtotime($createTimeStart . ' 00:00:00');
|
|
}
|
|
if ($createTimeEnd) {
|
|
$strCondition .= ' and create_time <=' . strtotime($createTimeEnd . ' 23:59:59');
|
|
}
|
|
if ($status != 0) {
|
|
$subConditions['status'] = $status;
|
|
}
|
|
|
|
$subConditions['verify_status'] = 1;
|
|
$subSql = M('testing_user', 'tab_')->field(['user_id'])->where($subConditions)->select(false);
|
|
$strCondition .= ' and user_id in (' . $subSql . ')';
|
|
|
|
if ($account) {
|
|
$user = M('user', 'tab_')->field(['id'])->where('account like "' . $account . '%"')->find();
|
|
if ($user) {
|
|
$conditions['user_id'] = $user['id'];
|
|
} else {
|
|
$strCondition .= ' and 1<>1';
|
|
}
|
|
}
|
|
if ($gameId) {
|
|
$conditions['game_id'] = $gameId;
|
|
}
|
|
if ($serverId) {
|
|
$conditions['server_id'] = $serverId;
|
|
}
|
|
if ($roleName) {
|
|
$conditions['role_name'] = ['like', $roleName . '%'];
|
|
}
|
|
$conditions['_string'] = $strCondition;
|
|
return M('user_play_info', 'tab_')->where($conditions)->order('create_time desc');
|
|
}
|
|
|
|
public function getTestingUsersQuery($params, array $promote = null)
|
|
{
|
|
$createTimeStart = $params['create_time_start'] ?? '';
|
|
$createTimeEnd = $params['create_time_end'] ?? '';
|
|
$status = $params['status'] ?? 0;
|
|
$verifyStatus = $params['verify_status'] ?? -1;
|
|
$account = $params['account'] ?? '';
|
|
|
|
$conditions = [];
|
|
$strCondition = '1=1';
|
|
|
|
/* $promoteService = new PromoteService();
|
|
if ($promote) {
|
|
$subSql = M('user', 'tab_')->field('id')->where('promote_id in (' . $promoteService->subInSql($promote) . ')')->select(false);
|
|
$strCondition .= ' and user_id in (' . $subSql . ')';
|
|
} */
|
|
|
|
if ($account) {
|
|
$conditions['user_account'] = ['like', '%' . $account . '%'];
|
|
}
|
|
if ($verifyStatus != -1) {
|
|
$conditions['verify_status'] = $verifyStatus;
|
|
}
|
|
if ($status != 0) {
|
|
$conditions['status'] = $status;
|
|
}
|
|
if ($createTimeStart) {
|
|
$strCondition .= ' and create_time >=' . strtotime($createTimeStart . ' 00:00:00');
|
|
}
|
|
if ($createTimeEnd) {
|
|
$strCondition .= ' and create_time <=' . strtotime($createTimeEnd . ' 23:59:59');
|
|
}
|
|
|
|
$conditions['_string'] = $strCondition;
|
|
return M('testing_user', 'tab_')->where($conditions);
|
|
}
|
|
|
|
public function makeTestingUserRecords($testingUsers)
|
|
{
|
|
$ids = array_column($testingUsers, 'user_id');
|
|
if (count($ids) == 0) {
|
|
return [];
|
|
}
|
|
$users = M('user', 'tab_')->field(['id', 'login_time', 'promote_account'])->where(['id' => ['in', $ids]])->select();
|
|
$users = index_by_column('id', $users);
|
|
|
|
$records = [];
|
|
foreach ($testingUsers as $testingUser) {
|
|
$user = $users[$testingUser['user_id']] ?? null;
|
|
|
|
$records[] = [
|
|
'user_id' => $testingUser['user_id'],
|
|
'user_account' => $testingUser['user_account'],
|
|
'status_text' => self::$userStatusList[$testingUser['status']] ?? '未知',
|
|
'verify_status_text' => self::$userVerifyStatusList[$testingUser['verify_status']] ?? '未知',
|
|
'verify_status' => $testingUser['verify_status'],
|
|
'status' => $testingUser['status'],
|
|
'verify_time' => $testingUser['verify_time'] == 0 ? '' : date('Y-m-d H:i:s', $testingUser['verify_time']),
|
|
'create_time' => date('Y-m-d H:i:s', $testingUser['create_time']),
|
|
'promote_account' => $user ? $user['promote_account'] : '--',
|
|
'login_time' => $user ? date('Y-m-d H:i:s', $user['login_time']) : '--',
|
|
];
|
|
}
|
|
return $records;
|
|
}
|
|
} |