UserRegisterAction.php
1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
namespace App\Actions;
use App\Helpers\IMHelper;
use App\Models\User;
use Lorisleiva\Actions\Concerns\AsAction;
class UserRegisterAction
{
use AsAction;
public string $jobQueue = 'im';
/**
* @throws \JsonException
* @throws \Exception
*/
public function handle(User $user): void
{
$content = '您邀请的用户:' . $user->getAttribute('nick_name') . ',已完成账号注册。感谢您对平台的支持!';
IMHelper::sendSingleChatMessage(IMHelper::SYSTEM_USER, $user->getAttribute('inviter_id'), [
"MsgBody" => [
IMHelper::createCustomMessage([
"Desc" => $content,
"Data" => [
'businessID' => 'user_register',
'MsgType' => 'text',
'MsgEvent' => 'user_register',
'MsgAttribute' => ['Id' => $user->getKey(), 'NickName' => $user->getAttribute('nick_name')],
'Content' => $content,
],
])
],
"CloudCustomData" => [],
"OfflinePushInfo" => IMHelper::createOfflineMessage('系统消息', $content)
]);
}
}