perf: 优化阅读消息

This commit is contained in:
kuaifan
2023-03-04 15:58:31 +08:00
parent 883cd94a5e
commit 5c6fc6fe1a
5 changed files with 34 additions and 7 deletions

View File

@@ -2,6 +2,8 @@
namespace App\Models;
use Carbon\Carbon;
/**
* App\Models\WebSocketDialogUser
*
@@ -40,4 +42,17 @@ class WebSocketDialogUser extends AbstractModel
{
return $this->hasOne(WebSocketDialog::class, 'id', 'dialog_id');
}
/**
* 转时间戳加上现在的毫秒
* @param $time
* @return int
*/
public static function userMs($time = 0)
{
if (empty($time)) {
return Carbon::now()->getPreciseTimestamp(3);
}
return intval(Carbon::parse($time)->timestamp . substr(Carbon::now()->getPreciseTimestamp(3), -3));
}
}