dataLists(new UserNoticeLists()); } public function options() { return $this->data([ 'scene_options' => UserNoticeEnum::getOptions(), ]); } public function send() { $params = (new UserNoticeValidate())->post()->goCheck('send'); $scope = (string) $params['recipient_scope']; $userIds = $scope === 'specified' ? array_values(array_unique(array_map('intval', $params['user_ids']))) : []; $sentCount = UserNoticeService::sendSystem( trim((string) $params['title']), trim((string) $params['content']), trim((string) ($params['target_url'] ?? '')), $userIds ); if ($sentCount === 0) { return $this->fail('没有可接收消息的启用用户'); } return $this->success("已发送给 {$sentCount} 位用户"); } public function delete() { $ids = $this->request->post('ids/a', []); $ids = array_values(array_unique(array_filter(array_map('intval', $ids)))); if (empty($ids)) { return $this->fail('请选择需要删除的消息'); } NoticeRecord::whereIn('id', $ids) ->whereIn('scene_id', UserNoticeEnum::getSceneIds()) ->delete(); return $this->success('删除成功'); } }