海南旅游SAAS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

54 lines
1.3 KiB

<?php
namespace App\Jobs;
use App\Models\Agent;
use App\Models\MiniProgramTemplate;
use App\Service\UploadMiniProgram;
use Exception;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class BatchUploadMiniProgram implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
private int $template_id; //小程序模板ID
private int $agent_id;
/**
* Create a new job instance.
*
* @param int $template_id 小程序模板ID
* @param int $agent_id 代理商ID
*/
public function __construct(int $template_id, int $agent_id)
{
$this->template_id = $template_id;
$this->agent_id = $agent_id;
}
/**
* Execute the job.
*
* @return void
* @throws Exception
*/
public function handle()
{
$agent = Agent::find($this->agent_id);
$template = MiniProgramTemplate::where('template_id', $this->template_id)->first();
if (!$agent || !$template) return;
try {
new UploadMiniProgram($agent, $template);
} catch (GuzzleException | \Exception $e) {
throw new Exception($e->getMessage());
}
}
}