|
|
|
@ -4,7 +4,7 @@ namespace app\enterprise\controller; |
|
|
|
|
|
|
|
use app\BaseController; |
|
|
|
use app\manage\model\Config; |
|
|
|
use app\enterprise\model\{User,Group as GroupModel,GroupUser,Message}; |
|
|
|
use app\enterprise\model\{File, User, Group as GroupModel, GroupUser, Message}; |
|
|
|
use think\Exception; |
|
|
|
use think\facade\Db; |
|
|
|
use app\common\controller\Upload; |
|
|
|
@ -549,7 +549,7 @@ class Group extends BaseController |
|
|
|
$id = $this->request->param('id'); |
|
|
|
$group_id = explode('-', $id)[1]; |
|
|
|
$day = $this->request->param('day', 0); |
|
|
|
$uid = $this->userInfo['id']; |
|
|
|
$uid = $this->userInfo['user_id']; |
|
|
|
if (!is_numeric($day)) return error(lang('system.fail')); |
|
|
|
if (!is_numeric($group_id)) return error(lang('system.fail')); |
|
|
|
|
|
|
|
@ -589,4 +589,37 @@ class Group extends BaseController |
|
|
|
wsSendMsg($group_id, 'undoMessage', $data, 1); |
|
|
|
return success('', $data); |
|
|
|
} |
|
|
|
|
|
|
|
// 群聊一键清除消息 |
|
|
|
public function removeAllMessage() |
|
|
|
{ |
|
|
|
$id = $this->request->param('id'); |
|
|
|
$group_id = explode('-', $id)[1]; |
|
|
|
if (!is_numeric($group_id)) return error(lang('system.fail')); |
|
|
|
|
|
|
|
$whereGroupUser = [ |
|
|
|
'group_id' => $group_id, |
|
|
|
'user_id' => $this->userInfo['user_id'], |
|
|
|
'status' => 1, |
|
|
|
'delete_time' => 0 |
|
|
|
]; |
|
|
|
$groupUser = GroupUser::where($whereGroupUser)->find(); |
|
|
|
if (!$groupUser) { |
|
|
|
return warning(lang('system.fail')); |
|
|
|
} |
|
|
|
$chat_identify = "group-{$group_id}"; |
|
|
|
|
|
|
|
$whereMsg = [ |
|
|
|
['is_group', '=', 1], |
|
|
|
['to_user', '=', $group_id], |
|
|
|
['chat_identify', '=', $chat_identify] |
|
|
|
]; |
|
|
|
$msgRes = Message::where($whereMsg)->select(); |
|
|
|
foreach ($msgRes as $msg) { |
|
|
|
$msg->force()->delete(); |
|
|
|
File::syncDelFile($msg->file_id); |
|
|
|
} |
|
|
|
wsSendMsg($group_id, 'delMessageAll', [], 1); |
|
|
|
return success(''); |
|
|
|
} |
|
|
|
} |
|
|
|
|