ProjectOut.php
2.35 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
namespace App\Console\Commands;
use App\Http\Service\ImSign;
use App\Http\Service\ImSendService;
use App\Models\Pivots\ProjectMemberPivot;
use App\Models\Pivots\UserProjectPivot;
use App\Models\Project;
use App\Models\SystemConfig;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Auth;
class ProjectOut extends Command
{
protected $signature = 'project:out';
/**
* The console command description.
*
* @var string
*/
protected $description = '自动退出厂牌';
/**
* Execute the console command.
*
* @return int
*/
public function handle(): int
{
$members = ProjectMemberPivot::query()->where('status', 3)->where('updated_at', '<=', now()->subDays($this->getLimitDay()))->get();
foreach ($members as $member){
$MsgBody = [
[
"MsgType" => "TIMCustomElem",
"MsgContent" => [
"Data" => "{\"businessID\": \"system_notice\",\"text\": \"厂牌成员提醒\",\"title\": \"厂牌成员提醒\",\"content\": \"到期自动退出厂牌\",\"version\": 4}",
"Desc" => "notification",
"Ext" => "url",
"Sound" => "dingdong.aiff"
]
]
];
$OfflinePushInfo = [
"PushFlag" => 0,
"Title" =>'厂牌提醒',
"Desc" => "到期自动退出厂牌",
"Ext" => "到期自动退出厂牌",
"AndroidInfo" => [
"Sound" => "android.mp3"
],
"ApnsInfo" => [
"Sound" => "apns.mp3",
"BadgeMode" => 1,
"Image" => "www.image.com"
]
];
$sendData = ['MsgBody'=>$MsgBody,'OfflinePushInfo'=>$OfflinePushInfo];
$getSign = new ImSign();
$sendService = new ImSendService();
$sign = $getSign->genUserSig('administrator');
$sendService->batchSend($sign,[$member->user_id],"system",$sendData,2);
$member->delete();
}
return self::SUCCESS;
}
public function getLimitDay()
{
return SystemConfig::query()->where('identifier', 'i9V0wD_FitcGXR3HxUK5C')->value('content') ?? 7;
}
}