1
0
Files
lkafu/app/Console/Commands/PerfBonusCommand.php
2020-08-06 14:45:56 +08:00

58 lines
1.3 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Models\User;
use Illuminate\Console\Command;
use RuLong\UserRelation\Models\UserRelation;
class PerfBonusCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'rulong:PerfBonusCommand';
/**
* 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()
{
$maxLayer = UserRelation::max('layer');
for ($i = $maxLayer; $i >= 1; $i--) {
$users = User::whereHas('identity.info', function ($query) {
$query->where('configs->perf_100', '>', 0)
->orWhere('configs->perf_500', '>', 0)
->orWhere('configs->perf_1000', '>', 0);
})->whereHas('relation', function ($query) use ($i) {
$query->where('layer', $i);
})->get();
foreach ($users as $key => $user) {
\App\Jobs\Perf::dispatch($user);
}
}
}
}