成长值 >= 650 的就是会员
parent
a672b5065e
commit
e41ad193c7
|
|
@ -0,0 +1,59 @@
|
||||||
|
<?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(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue