|
@@ -9,6 +9,7 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
+use Illuminate\Support\Facades\Log;
|
|
|
use Symfony\Component\Console\Output\ConsoleOutput;
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
|
@@ -40,15 +41,37 @@ class BoxAddJob implements ShouldQueue
|
|
|
public function handle()
|
|
|
{
|
|
|
$service = new BoxService();
|
|
|
+ $currentAttempt = $this->attempts();
|
|
|
+
|
|
|
try {
|
|
|
+ Log::info("任务开始执行", [
|
|
|
+ 'job_id' => $this->job->getJobId(),
|
|
|
+ 'attempt' => $currentAttempt,
|
|
|
+ 'data' => $this->data
|
|
|
+ ]);
|
|
|
|
|
|
list($status,$msg) = $service->boxInSettle($this->data, $this->user);
|
|
|
if(! $status) {
|
|
|
+ Log::info("业务逻辑执行失败", [
|
|
|
+ 'job_id' => $this->job->getJobId(),
|
|
|
+ 'attempt' => $currentAttempt,
|
|
|
+ 'error' => $msg
|
|
|
+ ]);
|
|
|
$service->dellimitingSendRequestBackgNeed($service->lock_key); //删除锁
|
|
|
$this->recordErrorTable($msg);
|
|
|
+ }else {
|
|
|
+ Log::info("任务执行成功", [
|
|
|
+ 'job_id' => $this->job->getJobId(),
|
|
|
+ 'attempt' => $currentAttempt
|
|
|
+ ]);
|
|
|
}
|
|
|
|
|
|
} catch (\Throwable $e) {
|
|
|
+ Log::error("任务执行异常", [
|
|
|
+ 'job_id' => $this->job->getJobId(),
|
|
|
+ 'attempt' => $currentAttempt,
|
|
|
+ 'exception' => $e->getMessage(),
|
|
|
+ ]);
|
|
|
$service->dellimitingSendRequestBackgNeed($service->lock_key);//删除锁
|
|
|
$this->delete();
|
|
|
$this->recordErrorTable($e->getFile() . $e->getMessage() . $e->getLine());
|