mirror of
https://github.com/kuaifan/dootask.git
synced 2026-03-17 03:03:41 +00:00
perf: 操作离职隐藏退出群通知
This commit is contained in:
parent
dcede463d7
commit
a4b719641b
@ -720,7 +720,7 @@ class UsersController extends AbstractController
|
|||||||
$userTransfer->start();
|
$userTransfer->start();
|
||||||
// 离职移出全员群组
|
// 离职移出全员群组
|
||||||
$dialog = WebSocketDialog::whereGroupType('all')->orderByDesc('id')->first();
|
$dialog = WebSocketDialog::whereGroupType('all')->orderByDesc('id')->first();
|
||||||
$dialog?->exitGroup($userInfo->userid, 'remove', false);
|
$dialog?->exitGroup($userInfo->userid, 'remove', false, false);
|
||||||
} elseif ($type === 'cleardisable') {
|
} elseif ($type === 'cleardisable') {
|
||||||
// 取消离职重新加入全员群组
|
// 取消离职重新加入全员群组
|
||||||
$dialog = WebSocketDialog::whereGroupType('all')->orderByDesc('id')->first();
|
$dialog = WebSocketDialog::whereGroupType('all')->orderByDesc('id')->first();
|
||||||
|
|||||||
@ -175,18 +175,19 @@ class WebSocketDialog extends AbstractModel
|
|||||||
* @param int|array $userid 退出的会员ID或会员ID组
|
* @param int|array $userid 退出的会员ID或会员ID组
|
||||||
* @param string $type exit|remove
|
* @param string $type exit|remove
|
||||||
* @param bool $checkDelete 是否检查删除
|
* @param bool $checkDelete 是否检查删除
|
||||||
|
* @param bool $pushMsg 是否推送消息
|
||||||
*/
|
*/
|
||||||
public function exitGroup($userid, $type = 'exit', $checkDelete = true)
|
public function exitGroup($userid, $type = 'exit', $checkDelete = true, $pushMsg = true)
|
||||||
{
|
{
|
||||||
$typeDesc = $type === 'remove' ? '移出' : '退出';
|
$typeDesc = $type === 'remove' ? '移出' : '退出';
|
||||||
AbstractModel::transaction(function () use ($checkDelete, $typeDesc, $type, $userid) {
|
AbstractModel::transaction(function () use ($pushMsg, $checkDelete, $typeDesc, $type, $userid) {
|
||||||
$builder = WebSocketDialogUser::whereDialogId($this->id);
|
$builder = WebSocketDialogUser::whereDialogId($this->id);
|
||||||
if (is_array($userid)) {
|
if (is_array($userid)) {
|
||||||
$builder->whereIn('userid', $userid);
|
$builder->whereIn('userid', $userid);
|
||||||
} else {
|
} else {
|
||||||
$builder->whereUserid($userid);
|
$builder->whereUserid($userid);
|
||||||
}
|
}
|
||||||
$builder->chunkById(100, function($list) use ($checkDelete, $typeDesc, $type) {
|
$builder->chunkById(100, function($list) use ($pushMsg, $checkDelete, $typeDesc, $type) {
|
||||||
/** @var WebSocketDialogUser $item */
|
/** @var WebSocketDialogUser $item */
|
||||||
foreach ($list as $item) {
|
foreach ($list as $item) {
|
||||||
if ($checkDelete) {
|
if ($checkDelete) {
|
||||||
@ -203,14 +204,16 @@ class WebSocketDialog extends AbstractModel
|
|||||||
//
|
//
|
||||||
$item->delete();
|
$item->delete();
|
||||||
//
|
//
|
||||||
if ($type === 'remove') {
|
if ($pushMsg) {
|
||||||
$notice = User::nickname() . " 将 " . User::userid2nickname($item->userid) . " 移出群组";
|
if ($type === 'remove') {
|
||||||
} else {
|
$notice = User::nickname() . " 将 " . User::userid2nickname($item->userid) . " 移出群组";
|
||||||
$notice = User::userid2nickname($item->userid) . " 退出群组";
|
} else {
|
||||||
|
$notice = User::userid2nickname($item->userid) . " 退出群组";
|
||||||
|
}
|
||||||
|
WebSocketDialogMsg::sendMsg(null, $this->id, 'notice', [
|
||||||
|
'notice' => $notice
|
||||||
|
], User::userid(), true, true);
|
||||||
}
|
}
|
||||||
WebSocketDialogMsg::sendMsg(null, $this->id, 'notice', [
|
|
||||||
'notice' => $notice
|
|
||||||
], User::userid(), true, true);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user