HandleAlbumStatus.php 1.15 KB
<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

class HandleAlbumStatus implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    private $callData = [];

    /**
     * Create a new job instance.
     * @param array $callData
     * @return void
     */
    public function __construct(array $callData)
    {
        $this->callData = $callData;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        //php artisan queue:work --queue=handle-album-status  --tries=3 --sleep=3

        $response_file = database_path('icms/album-status.notify');
        file_put_contents($response_file,
            '======接收回调数据在'.date('Y-m-n H:i:s').'======'. PHP_EOL
            .var_export($this->callData,true). PHP_EOL,FILE_APPEND);
    }

    /**
     * @param null $exception
     */
    public function fail($exception = null)
    {
        //todo: Artisan创建任务失败记录表
    }
}