fisrt
This commit is contained in:
36
app/Console/Commands/MonthPerfCommand.php
Normal file
36
app/Console/Commands/MonthPerfCommand.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Jobs\Bonus\MonthPerfJob;
|
||||
use Illuminate\Console\Command;
|
||||
use Modules\User\Models\User;
|
||||
|
||||
class MonthPerfCommand extends Command
|
||||
{
|
||||
protected $signature = 'Bonus:MonthPerf {last?}';
|
||||
|
||||
protected $description = '分红:计算用户月度业绩';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$last = $this->argument('last') ?: 0;
|
||||
|
||||
User::whereHas('identities', function ($query) {
|
||||
$query->where('id', 6);
|
||||
})
|
||||
->whereHas('identityMiddle', function ($query) {
|
||||
$query->where('star', '>', 0);
|
||||
})
|
||||
->chunkById(100, function ($users) use ($last) {
|
||||
foreach ($users as $user) {
|
||||
MonthPerfJob::dispatch($user, $last);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user