记录所有人在线时长:允许 user_position_id 为空,移除记录日志时的职务判断
This commit is contained in:
@@ -278,10 +278,8 @@ class AutoSaveExp extends Command
|
|||||||
*/
|
*/
|
||||||
private function tickDutyLog(User $user, int $roomId): void
|
private function tickDutyLog(User $user, int $roomId): void
|
||||||
{
|
{
|
||||||
|
// 无论有无职务,均记录在线流水
|
||||||
$activeUP = $user->activePosition;
|
$activeUP = $user->activePosition;
|
||||||
if (! $activeUP) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ① 今日未关闭的开放日志 → 刷新时长
|
// ① 今日未关闭的开放日志 → 刷新时长
|
||||||
$openLog = PositionDutyLog::query()
|
$openLog = PositionDutyLog::query()
|
||||||
@@ -315,7 +313,7 @@ class AutoSaveExp extends Command
|
|||||||
|
|
||||||
PositionDutyLog::create([
|
PositionDutyLog::create([
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'user_position_id' => $activeUP->id,
|
'user_position_id' => $activeUP?->id,
|
||||||
'login_at' => $loginAt,
|
'login_at' => $loginAt,
|
||||||
'ip_address' => '0.0.0.0',
|
'ip_address' => '0.0.0.0',
|
||||||
'room_id' => $roomId,
|
'room_id' => $roomId,
|
||||||
|
|||||||
@@ -1049,11 +1049,8 @@ class ChatController extends Controller
|
|||||||
*/
|
*/
|
||||||
private function tickDutyLog(User $user, int $roomId): void
|
private function tickDutyLog(User $user, int $roomId): void
|
||||||
{
|
{
|
||||||
// 无在职职务,无需记录
|
// 无论有无职务,均记录在线流水
|
||||||
$activeUP = $user->activePosition;
|
$activeUP = $user->activePosition;
|
||||||
if (! $activeUP) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ① 优先找今日未关闭的开放日志,直接刷新时长
|
// ① 优先找今日未关闭的开放日志,直接刷新时长
|
||||||
$openLog = PositionDutyLog::query()
|
$openLog = PositionDutyLog::query()
|
||||||
@@ -1091,7 +1088,7 @@ class ChatController extends Controller
|
|||||||
|
|
||||||
PositionDutyLog::create([
|
PositionDutyLog::create([
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'user_position_id' => $activeUP->id,
|
'user_position_id' => $activeUP?->id,
|
||||||
'login_at' => $loginAt,
|
'login_at' => $loginAt,
|
||||||
'ip_address' => request()->ip(),
|
'ip_address' => request()->ip(),
|
||||||
'room_id' => $roomId,
|
'room_id' => $roomId,
|
||||||
|
|||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('position_duty_logs', function (Blueprint $table) {
|
||||||
|
$table->unsignedBigInteger('user_position_id')->nullable()->change();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('position_duty_logs', function (Blueprint $table) {
|
||||||
|
$table->unsignedBigInteger('user_position_id')->nullable(false)->change();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user