|
- <?php
-
- namespace App\Jobs\SMS;
-
- use App\Codes\QueueName;
- use App\Logic\SMS\SMSManager;
- use App\Models\SMSSendOrder;
- use Illuminate\Bus\Queueable;
- use Illuminate\Contracts\Queue\ShouldQueue;
- use Illuminate\Foundation\Bus\Dispatchable;
- use Illuminate\Queue\InteractsWithQueue;
- use Illuminate\Queue\SerializesModels;
-
- class SendSMS implements ShouldQueue
- {
- use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
-
-
- /**
- * Create a new job instance.
- *
- * @return void
- */
- public function __construct(private SMSSendOrder $order)
- {
- $this->onQueue(QueueName::SMS->value);
- }
-
- /**
- * Execute the job.
- *
- * @return void
- */
- public function handle(SMSManager $manager)
- {
- $ret = $manager->setOrder($this->order)
- ->send();
-
- if ($ret) {
- info(sprintf(
- "SMS送信依頼成功 address:%s order_id:%s",
- $this->order->phone_number,
- $this->order->id,
- ));
- } else {
- $this->fail(sprintf("SMS送信依頼失敗 order_id:%s", $this->order->id));
- }
- }
- }
|