Refactor ChatConnect and related classes to use dynamic typing for properties and method parameters. Update event handling to use a consistent naming convention for emitted events. Adjust WebSocket message handling methods to accept event arrays instead of specific data structures. Update configuration for Swoole to increase ping intervals and timeouts.
This commit is contained in:
@@ -18,7 +18,7 @@ class ChatAdminStatus extends Model
|
||||
/**
|
||||
* 获取客服配置
|
||||
*/
|
||||
public static function getByAdminId(int $adminId): ?array
|
||||
public static function getByAdminId($adminId)
|
||||
{
|
||||
$status = self::where('admin_id', $adminId)->find();
|
||||
return $status ? $status->toArray() : null;
|
||||
@@ -27,7 +27,7 @@ class ChatAdminStatus extends Model
|
||||
/**
|
||||
* 获取或创建客服配置
|
||||
*/
|
||||
public static function getOrCreate(int $adminId): array
|
||||
public static function getOrCreate($adminId)
|
||||
{
|
||||
$status = self::getByAdminId($adminId);
|
||||
if ($status === null) {
|
||||
@@ -47,7 +47,7 @@ class ChatAdminStatus extends Model
|
||||
/**
|
||||
* 更新最后在线时间
|
||||
*/
|
||||
public static function updateLastOnlineTime(int $adminId): void
|
||||
public static function updateLastOnlineTime($adminId)
|
||||
{
|
||||
self::where('admin_id', $adminId)->update([
|
||||
'last_online_time' => time(),
|
||||
@@ -58,7 +58,7 @@ class ChatAdminStatus extends Model
|
||||
/**
|
||||
* 获取启用客服功能的管理员ID列表
|
||||
*/
|
||||
public static function getEnabledAdminIds(): array
|
||||
public static function getEnabledAdminIds()
|
||||
{
|
||||
return self::where('is_enabled', 1)->column('admin_id');
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ class ChatMessage extends Model
|
||||
/**
|
||||
* 获取会话消息列表
|
||||
*/
|
||||
public static function getBySessionId(int $sessionId, int $limit = 50, int $lastId = 0): array
|
||||
public static function getBySessionId($sessionId, $limit = 50, $lastId = 0)
|
||||
{
|
||||
$query = self::where('session_id', $sessionId);
|
||||
if ($lastId > 0) {
|
||||
@@ -48,7 +48,7 @@ class ChatMessage extends Model
|
||||
/**
|
||||
* 获取会话未读消息
|
||||
*/
|
||||
public static function getUnreadBySessionId(int $sessionId, int $senderType, int $limit = 50): array
|
||||
public static function getUnreadBySessionId($sessionId, $senderType, $limit = 50)
|
||||
{
|
||||
return self::where('session_id', $sessionId)
|
||||
->where('sender_type', '<>', $senderType)
|
||||
@@ -62,7 +62,7 @@ class ChatMessage extends Model
|
||||
/**
|
||||
* 检查消息ID是否存在(幂等性)
|
||||
*/
|
||||
public static function existsByMsgId(int $msgId): bool
|
||||
public static function existsByMsgId($msgId)
|
||||
{
|
||||
return self::where('msg_id', $msgId)->count() > 0;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ class ChatQuickReply extends Model
|
||||
/**
|
||||
* 获取启用的快捷回复列表
|
||||
*/
|
||||
public static function getEnabledList(?string $category = null): array
|
||||
public static function getEnabledList($category = null)
|
||||
{
|
||||
$query = self::where('status', 1);
|
||||
if ($category !== null) {
|
||||
@@ -33,7 +33,7 @@ class ChatQuickReply extends Model
|
||||
/**
|
||||
* 获取分类列表
|
||||
*/
|
||||
public static function getCategories(): array
|
||||
public static function getCategories()
|
||||
{
|
||||
return self::where('status', 1)
|
||||
->whereNotNull('category')
|
||||
|
||||
@@ -28,7 +28,7 @@ class ChatSession extends Model
|
||||
/**
|
||||
* 获取用户活跃会话
|
||||
*/
|
||||
public static function getActiveByUserId(int $userId): ?array
|
||||
public static function getActiveByUserId($userId)
|
||||
{
|
||||
$session = self::where('user_id', $userId)
|
||||
->whereIn('status', [self::STATUS_PENDING, self::STATUS_ACTIVE])
|
||||
@@ -39,7 +39,7 @@ class ChatSession extends Model
|
||||
/**
|
||||
* 获取客服进行中的会话列表
|
||||
*/
|
||||
public static function getActiveByAdminId(int $adminId): array
|
||||
public static function getActiveByAdminId($adminId)
|
||||
{
|
||||
return self::where('admin_id', $adminId)
|
||||
->where('status', self::STATUS_ACTIVE)
|
||||
@@ -51,7 +51,7 @@ class ChatSession extends Model
|
||||
/**
|
||||
* 获取待分配会话数量
|
||||
*/
|
||||
public static function getPendingCount(): int
|
||||
public static function getPendingCount()
|
||||
{
|
||||
return self::where('status', self::STATUS_PENDING)->count();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user