调整消息推送“
This commit is contained in:
@@ -122,14 +122,6 @@ class WsEvents
|
||||
'system.auth',
|
||||
['uid' => $user->uid]
|
||||
));
|
||||
|
||||
// 初始化推送
|
||||
$wdata = [
|
||||
'is_first' => true,
|
||||
'event' => 'approval.todo.counts',
|
||||
'user_id' => $user->uid
|
||||
];
|
||||
\Webman\RedisQueue\Redis::send('ws-msg', $wdata);
|
||||
} catch (\Throwable $th) {
|
||||
flg('[x] [TOKEN认证] TOKEN认证失败:'.$th->getMessage(), false);
|
||||
Gateway::sendToClient($client_id, WsResponse::error(
|
||||
@@ -164,6 +156,18 @@ class WsEvents
|
||||
}
|
||||
|
||||
|
||||
public function systemConnect(?string $traceId)
|
||||
{
|
||||
$num = (new \app\common\utils\approval\service\ApprovalFlowService())->getInitTodoCount($_SESSION['uid']);
|
||||
$this->todoCounts($_SESSION['uid'], $num);
|
||||
|
||||
Gateway::sendToClient($this->clientId, WsResponse::success(
|
||||
'system.connect.receive',
|
||||
['time' => time()],
|
||||
$traceId
|
||||
));
|
||||
}
|
||||
|
||||
// ================= 消息通知事件 =================
|
||||
/**
|
||||
* 管理端主动推送通知
|
||||
@@ -255,6 +259,7 @@ class WsEvents
|
||||
|
||||
|
||||
/*
|
||||
init.pull
|
||||
approval.todo.counts 审批待办数量
|
||||
|
||||
*/
|
||||
@@ -269,4 +274,38 @@ class WsEvents
|
||||
default => throw new \InvalidArgumentException('UID must be integer or string'),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ================= 临时业务处理 =================
|
||||
|
||||
public function todoCounts(int $userId, int $num = 0)
|
||||
{
|
||||
$ly = [
|
||||
1 => 186,
|
||||
3 => 226,
|
||||
];
|
||||
|
||||
if ($num === 0) {
|
||||
$num = (new \app\common\utils\approval\service\ApprovalFlowService())->getInitTodoCount($userId);
|
||||
}
|
||||
|
||||
$systemIds = \app\common\model\UserSystems::where('user_id', $userId)->pluck('system_id')->toArray();
|
||||
if (count($systemIds) > 0) {
|
||||
foreach ($systemIds as $systemId) {
|
||||
if (isset($ly[$systemId])) {
|
||||
$chain = \app\common\service\MenuBadgeService::buildBadgeChain(menuId: $ly[$systemId], leafCount: $num);
|
||||
$this->pushWebsocket('approval.todo.counts', $userId, $chain);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user