|
|
@@ -262,22 +262,34 @@ class ThirdGameOrderService
|
|
|
*/
|
|
|
private function usersByPlayerId(array $playerIds): array
|
|
|
{
|
|
|
- if ($playerIds === []) {
|
|
|
+ $requested = [];
|
|
|
+ foreach ($playerIds as $playerId) {
|
|
|
+ $playerId = trim((string) $playerId);
|
|
|
+ if (!preg_match('/^u([1-9]\d*)$/D', $playerId, $matches)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $userId = filter_var($matches[1], FILTER_VALIDATE_INT, [
|
|
|
+ 'options' => ['min_range' => 1, 'max_range' => PHP_INT_MAX],
|
|
|
+ ]);
|
|
|
+ if ($userId !== false) {
|
|
|
+ $requested[(int) $userId] = $playerId;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($requested === []) {
|
|
|
return [];
|
|
|
}
|
|
|
|
|
|
- $sn = (string) config('third_game.sn');
|
|
|
- $placeholders = implode(',', array_fill(0, count($playerIds), '?'));
|
|
|
- $expression = "CONCAT('p', SUBSTRING(MD5(CONCAT(?, '_', `member_id`)), 1, 10))";
|
|
|
$rows = DB::table('users')
|
|
|
->select(['id', 'member_id', 'username', 'first_name'])
|
|
|
- ->selectRaw($expression . ' AS third_game_player_id', [$sn])
|
|
|
- ->whereRaw($expression . " IN ({$placeholders})", array_merge([$sn], $playerIds))
|
|
|
+ ->whereIn('id', array_keys($requested))
|
|
|
->get();
|
|
|
|
|
|
$result = [];
|
|
|
foreach ($rows as $row) {
|
|
|
- $result[(string) $row->third_game_player_id] = $row;
|
|
|
+ $playerId = $requested[(int) $row->id] ?? null;
|
|
|
+ if ($playerId !== null) {
|
|
|
+ $result[$playerId] = $row;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return $result;
|