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
+65 -21
View File
@@ -35,11 +35,11 @@ class MockDataSeeder extends Seeder
'mail' => 'admin@runsystem.net',
'pass' => $password,
'departments' => 1,
'role' => User::ROLE_ADMIN,
'status' => User::STATUS_ACTIVE,
'role' => config('constants.ROLE_ADMIN'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 0,
'flag_send' => User::FLAG_SEND_ENABLED,
'first_login' => User::FIRST_LOGIN_FALSE,
'flag_send' => config('constants.FLAG_SEND_ENABLED'),
'first_login' => config('constants.FIRST_LOGIN_FALSE'),
]);
User::create([
@@ -48,20 +48,20 @@ class MockDataSeeder extends Seeder
'mail' => 'admin2@runsystem.net',
'pass' => $password,
'departments' => 1,
'role' => User::ROLE_ADMIN,
'status' => User::STATUS_ACTIVE,
'role' => config('constants.ROLE_ADMIN'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 0,
'flag_send' => User::FLAG_SEND_ENABLED,
'first_login' => User::FIRST_LOGIN_FALSE,
'flag_send' => config('constants.FLAG_SEND_ENABLED'),
'first_login' => config('constants.FIRST_LOGIN_FALSE'),
]);
// Active Users (Initialize with specific users needed for logs/transactions)
$users = [
['msnv' => 1001, 'name' => 'Nguyễn Văn A', 'mail' => 'nguyenvana@runsystem.net', 'card' => 10, 'flag' => User::FLAG_SEND_ENABLED, 'first_login' => User::FIRST_LOGIN_FALSE],
['msnv' => 1002, 'name' => 'Trần Thị Ngọc', 'mail' => 'tranthingoc@runsystem.net', 'card' => 3, 'flag' => User::FLAG_SEND_ENABLED, 'first_login' => User::FIRST_LOGIN_FALSE],
['msnv' => 1003, 'name' => 'Lê Kim Thư', 'mail' => 'lekiemthu@runsystem.net', 'card' => 6, 'flag' => User::FLAG_SEND_ENABLED, 'first_login' => User::FIRST_LOGIN_TRUE], // First-time login
['msnv' => 1004, 'name' => 'Phòng Nhân Sự', 'mail' => 'phongnhansu@runsystem.net', 'card' => 0, 'flag' => User::FLAG_SEND_DISABLED, 'first_login' => User::FIRST_LOGIN_FALSE], // Disabled sending permission
['msnv' => 1005, 'name' => 'Bản Giang', 'mail' => 'bangiang@runsystem.net', 'card' => 36, 'flag' => User::FLAG_SEND_ENABLED, 'first_login' => User::FIRST_LOGIN_FALSE],
['msnv' => 1001, 'name' => 'Nguyễn Văn A', 'mail' => 'nguyenvana@runsystem.net', 'card' => 10, 'flag' => config('constants.FLAG_SEND_ENABLED'), 'first_login' => config('constants.FIRST_LOGIN_FALSE')],
['msnv' => 1002, 'name' => 'Trần Thị Ngọc', 'mail' => 'tranthingoc@runsystem.net', 'card' => 3, 'flag' => config('constants.FLAG_SEND_ENABLED'), 'first_login' => config('constants.FIRST_LOGIN_FALSE')],
['msnv' => 1003, 'name' => 'Lê Kim Thư', 'mail' => 'lekiemthu@runsystem.net', 'card' => 6, 'flag' => config('constants.FLAG_SEND_ENABLED'), 'first_login' => config('constants.FIRST_LOGIN_TRUE')], // First-time login
['msnv' => 1004, 'name' => 'Phòng Nhân Sự', 'mail' => 'phongnhansu@runsystem.net', 'card' => 0, 'flag' => config('constants.FLAG_SEND_DISABLED'), 'first_login' => config('constants.FIRST_LOGIN_FALSE')], // Disabled sending permission
['msnv' => 1005, 'name' => 'Bản Giang', 'mail' => 'bangiang@runsystem.net', 'card' => 36, 'flag' => config('constants.FLAG_SEND_ENABLED'), 'first_login' => config('constants.FIRST_LOGIN_FALSE')],
];
// Generate additional users to reach exactly 100 member users
@@ -76,8 +76,8 @@ class MockDataSeeder extends Seeder
'name' => $randomName,
'mail' => 'dev' . str_pad($i, 3, '0', STR_PAD_LEFT) . '@runsystem.net',
'card' => rand(0, 30),
'flag' => rand(0, 5) > 0 ? User::FLAG_SEND_ENABLED : User::FLAG_SEND_DISABLED,
'first_login' => rand(0, 4) == 0 ? User::FIRST_LOGIN_TRUE : User::FIRST_LOGIN_FALSE
'flag' => rand(0, 5) > 0 ? config('constants.FLAG_SEND_ENABLED') : config('constants.FLAG_SEND_DISABLED'),
'first_login' => rand(0, 4) == 0 ? config('constants.FIRST_LOGIN_TRUE') : config('constants.FIRST_LOGIN_FALSE')
];
}
@@ -88,8 +88,8 @@ class MockDataSeeder extends Seeder
'mail' => $u['mail'],
'pass' => $password,
'departments' => rand(1, 5),
'role' => User::ROLE_MEMBER,
'status' => User::STATUS_ACTIVE,
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => $u['card'],
'flag_send' => $u['flag'],
'first_login' => $u['first_login'],
@@ -115,11 +115,11 @@ class MockDataSeeder extends Seeder
'mail' => 'nghiduy@runsystem.net',
'pass' => $password,
'departments' => 2,
'role' => User::ROLE_MEMBER,
'status' => User::STATUS_INACTIVE,
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_INACTIVE'),
'card' => 0,
'flag_send' => User::FLAG_SEND_DISABLED,
'first_login' => User::FIRST_LOGIN_FALSE,
'flag_send' => config('constants.FLAG_SEND_DISABLED'),
'first_login' => config('constants.FIRST_LOGIN_FALSE'),
]);
// 2. CREATE CARD ADDITION LOGS (add_card table)
@@ -195,5 +195,49 @@ class MockDataSeeder extends Seeder
'date' => $t['date']
]);
}
// 4. CREATE 10 USERS FOR TIE-RANKING IN CURRENT MONTH
$currentMonth = Carbon::now()->format('Y-m');
$currentDate = Carbon::now()->format('Y-m-d');
$depts = config('constants.DEPARTMENTS');
for ($i = 1; $i <= 10; $i++) {
$tieMsnv = 8000 + $i;
User::create([
'msnv' => $tieMsnv,
'name' => "Top 1 User {$i}",
'mail' => "top1_user_{$i}@runsystem.net",
'pass' => $password,
'departments' => $depts[($i - 1) % count($depts)],
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 100,
'flag_send' => config('constants.FLAG_SEND_ENABLED'),
'first_login' => config('constants.FIRST_LOGIN_FALSE'),
]);
$senderMsnv = 8000 + $i;
$receiverMsnv = 8000 + ($i % 10 + 1);
// Sender record
Administration::create([
'msnv' => $senderMsnv,
'received' => 0,
'sender' => null,
'sent' => 100,
'receiver' => $receiverMsnv,
'date' => $currentDate,
]);
// Receiver record
Administration::create([
'msnv' => $receiverMsnv,
'received' => 100,
'sender' => $senderMsnv,
'sent' => 0,
'receiver' => null,
'date' => $currentDate,
]);
}
}
}