|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Base\Repository;
|
|
|
|
|
|
|
|
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'] ?? '';
|
|
|
|
|
|
|
|
$conditions = [];
|
|
|
|
$conditions['_string'] = '1=1';
|
|
|
|
|
|
|
|
if (!is_null($promote)) {
|
|
|
|
$promoteService = new PromoteService();
|
|
|
|
$subSql = M('user', 'tab_')
|
|
|
|
->where('id=tab_testing_resource_batch.user_id and promote_id in (' . $promoteService->subInSql($promote) . ')')
|
|
|
|
->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 ($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');
|
|
|
|
}
|
|
|
|
|
|
|
|
private function getBatchesRelations($batches)
|
|
|
|
{
|
|
|
|
$roles = [];
|
|
|
|
$applyPromotes = [];
|
|
|
|
$users = [];
|
|
|
|
$promotes = [];
|
|
|
|
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);
|
|
|
|
|
|
|
|
if (count($users) > 0) {
|
|
|
|
$promotes = M('promote', 'tab_')->field(['id', 'account'])->where(['id' => ['in', array_column($users, 'promote_id')]])->select();
|
|
|
|
$promotes = index_by_column('id', $promotes);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return [
|
|
|
|
'roles' => $roles,
|
|
|
|
'applyPromotes' => $applyPromotes,
|
|
|
|
'users' => $users,
|
|
|
|
'promotes' => $promotes,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function makeBatchesRecords($batches)
|
|
|
|
{
|
|
|
|
$result = $this->getBatchesRelations($batches);
|
|
|
|
$roles = $result['roles'];
|
|
|
|
$applyPromotes = $result['applyPromotes'];
|
|
|
|
$users = $result['users'];
|
|
|
|
$promotes = $result['promotes'];
|
|
|
|
|
|
|
|
$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;
|
|
|
|
$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_promote_account' => $applyPromote ? $applyPromote['account'] : '',
|
|
|
|
'promote_account' => $promote['account'],
|
|
|
|
// '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' => $content,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
return $records;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private function statByRoles($roles)
|
|
|
|
{
|
|
|
|
$bindingOrWhere = [];
|
|
|
|
foreach ($roles as $role) {
|
|
|
|
$bindingOrWhere[] = '(role_id="' . $role['role_id'] . '" and game_id=' . $role['game_id'] . ')';
|
|
|
|
}
|
|
|
|
$userIds = array_unique(array_column($roles, 'user_id'));
|
|
|
|
|
|
|
|
$users = [];
|
|
|
|
$bindings = [];
|
|
|
|
$bindingRoles = [];
|
|
|
|
$applyRecords = [];
|
|
|
|
$testingUsers = [];
|
|
|
|
if (count($roles) > 0) {
|
|
|
|
$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' => implode(' or ', $bindingOrWhere)])->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']);
|
|
|
|
}
|
|
|
|
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' => implode(' or ', $bindingOrWhere)
|
|
|
|
])
|
|
|
|
->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' => implode(' or ', $bindingOrWhere)
|
|
|
|
])
|
|
|
|
->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' => implode(' or ', $bindingOrWhere),
|
|
|
|
'provide_time' => ['egt', strtotime(date('Y-m-d 00:00:00'))],
|
|
|
|
'provide_time' => ['elt', 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' => implode(' or ', $bindingOrWhere),
|
|
|
|
])
|
|
|
|
->group('game_id,role_id')->select();
|
|
|
|
$applyRecords = [];
|
|
|
|
foreach ($applyItems as $item) {
|
|
|
|
$applyRecords[$this->getGameRoleId($item['game_id'], $item['role_id'])] = $item['amount'] ;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
$spendItems = [];
|
|
|
|
if (count($bindingRoles) > 0) {
|
|
|
|
$spendOrWhere = [];
|
|
|
|
foreach ($bindingRoles as $bindingRole) {
|
|
|
|
$spendOrWhere[] = '(game_player_id="' . $bindingRole['role_id'] . '" and game_id=' . $bindingRole['game_id'] . ')';
|
|
|
|
}
|
|
|
|
$spendCondition = [
|
|
|
|
'pay_status' => 1,
|
|
|
|
'_string' => '(' . implode(' or ', $spendOrWhere) . ')',
|
|
|
|
];
|
|
|
|
$subBindingSql = M('testing_binding', 'tab_')
|
|
|
|
->where([
|
|
|
|
'_string' =>
|
|
|
|
'tab_testing_binding.bind_role_id = tab_spend.game_player_id and ' .
|
|
|
|
'tab_testing_binding.game_id = tab_spend.game_id and ' .
|
|
|
|
'UNIX_TIMESTAMP(FROM_UNIXTIME(tab_testing_binding.create_time, "%Y-%m-%d 00:00:00")) <= tab_spend.pay_time'
|
|
|
|
])
|
|
|
|
->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) {
|
|
|
|
$spendItems[$this->getGameRoleId($item['game_id'], $item['game_player_id'])] = $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,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
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'];
|
|
|
|
$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;
|
|
|
|
if ($binding) {
|
|
|
|
$bindGameRoleId = $this->getGameRoleId($binding['game_id'], $binding['bind_role_id']);
|
|
|
|
$bindingRole = $bindingRoles[$bindGameRoleId] ? $bindingRoles[$bindGameRoleId] : null;
|
|
|
|
}
|
|
|
|
$baseGame = $gameRepository->getBaseGameByGameId($role['game_id'], $baseGames);
|
|
|
|
$gameSetting = null;
|
|
|
|
if ($baseGame && isset($gameSettings[$baseGame['id']])) {
|
|
|
|
$gameSetting = $gameSettings[$baseGame['id']];
|
|
|
|
}
|
|
|
|
|
|
|
|
$spendQuota = $bindingRole && isset($spendItems[$bindingRole['game_role_id']]) ? $spendItems[$bindingRole['game_role_id']] : 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']),
|
|
|
|
'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();
|
|
|
|
if ($promote) {
|
|
|
|
$visibleGameIds = $promoteService->getVisibleGameIds($promote);
|
|
|
|
if (count($visibleGameIds) > 0) {
|
|
|
|
$strCondition .= ' and game_id in (' . implode(',', $visibleGameIds) . ')';
|
|
|
|
} else {
|
|
|
|
$strCondition .= ' and 1=0';
|
|
|
|
}
|
|
|
|
$strCondition .= ' and promote_id in (' . $promoteService->subInSql($promote) . ')';
|
|
|
|
}
|
|
|
|
|
|
|
|
$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;
|
|
|
|
}
|
|
|
|
}
|