增加业务强制绑定提醒

This commit is contained in:
mzl
2025-10-13 13:25:19 +08:00
parent 1b14d5450d
commit 04d7d73c45
6 changed files with 136 additions and 12 deletions
+51 -5
View File
@@ -5,6 +5,7 @@ namespace app\common\utils;
use GatewayWorker\Lib\Gateway;
use app\common\utils\WsResponse;
use app\common\service\MessageNotificationsService;
use support\Redis;
class WsEvents
{
@@ -158,14 +159,24 @@ 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
));
// 获取审批待办数量
$num = (new \app\common\utils\approval\service\ApprovalFlowService())->getInitTodoCount($_SESSION['uid']);
$this->todoCounts($_SESSION['uid'], $num);
// 绑定检查
$initData = $this->initCheck($_SESSION['uid']);
Gateway::sendToClient($this->clientId, WsResponse::success(
'system.init.check',
$initData,
$traceId
));
}
// ================= 消息通知事件 =================
@@ -259,7 +270,6 @@ class WsEvents
/*
init.pull
approval.todo.counts 审批待办数量
*/
@@ -285,8 +295,44 @@ class WsEvents
// ================= 临时业务处理 =================
// ================= 业务处理 =================
/**
* 初始化检查
*/
public function initCheck(int $userId)
{
$data = [
'is_report_to' => false,
'is_office_clerk' => false,
'is_sign' => false
];
$user = \app\common\model\User::find($userId);
if ($user->report_to > 0) {
$data['is_report_to'] = true;
}
if ($user->sign_img !== null || $user->is_sign !== '') {
$data['is_sign'] = true;
}
$ug = \app\common\model\UserGroupMembers::with(['group' => function($query) {
$query->where('scenario_code', 'stock_orders');
}])->where('user_id', $userId)->first();
if ($ug !== null) {
$data['is_office_clerk'] = true;
}
if ($data['is_report_to'] && $data['is_office_clerk'] && $data['is_sign']) {
Redis::hSet('user:init:check:'.$userId, 'status', 1);
}
return $data;
}
// 审批待办数量
public function todoCounts(int $userId, int $num = 0)
{
$ly = [