mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-13 03:52:50 +00:00
perf(任务可见性):修改可见性推送优化
This commit is contained in:
parent
29a651b261
commit
99403fad7d
@ -1717,7 +1717,7 @@ class ProjectController extends AbstractController
|
|||||||
$task_id = intval($param['task_id']);
|
$task_id = intval($param['task_id']);
|
||||||
//
|
//
|
||||||
$task = ProjectTask::userTask($task_id, true, true, 2);
|
$task = ProjectTask::userTask($task_id, true, true, 2);
|
||||||
$taskUser = ProjectTaskUser::select(['userid', 'owner'])->whereTaskId($task_id)->whereIn('owner', [0, 1])->get();
|
$taskUser = ProjectTaskUser::select(['userid', 'owner'])->whereTaskId($task_id)->get();
|
||||||
$owners = $taskUser->where('owner', 1)->pluck('userid')->toArray(); // 负责人
|
$owners = $taskUser->where('owner', 1)->pluck('userid')->toArray(); // 负责人
|
||||||
|
|
||||||
// 更新任务
|
// 更新任务
|
||||||
@ -1729,21 +1729,18 @@ class ProjectController extends AbstractController
|
|||||||
$data['visibility_appointor'] = $data['is_all_visible'] == 1 ? [0] : ProjectTaskUser::whereTaskId($task->id)->whereOwner(2)->pluck('userid');
|
$data['visibility_appointor'] = $data['is_all_visible'] == 1 ? [0] : ProjectTaskUser::whereTaskId($task->id)->whereOwner(2)->pluck('userid');
|
||||||
$task->pushMsg('update', $data);
|
$task->pushMsg('update', $data);
|
||||||
// 可见性推送
|
// 可见性推送
|
||||||
if (Arr::exists($param, 'is_all_visible')) {
|
if (Arr::exists($param, 'is_all_visible') || Arr::exists($param, 'visibility_appointor')) {
|
||||||
if ($data['is_all_visible'] == 1) {
|
if ($data['is_all_visible'] == 1) {
|
||||||
$task->pushMsgVisibleAdd($data);
|
$task->pushMsgVisibleAdd($data);
|
||||||
}
|
}
|
||||||
if ($data['is_all_visible'] == 0) {
|
|
||||||
if ($param['visibility_appointor']) {
|
|
||||||
$task->pushMsgVisibleUpdate($data);
|
|
||||||
} else {
|
|
||||||
$task->pushMsgVisibleRemove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} elseif (Arr::exists($param, 'visibility_appointor')) {
|
|
||||||
if ($param['visibility_appointor']) {
|
if ($param['visibility_appointor']) {
|
||||||
$task->pushMsgVisibleUpdate($data);
|
$oldVisibleUserIds = $taskUser->where('owner', 2)->pluck('userid')->toArray()??[];
|
||||||
} else {
|
$newVisibleUserIds = $param['visibility_appointor'] ?? [];
|
||||||
|
$deleteUserIds = array_diff($oldVisibleUserIds, $newVisibleUserIds);
|
||||||
|
$addUserIds = array_diff($newVisibleUserIds, $oldVisibleUserIds);
|
||||||
|
$task->pushMsgVisibleUpdate($data, $deleteUserIds, $addUserIds);
|
||||||
|
}
|
||||||
|
if ($data['is_all_visible'] == 0 && empty($param['visibility_appointor'])) {
|
||||||
$task->pushMsgVisibleRemove();
|
$task->pushMsgVisibleRemove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1488,7 +1488,7 @@ class ProjectTask extends AbstractModel
|
|||||||
* 添加可见性任务 推送
|
* 添加可见性任务 推送
|
||||||
* @param array|self $data 发送内容,默认为[id, parent_id, project_id, column_id, dialog_id]
|
* @param array|self $data 发送内容,默认为[id, parent_id, project_id, column_id, dialog_id]
|
||||||
*/
|
*/
|
||||||
public function pushMsgVisibleAdd($data = null)
|
public function pushMsgVisibleAdd($data = null, array $pushUserIds = [])
|
||||||
{
|
{
|
||||||
if (!$this->project) {
|
if (!$this->project) {
|
||||||
return;
|
return;
|
||||||
@ -1506,7 +1506,9 @@ class ProjectTask extends AbstractModel
|
|||||||
}
|
}
|
||||||
//
|
//
|
||||||
$array = [];
|
$array = [];
|
||||||
if ($this->is_all_visible == 0) {
|
if ($pushUserIds) {
|
||||||
|
$userids = $pushUserIds;
|
||||||
|
}elseif ($this->is_all_visible == 0) {
|
||||||
$userids = ProjectTaskUser::select(['userid', 'owner'])->whereTaskId($this->id)->orWhere('task_pid' , '=', $this->id)->pluck('userid')->toArray();
|
$userids = ProjectTaskUser::select(['userid', 'owner'])->whereTaskId($this->id)->orWhere('task_pid' , '=', $this->id)->pluck('userid')->toArray();
|
||||||
} else {
|
} else {
|
||||||
$userids = ProjectUser::whereProjectId($this->project_id)->pluck('userid')->toArray(); // 项目成员
|
$userids = ProjectUser::whereProjectId($this->project_id)->pluck('userid')->toArray(); // 项目成员
|
||||||
@ -1583,11 +1585,14 @@ class ProjectTask extends AbstractModel
|
|||||||
* 更新可见性任务 推送
|
* 更新可见性任务 推送
|
||||||
* @param array|self $data 发送内容,默认为[id, parent_id, project_id, column_id, dialog_id]
|
* @param array|self $data 发送内容,默认为[id, parent_id, project_id, column_id, dialog_id]
|
||||||
*/
|
*/
|
||||||
public function pushMsgVisibleUpdate($data)
|
public function pushMsgVisibleUpdate($data, array $deleteUserIds = [], array $addUserIds = [])
|
||||||
{
|
{
|
||||||
$this->pushMsgVisibleRemove();
|
if ($deleteUserIds) {
|
||||||
usleep(300);
|
$this->pushMsgVisibleRemove($deleteUserIds);
|
||||||
$this->pushMsgVisibleAdd($data);
|
}
|
||||||
|
if ($addUserIds) {
|
||||||
|
$this->pushMsgVisibleAdd($data, $addUserIds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user