更新代码
This commit is contained in:
59
app/Console/Commands/ProfitCommand.php
Normal file
59
app/Console/Commands/ProfitCommand.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Jobs\ProfitJob;
|
||||
use App\Models\ProfitLog;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
use RuLong\Identity\Models\IdentityPoint;
|
||||
|
||||
class ProfitCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'rulong:ProfitCommand';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
ProfitLog::getnow();
|
||||
|
||||
$info = ProfitLog::where('created_at', Carbon::yesterday()->toDateTimeString())->where('status', 0)->first();
|
||||
|
||||
if ($info) {
|
||||
if ($info->price > 0) {
|
||||
$users = IdentityPoint::where('created_at', '<', $info->end_at)->distinct()->pluck('user_id');
|
||||
foreach ($users as $key => $user_id) {
|
||||
ProfitJob::dispatch($user_id, $info);
|
||||
}
|
||||
}
|
||||
$info->status = 1;
|
||||
$info->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user