feature: user list

This commit is contained in:
antv
2026-07-08 15:29:13 +07:00
parent 7d9ba527a3
commit e476c2768a
32 changed files with 1091 additions and 284 deletions
+6 -6
View File
@@ -27,19 +27,19 @@ class UserService implements UserServiceInterface
public function getOtherActiveUsers(User $currentUser): Collection
{
return User::where('status', User::STATUS_ACTIVE)
return User::where('status', config('constants.STATUS_ACTIVE'))
->where('msnv', '!=', $currentUser->msnv)
->get();
}
public function sendThankcards(User $sender, string $receiverMsnv, int $amount): void
{
if ($sender->flag_send == User::FLAG_SEND_DISABLED) {
if ($sender->flag_send == config('constants.FLAG_SEND_DISABLED')) {
throw new \RuntimeException(__('messages.error.no_send_permission'));
}
$receiver = User::where('msnv', $receiverMsnv)->first();
if (!$receiver || $receiver->status != User::STATUS_ACTIVE) {
if (!$receiver || $receiver->status != config('constants.STATUS_ACTIVE')) {
throw new \RuntimeException(__('messages.error.receiver_invalid'));
}
@@ -91,7 +91,7 @@ class UserService implements UserServiceInterface
public function updatePassword(User $user, string $newPassword): void
{
$user->pass = md5($newPassword);
$user->first_login = User::FIRST_LOGIN_FALSE;
$user->first_login = config('constants.FIRST_LOGIN_FALSE');
$user->save();
}
@@ -109,7 +109,7 @@ class UserService implements UserServiceInterface
->sum('sent');
// Calculate current rank (based on received)
$rankings = User::where('status', User::STATUS_ACTIVE)
$rankings = User::where('status', config('constants.STATUS_ACTIVE'))
->addSelect([
'score' => Administration::selectRaw('COALESCE(SUM(received), 0)')
->whereColumn('msnv', 'user.msnv')
@@ -156,7 +156,7 @@ class UserService implements UserServiceInterface
$column = $type === 'sent' ? 'sent' : 'received';
$allActiveUsers = User::where('status', User::STATUS_ACTIVE)
$allActiveUsers = User::where('status', config('constants.STATUS_ACTIVE'))
->addSelect([
'score' => Administration::selectRaw('COALESCE(SUM(' . $column . '), 0)')
->whereColumn('msnv', 'user.msnv')