6
0
Fork 0

成长值 >= 650 为会员

release
李静 2021-12-28 15:18:10 +08:00
parent e41ad193c7
commit c7f88e3d53
2 changed files with 1 additions and 60 deletions

View File

@ -1,59 +0,0 @@
<?php
namespace App\Console\Commands\Distribution;
use App\Exceptions\BizException;
use App\Models\DistributionPreIncomeJob;
use App\Services\DistributionPreIncomeJobService;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Throwable;
class PreIncomeJobCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'distribution:pre-income-job';
/**
* The console command description.
*
* @var string
*/
protected $description = '分销预收益任务';
/**
* Execute the console command.
*
* @param \App\Services\DistributionPreIncomeJobService $jobService
* @return int
*/
public function handle(DistributionPreIncomeJobService $jobService)
{
DistributionPreIncomeJob::with('jobable')->pending()->chunkById(200, function ($jobs) use ($jobService) {
foreach ($jobs as $job) {
try {
DB::beginTransaction();
$jobService->run($job);
DB::commit();
} catch (Throwable $e) {
DB::rollBack();
report($e);
if ($e instanceof BizException) {
$job->update([
'status' => DistributionPreIncomeJob::STATUS_FAILED,
'failed_reason' => $e->getMessage(),
]);
}
}
}
});
}
}

View File

@ -133,7 +133,7 @@ class User extends Model implements AuthorizableContract, AuthenticatableContrac
*/
public function isVip(): bool
{
return true;
return $this->userInfo?->growth_value >= 650;
}
/**