This commit is contained in:
2023-03-08 09:16:04 +08:00
commit e78454540f
1318 changed files with 210569 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
<?php
namespace Modules\User\Console\Commands;
use Illuminate\Console\Command;
use Modules\User\Models\Identity;
use Modules\User\Models\IdentityLog;
use Modules\User\Models\IdentityMiddle;
class UserIdentityOver extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'xuanchen:auto-set-user-identity-over';
/**
* The console command description.
*
* @var string
*/
protected $description = '检查会员是否过期';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$identity = Identity::query()->where('default', 1)->first();
if ($identity) {
IdentityMiddle::query()
->whereNotNull('ended_at')
->where('ended_at', '<', now())
->chunkById(1000, function ($middles) use ($identity) {
foreach ($middles as $middle) {
$middle->user->joinIdentity($identity->id, IdentityLog::CHANNEL_SYSTEM);
}
});
}
}
}